map-transform 0.4.0-alpha.31 → 0.4.0-alpha.32
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 +5 -0
- package/dist/functions/index.d.ts +2 -0
- package/dist/functions/index.js +2 -0
- package/dist/functions/index.js.map +1 -1
- package/dist/functions/indexFn.d.ts +2 -0
- package/dist/functions/indexFn.js +9 -0
- package/dist/functions/indexFn.js.map +1 -0
- package/dist/operations/iterate.js +1 -1
- package/dist/operations/iterate.js.map +1 -1
- package/dist/types.d.ts +1 -0
- package/dist/utils/stateHelpers.d.ts +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1199,6 +1199,11 @@ Or as a transform object:
|
|
|
1199
1199
|
const def32o = ['currencies', { $transform: 'explode' }]
|
|
1200
1200
|
```
|
|
1201
1201
|
|
|
1202
|
+
### `index()` function
|
|
1203
|
+
|
|
1204
|
+
When iterating, this will return the index of the current item in the array.
|
|
1205
|
+
When used outside of an iteration, it always returns `0`.
|
|
1206
|
+
|
|
1202
1207
|
#### `implode()` function
|
|
1203
1208
|
|
|
1204
1209
|
This is the exact opposite of the `explode` helper, imploding from a service and
|
|
@@ -2,6 +2,7 @@ import { value, fixed } from './value';
|
|
|
2
2
|
import compare from './compare';
|
|
3
3
|
import { explode, implode } from './explode';
|
|
4
4
|
import get from './get';
|
|
5
|
+
import index from './indexFn';
|
|
5
6
|
import { join, split } from './joinSplit';
|
|
6
7
|
import logical from './logical';
|
|
7
8
|
import map from './map';
|
|
@@ -13,6 +14,7 @@ declare const _default: {
|
|
|
13
14
|
fixed: typeof fixed;
|
|
14
15
|
get: typeof get;
|
|
15
16
|
implode: typeof implode;
|
|
17
|
+
index: typeof index;
|
|
16
18
|
join: typeof join;
|
|
17
19
|
logical: typeof logical;
|
|
18
20
|
map: typeof map;
|
package/dist/functions/index.js
CHANGED
|
@@ -4,6 +4,7 @@ const value_1 = require("./value");
|
|
|
4
4
|
const compare_1 = require("./compare");
|
|
5
5
|
const explode_1 = require("./explode");
|
|
6
6
|
const get_1 = require("./get");
|
|
7
|
+
const indexFn_1 = require("./indexFn");
|
|
7
8
|
const joinSplit_1 = require("./joinSplit");
|
|
8
9
|
const logical_1 = require("./logical");
|
|
9
10
|
const map_1 = require("./map");
|
|
@@ -15,6 +16,7 @@ exports.default = {
|
|
|
15
16
|
fixed: value_1.fixed,
|
|
16
17
|
get: get_1.default,
|
|
17
18
|
implode: explode_1.implode,
|
|
19
|
+
index: indexFn_1.default,
|
|
18
20
|
join: joinSplit_1.join,
|
|
19
21
|
logical: logical_1.default,
|
|
20
22
|
map: map_1.default,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/functions/index.ts"],"names":[],"mappings":";;AAAA,mCAAsC;AACtC,uCAA+B;AAC/B,uCAA4C;AAC5C,+BAAuB;AACvB,2CAAyC;AACzC,uCAA+B;AAC/B,+BAAuB;AACvB,iCAAyB;AACzB,yCAAiC;AAEjC,kBAAe;IACb,OAAO,EAAP,iBAAO;IACP,OAAO,EAAP,iBAAO;IACP,KAAK,EAAL,aAAK;IACL,GAAG,EAAH,aAAG;IACH,OAAO,EAAP,iBAAO;IACP,IAAI,EAAJ,gBAAI;IACJ,OAAO,EAAP,iBAAO;IACP,GAAG,EAAH,aAAG;IACH,IAAI,EAAJ,cAAI;IACJ,KAAK,EAAL,iBAAK;IACL,QAAQ,EAAR,kBAAQ;IACR,KAAK,EAAL,aAAK;CACN,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/functions/index.ts"],"names":[],"mappings":";;AAAA,mCAAsC;AACtC,uCAA+B;AAC/B,uCAA4C;AAC5C,+BAAuB;AACvB,uCAA6B;AAC7B,2CAAyC;AACzC,uCAA+B;AAC/B,+BAAuB;AACvB,iCAAyB;AACzB,yCAAiC;AAEjC,kBAAe;IACb,OAAO,EAAP,iBAAO;IACP,OAAO,EAAP,iBAAO;IACP,KAAK,EAAL,aAAK;IACL,GAAG,EAAH,aAAG;IACH,OAAO,EAAP,iBAAO;IACP,KAAK,EAAL,iBAAK;IACL,IAAI,EAAJ,gBAAI;IACJ,OAAO,EAAP,iBAAO;IACP,GAAG,EAAH,aAAG;IACH,IAAI,EAAJ,cAAI;IACJ,KAAK,EAAL,iBAAK;IACL,QAAQ,EAAR,kBAAQ;IACR,KAAK,EAAL,aAAK;CACN,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexFn.js","sourceRoot":"","sources":["../../src/functions/indexFn.ts"],"names":[],"mappings":";;AAEA,SAAwB,OAAO;IAC7B,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;QACtB,OAAO,KAAK,CAAC,KAAK,IAAI,CAAC,CAAA;IACzB,CAAC,CAAA;AACH,CAAC;AAJD,0BAIC"}
|
|
@@ -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, 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), (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)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iterate.js","sourceRoot":"","sources":["../../src/operations/iterate.ts"],"names":[],"mappings":";;;AAAA,kCAAkC;AAElC,wDAM8B;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,KAAK,EAAE,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"iterate.js","sourceRoot":"","sources":["../../src/operations/iterate.ts"],"names":[],"mappings":";;;AAAA,kCAAkC;AAElC,wDAM8B;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,CAAC,EACzC,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,CACV,IAAA,0BAAW,EAAC,SAAS,EAAE,KAAK,CAAC,KAAK,CAAC,EACnC,IAAA,iCAAkB,EAAC,KAAK,CAAC,CAC1B,CACF,CAAA;QACH,CAAC,CAAA;IACL,CAAC,CAAA;AACH,CAAC;AArBD,0BAqBC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export declare const pushContext: (state: State, nextContext: unknown) => {
|
|
|
15
15
|
onlyMapped?: boolean | undefined;
|
|
16
16
|
arr?: boolean | undefined;
|
|
17
17
|
iterate?: boolean | undefined;
|
|
18
|
+
index?: number | undefined;
|
|
18
19
|
};
|
|
19
20
|
export declare const removeLastContext: (state: State) => {
|
|
20
21
|
context: unknown[];
|
|
@@ -25,6 +26,7 @@ export declare const removeLastContext: (state: State) => {
|
|
|
25
26
|
onlyMapped?: boolean | undefined;
|
|
26
27
|
arr?: boolean | undefined;
|
|
27
28
|
iterate?: boolean | undefined;
|
|
29
|
+
index?: number | undefined;
|
|
28
30
|
};
|
|
29
31
|
export declare const populateState: ({ rev, onlyMapped }: Partial<State>) => (data: unknown) => State;
|
|
30
32
|
export declare const isNoneValueState: (state: State, noneValues?: unknown[]) => boolean;
|
package/package.json
CHANGED