Node-Red configuration
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

internmap.js 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // https://github.com/mbostock/internmap/ v2.0.3 Copyright 2021 Mike Bostock
  2. (function (global, factory) {
  3. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
  4. typeof define === 'function' && define.amd ? define(['exports'], factory) :
  5. (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.internmap = {}));
  6. }(this, (function (exports) { 'use strict';
  7. class InternMap extends Map {
  8. constructor(entries, key = keyof) {
  9. super();
  10. Object.defineProperties(this, {_intern: {value: new Map()}, _key: {value: key}});
  11. if (entries != null) for (const [key, value] of entries) this.set(key, value);
  12. }
  13. get(key) {
  14. return super.get(intern_get(this, key));
  15. }
  16. has(key) {
  17. return super.has(intern_get(this, key));
  18. }
  19. set(key, value) {
  20. return super.set(intern_set(this, key), value);
  21. }
  22. delete(key) {
  23. return super.delete(intern_delete(this, key));
  24. }
  25. }
  26. class InternSet extends Set {
  27. constructor(values, key = keyof) {
  28. super();
  29. Object.defineProperties(this, {_intern: {value: new Map()}, _key: {value: key}});
  30. if (values != null) for (const value of values) this.add(value);
  31. }
  32. has(value) {
  33. return super.has(intern_get(this, value));
  34. }
  35. add(value) {
  36. return super.add(intern_set(this, value));
  37. }
  38. delete(value) {
  39. return super.delete(intern_delete(this, value));
  40. }
  41. }
  42. function intern_get({_intern, _key}, value) {
  43. const key = _key(value);
  44. return _intern.has(key) ? _intern.get(key) : value;
  45. }
  46. function intern_set({_intern, _key}, value) {
  47. const key = _key(value);
  48. if (_intern.has(key)) return _intern.get(key);
  49. _intern.set(key, value);
  50. return value;
  51. }
  52. function intern_delete({_intern, _key}, value) {
  53. const key = _key(value);
  54. if (_intern.has(key)) {
  55. value = _intern.get(key);
  56. _intern.delete(key);
  57. }
  58. return value;
  59. }
  60. function keyof(value) {
  61. return value !== null && typeof value === "object" ? value.valueOf() : value;
  62. }
  63. exports.InternMap = InternMap;
  64. exports.InternSet = InternSet;
  65. Object.defineProperty(exports, '__esModule', { value: true });
  66. })));