foxts 5.0.4 → 5.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/base/index.d.ts +18 -0
- package/dist/base/index.js +1 -0
- package/dist/base/index.mjs +1 -0
- package/dist/base92/index.d.ts +4 -0
- package/dist/base92/index.js +1 -0
- package/dist/base92/index.mjs +1 -0
- package/package.json +25 -13
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Common characters:
|
|
3
|
+
*
|
|
4
|
+
* base32: 0123456789ABCDEFGHJKMNPQRSTVWXYZ
|
|
5
|
+
* z-base-32: ybndrfg8ejkmcpqxot1uwisza345h769
|
|
6
|
+
* base36: 0123456789abcdefghijklmnopqrstuvwxyz
|
|
7
|
+
* base58: 123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz
|
|
8
|
+
* base62: 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
|
|
9
|
+
* base64: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/
|
|
10
|
+
* base67: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.!~
|
|
11
|
+
* base94: !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
|
|
12
|
+
*/
|
|
13
|
+
declare function base(ALPHABET: string): {
|
|
14
|
+
encode: (source: Uint8Array) => string;
|
|
15
|
+
decode: (source: string) => Uint8Array;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { base };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";exports.base=function(r){if(r.length>=255)throw TypeError("Alphabet too long");const t=new Uint8Array(256);for(let r=0;r<256;r++)t[r]=255;const o=r.length;for(let e=0;e<o;e++){const o=r.charAt(e),n=o.charCodeAt(0);if(255!==t[n])throw TypeError("Alphabet contains ambiguous characters: "+o);t[n]=e}const e=r.charAt(0),n=Math.log(o)/Math.log(256),l=Math.log(256)/Math.log(o);return{encode:function(t){if(0===t.length)return"";let n=0,a=0,c=0;const h=t.length;for(;c!==h&&0===t[c];)c++,n++;const f=(h-c)*l+1>>>0,i=new Uint8Array(f);for(;c!==h;){let r=t[c],e=0;for(let t=f-1;(0!==r||e<a)&&-1!==t;t--,e++)r+=256*i[t]>>>0,i[t]=r%o>>>0,r=r/o>>>0;if(0!==r)throw Error("Non-zero carry");a=e,c++}let s=f-a;for(;s!==f&&0===i[s];)s++;let g=e.repeat(n);for(;s<f;++s)g+=r.charAt(i[s]);return g},decode:function(r){if(0===r.length)return new Uint8Array(0);let l=0,a=0,c=0;for(;r[l]===e;)a++,l++;const h=(r.length-l)*n+1>>>0,f=new Uint8Array(h);for(;l<r.length;){let e=t[r.charCodeAt(l)],n=0;for(let r=h-1;(0!==e||n<c)&&-1!==r;r--,n++)e+=o*f[r]>>>0,f[r]=e%256>>>0,e=e/256>>>0;if(0!==e)throw Error("Non-zero carry");c=n,l++}let i=h-c;for(;i!==h&&0===f[i];)i++;const s=new Uint8Array(a+(h-i));let g=a;for(;i!==h;)s[g++]=f[i++];return s}}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function r(r){if(r.length>=255)throw TypeError("Alphabet too long");const t=new Uint8Array(256);for(let r=0;r<256;r++)t[r]=255;const o=r.length;for(let e=0;e<o;e++){const o=r.charAt(e),n=o.charCodeAt(0);if(255!==t[n])throw TypeError("Alphabet contains ambiguous characters: "+o);t[n]=e}const e=r.charAt(0),n=Math.log(o)/Math.log(256),l=Math.log(256)/Math.log(o);return{encode:function(t){if(0===t.length)return"";let n=0,a=0,c=0;const h=t.length;for(;c!==h&&0===t[c];)c++,n++;const f=(h-c)*l+1>>>0,i=new Uint8Array(f);for(;c!==h;){let r=t[c],e=0;for(let t=f-1;(0!==r||e<a)&&-1!==t;t--,e++)r+=256*i[t]>>>0,i[t]=r%o>>>0,r=r/o>>>0;if(0!==r)throw Error("Non-zero carry");a=e,c++}let g=f-a;for(;g!==f&&0===i[g];)g++;let s=e.repeat(n);for(;g<f;++g)s+=r.charAt(i[g]);return s},decode:function(r){if(0===r.length)return new Uint8Array(0);let l=0,a=0,c=0;for(;r[l]===e;)a++,l++;const h=(r.length-l)*n+1>>>0,f=new Uint8Array(h);for(;l<r.length;){let e=t[r.charCodeAt(l)],n=0;for(let r=h-1;(0!==e||n<c)&&-1!==r;r--,n++)e+=o*f[r]>>>0,f[r]=e%256>>>0,e=e/256>>>0;if(0!==e)throw Error("Non-zero carry");c=n,l++}let i=h-c;for(;i!==h&&0===f[i];)i++;const g=new Uint8Array(a+(h-i));let s=a;for(;i!==h;)g[s++]=f[i++];return g}}}export{r as base};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const{encode:e,decode:r}=require("../base/index.js").base(String.raw`!#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_abcdefghijklmnopqrstuvwxyz{|}~`);exports.base92ToUint8Array=r,exports.uint8ArrayToBase92=e;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{base as e}from"../base/index.mjs";const{encode:r,decode:o}=e(String.raw`!#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_abcdefghijklmnopqrstuvwxyz{|}~`);export{o as base92ToUint8Array,r as uint8ArrayToBase92};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "foxts",
|
|
3
|
-
"version": "5.0
|
|
3
|
+
"version": "5.2.0",
|
|
4
4
|
"description": "Opinionated collection of common TypeScript utils by @SukkaW",
|
|
5
5
|
"repository": {
|
|
6
6
|
"url": "https://github.com/SukkaW/foxts"
|
|
@@ -64,6 +64,18 @@
|
|
|
64
64
|
"require": "./dist/available-parallelism/index.js",
|
|
65
65
|
"default": "./dist/available-parallelism/index.js"
|
|
66
66
|
},
|
|
67
|
+
"./base": {
|
|
68
|
+
"types": "./dist/base/index.d.ts",
|
|
69
|
+
"import": "./dist/base/index.mjs",
|
|
70
|
+
"require": "./dist/base/index.js",
|
|
71
|
+
"default": "./dist/base/index.js"
|
|
72
|
+
},
|
|
73
|
+
"./base92": {
|
|
74
|
+
"types": "./dist/base92/index.d.ts",
|
|
75
|
+
"import": "./dist/base92/index.mjs",
|
|
76
|
+
"require": "./dist/base92/index.js",
|
|
77
|
+
"default": "./dist/base92/index.js"
|
|
78
|
+
},
|
|
67
79
|
"./bitwise": {
|
|
68
80
|
"types": "./dist/bitwise/index.d.ts",
|
|
69
81
|
"import": "./dist/bitwise/index.mjs",
|
|
@@ -314,42 +326,42 @@
|
|
|
314
326
|
"author": "SukkaW <https://skk.moe>",
|
|
315
327
|
"license": "MIT",
|
|
316
328
|
"devDependencies": {
|
|
317
|
-
"@eslint-sukka/node": "^8.0
|
|
318
|
-
"@happy-dom/global-registrator": "^20.
|
|
329
|
+
"@eslint-sukka/node": "^8.3.0",
|
|
330
|
+
"@happy-dom/global-registrator": "^20.3.7",
|
|
319
331
|
"@istanbuljs/nyc-config-typescript": "^1.0.2",
|
|
320
332
|
"@mitata/counters": "^0.0.8",
|
|
321
|
-
"@monyone/aho-corasick": "^1.1.
|
|
333
|
+
"@monyone/aho-corasick": "^1.1.5",
|
|
322
334
|
"@package-json/types": "^0.0.12",
|
|
323
335
|
"@swc-node/register": "^1.11.1",
|
|
324
|
-
"@swc/core": "^1.15.
|
|
336
|
+
"@swc/core": "^1.15.10",
|
|
325
337
|
"@types/mocha": "^10.0.10",
|
|
326
|
-
"@types/node": "^22.19.
|
|
338
|
+
"@types/node": "^22.19.7",
|
|
327
339
|
"@types/sinon": "^21.0.0",
|
|
328
|
-
"bumpp": "^10.
|
|
340
|
+
"bumpp": "^10.4.0",
|
|
329
341
|
"eslint": "^9.39.2",
|
|
330
|
-
"eslint-config-sukka": "^8.0
|
|
331
|
-
"eslint-formatter-sukka": "^8.0
|
|
342
|
+
"eslint-config-sukka": "^8.3.0",
|
|
343
|
+
"eslint-formatter-sukka": "^8.3.0",
|
|
332
344
|
"expect": "^30.2.0",
|
|
333
345
|
"fastscan": "^1.0.6",
|
|
334
|
-
"happy-dom": "^20.
|
|
346
|
+
"happy-dom": "^20.3.7",
|
|
335
347
|
"is-ci": "^4.1.0",
|
|
336
348
|
"is-network-error": "^1.3.0",
|
|
337
349
|
"mitata": "^1.0.34",
|
|
338
350
|
"mocha": "^11.7.5",
|
|
339
351
|
"modern-ahocorasick": "^2.0.4",
|
|
340
352
|
"nyc": "^17.1.0",
|
|
341
|
-
"rollup": "^4.
|
|
353
|
+
"rollup": "^4.56.0",
|
|
342
354
|
"rollup-plugin-dts": "^6.3.0",
|
|
343
355
|
"rollup-plugin-oxc-resolve": "^0.0.5",
|
|
344
356
|
"rollup-plugin-swc3": "^0.12.1",
|
|
345
|
-
"sinon": "^21.0.
|
|
357
|
+
"sinon": "^21.0.1",
|
|
346
358
|
"typescript": "^5.9.3",
|
|
347
359
|
"word-list": "3.0.0"
|
|
348
360
|
},
|
|
349
361
|
"scripts": {
|
|
350
362
|
"lint": "eslint --format=sukka .",
|
|
351
363
|
"build-ts-xor": "SWC_NODE_IGNORE_DYNAMIC=1 node --require @swc-node/register ./src/ts-xor/_build.ts",
|
|
352
|
-
"test": "SWC_NODE_IGNORE_DYNAMIC=1 SWC_NODE_INLINE_SOURCE_MAP=1 nyc mocha --require @swc-node/register --
|
|
364
|
+
"test": "SWC_NODE_IGNORE_DYNAMIC=1 SWC_NODE_INLINE_SOURCE_MAP=1 nyc mocha --require @swc-node/register --full-trace ./src/**/*.test.ts",
|
|
353
365
|
"bench": "SWC_NODE_IGNORE_DYNAMIC=1 node --require @swc-node/register",
|
|
354
366
|
"bench:all": "SWC_NODE_IGNORE_DYNAMIC=1 node --require @swc-node/register ./src/**/*.bench.ts",
|
|
355
367
|
"build": "rollup -c rollup.config.ts --bundleConfigAsCjs --configPlugin swc3",
|