🦖 this

Extend the Deno runtime global scope by injecting fully-typed functions/constants into globalThis. This module makes use of side-effect imports, meaning you do not need to import any actual named variables or functions - just import the filename itself.

encoding

import "https://deno.land/x/this@0.153.0/encoding.ts";

Also creates globals for this third-party library:


testing.ts

import "https://deno.land/x/this@0.153.0/testing.ts";

Also creates globals for these third-party testing libraries:

  • chai - chai@4.3.4
  • fc - fast-check@3.1.1

Examples

JSONC, JSON5, TOML, YAML

import "https://deno.land/x/this@0.153.0/encoding.ts";

const config = JSONC.parse(await Deno.readTextFile("./deno.jsonc"));

// deno.json5
await Deno.writeTextFile("./deno.json5", JSON5.stringify(config, null, 2));

// deno.toml
await Deno.writeTextFile("./deno.toml", TOML.stringify(config));

// deno.yml
await Deno.writeTextFile("./deno.yml", YAML.stringify(config));

Global Assertions

import "https://deno.land/x/this@0.153.0/testing.ts";

Deno.test("URL Test", () => {
  const url = new URL("./this@0.153.0/mod.ts", "https://deno.land/x/");
  assertEquals(url.href, "https://deno.land/x/this@0.153.0/mod.ts");
});

describe("Users Map", () => {
  const users = new Map();
  it("is initially empty", () => {
    assertEquals(users.size, 0);
  });
  it("is writeable", () => {
    users.set("key", "value");
    assertEquals(users.size, 1);
  });
  it("is readable", () => {
    assertArrayIncludes([...users.values()], ["value"]);
  });
});

The foundation of this module was inspired by ije/global.

MIT © Nicholas Berlette and ije