Skip to content

packagestats/list-index-changes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

list-index-changes npm npm

Get all element movement within lists

npm install list-index-changes

Usage

var listIndexChanges = require('list-index-changes');

var yesterday = ['foo', 'bar'];
var today = ['bar', 'foo'];

var results = listIndexChanges(yesterday, today);

results will be a list of two elements:

{
  element: 'foo',
  was: 0,
  now: 1
},
{
  element: 'bar',
  was: 1,
  now: 0
}
  • was and now represent positional indices within the lists
  • You can optionally get ordinal positions instead of array indices by supplying {ordinal: true}. Example: listIndexChanges(yesterday, today, {ordinal: true}).

License

MIT

About

Get all element movement within lists

Resources

Stars

Watchers

Forks

Packages

No packages published