function buildRulesFromPackageNames(packageNames) { return _(packageNames) .filter((p) => /^textlint-rule-/.test(p) && p !== "textlint-rule-helper") .map(getPackageInfo) .value(); }
}; httpOpts.jar = false; // disable cookies: avoids CSRF issues httpOpts.prepareToSend(jobUpdateUrl, jsonData); httpUtils.requestWithoutRetry(httpOpts, this.emit.bind(this), function(err, resp) { if(err) { return done(err); } if(resp.statusCode !== 200) { return done(new Error("Sauce job update failed with http status code:" + resp.statusCode)); } httpUtils.emit(_this, 'POST', '/rest/v1/:user/jobs/:sessionID', jsonData); done(); }); }; _(commands).each(function(fn, name) { Webdriver.prototype[name] = function() { var _this = this; var fargs = utils.varargs(arguments); this.emit('command', "CALL" , name + niceArgs(fargs.all)); var cb = function(err) { if(err) { err.message = '[' + name + niceArgs(fargs.all) + "] " + err.message; if(fargs.callback) { fargs.callback(err); } } else { var cbArgs = __slice.call(arguments, 0); _this.emit('command', "RESPONSE" , name + niceArgs(fargs.all), niceResp(_.drop(cbArgs))); if(fargs.callback) { fargs.callback.apply(null, cbArgs); } } };
if (error){ console.log('went wrong'); return; } //when dataBuffer is collected var string = dataBuffer.toString(); waiting--; contents[key] = string; //key is remembered here because passed to grabContents checkIfCompleted(); })); }); }; //after each grabContents we must check if all url's are grabbed var checkIfCompleted = function(){ //early return when not if (waiting){ return; } //output every item in array to the console _(contents).each(function(content){ console.log(content); }); }; //initialize grabbing for each url in urls _(urls).each(function(url, key){ waiting++; grabContents(url, key); });
exports.renderDebugPolygons = function (context, map, displayColors) { var color; if (map.centers.length === 0) { // We're still constructing the map so we may have some points context.fillStyle = '#dddddd'; context.fillRect(0, 0, core.toInt(map.SIZE.width), core.toInt(map.SIZE.height) /*context.canvas.width, context.canvas.height */); //graphics.drawRect(0, 0, SIZE, SIZE); _(map.points).each(function (point) { context.beginPath(); context.strokeStyle = '#000000'; context.fillStyle = '#000000'; context.arc(point.x, point.y, 1.3, Math.PI, 2 * Math.PI, false); context.closePath(); context.fill(); context.stroke(); }); } _(map.centers).each(function (p) { color = !_.isNull(p.biome) ? displayColors[p.biome] : (p.ocean ? displayColors.OCEAN : p.water ? displayColors.RIVER : 0xffffff); //Draw shape context.beginPath(); _(p.borders).each(function (edge) { if (!_.isNull(edge.v0) && !_.isNull(edge.v1)) { context.moveTo(p.point.x, p.point.y); context.lineTo(edge.v0.point.x, edge.v0.point.y); context.lineTo(edge.v1.point.x, edge.v1.point.y); } }); context.closePath(); context.fillStyle = colorModule.intToHexColor(colorModule.interpolateColor(color, 0xdddddd, 0.2)); context.fill(); //Draw borders _(p.borders).each(function (edge) { if (!_.isNull(edge.v0) && !_.isNull(edge.v1)) { context.beginPath(); context.moveTo(edge.v0.point.x, edge.v0.point.y); if (edge.river > 0) { context.lineWidth = 1; context.strokeStyle = colorModule.intToHexColor(displayColors.RIVER); } else { context.lineWidth = 0.1; context.strokeStyle = '#000000'; } context.lineTo(edge.v1.point.x, edge.v1.point.y); context.closePath(); context.stroke(); } }); context.beginPath(); context.fillStyle = (p.water ? '#003333' : '#000000'); context.globalAlpha = 0.7; context.arc(p.point.x, p.point.y, 1.3, Math.PI, 2 * Math.PI, false); context.closePath(); context.fill(); context.globalAlpha = 1.0; _(p.corners).each(function (q) { context.fillStyle = q.water ? '#0000ff' : '#009900'; context.fillRect(core.toInt(q.point.x - 0.7), core.toInt(q.point.y - 0.7), core.toInt(1.5), core.toInt(1.5)); }); }); };
return function checkDependencies(options, done) { var mappings, validRun = true, packageDir = options.packageDir || findup('package.json').replace(/package\.json$/, ''), scopeList = options.scopeList || ['peerDependencies', 'dependencies', 'devDependencies'], npmInstall = !!options.npmInstall, packageJson = grunt.file.readJSON(path.join(packageDir, 'package.json')); // Get names of all packages specified in package.json together with specified version numbers. mappings = scopeList.reduce(function (result, scope) { return _.merge(result, packageJson[scope] || {}); }, {}); // Make sure each package is present and matches a required version. _(mappings).forEach(function (versionString, name) { if (!grunt.file.exists(path.join(packageDir, 'node_modules', name))) { grunt.log.error(name + ': ' + 'not installed!'.red); validRun = false; return; } // Quick and dirty check - make sure we're dealing with semver, not // a URL or a shortcut to the GitHub repo. if (/\//.test(versionString)) { return; } var version = grunt.file.readJSON(path.join(packageDir, 'node_modules', name, 'package.json')).version; if (!semver.satisfies(version, versionString)) { validRun = false; grunt.log.error(name + ': installed: ' + version.red + ', expected: ' + versionString.green); } if (validRun) { grunt.verbose.writeln(name + ': installed: ' + version.green + ', expected: ' + versionString.green); } }); if (validRun) { done(true); } else { if (!npmInstall) { grunt.log.writeln('Invoke ' + 'npm install'.green + ' to install missing packages'); done(false); } else { grunt.log.writeln('Invoking ' + 'npm install'.green + '...'); // execSync errors on non-empty stderr; silent such output. spawn('npm', ['install'], { cwd: '.', stdio: 'inherit', }).on('close', function (code) { if (code !== 0) { grunt.log.error('npm install failed with code: ' + (code + '').red); done(false); } else { done(true); } }); } } };
find: function (query, queryOptions, callback) { var self = this; var options = { autoResolveProperties: true, entityResolver: generateObject }; queryOptions = _.defaults(queryOptions, {skip: 0, limit: -1}); var tableQuery = new azure.TableQuery(); var pageSize = queryOptions.skip + queryOptions.limit; tableQuery = _(query) .map(function (queryValue, queryKey) { if (_.isArray(queryValue)) { return _.map(queryValue, function (qV) { qV = defaultQueryValues(qV); return { key: queryKey + ' ' + qV.operator + ' ?' + (qV.isDate ? 'date?' : ''), value: qV.isDate ? new Date(qV.value) : qV.value } }); } else { queryValue = defaultQueryValues(queryValue); return { key: queryKey + ' ' + queryValue.operator + ' ?' + (queryValue.isDate ? 'date?' : ''), value: queryValue.isDate ? new Date(queryValue.value) : queryValue.value } } }) .flatten() .reduce(function (result, val, key) { if (result._where.length === 0) return tableQuery.where(val.key, val.value); return result.and(val.key, val.value); }, tableQuery); if (queryOptions.limit !== -1) { tableQuery = tableQuery.top(pageSize); } self.checkConnection(function (err) { if (err) { return callback(err); } var entities = []; var continuationToken = queryOptions.continuationToken; async.doWhilst(function (end) { // retrieve entities self.client.queryEntities(self.collectionName, tableQuery, continuationToken, options, function (err, results) { if (err) { return end(err); } continuationToken = results.continuationToken; entities = entities.concat(results.entries); end(null); }); }, function () { // test if we need to load more return (entities.length < pageSize || pageSize == -1) ? continuationToken !== null : false; }, function (err) { // return results if (err) { return callback(err); } if (queryOptions.skip !== undefined && queryOptions.limit !== undefined) { if (queryOptions.limit === -1) { entities = entities.slice(queryOptions.skip); } else { entities = entities.slice(queryOptions.skip, pageSize); } } var vms = _.map(entities, function (data) { var vm = new ViewModel(data, self); vm.actionOnCommit = 'update'; return vm; }); if (continuationToken) { vms.continuationToken = continuationToken; } callback(null, vms); }); }); },
const getRandomWithPriority = obj => ( _(obj) .map((v, k) => _.times(v, _.constant(parseInt(k, 10)))) .flatten() .sample() );
process: function(docs) { // Generate an object collection of pages that is grouped by section e.g. // - section "directive" // - group "Tab Bar" // - ion-tabs // - ion-tab // - group "" // - ion-toggle // - ion-checkbox // - ... // var groups = _(docs) .filter(function(doc) { return doc.area === 'api'; }) .filter(function(doc) { return doc.module === 'ionic'; }) .filter(function(doc) { return doc.docType !== 'componentGroup'; }) .groupBy(function(doc) { if (!doc.group) doc.group = 'Other'; return doc.group; }) .map(function(pages, groupName) { var sections = _(pages) .groupBy('docType') .map(function(pages, docType) { return { name: docType, pages: _(pages) .sortBy(function(doc) { return doc.groupMainItem; }) .map(function(doc) { return { href: doc.path, name: doc.name, docType: doc.docType, type: doc.docType, }; }) .filter(function(doc) { return !!doc.name; }) .value() }; }) .sortBy(function(section) { //Directives always first return section.name != 'directive'; }) .value(); return { name: groupName, sections: sections }; }) .sortBy(function(group) { //Sort by groups with most items last return _.values(group.sections).length; }) .value(); _.forEach(docs, function(doc) { if ( !doc.path ) { log.warn('Missing path property for ', doc.id); } }); var docData = { docType: 'pages-data', id: 'pages-data', template: processorConfig.template || 'pages-data.template.js', outputPath: processorConfig.outputPath || 'js/pages-data.js', groups: groups }; docs.push(docData); }
Kit.prototype.filter = function () { var nodes = this.dom.filter.apply(this.dom.map(factory), arguments); return factory(_(nodes).pluck('dom').flatten().value()); };
p.getUnmetDependencies = function() { var wrapped = _(this._nodes); wrapped = wrapped.map(nodesIterator.bind(this)); wrapped = wrapped.compact(); return wrapped.value(); };
module.exports = Request.get(LIST_MODULES_URL, { json: true }).then(function (data) { var modules = data.modules; return { entry: './webtask', output: { path: './dist', filename: pkg.name+'.js', library: true, libraryTarget: 'commonjs2', }, module: { loaders: [ { test: /\.jade$/, loader: StringReplacePlugin.replace({ replacements: [ { pattern: /@assets_baseurl/ig, replacement: function (match, p1, offset, string) { var location = 'http://localhost:3000'; if ((process.env.NODE_ENV || 'development') !== 'development') { location = 'https://cdn.auth0.com/extensions/' + pkg.name + '/assets'; } return location; }.bind(this) }, { pattern: /@extension_name/ig, replacement: function (match, p1, offset, string) { return pkg.name + '-' + pkg.version; }.bind(this) } ] }) }, { test: /\.jade$/, loader: require.resolve('jade-loader') } ] }, externals: _(modules).reduce(function (acc, module) { if (module.name === 'auth0-oauth2-express') { return _.set(acc, module.name, false); } return _.set(acc, module.name, true); }, { // Not provisioned via verquire 'auth0-api-jwt-rsa-validation': true, 'auth0-authz-rules-api': true, 'auth0-oauth2-express': false, 'auth0-sandbox-ext': true, 'detective': true, 'sandboxjs': true, 'webtask-tools': true, }), plugins: [ new StringReplacePlugin(), new Webpack.optimize.DedupePlugin(), new Webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } }) ], resolve: { modulesDirectories: ['node_modules'], root: __dirname, alias: {}, }, node: { console: false, global: false, process: false, Buffer: false, __filename: false, __dirname: false } }; });
parse(data) { data = data.replace(/\s+$/, ''); if (settings.debug) { // console.log('<<', data); } if (!data) { return; } this.emit('raw', data); // Example: Grbl 0.9j ['$' for help] if (matchGrblInitializationMessage(data)) { this.emit('startup', { raw: data }); return; } if (matchGrblCurrentStatus(data)) { let r = data.match(/<(\w+),\w+:([^,]+),([^,]+),([^,]+),\w+:([^,]+),([^,]+),([^,]+)>/); let status = { activeState: r[1], // Active States: Idle, Run, Hold, Door, Home, Alarm, Check machinePos: { // Machine position x: r[2], y: r[3], z: r[4] }, workingPos: { // Working position x: r[5], y: r[6], z: r[7] } }; this.emit('status', { raw: data, status: status }); if (!(_.isEqual(this.status, status))) { this.emit('statuschange', { raw: data, status: status }); } this.status = status; return; } if (matchGrblParserState(data)) { let r = data.match(/\[([^\]]*)\]/); let words = _(r[1].split(' ')) .compact() .map((word) => { return _.trim(word); }) .value(); let parserstate = {}; _.each(words, (word) => { // Gx, Mx if (word.indexOf('G') === 0 || word.indexOf('M') === 0) { let r = _.find(GRBL_MODAL_GROUPS, (group) => { return _.includes(group.modes, word); }); if (r) { _.set(parserstate, 'modal.' + r.group, word); } } // T: tool number if (word.indexOf('T') === 0) { _.set(parserstate, 'tool', word.substring(1)); } // F: feed rate if (word.indexOf('F') === 0) { _.set(parserstate, 'feedrate', word.substring(1)); } // S: spindle speed if (word.indexOf('S') === 0) { _.set(parserstate, 'spindle', word.substring(1)); } }); this.emit('parserstate', { raw: data, parserstate: parserstate }); if (!(_.isEqual(this.parserstate, parserstate))) { this.emit('parserstatechange', { raw: data, parserstate: parserstate }); } this.parserstate = parserstate; return; } if (data.indexOf('ok') === 0) { this.emit('ok', { raw: data }); return; } if (data.indexOf('error') === 0) { this.emit('error', { raw: data }); return; } if (data.length > 0) { this.emit('others', { raw: data }); return; } }
_.each(sails.middleware.controllers, function eachController (controller, controllerId) { if ( !_.isObject(controller) || _.isArray(controller) ) return; // Get globalId for use in errors/warnings var globalId = sails.controllers[controllerId].globalId; // Determine blueprint configuration for this controller var config = _.merge({}, sails.config.blueprints, controller._config || {}); // Validate blueprint config for this controller if ( config.prefix ) { if ( !_(config.prefix).isString() ) { sails.after('lifted', function () { console.log(); sails.log.warn(util.format('Ignoring invalid blueprint prefix configured for controller `%s`.', globalId)); sails.log.warn('`prefix` should be a string, e.g. "/api/v1".'); STRINGFILE.logMoreInfoLink(STRINGFILE.get('links.docs.config.blueprints'), sails.log.warn); }); return; } if ( !config.prefix.match(/^\//) ) { var originalPrefix = config.prefix; sails.after('lifted', function () { console.log(); sails.log.warn(util.format('Invalid blueprint prefix ("%s") configured for controller `%s` (should start with a `/`).', originalPrefix, globalId)); sails.log.warn(util.format('For now, assuming you meant: "%s".', config.prefix)); STRINGFILE.logMoreInfoLink(STRINGFILE.get('links.docs.config.blueprints'), sails.log.warn); }); config.prefix = '/' + config.prefix; } } // Determine the names of the controller's user-defined actions // Use `sails.controllers` instead of `sails.middleware.controllers` (which will have blueprints already mixed-in) var actions = Object.keys(sails.controllers[controllerId]); // Determine base route var baseRoute = config.prefix + '/' + controllerId; if (config.pluralize) { baseRoute = pluralize(baseRoute); } // Build route options for blueprint var routeOpts = config; // Bind "actions" and "index" shadows _.each(actions, function eachActionID (actionId) { var opts = _.merge({ action: actionId, controller: controllerId }, routeOpts); // Bind a route based on the action name, if `actions` shadows enabled if (config.actions) { var actionRoute = baseRoute + '/' + actionId.toLowerCase() + '/:id?'; sails.log.silly('Binding action ('+actionId.toLowerCase()+') blueprint/shadow route for controller:',controllerId); sails.router.bind(actionRoute, controller[actionId.toLowerCase()], null, opts); } // Bind base route to index action, if `index` shadows are not disabled if (config.index !== false && actionId.match(/^index$/i)) { sails.log.silly('Binding index blueprint/shadow route for controller:',controllerId); sails.router.bind(baseRoute, controller.index, null, opts); } }); // If the orm hook is enabled, it has already been loaded by this time, // so just double-check to see if `sails.models` exists before trying to // bind CRUD blueprint actions. if (sails.hooks.orm && sails.models && sails.models[controllerId]) { // If a model exists with the same identity as this controller, // extend route options with the id of the model. routeOpts.model = controllerId; var Model = sails.models[controllerId]; // TODO: determine whether we can remove the following now: // // Locate and validate `id` parameter // var id = sails.util.(req.param('id'), req.target.controller, 'find'); // var id = req.param('id'); // if (id === false) { // // Id was invalid-- and probably unintentional. // // Continue on as if this blueprint doesn't exist // return next(); // } // Bind convenience functions for readability below: var _getAction = _.partial(_getMiddlewareForShadowRoute, controllerId); var _getRoute = _.partialRight(util.format,baseRoute); // Mix in the known associations for this model to the route options. routeOpts = _.merge({ associations: _.cloneDeep(Model.associations) }, routeOpts); // Bind URL-bar "shortcuts" // (NOTE: in a future release, these may be superceded by embedding actions in generated controllers // and relying on action blueprints instead.) if ( config.shortcuts ) { sails.log.silly('Binding shortcut blueprint/shadow routes for model+controller:',controllerId); sails.router.bind( _getRoute('%s/find/:id?'), _getAction('find'), null, routeOpts ); sails.router.bind( _getRoute('%s/create'), _getAction('create'), null, routeOpts ); sails.router.bind( _getRoute('%s/update/:id'), _getAction('update'), null, routeOpts ); sails.router.bind( _getRoute('%s/destroy/:id?'), _getAction('destroy'), null, routeOpts ); // Bind "shortcuts" for add/remove (plural associations only) _(Model.associations).where({type: 'collection'}).forEach(function (association) { var alias = association.alias; var _getAssocRoute = _.partialRight(util.format, baseRoute, alias); var opts = _.merge({ alias: alias }, routeOpts); sails.log.silly('Binding "shortcuts" to association blueprint `'+alias+'` for',controllerId); sails.router.bind( _getAssocRoute('%s/:parentid/%s/add'), _getAction('add'), null, opts ); sails.router.bind( _getAssocRoute('%s/:parentid/%s/remove'), _getAction('remove'), null, opts ); }); } // Bind "rest" blueprint/shadow routes if ( config.rest ) { sails.log.silly('Binding RESTful blueprint/shadow routes for model+controller:',controllerId); sails.router.bind( _getRoute('get %s/:id?'), _getAction('find'), null, routeOpts ); sails.router.bind( _getRoute('post %s'), _getAction('create'), null, routeOpts ); sails.router.bind( _getRoute('put %s/:id'), _getAction('update'), null, routeOpts ); sails.router.bind( _getRoute('delete %s/:id?'), _getAction('destroy'), null, routeOpts ); // Bind "rest" blueprint/shadow routes based on known associations in our model's schema _(Model.associations).forEach(function (association) { var alias = association.alias; var _getAssocRoute = _.partialRight(util.format, baseRoute, alias); var opts = _.merge({ alias: alias }, routeOpts); sails.log.silly('Binding RESTful association blueprint `'+alias+'` for',controllerId); sails.router.bind( _getAssocRoute('get %s/:parentid/%s/:id?'), _getAction('populate'), null, opts ); sails.router.bind( _getAssocRoute('post %s/:parentid/%s'), _getAction('add'), null, opts ); sails.router.bind( _getAssocRoute('delete %s/:parentid/%s'), _getAction('remove'), null, opts ); }); } } });
return fetch().then(function () { return _(repo.branches) .keys() .map(createBranchBuilder) .reduce(q.when, q(0)); });
Resources.prototype.resourceNamesOf = function (memberId) { var self = this; return _(self.resourceNames()).map(function (resourceName) { return self.named(resourceName).isAlreadyRegistered(memberId) && resourceName; }).compact().sort().value(); };
hasAccess: function(req, access, entity, res) { var method = req.method.toUpperCase(); // Determine the roles and user based on the available token. var roles = [access.defaultRole]; var user = null; if (req.user) { user = util.idToString(req.user._id); // Get the roles for the permission checks. req.user.roles = req.user.roles || []; // If the user actually has roles, remove the default role and check their access using their roles. if (req.user.roles.length > 0) { // Add the users id to the roles to check for submission resource access. req.user.roles.push(user); // Ensure that all roles are strings to be compatible for comparison. roles = _(req.user.roles) .filter() .map(util.idToString) .uniq() .value(); } } // Setup some flags for other handlers. req.isAdmin = false; req.ownerAssign = false; // Check to see if this user has an admin role. var hasAdminRole = access.adminRole ? (_.indexOf(roles, access.adminRole) !== -1) : false; if (hasAdminRole || hook.alter('isAdmin', req.isAdmin, req)) { req.isAdmin = true; debug.permissions('Admin: true'); return true; } // See if we have an anonymous user with the default role included in the create_all access. if ( access.submission.hasOwnProperty('create_all') && (_.intersection(access.submission.create_all, roles).length > 0) ) { debug.permissions('Assign Owner: true'); req.ownerAssign = true; } debug.permissions('req.submissionResourceAccessAdminBlock: ' + req.submissionResourceAccessAdminBlock); debug.permissions('Checking access for method: ' + method); debug.permissions('Checking access for user: '******'POST': ['create_all', 'create_own'], 'GET': ['read_all', 'read_own'], 'PUT': ['update_all', 'update_own'], 'DELETE': ['delete_all', 'delete_own'] }; // Check if the user making the request owns the entity being requested. if ( user && access.hasOwnProperty(entity.type) && access[entity.type].hasOwnProperty('owner') && req.token.user._id === access[entity.type].owner ) { debug.permissions('This request is being made by the owner, Access Granted.'); _hasAccess = true; } // Using the given method, iterate the 8 available entity access. Compare the given roles with the roles // defined by the entity to have access. If this roleId is found within the defined roles, grant access. var search = methods[method]; if (!search || typeof search === 'undefined') { router.formio.util.error({ method: req.method, _method: method }); } // Unsupported request method. if (search === undefined) { if (res) { res.sendStatus(404); } return false; } search.forEach(function(type) { // Check if the given roles are contained within the allowed roles for our roles.forEach(function(role) { // Grant access if the role was found in the access for this resource. if ( access.hasOwnProperty(entity.type) && access[entity.type].hasOwnProperty(type) && ( (access[entity.type][type] === true) || (access[entity.type][type] instanceof Array && access[entity.type][type].indexOf(role) !== -1) ) ) { // Allow anonymous users to create a submission for themselves if defined. if (type === 'create_own') { _hasAccess = true; } else if (type.toString().indexOf('_own') !== -1) { // Entity has an owner, Request is from a User, and the User is the Owner. // OR, selfAccess was flagged, and the user is the entity. /* eslint-disable max-len */ if ( (access[entity.type].hasOwnProperty('owner') && user && access[entity.type].owner === user) || (req.selfAccess && user && access[entity.type].hasOwnProperty('_id') && user.toString() === access[entity.type]._id.toString()) ) { _hasAccess = true; } // Exception for Index endpoint, the else if (type === 'read_own' && entity.hasOwnProperty('id') && entity.id === '') { // The user has access to this endpoint, however the results will need to be filtered by the // ownerFilter middleware. _hasAccess = true; } /* eslint-enable max-len */ } else { // If the current request has been flagged for submission resource access (admin permissions). var submissionResourceAdmin = (_.get(req, 'submissionResourceAccessAdminBlock') || []); // Only allow certain users to edit the owner and submission access property. // (~A | B) logic for submission access, to not affect old permissions. if ( (type === 'create_all' || type === 'update_all') && submissionResourceAdmin.indexOf(util.idToString(role)) === -1 ) { // Only allow the the bootstrapEntityOwner middleware to assign an owner if defined in the payload. if (_.has(req, 'body.owner')) { req.assignOwner = true; } // Only allow the the bootstrapSubmissionAccess middleware to assign access if defined in the payload. if (entity.type === 'submission' && _.has(req, 'body.access')) { req.assignSubmissionAccess = true; } } // No ownership requirements here. req.skipOwnerFilter = true; _hasAccess = true; } } debug.permissions('----------------------------------------------------'); debug.permissions('type: ' + type); debug.permissions('role: ' + role); debug.permissions('_hasAccess: ' + _hasAccess); debug.permissions('selfAccess: ' + req.selfAccess); }); }); // No prior access was granted, the given role does not have access to this resource using the given method. debug.permissions('assignOwner: ' + req.assignOwner); debug.permissions('assignSubmissionAccess: ' + req.assignSubmissionAccess); debug.permissions('req.submissionResourceAccessFilter: ' + req.submissionResourceAccessFilter); debug.permissions('hasAccess: ' + _hasAccess); return _hasAccess; }
fs.readdir(awm.config.cacheDir, function(err, cachedDownloads){ _(cachedDownloads).each(function(file){ console.info(('Removing ' + awm.config.cacheDir + file + '...').cyan); fs.unlink(awm.config.cacheDir + file); }); });
const songs川 = groups川.map(groups => _(groups).map('songs').flatten().value()
Container.prototype.dockerEnv = function() { var env = this.env || {}; return _(env).pairs().map(function(p) { return p.join('='); }).value(); };
return function FieldAggParamFactory(Private) { var _ = require('lodash'); var editorHtml = require('text!components/agg_types/controls/field.html'); var BaseAggParam = Private(require('components/agg_types/param_types/base')); var SavedObjectNotFound = require('errors').SavedObjectNotFound; _(FieldAggParam).inherits(BaseAggParam); function FieldAggParam(config) { FieldAggParam.Super.call(this, config); } FieldAggParam.prototype.editor = editorHtml; FieldAggParam.prototype.scriptable = false; FieldAggParam.prototype.filterFieldTypes = '*'; /** * Called to serialize values for saving an aggConfig object * * @param {field} field - the field that was selected * @return {string} */ FieldAggParam.prototype.serialize = function (field) { return field.name; }; /** * Called to read values from a database record into the * aggConfig object * * @param {string} fieldName * @return {field} */ FieldAggParam.prototype.deserialize = function (fieldName, aggConfig) { var field = aggConfig.vis.indexPattern.fields.byName[fieldName]; if (!field) { throw new SavedObjectNotFound('index-pattern-field', fieldName); } return field; }; /** * Write the aggregation parameter. * * @param {AggConfig} aggConfig - the entire configuration for this agg * @param {object} output - the result of calling write on all of the aggregations * parameters. * @param {object} output.params - the final object that will be included as the params * for the agg * @return {undefined} */ FieldAggParam.prototype.write = function (aggConfig, output) { var field = aggConfig.params.field; if (field.scripted) { output.params.script = field.script; } else { output.params.field = field.name; } }; return FieldAggParam; };
exports.renderRoads = function (graphics, map, roads, colors) { // First draw the roads, because any other feature should draw // over them. Also, roads don't use the noisy lines. var A, B, C; var i, j, d, edge1, edge2, edges; /** * Helper function: find the normal vector across edge 'e' and * make sure to point it in a direction towards 'c'. */ function normalTowards(e, c, len) { // Rotate the v0-->v1 vector by 90 degrees: var n = { x: -(e.v1.point.y - e.v0.point.y), y: e.v1.point.x - e.v0.point.x }; // Flip it around it if doesn't point towards c var d = pointCore.subtract(c, e.midpoint); if (n.x * d.x + n.y * d.y < 0) { n.x = -n.x; n.y = -n.y; } pointCore.normalize(n, len); return n; } _(map.centers).each(function (p) { if (!core.isUndefinedOrNull(roads.roadConnections[p.index])) { if (roads.roadConnections[p.index].length === 2) { // Regular road: draw a spline from one edge to the other. edges = p.borders; for (i = 0; i < edges.length; i++) { edge1 = edges[i]; if (roads.road[edge1.index] > 0) { for (j = i + 1; j < edges.length; j++) { edge2 = edges[j]; if (roads.road[edge2.index] > 0) { // The spline connects the midpoints of the edges // and at right angles to them. In between we // generate two control points A and B and one // additional vertex C. This usually works but // not always. d = 0.5 * Math.min( pointCore.distanceFromOrigin(pointCore.subtract(edge1.midpoint, p.point)), pointCore.distanceFromOrigin(pointCore.subtract(edge2.midpoint, p.point)) ); A = pointCore.add(normalTowards(edge1, p.point, d), edge1.midpoint); B = pointCore.add(normalTowards(edge2, p.point, d), edge2.midpoint); C = pointCore.interpolate(A, B, 0.5); graphics.beginPath(); graphics.lineWidth = 1.1; graphics.strokeStyle = colorModule.intToHexColor(colors['ROAD' + roads.road[edge1.index]]); graphics.moveTo(edge1.midpoint.x, edge1.midpoint.y); graphics.quadraticCurveTo(A.x, A.y, C.x, C.y); graphics.moveTo(C.x, C.y); graphics.lineWidth = 1.1; graphics.strokeStyle = colorModule.intToHexColor(colors['ROAD' + roads.road[edge2.index]]); graphics.quadraticCurveTo(B.x, B.y, edge2.midpoint.x, edge2.midpoint.y); graphics.stroke(); graphics.closePath(); } } } } } else { // Intersection or dead end: draw a road spline from // each edge to the center _(p.borders).each(function (edge1) { if (roads.road[edge1.index] > 0) { d = 0.25 * pointCore.distanceFromOrigin(pointCore.subtract(edge1.midpoint, p.point)); A = pointCore.add(normalTowards(edge1, p.point, d), edge1.midpoint); graphics.beginPath(); graphics.lineWidth = 1.4; graphics.strokeStyle = colorModule.intToHexColor(colors['ROAD' + roads.road[edge1.index]]); graphics.moveTo(edge1.midpoint.x, edge1.midpoint.y); graphics.quadraticCurveTo(A.x, A.y, p.point.x, p.point.y); graphics.stroke(); graphics.closePath(); } }); } } }); };
Resources.prototype.waitinglistResourceNamesOf = function (memberId) { var self = this; return _(self.resourceNames()).map(function (resourceName) { return !!self.named(resourceName).waitinglistEntryFor(memberId) && resourceName; }).compact().sort().value(); };
addGraphsFromDecks(specs){ const newGraphs = _(specs.graphs).map(d => [d.id, d]).zipObject().value(); this.setState({ graphs: _.merge(this.state.graphs, newGraphs) }); }
Resources.prototype.allRegisteredMembers = function () { var self = this; return _(self.state).keys().map(function (key) {return self.named(key).registeredMembers(); }).flatten().uniq().value(); };
getSort.array = function (sort, indexPattern) { return _(getSort(sort, indexPattern)).pairs().pop(); };
Resources.prototype.allWaitinglistEntries = function () { var self = this; return _(self.state).keys().map(function (key) {return self.named(key).waitinglistEntries(); }).flatten().uniq().compact().value(); };
function hybrid_operation_to_uneven(collection) { return _(collection).filter(x => x%2 === 1).map(x =>x*3+2).value(); }
Resources.prototype.registrationDatesOf = function (memberId) { var self = this; return _(self.resourceNames()).map(function (resourceName) { return self.named(resourceName).registrationDateOf(memberId); }).compact().sortBy().value(); };
it('should return all scripted fields', function () { const scriptedNames = _(mockLogstashFields).where({ scripted: true }).pluck('name').value(); const respNames = _.pluck(indexPattern.getScriptedFields(), 'name'); expect(respNames).to.eql(scriptedNames); });
}).then(function (result) { return {expected: max, done: _(result).map('length').sum()}; });