diff --git a/.github/workflows/jsr.yml b/.github/workflows/jsr.yml new file mode 100644 index 0000000..2de3f3a --- /dev/null +++ b/.github/workflows/jsr.yml @@ -0,0 +1,27 @@ +name: jsr + +env: + DENO_VERSION: 1.x + +on: + push: + tags: + - "v*" + +permissions: + contents: read + id-token: write + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: denoland/setup-deno@v1 + with: + deno-version: ${{ env.DENO_VERSION }} + - name: Publish + run: | + deno run -A jsr:@david/publish-on-tag@0.1.3 diff --git a/README.md b/README.md index b60191f..1eebd51 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ # unknownutil -[![npm](http://img.shields.io/badge/available%20on-npm-lightgrey.svg?logo=npm&logoColor=white)](https://www.npmjs.com/package/unknownutil) -[![deno land](http://img.shields.io/badge/available%20on-deno.land/x-lightgrey.svg?logo=deno)](https://deno.land/x/unknownutil) +[![jsr](https://img.shields.io/jsr/v/%40core/unknownutil?logo=javascript&logoColor=white)](https://jsr.io/@core/unknownutil) +[![npm](https://img.shields.io/npm/v/unknownutil?logo=npm&logoColor=white)](https://www.npmjs.com/package/unknownutil) +[![denoland](https://img.shields.io/github/v/release/lambdalisue/deno-unknownutil?logo=deno&label=denoland)](https://github.com/lambdalisue/deno-unknownutil/releases) [![deno doc](https://doc.deno.land/badge.svg)](https://doc.deno.land/https/deno.land/x/unknownutil/mod.ts) -[![Test](https://github.com/lambdalisue/deno-unknownutil/workflows/Test/badge.svg)](https://github.com/lambdalisue/deno-unknownutil/actions?query=workflow%3ATest) -[![npm version](https://badge.fury.io/js/unknownutil.svg)](https://badge.fury.io/js/unknownutil) +[![test](https://github.com/lambdalisue/deno-unknownutil/workflows/Test/badge.svg)](https://github.com/lambdalisue/deno-unknownutil/actions?query=workflow%3ATest) [![codecov](https://codecov.io/github/lambdalisue/deno-unknownutil/graph/badge.svg?token=pfbLRGU5AM)](https://codecov.io/github/lambdalisue/deno-unknownutil) A utility pack for handling `unknown` type. diff --git a/deno.jsonc b/deno.jsonc index 31fc387..320f2c3 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -1,4 +1,7 @@ { + "name": "@core/unknownutil", + "version": "0.0.0", + "exports": "./mod.ts", "lock": false, "imports": { "https://deno.land/x/unknownutil@$MODULE_VERSION/": "./" diff --git a/is/_deprecated.ts b/is/_deprecated.ts index fa3b926..5bc7030 100644 --- a/is/_deprecated.ts +++ b/is/_deprecated.ts @@ -1,7 +1,7 @@ import type { UnionToIntersection } from "../_typeutil.ts"; import type { Predicate } from "./type.ts"; -import { type isObjectOf } from "./factory.ts"; -import { type GetMetadata, type WithMetadata } from "../metadata.ts"; +import type { isObjectOf } from "./factory.ts"; +import type { GetMetadata, WithMetadata } from "../metadata.ts"; import { isIntersectionOf, isUnionOf } from "./utility.ts"; type IsObjectOfMetadata = GetMetadata>; diff --git a/is/_deprecated_test.ts b/is/_deprecated_test.ts index 95e802d..8eae5af 100644 --- a/is/_deprecated_test.ts +++ b/is/_deprecated_test.ts @@ -7,7 +7,7 @@ import { } from "https://deno.land/std@0.211.0/testing/snapshot.ts"; import { assertType } from "https://deno.land/std@0.211.0/testing/types.ts"; import { type Equal, stringify } from "./_testutil.ts"; -import { type Predicate, type PredicateType } from "./type.ts"; +import type { Predicate, PredicateType } from "./type.ts"; import { isBoolean, isNumber, isString } from "./core.ts"; import { isObjectOf } from "./factory.ts"; import is, { isAllOf, isOneOf } from "./_deprecated.ts"; diff --git a/is/annotation_test.ts b/is/annotation_test.ts index 7d9307d..ceeed47 100644 --- a/is/annotation_test.ts +++ b/is/annotation_test.ts @@ -7,7 +7,7 @@ import { } from "https://deno.land/std@0.211.0/testing/snapshot.ts"; import { assertType } from "https://deno.land/std@0.211.0/testing/types.ts"; import { type Equal, stringify } from "./_testutil.ts"; -import { type Predicate } from "./type.ts"; +import type { Predicate } from "./type.ts"; import { isArray, isAsyncFunction, diff --git a/is/core_test.ts b/is/core_test.ts index 1e1dfa6..3b15eb9 100644 --- a/is/core_test.ts +++ b/is/core_test.ts @@ -3,7 +3,7 @@ import { assertStrictEquals, } from "https://deno.land/std@0.211.0/assert/mod.ts"; import { stringify } from "./_testutil.ts"; -import { type Predicate } from "./type.ts"; +import type { Predicate } from "./type.ts"; import is, { isAny, isArray, diff --git a/is/factory.ts b/is/factory.ts index aa5506f..a18c467 100644 --- a/is/factory.ts +++ b/is/factory.ts @@ -1,6 +1,6 @@ import type { FlatType } from "../_typeutil.ts"; import type { Predicate, PredicateType } from "./type.ts"; -import { isOptionalOf, isReadonlyOf } from "./annotation.ts"; +import { type isOptionalOf, isReadonlyOf } from "./annotation.ts"; import { isAny, isArray, diff --git a/is/factory_test.ts b/is/factory_test.ts index b31f491..5fea614 100644 --- a/is/factory_test.ts +++ b/is/factory_test.ts @@ -7,7 +7,7 @@ import { } from "https://deno.land/std@0.211.0/testing/snapshot.ts"; import { assertType } from "https://deno.land/std@0.211.0/testing/types.ts"; import { type Equal, stringify } from "./_testutil.ts"; -import { type Predicate } from "./type.ts"; +import type { Predicate } from "./type.ts"; import { isOptionalOf } from "./annotation.ts"; import { isArray, diff --git a/is/utility_test.ts b/is/utility_test.ts index 11ff12e..dfff944 100644 --- a/is/utility_test.ts +++ b/is/utility_test.ts @@ -7,7 +7,7 @@ import { } from "https://deno.land/std@0.211.0/testing/snapshot.ts"; import { assertType } from "https://deno.land/std@0.211.0/testing/types.ts"; import { type Equal, stringify } from "./_testutil.ts"; -import { type Predicate, type PredicateType } from "./type.ts"; +import type { Predicate, PredicateType } from "./type.ts"; import { isOptionalOf } from "./annotation.ts"; import { isBoolean, isNumber, isString, isUndefined } from "./core.ts"; import { isObjectOf } from "./factory.ts"; diff --git a/metadata.ts b/metadata.ts index 1e12571..584173e 100644 --- a/metadata.ts +++ b/metadata.ts @@ -1,13 +1,11 @@ import type { Predicate } from "./is/type.ts"; import { inspect } from "./inspect.ts"; -const metadataKey = "__unknownutil_metadata"; - /** * A type that has metadata. */ export type WithMetadata = { - [metadataKey]: T; + __unknownutil_metadata: T; }; /** @@ -21,7 +19,7 @@ export type GetMetadata = T extends WithMetadata ? M : never; export function getMetadata(v: unknown): T | undefined { if (v == null) return undefined; // deno-lint-ignore no-explicit-any - return (v as any)[metadataKey]; + return (v as any).__unknownutil_metadata; } /** @@ -44,7 +42,7 @@ export function setPredicateFactoryMetadata< ): P & WithMetadata { let cachedName: string | undefined; return Object.defineProperties(pred, { - [metadataKey]: { + __unknownutil_metadata: { value: metadata, configurable: true, },