forked from unjs/unenv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
42 lines (37 loc) · 1.23 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// https://nodejs.org/api/buffer.html
import type buffer from "node:buffer";
import { notImplemented } from "../../_internal/utils";
import { Buffer, kMaxLength, INSPECT_MAX_BYTES, SlowBuffer } from "./_buffer";
import { File } from "./_file";
// @ts-ignore
export { Buffer, kMaxLength, INSPECT_MAX_BYTES, SlowBuffer } from "./_buffer";
export { File } from "./_file";
// @ts-expect-eerror https://github.com/unjs/unenv/issues/64
export const Blob = globalThis.Blob as unknown as typeof buffer.Blob;
export const resolveObjectURL = notImplemented("buffer.resolveObjectURL");
export const transcode = notImplemented("buffer.transcode");
export const isUtf8 = notImplemented("buffer.isUtf8");
export const isAscii = notImplemented("buffer.isAscii");
export const btoa = global.btoa;
export const atob = globalThis.atob;
export const kStringMaxLength = 0; // TODO
export const constants = {
MAX_LENGTH: kMaxLength,
MAX_STRING_LENGTH: kStringMaxLength,
};
export default <typeof buffer>{
Buffer: Buffer as any as typeof buffer.Buffer,
SlowBuffer: SlowBuffer as any as typeof buffer.SlowBuffer,
kMaxLength,
INSPECT_MAX_BYTES,
Blob,
resolveObjectURL,
transcode,
btoa,
atob,
kStringMaxLength,
constants,
isUtf8,
isAscii,
File,
};