@bemedev/decompose 0.2.1 → 0.3.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/lib/constants/strings.cjs +2 -0
- package/lib/constants/strings.cjs.map +1 -1
- package/lib/constants/strings.d.ts +1 -0
- package/lib/constants/strings.d.ts.map +1 -1
- package/lib/constants/strings.js +2 -1
- package/lib/constants/strings.js.map +1 -1
- package/lib/decompose.cjs +15 -12
- package/lib/decompose.cjs.map +1 -1
- package/lib/decompose.d.ts +2 -2
- package/lib/decompose.d.ts.map +1 -1
- package/lib/decompose.js +15 -12
- package/lib/decompose.js.map +1 -1
- package/lib/decomposeSV.cjs +28 -0
- package/lib/decomposeSV.cjs.map +1 -0
- package/lib/decomposeSV.d.ts +3 -0
- package/lib/decomposeSV.d.ts.map +1 -0
- package/lib/decomposeSV.js +26 -0
- package/lib/decomposeSV.js.map +1 -0
- package/lib/helpers.cjs +12 -0
- package/lib/helpers.cjs.map +1 -0
- package/lib/helpers.d.ts +4 -0
- package/lib/helpers.d.ts.map +1 -0
- package/lib/helpers.js +10 -0
- package/lib/helpers.js.map +1 -0
- package/lib/index.cjs +5 -0
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/recompose.cjs +34 -0
- package/lib/recompose.cjs.map +1 -0
- package/lib/recompose.d.ts +4 -0
- package/lib/recompose.d.ts.map +1 -0
- package/lib/recompose.js +31 -0
- package/lib/recompose.js.map +1 -0
- package/lib/sortMap.cjs +2 -7
- package/lib/sortMap.cjs.map +1 -1
- package/lib/sortMap.d.ts +1 -1
- package/lib/sortMap.d.ts.map +1 -1
- package/lib/sortMap.js +2 -7
- package/lib/sortMap.js.map +1 -1
- package/lib/types.d.ts +11 -6
- package/lib/types.d.ts.map +1 -1
- package/package.json +11 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strings.cjs","sources":["../../src/constants/strings.ts"],"sourcesContent":["export const DELIMITER = '-{/./:}-' as const;\n"],"names":[],"mappings":";;AAAO,MAAM,SAAS,GAAG
|
|
1
|
+
{"version":3,"file":"strings.cjs","sources":["../../src/constants/strings.ts"],"sourcesContent":["export const DELIMITER = '-{/./:}-' as const;\nexport const SEPARETOR = '.' as const;\n"],"names":[],"mappings":";;AAAO,MAAM,SAAS,GAAG,WAAoB;AACtC,MAAM,SAAS,GAAG;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strings.d.ts","sourceRoot":"","sources":["../../src/constants/strings.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,YAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"strings.d.ts","sourceRoot":"","sources":["../../src/constants/strings.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,YAAsB,CAAC;AAC7C,eAAO,MAAM,SAAS,KAAe,CAAC"}
|
package/lib/constants/strings.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strings.js","sources":["../../src/constants/strings.ts"],"sourcesContent":["export const DELIMITER = '-{/./:}-' as const;\n"],"names":[],"mappings":"AAAO,MAAM,SAAS,GAAG;;;;"}
|
|
1
|
+
{"version":3,"file":"strings.js","sources":["../../src/constants/strings.ts"],"sourcesContent":["export const DELIMITER = '-{/./:}-' as const;\nexport const SEPARETOR = '.' as const;\n"],"names":[],"mappings":"AAAO,MAAM,SAAS,GAAG,WAAoB;AACtC,MAAM,SAAS,GAAG;;;;"}
|
package/lib/decompose.cjs
CHANGED
|
@@ -1,27 +1,30 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var constants_strings = require('./constants/strings.cjs');
|
|
4
|
+
var helpers = require('./helpers.cjs');
|
|
4
5
|
var sortMap = require('./sortMap.cjs');
|
|
5
6
|
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
8
|
function ddecompose(val, prev = '') {
|
|
7
9
|
const _prev = prev ? prev + constants_strings.DELIMITER : '';
|
|
8
10
|
const output = [];
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
output.push(`${_prev}${
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
const entries1 = Object.entries(val);
|
|
12
|
+
entries1.forEach(([key, value]) => {
|
|
13
|
+
output.push(`${_prev}${key}`);
|
|
14
|
+
const isPrimit = helpers.isPrimitive(value);
|
|
15
|
+
if (!isPrimit) {
|
|
16
|
+
const values = ddecompose(value, `${_prev}${key}`);
|
|
17
|
+
output.push(...values);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
17
20
|
return output;
|
|
18
21
|
}
|
|
19
22
|
function decompose(val, sorter) {
|
|
20
|
-
const
|
|
21
|
-
|
|
23
|
+
const output1 = ddecompose(val, '');
|
|
24
|
+
output1.sort(sorter ?? sortMap.sortMap);
|
|
22
25
|
const regex = new RegExp(constants_strings.DELIMITER, 'g');
|
|
23
|
-
const
|
|
24
|
-
return Object.freeze(
|
|
26
|
+
const output2 = output1.map(value => value.replace(regex, '.'));
|
|
27
|
+
return Object.freeze(output2);
|
|
25
28
|
}
|
|
26
29
|
|
|
27
30
|
exports.decompose = decompose;
|
package/lib/decompose.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decompose.cjs","sources":["../src/decompose.ts"],"sourcesContent":["import { DELIMITER } from './constants/strings';\nimport { sortMap } from './sortMap';\nimport {
|
|
1
|
+
{"version":3,"file":"decompose.cjs","sources":["../src/decompose.ts"],"sourcesContent":["import { DELIMITER } from './constants/strings';\nimport { isPrimitive } from './helpers';\nimport { sortMap } from './sortMap';\nimport { Ru } from './types';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction ddecompose(val: any, prev = '') {\n const _prev = prev ? prev + DELIMITER : '';\n const output: string[] = [];\n const entries1 = Object.entries(val);\n entries1.forEach(([key, value]) => {\n output.push(`${_prev}${key}`);\n const isPrimit = isPrimitive(value);\n if (!isPrimit) {\n const values = ddecompose(value, `${_prev}${key}`);\n output.push(...values);\n }\n });\n return output;\n}\n\nexport function decompose<T extends Ru>(\n val: T,\n sorter?: (a: string, b: string) => number,\n) {\n const output1 = ddecompose(val, '');\n output1.sort(sorter ?? sortMap);\n const regex = new RegExp(DELIMITER, 'g');\n const output2 = output1.map(value => value.replace(regex, '.'));\n\n return Object.freeze(output2);\n}\n"],"names":["DELIMITER","isPrimitive","sortMap"],"mappings":";;;;;;AAKA;AACA,SAAS,UAAU,CAAC,GAAQ,EAAE,IAAI,GAAG,EAAE,EAAA;AACrC,IAAA,MAAM,KAAK,GAAG,IAAI,GAAG,IAAI,GAAGA,2BAAS,GAAG,EAAE,CAAC;IAC3C,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACrC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,KAAI;QAChC,MAAM,CAAC,IAAI,CAAC,CAAA,EAAG,KAAK,CAAG,EAAA,GAAG,CAAE,CAAA,CAAC,CAAC;AAC9B,QAAA,MAAM,QAAQ,GAAGC,mBAAW,CAAC,KAAK,CAAC,CAAC;QACpC,IAAI,CAAC,QAAQ,EAAE;AACb,YAAA,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK,EAAE,CAAG,EAAA,KAAK,CAAG,EAAA,GAAG,CAAE,CAAA,CAAC,CAAC;AACnD,YAAA,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC;SACxB;AACH,KAAC,CAAC,CAAC;AACH,IAAA,OAAO,MAAM,CAAC;AAChB,CAAC;AAEe,SAAA,SAAS,CACvB,GAAM,EACN,MAAyC,EAAA;IAEzC,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AACpC,IAAA,OAAO,CAAC,IAAI,CAAC,MAAM,IAAIC,eAAO,CAAC,CAAC;IAChC,MAAM,KAAK,GAAG,IAAI,MAAM,CAACF,2BAAS,EAAE,GAAG,CAAC,CAAC;AACzC,IAAA,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;AAEhE,IAAA,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAChC;;;;"}
|
package/lib/decompose.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function decompose<T extends
|
|
1
|
+
import { Ru } from './types';
|
|
2
|
+
export declare function decompose<T extends Ru>(val: T, sorter?: (a: string, b: string) => number): readonly string[];
|
|
3
3
|
//# sourceMappingURL=decompose.d.ts.map
|
package/lib/decompose.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decompose.d.ts","sourceRoot":"","sources":["../src/decompose.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"decompose.d.ts","sourceRoot":"","sources":["../src/decompose.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAkB7B,wBAAgB,SAAS,CAAC,CAAC,SAAS,EAAE,EACpC,GAAG,EAAE,CAAC,EACN,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,MAAM,qBAQ1C"}
|
package/lib/decompose.js
CHANGED
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
import { DELIMITER } from './constants/strings.js';
|
|
2
|
+
import { isPrimitive } from './helpers.js';
|
|
2
3
|
import { sortMap } from './sortMap.js';
|
|
3
4
|
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4
6
|
function ddecompose(val, prev = '') {
|
|
5
7
|
const _prev = prev ? prev + DELIMITER : '';
|
|
6
8
|
const output = [];
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
output.push(`${_prev}${
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
const entries1 = Object.entries(val);
|
|
10
|
+
entries1.forEach(([key, value]) => {
|
|
11
|
+
output.push(`${_prev}${key}`);
|
|
12
|
+
const isPrimit = isPrimitive(value);
|
|
13
|
+
if (!isPrimit) {
|
|
14
|
+
const values = ddecompose(value, `${_prev}${key}`);
|
|
15
|
+
output.push(...values);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
15
18
|
return output;
|
|
16
19
|
}
|
|
17
20
|
function decompose(val, sorter) {
|
|
18
|
-
const
|
|
19
|
-
|
|
21
|
+
const output1 = ddecompose(val, '');
|
|
22
|
+
output1.sort(sorter ?? sortMap);
|
|
20
23
|
const regex = new RegExp(DELIMITER, 'g');
|
|
21
|
-
const
|
|
22
|
-
return Object.freeze(
|
|
24
|
+
const output2 = output1.map(value => value.replace(regex, '.'));
|
|
25
|
+
return Object.freeze(output2);
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
export { decompose };
|
package/lib/decompose.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decompose.js","sources":["../src/decompose.ts"],"sourcesContent":["import { DELIMITER } from './constants/strings';\nimport { sortMap } from './sortMap';\nimport {
|
|
1
|
+
{"version":3,"file":"decompose.js","sources":["../src/decompose.ts"],"sourcesContent":["import { DELIMITER } from './constants/strings';\nimport { isPrimitive } from './helpers';\nimport { sortMap } from './sortMap';\nimport { Ru } from './types';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction ddecompose(val: any, prev = '') {\n const _prev = prev ? prev + DELIMITER : '';\n const output: string[] = [];\n const entries1 = Object.entries(val);\n entries1.forEach(([key, value]) => {\n output.push(`${_prev}${key}`);\n const isPrimit = isPrimitive(value);\n if (!isPrimit) {\n const values = ddecompose(value, `${_prev}${key}`);\n output.push(...values);\n }\n });\n return output;\n}\n\nexport function decompose<T extends Ru>(\n val: T,\n sorter?: (a: string, b: string) => number,\n) {\n const output1 = ddecompose(val, '');\n output1.sort(sorter ?? sortMap);\n const regex = new RegExp(DELIMITER, 'g');\n const output2 = output1.map(value => value.replace(regex, '.'));\n\n return Object.freeze(output2);\n}\n"],"names":[],"mappings":";;;;AAKA;AACA,SAAS,UAAU,CAAC,GAAQ,EAAE,IAAI,GAAG,EAAE,EAAA;AACrC,IAAA,MAAM,KAAK,GAAG,IAAI,GAAG,IAAI,GAAG,SAAS,GAAG,EAAE,CAAC;IAC3C,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACrC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,KAAI;QAChC,MAAM,CAAC,IAAI,CAAC,CAAA,EAAG,KAAK,CAAG,EAAA,GAAG,CAAE,CAAA,CAAC,CAAC;AAC9B,QAAA,MAAM,QAAQ,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC;QACpC,IAAI,CAAC,QAAQ,EAAE;AACb,YAAA,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK,EAAE,CAAG,EAAA,KAAK,CAAG,EAAA,GAAG,CAAE,CAAA,CAAC,CAAC;AACnD,YAAA,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC;SACxB;AACH,KAAC,CAAC,CAAC;AACH,IAAA,OAAO,MAAM,CAAC;AAChB,CAAC;AAEe,SAAA,SAAS,CACvB,GAAM,EACN,MAAyC,EAAA;IAEzC,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AACpC,IAAA,OAAO,CAAC,IAAI,CAAC,MAAM,IAAI,OAAO,CAAC,CAAC;IAChC,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;AACzC,IAAA,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;AAEhE,IAAA,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAChC;;;;"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var constants_strings = require('./constants/strings.cjs');
|
|
4
|
+
var sortMap = require('./sortMap.cjs');
|
|
5
|
+
|
|
6
|
+
function ddecompose(val, prev = '') {
|
|
7
|
+
const _prev = prev ? prev + constants_strings.DELIMITER : '';
|
|
8
|
+
const output = [];
|
|
9
|
+
prev !== '' && output.push(prev);
|
|
10
|
+
if (typeof val === 'string') {
|
|
11
|
+
output.push(`${_prev}${val}`);
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
const keys = Object.keys(val);
|
|
15
|
+
output.push(...keys.map(key => ddecompose(val[key], `${_prev}${key}`)).flat());
|
|
16
|
+
}
|
|
17
|
+
return output;
|
|
18
|
+
}
|
|
19
|
+
function decomposeSV(val, sorter) {
|
|
20
|
+
const first = ddecompose(val, '');
|
|
21
|
+
first.sort(sorter ?? sortMap.sortMap);
|
|
22
|
+
const regex = new RegExp(constants_strings.DELIMITER, 'g');
|
|
23
|
+
const output = first.map(value => value.replace(regex, '.'));
|
|
24
|
+
return Object.freeze(output);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
exports.decomposeSV = decomposeSV;
|
|
28
|
+
//# sourceMappingURL=decomposeSV.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decomposeSV.cjs","sources":["../src/decomposeSV.ts"],"sourcesContent":["import { DELIMITER } from './constants/strings';\nimport { sortMap } from './sortMap';\nimport type { StateMatching, StateValue } from './types';\n\nfunction ddecompose(val: StateValue, prev = '') {\n const _prev = prev ? prev + DELIMITER : '';\n const output: string[] = [];\n prev !== '' && output.push(prev);\n if (typeof val === 'string') {\n output.push(`${_prev}${val}`);\n } else {\n const keys = Object.keys(val);\n output.push(\n ...keys.map(key => ddecompose(val[key], `${_prev}${key}`)).flat(),\n );\n }\n\n return output;\n}\n\nexport function decomposeSV<T extends StateValue>(\n val: T,\n sorter?: (a: string, b: string) => number,\n): readonly StateMatching<T>[] {\n const first = ddecompose(val, '');\n first.sort(sorter ?? sortMap);\n const regex = new RegExp(DELIMITER, 'g');\n const output = first.map(value => value.replace(regex, '.'));\n\n return Object.freeze(output) as StateMatching<T>[];\n}\n"],"names":["DELIMITER","sortMap"],"mappings":";;;;;AAIA,SAAS,UAAU,CAAC,GAAe,EAAE,IAAI,GAAG,EAAE,EAAA;AAC5C,IAAA,MAAM,KAAK,GAAG,IAAI,GAAG,IAAI,GAAGA,2BAAS,GAAG,EAAE,CAAC;IAC3C,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,IAAI,KAAK,EAAE,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjC,IAAA,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;QAC3B,MAAM,CAAC,IAAI,CAAC,CAAA,EAAG,KAAK,CAAG,EAAA,GAAG,CAAE,CAAA,CAAC,CAAC;KAC/B;SAAM;QACL,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC9B,QAAA,MAAM,CAAC,IAAI,CACT,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAG,EAAA,KAAK,CAAG,EAAA,GAAG,CAAE,CAAA,CAAC,CAAC,CAAC,IAAI,EAAE,CAClE,CAAC;KACH;AAED,IAAA,OAAO,MAAM,CAAC;AAChB,CAAC;AAEe,SAAA,WAAW,CACzB,GAAM,EACN,MAAyC,EAAA;IAEzC,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAClC,IAAA,KAAK,CAAC,IAAI,CAAC,MAAM,IAAIC,eAAO,CAAC,CAAC;IAC9B,MAAM,KAAK,GAAG,IAAI,MAAM,CAACD,2BAAS,EAAE,GAAG,CAAC,CAAC;AACzC,IAAA,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;AAE7D,IAAA,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAuB,CAAC;AACrD;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decomposeSV.d.ts","sourceRoot":"","sources":["../src/decomposeSV.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAkBzD,wBAAgB,WAAW,CAAC,CAAC,SAAS,UAAU,EAC9C,GAAG,EAAE,CAAC,EACN,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,MAAM,GACxC,SAAS,aAAa,CAAC,CAAC,CAAC,EAAE,CAO7B"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { DELIMITER } from './constants/strings.js';
|
|
2
|
+
import { sortMap } from './sortMap.js';
|
|
3
|
+
|
|
4
|
+
function ddecompose(val, prev = '') {
|
|
5
|
+
const _prev = prev ? prev + DELIMITER : '';
|
|
6
|
+
const output = [];
|
|
7
|
+
prev !== '' && output.push(prev);
|
|
8
|
+
if (typeof val === 'string') {
|
|
9
|
+
output.push(`${_prev}${val}`);
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
const keys = Object.keys(val);
|
|
13
|
+
output.push(...keys.map(key => ddecompose(val[key], `${_prev}${key}`)).flat());
|
|
14
|
+
}
|
|
15
|
+
return output;
|
|
16
|
+
}
|
|
17
|
+
function decomposeSV(val, sorter) {
|
|
18
|
+
const first = ddecompose(val, '');
|
|
19
|
+
first.sort(sorter ?? sortMap);
|
|
20
|
+
const regex = new RegExp(DELIMITER, 'g');
|
|
21
|
+
const output = first.map(value => value.replace(regex, '.'));
|
|
22
|
+
return Object.freeze(output);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { decomposeSV };
|
|
26
|
+
//# sourceMappingURL=decomposeSV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decomposeSV.js","sources":["../src/decomposeSV.ts"],"sourcesContent":["import { DELIMITER } from './constants/strings';\nimport { sortMap } from './sortMap';\nimport type { StateMatching, StateValue } from './types';\n\nfunction ddecompose(val: StateValue, prev = '') {\n const _prev = prev ? prev + DELIMITER : '';\n const output: string[] = [];\n prev !== '' && output.push(prev);\n if (typeof val === 'string') {\n output.push(`${_prev}${val}`);\n } else {\n const keys = Object.keys(val);\n output.push(\n ...keys.map(key => ddecompose(val[key], `${_prev}${key}`)).flat(),\n );\n }\n\n return output;\n}\n\nexport function decomposeSV<T extends StateValue>(\n val: T,\n sorter?: (a: string, b: string) => number,\n): readonly StateMatching<T>[] {\n const first = ddecompose(val, '');\n first.sort(sorter ?? sortMap);\n const regex = new RegExp(DELIMITER, 'g');\n const output = first.map(value => value.replace(regex, '.'));\n\n return Object.freeze(output) as StateMatching<T>[];\n}\n"],"names":[],"mappings":";;;AAIA,SAAS,UAAU,CAAC,GAAe,EAAE,IAAI,GAAG,EAAE,EAAA;AAC5C,IAAA,MAAM,KAAK,GAAG,IAAI,GAAG,IAAI,GAAG,SAAS,GAAG,EAAE,CAAC;IAC3C,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,IAAI,KAAK,EAAE,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjC,IAAA,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;QAC3B,MAAM,CAAC,IAAI,CAAC,CAAA,EAAG,KAAK,CAAG,EAAA,GAAG,CAAE,CAAA,CAAC,CAAC;KAC/B;SAAM;QACL,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC9B,QAAA,MAAM,CAAC,IAAI,CACT,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAG,EAAA,KAAK,CAAG,EAAA,GAAG,CAAE,CAAA,CAAC,CAAC,CAAC,IAAI,EAAE,CAClE,CAAC;KACH;AAED,IAAA,OAAO,MAAM,CAAC;AAChB,CAAC;AAEe,SAAA,WAAW,CACzB,GAAM,EACN,MAAyC,EAAA;IAEzC,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAClC,IAAA,KAAK,CAAC,IAAI,CAAC,MAAM,IAAI,OAAO,CAAC,CAAC;IAC9B,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;AACzC,IAAA,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;AAE7D,IAAA,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAuB,CAAC;AACrD;;;;"}
|
package/lib/helpers.cjs
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function isPrimitive(arg) {
|
|
4
|
+
return (typeof arg === 'number' ||
|
|
5
|
+
typeof arg === 'string' ||
|
|
6
|
+
typeof arg === 'boolean' ||
|
|
7
|
+
arg === undefined ||
|
|
8
|
+
arg === null);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
exports.isPrimitive = isPrimitive;
|
|
12
|
+
//# sourceMappingURL=helpers.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.cjs","sources":["../src/helpers.ts"],"sourcesContent":["type Primitive = string | number | boolean | null | undefined;\n\nexport function isPrimitive(arg: unknown): arg is Primitive {\n return (\n typeof arg === 'number' ||\n typeof arg === 'string' ||\n typeof arg === 'boolean' ||\n arg === undefined ||\n arg === null\n );\n}\n"],"names":[],"mappings":";;AAEM,SAAU,WAAW,CAAC,GAAY,EAAA;AACtC,IAAA,QACE,OAAO,GAAG,KAAK,QAAQ;QACvB,OAAO,GAAG,KAAK,QAAQ;QACvB,OAAO,GAAG,KAAK,SAAS;AACxB,QAAA,GAAG,KAAK,SAAS;QACjB,GAAG,KAAK,IAAI,EACZ;AACJ;;;;"}
|
package/lib/helpers.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA,KAAK,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;AAE9D,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,SAAS,CAQ1D"}
|
package/lib/helpers.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sources":["../src/helpers.ts"],"sourcesContent":["type Primitive = string | number | boolean | null | undefined;\n\nexport function isPrimitive(arg: unknown): arg is Primitive {\n return (\n typeof arg === 'number' ||\n typeof arg === 'string' ||\n typeof arg === 'boolean' ||\n arg === undefined ||\n arg === null\n );\n}\n"],"names":[],"mappings":"AAEM,SAAU,WAAW,CAAC,GAAY,EAAA;AACtC,IAAA,QACE,OAAO,GAAG,KAAK,QAAQ;QACvB,OAAO,GAAG,KAAK,QAAQ;QACvB,OAAO,GAAG,KAAK,SAAS;AACxB,QAAA,GAAG,KAAK,SAAS;QACjB,GAAG,KAAK,IAAI,EACZ;AACJ;;;;"}
|
package/lib/index.cjs
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var decompose = require('./decompose.cjs');
|
|
4
|
+
var decomposeSV = require('./decomposeSV.cjs');
|
|
5
|
+
var recompose = require('./recompose.cjs');
|
|
4
6
|
var sortMap = require('./sortMap.cjs');
|
|
5
7
|
|
|
6
8
|
|
|
7
9
|
|
|
8
10
|
exports.decompose = decompose.decompose;
|
|
11
|
+
exports.decomposeSV = decomposeSV.decomposeSV;
|
|
12
|
+
exports.recompose = recompose.recompose;
|
|
13
|
+
exports.recomposeObjectUrl = recompose.recomposeObjectUrl;
|
|
9
14
|
exports.sortMap = sortMap.sortMap;
|
|
10
15
|
//# sourceMappingURL=index.cjs.map
|
package/lib/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;"}
|
package/lib/index.d.ts
CHANGED
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC"}
|
package/lib/index.js
CHANGED
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tsDeepmerge = require('ts-deepmerge');
|
|
4
|
+
var constants_strings = require('./constants/strings.cjs');
|
|
5
|
+
|
|
6
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
7
|
+
function recomposeObjectUrl(shape, value) {
|
|
8
|
+
const obj = {};
|
|
9
|
+
if (shape.length <= 0)
|
|
10
|
+
return obj;
|
|
11
|
+
const keys = shape.split(constants_strings.SEPARETOR);
|
|
12
|
+
if (keys.length === 1) {
|
|
13
|
+
const key = keys.shift();
|
|
14
|
+
obj[key] = value;
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
const key = keys.shift();
|
|
18
|
+
obj[key] = recomposeObjectUrl(keys.join(constants_strings.SEPARETOR), value);
|
|
19
|
+
}
|
|
20
|
+
return obj;
|
|
21
|
+
}
|
|
22
|
+
function recompose(shape) {
|
|
23
|
+
const entries = Object.entries(shape);
|
|
24
|
+
const arr = [];
|
|
25
|
+
entries.forEach(([key, value]) => {
|
|
26
|
+
arr.push(recomposeObjectUrl(key, value));
|
|
27
|
+
});
|
|
28
|
+
const output = tsDeepmerge.merge(...arr);
|
|
29
|
+
return Object.freeze(output);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
exports.recompose = recompose;
|
|
33
|
+
exports.recomposeObjectUrl = recomposeObjectUrl;
|
|
34
|
+
//# sourceMappingURL=recompose.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recompose.cjs","sources":["../src/recompose.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { merge } from 'ts-deepmerge';\nimport { SEPARETOR } from './constants/strings';\nimport type { Recompose, Ru } from './types';\n\nexport function recomposeObjectUrl<T>(shape: string, value: T) {\n const obj: Ru = {};\n if (shape.length <= 0) return obj;\n\n const keys = shape.split(SEPARETOR);\n if (keys.length === 1) {\n const key = keys.shift();\n obj[key!] = value;\n } else {\n const key = keys.shift();\n obj[key!] = recomposeObjectUrl(keys.join(SEPARETOR), value);\n }\n\n return obj;\n}\n\nexport function recompose<T extends Ru>(shape: T) {\n const entries = Object.entries(shape);\n const arr: any[] = [];\n entries.forEach(([key, value]) => {\n arr.push(recomposeObjectUrl(key, value));\n });\n const output = merge(...arr);\n return Object.freeze(output) as Recompose<T>;\n}\n"],"names":["SEPARETOR","merge"],"mappings":";;;;;AAAA;AAKgB,SAAA,kBAAkB,CAAI,KAAa,EAAE,KAAQ,EAAA;IAC3D,MAAM,GAAG,GAAO,EAAE,CAAC;AACnB,IAAA,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC;AAAE,QAAA,OAAO,GAAG,CAAC;IAElC,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAACA,2BAAS,CAAC,CAAC;AACpC,IAAA,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;AACrB,QAAA,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;AACzB,QAAA,GAAG,CAAC,GAAI,CAAC,GAAG,KAAK,CAAC;KACnB;SAAM;AACL,QAAA,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;AACzB,QAAA,GAAG,CAAC,GAAI,CAAC,GAAG,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAACA,2BAAS,CAAC,EAAE,KAAK,CAAC,CAAC;KAC7D;AAED,IAAA,OAAO,GAAG,CAAC;AACb,CAAC;AAEK,SAAU,SAAS,CAAe,KAAQ,EAAA;IAC9C,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACtC,MAAM,GAAG,GAAU,EAAE,CAAC;IACtB,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,KAAI;QAC/B,GAAG,CAAC,IAAI,CAAC,kBAAkB,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;AAC3C,KAAC,CAAC,CAAC;AACH,IAAA,MAAM,MAAM,GAAGC,iBAAK,CAAC,GAAG,GAAG,CAAC,CAAC;AAC7B,IAAA,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAiB,CAAC;AAC/C;;;;;"}
|