ico-utils
Version:
A javascript library to create ICO file from PNG images and extract PNG images from ICO file.
14 lines (13 loc) • 482 B
JavaScript
export function splitNumberToBytes(num, bytes = 2) {
if (bytes <= 1) {
return [num & 255];
}
return [...splitNumberToBytes(num, bytes - 1), (num >> (8 * (bytes - 1))) & 255];
}
export function joinBytesToNumber(bytes) {
var _a, _b;
if (bytes.length <= 1) {
return (_a = bytes.pop()) !== null && _a !== void 0 ? _a : 0;
}
return (((_b = bytes.pop()) !== null && _b !== void 0 ? _b : 0) << (8 * bytes.length)) + joinBytesToNumber(bytes);
}