foxts 3.1.0 → 3.2.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/dist/cjs/append-array-in-place.d.ts +4 -0
- package/dist/cjs/append-array-in-place.js +1 -0
- package/dist/cjs/merge-headers.d.ts +2 -1
- package/dist/cjs/noop.d.ts +2 -1
- package/dist/cjs/repool.d.ts +2 -1
- package/dist/cjs/serialized-memo.d.ts +2 -1
- package/dist/cjs/serialized-memo.js +1 -1
- package/dist/cjs/string-join.d.ts +3 -0
- package/dist/cjs/string-join.js +1 -0
- package/dist/cjs/wait.js +1 -1
- package/dist/es/append-array-in-place.d.mts +4 -0
- package/dist/es/append-array-in-place.mjs +1 -0
- package/dist/es/merge-headers.d.mts +2 -1
- package/dist/es/noop.d.mts +2 -1
- package/dist/es/repool.d.mts +2 -1
- package/dist/es/serialized-memo.d.mts +2 -1
- package/dist/es/serialized-memo.mjs +1 -1
- package/dist/es/string-join.d.mts +3 -0
- package/dist/es/string-join.mjs +1 -0
- package/dist/es/wait.mjs +1 -1
- package/package.json +32 -13
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e,p){let r=0,l=p.length;if(l<=65535)e.push.apply(e,p);else for(;l>0;){let t=l>65535?65535:l,a=p.slice(r,r+t);e.push.apply(e,a),l-=t,r+=t}return e}Object.defineProperty(exports,"__esModule",{value:!0}),exports.appendArrayInPlace=e,exports.appendArrayInPlaceCurried=p=>r=>e(p,r);
|
|
@@ -5,4 +5,5 @@ declare function mergeHeaders(dest: HeadersInitLike, source: HeadersInitLike): H
|
|
|
5
5
|
declare function mergeNodeHttpHeaders(dest: IncomingHttpHeadersLike, source: IncomingHttpHeadersLike): IncomingHttpHeadersLike;
|
|
6
6
|
declare function mergeNodeHttpHeaders(dest: OutgoingHttpHeadersLike, source: IncomingHttpHeadersLike | OutgoingHttpHeadersLike): OutgoingHttpHeadersLike;
|
|
7
7
|
|
|
8
|
-
export {
|
|
8
|
+
export { mergeHeaders, mergeNodeHttpHeaders };
|
|
9
|
+
export type { HeadersInitLike, IncomingHttpHeadersLike, OutgoingHttpHeadersLike };
|
package/dist/cjs/noop.d.ts
CHANGED
|
@@ -8,4 +8,5 @@ declare const throwFn: Noop<never>;
|
|
|
8
8
|
declare const asyncNoop: Noop<Promise<any>>;
|
|
9
9
|
declare const asyncNeverFn: Noop<Promise<never>>;
|
|
10
10
|
|
|
11
|
-
export {
|
|
11
|
+
export { asyncNeverFn, asyncNoop, falseFn, noop, throwFn, trueFn };
|
|
12
|
+
export type { Noop };
|
package/dist/cjs/repool.d.ts
CHANGED
|
@@ -56,4 +56,5 @@ type MemoizeOptions<T> = T extends string ? MemoizeBaseOptions : MemoizeOptionsW
|
|
|
56
56
|
*/
|
|
57
57
|
declare function createMemoize(storage: MemoizeStorageProvider, { onlyUseCachedIfFail, resetTtlOnHit, defaultTtl, onCacheUpdate, onCacheMiss, onCacheHit, keyHasher, argHasher }: CreateMemoizeOptions): <Args extends SerializableValue[], R>(fn: (...args: Args) => R | Promise<R>, opt?: MemoizeOptions<R>) => (...args: Args) => Promise<R>;
|
|
58
58
|
|
|
59
|
-
export {
|
|
59
|
+
export { createMemoize };
|
|
60
|
+
export type { CreateMemoizeOptions, MemoizeOptions, MemoizeStorageProvider, SerializableValue };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./fast-string-array-join.js"),a=require("./identity.js"),t=require("./noop.js");exports.createMemoize=function(i,{onlyUseCachedIfFail:n=!1,resetTtlOnHit:r=!1,defaultTtl:l=6048e5,onCacheUpdate:s=t.noop,onCacheMiss:o=t.noop,onCacheHit:u=t.noop,keyHasher:d=a.identity,argHasher:f}){return function(t,h){if(h?.temporaryBypass)return(...e)=>Promise.resolve(t(...e));let m=h&&"serializer"in h?h.serializer:a.identity,c=h&&"deserializer"in h?h.deserializer:a.identity,p=h?.ttl??l,y=t.toString(),w=d(y);return async function(...a){let l=e.fastStringArrayJoin(await Promise.all([w,f(a)]),"|"),d=t.name||y||l,h=i.get(l);if(h&&"object"==typeof h&&"then"in h&&(h=await h),n)try{let e=await t(...a);s(l,{humanReadableName:d,isUseCachedIfFail:!0});let n=i.set(l,m(e),p);return n&&"then"in n&&await n,e}catch(e){if(null==h)throw o(l,{humanReadableName:d,isUseCachedIfFail:!0}),e;if(r){let e=i.updateTtl?.(l,p);e&&"then"in e&&await e}return u(l,{humanReadableName:d,isUseCachedIfFail:!0}),c(h)}
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./fast-string-array-join.js"),a=require("./identity.js"),t=require("./noop.js");exports.createMemoize=function(i,{onlyUseCachedIfFail:n=!1,resetTtlOnHit:r=!1,defaultTtl:l=6048e5,onCacheUpdate:s=t.noop,onCacheMiss:o=t.noop,onCacheHit:u=t.noop,keyHasher:d=a.identity,argHasher:f}){return function(t,h){if(h?.temporaryBypass)return(...e)=>Promise.resolve(t(...e));let m=h&&"serializer"in h?h.serializer:a.identity,c=h&&"deserializer"in h?h.deserializer:a.identity,p=h?.ttl??l,y=t.toString(),w=d(y);return async function(...a){let l=e.fastStringArrayJoin(await Promise.all([w,f(a)]),"|"),d=t.name||y||l,h=i.get(l);if(h&&"object"==typeof h&&"then"in h&&(h=await h),n)try{let e=await t(...a);s(l,{humanReadableName:d,isUseCachedIfFail:!0});let n=i.set(l,m(e),p);return n&&"then"in n&&await n,e}catch(e){if(null==h)throw o(l,{humanReadableName:d,isUseCachedIfFail:!0}),e;if(r){let e=i.updateTtl?.(l,p);e&&"then"in e&&await e}return u(l,{humanReadableName:d,isUseCachedIfFail:!0}),c(h)}if(null==h){o(l,{humanReadableName:d,isUseCachedIfFail:!1});let e=await t(...a),n=i.set(l,m(e),p);return n&&"then"in n&&await n,e}if(u(l,{humanReadableName:d,isUseCachedIfFail:!1}),r){let e=i.updateTtl?.(l,p);e&&"then"in e&&await e}return c(h)}}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0});var r=require("./fast-string-array-join.js"),e=require("./guard.js");exports.stringJoin=function(i,t=",",n=!1){return n&&(i=Array.from(new Set(i))),r.fastStringArrayJoin(i.filter(e.isNonNullish),t)};
|
package/dist/cjs/wait.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:!0}),exports.wait=function(e){return new Promise(t=>{setTimeout(t,e)})},exports.waitWithAbort=function(e,t){return new Promise((r,o)=>{if(t.aborted)
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.wait=function(e){return new Promise(t=>{setTimeout(t,e)})},exports.waitWithAbort=function(e,t){return new Promise((r,o)=>{if(t.aborted)return void o(t.reason);let n=setTimeout(()=>{t.removeEventListener("abort",i),r()},e);function i(){clearTimeout(n),t.removeEventListener("abort",i),o(t.reason)}t.addEventListener("abort",i)})};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e,p){let l=0,r=p.length;if(r<=65535)e.push.apply(e,p);else for(;r>0;){let a=r>65535?65535:r,n=p.slice(l,l+a);e.push.apply(e,n),r-=a,l+=a}return e}let p=p=>l=>e(p,l);export{e as appendArrayInPlace,p as appendArrayInPlaceCurried};
|
|
@@ -5,4 +5,5 @@ declare function mergeHeaders(dest: HeadersInitLike, source: HeadersInitLike): H
|
|
|
5
5
|
declare function mergeNodeHttpHeaders(dest: IncomingHttpHeadersLike, source: IncomingHttpHeadersLike): IncomingHttpHeadersLike;
|
|
6
6
|
declare function mergeNodeHttpHeaders(dest: OutgoingHttpHeadersLike, source: IncomingHttpHeadersLike | OutgoingHttpHeadersLike): OutgoingHttpHeadersLike;
|
|
7
7
|
|
|
8
|
-
export {
|
|
8
|
+
export { mergeHeaders, mergeNodeHttpHeaders };
|
|
9
|
+
export type { HeadersInitLike, IncomingHttpHeadersLike, OutgoingHttpHeadersLike };
|
package/dist/es/noop.d.mts
CHANGED
|
@@ -8,4 +8,5 @@ declare const throwFn: Noop<never>;
|
|
|
8
8
|
declare const asyncNoop: Noop<Promise<any>>;
|
|
9
9
|
declare const asyncNeverFn: Noop<Promise<never>>;
|
|
10
10
|
|
|
11
|
-
export {
|
|
11
|
+
export { asyncNeverFn, asyncNoop, falseFn, noop, throwFn, trueFn };
|
|
12
|
+
export type { Noop };
|
package/dist/es/repool.d.mts
CHANGED
|
@@ -56,4 +56,5 @@ type MemoizeOptions<T> = T extends string ? MemoizeBaseOptions : MemoizeOptionsW
|
|
|
56
56
|
*/
|
|
57
57
|
declare function createMemoize(storage: MemoizeStorageProvider, { onlyUseCachedIfFail, resetTtlOnHit, defaultTtl, onCacheUpdate, onCacheMiss, onCacheHit, keyHasher, argHasher }: CreateMemoizeOptions): <Args extends SerializableValue[], R>(fn: (...args: Args) => R | Promise<R>, opt?: MemoizeOptions<R>) => (...args: Args) => Promise<R>;
|
|
58
58
|
|
|
59
|
-
export {
|
|
59
|
+
export { createMemoize };
|
|
60
|
+
export type { CreateMemoizeOptions, MemoizeOptions, MemoizeStorageProvider, SerializableValue };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{fastStringArrayJoin as e}from"./fast-string-array-join.mjs";import{identity as a}from"./identity.mjs";import{noop as t}from"./noop.mjs";function i(i,{onlyUseCachedIfFail:r=!1,resetTtlOnHit:n=!1,defaultTtl:l=6048e5,onCacheUpdate:s=t,onCacheMiss:m=t,onCacheHit:o=t,keyHasher:f=a,argHasher:u}){return function(t,h){if(h?.temporaryBypass)return(...e)=>Promise.resolve(t(...e));let d=h&&"serializer"in h?h.serializer:a,c=h&&"deserializer"in h?h.deserializer:a,p=h?.ttl??l,w=t.toString(),y=f(w);return async function(...a){let l=e(await Promise.all([y,u(a)]),"|"),f=t.name||w||l,h=i.get(l);if(h&&"object"==typeof h&&"then"in h&&(h=await h),r)try{let e=await t(...a);s(l,{humanReadableName:f,isUseCachedIfFail:!0});let r=i.set(l,d(e),p);return r&&"then"in r&&await r,e}catch(e){if(null==h)throw m(l,{humanReadableName:f,isUseCachedIfFail:!0}),e;if(n){let e=i.updateTtl?.(l,p);e&&"then"in e&&await e}return o(l,{humanReadableName:f,isUseCachedIfFail:!0}),c(h)}
|
|
1
|
+
import{fastStringArrayJoin as e}from"./fast-string-array-join.mjs";import{identity as a}from"./identity.mjs";import{noop as t}from"./noop.mjs";function i(i,{onlyUseCachedIfFail:r=!1,resetTtlOnHit:n=!1,defaultTtl:l=6048e5,onCacheUpdate:s=t,onCacheMiss:m=t,onCacheHit:o=t,keyHasher:f=a,argHasher:u}){return function(t,h){if(h?.temporaryBypass)return(...e)=>Promise.resolve(t(...e));let d=h&&"serializer"in h?h.serializer:a,c=h&&"deserializer"in h?h.deserializer:a,p=h?.ttl??l,w=t.toString(),y=f(w);return async function(...a){let l=e(await Promise.all([y,u(a)]),"|"),f=t.name||w||l,h=i.get(l);if(h&&"object"==typeof h&&"then"in h&&(h=await h),r)try{let e=await t(...a);s(l,{humanReadableName:f,isUseCachedIfFail:!0});let r=i.set(l,d(e),p);return r&&"then"in r&&await r,e}catch(e){if(null==h)throw m(l,{humanReadableName:f,isUseCachedIfFail:!0}),e;if(n){let e=i.updateTtl?.(l,p);e&&"then"in e&&await e}return o(l,{humanReadableName:f,isUseCachedIfFail:!0}),c(h)}if(null==h){m(l,{humanReadableName:f,isUseCachedIfFail:!1});let e=await t(...a),r=i.set(l,d(e),p);return r&&"then"in r&&await r,e}if(o(l,{humanReadableName:f,isUseCachedIfFail:!1}),n){let e=i.updateTtl?.(l,p);e&&"then"in e&&await e}return c(h)}}}export{i as createMemoize};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{fastStringArrayJoin as r}from"./fast-string-array-join.mjs";import{isNonNullish as t}from"./guard.mjs";function o(i,n=",",m=!1){return m&&(i=Array.from(new Set(i))),r(i.filter(t),n)}export{o as stringJoin};
|
package/dist/es/wait.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(e){return new Promise(t=>{setTimeout(t,e)})}function t(e,t){return new Promise((r,n)=>{if(t.aborted)
|
|
1
|
+
function e(e){return new Promise(t=>{setTimeout(t,e)})}function t(e,t){return new Promise((r,n)=>{if(t.aborted)return void n(t.reason);let o=setTimeout(()=>{t.removeEventListener("abort",i),r()},e);function i(){clearTimeout(o),t.removeEventListener("abort",i),n(t.reason)}t.addEventListener("abort",i)})}export{e as wait,t as waitWithAbort};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "foxts",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "Opinionated collection of common TypeScript utils by @SukkaW",
|
|
5
5
|
"repository": {
|
|
6
6
|
"url": "https://github.com/SukkaW/foxts"
|
|
@@ -299,8 +299,27 @@
|
|
|
299
299
|
"default": "./dist/cjs/simple-string-hash.js"
|
|
300
300
|
}
|
|
301
301
|
},
|
|
302
|
-
"./append-array-in-place": {
|
|
303
|
-
|
|
302
|
+
"./append-array-in-place": {
|
|
303
|
+
"import": {
|
|
304
|
+
"types": "./dist/es/append-array-in-place.d.mts",
|
|
305
|
+
"default": "./dist/es/append-array-in-place.mjs"
|
|
306
|
+
},
|
|
307
|
+
"require": {
|
|
308
|
+
"types": "./dist/cjs/append-array-in-place.d.ts",
|
|
309
|
+
"default": "./dist/cjs/append-array-in-place.js"
|
|
310
|
+
}
|
|
311
|
+
},
|
|
312
|
+
"./string-join": {
|
|
313
|
+
"import": {
|
|
314
|
+
"types": "./dist/es/string-join.d.mts",
|
|
315
|
+
"default": "./dist/es/string-join.mjs"
|
|
316
|
+
},
|
|
317
|
+
"require": {
|
|
318
|
+
"types": "./dist/cjs/string-join.d.ts",
|
|
319
|
+
"default": "./dist/cjs/string-join.js"
|
|
320
|
+
}
|
|
321
|
+
},
|
|
322
|
+
"./compare-source": {}
|
|
304
323
|
},
|
|
305
324
|
"sideEffects": false,
|
|
306
325
|
"keywords": [
|
|
@@ -311,45 +330,45 @@
|
|
|
311
330
|
"author": "SukkaW <https://skk.moe>",
|
|
312
331
|
"license": "MIT",
|
|
313
332
|
"devDependencies": {
|
|
314
|
-
"@eslint-sukka/node": "^6.
|
|
333
|
+
"@eslint-sukka/node": "^6.19.0",
|
|
315
334
|
"@istanbuljs/nyc-config-typescript": "^1.0.2",
|
|
316
335
|
"@mitata/counters": "^0.0.8",
|
|
317
336
|
"@monyone/aho-corasick": "^1.0.4",
|
|
318
337
|
"@package-json/types": "^0.0.11",
|
|
319
338
|
"@swc-node/register": "^1.10.10",
|
|
320
|
-
"@swc/core": "^1.11.
|
|
339
|
+
"@swc/core": "^1.11.24",
|
|
321
340
|
"@types/escape-html": "^1.0.4",
|
|
322
341
|
"@types/escape-regexp": "^0.0.3",
|
|
323
342
|
"@types/html-escaper": "^3.0.4",
|
|
324
343
|
"@types/lodash.escape": "^4.0.9",
|
|
325
344
|
"@types/lodash.escaperegexp": "^4.1.9",
|
|
326
345
|
"@types/mocha": "^10.0.10",
|
|
327
|
-
"@types/node": "^22.
|
|
346
|
+
"@types/node": "^22.15.17",
|
|
328
347
|
"@types/regex-escape": "^3.4.1",
|
|
329
348
|
"@types/sinon": "^17.0.4",
|
|
330
349
|
"bumpp": "^10.1.0",
|
|
331
|
-
"bunchee": "^6.5.
|
|
350
|
+
"bunchee": "^6.5.1",
|
|
332
351
|
"devalue": "^5.1.1",
|
|
333
352
|
"escape-goat": "^3.0.0",
|
|
334
353
|
"escape-html": "^1.0.3",
|
|
335
354
|
"escape-regexp": "^0.0.1",
|
|
336
355
|
"escape-string-regexp": "4",
|
|
337
|
-
"eslint": "^9.
|
|
338
|
-
"eslint-config-sukka": "^6.
|
|
339
|
-
"eslint-formatter-sukka": "^6.
|
|
356
|
+
"eslint": "^9.26.0",
|
|
357
|
+
"eslint-config-sukka": "^6.19.0",
|
|
358
|
+
"eslint-formatter-sukka": "^6.19.0",
|
|
340
359
|
"expect": "^29.7.0",
|
|
341
360
|
"fastscan": "^1.0.6",
|
|
342
|
-
"fdir": "^6.4.
|
|
361
|
+
"fdir": "^6.4.4",
|
|
343
362
|
"hexo-util": "^3.3.0",
|
|
344
363
|
"html-escaper": "2.0.2",
|
|
345
364
|
"lodash.escape": "^4.0.1",
|
|
346
365
|
"lodash.escaperegexp": "^4.1.2",
|
|
347
366
|
"mitata": "^1.0.34",
|
|
348
|
-
"mocha": "^11.
|
|
367
|
+
"mocha": "^11.2.2",
|
|
349
368
|
"modern-ahocorasick": "^2.0.4",
|
|
350
369
|
"nyc": "^17.1.0",
|
|
351
370
|
"regex-escape": "^3.4.11",
|
|
352
|
-
"sinon": "^19.0.
|
|
371
|
+
"sinon": "^19.0.5"
|
|
353
372
|
},
|
|
354
373
|
"scripts": {
|
|
355
374
|
"lint": "eslint --format=sukka .",
|