Singly linked list code bricks for JavaScript. Parent is aureooms/js-data-structures.
let head = sll.list( [ 9 , 2 , 5 ] ) ; // { next : Node , value : 9 }
Can be managed through jspm, duo, component, bower, ender, jam, spm, and npm.
jspm install github:aureooms/js-sll
# or
jspm install npm:aureooms-js-sll
No install step needed for duo!
component install aureooms/js-sll
bower install aureooms-js-sll
ender add aureooms-js-sll
jam install aureooms-js-sll
spm install aureooms-js-sll --save
npm install aureooms-js-sll --save
let sll = require( "github:aureooms/js-sll" ) ;
// or
import sll from 'aureooms-js-sll' ;
let sll = require( "aureooms/js-sll" ) ;
let sll = require( "aureooms-js-sll" ) ;
The script tag exposes the global variable sll
.
<script src="bower_components/aureooms-js-sll/js/dist/sll.min.js"></script>
Alternatively, you can use any tool mentioned here.
require( [ "aureooms-js-sll" ] , function ( sll ) { ... } ) ;
let head = sll.list( [ 9 , 2 , 5 ] ) ; // { next : Node , value : 9 }
head.value ; // 9
head.next.value ; // 2
head.next.next.value ; // 5
head.next.next.next ; // null
for ( let value of sll.iter( head ) ) {
// yields 9 then 2 then 5
}