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

Version Path
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/webpacker-5.4.4/package/utils/helpers.js
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/webpacker-5.4.4/package/utils/helpers.js
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/webpacker-5.4.4/package/utils/helpers.js
jetpacker-0.7.0 package/utils/helpers.js
webpacker-5.4.4 package/utils/helpers.js
jetpacker-0.6.0 package/utils/helpers.js
disco_app-0.16.1 test/dummy/node_modules/@rails/webpacker/package/utils/helpers.js
disco_app-0.15.2 test/dummy/node_modules/@rails/webpacker/package/utils/helpers.js
disco_app-0.18.4 test/dummy/node_modules/@rails/webpacker/package/utils/helpers.js
disco_app-0.18.1 test/dummy/node_modules/@rails/webpacker/package/utils/helpers.js
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/@rails/webpacker/package/utils/helpers.js
disco_app-0.14.0 test/dummy/node_modules/@rails/webpacker/package/utils/helpers.js
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/@rails/webpacker/package/utils/helpers.js
webpacker-5.4.3 package/utils/helpers.js
webpacker-5.4.2 package/utils/helpers.js
webpacker-5.4.1 package/utils/helpers.js
webpacker-5.4.0 package/utils/helpers.js
webpacker-5.3.0 package/utils/helpers.js
webpacker-5.2.2 package/utils/helpers.js
tang-0.2.1 spec/tang_app/node_modules/@rails/webpacker/package/utils/helpers.js