@poppinss/utils 6.5.0-3 → 6.5.0-4

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 (72) hide show
  1. package/README.md +2 -0
  2. package/build/index.d.ts +284 -19
  3. package/build/index.js +372 -23
  4. package/build/src/json/main.d.ts +15 -3
  5. package/build/src/json/main.js +5 -6
  6. package/build/src/string/main.d.ts +121 -15
  7. package/build/src/string/main.js +6 -42
  8. package/build/src/string_builder.d.ts +60 -1
  9. package/build/src/string_builder.js +148 -86
  10. package/build/src/types.d.ts +18 -8
  11. package/build/src/types.js +0 -1
  12. package/package.json +22 -7
  13. package/build/src/base64.d.ts +0 -17
  14. package/build/src/base64.js +0 -35
  15. package/build/src/compose.d.ts +0 -14
  16. package/build/src/compose.js +0 -3
  17. package/build/src/define_static_property.d.ts +0 -7
  18. package/build/src/define_static_property.js +0 -21
  19. package/build/src/exception.d.ts +0 -21
  20. package/build/src/exception.js +0 -40
  21. package/build/src/exceptions/invalid_arguments_exception.d.ts +0 -5
  22. package/build/src/exceptions/invalid_arguments_exception.js +0 -5
  23. package/build/src/exceptions/runtime_exception.d.ts +0 -5
  24. package/build/src/exceptions/runtime_exception.js +0 -5
  25. package/build/src/flatten.d.ts +0 -1
  26. package/build/src/flatten.js +0 -4
  27. package/build/src/fs_import_all.d.ts +0 -3
  28. package/build/src/fs_import_all.js +0 -28
  29. package/build/src/fs_read_all.d.ts +0 -3
  30. package/build/src/fs_read_all.js +0 -55
  31. package/build/src/import_default.d.ts +0 -3
  32. package/build/src/import_default.js +0 -15
  33. package/build/src/is_script_file.d.ts +0 -1
  34. package/build/src/is_script_file.js +0 -12
  35. package/build/src/json/safe_parse.d.ts +0 -2
  36. package/build/src/json/safe_parse.js +0 -7
  37. package/build/src/json/safe_stringify.d.ts +0 -2
  38. package/build/src/json/safe_stringify.js +0 -18
  39. package/build/src/message_builder.d.ts +0 -5
  40. package/build/src/message_builder.js +0 -38
  41. package/build/src/natural_sort.d.ts +0 -1
  42. package/build/src/natural_sort.js +0 -3
  43. package/build/src/object_builder.d.ts +0 -18
  44. package/build/src/object_builder.js +0 -32
  45. package/build/src/safe_equal.d.ts +0 -7
  46. package/build/src/safe_equal.js +0 -14
  47. package/build/src/slash.d.ts +0 -1
  48. package/build/src/slash.js +0 -1
  49. package/build/src/string/bytes.d.ts +0 -6
  50. package/build/src/string/bytes.js +0 -12
  51. package/build/src/string/change_case.d.ts +0 -13
  52. package/build/src/string/change_case.js +0 -75
  53. package/build/src/string/excerpt.d.ts +0 -4
  54. package/build/src/string/excerpt.js +0 -10
  55. package/build/src/string/interpolate.d.ts +0 -1
  56. package/build/src/string/interpolate.js +0 -19
  57. package/build/src/string/milliseconds.d.ts +0 -5
  58. package/build/src/string/milliseconds.js +0 -16
  59. package/build/src/string/ordinal.d.ts +0 -1
  60. package/build/src/string/ordinal.js +0 -21
  61. package/build/src/string/pluralize.d.ts +0 -12
  62. package/build/src/string/pluralize.js +0 -12
  63. package/build/src/string/random.d.ts +0 -1
  64. package/build/src/string/random.js +0 -7
  65. package/build/src/string/seconds.d.ts +0 -5
  66. package/build/src/string/seconds.js +0 -16
  67. package/build/src/string/sentence.d.ts +0 -5
  68. package/build/src/string/sentence.js +0 -13
  69. package/build/src/string/slugify.d.ts +0 -2
  70. package/build/src/string/slugify.js +0 -2
  71. package/build/src/string/truncate.d.ts +0 -4
  72. package/build/src/string/truncate.js +0 -10
@@ -1,23 +1,82 @@
1
- export default class StringBuilder {
1
+ /**
2
+ * String builder to transform the string using the fluent API
3
+ */
4
+ declare class StringBuilder {
2
5
  #private;
3
6
  constructor(value: string | StringBuilder);
7
+ /**
8
+ * Applies dash case transformation
9
+ */
4
10
  dashCase(): this;
11
+ /**
12
+ * Applies dot case transformation
13
+ */
5
14
  dotCase(): this;
15
+ /**
16
+ * Applies snake case transformation
17
+ */
6
18
  snakeCase(): this;
19
+ /**
20
+ * Applies pascal case transformation
21
+ */
7
22
  pascalCase(): this;
23
+ /**
24
+ * Applies camelcase case transformation
25
+ */
8
26
  camelCase(): this;
27
+ /**
28
+ * Applies capital case transformation
29
+ */
9
30
  capitalCase(): this;
31
+ /**
32
+ * Applies title case transformation
33
+ */
10
34
  titleCase(): this;
35
+ /**
36
+ * Applies sentence case transformation
37
+ */
11
38
  sentenceCase(): this;
39
+ /**
40
+ * Removes all sorts of casing from the string
41
+ */
12
42
  noCase(): this;
43
+ /**
44
+ * Converts value to its plural form
45
+ */
13
46
  plural(): this;
47
+ /**
48
+ * Converts value to its singular form
49
+ */
14
50
  singular(): this;
51
+ /**
52
+ * Converts value to a URL friendly slug
53
+ */
15
54
  slugify(): this;
55
+ /**
56
+ * Removes a given suffix from the string
57
+ */
16
58
  removeSuffix(suffix: string): this;
59
+ /**
60
+ * Adds suffix to the string
61
+ */
17
62
  suffix(suffix: string): this;
63
+ /**
64
+ * Removes a given prefix from the string
65
+ */
18
66
  removePrefix(prefix: string): this;
67
+ /**
68
+ * Adds prefix to the string
69
+ */
19
70
  prefix(prefix: string): this;
71
+ /**
72
+ * Removes extension from the value
73
+ */
20
74
  removeExtension(): this;
75
+ /**
76
+ * Adds extension to the value
77
+ */
21
78
  ext(extension: string): this;
22
79
  toString(): string;
23
80
  }
81
+
82
+ export { StringBuilder as default };
@@ -1,86 +1,148 @@
1
- import { extname } from 'node:path';
2
- import string from './string/main.js';
3
- export default class StringBuilder {
4
- #value;
5
- constructor(value) {
6
- this.#value = typeof value === 'string' ? value : value.toString();
7
- }
8
- dashCase() {
9
- this.#value = string.dashCase(this.#value);
10
- return this;
11
- }
12
- dotCase() {
13
- this.#value = string.dotCase(this.#value);
14
- return this;
15
- }
16
- snakeCase() {
17
- this.#value = string.snakeCase(this.#value);
18
- return this;
19
- }
20
- pascalCase() {
21
- this.#value = string.pascalCase(this.#value);
22
- return this;
23
- }
24
- camelCase() {
25
- this.#value = string.camelCase(this.#value);
26
- return this;
27
- }
28
- capitalCase() {
29
- this.#value = string.capitalCase(this.#value);
30
- return this;
31
- }
32
- titleCase() {
33
- this.#value = string.titleCase(this.#value);
34
- return this;
35
- }
36
- sentenceCase() {
37
- this.#value = string.sentenceCase(this.#value);
38
- return this;
39
- }
40
- noCase() {
41
- this.#value = string.noCase(this.#value);
42
- return this;
43
- }
44
- plural() {
45
- this.#value = string.pluralize(this.#value);
46
- return this;
47
- }
48
- singular() {
49
- this.#value = string.singular(this.#value);
50
- return this;
51
- }
52
- slugify() {
53
- this.#value = string.slug(this.#value);
54
- return this;
55
- }
56
- removeSuffix(suffix) {
57
- this.#value = this.#value.replace(new RegExp(`[-_]?${suffix}$`, 'i'), '');
58
- return this;
59
- }
60
- suffix(suffix) {
61
- this.removeSuffix(suffix);
62
- this.#value = `${this.#value}${suffix}`;
63
- return this;
64
- }
65
- removePrefix(prefix) {
66
- this.#value = this.#value.replace(new RegExp(`^${prefix}[-_]?`, 'i'), '');
67
- return this;
68
- }
69
- prefix(prefix) {
70
- this.removePrefix(prefix);
71
- this.#value = `${prefix}${this.#value}`;
72
- return this;
73
- }
74
- removeExtension() {
75
- this.#value = this.#value.replace(new RegExp(`${extname(this.#value)}$`), '');
76
- return this;
77
- }
78
- ext(extension) {
79
- this.removeExtension();
80
- this.#value = `${this.#value}.${extension.replace(/^\./, '')}`;
81
- return this;
82
- }
83
- toString() {
84
- return this.#value;
85
- }
86
- }
1
+ import {
2
+ main_default
3
+ } from "../chunk-OKRMWJO4.js";
4
+ import "../chunk-PWRXO3NF.js";
5
+
6
+ // src/string_builder.ts
7
+ import { extname } from "node:path";
8
+ var StringBuilder = class {
9
+ #value;
10
+ constructor(value) {
11
+ this.#value = typeof value === "string" ? value : value.toString();
12
+ }
13
+ /**
14
+ * Applies dash case transformation
15
+ */
16
+ dashCase() {
17
+ this.#value = main_default.dashCase(this.#value);
18
+ return this;
19
+ }
20
+ /**
21
+ * Applies dot case transformation
22
+ */
23
+ dotCase() {
24
+ this.#value = main_default.dotCase(this.#value);
25
+ return this;
26
+ }
27
+ /**
28
+ * Applies snake case transformation
29
+ */
30
+ snakeCase() {
31
+ this.#value = main_default.snakeCase(this.#value);
32
+ return this;
33
+ }
34
+ /**
35
+ * Applies pascal case transformation
36
+ */
37
+ pascalCase() {
38
+ this.#value = main_default.pascalCase(this.#value);
39
+ return this;
40
+ }
41
+ /**
42
+ * Applies camelcase case transformation
43
+ */
44
+ camelCase() {
45
+ this.#value = main_default.camelCase(this.#value);
46
+ return this;
47
+ }
48
+ /**
49
+ * Applies capital case transformation
50
+ */
51
+ capitalCase() {
52
+ this.#value = main_default.capitalCase(this.#value);
53
+ return this;
54
+ }
55
+ /**
56
+ * Applies title case transformation
57
+ */
58
+ titleCase() {
59
+ this.#value = main_default.titleCase(this.#value);
60
+ return this;
61
+ }
62
+ /**
63
+ * Applies sentence case transformation
64
+ */
65
+ sentenceCase() {
66
+ this.#value = main_default.sentenceCase(this.#value);
67
+ return this;
68
+ }
69
+ /**
70
+ * Removes all sorts of casing from the string
71
+ */
72
+ noCase() {
73
+ this.#value = main_default.noCase(this.#value);
74
+ return this;
75
+ }
76
+ /**
77
+ * Converts value to its plural form
78
+ */
79
+ plural() {
80
+ this.#value = main_default.pluralize(this.#value);
81
+ return this;
82
+ }
83
+ /**
84
+ * Converts value to its singular form
85
+ */
86
+ singular() {
87
+ this.#value = main_default.singular(this.#value);
88
+ return this;
89
+ }
90
+ /**
91
+ * Converts value to a URL friendly slug
92
+ */
93
+ slugify() {
94
+ this.#value = main_default.slug(this.#value);
95
+ return this;
96
+ }
97
+ /**
98
+ * Removes a given suffix from the string
99
+ */
100
+ removeSuffix(suffix) {
101
+ this.#value = this.#value.replace(new RegExp(`[-_]?${suffix}$`, "i"), "");
102
+ return this;
103
+ }
104
+ /**
105
+ * Adds suffix to the string
106
+ */
107
+ suffix(suffix) {
108
+ this.removeSuffix(suffix);
109
+ this.#value = `${this.#value}${suffix}`;
110
+ return this;
111
+ }
112
+ /**
113
+ * Removes a given prefix from the string
114
+ */
115
+ removePrefix(prefix) {
116
+ this.#value = this.#value.replace(new RegExp(`^${prefix}[-_]?`, "i"), "");
117
+ return this;
118
+ }
119
+ /**
120
+ * Adds prefix to the string
121
+ */
122
+ prefix(prefix) {
123
+ this.removePrefix(prefix);
124
+ this.#value = `${prefix}${this.#value}`;
125
+ return this;
126
+ }
127
+ /**
128
+ * Removes extension from the value
129
+ */
130
+ removeExtension() {
131
+ this.#value = this.#value.replace(new RegExp(`${extname(this.#value)}$`), "");
132
+ return this;
133
+ }
134
+ /**
135
+ * Adds extension to the value
136
+ */
137
+ ext(extension) {
138
+ this.removeExtension();
139
+ this.#value = `${this.#value}.${extension.replace(/^\./, "")}`;
140
+ return this;
141
+ }
142
+ toString() {
143
+ return this.#value;
144
+ }
145
+ };
146
+ export {
147
+ StringBuilder as default
148
+ };
@@ -1,22 +1,32 @@
1
1
  type PickKeysByValue<T, V> = {
2
2
  [K in keyof T]: T[K] extends V ? K : never;
3
3
  }[keyof T];
4
- export type OmitProperties<T, P> = Omit<T, PickKeysByValue<T, P>>;
4
+ type OmitProperties<T, P> = Omit<T, PickKeysByValue<T, P>>;
5
5
  type ScanFsBaseOptions = {
6
6
  ignoreMissingRoot?: boolean;
7
7
  filter?: (filePath: string, index: number) => boolean;
8
8
  sort?: (current: string, next: string) => number;
9
9
  };
10
- export type ImportAllFilesOptions = ScanFsBaseOptions & {
10
+ type ImportAllFilesOptions = ScanFsBaseOptions & {
11
+ /**
12
+ * A custom method to transform collection keys
13
+ */
11
14
  transformKeys?: (keys: string[]) => string[];
12
15
  };
13
- export type ReadAllFilesOptions = ScanFsBaseOptions & {
16
+ type ReadAllFilesOptions = ScanFsBaseOptions & {
14
17
  pathType?: 'relative' | 'unixRelative' | 'absolute' | 'unixAbsolute' | 'url';
15
18
  };
16
- export type JSONReplacer = (this: any, key: string, value: any) => any;
17
- export type JSONReviver = (this: any, key: string, value: any) => any;
18
- export type Constructor = new (...args: any[]) => any;
19
- export type NormalizeConstructor<T extends Constructor> = {
19
+ type JSONReplacer = (this: any, key: string, value: any) => any;
20
+ type JSONReviver = (this: any, key: string, value: any) => any;
21
+ 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
+ type NormalizeConstructor<T extends Constructor> = {
20
29
  new (...args: any[]): InstanceType<T>;
21
30
  } & Omit<T, 'constructor'>;
22
- export {};
31
+
32
+ export { Constructor, ImportAllFilesOptions, JSONReplacer, JSONReviver, NormalizeConstructor, OmitProperties, ReadAllFilesOptions };
@@ -1 +0,0 @@
1
- export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@poppinss/utils",
3
- "version": "6.5.0-3",
3
+ "version": "6.5.0-4",
4
4
  "description": "Handy utilities for repetitive work",
5
5
  "main": "build/index.js",
6
6
  "type": "module",
@@ -32,11 +32,11 @@
32
32
  "quick:test": "node --loader=ts-node/esm bin/test.ts",
33
33
  "clean": "del-cli build",
34
34
  "typecheck": "tsc --noEmit",
35
- "compile": "npm run lint && npm run clean && tsc",
35
+ "compile": "npm run lint && npm run clean && tsup-node",
36
36
  "build": "npm run compile && npm run build:lodash",
37
37
  "release": "np",
38
38
  "version": "npm run build",
39
- "prepublishOnly": "npm run build && cd build && node bin/test.js",
39
+ "prepublishOnly": "npm run build",
40
40
  "lint": "eslint . --ext=.ts",
41
41
  "format": "prettier --write .",
42
42
  "sync-labels": "github-label-sync --labels .github/labels.json poppinss/utils"
@@ -61,7 +61,7 @@
61
61
  "@types/node": "^20.3.2",
62
62
  "c8": "^8.0.0",
63
63
  "del-cli": "^5.0.0",
64
- "eslint": "^8.43.0",
64
+ "eslint": "^8.45.0",
65
65
  "fs-extra": "^11.1.1",
66
66
  "github-label-sync": "^2.3.1",
67
67
  "husky": "^8.0.3",
@@ -69,14 +69,15 @@
69
69
  "lodash-cli": "^4.17.5",
70
70
  "move-file-cli": "^3.0.0",
71
71
  "np": "^8.0.4",
72
- "prettier": "^2.8.8",
72
+ "prettier": "^3.0.0",
73
73
  "ts-node": "^10.9.1",
74
+ "tsup": "^7.1.0",
74
75
  "typescript": "^5.1.6"
75
76
  },
76
77
  "dependencies": {
77
78
  "@lukeed/ms": "^2.0.1",
78
79
  "@types/bytes": "^3.1.1",
79
- "@types/pluralize": "^0.0.29",
80
+ "@types/pluralize": "0.0.30",
80
81
  "bytes": "^3.1.2",
81
82
  "case-anything": "^2.1.13",
82
83
  "flattie": "^1.1.0",
@@ -124,5 +125,19 @@
124
125
  "eslintConfig": {
125
126
  "extends": "@adonisjs/eslint-config/package"
126
127
  },
127
- "prettier": "@adonisjs/prettier-config"
128
+ "prettier": "@adonisjs/prettier-config",
129
+ "tsup": {
130
+ "entry": [
131
+ "./index.ts",
132
+ "./src/string/main.ts",
133
+ "./src/string_builder.ts",
134
+ "./src/json/main.ts",
135
+ "./src/types.ts"
136
+ ],
137
+ "outDir": "./build",
138
+ "clean": true,
139
+ "format": "esm",
140
+ "dts": true,
141
+ "target": "esnext"
142
+ }
128
143
  }
@@ -1,17 +0,0 @@
1
- /// <reference types="@types/node" resolution-mode="require"/>
2
- declare class Base64 {
3
- encode(arrayBuffer: ArrayBuffer | SharedArrayBuffer): string;
4
- encode(data: string, encoding?: BufferEncoding): string;
5
- decode(encode: string, encoding: BufferEncoding, strict: true): string;
6
- decode(encode: string, encoding: undefined, strict: true): string;
7
- decode(encode: string, encoding?: BufferEncoding, strict?: false): string | null;
8
- decode(encode: Buffer, encoding?: BufferEncoding): string;
9
- urlEncode(arrayBuffer: ArrayBuffer | SharedArrayBuffer): string;
10
- urlEncode(data: string, encoding?: BufferEncoding): string;
11
- urlDecode(encode: string, encoding: BufferEncoding, strict: true): string;
12
- urlDecode(encode: string, encoding: undefined, strict: true): string;
13
- urlDecode(encode: string, encoding?: BufferEncoding, strict?: false): string | null;
14
- urlDecode(encode: Buffer, encoding?: BufferEncoding): string;
15
- }
16
- export declare const base64: Base64;
17
- export {};
@@ -1,35 +0,0 @@
1
- class Base64 {
2
- encode(data, encoding) {
3
- if (typeof data === 'string') {
4
- return Buffer.from(data, encoding).toString('base64');
5
- }
6
- return Buffer.from(data).toString('base64');
7
- }
8
- decode(encoded, encoding = 'utf-8', strict = false) {
9
- if (Buffer.isBuffer(encoded)) {
10
- return encoded.toString(encoding);
11
- }
12
- const decoded = Buffer.from(encoded, 'base64').toString(encoding);
13
- const isInvalid = this.encode(decoded, encoding) !== encoded;
14
- if (strict && isInvalid) {
15
- throw new Error('Cannot decode malformed value');
16
- }
17
- return isInvalid ? null : decoded;
18
- }
19
- urlEncode(data, encoding) {
20
- const encoded = typeof data === 'string' ? this.encode(data, encoding) : this.encode(data);
21
- return encoded.replace(/\+/g, '-').replace(/\//g, '_').replace(/\=/g, '');
22
- }
23
- urlDecode(encoded, encoding = 'utf-8', strict = false) {
24
- if (Buffer.isBuffer(encoded)) {
25
- return encoded.toString(encoding);
26
- }
27
- const decoded = Buffer.from(encoded, 'base64').toString(encoding);
28
- const isInvalid = this.urlEncode(decoded, encoding) !== encoded;
29
- if (strict && isInvalid) {
30
- throw new Error('Cannot urlDecode malformed value');
31
- }
32
- return isInvalid ? null : decoded;
33
- }
34
- }
35
- export const base64 = new Base64();
@@ -1,14 +0,0 @@
1
- import type { Constructor } from './types.js';
2
- interface UnaryFunction<T, R> {
3
- (source: T): R;
4
- }
5
- export declare function compose<T extends Constructor, A>(superclass: T, mixin: UnaryFunction<T, A>): A;
6
- export declare function compose<T extends Constructor, A, B>(superclass: T, mixin: UnaryFunction<T, A>, mixinB: UnaryFunction<A, B>): B;
7
- 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;
8
- 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;
9
- 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;
10
- 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;
11
- 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;
12
- 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;
13
- 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;
14
- export {};
@@ -1,3 +0,0 @@
1
- export function compose(superclass, ...mixins) {
2
- return mixins.reduce((c, mixin) => mixin(c), superclass);
3
- }
@@ -1,7 +0,0 @@
1
- type Constructor = new (...args: any[]) => any;
2
- type AbstractConstructor = abstract new (...args: any[]) => any;
3
- export declare function defineStaticProperty<T extends Constructor | AbstractConstructor, Prop extends keyof T>(self: T, propertyName: Prop, { initialValue, strategy, }: {
4
- initialValue: T[Prop];
5
- strategy: 'inherit' | 'define' | ((value: T[Prop]) => T[Prop]);
6
- }): void;
7
- export {};
@@ -1,21 +0,0 @@
1
- import lodash from '@poppinss/utils/lodash';
2
- export function defineStaticProperty(self, propertyName, { initialValue, strategy, }) {
3
- if (!self.hasOwnProperty(propertyName)) {
4
- const value = self[propertyName];
5
- if (strategy === 'define' || value === undefined) {
6
- Object.defineProperty(self, propertyName, {
7
- value: initialValue,
8
- configurable: true,
9
- enumerable: true,
10
- writable: true,
11
- });
12
- return;
13
- }
14
- Object.defineProperty(self, propertyName, {
15
- value: typeof strategy === 'function' ? strategy(value) : lodash.cloneDeep(value),
16
- configurable: true,
17
- enumerable: true,
18
- writable: true,
19
- });
20
- }
21
- }
@@ -1,21 +0,0 @@
1
- export declare class Exception extends Error {
2
- static help?: string;
3
- static code?: string;
4
- static status?: number;
5
- static message?: string;
6
- name: string;
7
- help?: string;
8
- code?: string;
9
- status: number;
10
- constructor(message?: string, options?: ErrorOptions & {
11
- code?: string;
12
- status?: number;
13
- });
14
- get [Symbol.toStringTag](): string;
15
- toString(): string;
16
- }
17
- export declare function createError<T extends any[] = never>(message: string, code: string, status?: number): typeof Exception & T extends never ? {
18
- new (args?: any, options?: ErrorOptions): Exception;
19
- } : {
20
- new (args: T, options?: ErrorOptions): Exception;
21
- };
@@ -1,40 +0,0 @@
1
- import { format } from 'node:util';
2
- export class Exception extends Error {
3
- name;
4
- status;
5
- constructor(message, options) {
6
- super(message, options);
7
- const ErrorConstructor = this.constructor;
8
- this.name = ErrorConstructor.name;
9
- this.message = message || ErrorConstructor.message || '';
10
- this.status = options?.status || ErrorConstructor.status || 500;
11
- const code = options?.code || ErrorConstructor.code;
12
- if (code !== undefined) {
13
- this.code = code;
14
- }
15
- const help = ErrorConstructor.help;
16
- if (help !== undefined) {
17
- this.help = help;
18
- }
19
- Error.captureStackTrace(this, ErrorConstructor);
20
- }
21
- get [Symbol.toStringTag]() {
22
- return this.constructor.name;
23
- }
24
- toString() {
25
- if (this.code) {
26
- return `${this.name} [${this.code}]: ${this.message}`;
27
- }
28
- return `${this.name}: ${this.message}`;
29
- }
30
- }
31
- export function createError(message, code, status) {
32
- return class extends Exception {
33
- static message = message;
34
- static code = code;
35
- static status = status;
36
- constructor(args, options) {
37
- super(format(message, ...(args || [])), options);
38
- }
39
- };
40
- }
@@ -1,5 +0,0 @@
1
- import { Exception } from '../exception.js';
2
- export declare class InvalidArgumentsException extends Exception {
3
- static code: string;
4
- static status: number;
5
- }
@@ -1,5 +0,0 @@
1
- import { Exception } from '../exception.js';
2
- export class InvalidArgumentsException extends Exception {
3
- static code = 'E_INVALID_ARGUMENTS_EXCEPTION';
4
- static status = 500;
5
- }
@@ -1,5 +0,0 @@
1
- import { Exception } from '../exception.js';
2
- export declare class RuntimeException extends Exception {
3
- static code: string;
4
- static status: number;
5
- }
@@ -1,5 +0,0 @@
1
- import { Exception } from '../exception.js';
2
- export class RuntimeException extends Exception {
3
- static code = 'E_RUNTIME_EXCEPTION';
4
- static status = 500;
5
- }
@@ -1 +0,0 @@
1
- export declare function flatten<X = Record<string, any>, Y = unknown>(input: Y, glue?: string, keepNullish?: boolean): X;
@@ -1,4 +0,0 @@
1
- import { flattie } from 'flattie';
2
- export function flatten(input, glue, keepNullish) {
3
- return flattie(input, glue, keepNullish);
4
- }
@@ -1,3 +0,0 @@
1
- /// <reference types="@types/node" resolution-mode="require"/>
2
- import { ImportAllFilesOptions } from './types.js';
3
- export declare function fsImportAll(location: string | URL, options?: ImportAllFilesOptions): Promise<any>;