@tamagui/simple-hash
Advanced tools
Comparing version 1.108.4 to 1.109.0
@@ -23,9 +23,15 @@ var __defProp = Object.defineProperty; | ||
return cache.get(str); | ||
let hash = 0, valids = ""; | ||
let hash = 0, valids = "", added = 0; | ||
const len = str.length; | ||
for (let i = 0; i < len; i++) { | ||
const char = str.charCodeAt(i); | ||
if (hashMin !== "strict" && (char === 46 && (valids += "d0t"), isValidCSSCharCode(char) && len <= hashMin)) { | ||
valids += str[i]; | ||
continue; | ||
if (hashMin !== "strict" && added <= hashMin) { | ||
const char = str.charCodeAt(i); | ||
if (char === 46) { | ||
valids += "--"; | ||
continue; | ||
} | ||
if (isValidCSSCharCode(char)) { | ||
added++, valids += str[i]; | ||
continue; | ||
} | ||
} | ||
@@ -32,0 +38,0 @@ hash = hashChar(hash, str[i]); |
@@ -25,7 +25,13 @@ "use strict"; | ||
return cache.get(str); | ||
for (var hash = 0, valids = "", len = str.length, i = 0; i < len; i++) { | ||
var char = str.charCodeAt(i); | ||
if (hashMin !== "strict" && (char === 46 && (valids += "d0t"), isValidCSSCharCode(char) && len <= hashMin)) { | ||
valids += str[i]; | ||
continue; | ||
for (var hash = 0, valids = "", added = 0, len = str.length, i = 0; i < len; i++) { | ||
if (hashMin !== "strict" && added <= hashMin) { | ||
var char = str.charCodeAt(i); | ||
if (char === 46) { | ||
valids += "--"; | ||
continue; | ||
} | ||
if (isValidCSSCharCode(char)) { | ||
added++, valids += str[i]; | ||
continue; | ||
} | ||
} | ||
@@ -32,0 +38,0 @@ hash = hashChar(hash, str[i]); |
const cache = /* @__PURE__ */ new Map(), simpleHash = (str, hashMin = 10) => { | ||
if (cache.has(str)) | ||
return cache.get(str); | ||
let hash = 0, valids = ""; | ||
let hash = 0, valids = "", added = 0; | ||
const len = str.length; | ||
for (let i = 0; i < len; i++) { | ||
const char = str.charCodeAt(i); | ||
if (hashMin !== "strict" && (char === 46 && (valids += "d0t"), isValidCSSCharCode(char) && len <= hashMin)) { | ||
valids += str[i]; | ||
continue; | ||
if (hashMin !== "strict" && added <= hashMin) { | ||
const char = str.charCodeAt(i); | ||
if (char === 46) { | ||
valids += "--"; | ||
continue; | ||
} | ||
if (isValidCSSCharCode(char)) { | ||
added++, valids += str[i]; | ||
continue; | ||
} | ||
} | ||
@@ -12,0 +18,0 @@ hash = hashChar(hash, str[i]); |
@@ -5,7 +5,13 @@ var cache = /* @__PURE__ */ new Map(), simpleHash = function(str) { | ||
return cache.get(str); | ||
for (var hash = 0, valids = "", len = str.length, i = 0; i < len; i++) { | ||
var char = str.charCodeAt(i); | ||
if (hashMin !== "strict" && (char === 46 && (valids += "d0t"), isValidCSSCharCode(char) && len <= hashMin)) { | ||
valids += str[i]; | ||
continue; | ||
for (var hash = 0, valids = "", added = 0, len = str.length, i = 0; i < len; i++) { | ||
if (hashMin !== "strict" && added <= hashMin) { | ||
var char = str.charCodeAt(i); | ||
if (char === 46) { | ||
valids += "--"; | ||
continue; | ||
} | ||
if (isValidCSSCharCode(char)) { | ||
added++, valids += str[i]; | ||
continue; | ||
} | ||
} | ||
@@ -12,0 +18,0 @@ hash = hashChar(hash, str[i]); |
{ | ||
"name": "@tamagui/simple-hash", | ||
"version": "1.108.4", | ||
"version": "1.109.0", | ||
"sideEffects": false, | ||
@@ -32,3 +32,3 @@ "types": "./types/index.d.ts", | ||
"devDependencies": { | ||
"@tamagui/build": "1.108.4" | ||
"@tamagui/build": "1.109.0" | ||
}, | ||
@@ -35,0 +35,0 @@ "publishConfig": { |
@@ -7,14 +7,17 @@ const cache = new Map() | ||
} | ||
let hash = 0 | ||
let valids = '' | ||
let added = 0 | ||
const len = str.length | ||
for (let i = 0; i < len; i++) { | ||
const char = str.charCodeAt(i) | ||
// . => d0t | ||
if (hashMin !== 'strict') { | ||
if (hashMin !== 'strict' && added <= hashMin) { | ||
const char = str.charCodeAt(i) | ||
if (char === 46) { | ||
valids += 'd0t' | ||
valids += '--' | ||
continue | ||
} | ||
// dont do more than 10 non-hashed to avoid getting too girthy | ||
if (isValidCSSCharCode(char) && len <= hashMin) { | ||
if (isValidCSSCharCode(char)) { | ||
added++ | ||
valids += str[i] | ||
@@ -26,3 +29,5 @@ continue | ||
} | ||
const res = valids + (hash ? Math.abs(hash) : '') | ||
if (cache.size > 10_000) { | ||
@@ -32,2 +37,3 @@ cache.clear() | ||
cache.set(str, res) | ||
return res | ||
@@ -34,0 +40,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16158
271