repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
partition
stringclasses
1 value
stormpath/express-stormpath
lib/oauth/error-responder.js
oauthErrorResponder
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
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); }
[ "function", "oauthErrorResponder", "(", "req", ",", "res", ",", "err", ")", "{", "var", "accepts", "=", "req", ".", "accepts", "(", "[", "'html'", ",", "'json'", "]", ")", ";", "var", "config", "=", "req", ".", "app", ".", "get", "(", "'stormpathConf...
Takes an error object and responds either by rendering the login form with the error, or by returning the error as JSON. @method @param {Object} req - The http request. @param {Object} res - The http response. @param {Object} err - The error to handle.
[ "Takes", "an", "error", "object", "and", "responds", "either", "by", "rendering", "the", "login", "form", "with", "the", "error", "or", "by", "returning", "the", "error", "as", "JSON", "." ]
aed8d26ba51272755ea4eab706b4417e4bbeed99
https://github.com/stormpath/express-stormpath/blob/aed8d26ba51272755ea4eab706b4417e4bbeed99/lib/oauth/error-responder.js#L71-L80
train
stormpath/express-stormpath
lib/controllers/register.js
defaultUnverifiedHtmlResponse
function defaultUnverifiedHtmlResponse(req, res) { var config = req.app.get('stormpathConfig'); res.redirect(302, config.web.login.uri + '?status=unverified'); }
javascript
function defaultUnverifiedHtmlResponse(req, res) { var config = req.app.get('stormpathConfig'); res.redirect(302, config.web.login.uri + '?status=unverified'); }
[ "function", "defaultUnverifiedHtmlResponse", "(", "req", ",", "res", ")", "{", "var", "config", "=", "req", ".", "app", ".", "get", "(", "'stormpathConfig'", ")", ";", "res", ".", "redirect", "(", "302", ",", "config", ".", "web", ".", "login", ".", "u...
Delivers the default response for registration attempts that accept an HTML content type, where the new account is in an unverified state. In this situation we redirect to the login page with a query parameter that indidcates that the account is unverified @function @param {Object} req - The http request. @param {Obj...
[ "Delivers", "the", "default", "response", "for", "registration", "attempts", "that", "accept", "an", "HTML", "content", "type", "where", "the", "new", "account", "is", "in", "an", "unverified", "state", ".", "In", "this", "situation", "we", "redirect", "to", ...
aed8d26ba51272755ea4eab706b4417e4bbeed99
https://github.com/stormpath/express-stormpath/blob/aed8d26ba51272755ea4eab706b4417e4bbeed99/lib/controllers/register.js#L22-L25
train
stormpath/express-stormpath
lib/controllers/register.js
defaultAutoAuthorizeHtmlResponse
function defaultAutoAuthorizeHtmlResponse(req, res) { var config = req.app.get('stormpathConfig'); res.redirect(302, url.parse(req.query.next || '').path || config.web.register.nextUri); }
javascript
function defaultAutoAuthorizeHtmlResponse(req, res) { var config = req.app.get('stormpathConfig'); res.redirect(302, url.parse(req.query.next || '').path || config.web.register.nextUri); }
[ "function", "defaultAutoAuthorizeHtmlResponse", "(", "req", ",", "res", ")", "{", "var", "config", "=", "req", ".", "app", ".", "get", "(", "'stormpathConfig'", ")", ";", "res", ".", "redirect", "(", "302", ",", "url", ".", "parse", "(", "req", ".", "q...
Delivers the default response for registration attempts that accept an HTML content type, where the new account is in a verified state and the config has requested that we automatically log in the user. In this situation we redirect to the next URI that is in the url, or the nextUri that is defined on the registration ...
[ "Delivers", "the", "default", "response", "for", "registration", "attempts", "that", "accept", "an", "HTML", "content", "type", "where", "the", "new", "account", "is", "in", "a", "verified", "state", "and", "the", "config", "has", "requested", "that", "we", ...
aed8d26ba51272755ea4eab706b4417e4bbeed99
https://github.com/stormpath/express-stormpath/blob/aed8d26ba51272755ea4eab706b4417e4bbeed99/lib/controllers/register.js#L56-L59
train
stormpath/express-stormpath
lib/controllers/register.js
defaultJsonResponse
function defaultJsonResponse(req, res) { res.json({ account: helpers.strippedAccount(req.user) }); }
javascript
function defaultJsonResponse(req, res) { res.json({ account: helpers.strippedAccount(req.user) }); }
[ "function", "defaultJsonResponse", "(", "req", ",", "res", ")", "{", "res", ".", "json", "(", "{", "account", ":", "helpers", ".", "strippedAccount", "(", "req", ".", "user", ")", "}", ")", ";", "}" ]
Delivers the default response for registration attempts that accept a JSON content type. In this situation we simply return the new account object as JSON @function @param {Object} req - The http request. @param {Object} res - The http response.
[ "Delivers", "the", "default", "response", "for", "registration", "attempts", "that", "accept", "a", "JSON", "content", "type", ".", "In", "this", "situation", "we", "simply", "return", "the", "new", "account", "object", "as", "JSON" ]
aed8d26ba51272755ea4eab706b4417e4bbeed99
https://github.com/stormpath/express-stormpath/blob/aed8d26ba51272755ea4eab706b4417e4bbeed99/lib/controllers/register.js#L71-L75
train
stormpath/express-stormpath
lib/controllers/register.js
applyDefaultAccountFields
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
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...
[ "function", "applyDefaultAccountFields", "(", "stormpathConfig", ",", "req", ")", "{", "var", "registerFields", "=", "stormpathConfig", ".", "web", ".", "register", ".", "form", ".", "fields", ";", "if", "(", "(", "!", "registerFields", ".", "givenName", "||",...
The Stormpath API requires the `givenName` and `surname` fields to be provided, but as a convenience our framework integrations allow you to omit this data and fill those fields with the string `UNKNOWN` - but only if the field is not explicitly required. @function @param {Object} stormpathConfig - The express-stormp...
[ "The", "Stormpath", "API", "requires", "the", "givenName", "and", "surname", "fields", "to", "be", "provided", "but", "as", "a", "convenience", "our", "framework", "integrations", "allow", "you", "to", "omit", "this", "data", "and", "fill", "those", "fields", ...
aed8d26ba51272755ea4eab706b4417e4bbeed99
https://github.com/stormpath/express-stormpath/blob/aed8d26ba51272755ea4eab706b4417e4bbeed99/lib/controllers/register.js#L88-L98
train
stormpath/express-stormpath
lib/oauth/linkedin.js
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
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',...
[ "function", "(", "req", ",", "config", ",", "callback", ")", "{", "var", "baseUrl", "=", "config", ".", "web", ".", "baseUrl", "||", "req", ".", "protocol", "+", "'://'", "+", "getHost", "(", "req", ")", ";", "var", "linkedInAuthUrl", "=", "'https://ww...
Exchange a LinkedIn authentication code for a OAuth access token. @method @private @param {Object} req - The http request. @param {string} config - The Stormpath express config object. @param {string} callback - The callback to call once a response has been resolved.
[ "Exchange", "a", "LinkedIn", "authentication", "code", "for", "a", "OAuth", "access", "token", "." ]
aed8d26ba51272755ea4eab706b4417e4bbeed99
https://github.com/stormpath/express-stormpath/blob/aed8d26ba51272755ea4eab706b4417e4bbeed99/lib/oauth/linkedin.js#L18-L59
train
stormpath/express-stormpath
lib/okta/error-transformer.js
oktaErrorTransformer
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
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...
[ "function", "oktaErrorTransformer", "(", "err", ")", "{", "if", "(", "err", "&&", "err", ".", "errorCauses", ")", "{", "err", ".", "errorCauses", ".", "forEach", "(", "function", "(", "cause", ")", "{", "if", "(", "cause", ".", "errorSummary", "===", "...
Translates user creation errors into an end-user friendly userMessage @param {*} err
[ "Translates", "user", "creation", "errors", "into", "an", "end", "-", "user", "friendly", "userMessage" ]
aed8d26ba51272755ea4eab706b4417e4bbeed99
https://github.com/stormpath/express-stormpath/blob/aed8d26ba51272755ea4eab706b4417e4bbeed99/lib/okta/error-transformer.js#L7-L31
train
stormpath/express-stormpath
lib/controllers/forgot-password.js
function (form) { var data = { email: form.data.email }; if (req.organization) { data.accountStore = { href: req.organization.href }; } application.sendPasswordResetEmail(data, function (err) { ...
javascript
function (form) { var data = { email: form.data.email }; if (req.organization) { data.accountStore = { href: req.organization.href }; } application.sendPasswordResetEmail(data, function (err) { ...
[ "function", "(", "form", ")", "{", "var", "data", "=", "{", "email", ":", "form", ".", "data", ".", "email", "}", ";", "if", "(", "req", ".", "organization", ")", "{", "data", ".", "accountStore", "=", "{", "href", ":", "req", ".", "organization", ...
If we get here, it means the user is submitting a password reset request, so we should attempt to send the user a password reset email.
[ "If", "we", "get", "here", "it", "means", "the", "user", "is", "submitting", "a", "password", "reset", "request", "so", "we", "should", "attempt", "to", "send", "the", "user", "a", "password", "reset", "email", "." ]
aed8d26ba51272755ea4eab706b4417e4bbeed99
https://github.com/stormpath/express-stormpath/blob/aed8d26ba51272755ea4eab706b4417e4bbeed99/lib/controllers/forgot-password.js#L55-L73
train
stormpath/express-stormpath
lib/controllers/login.js
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
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...
[ "function", "(", "form", ")", "{", "if", "(", "config", ".", "web", ".", "multiTenancy", ".", "enabled", "&&", "req", ".", "organization", ")", "{", "setAccountStoreByHref", "(", "form", ".", "data", ",", "req", ".", "organization", ")", ";", "}", "els...
If we get here, it means the user is submitting a login request, so we should attempt to log the user into their account.
[ "If", "we", "get", "here", "it", "means", "the", "user", "is", "submitting", "a", "login", "request", "so", "we", "should", "attempt", "to", "log", "the", "user", "into", "their", "account", "." ]
aed8d26ba51272755ea4eab706b4417e4bbeed99
https://github.com/stormpath/express-stormpath/blob/aed8d26ba51272755ea4eab706b4417e4bbeed99/lib/controllers/login.js#L122-L147
train
stormpath/express-stormpath
lib/helpers/get-form-view-model.js
getFormFields
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
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) { ...
[ "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...
Returns list of all enabled fields, as defined by `form.fields`, and ordered by `form.fieldOrder`. @method @param {Object} form - The form from the Stormpath configuration.
[ "Returns", "list", "of", "all", "enabled", "fields", "as", "defined", "by", "form", ".", "fields", "and", "ordered", "by", "form", ".", "fieldOrder", "." ]
aed8d26ba51272755ea4eab706b4417e4bbeed99
https://github.com/stormpath/express-stormpath/blob/aed8d26ba51272755ea4eab706b4417e4bbeed99/lib/helpers/get-form-view-model.js#L17-L66
train
stormpath/express-stormpath
lib/helpers/get-form-view-model.js
getAccountStores
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
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 ...
[ "function", "getAccountStores", "(", "application", ",", "callback", ")", "{", "var", "options", "=", "{", "expand", ":", "'accountStore'", "}", ";", "// Get account store mappings.", "application", ".", "getAccountStoreMappings", "(", "options", ",", "function", "(...
Returns a list of account stores for the specified application. @method @param {Object} application - The Stormpath Application to get account stores from. @param {Function} callback - Callback function (error, providers).
[ "Returns", "a", "list", "of", "account", "stores", "for", "the", "specified", "application", "." ]
aed8d26ba51272755ea4eab706b4417e4bbeed99
https://github.com/stormpath/express-stormpath/blob/aed8d26ba51272755ea4eab706b4417e4bbeed99/lib/helpers/get-form-view-model.js#L76-L101
train
stormpath/express-stormpath
lib/helpers/get-form-view-model.js
getAccountStoreModel
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
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 } ...
[ "function", "getAccountStoreModel", "(", "accountStore", ")", "{", "var", "provider", "=", "accountStore", ".", "provider", ";", "return", "{", "href", ":", "accountStore", ".", "href", ",", "name", ":", "accountStore", ".", "name", ",", "provider", ":", "{"...
Takes an account store object and returns a new object with only the fields that we want to expose to the public. @method @param {Object} accountStore - The account store.
[ "Takes", "an", "account", "store", "object", "and", "returns", "a", "new", "object", "with", "only", "the", "fields", "that", "we", "want", "to", "expose", "to", "the", "public", "." ]
aed8d26ba51272755ea4eab706b4417e4bbeed99
https://github.com/stormpath/express-stormpath/blob/aed8d26ba51272755ea4eab706b4417e4bbeed99/lib/helpers/get-form-view-model.js#L112-L125
train
stormpath/express-stormpath
lib/helpers/handle-accept-request.js
handleAcceptRequest
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
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...
[ "function", "handleAcceptRequest", "(", "req", ",", "res", ",", "handlers", ",", "fallbackHandler", ")", "{", "var", "config", "=", "req", ".", "app", ".", "get", "(", "'stormpathConfig'", ")", ";", "// Accepted is an ordered list of preferred types, as specified by t...
Determines which handler should be used to fulfill a response, given the Accept header of the request and the content types that are allowed by the `stormpath.web.produces` configuration. Also handles the serving of the SPA root page, if needed. @method @private @param {Object} req - HTTP request. @param {Object} re...
[ "Determines", "which", "handler", "should", "be", "used", "to", "fulfill", "a", "response", "given", "the", "Accept", "header", "of", "the", "request", "and", "the", "content", "types", "that", "are", "allowed", "by", "the", "stormpath", ".", "web", ".", "...
aed8d26ba51272755ea4eab706b4417e4bbeed99
https://github.com/stormpath/express-stormpath/blob/aed8d26ba51272755ea4eab706b4417e4bbeed99/lib/helpers/handle-accept-request.js#L23-L60
train
stormpath/express-stormpath
lib/controllers/verify-email.js
function (form) { var options = { login: form.data.email }; if (req.organization) { options.accountStore = { href: req.organization.href }; } application.resendVerificationEmail(options, function (err...
javascript
function (form) { var options = { login: form.data.email }; if (req.organization) { options.accountStore = { href: req.organization.href }; } application.resendVerificationEmail(options, function (err...
[ "function", "(", "form", ")", "{", "var", "options", "=", "{", "login", ":", "form", ".", "data", ".", "email", "}", ";", "if", "(", "req", ".", "organization", ")", "{", "options", ".", "accountStore", "=", "{", "href", ":", "req", ".", "organizat...
If we get here, it means the user is submitting a request to resend their account verification email, so we should attempt to send the user another verification email.
[ "If", "we", "get", "here", "it", "means", "the", "user", "is", "submitting", "a", "request", "to", "resend", "their", "account", "verification", "email", "so", "we", "should", "attempt", "to", "send", "the", "user", "another", "verification", "email", "." ]
aed8d26ba51272755ea4eab706b4417e4bbeed99
https://github.com/stormpath/express-stormpath/blob/aed8d26ba51272755ea4eab706b4417e4bbeed99/lib/controllers/verify-email.js#L98-L124
train
stormpath/express-stormpath
lib/helpers/write-json-error.js
writeJsonError
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
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 }); ...
[ "function", "writeJsonError", "(", "res", ",", "err", ",", "statusCode", ")", "{", "var", "status", "=", "err", ".", "status", "||", "err", ".", "statusCode", "||", "statusCode", "||", "400", ";", "var", "message", "=", "'Unknown error. Please contact support....
Use this method to render JSON error responses. @function @param {Object} res - Express http response. @param {Object} err - An error object.
[ "Use", "this", "method", "to", "render", "JSON", "error", "responses", "." ]
aed8d26ba51272755ea4eab706b4417e4bbeed99
https://github.com/stormpath/express-stormpath/blob/aed8d26ba51272755ea4eab706b4417e4bbeed99/lib/helpers/write-json-error.js#L11-L27
train
stormpath/express-stormpath
lib/helpers/stripped-account-response.js
strippedAccount
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
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 ...
[ "function", "strippedAccount", "(", "account", ",", "expansionMap", ")", "{", "expansionMap", "=", "typeof", "expansionMap", "===", "'object'", "?", "expansionMap", ":", "{", "}", ";", "var", "strippedAccount", "=", "_", ".", "clone", "(", "account", ")", ";...
Returns an account object, but strips all of the linked resources and sensitive properties. @function @param {Object} account - The stormpath account object.
[ "Returns", "an", "account", "object", "but", "strips", "all", "of", "the", "linked", "resources", "and", "sensitive", "properties", "." ]
aed8d26ba51272755ea4eab706b4417e4bbeed99
https://github.com/stormpath/express-stormpath/blob/aed8d26ba51272755ea4eab706b4417e4bbeed99/lib/helpers/stripped-account-response.js#L12-L53
train
jesstelford/node-MarkerWithLabel
index.js
MarkerLabel_
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
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...
[ "function", "MarkerLabel_", "(", "marker", ",", "crossURL", ",", "handCursorURL", ")", "{", "this", ".", "marker_", "=", "marker", ";", "this", ".", "handCursorURL_", "=", "marker", ".", "handCursorURL", ";", "this", ".", "labelDiv_", "=", "document", ".", ...
This constructor creates a label and associates it with a marker. It is for the private use of the MarkerWithLabel class. @constructor @param {Marker} marker The marker with which the label is to be associated. @param {string} crossURL The URL of the cross image =. @param {string} handCursor The URL of the hand cursor....
[ "This", "constructor", "creates", "a", "label", "and", "associates", "it", "with", "a", "marker", ".", "It", "is", "for", "the", "private", "use", "of", "the", "MarkerWithLabel", "class", "." ]
54e0eb0fde830b591b0550a921420ef566bdbc0b
https://github.com/jesstelford/node-MarkerWithLabel/blob/54e0eb0fde830b591b0550a921420ef566bdbc0b/index.js#L67-L87
train
perry-mitchell/webdav-fs
source/index.js
function(filePath, options) { var clientOptions = {}; if (options && options !== null) { if (typeof options.headers === "object") { clientOptions.headers = options.headers; } } return client.createWriteStream(filePath, c...
javascript
function(filePath, options) { var clientOptions = {}; if (options && options !== null) { if (typeof options.headers === "object") { clientOptions.headers = options.headers; } } return client.createWriteStream(filePath, c...
[ "function", "(", "filePath", ",", "options", ")", "{", "var", "clientOptions", "=", "{", "}", ";", "if", "(", "options", "&&", "options", "!==", "null", ")", "{", "if", "(", "typeof", "options", ".", "headers", "===", "\"object\"", ")", "{", "clientOpt...
Create a write stream for a remote file @param {String} filePath The remote path @param {CreateWriteStreamOptions=} options Options for the stream @returns {Writeable} A writeable stream
[ "Create", "a", "write", "stream", "for", "a", "remote", "file" ]
b41794aae460df6d24ea6eaa1d833f8465b26606
https://github.com/perry-mitchell/webdav-fs/blob/b41794aae460df6d24ea6eaa1d833f8465b26606/source/index.js#L93-L101
train
perry-mitchell/webdav-fs
source/index.js
function(dirPath, callback) { client .createDirectory(dirPath) .then(function() { __executeCallbackAsync(callback, [null]); }) .catch(callback); }
javascript
function(dirPath, callback) { client .createDirectory(dirPath) .then(function() { __executeCallbackAsync(callback, [null]); }) .catch(callback); }
[ "function", "(", "dirPath", ",", "callback", ")", "{", "client", ".", "createDirectory", "(", "dirPath", ")", ".", "then", "(", "function", "(", ")", "{", "__executeCallbackAsync", "(", "callback", ",", "[", "null", "]", ")", ";", "}", ")", ".", "catch...
Create a remote directory @param {String} dirPath The remote path to create @param {Function} callback Callback: function(error)
[ "Create", "a", "remote", "directory" ]
b41794aae460df6d24ea6eaa1d833f8465b26606
https://github.com/perry-mitchell/webdav-fs/blob/b41794aae460df6d24ea6eaa1d833f8465b26606/source/index.js#L108-L115
train
perry-mitchell/webdav-fs
source/index.js
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
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[...
[ "function", "(", "/* dirPath[, mode], callback */", ")", "{", "var", "args", "=", "Array", ".", "prototype", ".", "slice", ".", "call", "(", "arguments", ")", ",", "argc", "=", "args", ".", "length", ";", "if", "(", "argc", "<=", "1", ")", "{", "throw"...
Readdir processing mode. When set to 'node', readdir will return an array of strings like Node's fs.readdir does. When set to 'stat', readdir will return an array of stat objects. @see stat @typedef {('node'|'stat')} ReadDirMode Read a directory synchronously. Maps -> fs.readdir @see https://nodejs.org/api/fs.html#fs...
[ "Readdir", "processing", "mode", ".", "When", "set", "to", "node", "readdir", "will", "return", "an", "array", "of", "strings", "like", "Node", "s", "fs", ".", "readdir", "does", ".", "When", "set", "to", "stat", "readdir", "will", "return", "an", "array...
b41794aae460df6d24ea6eaa1d833f8465b26606
https://github.com/perry-mitchell/webdav-fs/blob/b41794aae460df6d24ea6eaa1d833f8465b26606/source/index.js#L134-L164
train
perry-mitchell/webdav-fs
source/index.js
function(filePath, targetPath, callback) { client .moveFile(filePath, targetPath) .then(function() { __executeCallbackAsync(callback, [null]); }) .catch(callback); }
javascript
function(filePath, targetPath, callback) { client .moveFile(filePath, targetPath) .then(function() { __executeCallbackAsync(callback, [null]); }) .catch(callback); }
[ "function", "(", "filePath", ",", "targetPath", ",", "callback", ")", "{", "client", ".", "moveFile", "(", "filePath", ",", "targetPath", ")", ".", "then", "(", "function", "(", ")", "{", "__executeCallbackAsync", "(", "callback", ",", "[", "null", "]", ...
Rename a remote item @param {String} filePath The remote path to rename @param {String} targetPath The new path name of the item @param {Function} callback Callback: function(error)
[ "Rename", "a", "remote", "item" ]
b41794aae460df6d24ea6eaa1d833f8465b26606
https://github.com/perry-mitchell/webdav-fs/blob/b41794aae460df6d24ea6eaa1d833f8465b26606/source/index.js#L201-L208
train
perry-mitchell/webdav-fs
source/index.js
function(targetPath, callback) { client .deleteFile(targetPath) .then(function() { __executeCallbackAsync(callback, [null]); }) .catch(callback); }
javascript
function(targetPath, callback) { client .deleteFile(targetPath) .then(function() { __executeCallbackAsync(callback, [null]); }) .catch(callback); }
[ "function", "(", "targetPath", ",", "callback", ")", "{", "client", ".", "deleteFile", "(", "targetPath", ")", ".", "then", "(", "function", "(", ")", "{", "__executeCallbackAsync", "(", "callback", ",", "[", "null", "]", ")", ";", "}", ")", ".", "catc...
Remote remote directory @todo Check if remote is a directory before removing @param {String} targetPath Directory to remove @param {Function} callback Callback: function(error)
[ "Remote", "remote", "directory" ]
b41794aae460df6d24ea6eaa1d833f8465b26606
https://github.com/perry-mitchell/webdav-fs/blob/b41794aae460df6d24ea6eaa1d833f8465b26606/source/index.js#L216-L223
train
perry-mitchell/webdav-fs
source/index.js
function(remotePath, callback) { client .stat(remotePath) .then(function(stat) { __executeCallbackAsync(callback, [null, __convertStat(stat)]); }) .catch(callback); }
javascript
function(remotePath, callback) { client .stat(remotePath) .then(function(stat) { __executeCallbackAsync(callback, [null, __convertStat(stat)]); }) .catch(callback); }
[ "function", "(", "remotePath", ",", "callback", ")", "{", "client", ".", "stat", "(", "remotePath", ")", ".", "then", "(", "function", "(", "stat", ")", "{", "__executeCallbackAsync", "(", "callback", ",", "[", "null", ",", "__convertStat", "(", "stat", ...
Stat a remote item @param {String} remotePath The remote item to stat @param {Function} callback Callback: function(error, stat)
[ "Stat", "a", "remote", "item" ]
b41794aae460df6d24ea6eaa1d833f8465b26606
https://github.com/perry-mitchell/webdav-fs/blob/b41794aae460df6d24ea6eaa1d833f8465b26606/source/index.js#L230-L237
train
perry-mitchell/webdav-fs
source/index.js
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
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...
[ "function", "(", "/* filename, data[, encoding], callback */", ")", "{", "var", "args", "=", "Array", ".", "prototype", ".", "slice", ".", "call", "(", "arguments", ")", ",", "argc", "=", "args", ".", "length", ";", "if", "(", "argc", "<=", "2", ")", "{"...
Write data to a remote file @param {String} filename The remote file path to write to @param {Buffer|String} data The data to write @param {String=} encoding Optional encoding to write as (utf8/binary) (default: utf8) @param {Function} callback Callback: function(error)
[ "Write", "data", "to", "a", "remote", "file" ]
b41794aae460df6d24ea6eaa1d833f8465b26606
https://github.com/perry-mitchell/webdav-fs/blob/b41794aae460df6d24ea6eaa1d833f8465b26606/source/index.js#L260-L282
train
JamesMessinger/swagger-server
samples/sample3/handlers/employees.js
loadMockData
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
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); }
[ "function", "loadMockData", "(", "server", ",", "next", ")", "{", "// Create REST resources for each employee", "var", "resources", "=", "data", ".", "employees", ".", "map", "(", "function", "(", "employee", ")", "{", "return", "new", "swagger", ".", "Resource"...
Loads mock employee data @param {SwaggerServer} server @param {function} next
[ "Loads", "mock", "employee", "data" ]
7afa6bdb159022a9bed1efaa2997a6d5f993c7e4
https://github.com/JamesMessinger/swagger-server/blob/7afa6bdb159022a9bed1efaa2997a6d5f993c7e4/samples/sample3/handlers/employees.js#L34-L42
train
JamesMessinger/swagger-server
samples/sample3/handlers/employees.js
verifyUsernameDoesNotExist
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
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)...
[ "function", "verifyUsernameDoesNotExist", "(", "req", ",", "res", ",", "next", ")", "{", "var", "username", "=", "req", ".", "body", ".", "username", ";", "var", "dataStore", "=", "req", ".", "app", ".", "dataStore", ";", "// Check for an existing employee RES...
Verifies that the new employee's username isn't the same as any existing username.
[ "Verifies", "that", "the", "new", "employee", "s", "username", "isn", "t", "the", "same", "as", "any", "existing", "username", "." ]
7afa6bdb159022a9bed1efaa2997a6d5f993c7e4
https://github.com/JamesMessinger/swagger-server/blob/7afa6bdb159022a9bed1efaa2997a6d5f993c7e4/samples/sample3/handlers/employees.js#L47-L62
train
JamesMessinger/swagger-server
lib/server.js
SwaggerServer
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
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 ...
[ "function", "SwaggerServer", "(", "app", ")", "{", "app", "=", "app", "||", "express", "(", ")", ";", "// Event Emitter", "_", ".", "extend", "(", "this", ",", "EventEmitter", ".", "prototype", ")", ";", "EventEmitter", ".", "call", "(", "this", ")", "...
The Swagger Server class, which wraps an Express Application and extends it. @param {e.application} [app] An Express Application. If not provided, a new app is created. @constructor @extends EventEmitter
[ "The", "Swagger", "Server", "class", "which", "wraps", "an", "Express", "Application", "and", "extends", "it", "." ]
7afa6bdb159022a9bed1efaa2997a6d5f993c7e4
https://github.com/JamesMessinger/swagger-server/blob/7afa6bdb159022a9bed1efaa2997a6d5f993c7e4/lib/server.js#L22-L112
train
JamesMessinger/swagger-server
lib/index.js
createRouter
function createRouter() { var rtr = express.Router.apply(express, arguments); router.patch(rtr); return rtr; }
javascript
function createRouter() { var rtr = express.Router.apply(express, arguments); router.patch(rtr); return rtr; }
[ "function", "createRouter", "(", ")", "{", "var", "rtr", "=", "express", ".", "Router", ".", "apply", "(", "express", ",", "arguments", ")", ";", "router", ".", "patch", "(", "rtr", ")", ";", "return", "rtr", ";", "}" ]
Creates an Express Router and patches it to support Swagger. @returns {e.Router}
[ "Creates", "an", "Express", "Router", "and", "patches", "it", "to", "support", "Swagger", "." ]
7afa6bdb159022a9bed1efaa2997a6d5f993c7e4
https://github.com/JamesMessinger/swagger-server/blob/7afa6bdb159022a9bed1efaa2997a6d5f993c7e4/lib/index.js#L40-L44
train
JamesMessinger/swagger-server
lib/index.js
Route
function Route(path) { // Convert Swagger-style path to Express-style path path = path.replace(util.swaggerParamRegExp, ':$1'); express.Route.call(this, path); }
javascript
function Route(path) { // Convert Swagger-style path to Express-style path path = path.replace(util.swaggerParamRegExp, ':$1'); express.Route.call(this, path); }
[ "function", "Route", "(", "path", ")", "{", "// Convert Swagger-style path to Express-style path", "path", "=", "path", ".", "replace", "(", "util", ".", "swaggerParamRegExp", ",", "':$1'", ")", ";", "express", ".", "Route", ".", "call", "(", "this", ",", "pat...
Extends the Express Route class to support Swagger. @param {string} path @constructor @extends {e.Route}
[ "Extends", "the", "Express", "Route", "class", "to", "support", "Swagger", "." ]
7afa6bdb159022a9bed1efaa2997a6d5f993c7e4
https://github.com/JamesMessinger/swagger-server/blob/7afa6bdb159022a9bed1efaa2997a6d5f993c7e4/lib/index.js#L52-L56
train
JamesMessinger/swagger-server
lib/router.js
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
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...
[ "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...
Patches an Express Router to support Swagger. @param {e.Router|e.application} router @param {e.Router|e.application} [target]
[ "Patches", "an", "Express", "Router", "to", "support", "Swagger", "." ]
7afa6bdb159022a9bed1efaa2997a6d5f993c7e4
https://github.com/JamesMessinger/swagger-server/blob/7afa6bdb159022a9bed1efaa2997a6d5f993c7e4/lib/router.js#L13-L48
train
JamesMessinger/swagger-server
lib/handlers.js
Handlers
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
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...
[ "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'",...
The Handler class, correlates the swagger paths with the handlers directory structure and adds the d custom logic to the Express instance. @param server @constructor
[ "The", "Handler", "class", "correlates", "the", "swagger", "paths", "with", "the", "handlers", "directory", "structure", "and", "adds", "the", "d", "custom", "logic", "to", "the", "Express", "instance", "." ]
7afa6bdb159022a9bed1efaa2997a6d5f993c7e4
https://github.com/JamesMessinger/swagger-server/blob/7afa6bdb159022a9bed1efaa2997a6d5f993c7e4/lib/handlers.js#L19-L30
train
JamesMessinger/swagger-server
lib/handlers.js
addPathToExpress
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
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...
[ "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", ",", "han...
Add the handlePath to the Swagger Express server if valid @param handlePath
[ "Add", "the", "handlePath", "to", "the", "Swagger", "Express", "server", "if", "valid" ]
7afa6bdb159022a9bed1efaa2997a6d5f993c7e4
https://github.com/JamesMessinger/swagger-server/blob/7afa6bdb159022a9bed1efaa2997a6d5f993c7e4/lib/handlers.js#L69-L87
train
JamesMessinger/swagger-server
lib/handlers.js
moduleExists
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
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; }
[ "function", "moduleExists", "(", "name", ")", "{", "//TODO: Check that the file exists before trying to require it.", "try", "{", "require", ".", "resolve", "(", "name", ")", ";", "}", "catch", "(", "err", ")", "{", "this", ".", "server", ".", "emit", "(", "'e...
Check to see if the provided name is a valid node module. @param name @returns {boolean}
[ "Check", "to", "see", "if", "the", "provided", "name", "is", "a", "valid", "node", "module", "." ]
7afa6bdb159022a9bed1efaa2997a6d5f993c7e4
https://github.com/JamesMessinger/swagger-server/blob/7afa6bdb159022a9bed1efaa2997a6d5f993c7e4/lib/handlers.js#L119-L129
train
JamesMessinger/swagger-server
samples/sample3/handlers/employees/{username}/photos/{photoType}.js
loadMockData
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
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...
[ "function", "loadMockData", "(", "server", ",", "next", ")", "{", "// Create REST resources for each employee photo", "var", "resources", "=", "[", "]", ";", "data", ".", "employees", ".", "forEach", "(", "function", "(", "employee", ")", "{", "var", "collection...
Loads mock employee photo data @param {SwaggerServer} server @param {function} next
[ "Loads", "mock", "employee", "photo", "data" ]
7afa6bdb159022a9bed1efaa2997a6d5f993c7e4
https://github.com/JamesMessinger/swagger-server/blob/7afa6bdb159022a9bed1efaa2997a6d5f993c7e4/samples/sample3/handlers/employees/{username}/photos/{photoType}.js#L41-L52
train
JamesMessinger/swagger-server
lib/watcher.js
SwaggerWatcher
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
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 = []; ...
[ "function", "SwaggerWatcher", "(", "server", ")", "{", "var", "self", "=", "this", ";", "self", ".", "server", "=", "server", ";", "/**\n * The Swagger API files that are being watched.\n * @type {FSWatcher[]}\n */", "self", ".", "watchedSwaggerFiles", "=", "[", "...
Watches files for changes and updates the server accordingly. @param {SwaggerServer} server @constructor
[ "Watches", "files", "for", "changes", "and", "updates", "the", "server", "accordingly", "." ]
7afa6bdb159022a9bed1efaa2997a6d5f993c7e4
https://github.com/JamesMessinger/swagger-server/blob/7afa6bdb159022a9bed1efaa2997a6d5f993c7e4/lib/watcher.js#L14-L42
train
JamesMessinger/swagger-server
lib/watcher.js
watchFile
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
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 ...
[ "function", "watchFile", "(", "path", ",", "onChange", ")", "{", "try", "{", "var", "oldStats", "=", "fs", ".", "statSync", "(", "path", ")", ";", "var", "watcher", "=", "fs", ".", "watch", "(", "path", ",", "{", "persistent", ":", "false", "}", ")...
Watches a file, and calls the given callback whenever the file changes. @param {string} path The full path of the file. @param {function} onChange Callback signature is `function(event, filename)`. The event param will be "change", "delete", "move", etc. The filename param is the full path of the file, and it is guar...
[ "Watches", "a", "file", "and", "calls", "the", "given", "callback", "whenever", "the", "file", "changes", "." ]
7afa6bdb159022a9bed1efaa2997a6d5f993c7e4
https://github.com/JamesMessinger/swagger-server/blob/7afa6bdb159022a9bed1efaa2997a6d5f993c7e4/lib/watcher.js#L134-L165
train
JamesMessinger/swagger-server
samples/sample3/handlers/sessions.js
authenticate
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
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 =...
[ "function", "authenticate", "(", "req", ",", "res", ",", "next", ")", "{", "var", "username", "=", "req", ".", "body", ".", "username", ",", "password", "=", "req", ".", "body", ".", "password", ";", "if", "(", "req", ".", "session", "&&", "req", "...
Authenticates the user's login credentials and creates a new user session.
[ "Authenticates", "the", "user", "s", "login", "credentials", "and", "creates", "a", "new", "user", "session", "." ]
7afa6bdb159022a9bed1efaa2997a6d5f993c7e4
https://github.com/JamesMessinger/swagger-server/blob/7afa6bdb159022a9bed1efaa2997a6d5f993c7e4/samples/sample3/handlers/sessions.js#L35-L68
train
JamesMessinger/swagger-server
samples/sample3/handlers/sessions.js
sendSessionResponse
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
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); }
[ "function", "sendSessionResponse", "(", "req", ",", "res", ",", "next", ")", "{", "// Set the session cookie", "res", ".", "cookie", "(", "'session'", ",", "req", ".", "session", ".", "id", ")", ";", "// Set the Location HTTP header", "res", ".", "location", "...
Sends the session data and session cookie.
[ "Sends", "the", "session", "data", "and", "session", "cookie", "." ]
7afa6bdb159022a9bed1efaa2997a6d5f993c7e4
https://github.com/JamesMessinger/swagger-server/blob/7afa6bdb159022a9bed1efaa2997a6d5f993c7e4/samples/sample3/handlers/sessions.js#L73-L82
train
JamesMessinger/swagger-server
samples/sample3/handlers/sessions.js
identifyUser
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
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...
[ "function", "identifyUser", "(", "req", ",", "res", ",", "next", ")", "{", "// Get the session ID from the session cookie", "var", "sessionId", "=", "req", ".", "cookies", ".", "session", ";", "req", ".", "session", "=", "null", ";", "if", "(", "sessionId", ...
Identifies the user via the session cookie on the request. `req.session` is set to the user's session, so it can be used by subsequent middleware.
[ "Identifies", "the", "user", "via", "the", "session", "cookie", "on", "the", "request", ".", "req", ".", "session", "is", "set", "to", "the", "user", "s", "session", "so", "it", "can", "be", "used", "by", "subsequent", "middleware", "." ]
7afa6bdb159022a9bed1efaa2997a6d5f993c7e4
https://github.com/JamesMessinger/swagger-server/blob/7afa6bdb159022a9bed1efaa2997a6d5f993c7e4/samples/sample3/handlers/sessions.js#L88-L112
train
JamesMessinger/swagger-server
samples/sample3/handlers/sessions.js
mustBeLoggedIn
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
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'); } }
[ "function", "mustBeLoggedIn", "(", "req", ",", "res", ",", "next", ")", "{", "if", "(", "req", ".", "session", "&&", "req", ".", "session", ".", "user", ")", "{", "next", "(", ")", ";", "}", "else", "{", "res", ".", "status", "(", "401", ")", "...
Prevents access to anonymous users.
[ "Prevents", "access", "to", "anonymous", "users", "." ]
7afa6bdb159022a9bed1efaa2997a6d5f993c7e4
https://github.com/JamesMessinger/swagger-server/blob/7afa6bdb159022a9bed1efaa2997a6d5f993c7e4/samples/sample3/handlers/sessions.js#L117-L124
train
JamesMessinger/swagger-server
samples/sample3/handlers/sessions.js
adminsOnly
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
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'); } }
[ "function", "adminsOnly", "(", "req", ",", "res", ",", "next", ")", "{", "if", "(", "req", ".", "session", "&&", "_", ".", "contains", "(", "req", ".", "session", ".", "user", ".", "roles", ",", "'admin'", ")", ")", "{", "next", "(", ")", ";", ...
Prevents access to anyone who is not in the "admin" role.
[ "Prevents", "access", "to", "anyone", "who", "is", "not", "in", "the", "admin", "role", "." ]
7afa6bdb159022a9bed1efaa2997a6d5f993c7e4
https://github.com/JamesMessinger/swagger-server/blob/7afa6bdb159022a9bed1efaa2997a6d5f993c7e4/samples/sample3/handlers/sessions.js#L129-L136
train
JamesMessinger/swagger-server
samples/sample3/handlers/sessions.js
yourselfOnly
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
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...
[ "function", "yourselfOnly", "(", "req", ",", "res", ",", "next", ")", "{", "// Get the username or sessionId from the URL", "var", "username", "=", "req", ".", "params", ".", "username", ";", "var", "sessionId", "=", "req", ".", "params", ".", "sessionId", ";"...
Prevents users from accessing another user's account. Except for "admins", who can access any account.
[ "Prevents", "users", "from", "accessing", "another", "user", "s", "account", ".", "Except", "for", "admins", "who", "can", "access", "any", "account", "." ]
7afa6bdb159022a9bed1efaa2997a6d5f993c7e4
https://github.com/JamesMessinger/swagger-server/blob/7afa6bdb159022a9bed1efaa2997a6d5f993c7e4/samples/sample3/handlers/sessions.js#L142-L158
train
JamesMessinger/swagger-server
samples/sample3/handlers/projects.js
loadMockData
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
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); }
[ "function", "loadMockData", "(", "server", ",", "next", ")", "{", "// Create REST resources for each project", "var", "resources", "=", "data", ".", "projects", ".", "map", "(", "function", "(", "project", ")", "{", "return", "new", "swagger", ".", "Resource", ...
Loads mock project data @param {SwaggerServer} server @param {function} next
[ "Loads", "mock", "project", "data" ]
7afa6bdb159022a9bed1efaa2997a6d5f993c7e4
https://github.com/JamesMessinger/swagger-server/blob/7afa6bdb159022a9bed1efaa2997a6d5f993c7e4/samples/sample3/handlers/projects.js#L35-L43
train
JamesMessinger/swagger-server
samples/sample3/handlers/projects.js
verifyProjectIdDoesNotExist
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
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) { ...
[ "function", "verifyProjectIdDoesNotExist", "(", "req", ",", "res", ",", "next", ")", "{", "var", "projectId", "=", "req", ".", "body", ".", "id", ";", "var", "dataStore", "=", "req", ".", "app", ".", "dataStore", ";", "// Check for an existing project REST res...
Verifies that the new project's ID isn't the same as any existing ID.
[ "Verifies", "that", "the", "new", "project", "s", "ID", "isn", "t", "the", "same", "as", "any", "existing", "ID", "." ]
7afa6bdb159022a9bed1efaa2997a6d5f993c7e4
https://github.com/JamesMessinger/swagger-server/blob/7afa6bdb159022a9bed1efaa2997a6d5f993c7e4/samples/sample3/handlers/projects.js#L48-L63
train
JamesMessinger/swagger-server
samples/sample3/handlers/projects.js
verifyProjectNameDoesNotExist
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
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...
[ "function", "verifyProjectNameDoesNotExist", "(", "req", ",", "res", ",", "next", ")", "{", "var", "projectName", "=", "req", ".", "body", ".", "name", ".", "toLowerCase", "(", ")", ";", "var", "dataStore", "=", "req", ".", "app", ".", "dataStore", ";", ...
Verifies that the new project's name isn't the same as any existing name.
[ "Verifies", "that", "the", "new", "project", "s", "name", "isn", "t", "the", "same", "as", "any", "existing", "name", "." ]
7afa6bdb159022a9bed1efaa2997a6d5f993c7e4
https://github.com/JamesMessinger/swagger-server/blob/7afa6bdb159022a9bed1efaa2997a6d5f993c7e4/samples/sample3/handlers/projects.js#L68-L86
train
keycloak/keycloak-admin-client
lib/role-mappings.js
find
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
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}/...
[ "function", "find", "(", "client", ")", "{", "return", "function", "find", "(", "realmName", ",", "userId", ")", "{", "return", "new", "Promise", "(", "(", "resolve", ",", "reject", ")", "=>", "{", "const", "req", "=", "{", "auth", ":", "{", "bearer"...
A function to get the all the role mappings of an user @param {string} realmName - The name of the realm (not the realmID) where the client roles exist - ex: master @param {string} userId - The id of the user whose role mappings should be found @returns {Promise} A promise that will resolve with the Array of role mappi...
[ "A", "function", "to", "get", "the", "all", "the", "role", "mappings", "of", "an", "user" ]
eb75ad219dfc6aa14fe8c976647b9c017502458d
https://github.com/keycloak/keycloak-admin-client/blob/eb75ad219dfc6aa14fe8c976647b9c017502458d/lib/role-mappings.js#L28-L53
train
keycloak/keycloak-admin-client
lib/users.js
find
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
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 = `${...
[ "function", "find", "(", "client", ")", "{", "return", "function", "find", "(", "realm", ",", "options", ")", "{", "return", "new", "Promise", "(", "(", "resolve", ",", "reject", ")", "=>", "{", "options", "=", "options", "||", "{", "}", ";", "const"...
A function to get the list of users or a user for a realm. @param {string} realmName - The name of the realm(not the realmID) - ex: master @param {object} [options] - The options object @param {string} [options.userId] - use this options to get a user by an id. If this value is populated, it overrides the querystring p...
[ "A", "function", "to", "get", "the", "list", "of", "users", "or", "a", "user", "for", "a", "realm", "." ]
eb75ad219dfc6aa14fe8c976647b9c017502458d
https://github.com/keycloak/keycloak-admin-client/blob/eb75ad219dfc6aa14fe8c976647b9c017502458d/lib/users.js#L43-L74
train
keycloak/keycloak-admin-client
lib/users.js
create
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
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', ...
[ "function", "create", "(", "client", ")", "{", "return", "function", "create", "(", "realm", ",", "user", ")", "{", "return", "new", "Promise", "(", "(", "resolve", ",", "reject", ")", "=>", "{", "const", "req", "=", "{", "url", ":", "`", "${", "cl...
A function to create a new user for a realm. @param {string} realmName - The name of the realm(not the realmID) - ex: master @param {object} user - The JSON representation of a user - http://keycloak.github.io/docs/rest-api/index.html#_userrepresentation - username must be unique @returns {Promise} A promise that will ...
[ "A", "function", "to", "create", "a", "new", "user", "for", "a", "realm", "." ]
eb75ad219dfc6aa14fe8c976647b9c017502458d
https://github.com/keycloak/keycloak-admin-client/blob/eb75ad219dfc6aa14fe8c976647b9c017502458d/lib/users.js#L90-L124
train
keycloak/keycloak-admin-client
lib/users.js
update
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
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 }, ...
[ "function", "update", "(", "client", ")", "{", "return", "function", "update", "(", "realmName", ",", "user", ")", "{", "return", "new", "Promise", "(", "(", "resolve", ",", "reject", ")", "=>", "{", "user", "=", "user", "||", "{", "}", ";", "const",...
A function to update a user for a realm @param {string} realmName - The name of the realm(not the realmID) - ex: master, @param {object} user - The JSON representation of the fields to update for the user - This must include the user.id field. @returns {Promise} A promise that resolves. @example keycloakAdminClient(set...
[ "A", "function", "to", "update", "a", "user", "for", "a", "realm" ]
eb75ad219dfc6aa14fe8c976647b9c017502458d
https://github.com/keycloak/keycloak-admin-client/blob/eb75ad219dfc6aa14fe8c976647b9c017502458d/lib/users.js#L140-L168
train
keycloak/keycloak-admin-client
lib/users.js
resetPassword
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
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) { ...
[ "function", "resetPassword", "(", "c", ")", "{", "return", "function", "resetPassword", "(", "realmName", ",", "userId", ",", "payload", ")", "{", "return", "new", "Promise", "(", "(", "resolve", ",", "reject", ")", "=>", "{", "payload", "=", "payload", ...
A function to reset a user password for a realm @param {string} realmName - The name of the realm(not the realmID) - ex: master, @param {string} userId - The id of user @param {object} payload { temporary: boolean , value : string } - The JSON representation of the fields to update for the password @returns {Promise} A...
[ "A", "function", "to", "reset", "a", "user", "password", "for", "a", "realm" ]
eb75ad219dfc6aa14fe8c976647b9c017502458d
https://github.com/keycloak/keycloak-admin-client/blob/eb75ad219dfc6aa14fe8c976647b9c017502458d/lib/users.js#L226-L264
train
keycloak/keycloak-admin-client
lib/users.js
count
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
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, ...
[ "function", "count", "(", "client", ")", "{", "return", "function", "count", "(", "realm", ")", "{", "return", "new", "Promise", "(", "(", "resolve", ",", "reject", ")", "=>", "{", "const", "req", "=", "{", "auth", ":", "{", "bearer", ":", "privates"...
A function to get the number of users in a realm. @param {string} realmName - The name of the realm(not the realmID) - ex: master @returns {Promise} A promise that will resolve with an integer - the number of users in the realm @example keycloakAdminClient(settings) .then((client) => { client.users.count(realmName) .th...
[ "A", "function", "to", "get", "the", "number", "of", "users", "in", "a", "realm", "." ]
eb75ad219dfc6aa14fe8c976647b9c017502458d
https://github.com/keycloak/keycloak-admin-client/blob/eb75ad219dfc6aa14fe8c976647b9c017502458d/lib/users.js#L362-L386
train
marklogic/node-client-api
lib/values-builder.js
copyFromValueBuilder
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
function copyFromValueBuilder(otherValueBuilder) { var tb = new ValueBuilder(); // TODO: share with QueryBuilder if (otherValueBuilder != null) { var clauseKeys = [ 'fromIndexesClause', 'whereClause', 'aggregatesClause', 'sliceClause', 'withOptionsClause' ]; var isString = (typ...
[ "function", "copyFromValueBuilder", "(", "otherValueBuilder", ")", "{", "var", "tb", "=", "new", "ValueBuilder", "(", ")", ";", "// TODO: share with QueryBuilder", "if", "(", "otherValueBuilder", "!=", "null", ")", "{", "var", "clauseKeys", "=", "[", "'fromIndexes...
Initializes a new values builder by copying the from indexes clause and any where, aggregates, slice, or withOptions clause defined in the built query. @method valuesBuilder#copyFrom @since 1.0 @param {valuesBuilder.BuiltQuery} query - an existing values query with clauses to copy @returns {valuesBuilder.BuiltQuery} a ...
[ "Initializes", "a", "new", "values", "builder", "by", "copying", "the", "from", "indexes", "clause", "and", "any", "where", "aggregates", "slice", "or", "withOptions", "clause", "defined", "in", "the", "built", "query", "." ]
368be82f377eb4178ece35d9491dac6672bd1288
https://github.com/marklogic/node-client-api/blob/368be82f377eb4178ece35d9491dac6672bd1288/lib/values-builder.js#L408-L431
train
marklogic/node-client-api
lib/query-builder.js
checkQueryArray
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
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; }
[ "function", "checkQueryArray", "(", "queryArray", ")", "{", "if", "(", "queryArray", "==", "null", ")", "{", "return", "queryArray", ";", "}", "var", "max", "=", "queryArray", ".", "length", ";", "if", "(", "max", "===", "0", ")", "{", "return", "query...
A composable query. @typedef {object} queryBuilder.Query @since 1.0 An indexed name such as a JSON property, {@link queryBuilder#element} or {@link queryBuilder#attribute}, {@link queryBuilder#field}, or {@link queryBuilder#pathIndex}. @typedef {object} queryBuilder.IndexedName @since 1.0 An indexed name such as a ...
[ "A", "composable", "query", "." ]
368be82f377eb4178ece35d9491dac6672bd1288
https://github.com/marklogic/node-client-api/blob/368be82f377eb4178ece35d9491dac6672bd1288/lib/query-builder.js#L119-L135
train
marklogic/node-client-api
lib/query-builder.js
and
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
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...
[ "function", "and", "(", ")", "{", "var", "args", "=", "mlutil", ".", "asArray", ".", "apply", "(", "null", ",", "arguments", ")", ";", "var", "queries", "=", "[", "]", ";", "var", "ordered", "=", "null", ";", "var", "arg", "=", "null", ";", "for"...
Builds a query for the intersection of the subqueries. @method @since 1.0 @memberof queryBuilder# @param {...queryBuilder.Query} subquery - a word, value, range, geospatial, or other query or a composer such as an or query. @param {queryBuilder.OrderParam} [ordering] - the ordering on the subqueries returned from {@lin...
[ "Builds", "a", "query", "for", "the", "intersection", "of", "the", "subqueries", "." ]
368be82f377eb4178ece35d9491dac6672bd1288
https://github.com/marklogic/node-client-api/blob/368be82f377eb4178ece35d9491dac6672bd1288/lib/query-builder.js#L182-L207
train
marklogic/node-client-api
lib/query-builder.js
andNot
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
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...
[ "function", "andNot", "(", ")", "{", "var", "args", "=", "mlutil", ".", "asArray", ".", "apply", "(", "null", ",", "arguments", ")", ";", "switch", "(", "args", ".", "length", ")", "{", "case", "0", ":", "throw", "new", "Error", "(", "'missing positi...
Builds a query with positive and negative subqueries. @method @since 1.0 @memberof queryBuilder# @param {queryBuilder.Query} positiveQuery - a query that must match the result documents @param {queryBuilder.Query} negativeQuery - a query that must not match the result documents @returns {queryBuilder.Query} a composabl...
[ "Builds", "a", "query", "with", "positive", "and", "negative", "subqueries", "." ]
368be82f377eb4178ece35d9491dac6672bd1288
https://github.com/marklogic/node-client-api/blob/368be82f377eb4178ece35d9491dac6672bd1288/lib/query-builder.js#L272-L284
train
marklogic/node-client-api
lib/query-builder.js
boost
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
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...
[ "function", "boost", "(", ")", "{", "var", "args", "=", "mlutil", ".", "asArray", ".", "apply", "(", "null", ",", "arguments", ")", ";", "switch", "(", "args", ".", "length", ")", "{", "case", "0", ":", "throw", "new", "Error", "(", "'missing matchin...
Builds a query with matching and boosting subqueries. @method @since 1.0 @memberof queryBuilder# @param {queryBuilder.Query} matchingQuery - a query that must match the result documents @param {queryBuilder.Query} boostingQuery - a query that increases the ranking when qualifying result documents @returns {queryBuilder...
[ "Builds", "a", "query", "with", "matching", "and", "boosting", "subqueries", "." ]
368be82f377eb4178ece35d9491dac6672bd1288
https://github.com/marklogic/node-client-api/blob/368be82f377eb4178ece35d9491dac6672bd1288/lib/query-builder.js#L405-L417
train
marklogic/node-client-api
lib/query-builder.js
directory
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
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...
[ "function", "directory", "(", ")", "{", "var", "args", "=", "mlutil", ".", "asArray", ".", "apply", "(", "null", ",", "arguments", ")", ";", "var", "uris", "=", "[", "]", ";", "var", "infinite", "=", "null", ";", "var", "arg", "=", "null", ";", "...
Builds a query matching documents in one or more database directories. @method @since 1.0 @memberof queryBuilder# @param {string|string[]} uris - one or more directory uris to match @param {boolean} [infinite] - whether to match documents at the top level or at any level of depth within the specified directories @retur...
[ "Builds", "a", "query", "matching", "documents", "in", "one", "or", "more", "database", "directories", "." ]
368be82f377eb4178ece35d9491dac6672bd1288
https://github.com/marklogic/node-client-api/blob/368be82f377eb4178ece35d9491dac6672bd1288/lib/query-builder.js#L999-L1019
train
marklogic/node-client-api
lib/query-builder.js
field
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
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...
[ "function", "field", "(", ")", "{", "var", "args", "=", "mlutil", ".", "asArray", ".", "apply", "(", "null", ",", "arguments", ")", ";", "switch", "(", "args", ".", "length", ")", "{", "case", "0", ":", "throw", "new", "Error", "(", "'missing field n...
Specifies a field for a query. @method @since 1.0 @memberof queryBuilder# @param {string} name - the name of the field @param {string} [collation] - the collation of a field over strings @returns {queryBuilder.IndexedName} an indexed name for specifying a query
[ "Specifies", "a", "field", "for", "a", "query", "." ]
368be82f377eb4178ece35d9491dac6672bd1288
https://github.com/marklogic/node-client-api/blob/368be82f377eb4178ece35d9491dac6672bd1288/lib/query-builder.js#L1156-L1168
train
marklogic/node-client-api
lib/query-builder.js
heatmap
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
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...
[ "function", "heatmap", "(", ")", "{", "var", "args", "=", "mlutil", ".", "asArray", ".", "apply", "(", "null", ",", "arguments", ")", ";", "var", "argLen", "=", "args", ".", "length", ";", "if", "(", "argLen", "<", "1", ")", "{", "throw", "new", ...
Specifies the buckets for a geospatial facet. @typedef {object} queryBuilder.HeatMapParam @since 1.0 Divides a geospatial box into a two-dimensional grid for calculating facets based on document counts for each cell within the grid. The coordinates of the box can be specified either by passing the return value from t...
[ "Specifies", "the", "buckets", "for", "a", "geospatial", "facet", "." ]
368be82f377eb4178ece35d9491dac6672bd1288
https://github.com/marklogic/node-client-api/blob/368be82f377eb4178ece35d9491dac6672bd1288/lib/query-builder.js#L1742-L1813
train
marklogic/node-client-api
lib/query-builder.js
latlon
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
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...
[ "function", "latlon", "(", ")", "{", "var", "args", "=", "mlutil", ".", "asArray", ".", "apply", "(", "null", ",", "arguments", ")", ";", "switch", "(", "args", ".", "length", ")", "{", "case", "0", ":", "throw", "new", "Error", "(", "'missing latitu...
Specifies the latitude and longitude for a coordinate of the region criteria for a geospatial query. The latitude and longitude can be passed as individual numeric parameters or wrapped in an array @method @since 1.0 @memberof queryBuilder# @param {number} latitude - the north-south location @param {number} longitude -...
[ "Specifies", "the", "latitude", "and", "longitude", "for", "a", "coordinate", "of", "the", "region", "criteria", "for", "a", "geospatial", "query", ".", "The", "latitude", "and", "longitude", "can", "be", "passed", "as", "individual", "numeric", "parameters", ...
368be82f377eb4178ece35d9491dac6672bd1288
https://github.com/marklogic/node-client-api/blob/368be82f377eb4178ece35d9491dac6672bd1288/lib/query-builder.js#L1857-L1869
train
marklogic/node-client-api
lib/query-builder.js
notIn
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
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...
[ "function", "notIn", "(", ")", "{", "var", "args", "=", "mlutil", ".", "asArray", ".", "apply", "(", "null", ",", "arguments", ")", ";", "switch", "(", "args", ".", "length", ")", "{", "case", "0", ":", "throw", "new", "Error", "(", "'missing positiv...
Builds a query where the matching content qualifies for the positive query and does not qualify for the negative query. Positions must be enabled for indexes. @method @since 1.0 @memberof queryBuilder# @param {queryBuilder.Query} positiveQuery - a query that must match the content @param {queryBuilder.Query} negativeQu...
[ "Builds", "a", "query", "where", "the", "matching", "content", "qualifies", "for", "the", "positive", "query", "and", "does", "not", "qualify", "for", "the", "negative", "query", ".", "Positions", "must", "be", "enabled", "for", "indexes", "." ]
368be82f377eb4178ece35d9491dac6672bd1288
https://github.com/marklogic/node-client-api/blob/368be82f377eb4178ece35d9491dac6672bd1288/lib/query-builder.js#L2069-L2081
train
marklogic/node-client-api
lib/query-builder.js
pathIndex
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
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...
[ "function", "pathIndex", "(", ")", "{", "var", "args", "=", "mlutil", ".", "asArray", ".", "apply", "(", "null", ",", "arguments", ")", ";", "switch", "(", "args", ".", "length", ")", "{", "case", "0", ":", "throw", "new", "Error", "(", "'missing pat...
Specifies a path configured as an index over JSON or XML documents on the server. @method @since 1.0 @memberof queryBuilder# @param {string} pathExpression - the indexed path @param {object} namespaces - bindings between the prefixes in the path and namespace URIs @returns {queryBuilder.IndexedName} an indexed name for...
[ "Specifies", "a", "path", "configured", "as", "an", "index", "over", "JSON", "or", "XML", "documents", "on", "the", "server", "." ]
368be82f377eb4178ece35d9491dac6672bd1288
https://github.com/marklogic/node-client-api/blob/368be82f377eb4178ece35d9491dac6672bd1288/lib/query-builder.js#L2163-L2175
train
marklogic/node-client-api
lib/query-builder.js
coordSystem
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
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...
[ "function", "coordSystem", "(", ")", "{", "var", "args", "=", "mlutil", ".", "asArray", ".", "apply", "(", "null", ",", "arguments", ")", ";", "switch", "(", "args", ".", "length", ")", "{", "case", "0", ":", "throw", "new", "Error", "(", "'missing i...
Identifies the coordinate system used by a geospatial path index. @method @since 1.0 @memberof queryBuilder# @param {string} coord - the name of the coordinate system @returns {queryBuilder.CoordSystem} a coordinate system identifier
[ "Identifies", "the", "coordinate", "system", "used", "by", "a", "geospatial", "path", "index", "." ]
368be82f377eb4178ece35d9491dac6672bd1288
https://github.com/marklogic/node-client-api/blob/368be82f377eb4178ece35d9491dac6672bd1288/lib/query-builder.js#L2214-L2224
train
marklogic/node-client-api
lib/query-builder.js
property
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
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); } }
[ "function", "property", "(", ")", "{", "var", "args", "=", "mlutil", ".", "asArray", ".", "apply", "(", "null", ",", "arguments", ")", ";", "switch", "(", "args", ".", "length", ")", "{", "case", "0", ":", "throw", "new", "Error", "(", "'missing JSON...
Specifies a JSON property for a query. As a shortcut, a JSON property can also be specified with a string instead of calling this function. @method @since 1.0 @memberof queryBuilder# @param {string} name - the name of the property @returns {queryBuilder.IndexedName} an indexed name for specifying a query
[ "Specifies", "a", "JSON", "property", "for", "a", "query", ".", "As", "a", "shortcut", "a", "JSON", "property", "can", "also", "be", "specified", "with", "a", "string", "instead", "of", "calling", "this", "function", "." ]
368be82f377eb4178ece35d9491dac6672bd1288
https://github.com/marklogic/node-client-api/blob/368be82f377eb4178ece35d9491dac6672bd1288/lib/query-builder.js#L2357-L2367
train
marklogic/node-client-api
lib/query-builder.js
term
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
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...
[ "function", "term", "(", ")", "{", "var", "args", "=", "mlutil", ".", "asArray", ".", "apply", "(", "null", ",", "arguments", ")", ";", "var", "text", "=", "[", "]", ";", "var", "weight", "=", "null", ";", "var", "termOptions", "=", "null", ";", ...
Builds a query for matching words in a JSON, text, or XML document. @method @since 1.0 @memberof queryBuilder# @param {string} [...text] - one or more words to match @param {queryBuilder.WeightParam} [weight] - a weight returned by {@link queryBuilder#weight} to increase or decrease the score of the query relative to o...
[ "Builds", "a", "query", "for", "matching", "words", "in", "a", "JSON", "text", "or", "XML", "document", "." ]
368be82f377eb4178ece35d9491dac6672bd1288
https://github.com/marklogic/node-client-api/blob/368be82f377eb4178ece35d9491dac6672bd1288/lib/query-builder.js#L3104-L3128
train
marklogic/node-client-api
lib/query-builder.js
calculate
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
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; ...
[ "function", "calculate", "(", ")", "{", "/*jshint validthis:true */", "var", "self", "=", "(", "this", "instanceof", "QueryBuilder", ")", "?", "this", ":", "new", "QueryBuilder", "(", ")", ";", "var", "args", "=", "mlutil", ".", "asArray", ".", "apply", "(...
Sets the calculate clause of a built query, specifying JSON properties, XML elements or attributes, fields, or paths with a range index for value frequency or other aggregate calculation. @method @since 1.0 @memberof queryBuilder# @param {queryBuilder.Facet} ...facets - the facets to calculate over the documents in the...
[ "Sets", "the", "calculate", "clause", "of", "a", "built", "query", "specifying", "JSON", "properties", "XML", "elements", "or", "attributes", "fields", "or", "paths", "with", "a", "range", "index", "for", "value", "frequency", "or", "other", "aggregate", "calc...
368be82f377eb4178ece35d9491dac6672bd1288
https://github.com/marklogic/node-client-api/blob/368be82f377eb4178ece35d9491dac6672bd1288/lib/query-builder.js#L3918-L3932
train
marklogic/node-client-api
lib/query-builder.js
extract
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
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...
[ "function", "extract", "(", ")", "{", "var", "args", "=", "mlutil", ".", "asArray", ".", "apply", "(", "null", ",", "arguments", ")", ";", "var", "argLen", "=", "args", ".", "length", ";", "if", "(", "argLen", "<", "1", ")", "{", "throw", "new", ...
Specifies JSON properties or XML elements to project from the documents returned by a query. @method @since 1.0 @memberof queryBuilder# @param {string|string[]} paths - restricted XPaths (valid for the cts:valid-index-path() function) to match in documents @param {object} [namespaces] - for XPaths using namespaces, an ...
[ "Specifies", "JSON", "properties", "or", "XML", "elements", "to", "project", "from", "the", "documents", "returned", "by", "a", "query", "." ]
368be82f377eb4178ece35d9491dac6672bd1288
https://github.com/marklogic/node-client-api/blob/368be82f377eb4178ece35d9491dac6672bd1288/lib/query-builder.js#L4998-L5032
train
marklogic/node-client-api
lib/query-builder.js
withOptions
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
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...
[ "function", "withOptions", "(", ")", "{", "/*jshint validthis:true */", "var", "self", "=", "(", "this", "instanceof", "QueryBuilder", ")", "?", "this", ":", "new", "QueryBuilder", "(", ")", ";", "// TODO: share with documents.js", "var", "optionKeyMapping", "=", ...
Sets the withOptions clause of a built query to configure the query; takes a configuration object with the following named parameters. This function may be called on the result of building a query. When the 'debug', 'metrics', 'queryPlan', or 'similarDocs' parameter is set, a search summary object will be returned alon...
[ "Sets", "the", "withOptions", "clause", "of", "a", "built", "query", "to", "configure", "the", "query", ";", "takes", "a", "configuration", "object", "with", "the", "following", "named", "parameters", ".", "This", "function", "may", "be", "called", "on", "th...
368be82f377eb4178ece35d9491dac6672bd1288
https://github.com/marklogic/node-client-api/blob/368be82f377eb4178ece35d9491dac6672bd1288/lib/query-builder.js#L5125-L5159
train
marklogic/node-client-api
lib/patch-builder.js
remove
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
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...
[ "function", "remove", "(", ")", "{", "var", "select", "=", "null", ";", "var", "cardinality", "=", "null", ";", "var", "argLen", "=", "arguments", ".", "length", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "argLen", ";", "i", "++", ")",...
An operation as part of a document patch request. @typedef {object} patchBuilder.PatchOperation @since 1.0 Builds an operation to remove a JSON property or XML element or attribute. @method @since 1.0 @memberof patchBuilder# @param {string} select - the path to select the fragment to remove @param {string} [cardina...
[ "An", "operation", "as", "part", "of", "a", "document", "patch", "request", "." ]
368be82f377eb4178ece35d9491dac6672bd1288
https://github.com/marklogic/node-client-api/blob/368be82f377eb4178ece35d9491dac6672bd1288/lib/patch-builder.js#L47-L77
train
marklogic/node-client-api
lib/patch-builder.js
insert
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
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 ===...
[ "function", "insert", "(", ")", "{", "var", "context", "=", "null", ";", "var", "position", "=", "null", ";", "var", "content", "=", "void", "0", ";", "var", "cardinality", "=", "null", ";", "var", "argLen", "=", "arguments", ".", "length", ";", "for...
Builds an operation to insert content. @method @since 1.0 @memberof patchBuilder# @param {string} context - the path to the container of the inserted content @param {string} position - a specification from the before|after|last-child enumeration controlling where the content will be inserted relative to the context @...
[ "Builds", "an", "operation", "to", "insert", "content", "." ]
368be82f377eb4178ece35d9491dac6672bd1288
https://github.com/marklogic/node-client-api/blob/368be82f377eb4178ece35d9491dac6672bd1288/lib/patch-builder.js#L94-L145
train
marklogic/node-client-api
lib/patch-builder.js
replace
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
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 ===...
[ "function", "replace", "(", ")", "{", "var", "select", "=", "null", ";", "var", "content", "=", "void", "0", ";", "var", "cardinality", "=", "null", ";", "var", "apply", "=", "null", ";", "var", "argLen", "=", "arguments", ".", "length", ";", "for", ...
Builds an operation to replace a JSON property or XML element or attribute. @method @since 1.0 @memberof patchBuilder# @param {string} select - the path to select the fragment to replace @param [content] - the object or value replacing the selected fragment or an {@link patchBuilder.ApplyDefinition} specifyi...
[ "Builds", "an", "operation", "to", "replace", "a", "JSON", "property", "or", "XML", "element", "or", "attribute", "." ]
368be82f377eb4178ece35d9491dac6672bd1288
https://github.com/marklogic/node-client-api/blob/368be82f377eb4178ece35d9491dac6672bd1288/lib/patch-builder.js#L419-L473
train
marklogic/node-client-api
lib/patch-builder.js
addPermission
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
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...
[ "function", "addPermission", "(", ")", "{", "var", "permission", "=", "getPermission", "(", "mlutil", ".", "asArray", ".", "apply", "(", "null", ",", "arguments", ")", ")", ";", "if", "(", "permission", "===", "null", ")", "{", "throw", "new", "Error", ...
Specifies operations to patch the permissions of a document. @namespace patchBuilderPermissions Specifies a role to add to a document's permissions; takes a configuration object with the following named parameters or, as a shortcut, a role string and capabilities string or array. @method patchBuilderPermissions#add @...
[ "Specifies", "operations", "to", "patch", "the", "permissions", "of", "a", "document", "." ]
368be82f377eb4178ece35d9491dac6672bd1288
https://github.com/marklogic/node-client-api/blob/368be82f377eb4178ece35d9491dac6672bd1288/lib/patch-builder.js#L647-L655
train
marklogic/node-client-api
lib/patch-builder.js
replacePermission
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
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...
[ "function", "replacePermission", "(", ")", "{", "var", "permission", "=", "getPermission", "(", "mlutil", ".", "asArray", ".", "apply", "(", "null", ",", "arguments", ")", ")", ";", "if", "(", "permission", "===", "null", ")", "{", "throw", "new", "Error...
Specifies different capabilities for a role with permissions on a document; takes a configuration object with the following named parameters or, as a shortcut, a role string and capabilities string or array. @method patchBuilderPermissions#replace @since 1.0 @param {string} role - the name of an existing role with perm...
[ "Specifies", "different", "capabilities", "for", "a", "role", "with", "permissions", "on", "a", "document", ";", "takes", "a", "configuration", "object", "with", "the", "following", "named", "parameters", "or", "as", "a", "shortcut", "a", "role", "string", "an...
368be82f377eb4178ece35d9491dac6672bd1288
https://github.com/marklogic/node-client-api/blob/368be82f377eb4178ece35d9491dac6672bd1288/lib/patch-builder.js#L667-L678
train
marklogic/node-client-api
lib/patch-builder.js
addProperty
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
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); }
[ "function", "addProperty", "(", "name", ",", "value", ")", "{", "if", "(", "typeof", "name", "!==", "'string'", "||", "value", "==", "null", ")", "{", "throw", "new", "Error", "(", "'properties.add() takes a string name and a value'", ")", ";", "}", "var", "...
Specifies operations to patch the metadata properties of a document. @namespace patchBuilderProperties Specifies a new property to add to a document's metadata. @method patchBuilderProperties#add @since 1.0 @param {string} name - the name of the new metadata property @param value - the value of the new metadata prope...
[ "Specifies", "operations", "to", "patch", "the", "metadata", "properties", "of", "a", "document", "." ]
368be82f377eb4178ece35d9491dac6672bd1288
https://github.com/marklogic/node-client-api/blob/368be82f377eb4178ece35d9491dac6672bd1288/lib/patch-builder.js#L756-L763
train
marklogic/node-client-api
lib/patch-builder.js
replaceProperty
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
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); }
[ "function", "replaceProperty", "(", "name", ",", "value", ")", "{", "if", "(", "typeof", "name", "!==", "'string'", "||", "value", "==", "null", ")", "{", "throw", "new", "Error", "(", "'properties.replace() takes a string name and a value'", ")", ";", "}", "r...
Specifies a different value for a property in a document's metadata. @method patchBuilderProperties#replace @since 1.0 @param {string} name - the name of the existing metadata property @param value - the modified value of the metadata property @returns {patchBuilder.PatchOperation} a patch operation
[ "Specifies", "a", "different", "value", "for", "a", "property", "in", "a", "document", "s", "metadata", "." ]
368be82f377eb4178ece35d9491dac6672bd1288
https://github.com/marklogic/node-client-api/blob/368be82f377eb4178ece35d9491dac6672bd1288/lib/patch-builder.js#L772-L777
train
marklogic/node-client-api
lib/patch-builder.js
addMetadataValue
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
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); }
[ "function", "addMetadataValue", "(", "name", ",", "value", ")", "{", "if", "(", "typeof", "name", "!==", "'string'", "||", "typeof", "value", "!==", "'string'", ")", "{", "throw", "new", "Error", "(", "'metadataValues.add() takes a string name and string value'", ...
Specifies operations to patch the metadata values of a document. @namespace patchBuilderMetadataValues @since 2.0.1 Specifies a new metadata value to add to a document. @method patchBuilderMetadataValues#add @since 2.0.1 @param {string} name - the name of the new metadata value @param value - the value of the new met...
[ "Specifies", "operations", "to", "patch", "the", "metadata", "values", "of", "a", "document", "." ]
368be82f377eb4178ece35d9491dac6672bd1288
https://github.com/marklogic/node-client-api/blob/368be82f377eb4178ece35d9491dac6672bd1288/lib/patch-builder.js#L824-L831
train
marklogic/node-client-api
lib/mlutil.js
asArray
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
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...
[ "function", "asArray", "(", ")", "{", "var", "argLen", "=", "arguments", ".", "length", ";", "switch", "(", "argLen", ")", "{", "// No arguments returns an empty array", "case", "0", ":", "return", "[", "]", ";", "// Single array argument returns that array", "cas...
Normalize arguments by returning them as an array.
[ "Normalize", "arguments", "by", "returning", "them", "as", "an", "array", "." ]
368be82f377eb4178ece35d9491dac6672bd1288
https://github.com/marklogic/node-client-api/blob/368be82f377eb4178ece35d9491dac6672bd1288/lib/mlutil.js#L23-L45
train
marklogic/node-client-api
lib/transactions.js
openOutputTransform
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
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}; }
[ "function", "openOutputTransform", "(", "headers", "/*, data*/", ")", "{", "/*jshint validthis:true */", "var", "operation", "=", "this", ";", "var", "txid", "=", "headers", ".", "location", ".", "substring", "(", "'/v1/transactions/'", ".", "length", ")", ";", ...
Provides functions to open, commit, or rollback multi-statement transactions. The client must have been created for a user with the rest-writer role. @namespace transactions @ignore
[ "Provides", "functions", "to", "open", "commit", "or", "rollback", "multi", "-", "statement", "transactions", ".", "The", "client", "must", "have", "been", "created", "for", "a", "user", "with", "the", "rest", "-", "writer", "role", "." ]
368be82f377eb4178ece35d9491dac6672bd1288
https://github.com/marklogic/node-client-api/blob/368be82f377eb4178ece35d9491dac6672bd1288/lib/transactions.js#L29-L40
train
marklogic/node-client-api
lib/documents.js
probeOutputTransform
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
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...
[ "function", "probeOutputTransform", "(", "/*headers, data*/", ")", "{", "/*jshint validthis:true */", "var", "operation", "=", "this", ";", "var", "statusCode", "=", "operation", ".", "responseStatusCode", ";", "var", "exists", "=", "(", "statusCode", "===", "200", ...
Provides functions to write, read, query, or perform other operations on documents in the database. For operations that modify the database, the client must have been created for a user with the rest-writer role. For operations that read or query the database, the user need only have the rest-reader role. @namespace do...
[ "Provides", "functions", "to", "write", "read", "query", "or", "perform", "other", "operations", "on", "documents", "in", "the", "database", ".", "For", "operations", "that", "modify", "the", "database", "the", "client", "must", "have", "been", "created", "for...
368be82f377eb4178ece35d9491dac6672bd1288
https://github.com/marklogic/node-client-api/blob/368be82f377eb4178ece35d9491dac6672bd1288/lib/documents.js#L81-L96
train
marklogic/node-client-api
lib/marklogic.js
ExtlibsWrapper
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
function ExtlibsWrapper(extlibs, name, dir) { if (!(this instanceof ExtlibsWrapper)) { return new ExtlibsWrapper(extlibs, name, dir); } this.extlibs = extlibs; this.name = name; this.dir = dir; }
[ "function", "ExtlibsWrapper", "(", "extlibs", ",", "name", ",", "dir", ")", "{", "if", "(", "!", "(", "this", "instanceof", "ExtlibsWrapper", ")", ")", "{", "return", "new", "ExtlibsWrapper", "(", "extlibs", ",", "name", ",", "dir", ")", ";", "}", "thi...
Provides functions that maintain query snippet extensions on the REST server. The client must have been created for a user with the rest-admin role. @namespace config.query.snippet Reads a query snippet library installed on the server. @method config.query.snippet#read @since 1.0 @param {string} moduleName - the fil...
[ "Provides", "functions", "that", "maintain", "query", "snippet", "extensions", "on", "the", "REST", "server", ".", "The", "client", "must", "have", "been", "created", "for", "a", "user", "with", "the", "rest", "-", "admin", "role", "." ]
368be82f377eb4178ece35d9491dac6672bd1288
https://github.com/marklogic/node-client-api/blob/368be82f377eb4178ece35d9491dac6672bd1288/lib/marklogic.js#L166-L173
train
pvdlg/ncat
src/index.js
concatBanner
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
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...
[ "function", "concatBanner", "(", ")", "{", "if", "(", "typeof", "argv", ".", "banner", "!==", "'undefined'", ")", "{", "if", "(", "argv", ".", "banner", ")", "{", "return", "Promise", ".", "resolve", "(", ")", ".", "then", "(", "(", ")", "=>", "{",...
Concatenate a default or custom banner. @return {Promise<Any>} Promise that resolve once the banner has been generated and concatenated.
[ "Concatenate", "a", "default", "or", "custom", "banner", "." ]
7a7bdacf4cd6a97482964814ecb8dddc6c21b0c4
https://github.com/pvdlg/ncat/blob/7a7bdacf4cd6a97482964814ecb8dddc6c21b0c4/src/index.js#L127-L141
train
pvdlg/ncat
src/index.js
concatFooter
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
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(); }
[ "function", "concatFooter", "(", ")", "{", "if", "(", "argv", ".", "footer", ")", "{", "return", "Promise", ".", "resolve", "(", ")", ".", "then", "(", "(", ")", "=>", "{", "concat", ".", "add", "(", "null", ",", "require", "(", "path", ".", "joi...
Concatenate a custom banner. @return {Promise<Any>} Promise that resolve once the footer has been generated and concatenated.
[ "Concatenate", "a", "custom", "banner", "." ]
7a7bdacf4cd6a97482964814ecb8dddc6c21b0c4
https://github.com/pvdlg/ncat/blob/7a7bdacf4cd6a97482964814ecb8dddc6c21b0c4/src/index.js#L148-L156
train
pvdlg/ncat
src/index.js
concatFiles
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
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)) )...
[ "function", "concatFiles", "(", ")", "{", "return", "Promise", ".", "all", "(", "argv", ".", "_", ".", "map", "(", "handleGlob", ")", ")", ".", "then", "(", "globs", "=>", "{", "const", "files", "=", "globs", ".", "reduce", "(", "(", "acc", ",", ...
Concatenate the files in order. Exit process with error if there is less than two files, banner or footer to concatenate. @return {Promise<Any>} Promise that resolve once the files have been read/created and concatenated.
[ "Concatenate", "the", "files", "in", "order", ".", "Exit", "process", "with", "error", "if", "there", "is", "less", "than", "two", "files", "banner", "or", "footer", "to", "concatenate", "." ]
7a7bdacf4cd6a97482964814ecb8dddc6c21b0c4
https://github.com/pvdlg/ncat/blob/7a7bdacf4cd6a97482964814ecb8dddc6c21b0c4/src/index.js#L164-L180
train
pvdlg/ncat
src/index.js
handleGlob
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
function handleGlob(glob) { if (glob === '-') { return stdinCache.then(stdin => [{content: stdin}]); } return globby(glob.split(' '), {nodir: true}).then(files => Promise.all(files.map(handleFile))); }
[ "function", "handleGlob", "(", "glob", ")", "{", "if", "(", "glob", "===", "'-'", ")", "{", "return", "stdinCache", ".", "then", "(", "stdin", "=>", "[", "{", "content", ":", "stdin", "}", "]", ")", ";", "}", "return", "globby", "(", "glob", ".", ...
FileToConcat describe the filename, content and sourcemap to concatenate. @typedef {Object} FileToConcat @property {String} file @property {String} content @property {Object} sourcemap Retrieve files matched by the gloc and call {@link handleFile} for each one found. If the glob is '-' return one FileToConcat with s...
[ "FileToConcat", "describe", "the", "filename", "content", "and", "sourcemap", "to", "concatenate", "." ]
7a7bdacf4cd6a97482964814ecb8dddc6c21b0c4
https://github.com/pvdlg/ncat/blob/7a7bdacf4cd6a97482964814ecb8dddc6c21b0c4/src/index.js#L198-L203
train
pvdlg/ncat
src/index.js
getSourceMappingURL
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
function getSourceMappingURL() { if (path.extname(argv.output) === '.css') { return `\n/*# sourceMappingURL=${path.basename(argv.output)}.map */`; } return `\n//# sourceMappingURL=${path.basename(argv.output)}.map`; }
[ "function", "getSourceMappingURL", "(", ")", "{", "if", "(", "path", ".", "extname", "(", "argv", ".", "output", ")", "===", "'.css'", ")", "{", "return", "`", "\\n", "${", "path", ".", "basename", "(", "argv", ".", "output", ")", "}", "`", ";", "}...
Return a source mapping URL comment based on the output file extension. @return {String} the sourceMappingURL comment.
[ "Return", "a", "source", "mapping", "URL", "comment", "based", "on", "the", "output", "file", "extension", "." ]
7a7bdacf4cd6a97482964814ecb8dddc6c21b0c4
https://github.com/pvdlg/ncat/blob/7a7bdacf4cd6a97482964814ecb8dddc6c21b0c4/src/index.js#L310-L315
train
strongloop/strongloop
lib/commands/env.js
resolvePaths
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
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; }
[ "function", "resolvePaths", "(", "paths", ")", "{", "var", "exec", "=", "{", "}", ";", "var", "originalWd", "=", "process", ".", "cwd", "(", ")", ";", "for", "(", "var", "name", "in", "paths", ")", "{", "process", ".", "chdir", "(", "originalWd", "...
resolve symlinks of all paths to eventual targets
[ "resolve", "symlinks", "of", "all", "paths", "to", "eventual", "targets" ]
aa519ec2fd151f3816d224dfd8dac27958dd14ca
https://github.com/strongloop/strongloop/blob/aa519ec2fd151f3816d224dfd8dac27958dd14ca/lib/commands/env.js#L109-L119
train
strongloop/strongloop
lib/commands/env.js
resolveLink
function resolveLink(path) { var links = readLinkRecursive(path); var resolved = p.resolve.apply(null, links); trace('links', links, 'resolves to', resolved); return resolved; }
javascript
function resolveLink(path) { var links = readLinkRecursive(path); var resolved = p.resolve.apply(null, links); trace('links', links, 'resolves to', resolved); return resolved; }
[ "function", "resolveLink", "(", "path", ")", "{", "var", "links", "=", "readLinkRecursive", "(", "path", ")", ";", "var", "resolved", "=", "p", ".", "resolve", ".", "apply", "(", "null", ",", "links", ")", ";", "trace", "(", "'links'", ",", "links", ...
resolve link to absolute path
[ "resolve", "link", "to", "absolute", "path" ]
aa519ec2fd151f3816d224dfd8dac27958dd14ca
https://github.com/strongloop/strongloop/blob/aa519ec2fd151f3816d224dfd8dac27958dd14ca/lib/commands/env.js#L122-L129
train
strongloop/strongloop
lib/commands/env.js
readLinkRecursive
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
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); }
[ "function", "readLinkRecursive", "(", "path", ",", "seen", ")", "{", "seen", "=", "seen", "||", "[", "]", ";", "seen", ".", "push", "(", "p", ".", "dirname", "(", "path", ")", ")", ";", "var", "next", "=", "readLink", "(", "path", ")", ";", "trac...
read link, recursively, return array of links seen up to final path
[ "read", "link", "recursively", "return", "array", "of", "links", "seen", "up", "to", "final", "path" ]
aa519ec2fd151f3816d224dfd8dac27958dd14ca
https://github.com/strongloop/strongloop/blob/aa519ec2fd151f3816d224dfd8dac27958dd14ca/lib/commands/env.js#L132-L146
train
nodemailer/nodemailer-smtp-transport
lib/smtp-transport.js
SMTPTransport
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
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...
[ "function", "SMTPTransport", "(", "options", ")", "{", "EventEmitter", ".", "call", "(", "this", ")", ";", "options", "=", "options", "||", "{", "}", ";", "if", "(", "typeof", "options", "===", "'string'", ")", "{", "options", "=", "{", "url", ":", "...
Creates a SMTP transport object for Nodemailer @constructor @param {Object} options Connection options
[ "Creates", "a", "SMTP", "transport", "object", "for", "Nodemailer" ]
d854aa0e4e7b22cd921ae3e4e04ab7b6e02761e6
https://github.com/nodemailer/nodemailer-smtp-transport/blob/d854aa0e4e7b22cd921ae3e4e04ab7b6e02761e6/lib/smtp-transport.js#L22-L58
train
nodemailer/nodemailer-smtp-transport
lib/smtp-transport.js
assign
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
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...
[ "function", "assign", "(", "/* target, ... sources */", ")", "{", "var", "args", "=", "Array", ".", "prototype", ".", "slice", ".", "call", "(", "arguments", ")", ";", "var", "target", "=", "args", ".", "shift", "(", ")", "||", "{", "}", ";", "args", ...
Copies properties from source objects to target objects
[ "Copies", "properties", "from", "source", "objects", "to", "target", "objects" ]
d854aa0e4e7b22cd921ae3e4e04ab7b6e02761e6
https://github.com/nodemailer/nodemailer-smtp-transport/blob/d854aa0e4e7b22cd921ae3e4e04ab7b6e02761e6/lib/smtp-transport.js#L259-L281
train
fmarcia/UglifyCSS
uglifycss-lib.js
collectComments
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
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...
[ "function", "collectComments", "(", "content", ",", "comments", ")", "{", "const", "table", "=", "[", "]", "let", "from", "=", "0", "let", "end", "while", "(", "true", ")", "{", "let", "start", "=", "content", ".", "indexOf", "(", "'/*'", ",", "from"...
collectComments collects all comment blocks and return new content with comment placeholders @param {string} content - CSS content @param {string[]} comments - Global array of extracted comments @return {string} Processed CSS
[ "collectComments", "collects", "all", "comment", "blocks", "and", "return", "new", "content", "with", "comment", "placeholders" ]
3a4312ef9a321643ab27cf7438b85c92498af19b
https://github.com/fmarcia/UglifyCSS/blob/3a4312ef9a321643ab27cf7438b85c92498af19b/uglifycss-lib.js#L425-L460
train
fmarcia/UglifyCSS
uglifycss-lib.js
processFiles
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
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...
[ "function", "processFiles", "(", "filenames", "=", "[", "]", ",", "options", "=", "defaultOptions", ")", "{", "if", "(", "options", ".", "convertUrls", ")", "{", "options", ".", "target", "=", "resolve", "(", "process", ".", "cwd", "(", ")", ",", "opti...
processFiles uglifies a set of CSS files @param {string[]} filenames - List of filenames @param {options} options - UglifyCSS options @return {string} Uglified result
[ "processFiles", "uglifies", "a", "set", "of", "CSS", "files" ]
3a4312ef9a321643ab27cf7438b85c92498af19b
https://github.com/fmarcia/UglifyCSS/blob/3a4312ef9a321643ab27cf7438b85c92498af19b/uglifycss-lib.js#L820-L851
train
blackbaud/skyux2
config/karma/ci-ie.karma.conf.js
getSpecsRegex
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
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...
[ "function", "getSpecsRegex", "(", ")", "{", "const", "argv", "=", "minimist", "(", "process", ".", "argv", ".", "slice", "(", "2", ")", ")", ";", "/**\n * The command line argument `--ieBatch` is a string representing\n * the current batch to run, of total batches.\n * ...
Run only a few modules' specs
[ "Run", "only", "a", "few", "modules", "specs" ]
f4d70d718f718e6136e2262103e9b1eb7a295c18
https://github.com/blackbaud/skyux2/blob/f4d70d718f718e6136e2262103e9b1eb7a295c18/config/karma/ci-ie.karma.conf.js#L13-L51
train
wswebcreation/protractor-multiple-cucumber-html-reporter-plugin
index.js
setup
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
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...
[ "function", "setup", "(", ")", "{", "return", "browser", ".", "getProcessedConfig", "(", ")", ".", "then", "(", "(", "configuration", ")", "=>", "{", "let", "cucumberFormat", "=", "configuration", ".", "cucumberOpts", ".", "format", ";", "IS_JSON_FORMAT", "=...
Configures the plugin with the correct data @see docs/plugins.md @returns {Promise} A promise which resolves into a configured setup @public
[ "Configures", "the", "plugin", "with", "the", "correct", "data" ]
d01dc9f9660d7bec1ef47c007b429cebe58e3ff4
https://github.com/wswebcreation/protractor-multiple-cucumber-html-reporter-plugin/blob/d01dc9f9660d7bec1ef47c007b429cebe58e3ff4/index.js#L49-L127
train
wswebcreation/protractor-multiple-cucumber-html-reporter-plugin
index.js
onPrepare
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
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() ...
[ "function", "onPrepare", "(", ")", "{", "if", "(", "IS_JSON_FORMAT", ")", "{", "return", "browser", ".", "getCapabilities", "(", ")", ".", "then", "(", "(", "capabilities", ")", "=>", "{", "PID_INSTANCE_DATA", ".", "metadata", ".", "browser", ".", "name", ...
Enrich the instance data @see docs/plugins.md @returns {Promise} A promise which resolves in a enriched instance data object @public
[ "Enrich", "the", "instance", "data" ]
d01dc9f9660d7bec1ef47c007b429cebe58e3ff4
https://github.com/wswebcreation/protractor-multiple-cucumber-html-reporter-plugin/blob/d01dc9f9660d7bec1ef47c007b429cebe58e3ff4/index.js#L136-L147
train
olegskl/gulp-stylelint
src/index.js
passLintResultsThroughReporters
function passLintResultsThroughReporters(lintResults) { const warnings = lintResults .reduce((accumulated, res) => accumulated.concat(res.results), []); return Promise .all(reporters.map(reporter => reporter(warnings))) .then(() => lintResults); }
javascript
function passLintResultsThroughReporters(lintResults) { const warnings = lintResults .reduce((accumulated, res) => accumulated.concat(res.results), []); return Promise .all(reporters.map(reporter => reporter(warnings))) .then(() => lintResults); }
[ "function", "passLintResultsThroughReporters", "(", "lintResults", ")", "{", "const", "warnings", "=", "lintResults", ".", "reduce", "(", "(", "accumulated", ",", "res", ")", "=>", "accumulated", ".", "concat", "(", "res", ".", "results", ")", ",", "[", "]",...
Provides Stylelint result to reporters. @param {[Object]} lintResults - Stylelint results. @return {Promise} Resolved with original lint results.
[ "Provides", "Stylelint", "result", "to", "reporters", "." ]
bc79cfc11c87c95a1d1f0fd727e2e2c33a8f3fba
https://github.com/olegskl/gulp-stylelint/blob/bc79cfc11c87c95a1d1f0fd727e2e2c33a8f3fba/src/index.js#L126-L133
train
ajhsu/node-wget-promise
src/lib/wget.js
download
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
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...
[ "function", "download", "(", "source", ",", "{", "verbose", ",", "output", ",", "onStart", ",", "onProgress", "}", "=", "{", "}", ")", "{", "return", "new", "Promise", "(", "function", "(", "y", ",", "n", ")", "{", "if", "(", "typeof", "output", "=...
Downloads a file using http get and request @param {string} source - The http URL to download from @param {object} options - Options object @returns {Promise}
[ "Downloads", "a", "file", "using", "http", "get", "and", "request" ]
6b6f2c31b4adca89c8e4a0a743ea2fb2ba797c4c
https://github.com/ajhsu/node-wget-promise/blob/6b6f2c31b4adca89c8e4a0a743ea2fb2ba797c4c/src/lib/wget.js#L13-L122
train
jaredhanson/passport-oauth2-client-password
lib/strategy.js
Strategy
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
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...
[ "function", "Strategy", "(", "options", ",", "verify", ")", "{", "if", "(", "typeof", "options", "==", "'function'", ")", "{", "verify", "=", "options", ";", "options", "=", "{", "}", ";", "}", "if", "(", "!", "verify", ")", "throw", "new", "Error", ...
`ClientPasswordStrategy` constructor. @api protected
[ "ClientPasswordStrategy", "constructor", "." ]
0cf29e3f2dfd945dd710e2d1d24f298842204742
https://github.com/jaredhanson/passport-oauth2-client-password/blob/0cf29e3f2dfd945dd710e2d1d24f298842204742/lib/strategy.js#L13-L24
train
poppinss/youch
bin/compile.js
bundleJsFiles
function bundleJsFiles () { return concat(jsFiles) .then((output) => { const uglified = UglifyJS.minify(output) if (uglified.error) { throw new Error(uglified.error) } return uglified.code }) }
javascript
function bundleJsFiles () { return concat(jsFiles) .then((output) => { const uglified = UglifyJS.minify(output) if (uglified.error) { throw new Error(uglified.error) } return uglified.code }) }
[ "function", "bundleJsFiles", "(", ")", "{", "return", "concat", "(", "jsFiles", ")", ".", "then", "(", "(", "output", ")", "=>", "{", "const", "uglified", "=", "UglifyJS", ".", "minify", "(", "output", ")", "if", "(", "uglified", ".", "error", ")", "...
Bundling js files by concatenating them and then uglifying them. @method bundleJsFiles @return {Promise<String>}
[ "Bundling", "js", "files", "by", "concatenating", "them", "and", "then", "uglifying", "them", "." ]
f2db665c47b185c9ae0434af074644130a0f87aa
https://github.com/poppinss/youch/blob/f2db665c47b185c9ae0434af074644130a0f87aa/bin/compile.js#L59-L68
train
webgme/webgme-engine
src/client/gmeNodeSetter.js
addMember
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
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); ...
[ "function", "addMember", "(", "path", ",", "memberPath", ",", "setId", ",", "msg", ")", "{", "// FIXME: This will have to break due to switched arguments", "var", "node", "=", "_getNode", "(", "path", ")", ",", "memberNode", "=", "_getNode", "(", "memberPath", ")"...
Mixed argument methods - START
[ "Mixed", "argument", "methods", "-", "START" ]
f9af95d7bedd83cdfde9cca9c8c2d560c0222065
https://github.com/webgme/webgme-engine/blob/f9af95d7bedd83cdfde9cca9c8c2d560c0222065/src/client/gmeNodeSetter.js#L400-L409
train