How to use the underscore.has 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 esnet / react-timeseries-charts / src / components / BandChart.js View on Github external
styles[1] = this.style(column, event, 1); // eslint-disable-line
        styles[2] = this.style(column, event, 2); // eslint-disable-line

        // Use D3 to build an area generation function
        const areaGenerator = area()
            .curve(curves[this.props.interpolation])
            .x(d => d.x0)
            .y0(d => d.y0)
            .y1(d => d.y1);

        const columns = this.series.columns();

        // How many areas are we drawing
        let hasInner = true;
        let hasOuter = true;
        if (_.has(columns, "innerMin") || _.has(columns, "innerMax")) {
            hasInner = false;
        }
        if (_.has(columns, "outerMin") || _.has(columns, "outerMax")) {
            hasOuter = false;
        }

        // Build the outer area if we have one
        if (hasOuter) {
            let level = 0;
            if (!hasInner) {
                level += 1;
            }

            const outerData = [];
            for (let j = 0; j < this.series.size(); j += 1) {
                const e = this.series.at(j);
github ecomfe / baidubce-sdk / src / bcs_client.js View on Github external
BcsClient.prototype.putObjectFromFile = function (bucketName, key, filename, options) {
    options = options || {};

    var headers = {};
    headers[H.CONTENT_LENGTH] = fs.statSync(filename).size;

    // 因为Firefox会在发起请求的时候自动给 Content-Type 添加 charset 属性
    // 导致我们计算签名的时候使用的 Content-Type 值跟服务器收到的不一样,为了
    // 解决这个问题,我们需要显式的声明Charset
    headers[H.CONTENT_TYPE] = options[H.CONTENT_TYPE] || MimeType.guess(path.extname(filename));
    options = u.extend(headers, options);

    var fp = fs.createReadStream(filename);
    if (!u.has(options, H.CONTENT_MD5)) {
        var me = this;
        return require('./crypto').md5file(filename, 'hex')
            .then(function (md5sum) {
                options[H.CONTENT_MD5] = md5sum;
                return me.putObject(bucketName, key, fp, options);
            });
    }
    return this.putObject(bucketName, key, fp, options);
};
github jamesshore / automatopia / node_modules / jshint / src / jshint.js View on Github external
}

		// Is this a labelled statement?
		var res = isReserved(t);

		// We're being more tolerant here: if someone uses
		// a FutureReservedWord as a label, we warn but proceed
		// anyway.

		if (res && t.meta && t.meta.isFutureReservedWord && peek().id === ":") {
			warning("W024", t, t.id);
			res = false;
		}

		// detect a destructuring assignment
		if (_.has(["[", "{"], t.value)) {
			if (lookupBlockType().isDestAssign) {
				if (!state.option.inESNext()) {
					warning("W104", state.tokens.curr, "destructuring expression");
				}
				values = destructuringExpression();
				values.forEach(function (tok) {
					isundef(funct, "W117", tok.token, tok.id);
				});
				advance("=");
				destructuringExpressionMatch(values, expression(10, true));
				advance(";");
				return;
			}
		}
		if (t.identifier && !res && peek().id === ":") {
			advance();
github IntelOpenDesign / MakerNode / app / lib / socket.js View on Github external
});
            _.each(d.pins, function(pin, id) {
                msg.pins[id].value = pin.value;
                msg.pins[id].label = pin.label;
                msg.pins[id].is_visible = pin.is_visible;
                msg.pins[id].is_analog = pin.is_analog;
                msg.pins[id].is_input = pin.is_input;
                msg.pins[id].is_inverted = pin.is_inverted;
                msg.pins[id].input_min = pin.input_min;
                msg.pins[id].input_max = pin.input_max;
                msg.pins[id].damping = pin.damping;
                msg.pins[id].is_timer_on = pin.is_timer_on;
                msg.pins[id].timer_value = pin.timer_value;
            });
            messages_dict[d.message_id] = 0;
            if (_.has(d, 'mac_address')) {
                settings.confirm_network();
            }
            if (_.has(d, 'username') && _.has(d, 'user_password')) {
                settings.set_user_password();
            }
            if (_.has(d, 'wifi_ssid') && _.has(d, 'wifi_password')) {
                settings.set_router_info(d.wifi_ssid, d.wifi_password).then(function() {
                   // TODO app.js should really be the one to call this
                   var our_command = './init_supplicant.sh ' + d.wifi_ssid + ' ' + d.wifi_password;
				   if (settings.get_galileo_static_ip() !== "") {
				     our_command += ' ' + settings.get_galileo_static_ip() + ' ' + settings.get_router_gateway_ip();
				   }
				   log.info('Attempting to init wlan0 with command: ' + our_command);
				   exec(our_command, function(error, stdout, stderr) {
                       // TODO clean this up
                       if (error === null) return;
github perminder-klair / resume-parser / src / utils / Resume.js View on Github external
Resume.prototype.addObject = function(key, options) {
  var self = this;

  if (!_.has(this.parts, key)) {
    this.parts[key] = {};
  }

  _.forEach(options, function(optionVal, optionName) {
    if (optionVal) {
      self.parts[key][optionName] = optionVal;
    }
  });
};
github pact-foundation / pact-node / src / publisher.js View on Github external
function constructTagUrl(options, tag, data) {
	if (!_.has(options, 'pactBroker')) {
		throw new Error("Cannot construct Pact Tag URL: 'pactBroker' not specified");
	}

	if (!_.has(options, 'consumerVersion')) {
		throw new Error("Cannot construct Pact Tag URL: 'consumerVersion' not specified");
	}

	if (!_.isObject(options)
		|| !_.has(data, 'consumer')
		|| !_.has(data.consumer, 'name')) {
		throw new Error("Invalid Pact contract given. " +
			"Unable to parse consumer name");
	}

	return urlJoin(options.pactBroker, 'pacticipants', data.consumer.name, 'versions', options.consumerVersion, 'tags', tag)
}
github esnet / react-network-diagrams / src / circuit-diagram-concatenated.jsx View on Github external
_.each(memberList, member => {
            if (_.has(member.styleProperties, "squareWidth")) {
                totalSquareWidth += member.styleProperties.squareWidth;
                squareMemberCount += 1;
            }
        });
github microsoft / projection-grid / spec / integrated / data / js-data-source.js View on Github external
queryTransform: (definition, params) => {
    let query = {};

    _.has(params, 'offset') && (query.$skip = params.offset);
    _.has(params, 'limit') && (query.$top = params.limit);
    _.has(params, 'orderBy') && (query.$orderby = params.orderBy.map((item) => {
      return item[0] + ' ' + item[1].toLowerCase();
    }).join(','));

    return query;
  },
}), { default: true });
github oroinc / platform / src / Oro / Bundle / DataGridBundle / Resources / public / js / datagrid / grid.js View on Github external
setAdditionalParameter: function(name, value) {
            const state = this.collection.state;
            if (!_.has(state, 'parameters')) {
                state.parameters = {};
            }

            state.parameters[name] = value;
        },
github pump-io / pump.io / lib / model / activity.js View on Github external
reprOf = function(obj) {
            var name = sanitize(nameOf(obj)).escape();
            if (_.has(obj, "url")) {
                return "<a href="&quot;+obj.url+&quot;">"+name+"</a>";
            } else {
                return name;
            }
        },
        pastOf = function(verb) {