_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q55000
oauthErrorResponder
train
function oauthErrorResponder(req, res, err) { var accepts = req.accepts(['html', 'json']); var config = req.app.get('stormpathConfig'); if (accepts === 'json') { return writeJsonError(res, err); } return renderLoginFormWithError(req, res, config, err); }
javascript
{ "resource": "" }
q55001
defaultUnverifiedHtmlResponse
train
function defaultUnverifiedHtmlResponse(req, res) { var config = req.app.get('stormpathConfig'); res.redirect(302, config.web.login.uri + '?status=unverified'); }
javascript
{ "resource": "" }
q55002
defaultAutoAuthorizeHtmlResponse
train
function defaultAutoAuthorizeHtmlResponse(req, res) { var config = req.app.get('stormpathConfig'); res.redirect(302, url.parse(req.query.next || '').path || config.web.register.nextUri); }
javascript
{ "resource": "" }
q55003
defaultJsonResponse
train
function defaultJsonResponse(req, res) { res.json({ account: helpers.strippedAccount(req.user) }); }
javascript
{ "resource": "" }
q55004
applyDefaultAccountFields
train
function applyDefaultAccountFields(stormpathConfig, req) { var registerFields = stormpathConfig.web.register.form.fields; if ((!registerFields.givenName || !registerFields.givenName.required || !registerFields.givenName.enabled) && !req.body.givenName) { req.body.givenName = 'UNKNOWN'; } if ((!registerFie...
javascript
{ "resource": "" }
q55005
train
function (req, config, callback) { var baseUrl = config.web.baseUrl || req.protocol + '://' + getHost(req); var linkedInAuthUrl = 'https://www.linkedin.com/uas/oauth2/accessToken'; var linkedInProvider = config.web.social.linkedin; var options = { form: { grant_type: 'authorization_code',...
javascript
{ "resource": "" }
q55006
oktaErrorTransformer
train
function oktaErrorTransformer(err) { if (err && err.errorCauses) { err.errorCauses.forEach(function (cause) { if (cause.errorSummary === 'login: An object with this field already exists in the current organization') { err.userMessage = 'An account with that email address already exists.'; } el...
javascript
{ "resource": "" }
q55007
train
function (form) { var data = { email: form.data.email }; if (req.organization) { data.accountStore = { href: req.organization.href }; } application.sendPasswordResetEmail(data, function (err) { ...
javascript
{ "resource": "" }
q55008
train
function (form) { if (config.web.multiTenancy.enabled && req.organization) { setAccountStoreByHref(form.data, req.organization); } else { /** * Delete this form field, it's automatically added by the * forms library. If we do...
javascript
{ "resource": "" }
q55009
getFormFields
train
function getFormFields(form) { // Grab all fields that are enabled, and return them as an array. // If enabled, remove that property and apply the field name. var fields = Object.keys(form.fields).reduce(function (result, fieldKey) { var field = _.clone(form.fields[fieldKey]); if (!field.enabled) { ...
javascript
{ "resource": "" }
q55010
getAccountStores
train
function getAccountStores(application, callback) { var options = { expand: 'accountStore' }; // Get account store mappings. application.getAccountStoreMappings(options, function (err, accountStoreMappings) { if (err) { return callback(err); } // Iterate over all account stores, and filter out ...
javascript
{ "resource": "" }
q55011
getAccountStoreModel
train
function getAccountStoreModel(accountStore) { var provider = accountStore.provider; return { href: accountStore.href, name: accountStore.name, provider: { href: provider.href, providerId: provider.providerId, callbackUri: provider.callbackUri, clientId: provider.clientId } ...
javascript
{ "resource": "" }
q55012
handleAcceptRequest
train
function handleAcceptRequest(req, res, handlers, fallbackHandler) { var config = req.app.get('stormpathConfig'); // Accepted is an ordered list of preferred types, as specified by the request. var accepted = req.accepts(); var produces = config.web.produces; // Our default response is HTML, if the client do...
javascript
{ "resource": "" }
q55013
train
function (form) { var options = { login: form.data.email }; if (req.organization) { options.accountStore = { href: req.organization.href }; } application.resendVerificationEmail(options, function (err...
javascript
{ "resource": "" }
q55014
writeJsonError
train
function writeJsonError(res, err, statusCode) { var status = err.status || err.statusCode || statusCode || 400; var message = 'Unknown error. Please contact support.'; if (err) { message = err.userMessage || err.message; } res.status(status); res.json({ status: status, message: message }); ...
javascript
{ "resource": "" }
q55015
strippedAccount
train
function strippedAccount(account, expansionMap) { expansionMap = typeof expansionMap === 'object' ? expansionMap : {}; var strippedAccount = _.clone(account); var hiddenProperties = ['stormpathMigrationRecoveryAnswer', 'emailVerificationToken']; // Profile data is copied onto custom data, so we don't need to ...
javascript
{ "resource": "" }
q55016
MarkerLabel_
train
function MarkerLabel_(marker, crossURL, handCursorURL) { this.marker_ = marker; this.handCursorURL_ = marker.handCursorURL; this.labelDiv_ = document.createElement("div"); this.labelDiv_.style.cssText = "position: absolute; overflow: hidden;"; // Set up the DIV for handling mouse events in the lab...
javascript
{ "resource": "" }
q55017
train
function(filePath, options) { var clientOptions = {}; if (options && options !== null) { if (typeof options.headers === "object") { clientOptions.headers = options.headers; } } return client.createWriteStream(filePath, c...
javascript
{ "resource": "" }
q55018
train
function(dirPath, callback) { client .createDirectory(dirPath) .then(function() { __executeCallbackAsync(callback, [null]); }) .catch(callback); }
javascript
{ "resource": "" }
q55019
train
function(/* dirPath[, mode], callback */) { var args = Array.prototype.slice.call(arguments), argc = args.length; if (argc <= 1) { throw new Error("Invalid number of arguments"); } var dirPath = args[0], mode = (typeof args[...
javascript
{ "resource": "" }
q55020
train
function(filePath, targetPath, callback) { client .moveFile(filePath, targetPath) .then(function() { __executeCallbackAsync(callback, [null]); }) .catch(callback); }
javascript
{ "resource": "" }
q55021
train
function(targetPath, callback) { client .deleteFile(targetPath) .then(function() { __executeCallbackAsync(callback, [null]); }) .catch(callback); }
javascript
{ "resource": "" }
q55022
train
function(remotePath, callback) { client .stat(remotePath) .then(function(stat) { __executeCallbackAsync(callback, [null, __convertStat(stat)]); }) .catch(callback); }
javascript
{ "resource": "" }
q55023
train
function(/* filename, data[, encoding], callback */) { var args = Array.prototype.slice.call(arguments), argc = args.length; if (argc <= 2) { throw new Error("Invalid number of arguments"); } var filePath = args[0], data = a...
javascript
{ "resource": "" }
q55024
loadMockData
train
function loadMockData(server, next) { // Create REST resources for each employee var resources = data.employees.map(function(employee) { return new swagger.Resource('/employees', employee.username, employee); }); // Save the resources to the mock data store server.dataStore.save(resources, next); }
javascript
{ "resource": "" }
q55025
verifyUsernameDoesNotExist
train
function verifyUsernameDoesNotExist(req, res, next) { var username = req.body.username; var dataStore = req.app.dataStore; // Check for an existing employee REST resource - /employees/{username} var resource = new swagger.Resource('/employees', username, null); dataStore.get(resource, function(err, resource)...
javascript
{ "resource": "" }
q55026
SwaggerServer
train
function SwaggerServer(app) { app = app || express(); // Event Emitter _.extend(this, EventEmitter.prototype); EventEmitter.call(this); /** * @type {Middleware} * @protected */ this.__middleware = new SwaggerMiddleware(app); /** * @type {SwaggerParser} * @protected */ this.__parser ...
javascript
{ "resource": "" }
q55027
createRouter
train
function createRouter() { var rtr = express.Router.apply(express, arguments); router.patch(rtr); return rtr; }
javascript
{ "resource": "" }
q55028
Route
train
function Route(path) { // Convert Swagger-style path to Express-style path path = path.replace(util.swaggerParamRegExp, ':$1'); express.Route.call(this, path); }
javascript
{ "resource": "" }
q55029
train
function(router, target) { // By default, just patch the router's own methods. // If a target is given, then patch the router to call the target's methods target = target || router; // get(setting), which is different than get(path, fn) var get = router.get; // Wrap all of these methods to con...
javascript
{ "resource": "" }
q55030
Handlers
train
function Handlers(server) { var self = this; this.server = server; //Store the most recently parsed swagger data for when only the handlers get re-attached. this.server.on('parsed', function(err, api, parser, basePath) { self.api = api; self.parser = parser; self.basePath = basePath; self.setup...
javascript
{ "resource": "" }
q55031
addPathToExpress
train
function addPathToExpress(handlerObj, handlePath) { var self = handlerObj; //Check to make sure that the module exists and will load properly to what node expects if (moduleExists.call(self, handlePath)) { //retrieve the http verbs defined in the handler files and then add to the swagger server var handle...
javascript
{ "resource": "" }
q55032
moduleExists
train
function moduleExists(name) { //TODO: Check that the file exists before trying to require it. try { require.resolve(name); } catch (err) { this.server.emit('error', err); return false; } return true; }
javascript
{ "resource": "" }
q55033
loadMockData
train
function loadMockData(server, next) { // Create REST resources for each employee photo var resources = []; data.employees.forEach(function(employee) { var collectionPath = '/employees/' + employee.username + '/photos'; resources.push(new swagger.Resource(collectionPath, 'portrait', {path: employee.portrai...
javascript
{ "resource": "" }
q55034
SwaggerWatcher
train
function SwaggerWatcher(server) { var self = this; self.server = server; /** * The Swagger API files that are being watched. * @type {FSWatcher[]} */ self.watchedSwaggerFiles = []; /** * The Handler files that are being watched. * @type {FSWatcher[]} */ self.watchedHandlerFiles = []; ...
javascript
{ "resource": "" }
q55035
watchFile
train
function watchFile(path, onChange) { try { var oldStats = fs.statSync(path); var watcher = fs.watch(path, {persistent: false}); watcher.on('error', watchError); watcher.on('change', function(event) { fs.stat(path, function(err, stats) { if (err) { /* istanbul ignore next: not ...
javascript
{ "resource": "" }
q55036
authenticate
train
function authenticate(req, res, next) { var username = req.body.username, password = req.body.password; if (req.session && req.session.user.username === username) { // This user is already logged in next(); return; } // Get the employee REST resource - /employees/{username} var dataStore =...
javascript
{ "resource": "" }
q55037
sendSessionResponse
train
function sendSessionResponse(req, res, next) { // Set the session cookie res.cookie('session', req.session.id); // Set the Location HTTP header res.location('/sessions/' + req.session.id); // Send the response res.status(201).json(req.session); }
javascript
{ "resource": "" }
q55038
identifyUser
train
function identifyUser(req, res, next) { // Get the session ID from the session cookie var sessionId = req.cookies.session; req.session = null; if (sessionId) { // Get the session REST resource var resource = new swagger.Resource('/sessions', sessionId, null); req.app.dataStore.get(resource, functio...
javascript
{ "resource": "" }
q55039
mustBeLoggedIn
train
function mustBeLoggedIn(req, res, next) { if (req.session && req.session.user) { next(); } else { res.status(401).send('You must be logged-in to access this resource'); } }
javascript
{ "resource": "" }
q55040
adminsOnly
train
function adminsOnly(req, res, next) { if (req.session && _.contains(req.session.user.roles, 'admin')) { next(); } else { res.status(401).send('Only administrators can access this resource'); } }
javascript
{ "resource": "" }
q55041
yourselfOnly
train
function yourselfOnly(req, res, next) { // Get the username or sessionId from the URL var username = req.params.username; var sessionId = req.params.sessionId; if (!req.session) { res.status(401).send('You must be logged-in to access this resource'); } else if (_.contains(req.session.user.roles, 'admin...
javascript
{ "resource": "" }
q55042
loadMockData
train
function loadMockData(server, next) { // Create REST resources for each project var resources = data.projects.map(function(project) { return new swagger.Resource('/projects', project.id, project); }); // Save the resources to the mock data store server.dataStore.save(resources, next); }
javascript
{ "resource": "" }
q55043
verifyProjectIdDoesNotExist
train
function verifyProjectIdDoesNotExist(req, res, next) { var projectId = req.body.id; var dataStore = req.app.dataStore; // Check for an existing project REST resource - /projects/{projectId} var resource = new swagger.Resource('/projects', projectId, null); dataStore.get(resource, function(err, resource) { ...
javascript
{ "resource": "" }
q55044
verifyProjectNameDoesNotExist
train
function verifyProjectNameDoesNotExist(req, res, next) { var projectName = req.body.name.toLowerCase(); var dataStore = req.app.dataStore; // Get all project REST resources dataStore.getCollection('/projects', function(err, resources) { var alreadyExists = resources.some(function(resource) { return r...
javascript
{ "resource": "" }
q55045
find
train
function find (client) { return function find (realmName, userId) { return new Promise((resolve, reject) => { const req = { auth: { bearer: privates.get(client).accessToken }, json: true }; req.url = `${client.baseUrl}/admin/realms/${realmName}/users/${userId}/...
javascript
{ "resource": "" }
q55046
find
train
function find (client) { return function find (realm, options) { return new Promise((resolve, reject) => { options = options || {}; const req = { auth: { bearer: privates.get(client).accessToken }, json: true }; if (options.userId) { req.url = `${...
javascript
{ "resource": "" }
q55047
create
train
function create (client) { return function create (realm, user) { return new Promise((resolve, reject) => { const req = { url: `${client.baseUrl}/admin/realms/${realm}/users`, auth: { bearer: privates.get(client).accessToken }, body: user, method: 'POST', ...
javascript
{ "resource": "" }
q55048
update
train
function update (client) { return function update (realmName, user) { return new Promise((resolve, reject) => { user = user || {}; const req = { url: `${client.baseUrl}/admin/realms/${realmName}/users/${user.id}`, auth: { bearer: privates.get(client).accessToken }, ...
javascript
{ "resource": "" }
q55049
resetPassword
train
function resetPassword (c) { return function resetPassword (realmName, userId, payload) { return new Promise((resolve, reject) => { payload = payload || {}; payload.type = 'password'; if (!userId) { return reject(new Error('userId is missing')); } if (!payload.value) { ...
javascript
{ "resource": "" }
q55050
count
train
function count (client) { return function count (realm) { return new Promise((resolve, reject) => { const req = { auth: { bearer: privates.get(client).accessToken }, json: true, url: `${client.baseUrl}/admin/realms/${realm}/users/count` }; request(req, ...
javascript
{ "resource": "" }
q55051
copyFromValueBuilder
train
function copyFromValueBuilder(otherValueBuilder) { var tb = new ValueBuilder(); // TODO: share with QueryBuilder if (otherValueBuilder != null) { var clauseKeys = [ 'fromIndexesClause', 'whereClause', 'aggregatesClause', 'sliceClause', 'withOptionsClause' ]; var isString = (typ...
javascript
{ "resource": "" }
q55052
checkQueryArray
train
function checkQueryArray(queryArray) { if (queryArray == null) { return queryArray; } var max = queryArray.length; if (max === 0) { return queryArray; } var i = 0; for (; i < max; i++) { checkQuery(queryArray[i]); } return queryArray; }
javascript
{ "resource": "" }
q55053
and
train
function and() { var args = mlutil.asArray.apply(null, arguments); var queries = []; var ordered = null; var arg = null; for (var i=0; i < args.length; i++) { arg = args[i]; if (ordered === null) { if (arg instanceof OrderedDef) { ordered = arg.ordered; continue; } e...
javascript
{ "resource": "" }
q55054
andNot
train
function andNot() { var args = mlutil.asArray.apply(null, arguments); switch(args.length) { case 0: throw new Error('missing positive and negative queries'); case 1: throw new Error('has positive but missing negative query: '+mlutil.identify(args[0], true)); case 2: return new AndNotDef(new Positi...
javascript
{ "resource": "" }
q55055
boost
train
function boost() { var args = mlutil.asArray.apply(null, arguments); switch(args.length) { case 0: throw new Error('missing matching and boosting queries'); case 1: throw new Error('has matching but missing boosting query: '+mlutil.identify(args[0], true)); case 2: return new BoostDef(new Matching...
javascript
{ "resource": "" }
q55056
directory
train
function directory() { var args = mlutil.asArray.apply(null, arguments); var uris = []; var infinite = null; var arg = null; for (var i=0; i < args.length; i++) { arg = args[i]; if (infinite === null && (typeof arg === 'boolean')) { infinite = arg; } else if (arg instanceof Array){ Ar...
javascript
{ "resource": "" }
q55057
field
train
function field() { var args = mlutil.asArray.apply(null, arguments); switch(args.length) { case 0: throw new Error('missing field name'); case 1: return new FieldDef(new FieldNameDef(args[0])); case 2: return new FieldDef(new FieldNameDef(args[0], args[1])); default: throw new Error('too man...
javascript
{ "resource": "" }
q55058
heatmap
train
function heatmap() { var args = mlutil.asArray.apply(null, arguments); var argLen = args.length; if (argLen < 1) { throw new Error('no region or divisions for heat map'); } var hmap = {}; switch(argLen) { case 3: var first = args[0]; var second = args[1]; var third = args[2]; var re...
javascript
{ "resource": "" }
q55059
latlon
train
function latlon() { var args = mlutil.asArray.apply(null, arguments); switch(args.length) { case 0: throw new Error('missing latitude and longitude for latlon coordinate'); case 1: throw new Error('missing longitude for latlon coordinate'); case 2: return new LatLongDef(args[0], args[1]); defaul...
javascript
{ "resource": "" }
q55060
notIn
train
function notIn() { var args = mlutil.asArray.apply(null, arguments); switch(args.length) { case 0: throw new Error('missing positive and negative queries'); case 1: throw new Error('has positive query but missing negative query: '+mlutil.identify(args[0], true)); case 2: return new NotInDef(new Po...
javascript
{ "resource": "" }
q55061
pathIndex
train
function pathIndex() { var args = mlutil.asArray.apply(null, arguments); switch(args.length) { case 0: throw new Error('missing path for path index identifier'); case 1: return new PathIndexDef(new PathDef(args[0])); case 2: return new PathIndexDef(new PathDef(args[0], args[1])); default: th...
javascript
{ "resource": "" }
q55062
coordSystem
train
function coordSystem() { var args = mlutil.asArray.apply(null, arguments); switch(args.length) { case 0: throw new Error('missing identifier for coordinate system'); case 1: return new CoordSystemDef(args[0]); default: throw new Error('too many arguments for coordinate system identifier: '+args.le...
javascript
{ "resource": "" }
q55063
property
train
function property() { var args = mlutil.asArray.apply(null, arguments); switch(args.length) { case 0: throw new Error('missing JSON property name'); case 1: return new JSONPropertyDef(args[0]); default: throw new Error('too many arguments for JSON property identifier: '+args.length); } }
javascript
{ "resource": "" }
q55064
term
train
function term() { var args = mlutil.asArray.apply(null, arguments); var text = []; var weight = null; var termOptions = null; var arg = null; for (var i=0; i < args.length; i++) { arg = args[i]; if (weight === null && arg instanceof WeightDef) { weight = arg.weight; continue; } i...
javascript
{ "resource": "" }
q55065
calculate
train
function calculate() { /*jshint validthis:true */ var self = (this instanceof QueryBuilder) ? this : new QueryBuilder(); var args = mlutil.asArray.apply(null, arguments); // TODO: distinguish facets and values var calculateClause = { constraint: args }; self.calculateClause = calculateClause; ...
javascript
{ "resource": "" }
q55066
extract
train
function extract() { var args = mlutil.asArray.apply(null, arguments); var argLen = args.length; if (argLen < 1) { throw new Error('must specify paths to extract'); } var extractdef = {}; var arg = args[0]; if (typeof arg === 'string' || arg instanceof String) { extractdef['extract-path'] = args...
javascript
{ "resource": "" }
q55067
withOptions
train
function withOptions() { /*jshint validthis:true */ var self = (this instanceof QueryBuilder) ? this : new QueryBuilder(); // TODO: share with documents.js var optionKeyMapping = { search:'search-option', weight:'quality-weight', forestNames:'forest', similarDocs:'return-similar', metrics...
javascript
{ "resource": "" }
q55068
remove
train
function remove() { var select = null; var cardinality = null; var argLen = arguments.length; for (var i=0; i < argLen; i++) { var arg = arguments[i]; if (i === 0) { select = arg; continue; } if (cardinality === null && /^[?.*+]$/.test(arg)) { cardinality = arg; con...
javascript
{ "resource": "" }
q55069
insert
train
function insert() { var context = null; var position = null; var content = void 0; var cardinality = null; var argLen = arguments.length; for (var i=0; i < argLen; i++) { var arg = arguments[i]; if (i === 0) { context = arg; continue; } if (arg === null && content ===...
javascript
{ "resource": "" }
q55070
replace
train
function replace() { var select = null; var content = void 0; var cardinality = null; var apply = null; var argLen = arguments.length; for (var i=0; i < argLen; i++) { var arg = arguments[i]; if (i === 0) { select = arg; continue; } if (arg === null && content ===...
javascript
{ "resource": "" }
q55071
addPermission
train
function addPermission() { var permission = getPermission( mlutil.asArray.apply(null, arguments) ); if (permission === null) { throw new Error('permissions.add() takes the role name and one or more insert|update|read|execute capabilities'); } return insert('/array-node("permissions")', 'last-chi...
javascript
{ "resource": "" }
q55072
replacePermission
train
function replacePermission() { var permission = getPermission( mlutil.asArray.apply(null, arguments) ); if (permission === null) { throw new Error('permissions.replace() takes the role name and one or more insert|update|read|execute capabilities'); } return replace( '/permissions[node("rol...
javascript
{ "resource": "" }
q55073
addProperty
train
function addProperty(name, value) { if (typeof name !== 'string' || value == null) { throw new Error('properties.add() takes a string name and a value'); } var prop = {}; prop[name] = value; return insert('/object-node("properties")', 'last-child', prop); }
javascript
{ "resource": "" }
q55074
replaceProperty
train
function replaceProperty(name, value) { if (typeof name !== 'string' || value == null) { throw new Error('properties.replace() takes a string name and a value'); } return replace('/properties/node("'+name+'")', value); }
javascript
{ "resource": "" }
q55075
addMetadataValue
train
function addMetadataValue(name, value) { if (typeof name !== 'string' || typeof value !== 'string' ) { throw new Error('metadataValues.add() takes a string name and string value'); } var metaVal = {}; metaVal[name] = value; return insert('/object-node("metadataValues")', 'last-child', metaVal); }
javascript
{ "resource": "" }
q55076
asArray
train
function asArray() { var argLen = arguments.length; switch(argLen) { // No arguments returns an empty array case 0: return []; // Single array argument returns that array case 1: var arg = arguments[0]; if (Array.isArray(arg)) { return arg; } // Single object argument returns an ar...
javascript
{ "resource": "" }
q55077
openOutputTransform
train
function openOutputTransform(headers/*, data*/) { /*jshint validthis:true */ var operation = this; var txid = headers.location.substring('/v1/transactions/'.length); if (operation.withState === true) { return new mlutil.Transaction(txid, operation.rawHeaders['set-cookie']); } return {txid: txid}; }
javascript
{ "resource": "" }
q55078
probeOutputTransform
train
function probeOutputTransform(/*headers, data*/) { /*jshint validthis:true */ var operation = this; var statusCode = operation.responseStatusCode; var exists = (statusCode === 200) ? true : false; if (operation.contentOnly === true) { return exists; } var output = exists ? operation.responseHead...
javascript
{ "resource": "" }
q55079
ExtlibsWrapper
train
function ExtlibsWrapper(extlibs, name, dir) { if (!(this instanceof ExtlibsWrapper)) { return new ExtlibsWrapper(extlibs, name, dir); } this.extlibs = extlibs; this.name = name; this.dir = dir; }
javascript
{ "resource": "" }
q55080
concatBanner
train
function concatBanner() { if (typeof argv.banner !== 'undefined') { if (argv.banner) { return Promise.resolve().then(() => { concat.add(null, require(path.join(process.cwd(), argv.banner))); return log('banner', argv.banner); }); } return readPkg().then(pkg => { concat.add(null, getDefaultBanner...
javascript
{ "resource": "" }
q55081
concatFooter
train
function concatFooter() { if (argv.footer) { return Promise.resolve().then(() => { concat.add(null, require(path.join(process.cwd(), argv.footer))); return log('footer', `Concat footer from ${argv.footer}`); }); } return Promise.resolve(); }
javascript
{ "resource": "" }
q55082
concatFiles
train
function concatFiles() { return Promise.all(argv._.map(handleGlob)).then(globs => { const files = globs.reduce((acc, cur) => acc.concat(cur), []); if ( (files.length < 2 && typeof argv.banner === 'undefined' && !argv.footer) || (files.length === 0 && (typeof argv.banner === 'undefined' || !argv.footer)) )...
javascript
{ "resource": "" }
q55083
handleGlob
train
function handleGlob(glob) { if (glob === '-') { return stdinCache.then(stdin => [{content: stdin}]); } return globby(glob.split(' '), {nodir: true}).then(files => Promise.all(files.map(handleFile))); }
javascript
{ "resource": "" }
q55084
getSourceMappingURL
train
function getSourceMappingURL() { if (path.extname(argv.output) === '.css') { return `\n/*# sourceMappingURL=${path.basename(argv.output)}.map */`; } return `\n//# sourceMappingURL=${path.basename(argv.output)}.map`; }
javascript
{ "resource": "" }
q55085
resolvePaths
train
function resolvePaths(paths) { var exec = {}; var originalWd = process.cwd(); for (var name in paths) { process.chdir(originalWd); exec[name] = resolveLink(paths[name]); process.chdir(originalWd); } process.chdir(originalWd); return exec; }
javascript
{ "resource": "" }
q55086
resolveLink
train
function resolveLink(path) { var links = readLinkRecursive(path); var resolved = p.resolve.apply(null, links); trace('links', links, 'resolves to', resolved); return resolved; }
javascript
{ "resource": "" }
q55087
readLinkRecursive
train
function readLinkRecursive(path, seen) { seen = seen || []; seen.push(p.dirname(path)); var next = readLink(path); trace('recur', seen, next); if (!next) { seen.push(p.basename(path)); return seen; } return readLinkRecursive(next, seen); }
javascript
{ "resource": "" }
q55088
SMTPTransport
train
function SMTPTransport(options) { EventEmitter.call(this); options = options || {}; if (typeof options === 'string') { options = { url: options }; } var urlData; var service = options.service; if (typeof options.getSocket === 'function') { this.getSocke...
javascript
{ "resource": "" }
q55089
assign
train
function assign( /* target, ... sources */ ) { var args = Array.prototype.slice.call(arguments); var target = args.shift() || {}; args.forEach(function (source) { Object.keys(source || {}).forEach(function (key) { if (['tls', 'auth'].indexOf(key) >= 0 && source[key] && typeof source[key...
javascript
{ "resource": "" }
q55090
collectComments
train
function collectComments(content, comments) { const table = [] let from = 0 let end while (true) { let start = content.indexOf('/*', from) if (start > -1) { end = content.indexOf('*/', start + 2) if (end > -1) { comments.push(content.slice(s...
javascript
{ "resource": "" }
q55091
processFiles
train
function processFiles(filenames = [], options = defaultOptions) { if (options.convertUrls) { options.target = resolve(process.cwd(), options.convertUrls).split(PATH_SEP) } const uglies = [] // process files filenames.forEach(filename => { try { const content = readFile...
javascript
{ "resource": "" }
q55092
getSpecsRegex
train
function getSpecsRegex() { const argv = minimist(process.argv.slice(2)); /** * The command line argument `--ieBatch` is a string representing * the current batch to run, of total batches. * For example, `npm run test:unit:ci:ie -- --ieBatch 1of3` */ const [ currentRun, totalRuns ] = argv.ie...
javascript
{ "resource": "" }
q55093
setup
train
function setup() { return browser.getProcessedConfig() .then((configuration) => { let cucumberFormat = configuration.cucumberOpts.format; IS_JSON_FORMAT = cucumberFormat && cucumberFormat.includes('json'); if (Array.isArray(cucumberFormat)) { IS_JSON_FOR...
javascript
{ "resource": "" }
q55094
onPrepare
train
function onPrepare() { if (IS_JSON_FORMAT) { return browser.getCapabilities() .then((capabilities) => { PID_INSTANCE_DATA.metadata.browser.name = PID_INSTANCE_DATA.metadata.browser.name === '' ? capabilities.get('browserName').toLowerCase() ...
javascript
{ "resource": "" }
q55095
passLintResultsThroughReporters
train
function passLintResultsThroughReporters(lintResults) { const warnings = lintResults .reduce((accumulated, res) => accumulated.concat(res.results), []); return Promise .all(reporters.map(reporter => reporter(warnings))) .then(() => lintResults); }
javascript
{ "resource": "" }
q55096
download
train
function download(source, { verbose, output, onStart, onProgress } = {}) { return new Promise(function(y, n) { if (typeof output === 'undefined') { output = path.basename(url.parse(source).pathname) || 'unknown'; } /** * Parse the source url into parts */ const sourceUrl = url.parse(s...
javascript
{ "resource": "" }
q55097
Strategy
train
function Strategy(options, verify) { if (typeof options == 'function') { verify = options; options = {}; } if (!verify) throw new Error('OAuth 2.0 client password strategy requires a verify function'); passport.Strategy.call(this); this.name = 'oauth2-client-password'; this._verify = verify; this...
javascript
{ "resource": "" }
q55098
bundleJsFiles
train
function bundleJsFiles () { return concat(jsFiles) .then((output) => { const uglified = UglifyJS.minify(output) if (uglified.error) { throw new Error(uglified.error) } return uglified.code }) }
javascript
{ "resource": "" }
q55099
addMember
train
function addMember(path, memberPath, setId, msg) { // FIXME: This will have to break due to switched arguments var node = _getNode(path), memberNode = _getNode(memberPath); if (node && memberNode) { state.core.addMember(node, setId, memberNode); ...
javascript
{ "resource": "" }