/
kochenov
/
universal-modular
Обзор
Документация
Войти
/
kochenov
/
universal-modular
Код
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
node_modules/entities/src/internal/decode-shared.ts
30 строк
1 KB
Kochenov Dmitry
feat(foundation): Шаг 1.3 — Установить Node.js 24 + VitePress + настроить конфигурацию
10 июл 2026, 11:06
10 июл 2026, 11:06
70eff21
Код
Авторство
О чём код?
/* * Shared base64 decode helper for generated decode data. * Assumes global atob is available. */ export function decodeBase64(input: string): Uint16Array { const binary: string = // eslint-disable-next-line n/no-unsupported-features/node-builtins typeof atob === "function" ? // Browser (and Node >=16) // eslint-disable-next-line n/no-unsupported-features/node-builtins atob(input) : // Older Node versions (<16) // eslint-disable-next-line n/no-unsupported-features/node-builtins typeof Buffer.from === "function" ? // eslint-disable-next-line n/no-unsupported-features/node-builtins Buffer.from(input, "base64").toString("binary") : // eslint-disable-next-line unicorn/no-new-buffer, n/no-deprecated-api new Buffer(input, "base64").toString("binary"); const evenLength = binary.length & ~1; // Round down to even length const out = new Uint16Array(evenLength / 2); for (let index = 0, outIndex = 0; index < evenLength; index += 2) { const lo = binary.charCodeAt(index); const hi = binary.charCodeAt(index + 1); out[outIndex++] = lo | (hi << 8); } return out; }