mol_key 0.0.1

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/.nojekyll ADDED
File without changes
package/README.md ADDED
@@ -0,0 +1,8 @@
1
+ # $mol_key
2
+
3
+ Returns string key for any value.
4
+
5
+ - Primitives are returned as JSON (`true`, `12.34`).
6
+ - POJO's are returned as JSON with recursive `$mol_key` applying (`[123,{"foo":"A1B2C3D4"}]`, `{"foo":[123,"A1B2C3D4"]}"`).
7
+ - Result of `toJSON` calling is returned for objects with this method.
8
+ - Guid generated/reused for other objects (`"A1B2C3D4"`).
package/node.audit.js ADDED
@@ -0,0 +1 @@
1
+ console.info("Audit passed")
package/node.d.ts ADDED
@@ -0,0 +1,25 @@
1
+ declare let _$_: {
2
+ new (): {};
3
+ } & typeof globalThis;
4
+ declare class $ extends _$_ {
5
+ }
6
+ declare namespace $ {
7
+ export type $ = typeof $$;
8
+ export class $$ extends $ {
9
+ }
10
+ namespace $$ {
11
+ type $$ = $;
12
+ }
13
+ export {};
14
+ }
15
+
16
+ declare namespace $ {
17
+ function $mol_guid(length?: number, exists?: (id: string) => boolean): string;
18
+ }
19
+
20
+ declare namespace $ {
21
+ const $mol_key_store: WeakMap<object, string>;
22
+ function $mol_key<Value>(value: Value): string;
23
+ }
24
+
25
+ export = $;
package/node.deps.json ADDED
@@ -0,0 +1 @@
1
+ {"files":["LICENSE","README.md","lang.lang.tree","mam.jam.js","mam.ts","package.json","sandbox.config.json","tsconfig.json","tsfmt.json","yarn.lock","mol/CNAME","mol/CODE_OF_CONDUCT.md","mol/CONTRIBUTING.md","mol/LICENSE","mol/index.html","mol/mol.meta.tree","mol/readme.md","mol/guid/guid.ts","mol/key/README.md","mol/key/key.ts"],"mods":{},"deps_in":{"mol":{"mol/key":-9007199254740991,"mol/guid":-9007199254740991},"":{"mol":-9007199254740991},"mol/guid":{"mol/key":-3}},"deps_out":{"mol/key":{"mol":-9007199254740991,"mol/guid":-3},"mol":{"":-9007199254740991},"mol/guid":{"mol":-9007199254740991}},"sloc":{"LICENSE":113,"md":505,"tree":31,"js":10,"ts":46,"json":85,"lock":939,"CNAME":1,"html":1},"deps":{"mol/key":{"..":-9007199254740991,"/mol/key/store":-1,"/mol/key":-1,"/mol/key/store/get":-3,"/mol/guid":-3,"/mol/key/store/set":-3},"mol":{"..":-9007199254740991},"":{},"mol/guid":{"..":-9007199254740991,"/mol/guid":-1}}}
package/node.esm.js ADDED
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ var exports = void 0;
3
+ "use strict"
4
+
5
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
6
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
7
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
8
+ else for (var i = decorators.length - 1; i >= 0; i--) if ((d = decorators[i])) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
9
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
10
+ };
11
+
12
+ var globalThis = globalThis || ( typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : this )
13
+ var $ = ( typeof module === 'object' ) ? ( module['export'+'s'] = globalThis ) : globalThis
14
+ $.$$ = $
15
+
16
+ ;
17
+
18
+ var $node = $node || {}
19
+ void function( module ) { var exports = module.exports = this; function require( id ) { return $node[ id.replace( /^.\// , "../" ) ] };
20
+ ;
21
+ "use strict";
22
+ Error.stackTraceLimit = 50;
23
+ var $;
24
+ (function ($) {
25
+ })($ || ($ = {}));
26
+ module.exports = $;
27
+ //mam.ts
28
+ ;
29
+
30
+ $node[ "../mam.ts" ] = $node[ "../mam.ts" ] = module.exports }.call( {} , {} )
31
+ ;
32
+ "use strict";
33
+ var $;
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
+ //mol/guid/guid.ts
46
+ ;
47
+ "use strict";
48
+ var $;
49
+ (function ($) {
50
+ $.$mol_key_store = new WeakMap();
51
+ function $mol_key(value) {
52
+ if (!value)
53
+ return JSON.stringify(value);
54
+ if (typeof value !== 'object' && typeof value !== 'function')
55
+ return JSON.stringify(value);
56
+ return JSON.stringify(value, (field, value) => {
57
+ if (!value)
58
+ return value;
59
+ if (typeof value !== 'object' && typeof value !== 'function')
60
+ return value;
61
+ if (Array.isArray(value))
62
+ return value;
63
+ const proto = Reflect.getPrototypeOf(value);
64
+ if (!proto)
65
+ return value;
66
+ if (Reflect.getPrototypeOf(proto) === null)
67
+ return value;
68
+ if ('toJSON' in value)
69
+ return value;
70
+ if (value instanceof RegExp)
71
+ return value.toString();
72
+ let key = $.$mol_key_store.get(value);
73
+ if (key)
74
+ return key;
75
+ key = $mol_guid();
76
+ $.$mol_key_store.set(value, key);
77
+ return key;
78
+ });
79
+ }
80
+ $.$mol_key = $mol_key;
81
+ })($ || ($ = {}));
82
+ //mol/key/key.ts
83
+ ;
84
+ export default $
85
+ //# sourceMappingURL=node.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../mam.jam.js","-","../../../mam.ts","../../guid/mol/guid/guid.ts","../mol/key/key.ts"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACbA;AACA;AACA;AACA;;ACHA,KAAK,CAAC,eAAe,GAAG,EAAE,CAAC;AAK3B,IAAU,CAAC,CAMV;AAND,WAAU,CAAC;AAMX,CAAC,EANS,CAAC,KAAD,CAAC,QAMV;AAED,MAAM,CAAC,OAAO,GAAG,CAAC,CAAA;;;ADblB;AACA;AACA;;AEFA,IAAU,CAAC,CAkBV;AAlBD,WAAU,CAAC;IAGV,SAAg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,CAAA;YAE3D,IAAI,QAAQ,IAAI,KAAK;gBAAG,OAAO,KAAK,CAAA;YACpC,IAAI,KAAK,YAAY,MAAM;gBAAG,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAA;YAErD,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;IA3Be,UAAQ,WA2BvB,CAAA;AAEF,CAAC,EAjCS,CAAC,KAAD,CAAC,QAiCV;;;AHjCD","file":"node.esm.js","sourcesContent":[null,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\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\n\texport function $mol_key< Value >( value : Value ) : string {\n\t\t\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( !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\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"]}
package/node.js ADDED
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ var exports = void 0;
3
+ "use strict"
4
+
5
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
6
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
7
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
8
+ else for (var i = decorators.length - 1; i >= 0; i--) if ((d = decorators[i])) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
9
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
10
+ };
11
+
12
+ var globalThis = globalThis || ( typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : this )
13
+ var $ = ( typeof module === 'object' ) ? ( module['export'+'s'] = globalThis ) : globalThis
14
+ $.$$ = $
15
+
16
+ ;
17
+
18
+ var $node = $node || {}
19
+ void function( module ) { var exports = module.exports = this; function require( id ) { return $node[ id.replace( /^.\// , "../" ) ] };
20
+ ;
21
+ "use strict";
22
+ Error.stackTraceLimit = 50;
23
+ var $;
24
+ (function ($) {
25
+ })($ || ($ = {}));
26
+ module.exports = $;
27
+ //mam.ts
28
+ ;
29
+
30
+ $node[ "../mam.ts" ] = $node[ "../mam.ts" ] = module.exports }.call( {} , {} )
31
+ ;
32
+ "use strict";
33
+ var $;
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
+ //mol/guid/guid.ts
46
+ ;
47
+ "use strict";
48
+ var $;
49
+ (function ($) {
50
+ $.$mol_key_store = new WeakMap();
51
+ function $mol_key(value) {
52
+ if (!value)
53
+ return JSON.stringify(value);
54
+ if (typeof value !== 'object' && typeof value !== 'function')
55
+ return JSON.stringify(value);
56
+ return JSON.stringify(value, (field, value) => {
57
+ if (!value)
58
+ return value;
59
+ if (typeof value !== 'object' && typeof value !== 'function')
60
+ return value;
61
+ if (Array.isArray(value))
62
+ return value;
63
+ const proto = Reflect.getPrototypeOf(value);
64
+ if (!proto)
65
+ return value;
66
+ if (Reflect.getPrototypeOf(proto) === null)
67
+ return value;
68
+ if ('toJSON' in value)
69
+ return value;
70
+ if (value instanceof RegExp)
71
+ return value.toString();
72
+ let key = $.$mol_key_store.get(value);
73
+ if (key)
74
+ return key;
75
+ key = $mol_guid();
76
+ $.$mol_key_store.set(value, key);
77
+ return key;
78
+ });
79
+ }
80
+ $.$mol_key = $mol_key;
81
+ })($ || ($ = {}));
82
+ //mol/key/key.ts
83
+
84
+ //# sourceMappingURL=node.js.map
package/node.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../mam.jam.js","-","../../../mam.ts","../../guid/mol/guid/guid.ts","../mol/key/key.ts"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACbA;AACA;AACA;AACA;;ACHA,KAAK,CAAC,eAAe,GAAG,EAAE,CAAC;AAK3B,IAAU,CAAC,CAMV;AAND,WAAU,CAAC;AAMX,CAAC,EANS,CAAC,KAAD,CAAC,QAMV;AAED,MAAM,CAAC,OAAO,GAA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AAK,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,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;IA3Be,UAAQ,WA2BvB,CAAA;AAEF,CAAC,EAjCS,CAAC,KAAD,CAAC,QAiCV;;","file":"node.js","sourcesContent":[null,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\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\n\texport function $mol_key< Value >( value : Value ) : string {\n\t\t\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( !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\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"]}