Skip to content

nju33/order-align

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

orderAlign

Build Status XO code style npm version

In the order specified the array

Install

npm i order-align

Usage

const orderAlign = require('order-align');
orderAlign(orderList, dataArr, targetKey);

Example

String

const orderList = ['foo', 'bar', 'baz'];
const dataArr = ['baz', 'foo', 'bar'];

const result = orderAlign(orderList, dataArr);
console.log(result);
// [ 'foo', 'bar', 'baz' ]

Object

const orderList = ['foo', 'bar', 'baz'];
const dataArr = [
  {name: 'baz'},
  {name: 'foo'},
  {name: 'bar'}
];

const result = orderAlign(orderList, dataArr, 'name');
console.log(result);
// [ { name: 'foo' }, { name: 'bar' }, { name: 'baz' } ]

About

In the order specified the array

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published