-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(polyfill): add polyfill for composite key and composite symbol
- Loading branch information
1 parent
ee3dcf7
commit e1525cd
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright 2023-latest Tomoki Miyauchi. All rights reserved. MIT license. | ||
// This module is browser compatible. | ||
|
||
/** | ||
* @example | ||
* ```ts | ||
* import "https://deno.land/x/composition_key@$VERSION/polyfill.ts"; | ||
* import { assert } from "https://deno.land/std/testing/asserts.ts"; | ||
* | ||
* assert(compositeKey); | ||
* assert(compositeSymbol); | ||
* ``` | ||
*/ | ||
|
||
// deno-lint-ignore-file no-var ban-types | ||
|
||
import { compositeKey, compositeSymbol, type Ref } from "./composite.ts"; | ||
|
||
declare global { | ||
var compositeKey: ( | ||
...parts: [object, ...unknown[]] | [...unknown[], object] | ||
) => Ref; | ||
var compositeSymbol: (...parts: readonly unknown[]) => symbol; | ||
} | ||
|
||
globalThis.compositeKey = compositeKey; | ||
globalThis.compositeSymbol = compositeSymbol; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright 2023-latest Tomoki Miyauchi. All rights reserved. MIT license. | ||
|
||
import "./polyfill.ts"; | ||
import { assert, describe, it } from "./_dev_deps.ts"; | ||
import { | ||
compositeKey as _compositeKey, | ||
compositeSymbol as _compositeSymbol, | ||
} from "./composite.ts"; | ||
|
||
describe("compositeKey", () => { | ||
it("should define global", () => { | ||
assert(compositeKey === _compositeKey); | ||
}); | ||
}); | ||
|
||
describe("compositeSymbol", () => { | ||
it("should define global", () => { | ||
assert(compositeSymbol === _compositeSymbol); | ||
}); | ||
}); |