map-transform 0.3.12 → 0.4.0-alpha.11
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/LICENSE +1 -1
- package/README.md +641 -98
- package/dist/functions/compare.d.ts +7 -5
- package/dist/functions/compare.js +27 -16
- package/dist/functions/compare.js.map +1 -1
- package/dist/functions/explode.d.ts +7 -0
- package/dist/functions/explode.js +53 -0
- package/dist/functions/explode.js.map +1 -0
- package/dist/functions/get.d.ts +2 -2
- package/dist/functions/get.js +4 -2
- package/dist/functions/get.js.map +1 -1
- package/dist/functions/index.d.ts +16 -5
- package/dist/functions/index.js +17 -6
- package/dist/functions/index.js.map +1 -1
- package/dist/functions/join.d.ts +2 -2
- package/dist/functions/join.js +1 -1
- package/dist/functions/join.js.map +1 -1
- package/dist/functions/joinSplit.d.ts +8 -0
- package/dist/functions/joinSplit.js +32 -0
- package/dist/functions/joinSplit.js.map +1 -0
- package/dist/functions/logical.d.ts +7 -0
- package/dist/functions/logical.js +24 -0
- package/dist/functions/logical.js.map +1 -0
- package/dist/functions/map.d.ts +8 -0
- package/dist/functions/map.js +43 -0
- package/dist/functions/map.js.map +1 -0
- package/dist/functions/not.d.ts +2 -2
- package/dist/functions/not.js.map +1 -1
- package/dist/functions/sort.d.ts +7 -0
- package/dist/functions/sort.js +33 -0
- package/dist/functions/sort.js.map +1 -0
- package/dist/functions/template.d.ts +7 -0
- package/dist/functions/template.js +29 -0
- package/dist/functions/template.js.map +1 -0
- package/dist/functions/validate.d.ts +2 -2
- package/dist/functions/validate.js +3 -3
- package/dist/functions/validate.js.map +1 -1
- package/dist/functions/value.d.ts +4 -0
- package/dist/functions/value.js +20 -0
- package/dist/functions/value.js.map +1 -0
- package/dist/index.d.ts +8 -8
- package/dist/index.js +28 -13
- package/dist/index.js.map +1 -1
- package/dist/operations/alt.js +4 -9
- package/dist/operations/alt.js.map +1 -1
- package/dist/operations/apply.d.ts +2 -0
- package/dist/operations/apply.js +15 -0
- package/dist/operations/apply.js.map +1 -0
- package/dist/operations/concat.js +5 -5
- package/dist/operations/concat.js.map +1 -1
- package/dist/operations/directionals.d.ts +1 -1
- package/dist/operations/directionals.js +5 -5
- package/dist/operations/directionals.js.map +1 -1
- package/dist/operations/filter.d.ts +2 -2
- package/dist/operations/filter.js +10 -5
- package/dist/operations/filter.js.map +1 -1
- package/dist/operations/fixed.d.ts +2 -2
- package/dist/operations/fixed.js +5 -1
- package/dist/operations/fixed.js.map +1 -1
- package/dist/operations/getSet.d.ts +2 -1
- package/dist/operations/getSet.js +24 -25
- package/dist/operations/getSet.js.map +1 -1
- package/dist/operations/ifelse.d.ts +2 -0
- package/dist/operations/ifelse.js +20 -0
- package/dist/operations/ifelse.js.map +1 -0
- package/dist/operations/iterate.d.ts +2 -0
- package/dist/operations/iterate.js +21 -0
- package/dist/operations/iterate.js.map +1 -0
- package/dist/operations/lookup.js +3 -3
- package/dist/operations/lookup.js.map +1 -1
- package/dist/operations/merge.d.ts +3 -0
- package/dist/operations/merge.js +43 -0
- package/dist/operations/merge.js.map +1 -0
- package/dist/operations/modify.d.ts +2 -0
- package/dist/operations/modify.js +18 -0
- package/dist/operations/modify.js.map +1 -0
- package/dist/operations/mutate.js +84 -7
- package/dist/operations/mutate.js.map +1 -1
- package/dist/operations/pipe.js +19 -5
- package/dist/operations/pipe.js.map +1 -1
- package/dist/operations/plug.js +1 -1
- package/dist/operations/plug.js.map +1 -1
- package/dist/operations/root.js +3 -2
- package/dist/operations/root.js.map +1 -1
- package/dist/operations/transform.js +4 -4
- package/dist/operations/transform.js.map +1 -1
- package/dist/operations/value.d.ts +2 -2
- package/dist/operations/value.js +5 -1
- package/dist/operations/value.js.map +1 -1
- package/dist/types.d.ts +52 -23
- package/dist/utils/array.d.ts +2 -0
- package/dist/utils/array.js +12 -0
- package/dist/utils/array.js.map +1 -0
- package/dist/utils/definitionHelpers.d.ts +7 -8
- package/dist/utils/definitionHelpers.js +80 -47
- package/dist/utils/definitionHelpers.js.map +1 -1
- package/dist/utils/functional.d.ts +3 -0
- package/dist/utils/functional.js +10 -0
- package/dist/utils/functional.js.map +1 -0
- package/dist/utils/is.d.ts +3 -0
- package/dist/utils/is.js +10 -0
- package/dist/utils/is.js.map +1 -0
- package/dist/utils/pathGetter.d.ts +5 -3
- package/dist/utils/pathGetter.js +21 -11
- package/dist/utils/pathGetter.js.map +1 -1
- package/dist/utils/pathSetter.d.ts +5 -4
- package/dist/utils/pathSetter.js +36 -44
- package/dist/utils/pathSetter.js.map +1 -1
- package/dist/utils/stateHelpers.d.ts +8 -36
- package/dist/utils/stateHelpers.js +26 -11
- package/dist/utils/stateHelpers.js.map +1 -1
- package/package.json +16 -56
- package/dist/functions/alt.d.ts +0 -6
- package/dist/functions/alt.js +0 -10
- package/dist/functions/alt.js.map +0 -1
- package/dist/functions/exclude.d.ts +0 -7
- package/dist/functions/exclude.js +0 -16
- package/dist/functions/exclude.js.map +0 -1
- package/dist/utils/objectToMapFunction.d.ts +0 -2
- package/dist/utils/objectToMapFunction.js +0 -34
- package/dist/utils/objectToMapFunction.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { MapDefinition, MapTransform, Options } from './types';
|
|
2
|
+
import functions from './functions';
|
|
3
|
+
import iterate from './operations/iterate';
|
|
2
4
|
export { get, set } from './operations/getSet';
|
|
3
5
|
export { default as root } from './operations/root';
|
|
4
6
|
export { default as alt } from './operations/alt';
|
|
7
|
+
export { default as apply } from './operations/apply';
|
|
5
8
|
export { default as value } from './operations/value';
|
|
6
9
|
export { default as fixed } from './operations/fixed';
|
|
7
10
|
export { default as concat } from './operations/concat';
|
|
@@ -11,13 +14,10 @@ export { default as plug } from './operations/plug';
|
|
|
11
14
|
export { default as lookup } from './operations/lookup';
|
|
12
15
|
export { default as transform } from './operations/transform';
|
|
13
16
|
export { default as filter } from './operations/filter';
|
|
17
|
+
export { default as ifelse } from './operations/ifelse';
|
|
14
18
|
export { fwd, rev, divide } from './operations/directionals';
|
|
15
|
-
export {
|
|
16
|
-
export
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
exclude: typeof import("./functions/exclude").default;
|
|
20
|
-
get: typeof import("./functions/get").default;
|
|
21
|
-
join: typeof import("./functions/join").default;
|
|
22
|
-
};
|
|
19
|
+
export { default as merge } from './operations/merge';
|
|
20
|
+
export { default as modify } from './operations/modify';
|
|
21
|
+
export { iterate, functions };
|
|
22
|
+
export { CustomFunction, DataMapper, MapDefinition, MapObject, MapPipe, MapTransform, Dictionary, Dictionaries, OperationObject, TransformObject, FilterObject, ApplyObject, AltObject, } from './types';
|
|
23
23
|
export declare function mapTransform(def: MapDefinition, options?: Options): MapTransform;
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mapTransform = exports.functions = void 0;
|
|
4
|
-
const ramda_1 = require("ramda");
|
|
3
|
+
exports.mapTransform = exports.functions = exports.iterate = exports.modify = exports.merge = exports.divide = exports.rev = exports.fwd = exports.ifelse = exports.filter = exports.transform = exports.lookup = exports.plug = exports.not = exports.validate = exports.concat = exports.fixed = exports.value = exports.apply = exports.alt = exports.root = exports.set = exports.get = void 0;
|
|
5
4
|
const definitionHelpers_1 = require("./utils/definitionHelpers");
|
|
6
5
|
const stateHelpers_1 = require("./utils/stateHelpers");
|
|
7
|
-
const objectToMapFunction_1 = require("./utils/objectToMapFunction");
|
|
8
6
|
const functions_1 = require("./functions");
|
|
7
|
+
exports.functions = functions_1.default;
|
|
8
|
+
const iterate_1 = require("./operations/iterate");
|
|
9
|
+
exports.iterate = iterate_1.default;
|
|
9
10
|
var getSet_1 = require("./operations/getSet");
|
|
10
11
|
Object.defineProperty(exports, "get", { enumerable: true, get: function () { return getSet_1.get; } });
|
|
11
12
|
Object.defineProperty(exports, "set", { enumerable: true, get: function () { return getSet_1.set; } });
|
|
@@ -13,6 +14,8 @@ var root_1 = require("./operations/root");
|
|
|
13
14
|
Object.defineProperty(exports, "root", { enumerable: true, get: function () { return root_1.default; } });
|
|
14
15
|
var alt_1 = require("./operations/alt");
|
|
15
16
|
Object.defineProperty(exports, "alt", { enumerable: true, get: function () { return alt_1.default; } });
|
|
17
|
+
var apply_1 = require("./operations/apply");
|
|
18
|
+
Object.defineProperty(exports, "apply", { enumerable: true, get: function () { return apply_1.default; } });
|
|
16
19
|
var value_1 = require("./operations/value");
|
|
17
20
|
Object.defineProperty(exports, "value", { enumerable: true, get: function () { return value_1.default; } });
|
|
18
21
|
var fixed_1 = require("./operations/fixed");
|
|
@@ -31,26 +34,38 @@ var transform_1 = require("./operations/transform");
|
|
|
31
34
|
Object.defineProperty(exports, "transform", { enumerable: true, get: function () { return transform_1.default; } });
|
|
32
35
|
var filter_1 = require("./operations/filter");
|
|
33
36
|
Object.defineProperty(exports, "filter", { enumerable: true, get: function () { return filter_1.default; } });
|
|
37
|
+
var ifelse_1 = require("./operations/ifelse");
|
|
38
|
+
Object.defineProperty(exports, "ifelse", { enumerable: true, get: function () { return ifelse_1.default; } });
|
|
34
39
|
var directionals_1 = require("./operations/directionals");
|
|
35
40
|
Object.defineProperty(exports, "fwd", { enumerable: true, get: function () { return directionals_1.fwd; } });
|
|
36
41
|
Object.defineProperty(exports, "rev", { enumerable: true, get: function () { return directionals_1.rev; } });
|
|
37
42
|
Object.defineProperty(exports, "divide", { enumerable: true, get: function () { return directionals_1.divide; } });
|
|
38
|
-
|
|
43
|
+
var merge_1 = require("./operations/merge");
|
|
44
|
+
Object.defineProperty(exports, "merge", { enumerable: true, get: function () { return merge_1.default; } });
|
|
45
|
+
var modify_1 = require("./operations/modify");
|
|
46
|
+
Object.defineProperty(exports, "modify", { enumerable: true, get: function () { return modify_1.default; } });
|
|
39
47
|
const composeMapFunction = (mapFn, initialState) => {
|
|
40
|
-
const
|
|
41
|
-
return (data) =>
|
|
48
|
+
const createState = (0, stateHelpers_1.populateState)(initialState);
|
|
49
|
+
return (data) => data === undefined ? undefined : (0, stateHelpers_1.getStateValue)(mapFn(createState(data)));
|
|
42
50
|
};
|
|
43
|
-
const
|
|
51
|
+
const mergeOptions = (options) => ({
|
|
52
|
+
...options,
|
|
53
|
+
functions: {
|
|
54
|
+
...functions_1.default,
|
|
55
|
+
...(options.functions || {}),
|
|
56
|
+
},
|
|
57
|
+
});
|
|
44
58
|
function mapTransform(def, options = {}) {
|
|
45
|
-
const
|
|
46
|
-
const mapFn = (definitionHelpers_1.
|
|
47
|
-
? objectToMapFunction_1.default(def, preparedOptions)
|
|
48
|
-
: definitionHelpers_1.mapFunctionFromDef(def, preparedOptions);
|
|
59
|
+
const completeOptions = mergeOptions(options);
|
|
60
|
+
const mapFn = (0, definitionHelpers_1.mapFunctionFromDef)(def)(completeOptions);
|
|
49
61
|
return Object.assign(composeMapFunction(mapFn, {}), {
|
|
50
62
|
onlyMappedValues: composeMapFunction(mapFn, { onlyMapped: true }),
|
|
51
63
|
rev: Object.assign(composeMapFunction(mapFn, { rev: true }), {
|
|
52
|
-
onlyMappedValues: composeMapFunction(mapFn, {
|
|
53
|
-
|
|
64
|
+
onlyMappedValues: composeMapFunction(mapFn, {
|
|
65
|
+
rev: true,
|
|
66
|
+
onlyMapped: true,
|
|
67
|
+
}),
|
|
68
|
+
}),
|
|
54
69
|
});
|
|
55
70
|
}
|
|
56
71
|
exports.mapTransform = mapTransform;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAOA,iEAA8D;AAC9D,uDAAmE;AACnE,2CAAmC;AAoBjB,oBApBX,mBAAS,CAoBW;AAnB3B,kDAA0C;AAmBjC,kBAnBF,iBAAO,CAmBE;AAjBhB,8CAA8C;AAArC,6FAAA,GAAG,OAAA;AA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C7B;CACF,CAAC,CAAA;AAEF,SAAgB,YAAY,CAC1B,GAAkB,EAClB,UAAmB,EAAE;IAErB,MAAM,eAAe,GAAG,YAAY,CAAC,OAAO,CAAC,CAAA;IAC7C,MAAM,KAAK,GAAG,IAAA,sCAAkB,EAAC,GAAG,CAAC,CAAC,eAAe,CAAC,CAAA;IAEtD,OAAO,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE;QAClD,gBAAgB,EAAE,kBAAkB,CAAC,KAAK,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;QACjE,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE;YAC3D,gBAAgB,EAAE,kBAAkB,CAAC,KAAK,EAAE;gBAC1C,GAAG,EAAE,IAAI;gBACT,UAAU,EAAE,IAAI;aACjB,CAAC;SACH,CAAC;KACH,CAAC,CAAA;AACJ,CAAC;AAhBD,oCAgBC"}
|
package/dist/operations/alt.js
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const mapAny = require("map-any");
|
|
4
3
|
const stateHelpers_1 = require("../utils/stateHelpers");
|
|
5
4
|
const definitionHelpers_1 = require("../utils/definitionHelpers");
|
|
6
|
-
const getOne = (context, index) => typeof index === 'undefined' || !Array.isArray(context)
|
|
7
|
-
? context
|
|
8
|
-
: context[index];
|
|
9
|
-
const getValueOrDefault = (state, runAlt) => (value, index) => typeof value === 'undefined'
|
|
10
|
-
? stateHelpers_1.getStateValue(runAlt(Object.assign(Object.assign({}, state), { value: getOne(state.context, index) })))
|
|
11
|
-
: value;
|
|
12
5
|
function alt(fn) {
|
|
13
6
|
return (options) => {
|
|
14
|
-
const runAlt = definitionHelpers_1.mapFunctionFromDef(fn
|
|
15
|
-
return (state) =>
|
|
7
|
+
const runAlt = (0, definitionHelpers_1.mapFunctionFromDef)(fn)(options);
|
|
8
|
+
return (state) => (0, stateHelpers_1.getStateValue)(state) === undefined
|
|
9
|
+
? runAlt((0, stateHelpers_1.setStateValue)(state, state.context))
|
|
10
|
+
: state;
|
|
16
11
|
};
|
|
17
12
|
}
|
|
18
13
|
exports.default = alt;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alt.js","sourceRoot":"","sources":["../../src/operations/alt.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"alt.js","sourceRoot":"","sources":["../../src/operations/alt.ts"],"names":[],"mappings":";;AACA,wDAAoE;AACpE,kEAA+D;AAE/D,SAAwB,GAAG,CAAC,EAAiB;IAC3C,OAAO,CAAC,OAAO,EAAE,EAAE;QACjB,MAAM,MAAM,GAAG,IAAA,sCAAkB,EAAC,EAAE,CAAC,CAAC,OAAO,CAAC,CAAA;QAE9C,OAAO,CAAC,KAAK,EAAE,EAAE,CACf,IAAA,4BAAa,EAAC,KAAK,CAAC,KAAK,SAAS;YAChC,CAAC,CAAC,MAAM,CAAC,IAAA,4BAAa,EAAC,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;YAC7C,CAAC,CAAC,KAAK,CAAA;IACb,CAAC,CAAA;AACH,CAAC;AATD,sBASC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const definitionHelpers_1 = require("../utils/definitionHelpers");
|
|
4
|
+
const stateHelpers_1 = require("../utils/stateHelpers");
|
|
5
|
+
const extractPipeline = (pipelineId, { pipelines }) => pipelineId && pipelines ? pipelines[pipelineId] : undefined;
|
|
6
|
+
function apply(pipelineId) {
|
|
7
|
+
return (options) => {
|
|
8
|
+
const pipeline = extractPipeline(pipelineId, options);
|
|
9
|
+
return pipeline
|
|
10
|
+
? (0, definitionHelpers_1.mapFunctionFromDef)(pipeline)(options)
|
|
11
|
+
: (state) => (0, stateHelpers_1.setStateValue)(state, undefined);
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
exports.default = apply;
|
|
15
|
+
//# sourceMappingURL=apply.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply.js","sourceRoot":"","sources":["../../src/operations/apply.ts"],"names":[],"mappings":";;AACA,kEAA+D;AAC/D,wDAAqD;AAErD,MAAM,eAAe,GAAG,CAAC,UAAkB,EAAE,EAAE,SAAS,EAAW,EAAE,EAAE,CACrE,UAAU,IAAI,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;AAE7D,SAAwB,KAAK,CAAC,UAAkB;IAC9C,OAAO,CAAC,OAAO,EAAE,EAAE;QACjB,MAAM,QAAQ,GAAG,eAAe,CAAC,UAAU,EAAE,OAAO,CAAC,CAAA;QACrD,OAAO,QAAQ;YACb,CAAC,CAAC,IAAA,sCAAkB,EAAC,QAAQ,CAAC,CAAC,OAAO,CAAC;YACvC,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,4BAAa,EAAC,KAAK,EAAE,SAAS,CAAC,CAAA;IAChD,CAAC,CAAA;AACH,CAAC;AAPD,wBAOC"}
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const stateHelpers_1 = require("../utils/stateHelpers");
|
|
4
4
|
const definitionHelpers_1 = require("../utils/definitionHelpers");
|
|
5
|
-
const merge = (left, right) =>
|
|
5
|
+
const merge = (left, right) => Array.isArray(right) ? [...left, ...right] : [...left, right];
|
|
6
6
|
function concat(...defs) {
|
|
7
7
|
return (options) => {
|
|
8
|
-
const fns = defs.map((def) => definitionHelpers_1.mapFunctionFromDef(def
|
|
9
|
-
return (state) => stateHelpers_1.setStateValue(state, fns
|
|
10
|
-
.reduce((value, fn) => merge(value, stateHelpers_1.getStateValue(fn(state))), [])
|
|
11
|
-
.filter((val) =>
|
|
8
|
+
const fns = defs.map((def) => (0, definitionHelpers_1.mapFunctionFromDef)(def)(options));
|
|
9
|
+
return (state) => (0, stateHelpers_1.setStateValue)(state, fns
|
|
10
|
+
.reduce((value, fn) => merge(value, (0, stateHelpers_1.getStateValue)(fn(state))), [])
|
|
11
|
+
.filter((val) => val !== undefined));
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
14
|
exports.default = concat;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"concat.js","sourceRoot":"","sources":["../../src/operations/concat.ts"],"names":[],"mappings":";;AACA,wDAAoE;AACpE,kEAA+D;AAE/D,MAAM,KAAK,GAAG,
|
|
1
|
+
{"version":3,"file":"concat.js","sourceRoot":"","sources":["../../src/operations/concat.ts"],"names":[],"mappings":";;AACA,wDAAoE;AACpE,kEAA+D;AAE/D,MAAM,KAAK,GAAG,CAAO,IAAS,EAAE,KAAc,EAAE,EAAE,CAChD,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC,CAAA;AAE/D,SAAwB,MAAM,CAAC,GAAG,IAAqB;IACrD,OAAO,CAAC,OAAO,EAAE,EAAE;QACjB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAA,sCAAkB,EAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAA;QAE/D,OAAO,CAAC,KAAK,EAAE,EAAE,CACf,IAAA,4BAAa,EACX,KAAK,EACL,GAAG;aACA,MAAM,CACL,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,IAAA,4BAAa,EAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EACrD,EAAe,CAChB;aACA,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,KAAK,SAAS,CAAC,CACtC,CAAA;IACL,CAAC,CAAA;AACH,CAAC;AAfD,yBAeC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { MapDefinition, Operation } from '../types';
|
|
2
2
|
export declare function fwd(def: MapDefinition): Operation;
|
|
3
3
|
export declare function rev(def: MapDefinition): Operation;
|
|
4
|
-
export declare function divide(fwdDef:
|
|
4
|
+
export declare function divide(fwdDef: MapDefinition, revDef: MapDefinition): Operation;
|
|
@@ -4,8 +4,8 @@ exports.divide = exports.rev = exports.fwd = void 0;
|
|
|
4
4
|
const definitionHelpers_1 = require("../utils/definitionHelpers");
|
|
5
5
|
const applyInDirection = (def, rev) => {
|
|
6
6
|
return (options) => {
|
|
7
|
-
const fn = definitionHelpers_1.mapFunctionFromDef(def
|
|
8
|
-
return (state) => (rev ? state.rev : !state.rev) ? fn(state) : state;
|
|
7
|
+
const fn = (0, definitionHelpers_1.mapFunctionFromDef)(def)(options);
|
|
8
|
+
return (state) => ((rev ? state.rev : !state.rev) ? fn(state) : state);
|
|
9
9
|
};
|
|
10
10
|
};
|
|
11
11
|
function fwd(def) {
|
|
@@ -18,9 +18,9 @@ function rev(def) {
|
|
|
18
18
|
exports.rev = rev;
|
|
19
19
|
function divide(fwdDef, revDef) {
|
|
20
20
|
return (options) => {
|
|
21
|
-
const fwdFn = definitionHelpers_1.mapFunctionFromDef(fwdDef
|
|
22
|
-
const revFn = definitionHelpers_1.mapFunctionFromDef(revDef
|
|
23
|
-
return (state) => (state.rev
|
|
21
|
+
const fwdFn = (0, definitionHelpers_1.mapFunctionFromDef)(fwdDef)(options);
|
|
22
|
+
const revFn = (0, definitionHelpers_1.mapFunctionFromDef)(revDef)(options);
|
|
23
|
+
return (state) => (state.rev ? revFn(state) : fwdFn(state));
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
26
|
exports.divide = divide;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"directionals.js","sourceRoot":"","sources":["../../src/operations/directionals.ts"],"names":[],"mappings":";;;AACA,kEAA+D;AAE/D,MAAM,gBAAgB,GAAG,CAAC,GAAkB,EAAE,GAAY,EAAa,EAAE;IACvE,OAAO,CAAC,OAAgB,EAAE,EAAE;QAC1B,MAAM,EAAE,GAAG,sCAAkB,
|
|
1
|
+
{"version":3,"file":"directionals.js","sourceRoot":"","sources":["../../src/operations/directionals.ts"],"names":[],"mappings":";;;AACA,kEAA+D;AAE/D,MAAM,gBAAgB,GAAG,CAAC,GAAkB,EAAE,GAAY,EAAa,EAAE;IACvE,OAAO,CAAC,OAAgB,EAAE,EAAE;QAC1B,MAAM,EAAE,GAAG,IAAA,sCAAkB,EAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAA;QAC3C,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;IACxE,CAAC,CAAA;AACH,CAAC,CAAA;AAED,SAAgB,GAAG,CAAC,GAAkB;IACpC,OAAO,gBAAgB,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;AACrC,CAAC;AAFD,kBAEC;AAED,SAAgB,GAAG,CAAC,GAAkB;IACpC,OAAO,gBAAgB,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;AACpC,CAAC;AAFD,kBAEC;AAED,SAAgB,MAAM,CACpB,MAAqB,EACrB,MAAqB;IAErB,OAAO,CAAC,OAAO,EAAE,EAAE;QACjB,MAAM,KAAK,GAAG,IAAA,sCAAkB,EAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAA;QACjD,MAAM,KAAK,GAAG,IAAA,sCAAkB,EAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAA;QACjD,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAA;IAC7D,CAAC,CAAA;AACH,CAAC;AATD,wBASC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Operation, DataMapper
|
|
2
|
-
export default function filter(fn: DataMapper
|
|
1
|
+
import { Operation, DataMapper } from '../types';
|
|
2
|
+
export default function filter(fn: DataMapper): Operation;
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const ramda_1 = require("ramda");
|
|
4
3
|
const stateHelpers_1 = require("../utils/stateHelpers");
|
|
4
|
+
const functional_1 = require("../utils/functional");
|
|
5
|
+
const filterValue = (value, filterFn) => Array.isArray(value)
|
|
6
|
+
? value.filter(filterFn)
|
|
7
|
+
: filterFn(value)
|
|
8
|
+
? value
|
|
9
|
+
: undefined;
|
|
5
10
|
function filter(fn) {
|
|
6
11
|
return (_options) => {
|
|
7
12
|
if (typeof fn !== 'function') {
|
|
8
|
-
return
|
|
13
|
+
return functional_1.identity;
|
|
9
14
|
}
|
|
10
15
|
return (state) => {
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
return
|
|
16
|
+
const filterFn = (data) => !!fn(data, (0, stateHelpers_1.contextFromState)(state));
|
|
17
|
+
const value = (0, stateHelpers_1.getStateValue)(state);
|
|
18
|
+
return (0, stateHelpers_1.setStateValue)(state, filterValue(value, filterFn));
|
|
14
19
|
};
|
|
15
20
|
};
|
|
16
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter.js","sourceRoot":"","sources":["../../src/operations/filter.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"filter.js","sourceRoot":"","sources":["../../src/operations/filter.ts"],"names":[],"mappings":";;AACA,wDAI8B;AAC9B,oDAA8C;AAE9C,MAAM,WAAW,GAAG,CAAC,KAAc,EAAE,QAAoC,EAAE,EAAE,CAC3E,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;IAClB,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC;IACxB,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC;QACjB,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,SAAS,CAAA;AAEf,SAAwB,MAAM,CAAC,EAAc;IAC3C,OAAO,CAAC,QAAQ,EAAE,EAAE;QAClB,IAAI,OAAO,EAAE,KAAK,UAAU,EAAE;YAC5B,OAAO,qBAAQ,CAAA;SAChB;QAED,OAAO,CAAC,KAAK,EAAE,EAAE;YACf,MAAM,QAAQ,GAAG,CAAC,IAAa,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,EAAE,IAAA,+BAAgB,EAAC,KAAK,CAAC,CAAC,CAAA;YACvE,MAAM,KAAK,GAAG,IAAA,4BAAa,EAAC,KAAK,CAAC,CAAA;YAClC,OAAO,IAAA,4BAAa,EAAC,KAAK,EAAE,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAA;QAC3D,CAAC,CAAA;IACH,CAAC,CAAA;AACH,CAAC;AAZD,yBAYC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default function fixed(val:
|
|
1
|
+
import { Operation, ValueFunction } from '../types';
|
|
2
|
+
export default function fixed(val: unknown | ValueFunction): Operation;
|
package/dist/operations/fixed.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const value_1 = require("../functions/value");
|
|
3
4
|
function fixed(val) {
|
|
4
|
-
return () => (state) => (
|
|
5
|
+
return () => (state) => ({
|
|
6
|
+
...state,
|
|
7
|
+
value: (0, value_1.extractValue)(val),
|
|
8
|
+
});
|
|
5
9
|
}
|
|
6
10
|
exports.default = fixed;
|
|
7
11
|
//# sourceMappingURL=fixed.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fixed.js","sourceRoot":"","sources":["../../src/operations/fixed.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"fixed.js","sourceRoot":"","sources":["../../src/operations/fixed.ts"],"names":[],"mappings":";;AACA,8CAAiD;AAEjD,SAAwB,KAAK,CAAC,GAA4B;IACxD,OAAO,GAAG,EAAE,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACvB,GAAG,KAAK;QACR,KAAK,EAAE,IAAA,oBAAY,EAAC,GAAG,CAAC;KACzB,CAAC,CAAA;AACJ,CAAC;AALD,wBAKC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { Operation, Path } from '../types';
|
|
1
|
+
import { Operation, State, Path } from '../types';
|
|
2
|
+
export declare const getValueFromState: (path: Path) => (state: State) => unknown;
|
|
2
3
|
export declare const get: (path: Path) => Operation;
|
|
3
4
|
export declare const set: (path: Path) => Operation;
|
|
@@ -1,37 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.set = exports.get = void 0;
|
|
4
|
-
const mapAny = require("map-any");
|
|
3
|
+
exports.set = exports.get = exports.getValueFromState = void 0;
|
|
5
4
|
const pathGetter_1 = require("../utils/pathGetter");
|
|
6
5
|
const pathSetter_1 = require("../utils/pathSetter");
|
|
6
|
+
const stateHelpers_1 = require("../utils/stateHelpers");
|
|
7
7
|
const root_1 = require("./root");
|
|
8
8
|
const plug_1 = require("./plug");
|
|
9
9
|
const directionals_1 = require("./directionals");
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
const isGet = (isGetOperation, isRev = false) => isGetOperation ? !isRev : isRev;
|
|
11
|
+
const setWithOnlyMapped = (state, setFn) => (value) => state.onlyMapped && value === undefined
|
|
12
|
+
? state.target
|
|
13
|
+
: setFn(value, state.target);
|
|
14
|
+
const getValueFromState = (path) => (state) => (0, pathGetter_1.default)(path)((0, stateHelpers_1.getStateValue)(state));
|
|
15
|
+
exports.getValueFromState = getValueFromState;
|
|
16
|
+
const setValueFromState = (path) => (state) => {
|
|
17
|
+
const setFn = setWithOnlyMapped(state, (0, pathSetter_1.default)(path));
|
|
18
|
+
return setFn((0, stateHelpers_1.getStateValue)(state), undefined);
|
|
14
19
|
};
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
? directionals_1.divide(root_1.default(exports.get(path.substr(1))), plug_1.default())
|
|
22
|
-
: directionals_1.divide(plug_1.default(), root_1.default(exports.set(path.substr(1))));
|
|
23
|
-
const getOrSet = (isGet) => (path) => {
|
|
24
|
-
if (path && path.startsWith('$')) {
|
|
25
|
-
return setupRootGetOrSet(isGet, path);
|
|
20
|
+
const getOrSet = (isGetOperation) => (path) => {
|
|
21
|
+
if (path && path.startsWith('^')) {
|
|
22
|
+
const rootGetSet = (0, root_1.default)(getOrSet(isGetOperation)(path.slice(1)));
|
|
23
|
+
return isGetOperation
|
|
24
|
+
? (0, directionals_1.divide)(rootGetSet, (0, plug_1.default)())
|
|
25
|
+
: (0, directionals_1.divide)((0, plug_1.default)(), rootGetSet);
|
|
26
26
|
}
|
|
27
|
-
const getFn =
|
|
28
|
-
const setFn =
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
: setValue(setFn, isArray, state);
|
|
27
|
+
const getFn = (0, exports.getValueFromState)(path);
|
|
28
|
+
const setFn = setValueFromState(path);
|
|
29
|
+
return () => Object.assign((state) => (0, stateHelpers_1.setStateValue)(state, isGet(isGetOperation, state.rev) ? getFn(state) : setFn(state)), {
|
|
30
|
+
getTarget: (state) => !isGet(isGetOperation, state.rev)
|
|
31
|
+
? (0, pathGetter_1.default)(path)(state.target)
|
|
32
|
+
: state.target,
|
|
33
|
+
});
|
|
35
34
|
};
|
|
36
35
|
exports.get = getOrSet(true);
|
|
37
36
|
exports.set = getOrSet(false);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSet.js","sourceRoot":"","sources":["../../src/operations/getSet.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"getSet.js","sourceRoot":"","sources":["../../src/operations/getSet.ts"],"names":[],"mappings":";;;AACA,oDAAwC;AACxC,oDAAoD;AACpD,wDAAoE;AACpE,iCAAyB;AACzB,iCAAyB;AACzB,iDAAuC;AAEvC,MAAM,KAAK,GAAG,CAAC,cAAuB,EAAE,KAAK,GAAG,KAAK,EAAE,EAAE,CACvD,cAAc,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAA;AAEjC,MAAM,iBAAiB,GACrB,CAAC,KAAY,EAAE,KAAa,EAAU,EAAE,CACxC,CAAC,KAAK,EAAE,EAAE,CACR,KAAK,CAAC,UAAU,IAAI,KAAK,KAAK,SAAS;IACrC,CAAC,CAAC,KAAK,CAAC,MAAM;IACd,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;AAE3B,MAAM,iBAAiB,GAAG,CAAC,IAAU,EAAE,EAAE,CAAC,CAAC,KAAY,EAAE,EAAE,CAChE,IAAA,oBAAM,EAAC,IAAI,CAAC,CAAC,IAAA,4BAAa,EAAC,KAAK,CAAC,CAAC,CAAA;AADvB,QAAA,iBAAiB,qBACM;AAEpC,MAAM,iBAAiB,GAAG,CAAC,IAAU,EAAE,EAAE,CAAC,CAAC,KAAY,EAAE,EAAE;IACzD,MAAM,KAAK,GAAG,iBAAiB,CAAC,KAAK,EAAE,IAAA,oBAAM,EAAC,IAAI,CAAC,CAAC,CAAA;IACpD,OAAO,KAAK,CAAC,IAAA,4BAAa,EAAC,KAAK,CAAC,EAAE,SA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@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const stateHelpers_1 = require("../utils/stateHelpers");
|
|
4
|
+
const definitionHelpers_1 = require("../utils/definitionHelpers");
|
|
5
|
+
function default_1(fn, trueDef, falseDef) {
|
|
6
|
+
const falseFn = (0, definitionHelpers_1.mapFunctionFromDef)(falseDef);
|
|
7
|
+
if (typeof fn !== 'function') {
|
|
8
|
+
return falseFn;
|
|
9
|
+
}
|
|
10
|
+
const trueFn = (0, definitionHelpers_1.mapFunctionFromDef)(trueDef);
|
|
11
|
+
return (options) => {
|
|
12
|
+
const runTrue = trueFn(options);
|
|
13
|
+
const runFalse = falseFn(options);
|
|
14
|
+
return (state) => fn((0, stateHelpers_1.getStateValue)(state), (0, stateHelpers_1.contextFromState)(state))
|
|
15
|
+
? runTrue(state)
|
|
16
|
+
: runFalse(state);
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
exports.default = default_1;
|
|
20
|
+
//# sourceMappingURL=ifelse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ifelse.js","sourceRoot":"","sources":["../../src/operations/ifelse.ts"],"names":[],"mappings":";;AACA,wDAAuE;AACvE,kEAA+D;AAE/D,mBACE,EAAc,EACd,OAAuB,EACvB,QAAwB;IAExB,MAAM,OAAO,GAAG,IAAA,sCAAkB,EAAC,QAAQ,CAAC,CAAA;IAC5C,IAAI,OAAO,EAAE,KAAK,UAAU,EAAE;QAC5B,OAAO,OAAO,CAAA;KACf;IACD,MAAM,MAAM,GAAG,IAAA,sCAAkB,EAAC,OAAO,CAAC,CAAA;IAE1C,OAAO,CAAC,OAAO,EAAE,EAAE;QACjB,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,CAAA;QAC/B,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;QAEjC,OAAO,CAAC,KAAK,EAAE,EAAE,CACf,EAAE,CAAC,IAAA,4BAAa,EAAC,KAAK,CAAC,EAAE,IAAA,+BAAgB,EAAC,KAAK,CAAC,CAAC;YAC/C,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC;YAChB,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;IACvB,CAAC,CAAA;AACH,CAAC;AApBD,4BAoBC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const mapAny = require("map-any");
|
|
4
|
+
const stateHelpers_1 = require("../utils/stateHelpers");
|
|
5
|
+
const definitionHelpers_1 = require("../utils/definitionHelpers");
|
|
6
|
+
const indexOfIfArray = (arr, index) => Array.isArray(arr) && typeof index === 'number' ? arr[index] : arr;
|
|
7
|
+
function iterate(def) {
|
|
8
|
+
return (options) => {
|
|
9
|
+
if (!def || (typeof def === 'object' && Object.keys(def).length === 0)) {
|
|
10
|
+
return (state) => (0, stateHelpers_1.setStateValue)(state, undefined);
|
|
11
|
+
}
|
|
12
|
+
const fn = (0, definitionHelpers_1.mapFunctionFromDef)(def)(options);
|
|
13
|
+
return (state) => (0, stateHelpers_1.setStateValue)(state, mapAny((value, index) => (0, stateHelpers_1.getStateValue)(fn({
|
|
14
|
+
...state,
|
|
15
|
+
context: indexOfIfArray(state.context, index),
|
|
16
|
+
value,
|
|
17
|
+
})), (0, stateHelpers_1.getStateValue)(state)));
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
exports.default = iterate;
|
|
21
|
+
//# sourceMappingURL=iterate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iterate.js","sourceRoot":"","sources":["../../src/operations/iterate.ts"],"names":[],"mappings":";;AAAA,kCAAkC;AAElC,wDAAoE;AACpE,kEAA+D;AAE/D,MAAM,cAAc,GAAG,CAAC,GAAY,EAAE,KAAc,EAAE,EAAE,CACtD,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAA;AAEpE,SAAwB,OAAO,CAAC,GAAkB;IAChD,OAAO,CAAC,OAAO,EAAE,EAAE;QACjB,IAAI,CAAC,GAAG,IAAI,CAAC,OAAO,GAAG,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,EAAE;YACtE,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,4BAAa,EAAC,KAAK,EAAE,SAAS,CAAC,CAAA;SAClD;QACD,MAAM,EAAE,GAAG,IAAA,sCAAkB,EAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAA;QAE3C,OAAO,CAAC,KAAK,EAAE,EAAE,CACf,IAAA,4BAAa,EACX,KAAK,EACL,MAAM,CACJ,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CACf,IAAA,4BAAa,EACX,EAAE,CAAC;YACD,GAAG,KAAK;YACR,OAAO,EAAE,cAAc,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC;YAC7C,KAAK;SACN,CAAC,CACH,EACH,IAAA,4BAAa,EAAC,KAAK,CAAC,CACrB,CACF,CAAA;IACL,CAAC,CAAA;AACH,CAAC;AAvBD,0BAuBC"}
|
|
@@ -4,7 +4,7 @@ const mapAny = require("map-any");
|
|
|
4
4
|
const pathGetter_1 = require("../utils/pathGetter");
|
|
5
5
|
const getSet_1 = require("./getSet");
|
|
6
6
|
const stateHelpers_1 = require("../utils/stateHelpers");
|
|
7
|
-
const matchPropInArray = (getProp) => (arr) => (value) => arr.find(obj => getProp(obj) === value);
|
|
7
|
+
const matchPropInArray = (getProp) => (arr) => (value) => arr.find((obj) => getProp(obj) === value);
|
|
8
8
|
const mapValue = (getArray, getProp) => {
|
|
9
9
|
const matchInArray = matchPropInArray(getProp);
|
|
10
10
|
return (state) => {
|
|
@@ -19,8 +19,8 @@ const mapValue = (getArray, getProp) => {
|
|
|
19
19
|
};
|
|
20
20
|
function lookup(arrayPath, propPath) {
|
|
21
21
|
return () => {
|
|
22
|
-
const mapValueFn = mapValue(getSet_1.get(arrayPath), pathGetter_1.default(propPath));
|
|
23
|
-
return (state) => stateHelpers_1.setStateValue(state, mapAny(mapValueFn(state), state.value));
|
|
22
|
+
const mapValueFn = mapValue((0, getSet_1.get)(arrayPath), (0, pathGetter_1.default)(propPath));
|
|
23
|
+
return (state) => (0, stateHelpers_1.setStateValue)(state, mapAny(mapValueFn(state), state.value));
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
26
|
exports.default = lookup;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lookup.js","sourceRoot":"","sources":["../../src/operations/lookup.ts"],"names":[],"mappings":";;AAAA,kCAAkC;AAElC,
|
|
1
|
+
{"version":3,"file":"lookup.js","sourceRoot":"","sources":["../../src/operations/lookup.ts"],"names":[],"mappings":";;AAAA,kCAAkC;AAElC,oDAAoD;AACpD,qCAA8B;AAC9B,wDAAqD;AAErD,MAAM,gBAAgB,GACpB,CAAC,OAAe,EAAE,EAAE,CACpB,CAAC,GAAc,EAAE,EAAE,CACnB,CAAC,KAAuC,EAAE,EAAE,CAC1C,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,CAAA;AAE7C,MAAM,QAAQ,GAAG,CAAC,QAAmB,EAAE,OAAe,EAAE,EAAE;IACxD,MAAM,YAAY,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAA;IAC9C,OAAO,CAAC,KAAY,EAAE,EAAE;QACtB,IAAI,KAAK,CAAC,GAAG,EAAE;YACb,OAAO,OAAO,CAAA;SACf;aAAM;YACL,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAA;YAC1C,OAAO,GAAG,CAAC,CAAC,CAAC,YAAY,CAAC,GAAgB,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,SAAS,CAAA;SAC9D;IACH,CAAC,CAAA;AACH,CAAC,CAAA;AAED,SAAwB,MAAM,CAAC,SAAe,EAAE,QAAc;IAC5D,OAAO,GAAG,EAAE;QACV,MAAM,UAAU,GAAG,QAAQ,CAAC,IAAA,YAAG,EAAC,SAAS,CAAC,EAAE,IAAA,oBAAM,EAAC,QAAQ,CAAC,CAAC,CAAA;QAE7D,OAAO,CAAC,KAAK,EAAE,EAAE,CACf,IAAA,4BAAa,EAAC,KAAK,EAAE,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAA;IAChE,CAAC,CAAA;AACH,CAAC;AAPD,yBAOC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mergeExisting = void 0;
|
|
4
|
+
const deepmerge = require("deepmerge");
|
|
5
|
+
const stateHelpers_1 = require("../utils/stateHelpers");
|
|
6
|
+
const definitionHelpers_1 = require("../utils/definitionHelpers");
|
|
7
|
+
const isNullOrUndefined = (value) => value === null || value === undefined;
|
|
8
|
+
function mergeExisting(target, source) {
|
|
9
|
+
if (Array.isArray(target)) {
|
|
10
|
+
const arr = source.slice();
|
|
11
|
+
target.forEach((value, index) => {
|
|
12
|
+
arr[index] = deepmerge(source[index], value, {
|
|
13
|
+
arrayMerge: mergeExisting,
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
return arr;
|
|
17
|
+
}
|
|
18
|
+
return target;
|
|
19
|
+
}
|
|
20
|
+
exports.mergeExisting = mergeExisting;
|
|
21
|
+
function mergeStates(state, thisState) {
|
|
22
|
+
const target = (0, stateHelpers_1.getStateValue)(state);
|
|
23
|
+
const source = (0, stateHelpers_1.getStateValue)(thisState);
|
|
24
|
+
return (0, stateHelpers_1.setStateValue)(state, isNullOrUndefined(source)
|
|
25
|
+
? target
|
|
26
|
+
: isNullOrUndefined(target)
|
|
27
|
+
? source
|
|
28
|
+
: deepmerge(target, source, { arrayMerge: mergeExisting }));
|
|
29
|
+
}
|
|
30
|
+
function merge(...defs) {
|
|
31
|
+
return (options) => {
|
|
32
|
+
const skipMutation = (0, stateHelpers_1.shouldSkipMutation)(options);
|
|
33
|
+
if (defs.length === 0) {
|
|
34
|
+
return (state) => (0, stateHelpers_1.setStateValue)(state, undefined);
|
|
35
|
+
}
|
|
36
|
+
const pipelines = defs.map((def) => (0, definitionHelpers_1.mapFunctionFromDef)(def)(options));
|
|
37
|
+
return (state) => skipMutation(state)
|
|
38
|
+
? (0, stateHelpers_1.setStateValue)(state, undefined)
|
|
39
|
+
: pipelines.map((pipeline) => pipeline(state)).reduce(mergeStates);
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
exports.default = merge;
|
|
43
|
+
//# sourceMappingURL=merge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge.js","sourceRoot":"","sources":["../../src/operations/merge.ts"],"names":[],"mappings":";;;AAAA,uCAAuC;AAEvC,wDAI8B;AAC9B,kEAA+D;AAE/D,MAAM,iBAAiB,GAAG,CAAC,KAAc,EAA6B,EAAE,CACtE,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,CAAA;AAEvC,SAAgB,aAAa,CAC3B,MAAW,EACX,MAAW;IAEX,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QACzB,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,EAAE,CAAA;QAC1B,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;YAE9B,GAAG,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE;gBAC3C,UAAU,EAAE,aAAa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W,CAAC,CAAA;IACxE,CAAC,CAAA;AACH,CAAC;AAbD,wBAaC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const stateHelpers_1 = require("../utils/stateHelpers");
|
|
4
|
+
const definitionHelpers_1 = require("../utils/definitionHelpers");
|
|
5
|
+
const is_1 = require("../utils/is");
|
|
6
|
+
function modify(def) {
|
|
7
|
+
const runFn = (0, definitionHelpers_1.mapFunctionFromDef)(def);
|
|
8
|
+
return (options) => (state) => {
|
|
9
|
+
const nextState = runFn(options)(state);
|
|
10
|
+
const prevValue = (0, stateHelpers_1.getStateValue)(state);
|
|
11
|
+
const nextValue = (0, stateHelpers_1.getStateValue)(nextState);
|
|
12
|
+
return (0, stateHelpers_1.setStateValue)(state, (0, is_1.isObject)(prevValue) && (0, is_1.isObject)(nextValue)
|
|
13
|
+
? { ...prevValue, ...nextValue }
|
|
14
|
+
: nextValue);
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
exports.default = modify;
|
|
18
|
+
//# sourceMappingURL=modify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modify.js","sourceRoot":"","sources":["../../src/operations/modify.ts"],"names":[],"mappings":";;AACA,wDAAoE;AACpE,kEAA+D;AAC/D,oCAAsC;AAEtC,SAAwB,MAAM,CAAC,GAAkB;IAC/C,MAAM,KAAK,GAAG,IAAA,sCAAkB,EAAC,GAAG,CAAC,CAAA;IACrC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,EAAE;QAC5B,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAA;QAEvC,MAAM,SAAS,GAAG,IAAA,4BAAa,EAAC,KAAK,CAAC,CAAA;QACtC,MAAM,SAAS,GAAG,IAAA,4BAAa,EAAC,SAAS,CAAC,CAAA;QAE1C,OAAO,IAAA,4BAAa,EAClB,KAAK,EACL,IAAA,aAAQ,EAAC,SAAS,CAAC,IAAI,IAAA,aAAQ,EAAC,SAAS,CAAC;YACxC,CAAC,CAAC,EAAE,GAAG,SAAS,EAAE,GAAG,SAAS,EAAE;YAChC,CAAC,CAAC,SAAS,CACd,CAAA;IACH,CAAC,CAAA;AACH,CAAC;AAfD,yBAeC"}
|