Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hughsk/array-missing
Call a function for every element from a given array that's missing from another array
https://github.com/hughsk/array-missing
Last synced: 8 days ago
JSON representation
Call a function for every element from a given array that's missing from another array
- Host: GitHub
- URL: https://github.com/hughsk/array-missing
- Owner: hughsk
- License: other
- Created: 2014-09-25T12:49:50.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2014-09-25T13:47:26.000Z (about 10 years ago)
- Last Synced: 2024-10-17T16:40:57.241Z (22 days ago)
- Language: JavaScript
- Size: 113 KB
- Stars: 3
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# array-missing [![unstable](http://badges.github.io/stability-badges/dist/unstable.svg)](http://github.com/badges/stability-badges)
Call a function for every element from a given array that's missing from another array
## Usage
[![NPM](https://nodei.co/npm/array-missing.png)](https://nodei.co/npm/array-missing/)
### `missing(expected, actual, [missed], [matched])`
Checks every element in the `expected` array to see if it's present somewhere in
the `actual` array.If an element isn't found, `missed(el, index)` will be called, where `el` is the
element that's missing and `index` is its index within `expected`. Otherwise,
`matched` will be called with the same arguments.For example:
``` javascript
var missing = require('array-missing')missing([1, 2, 4, 8], [6, 1, 2, 5], function(el, i) {
console.log('element:', el)
console.log('index:', i)
})// element: 4
// index: 2
// element: 8
// index: 3
```## License
MIT. See [LICENSE.md](http://github.com/hughsk/array-missing/blob/master/LICENSE.md) for details.