Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

chain-lightning

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chain-lightning - npm Package Compare versions

Comparing version
0.4.0
to
0.4.1
+22
-0
lib/BinaryTree.js

@@ -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 @@