Exemplo n.º 1
0
handlebars.registerHelper('propType', function types(prop) {
  !prop.type && console.log(prop)
  var type = prop.type
    , name = type.name
    , doclets = metadata.parseDoclets(prop.desc || '') || {};

  switch (name){
    case 'object':
      if( type.value )
        return 'object: ' + displayObj(transform(type.value, function(obj, val, key){
          obj[key] = types(val)
        }, {}))

      return name
    case 'union':
      return type.value.map(function(val){
        return types({ type: val })
      }).join(', ')

    case 'array':
      return 'array<' + type.value.name + '>'
    case 'enum':
      return 'enum<' + type.value.join(', ') + '>'
    case 'custom':
      return cleanDocletValue(doclets.type || name)
    default:
      return name
  }
})
Exemplo n.º 2
0
/**
 * Returns a list of { text: ... }, { url: ... } parts extracted
 * from the given text.
 *
 * @param {Array<Object>|String} parts
 *
 * @return {Array<Object>}
 */
function extractUrls(parts) {

  if (typeof parts === 'string') {
    parts = [ {
      text: parts
    } ];
  }

  return transform(parts, function(newParts, part) {

    var text = part.text;

    if (text) {
      var urls = text.match(URL_REGEX);

      var lastIdx = 0,
          idx = 0;

      (urls || []).forEach(function(url) {

        idx = text.indexOf(url, lastIdx);

        newParts.push({ text: text.substring(lastIdx, idx) });
        newParts.push({ url: url });

        lastIdx = idx + url.length;
      });

      newParts.push({ text: text.substring(lastIdx) });
    } else {
      newParts.push(part);
    }
  });
}
 compiler.plugin('done', (stats) => {
   if (stats.hasErrors()) {
     emitManifest({
       manifestPath,
       status: 'errors',
       errors: stats.toJson().errors.map(err => stripAnsi(err))
     });
   } else {
     emitManifest({
       manifestPath,
       status: 'built',
       files: transform(stats.compilation.chunks, (files, chunk) => {
         files[chunk.name] = chunk.files.map(file => {
           if (outputPath === '/') {
             return file;
           }
           const absPath = path.join(outputPath, file);
           const relPath = absPath.slice(outputRoot.length);
           if (relPath[0] == path.sep) {
             return relPath.slice(1);
           }
           return relPath;
         });
       }, {})
     });
   }
 });
Exemplo n.º 4
0
    return $scope.$on('$routeUpdate', (event) => {
      let valentEvent = event.$valentEvent;

      let params = this.parse();

      let diff = transform(params, (result, n, key) => {
        // TODO: use cached params instead of state
        let state = this[_state][key];

        if (!isEqual(n, state)) {
          result[key] = n;
        }
      });

      this[_state] = cloneDeep(params);

      callback(params, diff, valentEvent);
    });
Exemplo n.º 5
0
function getProperties(businessObject, propertyNames) {
  return reduce(propertyNames, function(result, key) {
    result[key] = businessObject.get(key);
    return result;
  }, {});
}