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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
zenparsing/moon-unit | build/moon-unit.js | function(list) {
if (Array.isArray(list)) {
this.a.push.apply(this.a, list);
} else {
for (var __$0 = (list)[Symbol.iterator](), __$1; __$1 = __$0.next(), !__$1.done;)
{ var item$0 = __$1.value; this.a.push(item$0); }
... | javascript | function(list) {
if (Array.isArray(list)) {
this.a.push.apply(this.a, list);
} else {
for (var __$0 = (list)[Symbol.iterator](), __$1; __$1 = __$0.next(), !__$1.done;)
{ var item$0 = __$1.value; this.a.push(item$0); }
... | [
"function",
"(",
"list",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"list",
")",
")",
"{",
"this",
".",
"a",
".",
"push",
".",
"apply",
"(",
"this",
".",
"a",
",",
"list",
")",
";",
"}",
"else",
"{",
"for",
"(",
"var",
"__$0",
"=",
... | Add the contents of iterables | [
"Add",
"the",
"contents",
"of",
"iterables"
] | 5fbe6805e3d382a0ce9e2913da65613ec33b19cb | https://github.com/zenparsing/moon-unit/blob/5fbe6805e3d382a0ce9e2913da65613ec33b19cb/build/moon-unit.js#L308-L321 | train | |
zenparsing/moon-unit | build/moon-unit.js | function(obj) {
if (Array.isArray(obj)) {
return {
at: function(skip, pos) { return obj[pos] },
rest: function(skip, pos) { return obj.slice(pos) }
};
}
var iter = toObject(obj)[Symbol.iterator]();
return {
at: fun... | javascript | function(obj) {
if (Array.isArray(obj)) {
return {
at: function(skip, pos) { return obj[pos] },
rest: function(skip, pos) { return obj.slice(pos) }
};
}
var iter = toObject(obj)[Symbol.iterator]();
return {
at: fun... | [
"function",
"(",
"obj",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"obj",
")",
")",
"{",
"return",
"{",
"at",
":",
"function",
"(",
"skip",
",",
"pos",
")",
"{",
"return",
"obj",
"[",
"pos",
"]",
"}",
",",
"rest",
":",
"function",
"(",
... | Support for array destructuring | [
"Support",
"for",
"array",
"destructuring"
] | 5fbe6805e3d382a0ce9e2913da65613ec33b19cb | https://github.com/zenparsing/moon-unit/blob/5fbe6805e3d382a0ce9e2913da65613ec33b19cb/build/moon-unit.js#L333-L371 | train | |
zenparsing/moon-unit | build/moon-unit.js | function(obj, map, name) {
var entry = map.get(Object(obj));
if (!entry)
throw new TypeError;
return entry[name];
} | javascript | function(obj, map, name) {
var entry = map.get(Object(obj));
if (!entry)
throw new TypeError;
return entry[name];
} | [
"function",
"(",
"obj",
",",
"map",
",",
"name",
")",
"{",
"var",
"entry",
"=",
"map",
".",
"get",
"(",
"Object",
"(",
"obj",
")",
")",
";",
"if",
"(",
"!",
"entry",
")",
"throw",
"new",
"TypeError",
";",
"return",
"entry",
"[",
"name",
"]",
";... | Support for private fields | [
"Support",
"for",
"private",
"fields"
] | 5fbe6805e3d382a0ce9e2913da65613ec33b19cb | https://github.com/zenparsing/moon-unit/blob/5fbe6805e3d382a0ce9e2913da65613ec33b19cb/build/moon-unit.js#L374-L382 | train | |
zenparsing/moon-unit | build/moon-unit.js | getClass | function getClass(o) {
if (o === null || o === undefined) return "Object";
return OP_toString.call(o).slice("[object ".length, -1);
} | javascript | function getClass(o) {
if (o === null || o === undefined) return "Object";
return OP_toString.call(o).slice("[object ".length, -1);
} | [
"function",
"getClass",
"(",
"o",
")",
"{",
"if",
"(",
"o",
"===",
"null",
"||",
"o",
"===",
"undefined",
")",
"return",
"\"Object\"",
";",
"return",
"OP_toString",
".",
"call",
"(",
"o",
")",
".",
"slice",
"(",
"\"[object \"",
".",
"length",
",",
"-... | Returns the internal class of an object | [
"Returns",
"the",
"internal",
"class",
"of",
"an",
"object"
] | 5fbe6805e3d382a0ce9e2913da65613ec33b19cb | https://github.com/zenparsing/moon-unit/blob/5fbe6805e3d382a0ce9e2913da65613ec33b19cb/build/moon-unit.js#L409-L413 | train |
zenparsing/moon-unit | build/moon-unit.js | equal | function equal(a, b) {
if (Object.is(a, b))
return true;
// Dates must have equal time values
if (isDate(a) && isDate(b))
return a.getTime() === b.getTime();
// Non-objects must be strictly equal (types must be equal)
if (!isObject(a) || !isObject(b))
return a === b;
// Prototypes must be ident... | javascript | function equal(a, b) {
if (Object.is(a, b))
return true;
// Dates must have equal time values
if (isDate(a) && isDate(b))
return a.getTime() === b.getTime();
// Non-objects must be strictly equal (types must be equal)
if (!isObject(a) || !isObject(b))
return a === b;
// Prototypes must be ident... | [
"function",
"equal",
"(",
"a",
",",
"b",
")",
"{",
"if",
"(",
"Object",
".",
"is",
"(",
"a",
",",
"b",
")",
")",
"return",
"true",
";",
"// Dates must have equal time values",
"if",
"(",
"isDate",
"(",
"a",
")",
"&&",
"isDate",
"(",
"b",
")",
")",
... | Returns true if the arguments are "equal" | [
"Returns",
"true",
"if",
"the",
"arguments",
"are",
"equal"
] | 5fbe6805e3d382a0ce9e2913da65613ec33b19cb | https://github.com/zenparsing/moon-unit/blob/5fbe6805e3d382a0ce9e2913da65613ec33b19cb/build/moon-unit.js#L428-L469 | train |
davidmarkclements/seneca-scheduler | lib/scheduler.js | punch | function punch(date) {
Object.defineProperty(date, '_isValid', {
get: function() {
return this.toDate() !== this.lang().invalidDate()
}
});
return date;
} | javascript | function punch(date) {
Object.defineProperty(date, '_isValid', {
get: function() {
return this.toDate() !== this.lang().invalidDate()
}
});
return date;
} | [
"function",
"punch",
"(",
"date",
")",
"{",
"Object",
".",
"defineProperty",
"(",
"date",
",",
"'_isValid'",
",",
"{",
"get",
":",
"function",
"(",
")",
"{",
"return",
"this",
".",
"toDate",
"(",
")",
"!==",
"this",
".",
"lang",
"(",
")",
".",
"inv... | monkey punch moment to get around a validation bug | [
"monkey",
"punch",
"moment",
"to",
"get",
"around",
"a",
"validation",
"bug"
] | 3a2b3c40c086b244f985bd1612e6af677e2df9e5 | https://github.com/davidmarkclements/seneca-scheduler/blob/3a2b3c40c086b244f985bd1612e6af677e2df9e5/lib/scheduler.js#L13-L20 | train |
spacemaus/postvox | vox-server/interchangesockets.js | handleSocketMessage | function handleSocketMessage(method, data, replyFn) {
debug('%s %s %s', socket.id, method, data.url, data.payload);
eyes.mark('sockets.' + method);
var url = data.url;
if (!url) {
replyFn({ status: 400, message: 'No URL given in request!' });
return;
}
if (url.indexOf('/') == -1) {
... | javascript | function handleSocketMessage(method, data, replyFn) {
debug('%s %s %s', socket.id, method, data.url, data.payload);
eyes.mark('sockets.' + method);
var url = data.url;
if (!url) {
replyFn({ status: 400, message: 'No URL given in request!' });
return;
}
if (url.indexOf('/') == -1) {
... | [
"function",
"handleSocketMessage",
"(",
"method",
",",
"data",
",",
"replyFn",
")",
"{",
"debug",
"(",
"'%s %s %s'",
",",
"socket",
".",
"id",
",",
"method",
",",
"data",
".",
"url",
",",
"data",
".",
"payload",
")",
";",
"eyes",
".",
"mark",
"(",
"'... | Handles the VOX command. A VOX command wraps a URL, HTTP method, and JSON
data payload, and it expects a JSON response.
@param method {String} The command's HTTP-like method. E.g. "POST".
@param data.url {String} The URL of the command. E.g.,
"vox://<source>/threads/<threadId>".
@param data.payload {Object} The com... | [
"Handles",
"the",
"VOX",
"command",
".",
"A",
"VOX",
"command",
"wraps",
"a",
"URL",
"HTTP",
"method",
"and",
"JSON",
"data",
"payload",
"and",
"it",
"expects",
"a",
"JSON",
"response",
"."
] | de98e5ed37edaee1b1edadf93e15eb8f8d21f457 | https://github.com/spacemaus/postvox/blob/de98e5ed37edaee1b1edadf93e15eb8f8d21f457/vox-server/interchangesockets.js#L71-L119 | train |
shama/cettings | namespace.js | getParts | function getParts(str) {
return str.replace(/\\\./g, '\uffff').split('.').map(function(s) {
return s.replace(/\uffff/g, '.');
});
} | javascript | function getParts(str) {
return str.replace(/\\\./g, '\uffff').split('.').map(function(s) {
return s.replace(/\uffff/g, '.');
});
} | [
"function",
"getParts",
"(",
"str",
")",
"{",
"return",
"str",
".",
"replace",
"(",
"/",
"\\\\\\.",
"/",
"g",
",",
"'\\uffff'",
")",
".",
"split",
"(",
"'.'",
")",
".",
"map",
"(",
"function",
"(",
"s",
")",
"{",
"return",
"s",
".",
"replace",
"(... | Split strings on dot, but only if dot isn't preceded by a backslash. Since JavaScript doesn't support lookbehinds, use a placeholder for "\.", split on dot, then replace the placeholder character with a dot. | [
"Split",
"strings",
"on",
"dot",
"but",
"only",
"if",
"dot",
"isn",
"t",
"preceded",
"by",
"a",
"backslash",
".",
"Since",
"JavaScript",
"doesn",
"t",
"support",
"lookbehinds",
"use",
"a",
"placeholder",
"for",
"\\",
".",
"split",
"on",
"dot",
"then",
"r... | 886eeec0c1fb92a2d1ce9926c8c1edf61c678c03 | https://github.com/shama/cettings/blob/886eeec0c1fb92a2d1ce9926c8c1edf61c678c03/namespace.js#L17-L21 | train |
slikts/promiseproxy | src/cached.js | CachedPromiseProxy | function CachedPromiseProxy(target, context, cache = new WeakMap(), factory = PromiseProxy) {
const cached = cache.get(target)
if (cached) {
return cached
}
const obj = factory(target, context,
(target, context) => CachedPromiseProxy(target, context, cache))
cache.set(target, obj)
return obj
} | javascript | function CachedPromiseProxy(target, context, cache = new WeakMap(), factory = PromiseProxy) {
const cached = cache.get(target)
if (cached) {
return cached
}
const obj = factory(target, context,
(target, context) => CachedPromiseProxy(target, context, cache))
cache.set(target, obj)
return obj
} | [
"function",
"CachedPromiseProxy",
"(",
"target",
",",
"context",
",",
"cache",
"=",
"new",
"WeakMap",
"(",
")",
",",
"factory",
"=",
"PromiseProxy",
")",
"{",
"const",
"cached",
"=",
"cache",
".",
"get",
"(",
"target",
")",
"if",
"(",
"cached",
")",
"{... | Wraps PromiseProxy factory and caches instances in a WeakMap | [
"Wraps",
"PromiseProxy",
"factory",
"and",
"caches",
"instances",
"in",
"a",
"WeakMap"
] | bcda1b4372bf03a86af7d2bb1ba01a746a9ba952 | https://github.com/slikts/promiseproxy/blob/bcda1b4372bf03a86af7d2bb1ba01a746a9ba952/src/cached.js#L6-L15 | train |
alex-seville/feta | dist/devtools.js | checkIfPlaying | function checkIfPlaying(){
runInPage(window.fetaSource.isPlayingStr(),
function(result){
if(!result){
setTimeout(checkIfPlaying,500);
}else{
_window.msgFromDevtools("revertRun",{data: result});
}
},... | javascript | function checkIfPlaying(){
runInPage(window.fetaSource.isPlayingStr(),
function(result){
if(!result){
setTimeout(checkIfPlaying,500);
}else{
_window.msgFromDevtools("revertRun",{data: result});
}
},... | [
"function",
"checkIfPlaying",
"(",
")",
"{",
"runInPage",
"(",
"window",
".",
"fetaSource",
".",
"isPlayingStr",
"(",
")",
",",
"function",
"(",
"result",
")",
"{",
"if",
"(",
"!",
"result",
")",
"{",
"setTimeout",
"(",
"checkIfPlaying",
",",
"500",
")",... | we check if the test is still running when it isn't running anymore we update the run test button | [
"we",
"check",
"if",
"the",
"test",
"is",
"still",
"running",
"when",
"it",
"isn",
"t",
"running",
"anymore",
"we",
"update",
"the",
"run",
"test",
"button"
] | 2ba603320ccba3fec313d26a3a70fab3d6f39e3a | https://github.com/alex-seville/feta/blob/2ba603320ccba3fec313d26a3a70fab3d6f39e3a/dist/devtools.js#L86-L98 | train |
alex-seville/feta | dist/devtools.js | doFeta | function doFeta(msg) {
if(msg){
runInPage(window.fetaSource.startStr(),
function(){
btn.update("images/recording.png", "Stop Recording");
});
}else{
runInPage(window.fetaSource.stopStr(),
function(resul... | javascript | function doFeta(msg) {
if(msg){
runInPage(window.fetaSource.startStr(),
function(){
btn.update("images/recording.png", "Stop Recording");
});
}else{
runInPage(window.fetaSource.stopStr(),
function(resul... | [
"function",
"doFeta",
"(",
"msg",
")",
"{",
"if",
"(",
"msg",
")",
"{",
"runInPage",
"(",
"window",
".",
"fetaSource",
".",
"startStr",
"(",
")",
",",
"function",
"(",
")",
"{",
"btn",
".",
"update",
"(",
"\"images/recording.png\"",
",",
"\"Stop Recordin... | we inject feta.start or feta.stop depending on the mode. we update the panel button as well | [
"we",
"inject",
"feta",
".",
"start",
"or",
"feta",
".",
"stop",
"depending",
"on",
"the",
"mode",
".",
"we",
"update",
"the",
"panel",
"button",
"as",
"well"
] | 2ba603320ccba3fec313d26a3a70fab3d6f39e3a | https://github.com/alex-seville/feta/blob/2ba603320ccba3fec313d26a3a70fab3d6f39e3a/dist/devtools.js#L102-L115 | train |
alex-seville/feta | dist/devtools.js | makeDownload | function makeDownload(url,fname){
fname = fname === "" ? "feta_output.js" : fname;
//this code is from SO, but I'm missing the link right now
var s = "var a = document.createElement('a');";
s+= "a.href = '"+url+"';";
s+= "a.download = '"+ fname +"';";... | javascript | function makeDownload(url,fname){
fname = fname === "" ? "feta_output.js" : fname;
//this code is from SO, but I'm missing the link right now
var s = "var a = document.createElement('a');";
s+= "a.href = '"+url+"';";
s+= "a.download = '"+ fname +"';";... | [
"function",
"makeDownload",
"(",
"url",
",",
"fname",
")",
"{",
"fname",
"=",
"fname",
"===",
"\"\"",
"?",
"\"feta_output.js\"",
":",
"fname",
";",
"//this code is from SO, but I'm missing the link right now",
"var",
"s",
"=",
"\"var a = document.createElement('a');\"",
... | create a link element and click it to download the file | [
"create",
"a",
"link",
"element",
"and",
"click",
"it",
"to",
"download",
"the",
"file"
] | 2ba603320ccba3fec313d26a3a70fab3d6f39e3a | https://github.com/alex-seville/feta/blob/2ba603320ccba3fec313d26a3a70fab3d6f39e3a/dist/devtools.js#L123-L134 | train |
alex-seville/feta | dist/devtools.js | runInPage | function runInPage(code,callback,errorCallback){
errorCallback = errorCallback || function(err){ alert(errorMessage+err); };
chrome.devtools.inspectedWindow["eval"](
code,
function(result, isException) {
if (isException)
errorCallback(isException);
else{
callback(result);
}
})... | javascript | function runInPage(code,callback,errorCallback){
errorCallback = errorCallback || function(err){ alert(errorMessage+err); };
chrome.devtools.inspectedWindow["eval"](
code,
function(result, isException) {
if (isException)
errorCallback(isException);
else{
callback(result);
}
})... | [
"function",
"runInPage",
"(",
"code",
",",
"callback",
",",
"errorCallback",
")",
"{",
"errorCallback",
"=",
"errorCallback",
"||",
"function",
"(",
"err",
")",
"{",
"alert",
"(",
"errorMessage",
"+",
"err",
")",
";",
"}",
";",
"chrome",
".",
"devtools",
... | helper function to evaluate code in the inspected page context with access to the JS and the DOM | [
"helper",
"function",
"to",
"evaluate",
"code",
"in",
"the",
"inspected",
"page",
"context",
"with",
"access",
"to",
"the",
"JS",
"and",
"the",
"DOM"
] | 2ba603320ccba3fec313d26a3a70fab3d6f39e3a | https://github.com/alex-seville/feta/blob/2ba603320ccba3fec313d26a3a70fab3d6f39e3a/dist/devtools.js#L143-L154 | train |
nullivex/oose-sdk | helpers/api.js | function(err){
//if this is already a network error just throw it
if(err instanceof NetworkError){
throw err
}
//convert strings to errors
if('string' === typeof err){
err = new Error(err)
}
//check if the error message matches a known TCP error
var error
for(var i = 0; i < tcpErrors.length; i... | javascript | function(err){
//if this is already a network error just throw it
if(err instanceof NetworkError){
throw err
}
//convert strings to errors
if('string' === typeof err){
err = new Error(err)
}
//check if the error message matches a known TCP error
var error
for(var i = 0; i < tcpErrors.length; i... | [
"function",
"(",
"err",
")",
"{",
"//if this is already a network error just throw it",
"if",
"(",
"err",
"instanceof",
"NetworkError",
")",
"{",
"throw",
"err",
"}",
"//convert strings to errors",
"if",
"(",
"'string'",
"===",
"typeof",
"err",
")",
"{",
"err",
"=... | Handle network errors
@param {Error} err | [
"Handle",
"network",
"errors"
] | 46a3a950107b904825195b2a6645d9db5a3dd5bd | https://github.com/nullivex/oose-sdk/blob/46a3a950107b904825195b2a6645d9db5a3dd5bd/helpers/api.js#L102-L124 | train | |
nullivex/oose-sdk | helpers/api.js | function(type,options){
var cacheKey = type + ':' + options.host + ':' + options.port
if(!cache[cacheKey]){
debug('cache miss',cacheKey)
var reqDefaults = {
rejectUnauthorized: false,
json: true,
timeout:
+process.env.REQUEST_TIMEOUT ||
+options.timeout ||
214748364... | javascript | function(type,options){
var cacheKey = type + ':' + options.host + ':' + options.port
if(!cache[cacheKey]){
debug('cache miss',cacheKey)
var reqDefaults = {
rejectUnauthorized: false,
json: true,
timeout:
+process.env.REQUEST_TIMEOUT ||
+options.timeout ||
214748364... | [
"function",
"(",
"type",
",",
"options",
")",
"{",
"var",
"cacheKey",
"=",
"type",
"+",
"':'",
"+",
"options",
".",
"host",
"+",
"':'",
"+",
"options",
".",
"port",
"if",
"(",
"!",
"cache",
"[",
"cacheKey",
"]",
")",
"{",
"debug",
"(",
"'cache miss... | Setup a new request object
@param {string} type
@param {object} options
@return {request} | [
"Setup",
"a",
"new",
"request",
"object"
] | 46a3a950107b904825195b2a6645d9db5a3dd5bd | https://github.com/nullivex/oose-sdk/blob/46a3a950107b904825195b2a6645d9db5a3dd5bd/helpers/api.js#L151-L184 | train | |
Vanessa219/gulp-header-license | index.js | isMatch | function isMatch(file, license, rate, srcNLReg) {
var srcLines = file.contents.toString('utf8').split(/\r?\n/),
templateLines = license.split(/\r?\n/),
type = path.extname(file.path),
matchRates = 0,
removed = false;
// after '<?php' has n... | javascript | function isMatch(file, license, rate, srcNLReg) {
var srcLines = file.contents.toString('utf8').split(/\r?\n/),
templateLines = license.split(/\r?\n/),
type = path.extname(file.path),
matchRates = 0,
removed = false;
// after '<?php' has n... | [
"function",
"isMatch",
"(",
"file",
",",
"license",
",",
"rate",
",",
"srcNLReg",
")",
"{",
"var",
"srcLines",
"=",
"file",
".",
"contents",
".",
"toString",
"(",
"'utf8'",
")",
".",
"split",
"(",
"/",
"\\r?\\n",
"/",
")",
",",
"templateLines",
"=",
... | According to rate, get matching.
@param {object} file nodeJS file object.
@param {string} license The license template string.
@param {float} rate Matching rate.
@param {string} srcNLReg new line char code.
@returns {boolean} dose match. | [
"According",
"to",
"rate",
"get",
"matching",
"."
] | 41e5287a7a58aab7f1799d916d8c0ccaf3353358 | https://github.com/Vanessa219/gulp-header-license/blob/41e5287a7a58aab7f1799d916d8c0ccaf3353358/index.js#L39-L104 | train |
Vanessa219/gulp-header-license | index.js | getMatchRate | function getMatchRate(src, str) {
if (typeof (src) === 'undefined' || typeof (str) === 'undefined') {
return 0;
}
var maxLength = src.length > str.length ? src.length : str.length,
matchCnt = 0;
if (maxLength === 0) {
return 1;
}
... | javascript | function getMatchRate(src, str) {
if (typeof (src) === 'undefined' || typeof (str) === 'undefined') {
return 0;
}
var maxLength = src.length > str.length ? src.length : str.length,
matchCnt = 0;
if (maxLength === 0) {
return 1;
}
... | [
"function",
"getMatchRate",
"(",
"src",
",",
"str",
")",
"{",
"if",
"(",
"typeof",
"(",
"src",
")",
"===",
"'undefined'",
"||",
"typeof",
"(",
"str",
")",
"===",
"'undefined'",
")",
"{",
"return",
"0",
";",
"}",
"var",
"maxLength",
"=",
"src",
".",
... | Compare each character for ever line, and get ever line match rate.
@param {type} src text for template.
@param {type} str text for file.
@returns {float} match rate. | [
"Compare",
"each",
"character",
"for",
"ever",
"line",
"and",
"get",
"ever",
"line",
"match",
"rate",
"."
] | 41e5287a7a58aab7f1799d916d8c0ccaf3353358 | https://github.com/Vanessa219/gulp-header-license/blob/41e5287a7a58aab7f1799d916d8c0ccaf3353358/index.js#L113-L135 | train |
Vanessa219/gulp-header-license | index.js | getSeparator | function getSeparator(str, str2) {
// 13 \r 10 \n
for (var i = str.length; i > -1; i--) {
if (str.charCodeAt(i) === 10) {
if (str.charCodeAt(i - 1) === 13) {
return '\r\n';
}
if (str.charCodeAt(i + 1) === 13) {
... | javascript | function getSeparator(str, str2) {
// 13 \r 10 \n
for (var i = str.length; i > -1; i--) {
if (str.charCodeAt(i) === 10) {
if (str.charCodeAt(i - 1) === 13) {
return '\r\n';
}
if (str.charCodeAt(i + 1) === 13) {
... | [
"function",
"getSeparator",
"(",
"str",
",",
"str2",
")",
"{",
"// 13 \\r 10 \\n",
"for",
"(",
"var",
"i",
"=",
"str",
".",
"length",
";",
"i",
">",
"-",
"1",
";",
"i",
"--",
")",
"{",
"if",
"(",
"str",
".",
"charCodeAt",
"(",
"i",
")",
"===",
... | Test first newline character and get newline character.
@param {type} str file content.
@returns {String} newline character. | [
"Test",
"first",
"newline",
"character",
"and",
"get",
"newline",
"character",
"."
] | 41e5287a7a58aab7f1799d916d8c0ccaf3353358 | https://github.com/Vanessa219/gulp-header-license/blob/41e5287a7a58aab7f1799d916d8c0ccaf3353358/index.js#L143-L190 | train |
joneit/extend-me | index.js | function(memberName) {
var parent = this.super;
do { parent = Object.getPrototypeOf(parent); } while (!parent.hasOwnProperty(memberName));
return parent && parent[memberName];
} | javascript | function(memberName) {
var parent = this.super;
do { parent = Object.getPrototypeOf(parent); } while (!parent.hasOwnProperty(memberName));
return parent && parent[memberName];
} | [
"function",
"(",
"memberName",
")",
"{",
"var",
"parent",
"=",
"this",
".",
"super",
";",
"do",
"{",
"parent",
"=",
"Object",
".",
"getPrototypeOf",
"(",
"parent",
")",
";",
"}",
"while",
"(",
"!",
"parent",
".",
"hasOwnProperty",
"(",
"memberName",
")... | Find member on prototype chain beginning with super class.
@param {string} memberName
@returns {undefined|*} `undefined` if not found; value otherwise. | [
"Find",
"member",
"on",
"prototype",
"chain",
"beginning",
"with",
"super",
"class",
"."
] | 727386ee29ab77ec0eb48bcc995dcd20b72ff091 | https://github.com/joneit/extend-me/blob/727386ee29ab77ec0eb48bcc995dcd20b72ff091/index.js#L146-L150 | train | |
SwirlNetworks/discus | src/super.js | findSuper | function findSuper(methodName, childObject) {
var object = childObject;
while (object[methodName] === childObject[methodName]) {
object = object.constructor.__super__;
if (!object) {
throw new Error('Class has no super method for', methodName, '. Remove the _super call to the non-existent method');
}
}
re... | javascript | function findSuper(methodName, childObject) {
var object = childObject;
while (object[methodName] === childObject[methodName]) {
object = object.constructor.__super__;
if (!object) {
throw new Error('Class has no super method for', methodName, '. Remove the _super call to the non-existent method');
}
}
re... | [
"function",
"findSuper",
"(",
"methodName",
",",
"childObject",
")",
"{",
"var",
"object",
"=",
"childObject",
";",
"while",
"(",
"object",
"[",
"methodName",
"]",
"===",
"childObject",
"[",
"methodName",
"]",
")",
"{",
"object",
"=",
"object",
".",
"const... | Find the next object up the prototype chain that has a different implementation of the method. | [
"Find",
"the",
"next",
"object",
"up",
"the",
"prototype",
"chain",
"that",
"has",
"a",
"different",
"implementation",
"of",
"the",
"method",
"."
] | 79df8de5ec268879e50ec1e12e78b62a13b4a427 | https://github.com/SwirlNetworks/discus/blob/79df8de5ec268879e50ec1e12e78b62a13b4a427/src/super.js#L5-L15 | train |
teabyii/qa | lib/index.js | prompt | function prompt (config) {
const controller = new Controller()
return controller
.prompt(config)
.then(function (answer) {
controller.destroy()
return answer
})
} | javascript | function prompt (config) {
const controller = new Controller()
return controller
.prompt(config)
.then(function (answer) {
controller.destroy()
return answer
})
} | [
"function",
"prompt",
"(",
"config",
")",
"{",
"const",
"controller",
"=",
"new",
"Controller",
"(",
")",
"return",
"controller",
".",
"prompt",
"(",
"config",
")",
".",
"then",
"(",
"function",
"(",
"answer",
")",
"{",
"controller",
".",
"destroy",
"(",... | Prompt use not in `qa`, provide new constroller to take.
@param {Object} config
@returns {Promise} | [
"Prompt",
"use",
"not",
"in",
"qa",
"provide",
"new",
"constroller",
"to",
"take",
"."
] | 9224180dcb9e6b57c021f83b259316e84ebc573e | https://github.com/teabyii/qa/blob/9224180dcb9e6b57c021f83b259316e84ebc573e/lib/index.js#L10-L18 | train |
teabyii/qa | lib/index.js | function (gen) {
var main = co.wrap(gen)
const controller = new Controller()
function finish () {
controller.destroy()
return controller.answers
}
function error (error) {
console.error(error.stack)
}
return main(function (config) {
return controller.prompt(config)
}, register).... | javascript | function (gen) {
var main = co.wrap(gen)
const controller = new Controller()
function finish () {
controller.destroy()
return controller.answers
}
function error (error) {
console.error(error.stack)
}
return main(function (config) {
return controller.prompt(config)
}, register).... | [
"function",
"(",
"gen",
")",
"{",
"var",
"main",
"=",
"co",
".",
"wrap",
"(",
"gen",
")",
"const",
"controller",
"=",
"new",
"Controller",
"(",
")",
"function",
"finish",
"(",
")",
"{",
"controller",
".",
"destroy",
"(",
")",
"return",
"controller",
... | Method to run a generator for interative command line program.
@param {Generator} gen The generator to put program.
@returns {Promise} The Promise to end program and take answers. | [
"Method",
"to",
"run",
"a",
"generator",
"for",
"interative",
"command",
"line",
"program",
"."
] | 9224180dcb9e6b57c021f83b259316e84ebc573e | https://github.com/teabyii/qa/blob/9224180dcb9e6b57c021f83b259316e84ebc573e/lib/index.js#L37-L53 | train | |
fczbkk/style-properties | src/parse-property-value.js | convertColorComponent | function convertColorComponent (input) {
let result = input.toString(16);
if (result.length < 2) {
result = '0' + result
}
return result;
} | javascript | function convertColorComponent (input) {
let result = input.toString(16);
if (result.length < 2) {
result = '0' + result
}
return result;
} | [
"function",
"convertColorComponent",
"(",
"input",
")",
"{",
"let",
"result",
"=",
"input",
".",
"toString",
"(",
"16",
")",
";",
"if",
"(",
"result",
".",
"length",
"<",
"2",
")",
"{",
"result",
"=",
"'0'",
"+",
"result",
"}",
"return",
"result",
";... | converts number in base 10 to base 16, adds padding zero if needed | [
"converts",
"number",
"in",
"base",
"10",
"to",
"base",
"16",
"adds",
"padding",
"zero",
"if",
"needed"
] | d4e7b271001c0cd555534eb4a3bfde7795c58eed | https://github.com/fczbkk/style-properties/blob/d4e7b271001c0cd555534eb4a3bfde7795c58eed/src/parse-property-value.js#L6-L12 | train |
liuhaixia888/fis-parser-less-px2rem | index.js | function(s1, s2, s5, val){
return s1 ?
[s1 + s2 + val, 'px' + s5].join(''):
[s2 + val, 'px' + s5].join('');
} | javascript | function(s1, s2, s5, val){
return s1 ?
[s1 + s2 + val, 'px' + s5].join(''):
[s2 + val, 'px' + s5].join('');
} | [
"function",
"(",
"s1",
",",
"s2",
",",
"s5",
",",
"val",
")",
"{",
"return",
"s1",
"?",
"[",
"s1",
"+",
"s2",
"+",
"val",
",",
"'px'",
"+",
"s5",
"]",
".",
"join",
"(",
"''",
")",
":",
"[",
"s2",
"+",
"val",
",",
"'px'",
"+",
"s5",
"]",
... | REM => PX | [
"REM",
"=",
">",
"PX"
] | b56011a0749e607828c3a04e0b846fe727a8b18f | https://github.com/liuhaixia888/fis-parser-less-px2rem/blob/b56011a0749e607828c3a04e0b846fe727a8b18f/index.js#L24-L28 | train | |
carrascoMDD/protractor-relaunchable | lib/taskScheduler.js | function(capability, specLists) {
this.capability = capability;
this.numRunningInstances = 0;
this.maxInstance = capability.maxInstances || 1;
this.specsIndex = 0;
this.specLists = specLists;
} | javascript | function(capability, specLists) {
this.capability = capability;
this.numRunningInstances = 0;
this.maxInstance = capability.maxInstances || 1;
this.specsIndex = 0;
this.specLists = specLists;
} | [
"function",
"(",
"capability",
",",
"specLists",
")",
"{",
"this",
".",
"capability",
"=",
"capability",
";",
"this",
".",
"numRunningInstances",
"=",
"0",
";",
"this",
".",
"maxInstance",
"=",
"capability",
".",
"maxInstances",
"||",
"1",
";",
"this",
"."... | A queue of specs for a particular capacity | [
"A",
"queue",
"of",
"specs",
"for",
"a",
"particular",
"capacity"
] | c18e17ecd8b5b036217f87680800c6e14b47361f | https://github.com/carrascoMDD/protractor-relaunchable/blob/c18e17ecd8b5b036217f87680800c6e14b47361f/lib/taskScheduler.js#L10-L16 | train | |
MRN-Code/decentralized-laplacian-ridge-regression | src/local.js | addBias | function addBias(arr) {
if (!Array.isArray(arr) || !arr.length) {
throw new Error(`Expected ${arr} to be an array with length`);
} else if (!arr.every(Array.isArray)) {
throw new Error(`Expected every item of ${arr} to be an array`);
}
return arr.map(row => [1].concat(row));
} | javascript | function addBias(arr) {
if (!Array.isArray(arr) || !arr.length) {
throw new Error(`Expected ${arr} to be an array with length`);
} else if (!arr.every(Array.isArray)) {
throw new Error(`Expected every item of ${arr} to be an array`);
}
return arr.map(row => [1].concat(row));
} | [
"function",
"addBias",
"(",
"arr",
")",
"{",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"arr",
")",
"||",
"!",
"arr",
".",
"length",
")",
"{",
"throw",
"new",
"Error",
"(",
"`",
"${",
"arr",
"}",
"`",
")",
";",
"}",
"else",
"if",
"(",
"!",... | Add bias.
@param {?} A
@returns {Array} | [
"Add",
"bias",
"."
] | 38fbd789c90d0b6b7e320cca735b51c246179f3b | https://github.com/MRN-Code/decentralized-laplacian-ridge-regression/blob/38fbd789c90d0b6b7e320cca735b51c246179f3b/src/local.js#L16-L24 | train |
MRN-Code/decentralized-laplacian-ridge-regression | src/local.js | getNormalizedTags | function getNormalizedTags(tags) {
return Object.keys(tags).sort().reduce((memo, tag) => {
const value = tags[tag];
if (typeof value === 'boolean') {
return memo.concat(value === true ? 1 : -1);
} else if (typeof value === 'number') {
return memo.concat(value);
}
return memo;
}, []... | javascript | function getNormalizedTags(tags) {
return Object.keys(tags).sort().reduce((memo, tag) => {
const value = tags[tag];
if (typeof value === 'boolean') {
return memo.concat(value === true ? 1 : -1);
} else if (typeof value === 'number') {
return memo.concat(value);
}
return memo;
}, []... | [
"function",
"getNormalizedTags",
"(",
"tags",
")",
"{",
"return",
"Object",
".",
"keys",
"(",
"tags",
")",
".",
"sort",
"(",
")",
".",
"reduce",
"(",
"(",
"memo",
",",
"tag",
")",
"=>",
"{",
"const",
"value",
"=",
"tags",
"[",
"tag",
"]",
";",
"i... | Get normalized co-variate values.
@todo This ignores non-numeric and non-boolean tag values. Determine
an effective way to map strings and non-primitives to numbers.
@param {Object} tags Hash of tag names to tag values
@returns {Array} | [
"Get",
"normalized",
"co",
"-",
"variate",
"values",
"."
] | 38fbd789c90d0b6b7e320cca735b51c246179f3b | https://github.com/MRN-Code/decentralized-laplacian-ridge-regression/blob/38fbd789c90d0b6b7e320cca735b51c246179f3b/src/local.js#L35-L47 | train |
tanem/stweam | lib/stweam.js | Stweam | function Stweam(opts) {
stream.Transform.call(this);
opts = opts || {};
if (!opts.consumerKey) throw new Error('consumer key is required');
if (!opts.consumerSecret) throw new Error('consumer secret is required');
if (!opts.token) throw new Error('token is required');
if (!opts.tokenSecret) throw new Error(... | javascript | function Stweam(opts) {
stream.Transform.call(this);
opts = opts || {};
if (!opts.consumerKey) throw new Error('consumer key is required');
if (!opts.consumerSecret) throw new Error('consumer secret is required');
if (!opts.token) throw new Error('token is required');
if (!opts.tokenSecret) throw new Error(... | [
"function",
"Stweam",
"(",
"opts",
")",
"{",
"stream",
".",
"Transform",
".",
"call",
"(",
"this",
")",
";",
"opts",
"=",
"opts",
"||",
"{",
"}",
";",
"if",
"(",
"!",
"opts",
".",
"consumerKey",
")",
"throw",
"new",
"Error",
"(",
"'consumer key is re... | Initialise a new `Stweam` with the given `opts`.
@param {String} opts.consumerKey
@param {String} opts.consumerSecret
@param {String} opts.token
@param {String} opts.tokenSecret
@api public | [
"Initialise",
"a",
"new",
"Stweam",
"with",
"the",
"given",
"opts",
"."
] | 287469074655f7a120684b121876b470525bf963 | https://github.com/tanem/stweam/blob/287469074655f7a120684b121876b470525bf963/lib/stweam.js#L22-L37 | train |
azendal/argon | argon/model.js | all | function all(callback) {
var Model = this;
var request = {
find : 'find',
model : Model
};
this.dispatch('beforeAll');
this.storage.find(request, function findCallback(data) {
if (callback) {
callback(data);
... | javascript | function all(callback) {
var Model = this;
var request = {
find : 'find',
model : Model
};
this.dispatch('beforeAll');
this.storage.find(request, function findCallback(data) {
if (callback) {
callback(data);
... | [
"function",
"all",
"(",
"callback",
")",
"{",
"var",
"Model",
"=",
"this",
";",
"var",
"request",
"=",
"{",
"find",
":",
"'find'",
",",
"model",
":",
"Model",
"}",
";",
"this",
".",
"dispatch",
"(",
"'beforeAll'",
")",
";",
"this",
".",
"storage",
... | Fetches all records of a given Model and creates the instances.
@method all <public, static>
@argument callback <optional> [Function] method to handle data.
@return [Argon.Model]. | [
"Fetches",
"all",
"records",
"of",
"a",
"given",
"Model",
"and",
"creates",
"the",
"instances",
"."
] | 0cfd3a3b3731b69abca55c956c757476779ec1bd | https://github.com/azendal/argon/blob/0cfd3a3b3731b69abca55c956c757476779ec1bd/argon/model.js#L24-L40 | train |
azendal/argon | argon/model.js | find | function find(id, callback) {
var Model, request;
Model = this;
request = {
action : 'findOne',
model : Model,
params : {
id : id
}
};
this.storage.findOne(request, function findOneCallback(data) {
if (c... | javascript | function find(id, callback) {
var Model, request;
Model = this;
request = {
action : 'findOne',
model : Model,
params : {
id : id
}
};
this.storage.findOne(request, function findOneCallback(data) {
if (c... | [
"function",
"find",
"(",
"id",
",",
"callback",
")",
"{",
"var",
"Model",
",",
"request",
";",
"Model",
"=",
"this",
";",
"request",
"=",
"{",
"action",
":",
"'findOne'",
",",
"model",
":",
"Model",
",",
"params",
":",
"{",
"id",
":",
"id",
"}",
... | Fetches one record of a given Model and creates the instance.
@method find <public, static>
@argument id <required> [Object] the id of the record.
@argument callback <optional> [Function] method to handle data.
@return [Argon.Model]. | [
"Fetches",
"one",
"record",
"of",
"a",
"given",
"Model",
"and",
"creates",
"the",
"instance",
"."
] | 0cfd3a3b3731b69abca55c956c757476779ec1bd | https://github.com/azendal/argon/blob/0cfd3a3b3731b69abca55c956c757476779ec1bd/argon/model.js#L49-L66 | train |
azendal/argon | argon/model.js | init | function init(properties) {
this.eventListeners = [];
if (typeof properties !== 'undefined') {
Object.keys(properties).forEach(function (property) {
this[property] = properties[property];
}, this);
}
return this;
... | javascript | function init(properties) {
this.eventListeners = [];
if (typeof properties !== 'undefined') {
Object.keys(properties).forEach(function (property) {
this[property] = properties[property];
}, this);
}
return this;
... | [
"function",
"init",
"(",
"properties",
")",
"{",
"this",
".",
"eventListeners",
"=",
"[",
"]",
";",
"if",
"(",
"typeof",
"properties",
"!==",
"'undefined'",
")",
"{",
"Object",
".",
"keys",
"(",
"properties",
")",
".",
"forEach",
"(",
"function",
"(",
... | Object initializer, this method server as the real constructor
@method init <public>
@argument properties <optional> [Object] ({}) the attributes for the model isntance | [
"Object",
"initializer",
"this",
"method",
"server",
"as",
"the",
"real",
"constructor"
] | 0cfd3a3b3731b69abca55c956c757476779ec1bd | https://github.com/azendal/argon/blob/0cfd3a3b3731b69abca55c956c757476779ec1bd/argon/model.js#L75-L85 | train |
azendal/argon | argon/model.js | setProperty | function setProperty(property, newValue) {
var originalValue;
if (newValue != originalValue) {
originalValue = this[property];
this[property] = newValue;
this.dispatch('change:' + property, {
originalValue : originalValue,
... | javascript | function setProperty(property, newValue) {
var originalValue;
if (newValue != originalValue) {
originalValue = this[property];
this[property] = newValue;
this.dispatch('change:' + property, {
originalValue : originalValue,
... | [
"function",
"setProperty",
"(",
"property",
",",
"newValue",
")",
"{",
"var",
"originalValue",
";",
"if",
"(",
"newValue",
"!=",
"originalValue",
")",
"{",
"originalValue",
"=",
"this",
"[",
"property",
"]",
";",
"this",
"[",
"property",
"]",
"=",
"newValu... | Sets the value of a property.
@method setProperty <public>
@argument property <required> [String] the property to write.
@argument newValue <required> [String] the value for the property.
@return [Object] instance of the model. | [
"Sets",
"the",
"value",
"of",
"a",
"property",
"."
] | 0cfd3a3b3731b69abca55c956c757476779ec1bd | https://github.com/azendal/argon/blob/0cfd3a3b3731b69abca55c956c757476779ec1bd/argon/model.js#L104-L118 | train |
azendal/argon | argon/model.js | save | function save(callback) {
var model, request;
model = this;
this.constructor.dispatch('beforeSave', {
data : {
model : this
}
});
this.dispatch('beforeSave');
this.isValid(function (isValid) {
... | javascript | function save(callback) {
var model, request;
model = this;
this.constructor.dispatch('beforeSave', {
data : {
model : this
}
});
this.dispatch('beforeSave');
this.isValid(function (isValid) {
... | [
"function",
"save",
"(",
"callback",
")",
"{",
"var",
"model",
",",
"request",
";",
"model",
"=",
"this",
";",
"this",
".",
"constructor",
".",
"dispatch",
"(",
"'beforeSave'",
",",
"{",
"data",
":",
"{",
"model",
":",
"this",
"}",
"}",
")",
";",
"... | Saves the model to storage.
@method save <public>
@argument callback <required> [Function] function to manage response.
@return Noting. | [
"Saves",
"the",
"model",
"to",
"storage",
"."
] | 0cfd3a3b3731b69abca55c956c757476779ec1bd | https://github.com/azendal/argon/blob/0cfd3a3b3731b69abca55c956c757476779ec1bd/argon/model.js#L126-L185 | train |
azendal/argon | argon/model.js | destroy | function destroy(callback) {
var model = this;
var request = {
action : 'remove',
model : model.constructor,
data : this
};
this.dispatch('beforeDestroy');
this.constructor.storage.remove(request, function destr... | javascript | function destroy(callback) {
var model = this;
var request = {
action : 'remove',
model : model.constructor,
data : this
};
this.dispatch('beforeDestroy');
this.constructor.storage.remove(request, function destr... | [
"function",
"destroy",
"(",
"callback",
")",
"{",
"var",
"model",
"=",
"this",
";",
"var",
"request",
"=",
"{",
"action",
":",
"'remove'",
",",
"model",
":",
"model",
".",
"constructor",
",",
"data",
":",
"this",
"}",
";",
"this",
".",
"dispatch",
"(... | Removes a record from storage.
@method destroy <public>
@argument callback [Function] function to manage response.
@return Noting. | [
"Removes",
"a",
"record",
"from",
"storage",
"."
] | 0cfd3a3b3731b69abca55c956c757476779ec1bd | https://github.com/azendal/argon/blob/0cfd3a3b3731b69abca55c956c757476779ec1bd/argon/model.js#L193-L209 | train |
sebv/mocha-bdd-with-opts | common.js | function(mocha, test) {
test.parent._onlyTests = test.parent._onlyTests.concat(test);
mocha.options.hasOnly = true;
return test;
} | javascript | function(mocha, test) {
test.parent._onlyTests = test.parent._onlyTests.concat(test);
mocha.options.hasOnly = true;
return test;
} | [
"function",
"(",
"mocha",
",",
"test",
")",
"{",
"test",
".",
"parent",
".",
"_onlyTests",
"=",
"test",
".",
"parent",
".",
"_onlyTests",
".",
"concat",
"(",
"test",
")",
";",
"mocha",
".",
"options",
".",
"hasOnly",
"=",
"true",
";",
"return",
"test... | Exclusive test-case.
@param {Object} mocha
@param {Function} test
@returns {*} | [
"Exclusive",
"test",
"-",
"case",
"."
] | bc15bb96aa2ebda5b4427f8729b4e1cc5da69396 | https://github.com/sebv/mocha-bdd-with-opts/blob/bc15bb96aa2ebda5b4427f8729b4e1cc5da69396/common.js#L139-L143 | train | |
cirocosta/yaspm | src/Machines.js | Machines | function Machines (sigTerm) {
if (!(this instanceof Machines))
return new Machines(sigTerm);
this._sigTerm = sigTerm;
this._devices = {};
EventEmitter.call(this);
} | javascript | function Machines (sigTerm) {
if (!(this instanceof Machines))
return new Machines(sigTerm);
this._sigTerm = sigTerm;
this._devices = {};
EventEmitter.call(this);
} | [
"function",
"Machines",
"(",
"sigTerm",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Machines",
")",
")",
"return",
"new",
"Machines",
"(",
"sigTerm",
")",
";",
"this",
".",
"_sigTerm",
"=",
"sigTerm",
";",
"this",
".",
"_devices",
"=",
"{",
... | Describes the conjunction of machines to
search for.
emits:
- removeddevice,
- device,
- invaliddevice,
- validdevice.
@param {string} sigTerm signature string to
match. | [
"Describes",
"the",
"conjunction",
"of",
"machines",
"to",
"search",
"for",
"."
] | 676524906425ba99b1e6f95a75ce4a82501a0ee9 | https://github.com/cirocosta/yaspm/blob/676524906425ba99b1e6f95a75ce4a82501a0ee9/src/Machines.js#L24-L32 | train |
deanlandolt/bytespace | index.js | addHook | function addHook(hooks, hook) {
hooks.push(hook)
return function () {
var i = hooks.indexOf(hook)
if (i >= 0) return hooks.splice(i, 1)
}
} | javascript | function addHook(hooks, hook) {
hooks.push(hook)
return function () {
var i = hooks.indexOf(hook)
if (i >= 0) return hooks.splice(i, 1)
}
} | [
"function",
"addHook",
"(",
"hooks",
",",
"hook",
")",
"{",
"hooks",
".",
"push",
"(",
"hook",
")",
"return",
"function",
"(",
")",
"{",
"var",
"i",
"=",
"hooks",
".",
"indexOf",
"(",
"hook",
")",
"if",
"(",
"i",
">=",
"0",
")",
"return",
"hooks"... | helper to register pre and post commit hooks | [
"helper",
"to",
"register",
"pre",
"and",
"post",
"commit",
"hooks"
] | 3d3b92d5a8999eedf766fea62bfa7f5643fd467d | https://github.com/deanlandolt/bytespace/blob/3d3b92d5a8999eedf766fea62bfa7f5643fd467d/index.js#L150-L156 | train |
deanlandolt/bytespace | index.js | decodeStream | function decodeStream(opts) {
opts || (opts = {})
var stream = Transform({ objectMode: true })
stream._transform = function (data, _, cb) {
try {
// decode keys even when keys or values aren't requested specifically
if ((opts.keys && opts.values) || (!opts.keys && !opts.values)) {
... | javascript | function decodeStream(opts) {
opts || (opts = {})
var stream = Transform({ objectMode: true })
stream._transform = function (data, _, cb) {
try {
// decode keys even when keys or values aren't requested specifically
if ((opts.keys && opts.values) || (!opts.keys && !opts.values)) {
... | [
"function",
"decodeStream",
"(",
"opts",
")",
"{",
"opts",
"||",
"(",
"opts",
"=",
"{",
"}",
")",
"var",
"stream",
"=",
"Transform",
"(",
"{",
"objectMode",
":",
"true",
"}",
")",
"stream",
".",
"_transform",
"=",
"function",
"(",
"data",
",",
"_",
... | transform stream to decode data keys | [
"transform",
"stream",
"to",
"decode",
"data",
"keys"
] | 3d3b92d5a8999eedf766fea62bfa7f5643fd467d | https://github.com/deanlandolt/bytespace/blob/3d3b92d5a8999eedf766fea62bfa7f5643fd467d/index.js#L284-L305 | train |
Irrelon/overload | Overload.js | function (def) {
if (def) {
var self = this,
index,
count,
tmpDef,
defNewKey,
sigIndex,
signatures;
if (!(def instanceof Array)) {
tmpDef = {};
// Def is an object, make sure all prop names are devoid of spaces
for (index in def) {
if (def.hasOwnProperty(index)) {
defNewKey = ... | javascript | function (def) {
if (def) {
var self = this,
index,
count,
tmpDef,
defNewKey,
sigIndex,
signatures;
if (!(def instanceof Array)) {
tmpDef = {};
// Def is an object, make sure all prop names are devoid of spaces
for (index in def) {
if (def.hasOwnProperty(index)) {
defNewKey = ... | [
"function",
"(",
"def",
")",
"{",
"if",
"(",
"def",
")",
"{",
"var",
"self",
"=",
"this",
",",
"index",
",",
"count",
",",
"tmpDef",
",",
"defNewKey",
",",
"sigIndex",
",",
"signatures",
";",
"if",
"(",
"!",
"(",
"def",
"instanceof",
"Array",
")",
... | Allows a method to accept overloaded calls with different parameters controlling
which passed overload function is called.
@param {Object} def
@returns {Function}
@constructor | [
"Allows",
"a",
"method",
"to",
"accept",
"overloaded",
"calls",
"with",
"different",
"parameters",
"controlling",
"which",
"passed",
"overload",
"function",
"is",
"called",
"."
] | cfa76f0e2c1112938c27364c031dae8d530183b8 | https://github.com/Irrelon/overload/blob/cfa76f0e2c1112938c27364c031dae8d530183b8/Overload.js#L10-L106 | train | |
hammy2899/circle-assign | src/internals.js | mergeObject | function mergeObject(target, source) {
// create a variable to hold the target object
// so it can be changed if its not an object
let targetObject = target;
let sourceObject = source;
if (!isObj(target)) {
targetObject = {};
}
if (!isObj(source)) {
sourceObject = {};
}
// get the object ke... | javascript | function mergeObject(target, source) {
// create a variable to hold the target object
// so it can be changed if its not an object
let targetObject = target;
let sourceObject = source;
if (!isObj(target)) {
targetObject = {};
}
if (!isObj(source)) {
sourceObject = {};
}
// get the object ke... | [
"function",
"mergeObject",
"(",
"target",
",",
"source",
")",
"{",
"// create a variable to hold the target object",
"// so it can be changed if its not an object",
"let",
"targetObject",
"=",
"target",
";",
"let",
"sourceObject",
"=",
"source",
";",
"if",
"(",
"!",
"is... | Merge the specified source object into the target object
@param {Object} target The base target object
@param {Object} source The object to merge into the target
@returns {Object} The merged object | [
"Merge",
"the",
"specified",
"source",
"object",
"into",
"the",
"target",
"object"
] | 4eb202021279b789ce758b3feae2417eb7f2ded5 | https://github.com/hammy2899/circle-assign/blob/4eb202021279b789ce758b3feae2417eb7f2ded5/src/internals.js#L21-L88 | train |
coolony/inverter | inverter.js | function(str){
return str.replace(BORDER_RADIUS_RE,
function(){
var ret = 'border-radius' + arguments[1]
+ ':'
+ arguments[2]
+ reorderBorderRadius(arguments[3],
... | javascript | function(str){
return str.replace(BORDER_RADIUS_RE,
function(){
var ret = 'border-radius' + arguments[1]
+ ':'
+ arguments[2]
+ reorderBorderRadius(arguments[3],
... | [
"function",
"(",
"str",
")",
"{",
"return",
"str",
".",
"replace",
"(",
"BORDER_RADIUS_RE",
",",
"function",
"(",
")",
"{",
"var",
"ret",
"=",
"'border-radius'",
"+",
"arguments",
"[",
"1",
"]",
"+",
"':'",
"+",
"arguments",
"[",
"2",
"]",
"+",
"reor... | Fixes border radius This case is special because of the particularities of border-radius | [
"Fixes",
"border",
"radius",
"This",
"case",
"is",
"special",
"because",
"of",
"the",
"particularities",
"of",
"border",
"-",
"radius"
] | 77224da8675c36fd30fea88f4698f7e43674f83c | https://github.com/coolony/inverter/blob/77224da8675c36fd30fea88f4698f7e43674f83c/inverter.js#L113-L132 | train | |
coolony/inverter | inverter.js | invert | function invert(str, options){
if(!options) options = {};
if(!options.exclude) options.exclude = [];
for(var rule in rules) {
// Pass excluded rules
if(options.exclude.indexOf(rule) != -1) continue;
// Run rule
str = rules[rule](str, options);
}
return str;
} | javascript | function invert(str, options){
if(!options) options = {};
if(!options.exclude) options.exclude = [];
for(var rule in rules) {
// Pass excluded rules
if(options.exclude.indexOf(rule) != -1) continue;
// Run rule
str = rules[rule](str, options);
}
return str;
} | [
"function",
"invert",
"(",
"str",
",",
"options",
")",
"{",
"if",
"(",
"!",
"options",
")",
"options",
"=",
"{",
"}",
";",
"if",
"(",
"!",
"options",
".",
"exclude",
")",
"options",
".",
"exclude",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"rule",
... | Inverts a CSS string
@param {String} str CSS string
@param {Object} options (Optional)
@return {String} Inverted CSS
@api public | [
"Inverts",
"a",
"CSS",
"string"
] | 77224da8675c36fd30fea88f4698f7e43674f83c | https://github.com/coolony/inverter/blob/77224da8675c36fd30fea88f4698f7e43674f83c/inverter.js#L182-L199 | train |
coolony/inverter | inverter.js | reorderBorderRadius | function reorderBorderRadius(p1, p2, p3, p4){
if(p4)
return [p2, p1, p4, p3].join(' ');
if(p3)
return [p2, p1, p2, p3].join(' ');
if(p2)
return [p2, p1].join(' ');
else
return p1;
} | javascript | function reorderBorderRadius(p1, p2, p3, p4){
if(p4)
return [p2, p1, p4, p3].join(' ');
if(p3)
return [p2, p1, p2, p3].join(' ');
if(p2)
return [p2, p1].join(' ');
else
return p1;
} | [
"function",
"reorderBorderRadius",
"(",
"p1",
",",
"p2",
",",
"p3",
",",
"p4",
")",
"{",
"if",
"(",
"p4",
")",
"return",
"[",
"p2",
",",
"p1",
",",
"p4",
",",
"p3",
"]",
".",
"join",
"(",
"' '",
")",
";",
"if",
"(",
"p3",
")",
"return",
"[",
... | Reorders border radius values for opposite direction
reorderBorderRadius(A, B, C, D) -> 'B A D C'
reorderBorderRadius(A, B, C) -> 'B A B C'
reorderBorderRadius(A, B) -> 'B A'
reorderBorderRadius(A) -> 'A'
@param {String} p1 First element
@param {String} p2 (Optional) Second element
@param {String} p3 (Optional) Third... | [
"Reorders",
"border",
"radius",
"values",
"for",
"opposite",
"direction"
] | 77224da8675c36fd30fea88f4698f7e43674f83c | https://github.com/coolony/inverter/blob/77224da8675c36fd30fea88f4698f7e43674f83c/inverter.js#L218-L227 | train |
coolony/inverter | inverter.js | fixGradient | function fixGradient(str) {
var ret = str.replace(GRADIENT_REPLACE_RE, function($0, $1, $2){
return $1 ?
$0 :
($2 == 'right') ?
'left' :
($2 == 'left') ?
'right' :
(parseInt($2) % 180 == 0) ?
$2 :
($2.substr(0,1) == '-') ?
$2.su... | javascript | function fixGradient(str) {
var ret = str.replace(GRADIENT_REPLACE_RE, function($0, $1, $2){
return $1 ?
$0 :
($2 == 'right') ?
'left' :
($2 == 'left') ?
'right' :
(parseInt($2) % 180 == 0) ?
$2 :
($2.substr(0,1) == '-') ?
$2.su... | [
"function",
"fixGradient",
"(",
"str",
")",
"{",
"var",
"ret",
"=",
"str",
".",
"replace",
"(",
"GRADIENT_REPLACE_RE",
",",
"function",
"(",
"$0",
",",
"$1",
",",
"$2",
")",
"{",
"return",
"$1",
"?",
"$0",
":",
"(",
"$2",
"==",
"'right'",
")",
"?",... | Fixes most gradient definitions
Replaces `left` with `right`, `X(X(X))deg` to `-X(X(X))deg`, and the opposites
fixGradient("-webkit-gradient(linear, left bottom, right top, color-stop(0%,#000), color-stop(100%,#fff))")
-> "fixGradient("-webkit-gradient(linear, right bottom, left top, color-stop(0%,#000), color-stop(1... | [
"Fixes",
"most",
"gradient",
"definitions"
] | 77224da8675c36fd30fea88f4698f7e43674f83c | https://github.com/coolony/inverter/blob/77224da8675c36fd30fea88f4698f7e43674f83c/inverter.js#L241-L256 | train |
thlorenz/kodieren | kodieren.js | bitsToLayout | function bitsToLayout(bits) {
var idx = 0
const map = {}
for (const [ name, b ] of bits) {
const mask = maskForBits(b)
map[name] = [ idx, mask ]
idx += b
}
return map
} | javascript | function bitsToLayout(bits) {
var idx = 0
const map = {}
for (const [ name, b ] of bits) {
const mask = maskForBits(b)
map[name] = [ idx, mask ]
idx += b
}
return map
} | [
"function",
"bitsToLayout",
"(",
"bits",
")",
"{",
"var",
"idx",
"=",
"0",
"const",
"map",
"=",
"{",
"}",
"for",
"(",
"const",
"[",
"name",
",",
"b",
"]",
"of",
"bits",
")",
"{",
"const",
"mask",
"=",
"maskForBits",
"(",
"b",
")",
"map",
"[",
"... | Takes a table of properties with bit length and derives bit layout from it.
The bit layout is a hash map indexed by property name and each entry contains
the index of the property in the bit field and it's mask needed to isolate it.
### Example:
```
bitsToLayout([ [ 'foo', 2 ], [ 'bar', 4 ] ])
// => { foo: [ 0, 0b11 ... | [
"Takes",
"a",
"table",
"of",
"properties",
"with",
"bit",
"length",
"and",
"derives",
"bit",
"layout",
"from",
"it",
".",
"The",
"bit",
"layout",
"is",
"a",
"hash",
"map",
"indexed",
"by",
"property",
"name",
"and",
"each",
"entry",
"contains",
"the",
"i... | 2310ae3a8d38962deee8d0140092066f3bd1fbb3 | https://github.com/thlorenz/kodieren/blob/2310ae3a8d38962deee8d0140092066f3bd1fbb3/kodieren.js#L53-L62 | train |
insin/concur | examples/models.js | function(prototypeProps, constructorProps) {
if (typeof prototypeProps.Meta == 'undefined' ||
typeof prototypeProps.Meta.name == 'undefined') {
throw new Error('When extending Model, you must provide a name via a Meta object.')
}
var options = new ModelOptions(prototypeProps.Meta)
delete ... | javascript | function(prototypeProps, constructorProps) {
if (typeof prototypeProps.Meta == 'undefined' ||
typeof prototypeProps.Meta.name == 'undefined') {
throw new Error('When extending Model, you must provide a name via a Meta object.')
}
var options = new ModelOptions(prototypeProps.Meta)
delete ... | [
"function",
"(",
"prototypeProps",
",",
"constructorProps",
")",
"{",
"if",
"(",
"typeof",
"prototypeProps",
".",
"Meta",
"==",
"'undefined'",
"||",
"typeof",
"prototypeProps",
".",
"Meta",
".",
"name",
"==",
"'undefined'",
")",
"{",
"throw",
"new",
"Error",
... | Prepares a ModelOptions for the extended Model and places it in a
_meta property on the prototype and constructor. | [
"Prepares",
"a",
"ModelOptions",
"for",
"the",
"extended",
"Model",
"and",
"places",
"it",
"in",
"a",
"_meta",
"property",
"on",
"the",
"prototype",
"and",
"constructor",
"."
] | 86e816f1a0cb90ec227371bee065cc76e7234b7c | https://github.com/insin/concur/blob/86e816f1a0cb90ec227371bee065cc76e7234b7c/examples/models.js#L38-L59 | train | |
Tarrask/sails-generate-webpack-vue | vueAdapter.js | run | function run(cb) {
// check if template is local
if (/^[./]|(\w:)/.test(template)) {
var templatePath = template.charAt(0) === '/' || /^\w:/.test(template)
? template
: path.normalize(path.join(process.cwd(), template))
if (exists(templatePath)) {
generate(name, templatePath, to, cb)
}... | javascript | function run(cb) {
// check if template is local
if (/^[./]|(\w:)/.test(template)) {
var templatePath = template.charAt(0) === '/' || /^\w:/.test(template)
? template
: path.normalize(path.join(process.cwd(), template))
if (exists(templatePath)) {
generate(name, templatePath, to, cb)
}... | [
"function",
"run",
"(",
"cb",
")",
"{",
"// check if template is local",
"if",
"(",
"/",
"^[./]|(\\w:)",
"/",
".",
"test",
"(",
"template",
")",
")",
"{",
"var",
"templatePath",
"=",
"template",
".",
"charAt",
"(",
"0",
")",
"===",
"'/'",
"||",
"/",
"^... | Check, download and generate the project. | [
"Check",
"download",
"and",
"generate",
"the",
"project",
"."
] | 73f203bc8e3226edd13e21421adcddb938414eda | https://github.com/Tarrask/sails-generate-webpack-vue/blob/73f203bc8e3226edd13e21421adcddb938414eda/vueAdapter.js#L35-L67 | train |
Tarrask/sails-generate-webpack-vue | vueAdapter.js | downloadAndGenerate | function downloadAndGenerate (template, cb) {
var spinner = ora('downloading template')
spinner.start()
download(template, tmp, { clone: clone }, function (err) {
spinner.stop()
if (err) logger.fatal('Failed to download repo ' + template + ': ' + err.message.trim())
generate(name, tmp, to, cb)
})
} | javascript | function downloadAndGenerate (template, cb) {
var spinner = ora('downloading template')
spinner.start()
download(template, tmp, { clone: clone }, function (err) {
spinner.stop()
if (err) logger.fatal('Failed to download repo ' + template + ': ' + err.message.trim())
generate(name, tmp, to, cb)
})
} | [
"function",
"downloadAndGenerate",
"(",
"template",
",",
"cb",
")",
"{",
"var",
"spinner",
"=",
"ora",
"(",
"'downloading template'",
")",
"spinner",
".",
"start",
"(",
")",
"download",
"(",
"template",
",",
"tmp",
",",
"{",
"clone",
":",
"clone",
"}",
"... | Download a generate from a template repo.
@param {String} template | [
"Download",
"a",
"generate",
"from",
"a",
"template",
"repo",
"."
] | 73f203bc8e3226edd13e21421adcddb938414eda | https://github.com/Tarrask/sails-generate-webpack-vue/blob/73f203bc8e3226edd13e21421adcddb938414eda/vueAdapter.js#L75-L83 | train |
olivejs/olive | lib/actions/new.js | validateSeed | function validateSeed() {
return Q.Promise(function(resolve, reject) {
https.get('https://github.com/olivejs/seed-' + options.seed, function(res) {
if (res.statusCode === 200) {
resolve('>> seed exists');
} else {
reject(new Error('Invalid seed: ' + options.seed));
}
}).on('e... | javascript | function validateSeed() {
return Q.Promise(function(resolve, reject) {
https.get('https://github.com/olivejs/seed-' + options.seed, function(res) {
if (res.statusCode === 200) {
resolve('>> seed exists');
} else {
reject(new Error('Invalid seed: ' + options.seed));
}
}).on('e... | [
"function",
"validateSeed",
"(",
")",
"{",
"return",
"Q",
".",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"https",
".",
"get",
"(",
"'https://github.com/olivejs/seed-'",
"+",
"options",
".",
"seed",
",",
"function",
"(",
"res",
")... | Checks whether a seed exists
@param {String} seed Name of the seed
@return {Promise} | [
"Checks",
"whether",
"a",
"seed",
"exists"
] | ce7bd3fb4ef94d0b862276cbcee83b481ea23cef | https://github.com/olivejs/olive/blob/ce7bd3fb4ef94d0b862276cbcee83b481ea23cef/lib/actions/new.js#L17-L30 | train |
AndiDittrich/Node.mysql-magic | lib/pool-connection.js | exposeAPI | function exposeAPI(connection){
return {
query: function(stmt, params){
return _query(connection, stmt, params);
},
insert: function(table, data){
return _insert(connection, table, data);
},
fetchRow: function(stmt, params){
return _fet... | javascript | function exposeAPI(connection){
return {
query: function(stmt, params){
return _query(connection, stmt, params);
},
insert: function(table, data){
return _insert(connection, table, data);
},
fetchRow: function(stmt, params){
return _fet... | [
"function",
"exposeAPI",
"(",
"connection",
")",
"{",
"return",
"{",
"query",
":",
"function",
"(",
"stmt",
",",
"params",
")",
"{",
"return",
"_query",
"(",
"connection",
",",
"stmt",
",",
"params",
")",
";",
"}",
",",
"insert",
":",
"function",
"(",
... | expose async api wrapper | [
"expose",
"async",
"api",
"wrapper"
] | f9783ac93f4a5744407781d7875ae68cad58cc48 | https://github.com/AndiDittrich/Node.mysql-magic/blob/f9783ac93f4a5744407781d7875ae68cad58cc48/lib/pool-connection.js#L7-L30 | train |
robgietema/twist | public/libs/obviel/1.0b5/obviel-sync.js | function(config, defaults) {
var key, subdefaults, subconfig;
for (key in defaults) {
subdefaults = defaults[key];
subconfig = config[key];
if ($.isPlainObject(subdefaults)) {
if (!$.isPlainObject(subconfig)) {
subconfig = config... | javascript | function(config, defaults) {
var key, subdefaults, subconfig;
for (key in defaults) {
subdefaults = defaults[key];
subconfig = config[key];
if ($.isPlainObject(subdefaults)) {
if (!$.isPlainObject(subconfig)) {
subconfig = config... | [
"function",
"(",
"config",
",",
"defaults",
")",
"{",
"var",
"key",
",",
"subdefaults",
",",
"subconfig",
";",
"for",
"(",
"key",
"in",
"defaults",
")",
"{",
"subdefaults",
"=",
"defaults",
"[",
"key",
"]",
";",
"subconfig",
"=",
"config",
"[",
"key",
... | XXX maintain defaults with action? | [
"XXX",
"maintain",
"defaults",
"with",
"action?"
] | 7dc81080c6c28f34ad8e2334118ff416d2a004a0 | https://github.com/robgietema/twist/blob/7dc81080c6c28f34ad8e2334118ff416d2a004a0/public/libs/obviel/1.0b5/obviel-sync.js#L79-L98 | train | |
bitcoinnano/btcnano-wallet-service | bitcorenode/index.js | function(options) {
EventEmitter.call(this);
this.node = options.node;
this.https = options.https || this.node.https;
this.httpsOptions = options.httpsOptions || this.node.httpsOptions;
this.bwsPort = options.bwsPort || baseConfig.port;
this.messageBrokerPort = options.messageBrokerPort || 3380;
if (base... | javascript | function(options) {
EventEmitter.call(this);
this.node = options.node;
this.https = options.https || this.node.https;
this.httpsOptions = options.httpsOptions || this.node.httpsOptions;
this.bwsPort = options.bwsPort || baseConfig.port;
this.messageBrokerPort = options.messageBrokerPort || 3380;
if (base... | [
"function",
"(",
"options",
")",
"{",
"EventEmitter",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"node",
"=",
"options",
".",
"node",
";",
"this",
".",
"https",
"=",
"options",
".",
"https",
"||",
"this",
".",
"node",
".",
"https",
";",
"this... | A Bitcore Node Service module
@param {Object} options
@param {Node} options.node - A reference to the Bitcore Node instance
-* @param {Boolean} options.https - Enable https for this module, defaults to node settings.
@param {Number} options.bwsPort - Port for Bitcore Wallet Service API
@param {Number} options.messageBr... | [
"A",
"Bitcore",
"Node",
"Service",
"module"
] | cd69f5dc2cbfedbcaf4e379a2e1697a975c38eb2 | https://github.com/bitcoinnano/btcnano-wallet-service/blob/cd69f5dc2cbfedbcaf4e379a2e1697a975c38eb2/bitcorenode/index.js#L30-L42 | train | |
SolarNetwork/solarnetwork-d3 | src/api/loc/urlHelper.js | availableSourcesURL | function availableSourcesURL(startDate, endDate) {
var url = (baseURL() +'/location/datum/sources?locationId=' +locationId);
if ( startDate !== undefined ) {
url += '&start=' +encodeURIComponent(sn.format.dateFormat(startDate));
}
if ( endDate !== undefined ) {
url += '&end=' +encodeURIComponent(sn.format... | javascript | function availableSourcesURL(startDate, endDate) {
var url = (baseURL() +'/location/datum/sources?locationId=' +locationId);
if ( startDate !== undefined ) {
url += '&start=' +encodeURIComponent(sn.format.dateFormat(startDate));
}
if ( endDate !== undefined ) {
url += '&end=' +encodeURIComponent(sn.format... | [
"function",
"availableSourcesURL",
"(",
"startDate",
",",
"endDate",
")",
"{",
"var",
"url",
"=",
"(",
"baseURL",
"(",
")",
"+",
"'/location/datum/sources?locationId='",
"+",
"locationId",
")",
";",
"if",
"(",
"startDate",
"!==",
"undefined",
")",
"{",
"url",
... | Get a available source IDs for this location, optionally limited to a date range.
@param {Date} startDate An optional start date to limit the results to.
@param {Date} endDate An optional end date to limit the results to.
@returns {String} the URL to find the available source
@memberOf sn.api.loc.locationUrlHelper
@pr... | [
"Get",
"a",
"available",
"source",
"IDs",
"for",
"this",
"location",
"optionally",
"limited",
"to",
"a",
"date",
"range",
"."
] | 26848b1c303b98b7c0ddeefb8c68c5f5bf78927e | https://github.com/SolarNetwork/solarnetwork-d3/blob/26848b1c303b98b7c0ddeefb8c68c5f5bf78927e/src/api/loc/urlHelper.js#L81-L90 | train |
75lb/string-tools | lib/string-tools.js | fill | function fill(fillWith, len){
var buffer = new Buffer(len);
buffer.fill(fillWith);
return buffer.toString();
} | javascript | function fill(fillWith, len){
var buffer = new Buffer(len);
buffer.fill(fillWith);
return buffer.toString();
} | [
"function",
"fill",
"(",
"fillWith",
",",
"len",
")",
"{",
"var",
"buffer",
"=",
"new",
"Buffer",
"(",
"len",
")",
";",
"buffer",
".",
"fill",
"(",
"fillWith",
")",
";",
"return",
"buffer",
".",
"toString",
"(",
")",
";",
"}"
] | Create a new string filled with the supplied character
@param {string} - the fill character
@param {number} - the length of the output string
@returns {string}
@example
```js
> s.fill("a", 10)
'aaaaaaaaaa'
> s.fill("ab", 10)
'aaaaaaaaaa'
```
@alias module:string-tools.fill | [
"Create",
"a",
"new",
"string",
"filled",
"with",
"the",
"supplied",
"character"
] | ff6afacd534681dd8f7a6716a499f8b126a2943c | https://github.com/75lb/string-tools/blob/ff6afacd534681dd8f7a6716a499f8b126a2943c/lib/string-tools.js#L49-L53 | train |
75lb/string-tools | lib/string-tools.js | padRight | function padRight(input, width, padWith){
padWith = padWith || " ";
input = String(input);
if (input.length < width){
return input + fill(padWith, width - input.length);
} else {
return input;
}
} | javascript | function padRight(input, width, padWith){
padWith = padWith || " ";
input = String(input);
if (input.length < width){
return input + fill(padWith, width - input.length);
} else {
return input;
}
} | [
"function",
"padRight",
"(",
"input",
",",
"width",
",",
"padWith",
")",
"{",
"padWith",
"=",
"padWith",
"||",
"\" \"",
";",
"input",
"=",
"String",
"(",
"input",
")",
";",
"if",
"(",
"input",
".",
"length",
"<",
"width",
")",
"{",
"return",
"input",... | Add padding to the right of a string
@param {string} - the string to pad
@param {number} - the desired final width
@param {string} [padWith=" "] - the padding character
@returns {string}
@example
```js
> s.padRight("clive", 1)
'clive'
> s.padRight("clive", 1, "-")
'clive'
> s.padRight("clive", 10, "-")
'clive-----'
```... | [
"Add",
"padding",
"to",
"the",
"right",
"of",
"a",
"string"
] | ff6afacd534681dd8f7a6716a499f8b126a2943c | https://github.com/75lb/string-tools/blob/ff6afacd534681dd8f7a6716a499f8b126a2943c/lib/string-tools.js#L72-L80 | train |
75lb/string-tools | lib/string-tools.js | repeat | function repeat(input, times){
var output = "";
for (var i = 0; i < times; i++){
output += input;
}
return output;
} | javascript | function repeat(input, times){
var output = "";
for (var i = 0; i < times; i++){
output += input;
}
return output;
} | [
"function",
"repeat",
"(",
"input",
",",
"times",
")",
"{",
"var",
"output",
"=",
"\"\"",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"times",
";",
"i",
"++",
")",
"{",
"output",
"+=",
"input",
";",
"}",
"return",
"output",
";",
"}"
] | returns the input string repeated the specified number of times
@param {string} - input string to repeat
@param {number} - the number of times to repeat
@returns {string}
@alias module:string-tools.repeat | [
"returns",
"the",
"input",
"string",
"repeated",
"the",
"specified",
"number",
"of",
"times"
] | ff6afacd534681dd8f7a6716a499f8b126a2943c | https://github.com/75lb/string-tools/blob/ff6afacd534681dd8f7a6716a499f8b126a2943c/lib/string-tools.js#L96-L102 | train |
75lb/string-tools | lib/string-tools.js | clipLeft | function clipLeft(input, width, prefix){
prefix = prefix || "...";
if (input.length > width){
return prefix + input.slice(-(width - prefix.length));
} else {
return input;
}
} | javascript | function clipLeft(input, width, prefix){
prefix = prefix || "...";
if (input.length > width){
return prefix + input.slice(-(width - prefix.length));
} else {
return input;
}
} | [
"function",
"clipLeft",
"(",
"input",
",",
"width",
",",
"prefix",
")",
"{",
"prefix",
"=",
"prefix",
"||",
"\"...\"",
";",
"if",
"(",
"input",
".",
"length",
">",
"width",
")",
"{",
"return",
"prefix",
"+",
"input",
".",
"slice",
"(",
"-",
"(",
"w... | returns the input string clipped from the left side in order to meet the specified `width`
@param {string} - input string to repeat
@param {number} - the desired final width
@param [prefix=...] {string} - the prefix to replace the clipped region
@returns {string}
@alias module:string-tools.clipLeft | [
"returns",
"the",
"input",
"string",
"clipped",
"from",
"the",
"left",
"side",
"in",
"order",
"to",
"meet",
"the",
"specified",
"width"
] | ff6afacd534681dd8f7a6716a499f8b126a2943c | https://github.com/75lb/string-tools/blob/ff6afacd534681dd8f7a6716a499f8b126a2943c/lib/string-tools.js#L112-L119 | train |
AndCake/zino | src/mustacheparser.js | handleStyles | function handleStyles(tagName, styles) {
styles = (styles || []).map(style => {
let code = style;
return code.replace(/[\r\n]*([^%\{;\}]+?)\{/gm, (global, match) => {
if (match.trim().match(/^@/)) {
return match + '{';
}
var selectors = match.split(',').map(selector => {
selector = selector... | javascript | function handleStyles(tagName, styles) {
styles = (styles || []).map(style => {
let code = style;
return code.replace(/[\r\n]*([^%\{;\}]+?)\{/gm, (global, match) => {
if (match.trim().match(/^@/)) {
return match + '{';
}
var selectors = match.split(',').map(selector => {
selector = selector... | [
"function",
"handleStyles",
"(",
"tagName",
",",
"styles",
")",
"{",
"styles",
"=",
"(",
"styles",
"||",
"[",
"]",
")",
".",
"map",
"(",
"style",
"=>",
"{",
"let",
"code",
"=",
"style",
";",
"return",
"code",
".",
"replace",
"(",
"/",
"[\\r\\n]*([^%\... | parses style information from within a style tag makes sure it is localized | [
"parses",
"style",
"information",
"from",
"within",
"a",
"style",
"tag",
"makes",
"sure",
"it",
"is",
"localized"
] | a9d1de87ad80fe2d106fd84a0c20984c0f3ab125 | https://github.com/AndCake/zino/blob/a9d1de87ad80fe2d106fd84a0c20984c0f3ab125/src/mustacheparser.js#L126-L146 | train |
AndCake/zino | src/mustacheparser.js | handleText | function handleText(text, isAttr) {
let match, result = '', lastIndex = 0;
let cat = isAttr ? ' + ' : ', ';
if (!text.match(syntax)) {
return result += "'" + text.substr(lastIndex).replace(/\n/g, '').replace(/'/g, '\\\'') + "'" + cat;
}
// locate mustache syntax within the text
while (match = syntax.exec... | javascript | function handleText(text, isAttr) {
let match, result = '', lastIndex = 0;
let cat = isAttr ? ' + ' : ', ';
if (!text.match(syntax)) {
return result += "'" + text.substr(lastIndex).replace(/\n/g, '').replace(/'/g, '\\\'') + "'" + cat;
}
// locate mustache syntax within the text
while (match = syntax.exec... | [
"function",
"handleText",
"(",
"text",
",",
"isAttr",
")",
"{",
"let",
"match",
",",
"result",
"=",
"''",
",",
"lastIndex",
"=",
"0",
";",
"let",
"cat",
"=",
"isAttr",
"?",
"' + '",
":",
"', '",
";",
"if",
"(",
"!",
"text",
".",
"match",
"(",
"sy... | text is the only place where mustache code can be found | [
"text",
"is",
"the",
"only",
"place",
"where",
"mustache",
"code",
"can",
"be",
"found"
] | a9d1de87ad80fe2d106fd84a0c20984c0f3ab125 | https://github.com/AndCake/zino/blob/a9d1de87ad80fe2d106fd84a0c20984c0f3ab125/src/mustacheparser.js#L166-L224 | train |
AndCake/zino | src/mustacheparser.js | makeAttributes | function makeAttributes(attrs) {
let attributes = '{';
let attr;
while ((attr = attrRegExp.exec(attrs))) {
if (attributes !== '{') attributes += ', ';
attributes += '"' + attr[1].toLowerCase() + '": ' + handleText(attr[2] || attr[3] || '', true).replace(/\s*[,+]\s*$/g, '');
}
return attributes + '}';
... | javascript | function makeAttributes(attrs) {
let attributes = '{';
let attr;
while ((attr = attrRegExp.exec(attrs))) {
if (attributes !== '{') attributes += ', ';
attributes += '"' + attr[1].toLowerCase() + '": ' + handleText(attr[2] || attr[3] || '', true).replace(/\s*[,+]\s*$/g, '');
}
return attributes + '}';
... | [
"function",
"makeAttributes",
"(",
"attrs",
")",
"{",
"let",
"attributes",
"=",
"'{'",
";",
"let",
"attr",
";",
"while",
"(",
"(",
"attr",
"=",
"attrRegExp",
".",
"exec",
"(",
"attrs",
")",
")",
")",
"{",
"if",
"(",
"attributes",
"!==",
"'{'",
")",
... | generate attribute objects for vdom creation | [
"generate",
"attribute",
"objects",
"for",
"vdom",
"creation"
] | a9d1de87ad80fe2d106fd84a0c20984c0f3ab125 | https://github.com/AndCake/zino/blob/a9d1de87ad80fe2d106fd84a0c20984c0f3ab125/src/mustacheparser.js#L227-L236 | train |
SilentCicero/wafr | src/utils/index.js | bytes32ToType | function bytes32ToType(type, value) {
switch (type) {
case 'address':
return `0x${ethUtil.stripHexPrefix(value).slice(24)}`;
case 'bool':
return (ethUtil.stripHexPrefix(value).slice(63) === '1');
case 'int':
return bytes32ToInt(value);
case 'uint':
return bytes32ToInt(value);
... | javascript | function bytes32ToType(type, value) {
switch (type) {
case 'address':
return `0x${ethUtil.stripHexPrefix(value).slice(24)}`;
case 'bool':
return (ethUtil.stripHexPrefix(value).slice(63) === '1');
case 'int':
return bytes32ToInt(value);
case 'uint':
return bytes32ToInt(value);
... | [
"function",
"bytes32ToType",
"(",
"type",
",",
"value",
")",
"{",
"switch",
"(",
"type",
")",
"{",
"case",
"'address'",
":",
"return",
"`",
"${",
"ethUtil",
".",
"stripHexPrefix",
"(",
"value",
")",
".",
"slice",
"(",
"24",
")",
"}",
"`",
";",
"case"... | bytes32 to type | [
"bytes32",
"to",
"type"
] | 2c7483feec5df346d8903cab5badc17143c3876d | https://github.com/SilentCicero/wafr/blob/2c7483feec5df346d8903cab5badc17143c3876d/src/utils/index.js#L103-L116 | train |
SilentCicero/wafr | src/utils/index.js | filenameInclude | function filenameInclude(filename, exclude, include) { // eslint-disable-line
var output = true; // eslint-disable-line
if (exclude) {
if (globToRegExp(exclude, { extended: true }).test(filename)
&& !globToRegExp(include || '', { extended: true }).test(filename)) {
output = false;
}
}
return... | javascript | function filenameInclude(filename, exclude, include) { // eslint-disable-line
var output = true; // eslint-disable-line
if (exclude) {
if (globToRegExp(exclude, { extended: true }).test(filename)
&& !globToRegExp(include || '', { extended: true }).test(filename)) {
output = false;
}
}
return... | [
"function",
"filenameInclude",
"(",
"filename",
",",
"exclude",
",",
"include",
")",
"{",
"// eslint-disable-line",
"var",
"output",
"=",
"true",
";",
"// eslint-disable-line",
"if",
"(",
"exclude",
")",
"{",
"if",
"(",
"globToRegExp",
"(",
"exclude",
",",
"{"... | returns true if the filename should be included | [
"returns",
"true",
"if",
"the",
"filename",
"should",
"be",
"included"
] | 2c7483feec5df346d8903cab5badc17143c3876d | https://github.com/SilentCicero/wafr/blob/2c7483feec5df346d8903cab5badc17143c3876d/src/utils/index.js#L124-L135 | train |
SilentCicero/wafr | src/utils/index.js | allImportPaths | function allImportPaths(contractSource) {
const noCommentSource = strip.js(String(contractSource));
const rawImportStatements = execall(/^(\s*)((import)(.*?))("|')(.*?)("|')((;)|((.*?)(;)))$/gm, noCommentSource);
const importPaths = rawImportStatements
.map(v => String(execall(/("|')(.*?)("|')/g, v.match)[0].... | javascript | function allImportPaths(contractSource) {
const noCommentSource = strip.js(String(contractSource));
const rawImportStatements = execall(/^(\s*)((import)(.*?))("|')(.*?)("|')((;)|((.*?)(;)))$/gm, noCommentSource);
const importPaths = rawImportStatements
.map(v => String(execall(/("|')(.*?)("|')/g, v.match)[0].... | [
"function",
"allImportPaths",
"(",
"contractSource",
")",
"{",
"const",
"noCommentSource",
"=",
"strip",
".",
"js",
"(",
"String",
"(",
"contractSource",
")",
")",
";",
"const",
"rawImportStatements",
"=",
"execall",
"(",
"/",
"^(\\s*)((import)(.*?))(\"|')(.*?)(\"|'... | get all import paths from contract source | [
"get",
"all",
"import",
"paths",
"from",
"contract",
"source"
] | 2c7483feec5df346d8903cab5badc17143c3876d | https://github.com/SilentCicero/wafr/blob/2c7483feec5df346d8903cab5badc17143c3876d/src/utils/index.js#L138-L150 | train |
SilentCicero/wafr | src/utils/index.js | buildDependencyTreeFromSources | function buildDependencyTreeFromSources(filenames, sourcesObject) {
const orgnizedFlat = {};
// build tree object
filenames.forEach(sourceFileName => {
orgnizedFlat[sourceFileName] = {
path: sourceFileName,
source: sourcesObject[sourceFileName],
dependencies: buildDependencyTreeFromSources(... | javascript | function buildDependencyTreeFromSources(filenames, sourcesObject) {
const orgnizedFlat = {};
// build tree object
filenames.forEach(sourceFileName => {
orgnizedFlat[sourceFileName] = {
path: sourceFileName,
source: sourcesObject[sourceFileName],
dependencies: buildDependencyTreeFromSources(... | [
"function",
"buildDependencyTreeFromSources",
"(",
"filenames",
",",
"sourcesObject",
")",
"{",
"const",
"orgnizedFlat",
"=",
"{",
"}",
";",
"// build tree object",
"filenames",
".",
"forEach",
"(",
"sourceFileName",
"=>",
"{",
"orgnizedFlat",
"[",
"sourceFileName",
... | build dependency tree, returns a complex object | [
"build",
"dependency",
"tree",
"returns",
"a",
"complex",
"object"
] | 2c7483feec5df346d8903cab5badc17143c3876d | https://github.com/SilentCicero/wafr/blob/2c7483feec5df346d8903cab5badc17143c3876d/src/utils/index.js#L153-L167 | train |
SilentCicero/wafr | src/utils/index.js | buildFlatSourcesObjectFromTreeObject | function buildFlatSourcesObjectFromTreeObject(treeObject) {
const currentOutputObject = Object.assign({});
currentOutputObject[treeObject.path] = treeObject.source;
Object.keys(treeObject.dependencies).forEach(dependantTreeObjectFileName => {
Object.assign(currentOutputObject, buildFlatSourcesObjectFromTreeO... | javascript | function buildFlatSourcesObjectFromTreeObject(treeObject) {
const currentOutputObject = Object.assign({});
currentOutputObject[treeObject.path] = treeObject.source;
Object.keys(treeObject.dependencies).forEach(dependantTreeObjectFileName => {
Object.assign(currentOutputObject, buildFlatSourcesObjectFromTreeO... | [
"function",
"buildFlatSourcesObjectFromTreeObject",
"(",
"treeObject",
")",
"{",
"const",
"currentOutputObject",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
")",
";",
"currentOutputObject",
"[",
"treeObject",
".",
"path",
"]",
"=",
"treeObject",
".",
"source",
... | return flat source object from a specific tree root | [
"return",
"flat",
"source",
"object",
"from",
"a",
"specific",
"tree",
"root"
] | 2c7483feec5df346d8903cab5badc17143c3876d | https://github.com/SilentCicero/wafr/blob/2c7483feec5df346d8903cab5badc17143c3876d/src/utils/index.js#L170-L179 | train |
SilentCicero/wafr | src/utils/index.js | buildDependantsSourceTree | function buildDependantsSourceTree(sourceFileName, sourcesObject) {
const depsTree = buildDependencyTreeFromSources(Object.keys(sourcesObject), sourcesObject);
return buildFlatSourcesObjectFromTreeObject(depsTree[sourceFileName]);
} | javascript | function buildDependantsSourceTree(sourceFileName, sourcesObject) {
const depsTree = buildDependencyTreeFromSources(Object.keys(sourcesObject), sourcesObject);
return buildFlatSourcesObjectFromTreeObject(depsTree[sourceFileName]);
} | [
"function",
"buildDependantsSourceTree",
"(",
"sourceFileName",
",",
"sourcesObject",
")",
"{",
"const",
"depsTree",
"=",
"buildDependencyTreeFromSources",
"(",
"Object",
".",
"keys",
"(",
"sourcesObject",
")",
",",
"sourcesObject",
")",
";",
"return",
"buildFlatSourc... | returns a source list object of all dependancies | [
"returns",
"a",
"source",
"list",
"object",
"of",
"all",
"dependancies"
] | 2c7483feec5df346d8903cab5badc17143c3876d | https://github.com/SilentCicero/wafr/blob/2c7483feec5df346d8903cab5badc17143c3876d/src/utils/index.js#L182-L186 | train |
SilentCicero/wafr | src/utils/index.js | getInputSources | function getInputSources(dirname, exclude, include, focusContractPath, callback) {
let filesRead = 0;
const sources = {};
// get all file names
dir.files(dirname, (filesError, files) => {
if (filesError) {
throwError(`while while getting input sources ${filesError}`);
}
// if no files in dir... | javascript | function getInputSources(dirname, exclude, include, focusContractPath, callback) {
let filesRead = 0;
const sources = {};
// get all file names
dir.files(dirname, (filesError, files) => {
if (filesError) {
throwError(`while while getting input sources ${filesError}`);
}
// if no files in dir... | [
"function",
"getInputSources",
"(",
"dirname",
",",
"exclude",
",",
"include",
",",
"focusContractPath",
",",
"callback",
")",
"{",
"let",
"filesRead",
"=",
"0",
";",
"const",
"sources",
"=",
"{",
"}",
";",
"// get all file names",
"dir",
".",
"files",
"(",
... | get all contract input sources | [
"get",
"all",
"contract",
"input",
"sources"
] | 2c7483feec5df346d8903cab5badc17143c3876d | https://github.com/SilentCicero/wafr/blob/2c7483feec5df346d8903cab5badc17143c3876d/src/utils/index.js#L189-L240 | train |
SilentCicero/wafr | src/utils/index.js | compareABIByMethodName | function compareABIByMethodName(methodObjectA, methodObjectB) {
if (methodObjectA.name < methodObjectB.name) {
return -1;
}
if (methodObjectA.name > methodObjectB.name) {
return 1;
}
return 0;
} | javascript | function compareABIByMethodName(methodObjectA, methodObjectB) {
if (methodObjectA.name < methodObjectB.name) {
return -1;
}
if (methodObjectA.name > methodObjectB.name) {
return 1;
}
return 0;
} | [
"function",
"compareABIByMethodName",
"(",
"methodObjectA",
",",
"methodObjectB",
")",
"{",
"if",
"(",
"methodObjectA",
".",
"name",
"<",
"methodObjectB",
".",
"name",
")",
"{",
"return",
"-",
"1",
";",
"}",
"if",
"(",
"methodObjectA",
".",
"name",
">",
"m... | sort test method array | [
"sort",
"test",
"method",
"array"
] | 2c7483feec5df346d8903cab5badc17143c3876d | https://github.com/SilentCicero/wafr/blob/2c7483feec5df346d8903cab5badc17143c3876d/src/utils/index.js#L281-L291 | train |
SilentCicero/wafr | src/utils/index.js | errorEnhancement | function errorEnhancement(inputMessage) {
var message = inputMessage; // eslint-disable-line
var outputMessage = null; // eslint-disable-line
// if the input message is an array or object
if (inputMessage !== null
&& !isNaN(inputMessage)
&& typeof inputMessage !== 'string') {
message = JSON.stringi... | javascript | function errorEnhancement(inputMessage) {
var message = inputMessage; // eslint-disable-line
var outputMessage = null; // eslint-disable-line
// if the input message is an array or object
if (inputMessage !== null
&& !isNaN(inputMessage)
&& typeof inputMessage !== 'string') {
message = JSON.stringi... | [
"function",
"errorEnhancement",
"(",
"inputMessage",
")",
"{",
"var",
"message",
"=",
"inputMessage",
";",
"// eslint-disable-line",
"var",
"outputMessage",
"=",
"null",
";",
"// eslint-disable-line",
"// if the input message is an array or object",
"if",
"(",
"inputMessage... | error enhancement, more information about bad errors | [
"error",
"enhancement",
"more",
"information",
"about",
"bad",
"errors"
] | 2c7483feec5df346d8903cab5badc17143c3876d | https://github.com/SilentCicero/wafr/blob/2c7483feec5df346d8903cab5badc17143c3876d/src/utils/index.js#L298-L365 | train |
SilentCicero/wafr | src/utils/index.js | increaseProviderTime | function increaseProviderTime(provider, time, callback) {
if (typeof time !== 'number') {
callback('error while increasing TestRPC provider time, time value must be a number.', null);
return;
}
provider.sendAsync({
method: 'evm_increaseTime',
params: [time],
}, (increaseTimeError) => {
if (... | javascript | function increaseProviderTime(provider, time, callback) {
if (typeof time !== 'number') {
callback('error while increasing TestRPC provider time, time value must be a number.', null);
return;
}
provider.sendAsync({
method: 'evm_increaseTime',
params: [time],
}, (increaseTimeError) => {
if (... | [
"function",
"increaseProviderTime",
"(",
"provider",
",",
"time",
",",
"callback",
")",
"{",
"if",
"(",
"typeof",
"time",
"!==",
"'number'",
")",
"{",
"callback",
"(",
"'error while increasing TestRPC provider time, time value must be a number.'",
",",
"null",
")",
";... | increase the testrpc provider time by a specific amount, then mine | [
"increase",
"the",
"testrpc",
"provider",
"time",
"by",
"a",
"specific",
"amount",
"then",
"mine"
] | 2c7483feec5df346d8903cab5badc17143c3876d | https://github.com/SilentCicero/wafr/blob/2c7483feec5df346d8903cab5badc17143c3876d/src/utils/index.js#L384-L408 | train |
SilentCicero/wafr | src/utils/index.js | increaseBlockRecursively | function increaseBlockRecursively(provider, count, total, callback) {
// if the count hits the total, stop the recursion
if (count >= total) {
callback(null, true);
} else {
// else mine a block
provider.sendAsync({
method: 'evm_mine',
}, (mineError) => {
if (mineError) {
callb... | javascript | function increaseBlockRecursively(provider, count, total, callback) {
// if the count hits the total, stop the recursion
if (count >= total) {
callback(null, true);
} else {
// else mine a block
provider.sendAsync({
method: 'evm_mine',
}, (mineError) => {
if (mineError) {
callb... | [
"function",
"increaseBlockRecursively",
"(",
"provider",
",",
"count",
",",
"total",
",",
"callback",
")",
"{",
"// if the count hits the total, stop the recursion",
"if",
"(",
"count",
">=",
"total",
")",
"{",
"callback",
"(",
"null",
",",
"true",
")",
";",
"}"... | increase the TestRPC blocks by a specific count recursively | [
"increase",
"the",
"TestRPC",
"blocks",
"by",
"a",
"specific",
"count",
"recursively"
] | 2c7483feec5df346d8903cab5badc17143c3876d | https://github.com/SilentCicero/wafr/blob/2c7483feec5df346d8903cab5badc17143c3876d/src/utils/index.js#L411-L427 | train |
SilentCicero/wafr | src/utils/index.js | getBlockIncreaseFromName | function getBlockIncreaseFromName(methodName) {
const matchNumbers = String(methodName).match(/_increaseBlockBy(\d+)/);
if (matchNumbers !== null
&& typeof matchNumbers[1] === 'string') {
return parseInt(matchNumbers[1], 10);
}
return 0;
} | javascript | function getBlockIncreaseFromName(methodName) {
const matchNumbers = String(methodName).match(/_increaseBlockBy(\d+)/);
if (matchNumbers !== null
&& typeof matchNumbers[1] === 'string') {
return parseInt(matchNumbers[1], 10);
}
return 0;
} | [
"function",
"getBlockIncreaseFromName",
"(",
"methodName",
")",
"{",
"const",
"matchNumbers",
"=",
"String",
"(",
"methodName",
")",
".",
"match",
"(",
"/",
"_increaseBlockBy(\\d+)",
"/",
")",
";",
"if",
"(",
"matchNumbers",
"!==",
"null",
"&&",
"typeof",
"mat... | get block increase value from method name | [
"get",
"block",
"increase",
"value",
"from",
"method",
"name"
] | 2c7483feec5df346d8903cab5badc17143c3876d | https://github.com/SilentCicero/wafr/blob/2c7483feec5df346d8903cab5badc17143c3876d/src/utils/index.js#L435-L444 | train |
SilentCicero/wafr | src/utils/index.js | getTimeIncreaseFromName | function getTimeIncreaseFromName(methodName) {
const matchNumbers = String(methodName).match(/_increaseTimeBy(\d+)/);
if (matchNumbers !== null
&& typeof matchNumbers[1] === 'string') {
return parseInt(matchNumbers[1], 10);
}
return 0;
} | javascript | function getTimeIncreaseFromName(methodName) {
const matchNumbers = String(methodName).match(/_increaseTimeBy(\d+)/);
if (matchNumbers !== null
&& typeof matchNumbers[1] === 'string') {
return parseInt(matchNumbers[1], 10);
}
return 0;
} | [
"function",
"getTimeIncreaseFromName",
"(",
"methodName",
")",
"{",
"const",
"matchNumbers",
"=",
"String",
"(",
"methodName",
")",
".",
"match",
"(",
"/",
"_increaseTimeBy(\\d+)",
"/",
")",
";",
"if",
"(",
"matchNumbers",
"!==",
"null",
"&&",
"typeof",
"match... | get time increase value from method name | [
"get",
"time",
"increase",
"value",
"from",
"method",
"name"
] | 2c7483feec5df346d8903cab5badc17143c3876d | https://github.com/SilentCicero/wafr/blob/2c7483feec5df346d8903cab5badc17143c3876d/src/utils/index.js#L447-L456 | train |
iolo/express-toybox | cors.js | cors | function cors(options) {
options = _.merge({}, DEF_CONFIG, options);
DEBUG && debug('configure http cors middleware', options);
return function (req, res, next) {
if (req.headers.origin) {
res.header('Access-Control-Allow-Origin', options.origin === '*' ? req.headers.origin : options.ori... | javascript | function cors(options) {
options = _.merge({}, DEF_CONFIG, options);
DEBUG && debug('configure http cors middleware', options);
return function (req, res, next) {
if (req.headers.origin) {
res.header('Access-Control-Allow-Origin', options.origin === '*' ? req.headers.origin : options.ori... | [
"function",
"cors",
"(",
"options",
")",
"{",
"options",
"=",
"_",
".",
"merge",
"(",
"{",
"}",
",",
"DEF_CONFIG",
",",
"options",
")",
";",
"DEBUG",
"&&",
"debug",
"(",
"'configure http cors middleware'",
",",
"options",
")",
";",
"return",
"function",
... | CORS middleware.
@param {*} options
@param {String} [options.origin='*']
@param {String} [options.methods]
@param {String} [options.headers]
@param {String} [options.credentials=false]
@param {String} [options.maxAge=24*60*60]
@returns {Function} connect/express middleware function
@see https://developer.mozilla.org/e... | [
"CORS",
"middleware",
"."
] | c375a1388cfc167017e8dcd2325e71ca86ccb994 | https://github.com/iolo/express-toybox/blob/c375a1388cfc167017e8dcd2325e71ca86ccb994/cors.js#L31-L48 | train |
jtheriault/code-copter | examples/analyzer-inline.spec.js | itSucks | function itSucks (fileSourceData) {
var errors = [];
for (let sample of fileSourceData) {
errors.push({
line: sample.line,
message: 'This code sucks: ' + sample.text
});
}
return {
// Too noisy to set ```errors: errors```
// It all sucks, so just... | javascript | function itSucks (fileSourceData) {
var errors = [];
for (let sample of fileSourceData) {
errors.push({
line: sample.line,
message: 'This code sucks: ' + sample.text
});
}
return {
// Too noisy to set ```errors: errors```
// It all sucks, so just... | [
"function",
"itSucks",
"(",
"fileSourceData",
")",
"{",
"var",
"errors",
"=",
"[",
"]",
";",
"for",
"(",
"let",
"sample",
"of",
"fileSourceData",
")",
"{",
"errors",
".",
"push",
"(",
"{",
"line",
":",
"sample",
".",
"line",
",",
"message",
":",
"'Th... | A pretty harsh analyzer that passes NO files for the reason that "it sucks" starting on line 1.
@param {FileSourceData} fileSourceData - The file source data to analyze.
@returns {Object} An object consistent with a code-copter Analysis object bearing the inevitable message that the code in the analyzed file sucks. | [
"A",
"pretty",
"harsh",
"analyzer",
"that",
"passes",
"NO",
"files",
"for",
"the",
"reason",
"that",
"it",
"sucks",
"starting",
"on",
"line",
"1",
"."
] | e69f22e1c9de5d59d15958a09d732ce8d8b519fb | https://github.com/jtheriault/code-copter/blob/e69f22e1c9de5d59d15958a09d732ce8d8b519fb/examples/analyzer-inline.spec.js#L10-L29 | train |
iolo/express-toybox | error404.js | error404 | function error404(options) {
options = _.merge({}, DEF_CONFIG, options);
// pre-compile underscore template if available
if (typeof options.template === 'string' && options.template.length > 0) {
options.template = _.template(options.template);
}
return function (req, res, next) {
... | javascript | function error404(options) {
options = _.merge({}, DEF_CONFIG, options);
// pre-compile underscore template if available
if (typeof options.template === 'string' && options.template.length > 0) {
options.template = _.template(options.template);
}
return function (req, res, next) {
... | [
"function",
"error404",
"(",
"options",
")",
"{",
"options",
"=",
"_",
".",
"merge",
"(",
"{",
"}",
",",
"DEF_CONFIG",
",",
"options",
")",
";",
"// pre-compile underscore template if available",
"if",
"(",
"typeof",
"options",
".",
"template",
"===",
"'string... | express 404 error handler.
@param {*} options
@param {Number} [options.status=404]
@param {Number} [options.code=8404]
@param {String} [options.message='Not Found']
@param {String|Function} [options.template] lodash(underscore) micro template for html 404 error page.
@param {String} [options.view='errors/404'] express... | [
"express",
"404",
"error",
"handler",
"."
] | c375a1388cfc167017e8dcd2325e71ca86ccb994 | https://github.com/iolo/express-toybox/blob/c375a1388cfc167017e8dcd2325e71ca86ccb994/error404.js#L30-L61 | train |
haasz/laravel-mix-ext | src/logger.js | TemplateFileLog | function TemplateFileLog(src, target) {
this.templateFile = {
source: src,
target: target
};
this.isCompilationPerfect = true;
this.templateTagLogs = new Table({
chars: {
'top-mid': '',
'bottom-mid': '',
'middle': '',
'mid-mid': '',
},
style: {},
});
} | javascript | function TemplateFileLog(src, target) {
this.templateFile = {
source: src,
target: target
};
this.isCompilationPerfect = true;
this.templateTagLogs = new Table({
chars: {
'top-mid': '',
'bottom-mid': '',
'middle': '',
'mid-mid': '',
},
style: {},
});
} | [
"function",
"TemplateFileLog",
"(",
"src",
",",
"target",
")",
"{",
"this",
".",
"templateFile",
"=",
"{",
"source",
":",
"src",
",",
"target",
":",
"target",
"}",
";",
"this",
".",
"isCompilationPerfect",
"=",
"true",
";",
"this",
".",
"templateTagLogs",
... | The TemplateFileLog type
Create a template file log.
@constructor
@param {string} src The source template file.
@param {string} target The compiled target file. | [
"The",
"TemplateFileLog",
"type"
] | bd1c794bdbf934dae233ab697dc5d5593d4b1124 | https://github.com/haasz/laravel-mix-ext/blob/bd1c794bdbf934dae233ab697dc5d5593d4b1124/src/logger.js#L153-L168 | train |
gunins/stonewall | dist/es5/dev/widget/Constructor.js | render | function render(data) {
if (!this._rendered) {
if (this.template) {
if (data) {
this.data = data;
}
var options = this._options,
parentChildren = this._pare... | javascript | function render(data) {
if (!this._rendered) {
if (this.template) {
if (data) {
this.data = data;
}
var options = this._options,
parentChildren = this._pare... | [
"function",
"render",
"(",
"data",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_rendered",
")",
"{",
"if",
"(",
"this",
".",
"template",
")",
"{",
"if",
"(",
"data",
")",
"{",
"this",
".",
"data",
"=",
"data",
";",
"}",
"var",
"options",
"=",
"this... | method render called manually if flag async is true; @method render | [
"method",
"render",
"called",
"manually",
"if",
"flag",
"async",
"is",
"true",
";"
] | eebc6376f83115b6e29d4539582830e917f0e80e | https://github.com/gunins/stonewall/blob/eebc6376f83115b6e29d4539582830e917f0e80e/dist/es5/dev/widget/Constructor.js#L1285-L1346 | train |
gunins/stonewall | dist/es5/dev/widget/Constructor.js | loadCss | function loadCss(url) {
if (this.context._cssReady.indexOf(url) === -1) {
this.context._cssReady.push(url);
var linkRef = document.createElement("link");
linkRef.setAttribute("rel", "stylesheet");
linkRef.setAttribute("type"... | javascript | function loadCss(url) {
if (this.context._cssReady.indexOf(url) === -1) {
this.context._cssReady.push(url);
var linkRef = document.createElement("link");
linkRef.setAttribute("rel", "stylesheet");
linkRef.setAttribute("type"... | [
"function",
"loadCss",
"(",
"url",
")",
"{",
"if",
"(",
"this",
".",
"context",
".",
"_cssReady",
".",
"indexOf",
"(",
"url",
")",
"===",
"-",
"1",
")",
"{",
"this",
".",
"context",
".",
"_cssReady",
".",
"push",
"(",
"url",
")",
";",
"var",
"lin... | Load external css style for third party modules. @method loadCss @param {string} url | [
"Load",
"external",
"css",
"style",
"for",
"third",
"party",
"modules",
"."
] | eebc6376f83115b6e29d4539582830e917f0e80e | https://github.com/gunins/stonewall/blob/eebc6376f83115b6e29d4539582830e917f0e80e/dist/es5/dev/widget/Constructor.js#L1394-L1405 | train |
gunins/stonewall | dist/es5/dev/widget/Constructor.js | detach | function detach() {
if (!this._placeholder) {
this._placeholder = document.createElement(this.el.tagName);
}
if (!this._parent) {
this._parent = this.el.parentNode;
}
if (this.el && this._parent) {
... | javascript | function detach() {
if (!this._placeholder) {
this._placeholder = document.createElement(this.el.tagName);
}
if (!this._parent) {
this._parent = this.el.parentNode;
}
if (this.el && this._parent) {
... | [
"function",
"detach",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_placeholder",
")",
"{",
"this",
".",
"_placeholder",
"=",
"document",
".",
"createElement",
"(",
"this",
".",
"el",
".",
"tagName",
")",
";",
"}",
"if",
"(",
"!",
"this",
".",
"_pa... | Remove from parentNode @method detach | [
"Remove",
"from",
"parentNode"
] | eebc6376f83115b6e29d4539582830e917f0e80e | https://github.com/gunins/stonewall/blob/eebc6376f83115b6e29d4539582830e917f0e80e/dist/es5/dev/widget/Constructor.js#L1413-L1424 | train |
gunins/stonewall | dist/es5/dev/widget/Constructor.js | destroy | function destroy() {
this.onDestroy();
this.eventBus.clear();
while (this._events.length > 0) {
this._events.shift().remove();
}
while (this._globalEvents.length > 0) {
this._globalEvents.shift().rem... | javascript | function destroy() {
this.onDestroy();
this.eventBus.clear();
while (this._events.length > 0) {
this._events.shift().remove();
}
while (this._globalEvents.length > 0) {
this._globalEvents.shift().rem... | [
"function",
"destroy",
"(",
")",
"{",
"this",
".",
"onDestroy",
"(",
")",
";",
"this",
".",
"eventBus",
".",
"clear",
"(",
")",
";",
"while",
"(",
"this",
".",
"_events",
".",
"length",
">",
"0",
")",
"{",
"this",
".",
"_events",
".",
"shift",
"(... | Removing widget from Dom @method destroy | [
"Removing",
"widget",
"from",
"Dom"
] | eebc6376f83115b6e29d4539582830e917f0e80e | https://github.com/gunins/stonewall/blob/eebc6376f83115b6e29d4539582830e917f0e80e/dist/es5/dev/widget/Constructor.js#L1452-L1473 | train |
gunins/stonewall | dist/es5/dev/widget/Constructor.js | addComponent | function addComponent(Component, options) {
var name = options.name,
container = options.container;
if (name === undefined) {
throw 'you have to define data.name for component.';
} else if (container === undefined) {
... | javascript | function addComponent(Component, options) {
var name = options.name,
container = options.container;
if (name === undefined) {
throw 'you have to define data.name for component.';
} else if (container === undefined) {
... | [
"function",
"addComponent",
"(",
"Component",
",",
"options",
")",
"{",
"var",
"name",
"=",
"options",
".",
"name",
",",
"container",
"=",
"options",
".",
"container",
";",
"if",
"(",
"name",
"===",
"undefined",
")",
"{",
"throw",
"'you have to define data.n... | Adding Dynamic components @method addComponent @param {String} name @param {Constructor} Component @param {Element} container @param {Object} data (data attributes) @param {Object} children @param {Object} dataSet (Model for bindings) | [
"Adding",
"Dynamic",
"components"
] | eebc6376f83115b6e29d4539582830e917f0e80e | https://github.com/gunins/stonewall/blob/eebc6376f83115b6e29d4539582830e917f0e80e/dist/es5/dev/widget/Constructor.js#L1515-L1531 | train |
tmpfs/ttycolor | lib/ansi.js | open | function open(code, attr) {
return attr ? ANSI_OPEN + attr + ';' + code + ANSI_FINAL
: ANSI_OPEN + code + ANSI_FINAL;
} | javascript | function open(code, attr) {
return attr ? ANSI_OPEN + attr + ';' + code + ANSI_FINAL
: ANSI_OPEN + code + ANSI_FINAL;
} | [
"function",
"open",
"(",
"code",
",",
"attr",
")",
"{",
"return",
"attr",
"?",
"ANSI_OPEN",
"+",
"attr",
"+",
"';'",
"+",
"code",
"+",
"ANSI_FINAL",
":",
"ANSI_OPEN",
"+",
"code",
"+",
"ANSI_FINAL",
";",
"}"
] | Open an escape sequence.
@param code The color code.
@param attr An optional attribute code. | [
"Open",
"an",
"escape",
"sequence",
"."
] | 4b72de7f61bfd922f227f3f4e7c61fb95ff9c023 | https://github.com/tmpfs/ttycolor/blob/4b72de7f61bfd922f227f3f4e7c61fb95ff9c023/lib/ansi.js#L14-L17 | train |
tmpfs/ttycolor | lib/ansi.js | stringify | function stringify(value, code, attr, tag) {
var s = open(code, attr);
s += close(value, tag);
return s;
} | javascript | function stringify(value, code, attr, tag) {
var s = open(code, attr);
s += close(value, tag);
return s;
} | [
"function",
"stringify",
"(",
"value",
",",
"code",
",",
"attr",
",",
"tag",
")",
"{",
"var",
"s",
"=",
"open",
"(",
"code",
",",
"attr",
")",
";",
"s",
"+=",
"close",
"(",
"value",
",",
"tag",
")",
";",
"return",
"s",
";",
"}"
] | Low-level method for creating escaped string sequences.
@param value The value to escape.
@param code The color code.
@param attr An optional attribute code.
@param tag A specific closing tag to use. | [
"Low",
"-",
"level",
"method",
"for",
"creating",
"escaped",
"string",
"sequences",
"."
] | 4b72de7f61bfd922f227f3f4e7c61fb95ff9c023 | https://github.com/tmpfs/ttycolor/blob/4b72de7f61bfd922f227f3f4e7c61fb95ff9c023/lib/ansi.js#L36-L40 | train |
tmpfs/ttycolor | lib/ansi.js | function(value, key, parent){
this.t = definition.colors; // table of color codes
this.v = value; // value wrapped by this instance
this.k = key; // property name, eg 'red'
this.p = parent; // parent
this.a = null; // attribute
} | javascript | function(value, key, parent){
this.t = definition.colors; // table of color codes
this.v = value; // value wrapped by this instance
this.k = key; // property name, eg 'red'
this.p = parent; // parent
this.a = null; // attribute
} | [
"function",
"(",
"value",
",",
"key",
",",
"parent",
")",
"{",
"this",
".",
"t",
"=",
"definition",
".",
"colors",
";",
"// table of color codes",
"this",
".",
"v",
"=",
"value",
";",
"// value wrapped by this instance",
"this",
".",
"k",
"=",
"key",
";",
... | Chainable color builder.
@param value The underlying value to be escaped.
@param key The key for the code lookup.
@param parent A parent color instance. | [
"Chainable",
"color",
"builder",
"."
] | 4b72de7f61bfd922f227f3f4e7c61fb95ff9c023 | https://github.com/tmpfs/ttycolor/blob/4b72de7f61bfd922f227f3f4e7c61fb95ff9c023/lib/ansi.js#L49-L55 | train | |
dcodeIO/SourceCon | src/SourceCon.js | pack | function pack(id, type, body) {
var buf = new Buffer(body.length + 14);
buf.writeInt32LE(body.length + 10, 0);
buf.writeInt32LE(id, 4);
buf.writeInt32LE(type, 8);
body.copy(buf, 12);
buf[buf.length-2] = 0;
buf[buf.length-1] = 0;
return buf;
} | javascript | function pack(id, type, body) {
var buf = new Buffer(body.length + 14);
buf.writeInt32LE(body.length + 10, 0);
buf.writeInt32LE(id, 4);
buf.writeInt32LE(type, 8);
body.copy(buf, 12);
buf[buf.length-2] = 0;
buf[buf.length-1] = 0;
return buf;
} | [
"function",
"pack",
"(",
"id",
",",
"type",
",",
"body",
")",
"{",
"var",
"buf",
"=",
"new",
"Buffer",
"(",
"body",
".",
"length",
"+",
"14",
")",
";",
"buf",
".",
"writeInt32LE",
"(",
"body",
".",
"length",
"+",
"10",
",",
"0",
")",
";",
"buf"... | Creates a request packet.
@param {number} id Request id
@param {number} type Request type
@param {!Buffer} body Request data
@returns {!Buffer} | [
"Creates",
"a",
"request",
"packet",
"."
] | 20a800dc5d1599fd07e0076afdd7f017f7744def | https://github.com/dcodeIO/SourceCon/blob/20a800dc5d1599fd07e0076afdd7f017f7744def/src/SourceCon.js#L206-L215 | train |
aledbf/deis-api | lib/limits.js | list | function list(appName, callback) {
if (!appName) {
return callback(ArgumentError('appName'));
}
var uri = format('/%s/apps/%s/config/', deis.version, appName);
commons.get(uri, function onListResponse(err, result) {
console.log(result);
callback(err, result ? extractLimits(result) : n... | javascript | function list(appName, callback) {
if (!appName) {
return callback(ArgumentError('appName'));
}
var uri = format('/%s/apps/%s/config/', deis.version, appName);
commons.get(uri, function onListResponse(err, result) {
console.log(result);
callback(err, result ? extractLimits(result) : n... | [
"function",
"list",
"(",
"appName",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"appName",
")",
"{",
"return",
"callback",
"(",
"ArgumentError",
"(",
"'appName'",
")",
")",
";",
"}",
"var",
"uri",
"=",
"format",
"(",
"'/%s/apps/%s/config/'",
",",
"deis",
... | list resource limits for an app | [
"list",
"resource",
"limits",
"for",
"an",
"app"
] | f0833789998032b11221a3a617bb566ade1fcc13 | https://github.com/aledbf/deis-api/blob/f0833789998032b11221a3a617bb566ade1fcc13/lib/limits.js#L30-L40 | train |
aledbf/deis-api | lib/limits.js | set | function set(appName, limits, callback) {
if (!isObject(limits)) {
return callback(new Error('To set a variable pass an object'));
}
var keyValues = {};
if (limits.hasOwnProperty('memory')) {
keyValues.memory = limits.memory;
}
if (limits.hasOwnProperty('cpu')) {
keyValues.c... | javascript | function set(appName, limits, callback) {
if (!isObject(limits)) {
return callback(new Error('To set a variable pass an object'));
}
var keyValues = {};
if (limits.hasOwnProperty('memory')) {
keyValues.memory = limits.memory;
}
if (limits.hasOwnProperty('cpu')) {
keyValues.c... | [
"function",
"set",
"(",
"appName",
",",
"limits",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"isObject",
"(",
"limits",
")",
")",
"{",
"return",
"callback",
"(",
"new",
"Error",
"(",
"'To set a variable pass an object'",
")",
")",
";",
"}",
"var",
"keyVa... | set resource limits for an app | [
"set",
"resource",
"limits",
"for",
"an",
"app"
] | f0833789998032b11221a3a617bb566ade1fcc13 | https://github.com/aledbf/deis-api/blob/f0833789998032b11221a3a617bb566ade1fcc13/lib/limits.js#L45-L68 | train |
aledbf/deis-api | lib/limits.js | unset | function unset(appName, limitType, procType, callback) {
if (!appName) {
return callback(ArgumentError('appName'));
}
if (!limitType) {
return callback(ArgumentError('limitType'));
}
if (!procType) {
return callback(ArgumentError('procType'));
}
var keyValues = {};
... | javascript | function unset(appName, limitType, procType, callback) {
if (!appName) {
return callback(ArgumentError('appName'));
}
if (!limitType) {
return callback(ArgumentError('limitType'));
}
if (!procType) {
return callback(ArgumentError('procType'));
}
var keyValues = {};
... | [
"function",
"unset",
"(",
"appName",
",",
"limitType",
",",
"procType",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"appName",
")",
"{",
"return",
"callback",
"(",
"ArgumentError",
"(",
"'appName'",
")",
")",
";",
"}",
"if",
"(",
"!",
"limitType",
")",
... | unset resource limits for an app | [
"unset",
"resource",
"limits",
"for",
"an",
"app"
] | f0833789998032b11221a3a617bb566ade1fcc13 | https://github.com/aledbf/deis-api/blob/f0833789998032b11221a3a617bb566ade1fcc13/lib/limits.js#L73-L103 | train |
SolarNetwork/solarnetwork-d3 | src/format/util.js | sn_format_fmt | function sn_format_fmt() {
if ( !arguments.length ) {
return;
}
var i = 0,
formatted = arguments[i],
regexp,
replaceValue;
for ( i = 1; i < arguments.length; i += 1 ) {
regexp = new RegExp('\\{'+(i-1)+'\\}', 'gi');
replaceValue = arguments[i];
if ( replaceValue instanceof Date ) {
replaceValue = (r... | javascript | function sn_format_fmt() {
if ( !arguments.length ) {
return;
}
var i = 0,
formatted = arguments[i],
regexp,
replaceValue;
for ( i = 1; i < arguments.length; i += 1 ) {
regexp = new RegExp('\\{'+(i-1)+'\\}', 'gi');
replaceValue = arguments[i];
if ( replaceValue instanceof Date ) {
replaceValue = (r... | [
"function",
"sn_format_fmt",
"(",
")",
"{",
"if",
"(",
"!",
"arguments",
".",
"length",
")",
"{",
"return",
";",
"}",
"var",
"i",
"=",
"0",
",",
"formatted",
"=",
"arguments",
"[",
"i",
"]",
",",
"regexp",
",",
"replaceValue",
";",
"for",
"(",
"i",... | Helper to be able to use placeholders even on iOS, where console.log doesn't support them.
@param {String} Message template.
@param {Object[]} Optional parameters to replace in the message.
@preserve | [
"Helper",
"to",
"be",
"able",
"to",
"use",
"placeholders",
"even",
"on",
"iOS",
"where",
"console",
".",
"log",
"doesn",
"t",
"support",
"them",
"."
] | 26848b1c303b98b7c0ddeefb8c68c5f5bf78927e | https://github.com/SolarNetwork/solarnetwork-d3/blob/26848b1c303b98b7c0ddeefb8c68c5f5bf78927e/src/format/util.js#L12-L30 | train |
pagespace/pagespace | static/bower_components/angular-schema-form/dist/schema-form.js | function(args) {
if (args.form.ngModelOptions && Object.keys(args.form.ngModelOptions).length > 0) {
args.fieldFrag.firstChild.setAttribute('ng-model-options', JSON.stringify(args.form.ngModelOptions));
}
} | javascript | function(args) {
if (args.form.ngModelOptions && Object.keys(args.form.ngModelOptions).length > 0) {
args.fieldFrag.firstChild.setAttribute('ng-model-options', JSON.stringify(args.form.ngModelOptions));
}
} | [
"function",
"(",
"args",
")",
"{",
"if",
"(",
"args",
".",
"form",
".",
"ngModelOptions",
"&&",
"Object",
".",
"keys",
"(",
"args",
".",
"form",
".",
"ngModelOptions",
")",
".",
"length",
">",
"0",
")",
"{",
"args",
".",
"fieldFrag",
".",
"firstChild... | Patch on ngModelOptions, since it doesn't like waiting for its value. | [
"Patch",
"on",
"ngModelOptions",
"since",
"it",
"doesn",
"t",
"like",
"waiting",
"for",
"its",
"value",
"."
] | 943c45ddd9aaa4f3136e1ba4c2593aa0289daf43 | https://github.com/pagespace/pagespace/blob/943c45ddd9aaa4f3136e1ba4c2593aa0289daf43/static/bower_components/angular-schema-form/dist/schema-form.js#L148-L152 | train | |
pagespace/pagespace | static/bower_components/angular-schema-form/dist/schema-form.js | function(items, path, state) {
return build(items, decorator, templateFn, slots, path, state, lookup);
} | javascript | function(items, path, state) {
return build(items, decorator, templateFn, slots, path, state, lookup);
} | [
"function",
"(",
"items",
",",
"path",
",",
"state",
")",
"{",
"return",
"build",
"(",
"items",
",",
"decorator",
",",
"templateFn",
",",
"slots",
",",
"path",
",",
"state",
",",
"lookup",
")",
";",
"}"
] | Recursive build fn | [
"Recursive",
"build",
"fn"
] | 943c45ddd9aaa4f3136e1ba4c2593aa0289daf43 | https://github.com/pagespace/pagespace/blob/943c45ddd9aaa4f3136e1ba4c2593aa0289daf43/static/bower_components/angular-schema-form/dist/schema-form.js#L306-L308 | train | |
pagespace/pagespace | static/bower_components/angular-schema-form/dist/schema-form.js | function(form, decorator, slots, lookup) {
return build(form, decorator, function(form, field) {
if (form.type === 'template') {
return form.template;
}
return $templateCache.get(field.template);
}, slots, undefined, undefined, lookup);
} | javascript | function(form, decorator, slots, lookup) {
return build(form, decorator, function(form, field) {
if (form.type === 'template') {
return form.template;
}
return $templateCache.get(field.template);
}, slots, undefined, undefined, lookup);
} | [
"function",
"(",
"form",
",",
"decorator",
",",
"slots",
",",
"lookup",
")",
"{",
"return",
"build",
"(",
"form",
",",
"decorator",
",",
"function",
"(",
"form",
",",
"field",
")",
"{",
"if",
"(",
"form",
".",
"type",
"===",
"'template'",
")",
"{",
... | Builds a form from a canonical form definition | [
"Builds",
"a",
"form",
"from",
"a",
"canonical",
"form",
"definition"
] | 943c45ddd9aaa4f3136e1ba4c2593aa0289daf43 | https://github.com/pagespace/pagespace/blob/943c45ddd9aaa4f3136e1ba4c2593aa0289daf43/static/bower_components/angular-schema-form/dist/schema-form.js#L335-L343 | train | |
pagespace/pagespace | static/bower_components/angular-schema-form/dist/schema-form.js | function(name, form) {
//schemaDecorator is alias for whatever is set as default
if (name === 'sfDecorator') {
name = defaultDecorator;
}
var decorator = decorators[name];
if (decorator[form.type]) {
return decorator[form.type].template;
}
//try default
return decorator['de... | javascript | function(name, form) {
//schemaDecorator is alias for whatever is set as default
if (name === 'sfDecorator') {
name = defaultDecorator;
}
var decorator = decorators[name];
if (decorator[form.type]) {
return decorator[form.type].template;
}
//try default
return decorator['de... | [
"function",
"(",
"name",
",",
"form",
")",
"{",
"//schemaDecorator is alias for whatever is set as default",
"if",
"(",
"name",
"===",
"'sfDecorator'",
")",
"{",
"name",
"=",
"defaultDecorator",
";",
"}",
"var",
"decorator",
"=",
"decorators",
"[",
"name",
"]",
... | Map template after decorator and type. | [
"Map",
"template",
"after",
"decorator",
"and",
"type",
"."
] | 943c45ddd9aaa4f3136e1ba4c2593aa0289daf43 | https://github.com/pagespace/pagespace/blob/943c45ddd9aaa4f3136e1ba4c2593aa0289daf43/static/bower_components/angular-schema-form/dist/schema-form.js#L358-L371 | train | |
pagespace/pagespace | static/bower_components/angular-schema-form/dist/schema-form.js | function(enm) {
var titleMap = []; //canonical titleMap format is a list.
enm.forEach(function(name) {
titleMap.push({name: name, value: name});
});
return titleMap;
} | javascript | function(enm) {
var titleMap = []; //canonical titleMap format is a list.
enm.forEach(function(name) {
titleMap.push({name: name, value: name});
});
return titleMap;
} | [
"function",
"(",
"enm",
")",
"{",
"var",
"titleMap",
"=",
"[",
"]",
";",
"//canonical titleMap format is a list.",
"enm",
".",
"forEach",
"(",
"function",
"(",
"name",
")",
"{",
"titleMap",
".",
"push",
"(",
"{",
"name",
":",
"name",
",",
"value",
":",
... | Creates an default titleMap list from an enum, i.e. a list of strings. | [
"Creates",
"an",
"default",
"titleMap",
"list",
"from",
"an",
"enum",
"i",
".",
"e",
".",
"a",
"list",
"of",
"strings",
"."
] | 943c45ddd9aaa4f3136e1ba4c2593aa0289daf43 | https://github.com/pagespace/pagespace/blob/943c45ddd9aaa4f3136e1ba4c2593aa0289daf43/static/bower_components/angular-schema-form/dist/schema-form.js#L1022-L1028 | train | |
pagespace/pagespace | static/bower_components/angular-schema-form/dist/schema-form.js | function(titleMap, originalEnum) {
if (!angular.isArray(titleMap)) {
var canonical = [];
if (originalEnum) {
angular.forEach(originalEnum, function(value, index) {
canonical.push({name: titleMap[value], value: value});
});
} else {
angular.forEach(titleMap, functi... | javascript | function(titleMap, originalEnum) {
if (!angular.isArray(titleMap)) {
var canonical = [];
if (originalEnum) {
angular.forEach(originalEnum, function(value, index) {
canonical.push({name: titleMap[value], value: value});
});
} else {
angular.forEach(titleMap, functi... | [
"function",
"(",
"titleMap",
",",
"originalEnum",
")",
"{",
"if",
"(",
"!",
"angular",
".",
"isArray",
"(",
"titleMap",
")",
")",
"{",
"var",
"canonical",
"=",
"[",
"]",
";",
"if",
"(",
"originalEnum",
")",
"{",
"angular",
".",
"forEach",
"(",
"origi... | Takes a titleMap in either object or list format and returns one in in the list format. | [
"Takes",
"a",
"titleMap",
"in",
"either",
"object",
"or",
"list",
"format",
"and",
"returns",
"one",
"in",
"in",
"the",
"list",
"format",
"."
] | 943c45ddd9aaa4f3136e1ba4c2593aa0289daf43 | https://github.com/pagespace/pagespace/blob/943c45ddd9aaa4f3136e1ba4c2593aa0289daf43/static/bower_components/angular-schema-form/dist/schema-form.js#L1032-L1047 | train | |
pagespace/pagespace | static/bower_components/angular-schema-form/dist/schema-form.js | function(name, schema, options) {
options = options || {};
var f = options.global && options.global.formDefaults ?
angular.copy(options.global.formDefaults) : {};
if (options.global && options.global.supressPropertyTitles === true) {
f.title = schema.title;
} else {
f.title = sch... | javascript | function(name, schema, options) {
options = options || {};
var f = options.global && options.global.formDefaults ?
angular.copy(options.global.formDefaults) : {};
if (options.global && options.global.supressPropertyTitles === true) {
f.title = schema.title;
} else {
f.title = sch... | [
"function",
"(",
"name",
",",
"schema",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"var",
"f",
"=",
"options",
".",
"global",
"&&",
"options",
".",
"global",
".",
"formDefaults",
"?",
"angular",
".",
"copy",
"(",
"optio... | Creates a form object with all common properties | [
"Creates",
"a",
"form",
"object",
"with",
"all",
"common",
"properties"
] | 943c45ddd9aaa4f3136e1ba4c2593aa0289daf43 | https://github.com/pagespace/pagespace/blob/943c45ddd9aaa4f3136e1ba4c2593aa0289daf43/static/bower_components/angular-schema-form/dist/schema-form.js#L1071-L1100 | train | |
pagespace/pagespace | static/bower_components/angular-schema-form/dist/schema-form.js | function(arr) {
scope.titleMapValues = [];
arr = arr || [];
form.titleMap.forEach(function(item) {
scope.titleMapValues.push(arr.indexOf(item.value) !== -1);
});
} | javascript | function(arr) {
scope.titleMapValues = [];
arr = arr || [];
form.titleMap.forEach(function(item) {
scope.titleMapValues.push(arr.indexOf(item.value) !== -1);
});
} | [
"function",
"(",
"arr",
")",
"{",
"scope",
".",
"titleMapValues",
"=",
"[",
"]",
";",
"arr",
"=",
"arr",
"||",
"[",
"]",
";",
"form",
".",
"titleMap",
".",
"forEach",
"(",
"function",
"(",
"item",
")",
"{",
"scope",
".",
"titleMapValues",
".",
"pus... | We watch the model for changes and the titleMapValues to reflect the modelArray | [
"We",
"watch",
"the",
"model",
"for",
"changes",
"and",
"the",
"titleMapValues",
"to",
"reflect",
"the",
"modelArray"
] | 943c45ddd9aaa4f3136e1ba4c2593aa0289daf43 | https://github.com/pagespace/pagespace/blob/943c45ddd9aaa4f3136e1ba4c2593aa0289daf43/static/bower_components/angular-schema-form/dist/schema-form.js#L1787-L1794 | train | |
pagespace/pagespace | static/bower_components/angular-schema-form/dist/schema-form.js | function() {
//scope.modelArray = modelArray;
scope.modelArray = scope.$eval(attrs.sfNewArray);
// validateField method is exported by schema-validate
if (scope.ngModel && scope.ngModel.$pristine && scope.firstDigest &&
(!scope.options || scope.options.validateOnRender !== tr... | javascript | function() {
//scope.modelArray = modelArray;
scope.modelArray = scope.$eval(attrs.sfNewArray);
// validateField method is exported by schema-validate
if (scope.ngModel && scope.ngModel.$pristine && scope.firstDigest &&
(!scope.options || scope.options.validateOnRender !== tr... | [
"function",
"(",
")",
"{",
"//scope.modelArray = modelArray;",
"scope",
".",
"modelArray",
"=",
"scope",
".",
"$eval",
"(",
"attrs",
".",
"sfNewArray",
")",
";",
"// validateField method is exported by schema-validate",
"if",
"(",
"scope",
".",
"ngModel",
"&&",
"sco... | We need to have a ngModel to hook into validation. It doesn't really play well with arrays though so we both need to trigger validation and onChange. So we watch the value as well. But watching an array can be tricky. We wan't to know when it changes so we can validate, | [
"We",
"need",
"to",
"have",
"a",
"ngModel",
"to",
"hook",
"into",
"validation",
".",
"It",
"doesn",
"t",
"really",
"play",
"well",
"with",
"arrays",
"though",
"so",
"we",
"both",
"need",
"to",
"trigger",
"validation",
"and",
"onChange",
".",
"So",
"we",
... | 943c45ddd9aaa4f3136e1ba4c2593aa0289daf43 | https://github.com/pagespace/pagespace/blob/943c45ddd9aaa4f3136e1ba4c2593aa0289daf43/static/bower_components/angular-schema-form/dist/schema-form.js#L2285-L2295 | train | |
pagespace/pagespace | static/bower_components/angular-schema-form/dist/schema-form.js | function() {
var model = scope.modelArray;
if (!model) {
var selection = sfPath.parse(attrs.sfNewArray);
model = [];
sel(selection, scope, model);
scope.modelArray = model;
}
return model;
} | javascript | function() {
var model = scope.modelArray;
if (!model) {
var selection = sfPath.parse(attrs.sfNewArray);
model = [];
sel(selection, scope, model);
scope.modelArray = model;
}
return model;
} | [
"function",
"(",
")",
"{",
"var",
"model",
"=",
"scope",
".",
"modelArray",
";",
"if",
"(",
"!",
"model",
")",
"{",
"var",
"selection",
"=",
"sfPath",
".",
"parse",
"(",
"attrs",
".",
"sfNewArray",
")",
";",
"model",
"=",
"[",
"]",
";",
"sel",
"(... | If model is undefined make sure it gets set. | [
"If",
"model",
"is",
"undefined",
"make",
"sure",
"it",
"gets",
"set",
"."
] | 943c45ddd9aaa4f3136e1ba4c2593aa0289daf43 | https://github.com/pagespace/pagespace/blob/943c45ddd9aaa4f3136e1ba4c2593aa0289daf43/static/bower_components/angular-schema-form/dist/schema-form.js#L2308-L2317 | 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.