UNPKG

datum-focus

Version:

Data shape, model, metadata, JSON, JSON Schema, GraphQL, MongoDB query and aggregations, iterator generators

34 lines (24 loc) 912 B
// <reference types="../../typings/number" /> // <reference types="../../typings/record" /> // <reference types="../../typings/string" /> import { isNull, Nil } from './maybe'; export const DICTIONARY = "dictionary"; export const RECORD = "record"; export type RecordType = typeof RECORD; export type Known = | KnownRecord | [Known, ...Known[]] | Known[] | bigint | Date | number | string | boolean | null; export interface KnownRecord extends Record<string, Known> {} export const isEmpty = (val: unknown): val is Nil => val == null || (isObject(val) && Object.keys(val).length === 0); export const isObject = (val: unknown): val is Record<string, any> => val === Object(val); export const isPrimitive = (val: unknown): boolean => Object(val) !== val; export const isPlainObject = (val: unknown): val is KnownRecord => !isNull(val) && isObject(val) && val.constructor === Object;