Sha256: cf27554eb5addda3cfcb499cf3b80e750298abfaf7d2cb6b1a9ac5c3cc098bb4

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

const isObject = value => typeof value === 'object'
  && value !== null
  && (value.length === undefined || value.length === null)

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) => JSON.stringify(target) === JSON.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())

module.exports = {
  chdirTestApp,
  chdirCwd,
  isObject,
  isBoolean,
  isArray,
  isEqual,
  isEmpty,
  isStrPath,
  canMerge,
  prettyPrint
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
webpacker-4.0.0.pre.3 package/utils/helpers.js