Sha256: 9d6df0ac9488138429094b8e1bc0f72dde2df7a471daa7750ee4f575535a8f55
Contents?: true
Size: 1.27 KB
Versions: 29
Compression:
Stored size: 1.27 KB
Contents
const { stringify } = require('flatted') const isObject = (value) => typeof value === 'object' && value !== null && (value.length === undefined || value.length === null) const isNotObject = (value) => !isObject(value) const isBoolean = (str) => /^true/.test(str) || /^false/.test(str) const isEmpty = (value) => value === null || value === undefined const isString = (key) => key && typeof key === 'string' const isStrPath = (key) => { if (!isString(key)) throw new Error(`Key ${key} should be string`) return isString(key) && key.includes('.') } const isArray = (value) => Array.isArray(value) const isEqual = (target, source) => stringify(target) === stringify(source) const canMerge = (value) => isObject(value) || isArray(value) const prettyPrint = (obj) => JSON.stringify(obj, null, 2) const chdirTestApp = () => { try { return process.chdir('test/test_app') } catch (e) { return null } } const chdirCwd = () => process.chdir(process.cwd()) const resetEnv = () => { process.env = {} } const ensureTrailingSlash = (path) => (path.endsWith('/') ? path : `${path}/`) module.exports = { chdirTestApp, chdirCwd, ensureTrailingSlash, isObject, isNotObject, isBoolean, isArray, isEqual, isEmpty, isStrPath, canMerge, prettyPrint, resetEnv }
Version data entries
29 entries across 29 versions & 7 rubygems