chain-lightning
Advanced tools
+22
-0
@@ -982,2 +982,24 @@ /* | ||
| // Return an array being a slice of a range | ||
| BinaryTree.prototype.arraySlice = | ||
| BinaryTree.prototype.slice = function( start , end , including = true ) { | ||
| var element , array = [] , | ||
| current = this.getClosestNode( start , including , 1 ) ; | ||
| while ( current && this.isOrdered( current.key , end ) && ( including || current.key !== end ) ) { | ||
| if ( current.element instanceof Stack ) { | ||
| array.push( ... current.element ) ; | ||
| } | ||
| else { | ||
| array.push( current.element ) ; | ||
| } | ||
| current = this.nextNode( current ) ; | ||
| } | ||
| return array ; | ||
| } ; | ||
| /* | ||
@@ -984,0 +1006,0 @@ Internal, low-level |
+1
-1
| { | ||
| "name": "chain-lightning", | ||
| "version": "0.4.0", | ||
| "version": "0.4.1", | ||
| "description": "Linked list", | ||
@@ -5,0 +5,0 @@ "main": "lib/chainlightning.js", |
@@ -644,2 +644,34 @@ /* | ||
| } ) ; | ||
| it( ".slice() (or alias .arraySlice())" , () => { | ||
| var tree ; | ||
| var reset = () => { | ||
| tree = new BinaryTree( { stack: true } ) ; | ||
| tree.add( 3 , 'jack' ) ; | ||
| tree.add( 2 , 'jean' ) ; | ||
| tree.add( 5 , 'steve' ) ; | ||
| tree.add( 2.5 , 'john' ) ; | ||
| tree.add( 2.7 , 'robert' ) ; | ||
| tree.add( 2.8 , 'johnson' ) ; | ||
| tree.add( 6 , 'bobby' ) ; | ||
| tree.add( 2.7 , 'robert2' ) ; | ||
| tree.add( 2.7 , 'robert3' ) ; | ||
| } ; | ||
| reset() ; | ||
| expect( tree.slice( -1 , 10 ) ).to.equal( [ 'jean' , 'john' , 'robert' , 'robert2' , 'robert3' , 'johnson' , 'jack' , 'steve' , 'bobby' ] ) ; | ||
| expect( tree.slice( 2 , 6 ) ).to.equal( [ 'jean' , 'john' , 'robert' , 'robert2' , 'robert3' , 'johnson' , 'jack' , 'steve' , 'bobby' ] ) ; | ||
| expect( tree.slice( 3 , 5 ) ).to.equal( [ 'jack' , 'steve' ] ) ; | ||
| expect( tree.slice( 3 , 3 ) ).to.equal( [ 'jack' ] ) ; | ||
| expect( tree.slice( 3 , 2 ) ).to.equal( [] ) ; | ||
| expect( tree.slice( 30 , 40 ) ).to.equal( [] ) ; | ||
| expect( tree.slice( -1 , 10 , false ) ).to.equal( [ 'jean' , 'john' , 'robert' , 'robert2' , 'robert3' , 'johnson' , 'jack' , 'steve' , 'bobby' ] ) ; | ||
| expect( tree.slice( 2 , 6 , false ) ).to.equal( [ 'john' , 'robert' , 'robert2' , 'robert3' , 'johnson' , 'jack' , 'steve' ] ) ; | ||
| expect( tree.slice( 3 , 5 , false ) ).to.equal( [] ) ; | ||
| expect( tree.slice( 3 , 3 , false ) ).to.equal( [] ) ; | ||
| expect( tree.slice( 3 , 2 , false ) ).to.equal( [] ) ; | ||
| expect( tree.slice( 30 , 40 , false ) ).to.equal( [] ) ; | ||
| } ) ; | ||
| } ) ; | ||
@@ -646,0 +678,0 @@ |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
130723
1.58%3316
1.34%