map-transform 0.4.0-beta.0 → 0.4.0-beta.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/README.md
CHANGED
|
@@ -821,6 +821,12 @@ This operation will always return an array, even when it is given only one
|
|
|
821
821
|
pipeline that does not return an array. Pipelines that does not result in a
|
|
822
822
|
value (i.e. return `undefined`) will be filtered away.
|
|
823
823
|
|
|
824
|
+
```javascript
|
|
825
|
+
{
|
|
826
|
+
$concat: ['data.users', 'data.admins']
|
|
827
|
+
}
|
|
828
|
+
```
|
|
829
|
+
|
|
824
830
|
#### `merge(pipeline, pipeline, ...)` operation
|
|
825
831
|
|
|
826
832
|
`merge()` will run all given pipelines and deep merge their results. Conflicts
|
|
@@ -6,7 +6,7 @@ const stateHelpers_1 = require("../utils/stateHelpers");
|
|
|
6
6
|
const definitionHelpers_1 = require("../utils/definitionHelpers");
|
|
7
7
|
const array_1 = require("../utils/array");
|
|
8
8
|
const functional_1 = require("../utils/functional");
|
|
9
|
-
const iterateState = (fn) => (state, target) => mapAny((value, index) => (0, stateHelpers_1.getStateValue)(fn((0, stateHelpers_1.setTargetOnState)((0, stateHelpers_1.setStateValue)({ ...state, index }, value), (0, array_1.indexOfIfArray)(target, index)))), (0, stateHelpers_1.getStateValue)(state));
|
|
9
|
+
const iterateState = (fn) => (state, target) => mapAny((value, index) => (0, stateHelpers_1.getStateValue)(fn((0, stateHelpers_1.setTargetOnState)((0, stateHelpers_1.setStateValue)({ ...state, index }, value, true), (0, array_1.indexOfIfArray)(target, index)))), (0, stateHelpers_1.getStateValue)(state));
|
|
10
10
|
exports.iterateState = iterateState;
|
|
11
11
|
function iterate(def) {
|
|
12
12
|
if (!def || (typeof def === 'object' && Object.keys(def).length === 0)) {
|
|
@@ -17,7 +17,7 @@ function iterate(def) {
|
|
|
17
17
|
const runIteration = (0, exports.iterateState)(fn(options)(functional_1.identity));
|
|
18
18
|
return (next) => function doIterate(state) {
|
|
19
19
|
const nextState = next(state);
|
|
20
|
-
return (0, stateHelpers_1.setStateValue)(nextState, runIteration(
|
|
20
|
+
return (0, stateHelpers_1.setStateValue)(nextState, runIteration(nextState, (0, stateHelpers_1.getTargetFromState)(state)));
|
|
21
21
|
};
|
|
22
22
|
};
|
|
23
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iterate.js","sourceRoot":"","sources":["../../src/operations/iterate.ts"],"names":[],"mappings":";;;AAAA,kCAAkC;AAElC,
|
|
1
|
+
{"version":3,"file":"iterate.js","sourceRoot":"","sources":["../../src/operations/iterate.ts"],"names":[],"mappings":";;;AAAA,kCAAkC;AAElC,wDAK8B;AAC9B,kEAA6D;AAC7D,0CAA+C;AAC/C,oDAA8C;AAEvC,MAAM,YAAY,GACvB,CAAC,EAAe,EAAE,EAAE,CAAC,CAAC,KAAY,EAAE,MAAe,EAAE,EAAE,CACrD,MAAM,CACJ,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CACf,IAAA,4BAAa,EACX,EAAE,CACA,IAAA,+BAAgB,EACd,IAAA,4BAAa,EAAC,EAAE,GAAG,KAAK,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,EAC/C,IAAA,sBAAc,EAAC,MAAM,EAAE,KAAK,CAAC,CAC9B,CACF,CACF,EACH,IAAA,4BAAa,EAAC,KAAK,CAAC,CACrB,CAAA;AAbQ,QAAA,YAAY,gBAapB;AAEL,SAAwB,OAAO,CAAC,GAAkB;IAChD,IAAI,CAAC,GAAG,IAAI,CAAC,OAAO,GAAG,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,EAAE;QACtE,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,EAAE,CACvC,IAAA,4BAAa,EAAC,IAAI,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC,CAAA;KACxC;IACD,MAAM,EAAE,GAAG,IAAA,oCAAgB,EAAC,GAAG,CAAC,CAAA;IAEhC,OAAO,CAAC,OAAO,EAAE,EAAE;QACjB,MAAM,YAAY,GAAG,IAAA,oBAAY,EAAC,EAAE,CAAC,OAAO,CAAC,CAAC,qBAAQ,CAAC,CAAC,CAAA;QACxD,OAAO,CAAC,IAAI,EAAE,EAAE,CACd,SAAS,SAAS,CAAC,KAAK;YACtB,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,CAAA;YAC7B,OAAO,IAAA,4BAAa,EAClB,SAAS,EACT,YAAY,CAAC,SAAS,EAAE,IAAA,iCAAkB,EAAC,KAAK,CAAC,CAAC,CACnD,CAAA;QACH,CAAC,CAAA;IACL,CAAC,CAAA;AACH,CAAC;AAlBD,0BAkBC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "map-transform",
|
|
3
|
-
"version": "0.4.0-beta.
|
|
3
|
+
"version": "0.4.0-beta.1",
|
|
4
4
|
"description": "Map and transform objects with mapping definitions",
|
|
5
5
|
"author": "Kjell-Morten Bratsberg Thorsen <post@kjellmorten.no>",
|
|
6
6
|
"license": "ISC",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"homepage": "https://github.com/integreat-io/map-transform#readme",
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@types/mustache": "^4.2.1",
|
|
40
|
-
"ajv": "^8.11.
|
|
40
|
+
"ajv": "^8.11.2",
|
|
41
41
|
"deepmerge": "^4.2.2",
|
|
42
42
|
"map-any": "^0.2.1",
|
|
43
43
|
"mustache": "^4.2.0"
|
|
@@ -47,6 +47,6 @@
|
|
|
47
47
|
"@types/deep-freeze": "^0.1.2",
|
|
48
48
|
"@types/sinon": "^10.0.13",
|
|
49
49
|
"deep-freeze": "0.0.1",
|
|
50
|
-
"sinon": "^14.0.
|
|
50
|
+
"sinon": "^14.0.2"
|
|
51
51
|
}
|
|
52
52
|
}
|