UNPKG

@atlaskit/adf-utils

Version:

Set of utilities to traverse, modify and create ADF documents.

20 lines (17 loc) 932 B
export const isDefined = x => x != null; export const isNumber = x => typeof x === 'number' && !isNaN(x) && isFinite(x); export const isInteger = x => typeof x === 'number' && isFinite(x) && Math.floor(x) === x; export const isBoolean = x => x === true || x === false || toString.call(x) === '[object Boolean]'; // This is a kludge, might replace with something like _.isString in future export const isString = s => typeof s === 'string' || s instanceof String; export const isPlainObject = x => typeof x === 'object' && x !== null && !Array.isArray(x); // Ignored via go/ees005 // eslint-disable-next-line @typescript-eslint/no-explicit-any export const copy = (source, dest, key) => { // Ignored via go/ees005 // eslint-disable-next-line @typescript-eslint/no-explicit-any dest[key] = source[key]; return dest; }; // Helpers export const makeArray = maybeArray => Array.isArray(maybeArray) ? maybeArray : [maybeArray];