isx

TypeScript-first is function collection

test GitHub release deno doc npm download

GitHub (Pre-)Release Date dependencies Status codecov Codacy Badge npm type definitions Commitizen friendly Gitmoji semantic-release License: MIT

What

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.

Install

Deno

import { isString } from "https://deno.land/x/isx";

Node.js

npm i isxx
yarn add isxx
pnpm add isxx

API

isBoolean

Whatever argument is type of boolean or not

types

declare const isBoolean: (val: unknown) => val is boolean;

examples

isBoolean(true); // true
isBoolean("hello"); // false

isLength0

Whatever argument length is 0 or not.

types

declare const isLength0: (val: { length: number }) => boolean;

examples

isLength0([]); // true
isLength0("hello"); // false

isString

Whatever argument is type of string or not

types

declare const isString: (val: unknown) => val is string;

examples

isString("hello world"); // true
isString(1000); // false

isNumber

Whatever argument is type of number or not

types

declare const isNumber: (val: unknown) => val is number;

examples

isNumber(0); // true
isNumber("hello"); // false

🤝 Contributing

Contributions, issues and feature requests are welcome!
Feel free to check issues.

🌱 Show your support

Give a ⭐️ if this project helped you!

💡 License

Copyright © 2021-present TomokiMiyauci.

Released under the MIT license