UNPKG

@atlaskit/adf-utils

Version:

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

42 lines (38 loc) 1.67 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.makeArray = exports.isString = exports.isPlainObject = exports.isNumber = exports.isInteger = exports.isDefined = exports.isBoolean = exports.copy = void 0; var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")); var isDefined = exports.isDefined = function isDefined(x) { return x != null; }; var isNumber = exports.isNumber = function isNumber(x) { return typeof x === 'number' && !isNaN(x) && isFinite(x); }; var isInteger = exports.isInteger = function isInteger(x) { return typeof x === 'number' && isFinite(x) && Math.floor(x) === x; }; var isBoolean = exports.isBoolean = function isBoolean(x) { return x === true || x === false || toString.call(x) === '[object Boolean]'; }; // This is a kludge, might replace with something like _.isString in future var isString = exports.isString = function isString(s) { return typeof s === 'string' || s instanceof String; }; var isPlainObject = exports.isPlainObject = function isPlainObject(x) { return (0, _typeof2.default)(x) === 'object' && x !== null && !Array.isArray(x); }; // Ignored via go/ees005 // eslint-disable-next-line @typescript-eslint/no-explicit-any var copy = exports.copy = function copy(source, dest, key) { // Ignored via go/ees005 // eslint-disable-next-line @typescript-eslint/no-explicit-any dest[key] = source[key]; return dest; }; // Helpers var makeArray = exports.makeArray = function makeArray(maybeArray) { return Array.isArray(maybeArray) ? maybeArray : [maybeArray]; };