💨 [Xtra]
Extra array methods : rand, uniq, sum, contain, flatt
$ npm i array-xtra --saveUsage
import {uniq} from 'array-xtra'
// or
var {uniq} = require('array-xtra')Or include it via jsDelivr CDN:
<script src="https://cdn.jsdelivr.net/npm/array-xtra@0.1.3/build/index.min.js"></script>
// access via object : xtra
xtra.uniq([1, 2, 3, 1, 2]) // [1,2,3]Methods & Examples
- remove([], element, [startIndex]) : []
remove([1,2,3,1], 1) // [2, 3, 1]
remove(['a','b','c','a'], 'a') // ['b', 'c', 'a']- removeAll([], element, [startIndex]) : []
removeAll([1,2,3,1], 1) // [2, 3]
removeAll(['a','b','c','a'], 'a') // ['b', 'c']- rand([]) : Number|String
return random item from an Array
rand([1, 2, 3]) // 3
rand(['a','b','c']) // 'c'- uniq([]) : []
uniq([1, 2, 3, 1, 2]) // [1, 2, 3]- sum([], [startIndex]) : Number
sum([1, 2, 3]) // 6
sum([1, 2, 3], 2) // 3- contain([], element, [startIndex]) : Boolean
contain([1, 2, 3, 1, 2], 2) // true
contain([1, 2, 3], 2, 2) // false- flatt([]) : []
flatt([1, 2, [3, [4]]]) // [ 1, 2, 3, 4 ]Notes
- Works both in Node.js and in the browser.
- Supported in all old and modern browsers.
- All pull requests are welcome, feel free.
License
MIT

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
