@tamagui/simple-hash 1.26.0 → 1.27.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/cjs/index.js +4 -7
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +4 -6
- package/dist/esm/index.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +6 -7
- package/types/index.d.ts +0 -1
- package/types/index.d.ts.map +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -18,7 +18,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var src_exports = {};
|
|
20
20
|
__export(src_exports, {
|
|
21
|
-
isValidCSSCharCode: () => isValidCSSCharCode,
|
|
22
21
|
simpleHash: () => simpleHash
|
|
23
22
|
});
|
|
24
23
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -32,23 +31,22 @@ const simpleHash = (str, hashMin = 10) => {
|
|
|
32
31
|
const len = str.length;
|
|
33
32
|
for (let i = 0; i < len; i++) {
|
|
34
33
|
const char = str.charCodeAt(i);
|
|
35
|
-
if (char === 46)
|
|
34
|
+
if (char === 46)
|
|
36
35
|
valids += "d0t";
|
|
37
|
-
}
|
|
38
36
|
if (isValidCSSCharCode(char) && len <= hashMin) {
|
|
39
37
|
valids += str[i];
|
|
40
38
|
} else {
|
|
41
|
-
hash = (hash
|
|
42
|
-
hash &= hash;
|
|
39
|
+
hash = hashChar(hash, str[i]);
|
|
43
40
|
}
|
|
44
41
|
}
|
|
45
|
-
const res = valids + (hash ?
|
|
42
|
+
const res = valids + (hash ? Math.abs(hash) : "");
|
|
46
43
|
if (cache.size > 1e4) {
|
|
47
44
|
cache.clear();
|
|
48
45
|
}
|
|
49
46
|
cache.set(str, res);
|
|
50
47
|
return res;
|
|
51
48
|
};
|
|
49
|
+
const hashChar = (hash, c) => Math.imul(31, hash) + c.charCodeAt(0) | 0;
|
|
52
50
|
function isValidCSSCharCode(code) {
|
|
53
51
|
return (
|
|
54
52
|
// A-Z
|
|
@@ -61,7 +59,6 @@ function isValidCSSCharCode(code) {
|
|
|
61
59
|
}
|
|
62
60
|
// Annotate the CommonJS export names for ESM import in node:
|
|
63
61
|
0 && (module.exports = {
|
|
64
|
-
isValidCSSCharCode,
|
|
65
62
|
simpleHash
|
|
66
63
|
});
|
|
67
64
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAAM,QAAQ,oBAAI,IAAI;AAEf,MAAM,aAAa,CAAC,KAAa,UAAU,OAAO;AACvD,MAAI,MAAM,IAAI,GAAG,GAAG;AAClB,WAAO,MAAM,IAAI,GAAG;AAAA,EACtB;AACA,MAAI,OAAO;AACX,MAAI,SAAS;AACb,QAAM,MAAM,IAAI;AAChB,WAAS,IAAI,GAAG,IAAI,KAAK,KAAK;AAC5B,UAAM,OAAO,IAAI,WAAW,CAAC;AAE7B,QAAI,SAAS;AAAI,gBAAU;AAE3B,QAAI,mBAAmB,IAAI,KAAK,OAAO,SAAS;AAC9C,gBAAU,IAAI,CAAC;AAAA,IACjB,OAAO;AACL,aAAO,SAAS,MAAM,IAAI,CAAC,CAAC;AAAA,IAC9B;AAAA,EACF;AACA,QAAM,MAAM,UAAU,OAAO,KAAK,IAAI,IAAI,IAAI;AAC9C,MAAI,MAAM,OAAO,KAAQ;AACvB,UAAM,MAAM;AAAA,EACd;AACA,QAAM,IAAI,KAAK,GAAG;AAClB,SAAO;AACT;AAEA,MAAM,WAAW,CAAC,MAAc,MAAe,KAAK,KAAK,IAAI,IAAI,IAAI,EAAE,WAAW,CAAC,IAAK;AAExF,SAAS,mBAAmB,MAAc;AACxC;AAAA;AAAA,IAEG,QAAQ,MAAM,QAAQ;AAAA,IAEtB,QAAQ,MAAM,QAAQ;AAAA,IAEvB,SAAS;AAAA,IAET,SAAS;AAAA,IAER,QAAQ,MAAM,QAAQ;AAAA;AAE3B;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -8,23 +8,22 @@ const simpleHash = (str, hashMin = 10) => {
|
|
|
8
8
|
const len = str.length;
|
|
9
9
|
for (let i = 0; i < len; i++) {
|
|
10
10
|
const char = str.charCodeAt(i);
|
|
11
|
-
if (char === 46)
|
|
11
|
+
if (char === 46)
|
|
12
12
|
valids += "d0t";
|
|
13
|
-
}
|
|
14
13
|
if (isValidCSSCharCode(char) && len <= hashMin) {
|
|
15
14
|
valids += str[i];
|
|
16
15
|
} else {
|
|
17
|
-
hash = (hash
|
|
18
|
-
hash &= hash;
|
|
16
|
+
hash = hashChar(hash, str[i]);
|
|
19
17
|
}
|
|
20
18
|
}
|
|
21
|
-
const res = valids + (hash ?
|
|
19
|
+
const res = valids + (hash ? Math.abs(hash) : "");
|
|
22
20
|
if (cache.size > 1e4) {
|
|
23
21
|
cache.clear();
|
|
24
22
|
}
|
|
25
23
|
cache.set(str, res);
|
|
26
24
|
return res;
|
|
27
25
|
};
|
|
26
|
+
const hashChar = (hash, c) => Math.imul(31, hash) + c.charCodeAt(0) | 0;
|
|
28
27
|
function isValidCSSCharCode(code) {
|
|
29
28
|
return (
|
|
30
29
|
// A-Z
|
|
@@ -36,7 +35,6 @@ function isValidCSSCharCode(code) {
|
|
|
36
35
|
);
|
|
37
36
|
}
|
|
38
37
|
export {
|
|
39
|
-
isValidCSSCharCode,
|
|
40
38
|
simpleHash
|
|
41
39
|
};
|
|
42
40
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1,6 +1,6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QAAQ,MAAM,QAAQ;AAAA,IAEvB,SAAS;AAAA,IAET,SAAS;AAAA,IAER,QAAQ,MAAM,QAAQ;AAAA;AAE3B;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/simple-hash",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.27.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"types": "./types/index.d.ts",
|
|
6
6
|
"main": "dist/cjs",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@tamagui/build": "1.
|
|
28
|
+
"@tamagui/build": "1.27.0"
|
|
29
29
|
},
|
|
30
30
|
"publishConfig": {
|
|
31
31
|
"access": "public"
|
package/src/index.ts
CHANGED
|
@@ -10,18 +10,15 @@ export const simpleHash = (str: string, hashMin = 10) => {
|
|
|
10
10
|
for (let i = 0; i < len; i++) {
|
|
11
11
|
const char = str.charCodeAt(i)
|
|
12
12
|
// . => d0t
|
|
13
|
-
if (char === 46)
|
|
14
|
-
valids += 'd0t'
|
|
15
|
-
}
|
|
13
|
+
if (char === 46) valids += 'd0t'
|
|
16
14
|
// dont do more than 10 non-hashed to avoid getting too girthy
|
|
17
15
|
if (isValidCSSCharCode(char) && len <= hashMin) {
|
|
18
16
|
valids += str[i]
|
|
19
17
|
} else {
|
|
20
|
-
hash = (hash
|
|
21
|
-
hash &= hash // Convert to 32bit integer
|
|
18
|
+
hash = hashChar(hash, str[i])
|
|
22
19
|
}
|
|
23
20
|
}
|
|
24
|
-
const res = valids + (hash ?
|
|
21
|
+
const res = valids + (hash ? Math.abs(hash) : '')
|
|
25
22
|
if (cache.size > 10_000) {
|
|
26
23
|
cache.clear()
|
|
27
24
|
}
|
|
@@ -29,7 +26,9 @@ export const simpleHash = (str: string, hashMin = 10) => {
|
|
|
29
26
|
return res
|
|
30
27
|
}
|
|
31
28
|
|
|
32
|
-
|
|
29
|
+
const hashChar = (hash: number, c: string) => (Math.imul(31, hash) + c.charCodeAt(0)) | 0
|
|
30
|
+
|
|
31
|
+
function isValidCSSCharCode(code: number) {
|
|
33
32
|
return (
|
|
34
33
|
// A-Z
|
|
35
34
|
(code >= 65 && code <= 90) ||
|
package/types/index.d.ts
CHANGED
package/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU,QAAS,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU,QAAS,MAAM,0BAwBrC,CAAA"}
|