0.0.5 • Published 8 years ago
@nathanfaucett/immutable-vector v0.0.5
Immutable Vector
Immutable persistent vector for the browser and node.js
Install using npm
$ npm install @nathanfaucett/immutable-vector --saveInstall using yarn
$ yarn add @nathanfaucett/immutable-vector --saveExample Usage
var ImmutableVector = require("@nathanfaucett/immutable-vector");
var a = new ImmutableVector([0, 1, 2]),
b = new ImmutableVector(0, 1, 2),
c = ImmutableVector.of([0, 1, 2]),
d = ImmutableVector.of(0, 1, 2);
var a0 = a.push(3),
a1 = a.unshift(-1);Docs
Members
length -> Number
returns size of Vector, only available if Object.defineProperty is supportedStatic Functions
Vector.isVector(value: Any) -> Boolean
returns true if value is a vector else falseVector.of(...values: Array) -> Vector
creates Vector from passed values same as new Vector(...values: Array<Any>)Vector.equal(a: Vector, b: Vector) -> Boolean
compares vectors by valuesFunctions
size() -> Number
returns size of Vectorget(index: UnsignedNumber) -> Any
returns value at indexnth(index: UnsignedNumber) -> Any
alias to getfirst() -> Any
returns first elementlast() -> Any
returns last elementindexOf(value: Any) -> Number
returns index of value, -1 if not foundset(index: UnsignedNumber, value: Any) -> Vector
returns new Vector if value at index is differentinsert(index: UnsignedNumber, ...values: Array) -> Vector
returns new Vector with inserted values at indexremove(index: UnsignedNumber, count = 1: UnsignedNumber) -> Vector
returns new Vector without the values from index to index + countconj(...values: Array) -> Vector
returns new Vector with values pushed to end of the Vectorunshift(...values: Array) -> Vector
returns new Vector with values pushed to front of the Vectorpop() -> Vector
returns new Vector without last elementshift() -> Vector
returns new Vector without first elementpush(...values: Array) -> Vector
returns new Vector with values pushed to end of the Vectorconcat(...vectors: Array) -> Vector
returns new Vector with values from vectors pushed to end of the Vectoriterator(reverse = false: Boolean) -> Iterator
returns Iteratorevery, filter, forEach, forEachRight, map, reduce, reduceRight, some
common Array methodstoArray() -> Array
returns Vector elements in an Arrayjoin(separator = " ") -> String
join all elements of an Vector into a StringtoString() -> String
String representation of Vectorequals(other: Vector) -> Boolean
compares this vector to other vector by values