id
int32 0
58k
| 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
sequence | docstring
stringlengths 4
11.8k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 86
226
|
---|---|---|---|---|---|---|---|---|---|---|---|
52,300 | copress/copress-component-oauth2 | lib/oauth2.js | function (req, res, next) {
if (options.decisionPage) {
var urlObj = {
pathname: options.decisionPage,
query: {
transactionId: req.oauth2.transactionID,
userId: req.oauth2.user.id,
clientId: req.oauth2.client.id,
scope: req.oauth2.req.scope,
redirectURI: req.oauth2.redirectURI
}
};
return res.redirect(url.format(urlObj));
}
res.render(options.decisionView || 'dialog',
{
transactionId: req.oauth2.transactionID,
user: req.user, client: req.oauth2.client,
scopes: req.oauth2.req.scope,
redirectURI: req.oauth2.redirectURI
});
} | javascript | function (req, res, next) {
if (options.decisionPage) {
var urlObj = {
pathname: options.decisionPage,
query: {
transactionId: req.oauth2.transactionID,
userId: req.oauth2.user.id,
clientId: req.oauth2.client.id,
scope: req.oauth2.req.scope,
redirectURI: req.oauth2.redirectURI
}
};
return res.redirect(url.format(urlObj));
}
res.render(options.decisionView || 'dialog',
{
transactionId: req.oauth2.transactionID,
user: req.user, client: req.oauth2.client,
scopes: req.oauth2.req.scope,
redirectURI: req.oauth2.redirectURI
});
} | [
"function",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"if",
"(",
"options",
".",
"decisionPage",
")",
"{",
"var",
"urlObj",
"=",
"{",
"pathname",
":",
"options",
".",
"decisionPage",
",",
"query",
":",
"{",
"transactionId",
":",
"req",
".",
"oauth2",
".",
"transactionID",
",",
"userId",
":",
"req",
".",
"oauth2",
".",
"user",
".",
"id",
",",
"clientId",
":",
"req",
".",
"oauth2",
".",
"client",
".",
"id",
",",
"scope",
":",
"req",
".",
"oauth2",
".",
"req",
".",
"scope",
",",
"redirectURI",
":",
"req",
".",
"oauth2",
".",
"redirectURI",
"}",
"}",
";",
"return",
"res",
".",
"redirect",
"(",
"url",
".",
"format",
"(",
"urlObj",
")",
")",
";",
"}",
"res",
".",
"render",
"(",
"options",
".",
"decisionView",
"||",
"'dialog'",
",",
"{",
"transactionId",
":",
"req",
".",
"oauth2",
".",
"transactionID",
",",
"user",
":",
"req",
".",
"user",
",",
"client",
":",
"req",
".",
"oauth2",
".",
"client",
",",
"scopes",
":",
"req",
".",
"oauth2",
".",
"req",
".",
"scope",
",",
"redirectURI",
":",
"req",
".",
"oauth2",
".",
"redirectURI",
"}",
")",
";",
"}"
] | Now try to render the dialog to approve client app's request for permissions | [
"Now",
"try",
"to",
"render",
"the",
"dialog",
"to",
"approve",
"client",
"app",
"s",
"request",
"for",
"permissions"
] | 4819f379a0d42753bfd51e237c5c3aaddee37544 | https://github.com/copress/copress-component-oauth2/blob/4819f379a0d42753bfd51e237c5c3aaddee37544/lib/oauth2.js#L628-L649 |
|
52,301 | copress/copress-component-oauth2 | lib/oauth2.js | clientLogin | function clientLogin(clientId, clientSecret, done) {
debug('clientLogin: %s', clientId);
clientId = parseInt(clientId);
if (!clientId && clientId !== 0) {
return done(null, false);
}
models.Clients.findByClientId(clientId, function (err, client) {
if (err) {
return done(err);
}
if (!client) {
return done(null, false);
}
var secret = client.clientSecret || client.restApiKey;
if (secret !== clientSecret) {
return done(null, false);
}
return done(null, client);
});
} | javascript | function clientLogin(clientId, clientSecret, done) {
debug('clientLogin: %s', clientId);
clientId = parseInt(clientId);
if (!clientId && clientId !== 0) {
return done(null, false);
}
models.Clients.findByClientId(clientId, function (err, client) {
if (err) {
return done(err);
}
if (!client) {
return done(null, false);
}
var secret = client.clientSecret || client.restApiKey;
if (secret !== clientSecret) {
return done(null, false);
}
return done(null, client);
});
} | [
"function",
"clientLogin",
"(",
"clientId",
",",
"clientSecret",
",",
"done",
")",
"{",
"debug",
"(",
"'clientLogin: %s'",
",",
"clientId",
")",
";",
"clientId",
"=",
"parseInt",
"(",
"clientId",
")",
";",
"if",
"(",
"!",
"clientId",
"&&",
"clientId",
"!==",
"0",
")",
"{",
"return",
"done",
"(",
"null",
",",
"false",
")",
";",
"}",
"models",
".",
"Clients",
".",
"findByClientId",
"(",
"clientId",
",",
"function",
"(",
"err",
",",
"client",
")",
"{",
"if",
"(",
"err",
")",
"{",
"return",
"done",
"(",
"err",
")",
";",
"}",
"if",
"(",
"!",
"client",
")",
"{",
"return",
"done",
"(",
"null",
",",
"false",
")",
";",
"}",
"var",
"secret",
"=",
"client",
".",
"clientSecret",
"||",
"client",
".",
"restApiKey",
";",
"if",
"(",
"secret",
"!==",
"clientSecret",
")",
"{",
"return",
"done",
"(",
"null",
",",
"false",
")",
";",
"}",
"return",
"done",
"(",
"null",
",",
"client",
")",
";",
"}",
")",
";",
"}"
] | BasicStrategy & ClientPasswordStrategy
These strategies are used to authenticate registered OAuth clients. They are
employed to protect the `token` endpoint, which consumers use to obtain
access tokens. The OAuth 2.0 specification suggests that clients use the
HTTP Basic scheme to authenticate. Use of the client password strategy
allows clients to send the same credentials in the request body (as opposed
to the `Authorization` header). While this approach is not recommended by
the specification, in practice it is quite common. | [
"BasicStrategy",
"&",
"ClientPasswordStrategy"
] | 4819f379a0d42753bfd51e237c5c3aaddee37544 | https://github.com/copress/copress-component-oauth2/blob/4819f379a0d42753bfd51e237c5c3aaddee37544/lib/oauth2.js#L708-L729 |
52,302 | blueskyfish/bluesky-logger | factory.js | function (namespaces) {
_.forEach(namespaces, function (level, namespace) {
cache.add(namespace, level);
});
return this;
} | javascript | function (namespaces) {
_.forEach(namespaces, function (level, namespace) {
cache.add(namespace, level);
});
return this;
} | [
"function",
"(",
"namespaces",
")",
"{",
"_",
".",
"forEach",
"(",
"namespaces",
",",
"function",
"(",
"level",
",",
"namespace",
")",
"{",
"cache",
".",
"add",
"(",
"namespace",
",",
"level",
")",
";",
"}",
")",
";",
"return",
"this",
";",
"}"
] | set the namespaces configuration.
Config object
```
{
'root': 'all',
'namespace1.namespace2': 'info',
}
```
**root** namespace is for all unknown namespaces.
@param {object} namespaces the map with the namespace and its log level
@return {self} | [
"set",
"the",
"namespaces",
"configuration",
"."
] | 87f7324e19222595fabfe9a8c9c5031f9546e16a | https://github.com/blueskyfish/bluesky-logger/blob/87f7324e19222595fabfe9a8c9c5031f9546e16a/factory.js#L33-L38 |
|
52,303 | totorojs/totoro-logger | lib/console.js | function(level, title, format, filters, needstack, args) {
var msg = utils.format.apply(this, args)
var data = {
timestamp : dateFormat(new Date(), _config.dateformat),
message : msg,
title : title,
level : level,
args : args
}
data.method = data.path = data.line = data.pos = data.file = ''
if (needstack) {
// get call stack, and analyze it
// get all file,method and line number
data.stack = (new Error()).stack.split('\n').slice(3)
// Stack trace format :
// http://code.google.com/p/v8/wiki/JavaScriptStackTraceApi
var s = data.stack[0], sp = /at\s+(.*)\s+\((.*):(\d*):(\d*)\)/gi
.exec(s) || /at\s+()(.*):(\d*):(\d*)/gi.exec(s)
if (sp && sp.length === 5) {
data.method = sp[1]
data.path = sp[2]
data.line = sp[3]
data.pos = sp[4]
var paths = data.path.split('/')
data.file = paths[paths.length - 1]
}
}
_config.preprocess(data)
// call micro-template to ouput
data.output = tinytim.tim(format, data)
// process every filter method
var len = filters.length
for ( var i = 0; i < len; i += 1) {
data.output = filters[i](data.output, data)
if (!data.output)
return data
// cancel next process if return a false(include null, undefined)
}
// trans the final result
return _config.transport(data)
} | javascript | function(level, title, format, filters, needstack, args) {
var msg = utils.format.apply(this, args)
var data = {
timestamp : dateFormat(new Date(), _config.dateformat),
message : msg,
title : title,
level : level,
args : args
}
data.method = data.path = data.line = data.pos = data.file = ''
if (needstack) {
// get call stack, and analyze it
// get all file,method and line number
data.stack = (new Error()).stack.split('\n').slice(3)
// Stack trace format :
// http://code.google.com/p/v8/wiki/JavaScriptStackTraceApi
var s = data.stack[0], sp = /at\s+(.*)\s+\((.*):(\d*):(\d*)\)/gi
.exec(s) || /at\s+()(.*):(\d*):(\d*)/gi.exec(s)
if (sp && sp.length === 5) {
data.method = sp[1]
data.path = sp[2]
data.line = sp[3]
data.pos = sp[4]
var paths = data.path.split('/')
data.file = paths[paths.length - 1]
}
}
_config.preprocess(data)
// call micro-template to ouput
data.output = tinytim.tim(format, data)
// process every filter method
var len = filters.length
for ( var i = 0; i < len; i += 1) {
data.output = filters[i](data.output, data)
if (!data.output)
return data
// cancel next process if return a false(include null, undefined)
}
// trans the final result
return _config.transport(data)
} | [
"function",
"(",
"level",
",",
"title",
",",
"format",
",",
"filters",
",",
"needstack",
",",
"args",
")",
"{",
"var",
"msg",
"=",
"utils",
".",
"format",
".",
"apply",
"(",
"this",
",",
"args",
")",
"var",
"data",
"=",
"{",
"timestamp",
":",
"dateFormat",
"(",
"new",
"Date",
"(",
")",
",",
"_config",
".",
"dateformat",
")",
",",
"message",
":",
"msg",
",",
"title",
":",
"title",
",",
"level",
":",
"level",
",",
"args",
":",
"args",
"}",
"data",
".",
"method",
"=",
"data",
".",
"path",
"=",
"data",
".",
"line",
"=",
"data",
".",
"pos",
"=",
"data",
".",
"file",
"=",
"''",
"if",
"(",
"needstack",
")",
"{",
"// get call stack, and analyze it",
"// get all file,method and line number",
"data",
".",
"stack",
"=",
"(",
"new",
"Error",
"(",
")",
")",
".",
"stack",
".",
"split",
"(",
"'\\n'",
")",
".",
"slice",
"(",
"3",
")",
"// Stack trace format :",
"// http://code.google.com/p/v8/wiki/JavaScriptStackTraceApi",
"var",
"s",
"=",
"data",
".",
"stack",
"[",
"0",
"]",
",",
"sp",
"=",
"/",
"at\\s+(.*)\\s+\\((.*):(\\d*):(\\d*)\\)",
"/",
"gi",
".",
"exec",
"(",
"s",
")",
"||",
"/",
"at\\s+()(.*):(\\d*):(\\d*)",
"/",
"gi",
".",
"exec",
"(",
"s",
")",
"if",
"(",
"sp",
"&&",
"sp",
".",
"length",
"===",
"5",
")",
"{",
"data",
".",
"method",
"=",
"sp",
"[",
"1",
"]",
"data",
".",
"path",
"=",
"sp",
"[",
"2",
"]",
"data",
".",
"line",
"=",
"sp",
"[",
"3",
"]",
"data",
".",
"pos",
"=",
"sp",
"[",
"4",
"]",
"var",
"paths",
"=",
"data",
".",
"path",
".",
"split",
"(",
"'/'",
")",
"data",
".",
"file",
"=",
"paths",
"[",
"paths",
".",
"length",
"-",
"1",
"]",
"}",
"}",
"_config",
".",
"preprocess",
"(",
"data",
")",
"// call micro-template to ouput",
"data",
".",
"output",
"=",
"tinytim",
".",
"tim",
"(",
"format",
",",
"data",
")",
"// process every filter method",
"var",
"len",
"=",
"filters",
".",
"length",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"len",
";",
"i",
"+=",
"1",
")",
"{",
"data",
".",
"output",
"=",
"filters",
"[",
"i",
"]",
"(",
"data",
".",
"output",
",",
"data",
")",
"if",
"(",
"!",
"data",
".",
"output",
")",
"return",
"data",
"// cancel next process if return a false(include null, undefined)",
"}",
"// trans the final result",
"return",
"_config",
".",
"transport",
"(",
"data",
")",
"}"
] | main log method | [
"main",
"log",
"method"
] | 1865b681e40bcd4a956226a016bcca4c0339cd6e | https://github.com/totorojs/totoro-logger/blob/1865b681e40bcd4a956226a016bcca4c0339cd6e/lib/console.js#L26-L74 |
|
52,304 | dutchenkoOleg/gulp-not-supported-file | index.js | withFilePath | function withFilePath (file, msg) {
if (file && file.path) {
msg += `\n ${file.path}`;
}
return msg;
} | javascript | function withFilePath (file, msg) {
if (file && file.path) {
msg += `\n ${file.path}`;
}
return msg;
} | [
"function",
"withFilePath",
"(",
"file",
",",
"msg",
")",
"{",
"if",
"(",
"file",
"&&",
"file",
".",
"path",
")",
"{",
"msg",
"+=",
"`",
"\\n",
"${",
"file",
".",
"path",
"}",
"`",
";",
"}",
"return",
"msg",
";",
"}"
] | Get msg with file path if exist
@param {File} file
@param {string} msg
@return {string}
@private | [
"Get",
"msg",
"with",
"file",
"path",
"if",
"exist"
] | 6a49c9df53bb3131828524eed71d30b73df36035 | https://github.com/dutchenkoOleg/gulp-not-supported-file/blob/6a49c9df53bb3131828524eed71d30b73df36035/index.js#L35-L40 |
52,305 | feedhenry/fh-mbaas-middleware | lib/middleware/forms.js | _createRequestParams | function _createRequestParams(params){
var resourcePath = params.resourcePath;
resourcePath = resourcePath.replace(":domain", params.domain)
.replace(":projectid", params.projectid)
.replace(":guid", params.appid);
log.logger.debug("Creating Request Params For Core ", params);
var coreHost = params.appMbaasModel.coreHost;
if(coreHost.indexOf("http") !== 0){
// We do not know protocol so using https as default one.
coreHost = "https://" + coreHost;
}
return {
url: url.format(coreHost + resourcePath),
method: params.method,
headers: {
'x-fh-auth-app' : params.apiKey
},
json: true,
body: params.data || {}
};
} | javascript | function _createRequestParams(params){
var resourcePath = params.resourcePath;
resourcePath = resourcePath.replace(":domain", params.domain)
.replace(":projectid", params.projectid)
.replace(":guid", params.appid);
log.logger.debug("Creating Request Params For Core ", params);
var coreHost = params.appMbaasModel.coreHost;
if(coreHost.indexOf("http") !== 0){
// We do not know protocol so using https as default one.
coreHost = "https://" + coreHost;
}
return {
url: url.format(coreHost + resourcePath),
method: params.method,
headers: {
'x-fh-auth-app' : params.apiKey
},
json: true,
body: params.data || {}
};
} | [
"function",
"_createRequestParams",
"(",
"params",
")",
"{",
"var",
"resourcePath",
"=",
"params",
".",
"resourcePath",
";",
"resourcePath",
"=",
"resourcePath",
".",
"replace",
"(",
"\":domain\"",
",",
"params",
".",
"domain",
")",
".",
"replace",
"(",
"\":projectid\"",
",",
"params",
".",
"projectid",
")",
".",
"replace",
"(",
"\":guid\"",
",",
"params",
".",
"appid",
")",
";",
"log",
".",
"logger",
".",
"debug",
"(",
"\"Creating Request Params For Core \"",
",",
"params",
")",
";",
"var",
"coreHost",
"=",
"params",
".",
"appMbaasModel",
".",
"coreHost",
";",
"if",
"(",
"coreHost",
".",
"indexOf",
"(",
"\"http\"",
")",
"!==",
"0",
")",
"{",
"// We do not know protocol so using https as default one.",
"coreHost",
"=",
"\"https://\"",
"+",
"coreHost",
";",
"}",
"return",
"{",
"url",
":",
"url",
".",
"format",
"(",
"coreHost",
"+",
"resourcePath",
")",
",",
"method",
":",
"params",
".",
"method",
",",
"headers",
":",
"{",
"'x-fh-auth-app'",
":",
"params",
".",
"apiKey",
"}",
",",
"json",
":",
"true",
",",
"body",
":",
"params",
".",
"data",
"||",
"{",
"}",
"}",
";",
"}"
] | Creating A Request To Supercore. Supercore will authenticate the app request. | [
"Creating",
"A",
"Request",
"To",
"Supercore",
".",
"Supercore",
"will",
"authenticate",
"the",
"app",
"request",
"."
] | f906e98efbb4b0963bf5137b34b5e0589ba24e69 | https://github.com/feedhenry/fh-mbaas-middleware/blob/f906e98efbb4b0963bf5137b34b5e0589ba24e69/lib/middleware/forms.js#L7-L29 |
52,306 | feedhenry/fh-mbaas-middleware | lib/middleware/forms.js | _createResponseHandler | function _createResponseHandler(req, next, skipDataResult){
return function(err, httpResponse, responseBody){
log.logger.debug("Performing Core Action ", req.url, err, httpResponse.statusCode, responseBody);
if(err || (httpResponse.statusCode !== 200 && httpResponse.statusCode !== 204)){
return next(err || responseBody);
}
//Not interested in the response from the core.
if(!skipDataResult){
req.appformsResultPayload = {
data: responseBody || []
};
}
next();
};
} | javascript | function _createResponseHandler(req, next, skipDataResult){
return function(err, httpResponse, responseBody){
log.logger.debug("Performing Core Action ", req.url, err, httpResponse.statusCode, responseBody);
if(err || (httpResponse.statusCode !== 200 && httpResponse.statusCode !== 204)){
return next(err || responseBody);
}
//Not interested in the response from the core.
if(!skipDataResult){
req.appformsResultPayload = {
data: responseBody || []
};
}
next();
};
} | [
"function",
"_createResponseHandler",
"(",
"req",
",",
"next",
",",
"skipDataResult",
")",
"{",
"return",
"function",
"(",
"err",
",",
"httpResponse",
",",
"responseBody",
")",
"{",
"log",
".",
"logger",
".",
"debug",
"(",
"\"Performing Core Action \"",
",",
"req",
".",
"url",
",",
"err",
",",
"httpResponse",
".",
"statusCode",
",",
"responseBody",
")",
";",
"if",
"(",
"err",
"||",
"(",
"httpResponse",
".",
"statusCode",
"!==",
"200",
"&&",
"httpResponse",
".",
"statusCode",
"!==",
"204",
")",
")",
"{",
"return",
"next",
"(",
"err",
"||",
"responseBody",
")",
";",
"}",
"//Not interested in the response from the core.",
"if",
"(",
"!",
"skipDataResult",
")",
"{",
"req",
".",
"appformsResultPayload",
"=",
"{",
"data",
":",
"responseBody",
"||",
"[",
"]",
"}",
";",
"}",
"next",
"(",
")",
";",
"}",
";",
"}"
] | Utility function for creating response handlers
@param req
@param next
@returns {Function} | [
"Utility",
"function",
"for",
"creating",
"response",
"handlers"
] | f906e98efbb4b0963bf5137b34b5e0589ba24e69 | https://github.com/feedhenry/fh-mbaas-middleware/blob/f906e98efbb4b0963bf5137b34b5e0589ba24e69/lib/middleware/forms.js#L38-L55 |
52,307 | feedhenry/fh-mbaas-middleware | lib/middleware/forms.js | checkFormAssociation | function checkFormAssociation(req, res, next){
var requestedFormId = req.params.id;
req.appformsResultPayload = req.appformsResultPayload || {};
var formsAssociatedWithProject = req.appformsResultPayload.data || [];
var foundForm = _.find(formsAssociatedWithProject, function(formId){
return requestedFormId === formId;
});
//Form Associated, can get the form
if(foundForm){
return next();
} else{
return next(new Error("Invalid Form Request. Form Not Associated With The Project"));
}
} | javascript | function checkFormAssociation(req, res, next){
var requestedFormId = req.params.id;
req.appformsResultPayload = req.appformsResultPayload || {};
var formsAssociatedWithProject = req.appformsResultPayload.data || [];
var foundForm = _.find(formsAssociatedWithProject, function(formId){
return requestedFormId === formId;
});
//Form Associated, can get the form
if(foundForm){
return next();
} else{
return next(new Error("Invalid Form Request. Form Not Associated With The Project"));
}
} | [
"function",
"checkFormAssociation",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"var",
"requestedFormId",
"=",
"req",
".",
"params",
".",
"id",
";",
"req",
".",
"appformsResultPayload",
"=",
"req",
".",
"appformsResultPayload",
"||",
"{",
"}",
";",
"var",
"formsAssociatedWithProject",
"=",
"req",
".",
"appformsResultPayload",
".",
"data",
"||",
"[",
"]",
";",
"var",
"foundForm",
"=",
"_",
".",
"find",
"(",
"formsAssociatedWithProject",
",",
"function",
"(",
"formId",
")",
"{",
"return",
"requestedFormId",
"===",
"formId",
";",
"}",
")",
";",
"//Form Associated, can get the form",
"if",
"(",
"foundForm",
")",
"{",
"return",
"next",
"(",
")",
";",
"}",
"else",
"{",
"return",
"next",
"(",
"new",
"Error",
"(",
"\"Invalid Form Request. Form Not Associated With The Project\"",
")",
")",
";",
"}",
"}"
] | Middleware To Check That A Requested Form Exists
@param req
@param res
@param next | [
"Middleware",
"To",
"Check",
"That",
"A",
"Requested",
"Form",
"Exists"
] | f906e98efbb4b0963bf5137b34b5e0589ba24e69 | https://github.com/feedhenry/fh-mbaas-middleware/blob/f906e98efbb4b0963bf5137b34b5e0589ba24e69/lib/middleware/forms.js#L64-L79 |
52,308 | feedhenry/fh-mbaas-middleware | lib/middleware/forms.js | notifySubmissionComplete | function notifySubmissionComplete(req, res, next){
req.appformsResultPayload = req.appformsResultPayload || {};
var completeStatus = req.appformsResultPayload.data;
var submission = completeStatus.formSubmission;
//The Submission Is Not Complete, No need to send a notification.
if("complete" !== completeStatus.status){
return next();
}
var resourcePath = "/api/v2/appforms/domain/:domain/projects/:projectid/apps/:guid/forms/" + submission.formId + "/submissions/" + req.params.id + "/complete";
var params = _createRequestParams(_.extend({
resourcePath: resourcePath,
method: "POST",
apiKey: req.get('x-fh-auth-app'),
appMbaasModel: req.appMbaasModel,
data: completeStatus
}, req.params));
log.logger.debug("notifySubmissionComplete ", {params: params});
request(params, _createResponseHandler(req, next, true));
} | javascript | function notifySubmissionComplete(req, res, next){
req.appformsResultPayload = req.appformsResultPayload || {};
var completeStatus = req.appformsResultPayload.data;
var submission = completeStatus.formSubmission;
//The Submission Is Not Complete, No need to send a notification.
if("complete" !== completeStatus.status){
return next();
}
var resourcePath = "/api/v2/appforms/domain/:domain/projects/:projectid/apps/:guid/forms/" + submission.formId + "/submissions/" + req.params.id + "/complete";
var params = _createRequestParams(_.extend({
resourcePath: resourcePath,
method: "POST",
apiKey: req.get('x-fh-auth-app'),
appMbaasModel: req.appMbaasModel,
data: completeStatus
}, req.params));
log.logger.debug("notifySubmissionComplete ", {params: params});
request(params, _createResponseHandler(req, next, true));
} | [
"function",
"notifySubmissionComplete",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"req",
".",
"appformsResultPayload",
"=",
"req",
".",
"appformsResultPayload",
"||",
"{",
"}",
";",
"var",
"completeStatus",
"=",
"req",
".",
"appformsResultPayload",
".",
"data",
";",
"var",
"submission",
"=",
"completeStatus",
".",
"formSubmission",
";",
"//The Submission Is Not Complete, No need to send a notification.",
"if",
"(",
"\"complete\"",
"!==",
"completeStatus",
".",
"status",
")",
"{",
"return",
"next",
"(",
")",
";",
"}",
"var",
"resourcePath",
"=",
"\"/api/v2/appforms/domain/:domain/projects/:projectid/apps/:guid/forms/\"",
"+",
"submission",
".",
"formId",
"+",
"\"/submissions/\"",
"+",
"req",
".",
"params",
".",
"id",
"+",
"\"/complete\"",
";",
"var",
"params",
"=",
"_createRequestParams",
"(",
"_",
".",
"extend",
"(",
"{",
"resourcePath",
":",
"resourcePath",
",",
"method",
":",
"\"POST\"",
",",
"apiKey",
":",
"req",
".",
"get",
"(",
"'x-fh-auth-app'",
")",
",",
"appMbaasModel",
":",
"req",
".",
"appMbaasModel",
",",
"data",
":",
"completeStatus",
"}",
",",
"req",
".",
"params",
")",
")",
";",
"log",
".",
"logger",
".",
"debug",
"(",
"\"notifySubmissionComplete \"",
",",
"{",
"params",
":",
"params",
"}",
")",
";",
"request",
"(",
"params",
",",
"_createResponseHandler",
"(",
"req",
",",
"next",
",",
"true",
")",
")",
";",
"}"
] | Function To Notify Core Platform That The Submission Is Complete. The core platform will send a mail to any subscribers.
@param req
@param res
@param next | [
"Function",
"To",
"Notify",
"Core",
"Platform",
"That",
"The",
"Submission",
"Is",
"Complete",
".",
"The",
"core",
"platform",
"will",
"send",
"a",
"mail",
"to",
"any",
"subscribers",
"."
] | f906e98efbb4b0963bf5137b34b5e0589ba24e69 | https://github.com/feedhenry/fh-mbaas-middleware/blob/f906e98efbb4b0963bf5137b34b5e0589ba24e69/lib/middleware/forms.js#L87-L110 |
52,309 | klovadis/redis-lua-helper | lib/index.js | replaceMacro | function replaceMacro(code) {
if (!re) return getKeys(code);
var match = code.match(re);
if (!match) return getKeys(code);
var includeFile = match[1];
includeFile = path.relative(self.config.root, path.join(path.dirname(fileName), includeFile));
self._parse(includeFile, function (err, includeCode) {
if (err) return callback(err);
includeCode = '\n\r-- ' + macro + ' ' + match[1] + ':\n'
+ includeCode
+ '\n\r-- End of ' + match[1];
code = code.replace(match[0], includeCode);
replaceMacro(code);
});
} | javascript | function replaceMacro(code) {
if (!re) return getKeys(code);
var match = code.match(re);
if (!match) return getKeys(code);
var includeFile = match[1];
includeFile = path.relative(self.config.root, path.join(path.dirname(fileName), includeFile));
self._parse(includeFile, function (err, includeCode) {
if (err) return callback(err);
includeCode = '\n\r-- ' + macro + ' ' + match[1] + ':\n'
+ includeCode
+ '\n\r-- End of ' + match[1];
code = code.replace(match[0], includeCode);
replaceMacro(code);
});
} | [
"function",
"replaceMacro",
"(",
"code",
")",
"{",
"if",
"(",
"!",
"re",
")",
"return",
"getKeys",
"(",
"code",
")",
";",
"var",
"match",
"=",
"code",
".",
"match",
"(",
"re",
")",
";",
"if",
"(",
"!",
"match",
")",
"return",
"getKeys",
"(",
"code",
")",
";",
"var",
"includeFile",
"=",
"match",
"[",
"1",
"]",
";",
"includeFile",
"=",
"path",
".",
"relative",
"(",
"self",
".",
"config",
".",
"root",
",",
"path",
".",
"join",
"(",
"path",
".",
"dirname",
"(",
"fileName",
")",
",",
"includeFile",
")",
")",
";",
"self",
".",
"_parse",
"(",
"includeFile",
",",
"function",
"(",
"err",
",",
"includeCode",
")",
"{",
"if",
"(",
"err",
")",
"return",
"callback",
"(",
"err",
")",
";",
"includeCode",
"=",
"'\\n\\r-- '",
"+",
"macro",
"+",
"' '",
"+",
"match",
"[",
"1",
"]",
"+",
"':\\n'",
"+",
"includeCode",
"+",
"'\\n\\r-- End of '",
"+",
"match",
"[",
"1",
"]",
";",
"code",
"=",
"code",
".",
"replace",
"(",
"match",
"[",
"0",
"]",
",",
"includeCode",
")",
";",
"replaceMacro",
"(",
"code",
")",
";",
"}",
")",
";",
"}"
] | get included files | [
"get",
"included",
"files"
] | f23b82054b8ea3c08b7713c6f996fd6f43b55e04 | https://github.com/klovadis/redis-lua-helper/blob/f23b82054b8ea3c08b7713c6f996fd6f43b55e04/lib/index.js#L162-L178 |
52,310 | klovadis/redis-lua-helper | lib/index.js | done | function done(code) {
// calculate shasum and cache info
var shasum = crypto.createHash('sha1');
shasum.update(code);
self._shasums[scriptName] = shasum.digest('hex');
self._scripts[scriptName] = code;
self._files[fileName] = code;
// make dublicate entries for both script and script.lua
if (path.extname(scriptName) === ext) {
var alt = scriptName.substr(0, scriptName.length - ext.length);
self._shasums[alt] = self._shasums[scriptName]
self._scripts[alt] = self._scripts[scriptName]
self._keys[alt] = self._keys[scriptName]
}
delete self._resolving[fileName];
callback(null, code);
} | javascript | function done(code) {
// calculate shasum and cache info
var shasum = crypto.createHash('sha1');
shasum.update(code);
self._shasums[scriptName] = shasum.digest('hex');
self._scripts[scriptName] = code;
self._files[fileName] = code;
// make dublicate entries for both script and script.lua
if (path.extname(scriptName) === ext) {
var alt = scriptName.substr(0, scriptName.length - ext.length);
self._shasums[alt] = self._shasums[scriptName]
self._scripts[alt] = self._scripts[scriptName]
self._keys[alt] = self._keys[scriptName]
}
delete self._resolving[fileName];
callback(null, code);
} | [
"function",
"done",
"(",
"code",
")",
"{",
"// calculate shasum and cache info",
"var",
"shasum",
"=",
"crypto",
".",
"createHash",
"(",
"'sha1'",
")",
";",
"shasum",
".",
"update",
"(",
"code",
")",
";",
"self",
".",
"_shasums",
"[",
"scriptName",
"]",
"=",
"shasum",
".",
"digest",
"(",
"'hex'",
")",
";",
"self",
".",
"_scripts",
"[",
"scriptName",
"]",
"=",
"code",
";",
"self",
".",
"_files",
"[",
"fileName",
"]",
"=",
"code",
";",
"// make dublicate entries for both script and script.lua",
"if",
"(",
"path",
".",
"extname",
"(",
"scriptName",
")",
"===",
"ext",
")",
"{",
"var",
"alt",
"=",
"scriptName",
".",
"substr",
"(",
"0",
",",
"scriptName",
".",
"length",
"-",
"ext",
".",
"length",
")",
";",
"self",
".",
"_shasums",
"[",
"alt",
"]",
"=",
"self",
".",
"_shasums",
"[",
"scriptName",
"]",
"self",
".",
"_scripts",
"[",
"alt",
"]",
"=",
"self",
".",
"_scripts",
"[",
"scriptName",
"]",
"self",
".",
"_keys",
"[",
"alt",
"]",
"=",
"self",
".",
"_keys",
"[",
"scriptName",
"]",
"}",
"delete",
"self",
".",
"_resolving",
"[",
"fileName",
"]",
";",
"callback",
"(",
"null",
",",
"code",
")",
";",
"}"
] | file has been loaded | [
"file",
"has",
"been",
"loaded"
] | f23b82054b8ea3c08b7713c6f996fd6f43b55e04 | https://github.com/klovadis/redis-lua-helper/blob/f23b82054b8ea3c08b7713c6f996fd6f43b55e04/lib/index.js#L195-L213 |
52,311 | origin1tech/stiks | dist/exec.js | exec | function exec(cmd, args, options) {
// If true user wants stdout to output value
// instead of using inherit outputting
// to process.stdout stream.
if (options === true)
options = { stdio: 'pipe' };
options = chek_1.extend({}, spawnDefaults, options);
if (chek_1.isString(args))
args = argv_1.splitArgs(args);
// Ensure command and arguments.
if (!cmd)
logger_1.log.error('Cannot execute process with command of undefined.');
args = args.map(function (s) {
if (/\s/g.test(s))
return '"' + s + '"';
return s;
});
// Spawn child.
var child = child_process_1.spawnSync(cmd, args, options);
if (child.stdout)
return child.stdout.toString();
} | javascript | function exec(cmd, args, options) {
// If true user wants stdout to output value
// instead of using inherit outputting
// to process.stdout stream.
if (options === true)
options = { stdio: 'pipe' };
options = chek_1.extend({}, spawnDefaults, options);
if (chek_1.isString(args))
args = argv_1.splitArgs(args);
// Ensure command and arguments.
if (!cmd)
logger_1.log.error('Cannot execute process with command of undefined.');
args = args.map(function (s) {
if (/\s/g.test(s))
return '"' + s + '"';
return s;
});
// Spawn child.
var child = child_process_1.spawnSync(cmd, args, options);
if (child.stdout)
return child.stdout.toString();
} | [
"function",
"exec",
"(",
"cmd",
",",
"args",
",",
"options",
")",
"{",
"// If true user wants stdout to output value",
"// instead of using inherit outputting",
"// to process.stdout stream.",
"if",
"(",
"options",
"===",
"true",
")",
"options",
"=",
"{",
"stdio",
":",
"'pipe'",
"}",
";",
"options",
"=",
"chek_1",
".",
"extend",
"(",
"{",
"}",
",",
"spawnDefaults",
",",
"options",
")",
";",
"if",
"(",
"chek_1",
".",
"isString",
"(",
"args",
")",
")",
"args",
"=",
"argv_1",
".",
"splitArgs",
"(",
"args",
")",
";",
"// Ensure command and arguments.",
"if",
"(",
"!",
"cmd",
")",
"logger_1",
".",
"log",
".",
"error",
"(",
"'Cannot execute process with command of undefined.'",
")",
";",
"args",
"=",
"args",
".",
"map",
"(",
"function",
"(",
"s",
")",
"{",
"if",
"(",
"/",
"\\s",
"/",
"g",
".",
"test",
"(",
"s",
")",
")",
"return",
"'\"'",
"+",
"s",
"+",
"'\"'",
";",
"return",
"s",
";",
"}",
")",
";",
"// Spawn child.",
"var",
"child",
"=",
"child_process_1",
".",
"spawnSync",
"(",
"cmd",
",",
"args",
",",
"options",
")",
";",
"if",
"(",
"child",
".",
"stdout",
")",
"return",
"child",
".",
"stdout",
".",
"toString",
"(",
")",
";",
"}"
] | Exec
Executes command using child process.
@param cmd node, npm or shell command to be executed.
@param args arguments to be passed to command.
@param options the child process spawn options. | [
"Exec",
"Executes",
"command",
"using",
"child",
"process",
"."
] | dca9cd352bb914e53e64e791fc85985aef3d9fb7 | https://github.com/origin1tech/stiks/blob/dca9cd352bb914e53e64e791fc85985aef3d9fb7/dist/exec.js#L54-L75 |
52,312 | SoftwarePlumbers/immutable-base | immutable.js | processArguments | function processArguments(props, args, defaults) {
debug('processArguments',props,args,defaults);
values = Object.assign({}, defaults);
let properties = Object.getOwnPropertyNames(values);
// First execute any single-arg functions to create dynamic defaults
for (property of properties) {
let value = values[property];
if (typeof value === 'function' && value.length === 0)
values[property] = value();
}
// Then expand a single argument that is an object into a set of values
if (args.length === 1 && typeof args[0] === 'object') {
Object.assign(values, args[0]);
} else {
// Or assign arguments to properties in order
for (i = 0; i < Math.min(args.length, props.length); i++)
values[props[i]] = args[i];
}
debug('processArguments returns',values);
return values;
} | javascript | function processArguments(props, args, defaults) {
debug('processArguments',props,args,defaults);
values = Object.assign({}, defaults);
let properties = Object.getOwnPropertyNames(values);
// First execute any single-arg functions to create dynamic defaults
for (property of properties) {
let value = values[property];
if (typeof value === 'function' && value.length === 0)
values[property] = value();
}
// Then expand a single argument that is an object into a set of values
if (args.length === 1 && typeof args[0] === 'object') {
Object.assign(values, args[0]);
} else {
// Or assign arguments to properties in order
for (i = 0; i < Math.min(args.length, props.length); i++)
values[props[i]] = args[i];
}
debug('processArguments returns',values);
return values;
} | [
"function",
"processArguments",
"(",
"props",
",",
"args",
",",
"defaults",
")",
"{",
"debug",
"(",
"'processArguments'",
",",
"props",
",",
"args",
",",
"defaults",
")",
";",
"values",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"defaults",
")",
";",
"let",
"properties",
"=",
"Object",
".",
"getOwnPropertyNames",
"(",
"values",
")",
";",
"// First execute any single-arg functions to create dynamic defaults",
"for",
"(",
"property",
"of",
"properties",
")",
"{",
"let",
"value",
"=",
"values",
"[",
"property",
"]",
";",
"if",
"(",
"typeof",
"value",
"===",
"'function'",
"&&",
"value",
".",
"length",
"===",
"0",
")",
"values",
"[",
"property",
"]",
"=",
"value",
"(",
")",
";",
"}",
"// Then expand a single argument that is an object into a set of values",
"if",
"(",
"args",
".",
"length",
"===",
"1",
"&&",
"typeof",
"args",
"[",
"0",
"]",
"===",
"'object'",
")",
"{",
"Object",
".",
"assign",
"(",
"values",
",",
"args",
"[",
"0",
"]",
")",
";",
"}",
"else",
"{",
"// Or assign arguments to properties in order",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"Math",
".",
"min",
"(",
"args",
".",
"length",
",",
"props",
".",
"length",
")",
";",
"i",
"++",
")",
"values",
"[",
"props",
"[",
"i",
"]",
"]",
"=",
"args",
"[",
"i",
"]",
";",
"}",
"debug",
"(",
"'processArguments returns'",
",",
"values",
")",
";",
"return",
"values",
";",
"}"
] | Handle case where we have a single argument containing an object.
Basically, merge properties in args[0] into defaults, iff we have a single argument and it is an object. | [
"Handle",
"case",
"where",
"we",
"have",
"a",
"single",
"argument",
"containing",
"an",
"object",
"."
] | 3975c5e3ca30614916d3df0a262aeef229a1d538 | https://github.com/SoftwarePlumbers/immutable-base/blob/3975c5e3ca30614916d3df0a262aeef229a1d538/immutable.js#L10-L35 |
52,313 | SoftwarePlumbers/immutable-base | immutable.js | create | function create(defaults) {
let props = Object.getOwnPropertyNames(defaults);
/** Immutable class created from defaults.
*
*/
const immutableClass = class {
/** Constructor.
*
* Can take a single object argument, in which case the properties of the object are copied over into
* any matching default propertis that were defined in 'create'. Can also take normal arguments, in which
* case the arguments are matched to the default properties in the order in which they were originally
* defined in the defaults object.
*/
constructor() {
debug('constructor', props, defaults, arguments);
values = processArguments(props,arguments,defaults);
// Otherwise assign arguments to properties in order
for (let prop of props) {
let value = values[prop]
Object.defineProperty(this, prop, { value, enumerable: true, writable: false });
}
}
/** Merge a set of properties with the immutable object, returning a new immutable object
*
* @param props Properties to merge.
* @returns a new immutable object of the same type as 'this'.
*/
merge(props) {
return new this.constructor(Object.assign({}, this, props));
}
/** Get the immutable property names
*
* An immutable object may legitimately have transient proprerties that are not part of the public
* interface of the object. We therefore create a getImmutablePropertyNames static method that gets
* the list of immutable properties names that is defined for this class.
*/
static getImmutablePropertyNames() { return props; }
/** Extends an immutable object, making a new immutable object.
*
* @param new_defaults additional properties for the extended object, plus default values for them.
*/
static extend(new_defaults) { return extend(immutableClass, new_defaults)}
};
for (let prop of props) {
let setterName = 'set' + prop.slice(0,1).toUpperCase() + prop.slice(1);
immutableClass.prototype[setterName] = function(val) {
debug(setterName, prop, val);
return this.merge({ [prop] : val });
};
}
return immutableClass;
} | javascript | function create(defaults) {
let props = Object.getOwnPropertyNames(defaults);
/** Immutable class created from defaults.
*
*/
const immutableClass = class {
/** Constructor.
*
* Can take a single object argument, in which case the properties of the object are copied over into
* any matching default propertis that were defined in 'create'. Can also take normal arguments, in which
* case the arguments are matched to the default properties in the order in which they were originally
* defined in the defaults object.
*/
constructor() {
debug('constructor', props, defaults, arguments);
values = processArguments(props,arguments,defaults);
// Otherwise assign arguments to properties in order
for (let prop of props) {
let value = values[prop]
Object.defineProperty(this, prop, { value, enumerable: true, writable: false });
}
}
/** Merge a set of properties with the immutable object, returning a new immutable object
*
* @param props Properties to merge.
* @returns a new immutable object of the same type as 'this'.
*/
merge(props) {
return new this.constructor(Object.assign({}, this, props));
}
/** Get the immutable property names
*
* An immutable object may legitimately have transient proprerties that are not part of the public
* interface of the object. We therefore create a getImmutablePropertyNames static method that gets
* the list of immutable properties names that is defined for this class.
*/
static getImmutablePropertyNames() { return props; }
/** Extends an immutable object, making a new immutable object.
*
* @param new_defaults additional properties for the extended object, plus default values for them.
*/
static extend(new_defaults) { return extend(immutableClass, new_defaults)}
};
for (let prop of props) {
let setterName = 'set' + prop.slice(0,1).toUpperCase() + prop.slice(1);
immutableClass.prototype[setterName] = function(val) {
debug(setterName, prop, val);
return this.merge({ [prop] : val });
};
}
return immutableClass;
} | [
"function",
"create",
"(",
"defaults",
")",
"{",
"let",
"props",
"=",
"Object",
".",
"getOwnPropertyNames",
"(",
"defaults",
")",
";",
"/** Immutable class created from defaults.\n *\n */",
"const",
"immutableClass",
"=",
"class",
"{",
"/** Constructor.\n *\n * Can take a single object argument, in which case the properties of the object are copied over into\n * any matching default propertis that were defined in 'create'. Can also take normal arguments, in which\n * case the arguments are matched to the default properties in the order in which they were originally \n * defined in the defaults object.\n */",
"constructor",
"(",
")",
"{",
"debug",
"(",
"'constructor'",
",",
"props",
",",
"defaults",
",",
"arguments",
")",
";",
"values",
"=",
"processArguments",
"(",
"props",
",",
"arguments",
",",
"defaults",
")",
";",
"// Otherwise assign arguments to properties in order",
"for",
"(",
"let",
"prop",
"of",
"props",
")",
"{",
"let",
"value",
"=",
"values",
"[",
"prop",
"]",
"Object",
".",
"defineProperty",
"(",
"this",
",",
"prop",
",",
"{",
"value",
",",
"enumerable",
":",
"true",
",",
"writable",
":",
"false",
"}",
")",
";",
"}",
"}",
"/** Merge a set of properties with the immutable object, returning a new immutable object\n *\n * @param props Properties to merge.\n * @returns a new immutable object of the same type as 'this'.\n */",
"merge",
"(",
"props",
")",
"{",
"return",
"new",
"this",
".",
"constructor",
"(",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"this",
",",
"props",
")",
")",
";",
"}",
"/** Get the immutable property names\n *\n * An immutable object may legitimately have transient proprerties that are not part of the public\n * interface of the object. We therefore create a getImmutablePropertyNames static method that gets\n * the list of immutable properties names that is defined for this class.\n */",
"static",
"getImmutablePropertyNames",
"(",
")",
"{",
"return",
"props",
";",
"}",
"/** Extends an immutable object, making a new immutable object.\n *\n * @param new_defaults additional properties for the extended object, plus default values for them.\n */",
"static",
"extend",
"(",
"new_defaults",
")",
"{",
"return",
"extend",
"(",
"immutableClass",
",",
"new_defaults",
")",
"}",
"}",
";",
"for",
"(",
"let",
"prop",
"of",
"props",
")",
"{",
"let",
"setterName",
"=",
"'set'",
"+",
"prop",
".",
"slice",
"(",
"0",
",",
"1",
")",
".",
"toUpperCase",
"(",
")",
"+",
"prop",
".",
"slice",
"(",
"1",
")",
";",
"immutableClass",
".",
"prototype",
"[",
"setterName",
"]",
"=",
"function",
"(",
"val",
")",
"{",
"debug",
"(",
"setterName",
",",
"prop",
",",
"val",
")",
";",
"return",
"this",
".",
"merge",
"(",
"{",
"[",
"prop",
"]",
":",
"val",
"}",
")",
";",
"}",
";",
"}",
"return",
"immutableClass",
";",
"}"
] | Create an immutable class
The resulting class will have the supplied properties and defaults, a constructor, and setters
which return a copy of the instance they are applied to with the implied update in place.
Passing in { property: undefined } will ensure a setter is created for 'property' without creating a default.
@param defaults {Object} A set of key/value pairs used to create default properties for class instances.
@returns A class object with appropriate properties and setter methods. | [
"Create",
"an",
"immutable",
"class"
] | 3975c5e3ca30614916d3df0a262aeef229a1d538 | https://github.com/SoftwarePlumbers/immutable-base/blob/3975c5e3ca30614916d3df0a262aeef229a1d538/immutable.js#L47-L109 |
52,314 | SoftwarePlumbers/immutable-base | immutable.js | extend | function extend(to_extend, new_defaults = {}) {
let new_default_props = Object.getOwnPropertyNames(new_defaults);
let old_props = to_extend.getImmutablePropertyNames();
let new_props = new_default_props.filter(e => old_props.indexOf(e) < 0);
//let overriden_props = new_default_props.filter(e => old_props.indexOf(e) >= 0);
let props = old_props.concat(new_props);
debug('merged props', props);
/** Immutable class created from new_defaults and the extended class
*
*/
let immutableClass = class extends to_extend {
/** Constructor.
*
* Can take a single object argument, in which case the properties of the object are copied over into
* any matching default propertis that were defined in 'create'. Can also take normal arguments, in which
* case the arguments are matched to the default properties in the base class, and then to additional
* properties defined in the new_defaults object .
*/
constructor() {
// Handle case where we have one argument that's an object: assume it's properties to pass in
let values = processArguments(props, arguments, new_defaults);
// Handle values for base class
super(values);
// assign values to properties in order
for (let prop of new_props) {
let value = values[prop];
debug('value', value);
Object.defineProperty(this, prop, { value, enumerable: true, writable: false });
}
}
/** Get the immutable property names
*
* An immutable object may legitimately have transient proprerties that are not part of the public
* interface of the object. We therefore create a getImmutablePropertyNames static method that gets
* the list of immutable properties names that is defined for this class.
*/
static getImmutablePropertyNames() { return props; }
/** Extends an immutable object, making a new immutable object.
*
* @param new_defaults additional properties for the extended object, plus default values for them.
*/
static extend(new_defaults) { return extend(immutableClass, new_defaults)}
};
for (let prop of new_props) {
let setterName = 'set' + prop.slice(0,1).toUpperCase() + prop.slice(1);
immutableClass.prototype[setterName] = function(val) {
debug(setterName, prop, val);
return this.merge({ [prop] : val });
};
}
return immutableClass;
} | javascript | function extend(to_extend, new_defaults = {}) {
let new_default_props = Object.getOwnPropertyNames(new_defaults);
let old_props = to_extend.getImmutablePropertyNames();
let new_props = new_default_props.filter(e => old_props.indexOf(e) < 0);
//let overriden_props = new_default_props.filter(e => old_props.indexOf(e) >= 0);
let props = old_props.concat(new_props);
debug('merged props', props);
/** Immutable class created from new_defaults and the extended class
*
*/
let immutableClass = class extends to_extend {
/** Constructor.
*
* Can take a single object argument, in which case the properties of the object are copied over into
* any matching default propertis that were defined in 'create'. Can also take normal arguments, in which
* case the arguments are matched to the default properties in the base class, and then to additional
* properties defined in the new_defaults object .
*/
constructor() {
// Handle case where we have one argument that's an object: assume it's properties to pass in
let values = processArguments(props, arguments, new_defaults);
// Handle values for base class
super(values);
// assign values to properties in order
for (let prop of new_props) {
let value = values[prop];
debug('value', value);
Object.defineProperty(this, prop, { value, enumerable: true, writable: false });
}
}
/** Get the immutable property names
*
* An immutable object may legitimately have transient proprerties that are not part of the public
* interface of the object. We therefore create a getImmutablePropertyNames static method that gets
* the list of immutable properties names that is defined for this class.
*/
static getImmutablePropertyNames() { return props; }
/** Extends an immutable object, making a new immutable object.
*
* @param new_defaults additional properties for the extended object, plus default values for them.
*/
static extend(new_defaults) { return extend(immutableClass, new_defaults)}
};
for (let prop of new_props) {
let setterName = 'set' + prop.slice(0,1).toUpperCase() + prop.slice(1);
immutableClass.prototype[setterName] = function(val) {
debug(setterName, prop, val);
return this.merge({ [prop] : val });
};
}
return immutableClass;
} | [
"function",
"extend",
"(",
"to_extend",
",",
"new_defaults",
"=",
"{",
"}",
")",
"{",
"let",
"new_default_props",
"=",
"Object",
".",
"getOwnPropertyNames",
"(",
"new_defaults",
")",
";",
"let",
"old_props",
"=",
"to_extend",
".",
"getImmutablePropertyNames",
"(",
")",
";",
"let",
"new_props",
"=",
"new_default_props",
".",
"filter",
"(",
"e",
"=>",
"old_props",
".",
"indexOf",
"(",
"e",
")",
"<",
"0",
")",
";",
"//let overriden_props = new_default_props.filter(e => old_props.indexOf(e) >= 0);",
"let",
"props",
"=",
"old_props",
".",
"concat",
"(",
"new_props",
")",
";",
"debug",
"(",
"'merged props'",
",",
"props",
")",
";",
"/** Immutable class created from new_defaults and the extended class\n *\n */",
"let",
"immutableClass",
"=",
"class",
"extends",
"to_extend",
"{",
"/** Constructor.\n *\n * Can take a single object argument, in which case the properties of the object are copied over into\n * any matching default propertis that were defined in 'create'. Can also take normal arguments, in which\n * case the arguments are matched to the default properties in the base class, and then to additional \n * properties defined in the new_defaults object .\n */",
"constructor",
"(",
")",
"{",
"// Handle case where we have one argument that's an object: assume it's properties to pass in",
"let",
"values",
"=",
"processArguments",
"(",
"props",
",",
"arguments",
",",
"new_defaults",
")",
";",
"// Handle values for base class",
"super",
"(",
"values",
")",
";",
"// assign values to properties in order",
"for",
"(",
"let",
"prop",
"of",
"new_props",
")",
"{",
"let",
"value",
"=",
"values",
"[",
"prop",
"]",
";",
"debug",
"(",
"'value'",
",",
"value",
")",
";",
"Object",
".",
"defineProperty",
"(",
"this",
",",
"prop",
",",
"{",
"value",
",",
"enumerable",
":",
"true",
",",
"writable",
":",
"false",
"}",
")",
";",
"}",
"}",
"/** Get the immutable property names\n *\n * An immutable object may legitimately have transient proprerties that are not part of the public\n * interface of the object. We therefore create a getImmutablePropertyNames static method that gets\n * the list of immutable properties names that is defined for this class.\n */",
"static",
"getImmutablePropertyNames",
"(",
")",
"{",
"return",
"props",
";",
"}",
"/** Extends an immutable object, making a new immutable object.\n *\n * @param new_defaults additional properties for the extended object, plus default values for them.\n */",
"static",
"extend",
"(",
"new_defaults",
")",
"{",
"return",
"extend",
"(",
"immutableClass",
",",
"new_defaults",
")",
"}",
"}",
";",
"for",
"(",
"let",
"prop",
"of",
"new_props",
")",
"{",
"let",
"setterName",
"=",
"'set'",
"+",
"prop",
".",
"slice",
"(",
"0",
",",
"1",
")",
".",
"toUpperCase",
"(",
")",
"+",
"prop",
".",
"slice",
"(",
"1",
")",
";",
"immutableClass",
".",
"prototype",
"[",
"setterName",
"]",
"=",
"function",
"(",
"val",
")",
"{",
"debug",
"(",
"setterName",
",",
"prop",
",",
"val",
")",
";",
"return",
"this",
".",
"merge",
"(",
"{",
"[",
"prop",
"]",
":",
"val",
"}",
")",
";",
"}",
";",
"}",
"return",
"immutableClass",
";",
"}"
] | Extend an immutable class
The resulting class will have the supplied properties and defaults, a constructor, an additional setters
which return a copy of the instance they are applied to with the implied update in place.
Passing in { property: undefined } will ensure a setter is created for 'property' without creating a default.
@param to_extend a class object (which must inherit from an immutable object as created above)
@param defaults {Object} A set of key/value pairs used to create additional default properties for class instances.
@returns A class object with appropriate properties and setter methods. | [
"Extend",
"an",
"immutable",
"class"
] | 3975c5e3ca30614916d3df0a262aeef229a1d538 | https://github.com/SoftwarePlumbers/immutable-base/blob/3975c5e3ca30614916d3df0a262aeef229a1d538/immutable.js#L122-L184 |
52,315 | tkesgar/sharo-next | index.js | withSharo | function withSharo(nextConfig = {}) {
// https://github.com/zeit/next-plugins/issues/320
const withMdx = require('@zeit/next-mdx')({
// Allow regular markdown files (*.md) to be imported.
extension: /\.mdx?$/
})
return (
withSass(withMdx(
Object.assign(
// =====================================================================
// Default configurations (can be overridden by nextConfig)
// =====================================================================
{
// Currently empty
},
// =====================================================================
// Override default configurations with nextConfig
// =====================================================================
nextConfig,
// =====================================================================
// Override nextConfig configurations
// (note to self: follow Next.js rules on this section)
// =====================================================================
{
webpack(config, options) {
// Allow autoresolving of MDX (*.md, *.mdx) and SCSS (*.scss, *.sass)
config.resolve.extensions.push('.md', '.mdx', '.scss', '.sass')
if (typeof nextConfig.webpack === 'function') {
return nextConfig.webpack(config, options)
}
return config
}
}
)
))
)
} | javascript | function withSharo(nextConfig = {}) {
// https://github.com/zeit/next-plugins/issues/320
const withMdx = require('@zeit/next-mdx')({
// Allow regular markdown files (*.md) to be imported.
extension: /\.mdx?$/
})
return (
withSass(withMdx(
Object.assign(
// =====================================================================
// Default configurations (can be overridden by nextConfig)
// =====================================================================
{
// Currently empty
},
// =====================================================================
// Override default configurations with nextConfig
// =====================================================================
nextConfig,
// =====================================================================
// Override nextConfig configurations
// (note to self: follow Next.js rules on this section)
// =====================================================================
{
webpack(config, options) {
// Allow autoresolving of MDX (*.md, *.mdx) and SCSS (*.scss, *.sass)
config.resolve.extensions.push('.md', '.mdx', '.scss', '.sass')
if (typeof nextConfig.webpack === 'function') {
return nextConfig.webpack(config, options)
}
return config
}
}
)
))
)
} | [
"function",
"withSharo",
"(",
"nextConfig",
"=",
"{",
"}",
")",
"{",
"// https://github.com/zeit/next-plugins/issues/320",
"const",
"withMdx",
"=",
"require",
"(",
"'@zeit/next-mdx'",
")",
"(",
"{",
"// Allow regular markdown files (*.md) to be imported.",
"extension",
":",
"/",
"\\.mdx?$",
"/",
"}",
")",
"return",
"(",
"withSass",
"(",
"withMdx",
"(",
"Object",
".",
"assign",
"(",
"// =====================================================================",
"// Default configurations (can be overridden by nextConfig)",
"// =====================================================================",
"{",
"// Currently empty",
"}",
",",
"// =====================================================================",
"// Override default configurations with nextConfig",
"// =====================================================================",
"nextConfig",
",",
"// =====================================================================",
"// Override nextConfig configurations",
"// (note to self: follow Next.js rules on this section)",
"// =====================================================================",
"{",
"webpack",
"(",
"config",
",",
"options",
")",
"{",
"// Allow autoresolving of MDX (*.md, *.mdx) and SCSS (*.scss, *.sass)",
"config",
".",
"resolve",
".",
"extensions",
".",
"push",
"(",
"'.md'",
",",
"'.mdx'",
",",
"'.scss'",
",",
"'.sass'",
")",
"if",
"(",
"typeof",
"nextConfig",
".",
"webpack",
"===",
"'function'",
")",
"{",
"return",
"nextConfig",
".",
"webpack",
"(",
"config",
",",
"options",
")",
"}",
"return",
"config",
"}",
"}",
")",
")",
")",
")",
"}"
] | This function is a Next.js plugin for sharo.
Features:
- Bundle analysis reporter via `@zeit/next-bundle-analyzer`
- MDX support via `@zeit/next-mdx`
- Web Workers transpilation support via `@zeit/next-workers`
- SASS/SCSS support via `@zeit/next-sass`
To generate bundle analysis report, provide `BUNDLE_ANALYZE` environment
variable with one of the following values:
- `server`: generate server report only
- `client`: generate client report only
- `both`: generate both server and client report
Docs:
- https://nextjs.org/docs#custom-configuration
- https://www.npmjs.com/package/@zeit/next-bundle-analyzer
- https://www.npmjs.com/package/@zeit/next-mdx
- https://www.npmjs.com/package/@zeit/next-sass
- https://www.npmjs.com/package/@zeit/next-workers
@param {any} nextConfig Next.js configuration object
@returns {any} New Next.js configuration object | [
"This",
"function",
"is",
"a",
"Next",
".",
"js",
"plugin",
"for",
"sharo",
"."
] | ce4fbd45b418a50599deba5d129286b8691d1f72 | https://github.com/tkesgar/sharo-next/blob/ce4fbd45b418a50599deba5d129286b8691d1f72/index.js#L28-L67 |
52,316 | vmarkdown/vremark-parse | packages/vremark-toc/mdast-util-toc/lib/insert.js | insert | function insert(node, parent, tight) {
var children = parent.children;
var length = children.length;
var last = children[length - 1];
var isLoose = false;
var index;
var item;
if (node.depth === 1) {
item = listItem();
item.children.push({
type: PARAGRAPH,
children: [
{
type: LINK,
title: null,
url: '#' + node.id,
children: [
{
type: TEXT,
value: node.value
}
]
}
]
});
children.push(item);
} else if (last && last.type === LIST_ITEM) {
insert(node, last, tight);
} else if (last && last.type === LIST) {
node.depth--;
insert(node, last, tight);
} else if (parent.type === LIST) {
item = listItem();
insert(node, item, tight);
children.push(item);
} else {
item = list();
node.depth--;
insert(node, item, tight);
children.push(item);
}
/*
* Properly style list-items with new lines.
*/
parent.spread = !tight;
if (parent.type === LIST && parent.spread) {
parent.spread = false;
index = -1;
while (++index < length) {
if (children[index].children.length > 1) {
parent.spread = true;
break;
}
}
}
// To do: remove `loose` in next major release.
if (parent.type === LIST_ITEM) {
parent.loose = tight ? false : children.length > 1;
} else {
if (tight) {
isLoose = false;
} else {
index = -1;
while (++index < length) {
if (children[index].loose) {
isLoose = true;
break;
}
}
}
index = -1;
while (++index < length) {
children[index].loose = isLoose;
}
}
} | javascript | function insert(node, parent, tight) {
var children = parent.children;
var length = children.length;
var last = children[length - 1];
var isLoose = false;
var index;
var item;
if (node.depth === 1) {
item = listItem();
item.children.push({
type: PARAGRAPH,
children: [
{
type: LINK,
title: null,
url: '#' + node.id,
children: [
{
type: TEXT,
value: node.value
}
]
}
]
});
children.push(item);
} else if (last && last.type === LIST_ITEM) {
insert(node, last, tight);
} else if (last && last.type === LIST) {
node.depth--;
insert(node, last, tight);
} else if (parent.type === LIST) {
item = listItem();
insert(node, item, tight);
children.push(item);
} else {
item = list();
node.depth--;
insert(node, item, tight);
children.push(item);
}
/*
* Properly style list-items with new lines.
*/
parent.spread = !tight;
if (parent.type === LIST && parent.spread) {
parent.spread = false;
index = -1;
while (++index < length) {
if (children[index].children.length > 1) {
parent.spread = true;
break;
}
}
}
// To do: remove `loose` in next major release.
if (parent.type === LIST_ITEM) {
parent.loose = tight ? false : children.length > 1;
} else {
if (tight) {
isLoose = false;
} else {
index = -1;
while (++index < length) {
if (children[index].loose) {
isLoose = true;
break;
}
}
}
index = -1;
while (++index < length) {
children[index].loose = isLoose;
}
}
} | [
"function",
"insert",
"(",
"node",
",",
"parent",
",",
"tight",
")",
"{",
"var",
"children",
"=",
"parent",
".",
"children",
";",
"var",
"length",
"=",
"children",
".",
"length",
";",
"var",
"last",
"=",
"children",
"[",
"length",
"-",
"1",
"]",
";",
"var",
"isLoose",
"=",
"false",
";",
"var",
"index",
";",
"var",
"item",
";",
"if",
"(",
"node",
".",
"depth",
"===",
"1",
")",
"{",
"item",
"=",
"listItem",
"(",
")",
";",
"item",
".",
"children",
".",
"push",
"(",
"{",
"type",
":",
"PARAGRAPH",
",",
"children",
":",
"[",
"{",
"type",
":",
"LINK",
",",
"title",
":",
"null",
",",
"url",
":",
"'#'",
"+",
"node",
".",
"id",
",",
"children",
":",
"[",
"{",
"type",
":",
"TEXT",
",",
"value",
":",
"node",
".",
"value",
"}",
"]",
"}",
"]",
"}",
")",
";",
"children",
".",
"push",
"(",
"item",
")",
";",
"}",
"else",
"if",
"(",
"last",
"&&",
"last",
".",
"type",
"===",
"LIST_ITEM",
")",
"{",
"insert",
"(",
"node",
",",
"last",
",",
"tight",
")",
";",
"}",
"else",
"if",
"(",
"last",
"&&",
"last",
".",
"type",
"===",
"LIST",
")",
"{",
"node",
".",
"depth",
"--",
";",
"insert",
"(",
"node",
",",
"last",
",",
"tight",
")",
";",
"}",
"else",
"if",
"(",
"parent",
".",
"type",
"===",
"LIST",
")",
"{",
"item",
"=",
"listItem",
"(",
")",
";",
"insert",
"(",
"node",
",",
"item",
",",
"tight",
")",
";",
"children",
".",
"push",
"(",
"item",
")",
";",
"}",
"else",
"{",
"item",
"=",
"list",
"(",
")",
";",
"node",
".",
"depth",
"--",
";",
"insert",
"(",
"node",
",",
"item",
",",
"tight",
")",
";",
"children",
".",
"push",
"(",
"item",
")",
";",
"}",
"/*\n * Properly style list-items with new lines.\n */",
"parent",
".",
"spread",
"=",
"!",
"tight",
";",
"if",
"(",
"parent",
".",
"type",
"===",
"LIST",
"&&",
"parent",
".",
"spread",
")",
"{",
"parent",
".",
"spread",
"=",
"false",
";",
"index",
"=",
"-",
"1",
";",
"while",
"(",
"++",
"index",
"<",
"length",
")",
"{",
"if",
"(",
"children",
"[",
"index",
"]",
".",
"children",
".",
"length",
">",
"1",
")",
"{",
"parent",
".",
"spread",
"=",
"true",
";",
"break",
";",
"}",
"}",
"}",
"// To do: remove `loose` in next major release.",
"if",
"(",
"parent",
".",
"type",
"===",
"LIST_ITEM",
")",
"{",
"parent",
".",
"loose",
"=",
"tight",
"?",
"false",
":",
"children",
".",
"length",
">",
"1",
";",
"}",
"else",
"{",
"if",
"(",
"tight",
")",
"{",
"isLoose",
"=",
"false",
";",
"}",
"else",
"{",
"index",
"=",
"-",
"1",
";",
"while",
"(",
"++",
"index",
"<",
"length",
")",
"{",
"if",
"(",
"children",
"[",
"index",
"]",
".",
"loose",
")",
"{",
"isLoose",
"=",
"true",
";",
"break",
";",
"}",
"}",
"}",
"index",
"=",
"-",
"1",
";",
"while",
"(",
"++",
"index",
"<",
"length",
")",
"{",
"children",
"[",
"index",
"]",
".",
"loose",
"=",
"isLoose",
";",
"}",
"}",
"}"
] | Insert a `node` into a `parent`.
@param {Object} node - `node` to insert.
@param {Object} parent - Parent of `node`.
@param {boolean?} [tight] - Prefer tight list-items.
@return {undefined} | [
"Insert",
"a",
"node",
"into",
"a",
"parent",
"."
] | d7b353dcb5d021eeceb40f3c505ece893202db7a | https://github.com/vmarkdown/vremark-parse/blob/d7b353dcb5d021eeceb40f3c505ece893202db7a/packages/vremark-toc/mdast-util-toc/lib/insert.js#L31-L123 |
52,317 | molecuel/gridfs-uploader | lib/gfsupload.js | GFSupload | function GFSupload(mongoinst, prefix) {
this.mongo = mongoinst;
this.db = this.mongo.db;
this.Grid = this.mongo.Grid;
this.GridStore = this.mongo.GridStore;
this.ObjectID = this.mongo.ObjectID;
this.prefix = prefix || this.GridStore.DEFAULT_ROOT_COLLECTION;
return this;
} | javascript | function GFSupload(mongoinst, prefix) {
this.mongo = mongoinst;
this.db = this.mongo.db;
this.Grid = this.mongo.Grid;
this.GridStore = this.mongo.GridStore;
this.ObjectID = this.mongo.ObjectID;
this.prefix = prefix || this.GridStore.DEFAULT_ROOT_COLLECTION;
return this;
} | [
"function",
"GFSupload",
"(",
"mongoinst",
",",
"prefix",
")",
"{",
"this",
".",
"mongo",
"=",
"mongoinst",
";",
"this",
".",
"db",
"=",
"this",
".",
"mongo",
".",
"db",
";",
"this",
".",
"Grid",
"=",
"this",
".",
"mongo",
".",
"Grid",
";",
"this",
".",
"GridStore",
"=",
"this",
".",
"mongo",
".",
"GridStore",
";",
"this",
".",
"ObjectID",
"=",
"this",
".",
"mongo",
".",
"ObjectID",
";",
"this",
".",
"prefix",
"=",
"prefix",
"||",
"this",
".",
"GridStore",
".",
"DEFAULT_ROOT_COLLECTION",
";",
"return",
"this",
";",
"}"
] | This class enables gridfs uploads for all the mongoose users
@constructor
@param {Object} mongoose Mongoose Object from you application
@param {String} prefix Prefix for the database like "imports"
@author "Dominic Böttger" <[email protected]>
@return {Object} | [
"This",
"class",
"enables",
"gridfs",
"uploads",
"for",
"all",
"the",
"mongoose",
"users"
] | 3a0a97d70de39e348881f7eca34a99dd7408454f | https://github.com/molecuel/gridfs-uploader/blob/3a0a97d70de39e348881f7eca34a99dd7408454f/lib/gfsupload.js#L66-L74 |
52,318 | TheDustyard/SimplerDiscord | SimplerDiscord/index.js | function (name, guild) {
let emoji = guild.emojis.find('name', name);
if (emoji === undefined || emoji === null)
return name;
return `<:${name}:${emoji.id}>`;
} | javascript | function (name, guild) {
let emoji = guild.emojis.find('name', name);
if (emoji === undefined || emoji === null)
return name;
return `<:${name}:${emoji.id}>`;
} | [
"function",
"(",
"name",
",",
"guild",
")",
"{",
"let",
"emoji",
"=",
"guild",
".",
"emojis",
".",
"find",
"(",
"'name'",
",",
"name",
")",
";",
"if",
"(",
"emoji",
"===",
"undefined",
"||",
"emoji",
"===",
"null",
")",
"return",
"name",
";",
"return",
"`",
"${",
"name",
"}",
"${",
"emoji",
".",
"id",
"}",
"`",
";",
"}"
] | METHODS
Gets an emoji
@returns {string} emoji
@param {string} name Name of the emoji
@param {Guild} guild Guild for the emoji | [
"METHODS",
"Gets",
"an",
"emoji"
] | fdbc854fa2d64d0637e9d4797d916a7494d88f62 | https://github.com/TheDustyard/SimplerDiscord/blob/fdbc854fa2d64d0637e9d4797d916a7494d88f62/SimplerDiscord/index.js#L32-L37 |
|
52,319 | TheDustyard/SimplerDiscord | SimplerDiscord/index.js | function (name, guild) {
return guild.members.filter((item) => item.user.username.toLowerCase() === this.name.toLowerCase()).join();
} | javascript | function (name, guild) {
return guild.members.filter((item) => item.user.username.toLowerCase() === this.name.toLowerCase()).join();
} | [
"function",
"(",
"name",
",",
"guild",
")",
"{",
"return",
"guild",
".",
"members",
".",
"filter",
"(",
"(",
"item",
")",
"=>",
"item",
".",
"user",
".",
"username",
".",
"toLowerCase",
"(",
")",
"===",
"this",
".",
"name",
".",
"toLowerCase",
"(",
")",
")",
".",
"join",
"(",
")",
";",
"}"
] | Gets a mention of a user
@returns {string} Mention
@param {string} name Name
@param {Guild} guild guild | [
"Gets",
"a",
"mention",
"of",
"a",
"user"
] | fdbc854fa2d64d0637e9d4797d916a7494d88f62 | https://github.com/TheDustyard/SimplerDiscord/blob/fdbc854fa2d64d0637e9d4797d916a7494d88f62/SimplerDiscord/index.js#L44-L46 |
|
52,320 | TheDustyard/SimplerDiscord | SimplerDiscord/index.js | function (name, guild) {
return guild.channels.filter((item) => item.type === "text").filter((item) => item.name === this.name).join();
} | javascript | function (name, guild) {
return guild.channels.filter((item) => item.type === "text").filter((item) => item.name === this.name).join();
} | [
"function",
"(",
"name",
",",
"guild",
")",
"{",
"return",
"guild",
".",
"channels",
".",
"filter",
"(",
"(",
"item",
")",
"=>",
"item",
".",
"type",
"===",
"\"text\"",
")",
".",
"filter",
"(",
"(",
"item",
")",
"=>",
"item",
".",
"name",
"===",
"this",
".",
"name",
")",
".",
"join",
"(",
")",
";",
"}"
] | Gets a mention of a channel
@returns {string} Mention
@param {string} name Name
@param {Guild} guild Guild | [
"Gets",
"a",
"mention",
"of",
"a",
"channel"
] | fdbc854fa2d64d0637e9d4797d916a7494d88f62 | https://github.com/TheDustyard/SimplerDiscord/blob/fdbc854fa2d64d0637e9d4797d916a7494d88f62/SimplerDiscord/index.js#L53-L55 |
|
52,321 | redisjs/jsr-server | lib/command/database/zset/zrange.js | validate | function validate(cmd, args, info) {
AbstractCommand.prototype.validate.apply(this, arguments);
var withscores;
if(args.length > 3) {
withscores = ('' + args[3]).toLowerCase();
if(withscores !== Constants.ZSET.WITHSCORES) {
throw CommandSyntax;
}
args[3] = withscores;
}
} | javascript | function validate(cmd, args, info) {
AbstractCommand.prototype.validate.apply(this, arguments);
var withscores;
if(args.length > 3) {
withscores = ('' + args[3]).toLowerCase();
if(withscores !== Constants.ZSET.WITHSCORES) {
throw CommandSyntax;
}
args[3] = withscores;
}
} | [
"function",
"validate",
"(",
"cmd",
",",
"args",
",",
"info",
")",
"{",
"AbstractCommand",
".",
"prototype",
".",
"validate",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"var",
"withscores",
";",
"if",
"(",
"args",
".",
"length",
">",
"3",
")",
"{",
"withscores",
"=",
"(",
"''",
"+",
"args",
"[",
"3",
"]",
")",
".",
"toLowerCase",
"(",
")",
";",
"if",
"(",
"withscores",
"!==",
"Constants",
".",
"ZSET",
".",
"WITHSCORES",
")",
"{",
"throw",
"CommandSyntax",
";",
"}",
"args",
"[",
"3",
"]",
"=",
"withscores",
";",
"}",
"}"
] | Validate the ZRANGE command. | [
"Validate",
"the",
"ZRANGE",
"command",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/database/zset/zrange.js#L19-L29 |
52,322 | mattaschmann/simple-menu | lib/simplemenu.js | _printItem | function _printItem (item) {
switch(item.type) {
case 'option':
console.log(item.index + ': ' + item.label);
break;
case 'break':
for (var breakString = ''; breakString.length < item.charCount;) {
breakString += item.character;
}
console.log(breakString);
break;
case 'text':
console.log(item.text);
break;
default:
console.error('Invalid item type: ' + item.type);
process.exit();
}
} | javascript | function _printItem (item) {
switch(item.type) {
case 'option':
console.log(item.index + ': ' + item.label);
break;
case 'break':
for (var breakString = ''; breakString.length < item.charCount;) {
breakString += item.character;
}
console.log(breakString);
break;
case 'text':
console.log(item.text);
break;
default:
console.error('Invalid item type: ' + item.type);
process.exit();
}
} | [
"function",
"_printItem",
"(",
"item",
")",
"{",
"switch",
"(",
"item",
".",
"type",
")",
"{",
"case",
"'option'",
":",
"console",
".",
"log",
"(",
"item",
".",
"index",
"+",
"': '",
"+",
"item",
".",
"label",
")",
";",
"break",
";",
"case",
"'break'",
":",
"for",
"(",
"var",
"breakString",
"=",
"''",
";",
"breakString",
".",
"length",
"<",
"item",
".",
"charCount",
";",
")",
"{",
"breakString",
"+=",
"item",
".",
"character",
";",
"}",
"console",
".",
"log",
"(",
"breakString",
")",
";",
"break",
";",
"case",
"'text'",
":",
"console",
".",
"log",
"(",
"item",
".",
"text",
")",
";",
"break",
";",
"default",
":",
"console",
".",
"error",
"(",
"'Invalid item type: '",
"+",
"item",
".",
"type",
")",
";",
"process",
".",
"exit",
"(",
")",
";",
"}",
"}"
] | Utility function to print out an item in the array.
@param {Object} item An item in the array. | [
"Utility",
"function",
"to",
"print",
"out",
"an",
"item",
"in",
"the",
"array",
"."
] | 8b93869fba5c2ffade6d33a97784201797a1e793 | https://github.com/mattaschmann/simple-menu/blob/8b93869fba5c2ffade6d33a97784201797a1e793/lib/simplemenu.js#L106-L125 |
52,323 | inviqa/deck-task-registry | src/assets/buildImages.js | buildImages | function buildImages(conf, undertaker) {
const imageMinConfig = {
progressive: true,
svgoPlugins: [{
removeViewBox: false
}, {
cleanupIDs: true
}, {
cleanupAttrs: true
}]
};
const imageSrc = path.join(conf.themeConfig.root, conf.themeConfig.images.src, '**', '*');
const imageDest = path.join(conf.themeConfig.root, conf.themeConfig.images.dest);
return undertaker.src(imageSrc)
.pipe(imagemin(imageMinConfig))
.pipe(undertaker.dest(imageDest));
} | javascript | function buildImages(conf, undertaker) {
const imageMinConfig = {
progressive: true,
svgoPlugins: [{
removeViewBox: false
}, {
cleanupIDs: true
}, {
cleanupAttrs: true
}]
};
const imageSrc = path.join(conf.themeConfig.root, conf.themeConfig.images.src, '**', '*');
const imageDest = path.join(conf.themeConfig.root, conf.themeConfig.images.dest);
return undertaker.src(imageSrc)
.pipe(imagemin(imageMinConfig))
.pipe(undertaker.dest(imageDest));
} | [
"function",
"buildImages",
"(",
"conf",
",",
"undertaker",
")",
"{",
"const",
"imageMinConfig",
"=",
"{",
"progressive",
":",
"true",
",",
"svgoPlugins",
":",
"[",
"{",
"removeViewBox",
":",
"false",
"}",
",",
"{",
"cleanupIDs",
":",
"true",
"}",
",",
"{",
"cleanupAttrs",
":",
"true",
"}",
"]",
"}",
";",
"const",
"imageSrc",
"=",
"path",
".",
"join",
"(",
"conf",
".",
"themeConfig",
".",
"root",
",",
"conf",
".",
"themeConfig",
".",
"images",
".",
"src",
",",
"'**'",
",",
"'*'",
")",
";",
"const",
"imageDest",
"=",
"path",
".",
"join",
"(",
"conf",
".",
"themeConfig",
".",
"root",
",",
"conf",
".",
"themeConfig",
".",
"images",
".",
"dest",
")",
";",
"return",
"undertaker",
".",
"src",
"(",
"imageSrc",
")",
".",
"pipe",
"(",
"imagemin",
"(",
"imageMinConfig",
")",
")",
".",
"pipe",
"(",
"undertaker",
".",
"dest",
"(",
"imageDest",
")",
")",
";",
"}"
] | Build project images.
@param {ConfigParser} conf A configuration parser object.
@param {Undertaker} undertaker An Undertaker instance.
@returns {Stream} A stream of files. | [
"Build",
"project",
"images",
"."
] | 4c31787b978e9d99a47052e090d4589a50cd3015 | https://github.com/inviqa/deck-task-registry/blob/4c31787b978e9d99a47052e090d4589a50cd3015/src/assets/buildImages.js#L14-L34 |
52,324 | gethuman/jyt | lib/jyt.runtime.js | render | function render(element, opts) {
opts = opts || {};
var prepend = opts.prepend;
var model = opts.model || {};
var indentLevel = opts.indentLevel || 0;
var isPretty = opts.isPretty;
var jtPrintIndent = isPretty ? '\t' : '';
var jtPrintNewline = isPretty ? '\n' : '';
var indent = '', i, len, prop;
var p = []; // p is going to be our concatenator for the HTML string
// if no element, then no HTML so return empty string
if (!element) { return ''; }
// if already a string, just return it
if (utils.isString(element)) { return element; }
// if an array, wrap it
if (utils.isArray(element)) { element = naked(element, null); }
// set the indentation level to the current indent
if (isPretty && indentLevel) {
for (i = 0; i < indentLevel; i++) {
indent += jtPrintIndent;
}
}
// if we are prepending some string, add it first
if (prepend) {
p.push(indent, prepend, jtPrintNewline);
}
// starting tag open
if (element.tag) {
p.push(indent, '<', element.tag);
}
// all tag attributes
if (element.attributes) {
for (prop in element.attributes) {
if (element.attributes.hasOwnProperty(prop)) {
if (element.attributes[prop] === null) {
p.push(' ', prop);
}
else {
p.push(' ', prop, '="', element.attributes[prop], '"');
}
}
}
}
// if no children or text, then close the tag
if (element.tag && !element.children && (element.text === undefined || element.text === null)) {
// for self closing we just close it, else we add the end tag
if (selfClosing.indexOf(element.tag) > -1) {
p.push('/>', jtPrintNewline);
}
else {
p.push('></', element.tag, '>', jtPrintNewline);
}
}
// else we need to add children or the inner text
else {
// if a tag (i.e. not just a string literal) put end bracket
if (element.tag) { p.push('>'); }
// if children, we will need to recurse
if (element.children) {
if (element.tag) { p.push(jtPrintNewline); }
// recurse down for each child
for (i = 0, len = element.children.length; i < len; ++i) {
p.push(render(element.children[i], {
indentLevel: element.tag ? indentLevel + 1 : indentLevel,
isPretty: isPretty,
model: model
}));
}
if (element.tag) { p.push(indent); }
}
// if text, simply add it
if (element.text !== null && element.text !== undefined) { p.push(element.text); }
// finally if a tag, add close tag
if (element.tag) {
p.push('</', element.tag, '>', jtPrintNewline);
}
}
return p.join('');
} | javascript | function render(element, opts) {
opts = opts || {};
var prepend = opts.prepend;
var model = opts.model || {};
var indentLevel = opts.indentLevel || 0;
var isPretty = opts.isPretty;
var jtPrintIndent = isPretty ? '\t' : '';
var jtPrintNewline = isPretty ? '\n' : '';
var indent = '', i, len, prop;
var p = []; // p is going to be our concatenator for the HTML string
// if no element, then no HTML so return empty string
if (!element) { return ''; }
// if already a string, just return it
if (utils.isString(element)) { return element; }
// if an array, wrap it
if (utils.isArray(element)) { element = naked(element, null); }
// set the indentation level to the current indent
if (isPretty && indentLevel) {
for (i = 0; i < indentLevel; i++) {
indent += jtPrintIndent;
}
}
// if we are prepending some string, add it first
if (prepend) {
p.push(indent, prepend, jtPrintNewline);
}
// starting tag open
if (element.tag) {
p.push(indent, '<', element.tag);
}
// all tag attributes
if (element.attributes) {
for (prop in element.attributes) {
if (element.attributes.hasOwnProperty(prop)) {
if (element.attributes[prop] === null) {
p.push(' ', prop);
}
else {
p.push(' ', prop, '="', element.attributes[prop], '"');
}
}
}
}
// if no children or text, then close the tag
if (element.tag && !element.children && (element.text === undefined || element.text === null)) {
// for self closing we just close it, else we add the end tag
if (selfClosing.indexOf(element.tag) > -1) {
p.push('/>', jtPrintNewline);
}
else {
p.push('></', element.tag, '>', jtPrintNewline);
}
}
// else we need to add children or the inner text
else {
// if a tag (i.e. not just a string literal) put end bracket
if (element.tag) { p.push('>'); }
// if children, we will need to recurse
if (element.children) {
if (element.tag) { p.push(jtPrintNewline); }
// recurse down for each child
for (i = 0, len = element.children.length; i < len; ++i) {
p.push(render(element.children[i], {
indentLevel: element.tag ? indentLevel + 1 : indentLevel,
isPretty: isPretty,
model: model
}));
}
if (element.tag) { p.push(indent); }
}
// if text, simply add it
if (element.text !== null && element.text !== undefined) { p.push(element.text); }
// finally if a tag, add close tag
if (element.tag) {
p.push('</', element.tag, '>', jtPrintNewline);
}
}
return p.join('');
} | [
"function",
"render",
"(",
"element",
",",
"opts",
")",
"{",
"opts",
"=",
"opts",
"||",
"{",
"}",
";",
"var",
"prepend",
"=",
"opts",
".",
"prepend",
";",
"var",
"model",
"=",
"opts",
".",
"model",
"||",
"{",
"}",
";",
"var",
"indentLevel",
"=",
"opts",
".",
"indentLevel",
"||",
"0",
";",
"var",
"isPretty",
"=",
"opts",
".",
"isPretty",
";",
"var",
"jtPrintIndent",
"=",
"isPretty",
"?",
"'\\t'",
":",
"''",
";",
"var",
"jtPrintNewline",
"=",
"isPretty",
"?",
"'\\n'",
":",
"''",
";",
"var",
"indent",
"=",
"''",
",",
"i",
",",
"len",
",",
"prop",
";",
"var",
"p",
"=",
"[",
"]",
";",
"// p is going to be our concatenator for the HTML string",
"// if no element, then no HTML so return empty string",
"if",
"(",
"!",
"element",
")",
"{",
"return",
"''",
";",
"}",
"// if already a string, just return it",
"if",
"(",
"utils",
".",
"isString",
"(",
"element",
")",
")",
"{",
"return",
"element",
";",
"}",
"// if an array, wrap it",
"if",
"(",
"utils",
".",
"isArray",
"(",
"element",
")",
")",
"{",
"element",
"=",
"naked",
"(",
"element",
",",
"null",
")",
";",
"}",
"// set the indentation level to the current indent",
"if",
"(",
"isPretty",
"&&",
"indentLevel",
")",
"{",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"indentLevel",
";",
"i",
"++",
")",
"{",
"indent",
"+=",
"jtPrintIndent",
";",
"}",
"}",
"// if we are prepending some string, add it first",
"if",
"(",
"prepend",
")",
"{",
"p",
".",
"push",
"(",
"indent",
",",
"prepend",
",",
"jtPrintNewline",
")",
";",
"}",
"// starting tag open",
"if",
"(",
"element",
".",
"tag",
")",
"{",
"p",
".",
"push",
"(",
"indent",
",",
"'<'",
",",
"element",
".",
"tag",
")",
";",
"}",
"// all tag attributes",
"if",
"(",
"element",
".",
"attributes",
")",
"{",
"for",
"(",
"prop",
"in",
"element",
".",
"attributes",
")",
"{",
"if",
"(",
"element",
".",
"attributes",
".",
"hasOwnProperty",
"(",
"prop",
")",
")",
"{",
"if",
"(",
"element",
".",
"attributes",
"[",
"prop",
"]",
"===",
"null",
")",
"{",
"p",
".",
"push",
"(",
"' '",
",",
"prop",
")",
";",
"}",
"else",
"{",
"p",
".",
"push",
"(",
"' '",
",",
"prop",
",",
"'=\"'",
",",
"element",
".",
"attributes",
"[",
"prop",
"]",
",",
"'\"'",
")",
";",
"}",
"}",
"}",
"}",
"// if no children or text, then close the tag",
"if",
"(",
"element",
".",
"tag",
"&&",
"!",
"element",
".",
"children",
"&&",
"(",
"element",
".",
"text",
"===",
"undefined",
"||",
"element",
".",
"text",
"===",
"null",
")",
")",
"{",
"// for self closing we just close it, else we add the end tag",
"if",
"(",
"selfClosing",
".",
"indexOf",
"(",
"element",
".",
"tag",
")",
">",
"-",
"1",
")",
"{",
"p",
".",
"push",
"(",
"'/>'",
",",
"jtPrintNewline",
")",
";",
"}",
"else",
"{",
"p",
".",
"push",
"(",
"'></'",
",",
"element",
".",
"tag",
",",
"'>'",
",",
"jtPrintNewline",
")",
";",
"}",
"}",
"// else we need to add children or the inner text",
"else",
"{",
"// if a tag (i.e. not just a string literal) put end bracket",
"if",
"(",
"element",
".",
"tag",
")",
"{",
"p",
".",
"push",
"(",
"'>'",
")",
";",
"}",
"// if children, we will need to recurse",
"if",
"(",
"element",
".",
"children",
")",
"{",
"if",
"(",
"element",
".",
"tag",
")",
"{",
"p",
".",
"push",
"(",
"jtPrintNewline",
")",
";",
"}",
"// recurse down for each child",
"for",
"(",
"i",
"=",
"0",
",",
"len",
"=",
"element",
".",
"children",
".",
"length",
";",
"i",
"<",
"len",
";",
"++",
"i",
")",
"{",
"p",
".",
"push",
"(",
"render",
"(",
"element",
".",
"children",
"[",
"i",
"]",
",",
"{",
"indentLevel",
":",
"element",
".",
"tag",
"?",
"indentLevel",
"+",
"1",
":",
"indentLevel",
",",
"isPretty",
":",
"isPretty",
",",
"model",
":",
"model",
"}",
")",
")",
";",
"}",
"if",
"(",
"element",
".",
"tag",
")",
"{",
"p",
".",
"push",
"(",
"indent",
")",
";",
"}",
"}",
"// if text, simply add it",
"if",
"(",
"element",
".",
"text",
"!==",
"null",
"&&",
"element",
".",
"text",
"!==",
"undefined",
")",
"{",
"p",
".",
"push",
"(",
"element",
".",
"text",
")",
";",
"}",
"// finally if a tag, add close tag",
"if",
"(",
"element",
".",
"tag",
")",
"{",
"p",
".",
"push",
"(",
"'</'",
",",
"element",
".",
"tag",
",",
"'>'",
",",
"jtPrintNewline",
")",
";",
"}",
"}",
"return",
"p",
".",
"join",
"(",
"''",
")",
";",
"}"
] | Take a jyt element and render it to an HTML string
@param element
@param opts | [
"Take",
"a",
"jyt",
"element",
"and",
"render",
"it",
"to",
"an",
"HTML",
"string"
] | 716be37e09217b4be917e179389f752212a428b3 | https://github.com/gethuman/jyt/blob/716be37e09217b4be917e179389f752212a428b3/lib/jyt.runtime.js#L27-L123 |
52,325 | gethuman/jyt | lib/jyt.runtime.js | addElemsToScope | function addElemsToScope(scope) {
var prop;
for (prop in elems) {
if (elems.hasOwnProperty(prop)) {
scope[prop] = elems[prop];
}
}
scope.elem = elem;
} | javascript | function addElemsToScope(scope) {
var prop;
for (prop in elems) {
if (elems.hasOwnProperty(prop)) {
scope[prop] = elems[prop];
}
}
scope.elem = elem;
} | [
"function",
"addElemsToScope",
"(",
"scope",
")",
"{",
"var",
"prop",
";",
"for",
"(",
"prop",
"in",
"elems",
")",
"{",
"if",
"(",
"elems",
".",
"hasOwnProperty",
"(",
"prop",
")",
")",
"{",
"scope",
"[",
"prop",
"]",
"=",
"elems",
"[",
"prop",
"]",
";",
"}",
"}",
"scope",
".",
"elem",
"=",
"elem",
";",
"}"
] | Add all elements to the given scope
@param scope | [
"Add",
"all",
"elements",
"to",
"the",
"given",
"scope"
] | 716be37e09217b4be917e179389f752212a428b3 | https://github.com/gethuman/jyt/blob/716be37e09217b4be917e179389f752212a428b3/lib/jyt.runtime.js#L191-L199 |
52,326 | gethuman/jyt | lib/jyt.runtime.js | registerComponents | function registerComponents(elemNames) {
if (!elemNames) { return; }
var elemNameDashCase, elemNameCamelCase;
for (var i = 0; i < elemNames.length; i++) {
elemNameDashCase = elemNames[i];
elemNameCamelCase = utils.dashToCamelCase(elemNameDashCase);
elems[elemNameCamelCase] = makeElem(elemNameDashCase);
}
} | javascript | function registerComponents(elemNames) {
if (!elemNames) { return; }
var elemNameDashCase, elemNameCamelCase;
for (var i = 0; i < elemNames.length; i++) {
elemNameDashCase = elemNames[i];
elemNameCamelCase = utils.dashToCamelCase(elemNameDashCase);
elems[elemNameCamelCase] = makeElem(elemNameDashCase);
}
} | [
"function",
"registerComponents",
"(",
"elemNames",
")",
"{",
"if",
"(",
"!",
"elemNames",
")",
"{",
"return",
";",
"}",
"var",
"elemNameDashCase",
",",
"elemNameCamelCase",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"elemNames",
".",
"length",
";",
"i",
"++",
")",
"{",
"elemNameDashCase",
"=",
"elemNames",
"[",
"i",
"]",
";",
"elemNameCamelCase",
"=",
"utils",
".",
"dashToCamelCase",
"(",
"elemNameDashCase",
")",
";",
"elems",
"[",
"elemNameCamelCase",
"]",
"=",
"makeElem",
"(",
"elemNameDashCase",
")",
";",
"}",
"}"
] | Given an array of element names, register the custom
elements so that a user can make them accessible
@param elemNames | [
"Given",
"an",
"array",
"of",
"element",
"names",
"register",
"the",
"custom",
"elements",
"so",
"that",
"a",
"user",
"can",
"make",
"them",
"accessible"
] | 716be37e09217b4be917e179389f752212a428b3 | https://github.com/gethuman/jyt/blob/716be37e09217b4be917e179389f752212a428b3/lib/jyt.runtime.js#L218-L227 |
52,327 | gethuman/jyt | lib/jyt.runtime.js | init | function init() {
var tagName;
for (var i = 0; i < allTags.length; i++) {
tagName = allTags[i];
elems[tagName] = makeElem(tagName);
}
} | javascript | function init() {
var tagName;
for (var i = 0; i < allTags.length; i++) {
tagName = allTags[i];
elems[tagName] = makeElem(tagName);
}
} | [
"function",
"init",
"(",
")",
"{",
"var",
"tagName",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"allTags",
".",
"length",
";",
"i",
"++",
")",
"{",
"tagName",
"=",
"allTags",
"[",
"i",
"]",
";",
"elems",
"[",
"tagName",
"]",
"=",
"makeElem",
"(",
"tagName",
")",
";",
"}",
"}"
] | Create functions for all standard HTML element | [
"Create",
"functions",
"for",
"all",
"standard",
"HTML",
"element"
] | 716be37e09217b4be917e179389f752212a428b3 | https://github.com/gethuman/jyt/blob/716be37e09217b4be917e179389f752212a428b3/lib/jyt.runtime.js#L232-L238 |
52,328 | staticbuild/staticbuild | index.js | getBundleMinIf | function getBundleMinIf(bundle, build, min) {
// Disable minification?
if (bundle.noMin)
return false;
// Glob filter paths to exlude and include files for minification.
// Start by excluding absolute paths of pre-minified files.
var minGlobs = lodash.map(min, function minAbsPath(relPath) {
return build.notPath(path.resolve(relPath));
});
if (minGlobs.length === 0) {
// Nothing to exclude, so include all files.
return true;
}
// Append a catch-all inclusion after all exclusions.
minGlobs.push('**/*');
return minGlobs;
} | javascript | function getBundleMinIf(bundle, build, min) {
// Disable minification?
if (bundle.noMin)
return false;
// Glob filter paths to exlude and include files for minification.
// Start by excluding absolute paths of pre-minified files.
var minGlobs = lodash.map(min, function minAbsPath(relPath) {
return build.notPath(path.resolve(relPath));
});
if (minGlobs.length === 0) {
// Nothing to exclude, so include all files.
return true;
}
// Append a catch-all inclusion after all exclusions.
minGlobs.push('**/*');
return minGlobs;
} | [
"function",
"getBundleMinIf",
"(",
"bundle",
",",
"build",
",",
"min",
")",
"{",
"// Disable minification?",
"if",
"(",
"bundle",
".",
"noMin",
")",
"return",
"false",
";",
"// Glob filter paths to exlude and include files for minification.",
"// Start by excluding absolute paths of pre-minified files.",
"var",
"minGlobs",
"=",
"lodash",
".",
"map",
"(",
"min",
",",
"function",
"minAbsPath",
"(",
"relPath",
")",
"{",
"return",
"build",
".",
"notPath",
"(",
"path",
".",
"resolve",
"(",
"relPath",
")",
")",
";",
"}",
")",
";",
"if",
"(",
"minGlobs",
".",
"length",
"===",
"0",
")",
"{",
"// Nothing to exclude, so include all files.",
"return",
"true",
";",
"}",
"// Append a catch-all inclusion after all exclusions.",
"minGlobs",
".",
"push",
"(",
"'**/*'",
")",
";",
"return",
"minGlobs",
";",
"}"
] | Returns a minIf value for a new bundle-info object.
@param {string} - Array of pre-minified source paths.
@returns {boolean|string} - The minIf value. | [
"Returns",
"a",
"minIf",
"value",
"for",
"a",
"new",
"bundle",
"-",
"info",
"object",
"."
] | 73891a9a719de46ba07c26a10ce36c43da34ff0e | https://github.com/staticbuild/staticbuild/blob/73891a9a719de46ba07c26a10ce36c43da34ff0e/index.js#L1485-L1501 |
52,329 | Nazariglez/perenquen | lib/pixi/src/core/sprites/Sprite.js | Sprite | function Sprite(texture)
{
Container.call(this);
/**
* The anchor sets the origin point of the texture.
* The default is 0,0 this means the texture's origin is the top left
* Setting the anchor to 0.5,0.5 means the texture's origin is centered
* Setting the anchor to 1,1 would mean the texture's origin point will be the bottom right corner
*
* @member {Point}
*/
this.anchor = new math.Point();
/**
* The texture that the sprite is using
*
* @member {Texture}
* @private
*/
this._texture = null;
/**
* The width of the sprite (this is initially set by the texture)
*
* @member {number}
* @private
*/
this._width = 0;
/**
* The height of the sprite (this is initially set by the texture)
*
* @member {number}
* @private
*/
this._height = 0;
/**
* The tint applied to the sprite. This is a hex value. A value of 0xFFFFFF will remove any tint effect.
*
* @member {number}
* @default [0xFFFFFF]
*/
this.tint = 0xFFFFFF;
/**
* The blend mode to be applied to the sprite. Apply a value of blendModes.NORMAL to reset the blend mode.
*
* @member {number}
* @default CONST.BLEND_MODES.NORMAL;
*/
this.blendMode = CONST.BLEND_MODES.NORMAL;
/**
* The shader that will be used to render the sprite. Set to null to remove a current shader.
*
* @member {AbstractFilter}
*/
this.shader = null;
/**
* An internal cached value of the tint.
*
* @member {number}
* @default [0xFFFFFF]
*/
this.cachedTint = 0xFFFFFF;
// call texture setter
this.texture = texture || Texture.EMPTY;
} | javascript | function Sprite(texture)
{
Container.call(this);
/**
* The anchor sets the origin point of the texture.
* The default is 0,0 this means the texture's origin is the top left
* Setting the anchor to 0.5,0.5 means the texture's origin is centered
* Setting the anchor to 1,1 would mean the texture's origin point will be the bottom right corner
*
* @member {Point}
*/
this.anchor = new math.Point();
/**
* The texture that the sprite is using
*
* @member {Texture}
* @private
*/
this._texture = null;
/**
* The width of the sprite (this is initially set by the texture)
*
* @member {number}
* @private
*/
this._width = 0;
/**
* The height of the sprite (this is initially set by the texture)
*
* @member {number}
* @private
*/
this._height = 0;
/**
* The tint applied to the sprite. This is a hex value. A value of 0xFFFFFF will remove any tint effect.
*
* @member {number}
* @default [0xFFFFFF]
*/
this.tint = 0xFFFFFF;
/**
* The blend mode to be applied to the sprite. Apply a value of blendModes.NORMAL to reset the blend mode.
*
* @member {number}
* @default CONST.BLEND_MODES.NORMAL;
*/
this.blendMode = CONST.BLEND_MODES.NORMAL;
/**
* The shader that will be used to render the sprite. Set to null to remove a current shader.
*
* @member {AbstractFilter}
*/
this.shader = null;
/**
* An internal cached value of the tint.
*
* @member {number}
* @default [0xFFFFFF]
*/
this.cachedTint = 0xFFFFFF;
// call texture setter
this.texture = texture || Texture.EMPTY;
} | [
"function",
"Sprite",
"(",
"texture",
")",
"{",
"Container",
".",
"call",
"(",
"this",
")",
";",
"/**\n * The anchor sets the origin point of the texture.\n * The default is 0,0 this means the texture's origin is the top left\n * Setting the anchor to 0.5,0.5 means the texture's origin is centered\n * Setting the anchor to 1,1 would mean the texture's origin point will be the bottom right corner\n *\n * @member {Point}\n */",
"this",
".",
"anchor",
"=",
"new",
"math",
".",
"Point",
"(",
")",
";",
"/**\n * The texture that the sprite is using\n *\n * @member {Texture}\n * @private\n */",
"this",
".",
"_texture",
"=",
"null",
";",
"/**\n * The width of the sprite (this is initially set by the texture)\n *\n * @member {number}\n * @private\n */",
"this",
".",
"_width",
"=",
"0",
";",
"/**\n * The height of the sprite (this is initially set by the texture)\n *\n * @member {number}\n * @private\n */",
"this",
".",
"_height",
"=",
"0",
";",
"/**\n * The tint applied to the sprite. This is a hex value. A value of 0xFFFFFF will remove any tint effect.\n *\n * @member {number}\n * @default [0xFFFFFF]\n */",
"this",
".",
"tint",
"=",
"0xFFFFFF",
";",
"/**\n * The blend mode to be applied to the sprite. Apply a value of blendModes.NORMAL to reset the blend mode.\n *\n * @member {number}\n * @default CONST.BLEND_MODES.NORMAL;\n */",
"this",
".",
"blendMode",
"=",
"CONST",
".",
"BLEND_MODES",
".",
"NORMAL",
";",
"/**\n * The shader that will be used to render the sprite. Set to null to remove a current shader.\n *\n * @member {AbstractFilter}\n */",
"this",
".",
"shader",
"=",
"null",
";",
"/**\n * An internal cached value of the tint.\n *\n * @member {number}\n * @default [0xFFFFFF]\n */",
"this",
".",
"cachedTint",
"=",
"0xFFFFFF",
";",
"// call texture setter",
"this",
".",
"texture",
"=",
"texture",
"||",
"Texture",
".",
"EMPTY",
";",
"}"
] | The Sprite object is the base for all textured objects that are rendered to the screen
A sprite can be created directly from an image like this:
```js
var sprite = new PIXI.Sprite.fromImage('assets/image.png');
```
@class
@extends Container
@memberof PIXI
@param texture {Texture} The texture for this sprite | [
"The",
"Sprite",
"object",
"is",
"the",
"base",
"for",
"all",
"textured",
"objects",
"that",
"are",
"rendered",
"to",
"the",
"screen"
] | e023964d05afeefebdcac4e2044819fdfa3899ae | https://github.com/Nazariglez/perenquen/blob/e023964d05afeefebdcac4e2044819fdfa3899ae/lib/pixi/src/core/sprites/Sprite.js#L23-L94 |
52,330 | bholloway/browserify-esprima-tools | index.js | processSync | function processSync(filename, content, updater, format) {
var text = String(content);
// parse code to AST using esprima
var ast = esprima.parse(text, {
loc : true,
comment: true,
source : filename
});
// sort nodes before changing the source-map
var sorted = orderNodes(ast);
// associate comments with nodes they annotate before changing the sort map
associateComments(ast, sorted);
// make sure the AST has the data from the original source map
var converter = convert.fromSource(text);
var originalMap = converter && converter.toObject();
var sourceContent = text;
if (originalMap) {
sourcemapToAst(ast, originalMap);
sourceContent = originalMap.sourcesContent[0];
}
// update the AST
var updated = ((typeof updater === 'function') && updater(filename, ast)) || ast;
// generate compressed code from the AST
var pair = codegen.generate(updated, {
sourceMap : true,
sourceMapWithCode: true,
format : format || {}
});
// ensure that the source-map has sourcesContent or browserify will not work
// source-map source files are posix so we have to slash them
var posixPath = filename.replace(/\\/g, '/');
pair.map.setSourceContent(posixPath, sourceContent);
// convert the map to base64 embedded comment
var mapComment = convert.fromJSON(pair.map.toString()).toComment();
// complete
return pair.code + mapComment;
} | javascript | function processSync(filename, content, updater, format) {
var text = String(content);
// parse code to AST using esprima
var ast = esprima.parse(text, {
loc : true,
comment: true,
source : filename
});
// sort nodes before changing the source-map
var sorted = orderNodes(ast);
// associate comments with nodes they annotate before changing the sort map
associateComments(ast, sorted);
// make sure the AST has the data from the original source map
var converter = convert.fromSource(text);
var originalMap = converter && converter.toObject();
var sourceContent = text;
if (originalMap) {
sourcemapToAst(ast, originalMap);
sourceContent = originalMap.sourcesContent[0];
}
// update the AST
var updated = ((typeof updater === 'function') && updater(filename, ast)) || ast;
// generate compressed code from the AST
var pair = codegen.generate(updated, {
sourceMap : true,
sourceMapWithCode: true,
format : format || {}
});
// ensure that the source-map has sourcesContent or browserify will not work
// source-map source files are posix so we have to slash them
var posixPath = filename.replace(/\\/g, '/');
pair.map.setSourceContent(posixPath, sourceContent);
// convert the map to base64 embedded comment
var mapComment = convert.fromJSON(pair.map.toString()).toComment();
// complete
return pair.code + mapComment;
} | [
"function",
"processSync",
"(",
"filename",
",",
"content",
",",
"updater",
",",
"format",
")",
"{",
"var",
"text",
"=",
"String",
"(",
"content",
")",
";",
"// parse code to AST using esprima",
"var",
"ast",
"=",
"esprima",
".",
"parse",
"(",
"text",
",",
"{",
"loc",
":",
"true",
",",
"comment",
":",
"true",
",",
"source",
":",
"filename",
"}",
")",
";",
"// sort nodes before changing the source-map",
"var",
"sorted",
"=",
"orderNodes",
"(",
"ast",
")",
";",
"// associate comments with nodes they annotate before changing the sort map",
"associateComments",
"(",
"ast",
",",
"sorted",
")",
";",
"// make sure the AST has the data from the original source map",
"var",
"converter",
"=",
"convert",
".",
"fromSource",
"(",
"text",
")",
";",
"var",
"originalMap",
"=",
"converter",
"&&",
"converter",
".",
"toObject",
"(",
")",
";",
"var",
"sourceContent",
"=",
"text",
";",
"if",
"(",
"originalMap",
")",
"{",
"sourcemapToAst",
"(",
"ast",
",",
"originalMap",
")",
";",
"sourceContent",
"=",
"originalMap",
".",
"sourcesContent",
"[",
"0",
"]",
";",
"}",
"// update the AST",
"var",
"updated",
"=",
"(",
"(",
"typeof",
"updater",
"===",
"'function'",
")",
"&&",
"updater",
"(",
"filename",
",",
"ast",
")",
")",
"||",
"ast",
";",
"// generate compressed code from the AST",
"var",
"pair",
"=",
"codegen",
".",
"generate",
"(",
"updated",
",",
"{",
"sourceMap",
":",
"true",
",",
"sourceMapWithCode",
":",
"true",
",",
"format",
":",
"format",
"||",
"{",
"}",
"}",
")",
";",
"// ensure that the source-map has sourcesContent or browserify will not work",
"// source-map source files are posix so we have to slash them",
"var",
"posixPath",
"=",
"filename",
".",
"replace",
"(",
"/",
"\\\\",
"/",
"g",
",",
"'/'",
")",
";",
"pair",
".",
"map",
".",
"setSourceContent",
"(",
"posixPath",
",",
"sourceContent",
")",
";",
"// convert the map to base64 embedded comment",
"var",
"mapComment",
"=",
"convert",
".",
"fromJSON",
"(",
"pair",
".",
"map",
".",
"toString",
"(",
")",
")",
".",
"toComment",
"(",
")",
";",
"// complete",
"return",
"pair",
".",
"code",
"+",
"mapComment",
";",
"}"
] | Synchronously process the given content and apply the updater function on its AST then output with the given format.
@throws {Error} Esprima parse error or updater error
@param {string} filename The name of the file that contains the given content
@param {*} content The text content to parse
@param {function} updater A function that works on the esprima AST
@param {object} [format] An optional format for escodegen
@returns {string} The transformed content with base64 source-map comment | [
"Synchronously",
"process",
"the",
"given",
"content",
"and",
"apply",
"the",
"updater",
"function",
"on",
"its",
"AST",
"then",
"output",
"with",
"the",
"given",
"format",
"."
] | a6f248ba3b486f6f7b1dbe27539dd139ede3df6a | https://github.com/bholloway/browserify-esprima-tools/blob/a6f248ba3b486f6f7b1dbe27539dd139ede3df6a/index.js#L82-L127 |
52,331 | bholloway/browserify-esprima-tools | index.js | depthFirst | function depthFirst(node, parent) {
var results = [];
if (node && (typeof node === 'object')) {
// valid node so push it to the list and set new parent
// don't overwrite parent if one was not given
if ('type' in node) {
if (parent !== undefined) {
node.parent = parent;
}
parent = node;
results.push(node);
}
// recurse object members using nested function call
for (var key in node) {
if (WHITE_LIST.test(key)) {
var value = node[key];
if (value && (typeof value === 'object')) {
results.push.apply(results, depthFirst(value, parent));
}
}
}
}
return results;
} | javascript | function depthFirst(node, parent) {
var results = [];
if (node && (typeof node === 'object')) {
// valid node so push it to the list and set new parent
// don't overwrite parent if one was not given
if ('type' in node) {
if (parent !== undefined) {
node.parent = parent;
}
parent = node;
results.push(node);
}
// recurse object members using nested function call
for (var key in node) {
if (WHITE_LIST.test(key)) {
var value = node[key];
if (value && (typeof value === 'object')) {
results.push.apply(results, depthFirst(value, parent));
}
}
}
}
return results;
} | [
"function",
"depthFirst",
"(",
"node",
",",
"parent",
")",
"{",
"var",
"results",
"=",
"[",
"]",
";",
"if",
"(",
"node",
"&&",
"(",
"typeof",
"node",
"===",
"'object'",
")",
")",
"{",
"// valid node so push it to the list and set new parent",
"// don't overwrite parent if one was not given",
"if",
"(",
"'type'",
"in",
"node",
")",
"{",
"if",
"(",
"parent",
"!==",
"undefined",
")",
"{",
"node",
".",
"parent",
"=",
"parent",
";",
"}",
"parent",
"=",
"node",
";",
"results",
".",
"push",
"(",
"node",
")",
";",
"}",
"// recurse object members using nested function call",
"for",
"(",
"var",
"key",
"in",
"node",
")",
"{",
"if",
"(",
"WHITE_LIST",
".",
"test",
"(",
"key",
")",
")",
"{",
"var",
"value",
"=",
"node",
"[",
"key",
"]",
";",
"if",
"(",
"value",
"&&",
"(",
"typeof",
"value",
"===",
"'object'",
")",
")",
"{",
"results",
".",
"push",
".",
"apply",
"(",
"results",
",",
"depthFirst",
"(",
"value",
",",
"parent",
")",
")",
";",
"}",
"}",
"}",
"}",
"return",
"results",
";",
"}"
] | List the given node and all children, depth first.
@param {object} node An esprima node
@param {object|undefined} [parent] The parent of the given node, where known
@returns {Array} A list of nodes | [
"List",
"the",
"given",
"node",
"and",
"all",
"children",
"depth",
"first",
"."
] | a6f248ba3b486f6f7b1dbe27539dd139ede3df6a | https://github.com/bholloway/browserify-esprima-tools/blob/a6f248ba3b486f6f7b1dbe27539dd139ede3df6a/index.js#L149-L174 |
52,332 | bholloway/browserify-esprima-tools | index.js | breadthFirst | function breadthFirst(node, parent) {
var results = [];
if (node && (typeof node === 'object')) {
// begin the queue with the given node
var queue = [{node:node, parent:parent}];
while (queue.length) {
// pull the next item from the front of the queue
var item = queue.shift();
node = item.node;
parent = item.parent;
// valid node so push it to the list and set new parent
// don't overwrite parent if one was not given
if ('type' in node) {
if (parent !== undefined) {
node.parent = parent;
}
parent = node;
results.push(node);
}
// recurse object members using the queue
for (var key in node) {
if (WHITE_LIST.test(key)) {
var value = node[key];
if (value && (typeof value === 'object')) {
queue.push({
node : value,
parent: parent
});
}
}
}
}
}
return results;
} | javascript | function breadthFirst(node, parent) {
var results = [];
if (node && (typeof node === 'object')) {
// begin the queue with the given node
var queue = [{node:node, parent:parent}];
while (queue.length) {
// pull the next item from the front of the queue
var item = queue.shift();
node = item.node;
parent = item.parent;
// valid node so push it to the list and set new parent
// don't overwrite parent if one was not given
if ('type' in node) {
if (parent !== undefined) {
node.parent = parent;
}
parent = node;
results.push(node);
}
// recurse object members using the queue
for (var key in node) {
if (WHITE_LIST.test(key)) {
var value = node[key];
if (value && (typeof value === 'object')) {
queue.push({
node : value,
parent: parent
});
}
}
}
}
}
return results;
} | [
"function",
"breadthFirst",
"(",
"node",
",",
"parent",
")",
"{",
"var",
"results",
"=",
"[",
"]",
";",
"if",
"(",
"node",
"&&",
"(",
"typeof",
"node",
"===",
"'object'",
")",
")",
"{",
"// begin the queue with the given node",
"var",
"queue",
"=",
"[",
"{",
"node",
":",
"node",
",",
"parent",
":",
"parent",
"}",
"]",
";",
"while",
"(",
"queue",
".",
"length",
")",
"{",
"// pull the next item from the front of the queue",
"var",
"item",
"=",
"queue",
".",
"shift",
"(",
")",
";",
"node",
"=",
"item",
".",
"node",
";",
"parent",
"=",
"item",
".",
"parent",
";",
"// valid node so push it to the list and set new parent",
"// don't overwrite parent if one was not given",
"if",
"(",
"'type'",
"in",
"node",
")",
"{",
"if",
"(",
"parent",
"!==",
"undefined",
")",
"{",
"node",
".",
"parent",
"=",
"parent",
";",
"}",
"parent",
"=",
"node",
";",
"results",
".",
"push",
"(",
"node",
")",
";",
"}",
"// recurse object members using the queue",
"for",
"(",
"var",
"key",
"in",
"node",
")",
"{",
"if",
"(",
"WHITE_LIST",
".",
"test",
"(",
"key",
")",
")",
"{",
"var",
"value",
"=",
"node",
"[",
"key",
"]",
";",
"if",
"(",
"value",
"&&",
"(",
"typeof",
"value",
"===",
"'object'",
")",
")",
"{",
"queue",
".",
"push",
"(",
"{",
"node",
":",
"value",
",",
"parent",
":",
"parent",
"}",
")",
";",
"}",
"}",
"}",
"}",
"}",
"return",
"results",
";",
"}"
] | List the given node and all children, breadth first.
@param {object} node An esprima node
@param {object|undefined} [parent] The parent of the given node, where known
@returns {Array} A list of nodes | [
"List",
"the",
"given",
"node",
"and",
"all",
"children",
"breadth",
"first",
"."
] | a6f248ba3b486f6f7b1dbe27539dd139ede3df6a | https://github.com/bholloway/browserify-esprima-tools/blob/a6f248ba3b486f6f7b1dbe27539dd139ede3df6a/index.js#L182-L220 |
52,333 | bholloway/browserify-esprima-tools | index.js | nodeSplicer | function nodeSplicer(candidate, offset) {
offset = offset || 0;
return function setter(value) {
var found = findReferrer(candidate);
if (found) {
var key = found.key;
var obj = found.object;
var array = Array.isArray(obj) && obj;
if (!array) {
obj[key] = value;
}
else if (typeof key !== 'number') {
throw new Error('A numerical key is required to splice an array');
}
else {
if (typeof offset === 'function') {
offset = offset(array, candidate, value);
}
var index = Math.max(0, Math.min(array.length, key + offset + Number(offset < 0)));
var remove = Number(offset === 0);
array.splice(index, remove, value);
}
}
};
} | javascript | function nodeSplicer(candidate, offset) {
offset = offset || 0;
return function setter(value) {
var found = findReferrer(candidate);
if (found) {
var key = found.key;
var obj = found.object;
var array = Array.isArray(obj) && obj;
if (!array) {
obj[key] = value;
}
else if (typeof key !== 'number') {
throw new Error('A numerical key is required to splice an array');
}
else {
if (typeof offset === 'function') {
offset = offset(array, candidate, value);
}
var index = Math.max(0, Math.min(array.length, key + offset + Number(offset < 0)));
var remove = Number(offset === 0);
array.splice(index, remove, value);
}
}
};
} | [
"function",
"nodeSplicer",
"(",
"candidate",
",",
"offset",
")",
"{",
"offset",
"=",
"offset",
"||",
"0",
";",
"return",
"function",
"setter",
"(",
"value",
")",
"{",
"var",
"found",
"=",
"findReferrer",
"(",
"candidate",
")",
";",
"if",
"(",
"found",
")",
"{",
"var",
"key",
"=",
"found",
".",
"key",
";",
"var",
"obj",
"=",
"found",
".",
"object",
";",
"var",
"array",
"=",
"Array",
".",
"isArray",
"(",
"obj",
")",
"&&",
"obj",
";",
"if",
"(",
"!",
"array",
")",
"{",
"obj",
"[",
"key",
"]",
"=",
"value",
";",
"}",
"else",
"if",
"(",
"typeof",
"key",
"!==",
"'number'",
")",
"{",
"throw",
"new",
"Error",
"(",
"'A numerical key is required to splice an array'",
")",
";",
"}",
"else",
"{",
"if",
"(",
"typeof",
"offset",
"===",
"'function'",
")",
"{",
"offset",
"=",
"offset",
"(",
"array",
",",
"candidate",
",",
"value",
")",
";",
"}",
"var",
"index",
"=",
"Math",
".",
"max",
"(",
"0",
",",
"Math",
".",
"min",
"(",
"array",
".",
"length",
",",
"key",
"+",
"offset",
"+",
"Number",
"(",
"offset",
"<",
"0",
")",
")",
")",
";",
"var",
"remove",
"=",
"Number",
"(",
"offset",
"===",
"0",
")",
";",
"array",
".",
"splice",
"(",
"index",
",",
"remove",
",",
"value",
")",
";",
"}",
"}",
"}",
";",
"}"
] | Create a setter that will replace the given node or insert relative to it.
@param {object} candidate An esprima AST node to match
@param {number|function} [offset] 0 to replace, -1 to insert before node, +1 to insert after node
@returns {function|null} A setter that will replace the given node or do nothing if not valid | [
"Create",
"a",
"setter",
"that",
"will",
"replace",
"the",
"given",
"node",
"or",
"insert",
"relative",
"to",
"it",
"."
] | a6f248ba3b486f6f7b1dbe27539dd139ede3df6a | https://github.com/bholloway/browserify-esprima-tools/blob/a6f248ba3b486f6f7b1dbe27539dd139ede3df6a/index.js#L228-L252 |
52,334 | bholloway/browserify-esprima-tools | index.js | compareLocation | function compareLocation(nodeA, nodeB) {
var locA = nodeA && nodeA.loc;
var locB = nodeB && nodeB.loc;
if (!locA && !locB) {
return 0;
}
else if (Boolean(locA) !== Boolean(locB)) {
return locA ? +1 : locB ? -1 : 0;
}
else {
var result =
isOrdered(locB.end, locA.start) ? +1 : isOrdered(locA.end, locB.start) ? -1 : // non-overlapping
isOrdered(locB.start, locA.start) ? +1 : isOrdered(locA.start, locB.start) ? -1 : // overlapping
isOrdered(locA.end, locB.end ) ? +1 : isOrdered(locB.end, locA.end ) ? -1 : // enclosed
0;
return result;
}
} | javascript | function compareLocation(nodeA, nodeB) {
var locA = nodeA && nodeA.loc;
var locB = nodeB && nodeB.loc;
if (!locA && !locB) {
return 0;
}
else if (Boolean(locA) !== Boolean(locB)) {
return locA ? +1 : locB ? -1 : 0;
}
else {
var result =
isOrdered(locB.end, locA.start) ? +1 : isOrdered(locA.end, locB.start) ? -1 : // non-overlapping
isOrdered(locB.start, locA.start) ? +1 : isOrdered(locA.start, locB.start) ? -1 : // overlapping
isOrdered(locA.end, locB.end ) ? +1 : isOrdered(locB.end, locA.end ) ? -1 : // enclosed
0;
return result;
}
} | [
"function",
"compareLocation",
"(",
"nodeA",
",",
"nodeB",
")",
"{",
"var",
"locA",
"=",
"nodeA",
"&&",
"nodeA",
".",
"loc",
";",
"var",
"locB",
"=",
"nodeB",
"&&",
"nodeB",
".",
"loc",
";",
"if",
"(",
"!",
"locA",
"&&",
"!",
"locB",
")",
"{",
"return",
"0",
";",
"}",
"else",
"if",
"(",
"Boolean",
"(",
"locA",
")",
"!==",
"Boolean",
"(",
"locB",
")",
")",
"{",
"return",
"locA",
"?",
"+",
"1",
":",
"locB",
"?",
"-",
"1",
":",
"0",
";",
"}",
"else",
"{",
"var",
"result",
"=",
"isOrdered",
"(",
"locB",
".",
"end",
",",
"locA",
".",
"start",
")",
"?",
"+",
"1",
":",
"isOrdered",
"(",
"locA",
".",
"end",
",",
"locB",
".",
"start",
")",
"?",
"-",
"1",
":",
"// non-overlapping",
"isOrdered",
"(",
"locB",
".",
"start",
",",
"locA",
".",
"start",
")",
"?",
"+",
"1",
":",
"isOrdered",
"(",
"locA",
".",
"start",
",",
"locB",
".",
"start",
")",
"?",
"-",
"1",
":",
"// overlapping",
"isOrdered",
"(",
"locA",
".",
"end",
",",
"locB",
".",
"end",
")",
"?",
"+",
"1",
":",
"isOrdered",
"(",
"locB",
".",
"end",
",",
"locA",
".",
"end",
")",
"?",
"-",
"1",
":",
"// enclosed",
"0",
";",
"return",
"result",
";",
"}",
"}"
] | Compare function for nodes with location.
@param {object} nodeA First node
@param {object} nodeB Second node
@returns {number} -1 where a follows b, +1 where b follows a, 0 otherwise | [
"Compare",
"function",
"for",
"nodes",
"with",
"location",
"."
] | a6f248ba3b486f6f7b1dbe27539dd139ede3df6a | https://github.com/bholloway/browserify-esprima-tools/blob/a6f248ba3b486f6f7b1dbe27539dd139ede3df6a/index.js#L289-L306 |
52,335 | bholloway/browserify-esprima-tools | index.js | isOrdered | function isOrdered(tupleA, tupleB) {
return (tupleA.line < tupleB.line) || ((tupleA.line === tupleB.line) && (tupleA.column < tupleB.column));
} | javascript | function isOrdered(tupleA, tupleB) {
return (tupleA.line < tupleB.line) || ((tupleA.line === tupleB.line) && (tupleA.column < tupleB.column));
} | [
"function",
"isOrdered",
"(",
"tupleA",
",",
"tupleB",
")",
"{",
"return",
"(",
"tupleA",
".",
"line",
"<",
"tupleB",
".",
"line",
")",
"||",
"(",
"(",
"tupleA",
".",
"line",
"===",
"tupleB",
".",
"line",
")",
"&&",
"(",
"tupleA",
".",
"column",
"<",
"tupleB",
".",
"column",
")",
")",
";",
"}"
] | Check the order of the given location tuples.
@param {{line:number, column:number}} tupleA The first tuple
@param {{line:number, column:number}} tupleB The second tuple
@returns {boolean} True where tupleA precedes tupleB | [
"Check",
"the",
"order",
"of",
"the",
"given",
"location",
"tuples",
"."
] | a6f248ba3b486f6f7b1dbe27539dd139ede3df6a | https://github.com/bholloway/browserify-esprima-tools/blob/a6f248ba3b486f6f7b1dbe27539dd139ede3df6a/index.js#L314-L316 |
52,336 | bholloway/browserify-esprima-tools | index.js | compareIndex | function compareIndex(nodeA, nodeB) {
var indexA = nodeA && nodeA.sortIndex;
var indexB = nodeB && nodeB.sortIndex;
if (!indexA && !indexB) {
return 0;
}
else if (Boolean(indexA) !== Boolean(indexB)) {
return indexA ? +1 : indexB ? -1 : 0;
}
else {
return indexA - indexB;
}
} | javascript | function compareIndex(nodeA, nodeB) {
var indexA = nodeA && nodeA.sortIndex;
var indexB = nodeB && nodeB.sortIndex;
if (!indexA && !indexB) {
return 0;
}
else if (Boolean(indexA) !== Boolean(indexB)) {
return indexA ? +1 : indexB ? -1 : 0;
}
else {
return indexA - indexB;
}
} | [
"function",
"compareIndex",
"(",
"nodeA",
",",
"nodeB",
")",
"{",
"var",
"indexA",
"=",
"nodeA",
"&&",
"nodeA",
".",
"sortIndex",
";",
"var",
"indexB",
"=",
"nodeB",
"&&",
"nodeB",
".",
"sortIndex",
";",
"if",
"(",
"!",
"indexA",
"&&",
"!",
"indexB",
")",
"{",
"return",
"0",
";",
"}",
"else",
"if",
"(",
"Boolean",
"(",
"indexA",
")",
"!==",
"Boolean",
"(",
"indexB",
")",
")",
"{",
"return",
"indexA",
"?",
"+",
"1",
":",
"indexB",
"?",
"-",
"1",
":",
"0",
";",
"}",
"else",
"{",
"return",
"indexA",
"-",
"indexB",
";",
"}",
"}"
] | Compare function for nodes with sort-index.
@param {object} nodeA First node
@param {object} nodeB Second node
@returns {number} -1 where a follows b, +1 where b follows a, 0 otherwise | [
"Compare",
"function",
"for",
"nodes",
"with",
"sort",
"-",
"index",
"."
] | a6f248ba3b486f6f7b1dbe27539dd139ede3df6a | https://github.com/bholloway/browserify-esprima-tools/blob/a6f248ba3b486f6f7b1dbe27539dd139ede3df6a/index.js#L324-L336 |
52,337 | bholloway/browserify-esprima-tools | index.js | findReferrer | function findReferrer(candidate, container) {
var result;
if (candidate) {
// initially for the parent of the candidate node
container = container || candidate.parent;
// consider keys in the node until we have a result
var keys = getKeys(container);
for (var i = 0; !result && (i < keys.length); i++) {
var key = keys[i];
if (WHITE_LIST.test(key)) {
var value = container[key];
// found
if (value === candidate) {
result = {
object: container,
key : key
};
}
// recurse
else if (value && (typeof value === 'object')) {
result = findReferrer(candidate, value);
}
}
}
}
// complete
return result;
} | javascript | function findReferrer(candidate, container) {
var result;
if (candidate) {
// initially for the parent of the candidate node
container = container || candidate.parent;
// consider keys in the node until we have a result
var keys = getKeys(container);
for (var i = 0; !result && (i < keys.length); i++) {
var key = keys[i];
if (WHITE_LIST.test(key)) {
var value = container[key];
// found
if (value === candidate) {
result = {
object: container,
key : key
};
}
// recurse
else if (value && (typeof value === 'object')) {
result = findReferrer(candidate, value);
}
}
}
}
// complete
return result;
} | [
"function",
"findReferrer",
"(",
"candidate",
",",
"container",
")",
"{",
"var",
"result",
";",
"if",
"(",
"candidate",
")",
"{",
"// initially for the parent of the candidate node",
"container",
"=",
"container",
"||",
"candidate",
".",
"parent",
";",
"// consider keys in the node until we have a result",
"var",
"keys",
"=",
"getKeys",
"(",
"container",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"!",
"result",
"&&",
"(",
"i",
"<",
"keys",
".",
"length",
")",
";",
"i",
"++",
")",
"{",
"var",
"key",
"=",
"keys",
"[",
"i",
"]",
";",
"if",
"(",
"WHITE_LIST",
".",
"test",
"(",
"key",
")",
")",
"{",
"var",
"value",
"=",
"container",
"[",
"key",
"]",
";",
"// found",
"if",
"(",
"value",
"===",
"candidate",
")",
"{",
"result",
"=",
"{",
"object",
":",
"container",
",",
"key",
":",
"key",
"}",
";",
"}",
"// recurse",
"else",
"if",
"(",
"value",
"&&",
"(",
"typeof",
"value",
"===",
"'object'",
")",
")",
"{",
"result",
"=",
"findReferrer",
"(",
"candidate",
",",
"value",
")",
";",
"}",
"}",
"}",
"}",
"// complete",
"return",
"result",
";",
"}"
] | Find the object and field that refers to the given node.
@param {object} candidate An esprima AST node to match
@param {object} [container] Optional container to search within or the candidate parent where omitted
@returns {{object:object, key:*}} The object and its key where the candidate node is a value | [
"Find",
"the",
"object",
"and",
"field",
"that",
"refers",
"to",
"the",
"given",
"node",
"."
] | a6f248ba3b486f6f7b1dbe27539dd139ede3df6a | https://github.com/bholloway/browserify-esprima-tools/blob/a6f248ba3b486f6f7b1dbe27539dd139ede3df6a/index.js#L357-L388 |
52,338 | bholloway/browserify-esprima-tools | index.js | getKeys | function getKeys(container) {
function arrayIndex(value, i) {
return i;
}
if (typeof container === 'object') {
return Array.isArray(container) ? container.map(arrayIndex) : Object.keys(container);
} else {
return [];
}
} | javascript | function getKeys(container) {
function arrayIndex(value, i) {
return i;
}
if (typeof container === 'object') {
return Array.isArray(container) ? container.map(arrayIndex) : Object.keys(container);
} else {
return [];
}
} | [
"function",
"getKeys",
"(",
"container",
")",
"{",
"function",
"arrayIndex",
"(",
"value",
",",
"i",
")",
"{",
"return",
"i",
";",
"}",
"if",
"(",
"typeof",
"container",
"===",
"'object'",
")",
"{",
"return",
"Array",
".",
"isArray",
"(",
"container",
")",
"?",
"container",
".",
"map",
"(",
"arrayIndex",
")",
":",
"Object",
".",
"keys",
"(",
"container",
")",
";",
"}",
"else",
"{",
"return",
"[",
"]",
";",
"}",
"}"
] | Get the keys of an object as strings or those of an array as integers.
@param {object|Array} container A hash or array
@returns {Array.<string|number>} The keys of the container | [
"Get",
"the",
"keys",
"of",
"an",
"object",
"as",
"strings",
"or",
"those",
"of",
"an",
"array",
"as",
"integers",
"."
] | a6f248ba3b486f6f7b1dbe27539dd139ede3df6a | https://github.com/bholloway/browserify-esprima-tools/blob/a6f248ba3b486f6f7b1dbe27539dd139ede3df6a/index.js#L395-L404 |
52,339 | andrevinsky/redux-actions-sequences | src/index.js | tagResultFunction | function tagResultFunction(fn, tokenDescription, replacement) {
const description = tag(fn);
if (description) {
tokenDescription = description.replace(tokenDescription, replacement);
}
tag(fn, tokenDescription);
fn.toString = tokenToString;
return fn;
} | javascript | function tagResultFunction(fn, tokenDescription, replacement) {
const description = tag(fn);
if (description) {
tokenDescription = description.replace(tokenDescription, replacement);
}
tag(fn, tokenDescription);
fn.toString = tokenToString;
return fn;
} | [
"function",
"tagResultFunction",
"(",
"fn",
",",
"tokenDescription",
",",
"replacement",
")",
"{",
"const",
"description",
"=",
"tag",
"(",
"fn",
")",
";",
"if",
"(",
"description",
")",
"{",
"tokenDescription",
"=",
"description",
".",
"replace",
"(",
"tokenDescription",
",",
"replacement",
")",
";",
"}",
"tag",
"(",
"fn",
",",
"tokenDescription",
")",
";",
"fn",
".",
"toString",
"=",
"tokenToString",
";",
"return",
"fn",
";",
"}"
] | Internal utility function that wraps result function
@param fn
@param tokenDescription
@param replacement
@returns {*} | [
"Internal",
"utility",
"function",
"that",
"wraps",
"result",
"function"
] | 1357fce58c674c106d4d850f3fa0bca9c2359c6b | https://github.com/andrevinsky/redux-actions-sequences/blob/1357fce58c674c106d4d850f3fa0bca9c2359c6b/src/index.js#L106-L116 |
52,340 | inviqa/deck-task-registry | src/helpers/findRoot.js | findRoot | function findRoot() {
let rootPath;
try {
rootPath = glob.sync('../**/Drupal.php', {ignore: ['../vendor/**', '../node_modules/**']});
} catch (err) {
throw new Error('No Drupal root found.');
}
// If we found no results for Drupal.php..then bomb out.
if (rootPath.length === 0) {
throw new Error('No Drupal root found.');
}
// Glob returns an array, even though we've only got one item.
rootPath = rootPath[0];
const filePathParts = rootPath.split(path.sep);
const coreDirPosition = filePathParts.indexOf('core');
// If we found a Drupal.php file, but no core directory..then bomb out.
if (coreDirPosition === -1) {
throw new Error('No Drupal root found.');
}
return filePathParts.slice(0, coreDirPosition).join(path.sep);
} | javascript | function findRoot() {
let rootPath;
try {
rootPath = glob.sync('../**/Drupal.php', {ignore: ['../vendor/**', '../node_modules/**']});
} catch (err) {
throw new Error('No Drupal root found.');
}
// If we found no results for Drupal.php..then bomb out.
if (rootPath.length === 0) {
throw new Error('No Drupal root found.');
}
// Glob returns an array, even though we've only got one item.
rootPath = rootPath[0];
const filePathParts = rootPath.split(path.sep);
const coreDirPosition = filePathParts.indexOf('core');
// If we found a Drupal.php file, but no core directory..then bomb out.
if (coreDirPosition === -1) {
throw new Error('No Drupal root found.');
}
return filePathParts.slice(0, coreDirPosition).join(path.sep);
} | [
"function",
"findRoot",
"(",
")",
"{",
"let",
"rootPath",
";",
"try",
"{",
"rootPath",
"=",
"glob",
".",
"sync",
"(",
"'../**/Drupal.php'",
",",
"{",
"ignore",
":",
"[",
"'../vendor/**'",
",",
"'../node_modules/**'",
"]",
"}",
")",
";",
"}",
"catch",
"(",
"err",
")",
"{",
"throw",
"new",
"Error",
"(",
"'No Drupal root found.'",
")",
";",
"}",
"// If we found no results for Drupal.php..then bomb out.",
"if",
"(",
"rootPath",
".",
"length",
"===",
"0",
")",
"{",
"throw",
"new",
"Error",
"(",
"'No Drupal root found.'",
")",
";",
"}",
"// Glob returns an array, even though we've only got one item.",
"rootPath",
"=",
"rootPath",
"[",
"0",
"]",
";",
"const",
"filePathParts",
"=",
"rootPath",
".",
"split",
"(",
"path",
".",
"sep",
")",
";",
"const",
"coreDirPosition",
"=",
"filePathParts",
".",
"indexOf",
"(",
"'core'",
")",
";",
"// If we found a Drupal.php file, but no core directory..then bomb out.",
"if",
"(",
"coreDirPosition",
"===",
"-",
"1",
")",
"{",
"throw",
"new",
"Error",
"(",
"'No Drupal root found.'",
")",
";",
"}",
"return",
"filePathParts",
".",
"slice",
"(",
"0",
",",
"coreDirPosition",
")",
".",
"join",
"(",
"path",
".",
"sep",
")",
";",
"}"
] | Find the root of a Drupal project.
@throws {Error} Thrown if no Drupal root was found.
@returns {String} The root to the Drupal installation from tools root. | [
"Find",
"the",
"root",
"of",
"a",
"Drupal",
"project",
"."
] | 4c31787b978e9d99a47052e090d4589a50cd3015 | https://github.com/inviqa/deck-task-registry/blob/4c31787b978e9d99a47052e090d4589a50cd3015/src/helpers/findRoot.js#L13-L41 |
52,341 | LeoYehTW/data-service | public/js/xeditable.js | function(name) {
var i;
if (this.$editables.length) {
//activate by name
if (angular.isString(name)) {
for(i=0; i<this.$editables.length; i++) {
if (this.$editables[i].name === name) {
this.$editables[i].activate();
return;
}
}
}
//try activate error field
for(i=0; i<this.$editables.length; i++) {
if (this.$editables[i].error) {
this.$editables[i].activate();
return;
}
}
//by default activate first field
this.$editables[0].activate();
}
} | javascript | function(name) {
var i;
if (this.$editables.length) {
//activate by name
if (angular.isString(name)) {
for(i=0; i<this.$editables.length; i++) {
if (this.$editables[i].name === name) {
this.$editables[i].activate();
return;
}
}
}
//try activate error field
for(i=0; i<this.$editables.length; i++) {
if (this.$editables[i].error) {
this.$editables[i].activate();
return;
}
}
//by default activate first field
this.$editables[0].activate();
}
} | [
"function",
"(",
"name",
")",
"{",
"var",
"i",
";",
"if",
"(",
"this",
".",
"$editables",
".",
"length",
")",
"{",
"//activate by name",
"if",
"(",
"angular",
".",
"isString",
"(",
"name",
")",
")",
"{",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"$editables",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"this",
".",
"$editables",
"[",
"i",
"]",
".",
"name",
"===",
"name",
")",
"{",
"this",
".",
"$editables",
"[",
"i",
"]",
".",
"activate",
"(",
")",
";",
"return",
";",
"}",
"}",
"}",
"//try activate error field",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"$editables",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"this",
".",
"$editables",
"[",
"i",
"]",
".",
"error",
")",
"{",
"this",
".",
"$editables",
"[",
"i",
"]",
".",
"activate",
"(",
")",
";",
"return",
";",
"}",
"}",
"//by default activate first field",
"this",
".",
"$editables",
"[",
"0",
"]",
".",
"activate",
"(",
")",
";",
"}",
"}"
] | Sets focus on form field specified by `name`.
@method $activate(name)
@param {string} name name of field
@memberOf editable-form | [
"Sets",
"focus",
"on",
"form",
"field",
"specified",
"by",
"name",
"."
] | b55871663c2aacf2e3bd61c397987fa5bbedbc8d | https://github.com/LeoYehTW/data-service/blob/b55871663c2aacf2e3bd61c397987fa5bbedbc8d/public/js/xeditable.js#L974-L998 |
|
52,342 | gethuman/pancakes-recipe | middleware/mw.auth.token.js | getUserForToken | function getUserForToken(decodedToken) {
var userId = decodedToken._id;
var authToken = decodedToken.authToken;
var cacheKey = userId + authToken;
var conditions = {
caller: userService.admin,
where: { _id: userId, authToken: authToken, status: 'created' },
findOne: true
};
var cachedUser;
// if no user id or authToken, then no user
if (!userId || !authToken) { return null; }
// try to get user from cache, then DB
return userCacheService.get({ key: cacheKey })
.then(function (user) {
cachedUser = user;
return user ? user : userService.find(conditions);
})
.then(function (user) {
// if user found in database, but not in cache, save in cache
if (user && !cachedUser) {
userCacheService.set({ key: cacheKey, value: user });
}
// return the user
return user;
});
} | javascript | function getUserForToken(decodedToken) {
var userId = decodedToken._id;
var authToken = decodedToken.authToken;
var cacheKey = userId + authToken;
var conditions = {
caller: userService.admin,
where: { _id: userId, authToken: authToken, status: 'created' },
findOne: true
};
var cachedUser;
// if no user id or authToken, then no user
if (!userId || !authToken) { return null; }
// try to get user from cache, then DB
return userCacheService.get({ key: cacheKey })
.then(function (user) {
cachedUser = user;
return user ? user : userService.find(conditions);
})
.then(function (user) {
// if user found in database, but not in cache, save in cache
if (user && !cachedUser) {
userCacheService.set({ key: cacheKey, value: user });
}
// return the user
return user;
});
} | [
"function",
"getUserForToken",
"(",
"decodedToken",
")",
"{",
"var",
"userId",
"=",
"decodedToken",
".",
"_id",
";",
"var",
"authToken",
"=",
"decodedToken",
".",
"authToken",
";",
"var",
"cacheKey",
"=",
"userId",
"+",
"authToken",
";",
"var",
"conditions",
"=",
"{",
"caller",
":",
"userService",
".",
"admin",
",",
"where",
":",
"{",
"_id",
":",
"userId",
",",
"authToken",
":",
"authToken",
",",
"status",
":",
"'created'",
"}",
",",
"findOne",
":",
"true",
"}",
";",
"var",
"cachedUser",
";",
"// if no user id or authToken, then no user",
"if",
"(",
"!",
"userId",
"||",
"!",
"authToken",
")",
"{",
"return",
"null",
";",
"}",
"// try to get user from cache, then DB",
"return",
"userCacheService",
".",
"get",
"(",
"{",
"key",
":",
"cacheKey",
"}",
")",
".",
"then",
"(",
"function",
"(",
"user",
")",
"{",
"cachedUser",
"=",
"user",
";",
"return",
"user",
"?",
"user",
":",
"userService",
".",
"find",
"(",
"conditions",
")",
";",
"}",
")",
".",
"then",
"(",
"function",
"(",
"user",
")",
"{",
"// if user found in database, but not in cache, save in cache",
"if",
"(",
"user",
"&&",
"!",
"cachedUser",
")",
"{",
"userCacheService",
".",
"set",
"(",
"{",
"key",
":",
"cacheKey",
",",
"value",
":",
"user",
"}",
")",
";",
"}",
"// return the user",
"return",
"user",
";",
"}",
")",
";",
"}"
] | Get a user for a particular token
@param decodedToken
@returns {*} | [
"Get",
"a",
"user",
"for",
"a",
"particular",
"token"
] | ea3feb8839e2edaf1b4577c052b8958953db4498 | https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/middleware/mw.auth.token.js#L16-L46 |
52,343 | gethuman/pancakes-recipe | middleware/mw.auth.token.js | validateToken | function validateToken(req, reply) {
var authorization = req.headers.authorization;
if (!authorization) {
return reply.continue();
}
// this is hack fix so that localStorage and cookies can either have Bearer or not
// if in local storate, it is serialized, so need to replace %20 with space
// need to fix this in the future at the source (i.e. on the client side)
authorization = authorization.replace('Bearer%20', 'Bearer ');
if (!authorization.match(/^Bearer /)) {
authorization = 'Bearer ' + authorization;
}
var parts = authorization.split(/\s+/);
if (parts.length !== 2) {
log.debug('Authorization header invalid: ' + authorization);
return reply.continue();
}
if (parts[0].toLowerCase() !== 'bearer') {
log.debug('Authorization no bearer');
return reply.continue();
}
if (parts[1].split('.').length !== 3) {
log.debug('Authorization bearer value invalid');
return reply.continue();
}
var token = parts[1];
return jwt.verify(token, privateKey)
.then(function (decodedToken) {
return getUserForToken(decodedToken);
})
.then(function (user) {
req.user = user;
return reply.continue();
})
// if error continue on as anonymous
.catch(function () {
//log.debug('Problem verifying token: ' + token);
return reply.continue();
});
} | javascript | function validateToken(req, reply) {
var authorization = req.headers.authorization;
if (!authorization) {
return reply.continue();
}
// this is hack fix so that localStorage and cookies can either have Bearer or not
// if in local storate, it is serialized, so need to replace %20 with space
// need to fix this in the future at the source (i.e. on the client side)
authorization = authorization.replace('Bearer%20', 'Bearer ');
if (!authorization.match(/^Bearer /)) {
authorization = 'Bearer ' + authorization;
}
var parts = authorization.split(/\s+/);
if (parts.length !== 2) {
log.debug('Authorization header invalid: ' + authorization);
return reply.continue();
}
if (parts[0].toLowerCase() !== 'bearer') {
log.debug('Authorization no bearer');
return reply.continue();
}
if (parts[1].split('.').length !== 3) {
log.debug('Authorization bearer value invalid');
return reply.continue();
}
var token = parts[1];
return jwt.verify(token, privateKey)
.then(function (decodedToken) {
return getUserForToken(decodedToken);
})
.then(function (user) {
req.user = user;
return reply.continue();
})
// if error continue on as anonymous
.catch(function () {
//log.debug('Problem verifying token: ' + token);
return reply.continue();
});
} | [
"function",
"validateToken",
"(",
"req",
",",
"reply",
")",
"{",
"var",
"authorization",
"=",
"req",
".",
"headers",
".",
"authorization",
";",
"if",
"(",
"!",
"authorization",
")",
"{",
"return",
"reply",
".",
"continue",
"(",
")",
";",
"}",
"// this is hack fix so that localStorage and cookies can either have Bearer or not",
"// if in local storate, it is serialized, so need to replace %20 with space",
"// need to fix this in the future at the source (i.e. on the client side)",
"authorization",
"=",
"authorization",
".",
"replace",
"(",
"'Bearer%20'",
",",
"'Bearer '",
")",
";",
"if",
"(",
"!",
"authorization",
".",
"match",
"(",
"/",
"^Bearer ",
"/",
")",
")",
"{",
"authorization",
"=",
"'Bearer '",
"+",
"authorization",
";",
"}",
"var",
"parts",
"=",
"authorization",
".",
"split",
"(",
"/",
"\\s+",
"/",
")",
";",
"if",
"(",
"parts",
".",
"length",
"!==",
"2",
")",
"{",
"log",
".",
"debug",
"(",
"'Authorization header invalid: '",
"+",
"authorization",
")",
";",
"return",
"reply",
".",
"continue",
"(",
")",
";",
"}",
"if",
"(",
"parts",
"[",
"0",
"]",
".",
"toLowerCase",
"(",
")",
"!==",
"'bearer'",
")",
"{",
"log",
".",
"debug",
"(",
"'Authorization no bearer'",
")",
";",
"return",
"reply",
".",
"continue",
"(",
")",
";",
"}",
"if",
"(",
"parts",
"[",
"1",
"]",
".",
"split",
"(",
"'.'",
")",
".",
"length",
"!==",
"3",
")",
"{",
"log",
".",
"debug",
"(",
"'Authorization bearer value invalid'",
")",
";",
"return",
"reply",
".",
"continue",
"(",
")",
";",
"}",
"var",
"token",
"=",
"parts",
"[",
"1",
"]",
";",
"return",
"jwt",
".",
"verify",
"(",
"token",
",",
"privateKey",
")",
".",
"then",
"(",
"function",
"(",
"decodedToken",
")",
"{",
"return",
"getUserForToken",
"(",
"decodedToken",
")",
";",
"}",
")",
".",
"then",
"(",
"function",
"(",
"user",
")",
"{",
"req",
".",
"user",
"=",
"user",
";",
"return",
"reply",
".",
"continue",
"(",
")",
";",
"}",
")",
"// if error continue on as anonymous",
".",
"catch",
"(",
"function",
"(",
")",
"{",
"//log.debug('Problem verifying token: ' + token);",
"return",
"reply",
".",
"continue",
"(",
")",
";",
"}",
")",
";",
"}"
] | Attempt to find a user for a given token. There will be an error if the
Authorization header is invalid, but if it doesn't exist or the user
can't be found, no error because we let Fakeblock ACLs determine whether
transaction can be anonymous.
@param req
@param reply | [
"Attempt",
"to",
"find",
"a",
"user",
"for",
"a",
"given",
"token",
".",
"There",
"will",
"be",
"an",
"error",
"if",
"the",
"Authorization",
"header",
"is",
"invalid",
"but",
"if",
"it",
"doesn",
"t",
"exist",
"or",
"the",
"user",
"can",
"t",
"be",
"found",
"no",
"error",
"because",
"we",
"let",
"Fakeblock",
"ACLs",
"determine",
"whether",
"transaction",
"can",
"be",
"anonymous",
"."
] | ea3feb8839e2edaf1b4577c052b8958953db4498 | https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/middleware/mw.auth.token.js#L57-L102 |
52,344 | gethuman/pancakes-recipe | middleware/mw.auth.token.js | init | function init(ctx) {
var server = ctx.server;
if (!privateKey) {
throw new Error('Please set config.security.token.privateKey');
}
server.ext('onPreAuth', validateToken);
return new Q(ctx);
} | javascript | function init(ctx) {
var server = ctx.server;
if (!privateKey) {
throw new Error('Please set config.security.token.privateKey');
}
server.ext('onPreAuth', validateToken);
return new Q(ctx);
} | [
"function",
"init",
"(",
"ctx",
")",
"{",
"var",
"server",
"=",
"ctx",
".",
"server",
";",
"if",
"(",
"!",
"privateKey",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Please set config.security.token.privateKey'",
")",
";",
"}",
"server",
".",
"ext",
"(",
"'onPreAuth'",
",",
"validateToken",
")",
";",
"return",
"new",
"Q",
"(",
"ctx",
")",
";",
"}"
] | Register the hapi auth strategy
@param ctx | [
"Register",
"the",
"hapi",
"auth",
"strategy"
] | ea3feb8839e2edaf1b4577c052b8958953db4498 | https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/middleware/mw.auth.token.js#L109-L119 |
52,345 | redisjs/jsr-server | lib/command/transaction/unwatch.js | execute | function execute(req, res) {
req.conn.unwatch(req.db);
res.send(null, Constants.OK);
} | javascript | function execute(req, res) {
req.conn.unwatch(req.db);
res.send(null, Constants.OK);
} | [
"function",
"execute",
"(",
"req",
",",
"res",
")",
"{",
"req",
".",
"conn",
".",
"unwatch",
"(",
"req",
".",
"db",
")",
";",
"res",
".",
"send",
"(",
"null",
",",
"Constants",
".",
"OK",
")",
";",
"}"
] | Respond to the UNWATCH command. | [
"Respond",
"to",
"the",
"UNWATCH",
"command",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/transaction/unwatch.js#L19-L22 |
52,346 | noderaider/redux-addons | lib/dispatcher.js | getLibStateAccessor | function getLibStateAccessor(libState) {
/** The current state name */
return { get actionName() {
return libState.actionName;
}
/** Is in idle state (no more states to progress to) */
, get isIdle() {
return libState.isIdle;
}
/** State can be paused manually or via action dispatch or returning null/undefined from timeoutMS function */
, get isPaused() {
return libState.isPaused;
}
/** The epoch MS that the user was last active */
, get lastActive() {
return useFastStore ? fastState.lastActive : libState.lastActive;
}
/** Event information captured on the last recorded user action */
, get lastEvent() {
return useFastStore ? fastState.lastEvent : libState.lastEvent;
}
/** The timeoutID for the current scheduled next event if it exists */
, get timeoutID() {
return useFastStore ? fastState.timeoutID : libState.timeoutID;
}
};
} | javascript | function getLibStateAccessor(libState) {
/** The current state name */
return { get actionName() {
return libState.actionName;
}
/** Is in idle state (no more states to progress to) */
, get isIdle() {
return libState.isIdle;
}
/** State can be paused manually or via action dispatch or returning null/undefined from timeoutMS function */
, get isPaused() {
return libState.isPaused;
}
/** The epoch MS that the user was last active */
, get lastActive() {
return useFastStore ? fastState.lastActive : libState.lastActive;
}
/** Event information captured on the last recorded user action */
, get lastEvent() {
return useFastStore ? fastState.lastEvent : libState.lastEvent;
}
/** The timeoutID for the current scheduled next event if it exists */
, get timeoutID() {
return useFastStore ? fastState.timeoutID : libState.timeoutID;
}
};
} | [
"function",
"getLibStateAccessor",
"(",
"libState",
")",
"{",
"/** The current state name */",
"return",
"{",
"get",
"actionName",
"(",
")",
"{",
"return",
"libState",
".",
"actionName",
";",
"}",
"/** Is in idle state (no more states to progress to) */",
",",
"get",
"isIdle",
"(",
")",
"{",
"return",
"libState",
".",
"isIdle",
";",
"}",
"/** State can be paused manually or via action dispatch or returning null/undefined from timeoutMS function */",
",",
"get",
"isPaused",
"(",
")",
"{",
"return",
"libState",
".",
"isPaused",
";",
"}",
"/** The epoch MS that the user was last active */",
",",
"get",
"lastActive",
"(",
")",
"{",
"return",
"useFastStore",
"?",
"fastState",
".",
"lastActive",
":",
"libState",
".",
"lastActive",
";",
"}",
"/** Event information captured on the last recorded user action */",
",",
"get",
"lastEvent",
"(",
")",
"{",
"return",
"useFastStore",
"?",
"fastState",
".",
"lastEvent",
":",
"libState",
".",
"lastEvent",
";",
"}",
"/** The timeoutID for the current scheduled next event if it exists */",
",",
"get",
"timeoutID",
"(",
")",
"{",
"return",
"useFastStore",
"?",
"fastState",
".",
"timeoutID",
":",
"libState",
".",
"timeoutID",
";",
"}",
"}",
";",
"}"
] | ABSTRACTS ACCESS TO STATE VIA GETTERS | [
"ABSTRACTS",
"ACCESS",
"TO",
"STATE",
"VIA",
"GETTERS"
] | 7b11262b5a89039e7d96e47b8391840e72510fe1 | https://github.com/noderaider/redux-addons/blob/7b11262b5a89039e7d96e47b8391840e72510fe1/lib/dispatcher.js#L118-L144 |
52,347 | noderaider/redux-addons | lib/dispatcher.js | _shouldActivityUpdate | function _shouldActivityUpdate(_ref5) {
var type = _ref5.type;
var pageX = _ref5.pageX;
var pageY = _ref5.pageY;
if (type !== 'mousemove') return true;
var _stores$fast = stores.fast;
var lastActive = _stores$fast.lastActive;
var _stores$fast$lastEven = _stores$fast.lastEvent;
var x = _stores$fast$lastEven.x;
var y = _stores$fast$lastEven.y;
if (typeof pageX === 'undefined' || typeof pageY === 'undefined') return false;
if (Math.abs(pageX - x) < thresholds.mouse && Math.abs(pageY - y) < thresholds.mouse) return false;
// SKIP UPDATE IF ITS UNDER THE THRESHOLD MS FROM THE LAST UPDATE
var elapsedMS = +new Date() - lastActive;
if (elapsedMS < thresholds.elapsedMS) return false;
if (process.env.NODE_ENV !== 'production') log.trace('_shouldActivityUpdate: elapsed vs threshold => E[' + elapsedMS + '] >= T[' + thresholds.elapsedMS + '], lastActive => ' + lastActive);
return true;
} | javascript | function _shouldActivityUpdate(_ref5) {
var type = _ref5.type;
var pageX = _ref5.pageX;
var pageY = _ref5.pageY;
if (type !== 'mousemove') return true;
var _stores$fast = stores.fast;
var lastActive = _stores$fast.lastActive;
var _stores$fast$lastEven = _stores$fast.lastEvent;
var x = _stores$fast$lastEven.x;
var y = _stores$fast$lastEven.y;
if (typeof pageX === 'undefined' || typeof pageY === 'undefined') return false;
if (Math.abs(pageX - x) < thresholds.mouse && Math.abs(pageY - y) < thresholds.mouse) return false;
// SKIP UPDATE IF ITS UNDER THE THRESHOLD MS FROM THE LAST UPDATE
var elapsedMS = +new Date() - lastActive;
if (elapsedMS < thresholds.elapsedMS) return false;
if (process.env.NODE_ENV !== 'production') log.trace('_shouldActivityUpdate: elapsed vs threshold => E[' + elapsedMS + '] >= T[' + thresholds.elapsedMS + '], lastActive => ' + lastActive);
return true;
} | [
"function",
"_shouldActivityUpdate",
"(",
"_ref5",
")",
"{",
"var",
"type",
"=",
"_ref5",
".",
"type",
";",
"var",
"pageX",
"=",
"_ref5",
".",
"pageX",
";",
"var",
"pageY",
"=",
"_ref5",
".",
"pageY",
";",
"if",
"(",
"type",
"!==",
"'mousemove'",
")",
"return",
"true",
";",
"var",
"_stores$fast",
"=",
"stores",
".",
"fast",
";",
"var",
"lastActive",
"=",
"_stores$fast",
".",
"lastActive",
";",
"var",
"_stores$fast$lastEven",
"=",
"_stores$fast",
".",
"lastEvent",
";",
"var",
"x",
"=",
"_stores$fast$lastEven",
".",
"x",
";",
"var",
"y",
"=",
"_stores$fast$lastEven",
".",
"y",
";",
"if",
"(",
"typeof",
"pageX",
"===",
"'undefined'",
"||",
"typeof",
"pageY",
"===",
"'undefined'",
")",
"return",
"false",
";",
"if",
"(",
"Math",
".",
"abs",
"(",
"pageX",
"-",
"x",
")",
"<",
"thresholds",
".",
"mouse",
"&&",
"Math",
".",
"abs",
"(",
"pageY",
"-",
"y",
")",
"<",
"thresholds",
".",
"mouse",
")",
"return",
"false",
";",
"// SKIP UPDATE IF ITS UNDER THE THRESHOLD MS FROM THE LAST UPDATE",
"var",
"elapsedMS",
"=",
"+",
"new",
"Date",
"(",
")",
"-",
"lastActive",
";",
"if",
"(",
"elapsedMS",
"<",
"thresholds",
".",
"elapsedMS",
")",
"return",
"false",
";",
"if",
"(",
"process",
".",
"env",
".",
"NODE_ENV",
"!==",
"'production'",
")",
"log",
".",
"trace",
"(",
"'_shouldActivityUpdate: elapsed vs threshold => E['",
"+",
"elapsedMS",
"+",
"'] >= T['",
"+",
"thresholds",
".",
"elapsedMS",
"+",
"'], lastActive => '",
"+",
"lastActive",
")",
";",
"return",
"true",
";",
"}"
] | Detects whether the activity should trigger a redux update | [
"Detects",
"whether",
"the",
"activity",
"should",
"trigger",
"a",
"redux",
"update"
] | 7b11262b5a89039e7d96e47b8391840e72510fe1 | https://github.com/noderaider/redux-addons/blob/7b11262b5a89039e7d96e47b8391840e72510fe1/lib/dispatcher.js#L222-L243 |
52,348 | noderaider/redux-addons | lib/dispatcher.js | onActivity | function onActivity(e) {
if (!_shouldActivityUpdate(e)) return;
if (_shouldRestart()) return dispatch(context.actions.start());
/** THIS WILL BE ROUTED TO FAST OR LOCAL STATE IF ENABLED */
setState(_constants.IDLEMONITOR_ACTIVITY, { lastActive: +new Date(), lastEvent: { x: e.pageX, y: e.pageY } });
} | javascript | function onActivity(e) {
if (!_shouldActivityUpdate(e)) return;
if (_shouldRestart()) return dispatch(context.actions.start());
/** THIS WILL BE ROUTED TO FAST OR LOCAL STATE IF ENABLED */
setState(_constants.IDLEMONITOR_ACTIVITY, { lastActive: +new Date(), lastEvent: { x: e.pageX, y: e.pageY } });
} | [
"function",
"onActivity",
"(",
"e",
")",
"{",
"if",
"(",
"!",
"_shouldActivityUpdate",
"(",
"e",
")",
")",
"return",
";",
"if",
"(",
"_shouldRestart",
"(",
")",
")",
"return",
"dispatch",
"(",
"context",
".",
"actions",
".",
"start",
"(",
")",
")",
";",
"/** THIS WILL BE ROUTED TO FAST OR LOCAL STATE IF ENABLED */",
"setState",
"(",
"_constants",
".",
"IDLEMONITOR_ACTIVITY",
",",
"{",
"lastActive",
":",
"+",
"new",
"Date",
"(",
")",
",",
"lastEvent",
":",
"{",
"x",
":",
"e",
".",
"pageX",
",",
"y",
":",
"e",
".",
"pageY",
"}",
"}",
")",
";",
"}"
] | One of the event listeners triggered an activity occurrence event. This gets spammed | [
"One",
"of",
"the",
"event",
"listeners",
"triggered",
"an",
"activity",
"occurrence",
"event",
".",
"This",
"gets",
"spammed"
] | 7b11262b5a89039e7d96e47b8391840e72510fe1 | https://github.com/noderaider/redux-addons/blob/7b11262b5a89039e7d96e47b8391840e72510fe1/lib/dispatcher.js#L250-L255 |
52,349 | noderaider/redux-addons | lib/dispatcher.js | schedule | function schedule(actionName) {
timeout.clear();
var timeoutMS = timeout.timeoutMS(actionName);
log.debug({ actionName: actionName, timeoutMS: timeoutMS }, 'schedule');
var args = { actionName: actionName, isPaused: _isPauseTriggered(timeoutMS) };
if (timeoutMS > 0) return setTimeout(function () {
return execute(args);
}, timeoutMS);
execute(args);
} | javascript | function schedule(actionName) {
timeout.clear();
var timeoutMS = timeout.timeoutMS(actionName);
log.debug({ actionName: actionName, timeoutMS: timeoutMS }, 'schedule');
var args = { actionName: actionName, isPaused: _isPauseTriggered(timeoutMS) };
if (timeoutMS > 0) return setTimeout(function () {
return execute(args);
}, timeoutMS);
execute(args);
} | [
"function",
"schedule",
"(",
"actionName",
")",
"{",
"timeout",
".",
"clear",
"(",
")",
";",
"var",
"timeoutMS",
"=",
"timeout",
".",
"timeoutMS",
"(",
"actionName",
")",
";",
"log",
".",
"debug",
"(",
"{",
"actionName",
":",
"actionName",
",",
"timeoutMS",
":",
"timeoutMS",
"}",
",",
"'schedule'",
")",
";",
"var",
"args",
"=",
"{",
"actionName",
":",
"actionName",
",",
"isPaused",
":",
"_isPauseTriggered",
"(",
"timeoutMS",
")",
"}",
";",
"if",
"(",
"timeoutMS",
">",
"0",
")",
"return",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"return",
"execute",
"(",
"args",
")",
";",
"}",
",",
"timeoutMS",
")",
";",
"execute",
"(",
"args",
")",
";",
"}"
] | Responsible for clearing old timeout and scheduling new one or immediately executing, returns new timeoutID or undefined | [
"Responsible",
"for",
"clearing",
"old",
"timeout",
"and",
"scheduling",
"new",
"one",
"or",
"immediately",
"executing",
"returns",
"new",
"timeoutID",
"or",
"undefined"
] | 7b11262b5a89039e7d96e47b8391840e72510fe1 | https://github.com/noderaider/redux-addons/blob/7b11262b5a89039e7d96e47b8391840e72510fe1/lib/dispatcher.js#L298-L307 |
52,350 | noderaider/redux-addons | lib/dispatcher.js | execute | function execute(_ref7) {
var actionName = _ref7.actionName;
var isPaused = _ref7.isPaused;
var nextActionName = getNextActionName(actionName);
var wasPaused = stores.redux.isPaused;
/** TODO: CHECK LOCAL STATE HERE AND IF ITS BEEN ACTIVE, POSTPONE THE ACTION ABOUT TO BE EXECUTED */
/** SCHEDULE THE NEXT ACTION IF IT EXISTS */
var timeoutID = nextActionName && !isPaused ? schedule(nextActionName) : null;
if (isPaused && !wasPaused) {
log.info('pausing activity detection');
detection.stop();
}
if (!isPaused && wasPaused) {
log.info('unpausing activity detection');
detection.start();
}
/** UPDATE THE STATE OF THE APP */
setState(actionName, { actionName: actionName,
isIdle: typeof nextActionName === 'undefined',
isPaused: isPaused,
timeoutID: timeoutID
});
/** EXECUTE THE USER DEFINED ACTION WITH REDUX THUNK ARGS + CONTEXT (LOG, START/STOP/RESET DISPATCHABLE ACTIONS) */
getAction(actionName)(dispatch, getState, _getChildContext(context));
} | javascript | function execute(_ref7) {
var actionName = _ref7.actionName;
var isPaused = _ref7.isPaused;
var nextActionName = getNextActionName(actionName);
var wasPaused = stores.redux.isPaused;
/** TODO: CHECK LOCAL STATE HERE AND IF ITS BEEN ACTIVE, POSTPONE THE ACTION ABOUT TO BE EXECUTED */
/** SCHEDULE THE NEXT ACTION IF IT EXISTS */
var timeoutID = nextActionName && !isPaused ? schedule(nextActionName) : null;
if (isPaused && !wasPaused) {
log.info('pausing activity detection');
detection.stop();
}
if (!isPaused && wasPaused) {
log.info('unpausing activity detection');
detection.start();
}
/** UPDATE THE STATE OF THE APP */
setState(actionName, { actionName: actionName,
isIdle: typeof nextActionName === 'undefined',
isPaused: isPaused,
timeoutID: timeoutID
});
/** EXECUTE THE USER DEFINED ACTION WITH REDUX THUNK ARGS + CONTEXT (LOG, START/STOP/RESET DISPATCHABLE ACTIONS) */
getAction(actionName)(dispatch, getState, _getChildContext(context));
} | [
"function",
"execute",
"(",
"_ref7",
")",
"{",
"var",
"actionName",
"=",
"_ref7",
".",
"actionName",
";",
"var",
"isPaused",
"=",
"_ref7",
".",
"isPaused",
";",
"var",
"nextActionName",
"=",
"getNextActionName",
"(",
"actionName",
")",
";",
"var",
"wasPaused",
"=",
"stores",
".",
"redux",
".",
"isPaused",
";",
"/** TODO: CHECK LOCAL STATE HERE AND IF ITS BEEN ACTIVE, POSTPONE THE ACTION ABOUT TO BE EXECUTED */",
"/** SCHEDULE THE NEXT ACTION IF IT EXISTS */",
"var",
"timeoutID",
"=",
"nextActionName",
"&&",
"!",
"isPaused",
"?",
"schedule",
"(",
"nextActionName",
")",
":",
"null",
";",
"if",
"(",
"isPaused",
"&&",
"!",
"wasPaused",
")",
"{",
"log",
".",
"info",
"(",
"'pausing activity detection'",
")",
";",
"detection",
".",
"stop",
"(",
")",
";",
"}",
"if",
"(",
"!",
"isPaused",
"&&",
"wasPaused",
")",
"{",
"log",
".",
"info",
"(",
"'unpausing activity detection'",
")",
";",
"detection",
".",
"start",
"(",
")",
";",
"}",
"/** UPDATE THE STATE OF THE APP */",
"setState",
"(",
"actionName",
",",
"{",
"actionName",
":",
"actionName",
",",
"isIdle",
":",
"typeof",
"nextActionName",
"===",
"'undefined'",
",",
"isPaused",
":",
"isPaused",
",",
"timeoutID",
":",
"timeoutID",
"}",
")",
";",
"/** EXECUTE THE USER DEFINED ACTION WITH REDUX THUNK ARGS + CONTEXT (LOG, START/STOP/RESET DISPATCHABLE ACTIONS) */",
"getAction",
"(",
"actionName",
")",
"(",
"dispatch",
",",
"getState",
",",
"_getChildContext",
"(",
"context",
")",
")",
";",
"}"
] | Responsible for executing an action | [
"Responsible",
"for",
"executing",
"an",
"action"
] | 7b11262b5a89039e7d96e47b8391840e72510fe1 | https://github.com/noderaider/redux-addons/blob/7b11262b5a89039e7d96e47b8391840e72510fe1/lib/dispatcher.js#L310-L340 |
52,351 | panjiesw/frest | internal/docs/themes/hugo-theme-learn/static/js/learn.js | function (e) {
var elem = e.target;
if (this.scrollIfAnchor(elem.getAttribute('href'), true)) {
e.preventDefault();
}
} | javascript | function (e) {
var elem = e.target;
if (this.scrollIfAnchor(elem.getAttribute('href'), true)) {
e.preventDefault();
}
} | [
"function",
"(",
"e",
")",
"{",
"var",
"elem",
"=",
"e",
".",
"target",
";",
"if",
"(",
"this",
".",
"scrollIfAnchor",
"(",
"elem",
".",
"getAttribute",
"(",
"'href'",
")",
",",
"true",
")",
")",
"{",
"e",
".",
"preventDefault",
"(",
")",
";",
"}",
"}"
] | If the click event's target was an anchor, fix the scroll position. | [
"If",
"the",
"click",
"event",
"s",
"target",
"was",
"an",
"anchor",
"fix",
"the",
"scroll",
"position",
"."
] | 975a16ae24bd214b608d0b0001d3d86e5cd65f9e | https://github.com/panjiesw/frest/blob/975a16ae24bd214b608d0b0001d3d86e5cd65f9e/internal/docs/themes/hugo-theme-learn/static/js/learn.js#L331-L337 |
|
52,352 | DIMLEO/dim | Session/Session.js | function(key, defaultValue){
var value = this.get(key, defaultValue);
if($ExpressSESSION.session.store[key]){
delete $ExpressSESSION.session.store[key];
}
return value;
} | javascript | function(key, defaultValue){
var value = this.get(key, defaultValue);
if($ExpressSESSION.session.store[key]){
delete $ExpressSESSION.session.store[key];
}
return value;
} | [
"function",
"(",
"key",
",",
"defaultValue",
")",
"{",
"var",
"value",
"=",
"this",
".",
"get",
"(",
"key",
",",
"defaultValue",
")",
";",
"if",
"(",
"$ExpressSESSION",
".",
"session",
".",
"store",
"[",
"key",
"]",
")",
"{",
"delete",
"$ExpressSESSION",
".",
"session",
".",
"store",
"[",
"key",
"]",
";",
"}",
"return",
"value",
";",
"}"
] | Retrieving An Item And Forgetting It | [
"Retrieving",
"An",
"Item",
"And",
"Forgetting",
"It"
] | 4e8066be4dfc6c6cf53698c302c1ad0cc082d5d3 | https://github.com/DIMLEO/dim/blob/4e8066be4dfc6c6cf53698c302c1ad0cc082d5d3/Session/Session.js#L44-L50 |
|
52,353 | phelpstream/svp | lib/functions/merge.js | merge | function merge(target) {
for (var _len = arguments.length, sources = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
sources[_key - 1] = arguments[_key];
}
if (!sources.length) return target;
var source = sources.shift();
if ((0, _isObject2.default)(target) && (0, _isObject2.default)(source)) {
for (var key in source) {
if ((0, _isObject2.default)(source[key])) {
if (!target[key]) Object.assign(target, _defineProperty({}, key, {}));
merge(target[key], source[key]);
} else {
Object.assign(target, _defineProperty({}, key, source[key]));
}
}
}
return merge.apply(undefined, [target].concat(sources));
} | javascript | function merge(target) {
for (var _len = arguments.length, sources = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
sources[_key - 1] = arguments[_key];
}
if (!sources.length) return target;
var source = sources.shift();
if ((0, _isObject2.default)(target) && (0, _isObject2.default)(source)) {
for (var key in source) {
if ((0, _isObject2.default)(source[key])) {
if (!target[key]) Object.assign(target, _defineProperty({}, key, {}));
merge(target[key], source[key]);
} else {
Object.assign(target, _defineProperty({}, key, source[key]));
}
}
}
return merge.apply(undefined, [target].concat(sources));
} | [
"function",
"merge",
"(",
"target",
")",
"{",
"for",
"(",
"var",
"_len",
"=",
"arguments",
".",
"length",
",",
"sources",
"=",
"Array",
"(",
"_len",
">",
"1",
"?",
"_len",
"-",
"1",
":",
"0",
")",
",",
"_key",
"=",
"1",
";",
"_key",
"<",
"_len",
";",
"_key",
"++",
")",
"{",
"sources",
"[",
"_key",
"-",
"1",
"]",
"=",
"arguments",
"[",
"_key",
"]",
";",
"}",
"if",
"(",
"!",
"sources",
".",
"length",
")",
"return",
"target",
";",
"var",
"source",
"=",
"sources",
".",
"shift",
"(",
")",
";",
"if",
"(",
"(",
"0",
",",
"_isObject2",
".",
"default",
")",
"(",
"target",
")",
"&&",
"(",
"0",
",",
"_isObject2",
".",
"default",
")",
"(",
"source",
")",
")",
"{",
"for",
"(",
"var",
"key",
"in",
"source",
")",
"{",
"if",
"(",
"(",
"0",
",",
"_isObject2",
".",
"default",
")",
"(",
"source",
"[",
"key",
"]",
")",
")",
"{",
"if",
"(",
"!",
"target",
"[",
"key",
"]",
")",
"Object",
".",
"assign",
"(",
"target",
",",
"_defineProperty",
"(",
"{",
"}",
",",
"key",
",",
"{",
"}",
")",
")",
";",
"merge",
"(",
"target",
"[",
"key",
"]",
",",
"source",
"[",
"key",
"]",
")",
";",
"}",
"else",
"{",
"Object",
".",
"assign",
"(",
"target",
",",
"_defineProperty",
"(",
"{",
"}",
",",
"key",
",",
"source",
"[",
"key",
"]",
")",
")",
";",
"}",
"}",
"}",
"return",
"merge",
".",
"apply",
"(",
"undefined",
",",
"[",
"target",
"]",
".",
"concat",
"(",
"sources",
")",
")",
";",
"}"
] | Recursively merge two objects.
@param target
@param ...sources | [
"Recursively",
"merge",
"two",
"objects",
"."
] | 2f99adb9c5d0709e567264bba896d6a59f6a0a59 | https://github.com/phelpstream/svp/blob/2f99adb9c5d0709e567264bba896d6a59f6a0a59/lib/functions/merge.js#L21-L41 |
52,354 | chriskinsman/disque-eventemitter | index.js | readQueue | function readQueue() {
disq.getJob({queue: queueName, count: self.jobCount, withcounters: self.withCounters}, function(err, jobs) {
if(err) {
self.emit('error', err);
}
else {
jobs.forEach(function(job) {
pendingMessages++;
self.emit('job', job, function() {
pendingMessages--;
if(!self.paused && concurrencyPaused && pendingMessages < self.concurrency) {
concurrencyPaused = false;
setImmediate(readQueue);
}
});
});
if(!self.paused && pendingMessages<self.concurrency) {
setImmediate(readQueue);
}
else {
concurrencyPaused = true;
}
}
});
} | javascript | function readQueue() {
disq.getJob({queue: queueName, count: self.jobCount, withcounters: self.withCounters}, function(err, jobs) {
if(err) {
self.emit('error', err);
}
else {
jobs.forEach(function(job) {
pendingMessages++;
self.emit('job', job, function() {
pendingMessages--;
if(!self.paused && concurrencyPaused && pendingMessages < self.concurrency) {
concurrencyPaused = false;
setImmediate(readQueue);
}
});
});
if(!self.paused && pendingMessages<self.concurrency) {
setImmediate(readQueue);
}
else {
concurrencyPaused = true;
}
}
});
} | [
"function",
"readQueue",
"(",
")",
"{",
"disq",
".",
"getJob",
"(",
"{",
"queue",
":",
"queueName",
",",
"count",
":",
"self",
".",
"jobCount",
",",
"withcounters",
":",
"self",
".",
"withCounters",
"}",
",",
"function",
"(",
"err",
",",
"jobs",
")",
"{",
"if",
"(",
"err",
")",
"{",
"self",
".",
"emit",
"(",
"'error'",
",",
"err",
")",
";",
"}",
"else",
"{",
"jobs",
".",
"forEach",
"(",
"function",
"(",
"job",
")",
"{",
"pendingMessages",
"++",
";",
"self",
".",
"emit",
"(",
"'job'",
",",
"job",
",",
"function",
"(",
")",
"{",
"pendingMessages",
"--",
";",
"if",
"(",
"!",
"self",
".",
"paused",
"&&",
"concurrencyPaused",
"&&",
"pendingMessages",
"<",
"self",
".",
"concurrency",
")",
"{",
"concurrencyPaused",
"=",
"false",
";",
"setImmediate",
"(",
"readQueue",
")",
";",
"}",
"}",
")",
";",
"}",
")",
";",
"if",
"(",
"!",
"self",
".",
"paused",
"&&",
"pendingMessages",
"<",
"self",
".",
"concurrency",
")",
"{",
"setImmediate",
"(",
"readQueue",
")",
";",
"}",
"else",
"{",
"concurrencyPaused",
"=",
"true",
";",
"}",
"}",
"}",
")",
";",
"}"
] | Main message processor | [
"Main",
"message",
"processor"
] | 0b7550def40f5e1e614de4b015c7fccc9bd6a497 | https://github.com/chriskinsman/disque-eventemitter/blob/0b7550def40f5e1e614de4b015c7fccc9bd6a497/index.js#L22-L47 |
52,355 | implicit-invocation/world-walkable | index.js | dst | function dst(lat1, lon1, lat2, lon2) {
// generally used geo measurement function
var dLat = lat2 * Math.PI / 180 - lat1 * Math.PI / 180;
var dLon = lon2 * Math.PI / 180 - lon1 * Math.PI / 180;
var a =
Math.sin(dLat / 2) * Math.sin(dLat / 2) +
Math.cos(lat1 * Math.PI / 180) *
Math.cos(lat2 * Math.PI / 180) *
Math.sin(dLon / 2) *
Math.sin(dLon / 2);
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
var d = R * c;
return d * 1000; // meters
} | javascript | function dst(lat1, lon1, lat2, lon2) {
// generally used geo measurement function
var dLat = lat2 * Math.PI / 180 - lat1 * Math.PI / 180;
var dLon = lon2 * Math.PI / 180 - lon1 * Math.PI / 180;
var a =
Math.sin(dLat / 2) * Math.sin(dLat / 2) +
Math.cos(lat1 * Math.PI / 180) *
Math.cos(lat2 * Math.PI / 180) *
Math.sin(dLon / 2) *
Math.sin(dLon / 2);
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
var d = R * c;
return d * 1000; // meters
} | [
"function",
"dst",
"(",
"lat1",
",",
"lon1",
",",
"lat2",
",",
"lon2",
")",
"{",
"// generally used geo measurement function",
"var",
"dLat",
"=",
"lat2",
"*",
"Math",
".",
"PI",
"/",
"180",
"-",
"lat1",
"*",
"Math",
".",
"PI",
"/",
"180",
";",
"var",
"dLon",
"=",
"lon2",
"*",
"Math",
".",
"PI",
"/",
"180",
"-",
"lon1",
"*",
"Math",
".",
"PI",
"/",
"180",
";",
"var",
"a",
"=",
"Math",
".",
"sin",
"(",
"dLat",
"/",
"2",
")",
"*",
"Math",
".",
"sin",
"(",
"dLat",
"/",
"2",
")",
"+",
"Math",
".",
"cos",
"(",
"lat1",
"*",
"Math",
".",
"PI",
"/",
"180",
")",
"*",
"Math",
".",
"cos",
"(",
"lat2",
"*",
"Math",
".",
"PI",
"/",
"180",
")",
"*",
"Math",
".",
"sin",
"(",
"dLon",
"/",
"2",
")",
"*",
"Math",
".",
"sin",
"(",
"dLon",
"/",
"2",
")",
";",
"var",
"c",
"=",
"2",
"*",
"Math",
".",
"atan2",
"(",
"Math",
".",
"sqrt",
"(",
"a",
")",
",",
"Math",
".",
"sqrt",
"(",
"1",
"-",
"a",
")",
")",
";",
"var",
"d",
"=",
"R",
"*",
"c",
";",
"return",
"d",
"*",
"1000",
";",
"// meters",
"}"
] | Radius of earth in KM | [
"Radius",
"of",
"earth",
"in",
"KM"
] | fedeee4e03fe2e91d417621c325ad71400a1a258 | https://github.com/implicit-invocation/world-walkable/blob/fedeee4e03fe2e91d417621c325ad71400a1a258/index.js#L5-L18 |
52,356 | gethuman/pancakes-angular | lib/middleware/jng.pages.js | renderLayout | function renderLayout(appName, layoutName, isAmp, dependencies) {
var layout = this.pancakes.cook('app/' + appName + '/layouts/' + layoutName + '.layout');
var layoutView = this.pancakes.cook(layout.view, { dependencies: dependencies });
return jangular.render(layoutView, dependencies.model, { strip: false, isAmp: isAmp });
} | javascript | function renderLayout(appName, layoutName, isAmp, dependencies) {
var layout = this.pancakes.cook('app/' + appName + '/layouts/' + layoutName + '.layout');
var layoutView = this.pancakes.cook(layout.view, { dependencies: dependencies });
return jangular.render(layoutView, dependencies.model, { strip: false, isAmp: isAmp });
} | [
"function",
"renderLayout",
"(",
"appName",
",",
"layoutName",
",",
"isAmp",
",",
"dependencies",
")",
"{",
"var",
"layout",
"=",
"this",
".",
"pancakes",
".",
"cook",
"(",
"'app/'",
"+",
"appName",
"+",
"'/layouts/'",
"+",
"layoutName",
"+",
"'.layout'",
")",
";",
"var",
"layoutView",
"=",
"this",
".",
"pancakes",
".",
"cook",
"(",
"layout",
".",
"view",
",",
"{",
"dependencies",
":",
"dependencies",
"}",
")",
";",
"return",
"jangular",
".",
"render",
"(",
"layoutView",
",",
"dependencies",
".",
"model",
",",
"{",
"strip",
":",
"false",
",",
"isAmp",
":",
"isAmp",
"}",
")",
";",
"}"
] | Get a particular layout
@param appName
@param layoutName
@param isAmp
@param dependencies | [
"Get",
"a",
"particular",
"layout"
] | 9589b7ba09619843e271293088005c62ed23f355 | https://github.com/gethuman/pancakes-angular/blob/9589b7ba09619843e271293088005c62ed23f355/lib/middleware/jng.pages.js#L18-L22 |
52,357 | gethuman/pancakes-angular | lib/middleware/jng.directives.js | checkOnScopeChangeVals | function checkOnScopeChangeVals(partial, partialName) {
var remodelOnScopeChange = partial.remodelOnScopeChange || (partial.remodel && partial.remodel.onScopeChange);
var rerenderOnScopeChange = partial.rerenderOnScopeChange || (partial.rerender && partial.rerender.onScopeChange);
var scope = partial.scope || {};
_.each(remodelOnScopeChange, function (scopeVal) {
var idx = scopeVal.indexOf('.');
var val = idx > 0 ? scopeVal.substring(0, idx) : scopeVal;
if (!scope[val]) {
throw new Error(partialName + ' remodelOnScope value \'' + scopeVal + '\' is not defined in the scope definition.');
}
});
_.each(rerenderOnScopeChange, function (scopeVal) {
var idx = scopeVal.indexOf('.');
var val = idx > 0 ? scopeVal.substring(0, idx) : scopeVal;
if (!scope[val]) {
throw new Error(partialName + ' rerenderOnScopeChange value \'' + scopeVal + '\' is not defined in the scope definition.');
}
});
} | javascript | function checkOnScopeChangeVals(partial, partialName) {
var remodelOnScopeChange = partial.remodelOnScopeChange || (partial.remodel && partial.remodel.onScopeChange);
var rerenderOnScopeChange = partial.rerenderOnScopeChange || (partial.rerender && partial.rerender.onScopeChange);
var scope = partial.scope || {};
_.each(remodelOnScopeChange, function (scopeVal) {
var idx = scopeVal.indexOf('.');
var val = idx > 0 ? scopeVal.substring(0, idx) : scopeVal;
if (!scope[val]) {
throw new Error(partialName + ' remodelOnScope value \'' + scopeVal + '\' is not defined in the scope definition.');
}
});
_.each(rerenderOnScopeChange, function (scopeVal) {
var idx = scopeVal.indexOf('.');
var val = idx > 0 ? scopeVal.substring(0, idx) : scopeVal;
if (!scope[val]) {
throw new Error(partialName + ' rerenderOnScopeChange value \'' + scopeVal + '\' is not defined in the scope definition.');
}
});
} | [
"function",
"checkOnScopeChangeVals",
"(",
"partial",
",",
"partialName",
")",
"{",
"var",
"remodelOnScopeChange",
"=",
"partial",
".",
"remodelOnScopeChange",
"||",
"(",
"partial",
".",
"remodel",
"&&",
"partial",
".",
"remodel",
".",
"onScopeChange",
")",
";",
"var",
"rerenderOnScopeChange",
"=",
"partial",
".",
"rerenderOnScopeChange",
"||",
"(",
"partial",
".",
"rerender",
"&&",
"partial",
".",
"rerender",
".",
"onScopeChange",
")",
";",
"var",
"scope",
"=",
"partial",
".",
"scope",
"||",
"{",
"}",
";",
"_",
".",
"each",
"(",
"remodelOnScopeChange",
",",
"function",
"(",
"scopeVal",
")",
"{",
"var",
"idx",
"=",
"scopeVal",
".",
"indexOf",
"(",
"'.'",
")",
";",
"var",
"val",
"=",
"idx",
">",
"0",
"?",
"scopeVal",
".",
"substring",
"(",
"0",
",",
"idx",
")",
":",
"scopeVal",
";",
"if",
"(",
"!",
"scope",
"[",
"val",
"]",
")",
"{",
"throw",
"new",
"Error",
"(",
"partialName",
"+",
"' remodelOnScope value \\''",
"+",
"scopeVal",
"+",
"'\\' is not defined in the scope definition.'",
")",
";",
"}",
"}",
")",
";",
"_",
".",
"each",
"(",
"rerenderOnScopeChange",
",",
"function",
"(",
"scopeVal",
")",
"{",
"var",
"idx",
"=",
"scopeVal",
".",
"indexOf",
"(",
"'.'",
")",
";",
"var",
"val",
"=",
"idx",
">",
"0",
"?",
"scopeVal",
".",
"substring",
"(",
"0",
",",
"idx",
")",
":",
"scopeVal",
";",
"if",
"(",
"!",
"scope",
"[",
"val",
"]",
")",
"{",
"throw",
"new",
"Error",
"(",
"partialName",
"+",
"' rerenderOnScopeChange value \\''",
"+",
"scopeVal",
"+",
"'\\' is not defined in the scope definition.'",
")",
";",
"}",
"}",
")",
";",
"}"
] | Make sure the remodelOnScopeChange and rerenderOnScopeChange values are
all from the isolated scope definition. In other words, are values that
come from the parent scope.
@param partial
@param partialName | [
"Make",
"sure",
"the",
"remodelOnScopeChange",
"and",
"rerenderOnScopeChange",
"values",
"are",
"all",
"from",
"the",
"isolated",
"scope",
"definition",
".",
"In",
"other",
"words",
"are",
"values",
"that",
"come",
"from",
"the",
"parent",
"scope",
"."
] | 9589b7ba09619843e271293088005c62ed23f355 | https://github.com/gethuman/pancakes-angular/blob/9589b7ba09619843e271293088005c62ed23f355/lib/middleware/jng.directives.js#L50-L70 |
52,358 | gethuman/pancakes-angular | lib/middleware/jng.directives.js | getSubviews | function getSubviews(subviewFlapjacks) {
var renderedSubviews = {};
var jangularDeps = this.getJangularDeps();
var me = this;
_.each(subviewFlapjacks, function (subview, subviewName) {
renderedSubviews[subviewName] = me.pancakes.cook(subview, { dependencies: jangularDeps });
});
return renderedSubviews;
} | javascript | function getSubviews(subviewFlapjacks) {
var renderedSubviews = {};
var jangularDeps = this.getJangularDeps();
var me = this;
_.each(subviewFlapjacks, function (subview, subviewName) {
renderedSubviews[subviewName] = me.pancakes.cook(subview, { dependencies: jangularDeps });
});
return renderedSubviews;
} | [
"function",
"getSubviews",
"(",
"subviewFlapjacks",
")",
"{",
"var",
"renderedSubviews",
"=",
"{",
"}",
";",
"var",
"jangularDeps",
"=",
"this",
".",
"getJangularDeps",
"(",
")",
";",
"var",
"me",
"=",
"this",
";",
"_",
".",
"each",
"(",
"subviewFlapjacks",
",",
"function",
"(",
"subview",
",",
"subviewName",
")",
"{",
"renderedSubviews",
"[",
"subviewName",
"]",
"=",
"me",
".",
"pancakes",
".",
"cook",
"(",
"subview",
",",
"{",
"dependencies",
":",
"jangularDeps",
"}",
")",
";",
"}",
")",
";",
"return",
"renderedSubviews",
";",
"}"
] | Get all subviews
@param subviewFlapjacks | [
"Get",
"all",
"subviews"
] | 9589b7ba09619843e271293088005c62ed23f355 | https://github.com/gethuman/pancakes-angular/blob/9589b7ba09619843e271293088005c62ed23f355/lib/middleware/jng.directives.js#L162-L172 |
52,359 | gethuman/pancakes-angular | lib/middleware/jng.directives.js | getPartialRenderFn | function getPartialRenderFn(partial, partialName) {
var jangularDeps = this.getJangularDeps();
var me = this;
return function renderPartial(model, elem, attrs) {
me.isolateScope(model, partial.scope, attrs);
// throw error if onScopeChange values not in the scope {} definition
me.checkOnScopeChangeVals(partial, partialName);
// set defaults before the modify model
me.setDefaults(model, partial.defaults, partial.scope);
// set the presets if they exist
me.applyPresets(model, partial.defaults, partial.presets);
// if model is injection function, just use that
me.evalModel(model, partial.scope, partial.model, partialName);
// this is similar to both jng.pages renderPage()
// as well as ng.uipart.template (for client side pages and partials)
me.attachToScope(model, partial.attachToScope);
// generate the partial view
var dependencies = _.extend({ subviews: me.getSubviews(partial.subviews) }, jangularDeps);
return me.pancakes.cook(partial.view, { dependencies: dependencies });
};
} | javascript | function getPartialRenderFn(partial, partialName) {
var jangularDeps = this.getJangularDeps();
var me = this;
return function renderPartial(model, elem, attrs) {
me.isolateScope(model, partial.scope, attrs);
// throw error if onScopeChange values not in the scope {} definition
me.checkOnScopeChangeVals(partial, partialName);
// set defaults before the modify model
me.setDefaults(model, partial.defaults, partial.scope);
// set the presets if they exist
me.applyPresets(model, partial.defaults, partial.presets);
// if model is injection function, just use that
me.evalModel(model, partial.scope, partial.model, partialName);
// this is similar to both jng.pages renderPage()
// as well as ng.uipart.template (for client side pages and partials)
me.attachToScope(model, partial.attachToScope);
// generate the partial view
var dependencies = _.extend({ subviews: me.getSubviews(partial.subviews) }, jangularDeps);
return me.pancakes.cook(partial.view, { dependencies: dependencies });
};
} | [
"function",
"getPartialRenderFn",
"(",
"partial",
",",
"partialName",
")",
"{",
"var",
"jangularDeps",
"=",
"this",
".",
"getJangularDeps",
"(",
")",
";",
"var",
"me",
"=",
"this",
";",
"return",
"function",
"renderPartial",
"(",
"model",
",",
"elem",
",",
"attrs",
")",
"{",
"me",
".",
"isolateScope",
"(",
"model",
",",
"partial",
".",
"scope",
",",
"attrs",
")",
";",
"// throw error if onScopeChange values not in the scope {} definition",
"me",
".",
"checkOnScopeChangeVals",
"(",
"partial",
",",
"partialName",
")",
";",
"// set defaults before the modify model",
"me",
".",
"setDefaults",
"(",
"model",
",",
"partial",
".",
"defaults",
",",
"partial",
".",
"scope",
")",
";",
"// set the presets if they exist",
"me",
".",
"applyPresets",
"(",
"model",
",",
"partial",
".",
"defaults",
",",
"partial",
".",
"presets",
")",
";",
"// if model is injection function, just use that",
"me",
".",
"evalModel",
"(",
"model",
",",
"partial",
".",
"scope",
",",
"partial",
".",
"model",
",",
"partialName",
")",
";",
"// this is similar to both jng.pages renderPage()",
"// as well as ng.uipart.template (for client side pages and partials)",
"me",
".",
"attachToScope",
"(",
"model",
",",
"partial",
".",
"attachToScope",
")",
";",
"// generate the partial view",
"var",
"dependencies",
"=",
"_",
".",
"extend",
"(",
"{",
"subviews",
":",
"me",
".",
"getSubviews",
"(",
"partial",
".",
"subviews",
")",
"}",
",",
"jangularDeps",
")",
";",
"return",
"me",
".",
"pancakes",
".",
"cook",
"(",
"partial",
".",
"view",
",",
"{",
"dependencies",
":",
"dependencies",
"}",
")",
";",
"}",
";",
"}"
] | Get a function to help render a partial
@param partial
@param partialName
@returns {Function} | [
"Get",
"a",
"function",
"to",
"help",
"render",
"a",
"partial"
] | 9589b7ba09619843e271293088005c62ed23f355 | https://github.com/gethuman/pancakes-angular/blob/9589b7ba09619843e271293088005c62ed23f355/lib/middleware/jng.directives.js#L180-L207 |
52,360 | gethuman/pancakes-angular | lib/middleware/jng.directives.js | getBehavioralDirectives | function getBehavioralDirectives(appName) {
var directives = {};
var me = this;
_.each(this.getAppFileNames(appName, 'jng.directives'), function (directiveName) {
// if not a JavaScript file, ignore it
if (!me.pancakes.utils.isJavaScript(directiveName)) { return; }
// get the directive and load it into the directive map
var directivePath = 'app/' + appName + '/jng.directives/' + directiveName;
var directive = me.pancakes.cook(directivePath, null);
directiveName = directiveName.substring(0, directiveName.length - 3).replace('.', '-');
directives[directiveName] = directive;
});
return directives;
} | javascript | function getBehavioralDirectives(appName) {
var directives = {};
var me = this;
_.each(this.getAppFileNames(appName, 'jng.directives'), function (directiveName) {
// if not a JavaScript file, ignore it
if (!me.pancakes.utils.isJavaScript(directiveName)) { return; }
// get the directive and load it into the directive map
var directivePath = 'app/' + appName + '/jng.directives/' + directiveName;
var directive = me.pancakes.cook(directivePath, null);
directiveName = directiveName.substring(0, directiveName.length - 3).replace('.', '-');
directives[directiveName] = directive;
});
return directives;
} | [
"function",
"getBehavioralDirectives",
"(",
"appName",
")",
"{",
"var",
"directives",
"=",
"{",
"}",
";",
"var",
"me",
"=",
"this",
";",
"_",
".",
"each",
"(",
"this",
".",
"getAppFileNames",
"(",
"appName",
",",
"'jng.directives'",
")",
",",
"function",
"(",
"directiveName",
")",
"{",
"// if not a JavaScript file, ignore it",
"if",
"(",
"!",
"me",
".",
"pancakes",
".",
"utils",
".",
"isJavaScript",
"(",
"directiveName",
")",
")",
"{",
"return",
";",
"}",
"// get the directive and load it into the directive map",
"var",
"directivePath",
"=",
"'app/'",
"+",
"appName",
"+",
"'/jng.directives/'",
"+",
"directiveName",
";",
"var",
"directive",
"=",
"me",
".",
"pancakes",
".",
"cook",
"(",
"directivePath",
",",
"null",
")",
";",
"directiveName",
"=",
"directiveName",
".",
"substring",
"(",
"0",
",",
"directiveName",
".",
"length",
"-",
"3",
")",
".",
"replace",
"(",
"'.'",
",",
"'-'",
")",
";",
"directives",
"[",
"directiveName",
"]",
"=",
"directive",
";",
"}",
")",
";",
"return",
"directives",
";",
"}"
] | Add behavior directives from the jng.directives folder.
@param appName | [
"Add",
"behavior",
"directives",
"from",
"the",
"jng",
".",
"directives",
"folder",
"."
] | 9589b7ba09619843e271293088005c62ed23f355 | https://github.com/gethuman/pancakes-angular/blob/9589b7ba09619843e271293088005c62ed23f355/lib/middleware/jng.directives.js#L245-L262 |
52,361 | gethuman/pancakes-angular | lib/middleware/jng.directives.js | getClientDirectives | function getClientDirectives(appName) {
var directives = [];
var me = this;
_.each(this.getAppFileNames(appName, 'ng.directives'), function (directiveName) {
// if not a JavaScript file, ignore it
if (!me.pancakes.utils.isJavaScript(directiveName)) { return; }
directiveName = directiveName.substring(0, directiveName.length - 3).replace('.', '-');
directives.push(directiveName);
});
return directives;
} | javascript | function getClientDirectives(appName) {
var directives = [];
var me = this;
_.each(this.getAppFileNames(appName, 'ng.directives'), function (directiveName) {
// if not a JavaScript file, ignore it
if (!me.pancakes.utils.isJavaScript(directiveName)) { return; }
directiveName = directiveName.substring(0, directiveName.length - 3).replace('.', '-');
directives.push(directiveName);
});
return directives;
} | [
"function",
"getClientDirectives",
"(",
"appName",
")",
"{",
"var",
"directives",
"=",
"[",
"]",
";",
"var",
"me",
"=",
"this",
";",
"_",
".",
"each",
"(",
"this",
".",
"getAppFileNames",
"(",
"appName",
",",
"'ng.directives'",
")",
",",
"function",
"(",
"directiveName",
")",
"{",
"// if not a JavaScript file, ignore it",
"if",
"(",
"!",
"me",
".",
"pancakes",
".",
"utils",
".",
"isJavaScript",
"(",
"directiveName",
")",
")",
"{",
"return",
";",
"}",
"directiveName",
"=",
"directiveName",
".",
"substring",
"(",
"0",
",",
"directiveName",
".",
"length",
"-",
"3",
")",
".",
"replace",
"(",
"'.'",
",",
"'-'",
")",
";",
"directives",
".",
"push",
"(",
"directiveName",
")",
";",
"}",
")",
";",
"return",
"directives",
";",
"}"
] | Just because they are client-side directives, doesn't mean we don't need to do anything server-side. For example,
if JNG_STRIP is true, we need to strip them. We do, however, need to make it so they don't actually do anything
server-side (noop function0
@param appName | [
"Just",
"because",
"they",
"are",
"client",
"-",
"side",
"directives",
"doesn",
"t",
"mean",
"we",
"don",
"t",
"need",
"to",
"do",
"anything",
"server",
"-",
"side",
".",
"For",
"example",
"if",
"JNG_STRIP",
"is",
"true",
"we",
"need",
"to",
"strip",
"them",
".",
"We",
"do",
"however",
"need",
"to",
"make",
"it",
"so",
"they",
"don",
"t",
"actually",
"do",
"anything",
"server",
"-",
"side",
"(",
"noop",
"function0"
] | 9589b7ba09619843e271293088005c62ed23f355 | https://github.com/gethuman/pancakes-angular/blob/9589b7ba09619843e271293088005c62ed23f355/lib/middleware/jng.directives.js#L271-L285 |
52,362 | gethuman/pancakes-angular | lib/middleware/jng.directives.js | getGenericDirective | function getGenericDirective(prefix, attrName, filterType, isBind, isFilter) {
var directiveName = prefix + attrName.substring(0, 1).toUpperCase() + attrName.substring(1);
var config = this.pancakes.cook('config', null);
var i18n = this.pancakes.cook('i18n', null);
var eventBus = this.pancakes.cook('eventBus', null);
var me = this;
return function (scope, element, attrs) {
var originalValue = attrs[directiveName];
var boundValue = isBind ? me.getNestedValue(scope, originalValue) : originalValue;
var value = boundValue;
var useSSL, staticFileRoot, status;
// if we are using a file filter, add the static file root
if (isFilter && filterType === 'file' && config && config.staticFiles) {
useSSL = (config[scope.appName] && config[scope.appName].useSSL !== undefined) ?
config[scope.appName].useSSL : config.useSSL;
staticFileRoot = config.staticFiles.assets;
staticFileRoot = (staticFileRoot.charAt(0) === '/') ? staticFileRoot :
((useSSL ? 'https://' : 'http://') + config.staticFiles.assets + '/');
value = staticFileRoot + value;
}
// else for i18n filter, try to translate
else if (isFilter && filterType === 'i18n' && i18n && i18n.translate) {
//var cls = require('continuation-local-storage');
//var session = cls.getNamespace('appSession');
//var appName = (session && session.active && session.get('app')) || 'contact';
//var lang = (session && session.active && session.get('lang')) || 'en';
status = {};
value = i18n.translate(value, scope, status);
// this is only done when we are in i18nDebug mode which is used to figure out
// where we have missing translations
if (status.missing) {
eventBus.emit('i18n.missing', {
lang: status.lang,
text: boundValue,
appName: status.app,
binding: originalValue,
directive: directiveName,
context: JSON.stringify(element)
});
}
}
if (attrName === 'text') {
element.text(value);
}
else if (attrName === 'class') {
attrs.$addClass(value);
}
else {
value = value ? value.replace(/"/g, '') : value;
attrs.$set(attrName, value, scope);
}
// attrName === 'text' ?
// element.text(value) :
// attrName === 'class' ?
// attrs.$addClass(value) :
// attrs.$set(attrName, value, scope);
};
} | javascript | function getGenericDirective(prefix, attrName, filterType, isBind, isFilter) {
var directiveName = prefix + attrName.substring(0, 1).toUpperCase() + attrName.substring(1);
var config = this.pancakes.cook('config', null);
var i18n = this.pancakes.cook('i18n', null);
var eventBus = this.pancakes.cook('eventBus', null);
var me = this;
return function (scope, element, attrs) {
var originalValue = attrs[directiveName];
var boundValue = isBind ? me.getNestedValue(scope, originalValue) : originalValue;
var value = boundValue;
var useSSL, staticFileRoot, status;
// if we are using a file filter, add the static file root
if (isFilter && filterType === 'file' && config && config.staticFiles) {
useSSL = (config[scope.appName] && config[scope.appName].useSSL !== undefined) ?
config[scope.appName].useSSL : config.useSSL;
staticFileRoot = config.staticFiles.assets;
staticFileRoot = (staticFileRoot.charAt(0) === '/') ? staticFileRoot :
((useSSL ? 'https://' : 'http://') + config.staticFiles.assets + '/');
value = staticFileRoot + value;
}
// else for i18n filter, try to translate
else if (isFilter && filterType === 'i18n' && i18n && i18n.translate) {
//var cls = require('continuation-local-storage');
//var session = cls.getNamespace('appSession');
//var appName = (session && session.active && session.get('app')) || 'contact';
//var lang = (session && session.active && session.get('lang')) || 'en';
status = {};
value = i18n.translate(value, scope, status);
// this is only done when we are in i18nDebug mode which is used to figure out
// where we have missing translations
if (status.missing) {
eventBus.emit('i18n.missing', {
lang: status.lang,
text: boundValue,
appName: status.app,
binding: originalValue,
directive: directiveName,
context: JSON.stringify(element)
});
}
}
if (attrName === 'text') {
element.text(value);
}
else if (attrName === 'class') {
attrs.$addClass(value);
}
else {
value = value ? value.replace(/"/g, '') : value;
attrs.$set(attrName, value, scope);
}
// attrName === 'text' ?
// element.text(value) :
// attrName === 'class' ?
// attrs.$addClass(value) :
// attrs.$set(attrName, value, scope);
};
} | [
"function",
"getGenericDirective",
"(",
"prefix",
",",
"attrName",
",",
"filterType",
",",
"isBind",
",",
"isFilter",
")",
"{",
"var",
"directiveName",
"=",
"prefix",
"+",
"attrName",
".",
"substring",
"(",
"0",
",",
"1",
")",
".",
"toUpperCase",
"(",
")",
"+",
"attrName",
".",
"substring",
"(",
"1",
")",
";",
"var",
"config",
"=",
"this",
".",
"pancakes",
".",
"cook",
"(",
"'config'",
",",
"null",
")",
";",
"var",
"i18n",
"=",
"this",
".",
"pancakes",
".",
"cook",
"(",
"'i18n'",
",",
"null",
")",
";",
"var",
"eventBus",
"=",
"this",
".",
"pancakes",
".",
"cook",
"(",
"'eventBus'",
",",
"null",
")",
";",
"var",
"me",
"=",
"this",
";",
"return",
"function",
"(",
"scope",
",",
"element",
",",
"attrs",
")",
"{",
"var",
"originalValue",
"=",
"attrs",
"[",
"directiveName",
"]",
";",
"var",
"boundValue",
"=",
"isBind",
"?",
"me",
".",
"getNestedValue",
"(",
"scope",
",",
"originalValue",
")",
":",
"originalValue",
";",
"var",
"value",
"=",
"boundValue",
";",
"var",
"useSSL",
",",
"staticFileRoot",
",",
"status",
";",
"// if we are using a file filter, add the static file root",
"if",
"(",
"isFilter",
"&&",
"filterType",
"===",
"'file'",
"&&",
"config",
"&&",
"config",
".",
"staticFiles",
")",
"{",
"useSSL",
"=",
"(",
"config",
"[",
"scope",
".",
"appName",
"]",
"&&",
"config",
"[",
"scope",
".",
"appName",
"]",
".",
"useSSL",
"!==",
"undefined",
")",
"?",
"config",
"[",
"scope",
".",
"appName",
"]",
".",
"useSSL",
":",
"config",
".",
"useSSL",
";",
"staticFileRoot",
"=",
"config",
".",
"staticFiles",
".",
"assets",
";",
"staticFileRoot",
"=",
"(",
"staticFileRoot",
".",
"charAt",
"(",
"0",
")",
"===",
"'/'",
")",
"?",
"staticFileRoot",
":",
"(",
"(",
"useSSL",
"?",
"'https://'",
":",
"'http://'",
")",
"+",
"config",
".",
"staticFiles",
".",
"assets",
"+",
"'/'",
")",
";",
"value",
"=",
"staticFileRoot",
"+",
"value",
";",
"}",
"// else for i18n filter, try to translate",
"else",
"if",
"(",
"isFilter",
"&&",
"filterType",
"===",
"'i18n'",
"&&",
"i18n",
"&&",
"i18n",
".",
"translate",
")",
"{",
"//var cls = require('continuation-local-storage');",
"//var session = cls.getNamespace('appSession');",
"//var appName = (session && session.active && session.get('app')) || 'contact';",
"//var lang = (session && session.active && session.get('lang')) || 'en';",
"status",
"=",
"{",
"}",
";",
"value",
"=",
"i18n",
".",
"translate",
"(",
"value",
",",
"scope",
",",
"status",
")",
";",
"// this is only done when we are in i18nDebug mode which is used to figure out",
"// where we have missing translations",
"if",
"(",
"status",
".",
"missing",
")",
"{",
"eventBus",
".",
"emit",
"(",
"'i18n.missing'",
",",
"{",
"lang",
":",
"status",
".",
"lang",
",",
"text",
":",
"boundValue",
",",
"appName",
":",
"status",
".",
"app",
",",
"binding",
":",
"originalValue",
",",
"directive",
":",
"directiveName",
",",
"context",
":",
"JSON",
".",
"stringify",
"(",
"element",
")",
"}",
")",
";",
"}",
"}",
"if",
"(",
"attrName",
"===",
"'text'",
")",
"{",
"element",
".",
"text",
"(",
"value",
")",
";",
"}",
"else",
"if",
"(",
"attrName",
"===",
"'class'",
")",
"{",
"attrs",
".",
"$addClass",
"(",
"value",
")",
";",
"}",
"else",
"{",
"value",
"=",
"value",
"?",
"value",
".",
"replace",
"(",
"/",
"\"",
"/",
"g",
",",
"''",
")",
":",
"value",
";",
"attrs",
".",
"$set",
"(",
"attrName",
",",
"value",
",",
"scope",
")",
";",
"}",
"// attrName === 'text' ?",
"// element.text(value) :",
"// attrName === 'class' ?",
"// attrs.$addClass(value) :",
"// attrs.$set(attrName, value, scope);",
"}",
";",
"}"
] | Get a generic directive
@param prefix
@param attrName
@param filterType
@param isBind
@param isFilter
@returns {Function} | [
"Get",
"a",
"generic",
"directive"
] | 9589b7ba09619843e271293088005c62ed23f355 | https://github.com/gethuman/pancakes-angular/blob/9589b7ba09619843e271293088005c62ed23f355/lib/middleware/jng.directives.js#L308-L371 |
52,363 | gethuman/pancakes-angular | lib/middleware/jng.directives.js | getGenericDirectives | function getGenericDirectives() {
var directives = {};
var genericDirectives = {
'src': 'file',
'title': 'i18n',
'placeholder': 'i18n',
'popover': 'i18n',
'value': 'i18n',
'alt': 'i18n',
'text': 'i18n',
'id': null,
'type': null,
'class': null
};
var me = this;
_.each(genericDirectives, function (type, attr) {
// no b-class because it is just adding classes one time
if (attr !== 'class') {
directives['b-' + attr] = me.getGenericDirective('b', attr, null, true, false);
}
directives['bo-' + attr] = me.getGenericDirective('bo', attr, null, true, false);
if (type) {
directives['f-' + attr] = me.getGenericDirective('f', attr, type, false, true);
directives['fo-' + attr] = me.getGenericDirective('fo', attr, type, false, true);
directives['bf-' + attr] = me.getGenericDirective('bf', attr, type, true, true);
directives['bfo-' + attr] = me.getGenericDirective('bfo', attr, type, true, true);
}
});
return directives;
} | javascript | function getGenericDirectives() {
var directives = {};
var genericDirectives = {
'src': 'file',
'title': 'i18n',
'placeholder': 'i18n',
'popover': 'i18n',
'value': 'i18n',
'alt': 'i18n',
'text': 'i18n',
'id': null,
'type': null,
'class': null
};
var me = this;
_.each(genericDirectives, function (type, attr) {
// no b-class because it is just adding classes one time
if (attr !== 'class') {
directives['b-' + attr] = me.getGenericDirective('b', attr, null, true, false);
}
directives['bo-' + attr] = me.getGenericDirective('bo', attr, null, true, false);
if (type) {
directives['f-' + attr] = me.getGenericDirective('f', attr, type, false, true);
directives['fo-' + attr] = me.getGenericDirective('fo', attr, type, false, true);
directives['bf-' + attr] = me.getGenericDirective('bf', attr, type, true, true);
directives['bfo-' + attr] = me.getGenericDirective('bfo', attr, type, true, true);
}
});
return directives;
} | [
"function",
"getGenericDirectives",
"(",
")",
"{",
"var",
"directives",
"=",
"{",
"}",
";",
"var",
"genericDirectives",
"=",
"{",
"'src'",
":",
"'file'",
",",
"'title'",
":",
"'i18n'",
",",
"'placeholder'",
":",
"'i18n'",
",",
"'popover'",
":",
"'i18n'",
",",
"'value'",
":",
"'i18n'",
",",
"'alt'",
":",
"'i18n'",
",",
"'text'",
":",
"'i18n'",
",",
"'id'",
":",
"null",
",",
"'type'",
":",
"null",
",",
"'class'",
":",
"null",
"}",
";",
"var",
"me",
"=",
"this",
";",
"_",
".",
"each",
"(",
"genericDirectives",
",",
"function",
"(",
"type",
",",
"attr",
")",
"{",
"// no b-class because it is just adding classes one time",
"if",
"(",
"attr",
"!==",
"'class'",
")",
"{",
"directives",
"[",
"'b-'",
"+",
"attr",
"]",
"=",
"me",
".",
"getGenericDirective",
"(",
"'b'",
",",
"attr",
",",
"null",
",",
"true",
",",
"false",
")",
";",
"}",
"directives",
"[",
"'bo-'",
"+",
"attr",
"]",
"=",
"me",
".",
"getGenericDirective",
"(",
"'bo'",
",",
"attr",
",",
"null",
",",
"true",
",",
"false",
")",
";",
"if",
"(",
"type",
")",
"{",
"directives",
"[",
"'f-'",
"+",
"attr",
"]",
"=",
"me",
".",
"getGenericDirective",
"(",
"'f'",
",",
"attr",
",",
"type",
",",
"false",
",",
"true",
")",
";",
"directives",
"[",
"'fo-'",
"+",
"attr",
"]",
"=",
"me",
".",
"getGenericDirective",
"(",
"'fo'",
",",
"attr",
",",
"type",
",",
"false",
",",
"true",
")",
";",
"directives",
"[",
"'bf-'",
"+",
"attr",
"]",
"=",
"me",
".",
"getGenericDirective",
"(",
"'bf'",
",",
"attr",
",",
"type",
",",
"true",
",",
"true",
")",
";",
"directives",
"[",
"'bfo-'",
"+",
"attr",
"]",
"=",
"me",
".",
"getGenericDirective",
"(",
"'bfo'",
",",
"attr",
",",
"type",
",",
"true",
",",
"true",
")",
";",
"}",
"}",
")",
";",
"return",
"directives",
";",
"}"
] | Add generic directives. This functionality should match up to the generic.directives.js
client side code. | [
"Add",
"generic",
"directives",
".",
"This",
"functionality",
"should",
"match",
"up",
"to",
"the",
"generic",
".",
"directives",
".",
"js",
"client",
"side",
"code",
"."
] | 9589b7ba09619843e271293088005c62ed23f355 | https://github.com/gethuman/pancakes-angular/blob/9589b7ba09619843e271293088005c62ed23f355/lib/middleware/jng.directives.js#L377-L411 |
52,364 | gethuman/pancakes-angular | lib/middleware/jng.directives.js | addDirectivesToJangular | function addDirectivesToJangular(directives) {
_.each(directives, function (directive, directiveName) {
jangular.addDirective(directiveName, directive);
});
} | javascript | function addDirectivesToJangular(directives) {
_.each(directives, function (directive, directiveName) {
jangular.addDirective(directiveName, directive);
});
} | [
"function",
"addDirectivesToJangular",
"(",
"directives",
")",
"{",
"_",
".",
"each",
"(",
"directives",
",",
"function",
"(",
"directive",
",",
"directiveName",
")",
"{",
"jangular",
".",
"addDirective",
"(",
"directiveName",
",",
"directive",
")",
";",
"}",
")",
";",
"}"
] | Add directives to jangular
@param directives | [
"Add",
"directives",
"to",
"jangular"
] | 9589b7ba09619843e271293088005c62ed23f355 | https://github.com/gethuman/pancakes-angular/blob/9589b7ba09619843e271293088005c62ed23f355/lib/middleware/jng.directives.js#L417-L421 |
52,365 | cemtopkaya/kuark-db | src/db_rol.js | f_rol_tumu | function f_rol_tumu(_tahta_id) {
return result.dbQ.smembers(result.kp.tahta.ssetOzelTahtaRolleri(_tahta_id, true))
.then(function (_rol_idler) {
return f_rol_id(_rol_idler);
});
} | javascript | function f_rol_tumu(_tahta_id) {
return result.dbQ.smembers(result.kp.tahta.ssetOzelTahtaRolleri(_tahta_id, true))
.then(function (_rol_idler) {
return f_rol_id(_rol_idler);
});
} | [
"function",
"f_rol_tumu",
"(",
"_tahta_id",
")",
"{",
"return",
"result",
".",
"dbQ",
".",
"smembers",
"(",
"result",
".",
"kp",
".",
"tahta",
".",
"ssetOzelTahtaRolleri",
"(",
"_tahta_id",
",",
"true",
")",
")",
".",
"then",
"(",
"function",
"(",
"_rol_idler",
")",
"{",
"return",
"f_rol_id",
"(",
"_rol_idler",
")",
";",
"}",
")",
";",
"}"
] | endregion region ROLLER | [
"endregion",
"region",
"ROLLER"
] | d584aaf51f65a013bec79220a05007bd70767ac2 | https://github.com/cemtopkaya/kuark-db/blob/d584aaf51f65a013bec79220a05007bd70767ac2/src/db_rol.js#L63-L68 |
52,366 | usenode/litmus.js | lib/commandline.js | getLitmusForModule | function getLitmusForModule (module) {
if (isLitmus(module)) {
return module;
}
if (module.test && isLitmus(module.test)) {
return module.test;
}
throw new Error('litmus: expected module to export litmus.Test or litmus.Suite');
} | javascript | function getLitmusForModule (module) {
if (isLitmus(module)) {
return module;
}
if (module.test && isLitmus(module.test)) {
return module.test;
}
throw new Error('litmus: expected module to export litmus.Test or litmus.Suite');
} | [
"function",
"getLitmusForModule",
"(",
"module",
")",
"{",
"if",
"(",
"isLitmus",
"(",
"module",
")",
")",
"{",
"return",
"module",
";",
"}",
"if",
"(",
"module",
".",
"test",
"&&",
"isLitmus",
"(",
"module",
".",
"test",
")",
")",
"{",
"return",
"module",
".",
"test",
";",
"}",
"throw",
"new",
"Error",
"(",
"'litmus: expected module to export litmus.Test or litmus.Suite'",
")",
";",
"}"
] | Find the litmus.Test or litmus.Suite for a module.
Previous versions of litmus expected this to be exposed under a 'test' key. | [
"Find",
"the",
"litmus",
".",
"Test",
"or",
"litmus",
".",
"Suite",
"for",
"a",
"module",
".",
"Previous",
"versions",
"of",
"litmus",
"expected",
"this",
"to",
"be",
"exposed",
"under",
"a",
"test",
"key",
"."
] | 8bed2ea18a925f4590387556b6438f3a15ea82c0 | https://github.com/usenode/litmus.js/blob/8bed2ea18a925f4590387556b6438f3a15ea82c0/lib/commandline.js#L113-L124 |
52,367 | markhuge/aws-sdk-sugar | lib/elb.js | function (elbName, cb) {
query(elbName, function (err, data) {
if (err) return cb(err);
var result = [];
data.Instances.map(function (item) { result.push(item.InstanceId); });
cb(undefined, result);
});
} | javascript | function (elbName, cb) {
query(elbName, function (err, data) {
if (err) return cb(err);
var result = [];
data.Instances.map(function (item) { result.push(item.InstanceId); });
cb(undefined, result);
});
} | [
"function",
"(",
"elbName",
",",
"cb",
")",
"{",
"query",
"(",
"elbName",
",",
"function",
"(",
"err",
",",
"data",
")",
"{",
"if",
"(",
"err",
")",
"return",
"cb",
"(",
"err",
")",
";",
"var",
"result",
"=",
"[",
"]",
";",
"data",
".",
"Instances",
".",
"map",
"(",
"function",
"(",
"item",
")",
"{",
"result",
".",
"push",
"(",
"item",
".",
"InstanceId",
")",
";",
"}",
")",
";",
"cb",
"(",
"undefined",
",",
"result",
")",
";",
"}",
")",
";",
"}"
] | List instances in ELB | [
"List",
"instances",
"in",
"ELB"
] | 16f8c1275b3f730c57d06aece6ebb0a34e492163 | https://github.com/markhuge/aws-sdk-sugar/blob/16f8c1275b3f730c57d06aece6ebb0a34e492163/lib/elb.js#L23-L30 |
|
52,368 | vkiding/jud-vue-render | src/render/browser/base/component/index.js | isEventValid | function isEventValid (comp, type) {
// if a component has aleary triggered 'appear' event, then
// the 'appear' even† can't be triggered again utill the
// 'disappear' event triggered.
if (appearEvts.indexOf(type) <= -1) {
return true
}
if (comp._appear === undefined && type === 'disappear') {
return false
}
let res
if (comp._appear === undefined && type === 'appear') {
res = true
}
else {
res = type !== comp._appear
}
res && (comp._appear = type)
return res
} | javascript | function isEventValid (comp, type) {
// if a component has aleary triggered 'appear' event, then
// the 'appear' even† can't be triggered again utill the
// 'disappear' event triggered.
if (appearEvts.indexOf(type) <= -1) {
return true
}
if (comp._appear === undefined && type === 'disappear') {
return false
}
let res
if (comp._appear === undefined && type === 'appear') {
res = true
}
else {
res = type !== comp._appear
}
res && (comp._appear = type)
return res
} | [
"function",
"isEventValid",
"(",
"comp",
",",
"type",
")",
"{",
"// if a component has aleary triggered 'appear' event, then",
"// the 'appear' even† can't be triggered again utill the",
"// 'disappear' event triggered.",
"if",
"(",
"appearEvts",
".",
"indexOf",
"(",
"type",
")",
"<=",
"-",
"1",
")",
"{",
"return",
"true",
"}",
"if",
"(",
"comp",
".",
"_appear",
"===",
"undefined",
"&&",
"type",
"===",
"'disappear'",
")",
"{",
"return",
"false",
"}",
"let",
"res",
"if",
"(",
"comp",
".",
"_appear",
"===",
"undefined",
"&&",
"type",
"===",
"'appear'",
")",
"{",
"res",
"=",
"true",
"}",
"else",
"{",
"res",
"=",
"type",
"!==",
"comp",
".",
"_appear",
"}",
"res",
"&&",
"(",
"comp",
".",
"_appear",
"=",
"type",
")",
"return",
"res",
"}"
] | check whether a event is valid to dispatch.
@param {Component} comp the component that this event is to trigger on.
@param {string} type the event type.
@return {Boolean} is it valid to dispatch. | [
"check",
"whether",
"a",
"event",
"is",
"valid",
"to",
"dispatch",
"."
] | 07d8ab08d0ef86cf2819e5f2bf1f4b06381f4d47 | https://github.com/vkiding/jud-vue-render/blob/07d8ab08d0ef86cf2819e5f2bf1f4b06381f4d47/src/render/browser/base/component/index.js#L19-L38 |
52,369 | rm3web/textblocks | lib/textblock.js | splitIntoSlabs | function splitIntoSlabs(str) {
var slabs = str.split('<!-- TEXTBLOCK -->');
return slabs.map(function(val, index, array) {
if (index % 2 == 1) {
var rawAttr = val.match(/<code>(.*)<\/code>/);
var attrs = JSON.parse(decodeURI(rawAttr[1]));
return attrs;
} else {
return val;
}
});
} | javascript | function splitIntoSlabs(str) {
var slabs = str.split('<!-- TEXTBLOCK -->');
return slabs.map(function(val, index, array) {
if (index % 2 == 1) {
var rawAttr = val.match(/<code>(.*)<\/code>/);
var attrs = JSON.parse(decodeURI(rawAttr[1]));
return attrs;
} else {
return val;
}
});
} | [
"function",
"splitIntoSlabs",
"(",
"str",
")",
"{",
"var",
"slabs",
"=",
"str",
".",
"split",
"(",
"'<!-- TEXTBLOCK -->'",
")",
";",
"return",
"slabs",
".",
"map",
"(",
"function",
"(",
"val",
",",
"index",
",",
"array",
")",
"{",
"if",
"(",
"index",
"%",
"2",
"==",
"1",
")",
"{",
"var",
"rawAttr",
"=",
"val",
".",
"match",
"(",
"/",
"<code>(.*)<\\/code>",
"/",
")",
";",
"var",
"attrs",
"=",
"JSON",
".",
"parse",
"(",
"decodeURI",
"(",
"rawAttr",
"[",
"1",
"]",
")",
")",
";",
"return",
"attrs",
";",
"}",
"else",
"{",
"return",
"val",
";",
"}",
"}",
")",
";",
"}"
] | Split into slabs, undoing the placeholders created in generatePlaceholder
@param {String} str The string to convert back to slabs
@return {Array} Slabs that have been broken out | [
"Split",
"into",
"slabs",
"undoing",
"the",
"placeholders",
"created",
"in",
"generatePlaceholder"
] | 5c3896a66339c6de64de691fc6bacd4f4626ce1b | https://github.com/rm3web/textblocks/blob/5c3896a66339c6de64de691fc6bacd4f4626ce1b/lib/textblock.js#L103-L114 |
52,370 | rm3web/textblocks | lib/textblock.js | function(source, format, ctx) {
if (inputFormats.hasOwnProperty(format)) {
return inputFormats[format](source, ctx);
} else {
throw new Error('invalid format to make a text block from: ' + source.format);
}
} | javascript | function(source, format, ctx) {
if (inputFormats.hasOwnProperty(format)) {
return inputFormats[format](source, ctx);
} else {
throw new Error('invalid format to make a text block from: ' + source.format);
}
} | [
"function",
"(",
"source",
",",
"format",
",",
"ctx",
")",
"{",
"if",
"(",
"inputFormats",
".",
"hasOwnProperty",
"(",
"format",
")",
")",
"{",
"return",
"inputFormats",
"[",
"format",
"]",
"(",
"source",
",",
"ctx",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Error",
"(",
"'invalid format to make a text block from: '",
"+",
"source",
".",
"format",
")",
";",
"}",
"}"
] | Make a text block from source
@param {String} source The source to make a text block from
@param {String} format The format to use
@param {Object} ctx An object to be passed to all of the rendering functions
@return {Object} a new textblock | [
"Make",
"a",
"text",
"block",
"from",
"source"
] | 5c3896a66339c6de64de691fc6bacd4f4626ce1b | https://github.com/rm3web/textblocks/blob/5c3896a66339c6de64de691fc6bacd4f4626ce1b/lib/textblock.js#L188-L194 |
|
52,371 | rm3web/textblocks | lib/textblock.js | function(source, ctx) {
if (source.hasOwnProperty('format')) {
if (validateFormats.hasOwnProperty(source.format)) {
return validateFormats[source.format](source, ctx);
} else {
throw new Error('invalid format for textblock: ' + source.format);
}
}
throw new Error('invalid format for textblock (did you pass an Object in?)');
} | javascript | function(source, ctx) {
if (source.hasOwnProperty('format')) {
if (validateFormats.hasOwnProperty(source.format)) {
return validateFormats[source.format](source, ctx);
} else {
throw new Error('invalid format for textblock: ' + source.format);
}
}
throw new Error('invalid format for textblock (did you pass an Object in?)');
} | [
"function",
"(",
"source",
",",
"ctx",
")",
"{",
"if",
"(",
"source",
".",
"hasOwnProperty",
"(",
"'format'",
")",
")",
"{",
"if",
"(",
"validateFormats",
".",
"hasOwnProperty",
"(",
"source",
".",
"format",
")",
")",
"{",
"return",
"validateFormats",
"[",
"source",
".",
"format",
"]",
"(",
"source",
",",
"ctx",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Error",
"(",
"'invalid format for textblock: '",
"+",
"source",
".",
"format",
")",
";",
"}",
"}",
"throw",
"new",
"Error",
"(",
"'invalid format for textblock (did you pass an Object in?)'",
")",
";",
"}"
] | Validate a text blocks
@param {String} source The source untrusted text block
@param {Object} ctx An object to be passed to all of the rendering functions
@return {Object} a cleaned text block | [
"Validate",
"a",
"text",
"blocks"
] | 5c3896a66339c6de64de691fc6bacd4f4626ce1b | https://github.com/rm3web/textblocks/blob/5c3896a66339c6de64de691fc6bacd4f4626ce1b/lib/textblock.js#L202-L211 |
|
52,372 | rm3web/textblocks | lib/textblock.js | function(source, type) {
if (source.hasOwnProperty('format')) {
if (source.format !== type) {
if (source.format === 'section') {
var blocks = [];
source.blocks.forEach(function(val, index, array) {
var block = deleteTextBlockFormat(val, type);
if (block) {
blocks.push(block);
}
});
if (blocks.length) {
return {format: 'section', blocks: blocks};
} else {
return null;
}
} else {
return source;
}
} else {
return null;
}
}
throw new Error('invalid format for textblock (did you pass an Object in?)');
} | javascript | function(source, type) {
if (source.hasOwnProperty('format')) {
if (source.format !== type) {
if (source.format === 'section') {
var blocks = [];
source.blocks.forEach(function(val, index, array) {
var block = deleteTextBlockFormat(val, type);
if (block) {
blocks.push(block);
}
});
if (blocks.length) {
return {format: 'section', blocks: blocks};
} else {
return null;
}
} else {
return source;
}
} else {
return null;
}
}
throw new Error('invalid format for textblock (did you pass an Object in?)');
} | [
"function",
"(",
"source",
",",
"type",
")",
"{",
"if",
"(",
"source",
".",
"hasOwnProperty",
"(",
"'format'",
")",
")",
"{",
"if",
"(",
"source",
".",
"format",
"!==",
"type",
")",
"{",
"if",
"(",
"source",
".",
"format",
"===",
"'section'",
")",
"{",
"var",
"blocks",
"=",
"[",
"]",
";",
"source",
".",
"blocks",
".",
"forEach",
"(",
"function",
"(",
"val",
",",
"index",
",",
"array",
")",
"{",
"var",
"block",
"=",
"deleteTextBlockFormat",
"(",
"val",
",",
"type",
")",
";",
"if",
"(",
"block",
")",
"{",
"blocks",
".",
"push",
"(",
"block",
")",
";",
"}",
"}",
")",
";",
"if",
"(",
"blocks",
".",
"length",
")",
"{",
"return",
"{",
"format",
":",
"'section'",
",",
"blocks",
":",
"blocks",
"}",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}",
"else",
"{",
"return",
"source",
";",
"}",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}",
"throw",
"new",
"Error",
"(",
"'invalid format for textblock (did you pass an Object in?)'",
")",
";",
"}"
] | Delete all blocks with a given format.
@param {String} source The source untrusted text block
@param {String} type The type of block to remove
@return {Object} a cleaned text block | [
"Delete",
"all",
"blocks",
"with",
"a",
"given",
"format",
"."
] | 5c3896a66339c6de64de691fc6bacd4f4626ce1b | https://github.com/rm3web/textblocks/blob/5c3896a66339c6de64de691fc6bacd4f4626ce1b/lib/textblock.js#L219-L243 |
|
52,373 | rm3web/textblocks | lib/textblock.js | function(blocks) {
var blockarr = blocks;
if (!(blockarr instanceof Array)) {
blockarr = [blockarr];
}
return {format: 'section', blocks: blockarr};
} | javascript | function(blocks) {
var blockarr = blocks;
if (!(blockarr instanceof Array)) {
blockarr = [blockarr];
}
return {format: 'section', blocks: blockarr};
} | [
"function",
"(",
"blocks",
")",
"{",
"var",
"blockarr",
"=",
"blocks",
";",
"if",
"(",
"!",
"(",
"blockarr",
"instanceof",
"Array",
")",
")",
"{",
"blockarr",
"=",
"[",
"blockarr",
"]",
";",
"}",
"return",
"{",
"format",
":",
"'section'",
",",
"blocks",
":",
"blockarr",
"}",
";",
"}"
] | Convert one or more blocks into a section
@param {Object|Array} blocks A block or an array of blocks
@return {Object} A text block | [
"Convert",
"one",
"or",
"more",
"blocks",
"into",
"a",
"section"
] | 5c3896a66339c6de64de691fc6bacd4f4626ce1b | https://github.com/rm3web/textblocks/blob/5c3896a66339c6de64de691fc6bacd4f4626ce1b/lib/textblock.js#L250-L256 |
|
52,374 | rm3web/textblocks | lib/textblock.js | function(block, pos, ctx, callback) {
if (block.hasOwnProperty('htmlslabs')) {
outputSlabs(block.htmlslabs, ctx, callback);
} else {
if (formats.hasOwnProperty(block.format)) {
formats[block.format](block, pos, ctx, callback);
} else {
callback(new Error('unknown format: ' + block.format));
}
}
} | javascript | function(block, pos, ctx, callback) {
if (block.hasOwnProperty('htmlslabs')) {
outputSlabs(block.htmlslabs, ctx, callback);
} else {
if (formats.hasOwnProperty(block.format)) {
formats[block.format](block, pos, ctx, callback);
} else {
callback(new Error('unknown format: ' + block.format));
}
}
} | [
"function",
"(",
"block",
",",
"pos",
",",
"ctx",
",",
"callback",
")",
"{",
"if",
"(",
"block",
".",
"hasOwnProperty",
"(",
"'htmlslabs'",
")",
")",
"{",
"outputSlabs",
"(",
"block",
".",
"htmlslabs",
",",
"ctx",
",",
"callback",
")",
";",
"}",
"else",
"{",
"if",
"(",
"formats",
".",
"hasOwnProperty",
"(",
"block",
".",
"format",
")",
")",
"{",
"formats",
"[",
"block",
".",
"format",
"]",
"(",
"block",
",",
"pos",
",",
"ctx",
",",
"callback",
")",
";",
"}",
"else",
"{",
"callback",
"(",
"new",
"Error",
"(",
"'unknown format: '",
"+",
"block",
".",
"format",
")",
")",
";",
"}",
"}",
"}"
] | Output a text block in HTML.
Warning: This assumes that you have used validateTextBlock or makeTextBlock
to ensure a valid XSS-free textblock.
@param {Object} block The text block to be output
@param {String} pos The position to start adding suffixes to (useful for generating links or pagination)
@param {Object} ctx An object to be passed to all of the rendering functions
@param {Function} callback A callback called with (err, text) | [
"Output",
"a",
"text",
"block",
"in",
"HTML",
"."
] | 5c3896a66339c6de64de691fc6bacd4f4626ce1b | https://github.com/rm3web/textblocks/blob/5c3896a66339c6de64de691fc6bacd4f4626ce1b/lib/textblock.js#L295-L305 |
|
52,375 | rm3web/textblocks | lib/textblock.js | function(block) {
if (block.hasOwnProperty('htmlslabs')) {
return outputSlabsAsText(block.htmlslabs);
} else {
if (block.format === 'section') {
return block.blocks.reduce(function(previousValue, currentValue, currentIndex, array) {
return previousValue + extractTextBlockText(currentValue);
}, '');
} else {
return '';
}
}
} | javascript | function(block) {
if (block.hasOwnProperty('htmlslabs')) {
return outputSlabsAsText(block.htmlslabs);
} else {
if (block.format === 'section') {
return block.blocks.reduce(function(previousValue, currentValue, currentIndex, array) {
return previousValue + extractTextBlockText(currentValue);
}, '');
} else {
return '';
}
}
} | [
"function",
"(",
"block",
")",
"{",
"if",
"(",
"block",
".",
"hasOwnProperty",
"(",
"'htmlslabs'",
")",
")",
"{",
"return",
"outputSlabsAsText",
"(",
"block",
".",
"htmlslabs",
")",
";",
"}",
"else",
"{",
"if",
"(",
"block",
".",
"format",
"===",
"'section'",
")",
"{",
"return",
"block",
".",
"blocks",
".",
"reduce",
"(",
"function",
"(",
"previousValue",
",",
"currentValue",
",",
"currentIndex",
",",
"array",
")",
"{",
"return",
"previousValue",
"+",
"extractTextBlockText",
"(",
"currentValue",
")",
";",
"}",
",",
"''",
")",
";",
"}",
"else",
"{",
"return",
"''",
";",
"}",
"}",
"}"
] | Output a text block as plain-text
@param {Object} block The text block to be output
@return {String} the textual content, sans enhancement and HTML | [
"Output",
"a",
"text",
"block",
"as",
"plain",
"-",
"text"
] | 5c3896a66339c6de64de691fc6bacd4f4626ce1b | https://github.com/rm3web/textblocks/blob/5c3896a66339c6de64de691fc6bacd4f4626ce1b/lib/textblock.js#L313-L325 |
|
52,376 | redisjs/jsr-server | lib/command/database/key/scan.js | execute | function execute(req, res) {
var scanner = new Scanner(
req.db.getKeys(), req.info.cursor, req.info.pattern, req.info.count);
scanner.scan(req, res);
} | javascript | function execute(req, res) {
var scanner = new Scanner(
req.db.getKeys(), req.info.cursor, req.info.pattern, req.info.count);
scanner.scan(req, res);
} | [
"function",
"execute",
"(",
"req",
",",
"res",
")",
"{",
"var",
"scanner",
"=",
"new",
"Scanner",
"(",
"req",
".",
"db",
".",
"getKeys",
"(",
")",
",",
"req",
".",
"info",
".",
"cursor",
",",
"req",
".",
"info",
".",
"pattern",
",",
"req",
".",
"info",
".",
"count",
")",
";",
"scanner",
".",
"scan",
"(",
"req",
",",
"res",
")",
";",
"}"
] | Respond to the SCAN command. | [
"Respond",
"to",
"the",
"SCAN",
"command",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/database/key/scan.js#L29-L33 |
52,377 | redisjs/jsr-server | lib/command/database/key/scan.js | validate | function validate(cmd, args, info) {
AbstractCommand.prototype.validate.apply(this, arguments);
var offset = info.exec.offset
, arg = args[offset];
if(args.length > offset + 4) {
throw new CommandArgLength(info.exec.definition.name);
}
// cursor already parsed to integer by numeric validation
info.cursor = args[offset - 1]
//console.dir(args);
if(arg !== undefined) {
arg = (('' + arg).toLowerCase());
while(arg !== undefined) {
//console.dir(arg);
if(arg !== Constants.SCAN.MATCH && arg !== Constants.SCAN.COUNT) {
throw CommandSyntax;
}else if(arg === Constants.SCAN.MATCH) {
/* istanbul ignore next: really tough to get a pattern compile error! */
try {
info.pattern = Pattern.compile(args[offset + 1]);
}catch(e) {
throw PatternCompile;
}
// should be on count arg
}else{
info.count = parseInt('' + args[offset + 1]);
if(isNaN(info.count)) {
throw IntegerRange;
}
}
offset+=2;
arg = args[offset] ? '' + args[offset] : undefined;
}
}
} | javascript | function validate(cmd, args, info) {
AbstractCommand.prototype.validate.apply(this, arguments);
var offset = info.exec.offset
, arg = args[offset];
if(args.length > offset + 4) {
throw new CommandArgLength(info.exec.definition.name);
}
// cursor already parsed to integer by numeric validation
info.cursor = args[offset - 1]
//console.dir(args);
if(arg !== undefined) {
arg = (('' + arg).toLowerCase());
while(arg !== undefined) {
//console.dir(arg);
if(arg !== Constants.SCAN.MATCH && arg !== Constants.SCAN.COUNT) {
throw CommandSyntax;
}else if(arg === Constants.SCAN.MATCH) {
/* istanbul ignore next: really tough to get a pattern compile error! */
try {
info.pattern = Pattern.compile(args[offset + 1]);
}catch(e) {
throw PatternCompile;
}
// should be on count arg
}else{
info.count = parseInt('' + args[offset + 1]);
if(isNaN(info.count)) {
throw IntegerRange;
}
}
offset+=2;
arg = args[offset] ? '' + args[offset] : undefined;
}
}
} | [
"function",
"validate",
"(",
"cmd",
",",
"args",
",",
"info",
")",
"{",
"AbstractCommand",
".",
"prototype",
".",
"validate",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"var",
"offset",
"=",
"info",
".",
"exec",
".",
"offset",
",",
"arg",
"=",
"args",
"[",
"offset",
"]",
";",
"if",
"(",
"args",
".",
"length",
">",
"offset",
"+",
"4",
")",
"{",
"throw",
"new",
"CommandArgLength",
"(",
"info",
".",
"exec",
".",
"definition",
".",
"name",
")",
";",
"}",
"// cursor already parsed to integer by numeric validation",
"info",
".",
"cursor",
"=",
"args",
"[",
"offset",
"-",
"1",
"]",
"//console.dir(args);",
"if",
"(",
"arg",
"!==",
"undefined",
")",
"{",
"arg",
"=",
"(",
"(",
"''",
"+",
"arg",
")",
".",
"toLowerCase",
"(",
")",
")",
";",
"while",
"(",
"arg",
"!==",
"undefined",
")",
"{",
"//console.dir(arg);",
"if",
"(",
"arg",
"!==",
"Constants",
".",
"SCAN",
".",
"MATCH",
"&&",
"arg",
"!==",
"Constants",
".",
"SCAN",
".",
"COUNT",
")",
"{",
"throw",
"CommandSyntax",
";",
"}",
"else",
"if",
"(",
"arg",
"===",
"Constants",
".",
"SCAN",
".",
"MATCH",
")",
"{",
"/* istanbul ignore next: really tough to get a pattern compile error! */",
"try",
"{",
"info",
".",
"pattern",
"=",
"Pattern",
".",
"compile",
"(",
"args",
"[",
"offset",
"+",
"1",
"]",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"throw",
"PatternCompile",
";",
"}",
"// should be on count arg",
"}",
"else",
"{",
"info",
".",
"count",
"=",
"parseInt",
"(",
"''",
"+",
"args",
"[",
"offset",
"+",
"1",
"]",
")",
";",
"if",
"(",
"isNaN",
"(",
"info",
".",
"count",
")",
")",
"{",
"throw",
"IntegerRange",
";",
"}",
"}",
"offset",
"+=",
"2",
";",
"arg",
"=",
"args",
"[",
"offset",
"]",
"?",
"''",
"+",
"args",
"[",
"offset",
"]",
":",
"undefined",
";",
"}",
"}",
"}"
] | Validate the SCAN command. | [
"Validate",
"the",
"SCAN",
"command",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/database/key/scan.js#L38-L76 |
52,378 | aureooms/js-selection | lib/quickselect/singletco.js | singletco | function singletco(partition) {
var select = function select(compare, a, i, j, k) {
while (true) {
if (j - i < 2) return;
var p = partition(compare, a, i, j);
if (k < p) j = p;else if (k > p) i = p + 1;else return;
}
};
return select;
} | javascript | function singletco(partition) {
var select = function select(compare, a, i, j, k) {
while (true) {
if (j - i < 2) return;
var p = partition(compare, a, i, j);
if (k < p) j = p;else if (k > p) i = p + 1;else return;
}
};
return select;
} | [
"function",
"singletco",
"(",
"partition",
")",
"{",
"var",
"select",
"=",
"function",
"select",
"(",
"compare",
",",
"a",
",",
"i",
",",
"j",
",",
"k",
")",
"{",
"while",
"(",
"true",
")",
"{",
"if",
"(",
"j",
"-",
"i",
"<",
"2",
")",
"return",
";",
"var",
"p",
"=",
"partition",
"(",
"compare",
",",
"a",
",",
"i",
",",
"j",
")",
";",
"if",
"(",
"k",
"<",
"p",
")",
"j",
"=",
"p",
";",
"else",
"if",
"(",
"k",
">",
"p",
")",
"i",
"=",
"p",
"+",
"1",
";",
"else",
"return",
";",
"}",
"}",
";",
"return",
"select",
";",
"}"
] | Template for the recursive implementation of quickselect with explicit tail
call optimization. | [
"Template",
"for",
"the",
"recursive",
"implementation",
"of",
"quickselect",
"with",
"explicit",
"tail",
"call",
"optimization",
"."
] | 55d592614e55052ddebe204367a5ada0cddba547 | https://github.com/aureooms/js-selection/blob/55d592614e55052ddebe204367a5ada0cddba547/lib/quickselect/singletco.js#L14-L29 |
52,379 | Nazariglez/perenquen | lib/pixi/src/filters/blur/BlurXFilter.js | BlurXFilter | function BlurXFilter()
{
core.AbstractFilter.call(this,
// vertex shader
fs.readFileSync(__dirname + '/blurX.vert', 'utf8'),
// fragment shader
fs.readFileSync(__dirname + '/blur.frag', 'utf8'),
// set the uniforms
{
strength: { type: '1f', value: 1 }
}
);
/**
* Sets the number of passes for blur. More passes means higher quaility bluring.
*
* @member {number}
* @memberof BlurXFilter#
* @default 1
*/
this.passes = 1;
this.strength = 4;
} | javascript | function BlurXFilter()
{
core.AbstractFilter.call(this,
// vertex shader
fs.readFileSync(__dirname + '/blurX.vert', 'utf8'),
// fragment shader
fs.readFileSync(__dirname + '/blur.frag', 'utf8'),
// set the uniforms
{
strength: { type: '1f', value: 1 }
}
);
/**
* Sets the number of passes for blur. More passes means higher quaility bluring.
*
* @member {number}
* @memberof BlurXFilter#
* @default 1
*/
this.passes = 1;
this.strength = 4;
} | [
"function",
"BlurXFilter",
"(",
")",
"{",
"core",
".",
"AbstractFilter",
".",
"call",
"(",
"this",
",",
"// vertex shader",
"fs",
".",
"readFileSync",
"(",
"__dirname",
"+",
"'/blurX.vert'",
",",
"'utf8'",
")",
",",
"// fragment shader",
"fs",
".",
"readFileSync",
"(",
"__dirname",
"+",
"'/blur.frag'",
",",
"'utf8'",
")",
",",
"// set the uniforms",
"{",
"strength",
":",
"{",
"type",
":",
"'1f'",
",",
"value",
":",
"1",
"}",
"}",
")",
";",
"/**\n * Sets the number of passes for blur. More passes means higher quaility bluring.\n *\n * @member {number}\n * @memberof BlurXFilter#\n * @default 1\n */",
"this",
".",
"passes",
"=",
"1",
";",
"this",
".",
"strength",
"=",
"4",
";",
"}"
] | The BlurXFilter applies a horizontal Gaussian blur to an object.
@class
@extends AbstractFilter
@memberof PIXI.filters | [
"The",
"BlurXFilter",
"applies",
"a",
"horizontal",
"Gaussian",
"blur",
"to",
"an",
"object",
"."
] | e023964d05afeefebdcac4e2044819fdfa3899ae | https://github.com/Nazariglez/perenquen/blob/e023964d05afeefebdcac4e2044819fdfa3899ae/lib/pixi/src/filters/blur/BlurXFilter.js#L12-L35 |
52,380 | meltmedia/node-usher | lib/activity/task.js | ActivityTask | function ActivityTask(task) {
if (!(this instanceof ActivityTask)) {
return new ActivityTask(task);
}
this.input = {};
if (task.config.input) {
this.input = JSON.parse(task.config.input);
}
// Depending on the language of the Decider impl, this can be an Array or Object
// This is a big assumption, maybe make this configurable
if (Array.isArray(this.input)) {
this.input = this.input[0];
}
this.activityId = task.config.activityId;
this.activityType = task.config.activityType;
this.startedEventId = task.config.startedEventId;
this.taskToken = task.config.taskToken;
this.workflowExecution = task.config.workflowExecution;
this._task = task;
// Register a hearbeat callback every 10 seconds
this.hearbeatCount = 0;
this.heartbeatTimer = setInterval(function () {
var self = this;
self._task.recordHeartbeat(
{ activity: self.activityType.name, id: self.activityId, count: self.hearbeatCount++ },
function (err) {
if (err) {
winston.log('debug', 'Heartbead failed for task: %s (%s) due to:', self.activityType.name, self.activityId, err);
}
});
}.bind(this), 10000);
} | javascript | function ActivityTask(task) {
if (!(this instanceof ActivityTask)) {
return new ActivityTask(task);
}
this.input = {};
if (task.config.input) {
this.input = JSON.parse(task.config.input);
}
// Depending on the language of the Decider impl, this can be an Array or Object
// This is a big assumption, maybe make this configurable
if (Array.isArray(this.input)) {
this.input = this.input[0];
}
this.activityId = task.config.activityId;
this.activityType = task.config.activityType;
this.startedEventId = task.config.startedEventId;
this.taskToken = task.config.taskToken;
this.workflowExecution = task.config.workflowExecution;
this._task = task;
// Register a hearbeat callback every 10 seconds
this.hearbeatCount = 0;
this.heartbeatTimer = setInterval(function () {
var self = this;
self._task.recordHeartbeat(
{ activity: self.activityType.name, id: self.activityId, count: self.hearbeatCount++ },
function (err) {
if (err) {
winston.log('debug', 'Heartbead failed for task: %s (%s) due to:', self.activityType.name, self.activityId, err);
}
});
}.bind(this), 10000);
} | [
"function",
"ActivityTask",
"(",
"task",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"ActivityTask",
")",
")",
"{",
"return",
"new",
"ActivityTask",
"(",
"task",
")",
";",
"}",
"this",
".",
"input",
"=",
"{",
"}",
";",
"if",
"(",
"task",
".",
"config",
".",
"input",
")",
"{",
"this",
".",
"input",
"=",
"JSON",
".",
"parse",
"(",
"task",
".",
"config",
".",
"input",
")",
";",
"}",
"// Depending on the language of the Decider impl, this can be an Array or Object",
"// This is a big assumption, maybe make this configurable",
"if",
"(",
"Array",
".",
"isArray",
"(",
"this",
".",
"input",
")",
")",
"{",
"this",
".",
"input",
"=",
"this",
".",
"input",
"[",
"0",
"]",
";",
"}",
"this",
".",
"activityId",
"=",
"task",
".",
"config",
".",
"activityId",
";",
"this",
".",
"activityType",
"=",
"task",
".",
"config",
".",
"activityType",
";",
"this",
".",
"startedEventId",
"=",
"task",
".",
"config",
".",
"startedEventId",
";",
"this",
".",
"taskToken",
"=",
"task",
".",
"config",
".",
"taskToken",
";",
"this",
".",
"workflowExecution",
"=",
"task",
".",
"config",
".",
"workflowExecution",
";",
"this",
".",
"_task",
"=",
"task",
";",
"// Register a hearbeat callback every 10 seconds",
"this",
".",
"hearbeatCount",
"=",
"0",
";",
"this",
".",
"heartbeatTimer",
"=",
"setInterval",
"(",
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"self",
".",
"_task",
".",
"recordHeartbeat",
"(",
"{",
"activity",
":",
"self",
".",
"activityType",
".",
"name",
",",
"id",
":",
"self",
".",
"activityId",
",",
"count",
":",
"self",
".",
"hearbeatCount",
"++",
"}",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"{",
"winston",
".",
"log",
"(",
"'debug'",
",",
"'Heartbead failed for task: %s (%s) due to:'",
",",
"self",
".",
"activityType",
".",
"name",
",",
"self",
".",
"activityId",
",",
"err",
")",
";",
"}",
"}",
")",
";",
"}",
".",
"bind",
"(",
"this",
")",
",",
"10000",
")",
";",
"}"
] | The context for the execution of the activity
@constructor
@param {string} task - The raw `aws-swf` activity task | [
"The",
"context",
"for",
"the",
"execution",
"of",
"the",
"activity"
] | fe6183bf7097f84bef935e8d9c19463accc08ad6 | https://github.com/meltmedia/node-usher/blob/fe6183bf7097f84bef935e8d9c19463accc08ad6/lib/activity/task.js#L19-L56 |
52,381 | lemyskaman/kaman-core | kaman.functions.js | backboneOptsAsProps | function backboneOptsAsProps(subject, opts) {
if (!opts) {
opts = subject.options
}
subject.mergeOptions(subject.options, _.keys(opts));
//removing form view.options the options that ve been merged above
//so if we use view.getOption("opt") will return the merged opt and not the opt in view.options boject
subject.options=_.omit(subject.options,_.keys(opts))
console.log("opts mergerged for ",subject);
} | javascript | function backboneOptsAsProps(subject, opts) {
if (!opts) {
opts = subject.options
}
subject.mergeOptions(subject.options, _.keys(opts));
//removing form view.options the options that ve been merged above
//so if we use view.getOption("opt") will return the merged opt and not the opt in view.options boject
subject.options=_.omit(subject.options,_.keys(opts))
console.log("opts mergerged for ",subject);
} | [
"function",
"backboneOptsAsProps",
"(",
"subject",
",",
"opts",
")",
"{",
"if",
"(",
"!",
"opts",
")",
"{",
"opts",
"=",
"subject",
".",
"options",
"}",
"subject",
".",
"mergeOptions",
"(",
"subject",
".",
"options",
",",
"_",
".",
"keys",
"(",
"opts",
")",
")",
";",
"//removing form view.options the options that ve been merged above",
"//so if we use view.getOption(\"opt\") will return the merged opt and not the opt in view.options boject ",
"subject",
".",
"options",
"=",
"_",
".",
"omit",
"(",
"subject",
".",
"options",
",",
"_",
".",
"keys",
"(",
"opts",
")",
")",
"console",
".",
"log",
"(",
"\"opts mergerged for \"",
",",
"subject",
")",
";",
"}"
] | It takes a Backbone Object as subject and merge all
opt as subjet properties removing the opt from view options
@param subject Backbone.Object, the object to operate over
@param opts Object, the options to add
@return void | [
"It",
"takes",
"a",
"Backbone",
"Object",
"as",
"subject",
"and",
"merge",
"all",
"opt",
"as",
"subjet",
"properties",
"removing",
"the",
"opt",
"from",
"view",
"options"
] | 331340a01879ec636a31961a81db9a58484d1381 | https://github.com/lemyskaman/kaman-core/blob/331340a01879ec636a31961a81db9a58484d1381/kaman.functions.js#L15-L29 |
52,382 | lemyskaman/kaman-core | kaman.functions.js | omitBackboneOptsAsProps | function omitBackboneOptsAsProps(subject, omit) {
console.log("omitBackboneOptsAsProps:")
console.log(subject, subject.options, omit, _.omit(subject.options, omit))
backboneOptsAsProps(subject, _.omit(subject.options, omit))
} | javascript | function omitBackboneOptsAsProps(subject, omit) {
console.log("omitBackboneOptsAsProps:")
console.log(subject, subject.options, omit, _.omit(subject.options, omit))
backboneOptsAsProps(subject, _.omit(subject.options, omit))
} | [
"function",
"omitBackboneOptsAsProps",
"(",
"subject",
",",
"omit",
")",
"{",
"console",
".",
"log",
"(",
"\"omitBackboneOptsAsProps:\"",
")",
"console",
".",
"log",
"(",
"subject",
",",
"subject",
".",
"options",
",",
"omit",
",",
"_",
".",
"omit",
"(",
"subject",
".",
"options",
",",
"omit",
")",
")",
"backboneOptsAsProps",
"(",
"subject",
",",
"_",
".",
"omit",
"(",
"subject",
".",
"options",
",",
"omit",
")",
")",
"}"
] | It takes a Backbone Object as subject and return same object without omit
@param subject Backbone.Object, the object to operate over
@param omit Array, the keys from subjet.options to omit
@return void | [
"It",
"takes",
"a",
"Backbone",
"Object",
"as",
"subject",
"and",
"return",
"same",
"object",
"without",
"omit"
] | 331340a01879ec636a31961a81db9a58484d1381 | https://github.com/lemyskaman/kaman-core/blob/331340a01879ec636a31961a81db9a58484d1381/kaman.functions.js#L38-L42 |
52,383 | lemyskaman/kaman-core | kaman.functions.js | kappInit | function kappInit(subject, callback) {
//if expose option is added we expose this view
console.log("kappInit:", subject)
if (subject.getOption("expose_as")) {
console.log("kappInit: found exposeAs option " + subject.getOption("expose_as"))
subject.exposeAs(subject.getOption("expose_as"))
}
//as backbone has its owne method to bind a model and collections to views we just
//avoid to merge it to the object atributes by this way
omitBackboneOptsAsProps(subject, ['model', 'collection'])
//giving the replaceable regions to the view
if (typeof subject._addReplaceableRegions === "function") {
subject._addReplaceableRegions();
};
if (typeof callback === "function") {
callback()
}
} | javascript | function kappInit(subject, callback) {
//if expose option is added we expose this view
console.log("kappInit:", subject)
if (subject.getOption("expose_as")) {
console.log("kappInit: found exposeAs option " + subject.getOption("expose_as"))
subject.exposeAs(subject.getOption("expose_as"))
}
//as backbone has its owne method to bind a model and collections to views we just
//avoid to merge it to the object atributes by this way
omitBackboneOptsAsProps(subject, ['model', 'collection'])
//giving the replaceable regions to the view
if (typeof subject._addReplaceableRegions === "function") {
subject._addReplaceableRegions();
};
if (typeof callback === "function") {
callback()
}
} | [
"function",
"kappInit",
"(",
"subject",
",",
"callback",
")",
"{",
"//if expose option is added we expose this view",
"console",
".",
"log",
"(",
"\"kappInit:\"",
",",
"subject",
")",
"if",
"(",
"subject",
".",
"getOption",
"(",
"\"expose_as\"",
")",
")",
"{",
"console",
".",
"log",
"(",
"\"kappInit: found exposeAs option \"",
"+",
"subject",
".",
"getOption",
"(",
"\"expose_as\"",
")",
")",
"subject",
".",
"exposeAs",
"(",
"subject",
".",
"getOption",
"(",
"\"expose_as\"",
")",
")",
"}",
"//as backbone has its owne method to bind a model and collections to views we just",
"//avoid to merge it to the object atributes by this way",
"omitBackboneOptsAsProps",
"(",
"subject",
",",
"[",
"'model'",
",",
"'collection'",
"]",
")",
"//giving the replaceable regions to the view",
"if",
"(",
"typeof",
"subject",
".",
"_addReplaceableRegions",
"===",
"\"function\"",
")",
"{",
"subject",
".",
"_addReplaceableRegions",
"(",
")",
";",
"}",
";",
"if",
"(",
"typeof",
"callback",
"===",
"\"function\"",
")",
"{",
"callback",
"(",
")",
"}",
"}"
] | you got to bind view object to this function
@param {function} callback | [
"you",
"got",
"to",
"bind",
"view",
"object",
"to",
"this",
"function"
] | 331340a01879ec636a31961a81db9a58484d1381 | https://github.com/lemyskaman/kaman-core/blob/331340a01879ec636a31961a81db9a58484d1381/kaman.functions.js#L48-L71 |
52,384 | lemyskaman/kaman-core | kaman.functions.js | lang | function lang(key, source) {
//first we retrive the lang value of the root of the DOM
var LANG = document.documentElement.lang;
//console.log(source)
//console.log(LANG+' '+key+' - '+source[LANG][key]);
if (_.isObject(source) && _.isObject(source[LANG]) && _.isString(source[LANG][key])) {
return source[LANG][key]
} else {
return key
}
} | javascript | function lang(key, source) {
//first we retrive the lang value of the root of the DOM
var LANG = document.documentElement.lang;
//console.log(source)
//console.log(LANG+' '+key+' - '+source[LANG][key]);
if (_.isObject(source) && _.isObject(source[LANG]) && _.isString(source[LANG][key])) {
return source[LANG][key]
} else {
return key
}
} | [
"function",
"lang",
"(",
"key",
",",
"source",
")",
"{",
"//first we retrive the lang value of the root of the DOM",
"var",
"LANG",
"=",
"document",
".",
"documentElement",
".",
"lang",
";",
"//console.log(source)",
"//console.log(LANG+' '+key+' - '+source[LANG][key]);",
"if",
"(",
"_",
".",
"isObject",
"(",
"source",
")",
"&&",
"_",
".",
"isObject",
"(",
"source",
"[",
"LANG",
"]",
")",
"&&",
"_",
".",
"isString",
"(",
"source",
"[",
"LANG",
"]",
"[",
"key",
"]",
")",
")",
"{",
"return",
"source",
"[",
"LANG",
"]",
"[",
"key",
"]",
"}",
"else",
"{",
"return",
"key",
"}",
"}"
] | utility function to get the language value from keys
on a languageSource object acording the specified language
comming from the server and placed in the
@param key String, the key to search of
@param source Object, the list to search for the key
@return string, the key value if it is in the source list, otherwise will retrun the key name | [
"utility",
"function",
"to",
"get",
"the",
"language",
"value",
"from",
"keys",
"on",
"a",
"languageSource",
"object",
"acording",
"the",
"specified",
"language",
"comming",
"from",
"the",
"server",
"and",
"placed",
"in",
"the"
] | 331340a01879ec636a31961a81db9a58484d1381 | https://github.com/lemyskaman/kaman-core/blob/331340a01879ec636a31961a81db9a58484d1381/kaman.functions.js#L82-L93 |
52,385 | lemyskaman/kaman-core | kaman.functions.js | expose | function expose(subject, name) {
//console.log(window[name])
if (subject.isRendered()) {
exposer(subject, name);
} else {
subject.on("attach", function () {
exposer(subject, name);
})
}
} | javascript | function expose(subject, name) {
//console.log(window[name])
if (subject.isRendered()) {
exposer(subject, name);
} else {
subject.on("attach", function () {
exposer(subject, name);
})
}
} | [
"function",
"expose",
"(",
"subject",
",",
"name",
")",
"{",
"//console.log(window[name])",
"if",
"(",
"subject",
".",
"isRendered",
"(",
")",
")",
"{",
"exposer",
"(",
"subject",
",",
"name",
")",
";",
"}",
"else",
"{",
"subject",
".",
"on",
"(",
"\"attach\"",
",",
"function",
"(",
")",
"{",
"exposer",
"(",
"subject",
",",
"name",
")",
";",
"}",
")",
"}",
"}"
] | a tool to let some object to be exposed to window on
browsers avoiding overwrite existent objects | [
"a",
"tool",
"to",
"let",
"some",
"object",
"to",
"be",
"exposed",
"to",
"window",
"on",
"browsers",
"avoiding",
"overwrite",
"existent",
"objects"
] | 331340a01879ec636a31961a81db9a58484d1381 | https://github.com/lemyskaman/kaman-core/blob/331340a01879ec636a31961a81db9a58484d1381/kaman.functions.js#L118-L127 |
52,386 | lemyskaman/kaman-core | kaman.functions.js | commutate | function commutate(key, list) {
_.each(list, function (v, k, l) {
if (k === key) {
l[key] = true
}
if (v === true && k !== key) {
l[k] = false
}
})
} | javascript | function commutate(key, list) {
_.each(list, function (v, k, l) {
if (k === key) {
l[key] = true
}
if (v === true && k !== key) {
l[k] = false
}
})
} | [
"function",
"commutate",
"(",
"key",
",",
"list",
")",
"{",
"_",
".",
"each",
"(",
"list",
",",
"function",
"(",
"v",
",",
"k",
",",
"l",
")",
"{",
"if",
"(",
"k",
"===",
"key",
")",
"{",
"l",
"[",
"key",
"]",
"=",
"true",
"}",
"if",
"(",
"v",
"===",
"true",
"&&",
"k",
"!==",
"key",
")",
"{",
"l",
"[",
"k",
"]",
"=",
"false",
"}",
"}",
")",
"}"
] | this function will iterate over each list elements
setting the one on key to true an all other on false
@param key String, the key to set as true
@param list Object, the object to search for the key to set to true
@return void | [
"this",
"function",
"will",
"iterate",
"over",
"each",
"list",
"elements",
"setting",
"the",
"one",
"on",
"key",
"to",
"true",
"an",
"all",
"other",
"on",
"false"
] | 331340a01879ec636a31961a81db9a58484d1381 | https://github.com/lemyskaman/kaman-core/blob/331340a01879ec636a31961a81db9a58484d1381/kaman.functions.js#L136-L145 |
52,387 | GreenGremlin/karma-gzip-preprocessor | lib/Preprocessor.js | Preprocessor | function Preprocessor(config, logger) {
const log = logger.create('preprocessor.gzip');
return (content, file, done) => {
const originalSize = content.length;
// const contentBuffer = Buffer.isBuffer(content) ? content : Buffer.from(content);
zlib.gzip(content, (err, gzippedContent) => {
if (err) {
log.error(err);
done(err);
return;
}
// eslint-disable-next-line no-param-reassign
file.encodings.gzip = gzippedContent;
log.info(`compressed ${file.originalPath} [${util.bytesToSize(originalSize)} -> ${util.bytesToSize(gzippedContent.length)}]`);
done(null, content);
});
};
} | javascript | function Preprocessor(config, logger) {
const log = logger.create('preprocessor.gzip');
return (content, file, done) => {
const originalSize = content.length;
// const contentBuffer = Buffer.isBuffer(content) ? content : Buffer.from(content);
zlib.gzip(content, (err, gzippedContent) => {
if (err) {
log.error(err);
done(err);
return;
}
// eslint-disable-next-line no-param-reassign
file.encodings.gzip = gzippedContent;
log.info(`compressed ${file.originalPath} [${util.bytesToSize(originalSize)} -> ${util.bytesToSize(gzippedContent.length)}]`);
done(null, content);
});
};
} | [
"function",
"Preprocessor",
"(",
"config",
",",
"logger",
")",
"{",
"const",
"log",
"=",
"logger",
".",
"create",
"(",
"'preprocessor.gzip'",
")",
";",
"return",
"(",
"content",
",",
"file",
",",
"done",
")",
"=>",
"{",
"const",
"originalSize",
"=",
"content",
".",
"length",
";",
"// const contentBuffer = Buffer.isBuffer(content) ? content : Buffer.from(content);",
"zlib",
".",
"gzip",
"(",
"content",
",",
"(",
"err",
",",
"gzippedContent",
")",
"=>",
"{",
"if",
"(",
"err",
")",
"{",
"log",
".",
"error",
"(",
"err",
")",
";",
"done",
"(",
"err",
")",
";",
"return",
";",
"}",
"// eslint-disable-next-line no-param-reassign",
"file",
".",
"encodings",
".",
"gzip",
"=",
"gzippedContent",
";",
"log",
".",
"info",
"(",
"`",
"${",
"file",
".",
"originalPath",
"}",
"${",
"util",
".",
"bytesToSize",
"(",
"originalSize",
")",
"}",
"${",
"util",
".",
"bytesToSize",
"(",
"gzippedContent",
".",
"length",
")",
"}",
"`",
")",
";",
"done",
"(",
"null",
",",
"content",
")",
";",
"}",
")",
";",
"}",
";",
"}"
] | Preprocess files to provide a gzip compressed alternative version | [
"Preprocess",
"files",
"to",
"provide",
"a",
"gzip",
"compressed",
"alternative",
"version"
] | 2ceb15b0f4c58beb3e6a13d1a58c5140569a5877 | https://github.com/GreenGremlin/karma-gzip-preprocessor/blob/2ceb15b0f4c58beb3e6a13d1a58c5140569a5877/lib/Preprocessor.js#L5-L26 |
52,388 | apathetic/stickynav | dist/stickynav.es6.js | scrollPage | function scrollPage(to, offset, callback) {
if ( offset === void 0 ) offset = 0;
var startTime;
var duration = 500;
var startPos = window.pageYOffset;
var endPos = ~~(to.getBoundingClientRect().top - offset);
var scroll = function (timestamp) {
var elapsed;
startTime = startTime || timestamp;
elapsed = timestamp - startTime;
document.body.scrollTop = document.documentElement.scrollTop = easeInOutCubic(elapsed, startPos, endPos, duration);
if (elapsed < duration) {
requestAnimationFrame(scroll);
} else if (callback) {
callback.call(to);
}
};
requestAnimationFrame(scroll);
} | javascript | function scrollPage(to, offset, callback) {
if ( offset === void 0 ) offset = 0;
var startTime;
var duration = 500;
var startPos = window.pageYOffset;
var endPos = ~~(to.getBoundingClientRect().top - offset);
var scroll = function (timestamp) {
var elapsed;
startTime = startTime || timestamp;
elapsed = timestamp - startTime;
document.body.scrollTop = document.documentElement.scrollTop = easeInOutCubic(elapsed, startPos, endPos, duration);
if (elapsed < duration) {
requestAnimationFrame(scroll);
} else if (callback) {
callback.call(to);
}
};
requestAnimationFrame(scroll);
} | [
"function",
"scrollPage",
"(",
"to",
",",
"offset",
",",
"callback",
")",
"{",
"if",
"(",
"offset",
"===",
"void",
"0",
")",
"offset",
"=",
"0",
";",
"var",
"startTime",
";",
"var",
"duration",
"=",
"500",
";",
"var",
"startPos",
"=",
"window",
".",
"pageYOffset",
";",
"var",
"endPos",
"=",
"~",
"~",
"(",
"to",
".",
"getBoundingClientRect",
"(",
")",
".",
"top",
"-",
"offset",
")",
";",
"var",
"scroll",
"=",
"function",
"(",
"timestamp",
")",
"{",
"var",
"elapsed",
";",
"startTime",
"=",
"startTime",
"||",
"timestamp",
";",
"elapsed",
"=",
"timestamp",
"-",
"startTime",
";",
"document",
".",
"body",
".",
"scrollTop",
"=",
"document",
".",
"documentElement",
".",
"scrollTop",
"=",
"easeInOutCubic",
"(",
"elapsed",
",",
"startPos",
",",
"endPos",
",",
"duration",
")",
";",
"if",
"(",
"elapsed",
"<",
"duration",
")",
"{",
"requestAnimationFrame",
"(",
"scroll",
")",
";",
"}",
"else",
"if",
"(",
"callback",
")",
"{",
"callback",
".",
"call",
"(",
"to",
")",
";",
"}",
"}",
";",
"requestAnimationFrame",
"(",
"scroll",
")",
";",
"}"
] | Scroll the page to a particular page anchor
@param {HTMLElement} to The element to scroll to.
@param {number} offset A scrolling offset.
@param {function} callback Function to apply after scrolling
@return {void} | [
"Scroll",
"the",
"page",
"to",
"a",
"particular",
"page",
"anchor"
] | badde353ec6210d6b3759925d2308dc49aa2e65f | https://github.com/apathetic/stickynav/blob/badde353ec6210d6b3759925d2308dc49aa2e65f/dist/stickynav.es6.js#L136-L159 |
52,389 | apathetic/stickynav | dist/stickynav.es6.js | $$ | function $$(els) {
return els instanceof NodeList ? Array.prototype.slice.call(els) :
els instanceof HTMLElement ? [els] :
typeof els === 'string' ? Array.prototype.slice.call(document.querySelectorAll(els)) :
[];
} | javascript | function $$(els) {
return els instanceof NodeList ? Array.prototype.slice.call(els) :
els instanceof HTMLElement ? [els] :
typeof els === 'string' ? Array.prototype.slice.call(document.querySelectorAll(els)) :
[];
} | [
"function",
"$$",
"(",
"els",
")",
"{",
"return",
"els",
"instanceof",
"NodeList",
"?",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"els",
")",
":",
"els",
"instanceof",
"HTMLElement",
"?",
"[",
"els",
"]",
":",
"typeof",
"els",
"===",
"'string'",
"?",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"document",
".",
"querySelectorAll",
"(",
"els",
")",
")",
":",
"[",
"]",
";",
"}"
] | mini querySelectorAll helper fn | [
"mini",
"querySelectorAll",
"helper",
"fn"
] | badde353ec6210d6b3759925d2308dc49aa2e65f | https://github.com/apathetic/stickynav/blob/badde353ec6210d6b3759925d2308dc49aa2e65f/dist/stickynav.es6.js#L162-L167 |
52,390 | loggur-legacy/baucis-decorator-auth | index.js | requestHandler | function requestHandler (method) {
return function (req, res, next) {
method.call(this, req, responseHandler(res, next));
}.bind(this);
} | javascript | function requestHandler (method) {
return function (req, res, next) {
method.call(this, req, responseHandler(res, next));
}.bind(this);
} | [
"function",
"requestHandler",
"(",
"method",
")",
"{",
"return",
"function",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"method",
".",
"call",
"(",
"this",
",",
"req",
",",
"responseHandler",
"(",
"res",
",",
"next",
")",
")",
";",
"}",
".",
"bind",
"(",
"this",
")",
";",
"}"
] | Returns a request handler using some method.
@param {Function} method
@return {Function}
@api private | [
"Returns",
"a",
"request",
"handler",
"using",
"some",
"method",
"."
] | aa31cf625d3c7ba69d97e5d1c07e4dceffbb7dfb | https://github.com/loggur-legacy/baucis-decorator-auth/blob/aa31cf625d3c7ba69d97e5d1c07e4dceffbb7dfb/index.js#L51-L55 |
52,391 | loggur-legacy/baucis-decorator-auth | index.js | responseHandler | function responseHandler (res, next) {
return function (err, message) {
if (err || !message) {
next(err);
} else {
res.send(message);
}
}
} | javascript | function responseHandler (res, next) {
return function (err, message) {
if (err || !message) {
next(err);
} else {
res.send(message);
}
}
} | [
"function",
"responseHandler",
"(",
"res",
",",
"next",
")",
"{",
"return",
"function",
"(",
"err",
",",
"message",
")",
"{",
"if",
"(",
"err",
"||",
"!",
"message",
")",
"{",
"next",
"(",
"err",
")",
";",
"}",
"else",
"{",
"res",
".",
"send",
"(",
"message",
")",
";",
"}",
"}",
"}"
] | Returns a response handler using `res` and `next` from Express.
@param {Object} res
@param {Function} next
@return {Function}
@api private | [
"Returns",
"a",
"response",
"handler",
"using",
"res",
"and",
"next",
"from",
"Express",
"."
] | aa31cf625d3c7ba69d97e5d1c07e4dceffbb7dfb | https://github.com/loggur-legacy/baucis-decorator-auth/blob/aa31cf625d3c7ba69d97e5d1c07e4dceffbb7dfb/index.js#L65-L73 |
52,392 | loggur-legacy/baucis-decorator-auth | index.js | getPasswordObj | function getPasswordObj (values, keys) {
var passwordObj = {};
(keys || Object.keys(values)).forEach(function (key) {
passwordObj[values[key].password] = key;
});
return passwordObj;
} | javascript | function getPasswordObj (values, keys) {
var passwordObj = {};
(keys || Object.keys(values)).forEach(function (key) {
passwordObj[values[key].password] = key;
});
return passwordObj;
} | [
"function",
"getPasswordObj",
"(",
"values",
",",
"keys",
")",
"{",
"var",
"passwordObj",
"=",
"{",
"}",
";",
"(",
"keys",
"||",
"Object",
".",
"keys",
"(",
"values",
")",
")",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"passwordObj",
"[",
"values",
"[",
"key",
"]",
".",
"password",
"]",
"=",
"key",
";",
"}",
")",
";",
"return",
"passwordObj",
";",
"}"
] | Gets the password keys from some set of values.
@param {Object} values
@param {Array} keys optional
@return {Object}
@api private | [
"Gets",
"the",
"password",
"keys",
"from",
"some",
"set",
"of",
"values",
"."
] | aa31cf625d3c7ba69d97e5d1c07e4dceffbb7dfb | https://github.com/loggur-legacy/baucis-decorator-auth/blob/aa31cf625d3c7ba69d97e5d1c07e4dceffbb7dfb/index.js#L170-L178 |
52,393 | loggur-legacy/baucis-decorator-auth | index.js | getResetterObj | function getResetterObj (values, keys) {
var resetterObj = {};
(keys || Object.keys(values)).forEach(function (key) {
if (values[key].resetter) {
resetterObj[values[key].resetter] = key;
}
});
return resetterObj;
} | javascript | function getResetterObj (values, keys) {
var resetterObj = {};
(keys || Object.keys(values)).forEach(function (key) {
if (values[key].resetter) {
resetterObj[values[key].resetter] = key;
}
});
return resetterObj;
} | [
"function",
"getResetterObj",
"(",
"values",
",",
"keys",
")",
"{",
"var",
"resetterObj",
"=",
"{",
"}",
";",
"(",
"keys",
"||",
"Object",
".",
"keys",
"(",
"values",
")",
")",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"if",
"(",
"values",
"[",
"key",
"]",
".",
"resetter",
")",
"{",
"resetterObj",
"[",
"values",
"[",
"key",
"]",
".",
"resetter",
"]",
"=",
"key",
";",
"}",
"}",
")",
";",
"return",
"resetterObj",
";",
"}"
] | Gets the resetter keys from some set of values.
@param {Object} values
@param {Array} keys optional
@return {Object}
@api private | [
"Gets",
"the",
"resetter",
"keys",
"from",
"some",
"set",
"of",
"values",
"."
] | aa31cf625d3c7ba69d97e5d1c07e4dceffbb7dfb | https://github.com/loggur-legacy/baucis-decorator-auth/blob/aa31cf625d3c7ba69d97e5d1c07e4dceffbb7dfb/index.js#L372-L382 |
52,394 | berkeleybop/bbop-core | lib/core.js | _first_split | function _first_split(character, string){
var retlist = null;
var eq_loc = string.indexOf(character);
if( eq_loc == 0 ){
retlist = ['', string.substr(eq_loc +1, string.length)];
}else if( eq_loc > 0 ){
var before = string.substr(0, eq_loc);
var after = string.substr(eq_loc +1, string.length);
retlist = [before, after];
}else{
retlist = ['', ''];
}
return retlist;
} | javascript | function _first_split(character, string){
var retlist = null;
var eq_loc = string.indexOf(character);
if( eq_loc == 0 ){
retlist = ['', string.substr(eq_loc +1, string.length)];
}else if( eq_loc > 0 ){
var before = string.substr(0, eq_loc);
var after = string.substr(eq_loc +1, string.length);
retlist = [before, after];
}else{
retlist = ['', ''];
}
return retlist;
} | [
"function",
"_first_split",
"(",
"character",
",",
"string",
")",
"{",
"var",
"retlist",
"=",
"null",
";",
"var",
"eq_loc",
"=",
"string",
".",
"indexOf",
"(",
"character",
")",
";",
"if",
"(",
"eq_loc",
"==",
"0",
")",
"{",
"retlist",
"=",
"[",
"''",
",",
"string",
".",
"substr",
"(",
"eq_loc",
"+",
"1",
",",
"string",
".",
"length",
")",
"]",
";",
"}",
"else",
"if",
"(",
"eq_loc",
">",
"0",
")",
"{",
"var",
"before",
"=",
"string",
".",
"substr",
"(",
"0",
",",
"eq_loc",
")",
";",
"var",
"after",
"=",
"string",
".",
"substr",
"(",
"eq_loc",
"+",
"1",
",",
"string",
".",
"length",
")",
";",
"retlist",
"=",
"[",
"before",
",",
"after",
"]",
";",
"}",
"else",
"{",
"retlist",
"=",
"[",
"''",
",",
"''",
"]",
";",
"}",
"return",
"retlist",
";",
"}"
] | Attempt to return a two part split on the first occurrence of a
character.
Returns '' for parts not found.
Unit tests make the edge cases clear.
@function
@name module:bbop-core#first_split
@param {String} character - the character to split on
@param {String} string - the string to split
@returns {Array} list of first and second parts | [
"Attempt",
"to",
"return",
"a",
"two",
"part",
"split",
"on",
"the",
"first",
"occurrence",
"of",
"a",
"character",
"."
] | d9ce82a3a7d4f5e7300c0b637d8f7ff0e6969adf | https://github.com/berkeleybop/bbop-core/blob/d9ce82a3a7d4f5e7300c0b637d8f7ff0e6969adf/lib/core.js#L189-L205 |
52,395 | berkeleybop/bbop-core | lib/core.js | function(str, lim, suff){
var ret = str;
var limit = 10;
if( lim ){ limit = lim; }
var suffix = '';
if( suff ){ suffix = suff; }
if( str.length > limit ){
ret = str.substring(0, (limit - suffix.length)) + suffix;
}
return ret;
} | javascript | function(str, lim, suff){
var ret = str;
var limit = 10;
if( lim ){ limit = lim; }
var suffix = '';
if( suff ){ suffix = suff; }
if( str.length > limit ){
ret = str.substring(0, (limit - suffix.length)) + suffix;
}
return ret;
} | [
"function",
"(",
"str",
",",
"lim",
",",
"suff",
")",
"{",
"var",
"ret",
"=",
"str",
";",
"var",
"limit",
"=",
"10",
";",
"if",
"(",
"lim",
")",
"{",
"limit",
"=",
"lim",
";",
"}",
"var",
"suffix",
"=",
"''",
";",
"if",
"(",
"suff",
")",
"{",
"suffix",
"=",
"suff",
";",
"}",
"if",
"(",
"str",
".",
"length",
">",
"limit",
")",
"{",
"ret",
"=",
"str",
".",
"substring",
"(",
"0",
",",
"(",
"limit",
"-",
"suffix",
".",
"length",
")",
")",
"+",
"suffix",
";",
"}",
"return",
"ret",
";",
"}"
] | Crop a string nicely.
Returns: Nothing. Side-effects: throws an error if the namespace
defined by the strings is not currently found.
@param {} str - the string to crop
@param {} lim - the final length to crop to (optional, defaults to 10)
@param {} suff - the string to add to the end (optional, defaults to '')
@returns {string} cropped string | [
"Crop",
"a",
"string",
"nicely",
"."
] | d9ce82a3a7d4f5e7300c0b637d8f7ff0e6969adf | https://github.com/berkeleybop/bbop-core/blob/d9ce82a3a7d4f5e7300c0b637d8f7ff0e6969adf/lib/core.js#L227-L240 |
|
52,396 | berkeleybop/bbop-core | lib/core.js | function(older_hash, newer_hash){
if( ! older_hash ){ older_hash = {}; }
if( ! newer_hash ){ newer_hash = {}; }
var ret_hash = {};
function _add (val, key){
ret_hash[key] = val;
}
each(older_hash, _add);
each(newer_hash, _add);
return ret_hash;
} | javascript | function(older_hash, newer_hash){
if( ! older_hash ){ older_hash = {}; }
if( ! newer_hash ){ newer_hash = {}; }
var ret_hash = {};
function _add (val, key){
ret_hash[key] = val;
}
each(older_hash, _add);
each(newer_hash, _add);
return ret_hash;
} | [
"function",
"(",
"older_hash",
",",
"newer_hash",
")",
"{",
"if",
"(",
"!",
"older_hash",
")",
"{",
"older_hash",
"=",
"{",
"}",
";",
"}",
"if",
"(",
"!",
"newer_hash",
")",
"{",
"newer_hash",
"=",
"{",
"}",
";",
"}",
"var",
"ret_hash",
"=",
"{",
"}",
";",
"function",
"_add",
"(",
"val",
",",
"key",
")",
"{",
"ret_hash",
"[",
"key",
"]",
"=",
"val",
";",
"}",
"each",
"(",
"older_hash",
",",
"_add",
")",
";",
"each",
"(",
"newer_hash",
",",
"_add",
")",
";",
"return",
"ret_hash",
";",
"}"
] | Merge a pair of hashes together, the second hash getting
precedence. This is a superset of the keys both hashes.
@see module:bbop-core.fold
@param {} older_hash - first pass
@param {} newer_hash - second pass
@returns {object} a new hash | [
"Merge",
"a",
"pair",
"of",
"hashes",
"together",
"the",
"second",
"hash",
"getting",
"precedence",
".",
"This",
"is",
"a",
"superset",
"of",
"the",
"keys",
"both",
"hashes",
"."
] | d9ce82a3a7d4f5e7300c0b637d8f7ff0e6969adf | https://github.com/berkeleybop/bbop-core/blob/d9ce82a3a7d4f5e7300c0b637d8f7ff0e6969adf/lib/core.js#L280-L292 |
|
52,397 | berkeleybop/bbop-core | lib/core.js | function(in_thing, filter_function, sort_function){
var ret = [];
// Probably an not array then.
if( typeof(in_thing) === 'undefined' ){
// this is a nothing, to nothing....
}else if( typeof(in_thing) != 'object' ){
throw new Error('Unsupported type in bbop.core.pare: ' +
typeof(in_thing) );
}else if( us.isArray(in_thing) ){
// An array; filter it if filter_function is defined.
if( filter_function ){
each(in_thing, function(item, index){
if( filter_function(item, index) ){
// filter out item if true
}else{
ret.push(item);
}
});
}else{
each(in_thing, function(item, index){ ret.push(item); });
}
}else if( us.isFunction(in_thing) ){
// Skip is function (which is also an object).
}else if( us.isObject(in_thing) ){
// Probably a hash; filter it if filter_function is defined.
if( filter_function ){
each(in_thing, function(val, key){
if( filter_function(key, val) ){
// Remove matches to the filter.
}else{
ret.push(val);
}
});
}else{
each(in_thing, function(val, key){ ret.push(val); });
}
}else{
// No idea what this is--skip.
}
// For both: sort if there is anything.
if( ret.length > 0 && sort_function ){
ret.sort(sort_function);
}
return ret;
} | javascript | function(in_thing, filter_function, sort_function){
var ret = [];
// Probably an not array then.
if( typeof(in_thing) === 'undefined' ){
// this is a nothing, to nothing....
}else if( typeof(in_thing) != 'object' ){
throw new Error('Unsupported type in bbop.core.pare: ' +
typeof(in_thing) );
}else if( us.isArray(in_thing) ){
// An array; filter it if filter_function is defined.
if( filter_function ){
each(in_thing, function(item, index){
if( filter_function(item, index) ){
// filter out item if true
}else{
ret.push(item);
}
});
}else{
each(in_thing, function(item, index){ ret.push(item); });
}
}else if( us.isFunction(in_thing) ){
// Skip is function (which is also an object).
}else if( us.isObject(in_thing) ){
// Probably a hash; filter it if filter_function is defined.
if( filter_function ){
each(in_thing, function(val, key){
if( filter_function(key, val) ){
// Remove matches to the filter.
}else{
ret.push(val);
}
});
}else{
each(in_thing, function(val, key){ ret.push(val); });
}
}else{
// No idea what this is--skip.
}
// For both: sort if there is anything.
if( ret.length > 0 && sort_function ){
ret.sort(sort_function);
}
return ret;
} | [
"function",
"(",
"in_thing",
",",
"filter_function",
",",
"sort_function",
")",
"{",
"var",
"ret",
"=",
"[",
"]",
";",
"// Probably an not array then.",
"if",
"(",
"typeof",
"(",
"in_thing",
")",
"===",
"'undefined'",
")",
"{",
"// this is a nothing, to nothing....",
"}",
"else",
"if",
"(",
"typeof",
"(",
"in_thing",
")",
"!=",
"'object'",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Unsupported type in bbop.core.pare: '",
"+",
"typeof",
"(",
"in_thing",
")",
")",
";",
"}",
"else",
"if",
"(",
"us",
".",
"isArray",
"(",
"in_thing",
")",
")",
"{",
"// An array; filter it if filter_function is defined.",
"if",
"(",
"filter_function",
")",
"{",
"each",
"(",
"in_thing",
",",
"function",
"(",
"item",
",",
"index",
")",
"{",
"if",
"(",
"filter_function",
"(",
"item",
",",
"index",
")",
")",
"{",
"// filter out item if true",
"}",
"else",
"{",
"ret",
".",
"push",
"(",
"item",
")",
";",
"}",
"}",
")",
";",
"}",
"else",
"{",
"each",
"(",
"in_thing",
",",
"function",
"(",
"item",
",",
"index",
")",
"{",
"ret",
".",
"push",
"(",
"item",
")",
";",
"}",
")",
";",
"}",
"}",
"else",
"if",
"(",
"us",
".",
"isFunction",
"(",
"in_thing",
")",
")",
"{",
"// Skip is function (which is also an object).",
"}",
"else",
"if",
"(",
"us",
".",
"isObject",
"(",
"in_thing",
")",
")",
"{",
"// Probably a hash; filter it if filter_function is defined.",
"if",
"(",
"filter_function",
")",
"{",
"each",
"(",
"in_thing",
",",
"function",
"(",
"val",
",",
"key",
")",
"{",
"if",
"(",
"filter_function",
"(",
"key",
",",
"val",
")",
")",
"{",
"// Remove matches to the filter.",
"}",
"else",
"{",
"ret",
".",
"push",
"(",
"val",
")",
";",
"}",
"}",
")",
";",
"}",
"else",
"{",
"each",
"(",
"in_thing",
",",
"function",
"(",
"val",
",",
"key",
")",
"{",
"ret",
".",
"push",
"(",
"val",
")",
";",
"}",
")",
";",
"}",
"}",
"else",
"{",
"// No idea what this is--skip.",
"}",
"// For both: sort if there is anything.",
"if",
"(",
"ret",
".",
"length",
">",
"0",
"&&",
"sort_function",
")",
"{",
"ret",
".",
"sort",
"(",
"sort_function",
")",
";",
"}",
"return",
"ret",
";",
"}"
] | Take an array or hash and pare it down using a couple of functions
to what we want.
Both parameters are optional in the sense that you can set them to
null and they will have no function; i.e. a null filter will let
everything through and a null sort will let things go in whatever
order.
@param {Array|Object} in_thing - hash or array
@param {Function} filter_function - hash (function(key, val)) or array (function(item, i)); this function must return boolean true or false.
@param {Function} sort_function - function to apply to elements: function(a, b); this function must return an integer as the usual sort functions do.
@returns {Array} array | [
"Take",
"an",
"array",
"or",
"hash",
"and",
"pare",
"it",
"down",
"using",
"a",
"couple",
"of",
"functions",
"to",
"what",
"we",
"want",
"."
] | d9ce82a3a7d4f5e7300c0b637d8f7ff0e6969adf | https://github.com/berkeleybop/bbop-core/blob/d9ce82a3a7d4f5e7300c0b637d8f7ff0e6969adf/lib/core.js#L487-L535 |
|
52,398 | berkeleybop/bbop-core | lib/core.js | function(iobj, interface_list){
var retval = true;
each(interface_list, function(iface){
//print('|' + typeof(in_key) + ' || ' + typeof(in_val));
//print('|' + in_key + ' || ' + in_val);
if( typeof(iobj[iface]) == 'undefined' &&
typeof(iobj.prototype[iface]) == 'undefined' ){
retval = false;
throw new Error(_what_is(iobj) +
' breaks interface ' + iface);
}
});
return retval;
} | javascript | function(iobj, interface_list){
var retval = true;
each(interface_list, function(iface){
//print('|' + typeof(in_key) + ' || ' + typeof(in_val));
//print('|' + in_key + ' || ' + in_val);
if( typeof(iobj[iface]) == 'undefined' &&
typeof(iobj.prototype[iface]) == 'undefined' ){
retval = false;
throw new Error(_what_is(iobj) +
' breaks interface ' + iface);
}
});
return retval;
} | [
"function",
"(",
"iobj",
",",
"interface_list",
")",
"{",
"var",
"retval",
"=",
"true",
";",
"each",
"(",
"interface_list",
",",
"function",
"(",
"iface",
")",
"{",
"//print('|' + typeof(in_key) + ' || ' + typeof(in_val));",
"//print('|' + in_key + ' || ' + in_val);",
"if",
"(",
"typeof",
"(",
"iobj",
"[",
"iface",
"]",
")",
"==",
"'undefined'",
"&&",
"typeof",
"(",
"iobj",
".",
"prototype",
"[",
"iface",
"]",
")",
"==",
"'undefined'",
")",
"{",
"retval",
"=",
"false",
";",
"throw",
"new",
"Error",
"(",
"_what_is",
"(",
"iobj",
")",
"+",
"' breaks interface '",
"+",
"iface",
")",
";",
"}",
"}",
")",
";",
"return",
"retval",
";",
"}"
] | Check to see if all top-level objects in a namespace supply an
"interface".
Mostly intended for use during unit testing.
TODO: Unit test this to make sure it catches both prototype (okay I
think) and uninstantiated objects (harder/impossible?).
@param {} iobj - the object/constructor in question
@param {} interface_list - the list of interfaces (as a strings) we're looking for
@returns {boolean} boolean | [
"Check",
"to",
"see",
"if",
"all",
"top",
"-",
"level",
"objects",
"in",
"a",
"namespace",
"supply",
"an",
"interface",
"."
] | d9ce82a3a7d4f5e7300c0b637d8f7ff0e6969adf | https://github.com/berkeleybop/bbop-core/blob/d9ce82a3a7d4f5e7300c0b637d8f7ff0e6969adf/lib/core.js#L586-L599 |
|
52,399 | berkeleybop/bbop-core | lib/core.js | function(qargs){
var mbuff = [];
for( var qname in qargs ){
var qval = qargs[qname];
// null is technically an object, but we don't want to render
// it.
if( qval != null ){
if( typeof qval == 'string' || typeof qval == 'number' ){
// Is standard name/value pair.
var nano_buffer = [];
nano_buffer.push(qname);
nano_buffer.push('=');
nano_buffer.push(qval);
mbuff.push(nano_buffer.join(''));
}else if( typeof qval == 'object' ){
if( typeof qval.length != 'undefined' ){
// Is array (probably).
// Iterate through and double on.
for(var qval_i = 0; qval_i < qval.length ; qval_i++){
var nano_buff = [];
nano_buff.push(qname);
nano_buff.push('=');
nano_buff.push(qval[qval_i]);
mbuff.push(nano_buff.join(''));
}
}else{
// // TODO: The "and" case is pretty much like
// // the array, the "or" case needs to be
// // handled carefully. In both cases, care will
// // be needed to show which filters are marked.
// Is object (probably).
// Special "Solr-esque" handling.
for( var sub_name in qval ){
var sub_vals = qval[sub_name];
// Since there might be an array down there,
// ensure that there is an iterate over it.
if( _what_is(sub_vals) != 'array' ){
sub_vals = [sub_vals];
}
each(sub_vals, function(sub_val){
var nano_buff = [];
nano_buff.push(qname);
nano_buff.push('=');
nano_buff.push(sub_name);
nano_buff.push(':');
if( typeof sub_val !== 'undefined' && sub_val ){
// Do not double quote strings.
// Also, do not requote if we already
// have parens in place--that
// indicates a complicated
// expression. See the unit tests.
var val_is_a = _what_is(sub_val);
if( val_is_a == 'string' &&
sub_val.charAt(0) == '"' &&
sub_val.charAt(sub_val.length -1) == '"' ){
nano_buff.push(sub_val);
}else if( val_is_a == 'string' &&
sub_val.charAt(0) == '(' &&
sub_val.charAt(sub_val.length -1) == ')' ){
nano_buff.push(sub_val);
}else{
nano_buff.push('"' + sub_val + '"');
}
}else{
nano_buff.push('""');
}
mbuff.push(nano_buff.join(''));
});
}
}
}else if( typeof qval == 'undefined' ){
// This happens in some cases where a key is tried, but no
// value is found--likely equivalent to q="", but we'll
// let it drop.
// var nano_buff = [];
// nano_buff.push(qname);
// nano_buff.push('=');
// mbuff.push(nano_buff.join(''));
}else{
throw new Error("bbop.core.get_assemble: unknown type: " +
typeof(qval));
}
}
}
return mbuff.join('&');
} | javascript | function(qargs){
var mbuff = [];
for( var qname in qargs ){
var qval = qargs[qname];
// null is technically an object, but we don't want to render
// it.
if( qval != null ){
if( typeof qval == 'string' || typeof qval == 'number' ){
// Is standard name/value pair.
var nano_buffer = [];
nano_buffer.push(qname);
nano_buffer.push('=');
nano_buffer.push(qval);
mbuff.push(nano_buffer.join(''));
}else if( typeof qval == 'object' ){
if( typeof qval.length != 'undefined' ){
// Is array (probably).
// Iterate through and double on.
for(var qval_i = 0; qval_i < qval.length ; qval_i++){
var nano_buff = [];
nano_buff.push(qname);
nano_buff.push('=');
nano_buff.push(qval[qval_i]);
mbuff.push(nano_buff.join(''));
}
}else{
// // TODO: The "and" case is pretty much like
// // the array, the "or" case needs to be
// // handled carefully. In both cases, care will
// // be needed to show which filters are marked.
// Is object (probably).
// Special "Solr-esque" handling.
for( var sub_name in qval ){
var sub_vals = qval[sub_name];
// Since there might be an array down there,
// ensure that there is an iterate over it.
if( _what_is(sub_vals) != 'array' ){
sub_vals = [sub_vals];
}
each(sub_vals, function(sub_val){
var nano_buff = [];
nano_buff.push(qname);
nano_buff.push('=');
nano_buff.push(sub_name);
nano_buff.push(':');
if( typeof sub_val !== 'undefined' && sub_val ){
// Do not double quote strings.
// Also, do not requote if we already
// have parens in place--that
// indicates a complicated
// expression. See the unit tests.
var val_is_a = _what_is(sub_val);
if( val_is_a == 'string' &&
sub_val.charAt(0) == '"' &&
sub_val.charAt(sub_val.length -1) == '"' ){
nano_buff.push(sub_val);
}else if( val_is_a == 'string' &&
sub_val.charAt(0) == '(' &&
sub_val.charAt(sub_val.length -1) == ')' ){
nano_buff.push(sub_val);
}else{
nano_buff.push('"' + sub_val + '"');
}
}else{
nano_buff.push('""');
}
mbuff.push(nano_buff.join(''));
});
}
}
}else if( typeof qval == 'undefined' ){
// This happens in some cases where a key is tried, but no
// value is found--likely equivalent to q="", but we'll
// let it drop.
// var nano_buff = [];
// nano_buff.push(qname);
// nano_buff.push('=');
// mbuff.push(nano_buff.join(''));
}else{
throw new Error("bbop.core.get_assemble: unknown type: " +
typeof(qval));
}
}
}
return mbuff.join('&');
} | [
"function",
"(",
"qargs",
")",
"{",
"var",
"mbuff",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"qname",
"in",
"qargs",
")",
"{",
"var",
"qval",
"=",
"qargs",
"[",
"qname",
"]",
";",
"// null is technically an object, but we don't want to render",
"// it.",
"if",
"(",
"qval",
"!=",
"null",
")",
"{",
"if",
"(",
"typeof",
"qval",
"==",
"'string'",
"||",
"typeof",
"qval",
"==",
"'number'",
")",
"{",
"// Is standard name/value pair.",
"var",
"nano_buffer",
"=",
"[",
"]",
";",
"nano_buffer",
".",
"push",
"(",
"qname",
")",
";",
"nano_buffer",
".",
"push",
"(",
"'='",
")",
";",
"nano_buffer",
".",
"push",
"(",
"qval",
")",
";",
"mbuff",
".",
"push",
"(",
"nano_buffer",
".",
"join",
"(",
"''",
")",
")",
";",
"}",
"else",
"if",
"(",
"typeof",
"qval",
"==",
"'object'",
")",
"{",
"if",
"(",
"typeof",
"qval",
".",
"length",
"!=",
"'undefined'",
")",
"{",
"// Is array (probably).",
"// Iterate through and double on.",
"for",
"(",
"var",
"qval_i",
"=",
"0",
";",
"qval_i",
"<",
"qval",
".",
"length",
";",
"qval_i",
"++",
")",
"{",
"var",
"nano_buff",
"=",
"[",
"]",
";",
"nano_buff",
".",
"push",
"(",
"qname",
")",
";",
"nano_buff",
".",
"push",
"(",
"'='",
")",
";",
"nano_buff",
".",
"push",
"(",
"qval",
"[",
"qval_i",
"]",
")",
";",
"mbuff",
".",
"push",
"(",
"nano_buff",
".",
"join",
"(",
"''",
")",
")",
";",
"}",
"}",
"else",
"{",
"// // TODO: The \"and\" case is pretty much like",
"// // the array, the \"or\" case needs to be",
"// // handled carefully. In both cases, care will",
"// // be needed to show which filters are marked.",
"// Is object (probably).",
"// Special \"Solr-esque\" handling.",
"for",
"(",
"var",
"sub_name",
"in",
"qval",
")",
"{",
"var",
"sub_vals",
"=",
"qval",
"[",
"sub_name",
"]",
";",
"// Since there might be an array down there,",
"// ensure that there is an iterate over it.",
"if",
"(",
"_what_is",
"(",
"sub_vals",
")",
"!=",
"'array'",
")",
"{",
"sub_vals",
"=",
"[",
"sub_vals",
"]",
";",
"}",
"each",
"(",
"sub_vals",
",",
"function",
"(",
"sub_val",
")",
"{",
"var",
"nano_buff",
"=",
"[",
"]",
";",
"nano_buff",
".",
"push",
"(",
"qname",
")",
";",
"nano_buff",
".",
"push",
"(",
"'='",
")",
";",
"nano_buff",
".",
"push",
"(",
"sub_name",
")",
";",
"nano_buff",
".",
"push",
"(",
"':'",
")",
";",
"if",
"(",
"typeof",
"sub_val",
"!==",
"'undefined'",
"&&",
"sub_val",
")",
"{",
"// Do not double quote strings.",
"// Also, do not requote if we already",
"// have parens in place--that",
"// indicates a complicated",
"// expression. See the unit tests.",
"var",
"val_is_a",
"=",
"_what_is",
"(",
"sub_val",
")",
";",
"if",
"(",
"val_is_a",
"==",
"'string'",
"&&",
"sub_val",
".",
"charAt",
"(",
"0",
")",
"==",
"'\"'",
"&&",
"sub_val",
".",
"charAt",
"(",
"sub_val",
".",
"length",
"-",
"1",
")",
"==",
"'\"'",
")",
"{",
"nano_buff",
".",
"push",
"(",
"sub_val",
")",
";",
"}",
"else",
"if",
"(",
"val_is_a",
"==",
"'string'",
"&&",
"sub_val",
".",
"charAt",
"(",
"0",
")",
"==",
"'('",
"&&",
"sub_val",
".",
"charAt",
"(",
"sub_val",
".",
"length",
"-",
"1",
")",
"==",
"')'",
")",
"{",
"nano_buff",
".",
"push",
"(",
"sub_val",
")",
";",
"}",
"else",
"{",
"nano_buff",
".",
"push",
"(",
"'\"'",
"+",
"sub_val",
"+",
"'\"'",
")",
";",
"}",
"}",
"else",
"{",
"nano_buff",
".",
"push",
"(",
"'\"\"'",
")",
";",
"}",
"mbuff",
".",
"push",
"(",
"nano_buff",
".",
"join",
"(",
"''",
")",
")",
";",
"}",
")",
";",
"}",
"}",
"}",
"else",
"if",
"(",
"typeof",
"qval",
"==",
"'undefined'",
")",
"{",
"// This happens in some cases where a key is tried, but no",
"// value is found--likely equivalent to q=\"\", but we'll",
"// let it drop.",
"// var nano_buff = [];",
"// nano_buff.push(qname);",
"// nano_buff.push('=');",
"// mbuff.push(nano_buff.join(''));\t ",
"}",
"else",
"{",
"throw",
"new",
"Error",
"(",
"\"bbop.core.get_assemble: unknown type: \"",
"+",
"typeof",
"(",
"qval",
")",
")",
";",
"}",
"}",
"}",
"return",
"mbuff",
".",
"join",
"(",
"'&'",
")",
";",
"}"
] | Assemble an object into a GET-like query. You probably want to see
the tests to get an idea of what this is doing.
The last argument of double hashes gets quoted (Solr-esque),
otherwise not. It will try and avoid adding additional sets of
quotes to strings.
This does nothing to make the produced "URL" in any way safe.
WARNING: Not a hugely clean function--there are a lot of special
cases and it could use a good (and safe) clean-up.
@param {} qargs - hash/object
@returns {string} string | [
"Assemble",
"an",
"object",
"into",
"a",
"GET",
"-",
"like",
"query",
".",
"You",
"probably",
"want",
"to",
"see",
"the",
"tests",
"to",
"get",
"an",
"idea",
"of",
"what",
"this",
"is",
"doing",
"."
] | d9ce82a3a7d4f5e7300c0b637d8f7ff0e6969adf | https://github.com/berkeleybop/bbop-core/blob/d9ce82a3a7d4f5e7300c0b637d8f7ff0e6969adf/lib/core.js#L617-L707 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.