TypeScript-first is function collection
This is a very small collection of is? functions.
Some of them contain wrappers for typeof
statements, which may be used to
reduce the number of repeated expressions and thus reduce the bundle size.
import { isString } from "https://deno.land/x/isx";
npm i isxx
yarn add isxx
pnpm add isxx
Whatever argument is type of boolean
or not
declare const isBoolean: (val: unknown) => val is boolean;
isBoolean(true); // true
isBoolean("hello"); // false
Whatever argument length is 0
or not.
declare const isLength0: (val: { length: number }) => boolean;
isLength0([]); // true
isLength0("hello"); // false
Whatever argument is type of string
or not
declare const isString: (val: unknown) => val is string;
isString("hello world"); // true
isString(1000); // false
Whatever argument is type of number
or not
declare const isNumber: (val: unknown) => val is number;
isNumber(0); // true
isNumber("hello"); // false
Contributions, issues and feature requests are welcome!
Feel free to check
issues.
Give a ⭐️ if this project helped you!
Copyright © 2021-present TomokiMiyauci.
Released under the MIT license