You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
parttimejob/node_modules/core-js/internals/set-difference.js

27 lines
891 B

'use strict';
var aSet = require('../internals/a-set');
var SetHelpers = require('../internals/set-helpers');
var clone = require('../internals/set-clone');
var size = require('../internals/set-size');
var getSetRecord = require('../internals/get-set-record');
var iterateSet = require('../internals/set-iterate');
var iterateSimple = require('../internals/iterate-simple');
var has = SetHelpers.has;
var remove = SetHelpers.remove;
// `Set.prototype.difference` method
// https://github.com/tc39/proposal-set-methods
module.exports = function difference(other) {
var O = aSet(this);
var otherRec = getSetRecord(other);
var result = clone(O);
if (size(O) <= otherRec.size) iterateSet(O, function (e) {
if (otherRec.includes(e)) remove(result, e);
});
else iterateSimple(otherRec.getIterator(), function (e) {
if (has(O, e)) remove(result, e);
});
return result;
};