ensure-type

Ensure runtime type safety and perform type coercion if needed.

Usage no npm install needed!

<script type="module">
  import ensureType from 'https://cdn.skypack.dev/ensure-type';
</script>

README

ensure-type Build Status Coverage Status

NPM

Ensure runtime type safety and perform type coercion if needed.

Install

$ npm install --save ensure-type

Usage

import { ensureArray } from 'ensure-type';

ensureArray(null);
//=> []

ensureArray('apple');
//=> ['apple']

ensureArray(['apple', 'banana']);
//=> ['apple', 'banana']

API

Array

BigInt

Boolean

Function

Number

Object

String

License

MIT