@poppinss/utils 6.9.3 → 7.0.0-next.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 +204 -826
- package/build/index.d.ts +4 -24
- package/build/index.js +104 -233
- package/build/{src → modules}/base64.d.ts +2 -2
- package/build/modules/exception.d.ts +1 -0
- package/build/{src → modules/fs}/fs_import_all.d.ts +6 -1
- package/build/{src → modules/fs}/fs_read_all.d.ts +6 -1
- package/build/modules/fs/main.d.ts +2 -0
- package/build/modules/json/main.d.ts +2 -0
- package/build/{src → modules}/json/safe_parse.d.ts +1 -1
- package/build/{src → modules}/json/safe_stringify.d.ts +1 -1
- package/build/modules/string/string_builder.d.ts +2 -0
- package/build/modules/types.d.ts +1 -0
- package/build/src/compose.d.ts +12 -10
- package/build/src/define_static_property.d.ts +2 -4
- package/package.json +18 -18
- package/build/chunk-2KG3PWR4.js +0 -17
- package/build/chunk-4V5ON6P7.js +0 -7
- package/build/chunk-EJKUJ44Y.js +0 -12
- package/build/chunk-H54AK3PI.js +0 -7
- package/build/chunk-XHQBV7AF.js +0 -39
- package/build/src/assert.js +0 -33
- package/build/src/exception.d.ts +0 -1
- package/build/src/exception.js +0 -9
- package/build/src/exceptions/main.d.ts +0 -1
- package/build/src/exceptions/main.js +0 -9
- package/build/src/json/main.d.ts +0 -7
- package/build/src/json/main.js +0 -7
- package/build/src/object_builder.d.ts +0 -1
- package/build/src/slash.d.ts +0 -24
- package/build/src/slash.js +0 -7
- package/build/src/string/main.js +0 -8
- package/build/src/string/string_builder.d.ts +0 -3
- package/build/src/string/string_builder.js +0 -9
- package/build/src/types.d.ts +0 -35
- package/build/src/types.js +0 -0
- /package/build/{src → modules}/assert.d.ts +0 -0
- /package/build/{src → modules}/string/main.d.ts +0 -0
package/build/chunk-4V5ON6P7.js
DELETED
package/build/chunk-EJKUJ44Y.js
DELETED
package/build/chunk-H54AK3PI.js
DELETED
package/build/chunk-XHQBV7AF.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
// src/json/safe_parse.ts
|
|
2
|
-
import { parse } from "secure-json-parse";
|
|
3
|
-
function safeParse(jsonString, reviver) {
|
|
4
|
-
return parse(jsonString, reviver, {
|
|
5
|
-
protoAction: "remove",
|
|
6
|
-
constructorAction: "remove"
|
|
7
|
-
});
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
// src/json/safe_stringify.ts
|
|
11
|
-
import { configure } from "safe-stable-stringify";
|
|
12
|
-
var stringify = configure({
|
|
13
|
-
bigint: false,
|
|
14
|
-
circularValue: void 0,
|
|
15
|
-
deterministic: false
|
|
16
|
-
});
|
|
17
|
-
function jsonStringifyReplacer(replacer) {
|
|
18
|
-
return function(key, value) {
|
|
19
|
-
const val = replacer ? replacer.call(this, key, value) : value;
|
|
20
|
-
if (typeof val === "bigint") {
|
|
21
|
-
return val.toString();
|
|
22
|
-
}
|
|
23
|
-
return val;
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
function safeStringify(value, replacer, space) {
|
|
27
|
-
return stringify(value, jsonStringifyReplacer(replacer), space);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// src/json/main.ts
|
|
31
|
-
var json = {
|
|
32
|
-
safeParse,
|
|
33
|
-
safeStringify
|
|
34
|
-
};
|
|
35
|
-
var main_default = json;
|
|
36
|
-
|
|
37
|
-
export {
|
|
38
|
-
main_default
|
|
39
|
-
};
|
package/build/src/assert.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import "../chunk-2KG3PWR4.js";
|
|
2
|
-
|
|
3
|
-
// src/assert.ts
|
|
4
|
-
import { inspect } from "node:util";
|
|
5
|
-
import { AssertionError } from "node:assert";
|
|
6
|
-
function assert(value, message) {
|
|
7
|
-
return assertExists(value, message);
|
|
8
|
-
}
|
|
9
|
-
function assertExists(value, message) {
|
|
10
|
-
if (!value) {
|
|
11
|
-
throw new AssertionError({ message: message ?? "value is falsy" });
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
function assertUnreachable(x) {
|
|
15
|
-
throw new AssertionError({ message: `unreachable code executed: ${inspect(x)}` });
|
|
16
|
-
}
|
|
17
|
-
function assertNotNull(value, message) {
|
|
18
|
-
if (value === null) {
|
|
19
|
-
throw new AssertionError({ message: message ?? "unexpected null value" });
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
function assertIsDefined(value, message) {
|
|
23
|
-
if (value === void 0) {
|
|
24
|
-
throw new AssertionError({ message: message ?? "unexpected undefined value" });
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
export {
|
|
28
|
-
assert,
|
|
29
|
-
assertExists,
|
|
30
|
-
assertIsDefined,
|
|
31
|
-
assertNotNull,
|
|
32
|
-
assertUnreachable
|
|
33
|
-
};
|
package/build/src/exception.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Exception, createError } from '@poppinss/exception';
|
package/build/src/exception.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { InvalidArgumentsException, RuntimeException } from '@poppinss/exception';
|
package/build/src/json/main.d.ts
DELETED
package/build/src/json/main.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@poppinss/object-builder';
|
package/build/src/slash.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copy-pasted from https://github.com/sindresorhus/slash/blob/main/index.d.ts
|
|
3
|
-
* @credit - https://github.com/sindresorhus/slash
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Convert Windows backslash paths to slash paths: `foo\\bar` ➔ `foo/bar`.
|
|
7
|
-
* [Forward-slash paths can be used in Windows](http://superuser.com/a/176395/6877) as long as
|
|
8
|
-
* they're not extended-length paths.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```
|
|
12
|
-
* import path from 'node:path';
|
|
13
|
-
* import slash from 'slash';
|
|
14
|
-
*
|
|
15
|
-
* const string = path.join('foo', 'bar');
|
|
16
|
-
* // Unix => foo/bar
|
|
17
|
-
* // Windows => foo\\bar
|
|
18
|
-
*
|
|
19
|
-
* slash(string);
|
|
20
|
-
* // Unix => foo/bar
|
|
21
|
-
* // Windows => foo/bar
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
export declare function slash(path: string): string;
|
package/build/src/slash.js
DELETED
package/build/src/string/main.js
DELETED
package/build/src/types.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
type PickKeysByValue<T, V> = {
|
|
2
|
-
[K in keyof T]: T[K] extends V ? K : never;
|
|
3
|
-
}[keyof T];
|
|
4
|
-
export type OmitProperties<T, P> = Omit<T, PickKeysByValue<T, P>>;
|
|
5
|
-
type ScanFsBaseOptions = {
|
|
6
|
-
ignoreMissingRoot?: boolean;
|
|
7
|
-
filter?: (filePath: string, index: number) => boolean;
|
|
8
|
-
sort?: (current: string, next: string) => number;
|
|
9
|
-
};
|
|
10
|
-
export type ImportAllFilesOptions = ScanFsBaseOptions & {
|
|
11
|
-
/**
|
|
12
|
-
* A custom method to transform collection keys
|
|
13
|
-
*/
|
|
14
|
-
transformKeys?: (keys: string[]) => string[];
|
|
15
|
-
};
|
|
16
|
-
export type ReadAllFilesOptions = ScanFsBaseOptions & {
|
|
17
|
-
pathType?: 'relative' | 'unixRelative' | 'absolute' | 'unixAbsolute' | 'url';
|
|
18
|
-
};
|
|
19
|
-
export type JSONReplacer = (this: any, key: string, value: any) => any;
|
|
20
|
-
export type JSONReviver = (this: any, key: string, value: any) => any;
|
|
21
|
-
export type Constructor = new (...args: any[]) => any;
|
|
22
|
-
/**
|
|
23
|
-
* Normalizes constructor to work with mixins. There is an open bug for mixins
|
|
24
|
-
* to allow constructors other than `...args: any[]`
|
|
25
|
-
*
|
|
26
|
-
* https://github.com/microsoft/TypeScript/issues/37142
|
|
27
|
-
*/
|
|
28
|
-
export type NormalizeConstructor<T extends Constructor> = {
|
|
29
|
-
new (...args: any[]): InstanceType<T>;
|
|
30
|
-
} & Omit<T, 'constructor'>;
|
|
31
|
-
declare const opaqueProp: unique symbol;
|
|
32
|
-
export type Opaque<T, K> = T & {
|
|
33
|
-
[opaqueProp]: K;
|
|
34
|
-
};
|
|
35
|
-
export {};
|
package/build/src/types.js
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|