JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3343300
  • Score
    100M100P100Q199826F
  • License ISC

ECMAScript6 Set polyfill

Package Exports

  • es6-set
  • es6-set/ext/copy
  • es6-set/ext/copy.js
  • es6-set/ext/every
  • es6-set/ext/every.js
  • es6-set/ext/get-first
  • es6-set/ext/get-first.js
  • es6-set/ext/get-last
  • es6-set/ext/get-last.js
  • es6-set/ext/some
  • es6-set/ext/some.js
  • es6-set/implement
  • es6-set/implement.js
  • es6-set/index.js
  • es6-set/is-set
  • es6-set/is-set.js
  • es6-set/polyfill
  • es6-set/polyfill.js
  • es6-set/primitive
  • es6-set/primitive/index.js
  • es6-set/valid-set
  • es6-set/valid-set.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (es6-set) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Build status Tests coverage npm version

es6-set

Set collection as specified in ECMAScript6

Warning:
v0.1 version does not ensure O(1) algorithm complexity (but O(n)). This shortcoming will be addressed in v1.0

Usage

If you want to make sure your environment implements Set, do:

require("es6-set/implement");

If you'd like to use native version when it exists and fallback to polyfill if it doesn't, but without implementing Set on global scope, do:

var Set = require("es6-set");

If you strictly want to use polyfill even if native Set exists, do:

var Set = require("es6-set/polyfill");

Installation

$ npm install es6-set

To port it to Browser or any other (non CJS) environment, use your favorite CJS bundler. No favorite yet? Try: Browserify, Webmake or Webpack

API

Best is to refer to specification. Still if you want quick look, follow examples:

var Set = require("es6-set");

var set = new Set(["raz", "dwa", {}]);

set.size; // 3
set.has("raz"); // true
set.has("foo"); // false
set.add("foo"); // set
set.size; // 4
set.has("foo"); // true
set.has("dwa"); // true
set.delete("dwa"); // true
set.size; // 3

set.forEach(function (value) {
  // 'raz', {}, 'foo' iterated
});

// FF nightly only:
for (value of set) {
  // 'raz', {}, 'foo' iterated
}

var iterator = set.values();

iterator.next(); // { done: false, value: 'raz' }
iterator.next(); // { done: false, value: {} }
iterator.next(); // { done: false, value: 'foo' }
iterator.next(); // { done: true, value: undefined }

set.clear(); // undefined
set.size; // 0

Tests

$ npm test

Security contact information

To report a security vulnerability, please use the Tidelift security contact. Tidelift will coordinate the fix and disclosure.


Get professional support for d with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.