@aureooms/js-sll
v1.0.2
Published
Singly linked list code bricks for JavaScript
Downloads
10
Maintainers
Readme
js-sll
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.
Install
jspm
jspm install github:aureooms/js-sll
# or
jspm install npm:@aureooms/js-sll
duo
No install step needed for duo!
component
component install aureooms/js-sll
bower
bower install @aureooms/js-sll
ender
ender add @aureooms/js-sll
jam
jam install @aureooms/js-sll
spm
spm install @aureooms/js-sll --save
npm
npm install @aureooms/js-sll --save
Require
jspm
let sll = require( "github:aureooms/js-sll" ) ;
// or
import sll from '@aureooms/js-sll' ;
duo
let sll = require( "aureooms/js-sll" ) ;
component, ender, spm, npm
let sll = require( "@aureooms/js-sll" ) ;
bower
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.
jam
require( [ "@aureooms/js-sll" ] , function ( sll ) { ... } ) ;
Use
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
}