@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.
Files changed (46) hide show
  1. package/README.md +205 -829
  2. package/build/chunk-SKNTF5Q5.js +14 -0
  3. package/build/chunk-XFX47BKO.js +23 -0
  4. package/build/{chunk-XHQBV7AF.js → chunk-YFSCSJNE.js} +3 -9
  5. package/build/index.d.ts +4 -24
  6. package/build/index.js +57 -243
  7. package/build/{src → modules}/assert.js +1 -3
  8. package/build/{src → modules}/base64.d.ts +2 -2
  9. package/build/modules/base64.js +43 -0
  10. package/build/modules/exception.d.ts +1 -0
  11. package/build/modules/exception.js +12 -0
  12. package/build/{src → modules/fs}/fs_import_all.d.ts +6 -1
  13. package/build/{src → modules/fs}/fs_read_all.d.ts +6 -1
  14. package/build/modules/fs/main.d.ts +2 -0
  15. package/build/modules/fs/main.js +82 -0
  16. package/build/modules/json/main.d.ts +2 -0
  17. package/build/modules/json/main.js +8 -0
  18. package/build/{src → modules}/json/safe_parse.d.ts +1 -1
  19. package/build/{src → modules}/json/safe_stringify.d.ts +1 -1
  20. package/build/{src → modules}/string/main.js +1 -3
  21. package/build/modules/string/string_builder.d.ts +2 -0
  22. package/build/modules/string/string_builder.js +6 -0
  23. package/build/modules/types.d.ts +1 -0
  24. package/build/modules/types.js +2 -0
  25. package/build/src/compose.d.ts +12 -10
  26. package/build/src/define_static_property.d.ts +2 -4
  27. package/package.json +26 -27
  28. package/build/chunk-2KG3PWR4.js +0 -17
  29. package/build/chunk-4V5ON6P7.js +0 -7
  30. package/build/chunk-EJKUJ44Y.js +0 -12
  31. package/build/chunk-H54AK3PI.js +0 -7
  32. package/build/src/exception.d.ts +0 -1
  33. package/build/src/exception.js +0 -9
  34. package/build/src/exceptions/main.d.ts +0 -1
  35. package/build/src/exceptions/main.js +0 -9
  36. package/build/src/json/main.d.ts +0 -7
  37. package/build/src/json/main.js +0 -7
  38. package/build/src/object_builder.d.ts +0 -1
  39. package/build/src/slash.d.ts +0 -24
  40. package/build/src/slash.js +0 -7
  41. package/build/src/string/string_builder.d.ts +0 -3
  42. package/build/src/string/string_builder.js +0 -9
  43. package/build/src/types.d.ts +0 -35
  44. package/build/src/types.js +0 -0
  45. /package/build/{src → modules}/assert.d.ts +0 -0
  46. /package/build/{src → modules}/string/main.d.ts +0 -0
@@ -0,0 +1,2 @@
1
+ import StringBuilder from '@poppinss/string/builder';
2
+ export default StringBuilder;
@@ -0,0 +1,6 @@
1
+ // modules/string/string_builder.ts
2
+ import StringBuilder from "@poppinss/string/builder";
3
+ var string_builder_default = StringBuilder;
4
+ export {
5
+ string_builder_default as default
6
+ };
@@ -0,0 +1 @@
1
+ export * from '@poppinss/types';
@@ -0,0 +1,2 @@
1
+ // modules/types.ts
2
+ export * from "@poppinss/types";
@@ -1,4 +1,4 @@
1
- import type { Constructor } from './types.js';
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, A>(superclass: T, mixin: UnaryFunction<T, A>): A;
11
- export declare function compose<T extends Constructor, A, B>(superclass: T, mixin: UnaryFunction<T, A>, mixinB: UnaryFunction<A, B>): B;
12
- export declare function compose<T extends Constructor, A, B, C>(superclass: T, mixin: UnaryFunction<T, A>, mixinB: UnaryFunction<A, B>, mixinC: UnaryFunction<B, C>): C;
13
- export declare function compose<T extends Constructor, A, B, C, D>(superclass: T, mixin: UnaryFunction<T, A>, mixinB: UnaryFunction<A, B>, mixinC: UnaryFunction<B, C>, mixinD: UnaryFunction<C, D>): D;
14
- export declare function compose<T extends Constructor, 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;
15
- export declare function compose<T extends Constructor, 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;
16
- export declare function compose<T extends Constructor, 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;
17
- export declare function compose<T extends Constructor, 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;
18
- export declare function compose<T extends Constructor, 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;
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 Constructor = new (...args: any[]) => any;
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, Prop extends keyof T>(self: T, propertyName: Prop, { initialValue, strategy, }: {
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": "6.9.4",
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
- "./assert": "./build/src/assert.js",
22
- "./string": "./build/src/string/main.js",
23
- "./string_builder": "./build/src/string/string_builder.js",
24
- "./json": "./build/src/json/main.js",
25
- "./types": "./build/src/types.js",
26
- "./exceptions": "./build/src/exceptions/main.js",
27
- "./exception": "./build/src/exception.js",
28
- "./slash": "./build/src/slash.js"
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": ">=18.16.0"
30
+ "node": ">=24.0.0"
32
31
  },
33
32
  "scripts": {
34
33
  "pretest": "npm run lint",
35
- "test": "npm run build:lodash && c8 npm run quick:test",
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=ts-node-maintained/register/esm bin/test.ts"
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.3",
58
+ "@types/node": "^22.15.21",
60
59
  "c8": "^10.1.3",
61
- "eslint": "^9.26.0",
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
- "ts-node-maintained": "^10.9.5",
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.3.0",
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
- "./src/assert.ts",
102
- "./src/string/main.ts",
103
- "./src/string/string_builder.ts",
104
- "./src/json/main.ts",
105
- "./src/types.ts",
106
- "./src/slash.ts",
107
- "./src/exception.ts",
108
- "./src/exceptions/main.ts"
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,
@@ -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
- };
@@ -1,7 +0,0 @@
1
- // src/exceptions/main.ts
2
- import { InvalidArgumentsException, RuntimeException } from "@poppinss/exception";
3
-
4
- export {
5
- InvalidArgumentsException,
6
- RuntimeException
7
- };
@@ -1,12 +0,0 @@
1
- // src/slash.ts
2
- function slash(path) {
3
- const isExtendedLengthPath = path.startsWith("\\\\?\\");
4
- if (isExtendedLengthPath) {
5
- return path;
6
- }
7
- return path.replace(/\\/g, "/");
8
- }
9
-
10
- export {
11
- slash
12
- };
@@ -1,7 +0,0 @@
1
- // src/exception.ts
2
- import { Exception, createError } from "@poppinss/exception";
3
-
4
- export {
5
- Exception,
6
- createError
7
- };
@@ -1 +0,0 @@
1
- export { Exception, createError } from '@poppinss/exception';
@@ -1,9 +0,0 @@
1
- import {
2
- Exception,
3
- createError
4
- } from "../chunk-H54AK3PI.js";
5
- import "../chunk-2KG3PWR4.js";
6
- export {
7
- Exception,
8
- createError
9
- };
@@ -1 +0,0 @@
1
- export { InvalidArgumentsException, RuntimeException } from '@poppinss/exception';
@@ -1,9 +0,0 @@
1
- import {
2
- InvalidArgumentsException,
3
- RuntimeException
4
- } from "../../chunk-4V5ON6P7.js";
5
- import "../../chunk-2KG3PWR4.js";
6
- export {
7
- InvalidArgumentsException,
8
- RuntimeException
9
- };
@@ -1,7 +0,0 @@
1
- import { safeParse } from './safe_parse.js';
2
- import { safeStringify } from './safe_stringify.js';
3
- declare const json: {
4
- safeParse: typeof safeParse;
5
- safeStringify: typeof safeStringify;
6
- };
7
- export default json;
@@ -1,7 +0,0 @@
1
- import {
2
- main_default
3
- } from "../../chunk-XHQBV7AF.js";
4
- import "../../chunk-2KG3PWR4.js";
5
- export {
6
- main_default as default
7
- };
@@ -1 +0,0 @@
1
- export * from '@poppinss/object-builder';
@@ -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;
@@ -1,7 +0,0 @@
1
- import {
2
- slash
3
- } from "../chunk-EJKUJ44Y.js";
4
- import "../chunk-2KG3PWR4.js";
5
- export {
6
- slash
7
- };
@@ -1,3 +0,0 @@
1
- import string from '@poppinss/string/builder';
2
- export * from '@poppinss/string/builder';
3
- export default string;
@@ -1,9 +0,0 @@
1
- import "../../chunk-2KG3PWR4.js";
2
-
3
- // src/string/string_builder.ts
4
- import string from "@poppinss/string/builder";
5
- export * from "@poppinss/string/builder";
6
- var string_builder_default = string;
7
- export {
8
- string_builder_default as default
9
- };
@@ -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 {};
File without changes
File without changes
File without changes