diff --git a/denops/@denops-private/denops.ts b/denops/@denops-private/denops.ts index dc305af4..a7c073bd 100644 --- a/denops/@denops-private/denops.ts +++ b/denops/@denops-private/denops.ts @@ -5,11 +5,14 @@ import { type Dispatcher, type Meta, } from "jsr:@denops/core@^7.0.0"; -import { ensure, is } from "jsr:@core/unknownutil@^3.18.1"; +import { ensure } from "jsr:@core/unknownutil@^4.0.0/ensure"; +import { isTupleOf } from "jsr:@core/unknownutil@^4.0.0/is/tuple-of"; +import { isArray } from "jsr:@core/unknownutil@^4.0.0/is/array"; +import { isString } from "jsr:@core/unknownutil@^4.0.0/is/string"; import type { Host as HostOrigin } from "./host.ts"; import type { Service as ServiceOrigin } from "./service.ts"; -const isBatchReturn = is.TupleOf([is.Array, is.String] as const); +const isBatchReturn = isTupleOf([isArray, isString] as const); export type Host = Pick; diff --git a/denops/@denops-private/error.ts b/denops/@denops-private/error.ts index 96cc0fbb..e8e2cc04 100644 --- a/denops/@denops-private/error.ts +++ b/denops/@denops-private/error.ts @@ -1,4 +1,4 @@ -import { is } from "jsr:@core/unknownutil@^3.18.1"; +import { isString } from "jsr:@core/unknownutil@^4.0.0/is/string"; import { fromErrorObject, isErrorObject, @@ -16,7 +16,7 @@ export function errorSerializer(err: unknown): unknown { } export function errorDeserializer(err: unknown): unknown { - if (is.String(err)) { + if (isString(err)) { const obj = tryOr(() => JSON.parse(err), undefined); if (isErrorObject(obj)) { return fromErrorObject(obj); diff --git a/denops/@denops-private/error_test.ts b/denops/@denops-private/error_test.ts index bef58402..1e9e2508 100644 --- a/denops/@denops-private/error_test.ts +++ b/denops/@denops-private/error_test.ts @@ -1,12 +1,12 @@ import { assert, assertEquals, assertInstanceOf } from "jsr:@std/assert@^1.0.1"; -import { is } from "jsr:@core/unknownutil@^3.18.1"; +import { isString } from "jsr:@core/unknownutil@^4.0.0/is/string"; import { errorDeserializer, errorSerializer } from "./error.ts"; Deno.test("errorSerializer", async (t) => { await t.step("serializes Error", () => { const err = new Error("error message"); const ret = errorSerializer(err); - assert(is.String(ret)); + assert(isString(ret)); assertEquals({ ...JSON.parse(ret), stack: "stack" }, { attributes: {}, message: "error message", @@ -19,7 +19,7 @@ Deno.test("errorSerializer", async (t) => { await t.step("serializes String", () => { const err = "error message"; const ret = errorSerializer(err); - assert(is.String(ret)); + assert(isString(ret)); assertEquals(ret, "error message"); }); @@ -29,7 +29,7 @@ Deno.test("errorSerializer", async (t) => { message: "error message", }; const ret = errorSerializer(err); - assert(is.String(ret)); + assert(isString(ret)); assertEquals(JSON.parse(ret), { type: "error", message: "error message", diff --git a/denops/@denops-private/host.ts b/denops/@denops-private/host.ts index c2ff268d..6ee00434 100644 --- a/denops/@denops-private/host.ts +++ b/denops/@denops-private/host.ts @@ -1,4 +1,10 @@ -import { ensure, is, type Predicate } from "jsr:@core/unknownutil@^3.18.1"; +import type { Predicate } from "jsr:@core/unknownutil@^4.0.0/type"; +import { ensure } from "jsr:@core/unknownutil@^4.0.0/ensure"; +import { asOptional } from "jsr:@core/unknownutil@^4.0.0/as/optional"; +import { isArray } from "jsr:@core/unknownutil@^4.0.0/is/array"; +import { isParametersOf } from "jsr:@core/unknownutil@^4.0.0/is/parameters-of"; +import { isString } from "jsr:@core/unknownutil@^4.0.0/is/string"; +import { isUnknown } from "jsr:@core/unknownutil@^4.0.0/is/unknown"; /** * Host (Vim/Neovim) which is visible from Service @@ -94,15 +100,15 @@ export function invoke( } const serviceMethodArgs = { - load: is.ParametersOf([is.String, is.String] as const), - unload: is.ParametersOf([is.String] as const), - reload: is.ParametersOf([is.String] as const), - interrupt: is.ParametersOf([is.OptionalOf(is.Unknown)] as const), - dispatch: is.ParametersOf([is.String, is.String, is.Array] as const), - dispatchAsync: is.ParametersOf( - [is.String, is.String, is.Array, is.String, is.String] as const, + load: isParametersOf([isString, isString] as const), + unload: isParametersOf([isString] as const), + reload: isParametersOf([isString] as const), + interrupt: isParametersOf([asOptional(isUnknown)] as const), + dispatch: isParametersOf([isString, isString, isArray] as const), + dispatchAsync: isParametersOf( + [isString, isString, isArray, isString, isString] as const, ), - close: is.ParametersOf([] as const), + close: isParametersOf([] as const), } as const satisfies { [K in keyof ServiceForInvoke]: Predicate>; }; diff --git a/denops/@denops-private/host/nvim.ts b/denops/@denops-private/host/nvim.ts index 89f88422..4c70475d 100644 --- a/denops/@denops-private/host/nvim.ts +++ b/denops/@denops-private/host/nvim.ts @@ -1,4 +1,10 @@ -import { ensure, is } from "jsr:@core/unknownutil@^3.18.1"; +import { ensure } from "jsr:@core/unknownutil@^4.0.0/ensure"; +import { isArray } from "jsr:@core/unknownutil@^4.0.0/is/array"; +import { isNull } from "jsr:@core/unknownutil@^4.0.0/is/null"; +import { isNumber } from "jsr:@core/unknownutil@^4.0.0/is/number"; +import { isString } from "jsr:@core/unknownutil@^4.0.0/is/string"; +import { isTupleOf } from "jsr:@core/unknownutil@^4.0.0/is/tuple-of"; +import { isUnionOf } from "jsr:@core/unknownutil@^4.0.0/is/union-of"; import { Client, Session } from "jsr:@lambdalisue/messagepack-rpc@^2.4.0"; import { errorDeserializer, errorSerializer } from "../error.ts"; import { getVersionOr } from "../version.ts"; @@ -27,8 +33,8 @@ export class Neovim implements Host { } return invoke( this.#service, - ensure(method, is.String), - ensure(args, is.Array), + ensure(method, isString), + ensure(args, isArray), ); }, @@ -130,16 +136,16 @@ export class Neovim implements Host { // nvim_call_function throws a special error object // https://github.com/neovim/neovim/blob/5dc0bdfe98b59bb03226167ed541d17cc5af30b1/src/nvim/api/vimscript.c#L260 // https://github.com/neovim/neovim/blob/5dc0bdfe98b59bb03226167ed541d17cc5af30b1/src/nvim/api/private/defs.h#L63-L66 -const isNvimErrorObject = is.TupleOf([is.Number, is.String] as const); +const isNvimErrorObject = isTupleOf([isNumber, isString] as const); // nvim_call_atomics returns a tuple of [return values, error details] -const isNvimCallAtomicReturn = is.TupleOf( +const isNvimCallAtomicReturn = isTupleOf( [ - is.Array, - is.OneOf([ - is.Null, + isArray, + isUnionOf([ + isNull, // the index, the error type, the error message - is.TupleOf([is.Number, is.Number, is.String] as const), + isTupleOf([isNumber, isNumber, isString] as const), ]), ] as const, ); diff --git a/denops/@denops-private/host/vim.ts b/denops/@denops-private/host/vim.ts index 52d059a8..3c2626a6 100644 --- a/denops/@denops-private/host/vim.ts +++ b/denops/@denops-private/host/vim.ts @@ -1,4 +1,9 @@ -import { ensure, is } from "jsr:@core/unknownutil@^3.18.1"; +import { ensure } from "jsr:@core/unknownutil@^4.0.0/ensure"; +import { isArray } from "jsr:@core/unknownutil@^4.0.0/is/array"; +import { isLiteralOf } from "jsr:@core/unknownutil@^4.0.0/is/literal-of"; +import { isString } from "jsr:@core/unknownutil@^4.0.0/is/string"; +import { isTupleOf } from "jsr:@core/unknownutil@^4.0.0/is/tuple-of"; +import { isUnknown } from "jsr:@core/unknownutil@^4.0.0/is/unknown"; import { Client, type Message, @@ -120,16 +125,16 @@ export class Vim implements Host { } } -const isCallReturn = is.TupleOf([is.Unknown, is.String] as const); +const isCallReturn = isTupleOf([isUnknown, isString] as const); -const isBatchReturn = is.TupleOf([is.Array, is.String] as const); +const isBatchReturn = isTupleOf([isArray, isString] as const); -const isVoidMessage = is.TupleOf([is.LiteralOf("void")] as const); +const isVoidMessage = isTupleOf([isLiteralOf("void")] as const); -const isInvokeMessage = is.TupleOf( +const isInvokeMessage = isTupleOf( [ - is.LiteralOf("invoke"), - is.String, - is.Array, + isLiteralOf("invoke"), + isString, + isArray, ] as const, ); diff --git a/denops/@denops-private/host_test.ts b/denops/@denops-private/host_test.ts index 050d9b8d..ea2f644e 100644 --- a/denops/@denops-private/host_test.ts +++ b/denops/@denops-private/host_test.ts @@ -4,7 +4,7 @@ import { assertSpyCalls, stub, } from "jsr:@std/testing@^1.0.0-rc.5/mock"; -import { AssertError } from "jsr:@core/unknownutil@^3.18.1"; +import { AssertError } from "jsr:@core/unknownutil@^4.0.0/assert"; import { unimplemented } from "jsr:@lambdalisue/errorutil@^1.1.0"; import { invoke, type Service } from "./host.ts"; diff --git a/denops/@denops-private/util.ts b/denops/@denops-private/util.ts index 1e12b1b3..fb407e27 100644 --- a/denops/@denops-private/util.ts +++ b/denops/@denops-private/util.ts @@ -1,9 +1,12 @@ import type { Meta } from "jsr:@denops/core@^7.0.0"; -import { is, type Predicate } from "jsr:@core/unknownutil@^3.18.1"; +import type { Predicate } from "jsr:@core/unknownutil@^4.0.0/type"; +import { isLiteralOneOf } from "jsr:@core/unknownutil@^4.0.0/is/literal-one-of"; +import { isObjectOf } from "jsr:@core/unknownutil@^4.0.0/is/object-of"; +import { isString } from "jsr:@core/unknownutil@^4.0.0/is/string"; -export const isMeta: Predicate = is.ObjectOf({ - mode: is.LiteralOneOf(["release", "debug", "test"] as const), - host: is.LiteralOneOf(["vim", "nvim"] as const), - version: is.String, - platform: is.LiteralOneOf(["windows", "mac", "linux"] as const), +export const isMeta: Predicate = isObjectOf({ + mode: isLiteralOneOf(["release", "debug", "test"] as const), + host: isLiteralOneOf(["vim", "nvim"] as const), + version: isString, + platform: isLiteralOneOf(["windows", "mac", "linux"] as const), }); diff --git a/denops/@denops-private/version_test.ts b/denops/@denops-private/version_test.ts index 53195019..621fcadb 100644 --- a/denops/@denops-private/version_test.ts +++ b/denops/@denops-private/version_test.ts @@ -1,7 +1,12 @@ import { assert, assertEquals } from "jsr:@std/assert@^1.0.1"; import { resolvesNext, stub } from "jsr:@std/testing@^1.0.0-rc.5/mock"; import type { SemVer } from "jsr:@std/semver@^0.224.3/types"; -import { is, type Predicate } from "jsr:@core/unknownutil@^3.18.1"; +import type { Predicate } from "jsr:@core/unknownutil@^4.0.0/type"; +import { isArrayOf } from "jsr:@core/unknownutil@^4.0.0/is/array-of"; +import { isNumber } from "jsr:@core/unknownutil@^4.0.0/is/number"; +import { isObjectOf } from "jsr:@core/unknownutil@^4.0.0/is/object-of"; +import { isString } from "jsr:@core/unknownutil@^4.0.0/is/string"; +import { isUnionOf } from "jsr:@core/unknownutil@^4.0.0/is/union-of"; import { getVersionOr } from "./version.ts"; Deno.test("getVersionOr()", async (t) => { @@ -53,12 +58,12 @@ Deno.test("getVersionOr()", async (t) => { }); }); -const isSemVer = is.ObjectOf({ - major: is.Number, - minor: is.Number, - patch: is.Number, - prerelease: is.ArrayOf(is.UnionOf([is.String, is.Number])), - build: is.ArrayOf(is.String), +const isSemVer = isObjectOf({ + major: isNumber, + minor: isNumber, + patch: isNumber, + prerelease: isArrayOf(isUnionOf([isString, isNumber])), + build: isArrayOf(isString), }) satisfies Predicate; async function isInsideWorkTree(): Promise { diff --git a/denops/@denops-private/worker.ts b/denops/@denops-private/worker.ts index 5902655a..4902ba97 100644 --- a/denops/@denops-private/worker.ts +++ b/denops/@denops-private/worker.ts @@ -5,7 +5,7 @@ import { readableStreamFromWorker, writableStreamFromWorker, } from "jsr:@lambdalisue/workerio@^4.0.1"; -import { ensure } from "jsr:@core/unknownutil@^3.18.1"; +import { ensure } from "jsr:@core/unknownutil@^4.0.0/ensure"; import { pop } from "jsr:@lambdalisue/streamtools@^1.0.0"; import { asyncSignal } from "jsr:@milly/async-signal@^1.0.0"; import type { Meta } from "jsr:@denops/core@^7.0.0";