@tamagui/simple-hash 1.125.21 → 1.125.22

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/simple-hash",
3
- "version": "1.125.21",
3
+ "version": "1.125.22",
4
4
  "sideEffects": false,
5
5
  "types": "./types/index.d.ts",
6
6
  "main": "dist/cjs",
@@ -32,7 +32,7 @@
32
32
  }
33
33
  },
34
34
  "devDependencies": {
35
- "@tamagui/build": "1.125.21"
35
+ "@tamagui/build": "1.125.22"
36
36
  },
37
37
  "publishConfig": {
38
38
  "access": "public"
@@ -0,0 +1,14 @@
1
+ {
2
+ "mappings": "AAGA,OAAO,cAAM,aAAcA,eAAeC,mBAAkB",
3
+ "names": [
4
+ "strIn: string",
5
+ "hashMin: number | 'strict'"
6
+ ],
7
+ "sources": [
8
+ "src/index.ts"
9
+ ],
10
+ "sourcesContent": [
11
+ "const cache = new Map<string, string>()\nlet cacheSize = 0\n\nexport const simpleHash = (strIn: string, hashMin: number | 'strict' = 10): string => {\n if (cache.has(strIn)) {\n return cache.get(strIn)!\n }\n\n let str = strIn\n\n // remove var()\n if (str[0] === 'v' && str.startsWith('var(')) {\n str = str.slice(6, str.length - 1)\n }\n\n let hash = 0\n let valids = ''\n let added = 0\n const len = str.length\n\n for (let i = 0; i < len; i++) {\n if (hashMin !== 'strict' && added <= hashMin) {\n const char = str.charCodeAt(i)\n if (char === 46) {\n valids += '--'\n continue\n }\n if (isValidCSSCharCode(char)) {\n added++\n valids += str[i]\n continue\n }\n }\n hash = hashChar(hash, str[i])\n }\n\n const res = valids + (hash ? Math.abs(hash) : '')\n\n if (cacheSize > 10_000) {\n cache.clear()\n cacheSize = 0\n }\n\n cache.set(strIn, res)\n cacheSize++\n\n return res\n}\n\nconst hashChar = (hash: number, c: string) => (Math.imul(31, hash) + c.charCodeAt(0)) | 0\n\nfunction isValidCSSCharCode(code: number) {\n return (\n // A-Z\n (code >= 65 && code <= 90) ||\n // a-z\n (code >= 97 && code <= 122) ||\n // _\n code === 95 ||\n // -\n code === 45 ||\n // 0-9\n (code >= 48 && code <= 57)\n )\n}\n"
12
+ ],
13
+ "version": 3
14
+ }