@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/index.d.ts
CHANGED
|
@@ -1,29 +1,9 @@
|
|
|
1
1
|
export { Secret } from './src/secret.js';
|
|
2
|
-
export { base64 } from './src/base64.js';
|
|
3
2
|
export { compose } from './src/compose.js';
|
|
4
|
-
export { importDefault } from './src/import_default.js';
|
|
5
|
-
export { defineStaticProperty } from './src/define_static_property.js';
|
|
6
|
-
export { Exception, createError } from './src/exception.js';
|
|
7
3
|
export { flatten } from './src/flatten.js';
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
4
|
+
export { safeEqual } from './src/safe_equal.js';
|
|
5
|
+
export { naturalSort } from './src/natural_sort.js';
|
|
10
6
|
export { isScriptFile } from './src/is_script_file.js';
|
|
7
|
+
export { importDefault } from './src/import_default.js';
|
|
11
8
|
export { MessageBuilder } from './src/message_builder.js';
|
|
12
|
-
export {
|
|
13
|
-
export { ObjectBuilder } from './src/object_builder.js';
|
|
14
|
-
export { safeEqual } from './src/safe_equal.js';
|
|
15
|
-
export { slash } from './src/slash.js';
|
|
16
|
-
export { RuntimeException, InvalidArgumentsException } from './src/exceptions/main.js';
|
|
17
|
-
/**
|
|
18
|
-
* Get dirname for a given file path URL
|
|
19
|
-
*/
|
|
20
|
-
export declare function getDirname(url: string | URL): string;
|
|
21
|
-
/**
|
|
22
|
-
* Get filename for a given file path URL
|
|
23
|
-
*/
|
|
24
|
-
export declare function getFilename(url: string | URL): string;
|
|
25
|
-
/**
|
|
26
|
-
* Join paths to a URL instance or a URL string. The return
|
|
27
|
-
* value will be a file path without the `file:///` protocol.
|
|
28
|
-
*/
|
|
29
|
-
export declare function joinToURL(url: string | URL, ...str: string[]): string;
|
|
9
|
+
export { defineStaticProperty } from './src/define_static_property.js';
|
package/build/index.js
CHANGED
|
@@ -1,24 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
} from "./chunk-XHQBV7AF.js";
|
|
15
|
-
import {
|
|
16
|
-
__reExport
|
|
17
|
-
} from "./chunk-2KG3PWR4.js";
|
|
18
|
-
|
|
19
|
-
// index.ts
|
|
20
|
-
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
21
|
-
import { join as pathJoin, dirname as pathDirname } from "node:path";
|
|
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"));
|
|
22
14
|
|
|
23
15
|
// src/secret.ts
|
|
24
16
|
var REDACTED = "[redacted]";
|
|
@@ -60,167 +52,42 @@ var Secret = class _Secret {
|
|
|
60
52
|
}
|
|
61
53
|
};
|
|
62
54
|
|
|
63
|
-
// src/base64.ts
|
|
64
|
-
var Base64 = class {
|
|
65
|
-
encode(data, encoding) {
|
|
66
|
-
if (typeof data === "string") {
|
|
67
|
-
return Buffer.from(data, encoding).toString("base64");
|
|
68
|
-
}
|
|
69
|
-
if (Buffer.isBuffer(data)) {
|
|
70
|
-
return data.toString("base64");
|
|
71
|
-
}
|
|
72
|
-
return Buffer.from(data).toString("base64");
|
|
73
|
-
}
|
|
74
|
-
decode(encoded, encoding = "utf-8", strict = false) {
|
|
75
|
-
if (Buffer.isBuffer(encoded)) {
|
|
76
|
-
return encoded.toString(encoding);
|
|
77
|
-
}
|
|
78
|
-
const decoded = Buffer.from(encoded, "base64").toString(encoding);
|
|
79
|
-
const isInvalid = this.encode(decoded, encoding) !== encoded;
|
|
80
|
-
if (strict && isInvalid) {
|
|
81
|
-
throw new Error("Cannot decode malformed value");
|
|
82
|
-
}
|
|
83
|
-
return isInvalid ? null : decoded;
|
|
84
|
-
}
|
|
85
|
-
urlEncode(data, encoding) {
|
|
86
|
-
const encoded = typeof data === "string" ? this.encode(data, encoding) : this.encode(data);
|
|
87
|
-
return encoded.replace(/\+/g, "-").replace(/\//g, "_").replace(/\=/g, "");
|
|
88
|
-
}
|
|
89
|
-
urlDecode(encoded, encoding = "utf-8", strict = false) {
|
|
90
|
-
if (Buffer.isBuffer(encoded)) {
|
|
91
|
-
return encoded.toString(encoding);
|
|
92
|
-
}
|
|
93
|
-
const decoded = Buffer.from(encoded, "base64").toString(encoding);
|
|
94
|
-
const isInvalid = this.urlEncode(decoded, encoding) !== encoded;
|
|
95
|
-
if (strict && isInvalid) {
|
|
96
|
-
throw new Error("Cannot urlDecode malformed value");
|
|
97
|
-
}
|
|
98
|
-
return isInvalid ? null : decoded;
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
var base64 = new Base64();
|
|
102
|
-
|
|
103
55
|
// src/compose.ts
|
|
104
56
|
function compose(superclass, ...mixins) {
|
|
105
57
|
return mixins.reduce((c, mixin) => mixin(c), superclass);
|
|
106
58
|
}
|
|
107
59
|
|
|
108
|
-
// src/import_default.ts
|
|
109
|
-
async function importDefault(importFn, filePath) {
|
|
110
|
-
const moduleExports = await importFn();
|
|
111
|
-
if (!("default" in moduleExports)) {
|
|
112
|
-
const errorMessage = filePath ? `Missing "export default" in module "${filePath}"` : `Missing "export default" from lazy import "${importFn}"`;
|
|
113
|
-
throw new RuntimeException(errorMessage, {
|
|
114
|
-
cause: {
|
|
115
|
-
source: importFn
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
return moduleExports.default;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// src/define_static_property.ts
|
|
123
|
-
import lodash from "@poppinss/utils/lodash";
|
|
124
|
-
function defineStaticProperty(self, propertyName, {
|
|
125
|
-
initialValue,
|
|
126
|
-
strategy
|
|
127
|
-
}) {
|
|
128
|
-
if (!self.hasOwnProperty(propertyName)) {
|
|
129
|
-
const value = self[propertyName];
|
|
130
|
-
if (strategy === "define" || value === void 0) {
|
|
131
|
-
Object.defineProperty(self, propertyName, {
|
|
132
|
-
value: initialValue,
|
|
133
|
-
configurable: true,
|
|
134
|
-
enumerable: true,
|
|
135
|
-
writable: true
|
|
136
|
-
});
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
Object.defineProperty(self, propertyName, {
|
|
140
|
-
value: typeof strategy === "function" ? strategy(value) : lodash.cloneDeep(value),
|
|
141
|
-
configurable: true,
|
|
142
|
-
enumerable: true,
|
|
143
|
-
writable: true
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
60
|
// src/flatten.ts
|
|
149
61
|
import { flattie } from "flattie";
|
|
150
62
|
function flatten(input, glue, keepNullish) {
|
|
151
63
|
return flattie(input, glue, keepNullish);
|
|
152
64
|
}
|
|
153
65
|
|
|
154
|
-
// src/
|
|
155
|
-
import {
|
|
156
|
-
import
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
66
|
+
// src/safe_equal.ts
|
|
67
|
+
import { Buffer as Buffer2 } from "buffer";
|
|
68
|
+
import { timingSafeEqual } from "crypto";
|
|
69
|
+
function safeEqual(trustedValue, userInput) {
|
|
70
|
+
if (typeof trustedValue === "string" && typeof userInput === "string") {
|
|
71
|
+
const trustedLength = Buffer2.byteLength(trustedValue);
|
|
72
|
+
const trustedValueBuffer = Buffer2.alloc(trustedLength, 0, "utf-8");
|
|
73
|
+
trustedValueBuffer.write(trustedValue);
|
|
74
|
+
const userValueBuffer = Buffer2.alloc(trustedLength, 0, "utf-8");
|
|
75
|
+
userValueBuffer.write(userInput);
|
|
76
|
+
return timingSafeEqual(trustedValueBuffer, userValueBuffer) && trustedLength === Buffer2.byteLength(userInput);
|
|
77
|
+
}
|
|
78
|
+
return timingSafeEqual(
|
|
79
|
+
Buffer2.from(trustedValue),
|
|
80
|
+
Buffer2.from(userInput)
|
|
81
|
+
);
|
|
82
|
+
}
|
|
163
83
|
|
|
164
84
|
// src/natural_sort.ts
|
|
165
85
|
function naturalSort(current, next) {
|
|
166
86
|
return current.localeCompare(next, void 0, { numeric: true, sensitivity: "base" });
|
|
167
87
|
}
|
|
168
88
|
|
|
169
|
-
// src/fs_read_all.ts
|
|
170
|
-
function filterDotFiles(fileName) {
|
|
171
|
-
return fileName[0] !== ".";
|
|
172
|
-
}
|
|
173
|
-
async function readFiles(root, files, options, relativePath) {
|
|
174
|
-
const location = join(root, relativePath);
|
|
175
|
-
const stats = await stat(location);
|
|
176
|
-
if (stats.isDirectory()) {
|
|
177
|
-
let locationFiles = await readdir(location);
|
|
178
|
-
await Promise.all(
|
|
179
|
-
locationFiles.filter(filterDotFiles).map((file) => {
|
|
180
|
-
return readFiles(root, files, options, join(relativePath, file));
|
|
181
|
-
})
|
|
182
|
-
);
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
const pathType = options.pathType || "relative";
|
|
186
|
-
switch (pathType) {
|
|
187
|
-
case "relative":
|
|
188
|
-
files.push(relativePath);
|
|
189
|
-
break;
|
|
190
|
-
case "absolute":
|
|
191
|
-
files.push(location);
|
|
192
|
-
break;
|
|
193
|
-
case "unixRelative":
|
|
194
|
-
files.push(slash(relativePath));
|
|
195
|
-
break;
|
|
196
|
-
case "unixAbsolute":
|
|
197
|
-
files.push(slash(location));
|
|
198
|
-
break;
|
|
199
|
-
case "url":
|
|
200
|
-
files.push(pathToFileURL(location).href);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
async function fsReadAll(location, options) {
|
|
204
|
-
const normalizedLocation = typeof location === "string" ? location : fileURLToPath(location);
|
|
205
|
-
const normalizedOptions = Object.assign({ absolute: false, sort: naturalSort }, options);
|
|
206
|
-
const files = [];
|
|
207
|
-
try {
|
|
208
|
-
await stat(normalizedLocation);
|
|
209
|
-
} catch (error) {
|
|
210
|
-
if (normalizedOptions.ignoreMissingRoot) {
|
|
211
|
-
return [];
|
|
212
|
-
}
|
|
213
|
-
throw error;
|
|
214
|
-
}
|
|
215
|
-
await readFiles(normalizedLocation, files, normalizedOptions, "");
|
|
216
|
-
if (normalizedOptions.filter) {
|
|
217
|
-
return files.filter(normalizedOptions.filter).sort(normalizedOptions.sort);
|
|
218
|
-
}
|
|
219
|
-
return files.sort(normalizedOptions.sort);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
89
|
// src/is_script_file.ts
|
|
223
|
-
import { extname } from "
|
|
90
|
+
import { extname } from "path";
|
|
224
91
|
var JS_MODULES = [".js", ".json", ".cjs", ".mjs"];
|
|
225
92
|
function isScriptFile(filePath) {
|
|
226
93
|
const ext = extname(filePath);
|
|
@@ -233,33 +100,58 @@ function isScriptFile(filePath) {
|
|
|
233
100
|
return false;
|
|
234
101
|
}
|
|
235
102
|
|
|
236
|
-
//
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
103
|
+
// modules/exception.ts
|
|
104
|
+
var exception_exports = {};
|
|
105
|
+
__reExport(exception_exports, exception_star);
|
|
106
|
+
import * as exception_star from "@poppinss/exception";
|
|
107
|
+
|
|
108
|
+
// src/import_default.ts
|
|
109
|
+
async function importDefault(importFn, filePath) {
|
|
110
|
+
const moduleExports = await importFn();
|
|
111
|
+
if (!("default" in moduleExports)) {
|
|
112
|
+
const errorMessage = filePath ? `Missing "export default" in module "${filePath}"` : `Missing "export default" from lazy import "${importFn}"`;
|
|
113
|
+
throw new exception_exports.RuntimeException(errorMessage, {
|
|
114
|
+
cause: {
|
|
115
|
+
source: importFn
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
return moduleExports.default;
|
|
247
120
|
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
121
|
+
|
|
122
|
+
// src/message_builder.ts
|
|
123
|
+
import string from "@poppinss/string";
|
|
124
|
+
|
|
125
|
+
// modules/json/safe_parse.ts
|
|
126
|
+
import { parse } from "secure-json-parse";
|
|
127
|
+
function safeParse(jsonString, reviver) {
|
|
128
|
+
return parse(jsonString, reviver, {
|
|
129
|
+
protoAction: "remove",
|
|
130
|
+
constructorAction: "remove"
|
|
256
131
|
});
|
|
257
|
-
|
|
258
|
-
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// modules/json/safe_stringify.ts
|
|
135
|
+
import { configure } from "safe-stable-stringify";
|
|
136
|
+
var stringify = configure({
|
|
137
|
+
bigint: false,
|
|
138
|
+
circularValue: void 0,
|
|
139
|
+
deterministic: false
|
|
140
|
+
});
|
|
141
|
+
function jsonStringifyReplacer(replacer) {
|
|
142
|
+
return function(key, value) {
|
|
143
|
+
const val = replacer ? replacer.call(this, key, value) : value;
|
|
144
|
+
if (typeof val === "bigint") {
|
|
145
|
+
return val.toString();
|
|
146
|
+
}
|
|
147
|
+
return val;
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
function safeStringify(value, replacer, space) {
|
|
151
|
+
return stringify(value, jsonStringifyReplacer(replacer), space);
|
|
259
152
|
}
|
|
260
153
|
|
|
261
154
|
// src/message_builder.ts
|
|
262
|
-
import string from "@poppinss/string";
|
|
263
155
|
var MessageBuilder = class {
|
|
264
156
|
#getExpiryDate(expiresIn) {
|
|
265
157
|
if (!expiresIn) {
|
|
@@ -283,13 +175,13 @@ var MessageBuilder = class {
|
|
|
283
175
|
*/
|
|
284
176
|
build(message, expiresIn, purpose) {
|
|
285
177
|
const expiryDate = this.#getExpiryDate(expiresIn);
|
|
286
|
-
return
|
|
178
|
+
return safeStringify({ message, purpose, expiryDate });
|
|
287
179
|
}
|
|
288
180
|
/**
|
|
289
181
|
* Verifies the message for expiry and purpose.
|
|
290
182
|
*/
|
|
291
183
|
verify(message, purpose) {
|
|
292
|
-
const parsed =
|
|
184
|
+
const parsed = safeParse(message);
|
|
293
185
|
if (typeof parsed !== "object" || !parsed) {
|
|
294
186
|
return null;
|
|
295
187
|
}
|
|
@@ -306,60 +198,39 @@ var MessageBuilder = class {
|
|
|
306
198
|
}
|
|
307
199
|
};
|
|
308
200
|
|
|
309
|
-
// src/
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
201
|
+
// src/define_static_property.ts
|
|
202
|
+
import lodash from "@poppinss/utils/lodash";
|
|
203
|
+
function defineStaticProperty(self, propertyName, {
|
|
204
|
+
initialValue,
|
|
205
|
+
strategy
|
|
206
|
+
}) {
|
|
207
|
+
if (!self.hasOwnProperty(propertyName)) {
|
|
208
|
+
const value = self[propertyName];
|
|
209
|
+
if (strategy === "define" || value === void 0) {
|
|
210
|
+
Object.defineProperty(self, propertyName, {
|
|
211
|
+
value: initialValue,
|
|
212
|
+
configurable: true,
|
|
213
|
+
enumerable: true,
|
|
214
|
+
writable: true
|
|
215
|
+
});
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
Object.defineProperty(self, propertyName, {
|
|
219
|
+
value: typeof strategy === "function" ? strategy(value) : lodash.cloneDeep(value),
|
|
220
|
+
configurable: true,
|
|
221
|
+
enumerable: true,
|
|
222
|
+
writable: true
|
|
223
|
+
});
|
|
325
224
|
}
|
|
326
|
-
return timingSafeEqual(
|
|
327
|
-
Buffer2.from(trustedValue),
|
|
328
|
-
Buffer2.from(userInput)
|
|
329
|
-
);
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
// index.ts
|
|
333
|
-
function getDirname(url) {
|
|
334
|
-
return pathDirname(getFilename(url));
|
|
335
|
-
}
|
|
336
|
-
function getFilename(url) {
|
|
337
|
-
return fileURLToPath3(url);
|
|
338
|
-
}
|
|
339
|
-
function joinToURL(url, ...str) {
|
|
340
|
-
return pathJoin(getDirname(url), ...str);
|
|
341
225
|
}
|
|
342
|
-
var export_ObjectBuilder = object_builder_exports.ObjectBuilder;
|
|
343
226
|
export {
|
|
344
|
-
Exception,
|
|
345
|
-
InvalidArgumentsException,
|
|
346
227
|
MessageBuilder,
|
|
347
|
-
export_ObjectBuilder as ObjectBuilder,
|
|
348
|
-
RuntimeException,
|
|
349
228
|
Secret,
|
|
350
|
-
base64,
|
|
351
229
|
compose,
|
|
352
|
-
createError,
|
|
353
230
|
defineStaticProperty,
|
|
354
231
|
flatten,
|
|
355
|
-
fsImportAll,
|
|
356
|
-
fsReadAll,
|
|
357
|
-
getDirname,
|
|
358
|
-
getFilename,
|
|
359
232
|
importDefault,
|
|
360
233
|
isScriptFile,
|
|
361
|
-
joinToURL,
|
|
362
234
|
naturalSort,
|
|
363
|
-
safeEqual
|
|
364
|
-
slash
|
|
235
|
+
safeEqual
|
|
365
236
|
};
|
|
@@ -28,5 +28,5 @@ declare class Base64 {
|
|
|
28
28
|
urlDecode(encode: string, encoding?: BufferEncoding, strict?: false): string | null;
|
|
29
29
|
urlDecode(encode: Buffer, encoding?: BufferEncoding): string;
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
export
|
|
31
|
+
declare const base64: Base64;
|
|
32
|
+
export default base64;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@poppinss/exception';
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
export type ImportAllFilesOptions = {
|
|
2
|
+
ignoreMissingRoot?: boolean;
|
|
3
|
+
filter?: (filePath: string, index: number) => boolean;
|
|
4
|
+
sort?: (current: string, next: string) => number;
|
|
5
|
+
transformKeys?: (keys: string[]) => string[];
|
|
6
|
+
};
|
|
2
7
|
/**
|
|
3
8
|
* Returns an array of file paths from the given location. You can
|
|
4
9
|
* optionally filter and sort files by passing relevant options
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
export type ReadAllFilesOptions = {
|
|
2
|
+
ignoreMissingRoot?: boolean;
|
|
3
|
+
filter?: (filePath: string, index: number) => boolean;
|
|
4
|
+
sort?: (current: string, next: string) => number;
|
|
5
|
+
pathType?: 'relative' | 'unixRelative' | 'absolute' | 'unixAbsolute' | 'url';
|
|
6
|
+
};
|
|
2
7
|
/**
|
|
3
8
|
* Returns an array of file paths from the given location. You can
|
|
4
9
|
* optionally filter and sort files by passing relevant options
|
|
@@ -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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@poppinss/utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0-next.0",
|
|
4
4
|
"description": "Handy utilities for repetitive work",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -18,21 +18,21 @@
|
|
|
18
18
|
"node": "./build/lodash/main.cjs",
|
|
19
19
|
"default": "./build/lodash/main.cjs"
|
|
20
20
|
},
|
|
21
|
-
"./
|
|
22
|
-
"./
|
|
23
|
-
"./
|
|
24
|
-
"./
|
|
25
|
-
"./
|
|
26
|
-
"./
|
|
27
|
-
"./exception": "./build/
|
|
28
|
-
"./
|
|
21
|
+
"./fs": "./build/modules/fs/main.js",
|
|
22
|
+
"./json": "./build/modules/json/main.js",
|
|
23
|
+
"./string": "./build/modules/string/main.js",
|
|
24
|
+
"./string_builder": "./build/modules/string/string_builder.js",
|
|
25
|
+
"./assert": "./build/modules/assert.js",
|
|
26
|
+
"./base64": "./build/modules/base64.js",
|
|
27
|
+
"./exception": "./build/modules/exception.js",
|
|
28
|
+
"./types": "./build/modules/types.js"
|
|
29
29
|
},
|
|
30
30
|
"engines": {
|
|
31
|
-
"node": ">=
|
|
31
|
+
"node": ">=24.0.0"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
34
|
"pretest": "npm run lint",
|
|
35
|
-
"test": "npm run build:lodash &&
|
|
35
|
+
"test": "npm run build:lodash && npm run quick:test",
|
|
36
36
|
"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
37
|
"lint": "eslint",
|
|
38
38
|
"format": "prettier --write .",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"version": "npm run build",
|
|
44
44
|
"prepublishOnly": "npm run build",
|
|
45
45
|
"release": "release-it",
|
|
46
|
-
"quick:test": "node --import
|
|
46
|
+
"quick:test": "node --import=@poppinss/ts-exec bin/test.ts"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@adonisjs/eslint-config": "^2.0.0",
|
|
@@ -53,26 +53,26 @@
|
|
|
53
53
|
"@japa/assert": "^4.0.1",
|
|
54
54
|
"@japa/expect-type": "^2.0.3",
|
|
55
55
|
"@japa/runner": "^4.2.0",
|
|
56
|
+
"@poppinss/ts-exec": "^1.1.5",
|
|
56
57
|
"@release-it/conventional-changelog": "^10.0.1",
|
|
57
|
-
"@swc/core": "1.10.7",
|
|
58
58
|
"@types/fs-extra": "^11.0.4",
|
|
59
|
-
"@types/node": "^22.15.
|
|
59
|
+
"@types/node": "^22.15.21",
|
|
60
60
|
"c8": "^10.1.3",
|
|
61
|
-
"eslint": "^9.
|
|
61
|
+
"eslint": "^9.27.0",
|
|
62
62
|
"fs-extra": "^11.3.0",
|
|
63
63
|
"lodash": "^4.17.21",
|
|
64
64
|
"lodash-cli": "^4.17.5",
|
|
65
65
|
"move-file-cli": "^3.0.0",
|
|
66
66
|
"prettier": "^3.5.3",
|
|
67
67
|
"release-it": "^19.0.2",
|
|
68
|
-
"
|
|
69
|
-
"tsup": "^8.4.0",
|
|
68
|
+
"tsup": "^8.5.0",
|
|
70
69
|
"typescript": "^5.8.3"
|
|
71
70
|
},
|
|
72
71
|
"dependencies": {
|
|
73
72
|
"@poppinss/exception": "^1.2.1",
|
|
74
73
|
"@poppinss/object-builder": "^1.1.0",
|
|
75
|
-
"@poppinss/string": "^1.
|
|
74
|
+
"@poppinss/string": "^1.6.0",
|
|
75
|
+
"@poppinss/types": "^1.1.0",
|
|
76
76
|
"flattie": "^1.1.1",
|
|
77
77
|
"safe-stable-stringify": "^2.5.0",
|
|
78
78
|
"secure-json-parse": "^4.0.0"
|
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
|
-
};
|