shale
v0.1.0
Published
A Javascript library for creating and manipulating immutable objects
Downloads
5
Readme
shale
A Javascript library for creating and manipulating immutable objects
shale : object
Kind: global namespace
- shale : object
- .array : object
- .boolean : object
- .null : object
- .number : object
- .object : object
- .string : object
- .undefined : object
- .type ⇒
- .hashcode(val) ⇒
- .compact(val) ⇒
- .equals(val1, val2) ⇒
shale.array : object
Kind: static namespace of shale
- .array : object
array.hashcode(arr) ⇒
A function that returns a hashcode for an array. You should never need to call this directly, just call shale.hashcode
Kind: static method of array
Returns: an hashcode for arr
| Param | Description | | --- | --- | | arr | the array to hash |
array.compact(arr) ⇒
A function that compacts an array into an immutable representation. You should never need to call this directly, just call shale.compact
Kind: static method of array
Returns: an immutable representation of arr
| Param | Description | | --- | --- | | arr | the array to compact |
array.equals(arr1, arr2) ⇒
A function that compares two arrays for deep equality. You should never call this directly, use shale.equals
Kind: static method of array
Returns: true if arr1 is equal to arr2, false otherwise
| Param | Description | | --- | --- | | arr1 | an array to compare | | arr2 | an array to compare |
array.slice(arr, begin, end) ⇒
A function that slices an array or an immutable array. This doesn't modify the source array.
Kind: static method of array
Returns: an immutable slice of val
| Param | Description | | --- | --- | | arr | the array or immutable array to slice | | begin | the beginning index | | end | the ending index |
array.push(arr, end) ⇒
A function that pushes any number of elements onto an array or an immutable array. This doesn't modify the source array.
Kind: static method of array
Returns: an immutable array equivalent to [ ...arr, ...elements ]
| Param | Description | | --- | --- | | arr | the array or immutable array to 'push' onto | | ...elements | any number of elements to push onto the end of the arr | | end | the ending index |
array.pop(arr) ⇒
A function that 'pops' one element off the source array. This doesn't modify the source array, it returns an immutable copy of the array, minus the last element.
Kind: static method of array
Returns: an immutable array that is a copy of arr, with the last element removed
| Param | Description | | --- | --- | | arr | the array or immutable array to 'pop' |
array.map(arr, func) ⇒
A function that maps every element of an array to a new array using a mapping function. This is equivalent to array.map, but the returned array is immutable
Kind: static method of array
Returns: an immutable array that is a mapped copy of the original
| Param | Description | | --- | --- | | arr | the array to map | | func | the mapping function |
array.filter(arr, func) ⇒
A function that filters elements from an array using a filter function. This is equivalent to array.filter, but the returned array is immutable
Kind: static method of array
Returns: an immutable array that is a filter copy of the original
| Param | Description | | --- | --- | | arr | the array to filter | | func | the filter function |
array.sort(arr, func) ⇒
A function that sorts an array or an immutable array. This doesn't modify the original array, but returns an immutable sorted copy.
Kind: static method of array
Returns: an immutable array that is a sorted immutable copy of the original
| Param | Description | | --- | --- | | arr | the array to filter | | func | the sorting function |
shale.boolean : object
Kind: static namespace of shale
- .boolean : object
boolean.hashcode(val) ⇒
A function that returns a hashcode for a boolean. You should never need to call this directly, just call shale.hashcode
Kind: static method of boolean
Returns: an hashcode for val
| Param | Description | | --- | --- | | val | the boolean to hash |
boolean.compact(val) ⇒
A function that compacts a boolean into an immutable representation. You should never need to call this directly, just call shale.compact
Kind: static method of boolean
Returns: an immutable representation of val
| Param | Description | | --- | --- | | val | the boolean to compact |
boolean.equals(val1, val2) ⇒
A function that compares two booleans for equality. You should never call this directly, use shale.equals
Kind: static method of boolean
Returns: true if val1 is equal to val2, false otherwise
| Param | Description | | --- | --- | | val1 | a boolean to compare | | val2 | a boolean to compare |
shale.null : object
Kind: static namespace of shale
- .null : object
null.hashcode(val) ⇒
A function that returns a hashcode for a null. You should never need to call this directly, just call shale.hashcode
Kind: static method of null
Returns: an hashcode for val
| Param | Description | | --- | --- | | val | the null to hash |
null.compact(val) ⇒
A function that compacts a null into an immutable representation. You should never need to call this directly, just call shale.compact
Kind: static method of null
Returns: an immutable representation of val
| Param | Description | | --- | --- | | val | the null to compact |
null.equals(val1, val2) ⇒
A function that compares two nulls for equality. You should never call this directly, use shale.equals
Kind: static method of null
Returns: true if val1 is equal to val2, false otherwise
| Param | Description | | --- | --- | | val1 | a null to compare | | val2 | a null to compare |
shale.number : object
Kind: static namespace of shale
- .number : object
number.hashcode(val) ⇒
A function that returns a hashcode for a number. You should never need to call this directly, just call shale.hashcode
Kind: static method of number
Returns: an hashcode for val
| Param | Description | | --- | --- | | val | the number to hash |
number.compact(val) ⇒
A function that compacts a number into an immutable representation. You should never need to call this directly, just call shale.compact
Kind: static method of number
Returns: an immutable representation of val
| Param | Description | | --- | --- | | val | the number to compact |
number.equals(val1, val2) ⇒
A function that compares two numbers for equality. You should never call this directly, use shale.equals
Kind: static method of number
Returns: true if val1 is equal to val2, false otherwise
| Param | Description | | --- | --- | | val1 | a number to compare | | val2 | a number to compare |
shale.object : object
Kind: static namespace of shale
- .object : object
object.hashcode(val) ⇒
A function that returns a hashcode for an object. You should never need to call this directly, just call shale.hashcode
Kind: static method of object
Returns: an hashcode for val
| Param | Description | | --- | --- | | val | the object to hash |
object.compact(val) ⇒
A function that compacts an object into an immutable representation. You should never need to call this directly, just call shale.compact
Kind: static method of object
Returns: an immutable representation of val
| Param | Description | | --- | --- | | val | the object to compact |
object.equals(val1, val2) ⇒
A function that compares two objects for deep equality. You should never call this directly, use shale.equals
Kind: static method of object
Returns: true if val1 is equal to val2, false otherwise
| Param | Description | | --- | --- | | val1 | an object to compare | | val2 | an object to compare |
object.patch(target) ⇒
A function that "patches" one object with others. This works like Object.assign, but without modifying the target object
Kind: static method of object
Returns: an immutable representation of the patched target
| Param | Description | | --- | --- | | target | the target object to "patch" | | ...sources | any number of source objects to patch target with |
object.filter(obj, filter) ⇒
A function that returns a "filtered" copy of an object. This works like array.filter, but on each key-value pair of the object
Kind: static method of object
Returns: a filtered representation of obj
| Param | Description | | --- | --- | | obj | the target object to "filter" | | filter | a filtering function (value, key, obj) => boolean |
object.map(obj, ma) ⇒
A function that returns a "mapped" copy of an object. This works like array.map, but on each key-value pair of the object
Kind: static method of object
Returns: a mapped representation of obj
| Param | Description | | --- | --- | | obj | the target object to "map" | | ma | a mapping function (value, key, obj) => newValue |
shale.string : object
Kind: static namespace of shale
- .string : object
string.hashcode(val) ⇒
A function that returns a hashcode for a string. You should never need to call this directly, just call shale.hashcode
Kind: static method of string
Returns: an hashcode for val
| Param | Description | | --- | --- | | val | the string to hash |
string.compact(val) ⇒
A function that compacts a string into an immutable representation. You should never need to call this directly, just call shale.compact
Kind: static method of string
Returns: an immutable representation of val
| Param | Description | | --- | --- | | val | the string to compact |
string.equals(val1, val2) ⇒
A function that compares two strings for equality. You should never call this directly, use shale.equals
Kind: static method of string
Returns: true if val1 is equal to val2, false otherwise
| Param | Description | | --- | --- | | val1 | a string to compare | | val2 | a string to compare |
shale.undefined : object
Kind: static namespace of shale
- .undefined : object
undefined.hashcode(val) ⇒
A function that returns a hashcode for an undefined. You should never need to call this directly, just call shale.hashcode
Kind: static method of undefined
Returns: an hashcode for val
| Param | Description | | --- | --- | | val | the undefined to hash |
undefined.compact(val) ⇒
A function that compacts an undefined into an immutable representation. You should never need to call this directly, just call shale.compact
Kind: static method of undefined
Returns: an immutable representation of val
| Param | Description | | --- | --- | | val | the undefined to compact |
undefined.equals(val1, val2) ⇒
A function that compares two undefineds for equality. You should never call this directly, use shale.equals
Kind: static method of undefined
Returns: true if val1 is equal to val2, false otherwise
| Param | Description | | --- | --- | | val1 | an undefined to compare | | val2 | an undefined null to compare |
shale.type ⇒
A function that returns the type of a value
Kind: static constant of shale
Returns: a type string
| Param | Description | | --- | --- | | val | the value to check |
shale.hashcode(val) ⇒
A function that returns the shale hashcode of a value
Kind: static method of shale
Returns: a 32-bit hashcode
| Param | Description | | --- | --- | | val | the value to check |
shale.compact(val) ⇒
A function that compacts a value into an immutable representation
Kind: static method of shale
Returns: an immutable representation of val
| Param | Description | | --- | --- | | val | the value to compact |
shale.equals(val1, val2) ⇒
A function that checks if two values are equal
Kind: static method of shale
Returns: a boolean, true if val1 is equal to val2
| Param | Description | | --- | --- | | val1 | a value to compare | | val2 | a value to compare |