Some functional/semantic codes for TypeScript(JavaScript) development.
npm install tslang-utilsSome functional/semantic codes for TypeScript(JavaScript) development.
- tslang utils
- installation
- type checker
- isDef
- isFunc
- isString
- isNumber
- isStrictNumber
- hasOwnProp
- Env
- isServer
- isBrowser
- License
``bash`
$ yarn add tslang-utils
Whether value isn't undefined or null.
`ts
const a = { name: 'github user', bio: null }
isDef(a.name) // true
isDef(a.age) // false
isDef(a.bio) // false
`
Whether value is Function type
`ts`
isFunc(() => {}) // true
isFunc(true) // false
`ts`
isString('') // true
isString(true) // false
Whether value is Number type. It will omit NaN when we set second parameter to true.
`ts`
isNumber(0) // true
isNumber(NaN) // true
isNumber(NaN, true) // false
Equivalent to isNumber(/ value /, true).
Whether an object has a property with the specified name.
`ts
const a = { name: 'github user', bio: null }
hasOwnProp(a, 'name') // true
hasOwnProp(a, 'toString') // false
`
Whether current JS runtime is in the server(node.js) environment.
`ts`
isSever() // true or false
Whether current JS runtime is in the browser environment.
`ts``
isBrowser() // true or false