foxts 3.11.1 → 3.13.0-beta.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/dist/define-lazy-property.d.ts +5 -0
- package/dist/define-lazy-property.js +1 -0
- package/dist/define-lazy-property.mjs +1 -0
- package/dist/extract-error-message.d.ts +10 -0
- package/dist/extract-error-message.js +1 -0
- package/dist/extract-error-message.mjs +1 -0
- package/dist/lazy-promise.d.ts +14 -0
- package/dist/lazy-promise.js +1 -0
- package/dist/lazy-promise.mjs +1 -0
- package/dist/lazy-value.d.ts +5 -0
- package/dist/lazy-value.js +1 -0
- package/dist/lazy-value.mjs +1 -0
- package/dist/shuffle-array.js +1 -1
- package/dist/shuffle-array.mjs +1 -1
- package/package.json +33 -9
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
declare function defineLazyProperty<ObjectType extends Record<string, any>, PropertyNameType extends string, PropertyValueType>(object: ObjectType, propertyName: PropertyNameType, valueGetter: () => PropertyValueType): ObjectType & {
|
|
2
|
+
[K in PropertyNameType]: PropertyValueType;
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
export { defineLazyProperty };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.defineLazyProperty=function(e,r,t){let n=t=>Object.defineProperty(e,r,{value:t,enumerable:!0,writable:!0});return Object.defineProperty(e,r,{configurable:!0,enumerable:!0,get(){let e=t();return n(e),e},set(e){n(e)}}),e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e,r,t){let n=t=>Object.defineProperty(e,r,{value:t,enumerable:!0,writable:!0});return Object.defineProperty(e,r,{configurable:!0,enumerable:!0,get(){let e=t();return n(e),e},set(e){n(e)}}),e}export{e as defineLazyProperty};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
interface ErrorLikeObject {
|
|
2
|
+
name: string;
|
|
3
|
+
message: string;
|
|
4
|
+
stack?: string;
|
|
5
|
+
}
|
|
6
|
+
declare function isErrorLikeObject(obj: unknown): obj is ErrorLikeObject;
|
|
7
|
+
declare function extractErrorMessage(error: unknown, includeName?: boolean, includeStack?: boolean): string | null;
|
|
8
|
+
|
|
9
|
+
export { extractErrorMessage, isErrorLikeObject };
|
|
10
|
+
export type { ErrorLikeObject };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e){return"object"==typeof e&&null!==e&&"name"in e&&"string"==typeof e.name&&"message"in e&&"string"==typeof e.message&&(!("stack"in e)||"string"==typeof e.stack)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.extractErrorMessage=function(t,r=!0,n=!1){if(!e(t))return null;let s="";return r&&(s+=t.name,s+=": "),s+=t.message,n&&"stack"in t&&"string"==typeof t.stack&&(s+="\n"+t.stack),s.trim()},exports.isErrorLikeObject=e;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function t(t){return"object"==typeof t&&null!==t&&"name"in t&&"string"==typeof t.name&&"message"in t&&"string"==typeof t.message&&(!("stack"in t)||"string"==typeof t.stack)}function e(n,r=!0,s=!1){if(!t(n))return null;let i="";return r&&(i+=n.name,i+=": "),i+=n.message,s&&"stack"in n&&"string"==typeof n.stack&&(i+="\n"+n.stack),i.trim()}export{e as extractErrorMessage,t as isErrorLikeObject};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare class LazyPromise<T> extends Promise<T> {
|
|
2
|
+
private readonly executor;
|
|
3
|
+
private promise;
|
|
4
|
+
constructor(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void);
|
|
5
|
+
static from<T>(this: void, fn: () => T | PromiseLike<T>): LazyPromise<T>;
|
|
6
|
+
static resolve(this: void): LazyPromise<void>;
|
|
7
|
+
static resolve<T>(this: void, value: T | PromiseLike<T>): LazyPromise<T>;
|
|
8
|
+
static reject<T = never>(this: void, reason?: any): LazyPromise<T>;
|
|
9
|
+
then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
|
10
|
+
catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null): Promise<T | TResult>;
|
|
11
|
+
finally(onfinally?: (() => void) | null): Promise<T>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { LazyPromise };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0});class e extends Promise{constructor(e){super(e=>e()),this.executor=e}static from(t){return new e(e=>{e(t())})}static resolve(t){return new e(e=>e(t))}static reject(t){return new e((e,r)=>r(t))}then(e,t){return this.promise??=new Promise(this.executor),this.promise.then(e,t)}catch(e){return this.promise??=new Promise(this.executor),this.promise.catch(e)}finally(e){return this.promise??=new Promise(this.executor),this.promise.finally(e)}}exports.LazyPromise=e;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
class e extends Promise{constructor(e){super(e=>e()),this.executor=e}static from(t){return new e(e=>{e(t())})}static resolve(t){return new e(e=>e(t))}static reject(t){return new e((e,r)=>r(t))}then(e,t){return this.promise??=new Promise(this.executor),this.promise.then(e,t)}catch(e){return this.promise??=new Promise(this.executor),this.promise.catch(e)}finally(e){return this.promise??=new Promise(this.executor),this.promise.finally(e)}}export{e as LazyPromise};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0});const e=require("./once.js").once;exports.lazyValue=e;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{once as e}from"./once.mjs";let o=e;export{o as lazyValue};
|
package/dist/shuffle-array.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:!0})
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.shuffleArray=function(e,r={}){let t,{copy:o=!1,random:l=Math.random}=r,n=o?e.slice():e,f=0,s=n.length;for(;s;)f=l()*s--|0,t=n[s],n[s]=n[f],n[f]=t;return n};
|
package/dist/shuffle-array.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function r(e,t={}){let n,{copy:f=!1,random:l=Math.random}=t,o=f?e.slice():e,a=0,h=o.length;for(;h;)a=l()*h--|0,n=o[h],o[h]=o[a],o[a]=n;return o}export{r as shuffleArray};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "foxts",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.13.0-beta.1",
|
|
4
4
|
"description": "Opinionated collection of common TypeScript utils by @SukkaW",
|
|
5
5
|
"repository": {
|
|
6
6
|
"url": "https://github.com/SukkaW/foxts"
|
|
@@ -224,6 +224,30 @@
|
|
|
224
224
|
"import": "./dist/chunk.mjs",
|
|
225
225
|
"require": "./dist/chunk.js",
|
|
226
226
|
"default": "./dist/chunk.js"
|
|
227
|
+
},
|
|
228
|
+
"./extract-error-message": {
|
|
229
|
+
"types": "./dist/extract-error-message.d.ts",
|
|
230
|
+
"import": "./dist/extract-error-message.mjs",
|
|
231
|
+
"require": "./dist/extract-error-message.js",
|
|
232
|
+
"default": "./dist/extract-error-message.js"
|
|
233
|
+
},
|
|
234
|
+
"./lazy-value": {
|
|
235
|
+
"types": "./dist/lazy-value.d.ts",
|
|
236
|
+
"import": "./dist/lazy-value.mjs",
|
|
237
|
+
"require": "./dist/lazy-value.js",
|
|
238
|
+
"default": "./dist/lazy-value.js"
|
|
239
|
+
},
|
|
240
|
+
"./lazy-promise": {
|
|
241
|
+
"types": "./dist/lazy-promise.d.ts",
|
|
242
|
+
"import": "./dist/lazy-promise.mjs",
|
|
243
|
+
"require": "./dist/lazy-promise.js",
|
|
244
|
+
"default": "./dist/lazy-promise.js"
|
|
245
|
+
},
|
|
246
|
+
"./define-lazy-property": {
|
|
247
|
+
"types": "./dist/define-lazy-property.d.ts",
|
|
248
|
+
"import": "./dist/define-lazy-property.mjs",
|
|
249
|
+
"require": "./dist/define-lazy-property.js",
|
|
250
|
+
"default": "./dist/define-lazy-property.js"
|
|
227
251
|
}
|
|
228
252
|
},
|
|
229
253
|
"sideEffects": false,
|
|
@@ -244,20 +268,20 @@
|
|
|
244
268
|
"@mitata/counters": "^0.0.8",
|
|
245
269
|
"@monyone/aho-corasick": "^1.0.4",
|
|
246
270
|
"@package-json/types": "^0.0.11",
|
|
247
|
-
"@swc-node/register": "^1.
|
|
248
|
-
"@swc/core": "^1.13.
|
|
271
|
+
"@swc-node/register": "^1.11.1",
|
|
272
|
+
"@swc/core": "^1.13.5",
|
|
249
273
|
"@types/mocha": "^10.0.10",
|
|
250
|
-
"@types/node": "^22.
|
|
274
|
+
"@types/node": "^22.18.0",
|
|
251
275
|
"@types/sinon": "^17.0.4",
|
|
252
276
|
"bumpp": "^10.2.3",
|
|
253
277
|
"bunchee": "^6.6.0",
|
|
254
|
-
"devalue": "^5.
|
|
255
|
-
"eslint": "^9.
|
|
278
|
+
"devalue": "^5.3.2",
|
|
279
|
+
"eslint": "^9.34.0",
|
|
256
280
|
"eslint-config-sukka": "^6.23.1",
|
|
257
281
|
"eslint-formatter-sukka": "^6.23.1",
|
|
258
|
-
"expect": "^30.
|
|
282
|
+
"expect": "^30.1.1",
|
|
259
283
|
"fastscan": "^1.0.6",
|
|
260
|
-
"fdir": "^6.
|
|
284
|
+
"fdir": "^6.5.0",
|
|
261
285
|
"mitata": "^1.0.34",
|
|
262
286
|
"mocha": "^11.7.1",
|
|
263
287
|
"modern-ahocorasick": "^2.0.4",
|
|
@@ -266,7 +290,7 @@
|
|
|
266
290
|
},
|
|
267
291
|
"scripts": {
|
|
268
292
|
"lint": "eslint --format=sukka .",
|
|
269
|
-
"test": "SWC_NODE_IGNORE_DYNAMIC=1
|
|
293
|
+
"test": "SWC_NODE_IGNORE_DYNAMIC=1 SWC_NODE_INLINE_SOURCE_MAP=1 nyc mocha --require @swc-node/register --full-trace ./src/**/*.test.ts",
|
|
270
294
|
"bench": "SWC_NODE_IGNORE_DYNAMIC=1 node --require @swc-node/register",
|
|
271
295
|
"bench:all": "SWC_NODE_IGNORE_DYNAMIC=1 node --require @swc-node/register ./src/**/*.bench.ts",
|
|
272
296
|
"prebuild": "bunchee prepare && node -r @swc-node/register ./tools/index.ts",
|