UNPKG

@segment/analytics-core

Version:

This package represents core 'shared' functionality that is shared by analytics packages. This is not designed to be used directly, but internal to analytics-node and analytics-browser.

24 lines (19 loc) 590 B
export function isString(obj: unknown): obj is string { return typeof obj === 'string' } export function isNumber(obj: unknown): obj is number { return typeof obj === 'number' } export function isFunction(obj: unknown): obj is Function { return typeof obj === 'function' } export function exists<T>(val: unknown): val is NonNullable<T> { return val !== undefined && val !== null } export function isPlainObject( obj: unknown ): obj is Record<string | symbol | number, unknown> { return ( Object.prototype.toString.call(obj).slice(8, -1).toLowerCase() === 'object' ) }