@poppinss/utils 5.0.0 → 6.0.0-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +661 -873
- package/build/index.d.ts +16 -10
- package/build/index.js +21 -53
- package/build/lodash/main.cjs +37 -0
- package/build/src/{Helpers/base64.d.ts → base64.d.ts} +7 -23
- package/build/src/{Helpers/base64.js → base64.js} +9 -22
- package/build/src/{Helpers/compose.d.ts → compose.d.ts} +0 -11
- package/build/src/compose.js +3 -0
- package/build/src/{defineStaticProperty.d.ts → define_static_property.d.ts} +2 -6
- package/build/src/define_static_property.js +21 -0
- package/build/src/exception.d.ts +16 -0
- package/build/src/exception.js +29 -0
- package/build/src/flatten.d.ts +1 -1
- package/build/src/flatten.js +4 -13
- package/build/src/fs_import_all.d.ts +3 -0
- package/build/src/fs_import_all.js +28 -0
- package/build/src/fs_read_all.d.ts +3 -0
- package/build/src/fs_read_all.js +55 -0
- package/build/src/is_script_file.d.ts +1 -0
- package/build/src/is_script_file.js +12 -0
- package/build/src/json/main.d.ts +7 -0
- package/build/src/json/main.js +6 -0
- package/build/src/json/safe_parse.d.ts +2 -0
- package/build/src/json/safe_parse.js +7 -0
- package/build/src/json/safe_stringify.d.ts +2 -0
- package/build/src/json/safe_stringify.js +18 -0
- package/build/src/message_builder.d.ts +5 -0
- package/build/src/message_builder.js +43 -0
- package/build/src/natural_sort.d.ts +1 -0
- package/build/src/natural_sort.js +3 -0
- package/build/src/object_builder.d.ts +10 -0
- package/build/src/object_builder.js +31 -0
- package/build/src/{Helpers/safeEqual.d.ts → safe_equal.d.ts} +1 -4
- package/build/src/safe_equal.js +14 -0
- package/build/src/slash.d.ts +1 -5
- package/build/src/slash.js +1 -24
- package/build/src/string/bytes.d.ts +6 -0
- package/build/src/string/bytes.js +12 -0
- package/build/src/string/change_case.d.ts +13 -0
- package/build/src/string/change_case.js +75 -0
- package/build/src/string/excerpt.d.ts +4 -0
- package/build/src/string/excerpt.js +10 -0
- package/build/src/string/interpolate.d.ts +1 -0
- package/build/src/{Helpers → string}/interpolate.js +1 -22
- package/build/src/string/main.d.ts +46 -0
- package/build/src/string/main.js +42 -0
- package/build/src/string/milliseconds.d.ts +5 -0
- package/build/src/string/milliseconds.js +16 -0
- package/build/src/string/ordinal.d.ts +1 -0
- package/build/src/string/ordinal.js +21 -0
- package/build/src/string/pluralize.d.ts +12 -0
- package/build/src/string/pluralize.js +12 -0
- package/build/src/string/random.d.ts +1 -0
- package/build/src/string/random.js +7 -0
- package/build/src/string/seconds.d.ts +5 -0
- package/build/src/string/seconds.js +16 -0
- package/build/src/string/slugify.d.ts +2 -0
- package/build/src/string/slugify.js +2 -0
- package/build/src/string/to_sentence.d.ts +5 -0
- package/build/src/string/to_sentence.js +13 -0
- package/build/src/string/truncate.d.ts +4 -0
- package/build/src/string/truncate.js +10 -0
- package/build/src/types.d.ts +14 -0
- package/build/src/types.js +1 -0
- package/lodash/lodash.types.d.ts +44 -0
- package/package.json +70 -82
- package/build/helpers.d.ts +0 -1
- package/build/helpers.js +0 -25
- package/build/src/Exception.d.ts +0 -17
- package/build/src/Exception.js +0 -68
- package/build/src/Helpers/MessageBuilder.d.ts +0 -28
- package/build/src/Helpers/MessageBuilder.js +0 -97
- package/build/src/Helpers/ObjectBuilder.d.ts +0 -46
- package/build/src/Helpers/ObjectBuilder.js +0 -75
- package/build/src/Helpers/compose.js +0 -15
- package/build/src/Helpers/fsReadAll.d.ts +0 -4
- package/build/src/Helpers/fsReadAll.js +0 -23
- package/build/src/Helpers/index.d.ts +0 -14
- package/build/src/Helpers/index.js +0 -62
- package/build/src/Helpers/interpolate.d.ts +0 -7
- package/build/src/Helpers/requireAll.d.ts +0 -8
- package/build/src/Helpers/requireAll.js +0 -65
- package/build/src/Helpers/resolveDir.d.ts +0 -5
- package/build/src/Helpers/resolveDir.js +0 -46
- package/build/src/Helpers/resolveFrom.d.ts +0 -5
- package/build/src/Helpers/resolveFrom.js +0 -27
- package/build/src/Helpers/safeEqual.js +0 -42
- package/build/src/Helpers/string.d.ts +0 -124
- package/build/src/Helpers/string.js +0 -328
- package/build/src/Helpers/types.d.ts +0 -86
- package/build/src/Helpers/types.js +0 -161
- package/build/src/ManagerConfigValidator.d.ts +0 -20
- package/build/src/ManagerConfigValidator.js +0 -55
- package/build/src/defineStaticProperty.js +0 -57
- package/build/src/esmRequire.d.ts +0 -5
- package/build/src/esmRequire.js +0 -20
- package/build/src/esmResolver.d.ts +0 -1
- package/build/src/esmResolver.js +0 -15
- package/build/src/fast-safe-stringify.d.ts +0 -2
- package/build/src/fast-safe-stringify.js +0 -101
- package/build/src/isScriptFile.d.ts +0 -5
- package/build/src/isScriptFile.js +0 -28
- package/build/src/lodash.d.ts +0 -13
- package/build/src/lodash.js +0 -39
- package/build/src/safeParse.d.ts +0 -5
- package/build/src/safeParse.js +0 -42
- package/build/src/safeStringify.d.ts +0 -5
- package/build/src/safeStringify.js +0 -39
- package/types/lodash.types.d.ts +0 -65
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* @poppinss/utils
|
|
4
|
-
*
|
|
5
|
-
* (c) Harminder Virk <virk@adonisjs.com>
|
|
6
|
-
*
|
|
7
|
-
* For the full copyright and license information, please view the LICENSE
|
|
8
|
-
* file that was distributed with this source code.
|
|
9
|
-
*/
|
|
10
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
11
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.defineStaticProperty = void 0;
|
|
15
|
-
const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
|
|
16
|
-
/**
|
|
17
|
-
* Define static properties on a class with inheritance in play.
|
|
18
|
-
*/
|
|
19
|
-
function defineStaticProperty(self, BaseClass, { propertyName, defaultValue, strategy, }) {
|
|
20
|
-
if (!self.hasOwnProperty(propertyName)) {
|
|
21
|
-
/**
|
|
22
|
-
* Class is inhering the base class directly and hence we don't have to
|
|
23
|
-
* copy any properties
|
|
24
|
-
*/
|
|
25
|
-
if (Object.getPrototypeOf(self.prototype) === BaseClass.prototype || strategy === 'define') {
|
|
26
|
-
Object.defineProperty(self, propertyName, {
|
|
27
|
-
value: defaultValue,
|
|
28
|
-
configurable: true,
|
|
29
|
-
enumerable: true,
|
|
30
|
-
writable: true,
|
|
31
|
-
});
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Class is inherting another sub class. We must copy the values to the self
|
|
36
|
-
* class, otherwise mutating them inside the self class will be reflected
|
|
37
|
-
* on the base class.
|
|
38
|
-
*/
|
|
39
|
-
const value = self[propertyName];
|
|
40
|
-
if (value === undefined) {
|
|
41
|
-
Object.defineProperty(self, propertyName, {
|
|
42
|
-
value: defaultValue,
|
|
43
|
-
configurable: true,
|
|
44
|
-
enumerable: true,
|
|
45
|
-
writable: true,
|
|
46
|
-
});
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
Object.defineProperty(self, propertyName, {
|
|
50
|
-
value: typeof strategy === 'function' ? strategy(value) : (0, cloneDeep_1.default)(value),
|
|
51
|
-
configurable: true,
|
|
52
|
-
enumerable: true,
|
|
53
|
-
writable: true,
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
exports.defineStaticProperty = defineStaticProperty;
|
package/build/src/esmRequire.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* @poppinss/utils
|
|
4
|
-
*
|
|
5
|
-
* (c) Harminder Virk <virk@adonisjs.com>
|
|
6
|
-
*
|
|
7
|
-
* For the full copyright and license information, please view the LICENSE
|
|
8
|
-
* file that was distributed with this source code.
|
|
9
|
-
*/
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.esmRequire = void 0;
|
|
12
|
-
const esmResolver_1 = require("./esmResolver");
|
|
13
|
-
/**
|
|
14
|
-
* Handles ESM `default` exports and common js vanilla exports. The `default`
|
|
15
|
-
* exports are only entertained, when `esmEnabled` is set to true.
|
|
16
|
-
*/
|
|
17
|
-
function esmRequire(filePath) {
|
|
18
|
-
return (0, esmResolver_1.esmResolver)(require(filePath));
|
|
19
|
-
}
|
|
20
|
-
exports.esmRequire = esmRequire;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function esmResolver(output: any): any;
|
package/build/src/esmResolver.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* @poppinss/utils
|
|
4
|
-
*
|
|
5
|
-
* (c) Harminder Virk <virk@adonisjs.com>
|
|
6
|
-
*
|
|
7
|
-
* For the full copyright and license information, please view the LICENSE
|
|
8
|
-
* file that was distributed with this source code.
|
|
9
|
-
*/
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.esmResolver = void 0;
|
|
12
|
-
function esmResolver(output) {
|
|
13
|
-
return output && output.__esModule && output.default ? output.default : output;
|
|
14
|
-
}
|
|
15
|
-
exports.esmResolver = esmResolver;
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* @poppinss/utils
|
|
4
|
-
*
|
|
5
|
-
* (c) Harminder Virk <virk@adonisjs.com>
|
|
6
|
-
*
|
|
7
|
-
* For the full copyright and license information, please view the LICENSE
|
|
8
|
-
* file that was distributed with this source code.
|
|
9
|
-
*/
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.stringify = void 0;
|
|
12
|
-
/**
|
|
13
|
-
* Exact copy of https://github.com/davidmarkclements/fast-safe-stringify/blob/master/index.js
|
|
14
|
-
* with a few changes that were introduced in https://github.com/davidmarkclements/fast-safe-stringify/pull/52 PR.
|
|
15
|
-
*/
|
|
16
|
-
const arr = [];
|
|
17
|
-
const replacerStack = [];
|
|
18
|
-
// Regular stringify
|
|
19
|
-
function stringify(obj, replacer, spacer) {
|
|
20
|
-
decirc(obj, '', [], undefined);
|
|
21
|
-
let res;
|
|
22
|
-
if (replacerStack.length === 0) {
|
|
23
|
-
res = JSON.stringify(obj, replacer, spacer);
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
res = JSON.stringify(obj, replaceGetterValues(replacer), spacer);
|
|
27
|
-
}
|
|
28
|
-
while (arr.length !== 0) {
|
|
29
|
-
var part = arr.pop();
|
|
30
|
-
if (part.length === 4) {
|
|
31
|
-
Object.defineProperty(part[0], part[1], part[3]);
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
part[0][part[1]] = part[2];
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return res;
|
|
38
|
-
}
|
|
39
|
-
exports.stringify = stringify;
|
|
40
|
-
function decirc(val, k, stack, parent) {
|
|
41
|
-
let i;
|
|
42
|
-
if (typeof val === 'object' && val !== null) {
|
|
43
|
-
for (i = 0; i < stack.length; i++) {
|
|
44
|
-
if (stack[i] === val) {
|
|
45
|
-
let propertyDescriptor = Object.getOwnPropertyDescriptor(parent, k);
|
|
46
|
-
if (propertyDescriptor.get !== undefined) {
|
|
47
|
-
if (propertyDescriptor.configurable) {
|
|
48
|
-
Object.defineProperty(parent, k, { value: '[Circular]' });
|
|
49
|
-
arr.push([parent, k, val, propertyDescriptor]);
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
replacerStack.push([val, k]);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
parent[k] = '[Circular]';
|
|
57
|
-
arr.push([parent, k, val]);
|
|
58
|
-
}
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
stack.push(val);
|
|
63
|
-
// Optimize for Arrays. Big arrays could kill the performance otherwise!
|
|
64
|
-
if (Array.isArray(val)) {
|
|
65
|
-
for (i = 0; i < val.length; i++) {
|
|
66
|
-
decirc(val[i], i, stack, val);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
var keys = Object.keys(val);
|
|
71
|
-
for (i = 0; i < keys.length; i++) {
|
|
72
|
-
var key = keys[i];
|
|
73
|
-
decirc(val[key], key, stack, val);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
stack.pop();
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
// wraps replacer function to handle values we couldn't replace
|
|
80
|
-
// and mark them as [Circular]
|
|
81
|
-
function replaceGetterValues(replacer) {
|
|
82
|
-
replacer =
|
|
83
|
-
replacer !== undefined
|
|
84
|
-
? replacer
|
|
85
|
-
: function (_, v) {
|
|
86
|
-
return v;
|
|
87
|
-
};
|
|
88
|
-
return function (key, val) {
|
|
89
|
-
if (replacerStack.length > 0) {
|
|
90
|
-
for (var i = 0; i < replacerStack.length; i++) {
|
|
91
|
-
var part = replacerStack[i];
|
|
92
|
-
if (part[1] === key && part[0] === val) {
|
|
93
|
-
val = '[Circular]';
|
|
94
|
-
replacerStack.splice(i, 1);
|
|
95
|
-
break;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
return replacer.call(this, key, val);
|
|
100
|
-
};
|
|
101
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* @poppinss/utils
|
|
4
|
-
*
|
|
5
|
-
* (c) Harminder Virk <virk@adonisjs.com>
|
|
6
|
-
*
|
|
7
|
-
* For the full copyright and license information, please view the LICENSE
|
|
8
|
-
* file that was distributed with this source code.
|
|
9
|
-
*/
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.isScriptFile = void 0;
|
|
12
|
-
const path_1 = require("path");
|
|
13
|
-
const JS_MODULES = ['.js', '.json'];
|
|
14
|
-
/**
|
|
15
|
-
* Returns `true` when file ends with `.js`, `.json` or
|
|
16
|
-
* `.ts` but not `.d.ts`.
|
|
17
|
-
*/
|
|
18
|
-
function isScriptFile(file) {
|
|
19
|
-
const ext = (0, path_1.extname)(file);
|
|
20
|
-
if (JS_MODULES.includes(ext)) {
|
|
21
|
-
return true;
|
|
22
|
-
}
|
|
23
|
-
if (ext === '.ts' && !file.endsWith('.d.ts')) {
|
|
24
|
-
return true;
|
|
25
|
-
}
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
exports.isScriptFile = isScriptFile;
|
package/build/src/lodash.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/// <reference path="../../types/lodash.types.d.ts" />
|
|
2
|
-
export { default as pick } from 'lodash/pick';
|
|
3
|
-
export { default as omit } from 'lodash/omit';
|
|
4
|
-
export { default as has } from 'lodash/has';
|
|
5
|
-
export { default as get } from 'lodash/get';
|
|
6
|
-
export { default as set } from 'lodash/set';
|
|
7
|
-
export { default as unset } from 'lodash/unset';
|
|
8
|
-
export { default as mergeWith } from 'lodash/mergeWith';
|
|
9
|
-
export { default as merge } from 'lodash/merge';
|
|
10
|
-
export { default as size } from 'lodash/size';
|
|
11
|
-
export { default as clone } from 'lodash/clone';
|
|
12
|
-
export { default as cloneDeep } from 'lodash/cloneDeep';
|
|
13
|
-
export { default as toPath } from 'lodash/toPath';
|
package/build/src/lodash.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* @poppinss/utils
|
|
4
|
-
*
|
|
5
|
-
* (c) Harminder Virk <virk@adonisjs.com>
|
|
6
|
-
*
|
|
7
|
-
* For the full copyright and license information, please view the LICENSE
|
|
8
|
-
* file that was distributed with this source code.
|
|
9
|
-
*/
|
|
10
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
11
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.toPath = exports.cloneDeep = exports.clone = exports.size = exports.merge = exports.mergeWith = exports.unset = exports.set = exports.get = exports.has = exports.omit = exports.pick = void 0;
|
|
15
|
-
/// <reference path="../types/lodash.types.d.ts" />
|
|
16
|
-
var pick_1 = require("lodash/pick");
|
|
17
|
-
Object.defineProperty(exports, "pick", { enumerable: true, get: function () { return __importDefault(pick_1).default; } });
|
|
18
|
-
var omit_1 = require("lodash/omit");
|
|
19
|
-
Object.defineProperty(exports, "omit", { enumerable: true, get: function () { return __importDefault(omit_1).default; } });
|
|
20
|
-
var has_1 = require("lodash/has");
|
|
21
|
-
Object.defineProperty(exports, "has", { enumerable: true, get: function () { return __importDefault(has_1).default; } });
|
|
22
|
-
var get_1 = require("lodash/get");
|
|
23
|
-
Object.defineProperty(exports, "get", { enumerable: true, get: function () { return __importDefault(get_1).default; } });
|
|
24
|
-
var set_1 = require("lodash/set");
|
|
25
|
-
Object.defineProperty(exports, "set", { enumerable: true, get: function () { return __importDefault(set_1).default; } });
|
|
26
|
-
var unset_1 = require("lodash/unset");
|
|
27
|
-
Object.defineProperty(exports, "unset", { enumerable: true, get: function () { return __importDefault(unset_1).default; } });
|
|
28
|
-
var mergeWith_1 = require("lodash/mergeWith");
|
|
29
|
-
Object.defineProperty(exports, "mergeWith", { enumerable: true, get: function () { return __importDefault(mergeWith_1).default; } });
|
|
30
|
-
var merge_1 = require("lodash/merge");
|
|
31
|
-
Object.defineProperty(exports, "merge", { enumerable: true, get: function () { return __importDefault(merge_1).default; } });
|
|
32
|
-
var size_1 = require("lodash/size");
|
|
33
|
-
Object.defineProperty(exports, "size", { enumerable: true, get: function () { return __importDefault(size_1).default; } });
|
|
34
|
-
var clone_1 = require("lodash/clone");
|
|
35
|
-
Object.defineProperty(exports, "clone", { enumerable: true, get: function () { return __importDefault(clone_1).default; } });
|
|
36
|
-
var cloneDeep_1 = require("lodash/cloneDeep");
|
|
37
|
-
Object.defineProperty(exports, "cloneDeep", { enumerable: true, get: function () { return __importDefault(cloneDeep_1).default; } });
|
|
38
|
-
var toPath_1 = require("lodash/toPath");
|
|
39
|
-
Object.defineProperty(exports, "toPath", { enumerable: true, get: function () { return __importDefault(toPath_1).default; } });
|
package/build/src/safeParse.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copied directly from https://github.com/nuxt-contrib/destr/blob/master/src/index.ts but
|
|
3
|
-
* instead raises the malformed JSON exceptions vs swallowing them
|
|
4
|
-
*/
|
|
5
|
-
export declare function safeParse(val: string, reviver?: (this: any, jsonKey: string, jsonValue: any) => any): any;
|
package/build/src/safeParse.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* @poppinss/utils
|
|
4
|
-
*
|
|
5
|
-
* (c) Harminder Virk <virk@adonisjs.com>
|
|
6
|
-
*
|
|
7
|
-
* For the full copyright and license information, please view the LICENSE
|
|
8
|
-
* file that was distributed with this source code.
|
|
9
|
-
*/
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.safeParse = void 0;
|
|
12
|
-
// https://github.com/fastify/secure-json-parse
|
|
13
|
-
// https://github.com/hapijs/bourne
|
|
14
|
-
const suspectProtoRx = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/;
|
|
15
|
-
const suspectConstructorRx = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
|
|
16
|
-
const JsonSigRx = /^["{[]|^-?[0-9][0-9.]*$/;
|
|
17
|
-
function jsonParseTransform(key, value, reviver) {
|
|
18
|
-
if (key === '__proto__' || key === 'constructor') {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
return reviver ? reviver(key, value) : value;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Copied directly from https://github.com/nuxt-contrib/destr/blob/master/src/index.ts but
|
|
25
|
-
* instead raises the malformed JSON exceptions vs swallowing them
|
|
26
|
-
*/
|
|
27
|
-
function safeParse(val, reviver) {
|
|
28
|
-
if (typeof val !== 'string') {
|
|
29
|
-
return val;
|
|
30
|
-
}
|
|
31
|
-
if (val === 'null') {
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
34
|
-
if (!JsonSigRx.test(val)) {
|
|
35
|
-
return val;
|
|
36
|
-
}
|
|
37
|
-
if (suspectProtoRx.test(val) || suspectConstructorRx.test(val)) {
|
|
38
|
-
return JSON.parse(val, (key, value) => jsonParseTransform(key, value, reviver));
|
|
39
|
-
}
|
|
40
|
-
return JSON.parse(val, reviver);
|
|
41
|
-
}
|
|
42
|
-
exports.safeParse = safeParse;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* @poppinss/utils
|
|
4
|
-
*
|
|
5
|
-
* (c) Harminder Virk <virk@adonisjs.com>
|
|
6
|
-
*
|
|
7
|
-
* For the full copyright and license information, please view the LICENSE
|
|
8
|
-
* file that was distributed with this source code.
|
|
9
|
-
*/
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.safeStringify = void 0;
|
|
12
|
-
const fast_safe_stringify_1 = require("./fast-safe-stringify");
|
|
13
|
-
/**
|
|
14
|
-
* Replacer to handle bigints and remove Circular values all together
|
|
15
|
-
*/
|
|
16
|
-
function jsonStringifyReplacer(replacer, removeCircular) {
|
|
17
|
-
return function (key, value) {
|
|
18
|
-
if (removeCircular && value === '[Circular]') {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
const val = replacer ? replacer.call(this, key, value) : value;
|
|
22
|
-
if (typeof val === 'bigint') {
|
|
23
|
-
return val.toString();
|
|
24
|
-
}
|
|
25
|
-
return val;
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Safely stringifies a Javascript native value
|
|
30
|
-
*/
|
|
31
|
-
function safeStringify(value, replacer, space) {
|
|
32
|
-
try {
|
|
33
|
-
return JSON.stringify(value, jsonStringifyReplacer(replacer, false), space);
|
|
34
|
-
}
|
|
35
|
-
catch {
|
|
36
|
-
return (0, fast_safe_stringify_1.stringify)(value, jsonStringifyReplacer(replacer, true), space);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
exports.safeStringify = safeStringify;
|
package/types/lodash.types.d.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @poppinss/utils
|
|
3
|
-
*
|
|
4
|
-
* (c) Harminder Virk <virk@adonisjs.com>
|
|
5
|
-
*
|
|
6
|
-
* For the full copyright and license information, please view the LICENSE
|
|
7
|
-
* file that was distributed with this source code.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
type PropertyName = string | number | symbol
|
|
11
|
-
type PropertyNames = PropertyName | ReadonlyArray<PropertyName>
|
|
12
|
-
|
|
13
|
-
declare module 'lodash/pick' {
|
|
14
|
-
export default function pick<T>(
|
|
15
|
-
object: T | null | undefined,
|
|
16
|
-
...props: Array<PropertyNames>
|
|
17
|
-
): Partial<T>
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
declare module 'lodash/omit' {
|
|
21
|
-
export default function omit<T extends object>(
|
|
22
|
-
object: T | null | undefined,
|
|
23
|
-
...paths: Array<PropertyNames>
|
|
24
|
-
): Partial<T>
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
declare module 'lodash/has' {
|
|
28
|
-
export default function has<T>(object: T, path: PropertyNames): boolean
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
declare module 'lodash/get' {
|
|
32
|
-
export default function get(object: any, path: PropertyNames, defaultValue?: any): any
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
declare module 'lodash/set' {
|
|
36
|
-
export default function set(object: any, path: PropertyNames, value: any): any
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
declare module 'lodash/unset' {
|
|
40
|
-
export default function unset(object: any, path: PropertyNames): boolean
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
declare module 'lodash/mergeWith' {
|
|
44
|
-
export default function mergeWith(object: any, ...otherArgs: any[]): any
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
declare module 'lodash/merge' {
|
|
48
|
-
export default function merge(object: any, ...otherArgs: any[]): any
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
declare module 'lodash/size' {
|
|
52
|
-
export default function size(collection: object | string | null | undefined): number
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
declare module 'lodash/clone' {
|
|
56
|
-
export default function clone<T>(value: T): T
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
declare module 'lodash/cloneDeep' {
|
|
60
|
-
export default function cloneDeep<T>(value: T): T
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
declare module 'lodash/toPath' {
|
|
64
|
-
export default function toPath(value: any): string[]
|
|
65
|
-
}
|