mol_mutable 0.0.3 → 0.0.5
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/node.d.ts +7 -1
- package/node.deps.json +1 -1
- package/node.esm.js +3 -0
- package/node.esm.js.map +1 -1
- package/node.js +3 -0
- package/node.js.map +1 -1
- package/node.test.js +12 -0
- package/node.test.js.map +1 -1
- package/package.json +6 -2
- package/web.d.ts +7 -1
- package/web.deps.json +1 -1
- package/web.esm.js +3 -0
- package/web.esm.js.map +1 -1
- package/web.js +3 -0
- package/web.js.map +1 -1
- package/web.test.js +9 -0
- package/web.test.js.map +1 -1
package/node.d.ts
CHANGED
|
@@ -13,9 +13,15 @@ declare namespace $ {
|
|
|
13
13
|
export {};
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
declare namespace $ {
|
|
17
|
+
type $mol_type_immutable_deep<Val> = {
|
|
18
|
+
readonly [field in keyof Val]: $mol_type_immutable_deep<Val[field]>;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
16
22
|
declare namespace $ {
|
|
17
23
|
type $mol_mutable_wrapper<Value> = {
|
|
18
|
-
(patch?: (next: Value) => Value): Value
|
|
24
|
+
(patch?: (next: $mol_type_immutable_deep<Value>) => $mol_type_immutable_deep<Value>): $mol_type_immutable_deep<Value>;
|
|
19
25
|
} & {
|
|
20
26
|
[Field in keyof Value]: $mol_mutable_wrapper<Value[Field]>;
|
|
21
27
|
};
|
package/node.deps.json
CHANGED
|
@@ -1 +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/mutable/README.md","mol/mutable/mutable.ts"],"mods":{},"deps_in":{"mol":{"mol/mutable":-9007199254740991},"":{"mol":-9007199254740991}},"deps_out":{"mol/mutable":{"mol":-9007199254740991},"mol":{"":-9007199254740991}},"sloc":{"LICENSE":113,"md":
|
|
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/type/README.md","mol/type/immutable/deep/deep/deep.ts","mol/mutable/README.md","mol/mutable/mutable.ts"],"mods":{},"deps_in":{"mol":{"mol/mutable":-9007199254740991,"mol/type":-9007199254740991},"":{"mol":-9007199254740991},"mol/type/immutable/deep/deep":{"mol/mutable":-2},"mol/type/immutable/deep":{"mol/type/immutable/deep/deep":-9007199254740991},"mol/type/immutable":{"mol/type/immutable/deep":-9007199254740991},"mol/type":{"mol/type/immutable":-9007199254740991}},"deps_out":{"mol/mutable":{"mol":-9007199254740991,"mol/type/immutable/deep/deep":-2},"mol":{"":-9007199254740991},"mol/type/immutable/deep/deep":{"mol/type/immutable/deep":-9007199254740991},"mol/type/immutable/deep":{"mol/type/immutable":-9007199254740991},"mol/type/immutable":{"mol/type":-9007199254740991},"mol/type":{"mol":-9007199254740991}},"sloc":{"LICENSE":113,"md":508,"tree":31,"js":9,"ts":57,"json":92,"lock":959,"CNAME":1,"html":1},"deps":{"mol/mutable":{"..":-9007199254740991,"/mol/mutable/wrapper":-1,"/mol/type/immutable/deep":-2,"/mol/mutable":-1},"mol":{"..":-9007199254740991},"":{},"mol/type/immutable/deep/deep":{"..":-9007199254740991,"/mol/type/immutable/deep":-1},"mol/type/immutable/deep":{"..":-9007199254740991},"mol/type/immutable":{"..":-9007199254740991},"mol/type":{"..":-9007199254740991}}}
|
package/node.esm.js
CHANGED
|
@@ -29,6 +29,9 @@ module.exports = $;
|
|
|
29
29
|
$node[ "../mam.ts" ] = $node[ "../mam.ts" ] = module.exports }.call( {} , {} )
|
|
30
30
|
;
|
|
31
31
|
"use strict";
|
|
32
|
+
//mol/type/immutable/deep/deep/deep.ts
|
|
33
|
+
;
|
|
34
|
+
"use strict";
|
|
32
35
|
var $;
|
|
33
36
|
(function ($) {
|
|
34
37
|
function $mol_mutable(value, update = next => value = next) {
|
package/node.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../mam.jam.js","-","../../../mam.ts","../mol/mutable/mutable.ts"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACZA;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;;
|
|
1
|
+
{"version":3,"sources":["../../../mam.jam.js","-","../../../mam.ts","../../type/immutable/deep/deep/deep.ts","../mol/mutable/mutable.ts"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACZA;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;AACA;AACA;;ACFA,IAAU,CAAC,CA4CV;AA5CD,WAAU,CAAC;IAQV,SAAgB,YAAY,CAC3B,KAAY,EACZ,SAAkC,IAAI,CAAC,EAAE,CAAC,KAAK,GAAG,IAAI;QAGtD,OAAO,IAAI,KAAK,CAAE,YAAY,EAAE;YAE/B,GAAG,EAAE,CAAE,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,OAAO,CAChC,KAAK,CAAE,KAAK,CAAE,EACd,IAAI,CAAC,EAAE;gBACN,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAE,KAAK,CAAE,IAAI,OAAO,KAAK,KAAK,QAAQ;oBAChE,CAAC,CAAC;wBACD,GAAI,KAAK,CAAC,KAAK,CAAE,CAAC,EAAE,MAAM,CAAE,KAAK,CAAE,CAAE;wBACrC,IAAI;wBACJ,GAAI,KAAK,CAAC,KAAK,CAAE,MAAM,CAAE,KAAK,CAAE,GAAG,CAAC,CAAE;qBAC7B;oBACV,CAAC,CAAC,EAAE,GAAI,KAAK,EAAE,CAAE,KAAK,CAAE,EAAE,IAAI,EAAE,CAAA;gBACjC,KAAK,GAAG,MAAM,CAAE,KAAK,CAAE,CAAA;gBACvB,OAAO,KAAK,CAAE,KAAK,CAAE,CAAA;YACtB,CAAC,CACD;YAED,GAAG,EAAE,CAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;gBAC9B,KAAK,GAAG,MAAM,CAAE,IAAI,CAAE,CAAA;gBACtB,OAAO,IAAI,CAAA;YACZ,CAAC;YAED,KAAK,EAAE,CAAE,OAAO,EAAE,IAAI,EAAE,CAAE,KAAK,CAAE,EAAE,EAAE;gBACpC,IAAI,CAAC,KAAK;oBAAG,OAAO,KAAK,CAAA;gBACzB,OAAO,KAAK,GAAG,MAAM,CAAE,KAAK,CAAE,KAAK,CAAE,CAAE,CAAA;YACxC,CAAC;SAED,CAAS,CAAA;IAEX,CAAC;IAlCe,cAAY,eAkC3B,CAAA;AAEF,CAAC,EA5CS,CAAC,KAAD,CAAC,QA4CV;;;AH5CD","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",null,"namespace $ {\n\t\n\texport type $mol_mutable_wrapper< Value > = {\n\t\t( patch?: ( next: $mol_type_immutable_deep< Value > )=> $mol_type_immutable_deep< Value > ): $mol_type_immutable_deep< Value >\n\t} & {\n\t\t[ Field in keyof Value ]: $mol_mutable_wrapper< Value[ Field ] >\n\t}\n\t\n\texport function $mol_mutable< Value >(\n\t\tvalue: Value,\n\t\tupdate: ( next: Value )=> Value = next => value = next,\n\t): $mol_mutable_wrapper< Value > {\n\t\t\n\t\treturn new Proxy( $mol_mutable, {\n\t\t\t\n\t\t\tget: ( mutable, field )=> mutable(\n\t\t\t\tvalue[ field ],\n\t\t\t\tnext => {\n\t\t\t\t\tconst next2 = Array.isArray( value ) && typeof field === 'string'\n\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t... value.slice( 0, Number( field ) ),\n\t\t\t\t\t\t\tnext,\n\t\t\t\t\t\t\t... value.slice( Number( field ) + 1 ),\n\t\t\t\t\t\t] as Value\n\t\t\t\t\t\t: { ... value, [ field ]: next }\n\t\t\t\t\tvalue = update( next2 )\n\t\t\t\t\treturn value[ field ]\n\t\t\t\t},\n\t\t\t),\n\t\t\t\n\t\t\tset: ( mutable, field, next )=> {\n\t\t\t\tvalue = update( next )\n\t\t\t\treturn true\n\t\t\t},\n\t\t\t\n\t\t\tapply: ( mutable, self, [ patch ] )=> {\n\t\t\t\tif( !patch ) return value\n\t\t\t\treturn value = update( patch( value ) )\n\t\t\t},\n\t\t\t\n\t\t} ) as any\n\t\t\n\t}\n\t\n}"]}
|
package/node.js
CHANGED
|
@@ -29,6 +29,9 @@ module.exports = $;
|
|
|
29
29
|
$node[ "../mam.ts" ] = $node[ "../mam.ts" ] = module.exports }.call( {} , {} )
|
|
30
30
|
;
|
|
31
31
|
"use strict";
|
|
32
|
+
//mol/type/immutable/deep/deep/deep.ts
|
|
33
|
+
;
|
|
34
|
+
"use strict";
|
|
32
35
|
var $;
|
|
33
36
|
(function ($) {
|
|
34
37
|
function $mol_mutable(value, update = next => value = next) {
|
package/node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../mam.jam.js","-","../../../mam.ts","../mol/mutable/mutable.ts"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACZA;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;;
|
|
1
|
+
{"version":3,"sources":["../../../mam.jam.js","-","../../../mam.ts","../../type/immutable/deep/deep/deep.ts","../mol/mutable/mutable.ts"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACZA;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;AACA;AACA;;ACFA,IAAU,CAAC,CA4CV;AA5CD,WAAU,CAAC;IAQV,SAAgB,YAAY,CAC3B,KAAY,EACZ,SAAkC,IAAI,CAAC,EAAE,CAAC,KAAK,GAAG,IAAI;QAGtD,OAAO,IAAI,KAAK,CAAE,YAAY,EAAE;YAE/B,GAAG,EAAE,CAAE,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,OAAO,CAChC,KAAK,CAAE,KAAK,CAAE,EACd,IAAI,CAAC,EAAE;gBACN,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAE,KAAK,CAAE,IAAI,OAAO,KAAK,KAAK,QAAQ;oBAChE,CAAC,CAAC;wBACD,GAAI,KAAK,CAAC,KAAK,CAAE,CAAC,EAAE,MAAM,CAAE,KAAK,CAAE,CAAE;wBACrC,IAAI;wBACJ,GAAI,KAAK,CAAC,KAAK,CAAE,MAAM,CAAE,KAAK,CAAE,GAAG,CAAC,CAAE;qBAC7B;oBACV,CAAC,CAAC,EAAE,GAAI,KAAK,EAAE,CAAE,KAAK,CAAE,EAAE,IAAI,EAAE,CAAA;gBACjC,KAAK,GAAG,MAAM,CAAE,KAAK,CAAE,CAAA;gBACvB,OAAO,KAAK,CAAE,KAAK,CAAE,CAAA;YACtB,CAAC,CACD;YAED,GAAG,EAAE,CAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;gBAC9B,KAAK,GAAG,MAAM,CAAE,IAAI,CAAE,CAAA;gBACtB,OAAO,IAAI,CAAA;YACZ,CAAC;YAED,KAAK,EAAE,CAAE,OAAO,EAAE,IAAI,EAAE,CAAE,KAAK,CAAE,EAAE,EAAE;gBACpC,IAAI,CAAC,KAAK;oBAAG,OAAO,KAAK,CAAA;gBACzB,OAAO,KAAK,GAAG,MAAM,CAAE,KAAK,CAAE,KAAK,CAAE,CAAE,CAAA;YACxC,CAAC;SAED,CAAS,CAAA;IAEX,CAAC;IAlCe,cAAY,eAkC3B,CAAA;AAEF,CAAC,EA5CS,CAAC,KAAD,CAAC,QA4CV;;","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",null,"namespace $ {\n\t\n\texport type $mol_mutable_wrapper< Value > = {\n\t\t( patch?: ( next: $mol_type_immutable_deep< Value > )=> $mol_type_immutable_deep< Value > ): $mol_type_immutable_deep< Value >\n\t} & {\n\t\t[ Field in keyof Value ]: $mol_mutable_wrapper< Value[ Field ] >\n\t}\n\t\n\texport function $mol_mutable< Value >(\n\t\tvalue: Value,\n\t\tupdate: ( next: Value )=> Value = next => value = next,\n\t): $mol_mutable_wrapper< Value > {\n\t\t\n\t\treturn new Proxy( $mol_mutable, {\n\t\t\t\n\t\t\tget: ( mutable, field )=> mutable(\n\t\t\t\tvalue[ field ],\n\t\t\t\tnext => {\n\t\t\t\t\tconst next2 = Array.isArray( value ) && typeof field === 'string'\n\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t... value.slice( 0, Number( field ) ),\n\t\t\t\t\t\t\tnext,\n\t\t\t\t\t\t\t... value.slice( Number( field ) + 1 ),\n\t\t\t\t\t\t] as Value\n\t\t\t\t\t\t: { ... value, [ field ]: next }\n\t\t\t\t\tvalue = update( next2 )\n\t\t\t\t\treturn value[ field ]\n\t\t\t\t},\n\t\t\t),\n\t\t\t\n\t\t\tset: ( mutable, field, next )=> {\n\t\t\t\tvalue = update( next )\n\t\t\t\treturn true\n\t\t\t},\n\t\t\t\n\t\t\tapply: ( mutable, self, [ patch ] )=> {\n\t\t\t\tif( !patch ) return value\n\t\t\t\treturn value = update( patch( value ) )\n\t\t\t},\n\t\t\t\n\t\t} ) as any\n\t\t\n\t}\n\t\n}"]}
|
package/node.test.js
CHANGED
|
@@ -21,6 +21,9 @@ module.exports = $;
|
|
|
21
21
|
//mam.ts
|
|
22
22
|
;
|
|
23
23
|
"use strict";
|
|
24
|
+
//mol/type/immutable/deep/deep/deep.ts
|
|
25
|
+
;
|
|
26
|
+
"use strict";
|
|
24
27
|
var $;
|
|
25
28
|
(function ($) {
|
|
26
29
|
function $mol_mutable(value, update = next => value = next) {
|
|
@@ -1025,6 +1028,9 @@ var $;
|
|
|
1025
1028
|
//mol/assert/assert.ts
|
|
1026
1029
|
;
|
|
1027
1030
|
"use strict";
|
|
1031
|
+
//mol/type/immutable/deep/deep/deep.test.ts
|
|
1032
|
+
;
|
|
1033
|
+
"use strict";
|
|
1028
1034
|
var $;
|
|
1029
1035
|
(function ($) {
|
|
1030
1036
|
$.$mol_ambient_ref = Symbol('$mol_ambient_ref');
|
|
@@ -1691,6 +1697,12 @@ var $;
|
|
|
1691
1697
|
$mol_assert_unique(val[1], mut()[1]);
|
|
1692
1698
|
$mol_assert_like(mut()[1], [-2]);
|
|
1693
1699
|
},
|
|
1700
|
+
'Array insert'() {
|
|
1701
|
+
const val = [[1, 2, 3, 4]];
|
|
1702
|
+
const mut = $mol_mutable(val);
|
|
1703
|
+
$mol_assert_like(mut[0](a => [...a.slice(0, 2), 7, ...a.slice(2)]), [1, 2, 7, 3, 4]);
|
|
1704
|
+
$mol_assert_like(mut(), [[1, 2, 7, 3, 4]]);
|
|
1705
|
+
},
|
|
1694
1706
|
'Deep objects'() {
|
|
1695
1707
|
const val = { a: { x: 1 }, b: { y: 2 }, c: { z: 3 } };
|
|
1696
1708
|
const mut = $mol_mutable(val);
|