__.each(modelJSON, function(value, key) { if (!__.has(existingKeys, key)) { newFormData.append(key, value); } });
this.requiredArguments.forEach(argument => { if (!_.has(this, argument) || !_.result(this, argument, null)) { throw new Error(`Missing required argument ${argument}`); } });
test("has", function () { var obj = {foo: "bar", func: function () {} }; ok (_.has(obj, "foo"), "has() checks that the object has a property."); ok (_.has(obj, "baz") == false, "has() returns false if the object doesn't have the property."); ok (_.has(obj, "func"), "has() works for functions too."); obj.hasOwnProperty = null; ok (_.has(obj, "foo"), "has() works even when the hasOwnProperty method is deleted."); var child = {}; child.prototype = obj; ok (_.has(child, "foo") == false, "has() does not check the prototype chain for a property.") });
function hasOpt(opts, name) { return _.has(opts, name) && f.truthy(opts[name]); }
app.use('api/*', function(req, res, next) { var foundHeader = _.has(req.headers, authHeaderName.toLowerCase()); if (!foundHeader) { return res.status(401).send({ message: 'Unauthorized! Please make sure you send the appropriate token!' }); } next(); });
it('request should succeed', function(done) { var host = appServer.http.address().address; var port = appServer.http.address().port; var url = 'http://' + host + ':' + port + '/check'; var localAddress = '127.0.1.1'; var requestOptions = { localAddress: localAddress }; ProxyVerifier.request('get', url, requestOptions, function(error, data, status, headers) { try { expect(error).to.equal(null); expect(status).to.equal(200); expect(data).to.be.an('object'); expect(_.has(data, 'ipAddress')).to.equal(true); expect(_.has(data, 'headers')).to.equal(true); expect(data.ipAddress).to.equal(localAddress); expect(data.headers).to.be.an('object'); expect(data.headers.host).to.equal(host + ':' + port); } catch (error) { return done(error); } done(); }); });
function getBoardShields(board) { board = boards[board]; var result = []; if (_.has(board, "builtin")) { result.push("--- Built In"); Array.prototype.push.apply(result, board.builtin); } var all_shields = _.keys(shields); if (_.has(board, "exclude")) { var regexs = board.exclude; all_shields = all_shields.filter(function (text) { if (text.startsWith("---")) return true; return !regexs.some(function (regex) { return regex.test(text); }); }); } all_shields = all_shields.filter((k) => (shields[k].embedded !== true)); Array.prototype.push.apply(result, all_shields); return result; }
/** * Check if the parsed filename has the needed information in it. * @param {object} tvelem - Parsed filename usually containing things like show, episode, season etc. * @param {string} elempath - Filename without path (includes extension). * @param {string} elem - Full path to file. */ async hasShow(tvelem, elempath, elem) { if (_.has(tvelem, 'show') === true) { const already = await this.inDB(tvelem); if (already === 'got image') { log.info(`VIEWER: got image from DB for: ${elem}`); this.emit('tvelem', [tvelem, elempath]); } else if (already === 'need image') { this.getSeriesByName(tvelem, elempath); } } }
function emitCustomOr(isCustom, decoderBytes, alternativeEmit) { if (isCustom) { return function(event, emitter, bytebuf, listenerId) { var decoder = f.actions( [decoderBytes.fun(decoderBytes.obj)] , function(values) { return {result: values[0]}; } ); var custom = decoder(bytebuf); logger.tracel(function() { return ['Try to emit %s event %s', event, custom.result]; }); // TODO workaround ISPN-10166: key/value/prev should be JSON if (_.has(custom.result, '_type')) { custom.result.key = JSON.parse(custom.result.key); custom.result.value = JSON.parse(custom.result.value); custom.result.prev = JSON.parse(custom.result.prev); } var success = emitter.emit(event, custom.result, listenerId); if (success) logger.tracef('Event emitted'); else logger.tracef('No listener defined for %s event', event); return true; }; } return alternativeEmit(decoderBytes); }
if (_.has(returnObject, "error_code"))
function add_names(d) { _.keys(d).forEach((k) => { if (!_.has(d[k], "name")) { d[k].name = k; } }); }
React.createClass({ getDefaultProps: function() { return { outBoard: "entrance" }; }, propTypes: { outBoard: function(props, propName) { var currentOutBoard = props[propName]; if (!_.has(props, propName)) { return new Error("You need to define " + propName + " property when rendering LoggedOut component!"); } if (typeof currentOutBoard !== "string") { return new Error("The " + propName + " property must be a string in LoggedOut component!"); } if (!_.has(OUT_BOARDS, currentOutBoard)) { return new Error("Current '" + currentOutBoard + "' board is not an available " + propName + "!"); } } }, render: function() { switch (this.props.outBoard) { case 'entrance': return ( <Entrance /> ); break; } } })
function run_inherit(d) { var result = {}; _.keys(d).forEach((k) => { var i = d[k]; var chain = [i]; while (_.has(i, "inherit")) { var tgt = i.inherit; if (typeof tgt === 'string') { if (_.has(d,tgt)) tgt = d[tgt]; else console.error(tgt, "not found"); } chain.unshift(tgt); i = tgt; } //console.log(chain.map((i) => i.name)); result[k] = Object.assign({}, ...chain); delete result[k].inherit; }); return result; }
__.each(modelJSON, function(value, key) { if (!__.has(existingKeys, key)) { newFormData.append(key, value); } });
/** * Check if the parsed filename has the needed information in it. * @param {object} tvelem - Parsed filename usually containing things like show, episode, season etc. * @param {string} elempath - Filename without path (includes extension). * @param {string} elem - Full path to file. */ async hasShow(tvelem, elempath, elem) { if (_.has(tvelem, 'show') === true) { const already = await this.inDB(tvelem); if (already === 'got image') { log.info(`VIEWER: got image from DB for: ${elem}`); this.emit('tvelem', [tvelem, elempath]); } else if (already === 'need image') { this.getSeriesByName(tvelem, elempath); } } }