prompt.get(user_org_schema, function (err, user_org_results) { console.log('User Org data ' + util.inspect(user_org_results)); // Saving Roles ---------------------------- user_org_results.roles = []; var properties = user_org_results.string_roles.split(','); properties.forEach(function(property) { var roles_obj = {}; var tup = property.split(':'); roles_obj.role = tup[0]; roles_obj.hasRole = (tup[1] == "false") != Boolean(tup[1]); user_org_results.roles.push(roles_obj); }); // Saving Roles ---------------------------- _.extend(user_org_results, _.omit(user_org_results, 'string_roles')); prompt.get(org_license_schema, function (err, org_license_results) { org_license_results['license_enabled'] = (org_license_results.license_enabled_value == "false") != Boolean(org_license_results.license_enabled_value); org_license_results['license_start_epoch_s'] = Math.round(moment().add('days', org_license_results.license_start)/1000) org_license_results['license_end_epoch_s'] = Math.round(moment().add('days', org_license_results.license_end)/1000) _.extend(org_license_results, _.omit(org_license_results, 'license_start')); _.extend(org_license_results, _.omit(org_license_results, 'license_end')); _.extend(org_license_results, _.omit(org_license_results, 'license_enabled_value')); console.log('Org License data ' + util.inspect(org_license_results)); Organization.create(org, function (error, organization) { if (error) { console.log(error); } else { console.log('Organization created'); _.extend(org_license_results, { organization_oid: organization._id, organization_name: organization.organization}) User.create(user, function (error, user) { if (error) { console.log(error); } else { console.log('User created'); UserOrganization.create({ organization_name: org.organization , organization_oid: organization._id , user_contact_email: user.user_contact_email , user_oid: user._id , roles: user_org_results.roles }, function (err, user_organization) { if (error) { console.log(error); } else { console.log('User Organization created'); OrganizationLicense.create(org_license_results, function (error, org_license) { if ( error ) { console.log(error); } else { console.log('Organization License created'); console.log('Everything was saved.') return; } }) } }); } }); } }); }); });
var omitDates = function(item) { if (_.isObject(item)) { return _.omit(item, 'created_at', 'updated_at'); } return item; };
co(function* () { var _counter = thunkQuery(UnitOfAnalysis.select(UnitOfAnalysis.count('counter')), _.omit(req.query, 'offset', 'limit', 'order')); var uoa = thunkQuery(UnitOfAnalysis.select(), req.query); return yield [_counter, uoa]; }).then(function (data) {
it('validates config : time_window_in_days', done => { assertConfigIsInvalid(done, [_.omit(alertConfig, 'time_window_in_days')]); });
it('validates config : name', done => { assertConfigIsInvalid(done, [_.omit(alertConfig, 'name')]); });
function testRegex(regexText, value) { if (!regexCache[regexText]) { regexCache[regexText] = new RegExp(regexText); } return regexCache[regexText].test(value); } var BaseModel = Backbone.Model .extend(models.superMixin) .extend(models.cacheMixin) .extend(models.restrictionMixin) .extend({ constructorName: 'BaseModel', cacheFor: 60 * 1000, toJSON() { return _.omit(this.attributes, 'metadata'); }, validate() { var result = {}; _.each(this.attributes.metadata, (field) => { if (!VmWareModels.isRegularField(field) || field.type === 'checkbox') { return; } var isDisabled = this.checkRestrictions(restrictionModels, undefined, field); if (isDisabled.result) { return; } var value = this.get(field.name); if (field.regex) { if (!testRegex(field.regex.source, value)) { result[field.name] = field.regex.error;
it('validates config : message', done => { assertConfigIsInvalid(done, [_.omit(alertConfig, 'message')]); });
parseFindOptions: function(options) { return [options.where, _.omit(options, 'where')]; },
return _.map(_.pairs(tips), function(p){ return _.extend(_.omit(p[1], 'key'), { 'key' : p[0], }); });
flush: function(cache, keys) { //TODO: speficy short way to delete all? return _.omit(cache, function(e) { return utils.intersects(_.isEqual, e.keys, keys); }); },
processQueryOptionsOnResult(result, options = {}) { if (result === undefined || result === null) { return undefined; } if (Array.isArray(result)) { if (options.sort) { result = result.sort((a, b) => { let r = 0; for (const field in options.sort) { if (options.sort.hasOwnProperty(field)) { const direction = options.sort[field]; let valueA; let valueB; if (field.indexOf('.') > -1) { valueA = objectPath.get(a, field); valueB = objectPath.get(b, field); } else { valueA = a[field]; valueB = b[field]; } if (valueA > valueB) { r = direction; break; } if (valueA < valueB) { r = -direction; break; } } } return r; }); } if (typeof options.skip === 'number') { result.splice(0, options.skip); } if (typeof options.limit === 'number' && options.limit !== 0) { result.splice(options.limit); } } if (!options.fields) { options.fields = {}; } const fieldsToRemove = []; const fieldsToGet = []; for (const field in options.fields) { if (options.fields.hasOwnProperty(field)) { if (options.fields[field] === 0) { fieldsToRemove.push(field); } else if (options.fields[field] === 1) { fieldsToGet.push(field); } } } if (fieldsToRemove.length > 0 && fieldsToGet.length > 0) { console.warn('Can\'t mix remove and get fields'); fieldsToRemove.splice(0, fieldsToRemove.length); } if (fieldsToGet.length > 0 && fieldsToGet.indexOf('_id') === -1) { fieldsToGet.push('_id'); } const pickFields = (obj, fields) => { const picked = {}; fields.forEach((field) => { if (field.indexOf('.') !== -1) { objectPath.set(picked, field, objectPath.get(obj, field)); } else { picked[field] = obj[field]; } }); return picked; }; if (fieldsToRemove.length > 0 || fieldsToGet.length > 0) { if (Array.isArray(result)) { result = result.map((record) => { if (fieldsToRemove.length > 0) { return _.omit(record, ...fieldsToRemove); } if (fieldsToGet.length > 0) { return pickFields(record, fieldsToGet); } return null; }); } else { if (fieldsToRemove.length > 0) { return _.omit(result, ...fieldsToRemove); } if (fieldsToGet.length > 0) { return pickFields(result, fieldsToGet); } } } return result; }
const removeAlertsForQuestionReducer = (state, { payload: questionId }) => { return { ...state, result: _.omit(state.result || {}, alert => alert.card.id === questionId), }; };
const removeAlertReducer = (state, { payload: alertId }) => ({ ...state, result: _.omit(state.result || {}, alertId), });
_.each(deployment.clusters, function(cluster, name) { cleanedClusters[name] = _.omit(cluster, ["gateways", "dialects"]); });
(_.first([1,2,3]): number); (_.first([1,2,3], 2): Array<number>); (_.last([1,2,3]): number); (_.last([1,2,3], 2): Array<number>); (_.sample([1,2,3]): number); (_.sortBy(['hello', 'world'], function(e) { return e.length }): Array<string>); (_.uniq([1,2,2]): Array<number>); (_.compact([1, null]): Array<number>); (_.select([1,2,3], function(e) { return e % 2 == 0 }): Array<number>); (_.reject([1,2,3], function(e) { return e % 2 == 0 }): Array<number>); (_.without([1,2,3], 1, 2): Array<number>); (_.has({a: 1, b: 2}, 'b'): boolean); (_.isArray([1, 2]): boolean); (_.isArray(1): boolean); (_.pick({a: 1, b: 2}, 'a'): {[key: string]: number}); (_.omit({a: 1, b: 2}, 'a'): {[key: string]: number}); _.throttle(function(a) {a.length}, 10)('hello'); _.debounce(function(a) {a.length}, 10)('hello'); _.memoize(function(){})(); _.partial(function (a, b) { return a + b }, 1)(2); _.delay(function(){}, 0); _.defer(function(){}); ( _.compose( function (name:string):string { return name + ', hello!'; }, function (user:Object):string { return user.name; } ): (user: Object) => string
this.analyzeSalaryFile = function analyzeSalaryFile(filePath, columnSettings, headersRowNumber, company, cb) { try { var workbook = xlsx.readFile(filePath); } catch (err) { return cb(err); } let worksheet = workbook.Sheets[workbook.SheetNames[0]]; let salaries = xlsx.utils.sheet_to_json(worksheet, { range: headersRowNumber - 1, raw: true }); columnSettings = _.omit(columnSettings, (value, key, object) => value === null); let onlyPortfolio = false; if (Object.keys(columnSettings).length === 2) { if (columnSettings.hasOwnProperty('גודל תיק')) onlyPortfolio = true; } try { salaries = salaries .map((s, index) => { let sal = Object.keys(s).reduce((newObj, key) => { newObj[key.trim()] = s[key].toString(); return newObj; }, {}); sal.line = index + headersRowNumber + 1; return sal; }) .map(s => { let obj = {}; let invalidSettings = []; Object.keys(columnSettings).map(setting => { if (setting == 'מספר סוכן') { let agentNumber = s[columnSettings[setting].trim()]; if (agentNumber !== undefined) { // throw 'invalid agent number: ' + agentNumber obj[setting] = agentNumber.trim(); } } else if (s[columnSettings[setting].trim()] != null) { let value = s[columnSettings[setting].trim()].trim().replace(/,/g, '').match(/(?=.)^-?(([1-9][0-9]{0,2}(,[0-9]{3})*)|[0-9]+)?(\.[0-9]+)?$/g); if (value !== null && value.length === 1) obj[setting] = Number(value[0]); // throw 'invalid salary: ' + JSON.stringify(s) + ' invalid ' + setting } }); if (onlyPortfolio) { if (company.indexOf('וולתסטון') === -1) obj['נפרעים'] = 0; else obj['נדלן'] = 0; } Object.keys(columnSettings).forEach(setting => { if (!obj.hasOwnProperty(setting)) { // throw 'missing: ' + setting + ' in salary: ' + JSON.stringify(s) invalidSettings.push(setting); } else if (isNaN(obj[setting]) && setting !== 'מספר סוכן') { // throw 'invalid ' + setting + ' in salary ' + JSON.stringify(s) invalidSettings.push(setting); } }); if (invalidSettings.length > 0) { obj.invalid = true; obj.invalidSettings = invalidSettings; obj.line = s.line; } return obj; }); return cb(null, salaries); } catch (err) { return cb(err); } };
function buildModuleDefs(asts) { return _.map(_.omit(asts, 'main'), function(ast, name) { return { type: 'ModuleDef', name: name, elements: ast.elements }; }); }
updateHistory({ historyId, step, integration, event, data, triggerWord, ranPrepareScript, prepareSentMessage, processSentMessage, resultMessage, finished, url, httpCallData, httpError, httpResult, error, errorStack }) { const history = { type: 'outgoing-webhook', step, }; // Usually is only added on initial insert if (integration) { history.integration = integration; } // Usually is only added on initial insert if (event) { history.event = event; } if (data) { history.data = { ...data }; if (data.user) { history.data.user = _.omit(data.user, ['services']); } if (data.room) { history.data.room = data.room; } } if (triggerWord) { history.triggerWord = triggerWord; } if (typeof ranPrepareScript !== 'undefined') { history.ranPrepareScript = ranPrepareScript; } if (prepareSentMessage) { history.prepareSentMessage = prepareSentMessage; } if (processSentMessage) { history.processSentMessage = processSentMessage; } if (resultMessage) { history.resultMessage = resultMessage; } if (typeof finished !== 'undefined') { history.finished = finished; } if (url) { history.url = url; } if (typeof httpCallData !== 'undefined') { history.httpCallData = httpCallData; } if (httpError) { history.httpError = httpError; } if (typeof httpResult !== 'undefined') { history.httpResult = JSON.stringify(httpResult, null, 2); } if (typeof error !== 'undefined') { history.error = error; } if (typeof errorStack !== 'undefined') { history.errorStack = errorStack; } if (historyId) { RocketChat.models.IntegrationHistory.update({ _id: historyId }, { $set: history }); return historyId; } else { history._createdAt = new Date(); return RocketChat.models.IntegrationHistory.insert(Object.assign({ _id: Random.id() }, history)); } }
var classNames = require('classnames'); var _ = require('underscore'); module.exports = React.createClass({ displayName: 'FormLabel', propTypes: { verticalAlign: React.PropTypes.oneOf(['baseline', 'bottom', 'inherit', 'initial', 'middle', 'sub', 'super', 'text-bottom', 'text-top', 'top']), className: React.PropTypes.string }, render() { // classes var className = classNames('form-label', this.props.className); // props var props = _.omit(this.props, ['htmlFor', 'id', 'className', 'style']); // style var style; if (this.props.verticalAlign) { style = { verticalAlign: this.props.verticalAlign } } return ( <label className={className} htmlFor={this.props.htmlFor || this.props.id} style={style || this.props.style} {...props}> {this.props.children} </label> );
_pushState: function(params) { var paramsString = this._urlParamsToString(_.omit(params, ['saveState'])); var current = mediator.execute('pageCache:getCurrent'); mediator.execute('changeUrl', current.path + '?' + paramsString); },
it('validates config : recipients', done => { assertConfigIsInvalid(done, [_.omit(alertConfig, 'recipients')]); });
this.symbols.forEach(function(sym){ var node = _.omit(sym,'node','symbol'); obj.symbols.push(node); });
it('validates config : is_report_counted', done => { assertConfigIsInvalid(done, [_.omit(alertConfig, 'is_report_counted')]); });
backgridInitialize: function(options) { this.columns = options.columns; var filteredOptions = _.omit( options, ['el', 'id', 'attributes', 'className', 'tagName', 'events', 'themeOptions'] ); this.header = options.header || this.header; var headerOptions = _.extend({}, filteredOptions); this.columns.trigger('configureInitializeOptions', this.header, headerOptions); if (headerOptions.themeOptions.hide) { this.header = null; } this.body = options.body || this.body; var bodyOptions = _.extend({}, filteredOptions); this.columns.trigger('configureInitializeOptions', this.body, bodyOptions); this.footer = options.footer || this.footer; var footerOptions = _.extend({}, filteredOptions); this.columns.trigger('configureInitializeOptions', this.footer, footerOptions); if (footerOptions.themeOptions.hide) { this.footer = null; } // must construct body first so it listens to backgrid:sort first this.body = new this.body(bodyOptions); if (this.header) { this.header = new this.header(headerOptions); if ('selectState' in this.header.row.cells[0]) { this.selectState = this.header.row.cells[0].selectState; } } if (this.selectState === null) { this.selectState = new SelectState(); } if (this.footer) { this.footer = new this.footer(footerOptions); } this.listenTo(this.columns, 'reset', function() { if (this.header) { this.header = new (this.header.remove().constructor)(headerOptions); } this.body = new (this.body.remove().constructor)(bodyOptions); if (this.footer) { this.footer = new (this.footer.remove().constructor)(footerOptions); } this.render(); }); this.listenTo(this.collection, { 'remove': this.onCollectionModelRemove, 'updateState': this.onCollectionUpdateState, 'backgrid:selected': this.onSelectRow, 'backgrid:selectAll': this.selectAll, 'backgrid:selectAllVisible': this.selectAllVisible, 'backgrid:selectNone': this.selectNone, 'backgrid:isSelected': this.isSelected, 'backgrid:getSelected': this.getSelected }); },
it('validates config : num_reports_threshold', done => { assertConfigIsInvalid(done, [_.omit(alertConfig, 'num_reports_threshold')]); });
initialize: function(options) { this.options = _.extend({}, this.options, _.pick(options, ['screenType', 'component'])); this.options.componentOptions = _.omit(options, _.keys(this.options)); tools.loadModules(this.options.component, _.bind(this.onComponentLoaded, this)); },
toJSON: function () { return { type: this.get('type'), properties: _.omit(this.attributes, 'type', 'autogenerated') }; }
import React from 'react'; import _ from 'underscore'; import Target from './target-container.js'; import * as _Themes from './themes.js'; const Themes = _.omit(_Themes, '__esModule'); // Because it gets added by default class Body extends React.Component { constructor() { super(); this.state = { selected: Object.keys(Themes)[0] } } handleChange(event) { this.setState({ selected: event.target.value }); } render() { return ( <div> <select value={this.state.selected} onChange={this.handleChange.bind(this)}> { _.map(Themes, (theme, key) => ( <option key={key} value={key}>{theme.name}</option> )) } </select>
co(function* (){ var _counter = thunkQuery(UnitOfAnalysis.select(UnitOfAnalysis.count('counter')), _.omit(req.query, 'offset', 'limit', 'order')); var langId = yield* detectLanguage(req); var uoa = thunkQuery(getTranslateQuery(langId, UnitOfAnalysis)); return yield [_counter, uoa]; }).then(function(data){
displayName: 'Table', propTypes: { cols: React.PropTypes.array, rows: React.PropTypes.array, headers: React.PropTypes.array, className: React.PropTypes.string }, render() { // classes var componentClass = classNames( 'table', this.props.className ); // props var props = _.omit(this.props, ['cols', 'rows', 'headers', 'className']); // cols var tableCols; if (this.props.cols) { var cols = this.props.cols.map(function(col, i) { return ( <col key={'col' + i} width={col} /> ); }); } var tableCols = this.props.cols ? <colgroup>{cols}</colgroup> : null; return ( <table {...props} className={componentClass}> {tableCols}