@silen/is-boolean

Check if the parameter is boolean

Usage no npm install needed!

<script type="module">
  import silenIsBoolean from 'https://cdn.skypack.dev/@silen/is-boolean';
</script>

README

is-boolean

Determine if a value is Boolean

install

npm i @silen/is-boolean

api

  • declare function isBoolean(val: any): boolean;

usage

const { isBoolean } = require('@silen/is-boolean');
// or
import { isBoolean } from '@silen/is-boolean';

console.log(isBoolean(new Buffer(4)));
console.log(isBoolean(Buffer.alloc(4)));
console.log(isBoolean(undefined));
console.log(isBoolean(null));
console.log(isBoolean(''));
console.log(isBoolean(true));
console.log(isBoolean(0));
console.log(isBoolean(1));
console.log(isBoolean(1.0));
console.log(isBoolean('string'));
console.log(isBoolean({}));
console.log(isBoolean(function foo() {}));
console.log(isBoolean(Symbol()));
console.log(isBoolean(new Set));
console.log(isBoolean(new Map));
console.log(isBoolean(new WeakMap));
console.log(isBoolean(new WeakSet));

// or
console.log(window.Type.isBoolean(new WeakSet));

This is a demo for testing the usage of isBoolean from @silen/is-boolean module. You can try the others and do likewise.

others