array-missing
Advanced tools
Comparing version 1.0.0 to 1.1.0
13
index.js
module.exports = missing | ||
function missing(expected, actual, missed) { | ||
function noop() {} | ||
function missing(expected, actual, missed, matched) { | ||
var e = expected.length | ||
var a = actual.length | ||
missed = missed || noop | ||
matched = matched || noop | ||
out: for (var i = 0; i < e; i++) { | ||
var ex = expected[i] | ||
for (var j = 0; j < a; j++) { | ||
if (expected[i] === actual[j]) { | ||
if (ex === actual[j]) { | ||
matched(ex, i) | ||
continue out | ||
@@ -14,4 +21,4 @@ } | ||
missed(expected[i], i) | ||
missed(ex, i) | ||
} | ||
} |
{ | ||
"name": "array-missing", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Call a function for every element from a given array that's missing from another array", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -9,3 +9,3 @@ # array-missing [![unstable](http://badges.github.io/stability-badges/dist/unstable.svg)](http://github.com/badges/stability-badges) | ||
### `missing(expected, actual, missed)` | ||
### `missing(expected, actual, [missed], [matched])` | ||
@@ -16,3 +16,4 @@ Checks every element in the `expected` array to see if it's present somewhere in | ||
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`. | ||
element that's missing and `index` is its index within `expected`. Otherwise, | ||
`matched` will be called with the same arguments. | ||
@@ -19,0 +20,0 @@ For example: |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3341
18
37