Repository: denoland/deno
File: runtime/js/90_deno_ns.js (JavaScript)

Code before:
  watchFs: fsEvents.watchFs,
  chmodSync: fs.chmodSync,
  chmod: fs.chmod,
  chown: fs.chown,
  chownSync: fs.chownSync,
  copyFileSync: fs.copyFileSync,
  cwd: fs.cwd,
  makeTempDirSync: fs.makeTempDirSync,
  makeTempDir: fs.makeTempDir,
  makeTempFileSync: fs.makeTempFileSync,
  makeTempFile: fs.makeTempFile,
  cpuUsage: (previousValue) => {
    const { 0: system, 1: user } = op_runtime_cpu_usage();
    if (previousValue) {
      if (typeof previousValue.user !== "number") {
        throw new TypeErrorConstructor(
          'The "previousValue.user" property must be of type number.',
        );
      }
      if (typeof previousValue.system !== "number") {
        throw new TypeErrorConstructor(
          'The "previousValue.system" property must be of type number.',
        );
      }
      if (previousValue.user < 0 || !NumberIsFinite(previousValue.user)) {
        throw new RangeError(
          'The "previousValue.user" property must be 0 or greater.',
        );
      }
      if (previousValue.system < 0 || !NumberIsFinite(previousValue.system)) {
        throw new RangeError(
          'The "previousValue.system" property must be 0 or greater.',
        );
      }

      return {
        system: system - previousValue.system,
        user: user - previousValue.user,
      };
    }
    return { system, user };
  },
  memoryUsage: () => {
    const { 0: rss, 1: heapTotal, 2: heapUsed, 3: external } =
      op_runtime_memory_usage();
    return { rss, heapTotal, heapUsed, external };
  },
  mkdirSync: fs.mkdirSync,
  mkdir: fs.mkdir,
  chdir: fs.chdir,
  copyFile: fs.copyFile,

Review comment (suggestion):
@kt3k I looked at using `RangeErrorConstructor` here but that looks to be identical to `TypeErrorConstructor,` which is why I've gone with `new RangeError` instead 👍 

Code after:
  copyFileSync: fs.copyFileSync,
  cwd: fs.cwd,
  makeTempDirSync: fs.makeTempDirSync,
  makeTempDir: fs.makeTempDir,
  makeTempFileSync: fs.makeTempFileSync,
  makeTempFile: fs.makeTempFile,
  cpuUsage: () => {
    const { 0: system, 1: user } = op_runtime_cpu_usage();
    return { system, user };
  },
  memoryUsage: () => {
    const { 0: rss, 1: heapTotal, 2: heapUsed, 3: external } =
      op_runtime_memory_usage();
    return { rss, heapTotal, heapUsed, external };
  },
  mkdirSync: fs.mkdirSync,
  mkdir: fs.mkdir,
  chdir: fs.chdir,
  copyFile: fs.copyFile,
  readDirSync: fs.readDirSync,
  readDir: fs.readDir,
  readLinkSync: fs.readLinkSync,
  readLink: fs.readLink,
  realPathSync: fs.realPathSync,
  realPath: fs.realPath,
  removeSync: fs.removeSync,
  remove: fs.remove,
  renameSync: fs.renameSync,
  rename: fs.rename,
  version: version.version,
  build: core.build,
  statSync: fs.statSync,
  lstatSync: fs.lstatSync,
  stat: fs.stat,
  lstat: fs.lstat,
  truncateSync: fs.truncateSync,
  truncate: fs.truncate,
  errors: errors.errors,
  inspect: console.inspect,
  env: os.env,
  exit: os.exit,
  execPath: os.execPath,
  SeekMode: io.SeekMode,
  FsFile: fs.FsFile,
  open: fs.open,
  openSync: fs.openSync,
  create: fs.create,
  createSync: fs.createSync,
  stdin: io.stdin,
  stdout: io.stdout,
  stderr: io.stderr,