object-flatten-referencing 6.0.6 → 6.0.12
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 +4 -5
- package/dist/object-flatten-referencing.esm.js +2 -268
- package/dist/object-flatten-referencing.umd.js +4 -4
- package/examples/_quickTake.js +1 -0
- package/package.json +26 -77
- package/types/index.d.ts +38 -19
- package/types/util.d.ts +21 -16
- package/examples/api.json +0 -1
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2010-
|
|
3
|
+
Copyright (c) 2010-2022 Roy Revelt and other contributors
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
6
|
a copy of this software and associated documentation files (the
|
package/README.md
CHANGED
|
@@ -26,18 +26,17 @@
|
|
|
26
26
|
|
|
27
27
|
## Install
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
The latest version is **ESM only**: Node 12+ is needed to use it and it must be `import`ed instead of `require`d. If your project is not on ESM yet and you want to use `require`, use an older version of this program, `5.1.0`.
|
|
30
30
|
|
|
31
31
|
```bash
|
|
32
32
|
npm i object-flatten-referencing
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
If you need a legacy version which works with `require`, use version 5.1.0
|
|
36
|
-
|
|
37
35
|
## Quick Take
|
|
38
36
|
|
|
39
37
|
```js
|
|
40
38
|
import { strict as assert } from "assert";
|
|
39
|
+
|
|
41
40
|
import { flattenReferencing } from "object-flatten-referencing";
|
|
42
41
|
|
|
43
42
|
assert.deepEqual(
|
|
@@ -60,7 +59,7 @@ assert.deepEqual(
|
|
|
60
59
|
|
|
61
60
|
## Documentation
|
|
62
61
|
|
|
63
|
-
Please [visit codsen.com](https://codsen.com/os/object-flatten-referencing/) for a full description of the API
|
|
62
|
+
Please [visit codsen.com](https://codsen.com/os/object-flatten-referencing/) for a full description of the API.
|
|
64
63
|
|
|
65
64
|
## Contributing
|
|
66
65
|
|
|
@@ -70,6 +69,6 @@ To report bugs or request features or assistance, [raise an issue](https://githu
|
|
|
70
69
|
|
|
71
70
|
MIT License
|
|
72
71
|
|
|
73
|
-
Copyright (c) 2010-
|
|
72
|
+
Copyright (c) 2010-2022 Roy Revelt and other contributors
|
|
74
73
|
|
|
75
74
|
<img src="https://codsen.com/images/png-codsen-ok.png" width="98" alt="ok" align="center"> <img src="https://codsen.com/images/png-codsen-1.png" width="148" alt="codsen" align="center"> <img src="https://codsen.com/images/png-codsen-star-small.png" width="32" alt="star" align="center">
|
|
@@ -1,276 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name object-flatten-referencing
|
|
3
3
|
* @fileoverview Flatten complex nested objects according to a reference objects
|
|
4
|
-
* @version 6.0.
|
|
4
|
+
* @version 6.0.12
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/object-flatten-referencing/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import
|
|
11
|
-
import { strIndexesOfPlus } from 'str-indexes-of-plus';
|
|
12
|
-
import { isMatch } from 'matcher';
|
|
13
|
-
import isObj from 'lodash.isplainobject';
|
|
14
|
-
|
|
15
|
-
const defaults = {
|
|
16
|
-
wrapHeadsWith: "%%_",
|
|
17
|
-
wrapTailsWith: "_%%",
|
|
18
|
-
dontWrapKeys: [],
|
|
19
|
-
dontWrapPaths: [],
|
|
20
|
-
xhtml: true,
|
|
21
|
-
preventDoubleWrapping: true,
|
|
22
|
-
preventWrappingIfContains: [],
|
|
23
|
-
objectKeyAndValueJoinChar: ".",
|
|
24
|
-
wrapGlobalFlipSwitch: true,
|
|
25
|
-
ignore: [],
|
|
26
|
-
whatToDoWhenReferenceIsMissing: 0,
|
|
27
|
-
mergeArraysWithLineBreaks: true,
|
|
28
|
-
mergeWithoutTrailingBrIfLineContainsBr: true,
|
|
29
|
-
enforceStrictKeyset: true,
|
|
30
|
-
};
|
|
31
|
-
function isStr$1(something) {
|
|
32
|
-
return typeof something === "string";
|
|
33
|
-
}
|
|
34
|
-
function flattenObject(objOrig, originalOpts) {
|
|
35
|
-
const opts = { ...defaults, ...originalOpts };
|
|
36
|
-
if (arguments.length === 0 || Object.keys(objOrig).length === 0) {
|
|
37
|
-
return [];
|
|
38
|
-
}
|
|
39
|
-
const obj = clone(objOrig);
|
|
40
|
-
let res = [];
|
|
41
|
-
if (isObj(obj)) {
|
|
42
|
-
Object.keys(obj).forEach((key) => {
|
|
43
|
-
if (isObj(obj[key])) {
|
|
44
|
-
obj[key] = flattenObject(obj[key], opts);
|
|
45
|
-
}
|
|
46
|
-
if (Array.isArray(obj[key])) {
|
|
47
|
-
res = res.concat(obj[key].map((el) => key + opts.objectKeyAndValueJoinChar + el));
|
|
48
|
-
}
|
|
49
|
-
if (isStr$1(obj[key])) {
|
|
50
|
-
res.push(key + opts.objectKeyAndValueJoinChar + obj[key]);
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
return res;
|
|
55
|
-
}
|
|
56
|
-
function flattenArr(arrOrig, originalOpts, wrap = false, joinArraysUsingBrs = false) {
|
|
57
|
-
const opts = { ...defaults, ...originalOpts };
|
|
58
|
-
if (arguments.length === 0 || arrOrig.length === 0) {
|
|
59
|
-
return "";
|
|
60
|
-
}
|
|
61
|
-
const arr = clone(arrOrig);
|
|
62
|
-
let res = "";
|
|
63
|
-
if (arr.length > 0) {
|
|
64
|
-
if (joinArraysUsingBrs) {
|
|
65
|
-
for (let i = 0, len = arr.length; i < len; i++) {
|
|
66
|
-
if (isStr$1(arr[i])) {
|
|
67
|
-
let lineBreak;
|
|
68
|
-
lineBreak = "";
|
|
69
|
-
if (opts.mergeArraysWithLineBreaks &&
|
|
70
|
-
i > 0 &&
|
|
71
|
-
(!opts.mergeWithoutTrailingBrIfLineContainsBr ||
|
|
72
|
-
typeof arr[i - 1] !== "string" ||
|
|
73
|
-
(opts.mergeWithoutTrailingBrIfLineContainsBr &&
|
|
74
|
-
arr[i - 1] !== undefined &&
|
|
75
|
-
!arr[i - 1].toLowerCase().includes("<br")))) {
|
|
76
|
-
lineBreak = `<br${opts.xhtml ? " /" : ""}>`;
|
|
77
|
-
}
|
|
78
|
-
res +=
|
|
79
|
-
lineBreak +
|
|
80
|
-
(wrap ? opts.wrapHeadsWith : "") +
|
|
81
|
-
arr[i] +
|
|
82
|
-
(wrap ? opts.wrapTailsWith : "");
|
|
83
|
-
}
|
|
84
|
-
else if (Array.isArray(arr[i])) {
|
|
85
|
-
if (arr[i].length > 0 && arr[i].every(isStr$1)) {
|
|
86
|
-
let lineBreak = "";
|
|
87
|
-
if (opts.mergeArraysWithLineBreaks && res.length > 0) {
|
|
88
|
-
lineBreak = `<br${opts.xhtml ? " /" : ""}>`;
|
|
89
|
-
}
|
|
90
|
-
res = arr[i].reduce((acc, val, i2, arr2) => {
|
|
91
|
-
let trailingSpace = "";
|
|
92
|
-
if (i2 !== arr2.length - 1) {
|
|
93
|
-
trailingSpace = " ";
|
|
94
|
-
}
|
|
95
|
-
return (acc +
|
|
96
|
-
(i2 === 0 ? lineBreak : "") +
|
|
97
|
-
(wrap ? opts.wrapHeadsWith : "") +
|
|
98
|
-
val +
|
|
99
|
-
(wrap ? opts.wrapTailsWith : "") +
|
|
100
|
-
trailingSpace);
|
|
101
|
-
}, res);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
res = arr.reduce((acc, val, i, arr2) => {
|
|
108
|
-
let lineBreak = "";
|
|
109
|
-
if (opts.mergeArraysWithLineBreaks && i > 0) {
|
|
110
|
-
lineBreak = `<br${opts.xhtml ? " /" : ""}>`;
|
|
111
|
-
}
|
|
112
|
-
let trailingSpace = "";
|
|
113
|
-
if (i !== arr2.length - 1) {
|
|
114
|
-
trailingSpace = " ";
|
|
115
|
-
}
|
|
116
|
-
return (acc +
|
|
117
|
-
(i === 0 ? lineBreak : "") +
|
|
118
|
-
(wrap ? opts.wrapHeadsWith : "") +
|
|
119
|
-
val +
|
|
120
|
-
(wrap ? opts.wrapTailsWith : "") +
|
|
121
|
-
trailingSpace);
|
|
122
|
-
}, res);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
return res;
|
|
126
|
-
}
|
|
127
|
-
function arrayiffyString(something) {
|
|
128
|
-
if (isStr$1(something)) {
|
|
129
|
-
if (something.length > 0) {
|
|
130
|
-
return [something];
|
|
131
|
-
}
|
|
132
|
-
return [];
|
|
133
|
-
}
|
|
134
|
-
return something;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
var version$1 = "6.0.6";
|
|
138
|
-
|
|
139
|
-
const version = version$1;
|
|
140
|
-
function existy(x) {
|
|
141
|
-
return x != null;
|
|
142
|
-
}
|
|
143
|
-
function isStr(something) {
|
|
144
|
-
return typeof something === "string";
|
|
145
|
-
}
|
|
146
|
-
function flattenReferencing(originalInput1, originalReference1, opts1) {
|
|
147
|
-
if (arguments.length === 0) {
|
|
148
|
-
throw new Error("object-flatten-referencing/ofr(): [THROW_ID_01] all inputs missing!");
|
|
149
|
-
}
|
|
150
|
-
if (arguments.length === 1) {
|
|
151
|
-
throw new Error("object-flatten-referencing/ofr(): [THROW_ID_02] reference object missing!");
|
|
152
|
-
}
|
|
153
|
-
if (existy(opts1) && !isObj(opts1)) {
|
|
154
|
-
throw new Error(`object-flatten-referencing/ofr(): [THROW_ID_03] third input, options object must be a plain object. Currently it's: ${typeof opts1}`);
|
|
155
|
-
}
|
|
156
|
-
const originalOpts = { ...defaults, ...opts1 };
|
|
157
|
-
originalOpts.dontWrapKeys = arrayiffyString(originalOpts.dontWrapKeys);
|
|
158
|
-
originalOpts.preventWrappingIfContains = arrayiffyString(originalOpts.preventWrappingIfContains);
|
|
159
|
-
originalOpts.dontWrapPaths = arrayiffyString(originalOpts.dontWrapPaths);
|
|
160
|
-
originalOpts.ignore = arrayiffyString(originalOpts.ignore);
|
|
161
|
-
if (typeof originalOpts.whatToDoWhenReferenceIsMissing !== "number") {
|
|
162
|
-
originalOpts.whatToDoWhenReferenceIsMissing =
|
|
163
|
-
+originalOpts.whatToDoWhenReferenceIsMissing || 0;
|
|
164
|
-
}
|
|
165
|
-
function ofr(originalInput, originalReference, opts, wrap = true, joinArraysUsingBrs = true, currentRoot = "") {
|
|
166
|
-
let input = clone(originalInput);
|
|
167
|
-
const reference = clone(originalReference);
|
|
168
|
-
if (!opts.wrapGlobalFlipSwitch) {
|
|
169
|
-
wrap = false;
|
|
170
|
-
}
|
|
171
|
-
if (isObj(input)) {
|
|
172
|
-
Object.keys(input).forEach((key) => {
|
|
173
|
-
const currentPath = currentRoot + (currentRoot.length === 0 ? key : `.${key}`);
|
|
174
|
-
if (opts.ignore.length === 0 || !opts.ignore.includes(key)) {
|
|
175
|
-
if (opts.wrapGlobalFlipSwitch) {
|
|
176
|
-
wrap = true;
|
|
177
|
-
if (opts.dontWrapKeys.length > 0) {
|
|
178
|
-
wrap =
|
|
179
|
-
wrap &&
|
|
180
|
-
!opts.dontWrapKeys.some((elem) => isMatch(key, elem, { caseSensitive: true }));
|
|
181
|
-
}
|
|
182
|
-
if (opts.dontWrapPaths.length > 0) {
|
|
183
|
-
wrap =
|
|
184
|
-
wrap &&
|
|
185
|
-
!opts.dontWrapPaths.some((elem) => elem === currentPath);
|
|
186
|
-
}
|
|
187
|
-
if (opts.preventWrappingIfContains.length > 0 &&
|
|
188
|
-
typeof input[key] === "string") {
|
|
189
|
-
wrap =
|
|
190
|
-
wrap &&
|
|
191
|
-
!opts.preventWrappingIfContains.some((elem) => input[key].includes(elem));
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
if (existy(reference[key]) ||
|
|
195
|
-
(!existy(reference[key]) &&
|
|
196
|
-
opts.whatToDoWhenReferenceIsMissing === 2)) {
|
|
197
|
-
if (Array.isArray(input[key])) {
|
|
198
|
-
if (opts.whatToDoWhenReferenceIsMissing === 2 ||
|
|
199
|
-
isStr(reference[key])) {
|
|
200
|
-
input[key] = flattenArr(input[key], opts, wrap, joinArraysUsingBrs);
|
|
201
|
-
}
|
|
202
|
-
else {
|
|
203
|
-
if (input[key].every((el) => typeof el === "string" || Array.isArray(el))) {
|
|
204
|
-
let allOK = true;
|
|
205
|
-
input[key].forEach((oneOfElements) => {
|
|
206
|
-
if (Array.isArray(oneOfElements) &&
|
|
207
|
-
!oneOfElements.every(isStr)) {
|
|
208
|
-
allOK = false;
|
|
209
|
-
}
|
|
210
|
-
});
|
|
211
|
-
if (allOK) {
|
|
212
|
-
joinArraysUsingBrs = false;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
input[key] = ofr(input[key], reference[key], opts, wrap, joinArraysUsingBrs, currentPath);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
else if (isObj(input[key])) {
|
|
219
|
-
if (opts.whatToDoWhenReferenceIsMissing === 2 ||
|
|
220
|
-
isStr(reference[key])) {
|
|
221
|
-
input[key] = flattenArr(flattenObject(input[key], opts), opts, wrap, joinArraysUsingBrs);
|
|
222
|
-
}
|
|
223
|
-
else if (!wrap) {
|
|
224
|
-
input[key] = ofr(input[key], reference[key], { ...opts, wrapGlobalFlipSwitch: false }, wrap, joinArraysUsingBrs, currentPath);
|
|
225
|
-
}
|
|
226
|
-
else {
|
|
227
|
-
input[key] = ofr(input[key], reference[key], opts, wrap, joinArraysUsingBrs, currentPath);
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
else if (isStr(input[key])) {
|
|
231
|
-
input[key] = ofr(input[key], reference[key], opts, wrap, joinArraysUsingBrs, currentPath);
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
else if (typeof input[key] !== typeof reference[key]) {
|
|
235
|
-
if (opts.whatToDoWhenReferenceIsMissing === 1) {
|
|
236
|
-
throw new Error(`object-flatten-referencing/ofr(): [THROW_ID_06] reference object does not have the key ${key} and we need it. TIP: Turn off throwing via opts.whatToDoWhenReferenceIsMissing.`);
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
else if (Array.isArray(input)) {
|
|
243
|
-
if (Array.isArray(reference)) {
|
|
244
|
-
input.forEach((_el, i) => {
|
|
245
|
-
if (existy(input[i]) && existy(reference[i])) {
|
|
246
|
-
input[i] = ofr(input[i], reference[i], opts, wrap, joinArraysUsingBrs, `${currentRoot}[${i}]`);
|
|
247
|
-
}
|
|
248
|
-
else {
|
|
249
|
-
input[i] = ofr(input[i], reference[0], opts, wrap, joinArraysUsingBrs, `${currentRoot}[${i}]`);
|
|
250
|
-
}
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
else if (isStr(reference)) {
|
|
254
|
-
input = flattenArr(input, opts, wrap, joinArraysUsingBrs);
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
else if (isStr(input)) {
|
|
258
|
-
if (input.length > 0 && (opts.wrapHeadsWith || opts.wrapTailsWith)) {
|
|
259
|
-
if (!opts.preventDoubleWrapping ||
|
|
260
|
-
((opts.wrapHeadsWith === "" ||
|
|
261
|
-
!strIndexesOfPlus(input, opts.wrapHeadsWith.trim()).length) &&
|
|
262
|
-
(opts.wrapTailsWith === "" ||
|
|
263
|
-
!strIndexesOfPlus(input, opts.wrapTailsWith.trim()).length))) {
|
|
264
|
-
input =
|
|
265
|
-
(wrap ? opts.wrapHeadsWith : "") +
|
|
266
|
-
input +
|
|
267
|
-
(wrap ? opts.wrapTailsWith : "");
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
return input;
|
|
272
|
-
}
|
|
273
|
-
return ofr(originalInput1, originalReference1, originalOpts);
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
export { arrayiffyString, defaults, flattenArr, flattenObject, flattenReferencing, version };
|
|
10
|
+
import D from"lodash.clonedeep";import{strIndexesOfPlus as A}from"str-indexes-of-plus";import{isMatch as R}from"matcher";import $ from"lodash.isplainobject";import I from"lodash.clonedeep";import O from"lodash.isplainobject";var y={wrapHeadsWith:"%%_",wrapTailsWith:"_%%",dontWrapKeys:[],dontWrapPaths:[],xhtml:!0,preventDoubleWrapping:!0,preventWrappingIfContains:[],objectKeyAndValueJoinChar:".",wrapGlobalFlipSwitch:!0,ignore:[],whatToDoWhenReferenceIsMissing:0,mergeArraysWithLineBreaks:!0,mergeWithoutTrailingBrIfLineContainsBr:!0,enforceStrictKeyset:!0};function j(f){return typeof f=="string"}function T(f,b){let h={...y,...b};if(arguments.length===0||Object.keys(f).length===0)return[];let i=I(f),r=[];return O(i)&&Object.keys(i).forEach(a=>{O(i[a])&&(i[a]=T(i[a],h)),Array.isArray(i[a])&&(r=r.concat(i[a].map(p=>`${a}${h.objectKeyAndValueJoinChar}${p}`))),j(i[a])&&r.push(`${a}${h.objectKeyAndValueJoinChar}${i[a]}`)}),r}function w(f,b,h=!1,i=!1){let r={...y,...b};if(arguments.length===0||f.length===0)return"";let a=I(f),p="";if(a.length>0)if(i){for(let e=0,s=a.length;e<s;e++)if(j(a[e])){let l;l="",r.mergeArraysWithLineBreaks&&e>0&&(!r.mergeWithoutTrailingBrIfLineContainsBr||typeof a[e-1]!="string"||r.mergeWithoutTrailingBrIfLineContainsBr&&a[e-1]!==void 0&&!a[e-1].toLowerCase().includes("<br"))&&(l=`<br${r.xhtml?" /":""}>`),p+=`${l}${h?r.wrapHeadsWith:""}${a[e]}${h?r.wrapTailsWith:""}`}else if(Array.isArray(a[e])&&a[e].length>0&&a[e].every(j)){let l="";r.mergeArraysWithLineBreaks&&p.length>0&&(l=`<br${r.xhtml?" /":""}>`),p=a[e].reduce((g,t,o,n)=>{let c="";return o!==n.length-1&&(c=" "),g+(o===0?l:"")+(h?r.wrapHeadsWith:"")+t+(h?r.wrapTailsWith:"")+c},p)}}else p=a.reduce((e,s,l,g)=>{let t="";r.mergeArraysWithLineBreaks&&l>0&&(t=`<br${r.xhtml?" /":""}>`);let o="";return l!==g.length-1&&(o=" "),`${e}${l===0?t:""}${h?r.wrapHeadsWith:""}${s}${h?r.wrapTailsWith:""}${o}`},p);return p}function m(f){return j(f)?f.length>0?[f]:[]:f}var x="6.0.12";var J=x;function W(f){return f!=null}function d(f){return typeof f=="string"}function q(f,b,h){if(arguments.length===0)throw new Error("object-flatten-referencing/ofr(): [THROW_ID_01] all inputs missing!");if(arguments.length===1)throw new Error("object-flatten-referencing/ofr(): [THROW_ID_02] reference object missing!");if(W(h)&&!$(h))throw new Error(`object-flatten-referencing/ofr(): [THROW_ID_03] third input, options object must be a plain object. Currently it's: ${typeof h}`);let i={...y,...h};i.dontWrapKeys=m(i.dontWrapKeys),i.preventWrappingIfContains=m(i.preventWrappingIfContains),i.dontWrapPaths=m(i.dontWrapPaths),i.ignore=m(i.ignore),typeof i.whatToDoWhenReferenceIsMissing!="number"&&(i.whatToDoWhenReferenceIsMissing=+i.whatToDoWhenReferenceIsMissing||0);function r(a,p,e,s=!0,l=!0,g=""){let t=D(a),o=D(p);return e.wrapGlobalFlipSwitch||(s=!1),$(t)?Object.keys(t).forEach(n=>{let c=g+(g.length===0?n:`.${n}`);if(e.ignore.length===0||!e.ignore.includes(n)){if(e.wrapGlobalFlipSwitch&&(s=!0,e.dontWrapKeys.length>0&&(s=s&&!e.dontWrapKeys.some(u=>R(n,u,{caseSensitive:!0}))),e.dontWrapPaths.length>0&&(s=s&&!e.dontWrapPaths.some(u=>u===c)),e.preventWrappingIfContains.length>0&&typeof t[n]=="string"&&(s=s&&!e.preventWrappingIfContains.some(u=>t[n].includes(u)))),W(o[n])||!W(o[n])&&e.whatToDoWhenReferenceIsMissing===2)if(Array.isArray(t[n]))if(e.whatToDoWhenReferenceIsMissing===2||d(o[n]))t[n]=w(t[n],e,s,l);else{if(t[n].every(u=>typeof u=="string"||Array.isArray(u))){let u=!0;t[n].forEach(v=>{Array.isArray(v)&&!v.every(d)&&(u=!1)}),u&&(l=!1)}t[n]=r(t[n],o[n],e,s,l,c)}else $(t[n])?e.whatToDoWhenReferenceIsMissing===2||d(o[n])?t[n]=w(T(t[n],e),e,s,l):s?t[n]=r(t[n],o[n],e,s,l,c):t[n]=r(t[n],o[n],{...e,wrapGlobalFlipSwitch:!1},s,l,c):d(t[n])&&(t[n]=r(t[n],o[n],e,s,l,c));else if(typeof t[n]!=typeof o[n]&&e.whatToDoWhenReferenceIsMissing===1)throw new Error(`object-flatten-referencing/ofr(): [THROW_ID_06] reference object does not have the key ${n} and we need it. TIP: Turn off throwing via opts.whatToDoWhenReferenceIsMissing.`)}}):Array.isArray(t)?Array.isArray(o)?t.forEach((n,c)=>{W(t[c])&&W(o[c])?t[c]=r(t[c],o[c],e,s,l,`${g}[${c}]`):t[c]=r(t[c],o[0],e,s,l,`${g}[${c}]`)}):d(o)&&(t=w(t,e,s,l)):d(t)&&t.length>0&&(e.wrapHeadsWith||e.wrapTailsWith)&&(!e.preventDoubleWrapping||(e.wrapHeadsWith===""||!A(t,e.wrapHeadsWith.trim()).length)&&(e.wrapTailsWith===""||!A(t,e.wrapTailsWith.trim()).length))&&(t=`${s?e.wrapHeadsWith:""}${t}${s?e.wrapTailsWith:""}`),t}return r(f,b,i)}export{m as arrayiffyString,y as defaults,w as flattenArr,T as flattenObject,q as flattenReferencing,J as version};
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name object-flatten-referencing
|
|
3
3
|
* @fileoverview Flatten complex nested objects according to a reference objects
|
|
4
|
-
* @version 6.0.
|
|
4
|
+
* @version 6.0.12
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/object-flatten-referencing/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).objectFlattenReferencing={})}(this,(function(t){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},r={exports:{}};!function(t,r){var n="__lodash_hash_undefined__",o=9007199254740991,i="[object Arguments]",a="[object Boolean]",c="[object Date]",s="[object Function]",u="[object GeneratorFunction]",f="[object Map]",l="[object Number]",p="[object Object]",h="[object Promise]",y="[object RegExp]",g="[object Set]",d="[object String]",b="[object Symbol]",_="[object WeakMap]",v="[object ArrayBuffer]",w="[object DataView]",j="[object Float32Array]",W="[object Float64Array]",m="[object Int8Array]",A="[object Int16Array]",O="[object Int32Array]",T="[object Uint8Array]",x="[object Uint8ClampedArray]",I="[object Uint16Array]",$="[object Uint32Array]",E=/\w*$/,S=/^\[object .+?Constructor\]$/,P=/^(?:0|[1-9]\d*)$/,R={};R[i]=R["[object Array]"]=R[v]=R[w]=R[a]=R[c]=R[j]=R[W]=R[m]=R[A]=R[O]=R[f]=R[l]=R[p]=R[y]=R[g]=R[d]=R[b]=R[T]=R[x]=R[I]=R[$]=!0,R["[object Error]"]=R[s]=R[_]=!1;var C="object"==typeof self&&self&&self.Object===Object&&self,D="object"==typeof e&&e&&e.Object===Object&&e||C||Function("return this")(),k=r&&!r.nodeType&&r,B=k&&t&&!t.nodeType&&t,M=B&&B.exports===k;function F(t,e){return t.set(e[0],e[1]),t}function H(t,e){return t.add(e),t}function L(t,e,r,n){var o=-1,i=t?t.length:0;for(n&&i&&(r=t[++o]);++o<i;)r=e(r,t[o],o,t);return r}function K(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}function G(t){var e=-1,r=Array(t.size);return t.forEach((function(t,n){r[++e]=[n,t]})),r}function U(t,e){return function(r){return t(e(r))}}function V(t){var e=-1,r=Array(t.size);return t.forEach((function(t){r[++e]=t})),r}var J,N=Array.prototype,z=Function.prototype,q=Object.prototype,Q=D["__core-js_shared__"],X=(J=/[^.]+$/.exec(Q&&Q.keys&&Q.keys.IE_PROTO||""))?"Symbol(src)_1."+J:"",Y=z.toString,Z=q.hasOwnProperty,tt=q.toString,et=RegExp("^"+Y.call(Z).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),rt=M?D.Buffer:void 0,nt=D.Symbol,ot=D.Uint8Array,it=U(Object.getPrototypeOf,Object),at=Object.create,ct=q.propertyIsEnumerable,st=N.splice,ut=Object.getOwnPropertySymbols,ft=rt?rt.isBuffer:void 0,lt=U(Object.keys,Object),pt=Bt(D,"DataView"),ht=Bt(D,"Map"),yt=Bt(D,"Promise"),gt=Bt(D,"Set"),dt=Bt(D,"WeakMap"),bt=Bt(Object,"create"),_t=Kt(pt),vt=Kt(ht),wt=Kt(yt),jt=Kt(gt),Wt=Kt(dt),mt=nt?nt.prototype:void 0,At=mt?mt.valueOf:void 0;function Ot(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function Tt(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function xt(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function It(t){this.__data__=new Tt(t)}function $t(t,e){var r=Ut(t)||function(t){return function(t){return function(t){return!!t&&"object"==typeof t}(t)&&Vt(t)}(t)&&Z.call(t,"callee")&&(!ct.call(t,"callee")||tt.call(t)==i)}(t)?function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}(t.length,String):[],n=r.length,o=!!n;for(var a in t)!e&&!Z.call(t,a)||o&&("length"==a||Ht(a,n))||r.push(a);return r}function Et(t,e,r){var n=t[e];Z.call(t,e)&&Gt(n,r)&&(void 0!==r||e in t)||(t[e]=r)}function St(t,e){for(var r=t.length;r--;)if(Gt(t[r][0],e))return r;return-1}function Pt(t,e,r,n,o,h,_){var S;if(n&&(S=h?n(t,o,h,_):n(t)),void 0!==S)return S;if(!zt(t))return t;var P=Ut(t);if(P){if(S=function(t){var e=t.length,r=t.constructor(e);e&&"string"==typeof t[0]&&Z.call(t,"index")&&(r.index=t.index,r.input=t.input);return r}(t),!e)return function(t,e){var r=-1,n=t.length;e||(e=Array(n));for(;++r<n;)e[r]=t[r];return e}(t,S)}else{var C=Ft(t),D=C==s||C==u;if(Jt(t))return function(t,e){if(e)return t.slice();var r=new t.constructor(t.length);return t.copy(r),r}(t,e);if(C==p||C==i||D&&!h){if(K(t))return h?t:{};if(S=function(t){return"function"!=typeof t.constructor||Lt(t)?{}:(e=it(t),zt(e)?at(e):{});var e}(D?{}:t),!e)return function(t,e){return Dt(t,Mt(t),e)}(t,function(t,e){return t&&Dt(e,qt(e),t)}(S,t))}else{if(!R[C])return h?t:{};S=function(t,e,r,n){var o=t.constructor;switch(e){case v:return Ct(t);case a:case c:return new o(+t);case w:return function(t,e){var r=e?Ct(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,n);case j:case W:case m:case A:case O:case T:case x:case I:case $:return function(t,e){var r=e?Ct(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}(t,n);case f:return function(t,e,r){return L(e?r(G(t),!0):G(t),F,new t.constructor)}(t,n,r);case l:case d:return new o(t);case y:return function(t){var e=new t.constructor(t.source,E.exec(t));return e.lastIndex=t.lastIndex,e}(t);case g:return function(t,e,r){return L(e?r(V(t),!0):V(t),H,new t.constructor)}(t,n,r);case b:return i=t,At?Object(At.call(i)):{}}var i}(t,C,Pt,e)}}_||(_=new It);var k=_.get(t);if(k)return k;if(_.set(t,S),!P)var B=r?function(t){return function(t,e,r){var n=e(t);return Ut(t)?n:function(t,e){for(var r=-1,n=e.length,o=t.length;++r<n;)t[o+r]=e[r];return t}(n,r(t))}(t,qt,Mt)}(t):qt(t);return function(t,e){for(var r=-1,n=t?t.length:0;++r<n&&!1!==e(t[r],r,t););}(B||t,(function(o,i){B&&(o=t[i=o]),Et(S,i,Pt(o,e,r,n,i,t,_))})),S}function Rt(t){return!(!zt(t)||(e=t,X&&X in e))&&(Nt(t)||K(t)?et:S).test(Kt(t));var e}function Ct(t){var e=new t.constructor(t.byteLength);return new ot(e).set(new ot(t)),e}function Dt(t,e,r,n){r||(r={});for(var o=-1,i=e.length;++o<i;){var a=e[o],c=n?n(r[a],t[a],a,r,t):void 0;Et(r,a,void 0===c?t[a]:c)}return r}function kt(t,e){var r,n,o=t.__data__;return("string"==(n=typeof(r=e))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?o["string"==typeof e?"string":"hash"]:o.map}function Bt(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return Rt(r)?r:void 0}Ot.prototype.clear=function(){this.__data__=bt?bt(null):{}},Ot.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},Ot.prototype.get=function(t){var e=this.__data__;if(bt){var r=e[t];return r===n?void 0:r}return Z.call(e,t)?e[t]:void 0},Ot.prototype.has=function(t){var e=this.__data__;return bt?void 0!==e[t]:Z.call(e,t)},Ot.prototype.set=function(t,e){return this.__data__[t]=bt&&void 0===e?n:e,this},Tt.prototype.clear=function(){this.__data__=[]},Tt.prototype.delete=function(t){var e=this.__data__,r=St(e,t);return!(r<0)&&(r==e.length-1?e.pop():st.call(e,r,1),!0)},Tt.prototype.get=function(t){var e=this.__data__,r=St(e,t);return r<0?void 0:e[r][1]},Tt.prototype.has=function(t){return St(this.__data__,t)>-1},Tt.prototype.set=function(t,e){var r=this.__data__,n=St(r,t);return n<0?r.push([t,e]):r[n][1]=e,this},xt.prototype.clear=function(){this.__data__={hash:new Ot,map:new(ht||Tt),string:new Ot}},xt.prototype.delete=function(t){return kt(this,t).delete(t)},xt.prototype.get=function(t){return kt(this,t).get(t)},xt.prototype.has=function(t){return kt(this,t).has(t)},xt.prototype.set=function(t,e){return kt(this,t).set(t,e),this},It.prototype.clear=function(){this.__data__=new Tt},It.prototype.delete=function(t){return this.__data__.delete(t)},It.prototype.get=function(t){return this.__data__.get(t)},It.prototype.has=function(t){return this.__data__.has(t)},It.prototype.set=function(t,e){var r=this.__data__;if(r instanceof Tt){var n=r.__data__;if(!ht||n.length<199)return n.push([t,e]),this;r=this.__data__=new xt(n)}return r.set(t,e),this};var Mt=ut?U(ut,Object):function(){return[]},Ft=function(t){return tt.call(t)};function Ht(t,e){return!!(e=null==e?o:e)&&("number"==typeof t||P.test(t))&&t>-1&&t%1==0&&t<e}function Lt(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||q)}function Kt(t){if(null!=t){try{return Y.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function Gt(t,e){return t===e||t!=t&&e!=e}(pt&&Ft(new pt(new ArrayBuffer(1)))!=w||ht&&Ft(new ht)!=f||yt&&Ft(yt.resolve())!=h||gt&&Ft(new gt)!=g||dt&&Ft(new dt)!=_)&&(Ft=function(t){var e=tt.call(t),r=e==p?t.constructor:void 0,n=r?Kt(r):void 0;if(n)switch(n){case _t:return w;case vt:return f;case wt:return h;case jt:return g;case Wt:return _}return e});var Ut=Array.isArray;function Vt(t){return null!=t&&function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=o}(t.length)&&!Nt(t)}var Jt=ft||function(){return!1};function Nt(t){var e=zt(t)?tt.call(t):"";return e==s||e==u}function zt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function qt(t){return Vt(t)?$t(t):function(t){if(!Lt(t))return lt(t);var e=[];for(var r in Object(t))Z.call(t,r)&&"constructor"!=r&&e.push(r);return e}(t)}t.exports=function(t){return Pt(t,!0,!0)}}(r,r.exports);var n=r.exports;
|
|
10
|
+
var objectFlattenReferencing=(()=>{var _t=Object.create;var I=Object.defineProperty,mt=Object.defineProperties,wt=Object.getOwnPropertyDescriptor,Tt=Object.getOwnPropertyDescriptors,jt=Object.getOwnPropertyNames,_e=Object.getOwnPropertySymbols,Ot=Object.getPrototypeOf,me=Object.prototype.hasOwnProperty,vt=Object.prototype.propertyIsEnumerable;var we=(e,t,r)=>t in e?I(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,y=(e,t)=>{for(var r in t||(t={}))me.call(t,r)&&we(e,r,t[r]);if(_e)for(var r of _e(t))vt.call(t,r)&&we(e,r,t[r]);return e},Te=(e,t)=>mt(e,Tt(t)),je=e=>I(e,"__esModule",{value:!0});var Oe=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),xt=(e,t)=>{for(var r in t)I(e,r,{get:t[r],enumerable:!0})},ve=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of jt(t))!me.call(e,a)&&(r||a!=="default")&&I(e,a,{get:()=>t[a],enumerable:!(n=wt(t,a))||n.enumerable});return e},H=(e,t)=>ve(je(I(e!=null?_t(Ot(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),Wt=(e=>(t,r)=>e&&e.get(t)||(r=ve(je({}),t,1),e&&e.set(t,r),r))(typeof WeakMap!="undefined"?new WeakMap:0);var ce=Oe((P,S)=>{var St=200,xe="__lodash_hash_undefined__",We=9007199254740991,Z="[object Arguments]",At="[object Array]",Se="[object Boolean]",Ae="[object Date]",Ct="[object Error]",Q="[object Function]",Ce="[object GeneratorFunction]",K="[object Map]",Ie="[object Number]",z="[object Object]",$e="[object Promise]",Ee="[object RegExp]",L="[object Set]",Pe="[object String]",Me="[object Symbol]",U="[object WeakMap]",Re="[object ArrayBuffer]",B="[object DataView]",De="[object Float32Array]",He="[object Float64Array]",Ke="[object Int8Array]",Le="[object Int16Array]",Be="[object Int32Array]",Fe="[object Uint8Array]",Ge="[object Uint8ClampedArray]",Ne="[object Uint16Array]",Ve="[object Uint32Array]",It=/[\\^$.*+?()[\]{}|]/g,$t=/\w*$/,Et=/^\[object .+?Constructor\]$/,Pt=/^(?:0|[1-9]\d*)$/,h={};h[Z]=h[At]=h[Re]=h[B]=h[Se]=h[Ae]=h[De]=h[He]=h[Ke]=h[Le]=h[Be]=h[K]=h[Ie]=h[z]=h[Ee]=h[L]=h[Pe]=h[Me]=h[Fe]=h[Ge]=h[Ne]=h[Ve]=!0;h[Ct]=h[Q]=h[U]=!1;var Mt=typeof global=="object"&&global&&global.Object===Object&&global,Rt=typeof self=="object"&&self&&self.Object===Object&&self,_=Mt||Rt||Function("return this")(),Je=typeof P=="object"&&P&&!P.nodeType&&P,qe=Je&&typeof S=="object"&&S&&!S.nodeType&&S,Dt=qe&&qe.exports===Je;function Ht(e,t){return e.set(t[0],t[1]),e}function Kt(e,t){return e.add(t),e}function Lt(e,t){for(var r=-1,n=e?e.length:0;++r<n&&t(e[r],r,e)!==!1;);return e}function Bt(e,t){for(var r=-1,n=t.length,a=e.length;++r<n;)e[a+r]=t[r];return e}function Xe(e,t,r,n){var a=-1,o=e?e.length:0;for(n&&o&&(r=e[++a]);++a<o;)r=t(r,e[a],a,e);return r}function Ft(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}function Gt(e,t){return e==null?void 0:e[t]}function Ye(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch(r){}return t}function Ze(e){var t=-1,r=Array(e.size);return e.forEach(function(n,a){r[++t]=[a,n]}),r}function k(e,t){return function(r){return e(t(r))}}function Qe(e){var t=-1,r=Array(e.size);return e.forEach(function(n){r[++t]=n}),r}var Nt=Array.prototype,Vt=Function.prototype,F=Object.prototype,ee=_["__core-js_shared__"],ze=function(){var e=/[^.]+$/.exec(ee&&ee.keys&&ee.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),Ue=Vt.toString,w=F.hasOwnProperty,G=F.toString,Jt=RegExp("^"+Ue.call(w).replace(It,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ke=Dt?_.Buffer:void 0,et=_.Symbol,tt=_.Uint8Array,qt=k(Object.getPrototypeOf,Object),Xt=Object.create,Yt=F.propertyIsEnumerable,Zt=Nt.splice,rt=Object.getOwnPropertySymbols,Qt=ke?ke.isBuffer:void 0,zt=k(Object.keys,Object),te=W(_,"DataView"),$=W(_,"Map"),re=W(_,"Promise"),ne=W(_,"Set"),ie=W(_,"WeakMap"),E=W(Object,"create"),Ut=O(te),kt=O($),er=O(re),tr=O(ne),rr=O(ie),nt=et?et.prototype:void 0,it=nt?nt.valueOf:void 0;function T(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function nr(){this.__data__=E?E(null):{}}function ir(e){return this.has(e)&&delete this.__data__[e]}function ar(e){var t=this.__data__;if(E){var r=t[e];return r===xe?void 0:r}return w.call(t,e)?t[e]:void 0}function or(e){var t=this.__data__;return E?t[e]!==void 0:w.call(t,e)}function sr(e,t){var r=this.__data__;return r[e]=E&&t===void 0?xe:t,this}T.prototype.clear=nr;T.prototype.delete=ir;T.prototype.get=ar;T.prototype.has=or;T.prototype.set=sr;function m(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function fr(){this.__data__=[]}function cr(e){var t=this.__data__,r=N(t,e);if(r<0)return!1;var n=t.length-1;return r==n?t.pop():Zt.call(t,r,1),!0}function lr(e){var t=this.__data__,r=N(t,e);return r<0?void 0:t[r][1]}function ur(e){return N(this.__data__,e)>-1}function hr(e,t){var r=this.__data__,n=N(r,e);return n<0?r.push([e,t]):r[n][1]=t,this}m.prototype.clear=fr;m.prototype.delete=cr;m.prototype.get=lr;m.prototype.has=ur;m.prototype.set=hr;function v(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function pr(){this.__data__={hash:new T,map:new($||m),string:new T}}function gr(e){return V(this,e).delete(e)}function dr(e){return V(this,e).get(e)}function br(e){return V(this,e).has(e)}function yr(e,t){return V(this,e).set(e,t),this}v.prototype.clear=pr;v.prototype.delete=gr;v.prototype.get=dr;v.prototype.has=br;v.prototype.set=yr;function x(e){this.__data__=new m(e)}function _r(){this.__data__=new m}function mr(e){return this.__data__.delete(e)}function wr(e){return this.__data__.get(e)}function Tr(e){return this.__data__.has(e)}function jr(e,t){var r=this.__data__;if(r instanceof m){var n=r.__data__;if(!$||n.length<St-1)return n.push([e,t]),this;r=this.__data__=new v(n)}return r.set(e,t),this}x.prototype.clear=_r;x.prototype.delete=mr;x.prototype.get=wr;x.prototype.has=Tr;x.prototype.set=jr;function Or(e,t){var r=se(e)||Xr(e)?Ft(e.length,String):[],n=r.length,a=!!n;for(var o in e)(t||w.call(e,o))&&!(a&&(o=="length"||Nr(o,n)))&&r.push(o);return r}function at(e,t,r){var n=e[t];(!(w.call(e,t)&&ct(n,r))||r===void 0&&!(t in e))&&(e[t]=r)}function N(e,t){for(var r=e.length;r--;)if(ct(e[r][0],t))return r;return-1}function vr(e,t){return e&&ot(t,fe(t),e)}function ae(e,t,r,n,a,o,u){var i;if(n&&(i=o?n(e,a,o,u):n(e)),i!==void 0)return i;if(!J(e))return e;var c=se(e);if(c){if(i=Br(e),!t)return Hr(e,i)}else{var l=j(e),d=l==Q||l==Ce;if(Zr(e))return Ir(e,t);if(l==z||l==Z||d&&!o){if(Ye(e))return o?e:{};if(i=Fr(d?{}:e),!t)return Kr(e,vr(i,e))}else{if(!h[l])return o?e:{};i=Gr(e,l,ae,t)}}u||(u=new x);var s=u.get(e);if(s)return s;if(u.set(e,i),!c)var p=r?Lr(e):fe(e);return Lt(p||e,function(f,g){p&&(g=f,f=e[g]),at(i,g,ae(f,t,r,n,g,e,u))}),i}function xr(e){return J(e)?Xt(e):{}}function Wr(e,t,r){var n=t(e);return se(e)?n:Bt(n,r(e))}function Sr(e){return G.call(e)}function Ar(e){if(!J(e)||Jr(e))return!1;var t=ut(e)||Ye(e)?Jt:Et;return t.test(O(e))}function Cr(e){if(!ft(e))return zt(e);var t=[];for(var r in Object(e))w.call(e,r)&&r!="constructor"&&t.push(r);return t}function Ir(e,t){if(t)return e.slice();var r=new e.constructor(e.length);return e.copy(r),r}function oe(e){var t=new e.constructor(e.byteLength);return new tt(t).set(new tt(e)),t}function $r(e,t){var r=t?oe(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}function Er(e,t,r){var n=t?r(Ze(e),!0):Ze(e);return Xe(n,Ht,new e.constructor)}function Pr(e){var t=new e.constructor(e.source,$t.exec(e));return t.lastIndex=e.lastIndex,t}function Mr(e,t,r){var n=t?r(Qe(e),!0):Qe(e);return Xe(n,Kt,new e.constructor)}function Rr(e){return it?Object(it.call(e)):{}}function Dr(e,t){var r=t?oe(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}function Hr(e,t){var r=-1,n=e.length;for(t||(t=Array(n));++r<n;)t[r]=e[r];return t}function ot(e,t,r,n){r||(r={});for(var a=-1,o=t.length;++a<o;){var u=t[a],i=n?n(r[u],e[u],u,r,e):void 0;at(r,u,i===void 0?e[u]:i)}return r}function Kr(e,t){return ot(e,st(e),t)}function Lr(e){return Wr(e,fe,st)}function V(e,t){var r=e.__data__;return Vr(t)?r[typeof t=="string"?"string":"hash"]:r.map}function W(e,t){var r=Gt(e,t);return Ar(r)?r:void 0}var st=rt?k(rt,Object):Ur,j=Sr;(te&&j(new te(new ArrayBuffer(1)))!=B||$&&j(new $)!=K||re&&j(re.resolve())!=$e||ne&&j(new ne)!=L||ie&&j(new ie)!=U)&&(j=function(e){var t=G.call(e),r=t==z?e.constructor:void 0,n=r?O(r):void 0;if(n)switch(n){case Ut:return B;case kt:return K;case er:return $e;case tr:return L;case rr:return U}return t});function Br(e){var t=e.length,r=e.constructor(t);return t&&typeof e[0]=="string"&&w.call(e,"index")&&(r.index=e.index,r.input=e.input),r}function Fr(e){return typeof e.constructor=="function"&&!ft(e)?xr(qt(e)):{}}function Gr(e,t,r,n){var a=e.constructor;switch(t){case Re:return oe(e);case Se:case Ae:return new a(+e);case B:return $r(e,n);case De:case He:case Ke:case Le:case Be:case Fe:case Ge:case Ne:case Ve:return Dr(e,n);case K:return Er(e,n,r);case Ie:case Pe:return new a(e);case Ee:return Pr(e);case L:return Mr(e,n,r);case Me:return Rr(e)}}function Nr(e,t){return t=t==null?We:t,!!t&&(typeof e=="number"||Pt.test(e))&&e>-1&&e%1==0&&e<t}function Vr(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function Jr(e){return!!ze&&ze in e}function ft(e){var t=e&&e.constructor,r=typeof t=="function"&&t.prototype||F;return e===r}function O(e){if(e!=null){try{return Ue.call(e)}catch(t){}try{return e+""}catch(t){}}return""}function qr(e){return ae(e,!0,!0)}function ct(e,t){return e===t||e!==e&&t!==t}function Xr(e){return Yr(e)&&w.call(e,"callee")&&(!Yt.call(e,"callee")||G.call(e)==Z)}var se=Array.isArray;function lt(e){return e!=null&&Qr(e.length)&&!ut(e)}function Yr(e){return zr(e)&<(e)}var Zr=Qt||kr;function ut(e){var t=J(e)?G.call(e):"";return t==Q||t==Ce}function Qr(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=We}function J(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function zr(e){return!!e&&typeof e=="object"}function fe(e){return lt(e)?Or(e):Cr(e)}function Ur(){return[]}function kr(){return!1}S.exports=qr});var pe=Oe((jn,bt)=>{var rn="[object Object]";function nn(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch(r){}return t}function an(e,t){return function(r){return e(t(r))}}var on=Function.prototype,gt=Object.prototype,dt=on.toString,sn=gt.hasOwnProperty,fn=dt.call(Object),cn=gt.toString,ln=an(Object.getPrototypeOf,Object);function un(e){return!!e&&typeof e=="object"}function hn(e){if(!un(e)||cn.call(e)!=rn||nn(e))return!1;var t=ln(e);if(t===null)return!0;var r=sn.call(t,"constructor")&&t.constructor;return typeof r=="function"&&r instanceof r&&dt.call(r)==fn}bt.exports=hn});var bn={};xt(bn,{arrayiffyString:()=>A,defaults:()=>M,flattenArr:()=>R,flattenObject:()=>X,flattenReferencing:()=>dn,version:()=>gn});var be=H(ce(),1);function le(e,t,r=0){if(typeof e!="string")throw new TypeError(`str-indexes-of-plus/strIndexesOfPlus(): first input argument must be a string! Currently it's: ${typeof e}`);if(typeof t!="string")throw new TypeError(`str-indexes-of-plus/strIndexesOfPlus(): second input argument must be a string! Currently it's: ${typeof t}`);if(isNaN(+r)||typeof r=="string"&&!/^\d*$/.test(r))throw new TypeError(`str-indexes-of-plus/strIndexesOfPlus(): third input argument must be a natural number! Currently it's: ${r}`);let n=Array.from(e),a=Array.from(t);if(n.length===0||a.length===0||r!=null&&+r>=n.length)return[];r||(r=0);let o=[],u=!1,i;for(let c=r,l=n.length;c<l;c++)u&&(n[c]===a[c-+i]?c-+i+1===a.length&&o.push(+i):(i=null,u=!1)),u||n[c]===a[0]&&(a.length===1?o.push(c):(u=!0,i=c));return o}function ue(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var he=new Map,ht=(e,t)=>{if(!Array.isArray(e))switch(typeof e){case"string":e=[e];break;case"undefined":e=[];break;default:throw new TypeError(`Expected '${t}' to be a string or an array, but got a type of '${typeof e}'`)}return e.filter(r=>{if(typeof r!="string"){if(typeof r=="undefined")return!1;throw new TypeError(`Expected '${t}' to be an array of strings, but found a type of '${typeof r}' in the array`)}return!0})},en=(e,t)=>{t=y({caseSensitive:!1},t);let r=e+JSON.stringify(t);if(he.has(r))return he.get(r);let n=e[0]==="!";n&&(e=e.slice(1)),e=ue(e).replace(/\\\*/g,"[\\s\\S]*");let a=new RegExp(`^${e}$`,t.caseSensitive?"":"i");return a.negated=n,he.set(r,a),a},tn=(e,t,r,n)=>{if(e=ht(e,"inputs"),t=ht(t,"patterns"),t.length===0)return[];t=t.map(u=>en(u,r));let{allPatterns:a}=r||{},o=[];for(let u of e){let i,c=[...t].fill(!1);for(let[l,d]of t.entries())if(d.test(u)&&(c[l]=!0,i=!d.negated,!i))break;if(!(i===!1||i===void 0&&t.some(l=>!l.negated)||a&&c.some((l,d)=>!l&&!t[d].negated))&&(o.push(u),n))break}return o};function pt(e,t,r){return tn(e,t,r,!0).length>0}var Y=H(pe(),1);var ge=H(ce(),1),de=H(pe(),1),M={wrapHeadsWith:"%%_",wrapTailsWith:"_%%",dontWrapKeys:[],dontWrapPaths:[],xhtml:!0,preventDoubleWrapping:!0,preventWrappingIfContains:[],objectKeyAndValueJoinChar:".",wrapGlobalFlipSwitch:!0,ignore:[],whatToDoWhenReferenceIsMissing:0,mergeArraysWithLineBreaks:!0,mergeWithoutTrailingBrIfLineContainsBr:!0,enforceStrictKeyset:!0};function q(e){return typeof e=="string"}function X(e,t){let r=y(y({},M),t);if(arguments.length===0||Object.keys(e).length===0)return[];let n=(0,ge.default)(e),a=[];return(0,de.default)(n)&&Object.keys(n).forEach(o=>{(0,de.default)(n[o])&&(n[o]=X(n[o],r)),Array.isArray(n[o])&&(a=a.concat(n[o].map(u=>`${o}${r.objectKeyAndValueJoinChar}${u}`))),q(n[o])&&a.push(`${o}${r.objectKeyAndValueJoinChar}${n[o]}`)}),a}function R(e,t,r=!1,n=!1){let a=y(y({},M),t);if(arguments.length===0||e.length===0)return"";let o=(0,ge.default)(e),u="";if(o.length>0)if(n){for(let i=0,c=o.length;i<c;i++)if(q(o[i])){let l;l="",a.mergeArraysWithLineBreaks&&i>0&&(!a.mergeWithoutTrailingBrIfLineContainsBr||typeof o[i-1]!="string"||a.mergeWithoutTrailingBrIfLineContainsBr&&o[i-1]!==void 0&&!o[i-1].toLowerCase().includes("<br"))&&(l=`<br${a.xhtml?" /":""}>`),u+=`${l}${r?a.wrapHeadsWith:""}${o[i]}${r?a.wrapTailsWith:""}`}else if(Array.isArray(o[i])&&o[i].length>0&&o[i].every(q)){let l="";a.mergeArraysWithLineBreaks&&u.length>0&&(l=`<br${a.xhtml?" /":""}>`),u=o[i].reduce((d,s,p,f)=>{let g="";return p!==f.length-1&&(g=" "),d+(p===0?l:"")+(r?a.wrapHeadsWith:"")+s+(r?a.wrapTailsWith:"")+g},u)}}else u=o.reduce((i,c,l,d)=>{let s="";a.mergeArraysWithLineBreaks&&l>0&&(s=`<br${a.xhtml?" /":""}>`);let p="";return l!==d.length-1&&(p=" "),`${i}${l===0?s:""}${r?a.wrapHeadsWith:""}${c}${r?a.wrapTailsWith:""}${p}`},u);return u}function A(e){return q(e)?e.length>0?[e]:[]:e}var yt="6.0.12";var gn=yt;function D(e){return e!=null}function C(e){return typeof e=="string"}function dn(e,t,r){if(arguments.length===0)throw new Error("object-flatten-referencing/ofr(): [THROW_ID_01] all inputs missing!");if(arguments.length===1)throw new Error("object-flatten-referencing/ofr(): [THROW_ID_02] reference object missing!");if(D(r)&&!(0,Y.default)(r))throw new Error(`object-flatten-referencing/ofr(): [THROW_ID_03] third input, options object must be a plain object. Currently it's: ${typeof r}`);let n=y(y({},M),r);n.dontWrapKeys=A(n.dontWrapKeys),n.preventWrappingIfContains=A(n.preventWrappingIfContains),n.dontWrapPaths=A(n.dontWrapPaths),n.ignore=A(n.ignore),typeof n.whatToDoWhenReferenceIsMissing!="number"&&(n.whatToDoWhenReferenceIsMissing=+n.whatToDoWhenReferenceIsMissing||0);function a(o,u,i,c=!0,l=!0,d=""){let s=(0,be.default)(o),p=(0,be.default)(u);return i.wrapGlobalFlipSwitch||(c=!1),(0,Y.default)(s)?Object.keys(s).forEach(f=>{let g=d+(d.length===0?f:`.${f}`);if(i.ignore.length===0||!i.ignore.includes(f)){if(i.wrapGlobalFlipSwitch&&(c=!0,i.dontWrapKeys.length>0&&(c=c&&!i.dontWrapKeys.some(b=>pt(f,b,{caseSensitive:!0}))),i.dontWrapPaths.length>0&&(c=c&&!i.dontWrapPaths.some(b=>b===g)),i.preventWrappingIfContains.length>0&&typeof s[f]=="string"&&(c=c&&!i.preventWrappingIfContains.some(b=>s[f].includes(b)))),D(p[f])||!D(p[f])&&i.whatToDoWhenReferenceIsMissing===2)if(Array.isArray(s[f]))if(i.whatToDoWhenReferenceIsMissing===2||C(p[f]))s[f]=R(s[f],i,c,l);else{if(s[f].every(b=>typeof b=="string"||Array.isArray(b))){let b=!0;s[f].forEach(ye=>{Array.isArray(ye)&&!ye.every(C)&&(b=!1)}),b&&(l=!1)}s[f]=a(s[f],p[f],i,c,l,g)}else(0,Y.default)(s[f])?i.whatToDoWhenReferenceIsMissing===2||C(p[f])?s[f]=R(X(s[f],i),i,c,l):c?s[f]=a(s[f],p[f],i,c,l,g):s[f]=a(s[f],p[f],Te(y({},i),{wrapGlobalFlipSwitch:!1}),c,l,g):C(s[f])&&(s[f]=a(s[f],p[f],i,c,l,g));else if(typeof s[f]!=typeof p[f]&&i.whatToDoWhenReferenceIsMissing===1)throw new Error(`object-flatten-referencing/ofr(): [THROW_ID_06] reference object does not have the key ${f} and we need it. TIP: Turn off throwing via opts.whatToDoWhenReferenceIsMissing.`)}}):Array.isArray(s)?Array.isArray(p)?s.forEach((f,g)=>{D(s[g])&&D(p[g])?s[g]=a(s[g],p[g],i,c,l,`${d}[${g}]`):s[g]=a(s[g],p[0],i,c,l,`${d}[${g}]`)}):C(p)&&(s=R(s,i,c,l)):C(s)&&s.length>0&&(i.wrapHeadsWith||i.wrapTailsWith)&&(!i.preventDoubleWrapping||(i.wrapHeadsWith===""||!le(s,i.wrapHeadsWith.trim()).length)&&(i.wrapTailsWith===""||!le(s,i.wrapTailsWith.trim()).length))&&(s=`${c?i.wrapHeadsWith:""}${s}${c?i.wrapTailsWith:""}`),s}return a(e,t,n)}return Wt(bn);})();
|
|
11
11
|
/**
|
|
12
12
|
* @name str-indexes-of-plus
|
|
13
13
|
* @fileoverview Like indexOf but returns array and counts per-grapheme
|
|
14
|
-
* @version 4.0.
|
|
14
|
+
* @version 4.0.12
|
|
15
15
|
* @author Roy Revelt, Codsen Ltd
|
|
16
16
|
* @license MIT
|
|
17
17
|
* {@link https://codsen.com/os/str-indexes-of-plus/}
|
|
18
|
-
*/
|
|
18
|
+
*/
|
package/examples/_quickTake.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "object-flatten-referencing",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.12",
|
|
4
4
|
"description": "Flatten complex nested objects according to a reference objects",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"advanced",
|
|
@@ -33,98 +33,47 @@
|
|
|
33
33
|
},
|
|
34
34
|
"types": "types/index.d.ts",
|
|
35
35
|
"scripts": {
|
|
36
|
-
"build": "
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"prettier": "
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"test": "npm run test:ci && npm run perf",
|
|
52
|
-
"test:ci": "npm run unittest && npm run test:examples && npm run format",
|
|
53
|
-
"test:examples": "../../scripts/test-examples.js && npm run lect && npm run prettier",
|
|
54
|
-
"tsc": "tsc",
|
|
55
|
-
"unittest": "tap --no-only --reporter=terse && tsc -p tsconfig.json --noEmit"
|
|
36
|
+
"build": "node '../../ops/scripts/esbuild.js' && yarn run dts",
|
|
37
|
+
"dev": "DEV=true node '../../ops/scripts/esbuild.js' && yarn run dts",
|
|
38
|
+
"devtest": "c8 yarn run unit && yarn run examples && yarn run lint",
|
|
39
|
+
"dts": "rollup -c && yarn run prettier 'types/index.d.ts' --write",
|
|
40
|
+
"examples": "node '../../ops/scripts/run-examples.js'",
|
|
41
|
+
"lect": "node '../../ops/lect/lect.js' && yarn run prettier 'README.md' '.all-contributorsrc' 'rollup.config.js' --write",
|
|
42
|
+
"letspublish": "yarn publish || :",
|
|
43
|
+
"lint": "eslint . --fix",
|
|
44
|
+
"perf": "node perf/check.js",
|
|
45
|
+
"prepare": "echo 'ready'",
|
|
46
|
+
"prettier": "prettier",
|
|
47
|
+
"prettier:format": "prettier --write '**/*.{ts,tsx,md}' --no-error-on-unmatched-pattern",
|
|
48
|
+
"pretest": "yarn run lect && yarn run build",
|
|
49
|
+
"test": "yarn run devtest",
|
|
50
|
+
"unit": "uvu test"
|
|
56
51
|
},
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
52
|
+
"engines": {
|
|
53
|
+
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
|
54
|
+
},
|
|
55
|
+
"c8": {
|
|
56
|
+
"check-coverage": true,
|
|
57
|
+
"exclude": [
|
|
58
|
+
"**/test/**/*.*"
|
|
63
59
|
],
|
|
64
|
-
"
|
|
60
|
+
"lines": 100
|
|
65
61
|
},
|
|
66
62
|
"lect": {
|
|
67
63
|
"licence": {
|
|
68
64
|
"extras": [
|
|
69
65
|
""
|
|
70
66
|
]
|
|
71
|
-
},
|
|
72
|
-
"req": "{ flattenReferencing }",
|
|
73
|
-
"various": {
|
|
74
|
-
"devDependencies": [
|
|
75
|
-
"@types/lodash.clonedeep",
|
|
76
|
-
"@types/lodash.isplainobject"
|
|
77
|
-
]
|
|
78
67
|
}
|
|
79
68
|
},
|
|
80
69
|
"dependencies": {
|
|
81
|
-
"@babel/runtime": "^7.16.3",
|
|
82
70
|
"lodash.clonedeep": "^4.5.0",
|
|
83
71
|
"lodash.isplainobject": "^4.0.6",
|
|
84
72
|
"matcher": "^5.0.0",
|
|
85
|
-
"str-indexes-of-plus": "^4.0.
|
|
73
|
+
"str-indexes-of-plus": "^4.0.12"
|
|
86
74
|
},
|
|
87
75
|
"devDependencies": {
|
|
88
|
-
"@babel/cli": "^7.16.0",
|
|
89
|
-
"@babel/core": "^7.16.0",
|
|
90
|
-
"@babel/node": "^7.16.0",
|
|
91
|
-
"@babel/plugin-external-helpers": "^7.16.0",
|
|
92
|
-
"@babel/plugin-proposal-class-properties": "^7.16.0",
|
|
93
|
-
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
|
|
94
|
-
"@babel/plugin-proposal-object-rest-spread": "^7.16.0",
|
|
95
|
-
"@babel/plugin-proposal-optional-chaining": "^7.16.0",
|
|
96
|
-
"@babel/plugin-transform-runtime": "^7.16.4",
|
|
97
|
-
"@babel/preset-env": "^7.16.4",
|
|
98
|
-
"@babel/preset-typescript": "^7.16.0",
|
|
99
|
-
"@babel/register": "^7.16.0",
|
|
100
|
-
"@istanbuljs/esm-loader-hook": "^0.1.2",
|
|
101
|
-
"@rollup/plugin-babel": "^5.3.0",
|
|
102
|
-
"@rollup/plugin-commonjs": "^21.0.1",
|
|
103
|
-
"@rollup/plugin-json": "^4.1.0",
|
|
104
|
-
"@rollup/plugin-node-resolve": "^13.0.6",
|
|
105
|
-
"@rollup/plugin-strip": "^2.1.0",
|
|
106
|
-
"@rollup/plugin-typescript": "^8.3.0",
|
|
107
76
|
"@types/lodash.clonedeep": "^4.5.6",
|
|
108
|
-
"@types/lodash.isplainobject": "^4.0.6"
|
|
109
|
-
"@types/node": "^16.11.9",
|
|
110
|
-
"@types/tap": "^15.0.5",
|
|
111
|
-
"@typescript-eslint/eslint-plugin": "^5.4.0",
|
|
112
|
-
"@typescript-eslint/parser": "^5.4.0",
|
|
113
|
-
"core-js": "^3.19.1",
|
|
114
|
-
"cross-env": "^7.0.3",
|
|
115
|
-
"eslint": "^8.3.0",
|
|
116
|
-
"lect": "^0.18.6",
|
|
117
|
-
"rollup": "^2.60.0",
|
|
118
|
-
"rollup-plugin-ascii": "^0.0.3",
|
|
119
|
-
"rollup-plugin-banner": "^0.2.1",
|
|
120
|
-
"rollup-plugin-cleanup": "^3.2.1",
|
|
121
|
-
"rollup-plugin-dts": "^4.0.1",
|
|
122
|
-
"rollup-plugin-terser": "^7.0.2",
|
|
123
|
-
"tap": "^15.1.2",
|
|
124
|
-
"tslib": "^2.3.1",
|
|
125
|
-
"typescript": "^4.5.2"
|
|
126
|
-
},
|
|
127
|
-
"engines": {
|
|
128
|
-
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
|
77
|
+
"@types/lodash.isplainobject": "^4.0.6"
|
|
129
78
|
}
|
|
130
79
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,28 +1,47 @@
|
|
|
1
1
|
interface Obj {
|
|
2
|
-
|
|
2
|
+
[key: string]: any;
|
|
3
3
|
}
|
|
4
4
|
interface Opts {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
5
|
+
wrapHeadsWith: string;
|
|
6
|
+
wrapTailsWith: string;
|
|
7
|
+
dontWrapKeys: string[];
|
|
8
|
+
dontWrapPaths: string[];
|
|
9
|
+
xhtml: boolean;
|
|
10
|
+
preventDoubleWrapping: boolean;
|
|
11
|
+
preventWrappingIfContains: string[];
|
|
12
|
+
objectKeyAndValueJoinChar: string;
|
|
13
|
+
wrapGlobalFlipSwitch: boolean;
|
|
14
|
+
ignore: string[];
|
|
15
|
+
whatToDoWhenReferenceIsMissing: 0 | 1 | 2;
|
|
16
|
+
mergeArraysWithLineBreaks: boolean;
|
|
17
|
+
mergeWithoutTrailingBrIfLineContainsBr: boolean;
|
|
18
|
+
enforceStrictKeyset: boolean;
|
|
19
19
|
}
|
|
20
20
|
declare const defaults: Opts;
|
|
21
|
-
declare function flattenObject(
|
|
22
|
-
|
|
21
|
+
declare function flattenObject(
|
|
22
|
+
objOrig: Obj,
|
|
23
|
+
originalOpts?: Partial<Opts>
|
|
24
|
+
): any[];
|
|
25
|
+
declare function flattenArr(
|
|
26
|
+
arrOrig: any[],
|
|
27
|
+
originalOpts?: Partial<Opts>,
|
|
28
|
+
wrap?: boolean,
|
|
29
|
+
joinArraysUsingBrs?: boolean
|
|
30
|
+
): string;
|
|
23
31
|
declare function arrayiffyString(something: string | any): any;
|
|
24
32
|
|
|
25
33
|
declare const version: string;
|
|
26
|
-
declare function flattenReferencing(
|
|
34
|
+
declare function flattenReferencing(
|
|
35
|
+
originalInput1: any,
|
|
36
|
+
originalReference1: any,
|
|
37
|
+
opts1?: Partial<Opts>
|
|
38
|
+
): any;
|
|
27
39
|
|
|
28
|
-
export {
|
|
40
|
+
export {
|
|
41
|
+
arrayiffyString,
|
|
42
|
+
defaults,
|
|
43
|
+
flattenArr,
|
|
44
|
+
flattenObject,
|
|
45
|
+
flattenReferencing,
|
|
46
|
+
version,
|
|
47
|
+
};
|
package/types/util.d.ts
CHANGED
|
@@ -1,23 +1,28 @@
|
|
|
1
1
|
interface Obj {
|
|
2
|
-
|
|
2
|
+
[key: string]: any;
|
|
3
3
|
}
|
|
4
4
|
interface Opts {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
5
|
+
wrapHeadsWith: string;
|
|
6
|
+
wrapTailsWith: string;
|
|
7
|
+
dontWrapKeys: string[];
|
|
8
|
+
dontWrapPaths: string[];
|
|
9
|
+
xhtml: boolean;
|
|
10
|
+
preventDoubleWrapping: boolean;
|
|
11
|
+
preventWrappingIfContains: string[];
|
|
12
|
+
objectKeyAndValueJoinChar: string;
|
|
13
|
+
wrapGlobalFlipSwitch: boolean;
|
|
14
|
+
ignore: string[];
|
|
15
|
+
whatToDoWhenReferenceIsMissing: 0 | 1 | 2;
|
|
16
|
+
mergeArraysWithLineBreaks: boolean;
|
|
17
|
+
mergeWithoutTrailingBrIfLineContainsBr: boolean;
|
|
18
|
+
enforceStrictKeyset: boolean;
|
|
19
19
|
}
|
|
20
20
|
declare function flattenObject(objOrig: Obj, opts: Opts): any[];
|
|
21
|
-
declare function flattenArr(
|
|
21
|
+
declare function flattenArr(
|
|
22
|
+
arrOrig: any[],
|
|
23
|
+
opts: Opts,
|
|
24
|
+
wrap: boolean,
|
|
25
|
+
joinArraysUsingBrs: boolean
|
|
26
|
+
): string;
|
|
22
27
|
declare function arrayiffyString(something: string | any): any;
|
|
23
28
|
export { flattenObject, flattenArr, arrayiffyString, Obj, Opts };
|
package/examples/api.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"_quickTake.js":{"title":"Quick Take","content":"import { strict as assert } from \"assert\";\nimport { flattenReferencing } from \"object-flatten-referencing\";\n\nassert.deepEqual(\n flattenReferencing(\n {\n key1: \"val11.val12\",\n key2: \"val21.val22\",\n },\n {\n key1: \"Contact us\",\n key2: \"Tel. 0123456789\",\n }\n ),\n {\n key1: \"%%_val11.val12_%%\",\n key2: \"%%_val21.val22_%%\",\n }\n);"}}
|