summaryrefslogtreecommitdiff
path: root/std/node/global.ts
blob: b102edddc46cb241e982369563f8b6e63e213f84 (plain)
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
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import process from "./process.ts";
import { Buffer as buffer } from "./buffer.ts";

Object.defineProperty(globalThis, Symbol.toStringTag, {
  value: "global",
  writable: false,
  enumerable: false,
  configurable: true,
});

// deno-lint-ignore no-explicit-any
(globalThis as any)["global"] = globalThis;

// Define the type for the global declration
type Process = typeof process;
type Buffer = typeof buffer;

Object.defineProperty(globalThis, "process", {
  value: process,
  enumerable: false,
  writable: true,
  configurable: true,
});

declare global {
  const process: Process;
  const Buffer: Buffer;
}

Object.defineProperty(globalThis, "Buffer", {
  value: buffer,
  enumerable: false,
  writable: true,
  configurable: true,
});

export {};