@lowdefy/helpers 4.0.0-rc.0 → 4.0.0-rc.10
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 +2 -2
- package/dist/applyArrayIndices.js +1 -1
- package/dist/cachedPromises.js +2 -2
- package/dist/get.js +1 -1
- package/dist/index.js +1 -1
- package/dist/mergeObjects.js +1 -1
- package/dist/omit.js +1 -1
- package/dist/serializer.js +53 -23
- package/dist/set.js +2 -2
- package/dist/stableStringify.js +1 -1
- package/dist/swap.js +1 -1
- package/dist/type.js +13 -12
- package/dist/unset.js +1 -1
- package/dist/urlQuery.js +1 -1
- package/dist/wait.js +1 -1
- package/package.json +10 -9
package/dist/LRUCache.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -38,7 +38,7 @@ let LRUCache = class LRUCache {
|
|
|
38
38
|
first() {
|
|
39
39
|
return this.cache.keys().next().value;
|
|
40
40
|
}
|
|
41
|
-
constructor({ maxSize =100
|
|
41
|
+
constructor({ maxSize = 100 } = {}){
|
|
42
42
|
this.maxSize = maxSize;
|
|
43
43
|
this.cache = new Map();
|
|
44
44
|
}
|
package/dist/cachedPromises.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -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/get.js
CHANGED
package/dist/index.js
CHANGED
package/dist/mergeObjects.js
CHANGED
package/dist/omit.js
CHANGED
package/dist/serializer.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable no-param-reassign */ /*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable no-plusplus */ /* eslint-disable no-use-before-define */ /* eslint-disable no-param-reassign */ /*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -56,7 +56,7 @@ function set(target, path, value, options) {
|
|
|
56
56
|
if (!type.isArray(path) && !type.isString(path)) {
|
|
57
57
|
return target;
|
|
58
58
|
}
|
|
59
|
-
let { merge
|
|
59
|
+
let { merge } = opts;
|
|
60
60
|
if (merge && typeof merge !== 'function') {
|
|
61
61
|
merge = Object.assign;
|
|
62
62
|
}
|
package/dist/stableStringify.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable no-continue */ /* eslint-disable no-plusplus */ /* eslint-disable consistent-return */ /* eslint-disable no-param-reassign */ /*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
package/dist/swap.js
CHANGED
package/dist/type.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable indent */ /* eslint-disable default-case */ /*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -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
|
}
|
|
@@ -65,12 +65,12 @@ function kindOf(val) {
|
|
|
65
65
|
// eslint-disable-next-line no-void
|
|
66
66
|
if (val === void 0) return 'undefined';
|
|
67
67
|
if (val === null) return 'null';
|
|
68
|
-
let
|
|
69
|
-
if (
|
|
70
|
-
if (
|
|
71
|
-
if (
|
|
72
|
-
if (
|
|
73
|
-
if (
|
|
68
|
+
let type = typeof val;
|
|
69
|
+
if (type === 'boolean') return 'boolean';
|
|
70
|
+
if (type === 'string') return 'string';
|
|
71
|
+
if (type === 'number') return 'number';
|
|
72
|
+
if (type === 'symbol') return 'symbol';
|
|
73
|
+
if (type === 'function') {
|
|
74
74
|
return isGeneratorFn(val) ? 'generatorfunction' : 'function';
|
|
75
75
|
}
|
|
76
76
|
if (isArray(val)) return 'array';
|
|
@@ -119,8 +119,8 @@ function kindOf(val) {
|
|
|
119
119
|
return 'generator';
|
|
120
120
|
}
|
|
121
121
|
// Non-plain objects
|
|
122
|
-
|
|
123
|
-
switch(
|
|
122
|
+
type = toString.call(val);
|
|
123
|
+
switch(type){
|
|
124
124
|
case '[object Object]':
|
|
125
125
|
return 'object';
|
|
126
126
|
// iterators
|
|
@@ -134,7 +134,7 @@ function kindOf(val) {
|
|
|
134
134
|
return 'arrayiterator';
|
|
135
135
|
}
|
|
136
136
|
// other
|
|
137
|
-
return
|
|
137
|
+
return type.slice(8, -1).toLowerCase().replace(/\s/g, '');
|
|
138
138
|
}
|
|
139
139
|
const reISO = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*))(?:Z|(\+|-)([\d|:]*))?$/;
|
|
140
140
|
function isDateString(val) {
|
|
@@ -158,7 +158,8 @@ type.isSet = (value)=>kindOf(value) === 'set';
|
|
|
158
158
|
type.isNull = (value)=>kindOf(value) === 'null';
|
|
159
159
|
type.isUndefined = (value)=>kindOf(value) === 'undefined';
|
|
160
160
|
type.isNone = (value)=>kindOf(value) === 'undefined' || kindOf(value) === 'null';
|
|
161
|
-
type.isPrimitive = (value)=>kindOf(value) === 'undefined' ||
|
|
161
|
+
type.isPrimitive = (value)=>kindOf(value) === 'undefined' || // are we making undefined a primative ?
|
|
162
|
+
kindOf(value) === 'null' || kindOf(value) === 'string' || kindOf(value) === 'number' || kindOf(value) === 'boolean' || kindOf(value) === 'date';
|
|
162
163
|
type.isEmptyObject = (value)=>kindOf(value) === 'object' && Object.keys(value).length === 0;
|
|
163
164
|
// Lowdefy operator types
|
|
164
165
|
function isName(value) {
|
package/dist/unset.js
CHANGED
package/dist/urlQuery.js
CHANGED
package/dist/wait.js
CHANGED
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.10",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -34,21 +34,22 @@
|
|
|
34
34
|
"build": "swc src --out-dir dist --config-file ../../../.swcrc --delete-dir-on-start",
|
|
35
35
|
"clean": "rm -rf dist",
|
|
36
36
|
"prepublishOnly": "pnpm build",
|
|
37
|
-
"test": "
|
|
37
|
+
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"lodash.merge": "4.6.2",
|
|
41
|
-
"query-string": "
|
|
41
|
+
"query-string": "8.1.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@
|
|
45
|
-
"@swc/
|
|
46
|
-
"@swc/
|
|
47
|
-
"jest": "
|
|
48
|
-
"jest
|
|
44
|
+
"@jest/globals": "28.1.3",
|
|
45
|
+
"@swc/cli": "0.1.62",
|
|
46
|
+
"@swc/core": "1.3.70",
|
|
47
|
+
"@swc/jest": "0.2.27",
|
|
48
|
+
"jest": "28.1.3",
|
|
49
|
+
"jest-diff": "28.1.3"
|
|
49
50
|
},
|
|
50
51
|
"publishConfig": {
|
|
51
52
|
"access": "public"
|
|
52
53
|
},
|
|
53
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "537af074f27770e32da9da8d48490f2eda94b406"
|
|
54
55
|
}
|