This library can be used as a shim for EcmaScript Harmony’s Set class.
For the server:
npm install Set
For the browser:
ender build Set
var Set = require'Set';var alpha = 'a' 'b' 'c' ;console.logalphatoString;alphaadd'd';console.logalphatoString;alpharemove'a' 'b';console.logalphatoString;console.logalphacontains'c';
Create a set from an array or object.
Create a set from a function.
This good for creating infinite sets.
contains is a function that takes one
argument and returns
true if it is in the set and
false otherwise. It works
well together with
set.remove(), but not with
Add one or more elements to the set.
Add all elements from array to the set.
Remove one or more elements from the set.
Check if the set contains
Returns the size of the set.
Returns the elements of the set as an Array.
Serialize the set.
Copyright © 2012 Paul VorbachPermission is hereby granted, free of charge, to any person obtaining a copy ofthis software and associated documentation files (the “Software”), to deal inthe Software without restriction, including without limitation the rights touse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies ofthe Software, and to permit persons to whom the Software is furnished to do so,subject to the following conditions:The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESSFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS ORCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHERIN AN ACTION OF CONTRACT, TORT OR OTHERWISE, OUT OF OR IN CONNECTION WITH THESOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.