Skip to content

Commit 25c34ee

Browse files
committed
drop bytesToHex in favour of Uint8Array::toHex()
- deprecate unused `escapeHTML()` Signed-off-by: 🕷️ <3756473+zendive@users.noreply.github.com>
1 parent 87a8013 commit 25c34ee

1 file changed

Lines changed: 2 additions & 16 deletions

File tree

src/api/toolkit.ts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,14 @@
11
import { sha256 } from '@noble/hashes/sha2.js';
2-
import { bytesToHex, utf8ToBytes } from '@noble/hashes/utils.js';
2+
import { utf8ToBytes } from '@noble/hashes/utils.js';
33

44
export function hasValue(o: unknown): boolean {
55
return undefined !== o && null !== o;
66
}
77

88
export function hashString(str: string) {
9-
return bytesToHex(sha256(utf8ToBytes(str)));
9+
return sha256(utf8ToBytes(str)).toHex();
1010
}
1111

1212
export function isSearchKeyboardEvent(e: KeyboardEvent) {
1313
return (e.ctrlKey || e.metaKey) && e.key.toLowerCase() === 'f';
1414
}
15-
16-
export function escapeHTML(str: string) {
17-
return str.replace(
18-
/[&<>"']/g,
19-
(match) =>
20-
(<Record<string, string>> {
21-
'&': '&amp;',
22-
'<': '&lt;',
23-
'>': '&gt;',
24-
'"': '&quot;',
25-
"'": '&#39;',
26-
})[match],
27-
);
28-
}

0 commit comments

Comments
 (0)