Files
bun.sh/src/node-fallbacks/buffer.js
chloe caruso f17ce2b756 hmr fixes (#17239)
Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2025-02-12 23:14:02 -08:00

37 lines
998 B
JavaScript

/**
* Browser polyfill for the `"buffer"` module.
*
* Imported on usage in `bun build --target=browser`
*/
export * from "./node_modules/buffer";
export { Buffer as default } from "./node_modules/buffer";
export { Buffer } from "./node_modules/buffer";
export var kStringMaxLength = 2 ** 32 - 1;
export var kMaxLength = 9007199254740991;
export var { Blob, File, atob, btoa } = globalThis;
export var { createObjectURL } = URL;
export var isAscii = buf => {
if (ArrayBuffer.isView(buf)) {
return buf.every(byte => byte < 128);
} else {
return buf.split("").every(char => char.charCodeAt(0) < 128);
}
};
export var isUtf8 = buf => {
throw new Error("Not implemented");
};
export var constants = {
__proto__: null,
MAX_LENGTH: kStringMaxLength,
MAX_STRING_LENGTH: kStringMaxLength,
BYTES_PER_ELEMENT: 1,
};
export function resolveObjectURL(url) {
throw new Error("Not implemented");
}
export function transcode(buf, from, to) {
throw new Error("Not implemented");
}