foxts 4.3.0 → 4.3.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.
@@ -1,3 +1,5 @@
1
- declare function fnv1a(s: string): number;
1
+ declare function fnv1a(str: string): number;
2
+ declare const __internal_hl_do_not_use__: string[];
3
+ declare function fnv1ahex(str: string): string;
2
4
 
3
- export { fnv1a };
5
+ export { __internal_hl_do_not_use__, fnv1a, fnv1ahex };
@@ -1 +1 @@
1
- "use strict";exports.fnv1a=function(t){let e=0x811c9dc5;for(let r=0,c=t.length;r<c;r++)e^=t.charCodeAt(r),e+=(e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24);return e>>>0};
1
+ "use strict";const t=Array(256);for(let r=0;r<256;r++)t[r]=(r>>4&15).toString(16)+(15&r).toString(16);exports.__internal_hl_do_not_use__=t,exports.fnv1a=function(t){const r=t.length-3;let o=0,e=0,n=40389,c=33052;for(;o<r;)n^=t.charCodeAt(o++),e=403*n,c=403*c+(n<<8)+(e>>>16)&65535,e=403*(n=65535&e^t.charCodeAt(o++)),c=403*c+(n<<8)+(e>>>16)&65535,e=403*(n=65535&e^t.charCodeAt(o++)),c=403*c+(n<<8)+(e>>>16)&65535,e=403*(n=65535&e^t.charCodeAt(o++)),c=403*c+(n<<8)+(e>>>16)&65535,n=65535&e;for(;o<r+3;)n^=t.charCodeAt(o++),e=403*n,c=403*c+(n<<8)+(e>>>16)&65535,n=65535&e;return(c<<16>>>0)+n},exports.fnv1ahex=function(r){const o=r.length-3;let e=0,n=0,c=40389,a=33052;for(;e<o;)c^=r.charCodeAt(e++),n=403*c,a=403*a+(c<<8)+(n>>>16)&65535,n=403*(c=65535&n^r.charCodeAt(e++)),a=403*a+(c<<8)+(n>>>16)&65535,n=403*(c=65535&n^r.charCodeAt(e++)),a=403*a+(c<<8)+(n>>>16)&65535,n=403*(c=65535&n^r.charCodeAt(e++)),a=403*a+(c<<8)+(n>>>16)&65535,c=65535&n;for(;e<o+3;)c^=r.charCodeAt(e++),n=403*c,a=403*a+(c<<8)+(n>>>16)&65535,c=65535&n;return t[a>>>8&255]+t[255&a]+t[c>>>8&255]+t[255&c]};
@@ -1 +1 @@
1
- function t(t){let e=0x811c9dc5;for(let n=0,r=t.length;n<r;n++)e^=t.charCodeAt(n),e+=(e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24);return e>>>0}export{t as fnv1a};
1
+ function t(t){const o=t.length-3;let r=0,e=0,n=40389,c=33052;for(;r<o;)n^=t.charCodeAt(r++),e=403*n,c=403*c+(n<<8)+(e>>>16)&65535,e=403*(n=65535&e^t.charCodeAt(r++)),c=403*c+(n<<8)+(e>>>16)&65535,e=403*(n=65535&e^t.charCodeAt(r++)),c=403*c+(n<<8)+(e>>>16)&65535,e=403*(n=65535&e^t.charCodeAt(r++)),c=403*c+(n<<8)+(e>>>16)&65535,n=65535&e;for(;r<o+3;)n^=t.charCodeAt(r++),e=403*n,c=403*c+(n<<8)+(e>>>16)&65535,n=65535&e;return(c<<16>>>0)+n}const o=Array(256);for(let t=0;t<256;t++)o[t]=(t>>4&15).toString(16)+(15&t).toString(16);const r=o;function e(t){const r=t.length-3;let e=0,n=0,c=40389,a=33052;for(;e<r;)c^=t.charCodeAt(e++),n=403*c,a=403*a+(c<<8)+(n>>>16)&65535,n=403*(c=65535&n^t.charCodeAt(e++)),a=403*a+(c<<8)+(n>>>16)&65535,n=403*(c=65535&n^t.charCodeAt(e++)),a=403*a+(c<<8)+(n>>>16)&65535,n=403*(c=65535&n^t.charCodeAt(e++)),a=403*a+(c<<8)+(n>>>16)&65535,c=65535&n;for(;e<r+3;)c^=t.charCodeAt(e++),n=403*c,a=403*a+(c<<8)+(n>>>16)&65535,c=65535&n;return o[a>>>8&255]+o[255&a]+o[c>>>8&255]+o[255&c]}export{r as __internal_hl_do_not_use__,t as fnv1a,e as fnv1ahex};
@@ -1,12 +1,18 @@
1
1
  /**
2
2
  * FNV-1a Hash implementation
3
+ *
4
+ * @author Sukka (sukkaw) <https://skk.moe>
3
5
  * @author Travis Webb (tjwebb) <me@traviswebb.com>
4
6
  *
5
- * Ported from https://github.com/tjwebb/fnv-plus/blob/master/index.js
7
+ * @description
6
8
  *
9
+ * Ported from https://github.com/tjwebb/fnv-plus/blob/master/index.js
7
10
  * Simplified, optimized and add modified for 52 bit, which provides a larger hash space
8
11
  * and still making use of Javascript's 53-bit integer space.
12
+ *
13
+ * DO NOT USE toString(16) here! Use `fnv1a52hex` instead, way faster
9
14
  */
10
15
  declare function fnv1a52(str: string): number;
16
+ declare function fnv1a52hex(str: string): string;
11
17
 
12
- export { fnv1a52 };
18
+ export { fnv1a52, fnv1a52hex };
@@ -1 +1 @@
1
- "use strict";exports.fnv1a52=function(t){const e=t.length;let n=0,r=0,o=8997,c=0,s=33826,f=0,u=40164,x=0,a=52210;for(;n<e;)o^=t.charCodeAt(n++),r=435*o,c=435*s,f=435*u,x=435*a,f+=o<<8,x+=s<<8,c+=r>>>16,o=65535&r,f+=c>>>16,s=65535&c,a=x+(f>>>16)&65535,u=65535&f;return(15&a)*0x1000000000000+0x100000000*u+65536*s+(o^a>>4)};
1
+ "use strict";var _=require("../fnv1a/index.js");const n=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];exports.fnv1a52=function(_){const n=_.length;let t=0,e=0,o=8997,r=0,l=33826,s=0,a=40164,u=0,h=52210;for(;t<n;)o^=_.charCodeAt(t++),e=435*o,r=435*l,s=435*a,u=435*h,s+=o<<8,u+=l<<8,r+=e>>>16,o=65535&e,s+=r>>>16,l=65535&r,h=u+(s>>>16)&65535,a=65535&s;return(15&h)*0x1000000000000+0x100000000*a+65536*l+(o^h>>4)},exports.fnv1a52hex=function(t){const e=t.length;let o=0,r=0,l=8997,s=0,a=33826,u=0,h=40164,i=0,d=52210;for(;o<e;)l^=t.charCodeAt(o++),r=435*l,s=435*a,u=435*h,i=435*d,u+=l<<8,i+=a<<8,s+=r>>>16,l=65535&r,u+=s>>>16,a=65535&s,d=i+(u>>>16)&65535,h=65535&u;return n[15&d]+_.__internal_hl_do_not_use__[h>>8]+_.__internal_hl_do_not_use__[255&h]+_.__internal_hl_do_not_use__[a>>8]+_.__internal_hl_do_not_use__[255&a]+_.__internal_hl_do_not_use__[l>>8^d>>12]+_.__internal_hl_do_not_use__[(l^d>>4)&255]};
@@ -1 +1 @@
1
- function t(t){const n=t.length;let e=0,o=0,r=8997,c=0,f=33826,x=0,a=40164,h=0,l=52210;for(;e<n;)r^=t.charCodeAt(e++),o=435*r,c=435*f,x=435*a,h=435*l,x+=r<<8,h+=f<<8,c+=o>>>16,r=65535&o,x+=c>>>16,f=65535&c,l=h+(x>>>16)&65535,a=65535&x;return(15&l)*0x1000000000000+0x100000000*a+65536*f+(r^l>>4)}export{t as fnv1a52};
1
+ import{__internal_hl_do_not_use__ as n}from"../fnv1a/index.mjs";function t(n){const t=n.length;let e=0,o=0,r=8997,f=0,c=33826,a=0,h=40164,x=0,d=52210;for(;e<t;)r^=n.charCodeAt(e++),o=435*r,f=435*c,a=435*h,x=435*d,a+=r<<8,x+=c<<8,f+=o>>>16,r=65535&o,a+=f>>>16,c=65535&f,d=x+(a>>>16)&65535,h=65535&a;return(15&d)*0x1000000000000+0x100000000*h+65536*c+(r^d>>4)}const e=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function o(t){const o=t.length;let r=0,f=0,c=8997,a=0,h=33826,x=0,d=40164,i=0,l=52210;for(;r<o;)c^=t.charCodeAt(r++),f=435*c,a=435*h,x=435*d,i=435*l,x+=c<<8,i+=h<<8,a+=f>>>16,c=65535&f,x+=a>>>16,h=65535&a,l=i+(x>>>16)&65535,d=65535&x;return e[15&l]+n[d>>8]+n[255&d]+n[h>>8]+n[255&h]+n[c>>8^l>>12]+n[(c^l>>4)&255]}export{t as fnv1a52,o as fnv1a52hex};
@@ -1 +1 @@
1
- "use strict";var t=require("../fnv1a52/index.js");exports.simpleStringHash=function(n){return t.fnv1a52(n).toString(36)+n.length.toString(36)};
1
+ "use strict";var n=require("../fnv1a52/index.js");require("../fnv1a/index.js"),exports.simpleStringHash=function(r){return n.fnv1a52(r).toString(36)+r.length.toString(36)};
@@ -1 +1 @@
1
- import{fnv1a52 as t}from"../fnv1a52/index.mjs";function n(n){return t(n).toString(36)+n.length.toString(36)}export{n as simpleStringHash};
1
+ import{fnv1a52 as n}from"../fnv1a52/index.mjs";import"../fnv1a/index.mjs";function t(t){return n(t).toString(36)+t.length.toString(36)}export{t as simpleStringHash};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foxts",
3
- "version": "4.3.0",
3
+ "version": "4.3.1",
4
4
  "description": "Opinionated collection of common TypeScript utils by @SukkaW",
5
5
  "repository": {
6
6
  "url": "https://github.com/SukkaW/foxts"