Skip to content

chizukicn/maybe-types

Repository files navigation

maybe-types

npm version npm downloads bundle Codecov License JSDocs

A collection of types for Maybe in TypeScript.

Usage

Install package:

# npm
npm install maybe-types

# yarn
yarn add maybe-types

# pnpm
pnpm install maybe-types

Import:

import type { MaybePromise } from "maybe-types";

const fn = async (arg: string): MaybePromise<string> => {
  if (arg === "foo") {
    return "bar";
  }
  return Promise.resolve("baz");
};

const getPromise = async (): Promise<string> => {
  return promise = await fn("foo");
};

Development

  • Clone this repository
  • Install latest LTS version of Node.js
  • Enable Corepack using corepack enable
  • Install dependencies using pnpm install
  • Run interactive tests using pnpm test

License

Made with 💛

Published under MIT License.