1.0.14 • Published 4 years ago

ts-predicates v1.0.14

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

ts-predicates

Build Status Coverage Status npm version

Description:

A collection of predicate functions and utilities for creating new predicate functions in TypeScript. JavaScript UMD and TypeScript declaration file will be generated when building the package.

Installation:

npm install ts-predicates

Usage:

import { 
    isBoolean,
    isNotBoolean,
    isString,
    isNotString,
    isNumber,
    isNotNumber,
    isDefined,
    isUndefined,
    isNull,
    isNotNull,
    isObject,
    isNotObject,
    isPlainObject,
    isNotPlainObject,
    isArray,
    isNotArray,
    isEmptyArray,
    isNonEmptyArray,
    isFunction,
    isNotFunction,
    isTrue,
    isFalse,
    isTruthy,
    isFalsy,
    isDate,
    isNotDate,
    isRegExp,
    isNotRegExp,
    isSymbol,
    isNotSymbol,
    isEqual,
    isNotEqual
 } from 'ts-predicates';

// ...

isBoolean({})                  // false
isNotBoolean({})               // true
isString('foo')                // true
isNotString('foo')             // false
isNumber(5)                    // true
isNotNumber('foo')             // true
isDefined([])                  // true
isUndefined({})                // false
isNull(null)                   // true
isNotNull(null)                // false
isObject({})                   // true
isNotObject({})                // false
isPlainObject(new Array())     // false
isNotPlainObject(new Date())   // true
isArray([])                    // true
isNotArray([])                 // false
isEmptyArray([])               // true
isNonEmptyArray([])            // false
isFunction(() => {})           // true
isNotFunction(() => {})        // false
isTrue(1)                      // false
isFalse(false)                 // true
isTruthy(1)                    // true
isFalsy(0)                     // true
isDate(new Date())             // true
isNotDate(new Date())          // false
isRegExp(new RegExp(''))       // true
isNotRegExp(new RegExp(''))    // false
isSymbol(Symbol())             // true
isNotSymbol(Symbol())          // false
isEqual(1)(1)                  // true
isNotEqual({a: 1})({})         // true
1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago