@sindresorhus/is
Advanced tools
Comparing version 0.12.0 to 0.13.0
@@ -11,3 +11,3 @@ /// <reference types="node" /> | ||
} | ||
export interface Class<T = any> { | ||
export interface Class<T = unknown> { | ||
new (...args: any[]): T; | ||
@@ -58,75 +58,76 @@ } | ||
} | ||
declare function is(value: any): TypeName; | ||
declare function is(value: unknown): TypeName; | ||
declare namespace is { | ||
const undefined: (value: any) => value is undefined; | ||
const string: (value: any) => value is string; | ||
const number: (value: any) => value is number; | ||
const function_: (value: any) => value is Function; | ||
const null_: (value: any) => value is null; | ||
const class_: (value: any) => value is Class<any>; | ||
const boolean: (value: any) => value is boolean; | ||
const symbol: (value: any) => value is Symbol; | ||
const undefined: (value: unknown) => value is undefined; | ||
const string: (value: unknown) => value is string; | ||
const number: (value: unknown) => value is number; | ||
const function_: (value: unknown) => value is Function; | ||
const null_: (value: unknown) => value is null; | ||
const class_: (value: unknown) => value is Class<unknown>; | ||
const boolean: (value: unknown) => value is boolean; | ||
const symbol: (value: unknown) => value is Symbol; | ||
const numericString: (value: unknown) => boolean; | ||
const array: (arg: any) => arg is any[]; | ||
const buffer: (input: any) => input is Buffer; | ||
const nullOrUndefined: (value: any) => value is null | undefined; | ||
const object: (value: any) => value is object; | ||
const iterable: (value: any) => value is IterableIterator<any>; | ||
const asyncIterable: (value: any) => value is AsyncIterableIterator<any>; | ||
const generator: (value: any) => value is Generator; | ||
const nativePromise: (value: any) => value is Promise<any>; | ||
const promise: (value: any) => value is Promise<any>; | ||
const generatorFunction: (value: any) => value is GeneratorFunction; | ||
const asyncFunction: (value: any) => value is Function; | ||
const boundFunction: (value: any) => value is Function; | ||
const regExp: (value: any) => value is RegExp; | ||
const date: (value: any) => value is Date; | ||
const error: (value: any) => value is Error; | ||
const map: (value: any) => value is Map<any, any>; | ||
const set: (value: any) => value is Set<any>; | ||
const weakMap: (value: any) => value is WeakMap<any, any>; | ||
const weakSet: (value: any) => value is WeakSet<any>; | ||
const int8Array: (value: any) => value is Int8Array; | ||
const uint8Array: (value: any) => value is Uint8Array; | ||
const uint8ClampedArray: (value: any) => value is Uint8ClampedArray; | ||
const int16Array: (value: any) => value is Int16Array; | ||
const uint16Array: (value: any) => value is Uint16Array; | ||
const int32Array: (value: any) => value is Int32Array; | ||
const uint32Array: (value: any) => value is Uint32Array; | ||
const float32Array: (value: any) => value is Float32Array; | ||
const float64Array: (value: any) => value is Float64Array; | ||
const arrayBuffer: (value: any) => value is ArrayBuffer; | ||
const sharedArrayBuffer: (value: any) => value is SharedArrayBuffer; | ||
const dataView: (value: any) => value is DataView; | ||
const directInstanceOf: <T>(instance: any, klass: Class<T>) => instance is T; | ||
const urlInstance: (value: any) => value is URL; | ||
const truthy: (value: any) => boolean; | ||
const falsy: (value: any) => boolean; | ||
const nan: (value: any) => boolean; | ||
const primitive: (value: any) => value is Primitive; | ||
const integer: (value: any) => value is number; | ||
const safeInteger: (value: any) => value is number; | ||
const plainObject: (value: any) => boolean; | ||
const typedArray: (value: any) => value is TypedArray; | ||
const arrayLike: (value: any) => value is ArrayLike; | ||
const buffer: (input: unknown) => input is Buffer; | ||
const nullOrUndefined: (value: unknown) => value is null | undefined; | ||
const object: (value: unknown) => value is object; | ||
const iterable: (value: unknown) => value is IterableIterator<unknown>; | ||
const asyncIterable: (value: unknown) => value is AsyncIterableIterator<unknown>; | ||
const generator: (value: unknown) => value is Generator; | ||
const nativePromise: (value: unknown) => value is Promise<unknown>; | ||
const promise: (value: unknown) => value is Promise<unknown>; | ||
const generatorFunction: (value: unknown) => value is GeneratorFunction; | ||
const asyncFunction: (value: unknown) => value is Function; | ||
const boundFunction: (value: unknown) => value is Function; | ||
const regExp: (value: unknown) => value is RegExp; | ||
const date: (value: unknown) => value is Date; | ||
const error: (value: unknown) => value is Error; | ||
const map: (value: unknown) => value is Map<unknown, unknown>; | ||
const set: (value: unknown) => value is Set<unknown>; | ||
const weakMap: (value: unknown) => value is WeakMap<object, unknown>; | ||
const weakSet: (value: unknown) => value is WeakSet<object>; | ||
const int8Array: (value: unknown) => value is Int8Array; | ||
const uint8Array: (value: unknown) => value is Uint8Array; | ||
const uint8ClampedArray: (value: unknown) => value is Uint8ClampedArray; | ||
const int16Array: (value: unknown) => value is Int16Array; | ||
const uint16Array: (value: unknown) => value is Uint16Array; | ||
const int32Array: (value: unknown) => value is Int32Array; | ||
const uint32Array: (value: unknown) => value is Uint32Array; | ||
const float32Array: (value: unknown) => value is Float32Array; | ||
const float64Array: (value: unknown) => value is Float64Array; | ||
const arrayBuffer: (value: unknown) => value is ArrayBuffer; | ||
const sharedArrayBuffer: (value: unknown) => value is SharedArrayBuffer; | ||
const dataView: (value: unknown) => value is DataView; | ||
const directInstanceOf: <T>(instance: unknown, klass: Class<T>) => instance is T; | ||
const urlInstance: (value: unknown) => value is URL; | ||
const truthy: (value: unknown) => boolean; | ||
const falsy: (value: unknown) => boolean; | ||
const nan: (value: unknown) => boolean; | ||
const primitive: (value: unknown) => value is Primitive; | ||
const integer: (value: unknown) => value is number; | ||
const safeInteger: (value: unknown) => value is number; | ||
const plainObject: (value: unknown) => boolean; | ||
const typedArray: (value: unknown) => value is TypedArray; | ||
const arrayLike: (value: unknown) => value is ArrayLike; | ||
const inRange: (value: number, range: number | number[]) => boolean; | ||
const domElement: (value: any) => value is DomElement; | ||
const observable: (value: any) => boolean; | ||
const nodeStream: (value: any) => value is NodeStream; | ||
const infinite: (value: any) => boolean; | ||
const domElement: (value: unknown) => value is DomElement; | ||
const observable: (value: unknown) => boolean; | ||
const nodeStream: (value: unknown) => value is NodeStream; | ||
const infinite: (value: unknown) => boolean; | ||
const even: (value: number) => boolean; | ||
const odd: (value: number) => boolean; | ||
const emptyArray: (value: any) => boolean; | ||
const nonEmptyArray: (value: any) => boolean; | ||
const emptyString: (value: any) => boolean; | ||
const nonEmptyString: (value: any) => boolean; | ||
const emptyStringOrWhitespace: (value: any) => boolean; | ||
const emptyObject: (value: any) => boolean; | ||
const nonEmptyObject: (value: any) => boolean; | ||
const emptySet: (value: any) => boolean; | ||
const nonEmptySet: (value: any) => boolean; | ||
const emptyMap: (value: any) => boolean; | ||
const nonEmptyMap: (value: any) => boolean; | ||
const any: (predicate: any, ...values: any[]) => any; | ||
const all: (predicate: any, ...values: any[]) => any; | ||
const emptyArray: (value: unknown) => boolean; | ||
const nonEmptyArray: (value: unknown) => boolean; | ||
const emptyString: (value: unknown) => boolean; | ||
const nonEmptyString: (value: unknown) => boolean; | ||
const emptyStringOrWhitespace: (value: unknown) => boolean; | ||
const emptyObject: (value: unknown) => boolean; | ||
const nonEmptyObject: (value: unknown) => boolean; | ||
const emptySet: (value: unknown) => boolean; | ||
const nonEmptySet: (value: unknown) => boolean; | ||
const emptyMap: (value: unknown) => boolean; | ||
const nonEmptyMap: (value: unknown) => boolean; | ||
const any: (predicate: unknown, ...values: unknown[]) => any; | ||
const all: (predicate: unknown, ...values: unknown[]) => any; | ||
} | ||
export default is; |
@@ -64,2 +64,3 @@ "use strict"; | ||
(function (is) { | ||
// tslint:disable-next-line:strict-type-predicates | ||
const isObject = (value) => typeof value === 'object'; | ||
@@ -71,2 +72,3 @@ // tslint:disable:variable-name | ||
is.function_ = isOfType('function'); | ||
// tslint:disable-next-line:strict-type-predicates | ||
is.null_ = (value) => value === null; | ||
@@ -77,2 +79,3 @@ is.class_ = (value) => is.function_(value) && value.toString().startsWith('class '); | ||
// tslint:enable:variable-name | ||
is.numericString = (value) => is.string(value) && value.length > 0 && !Number.isNaN(Number(value)); | ||
is.array = Array.isArray; | ||
@@ -79,0 +82,0 @@ is.buffer = isBuffer; |
{ | ||
"name": "@sindresorhus/is", | ||
"version": "0.12.0", | ||
"version": "0.13.0", | ||
"description": "Type check values: `is.string('🦄') //=> true`", | ||
@@ -61,3 +61,3 @@ "license": "MIT", | ||
"tslint-xo": "^0.9.0", | ||
"typescript": "^3.1.1", | ||
"typescript": "^3.1.4", | ||
"zen-observable": "^0.8.8" | ||
@@ -64,0 +64,0 @@ }, |
@@ -99,2 +99,8 @@ # is [![Build Status](https://travis-ci.org/sindresorhus/is.svg?branch=master)](https://travis-ci.org/sindresorhus/is) | ||
##### .numericString(value) | ||
Returns `true` for a string that represents a number. For example, `'42'` and `'-8'`. | ||
Note: `'NaN'` return `false`, but `'Infinity'` and `'-Infinity'` return `true`. | ||
##### .regExp(value) | ||
@@ -236,3 +242,3 @@ ##### .date(value) | ||
class UnicornError extends Error {}; | ||
class UnicornError extends Error {} | ||
@@ -290,3 +296,3 @@ is.directInstanceOf(new UnicornError(), Error); | ||
Returns `true` for instances created by a ES2015 class. | ||
Returns `true` for instances created by a class. | ||
@@ -303,6 +309,7 @@ ##### .typedArray(value) | ||
function () { | ||
is.arrayLike(arguments); | ||
//=> true | ||
function foo() { | ||
is.arrayLike(arguments); | ||
//=> true | ||
} | ||
foo(); | ||
``` | ||
@@ -338,2 +345,3 @@ | ||
const fs = require('fs'); | ||
is.nodeStream(fs.createReadStream('unicorn.png')); | ||
@@ -349,2 +357,3 @@ //=> true | ||
const {Observable} = require('rxjs'); | ||
is.observable(new Observable()); | ||
@@ -351,0 +360,0 @@ //=> true |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38801
353
436