generated from wopjs/template
-
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.
- Loading branch information
Showing
5 changed files
with
39 additions
and
9 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
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
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 |
---|---|---|
@@ -1,7 +1,5 @@ | ||
import { type DisposableType, type Disposer } from "./interface"; | ||
import { dispose } from "./utils"; | ||
|
||
export const join = | ||
(...disposers: DisposableType[]): Disposer => | ||
() => | ||
disposers.forEach(dispose); | ||
export const join = (...disposers: DisposableType[]): Disposer => | ||
disposers.forEach.bind(disposers, dispose); |
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
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,26 @@ | ||
import { describe, expect, it } from "vitest"; | ||
|
||
import { type Disposer, type IDisposable, isDisposable } from "../src"; | ||
|
||
describe("isDisposable", () => { | ||
it("should returns true for Disposer", () => { | ||
const a = () => void 0; | ||
const b: Disposer = () => void 0; | ||
expect(isDisposable(a)).toBe(true); | ||
expect(isDisposable(b)).toBe(true); | ||
}); | ||
|
||
it("should returns true for IDisposable", () => { | ||
const a = { dispose() {} }; | ||
const b: IDisposable = { dispose: () => {} }; | ||
expect(isDisposable(a)).toBe(true); | ||
expect(isDisposable(b)).toBe(true); | ||
}); | ||
|
||
it("should returns false for other types", () => { | ||
const a = {}; | ||
const b = () => {}; | ||
expect(isDisposable(a)).toBe(false); | ||
expect(isDisposable(b)).toBe(false); | ||
}); | ||
}); |