Module: yo-utils/lib/app

yo-utils/lib/app

App related utilities

Source:

Methods

<static> flattenConfig(config, delim) → {Object}

Flatten a config object (on an optional delimeter) and return the result

Parameters:
Name Type Description
config Object

the object to be flattened

delim String

the delimeter to join keys on, default: -

Source:
Returns:

the flattened object

Type
Object
Example
var config = {
  'a': {
    'name': 'thing',
    'color': 'blue'
  },
  'b': {
    'name': 'stuff',
    'color': 'red'
  }
};

yoUtils.app.flattenConfig(config);
// → { 'a-name': 'thing', 'a-color': 'blue', 'b-name': 'stuff', 'b-color': 'red'}

<static> nameSuffix(self) → {String}

Return the properly cased app suffix according to options

Parameters:
Name Type Description
self Object

the generator

Source:
Returns:
  • the app's name
Type
String

<static> pluckOps(prefix, ops) → {Object}

Return a set of ops plucked from an options object

Parameters:
Name Type Description
prefix String | RegExp

the prefix to search on and strip

ops Object

the options object to pluck from

Source:
Returns:

the plucked and stripped options

Type
Object
Example
var ops = {
  'a-type': 'a',
  'b-type': 'b',
  'a-value': true,
  'b-value': false
};

yoUtils.app.pluckOps('a-', ops);
// → { 'type': 'a', 'value': ture }

<static> promptWhen(ops) → {function}

Return a variable when function that is bound to a generator's options

Parameters:
Name Type Description
ops Object

the generator's options object

Source:
Returns:

the variable when function when(option, [previousAnswer, ...])

Type
function