examples.js 594 B

1234567891011121314151617181920
  1. var StringSet = require("./stringset");
  2. var ss1 = new StringSet();
  3. ss1.add("greeting");
  4. ss1.add("check");
  5. ss1.add("__proto__");
  6. console.log(ss1.has("greeting")); // true
  7. console.log(ss1.has("__proto__")); // true
  8. ss1.remove("greeting");
  9. console.log(ss1.items()); // [ 'check', '__proto__' ]
  10. console.log(ss1.toString()); // {"check","__proto__"}
  11. var ss2 = new StringSet(["one", "two"]);
  12. console.log(ss2.isEmpty()); // false
  13. console.log(ss2.size()); // 2
  14. var ss3 = ss1.clone();
  15. ss3.merge(ss2);
  16. ss3.addMany(["a", "b"]);
  17. console.log(ss3.toString()); // {"check","one","two","a","b","__proto__"}