Sha256: fcc003b658c2b7236c3f0b5c4edab5aeca19227a33b7bb2058b7ba03b51de21b

Contents?: true

Size: 1.28 KB

Versions: 17

Compression:

Stored size: 1.28 KB

Contents

const { stringify } = require('flatted/cjs')

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

17 entries across 17 versions & 5 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/@rails/webpacker/package/utils/helpers.js
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/@rails/webpacker/package/utils/helpers.js
webpacker-4.3.0 package/utils/helpers.js
enju_library-0.3.8 spec/dummy/node_modules/@rails/webpacker/package/utils/helpers.js
webpacker-5.1.1 package/utils/helpers.js
webpacker-5.1.0 package/utils/helpers.js
webpacker-5.0.1 package/utils/helpers.js
webpacker-5.0.0 package/utils/helpers.js
jetpacker-0.4.2 package/utils/helpers.js
jetpacker-0.4.1 package/utils/helpers.js
jetpacker-0.4.0 package/utils/helpers.js
jetpacker-0.3.0 package/utils/helpers.js
jetpacker-0.2.0 package/utils/helpers.js
webpacker-4.2.2 package/utils/helpers.js
webpacker-4.2.1 package/utils/helpers.js
webpacker-4.2.0 package/utils/helpers.js
webpacker-4.1.0 package/utils/helpers.js