Add is.directInstanceOf() (#38)

This commit is contained in:
Brandon Smith 2017-12-09 11:55:08 -05:00 committed by GitHub
parent 4ce2ee9d39
commit 70b08940be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 0 deletions

View file

@ -162,6 +162,10 @@ namespace is { // tslint:disable-line:no-namespace
export const arrayBuffer = isObjectOfType(TypeName.ArrayBuffer);
export const sharedArrayBuffer = isObjectOfType(TypeName.SharedArrayBuffer);
// TODO: Remove `object` checks when targeting ES2015 or higher
// See `Notes`: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf
export const directInstanceOf = (instance: any, klass: any) => object(instance) && object(klass) && Object.getPrototypeOf(instance) === klass.prototype;
export const truthy = (value: any) => Boolean(value);
export const falsy = (value: any) => !value;