Comparing version 0.6.0 to 0.6.1
@@ -725,5 +725,3 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.treeKit = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){ | ||
},{}]},{},[1])(1) | ||
}); |
@@ -288,3 +288,1 @@ /* | ||
@@ -39,3 +39,4 @@ /* | ||
clone: require( './clone.js' ) , | ||
path: require( './path.js' ) | ||
path: require( './path.js' ) , | ||
dotPath: require( './dotPath.js' ) | ||
} , | ||
@@ -42,0 +43,0 @@ require( './lazy.js' ) , |
{ | ||
"name": "tree-kit", | ||
"version": "0.6.0", | ||
"version": "0.6.1", | ||
"description": "Tree utilities which provides a full-featured extend and object-cloning facility, and various tools to deal with nested object structures.", | ||
@@ -12,3 +12,3 @@ "main": "lib/tree.js", | ||
"devDependencies": { | ||
"browserify": "^16.2.2", | ||
"browserify": "^16.2.3", | ||
"uglify-es": "^3.3.9" | ||
@@ -15,0 +15,0 @@ }, |
@@ -31,3 +31,3 @@ /* | ||
var tree = require( '../lib/tree.js' ) ; | ||
const path = require( '../lib/path.js' ) ; | ||
@@ -57,4 +57,4 @@ | ||
expect( tree.path.get( o , 'a' ) ).to.be( 5 ) ; | ||
expect( tree.path.get( o , 'sub' ) ).to.eql( { | ||
expect( path.get( o , 'a' ) ).to.be( 5 ) ; | ||
expect( path.get( o , 'sub' ) ).to.eql( { | ||
b: "toto" , | ||
@@ -65,9 +65,9 @@ sub: { | ||
} ) ; | ||
expect( tree.path.get( o , 'sub.b' ) ).to.be( "toto" ) ; | ||
expect( tree.path.get( o , 'sub.sub' ) ).to.eql( { c: true } ) ; | ||
expect( tree.path.get( o , 'sub.sub.c' ) ).to.be( true ) ; | ||
expect( tree.path.get( o , 'd' ) ).to.be( null ) ; | ||
expect( tree.path.get( o , 'nothing' ) ).to.be( undefined ) ; | ||
expect( tree.path.get( o , 'sub.nothing' ) ).to.be( undefined ) ; | ||
expect( tree.path.get( o , 'nothing.nothing' ) ).to.be( undefined ) ; | ||
expect( path.get( o , 'sub.b' ) ).to.be( "toto" ) ; | ||
expect( path.get( o , 'sub.sub' ) ).to.eql( { c: true } ) ; | ||
expect( path.get( o , 'sub.sub.c' ) ).to.be( true ) ; | ||
expect( path.get( o , 'd' ) ).to.be( null ) ; | ||
expect( path.get( o , 'nothing' ) ).to.be( undefined ) ; | ||
expect( path.get( o , 'sub.nothing' ) ).to.be( undefined ) ; | ||
expect( path.get( o , 'nothing.nothing' ) ).to.be( undefined ) ; | ||
} ) ; | ||
@@ -89,4 +89,4 @@ | ||
expect( tree.path.get( o , '[a]' ) ).to.be( 5 ) ; | ||
expect( tree.path.get( o , '[sub][sub][c]' ) ).to.be( true ) ; | ||
expect( path.get( o , '[a]' ) ).to.be( 5 ) ; | ||
expect( path.get( o , '[sub][sub][c]' ) ).to.be( true ) ; | ||
} ) ; | ||
@@ -111,5 +111,5 @@ */ | ||
tree.path.delete( o , 'a' ) ; | ||
tree.path.delete( o , 'sub.sub' ) ; | ||
tree.path.delete( o , 'non.existant.path' ) ; | ||
path.delete( o , 'a' ) ; | ||
path.delete( o , 'sub.sub' ) ; | ||
path.delete( o , 'non.existant.path' ) ; | ||
@@ -137,6 +137,6 @@ expect( o ).to.eql( { | ||
tree.path.set( o , 'a' , "8" ) ; | ||
tree.path.set( o , 'sub.b' , false ) ; | ||
tree.path.set( o , 'sub.sub' , { x: 18 , y: 27 } ) ; | ||
tree.path.set( o , 'non.existant.path' , 'new' ) ; | ||
path.set( o , 'a' , "8" ) ; | ||
path.set( o , 'sub.b' , false ) ; | ||
path.set( o , 'sub.sub' , { x: 18 , y: 27 } ) ; | ||
path.set( o , 'non.existant.path' , 'new' ) ; | ||
@@ -174,7 +174,7 @@ expect( o ).to.eql( { | ||
tree.path.define( o , 'a' , "8" ) ; | ||
tree.path.define( o , 'sub.b' , false ) ; | ||
tree.path.define( o , 'unexistant' , '!' ) ; | ||
tree.path.define( o , 'sub.sub' , { x: 18 , y: 27 } ) ; | ||
tree.path.define( o , 'non.existant.path' , 'new' ) ; | ||
path.define( o , 'a' , "8" ) ; | ||
path.define( o , 'sub.b' , false ) ; | ||
path.define( o , 'unexistant' , '!' ) ; | ||
path.define( o , 'sub.sub' , { x: 18 , y: 27 } ) ; | ||
path.define( o , 'non.existant.path' , 'new' ) ; | ||
@@ -212,8 +212,8 @@ expect( o ).to.eql( { | ||
tree.path.inc( o , 'a' ) ; | ||
tree.path.dec( o , 'sub.b' ) ; | ||
tree.path.inc( o , 'sub' ) ; | ||
tree.path.dec( o , 'sub.sub' ) ; | ||
tree.path.inc( o , 'non.existant.path' ) ; | ||
tree.path.dec( o , 'another.non.existant.path' ) ; | ||
path.inc( o , 'a' ) ; | ||
path.dec( o , 'sub.b' ) ; | ||
path.inc( o , 'sub' ) ; | ||
path.dec( o , 'sub.sub' ) ; | ||
path.inc( o , 'non.existant.path' ) ; | ||
path.dec( o , 'another.non.existant.path' ) ; | ||
@@ -256,9 +256,9 @@ expect( o ).to.eql( { | ||
tree.path.append( o , 'a' , 'hello' ) ; | ||
tree.path.append( o , 'sub.b' , 'value' ) ; | ||
tree.path.prepend( o , 'sub.sub.c' , 'other' ) ; | ||
tree.path.prepend( o , 'sub.sub.c' , 'some' ) ; | ||
tree.path.append( o , 'sub.sub.c' , '!' ) ; | ||
tree.path.append( o , 'non.existant.path' , '!' ) ; | ||
tree.path.prepend( o , 'another.non.existant.path' , '!' ) ; | ||
path.append( o , 'a' , 'hello' ) ; | ||
path.append( o , 'sub.b' , 'value' ) ; | ||
path.prepend( o , 'sub.sub.c' , 'other' ) ; | ||
path.prepend( o , 'sub.sub.c' , 'some' ) ; | ||
path.append( o , 'sub.sub.c' , '!' ) ; | ||
path.append( o , 'non.existant.path' , '!' ) ; | ||
path.prepend( o , 'another.non.existant.path' , '!' ) ; | ||
@@ -300,5 +300,5 @@ expect( o ).to.eql( { | ||
tree.path.concat( o , 'a' , [ 'hello' , 'world' ] ) ; | ||
tree.path.concat( o , 'sub.b' , [ 'hello' , 'world' ] ) ; | ||
tree.path.insert( o , 'sub.sub.c' , [ 'hello' , 'world' ] ) ; | ||
path.concat( o , 'a' , [ 'hello' , 'world' ] ) ; | ||
path.concat( o , 'sub.b' , [ 'hello' , 'world' ] ) ; | ||
path.insert( o , 'sub.sub.c' , [ 'hello' , 'world' ] ) ; | ||
@@ -328,7 +328,7 @@ expect( o ).to.eql( { | ||
tree.path.autoPush( o , 'a' , 'hello' ) ; | ||
tree.path.autoPush( o , 'd' , 'D' ) ; | ||
tree.path.autoPush( o , 'sub.b' , 'value' ) ; | ||
tree.path.autoPush( o , 'sub.sub.c' , '!' ) ; | ||
tree.path.autoPush( o , 'non.existant.path' , '!' ) ; | ||
path.autoPush( o , 'a' , 'hello' ) ; | ||
path.autoPush( o , 'd' , 'D' ) ; | ||
path.autoPush( o , 'sub.b' , 'value' ) ; | ||
path.autoPush( o , 'sub.sub.c' , '!' ) ; | ||
path.autoPush( o , 'non.existant.path' , '!' ) ; | ||
@@ -367,7 +367,7 @@ expect( o ).to.eql( { | ||
expect( tree.path.get( o , 'a' ) ).to.be( 5 ) ; | ||
expect( tree.path.get( o , '' ) ).to.eql( { b: "toto" , sub: { c: true } } ) ; | ||
expect( tree.path.get( o , '.b' ) ).to.be( "toto" ) ; | ||
expect( tree.path.get( o , '.sub' ) ).to.eql( { c: true } ) ; | ||
expect( tree.path.get( o , '.sub.c' ) ).to.be( true ) ; | ||
expect( path.get( o , 'a' ) ).to.be( 5 ) ; | ||
expect( path.get( o , '' ) ).to.eql( { b: "toto" , sub: { c: true } } ) ; | ||
expect( path.get( o , '.b' ) ).to.be( "toto" ) ; | ||
expect( path.get( o , '.sub' ) ).to.eql( { c: true } ) ; | ||
expect( path.get( o , '.sub.c' ) ).to.be( true ) ; | ||
@@ -385,6 +385,6 @@ o = { | ||
expect( tree.path.get( o , '' ) ).to.eql( { "": { "": { a: 1 , b: 2 } } } ) ; | ||
expect( tree.path.get( o , '.' ) ).to.eql( { "": { a: 1 , b: 2 } } ) ; | ||
expect( tree.path.get( o , '..' ) ).to.eql( { a: 1 , b: 2 } ) ; | ||
expect( tree.path.get( o , '...a' ) ).to.eql( 1 ) ; | ||
expect( path.get( o , '' ) ).to.eql( { "": { "": { a: 1 , b: 2 } } } ) ; | ||
expect( path.get( o , '.' ) ).to.eql( { "": { a: 1 , b: 2 } } ) ; | ||
expect( path.get( o , '..' ) ).to.eql( { a: 1 , b: 2 } ) ; | ||
expect( path.get( o , '...a' ) ).to.eql( 1 ) ; | ||
} ) ; | ||
@@ -404,22 +404,22 @@ | ||
expect( tree.path.get( a , '0' ) ).to.be( 'a' ) ; | ||
expect( tree.path.get( a , '1' ) ).to.be( 'b' ) ; | ||
expect( tree.path.get( a , '2' ) ).to.be( 'c' ) ; | ||
expect( tree.path.get( a , '3' ) ).to.be( undefined ) ; | ||
expect( tree.path.get( a , '#0' ) ).to.be( 'a' ) ; | ||
expect( tree.path.get( a , '#1' ) ).to.be( 'b' ) ; | ||
expect( tree.path.get( a , '#2' ) ).to.be( 'c' ) ; | ||
expect( tree.path.get( a , '#3' ) ).to.be( undefined ) ; | ||
expect( tree.path.get( a , '[0]' ) ).to.be( 'a' ) ; | ||
expect( tree.path.get( a , '[1]' ) ).to.be( 'b' ) ; | ||
expect( tree.path.get( a , '[2]' ) ).to.be( 'c' ) ; | ||
expect( tree.path.get( a , '[3]' ) ).to.be( undefined ) ; | ||
expect( tree.path.get( a , 'length' ) ).to.be( 3 ) ; | ||
expect( tree.path.get( a , '#length' ) ).to.be( 3 ) ; | ||
expect( tree.path.get( a , 'first' ) ).to.be( undefined ) ; | ||
expect( tree.path.get( a , '#first' ) ).to.be( 'a' ) ; | ||
expect( tree.path.get( a , 'last' ) ).to.be( undefined ) ; | ||
expect( tree.path.get( a , '#last' ) ).to.be( 'c' ) ; | ||
expect( tree.path.get( a , 'next' ) ).to.be( undefined ) ; | ||
expect( tree.path.get( a , '#next' ) ).to.be( undefined ) ; | ||
expect( path.get( a , '0' ) ).to.be( 'a' ) ; | ||
expect( path.get( a , '1' ) ).to.be( 'b' ) ; | ||
expect( path.get( a , '2' ) ).to.be( 'c' ) ; | ||
expect( path.get( a , '3' ) ).to.be( undefined ) ; | ||
expect( path.get( a , '#0' ) ).to.be( 'a' ) ; | ||
expect( path.get( a , '#1' ) ).to.be( 'b' ) ; | ||
expect( path.get( a , '#2' ) ).to.be( 'c' ) ; | ||
expect( path.get( a , '#3' ) ).to.be( undefined ) ; | ||
expect( path.get( a , '[0]' ) ).to.be( 'a' ) ; | ||
expect( path.get( a , '[1]' ) ).to.be( 'b' ) ; | ||
expect( path.get( a , '[2]' ) ).to.be( 'c' ) ; | ||
expect( path.get( a , '[3]' ) ).to.be( undefined ) ; | ||
expect( path.get( a , 'length' ) ).to.be( 3 ) ; | ||
expect( path.get( a , '#length' ) ).to.be( 3 ) ; | ||
expect( path.get( a , 'first' ) ).to.be( undefined ) ; | ||
expect( path.get( a , '#first' ) ).to.be( 'a' ) ; | ||
expect( path.get( a , 'last' ) ).to.be( undefined ) ; | ||
expect( path.get( a , '#last' ) ).to.be( 'c' ) ; | ||
expect( path.get( a , 'next' ) ).to.be( undefined ) ; | ||
expect( path.get( a , '#next' ) ).to.be( undefined ) ; | ||
} ) ; | ||
@@ -431,27 +431,27 @@ | ||
expect( tree.path.get( a , '#0' ) ).to.be( 'a' ) ; | ||
expect( tree.path.get( a , '#1' ) ).to.eql( [ [ 'b' , 'c' ] , 'd' , [ 'e' , 'f' ] ] ) ; | ||
expect( tree.path.get( a , '#2' ) ).to.be( undefined ) ; | ||
expect( tree.path.get( a , '[0]' ) ).to.be( 'a' ) ; | ||
expect( tree.path.get( a , '[1]' ) ).to.eql( [ [ 'b' , 'c' ] , 'd' , [ 'e' , 'f' ] ] ) ; | ||
expect( tree.path.get( a , '[2]' ) ).to.be( undefined ) ; | ||
expect( tree.path.get( a , '#length' ) ).to.be( 2 ) ; | ||
expect( tree.path.get( a , '#first' ) ).to.be( 'a' ) ; | ||
expect( tree.path.get( a , '#last' ) ).to.eql( [ [ 'b' , 'c' ] , 'd' , [ 'e' , 'f' ] ] ) ; | ||
expect( tree.path.get( a , '#next' ) ).to.be( undefined ) ; | ||
expect( path.get( a , '#0' ) ).to.be( 'a' ) ; | ||
expect( path.get( a , '#1' ) ).to.eql( [ [ 'b' , 'c' ] , 'd' , [ 'e' , 'f' ] ] ) ; | ||
expect( path.get( a , '#2' ) ).to.be( undefined ) ; | ||
expect( path.get( a , '[0]' ) ).to.be( 'a' ) ; | ||
expect( path.get( a , '[1]' ) ).to.eql( [ [ 'b' , 'c' ] , 'd' , [ 'e' , 'f' ] ] ) ; | ||
expect( path.get( a , '[2]' ) ).to.be( undefined ) ; | ||
expect( path.get( a , '#length' ) ).to.be( 2 ) ; | ||
expect( path.get( a , '#first' ) ).to.be( 'a' ) ; | ||
expect( path.get( a , '#last' ) ).to.eql( [ [ 'b' , 'c' ] , 'd' , [ 'e' , 'f' ] ] ) ; | ||
expect( path.get( a , '#next' ) ).to.be( undefined ) ; | ||
expect( tree.path.get( a , '1#0' ) ).to.eql( [ 'b' , 'c' ] ) ; | ||
expect( tree.path.get( a , '1#1' ) ).to.eql( 'd' ) ; | ||
expect( tree.path.get( a , '1#2' ) ).to.eql( [ 'e' , 'f' ] ) ; | ||
expect( tree.path.get( a , '1#3' ) ).to.be( undefined ) ; | ||
expect( tree.path.get( a , '[1][0]' ) ).to.eql( [ 'b' , 'c' ] ) ; | ||
expect( tree.path.get( a , '[1][1]' ) ).to.eql( 'd' ) ; | ||
expect( tree.path.get( a , '[1][2]' ) ).to.eql( [ 'e' , 'f' ] ) ; | ||
expect( tree.path.get( a , '[1][3]' ) ).to.be( undefined ) ; | ||
expect( tree.path.get( a , '1#length' ) ).to.be( 3 ) ; | ||
expect( tree.path.get( a , '1#first' ) ).to.eql( [ 'b' , 'c' ] ) ; | ||
expect( tree.path.get( a , '1#last' ) ).to.eql( [ 'e' , 'f' ] ) ; | ||
expect( tree.path.get( a , '1#next' ) ).to.be( undefined ) ; | ||
expect( path.get( a , '1#0' ) ).to.eql( [ 'b' , 'c' ] ) ; | ||
expect( path.get( a , '1#1' ) ).to.eql( 'd' ) ; | ||
expect( path.get( a , '1#2' ) ).to.eql( [ 'e' , 'f' ] ) ; | ||
expect( path.get( a , '1#3' ) ).to.be( undefined ) ; | ||
expect( path.get( a , '[1][0]' ) ).to.eql( [ 'b' , 'c' ] ) ; | ||
expect( path.get( a , '[1][1]' ) ).to.eql( 'd' ) ; | ||
expect( path.get( a , '[1][2]' ) ).to.eql( [ 'e' , 'f' ] ) ; | ||
expect( path.get( a , '[1][3]' ) ).to.be( undefined ) ; | ||
expect( path.get( a , '1#length' ) ).to.be( 3 ) ; | ||
expect( path.get( a , '1#first' ) ).to.eql( [ 'b' , 'c' ] ) ; | ||
expect( path.get( a , '1#last' ) ).to.eql( [ 'e' , 'f' ] ) ; | ||
expect( path.get( a , '1#next' ) ).to.be( undefined ) ; | ||
expect( tree.path.get( a , '1#2#last' ) ).to.eql( 'f' ) ; | ||
expect( path.get( a , '1#2#last' ) ).to.eql( 'f' ) ; | ||
} ) ; | ||
@@ -465,19 +465,19 @@ | ||
tree.path.set( a , '1' , 'B' ) ; | ||
tree.path.set( a , '#last' , 3 ) ; | ||
tree.path.set( a , '#next' , 'D' ) ; | ||
tree.path.set( a , '#first' , 1 ) ; | ||
path.set( a , '1' , 'B' ) ; | ||
path.set( a , '#last' , 3 ) ; | ||
path.set( a , '#next' , 'D' ) ; | ||
path.set( a , '#first' , 1 ) ; | ||
expect( a ).to.eql( [ 1 , 'B' , 3 , 'D' ] ) ; | ||
expect( tree.path.get( a , '#length' ) ).to.be( 4 ) ; | ||
expect( path.get( a , '#length' ) ).to.be( 4 ) ; | ||
a = [ 'a' , 'b' , 'c' ] ; | ||
tree.path.set( a , '[1]' , 'BBB' ) ; | ||
tree.path.set( a , '#last' , 3 ) ; | ||
tree.path.set( a , '#next' , 'D' ) ; | ||
tree.path.set( a , '#first' , 1 ) ; | ||
path.set( a , '[1]' , 'BBB' ) ; | ||
path.set( a , '#last' , 3 ) ; | ||
path.set( a , '#next' , 'D' ) ; | ||
path.set( a , '#first' , 1 ) ; | ||
expect( a ).to.eql( [ 1 , 'BBB' , 3 , 'D' ] ) ; | ||
expect( tree.path.get( a , '#length' ) ).to.be( 4 ) ; | ||
expect( path.get( a , '#length' ) ).to.be( 4 ) ; | ||
} ) ; | ||
@@ -489,10 +489,10 @@ | ||
tree.path.set( a , '#next' , 'D' ) ; | ||
tree.path.set( a , '#next.f#next' , 'g' ) ; | ||
tree.path.set( a , '#next#next#next' , 'E' ) ; | ||
tree.path.set( a , '#insert' , '@' ) ; | ||
tree.path.set( a , '#last#insert' , '@' ) ; | ||
path.set( a , '#next' , 'D' ) ; | ||
path.set( a , '#next.f#next' , 'g' ) ; | ||
path.set( a , '#next#next#next' , 'E' ) ; | ||
path.set( a , '#insert' , '@' ) ; | ||
path.set( a , '#last#insert' , '@' ) ; | ||
expect( a ).to.eql( [ '@' , 'a' , 'b' , 'c' , 'D' , { f: [ 'g' ] } , [ '@' , [ 'E' ] ] ] ) ; | ||
expect( tree.path.get( a , '#length' ) ).to.be( 7 ) ; | ||
expect( path.get( a , '#length' ) ).to.be( 7 ) ; | ||
} ) ; | ||
@@ -505,47 +505,47 @@ | ||
a = [ 'a' , 'b' , 'c' ] ; | ||
tree.path.delete( a , '1' ) ; | ||
path.delete( a , '1' ) ; | ||
//expect( a ).to.eql( [ 'a' , undefined , 'c' ] ) ; // expect() bug here... | ||
expect( tree.path.get( a , '#length' ) ).to.be( 3 ) ; | ||
expect( path.get( a , '#length' ) ).to.be( 3 ) ; | ||
a = [ 'a' , 'b' , 'c' ] ; | ||
tree.path.delete( a , '#1' ) ; | ||
path.delete( a , '#1' ) ; | ||
expect( a ).to.eql( [ 'a' , 'c' ] ) ; | ||
expect( tree.path.get( a , '#length' ) ).to.be( 2 ) ; | ||
expect( path.get( a , '#length' ) ).to.be( 2 ) ; | ||
a = [ 'a' , 'b' , 'c' ] ; | ||
tree.path.delete( a , '[1]' ) ; | ||
path.delete( a , '[1]' ) ; | ||
expect( a ).to.eql( [ 'a' , 'c' ] ) ; | ||
expect( tree.path.get( a , '#length' ) ).to.be( 2 ) ; | ||
expect( path.get( a , '#length' ) ).to.be( 2 ) ; | ||
a = [ 'a' , 'b' , 'c' ] ; | ||
tree.path.delete( a , '#2' ) ; | ||
path.delete( a , '#2' ) ; | ||
expect( a ).to.eql( [ 'a' , 'b' ] ) ; | ||
expect( tree.path.get( a , '#length' ) ).to.be( 2 ) ; | ||
expect( path.get( a , '#length' ) ).to.be( 2 ) ; | ||
a = [ 'a' , 'b' , 'c' ] ; | ||
tree.path.delete( a , '[2]' ) ; | ||
path.delete( a , '[2]' ) ; | ||
expect( a ).to.eql( [ 'a' , 'b' ] ) ; | ||
expect( tree.path.get( a , '#length' ) ).to.be( 2 ) ; | ||
expect( path.get( a , '#length' ) ).to.be( 2 ) ; | ||
a = [ 'a' , 'b' , 'c' ] ; | ||
tree.path.delete( a , '#last' ) ; | ||
path.delete( a , '#last' ) ; | ||
expect( a ).to.eql( [ 'a' , 'b' ] ) ; | ||
expect( tree.path.get( a , '#length' ) ).to.be( 2 ) ; | ||
tree.path.delete( a , '#last' ) ; | ||
expect( path.get( a , '#length' ) ).to.be( 2 ) ; | ||
path.delete( a , '#last' ) ; | ||
expect( a ).to.eql( [ 'a' ] ) ; | ||
expect( tree.path.get( a , '#length' ) ).to.be( 1 ) ; | ||
tree.path.delete( a , '#last' ) ; | ||
expect( path.get( a , '#length' ) ).to.be( 1 ) ; | ||
path.delete( a , '#last' ) ; | ||
expect( a ).to.eql( [] ) ; | ||
expect( tree.path.get( a , '#length' ) ).to.be( 0 ) ; | ||
expect( path.get( a , '#length' ) ).to.be( 0 ) ; | ||
a = [ 'a' , 'b' , 'c' ] ; | ||
tree.path.delete( a , '#first' ) ; | ||
path.delete( a , '#first' ) ; | ||
expect( a ).to.eql( [ 'b' , 'c' ] ) ; | ||
expect( tree.path.get( a , '#length' ) ).to.be( 2 ) ; | ||
tree.path.delete( a , '#first' ) ; | ||
expect( path.get( a , '#length' ) ).to.be( 2 ) ; | ||
path.delete( a , '#first' ) ; | ||
expect( a ).to.eql( [ 'c' ] ) ; | ||
expect( tree.path.get( a , '#length' ) ).to.be( 1 ) ; | ||
tree.path.delete( a , '#first' ) ; | ||
expect( path.get( a , '#length' ) ).to.be( 1 ) ; | ||
path.delete( a , '#first' ) ; | ||
expect( a ).to.eql( [] ) ; | ||
expect( tree.path.get( a , '#length' ) ).to.be( 0 ) ; | ||
expect( path.get( a , '#length' ) ).to.be( 0 ) ; | ||
} ) ; | ||
@@ -568,7 +568,7 @@ | ||
expect( tree.path.get( a , 'method' ) ).to.be( 'get' ) ; | ||
expect( tree.path.get( a , 'populate' ) ).to.eql( [ 'parents', 'godfather' ] ) ; | ||
expect( tree.path.get( a , 'populate[0]' ) ).to.be( 'parents' ) ; | ||
expect( tree.path.get( a , 'populate[1]' ) ).to.be( 'godfather' ) ; | ||
expect( tree.path.get( a , 'populate[2]' ) ).to.be( undefined ) ; | ||
expect( path.get( a , 'method' ) ).to.be( 'get' ) ; | ||
expect( path.get( a , 'populate' ) ).to.eql( [ 'parents', 'godfather' ] ) ; | ||
expect( path.get( a , 'populate[0]' ) ).to.be( 'parents' ) ; | ||
expect( path.get( a , 'populate[1]' ) ).to.be( 'godfather' ) ; | ||
expect( path.get( a , 'populate[2]' ) ).to.be( undefined ) ; | ||
} ) ; | ||
@@ -583,4 +583,4 @@ | ||
tree.path.set( a , 'method' , 'post' ) ; | ||
tree.path.set( a , 'populate[0]' , 'friends' ) ; | ||
path.set( a , 'method' , 'post' ) ; | ||
path.set( a , 'populate[0]' , 'friends' ) ; | ||
expect( a ).to.eql( { | ||
@@ -595,7 +595,7 @@ method: 'post' , | ||
describe( "Inheritance, using Object.create( tree.path.prototype )" , function() { | ||
describe( "Inheritance, using Object.create( path.prototype )" , function() { | ||
it( ".get()" , function() { | ||
var o = Object.create( tree.path.prototype ) ; | ||
var o = Object.create( path.prototype ) ; | ||
@@ -629,3 +629,3 @@ o.a = 5 ; | ||
var o = Object.create( tree.path.prototype ) ; | ||
var o = Object.create( path.prototype ) ; | ||
@@ -659,3 +659,3 @@ o.a = 5 ; | ||
var o = Object.create( tree.path.prototype ) ; | ||
var o = Object.create( path.prototype ) ; | ||
@@ -697,3 +697,3 @@ o.a = 5 ; | ||
var o = Object.create( tree.path.prototype ) ; | ||
var o = Object.create( path.prototype ) ; | ||
@@ -735,3 +735,3 @@ o.a = 5 ; | ||
var o = Object.create( tree.path.prototype ) ; | ||
var o = Object.create( path.prototype ) ; | ||
@@ -797,4 +797,4 @@ o.a = 5 ; | ||
expect( tree.path.get( o , [ 'a' ] ) ).to.be( 5 ) ; | ||
expect( tree.path.get( o , [ 'sub' ] ) ).to.be.like( { | ||
expect( path.get( o , [ 'a' ] ) ).to.be( 5 ) ; | ||
expect( path.get( o , [ 'sub' ] ) ).to.be.like( { | ||
b: "toto" , | ||
@@ -806,9 +806,9 @@ sub: { | ||
expect( tree.path.get( o , [ 'sub' , 'b' ] ) ).to.be( "toto" ) ; | ||
expect( tree.path.get( o , [ 'sub' , 'sub' ] ) ).to.be.like( { c: true } ) ; | ||
expect( tree.path.get( o , [ 'sub' , 'sub' , 'c' ] ) ).to.be( true ) ; | ||
expect( tree.path.get( o , [ 'd' ] ) ).to.be( null ) ; | ||
expect( tree.path.get( o , [ 'nothing' ] ) ).to.be( undefined ) ; | ||
expect( tree.path.get( o , [ 'sub' , 'nothing' ] ) ).to.be( undefined ) ; | ||
expect( tree.path.get( o , [ 'nothing' , 'nothing' ] ) ).to.be( undefined ) ; | ||
expect( path.get( o , [ 'sub' , 'b' ] ) ).to.be( "toto" ) ; | ||
expect( path.get( o , [ 'sub' , 'sub' ] ) ).to.be.like( { c: true } ) ; | ||
expect( path.get( o , [ 'sub' , 'sub' , 'c' ] ) ).to.be( true ) ; | ||
expect( path.get( o , [ 'd' ] ) ).to.be( null ) ; | ||
expect( path.get( o , [ 'nothing' ] ) ).to.be( undefined ) ; | ||
expect( path.get( o , [ 'sub' , 'nothing' ] ) ).to.be( undefined ) ; | ||
expect( path.get( o , [ 'nothing' , 'nothing' ] ) ).to.be( undefined ) ; | ||
} ) ; | ||
@@ -832,5 +832,5 @@ | ||
tree.path.delete( o , [ 'a' ] ) ; | ||
tree.path.delete( o , [ 'sub' , 'sub' ] ) ; | ||
tree.path.delete( o , [ 'non' , 'existant' , 'path' ] ) ; | ||
path.delete( o , [ 'a' ] ) ; | ||
path.delete( o , [ 'sub' , 'sub' ] ) ; | ||
path.delete( o , [ 'non' , 'existant' , 'path' ] ) ; | ||
@@ -859,6 +859,6 @@ expect( o ).to.be.like( { | ||
tree.path.set( o , [ 'a' ] , "8" ) ; | ||
tree.path.set( o , [ 'sub' , 'b' ] , false ) ; | ||
tree.path.set( o , [ 'sub' , 'sub' ] , { x: 18 , y: 27 } ) ; | ||
tree.path.set( o , [ 'non' , 'existant' , 'path' ] , 'new' ) ; | ||
path.set( o , [ 'a' ] , "8" ) ; | ||
path.set( o , [ 'sub' , 'b' ] , false ) ; | ||
path.set( o , [ 'sub' , 'sub' ] , { x: 18 , y: 27 } ) ; | ||
path.set( o , [ 'non' , 'existant' , 'path' ] , 'new' ) ; | ||
@@ -897,7 +897,7 @@ expect( o ).to.be.like( { | ||
tree.path.define( o , [ 'a' ] , "8" ) ; | ||
tree.path.define( o , [ 'sub' , 'b' ] , false ) ; | ||
tree.path.define( o , [ 'unexistant' ] , '!' ) ; | ||
tree.path.define( o , [ 'sub' , 'sub' ] , { x: 18 , y: 27 } ) ; | ||
tree.path.define( o , [ 'non' , 'existant' , 'path' ] , 'new' ) ; | ||
path.define( o , [ 'a' ] , "8" ) ; | ||
path.define( o , [ 'sub' , 'b' ] , false ) ; | ||
path.define( o , [ 'unexistant' ] , '!' ) ; | ||
path.define( o , [ 'sub' , 'sub' ] , { x: 18 , y: 27 } ) ; | ||
path.define( o , [ 'non' , 'existant' , 'path' ] , 'new' ) ; | ||
@@ -935,8 +935,8 @@ expect( o ).to.be.like( { | ||
tree.path.inc( o , [ 'a' ] ) ; | ||
tree.path.dec( o , [ 'sub' , 'b' ] ) ; | ||
tree.path.inc( o , [ 'sub' ] ) ; | ||
tree.path.dec( o , [ 'sub' , 'sub' ] ) ; | ||
tree.path.inc( o , [ 'non' , 'existant' , 'path' ] ) ; | ||
tree.path.dec( o , [ 'another' , 'non' , 'existant' , 'path' ] ) ; | ||
path.inc( o , [ 'a' ] ) ; | ||
path.dec( o , [ 'sub' , 'b' ] ) ; | ||
path.inc( o , [ 'sub' ] ) ; | ||
path.dec( o , [ 'sub' , 'sub' ] ) ; | ||
path.inc( o , [ 'non' , 'existant' , 'path' ] ) ; | ||
path.dec( o , [ 'another' , 'non' , 'existant' , 'path' ] ) ; | ||
@@ -969,3 +969,1 @@ expect( o ).to.be.like( { | ||
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
206985
36
4900