reversejs

0.0.1 • Public • Published

reversejs Build Status

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

Install

DownloadsWeekly Downloads

2

Version

0.0.1

License

MIT

Last publish

Collaborators

  • jiang-di