Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

set.prototype.difference

es-shims63.4kMIT1.1.7

An ESnext spec-compliant Set.prototype.difference shim/polyfill/replacement that works as far down as ES3

javascript, ecmascript, Set, difference, set.prototype.difference, polyfill, shim, es-shim API, es-shims

readme

set.prototype.difference Version Badge

github actions coverage License Downloads

npm badge

ES Proposal spec-compliant shim for Set.prototype.difference. Invoke its "shim" method to shim Set.prototype.difference if it is unavailable or noncompliant.

This package implements the es-shim API interface. It works in an ES3-supported environment, and complies with the proposed spec. When shimmed, it uses es-set to shim the Set implementation itself if needed.

Most common usage:

var assert = require('assert');
var difference = require('set.prototype.difference');

var set1 = new Set([1, 2]);
var set2 = new Set([2, 3]);
var result = difference(set1, set2);

assert.deepEqual(result, new Set([1]));

difference.shim();

var shimmedResult = set1.difference(set2);
assert.deepEqual(shimmedResult, new Set([1]));

Compatibility

node v22 and equivalent versions of Chrome have Set difference, but has a bug with set-like arguments with non-SMI integer sizes.

Tests

Simply clone the repo, npm install, and run npm test

Set Method Packages

changelog

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

v1.1.7 - 2025-03-14

Commits

  • [actions] split out node 10-20, and 20+ bce4a13
  • [Dev Deps] update @es-shims/api, @ljharb/eslint-config, auto-changelog, es-map, es-value-fixtures, for-each, gopd, has-strict-mode, object-inspect, tape dc425de
  • [Deps] update call-bind, es-abstract, es-set, stop-iteration-iterator 86b42ed
  • [Refactor] use call-bound directly 937aa54
  • [Dev Deps] add missing peer dep 9bf95f0

v1.1.6 - 2024-09-10

Commits

  • [Fix] handle chrome/v8 bugs 266d8aa
  • [Dev Deps] update @es-shims/api, @ljharb/eslint-config, object-inspect, tape 7563c36
  • [Refactor] change internal slot name 113b587
  • [Tests] replace aud with npm audit eec956e
  • [Dev Deps] add missing peer dep b2219f3

v1.1.5 - 2024-04-06

Commits

v1.1.4 - 2024-03-19

Commits

  • [meta] remove useless ESM 6b200fa
  • [Refactor] add SetDataSize ae0d37f
  • [Deps] update call-bind, es-abstract, es-errors, is-set d7cc20a
  • [actions] remove redundant finisher 2acda7c
  • [Dev Deps] update tape e2d67e7

v1.1.3 - 2024-02-04

Commits

  • [Tests] ensure test mocks return iterators e67b02d
  • [Refactor] use es-errors where possible, so things that only need those do not need get-intrinsic a7950e7
  • [Dev Deps] fix incorrect dev deps 15f4527
  • [Dev Deps] update tape eedb6da

v1.1.2 - 2023-12-17

Commits

  • [Fix] properly implement algorithm 7d9aef9

v1.1.1 - 2023-12-16

Commits

  • [Tests] increase coverage 4604b92
  • [Fix] handle negative zero properly ffa29e2
  • [Deps] update call-bind, define-properties, es-abstract, es-set, get-intrinsic bd37b0d
  • [Dev Deps] update aud, npmignore, object-inspect, tape 7624a2b

v1.1.0 - 2023-07-18

Commits

  • [Deps] update define-properties, es-abstract, get-intrinsic dc423d8
  • [patch] remove GetKeysIterator and its callable check 90dcf36
  • [Tests] remove unused shimmed tests f5d9655
  • [patch] throw on negative set sizes bfa0fcf
  • [Dev Deps] update @es-shims/api, @ljharb/eslint-config, aud, es6-shim, tape 5993d2a

v1.0.2 - 2023-01-15

Commits

  • [Refactor] update es-set; use es-set/tools 0a4aa6b

v1.0.1 - 2023-01-13

Commits

  • [Fix] properly handle StopIteration envs, like FF 42 1bf936d
  • [readme] link to all set method packages ae8065e
  • [Dev Deps] update @ljharb/eslint-config, object-inspect 7da7a4e
  • [Deps] update es-abstract, es-set 66283bd
  • [Deps] update es-abstract, es-set 40dfca2
  • [Dev Deps] update aud, es6-shim b72e100

v1.0.0 - 2022-12-04

Commits