foxts 3.1.0 → 3.1.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.
@@ -0,0 +1,4 @@
1
+ declare function appendArrayInPlace<T>(dest: T[], source: T[]): T[];
2
+ declare const appendArrayInPlaceCurried: <T>(dest: T[]) => (source: T[]) => T[];
3
+
4
+ export { appendArrayInPlace, appendArrayInPlaceCurried };
@@ -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 { type HeadersInitLike, type IncomingHttpHeadersLike, type OutgoingHttpHeadersLike, mergeHeaders, mergeNodeHttpHeaders };
8
+ export { mergeHeaders, mergeNodeHttpHeaders };
9
+ export type { HeadersInitLike, IncomingHttpHeadersLike, OutgoingHttpHeadersLike };
@@ -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 { type Noop, asyncNeverFn, asyncNoop, falseFn, noop, throwFn, trueFn };
11
+ export { asyncNeverFn, asyncNoop, falseFn, noop, throwFn, trueFn };
12
+ export type { Noop };
@@ -15,4 +15,5 @@ declare class Repool<T extends Reusifiable> {
15
15
  release(obj: T): void;
16
16
  }
17
17
 
18
- export { Repool, type Reusifiable };
18
+ export { Repool };
19
+ export type { Reusifiable };
@@ -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 { type CreateMemoizeOptions, type MemoizeOptions, type MemoizeStorageProvider, type SerializableValue, createMemoize };
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)}else{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)}}}};
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,3 @@
1
+ declare function stringJoin(arr: Array<string | null | undefined>, sep?: string, dedupe?: boolean): string;
2
+
3
+ export { stringJoin };
@@ -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){o(t.reason);return}let n=setTimeout(()=>{t.removeEventListener("abort",i),r()},e);function i(){clearTimeout(n),t.removeEventListener("abort",i),o(t.reason)}t.addEventListener("abort",i)})};
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,4 @@
1
+ declare function appendArrayInPlace<T>(dest: T[], source: T[]): T[];
2
+ declare const appendArrayInPlaceCurried: <T>(dest: T[]) => (source: T[]) => T[];
3
+
4
+ export { appendArrayInPlace, appendArrayInPlaceCurried };
@@ -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 { type HeadersInitLike, type IncomingHttpHeadersLike, type OutgoingHttpHeadersLike, mergeHeaders, mergeNodeHttpHeaders };
8
+ export { mergeHeaders, mergeNodeHttpHeaders };
9
+ export type { HeadersInitLike, IncomingHttpHeadersLike, OutgoingHttpHeadersLike };
@@ -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 { type Noop, asyncNeverFn, asyncNoop, falseFn, noop, throwFn, trueFn };
11
+ export { asyncNeverFn, asyncNoop, falseFn, noop, throwFn, trueFn };
12
+ export type { Noop };
@@ -15,4 +15,5 @@ declare class Repool<T extends Reusifiable> {
15
15
  release(obj: T): void;
16
16
  }
17
17
 
18
- export { Repool, type Reusifiable };
18
+ export { Repool };
19
+ export type { Reusifiable };
@@ -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 { type CreateMemoizeOptions, type MemoizeOptions, type MemoizeStorageProvider, type SerializableValue, createMemoize };
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)}else{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};
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,3 @@
1
+ declare function stringJoin(arr: Array<string | null | undefined>, sep?: string, dedupe?: boolean): string;
2
+
3
+ export { stringJoin };
@@ -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){n(t.reason);return}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};
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.1.0",
3
+ "version": "3.1.1",
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,26 @@
299
299
  "default": "./dist/cjs/simple-string-hash.js"
300
300
  }
301
301
  },
302
- "./append-array-in-place": {},
303
- "./string-join": {}
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
+ }
304
322
  },
305
323
  "sideEffects": false,
306
324
  "keywords": [
@@ -311,35 +329,35 @@
311
329
  "author": "SukkaW <https://skk.moe>",
312
330
  "license": "MIT",
313
331
  "devDependencies": {
314
- "@eslint-sukka/node": "^6.17.1",
332
+ "@eslint-sukka/node": "^6.18.2",
315
333
  "@istanbuljs/nyc-config-typescript": "^1.0.2",
316
334
  "@mitata/counters": "^0.0.8",
317
335
  "@monyone/aho-corasick": "^1.0.4",
318
336
  "@package-json/types": "^0.0.11",
319
337
  "@swc-node/register": "^1.10.10",
320
- "@swc/core": "^1.11.13",
338
+ "@swc/core": "^1.11.24",
321
339
  "@types/escape-html": "^1.0.4",
322
340
  "@types/escape-regexp": "^0.0.3",
323
341
  "@types/html-escaper": "^3.0.4",
324
342
  "@types/lodash.escape": "^4.0.9",
325
343
  "@types/lodash.escaperegexp": "^4.1.9",
326
344
  "@types/mocha": "^10.0.10",
327
- "@types/node": "^22.13.13",
345
+ "@types/node": "^22.15.3",
328
346
  "@types/regex-escape": "^3.4.1",
329
347
  "@types/sinon": "^17.0.4",
330
348
  "bumpp": "^10.1.0",
331
- "bunchee": "^6.5.0",
349
+ "bunchee": "^6.5.1",
332
350
  "devalue": "^5.1.1",
333
351
  "escape-goat": "^3.0.0",
334
352
  "escape-html": "^1.0.3",
335
353
  "escape-regexp": "^0.0.1",
336
354
  "escape-string-regexp": "4",
337
- "eslint": "^9.23.0",
338
- "eslint-config-sukka": "^6.17.1",
339
- "eslint-formatter-sukka": "^6.17.1",
355
+ "eslint": "^9.25.1",
356
+ "eslint-config-sukka": "^6.18.2",
357
+ "eslint-formatter-sukka": "^6.18.2",
340
358
  "expect": "^29.7.0",
341
359
  "fastscan": "^1.0.6",
342
- "fdir": "^6.4.3",
360
+ "fdir": "^6.4.4",
343
361
  "hexo-util": "^3.3.0",
344
362
  "html-escaper": "2.0.2",
345
363
  "lodash.escape": "^4.0.1",
@@ -349,7 +367,7 @@
349
367
  "modern-ahocorasick": "^2.0.4",
350
368
  "nyc": "^17.1.0",
351
369
  "regex-escape": "^3.4.11",
352
- "sinon": "^19.0.4"
370
+ "sinon": "^19.0.5"
353
371
  },
354
372
  "scripts": {
355
373
  "lint": "eslint --format=sukka .",