mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-03 02:21:05 +08:00
R=jacktfranklin@chromium.org DISABLE_THIRD_PARTY_CHECK=Adding sinon to deps Change-Id: If47962332a4d9a4b4f0edbe637bca4f9894545ba Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2562704 Auto-Submit: Paul Lewis <aerotwist@chromium.org> Commit-Queue: Paul Lewis <aerotwist@chromium.org> Commit-Queue: Jack Franklin <jacktfranklin@chromium.org> Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
31 lines
869 B
JavaScript
31 lines
869 B
JavaScript
"use strict";
|
|
|
|
var forEach = require("@sinonjs/commons").prototypes.set.forEach;
|
|
|
|
/**
|
|
* Returns `true` when `s1` is a subset of `s2`, `false` otherwise
|
|
*
|
|
* @private
|
|
* @param {Array|Set} s1 The target value
|
|
* @param {Array|Set} s2 The containing value
|
|
* @param {Function} compare A comparison function, should return `true` when
|
|
* values are considered equal
|
|
* @returns {boolean} Returns `true` when `s1` is a subset of `s2`, `false`` otherwise
|
|
*/
|
|
function isSubset(s1, s2, compare) {
|
|
var allContained = true;
|
|
forEach(s1, function(v1) {
|
|
var includes = false;
|
|
forEach(s2, function(v2) {
|
|
if (compare(v2, v1)) {
|
|
includes = true;
|
|
}
|
|
});
|
|
allContained = allContained && includes;
|
|
});
|
|
|
|
return allContained;
|
|
}
|
|
|
|
module.exports = isSubset;
|