karmia-utility-array

0.5.0 • Public • Published

karmia-utility-array

Karmia utility array module

Usage

const karmia_utility_array = require('karmia-utility-array').default,
    karray = new karmia_utility_array();

unique

  • list <Array>

Removes duplicate values from an array

count

  • list <Array>
  • item <*>

Count item in list

range

  • start <number>
  • stop <number>
  • step <number> Default: 1

Get array of integer from start to end

karray.range(5);
// => [0, 1, 2, 3, 4]

karray.range(5, 10);
// => [5, 6, 7, 8, 9]

karray.range(3, 10, 3);
// => [3, 6, 9]

flip

  • list <Array>

Get object that exchanges index with their value

karray.flip(['a', 'b', 'c', 'd', 'e']);
// => {a: 0, b: 1, c: 2, d: 3, e: 4}

intersection

  • list1 <Array>
  • list2 <Array>

Get intersection of two arrays

const list1 = ['a', 'b', 'b', 'c', 'c', 'c'],
    list2 = ['a', 'b'];

console.log(karray.difference(list1, list2));
// => ['a', 'b']

difference

  • list1 <Array>
  • list2 <Array>

Get difference of two arrays

const list1 = ['a', 'b', 'b', 'c', 'c', 'c'],
    list2 = ['a', 'b'];

console.log(karray.difference(list1, list2));
// => ['c', 'c', 'c']

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.5.01latest

Version History

VersionDownloads (Last 7 Days)Published
0.5.01
0.4.10
0.4.00
0.3.30
0.3.20
0.3.10
0.3.00
0.2.10
0.2.00
0.1.20
0.1.10
0.1.00

Package Sidebar

Install

npm i karmia-utility-array

Weekly Downloads

1

Version

0.5.0

License

MIT

Unpacked Size

11.8 kB

Total Files

9

Last publish

Collaborators

  • fujimaki-k