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

Package detail

set.prototype.intersection

es-shims26.8kMIT1.1.7

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

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

readme

set.prototype.intersection Version Badge

github actions coverage License Downloads

npm badge

ES Proposal spec-compliant shim for Set.prototype.intersection. Invoke its "shim" method to shim Set.prototype.intersection 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 intersection = require('set.prototype.intersection');

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

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

intersection.shim();

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

Compatibility

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

Tests

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

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 - 2024-09-10

Commits

  • [Fix] polyfill: also detect Chrome/v8 bug with setlike size of 2**31 6344598

v1.1.6 - 2024-09-09

Commits

  • [Fix] node v22 and equivalent Chrome versions have a bug 2024f8c
  • [Dev Deps] update @es-shims/api, @ljharb/eslint-config, object-inspect, tape d50a71b
  • [Refactor] change internal slot name f3eea84
  • [Tests] replace aud with npm audit fba1b9c
  • [Dev Deps] add missing peer dep 047c8e0

v1.1.5 - 2024-04-06

Commits

v1.1.4 - 2024-03-19

Commits

  • [Refactor] add SetDataSize 714b7a1
  • [meta] remove useless ESM 766bf7a
  • [Deps] update call-bind, es-abstract, es-errors, is-set 72b2a56
  • [actions] remove redundant finisher ba66d24
  • [Dev Deps] update tape 4bc40ee

v1.1.3 - 2024-02-04

Commits

  • [Refactor] use es-errors where possible, so things that only need those do not need get-intrinsic 91d23b2
  • [Tests] ensure test mocks return iterators c6af839
  • [Tests] for some reason the glob does not include index.js d75a861
  • [Dev Deps] update tape 9ed3594

v1.1.2 - 2023-12-18

Commits

  • [Fix] properly implement algorithm 2d27685

v1.1.1 - 2023-12-17

Commits

  • [Tests] increase coverage 0b2a5ae
  • [Fix] properly handle negative zero d381180
  • [Deps] update call-bind, define-properties, es-abstract, get-intrinsic, stop-iteration-iterator 1a24a62
  • [Dev Deps] update aud, npmignore, object-inspect, tape 6bf9ab5
  • [Tests] oops, skip native tests 95bd850
  • [Deps] update es-set a166dfc
  • [Dev Deps] update tape 5b3b8ae

v1.1.0 - 2023-07-18

Commits

  • [patch] remove GetKeysIterator and its callable check 9f1b932
  • [Deps] update es-abstract, get-intrinsic b73c04e
  • [Tests] remove unused shimmed tests 1114fb6
  • [patch] throw on negative set sizes b4e7b5f
  • [Dev Deps] update @es-shims/api, @ljharb/eslint-config, aud, es6-shim, tape 681bb9f
  • [Deps] update define-properties, es-abstract, get-intrinsic 8361911
  • [Dev Deps] update @es-shims/api, tape b25ffae

v1.0.2 - 2023-01-14

Commits

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

v1.0.1 - 2023-01-13

Commits

  • [Fix] properly handle StopIteration envs, like FF 42 9b57a86
  • [Tests] add test case fca4503
  • [patch] adjust spec steps for latest PR 66c558e
  • [Dev Deps] update @ljharb/eslint-config, aud, es6-shim ab0dbf2
  • [Dev Deps] update object-inspect 0d1eb8f
  • [Deps] update es-abstract, es-set de002aa
  • [Deps] update es-set fef0d04

v1.0.0 - 2022-12-04

Commits