repo stringlengths 5 67 | path stringlengths 4 116 | func_name stringlengths 0 58 | original_string stringlengths 52 373k | language stringclasses 1
value | code stringlengths 52 373k | code_tokens list | docstring stringlengths 4 11.8k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 86 226 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
rstudio/shiny-server | lib/proxy/http.js | isKeepalive | function isKeepalive(req) {
var conn = req.headers.connection;
if (typeof(conn) === 'undefined' || conn === null)
conn = '';
conn = conn.trim().toLowerCase();
if (/\bclose\b/i.test(conn))
return false;
if (/\bkeep-alive\b/i.test(conn))
return true;
// No Connection header. Default to keepalive... | javascript | function isKeepalive(req) {
var conn = req.headers.connection;
if (typeof(conn) === 'undefined' || conn === null)
conn = '';
conn = conn.trim().toLowerCase();
if (/\bclose\b/i.test(conn))
return false;
if (/\bkeep-alive\b/i.test(conn))
return true;
// No Connection header. Default to keepalive... | [
"function",
"isKeepalive",
"(",
"req",
")",
"{",
"var",
"conn",
"=",
"req",
".",
"headers",
".",
"connection",
";",
"if",
"(",
"typeof",
"(",
"conn",
")",
"===",
"'undefined'",
"||",
"conn",
"===",
"null",
")",
"conn",
"=",
"''",
";",
"conn",
"=",
... | Determine if keepalive is desired by the client that generated this request | [
"Determine",
"if",
"keepalive",
"is",
"desired",
"by",
"the",
"client",
"that",
"generated",
"this",
"request"
] | 0227ff5e5ce0182921446e45295873932507b36f | https://github.com/rstudio/shiny-server/blob/0227ff5e5ce0182921446e45295873932507b36f/lib/proxy/http.js#L287-L304 | train |
rstudio/shiny-server | lib/config/config.js | read_p | function read_p(path, schemaPath) {
return Q.nfcall(fs.readFile, path, 'utf8')
.then(function(cdata) {
return Q.nfcall(fs.readFile, schemaPath, 'utf8')
.then(function(sdata) {
return schema.applySchema(parse(cdata, path), parse(sdata, schemaPath));
});
});
} | javascript | function read_p(path, schemaPath) {
return Q.nfcall(fs.readFile, path, 'utf8')
.then(function(cdata) {
return Q.nfcall(fs.readFile, schemaPath, 'utf8')
.then(function(sdata) {
return schema.applySchema(parse(cdata, path), parse(sdata, schemaPath));
});
});
} | [
"function",
"read_p",
"(",
"path",
",",
"schemaPath",
")",
"{",
"return",
"Q",
".",
"nfcall",
"(",
"fs",
".",
"readFile",
",",
"path",
",",
"'utf8'",
")",
".",
"then",
"(",
"function",
"(",
"cdata",
")",
"{",
"return",
"Q",
".",
"nfcall",
"(",
"fs"... | Reads the given config file. The returned promise resolves to the ConfigNode
object at the root of the config file.
@param {String} path File path for the config file.
@returns {Promise} Promise that resolves to ConfigNode. | [
"Reads",
"the",
"given",
"config",
"file",
".",
"The",
"returned",
"promise",
"resolves",
"to",
"the",
"ConfigNode",
"object",
"at",
"the",
"root",
"of",
"the",
"config",
"file",
"."
] | 0227ff5e5ce0182921446e45295873932507b36f | https://github.com/rstudio/shiny-server/blob/0227ff5e5ce0182921446e45295873932507b36f/lib/config/config.js#L29-L37 | train |
rstudio/shiny-server | lib/proxy/multiplex.js | MultiplexChannel | function MultiplexChannel(id, conn, properties) {
events.EventEmitter.call(this);
this.$id = id; // The channel id
this.$conn = conn; // The underlying SockJS connection
_.extend(this, properties); // Apply extra properties to this object
this.readyState = this.$conn.readyState;
assert(this.readyState ==... | javascript | function MultiplexChannel(id, conn, properties) {
events.EventEmitter.call(this);
this.$id = id; // The channel id
this.$conn = conn; // The underlying SockJS connection
_.extend(this, properties); // Apply extra properties to this object
this.readyState = this.$conn.readyState;
assert(this.readyState ==... | [
"function",
"MultiplexChannel",
"(",
"id",
",",
"conn",
",",
"properties",
")",
"{",
"events",
".",
"EventEmitter",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"$id",
"=",
"id",
";",
"// The channel id",
"this",
".",
"$conn",
"=",
"conn",
";",
"//... | Fake SockJS connection that can be multiplexed over a real SockJS connection. | [
"Fake",
"SockJS",
"connection",
"that",
"can",
"be",
"multiplexed",
"over",
"a",
"real",
"SockJS",
"connection",
"."
] | 0227ff5e5ce0182921446e45295873932507b36f | https://github.com/rstudio/shiny-server/blob/0227ff5e5ce0182921446e45295873932507b36f/lib/proxy/multiplex.js#L115-L122 | train |
rstudio/shiny-server | lib/router/config-router.js | createServers | function createServers(conf) {
var seenKeys = map.create();
var servers = _.map(conf.search('server'), function(serverNode) {
var listenNode = serverNode.getOne('listen');
if (!listenNode)
throwForNode(serverNode,
new Error('Required "listen" directive is missing'));
var port = serverN... | javascript | function createServers(conf) {
var seenKeys = map.create();
var servers = _.map(conf.search('server'), function(serverNode) {
var listenNode = serverNode.getOne('listen');
if (!listenNode)
throwForNode(serverNode,
new Error('Required "listen" directive is missing'));
var port = serverN... | [
"function",
"createServers",
"(",
"conf",
")",
"{",
"var",
"seenKeys",
"=",
"map",
".",
"create",
"(",
")",
";",
"var",
"servers",
"=",
"_",
".",
"map",
"(",
"conf",
".",
"search",
"(",
"'server'",
")",
",",
"function",
"(",
"serverNode",
")",
"{",
... | Crawl the parsed and validated config file data to create an array of
ServerRouters. | [
"Crawl",
"the",
"parsed",
"and",
"validated",
"config",
"file",
"data",
"to",
"create",
"an",
"array",
"of",
"ServerRouters",
"."
] | 0227ff5e5ce0182921446e45295873932507b36f | https://github.com/rstudio/shiny-server/blob/0227ff5e5ce0182921446e45295873932507b36f/lib/router/config-router.js#L191-L248 | train |
rstudio/shiny-server | lib/router/config-router.js | createLocation | function createLocation(locNode) {
// TODO: Include ancestor locations in path
var path = locNode.values.path;
var terminalLocation = !locNode.getOne('location', false);
var node = locNode.getOne(/^site_dir|user_dirs|app_dir|user_apps|redirect$/);
if (!node) {
// No directives. Only allow this if child l... | javascript | function createLocation(locNode) {
// TODO: Include ancestor locations in path
var path = locNode.values.path;
var terminalLocation = !locNode.getOne('location', false);
var node = locNode.getOne(/^site_dir|user_dirs|app_dir|user_apps|redirect$/);
if (!node) {
// No directives. Only allow this if child l... | [
"function",
"createLocation",
"(",
"locNode",
")",
"{",
"// TODO: Include ancestor locations in path",
"var",
"path",
"=",
"locNode",
".",
"values",
".",
"path",
";",
"var",
"terminalLocation",
"=",
"!",
"locNode",
".",
"getOne",
"(",
"'location'",
",",
"false",
... | Validates the location node, and returns the appropriate type of router
it represents. | [
"Validates",
"the",
"location",
"node",
"and",
"returns",
"the",
"appropriate",
"type",
"of",
"router",
"it",
"represents",
"."
] | 0227ff5e5ce0182921446e45295873932507b36f | https://github.com/rstudio/shiny-server/blob/0227ff5e5ce0182921446e45295873932507b36f/lib/router/config-router.js#L482-L527 | train |
rstudio/shiny-server | lib/core/qutil.js | forEachPromise_p | function forEachPromise_p(array, iterator, accept, defaultValue) {
var deferred = Q.defer();
var i = 0;
function tryNext() {
if (i >= array.length) {
// We've reached the end of the list--give up
deferred.resolve(defaultValue);
}
else {
try {
// Try the next item in the list
... | javascript | function forEachPromise_p(array, iterator, accept, defaultValue) {
var deferred = Q.defer();
var i = 0;
function tryNext() {
if (i >= array.length) {
// We've reached the end of the list--give up
deferred.resolve(defaultValue);
}
else {
try {
// Try the next item in the list
... | [
"function",
"forEachPromise_p",
"(",
"array",
",",
"iterator",
",",
"accept",
",",
"defaultValue",
")",
"{",
"var",
"deferred",
"=",
"Q",
".",
"defer",
"(",
")",
";",
"var",
"i",
"=",
"0",
";",
"function",
"tryNext",
"(",
")",
"{",
"if",
"(",
"i",
... | Starting at the beginning of the array, pass an element to the iterator,
which should return a promise. If the promise resolves, test the value
using the accept function. If accepted, that value is the result. If not
accepted, move on to the next array element.
If any of the iterator-produced promises fails, then reje... | [
"Starting",
"at",
"the",
"beginning",
"of",
"the",
"array",
"pass",
"an",
"element",
"to",
"the",
"iterator",
"which",
"should",
"return",
"a",
"promise",
".",
"If",
"the",
"promise",
"resolves",
"test",
"the",
"value",
"using",
"the",
"accept",
"function",
... | 0227ff5e5ce0182921446e45295873932507b36f | https://github.com/rstudio/shiny-server/blob/0227ff5e5ce0182921446e45295873932507b36f/lib/core/qutil.js#L91-L124 | train |
rstudio/shiny-server | lib/core/qutil.js | fapply | function fapply(func, object, args) {
try {
return Q.resolve(func.apply(object, args));
} catch(err) {
return Q.reject(err);
}
} | javascript | function fapply(func, object, args) {
try {
return Q.resolve(func.apply(object, args));
} catch(err) {
return Q.reject(err);
}
} | [
"function",
"fapply",
"(",
"func",
",",
"object",
",",
"args",
")",
"{",
"try",
"{",
"return",
"Q",
".",
"resolve",
"(",
"func",
".",
"apply",
"(",
"object",
",",
"args",
")",
")",
";",
"}",
"catch",
"(",
"err",
")",
"{",
"return",
"Q",
".",
"r... | Apply a synchronous function but wrap the result or exception in a promise.
Why doesn't Q.apply work this way?? | [
"Apply",
"a",
"synchronous",
"function",
"but",
"wrap",
"the",
"result",
"or",
"exception",
"in",
"a",
"promise",
".",
"Why",
"doesn",
"t",
"Q",
".",
"apply",
"work",
"this",
"way??"
] | 0227ff5e5ce0182921446e45295873932507b36f | https://github.com/rstudio/shiny-server/blob/0227ff5e5ce0182921446e45295873932507b36f/lib/core/qutil.js#L131-L137 | train |
rstudio/shiny-server | lib/core/qutil.js | map_p | function map_p(collection, func_p) {
if (collection.length === 0)
return Q.resolve([]);
var results = [];
var lastFunc = Q.resolve(true);
_.each(collection, function(el, index) {
lastFunc = lastFunc.then(function() {
return func_p(collection[index])
.then(function(result) {
results[index... | javascript | function map_p(collection, func_p) {
if (collection.length === 0)
return Q.resolve([]);
var results = [];
var lastFunc = Q.resolve(true);
_.each(collection, function(el, index) {
lastFunc = lastFunc.then(function() {
return func_p(collection[index])
.then(function(result) {
results[index... | [
"function",
"map_p",
"(",
"collection",
",",
"func_p",
")",
"{",
"if",
"(",
"collection",
".",
"length",
"===",
"0",
")",
"return",
"Q",
".",
"resolve",
"(",
"[",
"]",
")",
";",
"var",
"results",
"=",
"[",
"]",
";",
"var",
"lastFunc",
"=",
"Q",
"... | Pass in a collection and a promise-returning function, and map_p will
do a sequential map operation and resolve to the results. | [
"Pass",
"in",
"a",
"collection",
"and",
"a",
"promise",
"-",
"returning",
"function",
"and",
"map_p",
"will",
"do",
"a",
"sequential",
"map",
"operation",
"and",
"resolve",
"to",
"the",
"results",
"."
] | 0227ff5e5ce0182921446e45295873932507b36f | https://github.com/rstudio/shiny-server/blob/0227ff5e5ce0182921446e45295873932507b36f/lib/core/qutil.js#L158-L177 | train |
rstudio/shiny-server | lib/config/app-config.js | findConfig_p | function findConfig_p(appDir){
var filePath = path.join(appDir, ".shiny_app.conf");
return fsutil.safeStat_p(filePath)
.then(function(stat){
if (stat && stat.isFile()){
return (filePath);
}
throw new Error('Invalid app configuration file.');
});
} | javascript | function findConfig_p(appDir){
var filePath = path.join(appDir, ".shiny_app.conf");
return fsutil.safeStat_p(filePath)
.then(function(stat){
if (stat && stat.isFile()){
return (filePath);
}
throw new Error('Invalid app configuration file.');
});
} | [
"function",
"findConfig_p",
"(",
"appDir",
")",
"{",
"var",
"filePath",
"=",
"path",
".",
"join",
"(",
"appDir",
",",
"\".shiny_app.conf\"",
")",
";",
"return",
"fsutil",
".",
"safeStat_p",
"(",
"filePath",
")",
".",
"then",
"(",
"function",
"(",
"stat",
... | Check to see if there's a configuration file in the given app directory,
if so, parse it.
@param appDir The base directory in which the application is hosted.
@return A promise resolving to the path of the application-specific
configuration file | [
"Check",
"to",
"see",
"if",
"there",
"s",
"a",
"configuration",
"file",
"in",
"the",
"given",
"app",
"directory",
"if",
"so",
"parse",
"it",
"."
] | 0227ff5e5ce0182921446e45295873932507b36f | https://github.com/rstudio/shiny-server/blob/0227ff5e5ce0182921446e45295873932507b36f/lib/config/app-config.js#L92-L101 | train |
rstudio/shiny-server | lib/core/render.js | sendClientAlertMessage | function sendClientAlertMessage(ws, alert) {
var msg = JSON.stringify({
custom: {
alert: alert
}
});
ws.write(msg);
} | javascript | function sendClientAlertMessage(ws, alert) {
var msg = JSON.stringify({
custom: {
alert: alert
}
});
ws.write(msg);
} | [
"function",
"sendClientAlertMessage",
"(",
"ws",
",",
"alert",
")",
"{",
"var",
"msg",
"=",
"JSON",
".",
"stringify",
"(",
"{",
"custom",
":",
"{",
"alert",
":",
"alert",
"}",
"}",
")",
";",
"ws",
".",
"write",
"(",
"msg",
")",
";",
"}"
] | Sends the given string to the client, where it will be displayed as a
JavaScript alert message. | [
"Sends",
"the",
"given",
"string",
"to",
"the",
"client",
"where",
"it",
"will",
"be",
"displayed",
"as",
"a",
"JavaScript",
"alert",
"message",
"."
] | 0227ff5e5ce0182921446e45295873932507b36f | https://github.com/rstudio/shiny-server/blob/0227ff5e5ce0182921446e45295873932507b36f/lib/core/render.js#L110-L117 | train |
rstudio/shiny-server | lib/core/render.js | error404 | function error404(req, res, templateDir) {
sendPage(res, 404, 'Page not found', {
template: 'error-404',
templateDir: templateDir,
vars: {
message: "Sorry, but the page you requested doesn't exist."
}
});
} | javascript | function error404(req, res, templateDir) {
sendPage(res, 404, 'Page not found', {
template: 'error-404',
templateDir: templateDir,
vars: {
message: "Sorry, but the page you requested doesn't exist."
}
});
} | [
"function",
"error404",
"(",
"req",
",",
"res",
",",
"templateDir",
")",
"{",
"sendPage",
"(",
"res",
",",
"404",
",",
"'Page not found'",
",",
"{",
"template",
":",
"'error-404'",
",",
"templateDir",
":",
"templateDir",
",",
"vars",
":",
"{",
"message",
... | Send a 404 error response | [
"Send",
"a",
"404",
"error",
"response"
] | 0227ff5e5ce0182921446e45295873932507b36f | https://github.com/rstudio/shiny-server/blob/0227ff5e5ce0182921446e45295873932507b36f/lib/core/render.js#L121-L129 | train |
rstudio/shiny-server | lib/core/render.js | errorAppOverloaded | function errorAppOverloaded(req, res, templateDir) {
sendPage(res, 503, 'Too Many Users', {
template: 'error-503-users',
templateDir: templateDir,
vars: {
message: "Sorry, but this application has exceeded its quota of concurrent users. Please try again later."
}
});
} | javascript | function errorAppOverloaded(req, res, templateDir) {
sendPage(res, 503, 'Too Many Users', {
template: 'error-503-users',
templateDir: templateDir,
vars: {
message: "Sorry, but this application has exceeded its quota of concurrent users. Please try again later."
}
});
} | [
"function",
"errorAppOverloaded",
"(",
"req",
",",
"res",
",",
"templateDir",
")",
"{",
"sendPage",
"(",
"res",
",",
"503",
",",
"'Too Many Users'",
",",
"{",
"template",
":",
"'error-503-users'",
",",
"templateDir",
":",
"templateDir",
",",
"vars",
":",
"{"... | Send a 503 error response | [
"Send",
"a",
"503",
"error",
"response"
] | 0227ff5e5ce0182921446e45295873932507b36f | https://github.com/rstudio/shiny-server/blob/0227ff5e5ce0182921446e45295873932507b36f/lib/core/render.js#L133-L141 | train |
rstudio/shiny-server | lib/main.js | ping | function ping(req, res) {
if (url.parse(req.url).pathname == '/ping') {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('OK');
return true;
}
return false;
} | javascript | function ping(req, res) {
if (url.parse(req.url).pathname == '/ping') {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('OK');
return true;
}
return false;
} | [
"function",
"ping",
"(",
"req",
",",
"res",
")",
"{",
"if",
"(",
"url",
".",
"parse",
"(",
"req",
".",
"url",
")",
".",
"pathname",
"==",
"'/ping'",
")",
"{",
"res",
".",
"writeHead",
"(",
"200",
",",
"{",
"'Content-Type'",
":",
"'text/plain'",
"}"... | A simple router function that does nothing but respond "OK". Can be used for load balancer health checks, for example. | [
"A",
"simple",
"router",
"function",
"that",
"does",
"nothing",
"but",
"respond",
"OK",
".",
"Can",
"be",
"used",
"for",
"load",
"balancer",
"health",
"checks",
"for",
"example",
"."
] | 0227ff5e5ce0182921446e45295873932507b36f | https://github.com/rstudio/shiny-server/blob/0227ff5e5ce0182921446e45295873932507b36f/lib/main.js#L111-L118 | train |
rstudio/shiny-server | lib/core/map.js | compact | function compact(x) {
function shouldDrop(key) {
return typeof(x[key]) === 'undefined' || x[key] === null;
}
return _.omit(x, _.filter(_.keys(x), shouldDrop))
} | javascript | function compact(x) {
function shouldDrop(key) {
return typeof(x[key]) === 'undefined' || x[key] === null;
}
return _.omit(x, _.filter(_.keys(x), shouldDrop))
} | [
"function",
"compact",
"(",
"x",
")",
"{",
"function",
"shouldDrop",
"(",
"key",
")",
"{",
"return",
"typeof",
"(",
"x",
"[",
"key",
"]",
")",
"===",
"'undefined'",
"||",
"x",
"[",
"key",
"]",
"===",
"null",
";",
"}",
"return",
"_",
".",
"omit",
... | Return a copy of object x with null or undefined "own" properties removed. | [
"Return",
"a",
"copy",
"of",
"object",
"x",
"with",
"null",
"or",
"undefined",
"own",
"properties",
"removed",
"."
] | 0227ff5e5ce0182921446e45295873932507b36f | https://github.com/rstudio/shiny-server/blob/0227ff5e5ce0182921446e45295873932507b36f/lib/core/map.js#L28-L33 | train |
machty/ember-concurrency | vendor/dummy-deps/rx.js | AnonymousObserver | function AnonymousObserver(onNext, onError, onCompleted) {
__super__.call(this);
this._onNext = onNext;
this._onError = onError;
this._onCompleted = onCompleted;
} | javascript | function AnonymousObserver(onNext, onError, onCompleted) {
__super__.call(this);
this._onNext = onNext;
this._onError = onError;
this._onCompleted = onCompleted;
} | [
"function",
"AnonymousObserver",
"(",
"onNext",
",",
"onError",
",",
"onCompleted",
")",
"{",
"__super__",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"_onNext",
"=",
"onNext",
";",
"this",
".",
"_onError",
"=",
"onError",
";",
"this",
".",
"_onComp... | Creates an observer from the specified OnNext, OnError, and OnCompleted actions.
@param {Any} onNext Observer's OnNext action implementation.
@param {Any} onError Observer's OnError action implementation.
@param {Any} onCompleted Observer's OnCompleted action implementation. | [
"Creates",
"an",
"observer",
"from",
"the",
"specified",
"OnNext",
"OnError",
"and",
"OnCompleted",
"actions",
"."
] | 6b1a46e5ccd5495412409a29d82b5fcc6dae2272 | https://github.com/machty/ember-concurrency/blob/6b1a46e5ccd5495412409a29d82b5fcc6dae2272/vendor/dummy-deps/rx.js#L1806-L1811 | train |
machty/ember-concurrency | vendor/dummy-deps/rx.js | arrayIndexOfComparer | function arrayIndexOfComparer(array, item, comparer) {
for (var i = 0, len = array.length; i < len; i++) {
if (comparer(array[i], item)) { return i; }
}
return -1;
} | javascript | function arrayIndexOfComparer(array, item, comparer) {
for (var i = 0, len = array.length; i < len; i++) {
if (comparer(array[i], item)) { return i; }
}
return -1;
} | [
"function",
"arrayIndexOfComparer",
"(",
"array",
",",
"item",
",",
"comparer",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"array",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"if",
"(",
"comparer",
"(",
"arra... | Swap out for Array.findIndex | [
"Swap",
"out",
"for",
"Array",
".",
"findIndex"
] | 6b1a46e5ccd5495412409a29d82b5fcc6dae2272 | https://github.com/machty/ember-concurrency/blob/6b1a46e5ccd5495412409a29d82b5fcc6dae2272/vendor/dummy-deps/rx.js#L5256-L5261 | train |
machty/ember-concurrency | vendor/dummy-deps/rx.js | VirtualTimeScheduler | function VirtualTimeScheduler(initialClock, comparer) {
this.clock = initialClock;
this.comparer = comparer;
this.isEnabled = false;
this.queue = new PriorityQueue(1024);
__super__.call(this);
} | javascript | function VirtualTimeScheduler(initialClock, comparer) {
this.clock = initialClock;
this.comparer = comparer;
this.isEnabled = false;
this.queue = new PriorityQueue(1024);
__super__.call(this);
} | [
"function",
"VirtualTimeScheduler",
"(",
"initialClock",
",",
"comparer",
")",
"{",
"this",
".",
"clock",
"=",
"initialClock",
";",
"this",
".",
"comparer",
"=",
"comparer",
";",
"this",
".",
"isEnabled",
"=",
"false",
";",
"this",
".",
"queue",
"=",
"new"... | Creates a new virtual time scheduler with the specified initial clock value and absolute time comparer.
@constructor
@param {Number} initialClock Initial value for the clock.
@param {Function} comparer Comparer to determine causality of events based on absolute time. | [
"Creates",
"a",
"new",
"virtual",
"time",
"scheduler",
"with",
"the",
"specified",
"initial",
"clock",
"value",
"and",
"absolute",
"time",
"comparer",
"."
] | 6b1a46e5ccd5495412409a29d82b5fcc6dae2272 | https://github.com/machty/ember-concurrency/blob/6b1a46e5ccd5495412409a29d82b5fcc6dae2272/vendor/dummy-deps/rx.js#L10873-L10879 | train |
machty/ember-concurrency | vendor/dummy-deps/rx.js | HistoricalScheduler | function HistoricalScheduler(initialClock, comparer) {
var clock = initialClock == null ? 0 : initialClock;
var cmp = comparer || defaultSubComparer;
__super__.call(this, clock, cmp);
} | javascript | function HistoricalScheduler(initialClock, comparer) {
var clock = initialClock == null ? 0 : initialClock;
var cmp = comparer || defaultSubComparer;
__super__.call(this, clock, cmp);
} | [
"function",
"HistoricalScheduler",
"(",
"initialClock",
",",
"comparer",
")",
"{",
"var",
"clock",
"=",
"initialClock",
"==",
"null",
"?",
"0",
":",
"initialClock",
";",
"var",
"cmp",
"=",
"comparer",
"||",
"defaultSubComparer",
";",
"__super__",
".",
"call",
... | Creates a new historical scheduler with the specified initial clock value.
@constructor
@param {Number} initialClock Initial value for the clock.
@param {Function} comparer Comparer to determine causality of events based on absolute time. | [
"Creates",
"a",
"new",
"historical",
"scheduler",
"with",
"the",
"specified",
"initial",
"clock",
"value",
"."
] | 6b1a46e5ccd5495412409a29d82b5fcc6dae2272 | https://github.com/machty/ember-concurrency/blob/6b1a46e5ccd5495412409a29d82b5fcc6dae2272/vendor/dummy-deps/rx.js#L11067-L11071 | train |
machty/ember-concurrency | vendor/dummy-deps/rx.js | function (ticks, value) {
return typeof value === 'function' ?
new Recorded(ticks, new OnNextPredicate(value)) :
new Recorded(ticks, Notification.createOnNext(value));
} | javascript | function (ticks, value) {
return typeof value === 'function' ?
new Recorded(ticks, new OnNextPredicate(value)) :
new Recorded(ticks, Notification.createOnNext(value));
} | [
"function",
"(",
"ticks",
",",
"value",
")",
"{",
"return",
"typeof",
"value",
"===",
"'function'",
"?",
"new",
"Recorded",
"(",
"ticks",
",",
"new",
"OnNextPredicate",
"(",
"value",
")",
")",
":",
"new",
"Recorded",
"(",
"ticks",
",",
"Notification",
".... | Factory method for an OnNext notification record at a given time with a given value or a predicate function.
1 - ReactiveTest.onNext(200, 42);
2 - ReactiveTest.onNext(200, function (x) { return x.length == 2; });
@param ticks Recorded virtual time the OnNext notification occurs.
@param value Recorded value stored in ... | [
"Factory",
"method",
"for",
"an",
"OnNext",
"notification",
"record",
"at",
"a",
"given",
"time",
"with",
"a",
"given",
"value",
"or",
"a",
"predicate",
"function",
"."
] | 6b1a46e5ccd5495412409a29d82b5fcc6dae2272 | https://github.com/machty/ember-concurrency/blob/6b1a46e5ccd5495412409a29d82b5fcc6dae2272/vendor/dummy-deps/rx.js#L11142-L11146 | train | |
machty/ember-concurrency | vendor/dummy-deps/rx.js | function (ticks, error) {
return typeof error === 'function' ?
new Recorded(ticks, new OnErrorPredicate(error)) :
new Recorded(ticks, Notification.createOnError(error));
} | javascript | function (ticks, error) {
return typeof error === 'function' ?
new Recorded(ticks, new OnErrorPredicate(error)) :
new Recorded(ticks, Notification.createOnError(error));
} | [
"function",
"(",
"ticks",
",",
"error",
")",
"{",
"return",
"typeof",
"error",
"===",
"'function'",
"?",
"new",
"Recorded",
"(",
"ticks",
",",
"new",
"OnErrorPredicate",
"(",
"error",
")",
")",
":",
"new",
"Recorded",
"(",
"ticks",
",",
"Notification",
"... | Factory method for an OnError notification record at a given time with a given error.
1 - ReactiveTest.onNext(200, new Error('error'));
2 - ReactiveTest.onNext(200, function (e) { return e.message === 'error'; });
@param ticks Recorded virtual time the OnError notification occurs.
@param exception Recorded exception ... | [
"Factory",
"method",
"for",
"an",
"OnError",
"notification",
"record",
"at",
"a",
"given",
"time",
"with",
"a",
"given",
"error",
"."
] | 6b1a46e5ccd5495412409a29d82b5fcc6dae2272 | https://github.com/machty/ember-concurrency/blob/6b1a46e5ccd5495412409a29d82b5fcc6dae2272/vendor/dummy-deps/rx.js#L11157-L11161 | train | |
machty/ember-concurrency | vendor/dummy-deps/rx.js | AsyncSubject | function AsyncSubject() {
__super__.call(this);
this.isDisposed = false;
this.isStopped = false;
this.hasValue = false;
this.observers = [];
this.hasError = false;
} | javascript | function AsyncSubject() {
__super__.call(this);
this.isDisposed = false;
this.isStopped = false;
this.hasValue = false;
this.observers = [];
this.hasError = false;
} | [
"function",
"AsyncSubject",
"(",
")",
"{",
"__super__",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"isDisposed",
"=",
"false",
";",
"this",
".",
"isStopped",
"=",
"false",
";",
"this",
".",
"hasValue",
"=",
"false",
";",
"this",
".",
"observers",... | Creates a subject that can only receive one value and that value is cached for all future observations.
@constructor | [
"Creates",
"a",
"subject",
"that",
"can",
"only",
"receive",
"one",
"value",
"and",
"that",
"value",
"is",
"cached",
"for",
"all",
"future",
"observations",
"."
] | 6b1a46e5ccd5495412409a29d82b5fcc6dae2272 | https://github.com/machty/ember-concurrency/blob/6b1a46e5ccd5495412409a29d82b5fcc6dae2272/vendor/dummy-deps/rx.js#L11783-L11790 | train |
intel-iot-devkit/upm | examples/javascript/zfm20-register.js | exit | function exit()
{
myFingerprintSensor = null;
fingerprint_lib.cleanUp();
fingerprint_lib = null;
console.log("Exiting");
process.exit(0);
} | javascript | function exit()
{
myFingerprintSensor = null;
fingerprint_lib.cleanUp();
fingerprint_lib = null;
console.log("Exiting");
process.exit(0);
} | [
"function",
"exit",
"(",
")",
"{",
"myFingerprintSensor",
"=",
"null",
";",
"fingerprint_lib",
".",
"cleanUp",
"(",
")",
";",
"fingerprint_lib",
"=",
"null",
";",
"console",
".",
"log",
"(",
"\"Exiting\"",
")",
";",
"process",
".",
"exit",
"(",
"0",
")",... | Print message when exiting | [
"Print",
"message",
"when",
"exiting"
] | 5cf20df96c6b35c19d5b871ba4e319e96b4df72d | https://github.com/intel-iot-devkit/upm/blob/5cf20df96c6b35c19d5b871ba4e319e96b4df72d/examples/javascript/zfm20-register.js#L126-L133 | train |
intel-iot-devkit/upm | examples/javascript/md-stepper.js | start | function start()
{
if (motor)
{
// configure it, for this example, we'll assume 200 steps per rev
motor.configStepper(200);
motor.setStepperSteps(100);
// start it going at 10 RPM
motor.enableStepper(mdObj.MD.STEP_DIR_CW, 10);
}
} | javascript | function start()
{
if (motor)
{
// configure it, for this example, we'll assume 200 steps per rev
motor.configStepper(200);
motor.setStepperSteps(100);
// start it going at 10 RPM
motor.enableStepper(mdObj.MD.STEP_DIR_CW, 10);
}
} | [
"function",
"start",
"(",
")",
"{",
"if",
"(",
"motor",
")",
"{",
"// configure it, for this example, we'll assume 200 steps per rev",
"motor",
".",
"configStepper",
"(",
"200",
")",
";",
"motor",
".",
"setStepperSteps",
"(",
"100",
")",
";",
"// start it going at 1... | This example demonstrates using the MD to drive a stepper motor | [
"This",
"example",
"demonstrates",
"using",
"the",
"MD",
"to",
"drive",
"a",
"stepper",
"motor"
] | 5cf20df96c6b35c19d5b871ba4e319e96b4df72d | https://github.com/intel-iot-devkit/upm/blob/5cf20df96c6b35c19d5b871ba4e319e96b4df72d/examples/javascript/md-stepper.js#L29-L39 | train |
intel-iot-devkit/upm | examples/javascript/adis16448.js | periodicActivity | function periodicActivity()
{
//Read & Scale Gyro/Accel Data
var xgyro = imu.gyroScale(imu.regRead(0x04));
var ygyro = imu.gyroScale(imu.regRead(0x06));
var zgyro = imu.gyroScale(imu.regRead(0x08));
var xaccl = imu.accelScale(imu.regRead(0x0A));
var yaccl = imu.accelScale(imu.regRead(0x0C));... | javascript | function periodicActivity()
{
//Read & Scale Gyro/Accel Data
var xgyro = imu.gyroScale(imu.regRead(0x04));
var ygyro = imu.gyroScale(imu.regRead(0x06));
var zgyro = imu.gyroScale(imu.regRead(0x08));
var xaccl = imu.accelScale(imu.regRead(0x0A));
var yaccl = imu.accelScale(imu.regRead(0x0C));... | [
"function",
"periodicActivity",
"(",
")",
"{",
"//Read & Scale Gyro/Accel Data",
"var",
"xgyro",
"=",
"imu",
".",
"gyroScale",
"(",
"imu",
".",
"regRead",
"(",
"0x04",
")",
")",
";",
"var",
"ygyro",
"=",
"imu",
".",
"gyroScale",
"(",
"imu",
".",
"regRead",... | Call the periodicActivity function | [
"Call",
"the",
"periodicActivity",
"function"
] | 5cf20df96c6b35c19d5b871ba4e319e96b4df72d | https://github.com/intel-iot-devkit/upm/blob/5cf20df96c6b35c19d5b871ba4e319e96b4df72d/examples/javascript/adis16448.js#L48-L67 | train |
intel-iot-devkit/upm | examples/javascript/ttp223.js | readSensorValue | function readSensorValue() {
if ( touch.isPressed() ) {
console.log(touch.name() + " is pressed");
} else {
console.log(touch.name() + " is not pressed");
}
} | javascript | function readSensorValue() {
if ( touch.isPressed() ) {
console.log(touch.name() + " is pressed");
} else {
console.log(touch.name() + " is not pressed");
}
} | [
"function",
"readSensorValue",
"(",
")",
"{",
"if",
"(",
"touch",
".",
"isPressed",
"(",
")",
")",
"{",
"console",
".",
"log",
"(",
"touch",
".",
"name",
"(",
")",
"+",
"\" is pressed\"",
")",
";",
"}",
"else",
"{",
"console",
".",
"log",
"(",
"tou... | Check whether or not a finger is near the touch sensor and print accordingly, waiting one second between readings | [
"Check",
"whether",
"or",
"not",
"a",
"finger",
"is",
"near",
"the",
"touch",
"sensor",
"and",
"print",
"accordingly",
"waiting",
"one",
"second",
"between",
"readings"
] | 5cf20df96c6b35c19d5b871ba4e319e96b4df72d | https://github.com/intel-iot-devkit/upm/blob/5cf20df96c6b35c19d5b871ba4e319e96b4df72d/examples/javascript/ttp223.js#L33-L39 | train |
intel-iot-devkit/upm | examples/javascript/bno055.js | outputData | function outputData()
{
sensor.update();
var floatData = sensor.getEulerAngles();
console.log("Euler: Heading: " + floatData.get(0)
+ " Roll: " + floatData.get(1)
+ " Pitch: " + floatData.get(2)
+ " degrees");
floatData = sensor.getQuaternions();
con... | javascript | function outputData()
{
sensor.update();
var floatData = sensor.getEulerAngles();
console.log("Euler: Heading: " + floatData.get(0)
+ " Roll: " + floatData.get(1)
+ " Pitch: " + floatData.get(2)
+ " degrees");
floatData = sensor.getQuaternions();
con... | [
"function",
"outputData",
"(",
")",
"{",
"sensor",
".",
"update",
"(",
")",
";",
"var",
"floatData",
"=",
"sensor",
".",
"getEulerAngles",
"(",
")",
";",
"console",
".",
"log",
"(",
"\"Euler: Heading: \"",
"+",
"floatData",
".",
"get",
"(",
"0",
")",
"... | now output various fusion data every 250 milliseconds | [
"now",
"output",
"various",
"fusion",
"data",
"every",
"250",
"milliseconds"
] | 5cf20df96c6b35c19d5b871ba4e319e96b4df72d | https://github.com/intel-iot-devkit/upm/blob/5cf20df96c6b35c19d5b871ba4e319e96b4df72d/examples/javascript/bno055.js#L67-L96 | train |
intel-iot-devkit/upm | examples/javascript/tm1637.js | update | function update(){
now = new Date();
var time = now.getHours().toString() + ("0" + now.getMinutes().toString()).slice(-2);
display.writeString(time);
display.setColon(colon = !colon);
} | javascript | function update(){
now = new Date();
var time = now.getHours().toString() + ("0" + now.getMinutes().toString()).slice(-2);
display.writeString(time);
display.setColon(colon = !colon);
} | [
"function",
"update",
"(",
")",
"{",
"now",
"=",
"new",
"Date",
"(",
")",
";",
"var",
"time",
"=",
"now",
".",
"getHours",
"(",
")",
".",
"toString",
"(",
")",
"+",
"(",
"\"0\"",
"+",
"now",
".",
"getMinutes",
"(",
")",
".",
"toString",
"(",
")... | Display and time update function | [
"Display",
"and",
"time",
"update",
"function"
] | 5cf20df96c6b35c19d5b871ba4e319e96b4df72d | https://github.com/intel-iot-devkit/upm/blob/5cf20df96c6b35c19d5b871ba4e319e96b4df72d/examples/javascript/tm1637.js#L41-L46 | train |
intel-iot-devkit/upm | examples/javascript/ili9341.js | rotateScreen | function rotateScreen(r) {
lcd.setRotation(r);
lcd.fillRect(0, 0, 5, 5, ili9341.ILI9341_WHITE);
if (r < 4) {
r++;
setTimeout(function() { rotateScreen(r); }, 1000);
}
} | javascript | function rotateScreen(r) {
lcd.setRotation(r);
lcd.fillRect(0, 0, 5, 5, ili9341.ILI9341_WHITE);
if (r < 4) {
r++;
setTimeout(function() { rotateScreen(r); }, 1000);
}
} | [
"function",
"rotateScreen",
"(",
"r",
")",
"{",
"lcd",
".",
"setRotation",
"(",
"r",
")",
";",
"lcd",
".",
"fillRect",
"(",
"0",
",",
"0",
",",
"5",
",",
"5",
",",
"ili9341",
".",
"ILI9341_WHITE",
")",
";",
"if",
"(",
"r",
"<",
"4",
")",
"{",
... | Test screen rotation | [
"Test",
"screen",
"rotation"
] | 5cf20df96c6b35c19d5b871ba4e319e96b4df72d | https://github.com/intel-iot-devkit/upm/blob/5cf20df96c6b35c19d5b871ba4e319e96b4df72d/examples/javascript/ili9341.js#L65-L72 | train |
pkgcloud/pkgcloud | lib/pkgcloud/openstack/compute/client/extensions/networks-base.js | function (callback) {
return this._request({
path: this._extension
}, function (err, body, res) {
return err
? callback(err)
: callback(null, body.networks, res);
});
} | javascript | function (callback) {
return this._request({
path: this._extension
}, function (err, body, res) {
return err
? callback(err)
: callback(null, body.networks, res);
});
} | [
"function",
"(",
"callback",
")",
"{",
"return",
"this",
".",
"_request",
"(",
"{",
"path",
":",
"this",
".",
"_extension",
"}",
",",
"function",
"(",
"err",
",",
"body",
",",
"res",
")",
"{",
"return",
"err",
"?",
"callback",
"(",
"err",
")",
":",... | client.getNetworks
@description Display the currently available networks
@param {Function} callback f(err, networks) where networks is an array of networks
@returns {*} | [
"client",
".",
"getNetworks"
] | 44e08a0063252829cdb5e9a8b430c2f4c08b91ad | https://github.com/pkgcloud/pkgcloud/blob/44e08a0063252829cdb5e9a8b430c2f4c08b91ad/lib/pkgcloud/openstack/compute/client/extensions/networks-base.js#L26-L34 | train | |
pkgcloud/pkgcloud | lib/pkgcloud/openstack/compute/client/extensions/networks-base.js | function (network, callback) {
var networkId = (typeof network === 'object') ? network.id : network;
return this._request({
path: urlJoin(this._extension, networkId)
}, function (err, body) {
return err
? callback(err)
: callback(null, body.network);
});
... | javascript | function (network, callback) {
var networkId = (typeof network === 'object') ? network.id : network;
return this._request({
path: urlJoin(this._extension, networkId)
}, function (err, body) {
return err
? callback(err)
: callback(null, body.network);
});
... | [
"function",
"(",
"network",
",",
"callback",
")",
"{",
"var",
"networkId",
"=",
"(",
"typeof",
"network",
"===",
"'object'",
")",
"?",
"network",
".",
"id",
":",
"network",
";",
"return",
"this",
".",
"_request",
"(",
"{",
"path",
":",
"urlJoin",
"(",
... | client.getNetwork
@description Get the details for a specific network
@param {String|object} network The network or networkId to get
@param {Function} callback
@returns {*} | [
"client",
".",
"getNetwork"
] | 44e08a0063252829cdb5e9a8b430c2f4c08b91ad | https://github.com/pkgcloud/pkgcloud/blob/44e08a0063252829cdb5e9a8b430c2f4c08b91ad/lib/pkgcloud/openstack/compute/client/extensions/networks-base.js#L45-L55 | train | |
pkgcloud/pkgcloud | lib/pkgcloud/openstack/compute/client/extensions/networks-base.js | function (options, properties, callback) {
return this._request({
method: 'POST',
path: this._extension,
body: {
network: _.pick(options, properties)
}
}, function (err, body) {
return err
? callback(err)
: callback(null, body.network);
... | javascript | function (options, properties, callback) {
return this._request({
method: 'POST',
path: this._extension,
body: {
network: _.pick(options, properties)
}
}, function (err, body) {
return err
? callback(err)
: callback(null, body.network);
... | [
"function",
"(",
"options",
",",
"properties",
",",
"callback",
")",
"{",
"return",
"this",
".",
"_request",
"(",
"{",
"method",
":",
"'POST'",
",",
"path",
":",
"this",
".",
"_extension",
",",
"body",
":",
"{",
"network",
":",
"_",
".",
"pick",
"(",... | client._createNetwork
@description helper function for allowing a different set of options to be passed to the
remote API.
@param options
@param {Array} properties Array of properties to be used when building the payload
@param callback
@returns {*}
@private | [
"client",
".",
"_createNetwork"
] | 44e08a0063252829cdb5e9a8b430c2f4c08b91ad | https://github.com/pkgcloud/pkgcloud/blob/44e08a0063252829cdb5e9a8b430c2f4c08b91ad/lib/pkgcloud/openstack/compute/client/extensions/networks-base.js#L95-L107 | train | |
pkgcloud/pkgcloud | lib/pkgcloud/openstack/compute/client/extensions/networks-base.js | function (network, callback) {
var networkId = (typeof network === 'object') ? network.id : network;
return this._request({
path: urlJoin(this._extension, 'add'),
method: 'POST',
body: {
id: networkId
}
}, function (err) {
return callback(err);
... | javascript | function (network, callback) {
var networkId = (typeof network === 'object') ? network.id : network;
return this._request({
path: urlJoin(this._extension, 'add'),
method: 'POST',
body: {
id: networkId
}
}, function (err) {
return callback(err);
... | [
"function",
"(",
"network",
",",
"callback",
")",
"{",
"var",
"networkId",
"=",
"(",
"typeof",
"network",
"===",
"'object'",
")",
"?",
"network",
".",
"id",
":",
"network",
";",
"return",
"this",
".",
"_request",
"(",
"{",
"path",
":",
"urlJoin",
"(",
... | client.addNetwork
@description Add an existing network to a project
@param {String|object} network The network or networkId to add
@param {Function} callback | [
"client",
".",
"addNetwork"
] | 44e08a0063252829cdb5e9a8b430c2f4c08b91ad | https://github.com/pkgcloud/pkgcloud/blob/44e08a0063252829cdb5e9a8b430c2f4c08b91ad/lib/pkgcloud/openstack/compute/client/extensions/networks-base.js#L117-L129 | train | |
pkgcloud/pkgcloud | examples/compute/oneandone.js | handleServerResponse | function handleServerResponse(err, server) {
if (err) {
console.dir(err);
return;
}
console.log('SERVER CREATED: ' + server.name + ', waiting for active status');
// Wait for status: ACTIVE on our server, and then callback
server.setWait({ status: server.STATUS.running }, 5000, function (er... | javascript | function handleServerResponse(err, server) {
if (err) {
console.dir(err);
return;
}
console.log('SERVER CREATED: ' + server.name + ', waiting for active status');
// Wait for status: ACTIVE on our server, and then callback
server.setWait({ status: server.STATUS.running }, 5000, function (er... | [
"function",
"handleServerResponse",
"(",
"err",
",",
"server",
")",
"{",
"if",
"(",
"err",
")",
"{",
"console",
".",
"dir",
"(",
"err",
")",
";",
"return",
";",
"}",
"console",
".",
"log",
"(",
"'SERVER CREATED: '",
"+",
"server",
".",
"name",
"+",
"... | This function will handle our server creation, as well as waiting for the server to come online after we've created it. | [
"This",
"function",
"will",
"handle",
"our",
"server",
"creation",
"as",
"well",
"as",
"waiting",
"for",
"the",
"server",
"to",
"come",
"online",
"after",
"we",
"ve",
"created",
"it",
"."
] | 44e08a0063252829cdb5e9a8b430c2f4c08b91ad | https://github.com/pkgcloud/pkgcloud/blob/44e08a0063252829cdb5e9a8b430c2f4c08b91ad/examples/compute/oneandone.js#L15-L38 | train |
pkgcloud/pkgcloud | lib/pkgcloud/azure/utils/sharedkeytable.js | SharedKeyTable | function SharedKeyTable(storageAccount, storageAccessKey) {
this.storageAccount = storageAccount;
this.storageAccessKey = storageAccessKey;
this.signer = new HmacSha256Sign(storageAccessKey);
} | javascript | function SharedKeyTable(storageAccount, storageAccessKey) {
this.storageAccount = storageAccount;
this.storageAccessKey = storageAccessKey;
this.signer = new HmacSha256Sign(storageAccessKey);
} | [
"function",
"SharedKeyTable",
"(",
"storageAccount",
",",
"storageAccessKey",
")",
"{",
"this",
".",
"storageAccount",
"=",
"storageAccount",
";",
"this",
".",
"storageAccessKey",
"=",
"storageAccessKey",
";",
"this",
".",
"signer",
"=",
"new",
"HmacSha256Sign",
"... | Creates a new SharedKeyTable object.
@constructor
@param {string} storageAccount The storage account.
@param {string} storageAccessKey The storage account's access key. | [
"Creates",
"a",
"new",
"SharedKeyTable",
"object",
"."
] | 44e08a0063252829cdb5e9a8b430c2f4c08b91ad | https://github.com/pkgcloud/pkgcloud/blob/44e08a0063252829cdb5e9a8b430c2f4c08b91ad/lib/pkgcloud/azure/utils/sharedkeytable.js#L29-L33 | train |
pkgcloud/pkgcloud | lib/pkgcloud/rackspace/loadbalancer/client/loadbalancers.js | function(loadBalancer, callback) {
var self = this,
loadBalancerId =
loadBalancer instanceof lb.LoadBalancer ? loadBalancer.id : loadBalancer;
self._request({
path: urlJoin(_urlPrefix, loadBalancerId)
}, function (err, body) {
if (err) {
return callback(err);
}
... | javascript | function(loadBalancer, callback) {
var self = this,
loadBalancerId =
loadBalancer instanceof lb.LoadBalancer ? loadBalancer.id : loadBalancer;
self._request({
path: urlJoin(_urlPrefix, loadBalancerId)
}, function (err, body) {
if (err) {
return callback(err);
}
... | [
"function",
"(",
"loadBalancer",
",",
"callback",
")",
"{",
"var",
"self",
"=",
"this",
",",
"loadBalancerId",
"=",
"loadBalancer",
"instanceof",
"lb",
".",
"LoadBalancer",
"?",
"loadBalancer",
".",
"id",
":",
"loadBalancer",
";",
"self",
".",
"_request",
"(... | client.getLoadBalancer
@description Get the details for the provided load balancer Id
@param {object|String} loadBalancer The loadBalancer or loadBalancer id for the query
@param {function} callback
@returns {*} | [
"client",
".",
"getLoadBalancer"
] | 44e08a0063252829cdb5e9a8b430c2f4c08b91ad | https://github.com/pkgcloud/pkgcloud/blob/44e08a0063252829cdb5e9a8b430c2f4c08b91ad/lib/pkgcloud/rackspace/loadbalancer/client/loadbalancers.js#L120-L140 | train | |
pkgcloud/pkgcloud | lib/pkgcloud/rackspace/loadbalancer/client/loadbalancers.js | function(details, callback) {
var self = this,
createOptions = {
path: _urlPrefix,
method: 'POST',
body: {
name: details.name,
nodes: details.nodes || [],
protocol: details.protocol ? details.protocol.name : '',
port: details.prot... | javascript | function(details, callback) {
var self = this,
createOptions = {
path: _urlPrefix,
method: 'POST',
body: {
name: details.name,
nodes: details.nodes || [],
protocol: details.protocol ? details.protocol.name : '',
port: details.prot... | [
"function",
"(",
"details",
",",
"callback",
")",
"{",
"var",
"self",
"=",
"this",
",",
"createOptions",
"=",
"{",
"path",
":",
"_urlPrefix",
",",
"method",
":",
"'POST'",
",",
"body",
":",
"{",
"name",
":",
"details",
".",
"name",
",",
"nodes",
":",... | client.createLoadBalancer
@description Create a new cloud LoadBalancer. There are a number of options for
cloud load balancers; please reference the Rackspace API documentation for more
insight into the specific parameter values:
http://docs.rackspace.com/loadbalancers/api/v1.0/clb-devguide/content/Create_Load_Balanc... | [
"client",
".",
"createLoadBalancer"
] | 44e08a0063252829cdb5e9a8b430c2f4c08b91ad | https://github.com/pkgcloud/pkgcloud/blob/44e08a0063252829cdb5e9a8b430c2f4c08b91ad/lib/pkgcloud/rackspace/loadbalancer/client/loadbalancers.js#L164-L194 | train | |
pkgcloud/pkgcloud | lib/pkgcloud/rackspace/loadbalancer/client/loadbalancers.js | function (loadBalancer, callback) {
if (!(loadBalancer instanceof lb.LoadBalancer)) {
throw new Error('Missing required argument: loadBalancer');
}
var self = this,
updateOptions = {
path: urlJoin(_urlPrefix, loadBalancer.id),
method: 'PUT',
body: {}
};
upda... | javascript | function (loadBalancer, callback) {
if (!(loadBalancer instanceof lb.LoadBalancer)) {
throw new Error('Missing required argument: loadBalancer');
}
var self = this,
updateOptions = {
path: urlJoin(_urlPrefix, loadBalancer.id),
method: 'PUT',
body: {}
};
upda... | [
"function",
"(",
"loadBalancer",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"(",
"loadBalancer",
"instanceof",
"lb",
".",
"LoadBalancer",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Missing required argument: loadBalancer'",
")",
";",
"}",
"var",
"self",
... | client.updateLoadBalancer
@description updates specific parameters of the load balancer
Specific properties updated: name, protocol, port, timeout,
algorithm, httpsRedirect and halfClosed
@param {Object} loadBalancer
@param {function} callback | [
"client",
".",
"updateLoadBalancer"
] | 44e08a0063252829cdb5e9a8b430c2f4c08b91ad | https://github.com/pkgcloud/pkgcloud/blob/44e08a0063252829cdb5e9a8b430c2f4c08b91ad/lib/pkgcloud/rackspace/loadbalancer/client/loadbalancers.js#L207-L226 | train | |
pkgcloud/pkgcloud | lib/pkgcloud/rackspace/loadbalancer/client/loadbalancers.js | function(loadBalancer, details, callback) {
var self = this,
loadBalancerId =
loadBalancer instanceof lb.LoadBalancer ? loadBalancer.id : loadBalancer;
if (!details || !details.type) {
throw new Error('Details is a required option for loadBalancer health monitors');
}
var reque... | javascript | function(loadBalancer, details, callback) {
var self = this,
loadBalancerId =
loadBalancer instanceof lb.LoadBalancer ? loadBalancer.id : loadBalancer;
if (!details || !details.type) {
throw new Error('Details is a required option for loadBalancer health monitors');
}
var reque... | [
"function",
"(",
"loadBalancer",
",",
"details",
",",
"callback",
")",
"{",
"var",
"self",
"=",
"this",
",",
"loadBalancerId",
"=",
"loadBalancer",
"instanceof",
"lb",
".",
"LoadBalancer",
"?",
"loadBalancer",
".",
"id",
":",
"loadBalancer",
";",
"if",
"(",
... | client.updateHealthMonitor
@description get the current health monitor configuration for a loadBalancer
@param {Object} loadBalancer the loadBalancer or loadBalancerId
@param {Object} details
@param {function} callback
There are two kinds of connection monitors you can enable, CONNECT a... | [
"client",
".",
"updateHealthMonitor"
] | 44e08a0063252829cdb5e9a8b430c2f4c08b91ad | https://github.com/pkgcloud/pkgcloud/blob/44e08a0063252829cdb5e9a8b430c2f4c08b91ad/lib/pkgcloud/rackspace/loadbalancer/client/loadbalancers.js#L589-L633 | train | |
pkgcloud/pkgcloud | lib/pkgcloud/rackspace/loadbalancer/client/loadbalancers.js | function (loadBalancer, type, callback) {
var self = this,
loadBalancerId =
loadBalancer instanceof lb.LoadBalancer ? loadBalancer.id : loadBalancer;
if (!type || (type !== 'HTTP_COOKIE' && type !== 'SOURCE_IP')) {
throw new Error('Please provide a valid session persistence type');
... | javascript | function (loadBalancer, type, callback) {
var self = this,
loadBalancerId =
loadBalancer instanceof lb.LoadBalancer ? loadBalancer.id : loadBalancer;
if (!type || (type !== 'HTTP_COOKIE' && type !== 'SOURCE_IP')) {
throw new Error('Please provide a valid session persistence type');
... | [
"function",
"(",
"loadBalancer",
",",
"type",
",",
"callback",
")",
"{",
"var",
"self",
"=",
"this",
",",
"loadBalancerId",
"=",
"loadBalancer",
"instanceof",
"lb",
".",
"LoadBalancer",
"?",
"loadBalancer",
".",
"id",
":",
"loadBalancer",
";",
"if",
"(",
"... | client.enableSessionPersistence
@description Enable session persistence of the requested type
@param {Object} loadBalancer the loadBalancer or loadBalancerId
@param {String} type HTTP_COOKIE or SOURCE_IP
@param {function} callback | [
"client",
".",
"enableSessionPersistence"
] | 44e08a0063252829cdb5e9a8b430c2f4c08b91ad | https://github.com/pkgcloud/pkgcloud/blob/44e08a0063252829cdb5e9a8b430c2f4c08b91ad/lib/pkgcloud/rackspace/loadbalancer/client/loadbalancers.js#L687-L707 | train | |
pkgcloud/pkgcloud | lib/pkgcloud/rackspace/loadbalancer/client/loadbalancers.js | function (loadBalancer, details, callback) {
var self = this,
loadBalancerId =
loadBalancer instanceof lb.LoadBalancer ? loadBalancer.id : loadBalancer;
var options = _.pick(details, ['maxConnectionRate', 'maxConnections',
'minConnections', 'rateInterval']);
self._request({
p... | javascript | function (loadBalancer, details, callback) {
var self = this,
loadBalancerId =
loadBalancer instanceof lb.LoadBalancer ? loadBalancer.id : loadBalancer;
var options = _.pick(details, ['maxConnectionRate', 'maxConnections',
'minConnections', 'rateInterval']);
self._request({
p... | [
"function",
"(",
"loadBalancer",
",",
"details",
",",
"callback",
")",
"{",
"var",
"self",
"=",
"this",
",",
"loadBalancerId",
"=",
"loadBalancer",
"instanceof",
"lb",
".",
"LoadBalancer",
"?",
"loadBalancer",
".",
"id",
":",
"loadBalancer",
";",
"var",
"opt... | client.updateConnectionThrottle
@description update or add a connection throttle for the provided load balancer
@param {Object} loadBalancer the loadBalancer or loadBalancerId
@param {Object} details the connection throttle details
@param {function} callback
Sample Access List Entry:
... | [
"client",
".",
"updateConnectionThrottle"
] | 44e08a0063252829cdb5e9a8b430c2f4c08b91ad | https://github.com/pkgcloud/pkgcloud/blob/44e08a0063252829cdb5e9a8b430c2f4c08b91ad/lib/pkgcloud/rackspace/loadbalancer/client/loadbalancers.js#L827-L844 | train | |
pkgcloud/pkgcloud | lib/pkgcloud/rackspace/loadbalancer/client/loadbalancers.js | function (startTime, endTime, options, callback) {
var self = this;
if (typeof options === 'function') {
callback = options;
options = {};
}
var requestOpts = {
path: urlJoin(_urlPrefix, 'billable'),
qs: {
startTime: typeof startTime === 'Date' ? startTime.toISOString()... | javascript | function (startTime, endTime, options, callback) {
var self = this;
if (typeof options === 'function') {
callback = options;
options = {};
}
var requestOpts = {
path: urlJoin(_urlPrefix, 'billable'),
qs: {
startTime: typeof startTime === 'Date' ? startTime.toISOString()... | [
"function",
"(",
"startTime",
",",
"endTime",
",",
"options",
",",
"callback",
")",
"{",
"var",
"self",
"=",
"this",
";",
"if",
"(",
"typeof",
"options",
"===",
"'function'",
")",
"{",
"callback",
"=",
"options",
";",
"options",
"=",
"{",
"}",
";",
"... | client.getBillableLoadBalancers
@description gets the billable load balancer within the query limits provided
@param {Date|String} startTime the start time for the query
@param {Date|String} endTime the end time for the query
@param {object} [options]
@param {object} [options.limit... | [
"client",
".",
"getBillableLoadBalancers"
] | 44e08a0063252829cdb5e9a8b430c2f4c08b91ad | https://github.com/pkgcloud/pkgcloud/blob/44e08a0063252829cdb5e9a8b430c2f4c08b91ad/lib/pkgcloud/rackspace/loadbalancer/client/loadbalancers.js#L1033-L1056 | train | |
pkgcloud/pkgcloud | lib/pkgcloud/rackspace/loadbalancer/client/loadbalancers.js | function (startTime, endTime, callback) {
var self = this;
self._request({
path: urlJoin(_urlPrefix, 'usage'),
qs: {
startTime: typeof startTime === 'Date' ? startTime.toISOString() : startTime,
endTime: typeof endTime === 'Date' ? endTime.toISOString() : endTime
}
}, func... | javascript | function (startTime, endTime, callback) {
var self = this;
self._request({
path: urlJoin(_urlPrefix, 'usage'),
qs: {
startTime: typeof startTime === 'Date' ? startTime.toISOString() : startTime,
endTime: typeof endTime === 'Date' ? endTime.toISOString() : endTime
}
}, func... | [
"function",
"(",
"startTime",
",",
"endTime",
",",
"callback",
")",
"{",
"var",
"self",
"=",
"this",
";",
"self",
".",
"_request",
"(",
"{",
"path",
":",
"urlJoin",
"(",
"_urlPrefix",
",",
"'usage'",
")",
",",
"qs",
":",
"{",
"startTime",
":",
"typeo... | client.getAccountUsage
@description lists account level usage
@param {Date|String} startTime the start time for the query
@param {Date|String} endTime the end time for the query
@param {function} callback | [
"client",
".",
"getAccountUsage"
] | 44e08a0063252829cdb5e9a8b430c2f4c08b91ad | https://github.com/pkgcloud/pkgcloud/blob/44e08a0063252829cdb5e9a8b430c2f4c08b91ad/lib/pkgcloud/rackspace/loadbalancer/client/loadbalancers.js#L1067-L1079 | train | |
pkgcloud/pkgcloud | lib/pkgcloud/rackspace/loadbalancer/client/loadbalancers.js | function (callback) {
var self = this;
self._request({
path: urlJoin(_urlPrefix, 'alloweddomains')
}, function (err, body) {
return callback(err, body.allowedDomains);
});
} | javascript | function (callback) {
var self = this;
self._request({
path: urlJoin(_urlPrefix, 'alloweddomains')
}, function (err, body) {
return callback(err, body.allowedDomains);
});
} | [
"function",
"(",
"callback",
")",
"{",
"var",
"self",
"=",
"this",
";",
"self",
".",
"_request",
"(",
"{",
"path",
":",
"urlJoin",
"(",
"_urlPrefix",
",",
"'alloweddomains'",
")",
"}",
",",
"function",
"(",
"err",
",",
"body",
")",
"{",
"return",
"ca... | client.getAllowedDomains
@description gets a list of domains that are available in lieu of IP addresses
when adding nodes to a load balancer
@param {function} callback | [
"client",
".",
"getAllowedDomains"
] | 44e08a0063252829cdb5e9a8b430c2f4c08b91ad | https://github.com/pkgcloud/pkgcloud/blob/44e08a0063252829cdb5e9a8b430c2f4c08b91ad/lib/pkgcloud/rackspace/loadbalancer/client/loadbalancers.js#L1135-L1143 | train | |
pkgcloud/pkgcloud | lib/pkgcloud/azure/utils/sharedkey.js | SharedKey | function SharedKey(storageAccount, storageAccessKey) {
this.storageAccount = storageAccount;
this.storageAccessKey = storageAccessKey;
this.signer = new HmacSha256Sign(storageAccessKey);
} | javascript | function SharedKey(storageAccount, storageAccessKey) {
this.storageAccount = storageAccount;
this.storageAccessKey = storageAccessKey;
this.signer = new HmacSha256Sign(storageAccessKey);
} | [
"function",
"SharedKey",
"(",
"storageAccount",
",",
"storageAccessKey",
")",
"{",
"this",
".",
"storageAccount",
"=",
"storageAccount",
";",
"this",
".",
"storageAccessKey",
"=",
"storageAccessKey",
";",
"this",
".",
"signer",
"=",
"new",
"HmacSha256Sign",
"(",
... | Creates a new SharedKey object.
@constructor
@param {string} storageAccount The storage account.
@param {string} storageAccessKey The storage account's access key. | [
"Creates",
"a",
"new",
"SharedKey",
"object",
"."
] | 44e08a0063252829cdb5e9a8b430c2f4c08b91ad | https://github.com/pkgcloud/pkgcloud/blob/44e08a0063252829cdb5e9a8b430c2f4c08b91ad/lib/pkgcloud/azure/utils/sharedkey.js#L31-L35 | train |
pkgcloud/pkgcloud | lib/pkgcloud/rackspace/loadbalancer/client/nodes.js | function (loadBalancer, callback) {
var self = this,
loadBalancerId =
loadBalancer instanceof lb.LoadBalancer ? loadBalancer.id : loadBalancer;
self._request({
path: urlJoin(_urlPrefix, loadBalancerId, 'nodes')
}, function (err, body, res) {
if (err) {
return callback(... | javascript | function (loadBalancer, callback) {
var self = this,
loadBalancerId =
loadBalancer instanceof lb.LoadBalancer ? loadBalancer.id : loadBalancer;
self._request({
path: urlJoin(_urlPrefix, loadBalancerId, 'nodes')
}, function (err, body, res) {
if (err) {
return callback(... | [
"function",
"(",
"loadBalancer",
",",
"callback",
")",
"{",
"var",
"self",
"=",
"this",
",",
"loadBalancerId",
"=",
"loadBalancer",
"instanceof",
"lb",
".",
"LoadBalancer",
"?",
"loadBalancer",
".",
"id",
":",
"loadBalancer",
";",
"self",
".",
"_request",
"(... | client.getNodes
@description get an array of nodes for the provided load balancer
@param {Object} loadBalancer the loadBalancer or loadBalancerId
@param {function} callback | [
"client",
".",
"getNodes"
] | 44e08a0063252829cdb5e9a8b430c2f4c08b91ad | https://github.com/pkgcloud/pkgcloud/blob/44e08a0063252829cdb5e9a8b430c2f4c08b91ad/lib/pkgcloud/rackspace/loadbalancer/client/nodes.js#L27-L50 | train | |
pkgcloud/pkgcloud | lib/pkgcloud/rackspace/loadbalancer/client/nodes.js | function(loadBalancer, nodes, callback) {
var self = this,
loadBalancerId =
loadBalancer instanceof lb.LoadBalancer ? loadBalancer.id : loadBalancer;
if (!Array.isArray(nodes)) {
nodes = [ nodes ];
}
var postOptions = {
path: urlJoin(_urlPrefix, loadBalancerId, 'nodes'),
... | javascript | function(loadBalancer, nodes, callback) {
var self = this,
loadBalancerId =
loadBalancer instanceof lb.LoadBalancer ? loadBalancer.id : loadBalancer;
if (!Array.isArray(nodes)) {
nodes = [ nodes ];
}
var postOptions = {
path: urlJoin(_urlPrefix, loadBalancerId, 'nodes'),
... | [
"function",
"(",
"loadBalancer",
",",
"nodes",
",",
"callback",
")",
"{",
"var",
"self",
"=",
"this",
",",
"loadBalancerId",
"=",
"loadBalancer",
"instanceof",
"lb",
".",
"LoadBalancer",
"?",
"loadBalancer",
".",
"id",
":",
"loadBalancer",
";",
"if",
"(",
... | client.addNodes
@description add a node or array of nodes to the provided load balancer. Each of the addresses must be unique to this load balancer.
@param {Object} loadBalancer the loadBalancer or loadBalancerId
@param {Object|Array} nodes list of nodes to add
@param {function} ca... | [
"client",
".",
"addNodes"
] | 44e08a0063252829cdb5e9a8b430c2f4c08b91ad | https://github.com/pkgcloud/pkgcloud/blob/44e08a0063252829cdb5e9a8b430c2f4c08b91ad/lib/pkgcloud/rackspace/loadbalancer/client/nodes.js#L71-L106 | train | |
pkgcloud/pkgcloud | lib/pkgcloud/rackspace/loadbalancer/client/nodes.js | function(loadBalancer, node, callback) {
var self = this,
loadBalancerId =
loadBalancer instanceof lb.LoadBalancer ? loadBalancer.id : loadBalancer;
if (!(node instanceof lb.Node) && (typeof node !== 'object')) {
throw new Error('node is a required argument and must be an object');
... | javascript | function(loadBalancer, node, callback) {
var self = this,
loadBalancerId =
loadBalancer instanceof lb.LoadBalancer ? loadBalancer.id : loadBalancer;
if (!(node instanceof lb.Node) && (typeof node !== 'object')) {
throw new Error('node is a required argument and must be an object');
... | [
"function",
"(",
"loadBalancer",
",",
"node",
",",
"callback",
")",
"{",
"var",
"self",
"=",
"this",
",",
"loadBalancerId",
"=",
"loadBalancer",
"instanceof",
"lb",
".",
"LoadBalancer",
"?",
"loadBalancer",
".",
"id",
":",
"loadBalancer",
";",
"if",
"(",
"... | client.updateNode
@description update a node condition, type, or weight
@param {Object} loadBalancer the loadBalancer or loadBalancerId
@param {Object} node the node to update
@param {function} callback | [
"client",
".",
"updateNode"
] | 44e08a0063252829cdb5e9a8b430c2f4c08b91ad | https://github.com/pkgcloud/pkgcloud/blob/44e08a0063252829cdb5e9a8b430c2f4c08b91ad/lib/pkgcloud/rackspace/loadbalancer/client/nodes.js#L117-L135 | train | |
pkgcloud/pkgcloud | lib/pkgcloud/rackspace/loadbalancer/client/nodes.js | function (loadBalancer, node, callback) {
var self = this,
loadBalancerId =
loadBalancer instanceof lb.LoadBalancer ? loadBalancer.id : loadBalancer,
nodeId =
node instanceof lb.Node ? node.id : node;
self._request({
path: urlJoin(_urlPrefix, loadBalancerId, 'nodes', n... | javascript | function (loadBalancer, node, callback) {
var self = this,
loadBalancerId =
loadBalancer instanceof lb.LoadBalancer ? loadBalancer.id : loadBalancer,
nodeId =
node instanceof lb.Node ? node.id : node;
self._request({
path: urlJoin(_urlPrefix, loadBalancerId, 'nodes', n... | [
"function",
"(",
"loadBalancer",
",",
"node",
",",
"callback",
")",
"{",
"var",
"self",
"=",
"this",
",",
"loadBalancerId",
"=",
"loadBalancer",
"instanceof",
"lb",
".",
"LoadBalancer",
"?",
"loadBalancer",
".",
"id",
":",
"loadBalancer",
",",
"nodeId",
"=",... | client.removeNode
@description remove a node from a load balancer
@param {Object} loadBalancer the loadBalancer or loadBalancerId
@param {Object} node the node or nodeId to remove
@param {function} callback | [
"client",
".",
"removeNode"
] | 44e08a0063252829cdb5e9a8b430c2f4c08b91ad | https://github.com/pkgcloud/pkgcloud/blob/44e08a0063252829cdb5e9a8b430c2f4c08b91ad/lib/pkgcloud/rackspace/loadbalancer/client/nodes.js#L146-L159 | train | |
pkgcloud/pkgcloud | lib/pkgcloud/rackspace/loadbalancer/client/nodes.js | function (loadBalancer, nodes, callback) {
var self = this,
loadBalancerId =
loadBalancer instanceof lb.LoadBalancer ? loadBalancer.id : loadBalancer;
// check for valid inputs
if (!nodes || nodes.length === 0 || !Array.isArray(nodes)) {
throw new Error('nodes must be an array of No... | javascript | function (loadBalancer, nodes, callback) {
var self = this,
loadBalancerId =
loadBalancer instanceof lb.LoadBalancer ? loadBalancer.id : loadBalancer;
// check for valid inputs
if (!nodes || nodes.length === 0 || !Array.isArray(nodes)) {
throw new Error('nodes must be an array of No... | [
"function",
"(",
"loadBalancer",
",",
"nodes",
",",
"callback",
")",
"{",
"var",
"self",
"=",
"this",
",",
"loadBalancerId",
"=",
"loadBalancer",
"instanceof",
"lb",
".",
"LoadBalancer",
"?",
"loadBalancer",
".",
"id",
":",
"loadBalancer",
";",
"// check for v... | client.removeNodes
@description remove an array of nodes or nodeIds from a load balancer
@param {Object} loadBalancer the loadBalancer or loadBalancerId
@param {Array} nodes the nodes or nodeIds to remove
@param {function} callback | [
"client",
".",
"removeNodes"
] | 44e08a0063252829cdb5e9a8b430c2f4c08b91ad | https://github.com/pkgcloud/pkgcloud/blob/44e08a0063252829cdb5e9a8b430c2f4c08b91ad/lib/pkgcloud/rackspace/loadbalancer/client/nodes.js#L170-L191 | train | |
pkgcloud/pkgcloud | lib/pkgcloud/rackspace/loadbalancer/client/nodes.js | function (loadBalancer, callback) {
var self = this,
loadBalancerId =
loadBalancer instanceof lb.LoadBalancer ? loadBalancer.id : loadBalancer;
self._request({
path: urlJoin(_urlPrefix, loadBalancerId, 'nodes', 'events')
}, function (err, body) {
return err
? callback(... | javascript | function (loadBalancer, callback) {
var self = this,
loadBalancerId =
loadBalancer instanceof lb.LoadBalancer ? loadBalancer.id : loadBalancer;
self._request({
path: urlJoin(_urlPrefix, loadBalancerId, 'nodes', 'events')
}, function (err, body) {
return err
? callback(... | [
"function",
"(",
"loadBalancer",
",",
"callback",
")",
"{",
"var",
"self",
"=",
"this",
",",
"loadBalancerId",
"=",
"loadBalancer",
"instanceof",
"lb",
".",
"LoadBalancer",
"?",
"loadBalancer",
".",
"id",
":",
"loadBalancer",
";",
"self",
".",
"_request",
"(... | client.getNodeServiceEvents
@description retrieve a list of events associated with the activity
between the node and the load balancer
@param {Object} loadBalancer the loadBalancer or loadBalancerId
@param {function} callback | [
"client",
".",
"getNodeServiceEvents"
] | 44e08a0063252829cdb5e9a8b430c2f4c08b91ad | https://github.com/pkgcloud/pkgcloud/blob/44e08a0063252829cdb5e9a8b430c2f4c08b91ad/lib/pkgcloud/rackspace/loadbalancer/client/nodes.js#L202-L214 | train | |
emailjs/emailjs-imap-client | dist/command-parser.js | encodeAddressName | function encodeAddressName(name) {
if (!/^[\w ']*$/.test(name)) {
if (/^[\x20-\x7e]*$/.test(name)) {
return JSON.stringify(name);
} else {
return (0, _emailjsMimeCodec.mimeWordEncode)(name, 'Q', 52);
}
}
return name;
} | javascript | function encodeAddressName(name) {
if (!/^[\w ']*$/.test(name)) {
if (/^[\x20-\x7e]*$/.test(name)) {
return JSON.stringify(name);
} else {
return (0, _emailjsMimeCodec.mimeWordEncode)(name, 'Q', 52);
}
}
return name;
} | [
"function",
"encodeAddressName",
"(",
"name",
")",
"{",
"if",
"(",
"!",
"/",
"^[\\w ']*$",
"/",
".",
"test",
"(",
"name",
")",
")",
"{",
"if",
"(",
"/",
"^[\\x20-\\x7e]*$",
"/",
".",
"test",
"(",
"name",
")",
")",
"{",
"return",
"JSON",
".",
"strin... | If needed, encloses with quotes or mime encodes the name part of an e-mail address
@param {String} name Name part of an address
@returns {String} Mime word encoded or quoted string | [
"If",
"needed",
"encloses",
"with",
"quotes",
"or",
"mime",
"encodes",
"the",
"name",
"part",
"of",
"an",
"e",
"-",
"mail",
"address"
] | 32e768c83afe7a75433e1617b16e48eff318a957 | https://github.com/emailjs/emailjs-imap-client/blob/32e768c83afe7a75433e1617b16e48eff318a957/dist/command-parser.js#L201-L210 | train |
emailjs/emailjs-imap-client | src/command-parser.js | parseFetchValue | function parseFetchValue (key, value) {
if (!value) {
return null
}
if (!Array.isArray(value)) {
switch (key) {
case 'uid':
case 'rfc822.size':
return Number(value.value) || 0
case 'modseq': // do not cast 64 bit uint to a number
return value.value || '0'
}
retur... | javascript | function parseFetchValue (key, value) {
if (!value) {
return null
}
if (!Array.isArray(value)) {
switch (key) {
case 'uid':
case 'rfc822.size':
return Number(value.value) || 0
case 'modseq': // do not cast 64 bit uint to a number
return value.value || '0'
}
retur... | [
"function",
"parseFetchValue",
"(",
"key",
",",
"value",
")",
"{",
"if",
"(",
"!",
"value",
")",
"{",
"return",
"null",
"}",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"value",
")",
")",
"{",
"switch",
"(",
"key",
")",
"{",
"case",
"'uid'",
":... | Parses a single value from the FETCH response object
@param {String} key Key name (uppercase)
@param {Mized} value Value for the key
@return {Mixed} Processed value | [
"Parses",
"a",
"single",
"value",
"from",
"the",
"FETCH",
"response",
"object"
] | 32e768c83afe7a75433e1617b16e48eff318a957 | https://github.com/emailjs/emailjs-imap-client/blob/32e768c83afe7a75433e1617b16e48eff318a957/src/command-parser.js#L400-L433 | train |
emailjs/emailjs-imap-client | dist/command-builder.js | buildFETCHCommand | function buildFETCHCommand(sequence, items, options) {
let command = {
command: options.byUid ? 'UID FETCH' : 'FETCH',
attributes: [{
type: 'SEQUENCE',
value: sequence
}]
};
if (options.valueAsString !== undefined) {
command.valueAsString = options.valueAsString;
}
let query = []... | javascript | function buildFETCHCommand(sequence, items, options) {
let command = {
command: options.byUid ? 'UID FETCH' : 'FETCH',
attributes: [{
type: 'SEQUENCE',
value: sequence
}]
};
if (options.valueAsString !== undefined) {
command.valueAsString = options.valueAsString;
}
let query = []... | [
"function",
"buildFETCHCommand",
"(",
"sequence",
",",
"items",
",",
"options",
")",
"{",
"let",
"command",
"=",
"{",
"command",
":",
"options",
".",
"byUid",
"?",
"'UID FETCH'",
":",
"'FETCH'",
",",
"attributes",
":",
"[",
"{",
"type",
":",
"'SEQUENCE'",
... | Builds a FETCH command
@param {String} sequence Message range selector
@param {Array} items List of elements to fetch (eg. `['uid', 'envelope']`).
@param {Object} [options] Optional options object. Use `{byUid:true}` for `UID FETCH`
@returns {Object} Structured IMAP command | [
"Builds",
"a",
"FETCH",
"command"
] | 32e768c83afe7a75433e1617b16e48eff318a957 | https://github.com/emailjs/emailjs-imap-client/blob/32e768c83afe7a75433e1617b16e48eff318a957/dist/command-builder.js#L27-L83 | train |
emailjs/emailjs-imap-client | dist/command-builder.js | buildXOAuth2Token | function buildXOAuth2Token(user = '', token) {
let authData = [`user=${user}`, `auth=Bearer ${token}`, '', ''];
return (0, _emailjsBase.encode)(authData.join('\x01'));
} | javascript | function buildXOAuth2Token(user = '', token) {
let authData = [`user=${user}`, `auth=Bearer ${token}`, '', ''];
return (0, _emailjsBase.encode)(authData.join('\x01'));
} | [
"function",
"buildXOAuth2Token",
"(",
"user",
"=",
"''",
",",
"token",
")",
"{",
"let",
"authData",
"=",
"[",
"`",
"${",
"user",
"}",
"`",
",",
"`",
"${",
"token",
"}",
"`",
",",
"''",
",",
"''",
"]",
";",
"return",
"(",
"0",
",",
"_emailjsBase",... | Builds a login token for XOAUTH2 authentication command
@param {String} user E-mail address of the user
@param {String} token Valid access token for the user
@return {String} Base64 formatted login token | [
"Builds",
"a",
"login",
"token",
"for",
"XOAUTH2",
"authentication",
"command"
] | 32e768c83afe7a75433e1617b16e48eff318a957 | https://github.com/emailjs/emailjs-imap-client/blob/32e768c83afe7a75433e1617b16e48eff318a957/dist/command-builder.js#L92-L95 | train |
emailjs/emailjs-imap-client | dist/command-builder.js | buildSTORECommand | function buildSTORECommand(sequence, action = '', flags = [], options = {}) {
let command = {
command: options.byUid ? 'UID STORE' : 'STORE',
attributes: [{
type: 'sequence',
value: sequence
}]
};
command.attributes.push({
type: 'atom',
value: action.toUpperCase() + (options.silen... | javascript | function buildSTORECommand(sequence, action = '', flags = [], options = {}) {
let command = {
command: options.byUid ? 'UID STORE' : 'STORE',
attributes: [{
type: 'sequence',
value: sequence
}]
};
command.attributes.push({
type: 'atom',
value: action.toUpperCase() + (options.silen... | [
"function",
"buildSTORECommand",
"(",
"sequence",
",",
"action",
"=",
"''",
",",
"flags",
"=",
"[",
"]",
",",
"options",
"=",
"{",
"}",
")",
"{",
"let",
"command",
"=",
"{",
"command",
":",
"options",
".",
"byUid",
"?",
"'UID STORE'",
":",
"'STORE'",
... | Creates an IMAP STORE command from the selected arguments | [
"Creates",
"an",
"IMAP",
"STORE",
"command",
"from",
"the",
"selected",
"arguments"
] | 32e768c83afe7a75433e1617b16e48eff318a957 | https://github.com/emailjs/emailjs-imap-client/blob/32e768c83afe7a75433e1617b16e48eff318a957/dist/command-builder.js#L217-L239 | train |
davidkpiano/react-redux-form | src/utils/shallow-equal.js | shallowEqual | function shallowEqual(objA, objB, options = {}) {
if (is(objA, objB)) {
return true;
}
if ((typeof objA === 'undefined' ? 'undefined' : _typeof(objA)) !== 'object' || objA === null || (typeof objB === 'undefined' ? 'undefined' : _typeof(objB)) !== 'object' || objB === null) {
return false;
}
if(objA... | javascript | function shallowEqual(objA, objB, options = {}) {
if (is(objA, objB)) {
return true;
}
if ((typeof objA === 'undefined' ? 'undefined' : _typeof(objA)) !== 'object' || objA === null || (typeof objB === 'undefined' ? 'undefined' : _typeof(objB)) !== 'object' || objB === null) {
return false;
}
if(objA... | [
"function",
"shallowEqual",
"(",
"objA",
",",
"objB",
",",
"options",
"=",
"{",
"}",
")",
"{",
"if",
"(",
"is",
"(",
"objA",
",",
"objB",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"(",
"typeof",
"objA",
"===",
"'undefined'",
"?",
"'un... | Performs equality by iterating through keys on an object and returning false
when any key has values which are not strictly equal between the arguments.
Returns true when the values of all keys are strictly equal. | [
"Performs",
"equality",
"by",
"iterating",
"through",
"keys",
"on",
"an",
"object",
"and",
"returning",
"false",
"when",
"any",
"key",
"has",
"values",
"which",
"are",
"not",
"strictly",
"equal",
"between",
"the",
"arguments",
".",
"Returns",
"true",
"when",
... | 57028979c87e6f377104bf4069ff951e1a9faa19 | https://github.com/davidkpiano/react-redux-form/blob/57028979c87e6f377104bf4069ff951e1a9faa19/src/utils/shallow-equal.js#L32-L73 | train |
node-influx/node-influx | examples/esdoc-plugin.js | rewriteFonts | function rewriteFonts () {
const style = path.join(target, 'css', 'style.css')
const css = fs.readFileSync(style)
.toString()
.replace(/@import url\(.*?Roboto.*?\);/, `@import url('https://fonts.googleapis.com/css?family=Open+Sans:400,600|Source+Code+Pro:400,600');`)
.replace(/Roboto/g, 'Open Sans')
... | javascript | function rewriteFonts () {
const style = path.join(target, 'css', 'style.css')
const css = fs.readFileSync(style)
.toString()
.replace(/@import url\(.*?Roboto.*?\);/, `@import url('https://fonts.googleapis.com/css?family=Open+Sans:400,600|Source+Code+Pro:400,600');`)
.replace(/Roboto/g, 'Open Sans')
... | [
"function",
"rewriteFonts",
"(",
")",
"{",
"const",
"style",
"=",
"path",
".",
"join",
"(",
"target",
",",
"'css'",
",",
"'style.css'",
")",
"const",
"css",
"=",
"fs",
".",
"readFileSync",
"(",
"style",
")",
".",
"toString",
"(",
")",
".",
"replace",
... | Rewrites the fonts in the output CSS to replace them with our own.
Do this instead of overriding for load times and reduction in hackery. | [
"Rewrites",
"the",
"fonts",
"in",
"the",
"output",
"CSS",
"to",
"replace",
"them",
"with",
"our",
"own",
".",
"Do",
"this",
"instead",
"of",
"overriding",
"for",
"load",
"times",
"and",
"reduction",
"in",
"hackery",
"."
] | 54c6ddf19da033334c526da9416bbc7a0cd71859 | https://github.com/node-influx/node-influx/blob/54c6ddf19da033334c526da9416bbc7a0cd71859/examples/esdoc-plugin.js#L10-L48 | train |
apocas/dockerode | examples/exec_running_container.js | runExec | function runExec(container) {
var options = {
Cmd: ['bash', '-c', 'echo test $VAR'],
Env: ['VAR=ttslkfjsdalkfj'],
AttachStdout: true,
AttachStderr: true
};
container.exec(options, function(err, exec) {
if (err) return;
exec.start(function(err, stream) {
if (err) return;
cont... | javascript | function runExec(container) {
var options = {
Cmd: ['bash', '-c', 'echo test $VAR'],
Env: ['VAR=ttslkfjsdalkfj'],
AttachStdout: true,
AttachStderr: true
};
container.exec(options, function(err, exec) {
if (err) return;
exec.start(function(err, stream) {
if (err) return;
cont... | [
"function",
"runExec",
"(",
"container",
")",
"{",
"var",
"options",
"=",
"{",
"Cmd",
":",
"[",
"'bash'",
",",
"'-c'",
",",
"'echo test $VAR'",
"]",
",",
"Env",
":",
"[",
"'VAR=ttslkfjsdalkfj'",
"]",
",",
"AttachStdout",
":",
"true",
",",
"AttachStderr",
... | Get env list from running container
@param container | [
"Get",
"env",
"list",
"from",
"running",
"container"
] | 5ac15d82be325173c6f42c3e7b1d13a61a6d4bf1 | https://github.com/apocas/dockerode/blob/5ac15d82be325173c6f42c3e7b1d13a61a6d4bf1/examples/exec_running_container.js#L11-L33 | train |
apocas/dockerode | lib/plugin.js | function(modem, name, remote) {
this.modem = modem;
this.name = name;
this.remote = remote || name;
} | javascript | function(modem, name, remote) {
this.modem = modem;
this.name = name;
this.remote = remote || name;
} | [
"function",
"(",
"modem",
",",
"name",
",",
"remote",
")",
"{",
"this",
".",
"modem",
"=",
"modem",
";",
"this",
".",
"name",
"=",
"name",
";",
"this",
".",
"remote",
"=",
"remote",
"||",
"name",
";",
"}"
] | Represents a plugin
@param {Object} modem docker-modem
@param {String} name Plugin's name | [
"Represents",
"a",
"plugin"
] | 5ac15d82be325173c6f42c3e7b1d13a61a6d4bf1 | https://github.com/apocas/dockerode/blob/5ac15d82be325173c6f42c3e7b1d13a61a6d4bf1/lib/plugin.js#L8-L12 | train | |
apocas/dockerode | examples/logs.js | containerLogs | function containerLogs(container) {
// create a single stream for stdin and stdout
var logStream = new stream.PassThrough();
logStream.on('data', function(chunk){
console.log(chunk.toString('utf8'));
});
container.logs({
follow: true,
stdout: true,
stderr: true
}, function(err, stream){
... | javascript | function containerLogs(container) {
// create a single stream for stdin and stdout
var logStream = new stream.PassThrough();
logStream.on('data', function(chunk){
console.log(chunk.toString('utf8'));
});
container.logs({
follow: true,
stdout: true,
stderr: true
}, function(err, stream){
... | [
"function",
"containerLogs",
"(",
"container",
")",
"{",
"// create a single stream for stdin and stdout",
"var",
"logStream",
"=",
"new",
"stream",
".",
"PassThrough",
"(",
")",
";",
"logStream",
".",
"on",
"(",
"'data'",
",",
"function",
"(",
"chunk",
")",
"{"... | Get logs from running container | [
"Get",
"logs",
"from",
"running",
"container"
] | 5ac15d82be325173c6f42c3e7b1d13a61a6d4bf1 | https://github.com/apocas/dockerode/blob/5ac15d82be325173c6f42c3e7b1d13a61a6d4bf1/examples/logs.js#L11-L36 | train |
felixrieseberg/npm-windows-upgrade | src/find-npm.js | _getPathFromPowerShell | function _getPathFromPowerShell () {
return new Promise(resolve => {
const psArgs = 'Get-Command npm | Select-Object -ExpandProperty Definition'
const args = [ '-NoProfile', '-NoLogo', psArgs ]
const child = spawn('powershell.exe', args)
let stdout = []
let stderr = []
child.stdout.on('data'... | javascript | function _getPathFromPowerShell () {
return new Promise(resolve => {
const psArgs = 'Get-Command npm | Select-Object -ExpandProperty Definition'
const args = [ '-NoProfile', '-NoLogo', psArgs ]
const child = spawn('powershell.exe', args)
let stdout = []
let stderr = []
child.stdout.on('data'... | [
"function",
"_getPathFromPowerShell",
"(",
")",
"{",
"return",
"new",
"Promise",
"(",
"resolve",
"=>",
"{",
"const",
"psArgs",
"=",
"'Get-Command npm | Select-Object -ExpandProperty Definition'",
"const",
"args",
"=",
"[",
"'-NoProfile'",
",",
"'-NoLogo'",
",",
"psArg... | Attempts to get npm's path by calling out to "Get-Command npm"
@returns {Promise.<string>} - Promise that resolves with the found path (or null if not found) | [
"Attempts",
"to",
"get",
"npm",
"s",
"path",
"by",
"calling",
"out",
"to",
"Get",
"-",
"Command",
"npm"
] | 763c2ff750f65dfbef5dbc48b131a6af897f1a35 | https://github.com/felixrieseberg/npm-windows-upgrade/blob/763c2ff750f65dfbef5dbc48b131a6af897f1a35/src/find-npm.js#L33-L68 | train |
felixrieseberg/npm-windows-upgrade | src/find-npm.js | _getPath | function _getPath () {
return Promise.all([_getPathFromPowerShell(), _getPathFromNpm()])
.then((results) => {
const fromNpm = results[1] || ''
const fromPowershell = results[0] || ''
// Quickly check if there's an npm folder in there
const fromPowershellPath = path.join(fromPowershell, 'n... | javascript | function _getPath () {
return Promise.all([_getPathFromPowerShell(), _getPathFromNpm()])
.then((results) => {
const fromNpm = results[1] || ''
const fromPowershell = results[0] || ''
// Quickly check if there's an npm folder in there
const fromPowershellPath = path.join(fromPowershell, 'n... | [
"function",
"_getPath",
"(",
")",
"{",
"return",
"Promise",
".",
"all",
"(",
"[",
"_getPathFromPowerShell",
"(",
")",
",",
"_getPathFromNpm",
"(",
")",
"]",
")",
".",
"then",
"(",
"(",
"results",
")",
"=>",
"{",
"const",
"fromNpm",
"=",
"results",
"[",... | Attempts to get the current installation location of npm by looking up the global prefix.
Prefer PowerShell, be falls back to npm's opinion
@return {Promise.<string>} - NodeJS installation path | [
"Attempts",
"to",
"get",
"the",
"current",
"installation",
"location",
"of",
"npm",
"by",
"looking",
"up",
"the",
"global",
"prefix",
".",
"Prefer",
"PowerShell",
"be",
"falls",
"back",
"to",
"npm",
"s",
"opinion"
] | 763c2ff750f65dfbef5dbc48b131a6af897f1a35 | https://github.com/felixrieseberg/npm-windows-upgrade/blob/763c2ff750f65dfbef5dbc48b131a6af897f1a35/src/find-npm.js#L76-L109 | train |
felixrieseberg/npm-windows-upgrade | src/powershell.js | runUpgrade | function runUpgrade (version, npmPath) {
return new Promise((resolve, reject) => {
const scriptPath = path.resolve(__dirname, '../powershell/upgrade-npm.ps1')
const psArgs = npmPath === null
? `& {& '${scriptPath}' -version '${version}' }`
: `& {& '${scriptPath}' -version '${version}' -NodePath '$... | javascript | function runUpgrade (version, npmPath) {
return new Promise((resolve, reject) => {
const scriptPath = path.resolve(__dirname, '../powershell/upgrade-npm.ps1')
const psArgs = npmPath === null
? `& {& '${scriptPath}' -version '${version}' }`
: `& {& '${scriptPath}' -version '${version}' -NodePath '$... | [
"function",
"runUpgrade",
"(",
"version",
",",
"npmPath",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"const",
"scriptPath",
"=",
"path",
".",
"resolve",
"(",
"__dirname",
",",
"'../powershell/upgrade-npm.ps1'",
... | Executes the PS1 script upgrading npm
@param {string} version - The version to be installed (npm install npm@{version})
@param {string} npmPath - Path to Node installation (optional)
@return {Promise.<stderr[], stdout[]>} - stderr and stdout received from the PS1 process | [
"Executes",
"the",
"PS1",
"script",
"upgrading",
"npm"
] | 763c2ff750f65dfbef5dbc48b131a6af897f1a35 | https://github.com/felixrieseberg/npm-windows-upgrade/blob/763c2ff750f65dfbef5dbc48b131a6af897f1a35/src/powershell.js#L12-L47 | train |
felixrieseberg/npm-windows-upgrade | src/powershell.js | runSimpleUpgrade | function runSimpleUpgrade (version) {
return new Promise((resolve) => {
let npmCommand = (version) ? `npm install -g npm@${version}` : 'npm install -g npm'
let stdout = []
let stderr = []
let child
try {
child = spawn('powershell.exe', [ '-NoProfile', '-NoLogo', npmCommand ])
} catch (e... | javascript | function runSimpleUpgrade (version) {
return new Promise((resolve) => {
let npmCommand = (version) ? `npm install -g npm@${version}` : 'npm install -g npm'
let stdout = []
let stderr = []
let child
try {
child = spawn('powershell.exe', [ '-NoProfile', '-NoLogo', npmCommand ])
} catch (e... | [
"function",
"runSimpleUpgrade",
"(",
"version",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
")",
"=>",
"{",
"let",
"npmCommand",
"=",
"(",
"version",
")",
"?",
"`",
"${",
"version",
"}",
"`",
":",
"'npm install -g npm'",
"let",
"stdout",
"... | Executes 'npm install -g npm' upgrading npm
@param {string} version - The version to be installed (npm install npm@{version})
@return {Promise.<stderr[], stdout[]>} - stderr and stdout received from the PS1 process | [
"Executes",
"npm",
"install",
"-",
"g",
"npm",
"upgrading",
"npm"
] | 763c2ff750f65dfbef5dbc48b131a6af897f1a35 | https://github.com/felixrieseberg/npm-windows-upgrade/blob/763c2ff750f65dfbef5dbc48b131a6af897f1a35/src/powershell.js#L54-L75 | train |
felixrieseberg/npm-windows-upgrade | src/utils.js | exit | function exit (status, ...messages) {
if (messages) {
messages.forEach(message => console.log(message))
}
process.exit(status)
} | javascript | function exit (status, ...messages) {
if (messages) {
messages.forEach(message => console.log(message))
}
process.exit(status)
} | [
"function",
"exit",
"(",
"status",
",",
"...",
"messages",
")",
"{",
"if",
"(",
"messages",
")",
"{",
"messages",
".",
"forEach",
"(",
"message",
"=>",
"console",
".",
"log",
"(",
"message",
")",
")",
"}",
"process",
".",
"exit",
"(",
"status",
")",
... | Exits the process with a given status,
logging a given message before exiting.
@param {number} status - exit status
@param {string} messages - message to log | [
"Exits",
"the",
"process",
"with",
"a",
"given",
"status",
"logging",
"a",
"given",
"message",
"before",
"exiting",
"."
] | 763c2ff750f65dfbef5dbc48b131a6af897f1a35 | https://github.com/felixrieseberg/npm-windows-upgrade/blob/763c2ff750f65dfbef5dbc48b131a6af897f1a35/src/utils.js#L14-L20 | train |
felixrieseberg/npm-windows-upgrade | src/utils.js | checkExecutionPolicy | function checkExecutionPolicy () {
return new Promise((resolve, reject) => {
let output = []
let child
try {
debug('Powershell: Attempting to spawn PowerShell child')
child = spawn('powershell.exe', ['-NoProfile', '-NoLogo', 'Get-ExecutionPolicy'])
} catch (error) {
debug('Powershel... | javascript | function checkExecutionPolicy () {
return new Promise((resolve, reject) => {
let output = []
let child
try {
debug('Powershell: Attempting to spawn PowerShell child')
child = spawn('powershell.exe', ['-NoProfile', '-NoLogo', 'Get-ExecutionPolicy'])
} catch (error) {
debug('Powershel... | [
"function",
"checkExecutionPolicy",
"(",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"let",
"output",
"=",
"[",
"]",
"let",
"child",
"try",
"{",
"debug",
"(",
"'Powershell: Attempting to spawn PowerShell child'",
"... | Checks the current Windows PS1 execution policy. The upgrader requires an unrestricted policy.
@return {Promise.<boolean>} - True if unrestricted, false if it isn't | [
"Checks",
"the",
"current",
"Windows",
"PS1",
"execution",
"policy",
".",
"The",
"upgrader",
"requires",
"an",
"unrestricted",
"policy",
"."
] | 763c2ff750f65dfbef5dbc48b131a6af897f1a35 | https://github.com/felixrieseberg/npm-windows-upgrade/blob/763c2ff750f65dfbef5dbc48b131a6af897f1a35/src/utils.js#L44-L82 | train |
felixrieseberg/npm-windows-upgrade | src/utils.js | isPathAccessible | function isPathAccessible (filePath) {
try {
fs.accessSync(filePath)
debug(`Utils: isPathAccessible(): ${filePath} exists`)
return true
} catch (err) {
debug(`Utils: isPathAccessible(): ${filePath} does not exist`)
return false
}
} | javascript | function isPathAccessible (filePath) {
try {
fs.accessSync(filePath)
debug(`Utils: isPathAccessible(): ${filePath} exists`)
return true
} catch (err) {
debug(`Utils: isPathAccessible(): ${filePath} does not exist`)
return false
}
} | [
"function",
"isPathAccessible",
"(",
"filePath",
")",
"{",
"try",
"{",
"fs",
".",
"accessSync",
"(",
"filePath",
")",
"debug",
"(",
"`",
"${",
"filePath",
"}",
"`",
")",
"return",
"true",
"}",
"catch",
"(",
"err",
")",
"{",
"debug",
"(",
"`",
"${",
... | Checks if a path exists
@param filePath - file path to check
@returns {boolean} - does the file path exist? | [
"Checks",
"if",
"a",
"path",
"exists"
] | 763c2ff750f65dfbef5dbc48b131a6af897f1a35 | https://github.com/felixrieseberg/npm-windows-upgrade/blob/763c2ff750f65dfbef5dbc48b131a6af897f1a35/src/utils.js#L90-L99 | train |
felixrieseberg/npm-windows-upgrade | src/versions.js | getAvailableNPMVersions | function getAvailableNPMVersions () {
return new Promise((resolve, reject) => {
exec('npm view npm versions --json', (err, stdout) => {
if (err) {
let error = 'We could not show latest available versions. Try running this script again '
error += 'with the version you want to install (npm-win... | javascript | function getAvailableNPMVersions () {
return new Promise((resolve, reject) => {
exec('npm view npm versions --json', (err, stdout) => {
if (err) {
let error = 'We could not show latest available versions. Try running this script again '
error += 'with the version you want to install (npm-win... | [
"function",
"getAvailableNPMVersions",
"(",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"exec",
"(",
"'npm view npm versions --json'",
",",
"(",
"err",
",",
"stdout",
")",
"=>",
"{",
"if",
"(",
"err",
")",
"{... | Fetches the published versions of npm from the npm registry
@return {Promise.<versions[]>} - Array of the available versions | [
"Fetches",
"the",
"published",
"versions",
"of",
"npm",
"from",
"the",
"npm",
"registry"
] | 763c2ff750f65dfbef5dbc48b131a6af897f1a35 | https://github.com/felixrieseberg/npm-windows-upgrade/blob/763c2ff750f65dfbef5dbc48b131a6af897f1a35/src/versions.js#L27-L39 | train |
felixrieseberg/npm-windows-upgrade | src/versions.js | _getWindowsVersion | function _getWindowsVersion () {
return new Promise((resolve, reject) => {
const command = 'systeminfo | findstr /B /C:"OS Name" /C:"OS Version"'
exec(command, (error, stdout) => {
if (error) {
reject(error)
} else {
resolve(stdout)
}
})
})
} | javascript | function _getWindowsVersion () {
return new Promise((resolve, reject) => {
const command = 'systeminfo | findstr /B /C:"OS Name" /C:"OS Version"'
exec(command, (error, stdout) => {
if (error) {
reject(error)
} else {
resolve(stdout)
}
})
})
} | [
"function",
"_getWindowsVersion",
"(",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"const",
"command",
"=",
"'systeminfo | findstr /B /C:\"OS Name\" /C:\"OS Version\"'",
"exec",
"(",
"command",
",",
"(",
"error",
",",
... | Get the current name and version of Windows | [
"Get",
"the",
"current",
"name",
"and",
"version",
"of",
"Windows"
] | 763c2ff750f65dfbef5dbc48b131a6af897f1a35 | https://github.com/felixrieseberg/npm-windows-upgrade/blob/763c2ff750f65dfbef5dbc48b131a6af897f1a35/src/versions.js#L64-L75 | train |
felixrieseberg/npm-windows-upgrade | src/versions.js | getVersions | async function getVersions () {
let versions = process.versions
let prettyVersions = []
versions.os = process.platform + ' ' + process.arch
for (let variable in versions) {
if (versions.hasOwnProperty(variable)) {
prettyVersions.push(`${variable}: ${versions[variable]}`)
}
}
try {
const ... | javascript | async function getVersions () {
let versions = process.versions
let prettyVersions = []
versions.os = process.platform + ' ' + process.arch
for (let variable in versions) {
if (versions.hasOwnProperty(variable)) {
prettyVersions.push(`${variable}: ${versions[variable]}`)
}
}
try {
const ... | [
"async",
"function",
"getVersions",
"(",
")",
"{",
"let",
"versions",
"=",
"process",
".",
"versions",
"let",
"prettyVersions",
"=",
"[",
"]",
"versions",
".",
"os",
"=",
"process",
".",
"platform",
"+",
"' '",
"+",
"process",
".",
"arch",
"for",
"(",
... | Get installed versions of virtually everything important | [
"Get",
"installed",
"versions",
"of",
"virtually",
"everything",
"important"
] | 763c2ff750f65dfbef5dbc48b131a6af897f1a35 | https://github.com/felixrieseberg/npm-windows-upgrade/blob/763c2ff750f65dfbef5dbc48b131a6af897f1a35/src/versions.js#L80-L101 | train |
wix/angular-tree-control | demo/ui-bootstrap-tpls.0.11.2.js | function (hostEl, targetEl, positionStr, appendToBody) {
var positionStrParts = positionStr.split('-');
var pos0 = positionStrParts[0], pos1 = positionStrParts[1] || 'center';
var hostElPos,
targetElWidth,
targetElHeight,
targetElPos;
hostElPos = appendTo... | javascript | function (hostEl, targetEl, positionStr, appendToBody) {
var positionStrParts = positionStr.split('-');
var pos0 = positionStrParts[0], pos1 = positionStrParts[1] || 'center';
var hostElPos,
targetElWidth,
targetElHeight,
targetElPos;
hostElPos = appendTo... | [
"function",
"(",
"hostEl",
",",
"targetEl",
",",
"positionStr",
",",
"appendToBody",
")",
"{",
"var",
"positionStrParts",
"=",
"positionStr",
".",
"split",
"(",
"'-'",
")",
";",
"var",
"pos0",
"=",
"positionStrParts",
"[",
"0",
"]",
",",
"pos1",
"=",
"po... | Provides coordinates for the targetEl in relation to hostEl | [
"Provides",
"coordinates",
"for",
"the",
"targetEl",
"in",
"relation",
"to",
"hostEl"
] | 5bcedace8bcf135ec47d06a6549c802185318196 | https://github.com/wix/angular-tree-control/blob/5bcedace8bcf135ec47d06a6549c802185318196/demo/ui-bootstrap-tpls.0.11.2.js#L908-L975 | train | |
wix/angular-tree-control | demo/ui-bootstrap-tpls.0.11.2.js | snake_case | function snake_case(name){
var regexp = /[A-Z]/g;
var separator = '-';
return name.replace(regexp, function(letter, pos) {
return (pos ? separator : '') + letter.toLowerCase();
});
} | javascript | function snake_case(name){
var regexp = /[A-Z]/g;
var separator = '-';
return name.replace(regexp, function(letter, pos) {
return (pos ? separator : '') + letter.toLowerCase();
});
} | [
"function",
"snake_case",
"(",
"name",
")",
"{",
"var",
"regexp",
"=",
"/",
"[A-Z]",
"/",
"g",
";",
"var",
"separator",
"=",
"'-'",
";",
"return",
"name",
".",
"replace",
"(",
"regexp",
",",
"function",
"(",
"letter",
",",
"pos",
")",
"{",
"return",
... | This is a helper function for translating camel-case to snake-case. | [
"This",
"is",
"a",
"helper",
"function",
"for",
"translating",
"camel",
"-",
"case",
"to",
"snake",
"-",
"case",
"."
] | 5bcedace8bcf135ec47d06a6549c802185318196 | https://github.com/wix/angular-tree-control/blob/5bcedace8bcf135ec47d06a6549c802185318196/demo/ui-bootstrap-tpls.0.11.2.js#L2464-L2470 | train |
csstree/csstree | lib/tokenizer/Tokenizer.js | computeLinesAndColumns | function computeLinesAndColumns(tokenizer, source) {
var sourceLength = source.length;
var start = firstCharOffset(source);
var lines = tokenizer.lines;
var line = tokenizer.startLine;
var columns = tokenizer.columns;
var column = tokenizer.startColumn;
if (lines === null || lines.length < ... | javascript | function computeLinesAndColumns(tokenizer, source) {
var sourceLength = source.length;
var start = firstCharOffset(source);
var lines = tokenizer.lines;
var line = tokenizer.startLine;
var columns = tokenizer.columns;
var column = tokenizer.startColumn;
if (lines === null || lines.length < ... | [
"function",
"computeLinesAndColumns",
"(",
"tokenizer",
",",
"source",
")",
"{",
"var",
"sourceLength",
"=",
"source",
".",
"length",
";",
"var",
"start",
"=",
"firstCharOffset",
"(",
"source",
")",
";",
"var",
"lines",
"=",
"tokenizer",
".",
"lines",
";",
... | fallback on Array when TypedArray is not supported | [
"fallback",
"on",
"Array",
"when",
"TypedArray",
"is",
"not",
"supported"
] | 5835eabde1d789e8a5a030a0946f2b4a1698c350 | https://github.com/csstree/csstree/blob/5835eabde1d789e8a5a030a0946f2b4a1698c350/lib/tokenizer/Tokenizer.js#L60-L97 | train |
apache/cordova-plugin-splashscreen | src/browser/SplashScreenProxy.js | readPreferencesFromCfg | function readPreferencesFromCfg(cfg) {
try {
var value = cfg.getPreferenceValue('ShowSplashScreen');
if(typeof value != 'undefined') {
showSplashScreen = value === 'true';
}
splashScreenDelay = cfg.getPreferenceValue('SplashScreenDelay') || splashScreenDelay;
spl... | javascript | function readPreferencesFromCfg(cfg) {
try {
var value = cfg.getPreferenceValue('ShowSplashScreen');
if(typeof value != 'undefined') {
showSplashScreen = value === 'true';
}
splashScreenDelay = cfg.getPreferenceValue('SplashScreenDelay') || splashScreenDelay;
spl... | [
"function",
"readPreferencesFromCfg",
"(",
"cfg",
")",
"{",
"try",
"{",
"var",
"value",
"=",
"cfg",
".",
"getPreferenceValue",
"(",
"'ShowSplashScreen'",
")",
";",
"if",
"(",
"typeof",
"value",
"!=",
"'undefined'",
")",
"{",
"showSplashScreen",
"=",
"value",
... | Reads preferences via ConfigHelper and substitutes default parameters. | [
"Reads",
"preferences",
"via",
"ConfigHelper",
"and",
"substitutes",
"default",
"parameters",
"."
] | 6800de23b168b3de143ee3f91c1efcaba9309de8 | https://github.com/apache/cordova-plugin-splashscreen/blob/6800de23b168b3de143ee3f91c1efcaba9309de8/src/browser/SplashScreenProxy.js#L115-L135 | train |
samselikoff/ember-cli-mirage | addon/start-mirage.js | resolveRegistration | function resolveRegistration(owner, ...args) {
if (owner.resolveRegistration) {
return owner.resolveRegistration(...args);
} else if (owner.__container__) {
return owner.__container__.lookupFactory(...args);
} else {
return owner.container.lookupFactory(...args);
}
} | javascript | function resolveRegistration(owner, ...args) {
if (owner.resolveRegistration) {
return owner.resolveRegistration(...args);
} else if (owner.__container__) {
return owner.__container__.lookupFactory(...args);
} else {
return owner.container.lookupFactory(...args);
}
} | [
"function",
"resolveRegistration",
"(",
"owner",
",",
"...",
"args",
")",
"{",
"if",
"(",
"owner",
".",
"resolveRegistration",
")",
"{",
"return",
"owner",
".",
"resolveRegistration",
"(",
"...",
"args",
")",
";",
"}",
"else",
"if",
"(",
"owner",
".",
"_... | Support Ember 1.13 | [
"Support",
"Ember",
"1",
".",
"13"
] | 41422055dc884410a0b468ef9e336446d193c8cf | https://github.com/samselikoff/ember-cli-mirage/blob/41422055dc884410a0b468ef9e336446d193c8cf/addon/start-mirage.js#L42-L50 | train |
samselikoff/ember-cli-mirage | addon/server.js | createPretender | function createPretender(server) {
return new Pretender(function() {
this.passthroughRequest = function(verb, path, request) {
if (server.shouldLog()) {
console.log(`Passthrough request: ${verb.toUpperCase()} ${request.url}`);
}
};
this.handledRequest = function(verb, path, request) {... | javascript | function createPretender(server) {
return new Pretender(function() {
this.passthroughRequest = function(verb, path, request) {
if (server.shouldLog()) {
console.log(`Passthrough request: ${verb.toUpperCase()} ${request.url}`);
}
};
this.handledRequest = function(verb, path, request) {... | [
"function",
"createPretender",
"(",
"server",
")",
"{",
"return",
"new",
"Pretender",
"(",
"function",
"(",
")",
"{",
"this",
".",
"passthroughRequest",
"=",
"function",
"(",
"verb",
",",
"path",
",",
"request",
")",
"{",
"if",
"(",
"server",
".",
"shoul... | Creates a new Pretender instance.
@method createPretender
@param {Server} server
@return {Object} A new Pretender instance.
@public | [
"Creates",
"a",
"new",
"Pretender",
"instance",
"."
] | 41422055dc884410a0b468ef9e336446d193c8cf | https://github.com/samselikoff/ember-cli-mirage/blob/41422055dc884410a0b468ef9e336446d193c8cf/addon/server.js#L30-L74 | train |
samselikoff/ember-cli-mirage | addon/server.js | isOption | function isOption(option) {
if (!option || typeof option !== 'object') {
return false;
}
let allOptions = Object.keys(defaultRouteOptions);
let optionKeys = Object.keys(option);
for (let i = 0; i < optionKeys.length; i++) {
let key = optionKeys[i];
if (allOptions.indexOf(key) > -1) {
return... | javascript | function isOption(option) {
if (!option || typeof option !== 'object') {
return false;
}
let allOptions = Object.keys(defaultRouteOptions);
let optionKeys = Object.keys(option);
for (let i = 0; i < optionKeys.length; i++) {
let key = optionKeys[i];
if (allOptions.indexOf(key) > -1) {
return... | [
"function",
"isOption",
"(",
"option",
")",
"{",
"if",
"(",
"!",
"option",
"||",
"typeof",
"option",
"!==",
"'object'",
")",
"{",
"return",
"false",
";",
"}",
"let",
"allOptions",
"=",
"Object",
".",
"keys",
"(",
"defaultRouteOptions",
")",
";",
"let",
... | Determine if the object contains a valid option.
@method isOption
@param {Object} option An object with one option value pair.
@return {Boolean} True if option is a valid option, false otherwise.
@private | [
"Determine",
"if",
"the",
"object",
"contains",
"a",
"valid",
"option",
"."
] | 41422055dc884410a0b468ef9e336446d193c8cf | https://github.com/samselikoff/ember-cli-mirage/blob/41422055dc884410a0b468ef9e336446d193c8cf/addon/server.js#L102-L116 | train |
samselikoff/ember-cli-mirage | addon/server.js | extractRouteArguments | function extractRouteArguments(args) {
let [ lastArg ] = args.splice(-1);
if (isOption(lastArg)) {
lastArg = _assign({}, defaultRouteOptions, lastArg);
} else {
args.push(lastArg);
lastArg = defaultRouteOptions;
}
let t = 2 - args.length;
while (t-- > 0) {
args.push(undefined);
}
args.pu... | javascript | function extractRouteArguments(args) {
let [ lastArg ] = args.splice(-1);
if (isOption(lastArg)) {
lastArg = _assign({}, defaultRouteOptions, lastArg);
} else {
args.push(lastArg);
lastArg = defaultRouteOptions;
}
let t = 2 - args.length;
while (t-- > 0) {
args.push(undefined);
}
args.pu... | [
"function",
"extractRouteArguments",
"(",
"args",
")",
"{",
"let",
"[",
"lastArg",
"]",
"=",
"args",
".",
"splice",
"(",
"-",
"1",
")",
";",
"if",
"(",
"isOption",
"(",
"lastArg",
")",
")",
"{",
"lastArg",
"=",
"_assign",
"(",
"{",
"}",
",",
"defau... | Extract arguments for a route.
@method extractRouteArguments
@param {Array} args Of the form [options], [object, code], [function, code]
[shorthand, options], [shorthand, code, options]
@return {Array} [handler (i.e. the function, object or shorthand), code,
options].
@private | [
"Extract",
"arguments",
"for",
"a",
"route",
"."
] | 41422055dc884410a0b468ef9e336446d193c8cf | https://github.com/samselikoff/ember-cli-mirage/blob/41422055dc884410a0b468ef9e336446d193c8cf/addon/server.js#L128-L142 | train |
ianstormtaylor/superstruct | src/superstruct.js | superstruct | function superstruct(config = {}) {
const types = {
...Types,
...(config.types || {}),
}
/**
* Create a `kind` struct with `schema`, `defaults` and `options`.
*
* @param {Any} schema
* @param {Any} defaults
* @param {Object} options
* @return {Function}
*/
function struct(schema, ... | javascript | function superstruct(config = {}) {
const types = {
...Types,
...(config.types || {}),
}
/**
* Create a `kind` struct with `schema`, `defaults` and `options`.
*
* @param {Any} schema
* @param {Any} defaults
* @param {Object} options
* @return {Function}
*/
function struct(schema, ... | [
"function",
"superstruct",
"(",
"config",
"=",
"{",
"}",
")",
"{",
"const",
"types",
"=",
"{",
"...",
"Types",
",",
"...",
"(",
"config",
".",
"types",
"||",
"{",
"}",
")",
",",
"}",
"/**\n * Create a `kind` struct with `schema`, `defaults` and `options`.\n ... | Create a struct factory with a `config`.
@param {Object} config
@return {Function} | [
"Create",
"a",
"struct",
"factory",
"with",
"a",
"config",
"."
] | 5d72235a1ec84b06315e5c87b63787b9cfa2be4c | https://github.com/ianstormtaylor/superstruct/blob/5d72235a1ec84b06315e5c87b63787b9cfa2be4c/src/superstruct.js#L14-L106 | train |
Microsoft/BotBuilder-CognitiveServices | CSharp/Samples/LuisActions/LuisActions.Samples.Web/Scripts/jquery.validate.js | function( element, method ) {
return $(element).data("msg-" + method.toLowerCase()) || (element.attributes && $(element).attr("data-msg-" + method.toLowerCase()));
} | javascript | function( element, method ) {
return $(element).data("msg-" + method.toLowerCase()) || (element.attributes && $(element).attr("data-msg-" + method.toLowerCase()));
} | [
"function",
"(",
"element",
",",
"method",
")",
"{",
"return",
"$",
"(",
"element",
")",
".",
"data",
"(",
"\"msg-\"",
"+",
"method",
".",
"toLowerCase",
"(",
")",
")",
"||",
"(",
"element",
".",
"attributes",
"&&",
"$",
"(",
"element",
")",
".",
"... | return the custom message for the given element and validation method specified in the element's HTML5 data attribute | [
"return",
"the",
"custom",
"message",
"for",
"the",
"given",
"element",
"and",
"validation",
"method",
"specified",
"in",
"the",
"element",
"s",
"HTML5",
"data",
"attribute"
] | f74a54bd7ccc74ef08a3a1d5682dc0198e8869cd | https://github.com/Microsoft/BotBuilder-CognitiveServices/blob/f74a54bd7ccc74ef08a3a1d5682dc0198e8869cd/CSharp/Samples/LuisActions/LuisActions.Samples.Web/Scripts/jquery.validate.js#L600-L602 | train | |
Microsoft/BotBuilder-CognitiveServices | CSharp/Samples/LuisActions/LuisActions.Samples.Web/Scripts/jquery.validate-vsdoc.js | function(element, method) {
if (!$.metadata)
return;
var meta = this.settings.meta
? $(element).metadata()[this.settings.meta]
: $(element).metadata();
return meta && meta.messages && meta.messages[method];
} | javascript | function(element, method) {
if (!$.metadata)
return;
var meta = this.settings.meta
? $(element).metadata()[this.settings.meta]
: $(element).metadata();
return meta && meta.messages && meta.messages[method];
} | [
"function",
"(",
"element",
",",
"method",
")",
"{",
"if",
"(",
"!",
"$",
".",
"metadata",
")",
"return",
";",
"var",
"meta",
"=",
"this",
".",
"settings",
".",
"meta",
"?",
"$",
"(",
"element",
")",
".",
"metadata",
"(",
")",
"[",
"this",
".",
... | return the custom message for the given element and validation method specified in the element's "messages" metadata | [
"return",
"the",
"custom",
"message",
"for",
"the",
"given",
"element",
"and",
"validation",
"method",
"specified",
"in",
"the",
"element",
"s",
"messages",
"metadata"
] | f74a54bd7ccc74ef08a3a1d5682dc0198e8869cd | https://github.com/Microsoft/BotBuilder-CognitiveServices/blob/f74a54bd7ccc74ef08a3a1d5682dc0198e8869cd/CSharp/Samples/LuisActions/LuisActions.Samples.Web/Scripts/jquery.validate-vsdoc.js#L639-L648 | train | |
bencoveney/barrelsby | bin/modules.js | getModules | function getModules(directory, logger, local) {
logger(`Getting modules @ ${directory.path}`);
if (directory.barrel) {
// If theres a barrel then use that as it *should* contain descendant modules.
logger(`Found existing barrel @ ${directory.barrel.path}`);
return [directory.barrel];
... | javascript | function getModules(directory, logger, local) {
logger(`Getting modules @ ${directory.path}`);
if (directory.barrel) {
// If theres a barrel then use that as it *should* contain descendant modules.
logger(`Found existing barrel @ ${directory.barrel.path}`);
return [directory.barrel];
... | [
"function",
"getModules",
"(",
"directory",
",",
"logger",
",",
"local",
")",
"{",
"logger",
"(",
"`",
"${",
"directory",
".",
"path",
"}",
"`",
")",
";",
"if",
"(",
"directory",
".",
"barrel",
")",
"{",
"// If theres a barrel then use that as it *should* cont... | Get any typescript modules contained at any depth in the current directory. | [
"Get",
"any",
"typescript",
"modules",
"contained",
"at",
"any",
"depth",
"in",
"the",
"current",
"directory",
"."
] | 7271065d27ad9060a899a5c64c6b03c749ad7867 | https://github.com/bencoveney/barrelsby/blob/7271065d27ad9060a899a5c64c6b03c749ad7867/bin/modules.js#L5-L21 | train |
bencoveney/barrelsby | bin/builder.js | buildBarrel | function buildBarrel(directory, builder, quoteCharacter, semicolonCharacter, barrelName, logger, baseUrl, local, include, exclude) {
logger(`Building barrel @ ${directory.path}`);
const content = builder(directory, modules_1.loadDirectoryModules(directory, logger, include, exclude, local), quoteCharacter, semic... | javascript | function buildBarrel(directory, builder, quoteCharacter, semicolonCharacter, barrelName, logger, baseUrl, local, include, exclude) {
logger(`Building barrel @ ${directory.path}`);
const content = builder(directory, modules_1.loadDirectoryModules(directory, logger, include, exclude, local), quoteCharacter, semic... | [
"function",
"buildBarrel",
"(",
"directory",
",",
"builder",
",",
"quoteCharacter",
",",
"semicolonCharacter",
",",
"barrelName",
",",
"logger",
",",
"baseUrl",
",",
"local",
",",
"include",
",",
"exclude",
")",
"{",
"logger",
"(",
"`",
"${",
"directory",
".... | Build a barrel for the specified directory. | [
"Build",
"a",
"barrel",
"for",
"the",
"specified",
"directory",
"."
] | 7271065d27ad9060a899a5c64c6b03c749ad7867 | https://github.com/bencoveney/barrelsby/blob/7271065d27ad9060a899a5c64c6b03c749ad7867/bin/builder.js#L29-L51 | train |
bencoveney/barrelsby | bin/builder.js | buildImportPath | function buildImportPath(directory, target, baseUrl) {
// If the base URL option is set then imports should be relative to there.
const startLocation = baseUrl ? baseUrl : directory.path;
const relativePath = path_1.default.relative(startLocation, target.path);
// Get the route and ensure it's relative
... | javascript | function buildImportPath(directory, target, baseUrl) {
// If the base URL option is set then imports should be relative to there.
const startLocation = baseUrl ? baseUrl : directory.path;
const relativePath = path_1.default.relative(startLocation, target.path);
// Get the route and ensure it's relative
... | [
"function",
"buildImportPath",
"(",
"directory",
",",
"target",
",",
"baseUrl",
")",
"{",
"// If the base URL option is set then imports should be relative to there.",
"const",
"startLocation",
"=",
"baseUrl",
"?",
"baseUrl",
":",
"directory",
".",
"path",
";",
"const",
... | Builds the TypeScript | [
"Builds",
"the",
"TypeScript"
] | 7271065d27ad9060a899a5c64c6b03c749ad7867 | https://github.com/bencoveney/barrelsby/blob/7271065d27ad9060a899a5c64c6b03c749ad7867/bin/builder.js#L53-L68 | train |
bencoveney/barrelsby | bin/builder.js | getBasename | function getBasename(relativePath) {
const mayBeSuffix = [".ts", ".tsx", ".d.ts"];
let mayBePath = relativePath;
mayBeSuffix.map(suffix => {
const tmpPath = path_1.default.basename(relativePath, suffix);
if (tmpPath.length < mayBePath.length) {
mayBePath = tmpPath;
}
... | javascript | function getBasename(relativePath) {
const mayBeSuffix = [".ts", ".tsx", ".d.ts"];
let mayBePath = relativePath;
mayBeSuffix.map(suffix => {
const tmpPath = path_1.default.basename(relativePath, suffix);
if (tmpPath.length < mayBePath.length) {
mayBePath = tmpPath;
}
... | [
"function",
"getBasename",
"(",
"relativePath",
")",
"{",
"const",
"mayBeSuffix",
"=",
"[",
"\".ts\"",
",",
"\".tsx\"",
",",
"\".d.ts\"",
"]",
";",
"let",
"mayBePath",
"=",
"relativePath",
";",
"mayBeSuffix",
".",
"map",
"(",
"suffix",
"=>",
"{",
"const",
... | Strips the .ts or .tsx file extension from a path and returns the base filename. | [
"Strips",
"the",
".",
"ts",
"or",
".",
"tsx",
"file",
"extension",
"from",
"a",
"path",
"and",
"returns",
"the",
"base",
"filename",
"."
] | 7271065d27ad9060a899a5c64c6b03c749ad7867 | https://github.com/bencoveney/barrelsby/blob/7271065d27ad9060a899a5c64c6b03c749ad7867/bin/builder.js#L74-L85 | train |
bencoveney/barrelsby | bin/destinations.js | getDestinations | function getDestinations(rootTree, locationOption, barrelName, logger) {
let destinations;
switch (locationOption) {
case "top":
default:
destinations = [rootTree];
break;
case "below":
destinations = rootTree.directories;
break;
ca... | javascript | function getDestinations(rootTree, locationOption, barrelName, logger) {
let destinations;
switch (locationOption) {
case "top":
default:
destinations = [rootTree];
break;
case "below":
destinations = rootTree.directories;
break;
ca... | [
"function",
"getDestinations",
"(",
"rootTree",
",",
"locationOption",
",",
"barrelName",
",",
"logger",
")",
"{",
"let",
"destinations",
";",
"switch",
"(",
"locationOption",
")",
"{",
"case",
"\"top\"",
":",
"default",
":",
"destinations",
"=",
"[",
"rootTre... | Assess which directories in the tree should contain barrels. | [
"Assess",
"which",
"directories",
"in",
"the",
"tree",
"should",
"contain",
"barrels",
"."
] | 7271065d27ad9060a899a5c64c6b03c749ad7867 | https://github.com/bencoveney/barrelsby/blob/7271065d27ad9060a899a5c64c6b03c749ad7867/bin/destinations.js#L5-L45 | train |
bencoveney/barrelsby | bin/fileTree.js | buildTree | function buildTree(directory, barrelName, logger) {
logger(`Building directory tree for ${utilities_1.convertPathSeparator(directory)}`);
const names = fs_1.default.readdirSync(directory);
const result = {
directories: [],
files: [],
name: path_1.default.basename(directory),
... | javascript | function buildTree(directory, barrelName, logger) {
logger(`Building directory tree for ${utilities_1.convertPathSeparator(directory)}`);
const names = fs_1.default.readdirSync(directory);
const result = {
directories: [],
files: [],
name: path_1.default.basename(directory),
... | [
"function",
"buildTree",
"(",
"directory",
",",
"barrelName",
",",
"logger",
")",
"{",
"logger",
"(",
"`",
"${",
"utilities_1",
".",
"convertPathSeparator",
"(",
"directory",
")",
"}",
"`",
")",
";",
"const",
"names",
"=",
"fs_1",
".",
"default",
".",
"r... | Build directory information recursively. | [
"Build",
"directory",
"information",
"recursively",
"."
] | 7271065d27ad9060a899a5c64c6b03c749ad7867 | https://github.com/bencoveney/barrelsby/blob/7271065d27ad9060a899a5c64c6b03c749ad7867/bin/fileTree.js#L10-L38 | train |
bencoveney/barrelsby | bin/fileTree.js | walkTree | function walkTree(directory, callback) {
callback(directory);
directory.directories.forEach(childDirectory => walkTree(childDirectory, callback));
} | javascript | function walkTree(directory, callback) {
callback(directory);
directory.directories.forEach(childDirectory => walkTree(childDirectory, callback));
} | [
"function",
"walkTree",
"(",
"directory",
",",
"callback",
")",
"{",
"callback",
"(",
"directory",
")",
";",
"directory",
".",
"directories",
".",
"forEach",
"(",
"childDirectory",
"=>",
"walkTree",
"(",
"childDirectory",
",",
"callback",
")",
")",
";",
"}"
... | Walk an entire directory tree recursively. | [
"Walk",
"an",
"entire",
"directory",
"tree",
"recursively",
"."
] | 7271065d27ad9060a899a5c64c6b03c749ad7867 | https://github.com/bencoveney/barrelsby/blob/7271065d27ad9060a899a5c64c6b03c749ad7867/bin/fileTree.js#L41-L44 | train |
JKHeadley/rest-hapi | utilities/rest-helper-factory.js | function(server, model, options) {
// TODO: generate multiple DELETE routes at /RESOURCE and at
// TODO: /RESOURCE/{ownerId}/ASSOCIATION that take a list of Id's as a payload
try {
validationHelper.validateModel(model, logger)
let collectionName = model.collectionDisplayName || model.... | javascript | function(server, model, options) {
// TODO: generate multiple DELETE routes at /RESOURCE and at
// TODO: /RESOURCE/{ownerId}/ASSOCIATION that take a list of Id's as a payload
try {
validationHelper.validateModel(model, logger)
let collectionName = model.collectionDisplayName || model.... | [
"function",
"(",
"server",
",",
"model",
",",
"options",
")",
"{",
"// TODO: generate multiple DELETE routes at /RESOURCE and at",
"// TODO: /RESOURCE/{ownerId}/ASSOCIATION that take a list of Id's as a payload",
"try",
"{",
"validationHelper",
".",
"validateModel",
"(",
"model",
... | Generates the restful API endpoints for a single model.
@param server: A Hapi server.
@param model: A mongoose model.
@param options: options object. | [
"Generates",
"the",
"restful",
"API",
"endpoints",
"for",
"a",
"single",
"model",
"."
] | 36110fd3cb2775b3b2068b18d775f1c87fbcef76 | https://github.com/JKHeadley/rest-hapi/blob/36110fd3cb2775b3b2068b18d775f1c87fbcef76/utilities/rest-helper-factory.js#L39-L136 | train | |
JKHeadley/rest-hapi | utilities/handler-helper.js | _list | function _list(model, query, Log) {
let request = { query: query }
return _listHandler(model, request, Log)
} | javascript | function _list(model, query, Log) {
let request = { query: query }
return _listHandler(model, request, Log)
} | [
"function",
"_list",
"(",
"model",
",",
"query",
",",
"Log",
")",
"{",
"let",
"request",
"=",
"{",
"query",
":",
"query",
"}",
"return",
"_listHandler",
"(",
"model",
",",
"request",
",",
"Log",
")",
"}"
] | List function exposed as a mongoose wrapper.
@param model: A mongoose model.
@param query: rest-hapi query parameters to be converted to a mongoose query.
@param Log: A logging object.
@returns {object} A promise for the resulting model documents or the count of the query results.
@private | [
"List",
"function",
"exposed",
"as",
"a",
"mongoose",
"wrapper",
"."
] | 36110fd3cb2775b3b2068b18d775f1c87fbcef76 | https://github.com/JKHeadley/rest-hapi/blob/36110fd3cb2775b3b2068b18d775f1c87fbcef76/utilities/handler-helper.js#L68-L71 | train |
JKHeadley/rest-hapi | utilities/handler-helper.js | _find | function _find(model, _id, query, Log) {
let request = { params: { _id: _id }, query: query }
return _findHandler(model, _id, request, Log)
} | javascript | function _find(model, _id, query, Log) {
let request = { params: { _id: _id }, query: query }
return _findHandler(model, _id, request, Log)
} | [
"function",
"_find",
"(",
"model",
",",
"_id",
",",
"query",
",",
"Log",
")",
"{",
"let",
"request",
"=",
"{",
"params",
":",
"{",
"_id",
":",
"_id",
"}",
",",
"query",
":",
"query",
"}",
"return",
"_findHandler",
"(",
"model",
",",
"_id",
",",
"... | Find function exposed as a mongoose wrapper.
@param model: A mongoose model.
@param _id: The document id.
@param query: rest-hapi query parameters to be converted to a mongoose query.
@param Log: A logging object.
@returns {object} A promise for the resulting model document.
@private | [
"Find",
"function",
"exposed",
"as",
"a",
"mongoose",
"wrapper",
"."
] | 36110fd3cb2775b3b2068b18d775f1c87fbcef76 | https://github.com/JKHeadley/rest-hapi/blob/36110fd3cb2775b3b2068b18d775f1c87fbcef76/utilities/handler-helper.js#L220-L223 | train |
JKHeadley/rest-hapi | utilities/handler-helper.js | _findHandler | async function _findHandler(model, _id, request, Log) {
try {
let query = Object.assign({}, request.query)
try {
if (
model.routeOptions &&
model.routeOptions.find &&
model.routeOptions.find.pre
) {
query = await model.routeOptions.find.pre(_id, query, request, Log)... | javascript | async function _findHandler(model, _id, request, Log) {
try {
let query = Object.assign({}, request.query)
try {
if (
model.routeOptions &&
model.routeOptions.find &&
model.routeOptions.find.pre
) {
query = await model.routeOptions.find.pre(_id, query, request, Log)... | [
"async",
"function",
"_findHandler",
"(",
"model",
",",
"_id",
",",
"request",
",",
"Log",
")",
"{",
"try",
"{",
"let",
"query",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"request",
".",
"query",
")",
"try",
"{",
"if",
"(",
"model",
".",
... | Finds a model document.
@param model: A mongoose model.
@param _id: The document id.
@param request: The Hapi request object, or a container for the wrapper query.
@param Log: A logging object.
@returns {object} A promise for the resulting model document.
@private | [
"Finds",
"a",
"model",
"document",
"."
] | 36110fd3cb2775b3b2068b18d775f1c87fbcef76 | https://github.com/JKHeadley/rest-hapi/blob/36110fd3cb2775b3b2068b18d775f1c87fbcef76/utilities/handler-helper.js#L233-L313 | train |
JKHeadley/rest-hapi | utilities/handler-helper.js | _create | function _create(model, payload, Log) {
let request = { payload: payload }
return _createHandler(model, request, Log)
} | javascript | function _create(model, payload, Log) {
let request = { payload: payload }
return _createHandler(model, request, Log)
} | [
"function",
"_create",
"(",
"model",
",",
"payload",
",",
"Log",
")",
"{",
"let",
"request",
"=",
"{",
"payload",
":",
"payload",
"}",
"return",
"_createHandler",
"(",
"model",
",",
"request",
",",
"Log",
")",
"}"
] | Create function exposed as a mongoose wrapper.
@param model: A mongoose model.
@param payload: Data used to create the model document/s.
@param Log: A logging object.
@returns {object} A promise for the resulting model document/s.
@private | [
"Create",
"function",
"exposed",
"as",
"a",
"mongoose",
"wrapper",
"."
] | 36110fd3cb2775b3b2068b18d775f1c87fbcef76 | https://github.com/JKHeadley/rest-hapi/blob/36110fd3cb2775b3b2068b18d775f1c87fbcef76/utilities/handler-helper.js#L323-L326 | train |
JKHeadley/rest-hapi | utilities/handler-helper.js | _update | function _update(model, _id, payload, Log) {
let request = { params: { _id: _id }, payload: payload }
return _updateHandler(model, _id, request, Log)
} | javascript | function _update(model, _id, payload, Log) {
let request = { params: { _id: _id }, payload: payload }
return _updateHandler(model, _id, request, Log)
} | [
"function",
"_update",
"(",
"model",
",",
"_id",
",",
"payload",
",",
"Log",
")",
"{",
"let",
"request",
"=",
"{",
"params",
":",
"{",
"_id",
":",
"_id",
"}",
",",
"payload",
":",
"payload",
"}",
"return",
"_updateHandler",
"(",
"model",
",",
"_id",
... | Update function exposed as a mongoose wrapper.
@param model: A mongoose model.
@param _id: The document id.
@param payload: Data used to update the model document.
@param Log: A logging object.
@returns {object} A promise for the resulting model document.
@private | [
"Update",
"function",
"exposed",
"as",
"a",
"mongoose",
"wrapper",
"."
] | 36110fd3cb2775b3b2068b18d775f1c87fbcef76 | https://github.com/JKHeadley/rest-hapi/blob/36110fd3cb2775b3b2068b18d775f1c87fbcef76/utilities/handler-helper.js#L442-L445 | train |
JKHeadley/rest-hapi | utilities/handler-helper.js | _updateHandler | async function _updateHandler(model, _id, request, Log) {
let payload = Object.assign({}, request.payload)
try {
try {
if (
model.routeOptions &&
model.routeOptions.update &&
model.routeOptions.update.pre
) {
payload = await model.routeOptions.update.pre(
_i... | javascript | async function _updateHandler(model, _id, request, Log) {
let payload = Object.assign({}, request.payload)
try {
try {
if (
model.routeOptions &&
model.routeOptions.update &&
model.routeOptions.update.pre
) {
payload = await model.routeOptions.update.pre(
_i... | [
"async",
"function",
"_updateHandler",
"(",
"model",
",",
"_id",
",",
"request",
",",
"Log",
")",
"{",
"let",
"payload",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"request",
".",
"payload",
")",
"try",
"{",
"try",
"{",
"if",
"(",
"model",
"... | Updates a model document.
@param model: A mongoose model.
@param _id: The document id.
@param request: The Hapi request object, or a container for the wrapper payload.
@param Log: A logging object.
@returns {object} A promise for the resulting model document.
@private | [
"Updates",
"a",
"model",
"document",
"."
] | 36110fd3cb2775b3b2068b18d775f1c87fbcef76 | https://github.com/JKHeadley/rest-hapi/blob/36110fd3cb2775b3b2068b18d775f1c87fbcef76/utilities/handler-helper.js#L455-L526 | train |
JKHeadley/rest-hapi | utilities/handler-helper.js | _deleteOne | function _deleteOne(model, _id, hardDelete, Log) {
let request = { params: { _id: _id } }
return _deleteOneHandler(model, _id, hardDelete, request, Log)
} | javascript | function _deleteOne(model, _id, hardDelete, Log) {
let request = { params: { _id: _id } }
return _deleteOneHandler(model, _id, hardDelete, request, Log)
} | [
"function",
"_deleteOne",
"(",
"model",
",",
"_id",
",",
"hardDelete",
",",
"Log",
")",
"{",
"let",
"request",
"=",
"{",
"params",
":",
"{",
"_id",
":",
"_id",
"}",
"}",
"return",
"_deleteOneHandler",
"(",
"model",
",",
"_id",
",",
"hardDelete",
",",
... | DeleteOne function exposed as a mongoose wrapper.
@param model: A mongoose model.
@param _id: The document id.
@param hardDelete: Flag used to determine a soft or hard delete.
@param Log: A logging object.
@returns {object} A promise returning true if the delete succeeds.
@private | [
"DeleteOne",
"function",
"exposed",
"as",
"a",
"mongoose",
"wrapper",
"."
] | 36110fd3cb2775b3b2068b18d775f1c87fbcef76 | https://github.com/JKHeadley/rest-hapi/blob/36110fd3cb2775b3b2068b18d775f1c87fbcef76/utilities/handler-helper.js#L537-L540 | train |
JKHeadley/rest-hapi | utilities/handler-helper.js | _deleteOneHandler | async function _deleteOneHandler(model, _id, hardDelete, request, Log) {
try {
try {
if (
model.routeOptions &&
model.routeOptions.delete &&
model.routeOptions.delete.pre
) {
await model.routeOptions.delete.pre(_id, hardDelete, request, Log)
}
} catch (err) {
... | javascript | async function _deleteOneHandler(model, _id, hardDelete, request, Log) {
try {
try {
if (
model.routeOptions &&
model.routeOptions.delete &&
model.routeOptions.delete.pre
) {
await model.routeOptions.delete.pre(_id, hardDelete, request, Log)
}
} catch (err) {
... | [
"async",
"function",
"_deleteOneHandler",
"(",
"model",
",",
"_id",
",",
"hardDelete",
",",
"request",
",",
"Log",
")",
"{",
"try",
"{",
"try",
"{",
"if",
"(",
"model",
".",
"routeOptions",
"&&",
"model",
".",
"routeOptions",
".",
"delete",
"&&",
"model"... | Deletes a model document
@param model: A mongoose model.
@param _id: The document id.
@param hardDelete: Flag used to determine a soft or hard delete.
@param request: The Hapi request object.
@param Log: A logging object.
@returns {object} A promise returning true if the delete succeeds.
@private
TODO: only update "de... | [
"Deletes",
"a",
"model",
"document"
] | 36110fd3cb2775b3b2068b18d775f1c87fbcef76 | https://github.com/JKHeadley/rest-hapi/blob/36110fd3cb2775b3b2068b18d775f1c87fbcef76/utilities/handler-helper.js#L552-L632 | train |
JKHeadley/rest-hapi | utilities/handler-helper.js | _deleteMany | function _deleteMany(model, payload, Log) {
let request = { payload: payload }
return _deleteManyHandler(model, request, Log)
} | javascript | function _deleteMany(model, payload, Log) {
let request = { payload: payload }
return _deleteManyHandler(model, request, Log)
} | [
"function",
"_deleteMany",
"(",
"model",
",",
"payload",
",",
"Log",
")",
"{",
"let",
"request",
"=",
"{",
"payload",
":",
"payload",
"}",
"return",
"_deleteManyHandler",
"(",
"model",
",",
"request",
",",
"Log",
")",
"}"
] | DeleteMany function exposed as a mongoose wrapper.
@param model: A mongoose model.
@param payload: Either an array of ids or an array of objects containing an id and a "hardDelete" flag.
@param Log: A logging object.
@returns {object} A promise returning true if the delete succeeds.
@private | [
"DeleteMany",
"function",
"exposed",
"as",
"a",
"mongoose",
"wrapper",
"."
] | 36110fd3cb2775b3b2068b18d775f1c87fbcef76 | https://github.com/JKHeadley/rest-hapi/blob/36110fd3cb2775b3b2068b18d775f1c87fbcef76/utilities/handler-helper.js#L642-L645 | train |
JKHeadley/rest-hapi | utilities/handler-helper.js | _deleteManyHandler | async function _deleteManyHandler(model, request, Log) {
try {
// EXPL: make a copy of the payload so that request.payload remains unchanged
let payload = request.payload.map(item => {
return _.isObject(item) ? _.assignIn({}, item) : item
})
let promises = []
for (let arg of payload) {
... | javascript | async function _deleteManyHandler(model, request, Log) {
try {
// EXPL: make a copy of the payload so that request.payload remains unchanged
let payload = request.payload.map(item => {
return _.isObject(item) ? _.assignIn({}, item) : item
})
let promises = []
for (let arg of payload) {
... | [
"async",
"function",
"_deleteManyHandler",
"(",
"model",
",",
"request",
",",
"Log",
")",
"{",
"try",
"{",
"// EXPL: make a copy of the payload so that request.payload remains unchanged",
"let",
"payload",
"=",
"request",
".",
"payload",
".",
"map",
"(",
"item",
"=>",... | Deletes multiple documents.
@param model: A mongoose model.
@param request: The Hapi request object, or a container for the wrapper payload.
@param Log: A logging object.
@returns {object} A promise returning true if the delete succeeds.
@private
TODO: prevent Promise.all from catching first error and returning early.... | [
"Deletes",
"multiple",
"documents",
"."
] | 36110fd3cb2775b3b2068b18d775f1c87fbcef76 | https://github.com/JKHeadley/rest-hapi/blob/36110fd3cb2775b3b2068b18d775f1c87fbcef76/utilities/handler-helper.js#L656-L678 | train |
JKHeadley/rest-hapi | utilities/handler-helper.js | _addOne | function _addOne(
ownerModel,
ownerId,
childModel,
childId,
associationName,
payload,
Log
) {
let request = {
params: { ownerId: ownerId, childId: childId },
payload: payload
}
return _addOneHandler(
ownerModel,
ownerId,
childModel,
childId,
associationName,
request,
... | javascript | function _addOne(
ownerModel,
ownerId,
childModel,
childId,
associationName,
payload,
Log
) {
let request = {
params: { ownerId: ownerId, childId: childId },
payload: payload
}
return _addOneHandler(
ownerModel,
ownerId,
childModel,
childId,
associationName,
request,
... | [
"function",
"_addOne",
"(",
"ownerModel",
",",
"ownerId",
",",
"childModel",
",",
"childId",
",",
"associationName",
",",
"payload",
",",
"Log",
")",
"{",
"let",
"request",
"=",
"{",
"params",
":",
"{",
"ownerId",
":",
"ownerId",
",",
"childId",
":",
"ch... | AddOne function exposed as a mongoose wrapper.
@param ownerModel: The model that is being added to.
@param ownerId: The id of the owner document.
@param childModel: The model that is being added.
@param childId: The id of the child document.
@param associationName: The name of the association from the ownerModel's pers... | [
"AddOne",
"function",
"exposed",
"as",
"a",
"mongoose",
"wrapper",
"."
] | 36110fd3cb2775b3b2068b18d775f1c87fbcef76 | https://github.com/JKHeadley/rest-hapi/blob/36110fd3cb2775b3b2068b18d775f1c87fbcef76/utilities/handler-helper.js#L692-L714 | train |
Subsets and Splits
SQL Console for semeru/code-text-javascript
Retrieves 20,000 non-null code samples labeled as JavaScript, providing a basic overview of the dataset.