How to use the check-more-types.array function in check-more-types

To help you get started, we’ve selected a few check-more-types examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bahmutov / rambo / src / derive-functions.js View on Github external
if (f.f === R.append) {
    const allValues = grab.everything(examples)
    la(is.array(allValues), 'could not grab values from', examples)
    return allValues.map((value) => {
      const s = is.string(value) ? `'${value}'` : value
      return {
        f: f.f(value),
        name: `${f.name}(${s})`
      }
    })
  }

  if (f.f === R.split) {
    const strings = grab.strings(examples)

    la(is.array(strings), 'expected list of strings from', examples, strings)
    const characters = R.uniq(strings.join('').split(''))
    // console.log('characters', characters)
    return characters.map((sep) => {
      return {
        f: f.f(sep),
        name: `${f.name}('${sep}')`
      }
    })
  }

  return []
}
github bahmutov / snap-shot-core / src / prune.js View on Github external
const pruneSnapshotsInObject = (runtimeSnapshots, snapshots) => {
  la(is.array(runtimeSnapshots), 'invalid runtime snapshots', runtimeSnapshots)
  runtimeSnapshots.forEach((r, k) => {
    la(isRunTimeSnapshot(r), 'invalid runtime snapshot', r, 'at index', k)
  })

  const keys = R.map(R.prop('key'), runtimeSnapshots)
  debug(
    'have runtime %s before pruning',
    pluralize('snapshot name', keys.length, true)
  )
  if (debug.enabled) {
    // make sure NOT to mutate the list of snapshot names
    // otherwise we will save the pruned object with keys
    // in the sorted order!
    debug(keys)
    debug('snapshot file keys in the current order')
    debug(R.keys(snapshots))
github bahmutov / rocha / src / order-of-tests.js View on Github external
function setTestOrder (suite, tests, titles) {
  la(is.array(tests), 'invalid tests', tests)
  la(is.array(titles), 'invalid titles', titles)

  const orderedTests = []
  titles.forEach(title => {
    const test = _.find(tests, { title: title })
    if (!test) {
      log('cannot find test under title', title, 'skipping')
      return
    }
    la(test, 'could not find test with title', title,
      'among', tests, 'in', suite.fullTitle())
    orderedTests.push(test)
  })
  const newTests = _.difference(tests, orderedTests)
  suite.tests = orderedTests.concat(newTests)
}
github bahmutov / next-updater / src / update-npm-modules.js View on Github external
.then(function (modules) {
      la(check.array(modules), 'expected list of NPM modules', modules);
      console.log('user', quote(username), 'has', modules.length, 'NPM modules');
      return modules;
    })
    .then(toNames)
github bahmutov / web-packing / install-and-bundle.js View on Github external
function installAndBundle (...allNames) {
  const names = allNames.filter(is.unemptyString)
  la(is.array(names), 'expected list of names', names)
  la(is.not.empty(names), 'expected at least 1 name', names)
  console.log('install and bundling names', names)

  const times = []
  const timestamp = () => times.push(+(new Date()))
  timestamp()

  const slug = safeName(names)
  la(is.unemptyString(slug), 'could not slufigy', names)
  const bundleFilename = slug + '.js'
  const madeName = path.join(os.tmpdir(), bundleFilename)
  if (fs.existsSync(madeName)) {
    console.log('returning existing bundle file', madeName)
    const bundle = fs.readFileSync(madeName, 'utf8')
    timestamp()
github bahmutov / next-updater / src / update-user-repos.js View on Github external
function getReposPage(ghuser, k, allRepos) {
  la(check.positiveNumber(k), 'invalid repos page index', k);
  allRepos = allRepos || [];

  la(check.array(allRepos), 'expected all repos to be an array', allRepos);

  var defer = q.defer();

  console.log('fetching repos page', k);
  var perPage = 100;

  ghuser.repos(k, perPage, function (err, repos) {
    if (err) {
      console.error(err);
      defer.resolve(allRepos);
      return;
    }
    if (!check.array(repos) || repos.length === 0) {
      console.log('no repos at page', k, 'have', allRepos.length, 'total repos');
      defer.resolve(allRepos);
      return;
github bahmutov / data-cover / src / utils.js View on Github external
function toComments (lines) {
  la(is.array(lines), 'invalid lines', lines)
  return '/*\n' + lines.join('\n') + '\n*/\n'
}
github bahmutov / next-update / src / next-update.js View on Github external
function isSingleItem (names) {
  return names &&
        check.array(names) &&
        names.length === 1
}
github bahmutov / rambo / src / index.js View on Github external
}
      })
    }

    if (f.f === R.add || f.f === R.subtract || f.f === R.gt) {
      return firstValues.map((x) => {
        return {
          f: f.f(x),
          name: `${f.name}(${x})`
        }
      })
    }

    if (f.f === R.has) {
      const propertyNames = grabProperties(examples)
      la(is.array(propertyNames), 'could not grab property names from', examples)
      return propertyNames.map((property) => {
        return {
          f: f.f(property),
          name: `${f.name}('${property}')`
        }
      })
    }

    if (f.f === R.append) {
      const allValues = grabEverything(examples)
      la(is.array(allValues), 'could not grab values from', examples)
      return allValues.map((value) => {
        const s = is.string(value) ? `'${value}'` : value
        return {
          f: f.f(value),
          name: `${f.name}(${s})`
github bahmutov / generator-node-bahmutov / app / github-username.js View on Github external
function usernameFromGithubUrl (url) {
  la(is.unemptyString(url), 'expected url string', url)

  const parsed = parse(url)
  la(is.array(parsed), 'could not parse github url', url)
  return parsed[0]
}