.replace(/\.\./g, '.') .split('.') .map(part => _.defaultTo(_.toNumber(part), part));
var getCourseAttributeValue = function (name, value) { switch (_.get(COURSE_ATTRIBUTES, name)) { case "boolean": return _.lowerCase(value) === 'true' ? true : false; case "number": return _.toNumber(value); case "integer": return _.toInteger(value); // Value is a string by default. default: return value; } }
role.permissions.reduce((acc, permission) => { _.set(acc, `${permission.type}.controllers.${permission.controller}.${permission.action}`, { enabled: _.toNumber(permission.enabled) == true, policy: permission.policy }); if (permission.type !== 'application' && !acc[permission.type].information) { acc[permission.type].information = plugins.find(plugin => plugin.id === permission.type) || {}; } return acc; }, {})
/** * Returns commands to delete matching lines of a command * @private */ getCommandsToDeleteLinesThatMatch(regexp, commandName, offset) { if (!offset) offset = 0 return this.getLinesThatMatch(regexp, commandName) .then(matching => { let lineNumbers = Object.keys(matching).map(_.toNumber) // Delete in reverse order, otherwise they all shuffle down! let deleteCommands = lineNumbers.sort((a,b)=>b-a) .map(n => { return `command deleteline ${commandName} ${n+offset}` }) return deleteCommands }) }
self.fetchContent(url, function (err, content) { if (err) { return callback(err, null); } // Parse the content fetch from google finance var bid = self.parseContent(content); if (_.isNull(bid) || _.isUndefined(bid) || bid.length === 0) { return callback(new UnsupportedCurrencyPairException(currencyPair, Provider), null); } // split the fetched rate to remove currency symbol and verify if its number var parts = _.split(bid, ' '); if (parts.length == 0 || !_.toNumber(parts[0])) { return callback(new UnsupportedCurrencyPairException(currencyPair, Provider), null); } return callback(null, new Rate(parts[0], new Date(), Provider)); });
//Transform CSV data function transformCSVRowFromMetadata(row, numericCols) { var val; _.forEach(numericCols, function (col) { if (!_.isNull(row[col])) row[col] = _.toNumber(row[col]); else row[col] = null; }); return row; }
this.query(function(qb) { _.forEach(params.where, (where, key) => { if (_.isArray(where.value) && where.symbol !== 'IN' && where.symbol !== 'NOT IN') { for (const value in where.value) { qb[parseInt(value) ? 'orWhere' : 'where'](key, where.symbol, where.value[value]); } } else { qb.where(key, where.symbol, where.value); } }); if (params.sort) { qb.orderBy(params.sort.key, params.sort.order); } if (params.skip) { qb.offset(_.toNumber(params.skip)); } if (params.limit) { qb.limit(_.toNumber(params.limit)); } }).fetchAll({ withRelated: populate || this.associations.map(x => x.alias) }).then(data => raw ? data.toJSON() : data)
Object.keys(this.attributes).reduce((acc, curr) => { switch (this.attributes[curr].type) { case 'integer': case 'float': case 'decimal': if (!_.isNaN(_.toNumber(params.search))) { return acc.concat({ [curr]: params.search }); } return acc; case 'string': case 'text': case 'password': return acc.concat({ [curr]: { $regex: params.search, $options: 'i' } }); case 'boolean': if (params.search === 'true' || params.search === 'false') { return acc.concat({ [curr]: params.search === 'true' }); } return acc; default: return acc; } }, [])
_.filter(input.products, function(item){ return _.toNumber(_.trim(item.price, '¥')) > 200; })
/** * Returns an object defining what the Show command is showing * @return {Promise} */ showing() { return this.list('Show') .then(arrayOfLines => { if (!arrayOfLines) return // means no Show command yet let showingItems = { text: [], image: [], vfeed: [] } arrayOfLines.forEach(l => { if (!l) return let match = l.match(/^(text|image|vfeed) overlay\s*(.+)$/) if (match) { let type = match[1] let ids = match[2].split(' ').map(_.toNumber) showingItems[type] = showingItems[type].concat(ids) } }) return showingItems }) }
Object.keys(this.attributes).reduce((acc, curr) => { switch (this.attributes[curr].type) { case 'integer': case 'float': case 'decimal': if (!_.isNaN(_.toNumber(params.search))) { return acc.concat({ [curr]: params.search }); } return acc; case 'string': case 'text': case 'password': return acc.concat({ [curr]: { $regex: params.search, $options: 'i' } }); case 'boolean': if (params.search === 'true' || params.search === 'false') { return acc.concat({ [curr]: params.search === 'true' }); } return acc; default: return acc; } }, [])