Package Exports
- @migudevelop/types-utils
- @migudevelop/types-utils/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@migudevelop/types-utils) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
types-utils
A collection of functions to check the types of the values provided.
Table of Contents
Installation
# NPM
pnpm install @migudevelop/types-utils
# NPM
npm install @migudevelop/types-utils
# YARN
yarn add @migudevelop/types-utilsUsage
Using CommonJS
// CommonJS
const typeUtils = require('@migudevelop/types-utils')
console.log(typeUtils.isString('Programming'))Using ES6 Modules or TypeScript:
// ES6 Modules or TypeScript
import { isString } from '@migudevelop/types-utils'
console.log(isString('Programming'))Utilities
Check types
isString(): Determines whether a value is a stringisNumber(): Determines whether a value is a numberisBoolean(): Determines whether a value is a booleanisNull(): Determines whether a value is nullisArray(): Determines whether a value an arrayisFunction(): Determines whether a value is a functionisUndefined(): Determines whether a value is undefinedisNullish(): Determines whether a value is undefined or null
Check empty values
isEmptyString(): Determines whether a value is an empty stringisEmptyArray(): Determines whether a value is an empty array
Ensure values
ensureString(): Determines whether a value is a string and returns it, but otherwise returns an empty stringensureBoolean(): Determines whether a value is a boolean and returns it, but otherwise returns a false valueensureNumber(): Determines whether a value is a number and returns it, but otherwise returns a zero valueensureUndefined(): Determines whether a value is an undefined and returns it, but otherwise returns an undefined valueensureNull(): Determines whether a value is a null and returns it, but otherwise returns a null valueensureArray(): Determines whether a value is an array and returns it, but otherwise returns an empty array
License
Copyright (c) 2024 Migudevelop