order-changed

Check if the order between two arrays has changed

npm install order-changed
2 downloads in the last week
17 downloads in the last month

order-changed

Check if the order between two arrays has changed

Installation

$ component install component/order-changed

Examples

var assert = require('assert');
var changed = require('./');

var a = [];
var b = [];

assert(false == changed(a, b), 'empty');


var a = ['foo', 'bar', 'baz'];
var b = ['foo', 'baz'];

assert(false == changed(a, b), 'removing one');


var a = ['foo', 'bar', 'baz'];
var b = ['foo', 'bar', 'baz', 'raz'];

assert(false == changed(a, b), 'adding one');


var a = ['foo', 'bar', 'baz'];
var b = ['foo'];

assert(false == changed(a, b), 'removing two');


var a = ['foo', 'bar', 'baz'];
var b = [];

assert(false == changed(a, b), 'removing all');


var a = ['foo', 'bar', 'baz'];
var b = ['hey', 'foo', 'bar', 'baz'];

assert(true == changed(a, b), 'prepend');


var a = ['foo', 'bar', 'baz'];
var b = ['bar', 'foo', 'baz'];

assert(true == changed(a, b), 're-order');

License

MIT

npm loves you