mol_key 0.0.1499 → 0.0.1500

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -18,6 +18,6 @@ npm install mol_key
18
18
  ```ts
19
19
  import { $mol_key as key } from 'mol_key'
20
20
 
21
- // {"regexp":"/foo/","elems":["04Y7LLST","XMSPWAKY"]}
21
+ // {"regexp":/foo/,"elems":[#FEB7B7JN,#XO9QW5P0]}
22
22
  key({ regexp: /foo/, elems: [ document.head, document.body ] })
23
23
  ```
package/node.d.ts CHANGED
@@ -15,12 +15,8 @@ declare namespace $ {
15
15
  }
16
16
 
17
17
  declare namespace $ {
18
- function $mol_guid(length?: number, exists?: (id: string) => boolean): string;
19
- }
20
-
21
- declare namespace $ {
18
+ const $mol_key_handle: unique symbol;
22
19
  const $mol_key_store: WeakMap<object, string>;
23
- function $mol_key<Value>(value: Value): string;
24
20
  }
25
21
 
26
22
  export = $;
package/node.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../mam.d.ts","../../guid/guid.d.ts","../key.d.ts"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACfA;AACA;AACA;AACA;ACHA;AACA;AACA;AACA;AACA","sourcesContent":[null,null,null]}
1
+ {"version":3,"sources":["../../../mam.d.ts","../key.d.ts"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACfA;AACA;AACA;AACA;AACA","sourcesContent":[null,null]}
package/node.deps.json CHANGED
@@ -1 +1 @@
1
- {"files":["mam.ts","LICENSE","README.md","mam.jam.js","tsfmt.json","package.json","tsconfig.json","lang.lang.tree","meta.lang.tree","sandbox.config.json","mol/CNAME","mol/LICENSE","mol/readme.md","mol/mol.meta.tree","mol/CONTRIBUTING.md","mol/CODE_OF_CONDUCT.md","mol/guid/guid.ts","mol/key/key.ts","mol/key/README.md"],"mods":{},"deps_in":{"mol":{"mol/key":-999,"mol/guid":-999},"":{"mol":-999},"mol/guid":{"mol/key":-3}},"deps_out":{"mol/key":{"mol":-999,"mol/guid":-3},"mol":{"":-999},"mol/guid":{"mol":-999}},"sloc":{"ts":56,"LICENSE":113,"md":481,"js":9,"json":82,"tree":41,"CNAME":1},"deps":{"mol/key":{"..":-999,"/mol/key/store":-1,"/mol/key":-1,"/mol/key/store/get":-3,"/mol/guid":-3,"/mol/key/store/set":-3},"mol":{"..":-999},"":{},"mol/guid":{"..":-999,"/mol/guid":-1}}}
1
+ {"files":["mam.ts","LICENSE","README.md","mam.jam.js","tsfmt.json","package.json","tsconfig.json","lang.lang.tree","meta.lang.tree","sandbox.config.json","mol/CNAME","mol/LICENSE","mol/readme.md","mol/mol.meta.tree","mol/CONTRIBUTING.md","mol/CODE_OF_CONDUCT.md","mol/key/key.ts","mol/key/README.md"],"mods":{},"deps_in":{"mol":{"mol/key":-999},"":{"mol":-999}},"deps_out":{"mol/key":{"mol":-999},"mol":{"":-999}},"sloc":{"ts":17,"LICENSE":113,"md":481,"js":9,"json":82,"tree":41,"CNAME":1},"deps":{"mol/key":{"..":-999,"/mol/key/handle":-1,"/mol/key/store":-1},"mol":{"..":-999},"":{}}}
package/node.js CHANGED
@@ -32,63 +32,8 @@ $.$$ = $
32
32
  "use strict";
33
33
  var $;
34
34
  (function ($) {
35
- function $mol_guid(length = 8, exists = () => false) {
36
- for (;;) {
37
- let id = Math.random().toString(36).substring(2, length + 2).toUpperCase();
38
- if (exists(id))
39
- continue;
40
- return id;
41
- }
42
- }
43
- $.$mol_guid = $mol_guid;
44
- })($ || ($ = {}));
45
-
46
- ;
47
- "use strict";
48
- var $;
49
- (function ($) {
35
+ $.$mol_key_handle = Symbol.for('$mol_key_handle');
50
36
  $.$mol_key_store = new WeakMap();
51
- const TypedArray = Object.getPrototypeOf(Uint8Array);
52
- function $mol_key(value) {
53
- if (typeof value === 'bigint')
54
- return value.toString() + 'n';
55
- if (typeof value === 'symbol')
56
- return value.description;
57
- if (!value)
58
- return JSON.stringify(value);
59
- if (typeof value !== 'object' && typeof value !== 'function')
60
- return JSON.stringify(value);
61
- return JSON.stringify(value, (field, value) => {
62
- if (typeof value === 'bigint')
63
- return value.toString() + 'n';
64
- if (typeof value === 'symbol')
65
- return value.description;
66
- if (!value)
67
- return value;
68
- if (typeof value !== 'object' && typeof value !== 'function')
69
- return value;
70
- if (Array.isArray(value))
71
- return value;
72
- const proto = Reflect.getPrototypeOf(value);
73
- if (!proto)
74
- return value;
75
- if (Reflect.getPrototypeOf(proto) === null)
76
- return value;
77
- if ('toJSON' in value)
78
- return value;
79
- if (value instanceof RegExp)
80
- return value.toString();
81
- if (value instanceof TypedArray)
82
- return [...value];
83
- let key = $.$mol_key_store.get(value);
84
- if (key)
85
- return key;
86
- key = $mol_guid();
87
- $.$mol_key_store.set(value, key);
88
- return key;
89
- });
90
- }
91
- $.$mol_key = $mol_key;
92
37
  })($ || ($ = {}));
93
38
 
94
39
 
package/node.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["-","../../../mam.ts","../../../mol/guid/guid.ts","../../../mol/key/key.ts"],"names":[],"mappings":";;;AAAA;AACA;AACA;AACA;;ACHA,KAAK,CAAC,eAAe,GAAG,EAAE,CAAC;AAK3B,IAAU,CAAC,CAQV;AARD,WAAU,CAAC;AAQX,CAAC,EARS,CAAC,KAAD,CAAC,QAQV;AAED,MAAM,CAAC,OAAO,GAAG,CAAC,CAAA;;;ADflB;AACA;AACA;;;;;;;;;;;;;;;AEFA,IAAU,CAAC,CAkBV;AAlBD,WAAU,CAAC;IAGV,SAAgB,SAAS,CACxB,MAAM,GAAG,CAAC,EACV,SAAmC,GAAE,EAAE,CAAC,KAAK;QAG7C,SAAQ,CAAC;YAER,IAAI,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAE,EAAE,CAAE,CAAC,S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,CAAE,KAAK,CAAE;gBAAG,OAAO,KAAK,CAAA;YAEzC,MAAM,KAAK,GAAG,OAAO,CAAC,cAAc,CAAE,KAAK,CAAE,CAAA;YAC7C,IAAI,CAAC,KAAK;gBAAG,OAAO,KAAK,CAAA;YACzB,IAAI,OAAO,CAAC,cAAc,CAAE,KAAK,CAAE,KAAK,IAAI;gBAAG,OAAO,KAAK,CAAA;YAE3D,IAAI,QAAQ,IAAI,KAAK;gBAAG,OAAO,KAAK,CAAA;YACpC,IAAI,KAAK,YAAY,MAAM;gBAAG,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAA;YAErD,IAAI,KAAK,YAAY,UAAU;gBAAG,OAAO,CAAE,GAAI,KAAY,CAAE,CAAA;YAE7D,IAAI,GAAG,GAAG,EAAA,cAAc,CAAC,GAAG,CAAE,KAAK,CAAE,CAAA;YACrC,IAAI,GAAG;gBAAG,OAAO,GAAG,CAAA;YAEpB,GAAG,GAAG,SAAS,EAAE,CAAA;YACjB,EAAA,cAAc,CAAC,GAAG,CAAE,KAAK,EAAE,GAAG,CAAE,CAAA;YAEhC,OAAO,GAAG,CAAA;QACX,CAAC,CAAE,CAAA;IAEJ,CAAC;IAjCe,UAAQ,WAiCvB,CAAA;AAEF,CAAC,EA1CS,CAAC,KAAD,CAAC,QA0CV;;","sourcesContent":[null,"Error.stackTraceLimit = 50;\n\ndeclare let _$_: { new(): {} } & typeof globalThis\ndeclare class $ extends _$_ {}\n\nnamespace $ {\n\texport type $ = typeof $$\n\texport declare class $$ extends $ {\n\t\tstatic $: $\n\t}\n\tnamespace $$ {\n\t\texport type $$ = $\n\t}\n}\n\nmodule.exports = $\n","namespace $ {\n\n\t/** Generates unique identifier. */\n\texport function $mol_guid(\n\t\tlength = 8,\n\t\texists: ( id: string )=> boolean = ()=> false,\n\t) {\n\n\t\tfor(;;) {\n\n\t\t\tlet id = Math.random().toString( 36 ).substring( 2, length + 2 ).toUpperCase()\n\t\t\tif( exists( id ) ) continue\n\t\t\t\n\t\t\treturn id\n\t\t}\n\n\t}\n\n}\n","namespace $ {\n\t\n\texport const $mol_key_store = new WeakMap< object, string >()\n\t\n\tconst TypedArray = Object.getPrototypeOf( Uint8Array )\n\n\t/** Returns string key for any value. */\n\texport function $mol_key< Value >( value : Value ) : string {\n\t\t\n\t\tif( typeof value === 'bigint' ) return value.toString() + 'n'\n\t\tif( typeof value === 'symbol' ) return value.description!\n\t\tif( !value ) return JSON.stringify( value )\n\t\tif( typeof value !== 'object' && typeof value !== 'function' ) return JSON.stringify( value )\n\t\t\n\t\treturn JSON.stringify( value, ( field, value )=> {\n\t\t\t\n\t\t\tif( typeof value === 'bigint' ) return value.toString() + 'n'\n\t\t\tif( typeof value === 'symbol' ) return value.description\n\t\t\tif( !value ) return value\n\t\t\tif( typeof value !== 'object' && typeof value !== 'function' ) return value\n\t\t\tif( Array.isArray( value ) ) return value\n\t\t\t\n\t\t\tconst proto = Reflect.getPrototypeOf( value )\n\t\t\tif( !proto ) return value\n\t\t\tif( Reflect.getPrototypeOf( proto ) === null ) return value\n\t\t\t\n\t\t\tif( 'toJSON' in value ) return value\n\t\t\tif( value instanceof RegExp ) return value.toString()\n\t\t\t// if( value instanceof DataView ) return [ ... new Uint8Array( value.buffer ) ]\n\t\t\tif( value instanceof TypedArray ) return [ ... value as any ]\n\t\t\t\n\t\t\tlet key = $mol_key_store.get( value )\n\t\t\tif( key ) return key\n\t\t\t\n\t\t\tkey = $mol_guid()\n\t\t\t$mol_key_store.set( value, key )\n\t\t\t\n\t\t\treturn key\n\t\t} )\n\n\t}\n\t\n}\n"]}
1
+ {"version":3,"sources":["-","../../../mam.ts","../../../mol/key/key.ts"],"names":[],"mappings":";;;AAAA;AACA;AACA;AACA;;ACHA,KAAK,CAAC,eAAe,GAAG,EAAE,CAAC;AAK3B,IAAU,CAAC,CAQV;AARD,WAAU,CAAC;AAQX,CAAC,EARS,CAAC,KAAD,CAAC,QAQV;AAED,MAAM,CAAC,OAAO,GAAG,CAAC,CAAA;;;ADflB;AACA;AACA;;;;;;;;;;;;;;;AEFA,IAAU,CAAC,CAKV;AALD,WAAU,CAAC;IAEG,iBAAe,GAAG,MAAM,CAAC,GAAG,CAAE,iBAAiB,CAAE,CAAA;IACjD,gBAAc,GAAG,IAAI,OAAO,EAAoB,CAAA;AAE9D,CAAC,EALS,CAAC,KAAD,CAAC,QAKV;;","sourcesContent":[null,"Error.stackTraceLimit = 50;\n\ndeclare let _$_: { new(): {} } & typeof globalThis\ndeclare class $ extends _$_ {}\n\nnamespace $ {\n\texport type $ = typeof $$\n\texport declare class $$ extends $ {\n\t\tstatic $: $\n\t}\n\tnamespace $$ {\n\t\texport type $$ = $\n\t}\n}\n\nmodule.exports = $\n","namespace $ {\n\t\n\texport const $mol_key_handle = Symbol.for( '$mol_key_handle' )\n\texport const $mol_key_store = new WeakMap< object, string >()\n\t\n}\n"]}
package/node.mjs CHANGED
@@ -32,63 +32,8 @@ $.$$ = $
32
32
  "use strict";
33
33
  var $;
34
34
  (function ($) {
35
- function $mol_guid(length = 8, exists = () => false) {
36
- for (;;) {
37
- let id = Math.random().toString(36).substring(2, length + 2).toUpperCase();
38
- if (exists(id))
39
- continue;
40
- return id;
41
- }
42
- }
43
- $.$mol_guid = $mol_guid;
44
- })($ || ($ = {}));
45
-
46
- ;
47
- "use strict";
48
- var $;
49
- (function ($) {
35
+ $.$mol_key_handle = Symbol.for('$mol_key_handle');
50
36
  $.$mol_key_store = new WeakMap();
51
- const TypedArray = Object.getPrototypeOf(Uint8Array);
52
- function $mol_key(value) {
53
- if (typeof value === 'bigint')
54
- return value.toString() + 'n';
55
- if (typeof value === 'symbol')
56
- return value.description;
57
- if (!value)
58
- return JSON.stringify(value);
59
- if (typeof value !== 'object' && typeof value !== 'function')
60
- return JSON.stringify(value);
61
- return JSON.stringify(value, (field, value) => {
62
- if (typeof value === 'bigint')
63
- return value.toString() + 'n';
64
- if (typeof value === 'symbol')
65
- return value.description;
66
- if (!value)
67
- return value;
68
- if (typeof value !== 'object' && typeof value !== 'function')
69
- return value;
70
- if (Array.isArray(value))
71
- return value;
72
- const proto = Reflect.getPrototypeOf(value);
73
- if (!proto)
74
- return value;
75
- if (Reflect.getPrototypeOf(proto) === null)
76
- return value;
77
- if ('toJSON' in value)
78
- return value;
79
- if (value instanceof RegExp)
80
- return value.toString();
81
- if (value instanceof TypedArray)
82
- return [...value];
83
- let key = $.$mol_key_store.get(value);
84
- if (key)
85
- return key;
86
- key = $mol_guid();
87
- $.$mol_key_store.set(value, key);
88
- return key;
89
- });
90
- }
91
- $.$mol_key = $mol_key;
92
37
  })($ || ($ = {}));
93
38
 
94
39