@alwatr/hash-string 6.0.2 → 9.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.
- package/dist/main.js +2 -2
- package/dist/main.js.map +1 -1
- package/package.json +19 -19
package/dist/main.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/* 📦 @alwatr/hash-string
|
|
1
|
+
/* 📦 @alwatr/hash-string v9.1.1 */
|
|
2
2
|
function u(r,i,a=1){if(a<1)throw Error("The repeat parameter must be greater than or equal to 1");let e=3735928559,t=1103547991;if(typeof r==="number")r=r.toString();let h=r.length;for(let n=0;n<h;n++){let o=r.charCodeAt(n);e=Math.imul(e^o,2654435761),t=Math.imul(t^o,1597334677)}e=Math.imul(e^e>>>16,2246822507)^Math.imul(t^t>>>13,3266489909),t=Math.imul(t^t>>>16,2246822507)^Math.imul(e^e>>>13,3266489909);let s=i+(e>>>0).toString(36)+(t>>>0).toString(36);if(a===1)return s;else return u(s,i,a-1)}export{u as nanoHash};
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
4
|
+
//# debugId=67E6E953BEE404E264756E2164756E21
|
|
5
5
|
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
CHANGED
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
"/**\n * Simple hash string for fast hashing (like md5).\n * This function is not very secure and should not be used for security purposes.\n * But it cannot be reversed easily and brute force can take up to years for fast computers.\n *\n * @param str - The string or number to hash\n * @param prefix - A prefix to add to the beginning of the hash result\n * @param repeat - Number of times to repeat the hashing process for increased complexity (default: 3)\n * @returns A hashed string with the specified prefix\n */\nexport function nanoHash(str: string | number, prefix: string, repeat = 1): string {\n if (repeat < 1) {\n throw new Error('The repeat parameter must be greater than or equal to 1');\n }\n\n let hash1 = 0xdeadbeef;\n let hash2 = 0x41c6ce57;\n\n if (typeof str === 'number') {\n str = str.toString();\n }\n\n const len = str.length;\n for (let i = 0; i < len; i++) {\n const char = str.charCodeAt(i);\n hash1 = Math.imul(hash1 ^ char, 2654435761);\n hash2 = Math.imul(hash2 ^ char, 1597334677);\n }\n\n hash1 = Math.imul(hash1 ^ (hash1 >>> 16), 2246822507) ^ Math.imul(hash2 ^ (hash2 >>> 13), 3266489909);\n hash2 = Math.imul(hash2 ^ (hash2 >>> 16), 2246822507) ^ Math.imul(hash1 ^ (hash1 >>> 13), 3266489909);\n\n const result = prefix + (hash1 >>> 0).toString(36) + (hash2 >>> 0).toString(36);\n if (repeat === 1) {\n return result;\n }\n else {\n return nanoHash(result, prefix, repeat - 1);\n }\n}\n"
|
|
6
6
|
],
|
|
7
7
|
"mappings": ";AAUO,SAAS,CAAQ,CAAC,EAAsB,EAAgB,EAAS,EAAW,CACjF,GAAI,EAAS,EACX,MAAU,MAAM,yDAAyD,EAG3E,IAAI,EAAQ,WACR,EAAQ,WAEZ,GAAI,OAAO,IAAQ,SACjB,EAAM,EAAI,SAAS,EAGrB,IAAM,EAAM,EAAI,OAChB,QAAS,EAAI,EAAG,EAAI,EAAK,IAAK,CAC5B,IAAM,EAAO,EAAI,WAAW,CAAC,EAC7B,EAAQ,KAAK,KAAK,EAAQ,EAAM,UAAU,EAC1C,EAAQ,KAAK,KAAK,EAAQ,EAAM,UAAU,EAG5C,EAAQ,KAAK,KAAK,EAAS,IAAU,GAAK,UAAU,EAAI,KAAK,KAAK,EAAS,IAAU,GAAK,UAAU,EACpG,EAAQ,KAAK,KAAK,EAAS,IAAU,GAAK,UAAU,EAAI,KAAK,KAAK,EAAS,IAAU,GAAK,UAAU,EAEpG,IAAM,EAAS,GAAU,IAAU,GAAG,SAAS,EAAE,GAAK,IAAU,GAAG,SAAS,EAAE,EAC9E,GAAI,IAAW,EACb,OAAO,EAGP,YAAO,EAAS,EAAQ,EAAQ,EAAS,CAAC",
|
|
8
|
-
"debugId": "
|
|
8
|
+
"debugId": "67E6E953BEE404E264756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
package/package.json
CHANGED
|
@@ -1,28 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alwatr/hash-string",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.1.1",
|
|
4
4
|
"description": "A simple utility to generate a hash string.",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
|
-
"author": "S. Ali Mihandoost <ali.mihandoost@gmail.com>",
|
|
6
|
+
"author": "S. Ali Mihandoost <ali.mihandoost@gmail.com> (https://ali.mihandoost.com)",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"repository": {
|
|
9
|
-
"directory": "packages/hash-string",
|
|
10
9
|
"type": "git",
|
|
11
|
-
"url": "https://github.com/Alwatr/
|
|
10
|
+
"url": "https://github.com/Alwatr/alwatr",
|
|
11
|
+
"directory": "pkg/nanolib/hash-string"
|
|
12
12
|
},
|
|
13
|
-
"homepage": "https://github.com/Alwatr/
|
|
14
|
-
"bugs": "https://github.com/Alwatr/
|
|
13
|
+
"homepage": "https://github.com/Alwatr/alwatr/tree/next/pkg/nanolib/hash-string#readme",
|
|
14
|
+
"bugs": "https://github.com/Alwatr/alwatr/issues",
|
|
15
15
|
"exports": {
|
|
16
16
|
".": {
|
|
17
17
|
"types": "./dist/main.d.ts",
|
|
18
|
+
"import": "./dist/main.js",
|
|
18
19
|
"default": "./dist/main.js"
|
|
19
20
|
}
|
|
20
21
|
},
|
|
21
22
|
"sideEffects": false,
|
|
22
23
|
"devDependencies": {
|
|
23
|
-
"@alwatr/nano-build": "
|
|
24
|
-
"@alwatr/
|
|
25
|
-
"@alwatr/
|
|
24
|
+
"@alwatr/nano-build": "9.1.1",
|
|
25
|
+
"@alwatr/tsconfig-base": "9.1.1",
|
|
26
|
+
"@alwatr/type-helper": "9.1.1",
|
|
26
27
|
"typescript": "^6.0.2"
|
|
27
28
|
},
|
|
28
29
|
"scripts": {
|
|
@@ -30,23 +31,23 @@
|
|
|
30
31
|
"build": "bun run build:ts && bun run build:es",
|
|
31
32
|
"build:es": "nano-build --preset=module src/main.ts",
|
|
32
33
|
"build:ts": "tsc --build",
|
|
33
|
-
"
|
|
34
|
-
"cb": "bun run clean && bun run build",
|
|
34
|
+
"cl": "bun run clean",
|
|
35
35
|
"clean": "rm -rfv dist *.tsbuildinfo",
|
|
36
|
-
"
|
|
36
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
37
|
+
"lint": "eslint src/ --ext .ts",
|
|
37
38
|
"t": "bun run test",
|
|
38
|
-
"test": "bun test",
|
|
39
|
+
"test": "ALWATR_DEBUG=0 bun test",
|
|
39
40
|
"w": "bun run watch",
|
|
40
41
|
"watch": "bun run watch:ts & bun run watch:es",
|
|
41
42
|
"watch:es": "bun run build:es --watch",
|
|
42
43
|
"watch:ts": "bun run build:ts --watch --preserveWatchOutput"
|
|
43
44
|
},
|
|
44
45
|
"files": [
|
|
45
|
-
"
|
|
46
|
+
"dist",
|
|
47
|
+
"src/**/*.ts",
|
|
48
|
+
"!src/**/*.test.ts",
|
|
46
49
|
"README.md",
|
|
47
|
-
"LICENSE"
|
|
48
|
-
"!demo/**/*",
|
|
49
|
-
"!**/*.test.js"
|
|
50
|
+
"LICENSE"
|
|
50
51
|
],
|
|
51
52
|
"publishConfig": {
|
|
52
53
|
"access": "public"
|
|
@@ -69,6 +70,5 @@
|
|
|
69
70
|
"utility",
|
|
70
71
|
"utils"
|
|
71
72
|
],
|
|
72
|
-
"
|
|
73
|
-
"gitHead": "95bb13efd0a5f485c6b09f1a911b99492017aed1"
|
|
73
|
+
"gitHead": "38fb79dd8b6cf48108ae6492ecd7a285c7633e9b"
|
|
74
74
|
}
|