0.1.3 • Published 5 years ago

sub-array-order v0.1.3

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

array-order

This is a mini library, it was pretty handy to me , imagine this there is a certain sub array you have and then you want the sub array to have the same order as the parent does, Example,

var parent = [1,2,3,4,5,6,7,8,9];
var sub = [8,2,1,6,4];
  var newArr = getOrderedArray(parent, sub);

Which will give you 1,2,4,6,8

And to get the reverse of this simply add one more parameter to it, and set it to true

Installation

  yarn add sub-array-order

Usage

  const getOrderedArray = require('sub-array-order');
  getOrderedArray([1,2,3,4,5,6,7,8,9,10], [8,3,4,1]);

Result

  [ 1, 3, 4, 8 ]

Reverse

  getOrderedArray([1,2,3,4,5,6,7,8,9,10], [8,3,4,1], true);

Result

  [ 8, 4, 3, 1 ]
0.1.3

5 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago