0.1.3 • Published 6 years ago

array-xtra v0.1.3

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

💨Xtra

Extra array methods : rand, uniq, sum, contain, flatt
npm.io badgen badgen

$ npm i array-xtra --save

Usage

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([1,2,3,1], 1) // [2, 3, 1]
remove(['a','b','c','a'], 'a') // ['b', 'c', 'a']
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([1, 2, 3]) // 6
sum([1, 2, 3], 2) // 3
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

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago