@lowdefy/helpers 4.0.0-rc.1 → 4.0.0-rc.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/LRUCache.js +1 -1
- package/dist/cachedPromises.js +1 -1
- package/dist/serializer.js +52 -22
- package/dist/set.js +1 -1
- package/dist/stableStringify.js +5 -5
- package/dist/type.js +1 -1
- package/package.json +8 -8
package/dist/LRUCache.js
CHANGED
package/dist/cachedPromises.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
|
-
*/ function createCachedPromises({ getter
|
|
15
|
+
*/ function createCachedPromises({ getter, cache }) {
|
|
16
16
|
function cachedPromises(key) {
|
|
17
17
|
const cached = cache.get(key);
|
|
18
18
|
if (cached) {
|
package/dist/serializer.js
CHANGED
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
import stableStringify from './stableStringify.js';
|
|
17
17
|
const makeReplacer = (customReplacer, isoStringDates)=>(key, value)=>{
|
|
18
18
|
let dateReplacer = (date)=>({
|
|
19
|
-
|
|
19
|
+
'~d': date.valueOf()
|
|
20
20
|
});
|
|
21
21
|
if (isoStringDates) {
|
|
22
22
|
dateReplacer = (date)=>({
|
|
23
|
-
|
|
23
|
+
'~d': date.toISOString()
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
let newValue = value;
|
|
@@ -29,7 +29,7 @@ const makeReplacer = (customReplacer, isoStringDates)=>(key, value)=>{
|
|
|
29
29
|
}
|
|
30
30
|
if (type.isError(newValue)) {
|
|
31
31
|
return {
|
|
32
|
-
|
|
32
|
+
'~e': {
|
|
33
33
|
name: newValue.name,
|
|
34
34
|
message: newValue.message,
|
|
35
35
|
value: newValue.toString()
|
|
@@ -46,6 +46,22 @@ const makeReplacer = (customReplacer, isoStringDates)=>(key, value)=>{
|
|
|
46
46
|
newValue[k] = dateReplacer(newValue[k]);
|
|
47
47
|
}
|
|
48
48
|
});
|
|
49
|
+
if (newValue['~r']) {
|
|
50
|
+
Object.defineProperty(newValue, '~r', {
|
|
51
|
+
value: newValue['~r'],
|
|
52
|
+
enumerable: true,
|
|
53
|
+
writable: true,
|
|
54
|
+
configurable: true
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
if (newValue['~k']) {
|
|
58
|
+
Object.defineProperty(newValue, '~k', {
|
|
59
|
+
value: newValue['~k'],
|
|
60
|
+
enumerable: true,
|
|
61
|
+
writable: true,
|
|
62
|
+
configurable: true
|
|
63
|
+
});
|
|
64
|
+
}
|
|
49
65
|
return newValue;
|
|
50
66
|
}
|
|
51
67
|
if (type.isArray(newValue)) {
|
|
@@ -60,26 +76,40 @@ const makeReplacer = (customReplacer, isoStringDates)=>(key, value)=>{
|
|
|
60
76
|
};
|
|
61
77
|
const makeReviver = (customReviver)=>(key, value)=>{
|
|
62
78
|
let newValue = value;
|
|
79
|
+
if (type.isObject(newValue)) {
|
|
80
|
+
if (newValue['~r']) {
|
|
81
|
+
Object.defineProperty(newValue, '~r', {
|
|
82
|
+
value: newValue['~r'],
|
|
83
|
+
enumerable: false,
|
|
84
|
+
writable: true,
|
|
85
|
+
configurable: true
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
if (newValue['~k']) {
|
|
89
|
+
Object.defineProperty(newValue, '~k', {
|
|
90
|
+
value: newValue['~k'],
|
|
91
|
+
enumerable: false,
|
|
92
|
+
writable: true,
|
|
93
|
+
configurable: true
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
63
97
|
if (customReviver) {
|
|
64
98
|
newValue = customReviver(key, value);
|
|
65
99
|
}
|
|
66
|
-
if (type.isObject(newValue)
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (type.isObject(newValue) && !type.isUndefined(newValue._date)) {
|
|
72
|
-
if (type.isInt(newValue._date)) {
|
|
73
|
-
return new Date(newValue._date);
|
|
74
|
-
}
|
|
75
|
-
if (newValue._date === 'now') {
|
|
76
|
-
return newValue;
|
|
100
|
+
if (type.isObject(newValue)) {
|
|
101
|
+
if (!type.isUndefined(newValue['~e'])) {
|
|
102
|
+
const error = new Error(newValue['~e'].message);
|
|
103
|
+
error.name = newValue['~e'].name;
|
|
104
|
+
return error;
|
|
77
105
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
106
|
+
if (!type.isUndefined(newValue['~d'])) {
|
|
107
|
+
const result = new Date(newValue['~d']);
|
|
108
|
+
if (!type.isDate(result)) {
|
|
109
|
+
return newValue;
|
|
110
|
+
}
|
|
111
|
+
return result;
|
|
81
112
|
}
|
|
82
|
-
return result;
|
|
83
113
|
}
|
|
84
114
|
return newValue;
|
|
85
115
|
};
|
|
@@ -88,11 +118,11 @@ const serialize = (json, options = {})=>{
|
|
|
88
118
|
if (type.isDate(json)) {
|
|
89
119
|
if (options.isoStringDates) {
|
|
90
120
|
return {
|
|
91
|
-
|
|
121
|
+
'~d': json.toISOString()
|
|
92
122
|
};
|
|
93
123
|
}
|
|
94
124
|
return {
|
|
95
|
-
|
|
125
|
+
'~d': json.valueOf()
|
|
96
126
|
};
|
|
97
127
|
}
|
|
98
128
|
return JSON.parse(JSON.stringify(json, makeReplacer(options.replacer, options.isoStringDates)));
|
|
@@ -101,9 +131,9 @@ const serializeToString = (json, options = {})=>{
|
|
|
101
131
|
if (type.isUndefined(json)) return json;
|
|
102
132
|
if (type.isDate(json)) {
|
|
103
133
|
if (options.isoStringDates) {
|
|
104
|
-
return `{ "
|
|
134
|
+
return `{ "~d": "${json.toISOString()}" }`;
|
|
105
135
|
}
|
|
106
|
-
return `{ "
|
|
136
|
+
return `{ "~d": ${json.valueOf()} }`;
|
|
107
137
|
}
|
|
108
138
|
if (options.stable) {
|
|
109
139
|
return stableStringify(json, {
|
package/dist/set.js
CHANGED
package/dist/stableStringify.js
CHANGED
|
@@ -82,16 +82,16 @@ function stableStringify(obj, opts) {
|
|
|
82
82
|
throw new TypeError('Converting circular structure to JSON');
|
|
83
83
|
} else seen.push(node);
|
|
84
84
|
const keys = Object.keys(node).sort(cmp && cmp(node));
|
|
85
|
-
const
|
|
86
|
-
for(let
|
|
87
|
-
const ky = keys[
|
|
85
|
+
const out = [];
|
|
86
|
+
for(let i = 0; i < keys.length; i++){
|
|
87
|
+
const ky = keys[i];
|
|
88
88
|
const value = stringify(node, ky, node[ky], level + 1);
|
|
89
89
|
if (!value) continue;
|
|
90
90
|
const keyValue = JSON.stringify(ky) + colonSeparator + value;
|
|
91
|
-
|
|
91
|
+
out.push(indent + space + keyValue);
|
|
92
92
|
}
|
|
93
93
|
seen.splice(seen.indexOf(node), 1);
|
|
94
|
-
return `{${
|
|
94
|
+
return `{${out.join(',')}${indent}}`;
|
|
95
95
|
}({
|
|
96
96
|
'': obj
|
|
97
97
|
}, '', obj, 0);
|
package/dist/type.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/ // Derived from source:
|
|
16
16
|
// because both js typeof and instance of sucks! use this.
|
|
17
17
|
// https://ultimatecourses.com/blog/understanding-javascript-types-and-reliable-type-checking
|
|
18
|
-
const { toString
|
|
18
|
+
const { toString } = Object.prototype;
|
|
19
19
|
function ctorName(val) {
|
|
20
20
|
return val.constructor ? val.constructor.name : null;
|
|
21
21
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/helpers",
|
|
3
|
-
"version": "4.0.0-rc.
|
|
3
|
+
"version": "4.0.0-rc.11",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -41,15 +41,15 @@
|
|
|
41
41
|
"query-string": "8.1.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@jest/globals": "28.1.
|
|
45
|
-
"@swc/cli": "0.1.
|
|
46
|
-
"@swc/core": "1.3.
|
|
47
|
-
"@swc/jest": "0.2.
|
|
48
|
-
"jest": "28.1.
|
|
49
|
-
"jest-diff": "28.1.
|
|
44
|
+
"@jest/globals": "28.1.3",
|
|
45
|
+
"@swc/cli": "0.1.62",
|
|
46
|
+
"@swc/core": "1.3.92",
|
|
47
|
+
"@swc/jest": "0.2.29",
|
|
48
|
+
"jest": "28.1.3",
|
|
49
|
+
"jest-diff": "28.1.3"
|
|
50
50
|
},
|
|
51
51
|
"publishConfig": {
|
|
52
52
|
"access": "public"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "dbc49d3688a6d2f44de25cc3f4bc071627f7ebfa"
|
|
55
55
|
}
|