@poppinss/utils 6.9.4 → 7.0.0-next.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 +205 -829
- package/build/chunk-SKNTF5Q5.js +14 -0
- package/build/chunk-XFX47BKO.js +23 -0
- package/build/{chunk-XHQBV7AF.js → chunk-YFSCSJNE.js} +3 -9
- package/build/index.d.ts +4 -24
- package/build/index.js +57 -243
- package/build/{src → modules}/assert.js +1 -3
- package/build/{src → modules}/base64.d.ts +2 -2
- package/build/modules/base64.js +43 -0
- package/build/modules/exception.d.ts +1 -0
- package/build/modules/exception.js +12 -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/fs/main.js +82 -0
- package/build/modules/json/main.d.ts +2 -0
- package/build/modules/json/main.js +8 -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/{src → modules}/string/main.js +1 -3
- package/build/modules/string/string_builder.d.ts +2 -0
- package/build/modules/string/string_builder.js +6 -0
- package/build/modules/types.d.ts +1 -0
- package/build/modules/types.js +2 -0
- package/build/src/compose.d.ts +12 -10
- package/build/src/define_static_property.d.ts +2 -4
- package/package.json +26 -27
- 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/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/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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@poppinss/types';
|
package/build/src/compose.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Constructor } from '@poppinss/types';
|
|
2
2
|
interface UnaryFunction<T, R> {
|
|
3
3
|
(source: T): R;
|
|
4
4
|
}
|
|
@@ -6,14 +6,16 @@ interface UnaryFunction<T, R> {
|
|
|
6
6
|
* Compose a class by applying mixins to it.
|
|
7
7
|
* The code is inspired by https://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/, its
|
|
8
8
|
* just that I have added the support for static types too.
|
|
9
|
+
*
|
|
10
|
+
* Types https://github.com/tc39/proposal-pipeline-operator/issues/219
|
|
9
11
|
*/
|
|
10
|
-
export declare function compose<T extends Constructor
|
|
11
|
-
export declare function compose<T extends Constructor
|
|
12
|
-
export declare function compose<T extends Constructor
|
|
13
|
-
export declare function compose<T extends Constructor
|
|
14
|
-
export declare function compose<T extends Constructor
|
|
15
|
-
export declare function compose<T extends Constructor
|
|
16
|
-
export declare function compose<T extends Constructor
|
|
17
|
-
export declare function compose<T extends Constructor
|
|
18
|
-
export declare function compose<T extends Constructor
|
|
12
|
+
export declare function compose<T extends Constructor<any>, A>(superclass: T, mixin: UnaryFunction<T, A>): A;
|
|
13
|
+
export declare function compose<T extends Constructor<any>, A, B>(superclass: T, mixin: UnaryFunction<T, A>, mixinB: UnaryFunction<A, B>): B;
|
|
14
|
+
export declare function compose<T extends Constructor<any>, A, B, C>(superclass: T, mixin: UnaryFunction<T, A>, mixinB: UnaryFunction<A, B>, mixinC: UnaryFunction<B, C>): C;
|
|
15
|
+
export declare function compose<T extends Constructor<any>, A, B, C, D>(superclass: T, mixin: UnaryFunction<T, A>, mixinB: UnaryFunction<A, B>, mixinC: UnaryFunction<B, C>, mixinD: UnaryFunction<C, D>): D;
|
|
16
|
+
export declare function compose<T extends Constructor<any>, A, B, C, D, E>(superclass: T, mixin: UnaryFunction<T, A>, mixinB: UnaryFunction<A, B>, mixinC: UnaryFunction<B, C>, mixinD: UnaryFunction<C, D>, mixinE: UnaryFunction<D, E>): E;
|
|
17
|
+
export declare function compose<T extends Constructor<any>, A, B, C, D, E, F>(superclass: T, mixin: UnaryFunction<T, A>, mixinB: UnaryFunction<A, B>, mixinC: UnaryFunction<B, C>, mixinD: UnaryFunction<C, D>, mixinF: UnaryFunction<E, F>): F;
|
|
18
|
+
export declare function compose<T extends Constructor<any>, A, B, C, D, E, F, G>(superclass: T, mixin: UnaryFunction<T, A>, mixinB: UnaryFunction<A, B>, mixinC: UnaryFunction<B, C>, mixinD: UnaryFunction<C, D>, mixinF: UnaryFunction<E, F>, mixinG: UnaryFunction<F, G>): G;
|
|
19
|
+
export declare function compose<T extends Constructor<any>, A, B, C, D, E, F, G, H>(superclass: T, mixin: UnaryFunction<T, A>, mixinB: UnaryFunction<A, B>, mixinC: UnaryFunction<B, C>, mixinD: UnaryFunction<C, D>, mixinF: UnaryFunction<E, F>, mixinG: UnaryFunction<F, G>, mixinH: UnaryFunction<G, H>): H;
|
|
20
|
+
export declare function compose<T extends Constructor<any>, A, B, C, D, E, F, G, H, I>(superclass: T, mixin: UnaryFunction<T, A>, mixinB: UnaryFunction<A, B>, mixinC: UnaryFunction<B, C>, mixinD: UnaryFunction<C, D>, mixinF: UnaryFunction<E, F>, mixinG: UnaryFunction<F, G>, mixinH: UnaryFunction<G, H>, mixinI: UnaryFunction<H, I>): I;
|
|
19
21
|
export {};
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
type
|
|
2
|
-
type AbstractConstructor = abstract new (...args: any[]) => any;
|
|
1
|
+
import type { AbstractConstructor, Constructor } from '@poppinss/types';
|
|
3
2
|
/**
|
|
4
3
|
* Define static properties on a class with inheritance in play.
|
|
5
4
|
*/
|
|
6
|
-
export declare function defineStaticProperty<T extends Constructor | AbstractConstructor
|
|
5
|
+
export declare function defineStaticProperty<T extends Constructor<any> | AbstractConstructor<any>, Prop extends keyof T>(self: T, propertyName: Prop, { initialValue, strategy, }: {
|
|
7
6
|
initialValue: T[Prop];
|
|
8
7
|
strategy: 'inherit' | 'define' | ((value: T[Prop]) => T[Prop]);
|
|
9
8
|
}): void;
|
|
10
|
-
export {};
|
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@poppinss/utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0-next.1",
|
|
4
4
|
"description": "Handy utilities for repetitive work",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
|
8
8
|
"build",
|
|
9
9
|
"!build/tests",
|
|
10
|
-
"!build/test_helpers",
|
|
11
10
|
"!build/bin",
|
|
12
11
|
"lodash"
|
|
13
12
|
],
|
|
@@ -18,21 +17,21 @@
|
|
|
18
17
|
"node": "./build/lodash/main.cjs",
|
|
19
18
|
"default": "./build/lodash/main.cjs"
|
|
20
19
|
},
|
|
21
|
-
"./
|
|
22
|
-
"./
|
|
23
|
-
"./
|
|
24
|
-
"./
|
|
25
|
-
"./
|
|
26
|
-
"./
|
|
27
|
-
"./exception": "./build/
|
|
28
|
-
"./
|
|
20
|
+
"./fs": "./build/modules/fs/main.js",
|
|
21
|
+
"./json": "./build/modules/json/main.js",
|
|
22
|
+
"./string": "./build/modules/string/main.js",
|
|
23
|
+
"./string_builder": "./build/modules/string/string_builder.js",
|
|
24
|
+
"./assert": "./build/modules/assert.js",
|
|
25
|
+
"./base64": "./build/modules/base64.js",
|
|
26
|
+
"./exception": "./build/modules/exception.js",
|
|
27
|
+
"./types": "./build/modules/types.js"
|
|
29
28
|
},
|
|
30
29
|
"engines": {
|
|
31
|
-
"node": ">=
|
|
30
|
+
"node": ">=24.0.0"
|
|
32
31
|
},
|
|
33
32
|
"scripts": {
|
|
34
33
|
"pretest": "npm run lint",
|
|
35
|
-
"test": "npm run build:lodash &&
|
|
34
|
+
"test": "npm run build:lodash && npm run quick:test",
|
|
36
35
|
"build:lodash": "lodash include=\"pick,omit,has,get,set,unset,mergeWith,merge,size,clone,cloneDeep,toPath\" --production && move-file ./lodash.custom.min.js build/lodash/main.cjs",
|
|
37
36
|
"lint": "eslint",
|
|
38
37
|
"format": "prettier --write .",
|
|
@@ -43,7 +42,7 @@
|
|
|
43
42
|
"version": "npm run build",
|
|
44
43
|
"prepublishOnly": "npm run build",
|
|
45
44
|
"release": "release-it",
|
|
46
|
-
"quick:test": "node --import
|
|
45
|
+
"quick:test": "node --import=@poppinss/ts-exec bin/test.ts"
|
|
47
46
|
},
|
|
48
47
|
"devDependencies": {
|
|
49
48
|
"@adonisjs/eslint-config": "^2.0.0",
|
|
@@ -53,26 +52,26 @@
|
|
|
53
52
|
"@japa/assert": "^4.0.1",
|
|
54
53
|
"@japa/expect-type": "^2.0.3",
|
|
55
54
|
"@japa/runner": "^4.2.0",
|
|
55
|
+
"@poppinss/ts-exec": "^1.1.5",
|
|
56
56
|
"@release-it/conventional-changelog": "^10.0.1",
|
|
57
|
-
"@swc/core": "1.10.7",
|
|
58
57
|
"@types/fs-extra": "^11.0.4",
|
|
59
|
-
"@types/node": "^22.15.
|
|
58
|
+
"@types/node": "^22.15.21",
|
|
60
59
|
"c8": "^10.1.3",
|
|
61
|
-
"eslint": "^9.
|
|
60
|
+
"eslint": "^9.27.0",
|
|
62
61
|
"fs-extra": "^11.3.0",
|
|
63
62
|
"lodash": "^4.17.21",
|
|
64
63
|
"lodash-cli": "^4.17.5",
|
|
65
64
|
"move-file-cli": "^3.0.0",
|
|
66
65
|
"prettier": "^3.5.3",
|
|
67
66
|
"release-it": "^19.0.2",
|
|
68
|
-
"
|
|
69
|
-
"tsup": "^8.4.0",
|
|
67
|
+
"tsup": "^8.5.0",
|
|
70
68
|
"typescript": "^5.8.3"
|
|
71
69
|
},
|
|
72
70
|
"dependencies": {
|
|
73
71
|
"@poppinss/exception": "^1.2.1",
|
|
74
72
|
"@poppinss/object-builder": "^1.1.0",
|
|
75
|
-
"@poppinss/string": "^1.
|
|
73
|
+
"@poppinss/string": "^1.6.0",
|
|
74
|
+
"@poppinss/types": "^1.1.0",
|
|
76
75
|
"flattie": "^1.1.1",
|
|
77
76
|
"safe-stable-stringify": "^2.5.0",
|
|
78
77
|
"secure-json-parse": "^4.0.0"
|
|
@@ -98,14 +97,14 @@
|
|
|
98
97
|
"tsup": {
|
|
99
98
|
"entry": [
|
|
100
99
|
"./index.ts",
|
|
101
|
-
"./
|
|
102
|
-
"./
|
|
103
|
-
"./
|
|
104
|
-
"./
|
|
105
|
-
"./
|
|
106
|
-
"./
|
|
107
|
-
"./
|
|
108
|
-
"./
|
|
100
|
+
"./modules/fs/main.ts",
|
|
101
|
+
"./modules/json/main.ts",
|
|
102
|
+
"./modules/string/main.ts",
|
|
103
|
+
"./modules/string/string_builder.ts",
|
|
104
|
+
"./modules/assert.ts",
|
|
105
|
+
"./modules/base64.ts",
|
|
106
|
+
"./modules/exception.ts",
|
|
107
|
+
"./modules/types.ts"
|
|
109
108
|
],
|
|
110
109
|
"outDir": "./build",
|
|
111
110
|
"clean": true,
|
package/build/chunk-2KG3PWR4.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __copyProps = (to, from, except, desc) => {
|
|
6
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
-
for (let key of __getOwnPropNames(from))
|
|
8
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
-
}
|
|
11
|
-
return to;
|
|
12
|
-
};
|
|
13
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
-
|
|
15
|
-
export {
|
|
16
|
-
__reExport
|
|
17
|
-
};
|
package/build/chunk-4V5ON6P7.js
DELETED
package/build/chunk-EJKUJ44Y.js
DELETED
package/build/chunk-H54AK3PI.js
DELETED
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/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
|