stringset.js
A fast and robust stringset implementation that can hold any string items,
including __proto__
, with minimal overhead compared to a plain object.
Works in node and browsers.
The API is created to be as close to the ES6 Set API as possible. Prefer
ss.remove("key")
for deleting a key. ES6 Set uses set.delete("key")
instead and for that reason ss['delete']("key")
is available as a
stringset alias as well. Never do ss.delete("key")
unless you're
certain to be in the land of ES5 or later.
Examples
Available in examples.js
var StringSet = ; var ss1 = ;ss1;ss1;ss1;console; // trueconsole; // truess1;console; // [ 'check', '__proto__' ]console; // {"check","__proto__"} var ss2 = "one" "two";console; // falseconsole; // 2 var ss3 = ss1;ss3;ss3;console; // {"check","one","two","a","b","__proto__"}
Installation
Node
Install using npm
npm install stringset
var StringSet = ;
Browser
Clone the repo and include it in a script tag
git clone https://github.com/olov/stringset.git