JSPM

tidytype

1.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q25556F
  • License MIT

Expanded type recognition of native JS typeof

Package Exports

  • tidytype

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 (tidytype) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

TidyType

Same as native function typeof but:

How to use

Prerequisites

None

Parameters

val - variable or value of which to return type

Example

//Undefined type
valType() //'undefined'
valType(undefined) //'undefined'

//Number type
valType(0) //'number'
valType(1) //'number'

//NaN type
valType(NaN) //'NaN'

//String type
valType('helloworld') //'string'
valType('') //'string'

//Boolean type
valType(true) //'boolean'
valType(false) //'boolean'

//Function type
valType(function(){}) //'function'

//Object type
valType({}) //'object'

//Array type
valType([]) //'array'

//Null type
valType(null) //'null'

//Regex type
valType(/hello/) //'regex'

//Native arguments object type
var foo = function foo(bar){
    return valType(arguments);
}
foo(1) //'arguments'
});