@poppinss/utils 3.1.5 → 3.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -0
- package/build/index.d.ts +2 -0
- package/build/index.js +5 -1
- package/build/src/Helpers/MessageBuilder.js +3 -3
- package/build/src/Helpers/fsReadAll.js +1 -1
- package/build/src/Helpers/requireAll.d.ts +1 -1
- package/build/src/Helpers/requireAll.js +22 -9
- package/build/src/Helpers/resolveDir.js +4 -4
- package/build/src/Helpers/resolveFrom.js +2 -2
- package/build/src/Helpers/safeEqual.js +4 -4
- package/build/src/Helpers/string.js +9 -9
- package/build/src/Helpers/types.js +1 -1
- package/build/src/defineStaticProperty.d.ts +6 -3
- package/build/src/defineStaticProperty.js +1 -1
- package/build/src/esmRequire.js +1 -1
- package/build/src/flatten.d.ts +1 -0
- package/build/src/flatten.js +13 -0
- package/build/src/isScriptFile.js +1 -1
- package/build/src/safeStringify.js +1 -1
- package/build/src/slash.d.ts +5 -0
- package/build/src/slash.js +24 -0
- package/package.json +15 -14
package/README.md
CHANGED
|
@@ -113,6 +113,7 @@ string.titleCase()
|
|
|
113
113
|
- [Safe stringify](#safe-stringify)
|
|
114
114
|
- [Safe parse](#safe-parse)
|
|
115
115
|
- [defineStaticProperty](#definestaticproperty)
|
|
116
|
+
- [flatten](#flatten)
|
|
116
117
|
- [Helpers](#helpers)
|
|
117
118
|
- [fsReadAll](#fsreadall)
|
|
118
119
|
- [requireAll](#requireall)
|
|
@@ -379,6 +380,48 @@ The `defineStaticProperty` takes a total of three arguments.
|
|
|
379
380
|
- The `inherit` strategy will copy the properties from the base class.
|
|
380
381
|
- The `define` strategy will always use the `defaultValue` to define the property on the class. In other words, there is no copy behavior, but prototypal inheritance chain is also breaked by explicitly re-defining the property.
|
|
381
382
|
|
|
383
|
+
## flatten
|
|
384
|
+
Flatten an object/array. The method wraps the [flattie](https://github.com/lukeed/flattie) package.
|
|
385
|
+
|
|
386
|
+
```ts
|
|
387
|
+
import { flatten } from '@poppinss/utils'
|
|
388
|
+
|
|
389
|
+
flatten({
|
|
390
|
+
a: 'hi',
|
|
391
|
+
b: {
|
|
392
|
+
a: null,
|
|
393
|
+
b: ['foo', '', null, 'bar'],
|
|
394
|
+
d: 'hello',
|
|
395
|
+
e: {
|
|
396
|
+
a: 'yo',
|
|
397
|
+
b: undefined,
|
|
398
|
+
c: 'sup',
|
|
399
|
+
d: 0,
|
|
400
|
+
f: [
|
|
401
|
+
{ foo: 123, bar: 123 },
|
|
402
|
+
{ foo: 465, bar: 456 },
|
|
403
|
+
]
|
|
404
|
+
}
|
|
405
|
+
},
|
|
406
|
+
c: 'world'
|
|
407
|
+
});
|
|
408
|
+
// {
|
|
409
|
+
// 'a': 'hi',
|
|
410
|
+
// 'b.b.0': 'foo',
|
|
411
|
+
// 'b.b.1': '',
|
|
412
|
+
// 'b.b.3': 'bar',
|
|
413
|
+
// 'b.d': 'hello',
|
|
414
|
+
// 'b.e.a': 'yo',
|
|
415
|
+
// 'b.e.c': 'sup',
|
|
416
|
+
// 'b.e.d': 0,
|
|
417
|
+
// 'b.e.f.0.foo': 123,
|
|
418
|
+
// 'b.e.f.0.bar': 123,
|
|
419
|
+
// 'b.e.f.1.foo': 465,
|
|
420
|
+
// 'b.e.f.1.bar': 456,
|
|
421
|
+
// 'c': 'world'
|
|
422
|
+
// }
|
|
423
|
+
```
|
|
424
|
+
|
|
382
425
|
## Helpers
|
|
383
426
|
|
|
384
427
|
The helpers module is also available in AdonisJS applications as follows:
|
|
@@ -426,6 +469,16 @@ const config = requireAll(join(__dirname, 'config'))
|
|
|
426
469
|
}
|
|
427
470
|
```
|
|
428
471
|
|
|
472
|
+
The method also accepts the following options
|
|
473
|
+
|
|
474
|
+
```ts
|
|
475
|
+
requireAll(join(__dirname, 'config'), recursive, optional, filter)
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
- `recursive` Load all files recursively. Defaults to true.
|
|
479
|
+
- `optional` Do not raise exception when the root directory is missing. Defaults to false.
|
|
480
|
+
- `filter` Cherry pick files to require. By default, all JavaScript, TypeScript and JSON files are required.
|
|
481
|
+
|
|
429
482
|
### resolveFrom
|
|
430
483
|
|
|
431
484
|
Works similar to `require.resolve`, however it handles the absolute paths properly.
|
package/build/index.d.ts
CHANGED
package/build/index.js
CHANGED
|
@@ -27,8 +27,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
27
27
|
return result;
|
|
28
28
|
};
|
|
29
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
-
exports.ManagerConfigValidator = exports.defineStaticProperty = exports.safeStringify = exports.esmResolver = exports.esmRequire = exports.safeParse = exports.Exception = exports.lodash = void 0;
|
|
30
|
+
exports.ManagerConfigValidator = exports.defineStaticProperty = exports.safeStringify = exports.esmResolver = exports.esmRequire = exports.safeParse = exports.Exception = exports.flatten = exports.slash = exports.lodash = void 0;
|
|
31
31
|
exports.lodash = __importStar(require("./src/lodash"));
|
|
32
|
+
var slash_1 = require("./src/slash");
|
|
33
|
+
Object.defineProperty(exports, "slash", { enumerable: true, get: function () { return slash_1.slash; } });
|
|
34
|
+
var flatten_1 = require("./src/flatten");
|
|
35
|
+
Object.defineProperty(exports, "flatten", { enumerable: true, get: function () { return flatten_1.flatten; } });
|
|
32
36
|
var Exception_1 = require("./src/Exception");
|
|
33
37
|
Object.defineProperty(exports, "Exception", { enumerable: true, get: function () { return Exception_1.Exception; } });
|
|
34
38
|
var safeParse_1 = require("./src/safeParse");
|
|
@@ -33,7 +33,7 @@ class MessageBuilder {
|
|
|
33
33
|
if (!expiresIn) {
|
|
34
34
|
return undefined;
|
|
35
35
|
}
|
|
36
|
-
const expiryMs = typeof expiresIn === 'string' ? ms_1.default(expiresIn) : expiresIn;
|
|
36
|
+
const expiryMs = typeof expiresIn === 'string' ? (0, ms_1.default)(expiresIn) : expiresIn;
|
|
37
37
|
if (expiryMs === undefined || expiryMs === null) {
|
|
38
38
|
throw new Error(`Invalid value for expiresIn "${expiresIn}"`);
|
|
39
39
|
}
|
|
@@ -59,13 +59,13 @@ class MessageBuilder {
|
|
|
59
59
|
*/
|
|
60
60
|
build(message, expiresIn, purpose) {
|
|
61
61
|
const expiryDate = this.getExpiryDate(expiresIn);
|
|
62
|
-
return safeStringify_1.safeStringify({ message, purpose, expiryDate });
|
|
62
|
+
return (0, safeStringify_1.safeStringify)({ message, purpose, expiryDate });
|
|
63
63
|
}
|
|
64
64
|
/**
|
|
65
65
|
* Verifies the message for expiry and purpose
|
|
66
66
|
*/
|
|
67
67
|
verify(message, purpose) {
|
|
68
|
-
const parsed = safeParse_1.safeParse(message);
|
|
68
|
+
const parsed = (0, safeParse_1.safeParse)(message);
|
|
69
69
|
/**
|
|
70
70
|
* Safe parse returns the value as it is when unable to JSON.parse it. However, in
|
|
71
71
|
* our case if value was correctly parsed, it should never match the input
|
|
@@ -18,6 +18,6 @@ const isScriptFile_1 = require("../isScriptFile");
|
|
|
18
18
|
* Returns an array of file paths from the given location.
|
|
19
19
|
*/
|
|
20
20
|
function fsReadAll(location, callback) {
|
|
21
|
-
return fs_readdir_recursive_1.default(location).filter(typeof callback === 'function' ? callback : isScriptFile_1.isScriptFile);
|
|
21
|
+
return (0, fs_readdir_recursive_1.default)(location).filter(typeof callback === 'function' ? callback : isScriptFile_1.isScriptFile);
|
|
22
22
|
}
|
|
23
23
|
exports.fsReadAll = fsReadAll;
|
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
* for files ending with `.ts`, `.js` and `.json`. Also files ending with
|
|
4
4
|
* `.d.ts` are ignored.
|
|
5
5
|
*/
|
|
6
|
-
export declare function requireAll(location: string, recursive?: boolean, optional?: boolean): {
|
|
6
|
+
export declare function requireAll(location: string, recursive?: boolean, optional?: boolean, filter?: (file: string) => boolean | string): {
|
|
7
7
|
[key: string]: any;
|
|
8
8
|
} | undefined;
|
|
@@ -17,26 +17,39 @@ const require_all_1 = __importDefault(require("require-all"));
|
|
|
17
17
|
const esmResolver_1 = require("../esmResolver");
|
|
18
18
|
const isScriptFile_1 = require("../isScriptFile");
|
|
19
19
|
/**
|
|
20
|
-
* Function to filter
|
|
20
|
+
* Function to filter and keep script files only
|
|
21
21
|
*/
|
|
22
22
|
function fileFilter(file) {
|
|
23
|
-
|
|
24
|
-
if (!isScriptFile_1.isScriptFile(file)) {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
return file.replace(new RegExp(`${ext}$`), '');
|
|
23
|
+
return (0, isScriptFile_1.isScriptFile)(file);
|
|
28
24
|
}
|
|
29
25
|
/**
|
|
30
26
|
* Require all files from a given directory. The method automatically looks
|
|
31
27
|
* for files ending with `.ts`, `.js` and `.json`. Also files ending with
|
|
32
28
|
* `.d.ts` are ignored.
|
|
33
29
|
*/
|
|
34
|
-
function requireAll(location, recursive = true, optional = false) {
|
|
30
|
+
function requireAll(location, recursive = true, optional = false, filter = fileFilter) {
|
|
35
31
|
try {
|
|
36
|
-
return require_all_1.default({
|
|
32
|
+
return (0, require_all_1.default)({
|
|
37
33
|
dirname: location,
|
|
38
34
|
recursive,
|
|
39
|
-
filter:
|
|
35
|
+
filter: (file) => {
|
|
36
|
+
let result = true;
|
|
37
|
+
/**
|
|
38
|
+
* Invoke user defined function
|
|
39
|
+
*/
|
|
40
|
+
if (typeof filter === 'function') {
|
|
41
|
+
result = filter(file);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Use the default file name when file is meant to
|
|
45
|
+
* be kept
|
|
46
|
+
*/
|
|
47
|
+
if (result === true) {
|
|
48
|
+
const ext = (0, path_1.extname)(file);
|
|
49
|
+
return file.replace(new RegExp(`${ext}$`), '');
|
|
50
|
+
}
|
|
51
|
+
return result;
|
|
52
|
+
},
|
|
40
53
|
resolve: esmResolver_1.esmResolver,
|
|
41
54
|
});
|
|
42
55
|
}
|
|
@@ -19,14 +19,14 @@ const path_1 = require("path");
|
|
|
19
19
|
* but also works for directories with no `index.js` file.
|
|
20
20
|
*/
|
|
21
21
|
function resolveDir(fromLocation, dirPath) {
|
|
22
|
-
if (path_1.isAbsolute(dirPath)) {
|
|
22
|
+
if ((0, path_1.isAbsolute)(dirPath)) {
|
|
23
23
|
return dirPath;
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
26
|
* Relative paths are made by joining the baseDir
|
|
27
27
|
*/
|
|
28
28
|
if (dirPath.startsWith('./') || dirPath.startsWith(`.${path_1.sep}`)) {
|
|
29
|
-
return path_1.join(fromLocation, dirPath);
|
|
29
|
+
return (0, path_1.join)(fromLocation, dirPath);
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
32
|
* From here on, we are dealing with a package inside node module.
|
|
@@ -37,10 +37,10 @@ function resolveDir(fromLocation, dirPath) {
|
|
|
37
37
|
packageName = `${tokens.shift()}/`;
|
|
38
38
|
}
|
|
39
39
|
packageName += tokens.shift();
|
|
40
|
-
const resolved = resolve_from_1.default.silent(fromLocation, path_1.join(packageName, 'package.json'));
|
|
40
|
+
const resolved = resolve_from_1.default.silent(fromLocation, (0, path_1.join)(packageName, 'package.json'));
|
|
41
41
|
if (!resolved) {
|
|
42
42
|
throw new Error(`Cannot locate directory "${dirPath}"`);
|
|
43
43
|
}
|
|
44
|
-
return path_1.join(path_1.dirname(resolved), tokens.join('/'));
|
|
44
|
+
return (0, path_1.join)((0, path_1.dirname)(resolved), tokens.join('/'));
|
|
45
45
|
}
|
|
46
46
|
exports.resolveDir = resolveDir;
|
|
@@ -19,9 +19,9 @@ const resolve_from_1 = __importDefault(require("resolve-from"));
|
|
|
19
19
|
* but carefull handles the absolute paths.
|
|
20
20
|
*/
|
|
21
21
|
function resolveFrom(fromLocation, modulePath) {
|
|
22
|
-
if (path_1.isAbsolute(modulePath)) {
|
|
22
|
+
if ((0, path_1.isAbsolute)(modulePath)) {
|
|
23
23
|
return modulePath;
|
|
24
24
|
}
|
|
25
|
-
return resolve_from_1.default(fromLocation, modulePath);
|
|
25
|
+
return (0, resolve_from_1.default)(fromLocation, modulePath);
|
|
26
26
|
}
|
|
27
27
|
exports.resolveFrom = resolveFrom;
|
|
@@ -27,19 +27,19 @@ function safeEqual(value, comparisonValue) {
|
|
|
27
27
|
/**
|
|
28
28
|
* Value A
|
|
29
29
|
*/
|
|
30
|
-
const valueBuffer = buffer_alloc_1.default(expectedLength, 0, 'utf-8');
|
|
30
|
+
const valueBuffer = (0, buffer_alloc_1.default)(expectedLength, 0, 'utf-8');
|
|
31
31
|
valueBuffer.write(value);
|
|
32
32
|
/**
|
|
33
33
|
* Value B
|
|
34
34
|
*/
|
|
35
|
-
const comparisonValueBuffer = buffer_alloc_1.default(expectedLength, 0, 'utf-8');
|
|
35
|
+
const comparisonValueBuffer = (0, buffer_alloc_1.default)(expectedLength, 0, 'utf-8');
|
|
36
36
|
comparisonValueBuffer.write(comparisonValue);
|
|
37
37
|
/**
|
|
38
38
|
* Ensure values are same and also have same length
|
|
39
39
|
*/
|
|
40
|
-
return (crypto_1.timingSafeEqual(valueBuffer, comparisonValueBuffer) &&
|
|
40
|
+
return ((0, crypto_1.timingSafeEqual)(valueBuffer, comparisonValueBuffer) &&
|
|
41
41
|
expectedLength === Buffer.byteLength(comparisonValue));
|
|
42
42
|
}
|
|
43
|
-
return crypto_1.timingSafeEqual(Buffer.from(value), Buffer.from(comparisonValue));
|
|
43
|
+
return (0, crypto_1.timingSafeEqual)(Buffer.from(value), Buffer.from(comparisonValue));
|
|
44
44
|
}
|
|
45
45
|
exports.safeEqual = safeEqual;
|
|
@@ -76,14 +76,14 @@ function normalizeBase64(value) {
|
|
|
76
76
|
* Define an irregular rule
|
|
77
77
|
*/
|
|
78
78
|
function defineIrregularRule(singleValue, pluralValue) {
|
|
79
|
-
pluralize_1.addIrregularRule(singleValue, pluralValue);
|
|
79
|
+
(0, pluralize_1.addIrregularRule)(singleValue, pluralValue);
|
|
80
80
|
}
|
|
81
81
|
exports.defineIrregularRule = defineIrregularRule;
|
|
82
82
|
/**
|
|
83
83
|
* Define uncountable rule
|
|
84
84
|
*/
|
|
85
85
|
function defineUncountableRule(word) {
|
|
86
|
-
pluralize_1.addUncountableRule(word);
|
|
86
|
+
(0, pluralize_1.addUncountableRule)(word);
|
|
87
87
|
}
|
|
88
88
|
exports.defineUncountableRule = defineUncountableRule;
|
|
89
89
|
/**
|
|
@@ -149,21 +149,21 @@ exports.noCase = noCase;
|
|
|
149
149
|
* Pluralize a word
|
|
150
150
|
*/
|
|
151
151
|
function pluralize(word) {
|
|
152
|
-
return pluralize_1.plural(word);
|
|
152
|
+
return (0, pluralize_1.plural)(word);
|
|
153
153
|
}
|
|
154
154
|
exports.pluralize = pluralize;
|
|
155
155
|
/**
|
|
156
156
|
* Singularize a word
|
|
157
157
|
*/
|
|
158
158
|
function singularize(word) {
|
|
159
|
-
return pluralize_1.singular(word);
|
|
159
|
+
return (0, pluralize_1.singular)(word);
|
|
160
160
|
}
|
|
161
161
|
exports.singularize = singularize;
|
|
162
162
|
/**
|
|
163
163
|
* Truncate a sentence till a give limit of characters
|
|
164
164
|
*/
|
|
165
165
|
function truncate(sentence, charactersLimit, options) {
|
|
166
|
-
return truncatise_1.default(sentence, {
|
|
166
|
+
return (0, truncatise_1.default)(sentence, {
|
|
167
167
|
TruncateLength: charactersLimit,
|
|
168
168
|
/**
|
|
169
169
|
* Do not complete words when "completeWords" is not explicitly set
|
|
@@ -180,7 +180,7 @@ exports.truncate = truncate;
|
|
|
180
180
|
* Same as truncate, but strips out the HTML
|
|
181
181
|
*/
|
|
182
182
|
function excerpt(sentence, charactersLimit, options) {
|
|
183
|
-
return truncatise_1.default(sentence, {
|
|
183
|
+
return (0, truncatise_1.default)(sentence, {
|
|
184
184
|
TruncateLength: charactersLimit,
|
|
185
185
|
/**
|
|
186
186
|
* Do not complete words when "completeWords" is not explicitly set
|
|
@@ -258,7 +258,7 @@ exports.prettyBytes = prettyBytes;
|
|
|
258
258
|
* Convert milliseconds to a human readable string
|
|
259
259
|
*/
|
|
260
260
|
function prettyMs(value, options) {
|
|
261
|
-
return ms_1.default(value, options);
|
|
261
|
+
return (0, ms_1.default)(value, options);
|
|
262
262
|
}
|
|
263
263
|
exports.prettyMs = prettyMs;
|
|
264
264
|
/**
|
|
@@ -310,7 +310,7 @@ function toMs(value) {
|
|
|
310
310
|
if (typeof value === 'number') {
|
|
311
311
|
return value;
|
|
312
312
|
}
|
|
313
|
-
return ms_1.default(value);
|
|
313
|
+
return (0, ms_1.default)(value);
|
|
314
314
|
}
|
|
315
315
|
exports.toMs = toMs;
|
|
316
316
|
/**
|
|
@@ -318,7 +318,7 @@ exports.toMs = toMs;
|
|
|
318
318
|
*/
|
|
319
319
|
function generateRandom(size) {
|
|
320
320
|
const bits = (size + 1) * 6;
|
|
321
|
-
const buffer = crypto_1.randomBytes(Math.ceil(bits / 8));
|
|
321
|
+
const buffer = (0, crypto_1.randomBytes)(Math.ceil(bits / 8));
|
|
322
322
|
return normalizeBase64(buffer.toString('base64')).slice(0, size);
|
|
323
323
|
}
|
|
324
324
|
exports.generateRandom = generateRandom;
|
|
@@ -18,7 +18,7 @@ const toString = Function.prototype.toString;
|
|
|
18
18
|
* Lookup the type for a given value
|
|
19
19
|
*/
|
|
20
20
|
function lookup(value) {
|
|
21
|
-
const kind = kind_of_1.default(value);
|
|
21
|
+
const kind = (0, kind_of_1.default)(value);
|
|
22
22
|
if (kind === 'function' && /^class\s/.test(toString.call(value))) {
|
|
23
23
|
return 'class';
|
|
24
24
|
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
declare type Constructor = new (...args: any[]) => any;
|
|
2
|
+
declare type AbstractConstructor = abstract new (...args: any[]) => any;
|
|
1
3
|
/**
|
|
2
4
|
* Define static properties on a class with inheritance in play.
|
|
3
5
|
*/
|
|
4
|
-
export declare function defineStaticProperty<
|
|
6
|
+
export declare function defineStaticProperty<T extends Constructor | AbstractConstructor, Prop extends keyof T>(self: T, BaseClass: Constructor | AbstractConstructor, { propertyName, defaultValue, strategy, }: {
|
|
5
7
|
propertyName: Prop;
|
|
6
|
-
defaultValue:
|
|
7
|
-
strategy: 'inherit' | 'define' | ((value:
|
|
8
|
+
defaultValue: T[Prop];
|
|
9
|
+
strategy: 'inherit' | 'define' | ((value: T[Prop]) => T[Prop]);
|
|
8
10
|
}): void;
|
|
11
|
+
export {};
|
|
@@ -47,7 +47,7 @@ function defineStaticProperty(self, BaseClass, { propertyName, defaultValue, str
|
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
49
|
Object.defineProperty(self, propertyName, {
|
|
50
|
-
value: typeof strategy === 'function' ? strategy(value) : cloneDeep_1.default(value),
|
|
50
|
+
value: typeof strategy === 'function' ? strategy(value) : (0, cloneDeep_1.default)(value),
|
|
51
51
|
configurable: true,
|
|
52
52
|
enumerable: true,
|
|
53
53
|
writable: true,
|
package/build/src/esmRequire.js
CHANGED
|
@@ -15,6 +15,6 @@ const esmResolver_1 = require("./esmResolver");
|
|
|
15
15
|
* exports are only entertained, when `esmEnabled` is set to true.
|
|
16
16
|
*/
|
|
17
17
|
function esmRequire(filePath) {
|
|
18
|
-
return esmResolver_1.esmResolver(require(filePath));
|
|
18
|
+
return (0, esmResolver_1.esmResolver)(require(filePath));
|
|
19
19
|
}
|
|
20
20
|
exports.esmRequire = esmRequire;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { flattie as flatten } from 'flattie';
|
|
@@ -0,0 +1,13 @@
|
|
|
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.flatten = void 0;
|
|
12
|
+
var flattie_1 = require("flattie");
|
|
13
|
+
Object.defineProperty(exports, "flatten", { enumerable: true, get: function () { return flattie_1.flattie; } });
|
|
@@ -33,7 +33,7 @@ function safeStringify(value, replacer, space) {
|
|
|
33
33
|
return JSON.stringify(value, jsonStringifyReplacer(replacer, false), space);
|
|
34
34
|
}
|
|
35
35
|
catch {
|
|
36
|
-
return fast_safe_stringify_1.stringify(value, jsonStringifyReplacer(replacer, true), space);
|
|
36
|
+
return (0, fast_safe_stringify_1.stringify)(value, jsonStringifyReplacer(replacer, true), space);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
exports.safeStringify = safeStringify;
|
|
@@ -0,0 +1,24 @@
|
|
|
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.slash = void 0;
|
|
12
|
+
/**
|
|
13
|
+
* Convert windows path to unix.
|
|
14
|
+
* Copied from https://github.com/sindresorhus/slash as the package is ESM only
|
|
15
|
+
*/
|
|
16
|
+
function slash(filePath) {
|
|
17
|
+
const isExtendedLengthPath = /^\\\\\?\\/.test(filePath);
|
|
18
|
+
const hasNonAscii = /[^\u0000-\u0080]+/.test(filePath); // eslint-disable-line no-control-regex
|
|
19
|
+
if (isExtendedLengthPath || hasNonAscii) {
|
|
20
|
+
return filePath;
|
|
21
|
+
}
|
|
22
|
+
return filePath.replace(/\\/g, '/');
|
|
23
|
+
}
|
|
24
|
+
exports.slash = slash;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@poppinss/utils",
|
|
3
|
-
"version": "3.1
|
|
3
|
+
"version": "3.3.1",
|
|
4
4
|
"description": "Handy utilities for repetitive work",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"files": [
|
|
@@ -32,28 +32,28 @@
|
|
|
32
32
|
"author": "virk,poppinss",
|
|
33
33
|
"license": "MIT",
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@adonisjs/mrm-preset": "^4.1.
|
|
36
|
-
"@adonisjs/require-ts": "^2.0.
|
|
35
|
+
"@adonisjs/mrm-preset": "^4.1.2",
|
|
36
|
+
"@adonisjs/require-ts": "^2.0.8",
|
|
37
37
|
"@poppinss/dev-utils": "^1.1.5",
|
|
38
38
|
"@types/fs-readdir-recursive": "^1.0.0",
|
|
39
|
-
"@types/lodash": "^4.14.
|
|
39
|
+
"@types/lodash": "^4.14.175",
|
|
40
40
|
"@types/ms": "^0.7.31",
|
|
41
|
-
"@types/node": "^16.
|
|
41
|
+
"@types/node": "^16.10.3",
|
|
42
42
|
"@types/pluralize": "0.0.29",
|
|
43
43
|
"@types/require-all": "^3.0.3",
|
|
44
44
|
"del-cli": "^4.0.1",
|
|
45
45
|
"doctoc": "^2.0.1",
|
|
46
|
-
"eslint": "^7.
|
|
46
|
+
"eslint": "^7.32.0",
|
|
47
47
|
"eslint-config-prettier": "^8.3.0",
|
|
48
|
-
"eslint-plugin-adonis": "^1.3.
|
|
49
|
-
"eslint-plugin-prettier": "^
|
|
50
|
-
"github-label-sync": "^2.0.
|
|
51
|
-
"husky": "^7.0.
|
|
48
|
+
"eslint-plugin-adonis": "^1.3.3",
|
|
49
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
50
|
+
"github-label-sync": "^2.0.2",
|
|
51
|
+
"husky": "^7.0.2",
|
|
52
52
|
"japa": "^3.1.1",
|
|
53
|
-
"mrm": "^3.0.
|
|
53
|
+
"mrm": "^3.0.9",
|
|
54
54
|
"np": "^7.5.0",
|
|
55
|
-
"prettier": "^2.
|
|
56
|
-
"typescript": "^4.3
|
|
55
|
+
"prettier": "^2.4.1",
|
|
56
|
+
"typescript": "^4.4.3"
|
|
57
57
|
},
|
|
58
58
|
"nyc": {
|
|
59
59
|
"exclude": [
|
|
@@ -79,6 +79,7 @@
|
|
|
79
79
|
"bytes": "^3.1.0",
|
|
80
80
|
"change-case": "^4.1.2",
|
|
81
81
|
"cuid": "^2.1.8",
|
|
82
|
+
"flattie": "^1.1.0",
|
|
82
83
|
"fs-readdir-recursive": "^1.1.0",
|
|
83
84
|
"he": "^1.2.0",
|
|
84
85
|
"kind-of": "^6.0.3",
|
|
@@ -87,7 +88,7 @@
|
|
|
87
88
|
"pluralize": "^8.0.0",
|
|
88
89
|
"require-all": "^3.0.0",
|
|
89
90
|
"resolve-from": "^5.0.0",
|
|
90
|
-
"slugify": "^1.6.
|
|
91
|
+
"slugify": "^1.6.1",
|
|
91
92
|
"truncatise": "0.0.8"
|
|
92
93
|
},
|
|
93
94
|
"directories": {
|