Skip to content

Commit

Permalink
Merge pull request #64 from lambdalisue/jsr
Browse files Browse the repository at this point in the history
☕ Support JSR
  • Loading branch information
lambdalisue authored Apr 6, 2024
2 parents a4b91de + 024b8dd commit 92c763d
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 17 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/jsr.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
3 changes: 3 additions & 0 deletions deno.jsonc
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"name": "@core/unknownutil",
"version": "0.0.0",
"exports": "./mod.ts",
"lock": false,
"imports": {
"https://deno.land/x/unknownutil@$MODULE_VERSION/": "./"
Expand Down
4 changes: 2 additions & 2 deletions is/_deprecated.ts
Original file line number Diff line number Diff line change
@@ -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<ReturnType<typeof isObjectOf>>;
Expand Down
2 changes: 1 addition & 1 deletion is/_deprecated_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from "https://deno.land/[email protected]/testing/snapshot.ts";
import { assertType } from "https://deno.land/[email protected]/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";
Expand Down
2 changes: 1 addition & 1 deletion is/annotation_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from "https://deno.land/[email protected]/testing/snapshot.ts";
import { assertType } from "https://deno.land/[email protected]/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,
Expand Down
2 changes: 1 addition & 1 deletion is/core_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
assertStrictEquals,
} from "https://deno.land/[email protected]/assert/mod.ts";
import { stringify } from "./_testutil.ts";
import { type Predicate } from "./type.ts";
import type { Predicate } from "./type.ts";
import is, {
isAny,
isArray,
Expand Down
2 changes: 1 addition & 1 deletion is/factory.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 1 addition & 1 deletion is/factory_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from "https://deno.land/[email protected]/testing/snapshot.ts";
import { assertType } from "https://deno.land/[email protected]/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,
Expand Down
2 changes: 1 addition & 1 deletion is/utility_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from "https://deno.land/[email protected]/testing/snapshot.ts";
import { assertType } from "https://deno.land/[email protected]/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";
Expand Down
8 changes: 3 additions & 5 deletions metadata.ts
Original file line number Diff line number Diff line change
@@ -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<T> = {
[metadataKey]: T;
__unknownutil_metadata: T;
};

/**
Expand All @@ -21,7 +19,7 @@ export type GetMetadata<T> = T extends WithMetadata<infer M> ? M : never;
export function getMetadata<T>(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;
}

/**
Expand All @@ -44,7 +42,7 @@ export function setPredicateFactoryMetadata<
): P & WithMetadata<M> {
let cachedName: string | undefined;
return Object.defineProperties(pred, {
[metadataKey]: {
__unknownutil_metadata: {
value: metadata,
configurable: true,
},
Expand Down

0 comments on commit 92c763d

Please sign in to comment.