0.0.1 • Published 8 years ago
reversejs v0.0.1
reversejs
reverse an array(or array-like objects) and do not mutate it.
Why
the problem with Array.prototype.reverse
:
it matute the array, so you can't apply it to immutable data structure.
for example:
[].reverse.call('hello')
// TypeError: Cannot assign to read only property '0' of [object String]
Install
$ npm install --save reversejs
Usage
const reverse = require('reversejs')
reverse([1, 2, 3]) // [3, 2, 1]
reverse('世界').join('') // '界世'
API
reverse(arr)
arr
Type: array
or array-like objects
License
MIT © JIANG Di
0.0.1
8 years ago