New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@texting/string-value

Package Overview
Dependencies
Maintainers
0
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@texting/string-value - npm Package Compare versions

Comparing version

to
0.2.3

82

dist/index.js

@@ -1,46 +0,1 @@

import { STR } from '@typen/enum-data-types';
const v1 = word => {
word.toLowerCase();
return (word.charCodeAt(0) & 0x7f) << 21
};
const v2 = word => {
word = word.toLowerCase();
return (
((word.charCodeAt(0) & 0x7f) << 21) +
((word.charCodeAt(1) & 0x7f) << 14)
)
};
const v3 = word => {
word = word.toLowerCase();
return (
((word.charCodeAt(0) & 0x7f) << 21) +
((word.charCodeAt(1) & 0x7f) << 14) +
((word.charCodeAt(2) & 0x7f) << 7)
)
};
const v4 = word => {
word = word.toLowerCase();
return (
((word.charCodeAt(0) & 0x7f) << 21) +
((word.charCodeAt(1) & 0x7f) << 14) +
((word.charCodeAt(2) & 0x7f) << 7) +
(word.charCodeAt(3) & 0x7f)
)
};
const stringValue = word => {
const l = word?.length;
if (!l) return NaN
if (typeof word !== STR) return NaN
if (l >= 8) return (v4(word.slice(0, 4)) << 2) + v4(word.slice(-4))
if (l === 7) return (v4(word.slice(0, 4)) << 2) + v3(word.slice(-3))
if (l === 6) return (v4(word.slice(0, 4)) << 2) + v2(word.slice(-2))
if (l === 5) return (v4(word.slice(0, 4)) << 2) + v1(word.slice(-1))
if (l === 4) return v4(word) << 2
if (l === 3) return v3(word) << 2
if (l === 2) return v2(word) << 2
if (l === 1) return v1(word) << 2
};
const X32VAL = {

@@ -81,3 +36,3 @@ 0: 0,

function val(x, i) {
function val$1(x, i) {
let n = x.charCodeAt(i), p = n >> 5;

@@ -93,3 +48,3 @@ if (p === 1) return n & 0xF

if (hi <= lo) return n
while (lo < hi) n += val(x, lo++) << (i -= 4);
while (lo < hi) n += val$1(x, lo++) << (i -= 4);
return n

@@ -102,3 +57,3 @@ }

let i = 28, n = 0;
while (lo < hi) n += val(x, lo++) << (i -= 4);
while (lo < hi) n += val$1(x, lo++) << (i -= 4);
return n

@@ -127,2 +82,31 @@ }

export { stringValue, value, values };
const val = (x, i) => {
const n = x.charCodeAt(i);
return n < 32 ? 0 : n < 64 ? n & 0xF : n & 0x1F
};
const hash = (str, psl) => {
const length = str.length;
const hThres = Math.min(6, psl);
const hLen = Math.min(hThres, length);
let hVal = 0;
for (let i = 0; i < hLen; i++) {
hVal = (hVal << 5) | val(str, i);
}
hVal <<= (hThres - hLen) * 5;
let tVal = 0;
if (psl > 6 && length > 6) {
const tLen = Math.min(psl, length) - 6;
const tLo = length - tLen;
for (let i = tLo; i < length; i++) {
tVal = (tVal << 5) | val(str, i);
}
hVal += tVal / (1 << tLen * 5);
}
return hVal
};
export { hash, hash as stringValue, hash as value, values };
{
"name": "@texting/string-value",
"version": "0.2.2",
"version": "0.2.3",
"description": "Get quasi pseudo value of a string",

@@ -18,3 +18,3 @@ "type": "module",

"@typen/enum-data-types": "^0.2.0",
"@texting/enum-chars": "^0.2.2"
"@texting/enum-chars": "^0.2.3"
},

@@ -21,0 +21,0 @@ "devDependencies": {