Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/component/order-changed

Check if the order between two arrays has changed
https://github.com/component/order-changed

Last synced: 13 days ago
JSON representation

Check if the order between two arrays has changed

Awesome Lists containing this project

README

        

# order-changed

Check if the order between two arrays has changed

## Installation

$ component install component/order-changed

## Examples

```js
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