foxts 5.0.1 → 5.0.3

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.
@@ -76,7 +76,7 @@ declare class AsyncRetryAbortError extends E {
76
76
  cause?: unknown;
77
77
  constructor(message: string | Error | unknown);
78
78
  }
79
- declare function asyncRetry<T>(callback: (bail: (reason?: unknown) => void, attemptNumber: number) => PromiseLike<T> | T, retryOptions?: AsyncRetryOptions): Promise<T>;
79
+ declare function asyncRetry<T>(callback: (bail: (reason?: unknown) => never, attemptNumber: number) => PromiseLike<T> | T, retryOptions?: AsyncRetryOptions): Promise<T>;
80
80
  declare function makeRetriable<Args extends unknown[], Result>(fn: (...args: Args) => PromiseLike<Result> | Result, options?: AsyncRetryOptions): (this: unknown, ...args: Args) => Promise<Result>;
81
81
 
82
82
  export { AsyncRetryAbortError, asyncRetry, makeRetriable };
@@ -1 +1 @@
1
- "use strict";var e=require("../guard/index.js");const r=Uint8Array,t=ArrayBuffer,n=TextDecoder,o=new TextEncoder,u={utf8:new n("utf8")};exports.base64ToUint8Array=function(e){return r.from(atob(function(e){const r=e.replaceAll("-","+").replaceAll("_","/"),t=(4-r.length%4)%4;return r+"=".repeat(t)}(e)),e=>e.charCodeAt(0))},exports.concatUint8Arrays=function(e,t){if(0===e.length)return new r(0);const n=new r(t??=e.reduce((e,r)=>e+r.length,0));let o=0;for(let r=0,t=e.length;r<t;r++){const t=e[r];n.set(t,o),o+=t.length}return n},exports.stringToUint8Array=function(e){return o.encode(e)},exports.toUint8Array=function(n){return n instanceof t?new r(n):t.isView(n)?new r(n.buffer,n.byteOffset,n.byteLength):void e.never(n,"value must be ArrayBuffer or ArrayBufferView")},exports.uint8ArrayToBase64=function(e,r=!1){let t="";for(let r=0;r<e.length;r+=65535){const n=e.subarray(r,r+65535);t+=btoa(String.fromCharCode.apply(void 0,n))}return r?t.replaceAll("+","-").replaceAll("/","_").replace(/=+$/,""):t},exports.uint8ArrayToString=function(e,r="utf8"){return u[r]??=new n(r),u[r].decode(e)};
1
+ "use strict";var e=require("../guard/index.js");const t=Uint8Array,r=ArrayBuffer,n=TextDecoder,o=new TextEncoder,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=new Uint8Array(256);for(let e=0;e<c.length;e++)a[c.charCodeAt(e)]=e;const l={utf8:new n("utf8")};exports.base64ToUint8Array=function(e){const t=function(e){const t=e.replaceAll("-","+").replaceAll("_","/"),r=(4-t.length%4)%4;return t+"=".repeat(r)}(e),r=t.length;let n=.75*t.length,o,c=0,l,u,i,f;"="===t[t.length-1]&&(n--,"="===t[t.length-2]&&n--);const s=new Uint8Array(new ArrayBuffer(n));for(o=0;o<r;o+=4)l=a[t.charCodeAt(o)],u=a[t.charCodeAt(o+1)],i=a[t.charCodeAt(o+2)],f=a[t.charCodeAt(o+3)],s[c++]=l<<2|u>>4,s[c++]=(15&u)<<4|i>>2,s[c++]=(3&i)<<6|63&f;return s},exports.concatUint8Arrays=function(e,r){if(0===e.length)return new t(0);const n=new t(r??=e.reduce((e,t)=>e+t.length,0));let o=0;for(let t=0,r=e.length;t<r;t++){const r=e[t];n.set(r,o),o+=r.length}return n},exports.stringToUint8Array=function(e){return o.encode(e)},exports.toUint8Array=function(n){return n instanceof r?new t(n):r.isView(n)?new t(n.buffer,n.byteOffset,n.byteLength):void e.never(n,"value must be ArrayBuffer or ArrayBufferView")},exports.uint8ArrayToBase64=function(e,t=!1){let r="";const n=e.length;for(let t=0;t<n;t+=3)r+=c[e[t]>>2],r+=c[(3&e[t])<<4|e[t+1]>>4],r+=c[(15&e[t+1])<<2|e[t+2]>>6],r+=c[63&e[t+2]];return n%3==2?r=r.slice(0,Math.max(0,r.length-1))+"=":n%3==1&&(r=r.slice(0,Math.max(0,r.length-2))+"=="),t?r.replaceAll("+","-").replaceAll("/","_").replace(/=+$/,""):r},exports.uint8ArrayToString=function(e,t="utf8"){return l[t]??=new n(t),l[t].decode(e)};
@@ -1 +1 @@
1
- import{never as e}from"../guard/index.mjs";const r=Uint8Array,t=ArrayBuffer,n=TextDecoder,o=new TextEncoder;function a(e){return o.encode(e)}const u={utf8:new n("utf8")};function c(e,r="utf8"){return u[r]??=new n(r),u[r].decode(e)}function f(e){return r.from(atob(function(e){const r=e.replaceAll("-","+").replaceAll("_","/"),t=(4-r.length%4)%4;return r+"=".repeat(t)}(e)),e=>e.charCodeAt(0))}function i(e,r=!1){let t="";for(let r=0;r<e.length;r+=65535){const n=e.subarray(r,r+65535);t+=btoa(String.fromCharCode.apply(void 0,n))}return r?t.replaceAll("+","-").replaceAll("/","_").replace(/=+$/,""):t}function l(e,t){if(0===e.length)return new r(0);const n=new r(t??=e.reduce((e,r)=>e+r.length,0));let o=0;for(let r=0,t=e.length;r<t;r++){const t=e[r];n.set(t,o),o+=t.length}return n}function s(n){return n instanceof t?new r(n):t.isView(n)?new r(n.buffer,n.byteOffset,n.byteLength):void e(n,"value must be ArrayBuffer or ArrayBufferView")}export{f as base64ToUint8Array,l as concatUint8Arrays,a as stringToUint8Array,s as toUint8Array,i as uint8ArrayToBase64,c as uint8ArrayToString};
1
+ import{never as e}from"../guard/index.mjs";const t=Uint8Array,r=ArrayBuffer,n=TextDecoder,o=new TextEncoder,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",l=new Uint8Array(256);for(let e=0;e<c.length;e++)l[c.charCodeAt(e)]=e;function a(e){return o.encode(e)}const f={utf8:new n("utf8")};function u(e,t="utf8"){return f[t]??=new n(t),f[t].decode(e)}function i(e){const t=function(e){const t=e.replaceAll("-","+").replaceAll("_","/"),r=(4-t.length%4)%4;return t+"=".repeat(r)}(e),r=t.length;let n=.75*t.length,o,c=0,a,f,u,i;"="===t[t.length-1]&&(n--,"="===t[t.length-2]&&n--);const A=new Uint8Array(new ArrayBuffer(n));for(o=0;o<r;o+=4)a=l[t.charCodeAt(o)],f=l[t.charCodeAt(o+1)],u=l[t.charCodeAt(o+2)],i=l[t.charCodeAt(o+3)],A[c++]=a<<2|f>>4,A[c++]=(15&f)<<4|u>>2,A[c++]=(3&u)<<6|63&i;return A}function A(e,t=!1){let r="";const n=e.length;for(let t=0;t<n;t+=3)r+=c[e[t]>>2],r+=c[(3&e[t])<<4|e[t+1]>>4],r+=c[(15&e[t+1])<<2|e[t+2]>>6],r+=c[63&e[t+2]];return n%3==2?r=r.slice(0,Math.max(0,r.length-1))+"=":n%3==1&&(r=r.slice(0,Math.max(0,r.length-2))+"=="),t?r.replaceAll("+","-").replaceAll("/","_").replace(/=+$/,""):r}function h(e,r){if(0===e.length)return new t(0);const n=new t(r??=e.reduce((e,t)=>e+t.length,0));let o=0;for(let t=0,r=e.length;t<r;t++){const r=e[t];n.set(r,o),o+=r.length}return n}function s(n){return n instanceof r?new t(n):r.isView(n)?new t(n.buffer,n.byteOffset,n.byteLength):void e(n,"value must be ArrayBuffer or ArrayBufferView")}export{i as base64ToUint8Array,h as concatUint8Arrays,a as stringToUint8Array,s as toUint8Array,A as uint8ArrayToBase64,u as uint8ArrayToString};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foxts",
3
- "version": "5.0.1",
3
+ "version": "5.0.3",
4
4
  "description": "Opinionated collection of common TypeScript utils by @SukkaW",
5
5
  "repository": {
6
6
  "url": "https://github.com/SukkaW/foxts"
@@ -314,33 +314,32 @@
314
314
  "author": "SukkaW <https://skk.moe>",
315
315
  "license": "MIT",
316
316
  "devDependencies": {
317
- "@eslint-sukka/node": "^8.0.0-beta.1",
318
- "@happy-dom/global-registrator": "^20.0.8",
317
+ "@eslint-sukka/node": "^8.0.5",
318
+ "@happy-dom/global-registrator": "^20.0.11",
319
319
  "@istanbuljs/nyc-config-typescript": "^1.0.2",
320
320
  "@mitata/counters": "^0.0.8",
321
- "@monyone/aho-corasick": "^1.0.4",
321
+ "@monyone/aho-corasick": "^1.1.3",
322
322
  "@package-json/types": "^0.0.12",
323
323
  "@swc-node/register": "^1.11.1",
324
- "@swc/core": "^1.13.20",
324
+ "@swc/core": "^1.15.3",
325
325
  "@types/mocha": "^10.0.10",
326
- "@types/node": "^22.18.12",
326
+ "@types/node": "^22.19.1",
327
327
  "@types/sinon": "^17.0.4",
328
- "bumpp": "^10.3.1",
329
- "devalue": "^5.4.2",
330
- "eslint": "^9.38.0",
331
- "eslint-config-sukka": "^8.0.0-beta.1",
332
- "eslint-formatter-sukka": "^8.0.0-beta.1",
328
+ "bumpp": "^10.3.2",
329
+ "eslint": "^9.39.1",
330
+ "eslint-config-sukka": "^8.0.5",
331
+ "eslint-formatter-sukka": "^8.0.5",
333
332
  "expect": "^30.2.0",
334
333
  "fastscan": "^1.0.6",
335
- "happy-dom": "^20.0.8",
334
+ "happy-dom": "^20.0.11",
336
335
  "is-ci": "^4.1.0",
337
336
  "is-network-error": "^1.3.0",
338
337
  "mitata": "^1.0.34",
339
- "mocha": "^11.7.4",
338
+ "mocha": "^11.7.5",
340
339
  "modern-ahocorasick": "^2.0.4",
341
340
  "nyc": "^17.1.0",
342
- "rollup": "^4.52.5",
343
- "rollup-plugin-dts": "^6.2.3",
341
+ "rollup": "^4.53.3",
342
+ "rollup-plugin-dts": "^6.3.0",
344
343
  "rollup-plugin-oxc-resolve": "^0.0.5",
345
344
  "rollup-plugin-swc3": "^0.12.1",
346
345
  "sinon": "^21.0.0",