where-type
TypeScript icon, indicating that this package has built-in type declarations

1.2.15 • Public • Published

where-type

introduce

  1. judge assign data type
  2. computed get assign data type
  3. support import method: cjs and esm and iife

install

  1. npm install where-type -S
  2. yarn add where-type -S
  3. pnpm install where-type -S

use

const {isNumber, isString, getTypes} = require('where-type')
const _ = require("where-type");
isNumber(1) // true
isNumber('1') // false
isString('1') // true
getTypes(1) // [number]
getTypes([1, '1']) // [number, string]

// OR

import types, {isNumber} from 'where-type'

types.isNumber(1) // true
isNumber(1) // true

global api

  isNumber,
  isBoolean,
  isNull,
  isString,
  isObject,
  isUndefined,
  isFunction,
  isArray,
  isDate,
  isError,
  isRegExp,
  isSymbol,
  isMath,
  isJson,
  isEmpty,
  isEmptyString,
  getTypes
    parameter: string or array
    if parameter is any vlaue, return type is string[]
      getTypes('1') // [string]
    is parameter is array, Type is returned in an array 
      getTypes([1, '2', false]) // [number, string, boolean]

Package Sidebar

Install

npm i where-type

Weekly Downloads

2

Version

1.2.15

License

MIT

Unpacked Size

5.6 kB

Total Files

6

Last publish

Collaborators

  • lihh