How to use the underscore.each function in underscore

To help you get started, we’ve selected a few underscore 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 geneontology / noctua / js / lib / noctua-widgetry / widgetry.js View on Github external
us.each(form.evidence_profiles, function(prof){

			    // Mine out class expressions..
			    var cln_ce_str = [];
			    var cln_ce = [];
			    us.each(prof.class_expressions, function(ce){
				cln_ce.push(ce.class_id());
				cln_ce_str.push(ce.to_string_plus());
				//console.log(ce);
				ce_cache[ce.class_id()] = true;
			    });

			    // Mine out source and with.
			    var cln_src = [];
			    var cln_with = [];
			    //console.log(prof.annotations.length);
			    us.each(prof.annotations, function(ann){
				if( ann.key() === 'with' ){
				    cln_with.push(ann.value());
				}
				if( ann.key() === 'source' ){
				    cln_src.push(ann.value());
github arangodb / arangodb / js / apps / system / aardvark / frontend / js / modules / org / arangodb / general-graph.js View on Github external
var bindEdgeCollections = function(self, edgeCollections) {
  _.each(edgeCollections, function(key) {
    var obj = db._collection(key);
    var wrap = wrapCollection(obj);
    // save
    var old_save = wrap.save;
    wrap.save = function(from, to, data) {
      //check, if edge is allowed
      self.__edgeDefinitions.forEach(
        function(edgeDefinition) {
          if (edgeDefinition.collection === key) {
            var fromCollection = from.split("/")[0];
            var toCollection = to.split("/")[0];
            if (! _.contains(edgeDefinition.from, fromCollection)
              || ! _.contains(edgeDefinition.to, toCollection)) {
              throw "Edge is not allowed between " + from + " and " + to + ".";
            }
          }
github ecomfe / esui / src / Region.js View on Github external
function optionClick(region, dom, dontRefreshView) {
            var id = lib.getAttribute(dom, 'data-optionId');
            var isChecked = dom.checked;
            var data = region.regionDataIndex[id];
            data.isSelected = isChecked;
            var children = data.children;
            var len = children instanceof Array && children.length;
            // 有下层节点
            if (len) {
                // 自动勾选
                u.each(children, function (child) {
                    var checkbox = getOptionDOM(region, child.id);
                    if (checkbox) {
                        checkbox.checked = isChecked;
                        optionClick(region, checkbox, 1);
                    }
                    else {
                        region.regionDataIndex[child.id].isSelected = isChecked;
                    }
                });
            }
            else if (len === 0) {
                //获取第三层checkbox
                if (lib.getAttribute(dom, 'level') === 3) {
                    var selCityIdsLength = 0;
                    var cityTotal = region.regionDataIndex[id].parent.children;
                    u.each(cityTotal, function (city) {
github abiee / mastering-backbone / ch06 / app / js / common.js View on Github external
closeRegions() {
    var regions = this._regions || {};

    // Close each active region
    _.each(regions, region => {
      if (region && region.remove) region.remove();
    });
  }
}
github 2600hz / monster-ui / apps / voip / submodules / groups / groups.js View on Github external
self.groupsGetData(function(data) {
				var dataTemplate = self.groupsFormatListData(data),
				    template = $(monster.template(self, 'groups-layout', dataTemplate)),
					templateGroup;

				_.each(dataTemplate.groups, function(group) {
					templateGroup = monster.template(self, 'groups-row', group);

					template.find('.groups-rows').append(templateGroup);
				});

				self.groupsBindEvents(template, parent);

				parent
					.empty()
					.append(template);

				if(_groupId) {
					parent.find('.grid-row[data-id=' + _groupId + ']')
						.css('background-color', '#22CCFF')
						.animate({
							backgroundColor: '#fcfcfc'
github MaayanLab / clustergrammer / src / filters / make_slider_filter.js View on Github external
module.exports = function make_slider_filter(cgm, filter_type, div_filters){

  var params = cgm.params;
  var inst_view = {};

  var possible_filters = underscore.keys(params.viz.possible_filters);

  underscore.each(possible_filters, function(tmp_filter){
    if (tmp_filter != filter_type){
      var default_state = get_filter_default_state(params.viz.filter_data, tmp_filter);
      inst_view[tmp_filter] = default_state;
    }
  });

  var filter_title = make_filter_title(params, filter_type);

  div_filters
    .append('div')
    .classed('title_'+filter_type,true)
    .classed('sidebar_text', true)
    .classed('slider_description', true)
    .style('margin-top', '5px')
    .style('margin-bottom', '3px')
    .text(filter_title.text + filter_title.state + filter_title.suffix);
github node4good / jest / resource.js View on Github external
get_allowed_methods_tree: function () {
        if(_.isArray(this.allowed_methods)){
            var tree = {};
            _.each(this.allowed_methods, function(method){

                if(method == 'get')
                    tree[method] = { 'details':true, 'list':true };
                else
                    tree[method] = true;
            });

            this.allowed_methods = tree;
        }

        return this.allowed_methods;
    },
github PufferPanel / PufferPanel / lib / controller / server.js View on Github external
ServerController.prototype.addAddress = function (serverUUID, ip, port, primary) {
    Validate.isUUID(serverUUID, 'uuid');
    Validate.isIP(ip, 'ip');
    Validate.isNumber(port, 'port');
    Validate.isBoolean(primary, 'primary');

    var self = this;
    var server = self.collections.server.get(serverUUID);
    if (server) {
        var addresses = server.getAddresses();
        if (primary) {
            _.each(addresses, function (address) {
                address.primary = false;
            });
        }
        addresses.push({ ip: ip, port: port, primary: primary });
        self.collections.server.update(server.getUUID(), addresses);
    } else {
        throw new Error('No server with the given UUID');
    }
};
github catarse / catarse.js / legacy / src / c / project-google-contact-import.js View on Github external
reducedList = _.reduce(data.feed.entry, (memo, entry) => {
                            if (('gd$email' in entry) && entry.gd$email.length > 0) {
                                const gemails = entry.gd$email,
                                    name = entry.title.$t;

                                _.each(gemails, (email) => {
                                    memo.push({
                                        email: email.address,
                                        name
                                    });
                                });
                            }

                            return memo;
                        }, []);
github Laverna / laverna / app / scripts / components / dropbox / Sync.js View on Github external
sync() {
        let promise = Promise.resolve();
        this.channel.trigger('start');
        this.stat.statRemote = false;
        log('checking for changes...');

        _.each(this.collectionNames, name => {
            promise = promise.then(() => this.syncCollection(name));
        });

        return promise
        .then(() => {
            this.channel.trigger('stop', {result: 'success'});
            this.startWatch();
        })
        .catch(error => {
            log('sync error', error);
            this.channel.trigger('stop', {result: 'error', error});
        });
    }