Example #1
0
  InstancePacker.prototype.isBundled = function (name) {
    var bd = this.package && this.package.bundleDependencies
    if (!bd) return false

    if (!Array.isArray(bd)) {
      throw new Error(this.package.name + '\'s `bundledDependencies` should ' +
                      'be an array')
    }
    if (!tree) return false

    if (bd.indexOf(name) !== -1) return true
    var pkg = tree.children.filter(nameMatch(name))[0]
    if (!pkg) return false
    var requiredBy = union([], pkg.package._requiredBy)
    var seen = {}
    while (requiredBy.length) {
      var req = requiredBy.shift()
      if (seen[req]) continue
      seen[req] = true
      var reqPkg = flatTree[req]
      if (!reqPkg) continue
      if (reqPkg.parent === tree && bd.indexOf(reqPkg.package.name) !== -1) {
        return true
      }
      requiredBy = union(requiredBy, reqPkg.package._requiredBy)
    }
    return false
  }
util.findConnectedPatterns = function (graphPattern) {
  // Zero or single-triple patterns have exactly one cluster
  if (graphPattern.length <= 1)
    return [graphPattern];

  // Initially consider all individual triple patterns as disconnected clusters
  var clusters = graphPattern.map(function (triple) {
    return {
      triples:  [triple],
      variables: _.values(triple).filter(util.isVariableOrBlank),
    };
  }), commonVar;

  // Continue clustering as long as different clusters have common variables
  do {
    // Find a variable that occurs in more than one subpattern
    var allVariables = _.flatten(_.pluck(clusters, 'variables'));
    if (commonVar = _.find(allVariables, hasDuplicate)) {
      // Partition the subpatterns by whether they contain that common variable
      var hasCommon = _.groupBy(clusters,
                                function (c) { return _.contains(c.variables, commonVar); });
      // Replace the subpatterns with a common variable by a subpattern that combines them
      clusters = hasCommon[false] || [];
      clusters.push({
        triples:   _.union.apply(_, _.pluck(hasCommon[true], 'triples')),
        variables: _.union.apply(_, _.pluck(hasCommon[true], 'variables')),
      });
    }
  } while (commonVar);

  // The subpatterns consist of the triples of each cluster
  return _.pluck(clusters, 'triples');
};
Example #3
0
File: data.js Project: crubier/iii
var computeData = function(theData) {
  if(theData.type==="DataOperation") {
    switch  (theData.operator) {
      case 'union' :
        if(_.every(theData.operand,"type","DataComposite")) {
          return {
            type:"DataComposite",
            element:_.sortBy(_.unique(_.union.apply(null,_.map(theData.operand,"element")),"key"),"key")
          };
        }
        else {
          throw new Error("Arguments of the union data operator can only be composite data");
        }
        break;
      case 'intersection':
        if(_.every(theData.operand,"type","DataComposite")) {
          return {
            type:"DataComposite",
            element:_.sortBy(_.unique(_.intersectionObjects.apply(null,_.map(theData.operand,"element")),"key"),"key")
          };
        }
        else {
          throw new Error("Arguments of the intersection data operator can only be composite data");
        }
        break;
      case 'complement':
        //TODO
        break;
      default:
        throw new Error("Unknown data operator");
    }
  }
  return theData;
};
Example #4
0
exports.mergeAssetDependencies = function(dstAssetInfo, srcAssetInfo) {
  var assetDependenciesChanged = undefined

  if (srcAssetInfo.dependencies) {
    var srcDeps = srcAssetInfo.dependencies
    var dstDeps = dstAssetInfo.dependencies
    debug('[%s] merging asset dependencies', srcAssetInfo.name, srcDeps)

    // Ignore deps bundled by services.
    var srcBundleDeps = srcAssetInfo.srcBundleDeps || []
    var dstIgnoreDeps = dstAssetInfo.ignoreDeps || []
    dstAssetInfo.ignoreDeps = union(dstIgnoreDeps, srcBundleDeps)

    // Merge
    Object.keys(srcDeps).forEach(function(depName) {
      var oldDep = dstDeps[depName]
      var newDep = srcDeps[depName]
      if (!oldDep) {
        dstDeps[depName] = newDep
        assetDependenciesChanged = true
      } else if (oldDep !== newDep) {
        debug('Conflicting package version: %s vs %s', oldDep, newDep)
      }
    })

    dstAssetInfo.dependencies = dstDeps
  }

  return {
    assetInfo: dstAssetInfo,
    assetDependenciesChanged: assetDependenciesChanged
  }
}
Example #5
0
    (resolve, reject) => {
      if(!opts.noCache && opts.cachedSobj && opts.cachedSobj.attributes){
        opts.sobj = opts.cachedSobj;
        resolve(opts);
        return;
      }

      const fields = remove(union(opts.compactLayoutFieldNames, opts.defaultLayoutFieldNames, ['Id']), (name)=>{
        return trim(name,', _-\n\t').length>0;
      });

      const query = buildQuery(opts.type,opts.ids,fields);
      queryCount++;
      forceClient.query(query,
        (response) => {
          if(response.records && response.records.length){
            const records = response.records.map((r)=>{
                r.attributes.compactTitle = utils.getCompactTitle(r, opts.compactTitleFieldNames);
                r.attributes.shortId = utils.getShortId(r);
              return r;
            });
            broadcast(records, opts.compactLayout, opts.defaultLayout, opts.doRefs);
          }

          resolve(opts);
        },
        (error)=>{
          reject('Error: query');
        }
      );
    }
Example #6
0
	Object.keys( props ).forEach(function( key ) {
		var value = props[ key ];
		var currentVal = this._params[ key ];

		// Simple case: setting for the first time, or not merging
		if ( ! currentVal || ! merge ) {

			// Arrays should be de-duped and sorted
			if ( Array.isArray( value ) ) {
				value = _unique( value ).sort( alphaNumericSort );
			}

			// Set the value
			this._params[ key ] = value;

			// Continue
			return;
		}

		// value and currentVal must both be arrays in order to merge
		if ( ! Array.isArray( currentVal ) ) {
			currentVal = [ currentVal ];
		}

		if ( ! Array.isArray( value ) ) {
			value = [ value ];
		}

		// Concat the new values onto the old (and sort)
		this._params[ key ] = _union( currentVal, value ).sort( alphaNumericSort );
	}.bind( this ));
Example #7
0
//   _isEquivalent(a, b) {
//     // Create arrays of property names
//     var aProps = Object.getOwnPropertyNames(a);
//     var bProps = Object.getOwnPropertyNames(b);

//     // If number of properties is different,
//     // objects are not equivalent
//     if (aProps.length != bProps.length) {
//         return false;
//     }

//     for (var i = 0; i < aProps.length; i++) {
//         var propName = aProps[i];

//         // If values of same property are not equal,
//         // objects are not equivalent
//         if (a[propName] !== b[propName]) {
//             return false;
//         }
//     }

//     // If we made it this far, objects
//     // are considered equivalent
//     return true;
// }

// _shallowEqual(objA, objB) {
//   if (objA === objB) {
//     return true;
//   }

//   if (typeof objA !== 'object' || objA === null ||
//       typeof objB !== 'object' || objB === null) {
//     return false;
//   }

//   var keysA = Object.keys(objA);
//   var keysB = Object.keys(objB);

//   if (keysA.length !== keysB.length) {
//     return false;
//   }

//   // Test for A's keys different from B.
//   var bHasOwnProperty = Object.prototype.hasOwnProperty.bind(objB);
//   for (var i = 0; i < keysA.length; i++) {
//     if (!bHasOwnProperty(keysA[i]) || objA[keysA[i]] !== objB[keysA[i]]) {
//       return false;
//     }
//   }

//   return true;
// }




  /**
   * Calls config setters for all react props that have changed
   * @private
   */
  _applyProps(oldProps, props) {

    // if (this._shallowEqual(oldProps, props)) {
    //   console.log('*****************************************************************same'); 
    //   return
    // }
    // else {
    //   console.log('*****************************************************************not same'); 
    // }

    // var oldP = JSON.stringify(oldProps)
    // var newP = JSON.stringify(props)

    // if (oldP == newP) {
    //   console.log('*****************************************************************same'); 
    //   return
    // }
    // else {
    //   console.log('*****************************************************************not same'); 
    // }

    // if (JSON.stringify(oldProps) == JSON.stringify(props)) {
    //   alert('same'); // gives true
    //   return
    // }

      const keys = union(Object.keys(oldProps), Object.keys(props));
      for (let key of keys) {
          const oldValue = oldProps[key], newValue = props[key];
          if (key === 'children') continue;
          if (!isEqual(oldValue, newValue)) {
              const eventName = this._eventNameForProp(key);
              if (eventName) {
//                console.log('*****************************************************************eventName')
//                console.log(eventName)
                this._replaceEvent(eventName, oldValue, newValue);
              } else {

                  const setter = this._setterFor(key);
                  if (setter) {
                      const value = this._cloneProps(newValue);
                      if (this.ExtReactSettings.debug) console.log(setter, newValue, value)
                      // if (key == 'theme') {
                      //   Ext.thechart = this.cmp
                      //   console.log('*****************************************************************setter')
                      //   console.log(this.cmp.xtype + ' - ' + setter + ' - ' + value) 
                      //   //console.log(this.cmp)
                      //   //console.log('*****************************************************************value')
                      //   //console.log(key)
                      //   //console.log(value)
                      //   // debugger
                      //   //this.cmp.setTheme('Purple')
                      //   //this.cmp.redraw()
                      //  }
                      this.cmp[setter](value)
                  }
              }
          }
      }
  }
Example #8
0
/**
 * Собирает начальную часть css
 *
 * @typedef {Object} brebuildCssResult - результат отбработки css
 * @property {Array<pageInfo>} pagesInfo
 * @property {Array<moduleCssInfo>} modulesCssInfo
 *
 * @param {Array<pageInfo>} pagesInfo
 * @return {Promise<brebuildCssResult>}
 *
 */
function prebuildCss( pagesInfo ) {
  console.log('prebuildCss');
  const modules = _.union.apply(null, pagesInfo.map(page => page.modules));
  const pages = pagesInfo.map(page => page.name);
  const cssFiles = collectFiles('styl', pages, modules);
  return Promise.all(cssFiles.map(css.convert)).then(modulesCssInfo => ({ pagesInfo, modulesCssInfo }));
}
Example #9
0
      .then(pluginNames => {
        const plugins = options.plugins;
        if (plugins) {
          if (plugins.disable) {
            log.warn(
              '--plugins.disable is deprecated, use plugins.remove instead.'
            );
            plugins.remove = plugins.disable;
          }
          if (plugins.load) {
            log.warn('--plugins.load is deprecated, use plugins.add instead.');
            plugins.add = plugins.load;
          }

          pullAll(pluginNames, toArray(plugins.remove));
          pluginNames = union(pluginNames, toArray(plugins.add));

          if (plugins.list) {
            log.info(
              'The following plugins are enabled: %s',
              pluginNames.join(', ')
            );
          }
        }
        return pluginNames;
      })
var makeCCStats = function(results) {

  var allStepTypes = [];

  lodash.forEach(results, function(res) {
    allStepTypes.push(res.stepTypes);
  });
  allStepTypes = lodash.union.apply(this, allStepTypes);

  var stepData = {};
  var statsFn;
  lodash.forEach(allStepTypes, function(stepType) {
    statsFn = stepStatFns[stepType];

    if (!lodash.isUndefined(statsFn)) {
      stepData[stepType] = statsFn(results);
    }
  });

  var res = {
    stepTypes: allStepTypes,
    stepData: stepData
  };

  return res;
};
  sub: function(){
    var parent = this,
        subs = flatten(arguments);

    var descendants = reduce(subs, function(accum, sub, idx){
      var subSubs = sub.subProvinces && sub.subProvinces.map(identity);
      return union(accum, [sub], subSubs);
    }, []);


    descendants = union((parent.subProvinces && parent.subProvinces.map(identity)), descendants);

    parent.subProvinces = new ProvinceCollection(descendants);

    forEach(subs, function(prov){
      prov.parent = parent;
    });

    forEach(descendants, function(prov){
      prov.ancestors || (prov.ancestors = []);
      prov.ancestors.push(parent);
      prov.root = parent;
      prov.level += 1;
    });

    this._updateAutocrat(subs);

    return this;
  },
		reader.on('end', () => {
			// include last entry into whitelist
			addWhitelistEntry();

			// merge the result
			for (const name in titaniumKit_whitelist) {
				if (titaniumKit[name]) {
					titaniumKit[name].properties = union(titaniumKit[name].properties, titaniumKit_whitelist[name].properties);
					titaniumKit[name].methods    = union(titaniumKit[name].methods, titaniumKit_whitelist[name].methods);
					titaniumKit[name].events     = union(titaniumKit[name].events, titaniumKit_whitelist[name].events);
				} else {
					titaniumKit[name] = titaniumKit_whitelist[name];
				}
			}

			resolve();
		});
 _updateAutocrat: function(subs){
   var allAutocratProvs = this.autocrat.provinces.all;
   allAutocratProvs = union(
     (allAutocratProvs instanceof ProvinceCollection ?  allAutocratProvs.toArray() : allAutocratProvs),
     subs
   );
   this.autocrat.provinces.all = new ProvinceCollection(allAutocratProvs);
 }
Example #14
0
			.then(rows => {
				if (bucket.indexOf('allows_') === 0) {
					return this.getPermission(keys, rows);
				} else {
					return _.union.apply(_, rows.map(row => {
						return row.value;
					}));
				}
			}).nodeify(cb);
 })).forEach(function (item) {
   var i = _findIndex(mungedCategory.value, {key: item.key})
   if (i === -1) {
     mungedCategory.value.push(item)
   } else {
     mungedCategory.value[i].value =
       _union(mungedCategory.value[i].value, item.value)
   }
 })
Example #16
0
	function concatArrays(array, value) {
		let newArray;

		if (isArray(array)) {
			newArray = union(array, value);
		}

		return newArray;
	}
module.exports = function getHeaderSearchPath(sourceDir, headers) {
  const directories = union(
    headers.map(path.dirname)
  );

  return directories.length === 1
    ? `"$(SRCROOT)${path.sep}${path.relative(sourceDir, directories[0])}"`
    : `"$(SRCROOT)${path.sep}${path.relative(sourceDir, getOuterDirectory(directories))}/**"`;
};
Example #18
0
      forEach(fragments, (fragment, _queryName) => {
        const queryName =
          _queryName.indexOf(':') !== -1 ?
          _queryName.split(':')[0] :
          _queryName;

        // Normalize data
        //  relativeNodes - root nodes (Array || Object)
        //  nodes - all nodes added (Array)
        //  changes - changes to make to db (Object)
        const {relativeNodes, nodes, changes} = normalize(data[queryName], fragment);

        // Make changes in local DB
        this.db.mergeChanges(changes);

        // Save nodes changed to later check which connectors to update
        allNodes = union(allNodes, nodes);

        // Check if is mutation and brings a mutates field
        if (isMutation && mutates) {
          allNodes = union(
            nodes,
            this.db.performUserMutate(mutates, relativeNodes)
          );
        }

        // Process data to connectors
        if (connectors) {
          this.connectors.processConnectors(
            connectors,
            queryName,
            relativeNodes,
            nodes
          );
        }

        // If mutation check if some connector is listening
        if (isMutation) {
          connectorsToUpdate = union(
            connectorsToUpdate,
            this.connectors.checkMutationListeners(queryName, relativeNodes, nodes, this.db)
          );
        }
      });
Example #19
0
      matching: function (patterns) {
        function doMatch(pattern) {
          return minimatch.match(allFiles, pattern);
        }

        var incs = patterns.inc.map(doMatch);
        var excs = patterns.exc.map(doMatch);

        var matched = _.difference(_.union.apply(null, incs), _.union.apply(null, excs));

        // filter array
        notMatched = notMatched.filter(function (i) {
          return matched.indexOf(i) < 0;
        });

        return matched.map(function (path) {
          return filesByPath[path];
        });
      },
Example #20
0
QueryCompiler.prototype._normalizeInsert = function(data) {
  if (!_.isArray(data)) return _.clone(data);
  var defaultObj = _.reduce(_.union.apply(_, _.map(data, function(val) {
    return _.keys(val);
  })), function(memo, key) {
    memo[key] = void 0;
    return memo;
  }, {});
  return _.map(data, function(row) { return _.defaults(row, defaultObj); });
};
 getTranslations(dirname, function(err, allLanguages) {
   if (err) return done(err);
   var knownStrings = _.map(_.values(allLanguages), function(json) {
     return deepKeys(JSON.parse(json));
   });
   var allKnownStrings = _.union.apply({}, knownStrings);
   expect(allLanguages).to.have.property(debugFile);
   var debugTranslations = JSON.parse(allLanguages[debugFile]);
   expect(deepKeys(debugTranslations)).to.include.members(allKnownStrings);
   done();
 });
Example #22
0
        var result = elements.reduce(function(memo, element) {

            var fn = element.getVarsMentioned;
            if (!fn || !isFunction(fn)) {
                console.log('[ERROR] .getVarsMentioned not found on object ', element);
            }

            var vs = element.getVarsMentioned();
            var r = union(memo, vs);
            return r;
        }, []);
Example #23
0
test('deal 13 cards', function (t) {
  const result = chance.deal({ per_hand: 13 });

  t.equal(Object.keys(result).length, 4, '4 hands, no stock');
  t.equal(result[0].length, 13, 'equal portion');
  t.equal(result[1].length, 13, 'equal portion');
  t.equal(result[2].length, 13, 'equal portion');
  t.equal(result[3].length, 13, 'equal portion');
  t.equal(union(result[0], result[1], result[2], result[3]).length, 52, 'hands are unique');

  t.end();
});
Example #24
0
test('deal 3 hands', function (t) {
  const result = chance.deal({ hands: 3 });

  t.equal(Object.keys(result).length, 4, '3 hands with stock');
  t.equal(result[0].length, 17, 'equal portion');
  t.equal(result[1].length, 17, 'equal portion');
  t.equal(result[2].length, 17, 'equal portion');
  t.equal(result.stock.length, 1, 'stock');
  t.equal(union(result[0], result[1], result[2], result.stock).length, 52, 'hands are unique');

  t.end();
});
Example #25
0
const messageFetchComplete = (state, action) => {
  const key = JSON.stringify(action.narrow);
  const fetchedMessageIds = action.messages.map(message => message.id);
  const replaceExisting =
    action.anchor === FIRST_UNREAD_ANCHOR || action.anchor === LAST_MESSAGE_ANCHOR;
  return {
    ...state,
    [key]: replaceExisting
      ? fetchedMessageIds
      : union(state[key], fetchedMessageIds).sort((a, b) => a - b),
  };
};
Example #26
0
 function recursiveFindFlatDependencies(pkg) {
   var deps = Object.keys(pkg.dependencies);
   if (deps.length) {
     result = union(result, deps);
     if (isNestedStructure) {
       return Promise.resolve();
     }
     return Promise.all(deps.map(dep =>
       readPkg(resolveFlatDependencyPkg(dep)).then(recursiveFindFlatDependencies)
     ));
   }
   return Promise.resolve();
 }
Example #27
0
 Object.keys(posterComment).forEach(function(key){
   if (annotations[key] === undefined) return;
   var annotation = annotations[key];
   if ( isAnnotationAllowed(parsedComment, annotation) ) {
     if (parsedComment[key] === undefined) {
       parsedComment[key] = posterComment[key];
     } else if (isOverwritePoster(annotation)) {
       posterComment[key] = parsedComment[key];
     } else {
       parsedComment[key] = union(posterComment[key], parsedComment[key]);
     }
   }
 });
Example #28
0
      client.ready.then(function(){
        resourceNames = _.pluck(_.union.apply(_,_.map(setup.apps, function(app){
          return app.fortune.resources();
        })), "name");

        _.each(setup.apps, function(app){
          _.each(app.resources, function(documents, name){
            ids[name] = _.pluck(documents, "id");
          });
        });
        util.ids = ids;
        done();
      });
Example #29
0
function addScript(
  pkg /* : PackageJSON */,
  name /* : string */,
  value /* : string */,
) {
  const scripts = pkg.scripts || {};

  let values = (scripts[name] || '').split(' && ');
  values = values.filter(v => !!v); // drop empties
  values = union(values, [value]);
  scripts[name] = values.join(' && ');

  pkg.scripts = scripts;
}
Example #30
0
export function reportChanges(context, nProps, nState, log = logFunc) {
  const props = context.props || {};
  const state = context.state || {};
  const newProps = nProps || {};
  const newState = nState || {};
  const availableProps = union(keys(props), keys(newProps));
  const stateKeys = union(keys(state), keys(newState));
  const name = getComponentName(context);
  const changes = [];
  availableProps.forEach((key) => {
    const oldValue = props[key];
    const newValue = newProps[key];
    if (!is(oldValue, newValue)) {
      changes.push({
        component: name,
        type: 'props',
        from: props[key],
        to: newProps[key],
      });
      log('%s: changed prop %s from %o to %o', name, key, oldValue, newValue);
    }
  });
  stateKeys.forEach((key) => {
    const oldValue = state[key];
    const newValue = newState[key];
    if (!is(oldValue, newValue)) {
      changes.push({
        component: name,
        type: 'state',
        from: state[key],
        to: newState[key],
      });
      log('%s: changed state key %s from %o to %o', name, key, oldValue, newValue);
    }
  });
  return changes;
}