{"id":21905788,"url":"https://github.com/deno911/this","last_synced_at":"2026-04-19T10:35:53.490Z","repository":{"id":58099456,"uuid":"529512517","full_name":"deno911/this","owner":"deno911","description":"Inject variables/functions into the global scope of the Deno runtime. 🦕","archived":false,"fork":false,"pushed_at":"2022-10-21T01:10:15.000Z","size":51,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-22T14:02:58.344Z","etag":null,"topics":["bdd-tests","csv-parser","csvstream","deno","deno-module","deno911","denoland","encoding","global","globalthis","helpers","json","json-parser","json5-parser","jsonstream","testing","toml-parser","typescript","utilities","yaml-parser"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/deno911.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-08-27T07:17:32.000Z","updated_at":"2024-05-02T04:40:56.000Z","dependencies_parsed_at":"2022-09-12T22:02:46.806Z","dependency_job_id":null,"html_url":"https://github.com/deno911/this","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/deno911/this","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deno911%2Fthis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deno911%2Fthis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deno911%2Fthis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deno911%2Fthis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deno911","download_url":"https://codeload.github.com/deno911/this/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deno911%2Fthis/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32004041,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T20:23:30.271Z","status":"online","status_checked_at":"2026-04-19T02:00:07.110Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bdd-tests","csv-parser","csvstream","deno","deno-module","deno911","denoland","encoding","global","globalthis","helpers","json","json-parser","json5-parser","jsonstream","testing","toml-parser","typescript","utilities","yaml-parser"],"created_at":"2024-11-28T16:37:27.296Z","updated_at":"2026-04-19T10:35:53.468Z","avatar_url":"https://github.com/deno911.png","language":"TypeScript","readme":"\u003c!-- deno-fmt-ignore-file --\u003e\n# [![deno911/this][banner-img]][this]\n\n## **Usage**\n\n```ts\nimport \"https://deno.land/x/this@0.160.1/mod.ts\";\n```\n\n\u003cdetails\u003e\u003csummary\u003e\u003cstrong\u003e\u003cu\u003eTable of Contents\u003c/u\u003e\u003c/strong\u003e\u003c/summary\u003e\u003cbr\u003e  \n\n- [**Usage**](#usage)\n- [**encoding**](#encoding)\n  - [**`CSV`**](#csv)\n  - [**`JSONC`**](#jsonc)\n  - [**`JSON5`**](#json5)\n  - [**`JsonStream`**](#jsonstream)\n  - [**`TOML`**](#toml)\n  - [**`YAML`**](#yaml)\n  - [**`FrontMatter`**](#frontmatter)\n  - [**`base64`**](#base64)\n  - [**`base64url`**](#base64url)\n  - [**`binary`**](#binary)\n  - [**`Hex`**](#hex)\n- [**testing**](#testing)\n  - [**`all`**](#all)\n  - [**`asserts`**](#asserts)\n  - [**`bdd`**](#bdd)\n  - [**`mock`**](#mock)\n  - [**`snapshot`**](#snapshot)\n  - [**`chai`**](#chai)\n  - [**`fc`**](#fc-fastcheck)\n- [**Examples**](#examples)\n- [**Contributing**](#contributing)\n\n\u003c/details\u003e\u003cbr\u003e\n\nThis project uses side-effect imports to extend the global namespace of the Deno runtime. It adds various tools from Deno Standard Library's `encoding` and `testing` suites.\n\nFor example, by importing `./encoding.ts`, your project will have access to `CSV`, `JSON5`, `YAML`, and `TOML` modules (to name a few) **at the global level**. See all available API's below.\n\n---  \n\n## **encoding**\n\n`this/encoding` exposes all the [`std/encoding`](https://deno.land/std@0.160.0/encoding) modules from the\nDeno Standard Library, along with a few extra goodies too.\n\n```ts\nimport \"https://deno.land/x/this@0.160.1/encoding.ts\";\n```\n\n### **CSV**\n\n```ts\nimport \"https://deno.land/x/this@0.160.1/encoding/csv.ts\";\n```\n\n#### `.parse`\n\n```ts\nCSV.parse(text: string, options?: CSV.ParseOptions): string[][];\n```\n\n```ts\nCSV.parse(text: string, { columns?: CSV.Column[]; }): Record\u003cstring, unknown\u003e;\n```\n\n#### `.stringify`\n\n```ts\nCSV.stringify(data: CSV.DataItem[], options?: CSV.StringifyOptions): string;\n```\n\n\u003e **Source**: [**`std@0.160.0/encoding/csv.ts`**](https://deno.land/std@0.160.0/encoding/csv.ts)\n\n### **JSONC**\n\n```ts\nimport \"https://deno.land/x/this@0.160.1/encoding/jsonc.ts\";\n```\n\n#### `.parse`\n\n```ts\nJSONC.parse(data: string, { allowTrailingComma?: boolean }): JsonValue;\n```\n\n#### `.stringify`\n\n```ts\nJSONC.stringify(data: JsonValue, replacer?: (key: string, value: any) =\u003e any, space?: string | number): string;\n```\n\n```ts\nJSONC.stringify(data: JsonValue, replacer?: (string | number)[], space?: string | number): string;\n```\n\n\u003e **Source**: [**`std@0.160.0/encoding/jsonc.ts`**](https://deno.land/std@0.160.0/encoding/jsonc.ts)\n\n### **JSON5**\n\n```ts\nimport \"https://deno.land/x/this@0.160.1/encoding/json5.ts\";\n```\n\n#### `.parse`\n\n```ts\nJSON5.parse\u003cT = JSONValue\u003e(text: string, reviver?: JSONReviverFn): T;\n```\n\n#### `.stringify`\n\n```ts\nJSON5.stringify(data: JSONValue, replacer?: JSONReplacerFn, space?: string | number): string;\n```\n\n#### `.require`\n\n```ts\nJSON5.require\u003cT = JSONValue\u003e(path: string | URL, reviver?: JSONReviverFn): T;\n```\n\n#### `.requireAsync`\n\n```ts\nJSON5.require\u003cT = JSONValue\u003e(path: string | URL, reviver?: JSONReviverFn): Promise\u003cT\u003e;\n```\n\n### **JsonStream**\n\n```ts\nimport \"https://deno.land/x/this@0.160.1/encoding/jsonstream.ts\";\n```\n\nThis is a custom implementation of the Deno Standard Library's JsonStream classes.  \n\nImporting `jsonstream.ts` creates a global named **`JsonStream`** with these properties:\n\n#### `.Parse`\n\nShorthand alias for the **`JsonParseStream`** class.  \n\nMust be called with the **`new`** keyword before its constructor, like so:\n\n```ts\nconst stream = new JsonStream.Parse(...options);\n```\n\n[**`JsonParseStream Documentation`**](https://doc.deno.land/https://deno.land/std@0.160.0/encoding/json/stream.ts/~/JsonParseStream)\n\n#### `.Stringify`\n\nShorthand alias for the **`JsonStringifyStream`** class.  \n\nMust be called with the **`new`** keyword before its constructor, like so:\n\n```ts\nconst stream = new JsonStream.Stringify(...options);\n```\n\n[**`JsonStringifyStream Documentation`**](https://doc.deno.land/https://deno.land/std@0.160.0/encoding/json/stream.ts/~/JsonStringifyStream)\n\n#### `.Concatenated`\n\nShorthand alias for the **`ConcatenatedJsonParseStream`** class.  \n\nMust be called with the **`new`** keyword before its constructor, like so:\n\n```ts\nconst stream = new JsonStream.Concatenated(...options);\n```\n\n[**`ConcatenatedJsonParseStream Documentation`**](https://doc.deno.land/https://deno.land/std@0.160.0/encoding/json/stream.ts/~/ConcatenatedJsonParseStream)\n\n#### `.useParse`\n\nShorthand equivalent to calling **`new JsonStream.Parse()`**, this creates a new instance of the `JsonParseStream` class.\n\n```ts\nconst stream = JsonStream.useParse(...options);\n```\n\n#### `.useStringify`\n\nShorthand equivalent to calling **`new JsonStream.Stringify()`**, this creates a new instance of the **`JsonStringifyStream`** class.\n\n```ts\nconst stream = JsonStream.useStringify(...options);\n```\n\n#### `.useConcat`\n\nShorthand equivalent to calling **`new JsonStream.Concatenated()`**, this creates a new instance of the **`ConcatenatedJsonParseStream`** class.\n\n```ts\nconst stream = JsonStream.useConcat(...options);\n```\n\n### **TOML**\n\n```ts\nimport \"https://deno.land/x/this@0.160.1/encoding/toml.ts\";\n```\n\n#### `.parse`\n\n```ts\nTOML.parse(text: string): Record\u003cstring, unknown\u003e;\n```\n\n#### `.stringify`\n\n```ts\nTOML.stringify(data: Record\u003cstring, unknown\u003e, options: TOML.FormatOptions): string;\n```\n\n\u003e **Source**: [**`std@0.160.0/encoding/toml.ts`**](https://deno.land/std@0.160.0/encoding/toml.ts)\n\n### **YAML**\n\n```ts\nimport \"https://deno.land/x/this@0.160.1/encoding/yaml.ts\";\n```\n\n#### `.parse`\n\n```ts\nYAML.parse(content: string, options?: LoaderStateOptions): unknown;\n```\n\n#### `.parseAll`\n\n```ts\nYAML.parseAll(content: string, options?: LoaderStateOptions): unknown;\n```\n\n```ts\nYAML.parseAll(content: string, iterator: CbFunction, options?: LoaderStateOptions);\n```\n\n#### `.stringify`\n\n```ts\nYAML.stringify(obj: Record\u003cstring, unknown\u003e, options?: DumperStateOptions): string;\n```\n\n\u003e **Source**: [**`std@0.160.0/encoding/yaml.ts`**](https://deno.land/std@0.160.0/encoding/yaml.ts)\n\n\n### **FrontMatter**\n\n```ts\nimport \"https://deno.land/x/this@0.160.1/encoding/front_matter.ts\";\n```\n\n#### `.extract`\n\n```ts\nFrontMatter.extract\u003cT = unknown\u003e(str: string): Extract\u003cT\u003e;\n```\n\n```ts\ntype Extract\u003cT\u003e = {\n  frontMatter: string;\n  body: string;\n  attrs: T;\n}\n```\n\n#### `.test`\n\n```ts\nFrontMatter.test(markdown: string): boolean;\n```\n\n\u003e **Source**: [**`std@0.160.0/encoding/front_matter.ts`**](https://deno.land/std@0.160.0/encoding/front_matter.ts)\n\n---\n\n### **base64**\n\n```ts\nimport \"https://deno.land/x/this@0.160.1/encoding/base64.ts\";\n```\n\n#### `.encode`\n\n```ts\nbase64.encode(data: ArrayBuffer | string): string;\n```\n\n#### `.decode`\n\n```ts\nbase64.decode(b64: string): string;\n```\n\n#### `.decodeBytes`\n\n```ts\nbase64.decodeBytes(b64: string): Uint8Array;\n```\n\n\u003e **Source**: [**``std@0.160.0/encoding/base64.ts``**](https://deno.land/std@0.160.0/encoding/base64.ts)\n\n---  \n\n### **base64url**\n\n```ts\nimport \"https://deno.land/x/this@0.160.1/encoding/base64url.ts\";\n```\n\n#### `.encode`\n\n```ts\nbase64.encode(data: BufferSource | string): string;\n```\n\n#### `.decode`\n\n```ts\nbase64.decode(b64url: string): string;\n```\n\n#### `.decodeBytes`\n\n```ts\nbase64.decodeBytes(b64url: string): Uint8Array;\n```\n\n\u003e **Source**: [**`std@0.160.0/encoding/base64url.ts`**](https://deno.land/std@0.160.0/encoding/base64url.ts)\n\n### **binary**\n\n```ts\nimport \"https://deno.land/x/this@0.160.1/encoding/binary.ts\";\n```\n\n\u003e **Source**: [**`std@0.160.0/encoding/binary.ts`**](https://deno.land/std@0.160.0/encoding/binary.ts)\n\n\n### **Hex**\n\n```ts\nimport \"https://deno.land/x/this@0.160.1/encoding/hex.ts\";\n```\n\n#### `.encode`\n\n```ts\nHex.encode(); // TODO\n```\n\n#### `.decode`\n\n```ts\nHex.decode(); // TODO\n```\n\n\u003e **Source**: [**`std@0.160.0/encoding/hex.ts`**](https://deno.land/std@0.160.0/encoding/hex.ts)\n\n---\n\n## **testing**\n\n```ts\nimport \"https://deno.land/x/this@0.160.1/testing.ts\";\n```\n\n\u003e **Note**: due to the size of [`chai`](#chai) and [`fc`](#fc-fastcheck), they\n\u003e have been excluded from the imports in the `./testing.ts` file. To use them,\n\u003e please import their respective files instead. Or, if you **really** want to\n\u003e YOLO, you can import ***all of the testing tools at once***. See below.\n\n### **all**\n\n```ts\nimport \"https://deno.land/x/this@0.160.1/testing/all.ts\";\n```\n\n\u003e **Warning**: this Imports everything below add quite a bit of weight to your project.\n\n### **asserts**\n\n```ts\nimport \"https://deno.land/x/this@0.160.1/testing/asserts.ts\";\n```\n\n\u003e **Source**: [**`std@0.160.0/testing/asserts.ts`**](https://deno.land/std@0.160.0/testing/asserts.ts)\n\n---\n\n### **bdd**\n\n```ts\nimport \"https://deno.land/x/this@0.160.1/testing/bdd.ts\";\n```\n\n#### `beforeAll`\n\n```ts\nlet fixture: Set\u003cnumber\u003e;\nlet startTime: number, endTime: number;\n\nbeforeAll(() =\u003e {\n  fixture = new Set([]);\n  startTime = Date.now(); \n});\n```\n\n#### `afterAll`\n\n```ts\nafterAll(() =\u003e {\n  fixture.clear();\n  fixture = undefined;\n  console.log\n});\n```\n\n#### `beforeEach`\n\n```ts\nbeforeEach(() =\u003e {\n  fixture.clear();\n  for (let i = 1; i \u003c= 10; i++) fixture.add(i);\n});\n```\n\n#### `afterEach`\n\n```ts\nafterEach(() =\u003e {\n  fixture = new Set([1, 2, 3, 4]);\n});\n```\n\n#### `describe`\n\n#### `it`\n\n\u003e **Source**: [**`std@0.160.0/testing/bdd.ts`**](https://deno.land/std@0.160.0/testing/bdd.ts)\n\n### **mock**\n\n```ts\nimport \"https://deno.land/x/this@0.160.1/testing/mock.ts\";\n```\n\n\u003e **Source**: [**`std@0.160.0/testing/mock.ts`**](https://deno.land/std@0.160.0/testing/mock.ts)\n\n### **snapshot**\n\n```ts\nimport \"https://deno.land/x/this@0.160.1/testing/snapshot.ts\";\n```\n\n\u003e **Source**: [**`std@0.160.0/testing/snapshot.ts`**](https://deno.land/std@0.160.0/testing/snapshot.ts)\n\n### **chai**\n\n```ts\nimport \"https://deno.land/x/this@0.160.1/testing/chai.ts\";\n```\n\n\u003e **Source**: [**`chai@4.3.4`**]()\n\n### **fc** (fastcheck)\n\n```ts\nimport \"https://deno.land/x/this@0.160.1/testing/fc.ts\";\n```\n\n\u003e **Source**: [**`fast-check@3.2.0`**](https://github.com/dubzzz/fast-check#readme)\n\n---\n\n## **examples**\n\n### `JSONC`, `JSON5`, `YAML`, `TOML`\n\nNow you can use `CSV`, `JSON5`, `JSONC`, `YAML`, `TOML` (and more), just as easily as you would use JavaScript's builtin `JSON` object. Check it out below.\n\n```ts\nimport \"https://deno.land/x/this@0.160.1/encoding.ts\";\n\n// deno.jsonc =\u003e { \"compilerOptions\": { \"lib\": [\"deno.ns\", \"deno.window\"] }, ... }\nconst deno_jsonc = JSONC.parse(await Deno.readTextFile(\"./deno.jsonc\"));\n// { compilerOptions: { lib: [\"deno.ns\", \"deno.window\"] }, ... }\n\nconst deno_json5 = JSON5.stringify(deno_jsonc);\n// {compilerOptions:{lib:['deno.ns','deno.window']}, ... }\n\nconst deno_toml = TOML.stringify(deno_jsonc);\n// [compilerOptions.lib] = [\"deno.ns\", \"deno.window\"]\n\nconst deno_yml = YAML.stringify(deno_jsonc);\n// compilerOptions:\n//   lib: [deno.ns, deno.window]\n```\n\n### `FrontMatter.extract`\n\n```ts\nimport \"https://deno.land/x/this@0.160.1/testing/asserts.ts\";\nimport \"https://deno.land/x/this@0.160.1/encoding/front_matter.ts\";\n\nconst { attrs, body, frontMatter } = FrontMatter.extract\u003c{ title: string }\u003e(\n  \"---\\ntitle: Three dashes marks the spot\\n---\\n\");\n\nassertEquals(attrs.title, \"Three dashes marks the spot\");\nassertEquals(body, \"\");\nassertEquals(frontMatter, \"title: Three dashes marks the spot\");\n```\n\n### `describe` + `it`\n\n```ts\nimport \"https://deno.land/x/this@0.160.1/testing/bdd.ts\";\n\nlet users: Map\u003cstring, unknown\u003e;\n\n// globally available hooks! \n// (beforeAll, afterAll, beforeEach, afterEach)\nbeforeEach(() =\u003e {\n  users = new Map\u003cstring, unknown\u003e();\n});\n\n// behavior-driven development (bdd) testing API\ndescribe(\"Users Map\", () =\u003e {\n\n  it(\"should initially empty\", () =\u003e {\n    assertEquals(users.size, 0);\n  });\n\n  it(\"should be readable and writable\", () =\u003e {\n    users.set(\"key\", \"value\");\n    assertEquals(users.size, 1);\n    assertArrayIncludes([...users.values()], [\"value\"]);\n  });\n\n});\n```\n\n### `assertEquals` + `AssertionError`\n\n```ts\nimport \"https://deno.land/x/this@0.160.1/testing/asserts.ts\";\n\nDeno.test(\"Global Assertions\", async ({ step }) =\u003e {\n\n  await step(\"are they equal?\", () =\u003e\n    assertEquals(+new Date(\"1970-01-01T00:00:00.000Z\"), 0);\n\n  await step(\"AssertionError also available\", () =\u003e {\n    if (1 !== 1) {\n      throw new AssertionError(\"OH NO! 1 != 1?!?! BAD JUJU\")\n    }\n  });\n});\n```\n\n### **`chai`** (chai.js)\n\n```ts\nimport \"https://deno.land/x/this@0.160.1/testing/chai.ts\";\n```\n\n### **`fc`**\n\n```ts\nimport \"https://deno.land/x/this@0.160.1/testing/fc.ts\";\n```\n\n---  \n\n## Contributing\n\n### ⚠️ Fixing a bug? Create an Issue first\u003c!--omit from toc--\u003e\n\n\u003e Unless you're fixing a bug for which an issue already exists!\n\nThis allows the issue to be connected to your Pull Request, creating a permanent record of your contribution to the project. It also helps maintainers with tracking project progression.\n\nCreating an issue also ensures you're given credit for fixing that bug. 😁\n\n---\n\n### Fork + clone the repository\u003c!--omit from toc--\u003e\n\n\u003e **Note**: This section assumes you have [**the GitHub CLI**][gh]. You should get it.\n\n```sh\ngh repo fork deno911/this --clone\n```\n\n### Create a new branch for your changes\u003c!--omit from toc--\u003e\n\n```sh\ngit checkout -b fix/typo-in-readme\n```\n\n### Make small changes and concise commits\u003c!--omit from toc--\u003e\n\n```sh\n# hack hack hack...\n\ngit commit README.md -m \"fix: typos in README.md\" \u0026\u0026 git push\n```\n\n\u003e **Note**: keep the scope of your changes relevant and concise.\n\n### Open a Pull Request\u003c!--omit from toc--\u003e\n\n```sh\ngh pr create --title \"fix: typos in README.md\"\n```\n\n**Or just open your repo on GitHub.com and follow the prompts.**\n\n\u003e **Warning**: make sure you select the upstream repo for your PR!\n\n\u003cbr\u003e\n\n---\n\n\u003cdiv align=\"center\"\u003e\n\n## [🅓🅔🅝🅞⑨①①][deno911] \u003c!-- omit in toc --\u003e\n\n###### The foundation of this module was inspired by [ije/global][ije]. \u003c!-- omit in toc --\u003e\n\n\u003c/div\u003e\n\n[ije]: https://github.com/ije/global \"The foundation of this module was inspired by ije/global\"\n[deno911]: https://github.com/deno911 \"Projects by deno911 on GitHub\"\n[gh]: https://cli.github.com\n[this]: https://deno.land/x/this \"View deno911/this on deno.land/x\"\n[banner-img]: https://raw.githubusercontent.com/deno911/.github/main/static/this/banner.png \"deno911/this - Extend Deno's globals with std/encoding \u0026 std/testing tools\"","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeno911%2Fthis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeno911%2Fthis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeno911%2Fthis/lists"}