id
int32 0
58k
| repo
stringlengths 5
67
| path
stringlengths 4
116
| func_name
stringlengths 0
58
| original_string
stringlengths 52
373k
| language
stringclasses 1
value | code
stringlengths 52
373k
| code_tokens
sequence | docstring
stringlengths 4
11.8k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 86
226
|
---|---|---|---|---|---|---|---|---|---|---|---|
50,400 | icelab/attache-upload.js | lib/index.js | uploadRequest | function uploadRequest(res, fileObject, showProgress) {
var url = res.url;
var expiration = res.expiration;
var hmac = res.hmac;
var uuid = res.uuid;
var file = fileObject.file;
var uid = fileObject.uid;
var upload_url = buildUploadURL(url, uuid, expiration, hmac, file.name);
return new Promise(function (resolve, reject) {
reqs[uid] = _superagent2.default.put(upload_url).send(file).set({
'Accept': 'application/json',
'Content-Type': 'application/json'
}).on('progress', function (e) {
showProgress(e, fileObject);
}).end(function (err, res) {
delete reqs[uid];
// throw a custom error message
if (err) return reject(customError('uploadRequest', err));
resolve(res);
});
});
} | javascript | function uploadRequest(res, fileObject, showProgress) {
var url = res.url;
var expiration = res.expiration;
var hmac = res.hmac;
var uuid = res.uuid;
var file = fileObject.file;
var uid = fileObject.uid;
var upload_url = buildUploadURL(url, uuid, expiration, hmac, file.name);
return new Promise(function (resolve, reject) {
reqs[uid] = _superagent2.default.put(upload_url).send(file).set({
'Accept': 'application/json',
'Content-Type': 'application/json'
}).on('progress', function (e) {
showProgress(e, fileObject);
}).end(function (err, res) {
delete reqs[uid];
// throw a custom error message
if (err) return reject(customError('uploadRequest', err));
resolve(res);
});
});
} | [
"function",
"uploadRequest",
"(",
"res",
",",
"fileObject",
",",
"showProgress",
")",
"{",
"var",
"url",
"=",
"res",
".",
"url",
";",
"var",
"expiration",
"=",
"res",
".",
"expiration",
";",
"var",
"hmac",
"=",
"res",
".",
"hmac",
";",
"var",
"uuid",
"=",
"res",
".",
"uuid",
";",
"var",
"file",
"=",
"fileObject",
".",
"file",
";",
"var",
"uid",
"=",
"fileObject",
".",
"uid",
";",
"var",
"upload_url",
"=",
"buildUploadURL",
"(",
"url",
",",
"uuid",
",",
"expiration",
",",
"hmac",
",",
"file",
".",
"name",
")",
";",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"reqs",
"[",
"uid",
"]",
"=",
"_superagent2",
".",
"default",
".",
"put",
"(",
"upload_url",
")",
".",
"send",
"(",
"file",
")",
".",
"set",
"(",
"{",
"'Accept'",
":",
"'application/json'",
",",
"'Content-Type'",
":",
"'application/json'",
"}",
")",
".",
"on",
"(",
"'progress'",
",",
"function",
"(",
"e",
")",
"{",
"showProgress",
"(",
"e",
",",
"fileObject",
")",
";",
"}",
")",
".",
"end",
"(",
"function",
"(",
"err",
",",
"res",
")",
"{",
"delete",
"reqs",
"[",
"uid",
"]",
";",
"// throw a custom error message",
"if",
"(",
"err",
")",
"return",
"reject",
"(",
"customError",
"(",
"'uploadRequest'",
",",
"err",
")",
")",
";",
"resolve",
"(",
"res",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}"
] | uploadRequest
Assign an XHR request to the `reqs` hash using the `uid`.
@param {Object} res - the response from presignRequest()
@param {File Object} file
@param {Function} on progress event handler
@return {Promise} | [
"uploadRequest",
"Assign",
"an",
"XHR",
"request",
"to",
"the",
"reqs",
"hash",
"using",
"the",
"uid",
"."
] | ff40a9d8caa45c53e147c810dc7449de685fcaf4 | https://github.com/icelab/attache-upload.js/blob/ff40a9d8caa45c53e147c810dc7449de685fcaf4/lib/index.js#L146-L171 |
50,401 | tndinhbao/ngoto | index.spec.js | parseMiddleware | function parseMiddleware(ctx, next) {
try {
ctx.event = JSON.parse(ctx.content.toString());
next();
} catch (e) {
throw e;
}
} | javascript | function parseMiddleware(ctx, next) {
try {
ctx.event = JSON.parse(ctx.content.toString());
next();
} catch (e) {
throw e;
}
} | [
"function",
"parseMiddleware",
"(",
"ctx",
",",
"next",
")",
"{",
"try",
"{",
"ctx",
".",
"event",
"=",
"JSON",
".",
"parse",
"(",
"ctx",
".",
"content",
".",
"toString",
"(",
")",
")",
";",
"next",
"(",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"throw",
"e",
";",
"}",
"}"
] | Parse JSON middleware
@param {String} msg | [
"Parse",
"JSON",
"middleware"
] | ed9877af5b31cb7afaebb4da2c497b3342d61f3c | https://github.com/tndinhbao/ngoto/blob/ed9877af5b31cb7afaebb4da2c497b3342d61f3c/index.spec.js#L27-L34 |
50,402 | MakerCollider/node-red-contrib-smartnode-hook | html/scripts/RGraph/RGraph.common.resizing.js | function (e)
{
if (!RGraph.Resizing || !RGraph.Resizing.div || !RGraph.Resizing.mousedown) {
return;
}
if (RGraph.Resizing.div) {
var div = RGraph.Resizing.div;
var canvas = div.__canvas__;
var coords = RGraph.getCanvasXY(div.__canvas__);
var parentNode = canvas.parentNode;
if (canvas.style.position != 'absolute') {
// Create a DIV to go in the canvases place
var placeHolderDIV = document.createElement('DIV');
placeHolderDIV.style.width = RGraph.Resizing.originalw + 'px';
placeHolderDIV.style.height = RGraph.Resizing.originalh + 'px';
//placeHolderDIV.style.backgroundColor = 'red';
placeHolderDIV.style.display = 'inline-block'; // Added 5th Nov 2010
placeHolderDIV.style.position = canvas.style.position;
placeHolderDIV.style.left = canvas.style.left;
placeHolderDIV.style.top = canvas.style.top;
placeHolderDIV.style.cssFloat = canvas.style.cssFloat;
parentNode.insertBefore(placeHolderDIV, canvas);
}
// Now set the canvas to be positioned absolutely
canvas.style.backgroundColor = 'white';
canvas.style.position = 'absolute';
canvas.style.border = '1px dashed gray';
canvas.style.left = (RGraph.Resizing.originalCanvasX - 1) + 'px';
canvas.style.top = (RGraph.Resizing.originalCanvasY - 1) + 'px';
/**
* Set the dimensions of the canvas using the HTML attributes
*/
canvas.width = parseInt(div.style.width);
canvas.height = parseInt(div.style.height);
/**
* Because resizing the canvas resets any tranformation - the antialias fix needs to be reapplied.
*/
canvas.getContext('2d').translate(0.5,0.5);
/**
* Reset the gradient parsing status by setting all of the color values back to their original
* values before Draw was first called
*/
var objects = RGraph.ObjectRegistry.getObjectsByCanvasID(canvas.id);
for (var i=0,len=objects.length; i<len; i+=1) {
RGraph.resetColorsToOriginalValues(objects[i]);
if (typeof objects[i].reset === 'function') {
objects[i].reset();
}
}
/**
* Kill the background cache
*/
RGraph.cache = [];
/**
* Fire the onresize event
*/
RGraph.FireCustomEvent(canvas.__object__, 'onresizebeforedraw');
RGraph.RedrawCanvas(canvas);
// Get rid of transparent semi-opaque DIV
RGraph.Resizing.mousedown = false;
div.style.display = 'none';
document.body.removeChild(div);
}
/**
* If there is zoom enabled in thumbnail mode, lose the zoom image
*/
if (RGraph.Registry.Get('chart.zoomed.div') || RGraph.Registry.Get('chart.zoomed.img')) {
RGraph.Registry.Set('chart.zoomed.div', null);
RGraph.Registry.Set('chart.zoomed.img', null);
}
/**
* Fire the onresize event
*/
RGraph.FireCustomEvent(canvas.__object__, 'onresizeend');
} | javascript | function (e)
{
if (!RGraph.Resizing || !RGraph.Resizing.div || !RGraph.Resizing.mousedown) {
return;
}
if (RGraph.Resizing.div) {
var div = RGraph.Resizing.div;
var canvas = div.__canvas__;
var coords = RGraph.getCanvasXY(div.__canvas__);
var parentNode = canvas.parentNode;
if (canvas.style.position != 'absolute') {
// Create a DIV to go in the canvases place
var placeHolderDIV = document.createElement('DIV');
placeHolderDIV.style.width = RGraph.Resizing.originalw + 'px';
placeHolderDIV.style.height = RGraph.Resizing.originalh + 'px';
//placeHolderDIV.style.backgroundColor = 'red';
placeHolderDIV.style.display = 'inline-block'; // Added 5th Nov 2010
placeHolderDIV.style.position = canvas.style.position;
placeHolderDIV.style.left = canvas.style.left;
placeHolderDIV.style.top = canvas.style.top;
placeHolderDIV.style.cssFloat = canvas.style.cssFloat;
parentNode.insertBefore(placeHolderDIV, canvas);
}
// Now set the canvas to be positioned absolutely
canvas.style.backgroundColor = 'white';
canvas.style.position = 'absolute';
canvas.style.border = '1px dashed gray';
canvas.style.left = (RGraph.Resizing.originalCanvasX - 1) + 'px';
canvas.style.top = (RGraph.Resizing.originalCanvasY - 1) + 'px';
/**
* Set the dimensions of the canvas using the HTML attributes
*/
canvas.width = parseInt(div.style.width);
canvas.height = parseInt(div.style.height);
/**
* Because resizing the canvas resets any tranformation - the antialias fix needs to be reapplied.
*/
canvas.getContext('2d').translate(0.5,0.5);
/**
* Reset the gradient parsing status by setting all of the color values back to their original
* values before Draw was first called
*/
var objects = RGraph.ObjectRegistry.getObjectsByCanvasID(canvas.id);
for (var i=0,len=objects.length; i<len; i+=1) {
RGraph.resetColorsToOriginalValues(objects[i]);
if (typeof objects[i].reset === 'function') {
objects[i].reset();
}
}
/**
* Kill the background cache
*/
RGraph.cache = [];
/**
* Fire the onresize event
*/
RGraph.FireCustomEvent(canvas.__object__, 'onresizebeforedraw');
RGraph.RedrawCanvas(canvas);
// Get rid of transparent semi-opaque DIV
RGraph.Resizing.mousedown = false;
div.style.display = 'none';
document.body.removeChild(div);
}
/**
* If there is zoom enabled in thumbnail mode, lose the zoom image
*/
if (RGraph.Registry.Get('chart.zoomed.div') || RGraph.Registry.Get('chart.zoomed.img')) {
RGraph.Registry.Set('chart.zoomed.div', null);
RGraph.Registry.Set('chart.zoomed.img', null);
}
/**
* Fire the onresize event
*/
RGraph.FireCustomEvent(canvas.__object__, 'onresizeend');
} | [
"function",
"(",
"e",
")",
"{",
"if",
"(",
"!",
"RGraph",
".",
"Resizing",
"||",
"!",
"RGraph",
".",
"Resizing",
".",
"div",
"||",
"!",
"RGraph",
".",
"Resizing",
".",
"mousedown",
")",
"{",
"return",
";",
"}",
"if",
"(",
"RGraph",
".",
"Resizing",
".",
"div",
")",
"{",
"var",
"div",
"=",
"RGraph",
".",
"Resizing",
".",
"div",
";",
"var",
"canvas",
"=",
"div",
".",
"__canvas__",
";",
"var",
"coords",
"=",
"RGraph",
".",
"getCanvasXY",
"(",
"div",
".",
"__canvas__",
")",
";",
"var",
"parentNode",
"=",
"canvas",
".",
"parentNode",
";",
"if",
"(",
"canvas",
".",
"style",
".",
"position",
"!=",
"'absolute'",
")",
"{",
"// Create a DIV to go in the canvases place",
"var",
"placeHolderDIV",
"=",
"document",
".",
"createElement",
"(",
"'DIV'",
")",
";",
"placeHolderDIV",
".",
"style",
".",
"width",
"=",
"RGraph",
".",
"Resizing",
".",
"originalw",
"+",
"'px'",
";",
"placeHolderDIV",
".",
"style",
".",
"height",
"=",
"RGraph",
".",
"Resizing",
".",
"originalh",
"+",
"'px'",
";",
"//placeHolderDIV.style.backgroundColor = 'red';",
"placeHolderDIV",
".",
"style",
".",
"display",
"=",
"'inline-block'",
";",
"// Added 5th Nov 2010",
"placeHolderDIV",
".",
"style",
".",
"position",
"=",
"canvas",
".",
"style",
".",
"position",
";",
"placeHolderDIV",
".",
"style",
".",
"left",
"=",
"canvas",
".",
"style",
".",
"left",
";",
"placeHolderDIV",
".",
"style",
".",
"top",
"=",
"canvas",
".",
"style",
".",
"top",
";",
"placeHolderDIV",
".",
"style",
".",
"cssFloat",
"=",
"canvas",
".",
"style",
".",
"cssFloat",
";",
"parentNode",
".",
"insertBefore",
"(",
"placeHolderDIV",
",",
"canvas",
")",
";",
"}",
"// Now set the canvas to be positioned absolutely",
"canvas",
".",
"style",
".",
"backgroundColor",
"=",
"'white'",
";",
"canvas",
".",
"style",
".",
"position",
"=",
"'absolute'",
";",
"canvas",
".",
"style",
".",
"border",
"=",
"'1px dashed gray'",
";",
"canvas",
".",
"style",
".",
"left",
"=",
"(",
"RGraph",
".",
"Resizing",
".",
"originalCanvasX",
"-",
"1",
")",
"+",
"'px'",
";",
"canvas",
".",
"style",
".",
"top",
"=",
"(",
"RGraph",
".",
"Resizing",
".",
"originalCanvasY",
"-",
"1",
")",
"+",
"'px'",
";",
"/**\n * Set the dimensions of the canvas using the HTML attributes\n */",
"canvas",
".",
"width",
"=",
"parseInt",
"(",
"div",
".",
"style",
".",
"width",
")",
";",
"canvas",
".",
"height",
"=",
"parseInt",
"(",
"div",
".",
"style",
".",
"height",
")",
";",
"/**\n * Because resizing the canvas resets any tranformation - the antialias fix needs to be reapplied.\n */",
"canvas",
".",
"getContext",
"(",
"'2d'",
")",
".",
"translate",
"(",
"0.5",
",",
"0.5",
")",
";",
"/**\n * Reset the gradient parsing status by setting all of the color values back to their original\n * values before Draw was first called\n */",
"var",
"objects",
"=",
"RGraph",
".",
"ObjectRegistry",
".",
"getObjectsByCanvasID",
"(",
"canvas",
".",
"id",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"objects",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"+=",
"1",
")",
"{",
"RGraph",
".",
"resetColorsToOriginalValues",
"(",
"objects",
"[",
"i",
"]",
")",
";",
"if",
"(",
"typeof",
"objects",
"[",
"i",
"]",
".",
"reset",
"===",
"'function'",
")",
"{",
"objects",
"[",
"i",
"]",
".",
"reset",
"(",
")",
";",
"}",
"}",
"/**\n * Kill the background cache\n */",
"RGraph",
".",
"cache",
"=",
"[",
"]",
";",
"/**\n * Fire the onresize event\n */",
"RGraph",
".",
"FireCustomEvent",
"(",
"canvas",
".",
"__object__",
",",
"'onresizebeforedraw'",
")",
";",
"RGraph",
".",
"RedrawCanvas",
"(",
"canvas",
")",
";",
"// Get rid of transparent semi-opaque DIV",
"RGraph",
".",
"Resizing",
".",
"mousedown",
"=",
"false",
";",
"div",
".",
"style",
".",
"display",
"=",
"'none'",
";",
"document",
".",
"body",
".",
"removeChild",
"(",
"div",
")",
";",
"}",
"/**\n * If there is zoom enabled in thumbnail mode, lose the zoom image\n */",
"if",
"(",
"RGraph",
".",
"Registry",
".",
"Get",
"(",
"'chart.zoomed.div'",
")",
"||",
"RGraph",
".",
"Registry",
".",
"Get",
"(",
"'chart.zoomed.img'",
")",
")",
"{",
"RGraph",
".",
"Registry",
".",
"Set",
"(",
"'chart.zoomed.div'",
",",
"null",
")",
";",
"RGraph",
".",
"Registry",
".",
"Set",
"(",
"'chart.zoomed.img'",
",",
"null",
")",
";",
"}",
"/**\n * Fire the onresize event\n */",
"RGraph",
".",
"FireCustomEvent",
"(",
"canvas",
".",
"__object__",
",",
"'onresizeend'",
")",
";",
"}"
] | The window onmouseup function | [
"The",
"window",
"onmouseup",
"function"
] | 245c267e832968bad880ca009929043e82c7bc25 | https://github.com/MakerCollider/node-red-contrib-smartnode-hook/blob/245c267e832968bad880ca009929043e82c7bc25/html/scripts/RGraph/RGraph.common.resizing.js#L184-L283 |
|
50,403 | aureooms/js-random | lib/kernel/_shuffle.js | _shuffle | function _shuffle(sample) {
var shuffle = function shuffle(a, i, j) {
sample(j - i, a, i, j);
};
return shuffle;
} | javascript | function _shuffle(sample) {
var shuffle = function shuffle(a, i, j) {
sample(j - i, a, i, j);
};
return shuffle;
} | [
"function",
"_shuffle",
"(",
"sample",
")",
"{",
"var",
"shuffle",
"=",
"function",
"shuffle",
"(",
"a",
",",
"i",
",",
"j",
")",
"{",
"sample",
"(",
"j",
"-",
"i",
",",
"a",
",",
"i",
",",
"j",
")",
";",
"}",
";",
"return",
"shuffle",
";",
"}"
] | Shuffle array by sampling the complete array. | [
"Shuffle",
"array",
"by",
"sampling",
"the",
"complete",
"array",
"."
] | 4bc04ed5ddb90494d02d04ef4633915d383b9931 | https://github.com/aureooms/js-random/blob/4bc04ed5ddb90494d02d04ef4633915d383b9931/lib/kernel/_shuffle.js#L12-L19 |
50,404 | me-box-archive/nodeZestClient | zest.js | function (token, path, payload, contentFormat) {
return new Promise((resolve,reject)=>{
let zh = NewZestHeader();
zh.code = 2;
zh.token = token;
zh.tkl = token.length;
zh.payload = payload;
zh.oc = 3;
zh.options.push(NewZestOptionHeader(11,path,path.length));
let hostname = os.hostname();
zh.options.push(NewZestOptionHeader(3,hostname,hostname.length));
zh.options.push(NewZestOptionHeader(12,contentFormatToInt(contentFormat),2)); //uint32
let msg = MarshalZestHeader(zh)
sendRequestAndAwaitResponse(this.ZMQsoc,msg)
.then((resp)=>{
handleResponse(resp,(zh)=>{resolve(zh.payload)},reject);
})
.catch((err)=>{
reject(err);
});
});
} | javascript | function (token, path, payload, contentFormat) {
return new Promise((resolve,reject)=>{
let zh = NewZestHeader();
zh.code = 2;
zh.token = token;
zh.tkl = token.length;
zh.payload = payload;
zh.oc = 3;
zh.options.push(NewZestOptionHeader(11,path,path.length));
let hostname = os.hostname();
zh.options.push(NewZestOptionHeader(3,hostname,hostname.length));
zh.options.push(NewZestOptionHeader(12,contentFormatToInt(contentFormat),2)); //uint32
let msg = MarshalZestHeader(zh)
sendRequestAndAwaitResponse(this.ZMQsoc,msg)
.then((resp)=>{
handleResponse(resp,(zh)=>{resolve(zh.payload)},reject);
})
.catch((err)=>{
reject(err);
});
});
} | [
"function",
"(",
"token",
",",
"path",
",",
"payload",
",",
"contentFormat",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"let",
"zh",
"=",
"NewZestHeader",
"(",
")",
";",
"zh",
".",
"code",
"=",
"2",
";",
"zh",
".",
"token",
"=",
"token",
";",
"zh",
".",
"tkl",
"=",
"token",
".",
"length",
";",
"zh",
".",
"payload",
"=",
"payload",
";",
"zh",
".",
"oc",
"=",
"3",
";",
"zh",
".",
"options",
".",
"push",
"(",
"NewZestOptionHeader",
"(",
"11",
",",
"path",
",",
"path",
".",
"length",
")",
")",
";",
"let",
"hostname",
"=",
"os",
".",
"hostname",
"(",
")",
";",
"zh",
".",
"options",
".",
"push",
"(",
"NewZestOptionHeader",
"(",
"3",
",",
"hostname",
",",
"hostname",
".",
"length",
")",
")",
";",
"zh",
".",
"options",
".",
"push",
"(",
"NewZestOptionHeader",
"(",
"12",
",",
"contentFormatToInt",
"(",
"contentFormat",
")",
",",
"2",
")",
")",
";",
"//uint32",
"let",
"msg",
"=",
"MarshalZestHeader",
"(",
"zh",
")",
"sendRequestAndAwaitResponse",
"(",
"this",
".",
"ZMQsoc",
",",
"msg",
")",
".",
"then",
"(",
"(",
"resp",
")",
"=>",
"{",
"handleResponse",
"(",
"resp",
",",
"(",
"zh",
")",
"=>",
"{",
"resolve",
"(",
"zh",
".",
"payload",
")",
"}",
",",
"reject",
")",
";",
"}",
")",
".",
"catch",
"(",
"(",
"err",
")",
"=>",
"{",
"reject",
"(",
"err",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}"
] | a dict to keep track of observers so they can be closed | [
"a",
"dict",
"to",
"keep",
"track",
"of",
"observers",
"so",
"they",
"can",
"be",
"closed"
] | 4c2ef36f4bd21d9cbf4cdde74fd030ec7c807dd6 | https://github.com/me-box-archive/nodeZestClient/blob/4c2ef36f4bd21d9cbf4cdde74fd030ec7c807dd6/zest.js#L27-L50 |
|
50,405 | kulakowka/mithril-firebase-mixin | index.js | positionAfter | function positionAfter (arr, prevChild) {
var idx
if (prevChild === null) {
return 0
} else {
idx = findIndex(arr, prevChild)
return (idx === -1) ? arr.length : idx + 1
}
} | javascript | function positionAfter (arr, prevChild) {
var idx
if (prevChild === null) {
return 0
} else {
idx = findIndex(arr, prevChild)
return (idx === -1) ? arr.length : idx + 1
}
} | [
"function",
"positionAfter",
"(",
"arr",
",",
"prevChild",
")",
"{",
"var",
"idx",
"if",
"(",
"prevChild",
"===",
"null",
")",
"{",
"return",
"0",
"}",
"else",
"{",
"idx",
"=",
"findIndex",
"(",
"arr",
",",
"prevChild",
")",
"return",
"(",
"idx",
"===",
"-",
"1",
")",
"?",
"arr",
".",
"length",
":",
"idx",
"+",
"1",
"}",
"}"
] | using the Firebase API's prevChild behavior, we place each element in the list after it's prev sibling or, if prevChild is null, at the beginning | [
"using",
"the",
"Firebase",
"API",
"s",
"prevChild",
"behavior",
"we",
"place",
"each",
"element",
"in",
"the",
"list",
"after",
"it",
"s",
"prev",
"sibling",
"or",
"if",
"prevChild",
"is",
"null",
"at",
"the",
"beginning"
] | d1ad7fde3918bed7df823b2da853d53a0f1358e9 | https://github.com/kulakowka/mithril-firebase-mixin/blob/d1ad7fde3918bed7df823b2da853d53a0f1358e9/index.js#L31-L39 |
50,406 | aarki/grunt-lessvars | tasks/lib/extractor.js | toJS | function toJS(node, options, context) {
switch (node.type) {
// process numeric values and units
case 'Dimension':
var value = node.value;
var unit = options.units ? node.unit.toCSS(context) : null;
// if given a list of units to preserve, check if compiled unit is present in that list
if (Array.isArray(options.units)) unit = options.units.includes(unit) && unit;
// if we should keep the units, compile the entire node to perform necessary checks,
// otherwise just return the node value
return unit ? node.toCSS(context) : value;
// drop quotes from quoted values
case 'Quoted':
return node.value;
// recursively transform expressions into arrays
case 'Expression':
return node.value.map(function (child) {
return toJS(child, options, context);
});
}
return node.toCSS(context);
} | javascript | function toJS(node, options, context) {
switch (node.type) {
// process numeric values and units
case 'Dimension':
var value = node.value;
var unit = options.units ? node.unit.toCSS(context) : null;
// if given a list of units to preserve, check if compiled unit is present in that list
if (Array.isArray(options.units)) unit = options.units.includes(unit) && unit;
// if we should keep the units, compile the entire node to perform necessary checks,
// otherwise just return the node value
return unit ? node.toCSS(context) : value;
// drop quotes from quoted values
case 'Quoted':
return node.value;
// recursively transform expressions into arrays
case 'Expression':
return node.value.map(function (child) {
return toJS(child, options, context);
});
}
return node.toCSS(context);
} | [
"function",
"toJS",
"(",
"node",
",",
"options",
",",
"context",
")",
"{",
"switch",
"(",
"node",
".",
"type",
")",
"{",
"// process numeric values and units",
"case",
"'Dimension'",
":",
"var",
"value",
"=",
"node",
".",
"value",
";",
"var",
"unit",
"=",
"options",
".",
"units",
"?",
"node",
".",
"unit",
".",
"toCSS",
"(",
"context",
")",
":",
"null",
";",
"// if given a list of units to preserve, check if compiled unit is present in that list",
"if",
"(",
"Array",
".",
"isArray",
"(",
"options",
".",
"units",
")",
")",
"unit",
"=",
"options",
".",
"units",
".",
"includes",
"(",
"unit",
")",
"&&",
"unit",
";",
"// if we should keep the units, compile the entire node to perform necessary checks,",
"// otherwise just return the node value",
"return",
"unit",
"?",
"node",
".",
"toCSS",
"(",
"context",
")",
":",
"value",
";",
"// drop quotes from quoted values",
"case",
"'Quoted'",
":",
"return",
"node",
".",
"value",
";",
"// recursively transform expressions into arrays",
"case",
"'Expression'",
":",
"return",
"node",
".",
"value",
".",
"map",
"(",
"function",
"(",
"child",
")",
"{",
"return",
"toJS",
"(",
"child",
",",
"options",
",",
"context",
")",
";",
"}",
")",
";",
"}",
"return",
"node",
".",
"toCSS",
"(",
"context",
")",
";",
"}"
] | modify how value nodes are coerced into JS values, if different from CSS | [
"modify",
"how",
"value",
"nodes",
"are",
"coerced",
"into",
"JS",
"values",
"if",
"different",
"from",
"CSS"
] | 9e4f5a5ef2df62f9633b7278dc67361398bb601b | https://github.com/aarki/grunt-lessvars/blob/9e4f5a5ef2df62f9633b7278dc67361398bb601b/tasks/lib/extractor.js#L99-L125 |
50,407 | andrewscwei/requiem | src/dom/createElement.js | createElement | function createElement(value) {
if (!document) return null;
assertType(value, 'string', true, 'Value must be a string');
if (value.match(/^([a-z0-9]+-)+[a-z0-9]+$/)) {
return new (getElementRegistry(value))();
}
else {
let div = document.createElement('div');
if (value.indexOf('<') !== 0 && value.indexOf('>') !== (value.length - 1)) value = `<${value}>`;
div.innerHTML = value;
return div.firstChild;
}
} | javascript | function createElement(value) {
if (!document) return null;
assertType(value, 'string', true, 'Value must be a string');
if (value.match(/^([a-z0-9]+-)+[a-z0-9]+$/)) {
return new (getElementRegistry(value))();
}
else {
let div = document.createElement('div');
if (value.indexOf('<') !== 0 && value.indexOf('>') !== (value.length - 1)) value = `<${value}>`;
div.innerHTML = value;
return div.firstChild;
}
} | [
"function",
"createElement",
"(",
"value",
")",
"{",
"if",
"(",
"!",
"document",
")",
"return",
"null",
";",
"assertType",
"(",
"value",
",",
"'string'",
",",
"true",
",",
"'Value must be a string'",
")",
";",
"if",
"(",
"value",
".",
"match",
"(",
"/",
"^([a-z0-9]+-)+[a-z0-9]+$",
"/",
")",
")",
"{",
"return",
"new",
"(",
"getElementRegistry",
"(",
"value",
")",
")",
"(",
")",
";",
"}",
"else",
"{",
"let",
"div",
"=",
"document",
".",
"createElement",
"(",
"'div'",
")",
";",
"if",
"(",
"value",
".",
"indexOf",
"(",
"'<'",
")",
"!==",
"0",
"&&",
"value",
".",
"indexOf",
"(",
"'>'",
")",
"!==",
"(",
"value",
".",
"length",
"-",
"1",
")",
")",
"value",
"=",
"`",
"${",
"value",
"}",
"`",
";",
"div",
".",
"innerHTML",
"=",
"value",
";",
"return",
"div",
".",
"firstChild",
";",
"}",
"}"
] | Creates a DOM element from the provided string.
@param {string} value - String describing the DOM element.
@return {Node} DOM element.
@alias module:requiem~dom.createElement | [
"Creates",
"a",
"DOM",
"element",
"from",
"the",
"provided",
"string",
"."
] | c4182bfffc9841c6de5718f689ad3c2060511777 | https://github.com/andrewscwei/requiem/blob/c4182bfffc9841c6de5718f689ad3c2060511777/src/dom/createElement.js#L17-L31 |
50,408 | fengzilong/regular-router | src/installSync.js | install | function install(definition, Component) {
const Ctor = register(definition, Component);
// no dependencies
if (!definition.components) {
return Ctor;
}
const components = definition.components || {};
// avoid unnecessary re-registering for next time
delete definition.components;
// register components
for (const name in components) {
Ctor.component(name, register(components[name], Component));
install(components[name], Component);
}
return Ctor;
} | javascript | function install(definition, Component) {
const Ctor = register(definition, Component);
// no dependencies
if (!definition.components) {
return Ctor;
}
const components = definition.components || {};
// avoid unnecessary re-registering for next time
delete definition.components;
// register components
for (const name in components) {
Ctor.component(name, register(components[name], Component));
install(components[name], Component);
}
return Ctor;
} | [
"function",
"install",
"(",
"definition",
",",
"Component",
")",
"{",
"const",
"Ctor",
"=",
"register",
"(",
"definition",
",",
"Component",
")",
";",
"// no dependencies",
"if",
"(",
"!",
"definition",
".",
"components",
")",
"{",
"return",
"Ctor",
";",
"}",
"const",
"components",
"=",
"definition",
".",
"components",
"||",
"{",
"}",
";",
"// avoid unnecessary re-registering for next time",
"delete",
"definition",
".",
"components",
";",
"// register components",
"for",
"(",
"const",
"name",
"in",
"components",
")",
"{",
"Ctor",
".",
"component",
"(",
"name",
",",
"register",
"(",
"components",
"[",
"name",
"]",
",",
"Component",
")",
")",
";",
"install",
"(",
"components",
"[",
"name",
"]",
",",
"Component",
")",
";",
"}",
"return",
"Ctor",
";",
"}"
] | install single component | [
"install",
"single",
"component"
] | 897a6c571a935cec31dd0e51da0fb39f61e3a5d3 | https://github.com/fengzilong/regular-router/blob/897a6c571a935cec31dd0e51da0fb39f61e3a5d3/src/installSync.js#L6-L26 |
50,409 | webmarketingroi/optimizely-x-node | lib/OptimizelyClient.js | parseHttpHeaders | function parseHttpHeaders(headers) {
var meta = {};
for (var headerName in headers) {
var headerValue = headers[headerName];
if (headerName=="x-ratelimit-limit") {
meta.rateLimit = headerValue;
} else if (headerName=="x-ratelimit-remaining") {
meta.rateLimitRemaining = headerValue;
} else if (headerName=="x-ratelimit-reset") {
meta.rateLimitReset = headerValue;
} else if (headerName=="link") {
var regexp = /<(.+)>; rel=(.+),?/g;
var match;
do {
match = regexp.exec(headerValue);
if (match) {
var url = match[1];
var rel = match[2];
var regexp2 = /[\?|&]page=(\d+)/;
var match2 = regexp2.exec(url);
if (match2) {
var page = match2[1];
if (rel=='prev') {
meta.prevPage = page;
} else if (rel=='next') {
meta.nextPage = page;
} else if (rel=='last') {
meta.lastPage = page;
}
}
}
} while (match);
}
}
return meta;
} | javascript | function parseHttpHeaders(headers) {
var meta = {};
for (var headerName in headers) {
var headerValue = headers[headerName];
if (headerName=="x-ratelimit-limit") {
meta.rateLimit = headerValue;
} else if (headerName=="x-ratelimit-remaining") {
meta.rateLimitRemaining = headerValue;
} else if (headerName=="x-ratelimit-reset") {
meta.rateLimitReset = headerValue;
} else if (headerName=="link") {
var regexp = /<(.+)>; rel=(.+),?/g;
var match;
do {
match = regexp.exec(headerValue);
if (match) {
var url = match[1];
var rel = match[2];
var regexp2 = /[\?|&]page=(\d+)/;
var match2 = regexp2.exec(url);
if (match2) {
var page = match2[1];
if (rel=='prev') {
meta.prevPage = page;
} else if (rel=='next') {
meta.nextPage = page;
} else if (rel=='last') {
meta.lastPage = page;
}
}
}
} while (match);
}
}
return meta;
} | [
"function",
"parseHttpHeaders",
"(",
"headers",
")",
"{",
"var",
"meta",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"headerName",
"in",
"headers",
")",
"{",
"var",
"headerValue",
"=",
"headers",
"[",
"headerName",
"]",
";",
"if",
"(",
"headerName",
"==",
"\"x-ratelimit-limit\"",
")",
"{",
"meta",
".",
"rateLimit",
"=",
"headerValue",
";",
"}",
"else",
"if",
"(",
"headerName",
"==",
"\"x-ratelimit-remaining\"",
")",
"{",
"meta",
".",
"rateLimitRemaining",
"=",
"headerValue",
";",
"}",
"else",
"if",
"(",
"headerName",
"==",
"\"x-ratelimit-reset\"",
")",
"{",
"meta",
".",
"rateLimitReset",
"=",
"headerValue",
";",
"}",
"else",
"if",
"(",
"headerName",
"==",
"\"link\"",
")",
"{",
"var",
"regexp",
"=",
"/",
"<(.+)>; rel=(.+),?",
"/",
"g",
";",
"var",
"match",
";",
"do",
"{",
"match",
"=",
"regexp",
".",
"exec",
"(",
"headerValue",
")",
";",
"if",
"(",
"match",
")",
"{",
"var",
"url",
"=",
"match",
"[",
"1",
"]",
";",
"var",
"rel",
"=",
"match",
"[",
"2",
"]",
";",
"var",
"regexp2",
"=",
"/",
"[\\?|&]page=(\\d+)",
"/",
";",
"var",
"match2",
"=",
"regexp2",
".",
"exec",
"(",
"url",
")",
";",
"if",
"(",
"match2",
")",
"{",
"var",
"page",
"=",
"match2",
"[",
"1",
"]",
";",
"if",
"(",
"rel",
"==",
"'prev'",
")",
"{",
"meta",
".",
"prevPage",
"=",
"page",
";",
"}",
"else",
"if",
"(",
"rel",
"==",
"'next'",
")",
"{",
"meta",
".",
"nextPage",
"=",
"page",
";",
"}",
"else",
"if",
"(",
"rel",
"==",
"'last'",
")",
"{",
"meta",
".",
"lastPage",
"=",
"page",
";",
"}",
"}",
"}",
"}",
"while",
"(",
"match",
")",
";",
"}",
"}",
"return",
"meta",
";",
"}"
] | Private function that retrieves meta information from HTTP headers. | [
"Private",
"function",
"that",
"retrieves",
"meta",
"information",
"from",
"HTTP",
"headers",
"."
] | 64ac76f2aa44630c3d871d5003016f4910078c5e | https://github.com/webmarketingroi/optimizely-x-node/blob/64ac76f2aa44630c3d871d5003016f4910078c5e/lib/OptimizelyClient.js#L158-L197 |
50,410 | wavesoft/jbb-profile-three | profile-encode.js | getter_THREE_CubeTexture | function getter_THREE_CubeTexture(inst) {
return [
inst.name,
inst.mipmaps,
inst.flipY,
inst.mapping,
inst.wrapS,
inst.wrapT,
inst.magFilter,
inst.minFilter,
inst.anisotropy,
inst.format,
inst.type,
inst.offset,
inst.repeat,
inst.unpackAlignment,
inst.image];
} | javascript | function getter_THREE_CubeTexture(inst) {
return [
inst.name,
inst.mipmaps,
inst.flipY,
inst.mapping,
inst.wrapS,
inst.wrapT,
inst.magFilter,
inst.minFilter,
inst.anisotropy,
inst.format,
inst.type,
inst.offset,
inst.repeat,
inst.unpackAlignment,
inst.image];
} | [
"function",
"getter_THREE_CubeTexture",
"(",
"inst",
")",
"{",
"return",
"[",
"inst",
".",
"name",
",",
"inst",
".",
"mipmaps",
",",
"inst",
".",
"flipY",
",",
"inst",
".",
"mapping",
",",
"inst",
".",
"wrapS",
",",
"inst",
".",
"wrapT",
",",
"inst",
".",
"magFilter",
",",
"inst",
".",
"minFilter",
",",
"inst",
".",
"anisotropy",
",",
"inst",
".",
"format",
",",
"inst",
".",
"type",
",",
"inst",
".",
"offset",
",",
"inst",
".",
"repeat",
",",
"inst",
".",
"unpackAlignment",
",",
"inst",
".",
"image",
"]",
";",
"}"
] | Property getter THREE.CubeTexture | [
"Property",
"getter",
"THREE",
".",
"CubeTexture"
] | 8539cfbb2d04b67999eee6e530fcaf03083e0e04 | https://github.com/wavesoft/jbb-profile-three/blob/8539cfbb2d04b67999eee6e530fcaf03083e0e04/profile-encode.js#L30-L47 |
50,411 | wavesoft/jbb-profile-three | profile-encode.js | getter_THREE_LineBasicMaterial | function getter_THREE_LineBasicMaterial(inst) {
return [
inst.name,
inst.side,
inst.opacity,
inst.blending,
inst.blendSrc,
inst.blendDst,
inst.blendEquation,
inst.depthFunc,
inst.polygonOffsetFactor,
inst.polygonOffsetUnits,
inst.alphaTest,
inst.overdraw,
inst.blendSrcAlpha,
inst.blendDstAlpha,
inst.blendEquationAlpha,
inst.transparent,
inst.depthTest,
inst.depthWrite,
inst.colorWrite,
inst.polygonOffset,
inst.visible,
inst.precision,
inst.color,
inst.linewidth,
inst.linecap,
inst.linejoin,
inst.vertexColors,
inst.fog];
} | javascript | function getter_THREE_LineBasicMaterial(inst) {
return [
inst.name,
inst.side,
inst.opacity,
inst.blending,
inst.blendSrc,
inst.blendDst,
inst.blendEquation,
inst.depthFunc,
inst.polygonOffsetFactor,
inst.polygonOffsetUnits,
inst.alphaTest,
inst.overdraw,
inst.blendSrcAlpha,
inst.blendDstAlpha,
inst.blendEquationAlpha,
inst.transparent,
inst.depthTest,
inst.depthWrite,
inst.colorWrite,
inst.polygonOffset,
inst.visible,
inst.precision,
inst.color,
inst.linewidth,
inst.linecap,
inst.linejoin,
inst.vertexColors,
inst.fog];
} | [
"function",
"getter_THREE_LineBasicMaterial",
"(",
"inst",
")",
"{",
"return",
"[",
"inst",
".",
"name",
",",
"inst",
".",
"side",
",",
"inst",
".",
"opacity",
",",
"inst",
".",
"blending",
",",
"inst",
".",
"blendSrc",
",",
"inst",
".",
"blendDst",
",",
"inst",
".",
"blendEquation",
",",
"inst",
".",
"depthFunc",
",",
"inst",
".",
"polygonOffsetFactor",
",",
"inst",
".",
"polygonOffsetUnits",
",",
"inst",
".",
"alphaTest",
",",
"inst",
".",
"overdraw",
",",
"inst",
".",
"blendSrcAlpha",
",",
"inst",
".",
"blendDstAlpha",
",",
"inst",
".",
"blendEquationAlpha",
",",
"inst",
".",
"transparent",
",",
"inst",
".",
"depthTest",
",",
"inst",
".",
"depthWrite",
",",
"inst",
".",
"colorWrite",
",",
"inst",
".",
"polygonOffset",
",",
"inst",
".",
"visible",
",",
"inst",
".",
"precision",
",",
"inst",
".",
"color",
",",
"inst",
".",
"linewidth",
",",
"inst",
".",
"linecap",
",",
"inst",
".",
"linejoin",
",",
"inst",
".",
"vertexColors",
",",
"inst",
".",
"fog",
"]",
";",
"}"
] | Property getter THREE.LineBasicMaterial | [
"Property",
"getter",
"THREE",
".",
"LineBasicMaterial"
] | 8539cfbb2d04b67999eee6e530fcaf03083e0e04 | https://github.com/wavesoft/jbb-profile-three/blob/8539cfbb2d04b67999eee6e530fcaf03083e0e04/profile-encode.js#L96-L126 |
50,412 | wavesoft/jbb-profile-three | profile-encode.js | getter_THREE_SpriteMaterial | function getter_THREE_SpriteMaterial(inst) {
return [
inst.name,
inst.side,
inst.opacity,
inst.blending,
inst.blendSrc,
inst.blendDst,
inst.blendEquation,
inst.depthFunc,
inst.polygonOffsetFactor,
inst.polygonOffsetUnits,
inst.alphaTest,
inst.overdraw,
inst.blendSrcAlpha,
inst.blendDstAlpha,
inst.blendEquationAlpha,
inst.transparent,
inst.depthTest,
inst.depthWrite,
inst.colorWrite,
inst.polygonOffset,
inst.visible,
inst.precision,
inst.color,
inst.map,
inst.rotation,
inst.fog];
} | javascript | function getter_THREE_SpriteMaterial(inst) {
return [
inst.name,
inst.side,
inst.opacity,
inst.blending,
inst.blendSrc,
inst.blendDst,
inst.blendEquation,
inst.depthFunc,
inst.polygonOffsetFactor,
inst.polygonOffsetUnits,
inst.alphaTest,
inst.overdraw,
inst.blendSrcAlpha,
inst.blendDstAlpha,
inst.blendEquationAlpha,
inst.transparent,
inst.depthTest,
inst.depthWrite,
inst.colorWrite,
inst.polygonOffset,
inst.visible,
inst.precision,
inst.color,
inst.map,
inst.rotation,
inst.fog];
} | [
"function",
"getter_THREE_SpriteMaterial",
"(",
"inst",
")",
"{",
"return",
"[",
"inst",
".",
"name",
",",
"inst",
".",
"side",
",",
"inst",
".",
"opacity",
",",
"inst",
".",
"blending",
",",
"inst",
".",
"blendSrc",
",",
"inst",
".",
"blendDst",
",",
"inst",
".",
"blendEquation",
",",
"inst",
".",
"depthFunc",
",",
"inst",
".",
"polygonOffsetFactor",
",",
"inst",
".",
"polygonOffsetUnits",
",",
"inst",
".",
"alphaTest",
",",
"inst",
".",
"overdraw",
",",
"inst",
".",
"blendSrcAlpha",
",",
"inst",
".",
"blendDstAlpha",
",",
"inst",
".",
"blendEquationAlpha",
",",
"inst",
".",
"transparent",
",",
"inst",
".",
"depthTest",
",",
"inst",
".",
"depthWrite",
",",
"inst",
".",
"colorWrite",
",",
"inst",
".",
"polygonOffset",
",",
"inst",
".",
"visible",
",",
"inst",
".",
"precision",
",",
"inst",
".",
"color",
",",
"inst",
".",
"map",
",",
"inst",
".",
"rotation",
",",
"inst",
".",
"fog",
"]",
";",
"}"
] | Property getter THREE.SpriteMaterial | [
"Property",
"getter",
"THREE",
".",
"SpriteMaterial"
] | 8539cfbb2d04b67999eee6e530fcaf03083e0e04 | https://github.com/wavesoft/jbb-profile-three/blob/8539cfbb2d04b67999eee6e530fcaf03083e0e04/profile-encode.js#L131-L159 |
50,413 | wavesoft/jbb-profile-three | profile-encode.js | getter_THREE_MeshDepthMaterial | function getter_THREE_MeshDepthMaterial(inst) {
return [
inst.name,
inst.side,
inst.opacity,
inst.blending,
inst.blendSrc,
inst.blendDst,
inst.blendEquation,
inst.depthFunc,
inst.polygonOffsetFactor,
inst.polygonOffsetUnits,
inst.alphaTest,
inst.overdraw,
inst.blendSrcAlpha,
inst.blendDstAlpha,
inst.blendEquationAlpha,
inst.transparent,
inst.depthTest,
inst.depthWrite,
inst.colorWrite,
inst.polygonOffset,
inst.visible,
inst.precision,
inst.wireframeLinewidth,
inst.wireframe,
inst.morphTargets];
} | javascript | function getter_THREE_MeshDepthMaterial(inst) {
return [
inst.name,
inst.side,
inst.opacity,
inst.blending,
inst.blendSrc,
inst.blendDst,
inst.blendEquation,
inst.depthFunc,
inst.polygonOffsetFactor,
inst.polygonOffsetUnits,
inst.alphaTest,
inst.overdraw,
inst.blendSrcAlpha,
inst.blendDstAlpha,
inst.blendEquationAlpha,
inst.transparent,
inst.depthTest,
inst.depthWrite,
inst.colorWrite,
inst.polygonOffset,
inst.visible,
inst.precision,
inst.wireframeLinewidth,
inst.wireframe,
inst.morphTargets];
} | [
"function",
"getter_THREE_MeshDepthMaterial",
"(",
"inst",
")",
"{",
"return",
"[",
"inst",
".",
"name",
",",
"inst",
".",
"side",
",",
"inst",
".",
"opacity",
",",
"inst",
".",
"blending",
",",
"inst",
".",
"blendSrc",
",",
"inst",
".",
"blendDst",
",",
"inst",
".",
"blendEquation",
",",
"inst",
".",
"depthFunc",
",",
"inst",
".",
"polygonOffsetFactor",
",",
"inst",
".",
"polygonOffsetUnits",
",",
"inst",
".",
"alphaTest",
",",
"inst",
".",
"overdraw",
",",
"inst",
".",
"blendSrcAlpha",
",",
"inst",
".",
"blendDstAlpha",
",",
"inst",
".",
"blendEquationAlpha",
",",
"inst",
".",
"transparent",
",",
"inst",
".",
"depthTest",
",",
"inst",
".",
"depthWrite",
",",
"inst",
".",
"colorWrite",
",",
"inst",
".",
"polygonOffset",
",",
"inst",
".",
"visible",
",",
"inst",
".",
"precision",
",",
"inst",
".",
"wireframeLinewidth",
",",
"inst",
".",
"wireframe",
",",
"inst",
".",
"morphTargets",
"]",
";",
"}"
] | Property getter THREE.MeshDepthMaterial | [
"Property",
"getter",
"THREE",
".",
"MeshDepthMaterial"
] | 8539cfbb2d04b67999eee6e530fcaf03083e0e04 | https://github.com/wavesoft/jbb-profile-three/blob/8539cfbb2d04b67999eee6e530fcaf03083e0e04/profile-encode.js#L231-L258 |
50,414 | wavesoft/jbb-profile-three | profile-encode.js | getter_THREE_MeshLambertMaterial | function getter_THREE_MeshLambertMaterial(inst) {
return [
inst.name,
inst.side,
inst.opacity,
inst.blending,
inst.blendSrc,
inst.blendDst,
inst.blendEquation,
inst.depthFunc,
inst.polygonOffsetFactor,
inst.polygonOffsetUnits,
inst.alphaTest,
inst.overdraw,
inst.blendSrcAlpha,
inst.blendDstAlpha,
inst.blendEquationAlpha,
inst.transparent,
inst.depthTest,
inst.depthWrite,
inst.colorWrite,
inst.polygonOffset,
inst.visible,
inst.precision,
inst.wireframeLinecap,
inst.wireframeLinejoin,
inst.color,
inst.emissive,
inst.vertexColors,
inst.map,
inst.specularMap,
inst.alphaMap,
inst.envMap,
inst.combine,
inst.reflectivity,
inst.wireframeLinewidth,
inst.refractionRatio,
inst.fog,
inst.wireframe,
inst.skinning,
inst.morphTargets,
inst.morphNormals];
} | javascript | function getter_THREE_MeshLambertMaterial(inst) {
return [
inst.name,
inst.side,
inst.opacity,
inst.blending,
inst.blendSrc,
inst.blendDst,
inst.blendEquation,
inst.depthFunc,
inst.polygonOffsetFactor,
inst.polygonOffsetUnits,
inst.alphaTest,
inst.overdraw,
inst.blendSrcAlpha,
inst.blendDstAlpha,
inst.blendEquationAlpha,
inst.transparent,
inst.depthTest,
inst.depthWrite,
inst.colorWrite,
inst.polygonOffset,
inst.visible,
inst.precision,
inst.wireframeLinecap,
inst.wireframeLinejoin,
inst.color,
inst.emissive,
inst.vertexColors,
inst.map,
inst.specularMap,
inst.alphaMap,
inst.envMap,
inst.combine,
inst.reflectivity,
inst.wireframeLinewidth,
inst.refractionRatio,
inst.fog,
inst.wireframe,
inst.skinning,
inst.morphTargets,
inst.morphNormals];
} | [
"function",
"getter_THREE_MeshLambertMaterial",
"(",
"inst",
")",
"{",
"return",
"[",
"inst",
".",
"name",
",",
"inst",
".",
"side",
",",
"inst",
".",
"opacity",
",",
"inst",
".",
"blending",
",",
"inst",
".",
"blendSrc",
",",
"inst",
".",
"blendDst",
",",
"inst",
".",
"blendEquation",
",",
"inst",
".",
"depthFunc",
",",
"inst",
".",
"polygonOffsetFactor",
",",
"inst",
".",
"polygonOffsetUnits",
",",
"inst",
".",
"alphaTest",
",",
"inst",
".",
"overdraw",
",",
"inst",
".",
"blendSrcAlpha",
",",
"inst",
".",
"blendDstAlpha",
",",
"inst",
".",
"blendEquationAlpha",
",",
"inst",
".",
"transparent",
",",
"inst",
".",
"depthTest",
",",
"inst",
".",
"depthWrite",
",",
"inst",
".",
"colorWrite",
",",
"inst",
".",
"polygonOffset",
",",
"inst",
".",
"visible",
",",
"inst",
".",
"precision",
",",
"inst",
".",
"wireframeLinecap",
",",
"inst",
".",
"wireframeLinejoin",
",",
"inst",
".",
"color",
",",
"inst",
".",
"emissive",
",",
"inst",
".",
"vertexColors",
",",
"inst",
".",
"map",
",",
"inst",
".",
"specularMap",
",",
"inst",
".",
"alphaMap",
",",
"inst",
".",
"envMap",
",",
"inst",
".",
"combine",
",",
"inst",
".",
"reflectivity",
",",
"inst",
".",
"wireframeLinewidth",
",",
"inst",
".",
"refractionRatio",
",",
"inst",
".",
"fog",
",",
"inst",
".",
"wireframe",
",",
"inst",
".",
"skinning",
",",
"inst",
".",
"morphTargets",
",",
"inst",
".",
"morphNormals",
"]",
";",
"}"
] | Property getter THREE.MeshLambertMaterial | [
"Property",
"getter",
"THREE",
".",
"MeshLambertMaterial"
] | 8539cfbb2d04b67999eee6e530fcaf03083e0e04 | https://github.com/wavesoft/jbb-profile-three/blob/8539cfbb2d04b67999eee6e530fcaf03083e0e04/profile-encode.js#L263-L305 |
50,415 | wavesoft/jbb-profile-three | profile-encode.js | getter_THREE_MeshPhongMaterial | function getter_THREE_MeshPhongMaterial(inst) {
return [
inst.name,
inst.side,
inst.opacity,
inst.blending,
inst.blendSrc,
inst.blendDst,
inst.blendEquation,
inst.depthFunc,
inst.polygonOffsetFactor,
inst.polygonOffsetUnits,
inst.alphaTest,
inst.overdraw,
inst.blendSrcAlpha,
inst.blendDstAlpha,
inst.blendEquationAlpha,
inst.transparent,
inst.depthTest,
inst.depthWrite,
inst.colorWrite,
inst.polygonOffset,
inst.visible,
inst.precision,
inst.color,
inst.emissive,
inst.specular,
inst.shininess,
inst.vertexColors,
inst.metal,
inst.fog,
inst.skinning,
inst.morphTargets,
inst.morphNormals,
inst.map,
inst.lightMap,
inst.emissiveMap,
inst.aoMap,
inst.emissiveMap,
inst.bumpMap,
inst.normalMap,
inst.displacementMap,
inst.specularMap,
inst.alphaMap,
inst.envMap,
inst.lightMapIntensity,
inst.aoMapIntensity,
inst.bumpScale,
inst.normalScale,
inst.displacementScale,
inst.displacementBias,
inst.reflectivity,
inst.refractionRatio,
inst.combine,
inst.shading,
inst.wireframe,
inst.wireframeLinewidth,
inst.wireframeLinecap,
inst.wireframeLinecap];
} | javascript | function getter_THREE_MeshPhongMaterial(inst) {
return [
inst.name,
inst.side,
inst.opacity,
inst.blending,
inst.blendSrc,
inst.blendDst,
inst.blendEquation,
inst.depthFunc,
inst.polygonOffsetFactor,
inst.polygonOffsetUnits,
inst.alphaTest,
inst.overdraw,
inst.blendSrcAlpha,
inst.blendDstAlpha,
inst.blendEquationAlpha,
inst.transparent,
inst.depthTest,
inst.depthWrite,
inst.colorWrite,
inst.polygonOffset,
inst.visible,
inst.precision,
inst.color,
inst.emissive,
inst.specular,
inst.shininess,
inst.vertexColors,
inst.metal,
inst.fog,
inst.skinning,
inst.morphTargets,
inst.morphNormals,
inst.map,
inst.lightMap,
inst.emissiveMap,
inst.aoMap,
inst.emissiveMap,
inst.bumpMap,
inst.normalMap,
inst.displacementMap,
inst.specularMap,
inst.alphaMap,
inst.envMap,
inst.lightMapIntensity,
inst.aoMapIntensity,
inst.bumpScale,
inst.normalScale,
inst.displacementScale,
inst.displacementBias,
inst.reflectivity,
inst.refractionRatio,
inst.combine,
inst.shading,
inst.wireframe,
inst.wireframeLinewidth,
inst.wireframeLinecap,
inst.wireframeLinecap];
} | [
"function",
"getter_THREE_MeshPhongMaterial",
"(",
"inst",
")",
"{",
"return",
"[",
"inst",
".",
"name",
",",
"inst",
".",
"side",
",",
"inst",
".",
"opacity",
",",
"inst",
".",
"blending",
",",
"inst",
".",
"blendSrc",
",",
"inst",
".",
"blendDst",
",",
"inst",
".",
"blendEquation",
",",
"inst",
".",
"depthFunc",
",",
"inst",
".",
"polygonOffsetFactor",
",",
"inst",
".",
"polygonOffsetUnits",
",",
"inst",
".",
"alphaTest",
",",
"inst",
".",
"overdraw",
",",
"inst",
".",
"blendSrcAlpha",
",",
"inst",
".",
"blendDstAlpha",
",",
"inst",
".",
"blendEquationAlpha",
",",
"inst",
".",
"transparent",
",",
"inst",
".",
"depthTest",
",",
"inst",
".",
"depthWrite",
",",
"inst",
".",
"colorWrite",
",",
"inst",
".",
"polygonOffset",
",",
"inst",
".",
"visible",
",",
"inst",
".",
"precision",
",",
"inst",
".",
"color",
",",
"inst",
".",
"emissive",
",",
"inst",
".",
"specular",
",",
"inst",
".",
"shininess",
",",
"inst",
".",
"vertexColors",
",",
"inst",
".",
"metal",
",",
"inst",
".",
"fog",
",",
"inst",
".",
"skinning",
",",
"inst",
".",
"morphTargets",
",",
"inst",
".",
"morphNormals",
",",
"inst",
".",
"map",
",",
"inst",
".",
"lightMap",
",",
"inst",
".",
"emissiveMap",
",",
"inst",
".",
"aoMap",
",",
"inst",
".",
"emissiveMap",
",",
"inst",
".",
"bumpMap",
",",
"inst",
".",
"normalMap",
",",
"inst",
".",
"displacementMap",
",",
"inst",
".",
"specularMap",
",",
"inst",
".",
"alphaMap",
",",
"inst",
".",
"envMap",
",",
"inst",
".",
"lightMapIntensity",
",",
"inst",
".",
"aoMapIntensity",
",",
"inst",
".",
"bumpScale",
",",
"inst",
".",
"normalScale",
",",
"inst",
".",
"displacementScale",
",",
"inst",
".",
"displacementBias",
",",
"inst",
".",
"reflectivity",
",",
"inst",
".",
"refractionRatio",
",",
"inst",
".",
"combine",
",",
"inst",
".",
"shading",
",",
"inst",
".",
"wireframe",
",",
"inst",
".",
"wireframeLinewidth",
",",
"inst",
".",
"wireframeLinecap",
",",
"inst",
".",
"wireframeLinecap",
"]",
";",
"}"
] | Property getter THREE.MeshPhongMaterial | [
"Property",
"getter",
"THREE",
".",
"MeshPhongMaterial"
] | 8539cfbb2d04b67999eee6e530fcaf03083e0e04 | https://github.com/wavesoft/jbb-profile-three/blob/8539cfbb2d04b67999eee6e530fcaf03083e0e04/profile-encode.js#L310-L369 |
50,416 | wavesoft/jbb-profile-three | profile-encode.js | getter_THREE_Scene | function getter_THREE_Scene(inst) {
return [
inst.name,
inst.up,
inst.position,
inst.quaternion,
inst.scale,
inst.rotationAutoUpdate,
inst.matrix,
inst.matrixWorld,
inst.matrixAutoUpdate,
inst.visible,
inst.castShadow,
inst.receiveShadow,
inst.frustumCulled,
inst.renderOrder,
inst.userData,
inst.children,
inst.fog,
inst.overrideMaterial];
} | javascript | function getter_THREE_Scene(inst) {
return [
inst.name,
inst.up,
inst.position,
inst.quaternion,
inst.scale,
inst.rotationAutoUpdate,
inst.matrix,
inst.matrixWorld,
inst.matrixAutoUpdate,
inst.visible,
inst.castShadow,
inst.receiveShadow,
inst.frustumCulled,
inst.renderOrder,
inst.userData,
inst.children,
inst.fog,
inst.overrideMaterial];
} | [
"function",
"getter_THREE_Scene",
"(",
"inst",
")",
"{",
"return",
"[",
"inst",
".",
"name",
",",
"inst",
".",
"up",
",",
"inst",
".",
"position",
",",
"inst",
".",
"quaternion",
",",
"inst",
".",
"scale",
",",
"inst",
".",
"rotationAutoUpdate",
",",
"inst",
".",
"matrix",
",",
"inst",
".",
"matrixWorld",
",",
"inst",
".",
"matrixAutoUpdate",
",",
"inst",
".",
"visible",
",",
"inst",
".",
"castShadow",
",",
"inst",
".",
"receiveShadow",
",",
"inst",
".",
"frustumCulled",
",",
"inst",
".",
"renderOrder",
",",
"inst",
".",
"userData",
",",
"inst",
".",
"children",
",",
"inst",
".",
"fog",
",",
"inst",
".",
"overrideMaterial",
"]",
";",
"}"
] | Property getter THREE.Scene | [
"Property",
"getter",
"THREE",
".",
"Scene"
] | 8539cfbb2d04b67999eee6e530fcaf03083e0e04 | https://github.com/wavesoft/jbb-profile-three/blob/8539cfbb2d04b67999eee6e530fcaf03083e0e04/profile-encode.js#L451-L471 |
50,417 | wavesoft/jbb-profile-three | profile-encode.js | getter_THREE_Mesh | function getter_THREE_Mesh(inst) {
return [
inst.name,
inst.up,
inst.position,
inst.quaternion,
inst.scale,
inst.rotationAutoUpdate,
inst.matrix,
inst.matrixWorld,
inst.matrixAutoUpdate,
inst.visible,
inst.castShadow,
inst.receiveShadow,
inst.frustumCulled,
inst.renderOrder,
inst.userData,
inst.children,
inst.geometry,
inst.material,
inst.materialTexture,
inst.materialWireframe];
} | javascript | function getter_THREE_Mesh(inst) {
return [
inst.name,
inst.up,
inst.position,
inst.quaternion,
inst.scale,
inst.rotationAutoUpdate,
inst.matrix,
inst.matrixWorld,
inst.matrixAutoUpdate,
inst.visible,
inst.castShadow,
inst.receiveShadow,
inst.frustumCulled,
inst.renderOrder,
inst.userData,
inst.children,
inst.geometry,
inst.material,
inst.materialTexture,
inst.materialWireframe];
} | [
"function",
"getter_THREE_Mesh",
"(",
"inst",
")",
"{",
"return",
"[",
"inst",
".",
"name",
",",
"inst",
".",
"up",
",",
"inst",
".",
"position",
",",
"inst",
".",
"quaternion",
",",
"inst",
".",
"scale",
",",
"inst",
".",
"rotationAutoUpdate",
",",
"inst",
".",
"matrix",
",",
"inst",
".",
"matrixWorld",
",",
"inst",
".",
"matrixAutoUpdate",
",",
"inst",
".",
"visible",
",",
"inst",
".",
"castShadow",
",",
"inst",
".",
"receiveShadow",
",",
"inst",
".",
"frustumCulled",
",",
"inst",
".",
"renderOrder",
",",
"inst",
".",
"userData",
",",
"inst",
".",
"children",
",",
"inst",
".",
"geometry",
",",
"inst",
".",
"material",
",",
"inst",
".",
"materialTexture",
",",
"inst",
".",
"materialWireframe",
"]",
";",
"}"
] | Property getter THREE.Mesh | [
"Property",
"getter",
"THREE",
".",
"Mesh"
] | 8539cfbb2d04b67999eee6e530fcaf03083e0e04 | https://github.com/wavesoft/jbb-profile-three/blob/8539cfbb2d04b67999eee6e530fcaf03083e0e04/profile-encode.js#L607-L629 |
50,418 | wavesoft/jbb-profile-three | profile-encode.js | getter_THREE_BufferGeometry | function getter_THREE_BufferGeometry(inst) {
return [
inst.vertices,
inst.faces,
inst.faceVertexUvs,
inst.morphTargets,
inst.morphNormals,
inst.morphColors,
inst.animations,
inst.boundingSphere,
inst.boundingBox,
inst.name,
inst.attributes,
inst.index];
} | javascript | function getter_THREE_BufferGeometry(inst) {
return [
inst.vertices,
inst.faces,
inst.faceVertexUvs,
inst.morphTargets,
inst.morphNormals,
inst.morphColors,
inst.animations,
inst.boundingSphere,
inst.boundingBox,
inst.name,
inst.attributes,
inst.index];
} | [
"function",
"getter_THREE_BufferGeometry",
"(",
"inst",
")",
"{",
"return",
"[",
"inst",
".",
"vertices",
",",
"inst",
".",
"faces",
",",
"inst",
".",
"faceVertexUvs",
",",
"inst",
".",
"morphTargets",
",",
"inst",
".",
"morphNormals",
",",
"inst",
".",
"morphColors",
",",
"inst",
".",
"animations",
",",
"inst",
".",
"boundingSphere",
",",
"inst",
".",
"boundingBox",
",",
"inst",
".",
"name",
",",
"inst",
".",
"attributes",
",",
"inst",
".",
"index",
"]",
";",
"}"
] | Property getter THREE.BufferGeometry | [
"Property",
"getter",
"THREE",
".",
"BufferGeometry"
] | 8539cfbb2d04b67999eee6e530fcaf03083e0e04 | https://github.com/wavesoft/jbb-profile-three/blob/8539cfbb2d04b67999eee6e530fcaf03083e0e04/profile-encode.js#L657-L671 |
50,419 | wavesoft/jbb-profile-three | profile-encode.js | getter_THREE_Geometry | function getter_THREE_Geometry(inst) {
return [
inst.vertices,
inst.faces,
inst.faceVertexUvs,
inst.morphTargets,
inst.morphNormals,
inst.morphColors,
inst.animations,
inst.boundingSphere,
inst.boundingBox,
inst.name];
} | javascript | function getter_THREE_Geometry(inst) {
return [
inst.vertices,
inst.faces,
inst.faceVertexUvs,
inst.morphTargets,
inst.morphNormals,
inst.morphColors,
inst.animations,
inst.boundingSphere,
inst.boundingBox,
inst.name];
} | [
"function",
"getter_THREE_Geometry",
"(",
"inst",
")",
"{",
"return",
"[",
"inst",
".",
"vertices",
",",
"inst",
".",
"faces",
",",
"inst",
".",
"faceVertexUvs",
",",
"inst",
".",
"morphTargets",
",",
"inst",
".",
"morphNormals",
",",
"inst",
".",
"morphColors",
",",
"inst",
".",
"animations",
",",
"inst",
".",
"boundingSphere",
",",
"inst",
".",
"boundingBox",
",",
"inst",
".",
"name",
"]",
";",
"}"
] | Property getter THREE.Geometry | [
"Property",
"getter",
"THREE",
".",
"Geometry"
] | 8539cfbb2d04b67999eee6e530fcaf03083e0e04 | https://github.com/wavesoft/jbb-profile-three/blob/8539cfbb2d04b67999eee6e530fcaf03083e0e04/profile-encode.js#L847-L859 |
50,420 | wavesoft/jbb-profile-three | profile-encode.js | getter_THREE_Vector4 | function getter_THREE_Vector4(inst) {
return [
inst.x,
inst.y,
inst.z,
inst.w];
} | javascript | function getter_THREE_Vector4(inst) {
return [
inst.x,
inst.y,
inst.z,
inst.w];
} | [
"function",
"getter_THREE_Vector4",
"(",
"inst",
")",
"{",
"return",
"[",
"inst",
".",
"x",
",",
"inst",
".",
"y",
",",
"inst",
".",
"z",
",",
"inst",
".",
"w",
"]",
";",
"}"
] | Property getter THREE.Vector4 | [
"Property",
"getter",
"THREE",
".",
"Vector4"
] | 8539cfbb2d04b67999eee6e530fcaf03083e0e04 | https://github.com/wavesoft/jbb-profile-three/blob/8539cfbb2d04b67999eee6e530fcaf03083e0e04/profile-encode.js#L883-L889 |
50,421 | wavesoft/jbb-profile-three | profile-encode.js | getter_THREE_Face3 | function getter_THREE_Face3(inst) {
return [
inst.a,
inst.b,
inst.c,
inst.materialIndex,
inst.normal,
inst.color,
inst.vertexNormals,
inst.vertexColors];
} | javascript | function getter_THREE_Face3(inst) {
return [
inst.a,
inst.b,
inst.c,
inst.materialIndex,
inst.normal,
inst.color,
inst.vertexNormals,
inst.vertexColors];
} | [
"function",
"getter_THREE_Face3",
"(",
"inst",
")",
"{",
"return",
"[",
"inst",
".",
"a",
",",
"inst",
".",
"b",
",",
"inst",
".",
"c",
",",
"inst",
".",
"materialIndex",
",",
"inst",
".",
"normal",
",",
"inst",
".",
"color",
",",
"inst",
".",
"vertexNormals",
",",
"inst",
".",
"vertexColors",
"]",
";",
"}"
] | Property getter THREE.Face3 | [
"Property",
"getter",
"THREE",
".",
"Face3"
] | 8539cfbb2d04b67999eee6e530fcaf03083e0e04 | https://github.com/wavesoft/jbb-profile-three/blob/8539cfbb2d04b67999eee6e530fcaf03083e0e04/profile-encode.js#L894-L904 |
50,422 | wavesoft/jbb-profile-three | profile-encode.js | getter_THREE_Quaternion | function getter_THREE_Quaternion(inst) {
return [
inst._x,
inst._y,
inst._z,
inst._w];
} | javascript | function getter_THREE_Quaternion(inst) {
return [
inst._x,
inst._y,
inst._z,
inst._w];
} | [
"function",
"getter_THREE_Quaternion",
"(",
"inst",
")",
"{",
"return",
"[",
"inst",
".",
"_x",
",",
"inst",
".",
"_y",
",",
"inst",
".",
"_z",
",",
"inst",
".",
"_w",
"]",
";",
"}"
] | Property getter THREE.Quaternion | [
"Property",
"getter",
"THREE",
".",
"Quaternion"
] | 8539cfbb2d04b67999eee6e530fcaf03083e0e04 | https://github.com/wavesoft/jbb-profile-three/blob/8539cfbb2d04b67999eee6e530fcaf03083e0e04/profile-encode.js#L919-L925 |
50,423 | wavesoft/jbb-profile-three | profile-encode.js | getter_THREE_Euler | function getter_THREE_Euler(inst) {
return [
inst._x,
inst._y,
inst._z,
inst._order];
} | javascript | function getter_THREE_Euler(inst) {
return [
inst._x,
inst._y,
inst._z,
inst._order];
} | [
"function",
"getter_THREE_Euler",
"(",
"inst",
")",
"{",
"return",
"[",
"inst",
".",
"_x",
",",
"inst",
".",
"_y",
",",
"inst",
".",
"_z",
",",
"inst",
".",
"_order",
"]",
";",
"}"
] | Property getter THREE.Euler | [
"Property",
"getter",
"THREE",
".",
"Euler"
] | 8539cfbb2d04b67999eee6e530fcaf03083e0e04 | https://github.com/wavesoft/jbb-profile-three/blob/8539cfbb2d04b67999eee6e530fcaf03083e0e04/profile-encode.js#L930-L936 |
50,424 | wavesoft/jbb-profile-three | profile-encode.js | getter_THREE_BufferAttribute | function getter_THREE_BufferAttribute(inst) {
return [
inst.array,
inst.itemSize,
inst.dynamic,
inst.updateRange];
} | javascript | function getter_THREE_BufferAttribute(inst) {
return [
inst.array,
inst.itemSize,
inst.dynamic,
inst.updateRange];
} | [
"function",
"getter_THREE_BufferAttribute",
"(",
"inst",
")",
"{",
"return",
"[",
"inst",
".",
"array",
",",
"inst",
".",
"itemSize",
",",
"inst",
".",
"dynamic",
",",
"inst",
".",
"updateRange",
"]",
";",
"}"
] | Property getter THREE.BufferAttribute | [
"Property",
"getter",
"THREE",
".",
"BufferAttribute"
] | 8539cfbb2d04b67999eee6e530fcaf03083e0e04 | https://github.com/wavesoft/jbb-profile-three/blob/8539cfbb2d04b67999eee6e530fcaf03083e0e04/profile-encode.js#L984-L990 |
50,425 | wavesoft/jbb-profile-three | profile-encode.js | getter_THREE_PerspectiveCamera | function getter_THREE_PerspectiveCamera(inst) {
return [
inst.fov,
inst.aspect,
inst.near,
inst.far];
} | javascript | function getter_THREE_PerspectiveCamera(inst) {
return [
inst.fov,
inst.aspect,
inst.near,
inst.far];
} | [
"function",
"getter_THREE_PerspectiveCamera",
"(",
"inst",
")",
"{",
"return",
"[",
"inst",
".",
"fov",
",",
"inst",
".",
"aspect",
",",
"inst",
".",
"near",
",",
"inst",
".",
"far",
"]",
";",
"}"
] | Property getter THREE.PerspectiveCamera | [
"Property",
"getter",
"THREE",
".",
"PerspectiveCamera"
] | 8539cfbb2d04b67999eee6e530fcaf03083e0e04 | https://github.com/wavesoft/jbb-profile-three/blob/8539cfbb2d04b67999eee6e530fcaf03083e0e04/profile-encode.js#L1078-L1084 |
50,426 | wavesoft/jbb-profile-three | profile-encode.js | getter_THREE_OrthographicCamera | function getter_THREE_OrthographicCamera(inst) {
return [
inst.left,
inst.right,
inst.top,
inst.bottom,
inst.near,
inst.far];
} | javascript | function getter_THREE_OrthographicCamera(inst) {
return [
inst.left,
inst.right,
inst.top,
inst.bottom,
inst.near,
inst.far];
} | [
"function",
"getter_THREE_OrthographicCamera",
"(",
"inst",
")",
"{",
"return",
"[",
"inst",
".",
"left",
",",
"inst",
".",
"right",
",",
"inst",
".",
"top",
",",
"inst",
".",
"bottom",
",",
"inst",
".",
"near",
",",
"inst",
".",
"far",
"]",
";",
"}"
] | Property getter THREE.OrthographicCamera | [
"Property",
"getter",
"THREE",
".",
"OrthographicCamera"
] | 8539cfbb2d04b67999eee6e530fcaf03083e0e04 | https://github.com/wavesoft/jbb-profile-three/blob/8539cfbb2d04b67999eee6e530fcaf03083e0e04/profile-encode.js#L1089-L1097 |
50,427 | wavesoft/jbb-profile-three | profile-encode.js | getter_THREE_MD2Character | function getter_THREE_MD2Character(inst) {
return [
inst.scale,
inst.animationFPS,
inst.root,
inst.meshBody,
inst.skinsBody,
inst.meshWeapon,
inst.skinsWeapon,
inst.weapons,
inst.activeAnimation];
} | javascript | function getter_THREE_MD2Character(inst) {
return [
inst.scale,
inst.animationFPS,
inst.root,
inst.meshBody,
inst.skinsBody,
inst.meshWeapon,
inst.skinsWeapon,
inst.weapons,
inst.activeAnimation];
} | [
"function",
"getter_THREE_MD2Character",
"(",
"inst",
")",
"{",
"return",
"[",
"inst",
".",
"scale",
",",
"inst",
".",
"animationFPS",
",",
"inst",
".",
"root",
",",
"inst",
".",
"meshBody",
",",
"inst",
".",
"skinsBody",
",",
"inst",
".",
"meshWeapon",
",",
"inst",
".",
"skinsWeapon",
",",
"inst",
".",
"weapons",
",",
"inst",
".",
"activeAnimation",
"]",
";",
"}"
] | Property getter THREE.MD2Character | [
"Property",
"getter",
"THREE",
".",
"MD2Character"
] | 8539cfbb2d04b67999eee6e530fcaf03083e0e04 | https://github.com/wavesoft/jbb-profile-three/blob/8539cfbb2d04b67999eee6e530fcaf03083e0e04/profile-encode.js#L1112-L1123 |
50,428 | Lindurion/closure-pro-build | lib/graph-util.js | addSetValues | function addSetValues(args) {
for (var key in args.from) {
if (args.from[key]) {
args.to[key] = true;
}
}
} | javascript | function addSetValues(args) {
for (var key in args.from) {
if (args.from[key]) {
args.to[key] = true;
}
}
} | [
"function",
"addSetValues",
"(",
"args",
")",
"{",
"for",
"(",
"var",
"key",
"in",
"args",
".",
"from",
")",
"{",
"if",
"(",
"args",
".",
"from",
"[",
"key",
"]",
")",
"{",
"args",
".",
"to",
"[",
"key",
"]",
"=",
"true",
";",
"}",
"}",
"}"
] | Makes 'to' the set union of 'from' and 'to'.
@param {!{from: !Object.<string, boolean>, to: !Object.<string, boolean>}}
args | [
"Makes",
"to",
"the",
"set",
"union",
"of",
"from",
"and",
"to",
"."
] | c279d0fcc3a65969d2fe965f55e627b074792f1a | https://github.com/Lindurion/closure-pro-build/blob/c279d0fcc3a65969d2fe965f55e627b074792f1a/lib/graph-util.js#L32-L38 |
50,429 | sendanor/nor-errors | src/HTTPError.js | HTTPError | function HTTPError() {
var args = Array.prototype.slice.call(arguments);
if(!(this instanceof HTTPError)) {
if(args.length === 1) {
return new HTTPError(args[0]);
} else if(args.length === 2) {
return new HTTPError(args[0], args[1]);
} else if(args.length === 3) {
return new HTTPError(args[0], args[1], args[2]);
} else {
throw new TypeError("Too many arguments (" + args.length + ") for new HTTPError()");
}
}
var headers, msg, code;
ARRAY(args).forEach(function(arg) {
if(typeof arg === 'object') {
headers = arg;
}
if(typeof arg === 'string') {
msg = arg;
}
if(typeof arg === 'number') {
code = arg;
}
});
code = code || 500;
msg = msg || (''+code+' '+require('http').STATUS_CODES[code]);
headers = headers || {};
Error.call(this);
Error.captureStackTrace(this, this);
this.code = code;
this.message = msg;
this.headers = headers;
} | javascript | function HTTPError() {
var args = Array.prototype.slice.call(arguments);
if(!(this instanceof HTTPError)) {
if(args.length === 1) {
return new HTTPError(args[0]);
} else if(args.length === 2) {
return new HTTPError(args[0], args[1]);
} else if(args.length === 3) {
return new HTTPError(args[0], args[1], args[2]);
} else {
throw new TypeError("Too many arguments (" + args.length + ") for new HTTPError()");
}
}
var headers, msg, code;
ARRAY(args).forEach(function(arg) {
if(typeof arg === 'object') {
headers = arg;
}
if(typeof arg === 'string') {
msg = arg;
}
if(typeof arg === 'number') {
code = arg;
}
});
code = code || 500;
msg = msg || (''+code+' '+require('http').STATUS_CODES[code]);
headers = headers || {};
Error.call(this);
Error.captureStackTrace(this, this);
this.code = code;
this.message = msg;
this.headers = headers;
} | [
"function",
"HTTPError",
"(",
")",
"{",
"var",
"args",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
")",
";",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"HTTPError",
")",
")",
"{",
"if",
"(",
"args",
".",
"length",
"===",
"1",
")",
"{",
"return",
"new",
"HTTPError",
"(",
"args",
"[",
"0",
"]",
")",
";",
"}",
"else",
"if",
"(",
"args",
".",
"length",
"===",
"2",
")",
"{",
"return",
"new",
"HTTPError",
"(",
"args",
"[",
"0",
"]",
",",
"args",
"[",
"1",
"]",
")",
";",
"}",
"else",
"if",
"(",
"args",
".",
"length",
"===",
"3",
")",
"{",
"return",
"new",
"HTTPError",
"(",
"args",
"[",
"0",
"]",
",",
"args",
"[",
"1",
"]",
",",
"args",
"[",
"2",
"]",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"TypeError",
"(",
"\"Too many arguments (\"",
"+",
"args",
".",
"length",
"+",
"\") for new HTTPError()\"",
")",
";",
"}",
"}",
"var",
"headers",
",",
"msg",
",",
"code",
";",
"ARRAY",
"(",
"args",
")",
".",
"forEach",
"(",
"function",
"(",
"arg",
")",
"{",
"if",
"(",
"typeof",
"arg",
"===",
"'object'",
")",
"{",
"headers",
"=",
"arg",
";",
"}",
"if",
"(",
"typeof",
"arg",
"===",
"'string'",
")",
"{",
"msg",
"=",
"arg",
";",
"}",
"if",
"(",
"typeof",
"arg",
"===",
"'number'",
")",
"{",
"code",
"=",
"arg",
";",
"}",
"}",
")",
";",
"code",
"=",
"code",
"||",
"500",
";",
"msg",
"=",
"msg",
"||",
"(",
"''",
"+",
"code",
"+",
"' '",
"+",
"require",
"(",
"'http'",
")",
".",
"STATUS_CODES",
"[",
"code",
"]",
")",
";",
"headers",
"=",
"headers",
"||",
"{",
"}",
";",
"Error",
".",
"call",
"(",
"this",
")",
";",
"Error",
".",
"captureStackTrace",
"(",
"this",
",",
"this",
")",
";",
"this",
".",
"code",
"=",
"code",
";",
"this",
".",
"message",
"=",
"msg",
";",
"this",
".",
"headers",
"=",
"headers",
";",
"}"
] | Exception type for HTTP errors | [
"Exception",
"type",
"for",
"HTTP",
"errors"
] | 17e0f00816db53023fcae4847ed7ce67e993ddbf | https://github.com/sendanor/nor-errors/blob/17e0f00816db53023fcae4847ed7ce67e993ddbf/src/HTTPError.js#L10-L46 |
50,430 | nodejitsu/packages-pagelet | resolve.js | reduce | function reduce(data, fn) {
delete data.package.readmeFilename; // README is already parsed.
delete data.package.versions; // Adds to much bloat.
delete data.package.readme; // README is already parsed.
//
// Remove circular references as it would prevent us from caching in Redis or
// what ever because there's a circular reference. Keep track of what are main
// dependencies by providing them with a number, useful for sorting later on.
//
if ('object' === typeof data.shrinkwrap) {
Object.keys(data.shrinkwrap).forEach(function each(_id) {
var shrinkwrap = data.shrinkwrap[_id];
delete shrinkwrap.dependencies;
delete shrinkwrap.dependent;
delete shrinkwrap.parents;
});
}
//
// Extract github data from array.
//
if (data.github && data.github.length) data.github = data.github.pop();
//
// Make sure we default to something so we don't get template errors
//
data.readme = data.readme || data.package.description || '';
//
// Transform shrinkwrap to an array and prioritize on depth.
//
data.shrinkwrap = Object.keys(data.shrinkwrap || {}).map(function wrap(_id) {
return data.shrinkwrap[_id];
}).sort(function sort(a, b) {
return a.depth - b.depth;
});
//
// Remove empty objects from the package.
//
[
'repository',
'homepage',
'bugs'
].forEach(function each(key) {
if (Array.isArray(data.package[key])) {
if (!data.package[key].length) delete data.package[key];
} else if ('object' === typeof data.package[key] && !Object.keys(data.package[key]).length) {
delete data.package[key];
}
});
fn(undefined, data);
} | javascript | function reduce(data, fn) {
delete data.package.readmeFilename; // README is already parsed.
delete data.package.versions; // Adds to much bloat.
delete data.package.readme; // README is already parsed.
//
// Remove circular references as it would prevent us from caching in Redis or
// what ever because there's a circular reference. Keep track of what are main
// dependencies by providing them with a number, useful for sorting later on.
//
if ('object' === typeof data.shrinkwrap) {
Object.keys(data.shrinkwrap).forEach(function each(_id) {
var shrinkwrap = data.shrinkwrap[_id];
delete shrinkwrap.dependencies;
delete shrinkwrap.dependent;
delete shrinkwrap.parents;
});
}
//
// Extract github data from array.
//
if (data.github && data.github.length) data.github = data.github.pop();
//
// Make sure we default to something so we don't get template errors
//
data.readme = data.readme || data.package.description || '';
//
// Transform shrinkwrap to an array and prioritize on depth.
//
data.shrinkwrap = Object.keys(data.shrinkwrap || {}).map(function wrap(_id) {
return data.shrinkwrap[_id];
}).sort(function sort(a, b) {
return a.depth - b.depth;
});
//
// Remove empty objects from the package.
//
[
'repository',
'homepage',
'bugs'
].forEach(function each(key) {
if (Array.isArray(data.package[key])) {
if (!data.package[key].length) delete data.package[key];
} else if ('object' === typeof data.package[key] && !Object.keys(data.package[key]).length) {
delete data.package[key];
}
});
fn(undefined, data);
} | [
"function",
"reduce",
"(",
"data",
",",
"fn",
")",
"{",
"delete",
"data",
".",
"package",
".",
"readmeFilename",
";",
"// README is already parsed.",
"delete",
"data",
".",
"package",
".",
"versions",
";",
"// Adds to much bloat.",
"delete",
"data",
".",
"package",
".",
"readme",
";",
"// README is already parsed.",
"//",
"// Remove circular references as it would prevent us from caching in Redis or",
"// what ever because there's a circular reference. Keep track of what are main",
"// dependencies by providing them with a number, useful for sorting later on.",
"//",
"if",
"(",
"'object'",
"===",
"typeof",
"data",
".",
"shrinkwrap",
")",
"{",
"Object",
".",
"keys",
"(",
"data",
".",
"shrinkwrap",
")",
".",
"forEach",
"(",
"function",
"each",
"(",
"_id",
")",
"{",
"var",
"shrinkwrap",
"=",
"data",
".",
"shrinkwrap",
"[",
"_id",
"]",
";",
"delete",
"shrinkwrap",
".",
"dependencies",
";",
"delete",
"shrinkwrap",
".",
"dependent",
";",
"delete",
"shrinkwrap",
".",
"parents",
";",
"}",
")",
";",
"}",
"//",
"// Extract github data from array.",
"//",
"if",
"(",
"data",
".",
"github",
"&&",
"data",
".",
"github",
".",
"length",
")",
"data",
".",
"github",
"=",
"data",
".",
"github",
".",
"pop",
"(",
")",
";",
"//",
"// Make sure we default to something so we don't get template errors",
"//",
"data",
".",
"readme",
"=",
"data",
".",
"readme",
"||",
"data",
".",
"package",
".",
"description",
"||",
"''",
";",
"//",
"// Transform shrinkwrap to an array and prioritize on depth.",
"//",
"data",
".",
"shrinkwrap",
"=",
"Object",
".",
"keys",
"(",
"data",
".",
"shrinkwrap",
"||",
"{",
"}",
")",
".",
"map",
"(",
"function",
"wrap",
"(",
"_id",
")",
"{",
"return",
"data",
".",
"shrinkwrap",
"[",
"_id",
"]",
";",
"}",
")",
".",
"sort",
"(",
"function",
"sort",
"(",
"a",
",",
"b",
")",
"{",
"return",
"a",
".",
"depth",
"-",
"b",
".",
"depth",
";",
"}",
")",
";",
"//",
"// Remove empty objects from the package.",
"//",
"[",
"'repository'",
",",
"'homepage'",
",",
"'bugs'",
"]",
".",
"forEach",
"(",
"function",
"each",
"(",
"key",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"data",
".",
"package",
"[",
"key",
"]",
")",
")",
"{",
"if",
"(",
"!",
"data",
".",
"package",
"[",
"key",
"]",
".",
"length",
")",
"delete",
"data",
".",
"package",
"[",
"key",
"]",
";",
"}",
"else",
"if",
"(",
"'object'",
"===",
"typeof",
"data",
".",
"package",
"[",
"key",
"]",
"&&",
"!",
"Object",
".",
"keys",
"(",
"data",
".",
"package",
"[",
"key",
"]",
")",
".",
"length",
")",
"{",
"delete",
"data",
".",
"package",
"[",
"key",
"]",
";",
"}",
"}",
")",
";",
"fn",
"(",
"undefined",
",",
"data",
")",
";",
"}"
] | Reduce the massive data structure to something useful.
@param {Object} data The received data structure.
@param {Function} fn The callback.
@api private | [
"Reduce",
"the",
"massive",
"data",
"structure",
"to",
"something",
"useful",
"."
] | 10c4bdb1a99a808b58e41d87c8e7ec8c9947a3d8 | https://github.com/nodejitsu/packages-pagelet/blob/10c4bdb1a99a808b58e41d87c8e7ec8c9947a3d8/resolve.js#L105-L160 |
50,431 | nodejitsu/packages-pagelet | resolve.js | clients | function clients(options) {
options = options || {};
options.registry = options.registry || Registry.mirrors.nodejitsu;
var githulk = options.githulk || new GitHulk();
//
// Only create a new Registry instance if we've been supplied with a string.
//
var npm = 'string' !== typeof options.registry
? options.registry
: new Registry({
registry: options.registry,
githulk: githulk
});
return {
git: githulk,
npm: npm
};
} | javascript | function clients(options) {
options = options || {};
options.registry = options.registry || Registry.mirrors.nodejitsu;
var githulk = options.githulk || new GitHulk();
//
// Only create a new Registry instance if we've been supplied with a string.
//
var npm = 'string' !== typeof options.registry
? options.registry
: new Registry({
registry: options.registry,
githulk: githulk
});
return {
git: githulk,
npm: npm
};
} | [
"function",
"clients",
"(",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"options",
".",
"registry",
"=",
"options",
".",
"registry",
"||",
"Registry",
".",
"mirrors",
".",
"nodejitsu",
";",
"var",
"githulk",
"=",
"options",
".",
"githulk",
"||",
"new",
"GitHulk",
"(",
")",
";",
"//",
"// Only create a new Registry instance if we've been supplied with a string.",
"//",
"var",
"npm",
"=",
"'string'",
"!==",
"typeof",
"options",
".",
"registry",
"?",
"options",
".",
"registry",
":",
"new",
"Registry",
"(",
"{",
"registry",
":",
"options",
".",
"registry",
",",
"githulk",
":",
"githulk",
"}",
")",
";",
"return",
"{",
"git",
":",
"githulk",
",",
"npm",
":",
"npm",
"}",
";",
"}"
] | Simple helper function to get a working npm and githulk client.
@param {Object} options Configuration.
@returns {Object} Pre-configured npm and git.
@api private | [
"Simple",
"helper",
"function",
"to",
"get",
"a",
"working",
"npm",
"and",
"githulk",
"client",
"."
] | 10c4bdb1a99a808b58e41d87c8e7ec8c9947a3d8 | https://github.com/nodejitsu/packages-pagelet/blob/10c4bdb1a99a808b58e41d87c8e7ec8c9947a3d8/resolve.js#L169-L189 |
50,432 | ayan4m1/pg-redis | dist/index.js | function(text, options) {
var execute, queried;
queried = p.defer();
// caching disabled unless duration is specified
options = options != null ? options : {
duration: 0
};
execute = function(params) {
return db.prepare(text).then(function(stmt) {
return stmt.execute(params).then(function(results) {
if (options.duration > 0) {
cache.store(text, results.rows, options.duration);
}
return queried.resolve(results.rows);
}).done();
}).done();
};
// return results directly if cache hit, run query if cache miss
cache.get(text).then(function(results) {
return queried.resolve(results);
}, function(err) {
if (err != null) {
return queried.reject(err);
} else {
return execute();
}
}).done();
return queried.promise;
} | javascript | function(text, options) {
var execute, queried;
queried = p.defer();
// caching disabled unless duration is specified
options = options != null ? options : {
duration: 0
};
execute = function(params) {
return db.prepare(text).then(function(stmt) {
return stmt.execute(params).then(function(results) {
if (options.duration > 0) {
cache.store(text, results.rows, options.duration);
}
return queried.resolve(results.rows);
}).done();
}).done();
};
// return results directly if cache hit, run query if cache miss
cache.get(text).then(function(results) {
return queried.resolve(results);
}, function(err) {
if (err != null) {
return queried.reject(err);
} else {
return execute();
}
}).done();
return queried.promise;
} | [
"function",
"(",
"text",
",",
"options",
")",
"{",
"var",
"execute",
",",
"queried",
";",
"queried",
"=",
"p",
".",
"defer",
"(",
")",
";",
"// caching disabled unless duration is specified",
"options",
"=",
"options",
"!=",
"null",
"?",
"options",
":",
"{",
"duration",
":",
"0",
"}",
";",
"execute",
"=",
"function",
"(",
"params",
")",
"{",
"return",
"db",
".",
"prepare",
"(",
"text",
")",
".",
"then",
"(",
"function",
"(",
"stmt",
")",
"{",
"return",
"stmt",
".",
"execute",
"(",
"params",
")",
".",
"then",
"(",
"function",
"(",
"results",
")",
"{",
"if",
"(",
"options",
".",
"duration",
">",
"0",
")",
"{",
"cache",
".",
"store",
"(",
"text",
",",
"results",
".",
"rows",
",",
"options",
".",
"duration",
")",
";",
"}",
"return",
"queried",
".",
"resolve",
"(",
"results",
".",
"rows",
")",
";",
"}",
")",
".",
"done",
"(",
")",
";",
"}",
")",
".",
"done",
"(",
")",
";",
"}",
";",
"// return results directly if cache hit, run query if cache miss",
"cache",
".",
"get",
"(",
"text",
")",
".",
"then",
"(",
"function",
"(",
"results",
")",
"{",
"return",
"queried",
".",
"resolve",
"(",
"results",
")",
";",
"}",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
"!=",
"null",
")",
"{",
"return",
"queried",
".",
"reject",
"(",
"err",
")",
";",
"}",
"else",
"{",
"return",
"execute",
"(",
")",
";",
"}",
"}",
")",
".",
"done",
"(",
")",
";",
"return",
"queried",
".",
"promise",
";",
"}"
] | expose simplified, cache-enabled api | [
"expose",
"simplified",
"cache",
"-",
"enabled",
"api"
] | 131b1a7e566bfc73472bd53e42a07a753ed1b528 | https://github.com/ayan4m1/pg-redis/blob/131b1a7e566bfc73472bd53e42a07a753ed1b528/dist/index.js#L14-L42 |
|
50,433 | feedhenry/fh-mbaas-middleware | lib/middleware/app.js | findOrCreateMbaasApp | function findOrCreateMbaasApp(req, res, next){
log.logger.debug("findOrCreateMbaasApp ", req.params);
var models = mbaas.getModels();
//Checking For Required Params
var missingParams = _.filter(["appGuid", "apiKey", "coreHost"], function(requiredKey){
return validation.validateParamPresent(requiredKey, req);
});
if(missingParams.length > 0){
log.logger.debug("findOrCreateMbaasApp Missing Param ", missingParams[0]);
return validation.requireParam(missingParams[0], req, res);
}
findMbaasApp(req, res, function(err){
if(err){
log.logger.debug("Error Finding Mbaas App ", err);
return next(err);
}
var appMbaas = req.appMbaasModel;
//App Found, moving on.
if(_.isObject(appMbaas)){
log.logger.debug("Mbaas App Already Exists ");
return next();
}
//App mbaas does not exist, create it.
log.logger.debug("Mbaas App Does Not Exist, Creating New App Model ", {params: req.params, body: req.body});
models.AppMbaas.createModel({
name: req.params.appname,
domain: req.params.domain,
environment: req.params.environment,
guid: req.body.appGuid,
apiKey: req.body.apiKey,
coreHost: req.body.coreHost,
type: req.body.type,
mbaasUrl: req.body.mbaasUrl,
isServiceApp: req.body.isServiceApp,
url: req.body.url
}, function(err, createdMbaasApp){
if(err){
log.logger.debug("Error Creating New Mbaas App Model ", err);
return next(err);
}
req.appMbaasModel = createdMbaasApp;
next();
});
});
} | javascript | function findOrCreateMbaasApp(req, res, next){
log.logger.debug("findOrCreateMbaasApp ", req.params);
var models = mbaas.getModels();
//Checking For Required Params
var missingParams = _.filter(["appGuid", "apiKey", "coreHost"], function(requiredKey){
return validation.validateParamPresent(requiredKey, req);
});
if(missingParams.length > 0){
log.logger.debug("findOrCreateMbaasApp Missing Param ", missingParams[0]);
return validation.requireParam(missingParams[0], req, res);
}
findMbaasApp(req, res, function(err){
if(err){
log.logger.debug("Error Finding Mbaas App ", err);
return next(err);
}
var appMbaas = req.appMbaasModel;
//App Found, moving on.
if(_.isObject(appMbaas)){
log.logger.debug("Mbaas App Already Exists ");
return next();
}
//App mbaas does not exist, create it.
log.logger.debug("Mbaas App Does Not Exist, Creating New App Model ", {params: req.params, body: req.body});
models.AppMbaas.createModel({
name: req.params.appname,
domain: req.params.domain,
environment: req.params.environment,
guid: req.body.appGuid,
apiKey: req.body.apiKey,
coreHost: req.body.coreHost,
type: req.body.type,
mbaasUrl: req.body.mbaasUrl,
isServiceApp: req.body.isServiceApp,
url: req.body.url
}, function(err, createdMbaasApp){
if(err){
log.logger.debug("Error Creating New Mbaas App Model ", err);
return next(err);
}
req.appMbaasModel = createdMbaasApp;
next();
});
});
} | [
"function",
"findOrCreateMbaasApp",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"log",
".",
"logger",
".",
"debug",
"(",
"\"findOrCreateMbaasApp \"",
",",
"req",
".",
"params",
")",
";",
"var",
"models",
"=",
"mbaas",
".",
"getModels",
"(",
")",
";",
"//Checking For Required Params",
"var",
"missingParams",
"=",
"_",
".",
"filter",
"(",
"[",
"\"appGuid\"",
",",
"\"apiKey\"",
",",
"\"coreHost\"",
"]",
",",
"function",
"(",
"requiredKey",
")",
"{",
"return",
"validation",
".",
"validateParamPresent",
"(",
"requiredKey",
",",
"req",
")",
";",
"}",
")",
";",
"if",
"(",
"missingParams",
".",
"length",
">",
"0",
")",
"{",
"log",
".",
"logger",
".",
"debug",
"(",
"\"findOrCreateMbaasApp Missing Param \"",
",",
"missingParams",
"[",
"0",
"]",
")",
";",
"return",
"validation",
".",
"requireParam",
"(",
"missingParams",
"[",
"0",
"]",
",",
"req",
",",
"res",
")",
";",
"}",
"findMbaasApp",
"(",
"req",
",",
"res",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"{",
"log",
".",
"logger",
".",
"debug",
"(",
"\"Error Finding Mbaas App \"",
",",
"err",
")",
";",
"return",
"next",
"(",
"err",
")",
";",
"}",
"var",
"appMbaas",
"=",
"req",
".",
"appMbaasModel",
";",
"//App Found, moving on.",
"if",
"(",
"_",
".",
"isObject",
"(",
"appMbaas",
")",
")",
"{",
"log",
".",
"logger",
".",
"debug",
"(",
"\"Mbaas App Already Exists \"",
")",
";",
"return",
"next",
"(",
")",
";",
"}",
"//App mbaas does not exist, create it.",
"log",
".",
"logger",
".",
"debug",
"(",
"\"Mbaas App Does Not Exist, Creating New App Model \"",
",",
"{",
"params",
":",
"req",
".",
"params",
",",
"body",
":",
"req",
".",
"body",
"}",
")",
";",
"models",
".",
"AppMbaas",
".",
"createModel",
"(",
"{",
"name",
":",
"req",
".",
"params",
".",
"appname",
",",
"domain",
":",
"req",
".",
"params",
".",
"domain",
",",
"environment",
":",
"req",
".",
"params",
".",
"environment",
",",
"guid",
":",
"req",
".",
"body",
".",
"appGuid",
",",
"apiKey",
":",
"req",
".",
"body",
".",
"apiKey",
",",
"coreHost",
":",
"req",
".",
"body",
".",
"coreHost",
",",
"type",
":",
"req",
".",
"body",
".",
"type",
",",
"mbaasUrl",
":",
"req",
".",
"body",
".",
"mbaasUrl",
",",
"isServiceApp",
":",
"req",
".",
"body",
".",
"isServiceApp",
",",
"url",
":",
"req",
".",
"body",
".",
"url",
"}",
",",
"function",
"(",
"err",
",",
"createdMbaasApp",
")",
"{",
"if",
"(",
"err",
")",
"{",
"log",
".",
"logger",
".",
"debug",
"(",
"\"Error Creating New Mbaas App Model \"",
",",
"err",
")",
";",
"return",
"next",
"(",
"err",
")",
";",
"}",
"req",
".",
"appMbaasModel",
"=",
"createdMbaasApp",
";",
"next",
"(",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}"
] | Middleware To Find Or Create An Mbaas App
@param req
@param res
@param next | [
"Middleware",
"To",
"Find",
"Or",
"Create",
"An",
"Mbaas",
"App"
] | f906e98efbb4b0963bf5137b34b5e0589ba24e69 | https://github.com/feedhenry/fh-mbaas-middleware/blob/f906e98efbb4b0963bf5137b34b5e0589ba24e69/lib/middleware/app.js#L14-L65 |
50,434 | feedhenry/fh-mbaas-middleware | lib/middleware/app.js | findMbaasApp | function findMbaasApp(req, res, next){
log.logger.debug("findMbaasApp for appname " + req.params.appname);
getMbaasApp({
'$or': [{name: req.params.appname}, {guid: req.params.appname}]
}, function(err, appMbaas){
if(err){
log.logger.debug("findMbaasApp Error ", err);
return next(err);
}
req.appMbaasModel = appMbaas;
return next();
});
} | javascript | function findMbaasApp(req, res, next){
log.logger.debug("findMbaasApp for appname " + req.params.appname);
getMbaasApp({
'$or': [{name: req.params.appname}, {guid: req.params.appname}]
}, function(err, appMbaas){
if(err){
log.logger.debug("findMbaasApp Error ", err);
return next(err);
}
req.appMbaasModel = appMbaas;
return next();
});
} | [
"function",
"findMbaasApp",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"log",
".",
"logger",
".",
"debug",
"(",
"\"findMbaasApp for appname \"",
"+",
"req",
".",
"params",
".",
"appname",
")",
";",
"getMbaasApp",
"(",
"{",
"'$or'",
":",
"[",
"{",
"name",
":",
"req",
".",
"params",
".",
"appname",
"}",
",",
"{",
"guid",
":",
"req",
".",
"params",
".",
"appname",
"}",
"]",
"}",
",",
"function",
"(",
"err",
",",
"appMbaas",
")",
"{",
"if",
"(",
"err",
")",
"{",
"log",
".",
"logger",
".",
"debug",
"(",
"\"findMbaasApp Error \"",
",",
"err",
")",
";",
"return",
"next",
"(",
"err",
")",
";",
"}",
"req",
".",
"appMbaasModel",
"=",
"appMbaas",
";",
"return",
"next",
"(",
")",
";",
"}",
")",
";",
"}"
] | Middleware For Finding An App
@param req
@param res
@param next | [
"Middleware",
"For",
"Finding",
"An",
"App"
] | f906e98efbb4b0963bf5137b34b5e0589ba24e69 | https://github.com/feedhenry/fh-mbaas-middleware/blob/f906e98efbb4b0963bf5137b34b5e0589ba24e69/lib/middleware/app.js#L73-L87 |
50,435 | feedhenry/fh-mbaas-middleware | lib/middleware/app.js | getMbaasApp | function getMbaasApp(params, cb){
var models = mbaas.getModels();
models.AppMbaas.findOne(params, cb);
} | javascript | function getMbaasApp(params, cb){
var models = mbaas.getModels();
models.AppMbaas.findOne(params, cb);
} | [
"function",
"getMbaasApp",
"(",
"params",
",",
"cb",
")",
"{",
"var",
"models",
"=",
"mbaas",
".",
"getModels",
"(",
")",
";",
"models",
".",
"AppMbaas",
".",
"findOne",
"(",
"params",
",",
"cb",
")",
";",
"}"
] | Function to get an mbaas app model. | [
"Function",
"to",
"get",
"an",
"mbaas",
"app",
"model",
"."
] | f906e98efbb4b0963bf5137b34b5e0589ba24e69 | https://github.com/feedhenry/fh-mbaas-middleware/blob/f906e98efbb4b0963bf5137b34b5e0589ba24e69/lib/middleware/app.js#L90-L93 |
50,436 | feedhenry/fh-mbaas-middleware | lib/middleware/app.js | updateMbaasApp | function updateMbaasApp(req, res, next){
var model = req.appMbaasModel;
model.name = req.params.appname;
model.domain = req.params.domain;
model.environment = req.params.environment;
model.guid = req.body.appGuid;
model.apiKey = req.body.apiKey;
model.coreHost = req.body.coreHost;
model.type = req.body.type;
model.mbaasUrl = req.body.mbaasUrl;
//If the serviceApp is not set yet and it is a service app, then make sure it is set.
model.isServiceApp = typeof model.isServiceApp === "undefined" ? req.body.isServiceApp : model.isServiceApp;
model.url = req.body.url || model.url;
model.accessKey = model.accessKey || new mongoose.Types.ObjectId();
model.save(next);
} | javascript | function updateMbaasApp(req, res, next){
var model = req.appMbaasModel;
model.name = req.params.appname;
model.domain = req.params.domain;
model.environment = req.params.environment;
model.guid = req.body.appGuid;
model.apiKey = req.body.apiKey;
model.coreHost = req.body.coreHost;
model.type = req.body.type;
model.mbaasUrl = req.body.mbaasUrl;
//If the serviceApp is not set yet and it is a service app, then make sure it is set.
model.isServiceApp = typeof model.isServiceApp === "undefined" ? req.body.isServiceApp : model.isServiceApp;
model.url = req.body.url || model.url;
model.accessKey = model.accessKey || new mongoose.Types.ObjectId();
model.save(next);
} | [
"function",
"updateMbaasApp",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"var",
"model",
"=",
"req",
".",
"appMbaasModel",
";",
"model",
".",
"name",
"=",
"req",
".",
"params",
".",
"appname",
";",
"model",
".",
"domain",
"=",
"req",
".",
"params",
".",
"domain",
";",
"model",
".",
"environment",
"=",
"req",
".",
"params",
".",
"environment",
";",
"model",
".",
"guid",
"=",
"req",
".",
"body",
".",
"appGuid",
";",
"model",
".",
"apiKey",
"=",
"req",
".",
"body",
".",
"apiKey",
";",
"model",
".",
"coreHost",
"=",
"req",
".",
"body",
".",
"coreHost",
";",
"model",
".",
"type",
"=",
"req",
".",
"body",
".",
"type",
";",
"model",
".",
"mbaasUrl",
"=",
"req",
".",
"body",
".",
"mbaasUrl",
";",
"//If the serviceApp is not set yet and it is a service app, then make sure it is set.",
"model",
".",
"isServiceApp",
"=",
"typeof",
"model",
".",
"isServiceApp",
"===",
"\"undefined\"",
"?",
"req",
".",
"body",
".",
"isServiceApp",
":",
"model",
".",
"isServiceApp",
";",
"model",
".",
"url",
"=",
"req",
".",
"body",
".",
"url",
"||",
"model",
".",
"url",
";",
"model",
".",
"accessKey",
"=",
"model",
".",
"accessKey",
"||",
"new",
"mongoose",
".",
"Types",
".",
"ObjectId",
"(",
")",
";",
"model",
".",
"save",
"(",
"next",
")",
";",
"}"
] | Middleware To Update An Existing App Deployment
@param req
@param res
@param next | [
"Middleware",
"To",
"Update",
"An",
"Existing",
"App",
"Deployment"
] | f906e98efbb4b0963bf5137b34b5e0589ba24e69 | https://github.com/feedhenry/fh-mbaas-middleware/blob/f906e98efbb4b0963bf5137b34b5e0589ba24e69/lib/middleware/app.js#L101-L118 |
50,437 | redisjs/jsr-server | lib/command/transaction/discard.js | execute | function execute(req, res) {
// unwatch keys, clear references,
// and destroy the transaction reference on the conn
// and send the reply
req.conn.transaction.destroy(req, res, null, Constants.OK);
} | javascript | function execute(req, res) {
// unwatch keys, clear references,
// and destroy the transaction reference on the conn
// and send the reply
req.conn.transaction.destroy(req, res, null, Constants.OK);
} | [
"function",
"execute",
"(",
"req",
",",
"res",
")",
"{",
"// unwatch keys, clear references,",
"// and destroy the transaction reference on the conn",
"// and send the reply",
"req",
".",
"conn",
".",
"transaction",
".",
"destroy",
"(",
"req",
",",
"res",
",",
"null",
",",
"Constants",
".",
"OK",
")",
";",
"}"
] | Respond to the DISCARD command. | [
"Respond",
"to",
"the",
"DISCARD",
"command",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/transaction/discard.js#L19-L24 |
50,438 | redisjs/jsr-server | lib/command/transaction/discard.js | validate | function validate(cmd, args, info) {
AbstractCommand.prototype.validate.apply(this, arguments);
if(!info.conn.transaction) {
throw DiscardWithoutMulti;
}
} | javascript | function validate(cmd, args, info) {
AbstractCommand.prototype.validate.apply(this, arguments);
if(!info.conn.transaction) {
throw DiscardWithoutMulti;
}
} | [
"function",
"validate",
"(",
"cmd",
",",
"args",
",",
"info",
")",
"{",
"AbstractCommand",
".",
"prototype",
".",
"validate",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"if",
"(",
"!",
"info",
".",
"conn",
".",
"transaction",
")",
"{",
"throw",
"DiscardWithoutMulti",
";",
"}",
"}"
] | Validate the DISCARD command. | [
"Validate",
"the",
"DISCARD",
"command",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/transaction/discard.js#L29-L34 |
50,439 | ottojs/otto-errors | lib/unauthorized.error.js | ErrorUnauthorized | function ErrorUnauthorized (message) {
Error.call(this);
// Add Information
this.name = 'ErrorUnauthorized';
this.type = 'client';
this.status = 401;
if (message) {
this.message = message;
}
} | javascript | function ErrorUnauthorized (message) {
Error.call(this);
// Add Information
this.name = 'ErrorUnauthorized';
this.type = 'client';
this.status = 401;
if (message) {
this.message = message;
}
} | [
"function",
"ErrorUnauthorized",
"(",
"message",
")",
"{",
"Error",
".",
"call",
"(",
"this",
")",
";",
"// Add Information",
"this",
".",
"name",
"=",
"'ErrorUnauthorized'",
";",
"this",
".",
"type",
"=",
"'client'",
";",
"this",
".",
"status",
"=",
"401",
";",
"if",
"(",
"message",
")",
"{",
"this",
".",
"message",
"=",
"message",
";",
"}",
"}"
] | Error - ErrorUnauthorized | [
"Error",
"-",
"ErrorUnauthorized"
] | a3c6d98fd5d35ce3c136ed7e1edd2f800af268d9 | https://github.com/ottojs/otto-errors/blob/a3c6d98fd5d35ce3c136ed7e1edd2f800af268d9/lib/unauthorized.error.js#L8-L20 |
50,440 | skylarklangx/skylark-langx | dist/uncompressed/skylark-langx/objects.js | allKeys | function allKeys(obj) {
if (!isObject(obj)) return [];
var keys = [];
for (var key in obj) keys.push(key);
return keys;
} | javascript | function allKeys(obj) {
if (!isObject(obj)) return [];
var keys = [];
for (var key in obj) keys.push(key);
return keys;
} | [
"function",
"allKeys",
"(",
"obj",
")",
"{",
"if",
"(",
"!",
"isObject",
"(",
"obj",
")",
")",
"return",
"[",
"]",
";",
"var",
"keys",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"key",
"in",
"obj",
")",
"keys",
".",
"push",
"(",
"key",
")",
";",
"return",
"keys",
";",
"}"
] | Retrieve all the property names of an object. | [
"Retrieve",
"all",
"the",
"property",
"names",
"of",
"an",
"object",
"."
] | 49a5ca4de8d292a0fb902564566af8e149ac4e65 | https://github.com/skylarklangx/skylark-langx/blob/49a5ca4de8d292a0fb902564566af8e149ac4e65/dist/uncompressed/skylark-langx/objects.js#L144-L149 |
50,441 | folktale/core.inspect | index.js | showArray | function showArray(maxDepth, array) {
return '['
+ array.map(function(a) {
return show(maxDepth - 1, a)
}).join(', ')
+ ']';
} | javascript | function showArray(maxDepth, array) {
return '['
+ array.map(function(a) {
return show(maxDepth - 1, a)
}).join(', ')
+ ']';
} | [
"function",
"showArray",
"(",
"maxDepth",
",",
"array",
")",
"{",
"return",
"'['",
"+",
"array",
".",
"map",
"(",
"function",
"(",
"a",
")",
"{",
"return",
"show",
"(",
"maxDepth",
"-",
"1",
",",
"a",
")",
"}",
")",
".",
"join",
"(",
"', '",
")",
"+",
"']'",
";",
"}"
] | Displays the representation of an array.
@method
@private
@summary Number → [α] → String | [
"Displays",
"the",
"representation",
"of",
"an",
"array",
"."
] | aaf5cab00abbcaa3e5140e9f9581a2c4c7ffb57c | https://github.com/folktale/core.inspect/blob/aaf5cab00abbcaa3e5140e9f9581a2c4c7ffb57c/index.js#L118-L124 |
50,442 | folktale/core.inspect | index.js | showObject | function showObject(maxDepth, object) {
return '{'
+ pairs(object).map(function(pair){
return showString(pair.key) + ': ' + show(maxDepth - 1, pair.value)
}).join(', ')
+ '}'
} | javascript | function showObject(maxDepth, object) {
return '{'
+ pairs(object).map(function(pair){
return showString(pair.key) + ': ' + show(maxDepth - 1, pair.value)
}).join(', ')
+ '}'
} | [
"function",
"showObject",
"(",
"maxDepth",
",",
"object",
")",
"{",
"return",
"'{'",
"+",
"pairs",
"(",
"object",
")",
".",
"map",
"(",
"function",
"(",
"pair",
")",
"{",
"return",
"showString",
"(",
"pair",
".",
"key",
")",
"+",
"': '",
"+",
"show",
"(",
"maxDepth",
"-",
"1",
",",
"pair",
".",
"value",
")",
"}",
")",
".",
"join",
"(",
"', '",
")",
"+",
"'}'",
"}"
] | Displays the representation of an object.
@method
@private
@summary Number → { String → * } → String | [
"Displays",
"the",
"representation",
"of",
"an",
"object",
"."
] | aaf5cab00abbcaa3e5140e9f9581a2c4c7ffb57c | https://github.com/folktale/core.inspect/blob/aaf5cab00abbcaa3e5140e9f9581a2c4c7ffb57c/index.js#L133-L139 |
50,443 | avetjs/avet-styled-jsx | lib/utils.js | styledJsxOptions | function styledJsxOptions(opts) {
if (!opts) {
return {};
}
if (!Array.isArray(opts.plugins)) {
return opts;
}
opts.plugins = opts.plugins.map(plugin => {
if (Array.isArray(plugin)) {
const [ name, options ] = plugin;
return [ require.resolve(name), options ];
}
return require.resolve(plugin);
});
return opts;
} | javascript | function styledJsxOptions(opts) {
if (!opts) {
return {};
}
if (!Array.isArray(opts.plugins)) {
return opts;
}
opts.plugins = opts.plugins.map(plugin => {
if (Array.isArray(plugin)) {
const [ name, options ] = plugin;
return [ require.resolve(name), options ];
}
return require.resolve(plugin);
});
return opts;
} | [
"function",
"styledJsxOptions",
"(",
"opts",
")",
"{",
"if",
"(",
"!",
"opts",
")",
"{",
"return",
"{",
"}",
";",
"}",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"opts",
".",
"plugins",
")",
")",
"{",
"return",
"opts",
";",
"}",
"opts",
".",
"plugins",
"=",
"opts",
".",
"plugins",
".",
"map",
"(",
"plugin",
"=>",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"plugin",
")",
")",
"{",
"const",
"[",
"name",
",",
"options",
"]",
"=",
"plugin",
";",
"return",
"[",
"require",
".",
"resolve",
"(",
"name",
")",
",",
"options",
"]",
";",
"}",
"return",
"require",
".",
"resolve",
"(",
"plugin",
")",
";",
"}",
")",
";",
"return",
"opts",
";",
"}"
] | Resolve styled-jsx plugins | [
"Resolve",
"styled",
"-",
"jsx",
"plugins"
] | 306fb476b65f978110ac60291e0893dc3d0556c7 | https://github.com/avetjs/avet-styled-jsx/blob/306fb476b65f978110ac60291e0893dc3d0556c7/lib/utils.js#L2-L21 |
50,444 | derdesign/protos | drivers/mongodb.js | MongoDB | function MongoDB(config) {
var self = this;
this.events = new EventEmitter();
config = protos.extend({
host: 'localhost',
port: 27017,
database: 'default',
storage: null,
username: '',
password: '',
safe: true
}, config || {});
if (typeof config.port != 'number') config.port = parseInt(config.port, 10);
this.className = this.constructor.name;
app.debug(util.format('Initializing MongoDB for %s:%s', config.host, config.port));
/**
config: {
host: 'localhost',
port: 27017,
database: 'db_name',
storage: 'redis'
}
*/
this.config = config;
var reportError = function(err) {
app.log(util.format("MongoDB [%s:%s] %s", config.host, config.port, err));
self.client = null;
}
// Set db
self.db = new Db(config.database, new Server(config.host, config.port, {}), {safe: config.safe});
// Add async task
app.addReadyTask();
// Get client
self.db.open(function(err, client) {
if (err) {
reportError(err);
} else {
// Set client
self.client = client;
// Set storage
if (typeof config.storage == 'string') {
self.storage = app.getResource('storages/' + config.storage);
} else if (config.storage instanceof protos.lib.storage) {
self.storage = config.storage;
}
// Authenticate
if (config.username && config.password) {
self.db.authenticate(config.username, config.password, function(err, success) {
if (err) {
var msg = util.format('MongoDB: unable to authenticate %s@%s', config.username, config.host);
app.log(new Error(msg));
throw err;
} else {
// Emit initialization event
self.events.emit('init', self.db, self.client);
}
});
} else {
// Emit initialization event
self.events.emit('init', self.db, self.client);
}
}
});
// Flush async task
this.events.once('init', function() {
app.flushReadyTask();
});
// Only set important properties enumerable
protos.util.onlySetEnumerable(this, ['className', 'db']);
} | javascript | function MongoDB(config) {
var self = this;
this.events = new EventEmitter();
config = protos.extend({
host: 'localhost',
port: 27017,
database: 'default',
storage: null,
username: '',
password: '',
safe: true
}, config || {});
if (typeof config.port != 'number') config.port = parseInt(config.port, 10);
this.className = this.constructor.name;
app.debug(util.format('Initializing MongoDB for %s:%s', config.host, config.port));
/**
config: {
host: 'localhost',
port: 27017,
database: 'db_name',
storage: 'redis'
}
*/
this.config = config;
var reportError = function(err) {
app.log(util.format("MongoDB [%s:%s] %s", config.host, config.port, err));
self.client = null;
}
// Set db
self.db = new Db(config.database, new Server(config.host, config.port, {}), {safe: config.safe});
// Add async task
app.addReadyTask();
// Get client
self.db.open(function(err, client) {
if (err) {
reportError(err);
} else {
// Set client
self.client = client;
// Set storage
if (typeof config.storage == 'string') {
self.storage = app.getResource('storages/' + config.storage);
} else if (config.storage instanceof protos.lib.storage) {
self.storage = config.storage;
}
// Authenticate
if (config.username && config.password) {
self.db.authenticate(config.username, config.password, function(err, success) {
if (err) {
var msg = util.format('MongoDB: unable to authenticate %s@%s', config.username, config.host);
app.log(new Error(msg));
throw err;
} else {
// Emit initialization event
self.events.emit('init', self.db, self.client);
}
});
} else {
// Emit initialization event
self.events.emit('init', self.db, self.client);
}
}
});
// Flush async task
this.events.once('init', function() {
app.flushReadyTask();
});
// Only set important properties enumerable
protos.util.onlySetEnumerable(this, ['className', 'db']);
} | [
"function",
"MongoDB",
"(",
"config",
")",
"{",
"var",
"self",
"=",
"this",
";",
"this",
".",
"events",
"=",
"new",
"EventEmitter",
"(",
")",
";",
"config",
"=",
"protos",
".",
"extend",
"(",
"{",
"host",
":",
"'localhost'",
",",
"port",
":",
"27017",
",",
"database",
":",
"'default'",
",",
"storage",
":",
"null",
",",
"username",
":",
"''",
",",
"password",
":",
"''",
",",
"safe",
":",
"true",
"}",
",",
"config",
"||",
"{",
"}",
")",
";",
"if",
"(",
"typeof",
"config",
".",
"port",
"!=",
"'number'",
")",
"config",
".",
"port",
"=",
"parseInt",
"(",
"config",
".",
"port",
",",
"10",
")",
";",
"this",
".",
"className",
"=",
"this",
".",
"constructor",
".",
"name",
";",
"app",
".",
"debug",
"(",
"util",
".",
"format",
"(",
"'Initializing MongoDB for %s:%s'",
",",
"config",
".",
"host",
",",
"config",
".",
"port",
")",
")",
";",
"/**\n \n config: {\n host: 'localhost',\n port: 27017,\n database: 'db_name',\n storage: 'redis'\n }\n\n */",
"this",
".",
"config",
"=",
"config",
";",
"var",
"reportError",
"=",
"function",
"(",
"err",
")",
"{",
"app",
".",
"log",
"(",
"util",
".",
"format",
"(",
"\"MongoDB [%s:%s] %s\"",
",",
"config",
".",
"host",
",",
"config",
".",
"port",
",",
"err",
")",
")",
";",
"self",
".",
"client",
"=",
"null",
";",
"}",
"// Set db",
"self",
".",
"db",
"=",
"new",
"Db",
"(",
"config",
".",
"database",
",",
"new",
"Server",
"(",
"config",
".",
"host",
",",
"config",
".",
"port",
",",
"{",
"}",
")",
",",
"{",
"safe",
":",
"config",
".",
"safe",
"}",
")",
";",
"// Add async task",
"app",
".",
"addReadyTask",
"(",
")",
";",
"// Get client",
"self",
".",
"db",
".",
"open",
"(",
"function",
"(",
"err",
",",
"client",
")",
"{",
"if",
"(",
"err",
")",
"{",
"reportError",
"(",
"err",
")",
";",
"}",
"else",
"{",
"// Set client",
"self",
".",
"client",
"=",
"client",
";",
"// Set storage",
"if",
"(",
"typeof",
"config",
".",
"storage",
"==",
"'string'",
")",
"{",
"self",
".",
"storage",
"=",
"app",
".",
"getResource",
"(",
"'storages/'",
"+",
"config",
".",
"storage",
")",
";",
"}",
"else",
"if",
"(",
"config",
".",
"storage",
"instanceof",
"protos",
".",
"lib",
".",
"storage",
")",
"{",
"self",
".",
"storage",
"=",
"config",
".",
"storage",
";",
"}",
"// Authenticate",
"if",
"(",
"config",
".",
"username",
"&&",
"config",
".",
"password",
")",
"{",
"self",
".",
"db",
".",
"authenticate",
"(",
"config",
".",
"username",
",",
"config",
".",
"password",
",",
"function",
"(",
"err",
",",
"success",
")",
"{",
"if",
"(",
"err",
")",
"{",
"var",
"msg",
"=",
"util",
".",
"format",
"(",
"'MongoDB: unable to authenticate %s@%s'",
",",
"config",
".",
"username",
",",
"config",
".",
"host",
")",
";",
"app",
".",
"log",
"(",
"new",
"Error",
"(",
"msg",
")",
")",
";",
"throw",
"err",
";",
"}",
"else",
"{",
"// Emit initialization event",
"self",
".",
"events",
".",
"emit",
"(",
"'init'",
",",
"self",
".",
"db",
",",
"self",
".",
"client",
")",
";",
"}",
"}",
")",
";",
"}",
"else",
"{",
"// Emit initialization event",
"self",
".",
"events",
".",
"emit",
"(",
"'init'",
",",
"self",
".",
"db",
",",
"self",
".",
"client",
")",
";",
"}",
"}",
"}",
")",
";",
"// Flush async task",
"this",
".",
"events",
".",
"once",
"(",
"'init'",
",",
"function",
"(",
")",
"{",
"app",
".",
"flushReadyTask",
"(",
")",
";",
"}",
")",
";",
"// Only set important properties enumerable",
"protos",
".",
"util",
".",
"onlySetEnumerable",
"(",
"this",
",",
"[",
"'className'",
",",
"'db'",
"]",
")",
";",
"}"
] | MongoDB Driver class
@class MongoDB
@extends Driver
@constructor
@param {object} app Application instance
@param {object} config Driver configuration | [
"MongoDB",
"Driver",
"class"
] | 0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9 | https://github.com/derdesign/protos/blob/0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9/drivers/mongodb.js#L25-L123 |
50,445 | andrewscwei/requiem | src/helpers/debounce.js | debounce | function debounce(method, delay, leading) {
assertType(method, 'function', false, 'Invalid parameter: method');
assertType(delay, 'number', true, 'Invalid optional parameter: delay');
assertType(leading, 'boolean', true, 'Invalid optional parameter: leading');
if (delay === undefined) delay = 0;
if (leading === undefined) leading = false;
let timeout;
return function() {
let context = this;
let args = arguments;
let later = function() {
timeout = null;
if (!leading) method.apply(context, args);
};
let callNow = leading && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, delay);
if (callNow) method.apply(context, args);
};
} | javascript | function debounce(method, delay, leading) {
assertType(method, 'function', false, 'Invalid parameter: method');
assertType(delay, 'number', true, 'Invalid optional parameter: delay');
assertType(leading, 'boolean', true, 'Invalid optional parameter: leading');
if (delay === undefined) delay = 0;
if (leading === undefined) leading = false;
let timeout;
return function() {
let context = this;
let args = arguments;
let later = function() {
timeout = null;
if (!leading) method.apply(context, args);
};
let callNow = leading && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, delay);
if (callNow) method.apply(context, args);
};
} | [
"function",
"debounce",
"(",
"method",
",",
"delay",
",",
"leading",
")",
"{",
"assertType",
"(",
"method",
",",
"'function'",
",",
"false",
",",
"'Invalid parameter: method'",
")",
";",
"assertType",
"(",
"delay",
",",
"'number'",
",",
"true",
",",
"'Invalid optional parameter: delay'",
")",
";",
"assertType",
"(",
"leading",
",",
"'boolean'",
",",
"true",
",",
"'Invalid optional parameter: leading'",
")",
";",
"if",
"(",
"delay",
"===",
"undefined",
")",
"delay",
"=",
"0",
";",
"if",
"(",
"leading",
"===",
"undefined",
")",
"leading",
"=",
"false",
";",
"let",
"timeout",
";",
"return",
"function",
"(",
")",
"{",
"let",
"context",
"=",
"this",
";",
"let",
"args",
"=",
"arguments",
";",
"let",
"later",
"=",
"function",
"(",
")",
"{",
"timeout",
"=",
"null",
";",
"if",
"(",
"!",
"leading",
")",
"method",
".",
"apply",
"(",
"context",
",",
"args",
")",
";",
"}",
";",
"let",
"callNow",
"=",
"leading",
"&&",
"!",
"timeout",
";",
"clearTimeout",
"(",
"timeout",
")",
";",
"timeout",
"=",
"setTimeout",
"(",
"later",
",",
"delay",
")",
";",
"if",
"(",
"callNow",
")",
"method",
".",
"apply",
"(",
"context",
",",
"args",
")",
";",
"}",
";",
"}"
] | Returns a function that, as long as it continues to be invoked, will not be
triggered. The function will be called after it stops being called for N
milliseconds. If 'leading' is passed, the function will be triggered on the
leading edge instead of the trailing.
@param {Function} method - Method to be debounced.
@param {number} [delay=0] - Debounce rate in milliseconds.
@param {boolean} [leading=false] - Indicates whether the method is triggered
on the leading edge instead of the
trailing.
@return {Function} The debounced method.
@alias module:requiem~helpers.debounce | [
"Returns",
"a",
"function",
"that",
"as",
"long",
"as",
"it",
"continues",
"to",
"be",
"invoked",
"will",
"not",
"be",
"triggered",
".",
"The",
"function",
"will",
"be",
"called",
"after",
"it",
"stops",
"being",
"called",
"for",
"N",
"milliseconds",
".",
"If",
"leading",
"is",
"passed",
"the",
"function",
"will",
"be",
"triggered",
"on",
"the",
"leading",
"edge",
"instead",
"of",
"the",
"trailing",
"."
] | c4182bfffc9841c6de5718f689ad3c2060511777 | https://github.com/andrewscwei/requiem/blob/c4182bfffc9841c6de5718f689ad3c2060511777/src/helpers/debounce.js#L23-L48 |
50,446 | rearjs/rear | packages/rear-sql/query.js | exec | function exec(sqlQuery, poolName) {
return new Promise((resolve, reject) => {
db.connect((err, client, done) => {
if (err) {
reject(err);
}
client.query(sqlQuery, (err, results) => {
if (err) {
reject(err);
}
resolve(results);
});
}, poolName || 'default', );
});
} | javascript | function exec(sqlQuery, poolName) {
return new Promise((resolve, reject) => {
db.connect((err, client, done) => {
if (err) {
reject(err);
}
client.query(sqlQuery, (err, results) => {
if (err) {
reject(err);
}
resolve(results);
});
}, poolName || 'default', );
});
} | [
"function",
"exec",
"(",
"sqlQuery",
",",
"poolName",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"db",
".",
"connect",
"(",
"(",
"err",
",",
"client",
",",
"done",
")",
"=>",
"{",
"if",
"(",
"err",
")",
"{",
"reject",
"(",
"err",
")",
";",
"}",
"client",
".",
"query",
"(",
"sqlQuery",
",",
"(",
"err",
",",
"results",
")",
"=>",
"{",
"if",
"(",
"err",
")",
"{",
"reject",
"(",
"err",
")",
";",
"}",
"resolve",
"(",
"results",
")",
";",
"}",
")",
";",
"}",
",",
"poolName",
"||",
"'default'",
",",
")",
";",
"}",
")",
";",
"}"
] | Execute a sql query with pg.Pool
@param {ParametizedQuery} sqlQuery Parametized pg query object
@return {Promise<Object>} Resolve with query results
@example
const query = require('./query')
const SQL = query.SQL
const id = 2
query.exec(SQL`SELECT * FROM "Users" WHERE id = ${id}`)
.then((result) => {
console.log('User', result.rows[0])
}) | [
"Execute",
"a",
"sql",
"query",
"with",
"pg",
".",
"Pool"
] | 0b4a1fa42653a1b9ef200994cc9eef49baa43052 | https://github.com/rearjs/rear/blob/0b4a1fa42653a1b9ef200994cc9eef49baa43052/packages/rear-sql/query.js#L49-L63 |
50,447 | koumoul-dev/sd-express | index.js | _cors | function _cors (cookieDomain, publicUrl) {
return ({ acceptServers, acceptAllOrigins }) => {
// accept server 2 server requests by default
acceptServers = acceptServers === undefined ? true : acceptServers
// do not accept call by outside origins by default
acceptAllOrigins = acceptAllOrigins === undefined ? false : acceptAllOrigins
return corsBuilder({
credentials: true,
origin (origin, callback) {
// Case of server to server requests
if (!origin) {
if (acceptServers) return callback(null, true)
return callback(new Error('No CORS allowed for server to server requests'))
}
// Case where we accept any domain as origin
if (acceptAllOrigins) return callback(null, true)
const originDomain = new URL(origin).host
// Case of mono-domain acceptance
if (!cookieDomain) {
if (originDomain === new URL(publicUrl).host) return callback(null, true)
return callback(new Error(`No CORS allowed from origin ${origin}`))
}
// Case of subdomains acceptance
if (originDomain === cookieDomain || originDomain.endsWith('.' + cookieDomain)) {
return callback(null, true)
}
callback(new Error(`No CORS allowed from origin ${origin}`))
}
})
}
} | javascript | function _cors (cookieDomain, publicUrl) {
return ({ acceptServers, acceptAllOrigins }) => {
// accept server 2 server requests by default
acceptServers = acceptServers === undefined ? true : acceptServers
// do not accept call by outside origins by default
acceptAllOrigins = acceptAllOrigins === undefined ? false : acceptAllOrigins
return corsBuilder({
credentials: true,
origin (origin, callback) {
// Case of server to server requests
if (!origin) {
if (acceptServers) return callback(null, true)
return callback(new Error('No CORS allowed for server to server requests'))
}
// Case where we accept any domain as origin
if (acceptAllOrigins) return callback(null, true)
const originDomain = new URL(origin).host
// Case of mono-domain acceptance
if (!cookieDomain) {
if (originDomain === new URL(publicUrl).host) return callback(null, true)
return callback(new Error(`No CORS allowed from origin ${origin}`))
}
// Case of subdomains acceptance
if (originDomain === cookieDomain || originDomain.endsWith('.' + cookieDomain)) {
return callback(null, true)
}
callback(new Error(`No CORS allowed from origin ${origin}`))
}
})
}
} | [
"function",
"_cors",
"(",
"cookieDomain",
",",
"publicUrl",
")",
"{",
"return",
"(",
"{",
"acceptServers",
",",
"acceptAllOrigins",
"}",
")",
"=>",
"{",
"// accept server 2 server requests by default",
"acceptServers",
"=",
"acceptServers",
"===",
"undefined",
"?",
"true",
":",
"acceptServers",
"// do not accept call by outside origins by default",
"acceptAllOrigins",
"=",
"acceptAllOrigins",
"===",
"undefined",
"?",
"false",
":",
"acceptAllOrigins",
"return",
"corsBuilder",
"(",
"{",
"credentials",
":",
"true",
",",
"origin",
"(",
"origin",
",",
"callback",
")",
"{",
"// Case of server to server requests",
"if",
"(",
"!",
"origin",
")",
"{",
"if",
"(",
"acceptServers",
")",
"return",
"callback",
"(",
"null",
",",
"true",
")",
"return",
"callback",
"(",
"new",
"Error",
"(",
"'No CORS allowed for server to server requests'",
")",
")",
"}",
"// Case where we accept any domain as origin",
"if",
"(",
"acceptAllOrigins",
")",
"return",
"callback",
"(",
"null",
",",
"true",
")",
"const",
"originDomain",
"=",
"new",
"URL",
"(",
"origin",
")",
".",
"host",
"// Case of mono-domain acceptance",
"if",
"(",
"!",
"cookieDomain",
")",
"{",
"if",
"(",
"originDomain",
"===",
"new",
"URL",
"(",
"publicUrl",
")",
".",
"host",
")",
"return",
"callback",
"(",
"null",
",",
"true",
")",
"return",
"callback",
"(",
"new",
"Error",
"(",
"`",
"${",
"origin",
"}",
"`",
")",
")",
"}",
"// Case of subdomains acceptance",
"if",
"(",
"originDomain",
"===",
"cookieDomain",
"||",
"originDomain",
".",
"endsWith",
"(",
"'.'",
"+",
"cookieDomain",
")",
")",
"{",
"return",
"callback",
"(",
"null",
",",
"true",
")",
"}",
"callback",
"(",
"new",
"Error",
"(",
"`",
"${",
"origin",
"}",
"`",
")",
")",
"}",
"}",
")",
"}",
"}"
] | Return a function that can build a CORS middleware | [
"Return",
"a",
"function",
"that",
"can",
"build",
"a",
"CORS",
"middleware"
] | d7da1af5b9bcf893d9f9f82a67668f0d4b8099f9 | https://github.com/koumoul-dev/sd-express/blob/d7da1af5b9bcf893d9f9f82a67668f0d4b8099f9/index.js#L61-L95 |
50,448 | koumoul-dev/sd-express | index.js | _getCookieToken | function _getCookieToken (cookies, req, cookieName, cookieDomain, publicUrl) {
let token = cookies.get(cookieName)
if (!token) return null
const reqOrigin = req.headers['origin']
const originDomain = reqOrigin && new URL(reqOrigin).host
// check that the origin of the request is part of the accepted domain
if (reqOrigin && cookieDomain && originDomain !== cookieDomain && !originDomain.endsWith('.' + cookieDomain)) {
debug(`A cookie was sent from origin ${reqOrigin} while cookie domain is ${cookieDomain}, ignore it`)
return null
}
// or simply that it is strictly equal to current target if domain is unspecified
// in this case we are also protected by sameSite
if (reqOrigin && !cookieDomain && reqOrigin !== new URL(publicUrl).origin) {
debug(`A cookie was sent from origin ${reqOrigin} while public url is ${publicUrl}, ignore it`)
return null
}
// Putting the signature in a second token is recommended but optional
// and we accept full JWT in id_token cooke
const signature = cookies.get(cookieName + '_sign')
if (signature && (token.match(/\./g) || []).length === 1) {
token += '.' + signature
}
return token
} | javascript | function _getCookieToken (cookies, req, cookieName, cookieDomain, publicUrl) {
let token = cookies.get(cookieName)
if (!token) return null
const reqOrigin = req.headers['origin']
const originDomain = reqOrigin && new URL(reqOrigin).host
// check that the origin of the request is part of the accepted domain
if (reqOrigin && cookieDomain && originDomain !== cookieDomain && !originDomain.endsWith('.' + cookieDomain)) {
debug(`A cookie was sent from origin ${reqOrigin} while cookie domain is ${cookieDomain}, ignore it`)
return null
}
// or simply that it is strictly equal to current target if domain is unspecified
// in this case we are also protected by sameSite
if (reqOrigin && !cookieDomain && reqOrigin !== new URL(publicUrl).origin) {
debug(`A cookie was sent from origin ${reqOrigin} while public url is ${publicUrl}, ignore it`)
return null
}
// Putting the signature in a second token is recommended but optional
// and we accept full JWT in id_token cooke
const signature = cookies.get(cookieName + '_sign')
if (signature && (token.match(/\./g) || []).length === 1) {
token += '.' + signature
}
return token
} | [
"function",
"_getCookieToken",
"(",
"cookies",
",",
"req",
",",
"cookieName",
",",
"cookieDomain",
",",
"publicUrl",
")",
"{",
"let",
"token",
"=",
"cookies",
".",
"get",
"(",
"cookieName",
")",
"if",
"(",
"!",
"token",
")",
"return",
"null",
"const",
"reqOrigin",
"=",
"req",
".",
"headers",
"[",
"'origin'",
"]",
"const",
"originDomain",
"=",
"reqOrigin",
"&&",
"new",
"URL",
"(",
"reqOrigin",
")",
".",
"host",
"// check that the origin of the request is part of the accepted domain",
"if",
"(",
"reqOrigin",
"&&",
"cookieDomain",
"&&",
"originDomain",
"!==",
"cookieDomain",
"&&",
"!",
"originDomain",
".",
"endsWith",
"(",
"'.'",
"+",
"cookieDomain",
")",
")",
"{",
"debug",
"(",
"`",
"${",
"reqOrigin",
"}",
"${",
"cookieDomain",
"}",
"`",
")",
"return",
"null",
"}",
"// or simply that it is strictly equal to current target if domain is unspecified",
"// in this case we are also protected by sameSite",
"if",
"(",
"reqOrigin",
"&&",
"!",
"cookieDomain",
"&&",
"reqOrigin",
"!==",
"new",
"URL",
"(",
"publicUrl",
")",
".",
"origin",
")",
"{",
"debug",
"(",
"`",
"${",
"reqOrigin",
"}",
"${",
"publicUrl",
"}",
"`",
")",
"return",
"null",
"}",
"// Putting the signature in a second token is recommended but optional",
"// and we accept full JWT in id_token cooke",
"const",
"signature",
"=",
"cookies",
".",
"get",
"(",
"cookieName",
"+",
"'_sign'",
")",
"if",
"(",
"signature",
"&&",
"(",
"token",
".",
"match",
"(",
"/",
"\\.",
"/",
"g",
")",
"||",
"[",
"]",
")",
".",
"length",
"===",
"1",
")",
"{",
"token",
"+=",
"'.'",
"+",
"signature",
"}",
"return",
"token",
"}"
] | Fetch a session token from cookies if the same site policy is respected | [
"Fetch",
"a",
"session",
"token",
"from",
"cookies",
"if",
"the",
"same",
"site",
"policy",
"is",
"respected"
] | d7da1af5b9bcf893d9f9f82a67668f0d4b8099f9 | https://github.com/koumoul-dev/sd-express/blob/d7da1af5b9bcf893d9f9f82a67668f0d4b8099f9/index.js#L98-L123 |
50,449 | koumoul-dev/sd-express | index.js | _setCookieToken | function _setCookieToken (cookies, cookieName, cookieDomain, token, payload) {
const parts = token.split('.')
const opts = { sameSite: 'lax', expires: new Date(payload.exp * 1000) }
if (cookieDomain) {
opts.domain = cookieDomain
// to support subdomains we can't use the sameSite opt
// we rely on our manual check of the origin
delete opts.sameSite
}
cookies.set(cookieName, parts[0] + '.' + parts[1], { ...opts, httpOnly: false })
cookies.set(cookieName + '_sign', parts[2], { ...opts, httpOnly: true })
} | javascript | function _setCookieToken (cookies, cookieName, cookieDomain, token, payload) {
const parts = token.split('.')
const opts = { sameSite: 'lax', expires: new Date(payload.exp * 1000) }
if (cookieDomain) {
opts.domain = cookieDomain
// to support subdomains we can't use the sameSite opt
// we rely on our manual check of the origin
delete opts.sameSite
}
cookies.set(cookieName, parts[0] + '.' + parts[1], { ...opts, httpOnly: false })
cookies.set(cookieName + '_sign', parts[2], { ...opts, httpOnly: true })
} | [
"function",
"_setCookieToken",
"(",
"cookies",
",",
"cookieName",
",",
"cookieDomain",
",",
"token",
",",
"payload",
")",
"{",
"const",
"parts",
"=",
"token",
".",
"split",
"(",
"'.'",
")",
"const",
"opts",
"=",
"{",
"sameSite",
":",
"'lax'",
",",
"expires",
":",
"new",
"Date",
"(",
"payload",
".",
"exp",
"*",
"1000",
")",
"}",
"if",
"(",
"cookieDomain",
")",
"{",
"opts",
".",
"domain",
"=",
"cookieDomain",
"// to support subdomains we can't use the sameSite opt",
"// we rely on our manual check of the origin",
"delete",
"opts",
".",
"sameSite",
"}",
"cookies",
".",
"set",
"(",
"cookieName",
",",
"parts",
"[",
"0",
"]",
"+",
"'.'",
"+",
"parts",
"[",
"1",
"]",
",",
"{",
"...",
"opts",
",",
"httpOnly",
":",
"false",
"}",
")",
"cookies",
".",
"set",
"(",
"cookieName",
"+",
"'_sign'",
",",
"parts",
"[",
"2",
"]",
",",
"{",
"...",
"opts",
",",
"httpOnly",
":",
"true",
"}",
")",
"}"
] | Split JWT strategy, the signature is in a httpOnly cookie for XSS prevention the header and payload are not httpOnly to be readable by client all cookies use sameSite for CSRF prevention | [
"Split",
"JWT",
"strategy",
"the",
"signature",
"is",
"in",
"a",
"httpOnly",
"cookie",
"for",
"XSS",
"prevention",
"the",
"header",
"and",
"payload",
"are",
"not",
"httpOnly",
"to",
"be",
"readable",
"by",
"client",
"all",
"cookies",
"use",
"sameSite",
"for",
"CSRF",
"prevention"
] | d7da1af5b9bcf893d9f9f82a67668f0d4b8099f9 | https://github.com/koumoul-dev/sd-express/blob/d7da1af5b9bcf893d9f9f82a67668f0d4b8099f9/index.js#L128-L139 |
50,450 | koumoul-dev/sd-express | index.js | _setOrganization | function _setOrganization (cookies, cookieName, req, user) {
if (!user) return
// The order is important. The header can set explicitly on a query even if the cookie contradicts.
const organizationId = req.headers['x-organizationid'] || cookies.get(cookieName + '_org')
if (organizationId) {
user.organization = (user.organizations || []).find(o => o.id === organizationId)
if (user.organization) {
user.consumerFlag = user.organization.id
} else if (organizationId === '' || organizationId.toLowerCase() === 'user') {
user.consumerFlag = 'user'
}
}
} | javascript | function _setOrganization (cookies, cookieName, req, user) {
if (!user) return
// The order is important. The header can set explicitly on a query even if the cookie contradicts.
const organizationId = req.headers['x-organizationid'] || cookies.get(cookieName + '_org')
if (organizationId) {
user.organization = (user.organizations || []).find(o => o.id === organizationId)
if (user.organization) {
user.consumerFlag = user.organization.id
} else if (organizationId === '' || organizationId.toLowerCase() === 'user') {
user.consumerFlag = 'user'
}
}
} | [
"function",
"_setOrganization",
"(",
"cookies",
",",
"cookieName",
",",
"req",
",",
"user",
")",
"{",
"if",
"(",
"!",
"user",
")",
"return",
"// The order is important. The header can set explicitly on a query even if the cookie contradicts.",
"const",
"organizationId",
"=",
"req",
".",
"headers",
"[",
"'x-organizationid'",
"]",
"||",
"cookies",
".",
"get",
"(",
"cookieName",
"+",
"'_org'",
")",
"if",
"(",
"organizationId",
")",
"{",
"user",
".",
"organization",
"=",
"(",
"user",
".",
"organizations",
"||",
"[",
"]",
")",
".",
"find",
"(",
"o",
"=>",
"o",
".",
"id",
"===",
"organizationId",
")",
"if",
"(",
"user",
".",
"organization",
")",
"{",
"user",
".",
"consumerFlag",
"=",
"user",
".",
"organization",
".",
"id",
"}",
"else",
"if",
"(",
"organizationId",
"===",
"''",
"||",
"organizationId",
".",
"toLowerCase",
"(",
")",
"===",
"'user'",
")",
"{",
"user",
".",
"consumerFlag",
"=",
"'user'",
"}",
"}",
"}"
] | Use complementary cookie id_token_org to set the current active organization of the user also set consumerFlag that is used by applications to decide if they should ask confirmation to the user of the right quotas or other organization related context to apply it is 'user' if id_token_org is an empty string or is equal to 'user' it is null if id_token_org is absent or if it does not match an organization of the current user it is the id of the orga in id_token_org | [
"Use",
"complementary",
"cookie",
"id_token_org",
"to",
"set",
"the",
"current",
"active",
"organization",
"of",
"the",
"user",
"also",
"set",
"consumerFlag",
"that",
"is",
"used",
"by",
"applications",
"to",
"decide",
"if",
"they",
"should",
"ask",
"confirmation",
"to",
"the",
"user",
"of",
"the",
"right",
"quotas",
"or",
"other",
"organization",
"related",
"context",
"to",
"apply",
"it",
"is",
"user",
"if",
"id_token_org",
"is",
"an",
"empty",
"string",
"or",
"is",
"equal",
"to",
"user",
"it",
"is",
"null",
"if",
"id_token_org",
"is",
"absent",
"or",
"if",
"it",
"does",
"not",
"match",
"an",
"organization",
"of",
"the",
"current",
"user",
"it",
"is",
"the",
"id",
"of",
"the",
"orga",
"in",
"id_token_org"
] | d7da1af5b9bcf893d9f9f82a67668f0d4b8099f9 | https://github.com/koumoul-dev/sd-express/blob/d7da1af5b9bcf893d9f9f82a67668f0d4b8099f9/index.js#L147-L160 |
50,451 | koumoul-dev/sd-express | index.js | _verifyToken | async function _verifyToken (jwksClient, token) {
const decoded = jwt.decode(token, { complete: true })
const signingKey = await jwksClient.getSigningKeyAsync(decoded.header.kid)
return jwt.verifyAsync(token, signingKey.publicKey || signingKey.rsaPublicKey)
} | javascript | async function _verifyToken (jwksClient, token) {
const decoded = jwt.decode(token, { complete: true })
const signingKey = await jwksClient.getSigningKeyAsync(decoded.header.kid)
return jwt.verifyAsync(token, signingKey.publicKey || signingKey.rsaPublicKey)
} | [
"async",
"function",
"_verifyToken",
"(",
"jwksClient",
",",
"token",
")",
"{",
"const",
"decoded",
"=",
"jwt",
".",
"decode",
"(",
"token",
",",
"{",
"complete",
":",
"true",
"}",
")",
"const",
"signingKey",
"=",
"await",
"jwksClient",
".",
"getSigningKeyAsync",
"(",
"decoded",
".",
"header",
".",
"kid",
")",
"return",
"jwt",
".",
"verifyAsync",
"(",
"token",
",",
"signingKey",
".",
"publicKey",
"||",
"signingKey",
".",
"rsaPublicKey",
")",
"}"
] | Fetch the public info of signing key from the directory that acts as jwks provider | [
"Fetch",
"the",
"public",
"info",
"of",
"signing",
"key",
"from",
"the",
"directory",
"that",
"acts",
"as",
"jwks",
"provider"
] | d7da1af5b9bcf893d9f9f82a67668f0d4b8099f9 | https://github.com/koumoul-dev/sd-express/blob/d7da1af5b9bcf893d9f9f82a67668f0d4b8099f9/index.js#L163-L167 |
50,452 | koumoul-dev/sd-express | index.js | _decode | function _decode (cookieName, cookieDomain, publicUrl) {
return (req, res, next) => {
// JWT in a cookie = already active session
const cookies = new Cookies(req, res)
const token = _getCookieToken(cookies, req, cookieName, cookieDomain, publicUrl)
if (token) {
req.user = jwt.decode(token)
_setOrganization(cookies, cookieName, req, req.user)
}
next()
}
} | javascript | function _decode (cookieName, cookieDomain, publicUrl) {
return (req, res, next) => {
// JWT in a cookie = already active session
const cookies = new Cookies(req, res)
const token = _getCookieToken(cookies, req, cookieName, cookieDomain, publicUrl)
if (token) {
req.user = jwt.decode(token)
_setOrganization(cookies, cookieName, req, req.user)
}
next()
}
} | [
"function",
"_decode",
"(",
"cookieName",
",",
"cookieDomain",
",",
"publicUrl",
")",
"{",
"return",
"(",
"req",
",",
"res",
",",
"next",
")",
"=>",
"{",
"// JWT in a cookie = already active session",
"const",
"cookies",
"=",
"new",
"Cookies",
"(",
"req",
",",
"res",
")",
"const",
"token",
"=",
"_getCookieToken",
"(",
"cookies",
",",
"req",
",",
"cookieName",
",",
"cookieDomain",
",",
"publicUrl",
")",
"if",
"(",
"token",
")",
"{",
"req",
".",
"user",
"=",
"jwt",
".",
"decode",
"(",
"token",
")",
"_setOrganization",
"(",
"cookies",
",",
"cookieName",
",",
"req",
",",
"req",
".",
"user",
")",
"}",
"next",
"(",
")",
"}",
"}"
] | This middleware checks if a user has an active session and defines req.user Contrary to auth it does not validate the token, only decode it.. so it faster but it is limited to routes where req.user is informative | [
"This",
"middleware",
"checks",
"if",
"a",
"user",
"has",
"an",
"active",
"session",
"and",
"defines",
"req",
".",
"user",
"Contrary",
"to",
"auth",
"it",
"does",
"not",
"validate",
"the",
"token",
"only",
"decode",
"it",
"..",
"so",
"it",
"faster",
"but",
"it",
"is",
"limited",
"to",
"routes",
"where",
"req",
".",
"user",
"is",
"informative"
] | d7da1af5b9bcf893d9f9f82a67668f0d4b8099f9 | https://github.com/koumoul-dev/sd-express/blob/d7da1af5b9bcf893d9f9f82a67668f0d4b8099f9/index.js#L208-L219 |
50,453 | koumoul-dev/sd-express | index.js | _auth | function _auth (privateDirectoryUrl, publicUrl, jwksClient, cookieName, cookieDomain, forceExchange) {
return asyncWrap(async (req, res, next) => {
// JWT in a cookie = already active session
const cookies = new Cookies(req, res)
const token = _getCookieToken(cookies, req, cookieName, cookieDomain, publicUrl)
if (token) {
try {
debug(`Verify JWT token from the ${cookieName} cookie`)
req.user = await _verifyToken(jwksClient, token)
_setOrganization(cookies, cookieName, req, req.user)
debug('JWT token from cookie is ok', req.user)
} catch (err) {
// Token expired or bad in another way.. delete the cookie
debug('JWT token from cookie is broken, clear it', err)
cookies.set(cookieName, null, { domain: cookieDomain })
cookies.set(cookieName + '_sign', null, { domain: cookieDomain })
// case where the cookies were set before assigning domain
if (cookies.get(cookieName)) {
cookies.set(cookieName, null)
cookies.set(cookieName + '_sign', null)
}
}
}
// We have a token from cookie
// Does it need to be exchanged to prolongate the session ?
if (req.user && req.user.exp) {
debug('JWT token from cookie is set to expire on', new Date(req.user.exp * 1000))
const timestamp = Date.now() / 1000
// Token is more than 12 hours old or has less than half an hour left
const tooOld = timestamp > (req.user.iat + 43200)
const shortLife = timestamp > (req.user.exp - 1800)
if (tooOld) debug('The token was issued more than 12 hours ago, exchange it for a new one')
if (shortLife) debug('The token will expire in less than half an hour, exchange it for a new one')
if (forceExchange) debug('The token was explicitly required to be exchanged (keepalive route), exchange it for a new one')
if (tooOld || shortLife || forceExchange) {
const exchangedToken = await _exchangeToken(privateDirectoryUrl, token)
req.user = await _verifyToken(jwksClient, exchangedToken)
_setOrganization(cookies, cookieName, req, req.user)
debug('Exchanged token is ok, store it', req.user)
_setCookieToken(cookies, cookieName, cookieDomain, exchangedToken, req.user)
}
}
next()
})
} | javascript | function _auth (privateDirectoryUrl, publicUrl, jwksClient, cookieName, cookieDomain, forceExchange) {
return asyncWrap(async (req, res, next) => {
// JWT in a cookie = already active session
const cookies = new Cookies(req, res)
const token = _getCookieToken(cookies, req, cookieName, cookieDomain, publicUrl)
if (token) {
try {
debug(`Verify JWT token from the ${cookieName} cookie`)
req.user = await _verifyToken(jwksClient, token)
_setOrganization(cookies, cookieName, req, req.user)
debug('JWT token from cookie is ok', req.user)
} catch (err) {
// Token expired or bad in another way.. delete the cookie
debug('JWT token from cookie is broken, clear it', err)
cookies.set(cookieName, null, { domain: cookieDomain })
cookies.set(cookieName + '_sign', null, { domain: cookieDomain })
// case where the cookies were set before assigning domain
if (cookies.get(cookieName)) {
cookies.set(cookieName, null)
cookies.set(cookieName + '_sign', null)
}
}
}
// We have a token from cookie
// Does it need to be exchanged to prolongate the session ?
if (req.user && req.user.exp) {
debug('JWT token from cookie is set to expire on', new Date(req.user.exp * 1000))
const timestamp = Date.now() / 1000
// Token is more than 12 hours old or has less than half an hour left
const tooOld = timestamp > (req.user.iat + 43200)
const shortLife = timestamp > (req.user.exp - 1800)
if (tooOld) debug('The token was issued more than 12 hours ago, exchange it for a new one')
if (shortLife) debug('The token will expire in less than half an hour, exchange it for a new one')
if (forceExchange) debug('The token was explicitly required to be exchanged (keepalive route), exchange it for a new one')
if (tooOld || shortLife || forceExchange) {
const exchangedToken = await _exchangeToken(privateDirectoryUrl, token)
req.user = await _verifyToken(jwksClient, exchangedToken)
_setOrganization(cookies, cookieName, req, req.user)
debug('Exchanged token is ok, store it', req.user)
_setCookieToken(cookies, cookieName, cookieDomain, exchangedToken, req.user)
}
}
next()
})
} | [
"function",
"_auth",
"(",
"privateDirectoryUrl",
",",
"publicUrl",
",",
"jwksClient",
",",
"cookieName",
",",
"cookieDomain",
",",
"forceExchange",
")",
"{",
"return",
"asyncWrap",
"(",
"async",
"(",
"req",
",",
"res",
",",
"next",
")",
"=>",
"{",
"// JWT in a cookie = already active session",
"const",
"cookies",
"=",
"new",
"Cookies",
"(",
"req",
",",
"res",
")",
"const",
"token",
"=",
"_getCookieToken",
"(",
"cookies",
",",
"req",
",",
"cookieName",
",",
"cookieDomain",
",",
"publicUrl",
")",
"if",
"(",
"token",
")",
"{",
"try",
"{",
"debug",
"(",
"`",
"${",
"cookieName",
"}",
"`",
")",
"req",
".",
"user",
"=",
"await",
"_verifyToken",
"(",
"jwksClient",
",",
"token",
")",
"_setOrganization",
"(",
"cookies",
",",
"cookieName",
",",
"req",
",",
"req",
".",
"user",
")",
"debug",
"(",
"'JWT token from cookie is ok'",
",",
"req",
".",
"user",
")",
"}",
"catch",
"(",
"err",
")",
"{",
"// Token expired or bad in another way.. delete the cookie",
"debug",
"(",
"'JWT token from cookie is broken, clear it'",
",",
"err",
")",
"cookies",
".",
"set",
"(",
"cookieName",
",",
"null",
",",
"{",
"domain",
":",
"cookieDomain",
"}",
")",
"cookies",
".",
"set",
"(",
"cookieName",
"+",
"'_sign'",
",",
"null",
",",
"{",
"domain",
":",
"cookieDomain",
"}",
")",
"// case where the cookies were set before assigning domain",
"if",
"(",
"cookies",
".",
"get",
"(",
"cookieName",
")",
")",
"{",
"cookies",
".",
"set",
"(",
"cookieName",
",",
"null",
")",
"cookies",
".",
"set",
"(",
"cookieName",
"+",
"'_sign'",
",",
"null",
")",
"}",
"}",
"}",
"// We have a token from cookie",
"// Does it need to be exchanged to prolongate the session ?",
"if",
"(",
"req",
".",
"user",
"&&",
"req",
".",
"user",
".",
"exp",
")",
"{",
"debug",
"(",
"'JWT token from cookie is set to expire on'",
",",
"new",
"Date",
"(",
"req",
".",
"user",
".",
"exp",
"*",
"1000",
")",
")",
"const",
"timestamp",
"=",
"Date",
".",
"now",
"(",
")",
"/",
"1000",
"// Token is more than 12 hours old or has less than half an hour left",
"const",
"tooOld",
"=",
"timestamp",
">",
"(",
"req",
".",
"user",
".",
"iat",
"+",
"43200",
")",
"const",
"shortLife",
"=",
"timestamp",
">",
"(",
"req",
".",
"user",
".",
"exp",
"-",
"1800",
")",
"if",
"(",
"tooOld",
")",
"debug",
"(",
"'The token was issued more than 12 hours ago, exchange it for a new one'",
")",
"if",
"(",
"shortLife",
")",
"debug",
"(",
"'The token will expire in less than half an hour, exchange it for a new one'",
")",
"if",
"(",
"forceExchange",
")",
"debug",
"(",
"'The token was explicitly required to be exchanged (keepalive route), exchange it for a new one'",
")",
"if",
"(",
"tooOld",
"||",
"shortLife",
"||",
"forceExchange",
")",
"{",
"const",
"exchangedToken",
"=",
"await",
"_exchangeToken",
"(",
"privateDirectoryUrl",
",",
"token",
")",
"req",
".",
"user",
"=",
"await",
"_verifyToken",
"(",
"jwksClient",
",",
"exchangedToken",
")",
"_setOrganization",
"(",
"cookies",
",",
"cookieName",
",",
"req",
",",
"req",
".",
"user",
")",
"debug",
"(",
"'Exchanged token is ok, store it'",
",",
"req",
".",
"user",
")",
"_setCookieToken",
"(",
"cookies",
",",
"cookieName",
",",
"cookieDomain",
",",
"exchangedToken",
",",
"req",
".",
"user",
")",
"}",
"}",
"next",
"(",
")",
"}",
")",
"}"
] | This middleware checks if a user has an active session with a valid token it defines req.user and it can extend the session if necessary. | [
"This",
"middleware",
"checks",
"if",
"a",
"user",
"has",
"an",
"active",
"session",
"with",
"a",
"valid",
"token",
"it",
"defines",
"req",
".",
"user",
"and",
"it",
"can",
"extend",
"the",
"session",
"if",
"necessary",
"."
] | d7da1af5b9bcf893d9f9f82a67668f0d4b8099f9 | https://github.com/koumoul-dev/sd-express/blob/d7da1af5b9bcf893d9f9f82a67668f0d4b8099f9/index.js#L223-L268 |
50,454 | koumoul-dev/sd-express | index.js | _login | function _login (directoryUrl, publicUrl) {
return (req, res) => {
res.redirect(directoryUrl + '/login?redirect=' + encodeURIComponent(req.query.redirect || publicUrl))
}
} | javascript | function _login (directoryUrl, publicUrl) {
return (req, res) => {
res.redirect(directoryUrl + '/login?redirect=' + encodeURIComponent(req.query.redirect || publicUrl))
}
} | [
"function",
"_login",
"(",
"directoryUrl",
",",
"publicUrl",
")",
"{",
"return",
"(",
"req",
",",
"res",
")",
"=>",
"{",
"res",
".",
"redirect",
"(",
"directoryUrl",
"+",
"'/login?redirect='",
"+",
"encodeURIComponent",
"(",
"req",
".",
"query",
".",
"redirect",
"||",
"publicUrl",
")",
")",
"}",
"}"
] | Login is simply a link to the right page of the directory. Going to the directory through a redirect, not throug a link in UI allows us to send along some optional client id or any kind of trust enhancing secret | [
"Login",
"is",
"simply",
"a",
"link",
"to",
"the",
"right",
"page",
"of",
"the",
"directory",
".",
"Going",
"to",
"the",
"directory",
"through",
"a",
"redirect",
"not",
"throug",
"a",
"link",
"in",
"UI",
"allows",
"us",
"to",
"send",
"along",
"some",
"optional",
"client",
"id",
"or",
"any",
"kind",
"of",
"trust",
"enhancing",
"secret"
] | d7da1af5b9bcf893d9f9f82a67668f0d4b8099f9 | https://github.com/koumoul-dev/sd-express/blob/d7da1af5b9bcf893d9f9f82a67668f0d4b8099f9/index.js#L273-L277 |
50,455 | koumoul-dev/sd-express | index.js | _logout | function _logout (cookieName, cookieDomain) {
return (req, res) => {
const cookies = new Cookies(req, res)
cookies.set(cookieName, null, { domain: cookieDomain })
cookies.set(cookieName + '_sign', null, { domain: cookieDomain })
// case where the cookies were set before assigning domain
if (cookies.get(cookieName)) {
cookies.set(cookieName, null)
cookies.set(cookieName + '_sign', null)
}
res.status(204).send()
}
} | javascript | function _logout (cookieName, cookieDomain) {
return (req, res) => {
const cookies = new Cookies(req, res)
cookies.set(cookieName, null, { domain: cookieDomain })
cookies.set(cookieName + '_sign', null, { domain: cookieDomain })
// case where the cookies were set before assigning domain
if (cookies.get(cookieName)) {
cookies.set(cookieName, null)
cookies.set(cookieName + '_sign', null)
}
res.status(204).send()
}
} | [
"function",
"_logout",
"(",
"cookieName",
",",
"cookieDomain",
")",
"{",
"return",
"(",
"req",
",",
"res",
")",
"=>",
"{",
"const",
"cookies",
"=",
"new",
"Cookies",
"(",
"req",
",",
"res",
")",
"cookies",
".",
"set",
"(",
"cookieName",
",",
"null",
",",
"{",
"domain",
":",
"cookieDomain",
"}",
")",
"cookies",
".",
"set",
"(",
"cookieName",
"+",
"'_sign'",
",",
"null",
",",
"{",
"domain",
":",
"cookieDomain",
"}",
")",
"// case where the cookies were set before assigning domain",
"if",
"(",
"cookies",
".",
"get",
"(",
"cookieName",
")",
")",
"{",
"cookies",
".",
"set",
"(",
"cookieName",
",",
"null",
")",
"cookies",
".",
"set",
"(",
"cookieName",
"+",
"'_sign'",
",",
"null",
")",
"}",
"res",
".",
"status",
"(",
"204",
")",
".",
"send",
"(",
")",
"}",
"}"
] | Sessions are only the persistence of the JWT token in cookies no need to call the directory | [
"Sessions",
"are",
"only",
"the",
"persistence",
"of",
"the",
"JWT",
"token",
"in",
"cookies",
"no",
"need",
"to",
"call",
"the",
"directory"
] | d7da1af5b9bcf893d9f9f82a67668f0d4b8099f9 | https://github.com/koumoul-dev/sd-express/blob/d7da1af5b9bcf893d9f9f82a67668f0d4b8099f9/index.js#L281-L293 |
50,456 | francium/highlight-page | src/highlight-page.js | refineRangeBoundaries | function refineRangeBoundaries(range) {
let startContainer = range.startContainer,
endContainer = range.endContainer,
ancestor = range.commonAncestorContainer,
goDeeper = true;
if (range.endOffset === 0) {
while (!endContainer.previousSibling && endContainer.parentNode !== ancestor) {
endContainer = endContainer.parentNode;
}
endContainer = endContainer.previousSibling;
} else if (endContainer.nodeType === NODE_TYPE.TEXT_NODE) {
if (range.endOffset < endContainer.nodeValue.length) {
endContainer.splitText(range.endOffset);
}
} else if (range.endOffset > 0) {
endContainer = endContainer.childNodes.item(range.endOffset - 1);
}
if (startContainer.nodeType === NODE_TYPE.TEXT_NODE) {
if (range.startOffset === startContainer.nodeValue.length) {
goDeeper = false;
} else if (range.startOffset > 0) {
startContainer = startContainer.splitText(range.startOffset);
if (endContainer === startContainer.previousSibling) {
endContainer = startContainer;
}
}
} else if (range.startOffset < startContainer.childNodes.length) {
startContainer = startContainer.childNodes.item(range.startOffset);
} else {
startContainer = startContainer.nextSibling;
}
return {
startContainer: startContainer,
endContainer: endContainer,
goDeeper: goDeeper
};
} | javascript | function refineRangeBoundaries(range) {
let startContainer = range.startContainer,
endContainer = range.endContainer,
ancestor = range.commonAncestorContainer,
goDeeper = true;
if (range.endOffset === 0) {
while (!endContainer.previousSibling && endContainer.parentNode !== ancestor) {
endContainer = endContainer.parentNode;
}
endContainer = endContainer.previousSibling;
} else if (endContainer.nodeType === NODE_TYPE.TEXT_NODE) {
if (range.endOffset < endContainer.nodeValue.length) {
endContainer.splitText(range.endOffset);
}
} else if (range.endOffset > 0) {
endContainer = endContainer.childNodes.item(range.endOffset - 1);
}
if (startContainer.nodeType === NODE_TYPE.TEXT_NODE) {
if (range.startOffset === startContainer.nodeValue.length) {
goDeeper = false;
} else if (range.startOffset > 0) {
startContainer = startContainer.splitText(range.startOffset);
if (endContainer === startContainer.previousSibling) {
endContainer = startContainer;
}
}
} else if (range.startOffset < startContainer.childNodes.length) {
startContainer = startContainer.childNodes.item(range.startOffset);
} else {
startContainer = startContainer.nextSibling;
}
return {
startContainer: startContainer,
endContainer: endContainer,
goDeeper: goDeeper
};
} | [
"function",
"refineRangeBoundaries",
"(",
"range",
")",
"{",
"let",
"startContainer",
"=",
"range",
".",
"startContainer",
",",
"endContainer",
"=",
"range",
".",
"endContainer",
",",
"ancestor",
"=",
"range",
".",
"commonAncestorContainer",
",",
"goDeeper",
"=",
"true",
";",
"if",
"(",
"range",
".",
"endOffset",
"===",
"0",
")",
"{",
"while",
"(",
"!",
"endContainer",
".",
"previousSibling",
"&&",
"endContainer",
".",
"parentNode",
"!==",
"ancestor",
")",
"{",
"endContainer",
"=",
"endContainer",
".",
"parentNode",
";",
"}",
"endContainer",
"=",
"endContainer",
".",
"previousSibling",
";",
"}",
"else",
"if",
"(",
"endContainer",
".",
"nodeType",
"===",
"NODE_TYPE",
".",
"TEXT_NODE",
")",
"{",
"if",
"(",
"range",
".",
"endOffset",
"<",
"endContainer",
".",
"nodeValue",
".",
"length",
")",
"{",
"endContainer",
".",
"splitText",
"(",
"range",
".",
"endOffset",
")",
";",
"}",
"}",
"else",
"if",
"(",
"range",
".",
"endOffset",
">",
"0",
")",
"{",
"endContainer",
"=",
"endContainer",
".",
"childNodes",
".",
"item",
"(",
"range",
".",
"endOffset",
"-",
"1",
")",
";",
"}",
"if",
"(",
"startContainer",
".",
"nodeType",
"===",
"NODE_TYPE",
".",
"TEXT_NODE",
")",
"{",
"if",
"(",
"range",
".",
"startOffset",
"===",
"startContainer",
".",
"nodeValue",
".",
"length",
")",
"{",
"goDeeper",
"=",
"false",
";",
"}",
"else",
"if",
"(",
"range",
".",
"startOffset",
">",
"0",
")",
"{",
"startContainer",
"=",
"startContainer",
".",
"splitText",
"(",
"range",
".",
"startOffset",
")",
";",
"if",
"(",
"endContainer",
"===",
"startContainer",
".",
"previousSibling",
")",
"{",
"endContainer",
"=",
"startContainer",
";",
"}",
"}",
"}",
"else",
"if",
"(",
"range",
".",
"startOffset",
"<",
"startContainer",
".",
"childNodes",
".",
"length",
")",
"{",
"startContainer",
"=",
"startContainer",
".",
"childNodes",
".",
"item",
"(",
"range",
".",
"startOffset",
")",
";",
"}",
"else",
"{",
"startContainer",
"=",
"startContainer",
".",
"nextSibling",
";",
"}",
"return",
"{",
"startContainer",
":",
"startContainer",
",",
"endContainer",
":",
"endContainer",
",",
"goDeeper",
":",
"goDeeper",
"}",
";",
"}"
] | Takes range object as parameter and refines it boundaries
@param range
@returns {object} refined boundaries and initial state of highlighting algorithm. | [
"Takes",
"range",
"object",
"as",
"parameter",
"and",
"refines",
"it",
"boundaries"
] | 4e67fc531321f9987397dc247abba59b9d5ee521 | https://github.com/francium/highlight-page/blob/4e67fc531321f9987397dc247abba59b9d5ee521/src/highlight-page.js#L72-L111 |
50,457 | francium/highlight-page | src/highlight-page.js | groupHighlights | function groupHighlights(highlights) {
let order = [],
chunks = {},
grouped = [];
highlights.forEach(function (hl) {
let timestamp = hl.getAttribute(TIMESTAMP_ATTR);
if (typeof chunks[timestamp] === 'undefined') {
chunks[timestamp] = [];
order.push(timestamp);
}
chunks[timestamp].push(hl);
});
order.forEach(function (timestamp) {
let group = chunks[timestamp];
grouped.push({
chunks: group,
timestamp: timestamp,
toString: function () {
return group.map(function (h) {
return h.textContent;
}).join('');
}
});
});
return grouped;
} | javascript | function groupHighlights(highlights) {
let order = [],
chunks = {},
grouped = [];
highlights.forEach(function (hl) {
let timestamp = hl.getAttribute(TIMESTAMP_ATTR);
if (typeof chunks[timestamp] === 'undefined') {
chunks[timestamp] = [];
order.push(timestamp);
}
chunks[timestamp].push(hl);
});
order.forEach(function (timestamp) {
let group = chunks[timestamp];
grouped.push({
chunks: group,
timestamp: timestamp,
toString: function () {
return group.map(function (h) {
return h.textContent;
}).join('');
}
});
});
return grouped;
} | [
"function",
"groupHighlights",
"(",
"highlights",
")",
"{",
"let",
"order",
"=",
"[",
"]",
",",
"chunks",
"=",
"{",
"}",
",",
"grouped",
"=",
"[",
"]",
";",
"highlights",
".",
"forEach",
"(",
"function",
"(",
"hl",
")",
"{",
"let",
"timestamp",
"=",
"hl",
".",
"getAttribute",
"(",
"TIMESTAMP_ATTR",
")",
";",
"if",
"(",
"typeof",
"chunks",
"[",
"timestamp",
"]",
"===",
"'undefined'",
")",
"{",
"chunks",
"[",
"timestamp",
"]",
"=",
"[",
"]",
";",
"order",
".",
"push",
"(",
"timestamp",
")",
";",
"}",
"chunks",
"[",
"timestamp",
"]",
".",
"push",
"(",
"hl",
")",
";",
"}",
")",
";",
"order",
".",
"forEach",
"(",
"function",
"(",
"timestamp",
")",
"{",
"let",
"group",
"=",
"chunks",
"[",
"timestamp",
"]",
";",
"grouped",
".",
"push",
"(",
"{",
"chunks",
":",
"group",
",",
"timestamp",
":",
"timestamp",
",",
"toString",
":",
"function",
"(",
")",
"{",
"return",
"group",
".",
"map",
"(",
"function",
"(",
"h",
")",
"{",
"return",
"h",
".",
"textContent",
";",
"}",
")",
".",
"join",
"(",
"''",
")",
";",
"}",
"}",
")",
";",
"}",
")",
";",
"return",
"grouped",
";",
"}"
] | Groups given highlights by timestamp.
@param {Array} highlights
@returns {Array} Grouped highlights. | [
"Groups",
"given",
"highlights",
"by",
"timestamp",
"."
] | 4e67fc531321f9987397dc247abba59b9d5ee521 | https://github.com/francium/highlight-page/blob/4e67fc531321f9987397dc247abba59b9d5ee521/src/highlight-page.js#L129-L160 |
50,458 | francium/highlight-page | src/highlight-page.js | function (nodesToAppend) {
let nodes = Array.prototype.slice.call(nodesToAppend);
for (let i = 0, len = nodes.length; i < len; ++i) {
el.appendChild(nodes[i]);
}
} | javascript | function (nodesToAppend) {
let nodes = Array.prototype.slice.call(nodesToAppend);
for (let i = 0, len = nodes.length; i < len; ++i) {
el.appendChild(nodes[i]);
}
} | [
"function",
"(",
"nodesToAppend",
")",
"{",
"let",
"nodes",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"nodesToAppend",
")",
";",
"for",
"(",
"let",
"i",
"=",
"0",
",",
"len",
"=",
"nodes",
".",
"length",
";",
"i",
"<",
"len",
";",
"++",
"i",
")",
"{",
"el",
".",
"appendChild",
"(",
"nodes",
"[",
"i",
"]",
")",
";",
"}",
"}"
] | Appends child nodes to base element.
@param {Node[]} nodesToAppend | [
"Appends",
"child",
"nodes",
"to",
"base",
"element",
"."
] | 4e67fc531321f9987397dc247abba59b9d5ee521 | https://github.com/francium/highlight-page/blob/4e67fc531321f9987397dc247abba59b9d5ee521/src/highlight-page.js#L214-L220 |
|
50,459 | francium/highlight-page | src/highlight-page.js | function () {
if (!el) {
return;
}
if (el.nodeType === NODE_TYPE.TEXT_NODE) {
while (el.nextSibling && el.nextSibling.nodeType === NODE_TYPE.TEXT_NODE) {
el.nodeValue += el.nextSibling.nodeValue;
el.parentNode.removeChild(el.nextSibling);
}
} else {
dom(el.firstChild).normalizeTextNodes();
}
dom(el.nextSibling).normalizeTextNodes();
} | javascript | function () {
if (!el) {
return;
}
if (el.nodeType === NODE_TYPE.TEXT_NODE) {
while (el.nextSibling && el.nextSibling.nodeType === NODE_TYPE.TEXT_NODE) {
el.nodeValue += el.nextSibling.nodeValue;
el.parentNode.removeChild(el.nextSibling);
}
} else {
dom(el.firstChild).normalizeTextNodes();
}
dom(el.nextSibling).normalizeTextNodes();
} | [
"function",
"(",
")",
"{",
"if",
"(",
"!",
"el",
")",
"{",
"return",
";",
"}",
"if",
"(",
"el",
".",
"nodeType",
"===",
"NODE_TYPE",
".",
"TEXT_NODE",
")",
"{",
"while",
"(",
"el",
".",
"nextSibling",
"&&",
"el",
".",
"nextSibling",
".",
"nodeType",
"===",
"NODE_TYPE",
".",
"TEXT_NODE",
")",
"{",
"el",
".",
"nodeValue",
"+=",
"el",
".",
"nextSibling",
".",
"nodeValue",
";",
"el",
".",
"parentNode",
".",
"removeChild",
"(",
"el",
".",
"nextSibling",
")",
";",
"}",
"}",
"else",
"{",
"dom",
"(",
"el",
".",
"firstChild",
")",
".",
"normalizeTextNodes",
"(",
")",
";",
"}",
"dom",
"(",
"el",
".",
"nextSibling",
")",
".",
"normalizeTextNodes",
"(",
")",
";",
"}"
] | Normalizes text nodes within base element, ie. merges sibling text nodes and assures that every
element node has only one text node.
It should does the same as standard element.normalize, but IE implements it incorrectly. | [
"Normalizes",
"text",
"nodes",
"within",
"base",
"element",
"ie",
".",
"merges",
"sibling",
"text",
"nodes",
"and",
"assures",
"that",
"every",
"element",
"node",
"has",
"only",
"one",
"text",
"node",
".",
"It",
"should",
"does",
"the",
"same",
"as",
"standard",
"element",
".",
"normalize",
"but",
"IE",
"implements",
"it",
"incorrectly",
"."
] | 4e67fc531321f9987397dc247abba59b9d5ee521 | https://github.com/francium/highlight-page/blob/4e67fc531321f9987397dc247abba59b9d5ee521/src/highlight-page.js#L308-L322 |
|
50,460 | francium/highlight-page | src/highlight-page.js | function () {
let selection = dom(el).getSelection(),
range;
if (selection.rangeCount > 0) {
range = selection.getRangeAt(0);
}
return range;
} | javascript | function () {
let selection = dom(el).getSelection(),
range;
if (selection.rangeCount > 0) {
range = selection.getRangeAt(0);
}
return range;
} | [
"function",
"(",
")",
"{",
"let",
"selection",
"=",
"dom",
"(",
"el",
")",
".",
"getSelection",
"(",
")",
",",
"range",
";",
"if",
"(",
"selection",
".",
"rangeCount",
">",
"0",
")",
"{",
"range",
"=",
"selection",
".",
"getRangeAt",
"(",
"0",
")",
";",
"}",
"return",
"range",
";",
"}"
] | Returns first range of the window of base element.
@returns {Range} | [
"Returns",
"first",
"range",
"of",
"the",
"window",
"of",
"base",
"element",
"."
] | 4e67fc531321f9987397dc247abba59b9d5ee521 | https://github.com/francium/highlight-page/blob/4e67fc531321f9987397dc247abba59b9d5ee521/src/highlight-page.js#L347-L356 |
|
50,461 | insacjs/field-creator | lib/class/Field.js | _isTHIS | function _isTHIS (obj) {
if (obj && obj._this && (obj._this === true)) {
return true
}
return false
} | javascript | function _isTHIS (obj) {
if (obj && obj._this && (obj._this === true)) {
return true
}
return false
} | [
"function",
"_isTHIS",
"(",
"obj",
")",
"{",
"if",
"(",
"obj",
"&&",
"obj",
".",
"_this",
"&&",
"(",
"obj",
".",
"_this",
"===",
"true",
")",
")",
"{",
"return",
"true",
"}",
"return",
"false",
"}"
] | Indica si un objeto es una referencia THIS.
@param {Object} obj - Objeto.
@return {Boolean} | [
"Indica",
"si",
"un",
"objeto",
"es",
"una",
"referencia",
"THIS",
"."
] | bbba706852966b61658288d9b42659fdc42f342b | https://github.com/insacjs/field-creator/blob/bbba706852966b61658288d9b42659fdc42f342b/lib/class/Field.js#L245-L250 |
50,462 | insacjs/field-creator | lib/class/Field.js | _isField | function _isField (obj) {
if (obj && obj._modelAttribute && (obj._modelAttribute === true)) {
return true
}
return false
} | javascript | function _isField (obj) {
if (obj && obj._modelAttribute && (obj._modelAttribute === true)) {
return true
}
return false
} | [
"function",
"_isField",
"(",
"obj",
")",
"{",
"if",
"(",
"obj",
"&&",
"obj",
".",
"_modelAttribute",
"&&",
"(",
"obj",
".",
"_modelAttribute",
"===",
"true",
")",
")",
"{",
"return",
"true",
"}",
"return",
"false",
"}"
] | Indica si un objeto es atributo de un modelo.
@param {Object} obj - Objeto.
@return {Boolean} | [
"Indica",
"si",
"un",
"objeto",
"es",
"atributo",
"de",
"un",
"modelo",
"."
] | bbba706852966b61658288d9b42659fdc42f342b | https://github.com/insacjs/field-creator/blob/bbba706852966b61658288d9b42659fdc42f342b/lib/class/Field.js#L257-L262 |
50,463 | insacjs/field-creator | lib/class/Field.js | _updateTHIS | function _updateTHIS (model, obj) {
const RESULT = {}
if (Array.isArray(obj)) {
return [_updateTHIS(model, obj[0])]
}
Object.keys(obj).forEach(prop => {
const OBJ = obj[prop]
if (_isTHIS(OBJ)) {
delete OBJ._this
RESULT[prop] = Object.assign(_.cloneDeep(model.attributes[prop]), OBJ)
return
}
if (_isField(OBJ)) {
OBJ.fieldName = OBJ.fieldName || prop
OBJ.field = OBJ.field || prop
RESULT[prop] = OBJ
return
}
if (typeof OBJ === 'object') {
const SUB_MODEL = (model && model.associations[prop]) ? model.associations[prop].target : undefined
RESULT[prop] = _updateTHIS(SUB_MODEL, OBJ)
}
})
return RESULT
} | javascript | function _updateTHIS (model, obj) {
const RESULT = {}
if (Array.isArray(obj)) {
return [_updateTHIS(model, obj[0])]
}
Object.keys(obj).forEach(prop => {
const OBJ = obj[prop]
if (_isTHIS(OBJ)) {
delete OBJ._this
RESULT[prop] = Object.assign(_.cloneDeep(model.attributes[prop]), OBJ)
return
}
if (_isField(OBJ)) {
OBJ.fieldName = OBJ.fieldName || prop
OBJ.field = OBJ.field || prop
RESULT[prop] = OBJ
return
}
if (typeof OBJ === 'object') {
const SUB_MODEL = (model && model.associations[prop]) ? model.associations[prop].target : undefined
RESULT[prop] = _updateTHIS(SUB_MODEL, OBJ)
}
})
return RESULT
} | [
"function",
"_updateTHIS",
"(",
"model",
",",
"obj",
")",
"{",
"const",
"RESULT",
"=",
"{",
"}",
"if",
"(",
"Array",
".",
"isArray",
"(",
"obj",
")",
")",
"{",
"return",
"[",
"_updateTHIS",
"(",
"model",
",",
"obj",
"[",
"0",
"]",
")",
"]",
"}",
"Object",
".",
"keys",
"(",
"obj",
")",
".",
"forEach",
"(",
"prop",
"=>",
"{",
"const",
"OBJ",
"=",
"obj",
"[",
"prop",
"]",
"if",
"(",
"_isTHIS",
"(",
"OBJ",
")",
")",
"{",
"delete",
"OBJ",
".",
"_this",
"RESULT",
"[",
"prop",
"]",
"=",
"Object",
".",
"assign",
"(",
"_",
".",
"cloneDeep",
"(",
"model",
".",
"attributes",
"[",
"prop",
"]",
")",
",",
"OBJ",
")",
"return",
"}",
"if",
"(",
"_isField",
"(",
"OBJ",
")",
")",
"{",
"OBJ",
".",
"fieldName",
"=",
"OBJ",
".",
"fieldName",
"||",
"prop",
"OBJ",
".",
"field",
"=",
"OBJ",
".",
"field",
"||",
"prop",
"RESULT",
"[",
"prop",
"]",
"=",
"OBJ",
"return",
"}",
"if",
"(",
"typeof",
"OBJ",
"===",
"'object'",
")",
"{",
"const",
"SUB_MODEL",
"=",
"(",
"model",
"&&",
"model",
".",
"associations",
"[",
"prop",
"]",
")",
"?",
"model",
".",
"associations",
"[",
"prop",
"]",
".",
"target",
":",
"undefined",
"RESULT",
"[",
"prop",
"]",
"=",
"_updateTHIS",
"(",
"SUB_MODEL",
",",
"OBJ",
")",
"}",
"}",
")",
"return",
"RESULT",
"}"
] | Devuelve un objeto cuyos campos han sido definidos como THIS, con el valor que le corresponde.
Si el atributo no tiene un fieldName, se le asigna uno.
@param {SequelizeModel} model - Modelo Sequelize
@param {Object} obj - Objeto (grupo de fields).
@return {Object} | [
"Devuelve",
"un",
"objeto",
"cuyos",
"campos",
"han",
"sido",
"definidos",
"como",
"THIS",
"con",
"el",
"valor",
"que",
"le",
"corresponde",
".",
"Si",
"el",
"atributo",
"no",
"tiene",
"un",
"fieldName",
"se",
"le",
"asigna",
"uno",
"."
] | bbba706852966b61658288d9b42659fdc42f342b | https://github.com/insacjs/field-creator/blob/bbba706852966b61658288d9b42659fdc42f342b/lib/class/Field.js#L271-L295 |
50,464 | insacjs/field-creator | lib/class/Field.js | _createValidate | function _createValidate (type, defaultValidate = {}, customValidate) {
if (customValidate === null) { return null }
let val = {}
if (type.key === 'STRING') { val = { len: [0, type.options.length] } }
if (type.key === 'TEXT') { val = { len: [0, 2147483647] } }
if (type.key === 'INTEGER') { val = { isInt: true, min: -2147483647, max: 2147483647 } }
if (type.key === 'FLOAT') { val = { isFloat: true, min: -1E+308, max: 1E+308 } }
if (type.key === 'ENUM') { val = { isIn: [type.values] } }
if (type.key === 'BOOLEAN') { val = { isBoolean: true } }
if (type.key === 'DATE') { val = { isDate: true } }
if (type.key === 'DATEONLY') { val = { isDate: true } }
if (type.key === 'TIME') { val = { isTime: _isTimeValidate() } }
if (type.key === 'JSON') { val = { isJson: _isJsonValidate() } }
if (type.key === 'JSONB') { val = { isJson: _isJsonValidate() } }
if (type.key === 'UUID') { val = { isUUID: 4 } }
if (type.key === 'ARRAY') { val = { isArray: _isArrayValidate(type.type) } }
const FIELD = { validate: Object.assign(Object.assign(val, defaultValidate), customValidate) }
_normalizeValidate(FIELD)
return FIELD.validate
} | javascript | function _createValidate (type, defaultValidate = {}, customValidate) {
if (customValidate === null) { return null }
let val = {}
if (type.key === 'STRING') { val = { len: [0, type.options.length] } }
if (type.key === 'TEXT') { val = { len: [0, 2147483647] } }
if (type.key === 'INTEGER') { val = { isInt: true, min: -2147483647, max: 2147483647 } }
if (type.key === 'FLOAT') { val = { isFloat: true, min: -1E+308, max: 1E+308 } }
if (type.key === 'ENUM') { val = { isIn: [type.values] } }
if (type.key === 'BOOLEAN') { val = { isBoolean: true } }
if (type.key === 'DATE') { val = { isDate: true } }
if (type.key === 'DATEONLY') { val = { isDate: true } }
if (type.key === 'TIME') { val = { isTime: _isTimeValidate() } }
if (type.key === 'JSON') { val = { isJson: _isJsonValidate() } }
if (type.key === 'JSONB') { val = { isJson: _isJsonValidate() } }
if (type.key === 'UUID') { val = { isUUID: 4 } }
if (type.key === 'ARRAY') { val = { isArray: _isArrayValidate(type.type) } }
const FIELD = { validate: Object.assign(Object.assign(val, defaultValidate), customValidate) }
_normalizeValidate(FIELD)
return FIELD.validate
} | [
"function",
"_createValidate",
"(",
"type",
",",
"defaultValidate",
"=",
"{",
"}",
",",
"customValidate",
")",
"{",
"if",
"(",
"customValidate",
"===",
"null",
")",
"{",
"return",
"null",
"}",
"let",
"val",
"=",
"{",
"}",
"if",
"(",
"type",
".",
"key",
"===",
"'STRING'",
")",
"{",
"val",
"=",
"{",
"len",
":",
"[",
"0",
",",
"type",
".",
"options",
".",
"length",
"]",
"}",
"}",
"if",
"(",
"type",
".",
"key",
"===",
"'TEXT'",
")",
"{",
"val",
"=",
"{",
"len",
":",
"[",
"0",
",",
"2147483647",
"]",
"}",
"}",
"if",
"(",
"type",
".",
"key",
"===",
"'INTEGER'",
")",
"{",
"val",
"=",
"{",
"isInt",
":",
"true",
",",
"min",
":",
"-",
"2147483647",
",",
"max",
":",
"2147483647",
"}",
"}",
"if",
"(",
"type",
".",
"key",
"===",
"'FLOAT'",
")",
"{",
"val",
"=",
"{",
"isFloat",
":",
"true",
",",
"min",
":",
"-",
"1E+308",
",",
"max",
":",
"1E+308",
"}",
"}",
"if",
"(",
"type",
".",
"key",
"===",
"'ENUM'",
")",
"{",
"val",
"=",
"{",
"isIn",
":",
"[",
"type",
".",
"values",
"]",
"}",
"}",
"if",
"(",
"type",
".",
"key",
"===",
"'BOOLEAN'",
")",
"{",
"val",
"=",
"{",
"isBoolean",
":",
"true",
"}",
"}",
"if",
"(",
"type",
".",
"key",
"===",
"'DATE'",
")",
"{",
"val",
"=",
"{",
"isDate",
":",
"true",
"}",
"}",
"if",
"(",
"type",
".",
"key",
"===",
"'DATEONLY'",
")",
"{",
"val",
"=",
"{",
"isDate",
":",
"true",
"}",
"}",
"if",
"(",
"type",
".",
"key",
"===",
"'TIME'",
")",
"{",
"val",
"=",
"{",
"isTime",
":",
"_isTimeValidate",
"(",
")",
"}",
"}",
"if",
"(",
"type",
".",
"key",
"===",
"'JSON'",
")",
"{",
"val",
"=",
"{",
"isJson",
":",
"_isJsonValidate",
"(",
")",
"}",
"}",
"if",
"(",
"type",
".",
"key",
"===",
"'JSONB'",
")",
"{",
"val",
"=",
"{",
"isJson",
":",
"_isJsonValidate",
"(",
")",
"}",
"}",
"if",
"(",
"type",
".",
"key",
"===",
"'UUID'",
")",
"{",
"val",
"=",
"{",
"isUUID",
":",
"4",
"}",
"}",
"if",
"(",
"type",
".",
"key",
"===",
"'ARRAY'",
")",
"{",
"val",
"=",
"{",
"isArray",
":",
"_isArrayValidate",
"(",
"type",
".",
"type",
")",
"}",
"}",
"const",
"FIELD",
"=",
"{",
"validate",
":",
"Object",
".",
"assign",
"(",
"Object",
".",
"assign",
"(",
"val",
",",
"defaultValidate",
")",
",",
"customValidate",
")",
"}",
"_normalizeValidate",
"(",
"FIELD",
")",
"return",
"FIELD",
".",
"validate",
"}"
] | Devuelve un objeto validate.
@param {!SequelizeType} type - Propiedad tipo del atributo de un modelo sequelize.
@param {Object} [defaultValidate] - Propiedad validate por defecto.
@param {Object} [customValidate] - Propiedad validate personalizado.
@return {Object} | [
"Devuelve",
"un",
"objeto",
"validate",
"."
] | bbba706852966b61658288d9b42659fdc42f342b | https://github.com/insacjs/field-creator/blob/bbba706852966b61658288d9b42659fdc42f342b/lib/class/Field.js#L304-L323 |
50,465 | insacjs/field-creator | lib/class/Field.js | _normalizeValidate | function _normalizeValidate (field) {
if (field.validate) {
Object.keys(field.validate).forEach(key => {
let validateItem = field.validate[key]
if (typeof validateItem === 'function') { return }
// Adiciona la propiedad args, si el validador no lo tuviera.
// Ejemplo: min: 10 -> min: { args: 10 } isInt: true -> isInt: { args: true }
if ((typeof validateItem !== 'object') || (typeof validateItem.args === 'undefined')) {
field.validate[key] = { args: validateItem }
}
// Convierte los validadores booleanos: isInt: { args: true } -> isInt: true
// Sequelize no admite validateKey: { args: true }, es por eso que si existe, ésta se elimina.
if (typeof field.validate[key].args === 'boolean') {
delete field.validate[key].args
if (typeof field.validate[key].msg === 'undefined') {
field.validate[key] = true
}
}
// Corrige el problema cuando se declaran args con valores de 0 y 1.
// Se corrige porque Sequelize los toma como valores booleanos, cuando debería tomarlos como números enteros.
// Ejemplo: min: { args: 0 } -> min: { args: [0] } y min: { args: 1 } -> min: { args: [1] }
if ((typeof field.validate[key].args !== 'undefined') && ((field.validate[key].args === 0) || (field.validate[key].args === 1))) {
field.validate[key].args = [field.validate[key].args]
}
})
}
} | javascript | function _normalizeValidate (field) {
if (field.validate) {
Object.keys(field.validate).forEach(key => {
let validateItem = field.validate[key]
if (typeof validateItem === 'function') { return }
// Adiciona la propiedad args, si el validador no lo tuviera.
// Ejemplo: min: 10 -> min: { args: 10 } isInt: true -> isInt: { args: true }
if ((typeof validateItem !== 'object') || (typeof validateItem.args === 'undefined')) {
field.validate[key] = { args: validateItem }
}
// Convierte los validadores booleanos: isInt: { args: true } -> isInt: true
// Sequelize no admite validateKey: { args: true }, es por eso que si existe, ésta se elimina.
if (typeof field.validate[key].args === 'boolean') {
delete field.validate[key].args
if (typeof field.validate[key].msg === 'undefined') {
field.validate[key] = true
}
}
// Corrige el problema cuando se declaran args con valores de 0 y 1.
// Se corrige porque Sequelize los toma como valores booleanos, cuando debería tomarlos como números enteros.
// Ejemplo: min: { args: 0 } -> min: { args: [0] } y min: { args: 1 } -> min: { args: [1] }
if ((typeof field.validate[key].args !== 'undefined') && ((field.validate[key].args === 0) || (field.validate[key].args === 1))) {
field.validate[key].args = [field.validate[key].args]
}
})
}
} | [
"function",
"_normalizeValidate",
"(",
"field",
")",
"{",
"if",
"(",
"field",
".",
"validate",
")",
"{",
"Object",
".",
"keys",
"(",
"field",
".",
"validate",
")",
".",
"forEach",
"(",
"key",
"=>",
"{",
"let",
"validateItem",
"=",
"field",
".",
"validate",
"[",
"key",
"]",
"if",
"(",
"typeof",
"validateItem",
"===",
"'function'",
")",
"{",
"return",
"}",
"// Adiciona la propiedad args, si el validador no lo tuviera.",
"// Ejemplo: min: 10 -> min: { args: 10 } isInt: true -> isInt: { args: true }",
"if",
"(",
"(",
"typeof",
"validateItem",
"!==",
"'object'",
")",
"||",
"(",
"typeof",
"validateItem",
".",
"args",
"===",
"'undefined'",
")",
")",
"{",
"field",
".",
"validate",
"[",
"key",
"]",
"=",
"{",
"args",
":",
"validateItem",
"}",
"}",
"// Convierte los validadores booleanos: isInt: { args: true } -> isInt: true",
"// Sequelize no admite validateKey: { args: true }, es por eso que si existe, ésta se elimina.",
"if",
"(",
"typeof",
"field",
".",
"validate",
"[",
"key",
"]",
".",
"args",
"===",
"'boolean'",
")",
"{",
"delete",
"field",
".",
"validate",
"[",
"key",
"]",
".",
"args",
"if",
"(",
"typeof",
"field",
".",
"validate",
"[",
"key",
"]",
".",
"msg",
"===",
"'undefined'",
")",
"{",
"field",
".",
"validate",
"[",
"key",
"]",
"=",
"true",
"}",
"}",
"// Corrige el problema cuando se declaran args con valores de 0 y 1.",
"// Se corrige porque Sequelize los toma como valores booleanos, cuando debería tomarlos como números enteros.",
"// Ejemplo: min: { args: 0 } -> min: { args: [0] } y min: { args: 1 } -> min: { args: [1] }",
"if",
"(",
"(",
"typeof",
"field",
".",
"validate",
"[",
"key",
"]",
".",
"args",
"!==",
"'undefined'",
")",
"&&",
"(",
"(",
"field",
".",
"validate",
"[",
"key",
"]",
".",
"args",
"===",
"0",
")",
"||",
"(",
"field",
".",
"validate",
"[",
"key",
"]",
".",
"args",
"===",
"1",
")",
")",
")",
"{",
"field",
".",
"validate",
"[",
"key",
"]",
".",
"args",
"=",
"[",
"field",
".",
"validate",
"[",
"key",
"]",
".",
"args",
"]",
"}",
"}",
")",
"}",
"}"
] | Normaliza la propiedad validate.
@param {Object} field Atributo de un modelo sequelize. | [
"Normaliza",
"la",
"propiedad",
"validate",
"."
] | bbba706852966b61658288d9b42659fdc42f342b | https://github.com/insacjs/field-creator/blob/bbba706852966b61658288d9b42659fdc42f342b/lib/class/Field.js#L404-L430 |
50,466 | expedit85/valichain | index.js | function(v) {
return _.isNil(v) || (_.isString(v) && _.isEmpty(v));
} | javascript | function(v) {
return _.isNil(v) || (_.isString(v) && _.isEmpty(v));
} | [
"function",
"(",
"v",
")",
"{",
"return",
"_",
".",
"isNil",
"(",
"v",
")",
"||",
"(",
"_",
".",
"isString",
"(",
"v",
")",
"&&",
"_",
".",
"isEmpty",
"(",
"v",
")",
")",
";",
"}"
] | Returns true if argument is null, undefined or empty string.
@param {*} v - the value to be tested
@return {boolean} true if nil or "", false otherwise.
@memberof Valichain.$
@static | [
"Returns",
"true",
"if",
"argument",
"is",
"null",
"undefined",
"or",
"empty",
"string",
"."
] | 56f79fb9d53f879bbd81b25d573c8287993811f1 | https://github.com/expedit85/valichain/blob/56f79fb9d53f879bbd81b25d573c8287993811f1/index.js#L433-L435 |
|
50,467 | expedit85/valichain | index.js | function(v) {
return _.isNull(v) || (_.isString(v) && _.isEmpty(v));
} | javascript | function(v) {
return _.isNull(v) || (_.isString(v) && _.isEmpty(v));
} | [
"function",
"(",
"v",
")",
"{",
"return",
"_",
".",
"isNull",
"(",
"v",
")",
"||",
"(",
"_",
".",
"isString",
"(",
"v",
")",
"&&",
"_",
".",
"isEmpty",
"(",
"v",
")",
")",
";",
"}"
] | Returns true if argument is null or empty string.
@param {*} v - the value to be tested
@return {boolean} true if null or "", false otherwise.
@memberof Valichain.$
@static | [
"Returns",
"true",
"if",
"argument",
"is",
"null",
"or",
"empty",
"string",
"."
] | 56f79fb9d53f879bbd81b25d573c8287993811f1 | https://github.com/expedit85/valichain/blob/56f79fb9d53f879bbd81b25d573c8287993811f1/index.js#L446-L448 |
|
50,468 | expedit85/valichain | index.js | function(v) {
return !_.isNil(v)
&& (_.isString(v) || _.isNumber(v) || _.isBoolean)
&& !_.isObject(v);
} | javascript | function(v) {
return !_.isNil(v)
&& (_.isString(v) || _.isNumber(v) || _.isBoolean)
&& !_.isObject(v);
} | [
"function",
"(",
"v",
")",
"{",
"return",
"!",
"_",
".",
"isNil",
"(",
"v",
")",
"&&",
"(",
"_",
".",
"isString",
"(",
"v",
")",
"||",
"_",
".",
"isNumber",
"(",
"v",
")",
"||",
"_",
".",
"isBoolean",
")",
"&&",
"!",
"_",
".",
"isObject",
"(",
"v",
")",
";",
"}"
] | Returns true if argument is not nil primitive. A not nil primitive is
a boolean, number or string, but neither null, undefined nor object.
@param {*} v - the value to be tested
@return {boolean} true if boolean, number or string, false otherwise.
@memberof Valichain.$
@static | [
"Returns",
"true",
"if",
"argument",
"is",
"not",
"nil",
"primitive",
".",
"A",
"not",
"nil",
"primitive",
"is",
"a",
"boolean",
"number",
"or",
"string",
"but",
"neither",
"null",
"undefined",
"nor",
"object",
"."
] | 56f79fb9d53f879bbd81b25d573c8287993811f1 | https://github.com/expedit85/valichain/blob/56f79fb9d53f879bbd81b25d573c8287993811f1/index.js#L460-L464 |
|
50,469 | DeadAlready/node-foldermap | lib/map.js | normalize | function normalize(opts) {
if (typeof opts === 'string') {
opts = {path: opts};
}
opts.path = path.resolve(opts.path);
return opts;
} | javascript | function normalize(opts) {
if (typeof opts === 'string') {
opts = {path: opts};
}
opts.path = path.resolve(opts.path);
return opts;
} | [
"function",
"normalize",
"(",
"opts",
")",
"{",
"if",
"(",
"typeof",
"opts",
"===",
"'string'",
")",
"{",
"opts",
"=",
"{",
"path",
":",
"opts",
"}",
";",
"}",
"opts",
".",
"path",
"=",
"path",
".",
"resolve",
"(",
"opts",
".",
"path",
")",
";",
"return",
"opts",
";",
"}"
] | Function for normalizing input
@param opts
@returns {*} | [
"Function",
"for",
"normalizing",
"input"
] | be6048cb3b3e9fa3b6f36542cb8835d48c7bde1d | https://github.com/DeadAlready/node-foldermap/blob/be6048cb3b3e9fa3b6f36542cb8835d48c7bde1d/lib/map.js#L13-L19 |
50,470 | DeadAlready/node-foldermap | lib/map.js | mapObjects | function mapObjects(root, list, callback) {
var ret = {};
var sent = false;
var count = list.length;
if (count === 0) {
callback(null, ret);
}
list.forEach(function (pointer) {
var name = path.join(root._path, pointer);
fp.define({filePath: name, parent: root}, function (err, obj) {
if (err) {
if (!sent) {
callback(err);
sent = true;
}
return;
}
ret[name] = obj;
if (ret[name]._type === 'directory') {
addMaping(ret[name]);
}
if (--count === 0) {
callback(null, ret);
}
});
});
} | javascript | function mapObjects(root, list, callback) {
var ret = {};
var sent = false;
var count = list.length;
if (count === 0) {
callback(null, ret);
}
list.forEach(function (pointer) {
var name = path.join(root._path, pointer);
fp.define({filePath: name, parent: root}, function (err, obj) {
if (err) {
if (!sent) {
callback(err);
sent = true;
}
return;
}
ret[name] = obj;
if (ret[name]._type === 'directory') {
addMaping(ret[name]);
}
if (--count === 0) {
callback(null, ret);
}
});
});
} | [
"function",
"mapObjects",
"(",
"root",
",",
"list",
",",
"callback",
")",
"{",
"var",
"ret",
"=",
"{",
"}",
";",
"var",
"sent",
"=",
"false",
";",
"var",
"count",
"=",
"list",
".",
"length",
";",
"if",
"(",
"count",
"===",
"0",
")",
"{",
"callback",
"(",
"null",
",",
"ret",
")",
";",
"}",
"list",
".",
"forEach",
"(",
"function",
"(",
"pointer",
")",
"{",
"var",
"name",
"=",
"path",
".",
"join",
"(",
"root",
".",
"_path",
",",
"pointer",
")",
";",
"fp",
".",
"define",
"(",
"{",
"filePath",
":",
"name",
",",
"parent",
":",
"root",
"}",
",",
"function",
"(",
"err",
",",
"obj",
")",
"{",
"if",
"(",
"err",
")",
"{",
"if",
"(",
"!",
"sent",
")",
"{",
"callback",
"(",
"err",
")",
";",
"sent",
"=",
"true",
";",
"}",
"return",
";",
"}",
"ret",
"[",
"name",
"]",
"=",
"obj",
";",
"if",
"(",
"ret",
"[",
"name",
"]",
".",
"_type",
"===",
"'directory'",
")",
"{",
"addMaping",
"(",
"ret",
"[",
"name",
"]",
")",
";",
"}",
"if",
"(",
"--",
"count",
"===",
"0",
")",
"{",
"callback",
"(",
"null",
",",
"ret",
")",
";",
"}",
"}",
")",
";",
"}",
")",
";",
"}"
] | Function for mapping a list of objects relative to root object
@param root - Folder object
@param list - Array of file names
@param callback(err, result) - Function | [
"Function",
"for",
"mapping",
"a",
"list",
"of",
"objects",
"relative",
"to",
"root",
"object"
] | be6048cb3b3e9fa3b6f36542cb8835d48c7bde1d | https://github.com/DeadAlready/node-foldermap/blob/be6048cb3b3e9fa3b6f36542cb8835d48c7bde1d/lib/map.js#L28-L55 |
50,471 | DeadAlready/node-foldermap | lib/map.js | filter | function filter(pObjects, opts, returnArray) {
var filtered = returnArray ? [] : {};
function addToFiltered(key) {
if(returnArray) {
filtered.push((returnArray === 'keys' ? key : pObjects[key]));
} else {
filtered[key] = pObjects[key];
}
}
if (!opts) {
Object.keys(pObjects).forEach();
return;
}
function checkMatch(match, prop) {
if(utils.isArray(match)){
return match.indexOf(prop) !== -1;
}
return match === prop;
}
Object.keys(pObjects).forEach(function (key) {
//Return only fp objects
if(['File','Folder'].indexOf(pObjects[key].constructor.name) === -1) {
return;
}
//Recursive directories always added
if (opts.recursive && pObjects[key]._type === 'directory') {
addToFiltered(key);
return;
}
if (!opts.dotStart && pObjects[key]._name.charAt(0) === '.') {
return;
}
if(opts.type && !checkMatch(opts.type, pObjects[key]._type)) {
return;
}
if(opts.ext && pObjects[key]._type === 'file' && !checkMatch(opts.ext, pObjects[key]._ext)) {
return;
}
if (opts.match && !pObjects[key]._name.match(opts.match)) {
return;
}
if (opts.pathMatch && !pObjects[key]._path.match(opts.pathMatch)) {
return;
}
addToFiltered(key);
});
return filtered;
} | javascript | function filter(pObjects, opts, returnArray) {
var filtered = returnArray ? [] : {};
function addToFiltered(key) {
if(returnArray) {
filtered.push((returnArray === 'keys' ? key : pObjects[key]));
} else {
filtered[key] = pObjects[key];
}
}
if (!opts) {
Object.keys(pObjects).forEach();
return;
}
function checkMatch(match, prop) {
if(utils.isArray(match)){
return match.indexOf(prop) !== -1;
}
return match === prop;
}
Object.keys(pObjects).forEach(function (key) {
//Return only fp objects
if(['File','Folder'].indexOf(pObjects[key].constructor.name) === -1) {
return;
}
//Recursive directories always added
if (opts.recursive && pObjects[key]._type === 'directory') {
addToFiltered(key);
return;
}
if (!opts.dotStart && pObjects[key]._name.charAt(0) === '.') {
return;
}
if(opts.type && !checkMatch(opts.type, pObjects[key]._type)) {
return;
}
if(opts.ext && pObjects[key]._type === 'file' && !checkMatch(opts.ext, pObjects[key]._ext)) {
return;
}
if (opts.match && !pObjects[key]._name.match(opts.match)) {
return;
}
if (opts.pathMatch && !pObjects[key]._path.match(opts.pathMatch)) {
return;
}
addToFiltered(key);
});
return filtered;
} | [
"function",
"filter",
"(",
"pObjects",
",",
"opts",
",",
"returnArray",
")",
"{",
"var",
"filtered",
"=",
"returnArray",
"?",
"[",
"]",
":",
"{",
"}",
";",
"function",
"addToFiltered",
"(",
"key",
")",
"{",
"if",
"(",
"returnArray",
")",
"{",
"filtered",
".",
"push",
"(",
"(",
"returnArray",
"===",
"'keys'",
"?",
"key",
":",
"pObjects",
"[",
"key",
"]",
")",
")",
";",
"}",
"else",
"{",
"filtered",
"[",
"key",
"]",
"=",
"pObjects",
"[",
"key",
"]",
";",
"}",
"}",
"if",
"(",
"!",
"opts",
")",
"{",
"Object",
".",
"keys",
"(",
"pObjects",
")",
".",
"forEach",
"(",
")",
";",
"return",
";",
"}",
"function",
"checkMatch",
"(",
"match",
",",
"prop",
")",
"{",
"if",
"(",
"utils",
".",
"isArray",
"(",
"match",
")",
")",
"{",
"return",
"match",
".",
"indexOf",
"(",
"prop",
")",
"!==",
"-",
"1",
";",
"}",
"return",
"match",
"===",
"prop",
";",
"}",
"Object",
".",
"keys",
"(",
"pObjects",
")",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"//Return only fp objects",
"if",
"(",
"[",
"'File'",
",",
"'Folder'",
"]",
".",
"indexOf",
"(",
"pObjects",
"[",
"key",
"]",
".",
"constructor",
".",
"name",
")",
"===",
"-",
"1",
")",
"{",
"return",
";",
"}",
"//Recursive directories always added",
"if",
"(",
"opts",
".",
"recursive",
"&&",
"pObjects",
"[",
"key",
"]",
".",
"_type",
"===",
"'directory'",
")",
"{",
"addToFiltered",
"(",
"key",
")",
";",
"return",
";",
"}",
"if",
"(",
"!",
"opts",
".",
"dotStart",
"&&",
"pObjects",
"[",
"key",
"]",
".",
"_name",
".",
"charAt",
"(",
"0",
")",
"===",
"'.'",
")",
"{",
"return",
";",
"}",
"if",
"(",
"opts",
".",
"type",
"&&",
"!",
"checkMatch",
"(",
"opts",
".",
"type",
",",
"pObjects",
"[",
"key",
"]",
".",
"_type",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"opts",
".",
"ext",
"&&",
"pObjects",
"[",
"key",
"]",
".",
"_type",
"===",
"'file'",
"&&",
"!",
"checkMatch",
"(",
"opts",
".",
"ext",
",",
"pObjects",
"[",
"key",
"]",
".",
"_ext",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"opts",
".",
"match",
"&&",
"!",
"pObjects",
"[",
"key",
"]",
".",
"_name",
".",
"match",
"(",
"opts",
".",
"match",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"opts",
".",
"pathMatch",
"&&",
"!",
"pObjects",
"[",
"key",
"]",
".",
"_path",
".",
"match",
"(",
"opts",
".",
"pathMatch",
")",
")",
"{",
"return",
";",
"}",
"addToFiltered",
"(",
"key",
")",
";",
"}",
")",
";",
"return",
"filtered",
";",
"}"
] | Function for filtering pointer objects based on options
@param pObjects - object with subobjects being pointer objects
@param opts - options to use when filtering
@param returnArray - return an array instead of object
@returns {*} || [*] - object or array with filtered results | [
"Function",
"for",
"filtering",
"pointer",
"objects",
"based",
"on",
"options"
] | be6048cb3b3e9fa3b6f36542cb8835d48c7bde1d | https://github.com/DeadAlready/node-foldermap/blob/be6048cb3b3e9fa3b6f36542cb8835d48c7bde1d/lib/map.js#L65-L121 |
50,472 | DeadAlready/node-foldermap | lib/map.js | transfer | function transfer(root, map, opts) {
map = filter(map, opts);
var folders = [];
function getIndex(k) {
var index = k;
if (opts.relative) {
var replace = opts.relative === true ? (root._path + path.sep) : opts.relative;
index = k.replace(replace, '');
}
return index;
}
Object.keys(map).forEach(function (k) {
var index = getIndex(map[k]._path);
if (map[k]._type === 'directory') {
folders.push(map[k]);
if (opts.type !== 'file' && !(opts.match || opts.ext)) {
root[index] = map[k];
}
}
if (map[k]._type === 'file' && (!opts.type || opts.type === 'file')) {
root[index] = map[k];
}
});
return folders;
} | javascript | function transfer(root, map, opts) {
map = filter(map, opts);
var folders = [];
function getIndex(k) {
var index = k;
if (opts.relative) {
var replace = opts.relative === true ? (root._path + path.sep) : opts.relative;
index = k.replace(replace, '');
}
return index;
}
Object.keys(map).forEach(function (k) {
var index = getIndex(map[k]._path);
if (map[k]._type === 'directory') {
folders.push(map[k]);
if (opts.type !== 'file' && !(opts.match || opts.ext)) {
root[index] = map[k];
}
}
if (map[k]._type === 'file' && (!opts.type || opts.type === 'file')) {
root[index] = map[k];
}
});
return folders;
} | [
"function",
"transfer",
"(",
"root",
",",
"map",
",",
"opts",
")",
"{",
"map",
"=",
"filter",
"(",
"map",
",",
"opts",
")",
";",
"var",
"folders",
"=",
"[",
"]",
";",
"function",
"getIndex",
"(",
"k",
")",
"{",
"var",
"index",
"=",
"k",
";",
"if",
"(",
"opts",
".",
"relative",
")",
"{",
"var",
"replace",
"=",
"opts",
".",
"relative",
"===",
"true",
"?",
"(",
"root",
".",
"_path",
"+",
"path",
".",
"sep",
")",
":",
"opts",
".",
"relative",
";",
"index",
"=",
"k",
".",
"replace",
"(",
"replace",
",",
"''",
")",
";",
"}",
"return",
"index",
";",
"}",
"Object",
".",
"keys",
"(",
"map",
")",
".",
"forEach",
"(",
"function",
"(",
"k",
")",
"{",
"var",
"index",
"=",
"getIndex",
"(",
"map",
"[",
"k",
"]",
".",
"_path",
")",
";",
"if",
"(",
"map",
"[",
"k",
"]",
".",
"_type",
"===",
"'directory'",
")",
"{",
"folders",
".",
"push",
"(",
"map",
"[",
"k",
"]",
")",
";",
"if",
"(",
"opts",
".",
"type",
"!==",
"'file'",
"&&",
"!",
"(",
"opts",
".",
"match",
"||",
"opts",
".",
"ext",
")",
")",
"{",
"root",
"[",
"index",
"]",
"=",
"map",
"[",
"k",
"]",
";",
"}",
"}",
"if",
"(",
"map",
"[",
"k",
"]",
".",
"_type",
"===",
"'file'",
"&&",
"(",
"!",
"opts",
".",
"type",
"||",
"opts",
".",
"type",
"===",
"'file'",
")",
")",
"{",
"root",
"[",
"index",
"]",
"=",
"map",
"[",
"k",
"]",
";",
"}",
"}",
")",
";",
"return",
"folders",
";",
"}"
] | Function for transferring properties from map to root using opts
@param root {Object} - object to attach new pointers to
@param map {Object} - object with properties being pointer objects
@param opts {Object} - options
@returns {Array} - Folders for recursive mapping | [
"Function",
"for",
"transferring",
"properties",
"from",
"map",
"to",
"root",
"using",
"opts"
] | be6048cb3b3e9fa3b6f36542cb8835d48c7bde1d | https://github.com/DeadAlready/node-foldermap/blob/be6048cb3b3e9fa3b6f36542cb8835d48c7bde1d/lib/map.js#L131-L159 |
50,473 | DeadAlready/node-foldermap | lib/map.js | simpleMap | function simpleMap(map, lvls, opts, type, ext, callback) {
opts = utils.clone(opts);
lvls--;
if(lvls < 1) {
opts.simple = false;
opts.recursive = true;
opts.type = type;
opts.ext = ext;
}
var folders = map.__filter({type:'directory'}, true);
var count = folders.length;
var errs = [];
function end(err) {
if(err) {
errs.push(err);
}
if(--count !== 0) {
return;
}
if(errs.length) {
callback(errs);
return;
}
callback(null, map);
}
folders.forEach(function (folder) {
folder.__map(opts, function (err, fMap) {
if(err) {
end(err);
return;
}
if(lvls < 1) {
end();
} else {
simpleMap(fMap, lvls, opts, type, ext, end);
}
});
});
} | javascript | function simpleMap(map, lvls, opts, type, ext, callback) {
opts = utils.clone(opts);
lvls--;
if(lvls < 1) {
opts.simple = false;
opts.recursive = true;
opts.type = type;
opts.ext = ext;
}
var folders = map.__filter({type:'directory'}, true);
var count = folders.length;
var errs = [];
function end(err) {
if(err) {
errs.push(err);
}
if(--count !== 0) {
return;
}
if(errs.length) {
callback(errs);
return;
}
callback(null, map);
}
folders.forEach(function (folder) {
folder.__map(opts, function (err, fMap) {
if(err) {
end(err);
return;
}
if(lvls < 1) {
end();
} else {
simpleMap(fMap, lvls, opts, type, ext, end);
}
});
});
} | [
"function",
"simpleMap",
"(",
"map",
",",
"lvls",
",",
"opts",
",",
"type",
",",
"ext",
",",
"callback",
")",
"{",
"opts",
"=",
"utils",
".",
"clone",
"(",
"opts",
")",
";",
"lvls",
"--",
";",
"if",
"(",
"lvls",
"<",
"1",
")",
"{",
"opts",
".",
"simple",
"=",
"false",
";",
"opts",
".",
"recursive",
"=",
"true",
";",
"opts",
".",
"type",
"=",
"type",
";",
"opts",
".",
"ext",
"=",
"ext",
";",
"}",
"var",
"folders",
"=",
"map",
".",
"__filter",
"(",
"{",
"type",
":",
"'directory'",
"}",
",",
"true",
")",
";",
"var",
"count",
"=",
"folders",
".",
"length",
";",
"var",
"errs",
"=",
"[",
"]",
";",
"function",
"end",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"{",
"errs",
".",
"push",
"(",
"err",
")",
";",
"}",
"if",
"(",
"--",
"count",
"!==",
"0",
")",
"{",
"return",
";",
"}",
"if",
"(",
"errs",
".",
"length",
")",
"{",
"callback",
"(",
"errs",
")",
";",
"return",
";",
"}",
"callback",
"(",
"null",
",",
"map",
")",
";",
"}",
"folders",
".",
"forEach",
"(",
"function",
"(",
"folder",
")",
"{",
"folder",
".",
"__map",
"(",
"opts",
",",
"function",
"(",
"err",
",",
"fMap",
")",
"{",
"if",
"(",
"err",
")",
"{",
"end",
"(",
"err",
")",
";",
"return",
";",
"}",
"if",
"(",
"lvls",
"<",
"1",
")",
"{",
"end",
"(",
")",
";",
"}",
"else",
"{",
"simpleMap",
"(",
"fMap",
",",
"lvls",
",",
"opts",
",",
"type",
",",
"ext",
",",
"end",
")",
";",
"}",
"}",
")",
";",
"}",
")",
";",
"}"
] | Function for mapping simple first x lvls
@param map -> root map
@param lvls -> nr of levels
@param opts -> the options
@param type -> the final type to use
@param callback | [
"Function",
"for",
"mapping",
"simple",
"first",
"x",
"lvls"
] | be6048cb3b3e9fa3b6f36542cb8835d48c7bde1d | https://github.com/DeadAlready/node-foldermap/blob/be6048cb3b3e9fa3b6f36542cb8835d48c7bde1d/lib/map.js#L327-L366 |
50,474 | DeadAlready/node-foldermap | lib/map.js | map | function map(opts, callback) {
if(utils.isArray(opts)) {
mapWithArrayInput(opts, callback);
return;
}
opts = normalize(opts);
// Assume that the root is a folder
var root = new fp.Folder(opts.path);
var sent = false;
root.__listen('error', function (err) {
if (!sent) {
callback(err);
sent = true;
}
});
root.__listen('missing', function (err) {
if (!sent) {
callback(err);
sent = true;
}
});
root.__stats(function (err, stats) {
if (err) {
if (!sent) {
callback(err);
}
return;
}
// If the root is a file simply return it
if (!stats.isDirectory()) {
callback(null, new fp.File(opts.path));
return;
}
// Add functions
addMaping(root);
if(typeof opts.simple !== 'number' || !opts.recursive) {
root.__map(opts, callback);
} else {
var lvls = opts.simple;
var type = opts.type;
var ext = opts.ext;
opts.recursive = false;
opts.simple = true;
if(opts.type === 'file') {
delete opts.type;
}
if(opts.ext) {
delete opts.ext;
}
root.__map(opts, function (err, map) {
if(err) {
callback(err);
return;
}
simpleMap(map, lvls, opts, type, ext, callback);
});
}
});
} | javascript | function map(opts, callback) {
if(utils.isArray(opts)) {
mapWithArrayInput(opts, callback);
return;
}
opts = normalize(opts);
// Assume that the root is a folder
var root = new fp.Folder(opts.path);
var sent = false;
root.__listen('error', function (err) {
if (!sent) {
callback(err);
sent = true;
}
});
root.__listen('missing', function (err) {
if (!sent) {
callback(err);
sent = true;
}
});
root.__stats(function (err, stats) {
if (err) {
if (!sent) {
callback(err);
}
return;
}
// If the root is a file simply return it
if (!stats.isDirectory()) {
callback(null, new fp.File(opts.path));
return;
}
// Add functions
addMaping(root);
if(typeof opts.simple !== 'number' || !opts.recursive) {
root.__map(opts, callback);
} else {
var lvls = opts.simple;
var type = opts.type;
var ext = opts.ext;
opts.recursive = false;
opts.simple = true;
if(opts.type === 'file') {
delete opts.type;
}
if(opts.ext) {
delete opts.ext;
}
root.__map(opts, function (err, map) {
if(err) {
callback(err);
return;
}
simpleMap(map, lvls, opts, type, ext, callback);
});
}
});
} | [
"function",
"map",
"(",
"opts",
",",
"callback",
")",
"{",
"if",
"(",
"utils",
".",
"isArray",
"(",
"opts",
")",
")",
"{",
"mapWithArrayInput",
"(",
"opts",
",",
"callback",
")",
";",
"return",
";",
"}",
"opts",
"=",
"normalize",
"(",
"opts",
")",
";",
"// Assume that the root is a folder",
"var",
"root",
"=",
"new",
"fp",
".",
"Folder",
"(",
"opts",
".",
"path",
")",
";",
"var",
"sent",
"=",
"false",
";",
"root",
".",
"__listen",
"(",
"'error'",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"!",
"sent",
")",
"{",
"callback",
"(",
"err",
")",
";",
"sent",
"=",
"true",
";",
"}",
"}",
")",
";",
"root",
".",
"__listen",
"(",
"'missing'",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"!",
"sent",
")",
"{",
"callback",
"(",
"err",
")",
";",
"sent",
"=",
"true",
";",
"}",
"}",
")",
";",
"root",
".",
"__stats",
"(",
"function",
"(",
"err",
",",
"stats",
")",
"{",
"if",
"(",
"err",
")",
"{",
"if",
"(",
"!",
"sent",
")",
"{",
"callback",
"(",
"err",
")",
";",
"}",
"return",
";",
"}",
"// If the root is a file simply return it",
"if",
"(",
"!",
"stats",
".",
"isDirectory",
"(",
")",
")",
"{",
"callback",
"(",
"null",
",",
"new",
"fp",
".",
"File",
"(",
"opts",
".",
"path",
")",
")",
";",
"return",
";",
"}",
"// Add functions",
"addMaping",
"(",
"root",
")",
";",
"if",
"(",
"typeof",
"opts",
".",
"simple",
"!==",
"'number'",
"||",
"!",
"opts",
".",
"recursive",
")",
"{",
"root",
".",
"__map",
"(",
"opts",
",",
"callback",
")",
";",
"}",
"else",
"{",
"var",
"lvls",
"=",
"opts",
".",
"simple",
";",
"var",
"type",
"=",
"opts",
".",
"type",
";",
"var",
"ext",
"=",
"opts",
".",
"ext",
";",
"opts",
".",
"recursive",
"=",
"false",
";",
"opts",
".",
"simple",
"=",
"true",
";",
"if",
"(",
"opts",
".",
"type",
"===",
"'file'",
")",
"{",
"delete",
"opts",
".",
"type",
";",
"}",
"if",
"(",
"opts",
".",
"ext",
")",
"{",
"delete",
"opts",
".",
"ext",
";",
"}",
"root",
".",
"__map",
"(",
"opts",
",",
"function",
"(",
"err",
",",
"map",
")",
"{",
"if",
"(",
"err",
")",
"{",
"callback",
"(",
"err",
")",
";",
"return",
";",
"}",
"simpleMap",
"(",
"map",
",",
"lvls",
",",
"opts",
",",
"type",
",",
"ext",
",",
"callback",
")",
";",
"}",
")",
";",
"}",
"}",
")",
";",
"}"
] | Function for mapping a folder and returning a foldermap
@param opts -> object or array of objects
@param callback | [
"Function",
"for",
"mapping",
"a",
"folder",
"and",
"returning",
"a",
"foldermap"
] | be6048cb3b3e9fa3b6f36542cb8835d48c7bde1d | https://github.com/DeadAlready/node-foldermap/blob/be6048cb3b3e9fa3b6f36542cb8835d48c7bde1d/lib/map.js#L405-L468 |
50,475 | kvnneff/incremental | index.js | increment | function increment(value, skip, incrementBy) {
var str = (typeof value === 'string');
var incrementBy = incrementBy || 1;
var numeric = !isNaN(value);
var skip = skip || [];
var nextVal;
if (numeric) {
value = parseInt(value) + parseInt(incrementBy);
} else {
value = String.fromCharCode(value.charCodeAt(0) + parseInt(incrementBy));
}
if (str) value = value.toString();
if (skip.indexOf(value) === -1) return value;
return increment(value, skip, incrementBy);
} | javascript | function increment(value, skip, incrementBy) {
var str = (typeof value === 'string');
var incrementBy = incrementBy || 1;
var numeric = !isNaN(value);
var skip = skip || [];
var nextVal;
if (numeric) {
value = parseInt(value) + parseInt(incrementBy);
} else {
value = String.fromCharCode(value.charCodeAt(0) + parseInt(incrementBy));
}
if (str) value = value.toString();
if (skip.indexOf(value) === -1) return value;
return increment(value, skip, incrementBy);
} | [
"function",
"increment",
"(",
"value",
",",
"skip",
",",
"incrementBy",
")",
"{",
"var",
"str",
"=",
"(",
"typeof",
"value",
"===",
"'string'",
")",
";",
"var",
"incrementBy",
"=",
"incrementBy",
"||",
"1",
";",
"var",
"numeric",
"=",
"!",
"isNaN",
"(",
"value",
")",
";",
"var",
"skip",
"=",
"skip",
"||",
"[",
"]",
";",
"var",
"nextVal",
";",
"if",
"(",
"numeric",
")",
"{",
"value",
"=",
"parseInt",
"(",
"value",
")",
"+",
"parseInt",
"(",
"incrementBy",
")",
";",
"}",
"else",
"{",
"value",
"=",
"String",
".",
"fromCharCode",
"(",
"value",
".",
"charCodeAt",
"(",
"0",
")",
"+",
"parseInt",
"(",
"incrementBy",
")",
")",
";",
"}",
"if",
"(",
"str",
")",
"value",
"=",
"value",
".",
"toString",
"(",
")",
";",
"if",
"(",
"skip",
".",
"indexOf",
"(",
"value",
")",
"===",
"-",
"1",
")",
"return",
"value",
";",
"return",
"increment",
"(",
"value",
",",
"skip",
",",
"incrementBy",
")",
";",
"}"
] | Increment a number or alpha character
@param {String|Number} value
@param {Array} skip
@param {Number} incrementBy
@return {String|Number}
@api public | [
"Increment",
"a",
"number",
"or",
"alpha",
"character"
] | ed412879d3c22a3912ebfb9e7fc6a41f789196bb | https://github.com/kvnneff/incremental/blob/ed412879d3c22a3912ebfb9e7fc6a41f789196bb/index.js#L15-L31 |
50,476 | samleybrize/node-package-json-discover | lib/package-json-discover.js | discover | function discover(from) {
from = from || caller();
// check 'from' validity
if ("string" != typeof from) {
var given = typeof from;
throw new Error("'from' must be a string, [" + given + "] given");
}
// if 'from' is not absolute, make it absolute
if (!pathIsAbsolute(from)) {
from = path.join(
path.dirname(caller()),
from
);
}
// if 'from' is a file, keep its dirname
if (fs.existsSync(from)) {
var stat = fs.lstatSync(from);
if (stat.isFile()) {
from = path.dirname(from);
}
}
// check path cache
if (discoverCache[from]) {
return discoverCache[from];
}
// process directories from 'from' to system root directory until we find a package.json file
var dir = from;
var old = null;
var processedDirList = [];
while (true) {
if (discoverCache[dir]) {
// path from cache
return discoverCache[dir];
} else if (fs.existsSync(dir + "/package.json")) {
// package.json found
processedDirList.push(dir);
var discoveredDir = dir + "/package.json";
for (var i in processedDirList) {
discoverCache[processedDirList[i]] = discoveredDir;
}
return discoveredDir;
} else {
// process parent directory
old = dir;
dir = path.dirname(dir);
// check if we reached the system root directory
if (old === dir) {
break;
}
// add processed dir to the list
processedDirList.push(old);
}
}
throw new Error("Unabe to find a package.json from '" + from + "'");
} | javascript | function discover(from) {
from = from || caller();
// check 'from' validity
if ("string" != typeof from) {
var given = typeof from;
throw new Error("'from' must be a string, [" + given + "] given");
}
// if 'from' is not absolute, make it absolute
if (!pathIsAbsolute(from)) {
from = path.join(
path.dirname(caller()),
from
);
}
// if 'from' is a file, keep its dirname
if (fs.existsSync(from)) {
var stat = fs.lstatSync(from);
if (stat.isFile()) {
from = path.dirname(from);
}
}
// check path cache
if (discoverCache[from]) {
return discoverCache[from];
}
// process directories from 'from' to system root directory until we find a package.json file
var dir = from;
var old = null;
var processedDirList = [];
while (true) {
if (discoverCache[dir]) {
// path from cache
return discoverCache[dir];
} else if (fs.existsSync(dir + "/package.json")) {
// package.json found
processedDirList.push(dir);
var discoveredDir = dir + "/package.json";
for (var i in processedDirList) {
discoverCache[processedDirList[i]] = discoveredDir;
}
return discoveredDir;
} else {
// process parent directory
old = dir;
dir = path.dirname(dir);
// check if we reached the system root directory
if (old === dir) {
break;
}
// add processed dir to the list
processedDirList.push(old);
}
}
throw new Error("Unabe to find a package.json from '" + from + "'");
} | [
"function",
"discover",
"(",
"from",
")",
"{",
"from",
"=",
"from",
"||",
"caller",
"(",
")",
";",
"// check 'from' validity",
"if",
"(",
"\"string\"",
"!=",
"typeof",
"from",
")",
"{",
"var",
"given",
"=",
"typeof",
"from",
";",
"throw",
"new",
"Error",
"(",
"\"'from' must be a string, [\"",
"+",
"given",
"+",
"\"] given\"",
")",
";",
"}",
"// if 'from' is not absolute, make it absolute",
"if",
"(",
"!",
"pathIsAbsolute",
"(",
"from",
")",
")",
"{",
"from",
"=",
"path",
".",
"join",
"(",
"path",
".",
"dirname",
"(",
"caller",
"(",
")",
")",
",",
"from",
")",
";",
"}",
"// if 'from' is a file, keep its dirname",
"if",
"(",
"fs",
".",
"existsSync",
"(",
"from",
")",
")",
"{",
"var",
"stat",
"=",
"fs",
".",
"lstatSync",
"(",
"from",
")",
";",
"if",
"(",
"stat",
".",
"isFile",
"(",
")",
")",
"{",
"from",
"=",
"path",
".",
"dirname",
"(",
"from",
")",
";",
"}",
"}",
"// check path cache",
"if",
"(",
"discoverCache",
"[",
"from",
"]",
")",
"{",
"return",
"discoverCache",
"[",
"from",
"]",
";",
"}",
"// process directories from 'from' to system root directory until we find a package.json file",
"var",
"dir",
"=",
"from",
";",
"var",
"old",
"=",
"null",
";",
"var",
"processedDirList",
"=",
"[",
"]",
";",
"while",
"(",
"true",
")",
"{",
"if",
"(",
"discoverCache",
"[",
"dir",
"]",
")",
"{",
"// path from cache",
"return",
"discoverCache",
"[",
"dir",
"]",
";",
"}",
"else",
"if",
"(",
"fs",
".",
"existsSync",
"(",
"dir",
"+",
"\"/package.json\"",
")",
")",
"{",
"// package.json found",
"processedDirList",
".",
"push",
"(",
"dir",
")",
";",
"var",
"discoveredDir",
"=",
"dir",
"+",
"\"/package.json\"",
";",
"for",
"(",
"var",
"i",
"in",
"processedDirList",
")",
"{",
"discoverCache",
"[",
"processedDirList",
"[",
"i",
"]",
"]",
"=",
"discoveredDir",
";",
"}",
"return",
"discoveredDir",
";",
"}",
"else",
"{",
"// process parent directory",
"old",
"=",
"dir",
";",
"dir",
"=",
"path",
".",
"dirname",
"(",
"dir",
")",
";",
"// check if we reached the system root directory",
"if",
"(",
"old",
"===",
"dir",
")",
"{",
"break",
";",
"}",
"// add processed dir to the list",
"processedDirList",
".",
"push",
"(",
"old",
")",
";",
"}",
"}",
"throw",
"new",
"Error",
"(",
"\"Unabe to find a package.json from '\"",
"+",
"from",
"+",
"\"'\"",
")",
";",
"}"
] | Discovers the closest package.json file and returns its absolute path
@param {string} [from] - The path to the directory where to start discovering. If omitted, it is the path to the file that calls this function.
@returns {string} | [
"Discovers",
"the",
"closest",
"package",
".",
"json",
"file",
"and",
"returns",
"its",
"absolute",
"path"
] | 1e95d15406ba32b80d3998a5bb4016a1431ebd5c | https://github.com/samleybrize/node-package-json-discover/blob/1e95d15406ba32b80d3998a5bb4016a1431ebd5c/lib/package-json-discover.js#L21-L87 |
50,477 | enricostara/get-log | lib/get-log.js | Logger | function Logger(name) {
var prjName = module.exports.PROJECT_NAME;
this.name = prjName ? prjName + ':' + name : name;
this._debug = debug(this.name);
this._debug.log = logDebug;
this.debugEnabled = debug.enabled(this.name);
if (this.debugEnabled) {
logDebug('[%s] debug is %s', this.name.blue, 'ENABLED'.green);
}
} | javascript | function Logger(name) {
var prjName = module.exports.PROJECT_NAME;
this.name = prjName ? prjName + ':' + name : name;
this._debug = debug(this.name);
this._debug.log = logDebug;
this.debugEnabled = debug.enabled(this.name);
if (this.debugEnabled) {
logDebug('[%s] debug is %s', this.name.blue, 'ENABLED'.green);
}
} | [
"function",
"Logger",
"(",
"name",
")",
"{",
"var",
"prjName",
"=",
"module",
".",
"exports",
".",
"PROJECT_NAME",
";",
"this",
".",
"name",
"=",
"prjName",
"?",
"prjName",
"+",
"':'",
"+",
"name",
":",
"name",
";",
"this",
".",
"_debug",
"=",
"debug",
"(",
"this",
".",
"name",
")",
";",
"this",
".",
"_debug",
".",
"log",
"=",
"logDebug",
";",
"this",
".",
"debugEnabled",
"=",
"debug",
".",
"enabled",
"(",
"this",
".",
"name",
")",
";",
"if",
"(",
"this",
".",
"debugEnabled",
")",
"{",
"logDebug",
"(",
"'[%s] debug is %s'",
",",
"this",
".",
"name",
".",
"blue",
",",
"'ENABLED'",
".",
"green",
")",
";",
"}",
"}"
] | The constructor requires the logger name | [
"The",
"constructor",
"requires",
"the",
"logger",
"name"
] | 2a78a8397e4282064979bcd4291685cbe8e52745 | https://github.com/enricostara/get-log/blob/2a78a8397e4282064979bcd4291685cbe8e52745/lib/get-log.js#L55-L64 |
50,478 | schwarzkopfb/extw | index.js | extractWords | function extractWords(str, store) {
if (!str)
return []
if (Array.isArray(str))
return str
assert.equal(typeof str, 'string', 'first parameter must be an array or string')
switch (store) {
case undefined:
if (cache)
return parseWordListCached(str, cache)
else
return parseWordList(str)
case null:
case false:
return parseWordList(str)
default:
assert.equal(typeof store, 'object', 'second parameter must be an object or null')
return parseWordListCached(str, store)
}
} | javascript | function extractWords(str, store) {
if (!str)
return []
if (Array.isArray(str))
return str
assert.equal(typeof str, 'string', 'first parameter must be an array or string')
switch (store) {
case undefined:
if (cache)
return parseWordListCached(str, cache)
else
return parseWordList(str)
case null:
case false:
return parseWordList(str)
default:
assert.equal(typeof store, 'object', 'second parameter must be an object or null')
return parseWordListCached(str, store)
}
} | [
"function",
"extractWords",
"(",
"str",
",",
"store",
")",
"{",
"if",
"(",
"!",
"str",
")",
"return",
"[",
"]",
"if",
"(",
"Array",
".",
"isArray",
"(",
"str",
")",
")",
"return",
"str",
"assert",
".",
"equal",
"(",
"typeof",
"str",
",",
"'string'",
",",
"'first parameter must be an array or string'",
")",
"switch",
"(",
"store",
")",
"{",
"case",
"undefined",
":",
"if",
"(",
"cache",
")",
"return",
"parseWordListCached",
"(",
"str",
",",
"cache",
")",
"else",
"return",
"parseWordList",
"(",
"str",
")",
"case",
"null",
":",
"case",
"false",
":",
"return",
"parseWordList",
"(",
"str",
")",
"default",
":",
"assert",
".",
"equal",
"(",
"typeof",
"store",
",",
"'object'",
",",
"'second parameter must be an object or null'",
")",
"return",
"parseWordListCached",
"(",
"str",
",",
"store",
")",
"}",
"}"
] | Extract words from a given string.
@param {string|Array} str The string to parse.
@param {null|Object} [store] Pass an object to use for caching instead of the default one. Or pass `null` to disable caching for this call.
@returns {[string]} | [
"Extract",
"words",
"from",
"a",
"given",
"string",
"."
] | d95befe35cdd3c2ed5b10bbe83176323a3f86521 | https://github.com/schwarzkopfb/extw/blob/d95befe35cdd3c2ed5b10bbe83176323a3f86521/index.js#L26-L50 |
50,479 | nathanhood/postcss-variable-media | index.js | registerBreakpoints | function registerBreakpoints(breakpoints) {
let register = [];
Object.keys(breakpoints).forEach(name => {
register.push('(^' + escRgx(name) + '$)');
});
if (! register.length) {
return false;
}
return new RegExp(register.join('|'));
} | javascript | function registerBreakpoints(breakpoints) {
let register = [];
Object.keys(breakpoints).forEach(name => {
register.push('(^' + escRgx(name) + '$)');
});
if (! register.length) {
return false;
}
return new RegExp(register.join('|'));
} | [
"function",
"registerBreakpoints",
"(",
"breakpoints",
")",
"{",
"let",
"register",
"=",
"[",
"]",
";",
"Object",
".",
"keys",
"(",
"breakpoints",
")",
".",
"forEach",
"(",
"name",
"=>",
"{",
"register",
".",
"push",
"(",
"'(^'",
"+",
"escRgx",
"(",
"name",
")",
"+",
"'$)'",
")",
";",
"}",
")",
";",
"if",
"(",
"!",
"register",
".",
"length",
")",
"{",
"return",
"false",
";",
"}",
"return",
"new",
"RegExp",
"(",
"register",
".",
"join",
"(",
"'|'",
")",
")",
";",
"}"
] | Create regex to identify breakpoints
@param {object} breakpoints
@returns {RegExp} | [
"Create",
"regex",
"to",
"identify",
"breakpoints"
] | c8a761e6dc6d925309197e39e4e650b8ef5cdab7 | https://github.com/nathanhood/postcss-variable-media/blob/c8a761e6dc6d925309197e39e4e650b8ef5cdab7/index.js#L19-L31 |
50,480 | nathanhood/postcss-variable-media | index.js | convertBreakpointToMedia | function convertBreakpointToMedia(rule) {
rule.params = `(min-width: ${breakpoints[rule.name]}px)`;
rule.name = 'media';
rule.raws.afterName = ' ';
rule.raws.between = ' ';
return rule;
} | javascript | function convertBreakpointToMedia(rule) {
rule.params = `(min-width: ${breakpoints[rule.name]}px)`;
rule.name = 'media';
rule.raws.afterName = ' ';
rule.raws.between = ' ';
return rule;
} | [
"function",
"convertBreakpointToMedia",
"(",
"rule",
")",
"{",
"rule",
".",
"params",
"=",
"`",
"${",
"breakpoints",
"[",
"rule",
".",
"name",
"]",
"}",
"`",
";",
"rule",
".",
"name",
"=",
"'media'",
";",
"rule",
".",
"raws",
".",
"afterName",
"=",
"' '",
";",
"rule",
".",
"raws",
".",
"between",
"=",
"' '",
";",
"return",
"rule",
";",
"}"
] | Turn breakpoint to media
@param {postcss.Container} rule - AtRule
@returns {*} | [
"Turn",
"breakpoint",
"to",
"media"
] | c8a761e6dc6d925309197e39e4e650b8ef5cdab7 | https://github.com/nathanhood/postcss-variable-media/blob/c8a761e6dc6d925309197e39e4e650b8ef5cdab7/index.js#L39-L46 |
50,481 | nathanhood/postcss-variable-media | index.js | addToRegistry | function addToRegistry(rule) {
let name = rule.name;
if (registry.hasOwnProperty(name)) {
// `each` allows for safe looping while modifying the
// array being looped over. `append` is removing the rule
// from the array being looped over, so it is necessary
// to use this method instead of forEach
rule.each(r => registry[name].append(r));
} else {
registry[name] = rule.clone();
}
} | javascript | function addToRegistry(rule) {
let name = rule.name;
if (registry.hasOwnProperty(name)) {
// `each` allows for safe looping while modifying the
// array being looped over. `append` is removing the rule
// from the array being looped over, so it is necessary
// to use this method instead of forEach
rule.each(r => registry[name].append(r));
} else {
registry[name] = rule.clone();
}
} | [
"function",
"addToRegistry",
"(",
"rule",
")",
"{",
"let",
"name",
"=",
"rule",
".",
"name",
";",
"if",
"(",
"registry",
".",
"hasOwnProperty",
"(",
"name",
")",
")",
"{",
"// `each` allows for safe looping while modifying the",
"// array being looped over. `append` is removing the rule",
"// from the array being looped over, so it is necessary",
"// to use this method instead of forEach ",
"rule",
".",
"each",
"(",
"r",
"=>",
"registry",
"[",
"name",
"]",
".",
"append",
"(",
"r",
")",
")",
";",
"}",
"else",
"{",
"registry",
"[",
"name",
"]",
"=",
"rule",
".",
"clone",
"(",
")",
";",
"}",
"}"
] | Add breakpoint to registry
@param {object} rule - AtRule | [
"Add",
"breakpoint",
"to",
"registry"
] | c8a761e6dc6d925309197e39e4e650b8ef5cdab7 | https://github.com/nathanhood/postcss-variable-media/blob/c8a761e6dc6d925309197e39e4e650b8ef5cdab7/index.js#L53-L65 |
50,482 | gethuman/pancakes-hapi | lib/pancakes.hapi.web.js | processRoute | function processRoute(opts) {
if (routeHandler) {
routeHandler(opts.request, opts.reply, opts.urlOverride, opts.returnCode);
}
else {
opts.reply.continue();
}
} | javascript | function processRoute(opts) {
if (routeHandler) {
routeHandler(opts.request, opts.reply, opts.urlOverride, opts.returnCode);
}
else {
opts.reply.continue();
}
} | [
"function",
"processRoute",
"(",
"opts",
")",
"{",
"if",
"(",
"routeHandler",
")",
"{",
"routeHandler",
"(",
"opts",
".",
"request",
",",
"opts",
".",
"reply",
",",
"opts",
".",
"urlOverride",
",",
"opts",
".",
"returnCode",
")",
";",
"}",
"else",
"{",
"opts",
".",
"reply",
".",
"continue",
"(",
")",
";",
"}",
"}"
] | The idea here is to use the same request and reply
but a different route handler based on the given URL override | [
"The",
"idea",
"here",
"is",
"to",
"use",
"the",
"same",
"request",
"and",
"reply",
"but",
"a",
"different",
"route",
"handler",
"based",
"on",
"the",
"given",
"URL",
"override"
] | 1167cd7564cd8949c446c6fd8d95185f52b14492 | https://github.com/gethuman/pancakes-hapi/blob/1167cd7564cd8949c446c6fd8d95185f52b14492/lib/pancakes.hapi.web.js#L80-L87 |
50,483 | gethuman/pancakes-hapi | lib/pancakes.hapi.web.js | getServerPreProcessing | function getServerPreProcessing(request, reply) {
var me = this;
return function (routeInfo, page, model) {
if (!page.serverPreprocessing) { return false; }
var deps = { request: request, reply: reply, model: model, routeInfo: routeInfo };
return me.pancakes.cook(page.serverPreprocessing, { dependencies: deps });
};
} | javascript | function getServerPreProcessing(request, reply) {
var me = this;
return function (routeInfo, page, model) {
if (!page.serverPreprocessing) { return false; }
var deps = { request: request, reply: reply, model: model, routeInfo: routeInfo };
return me.pancakes.cook(page.serverPreprocessing, { dependencies: deps });
};
} | [
"function",
"getServerPreProcessing",
"(",
"request",
",",
"reply",
")",
"{",
"var",
"me",
"=",
"this",
";",
"return",
"function",
"(",
"routeInfo",
",",
"page",
",",
"model",
")",
"{",
"if",
"(",
"!",
"page",
".",
"serverPreprocessing",
")",
"{",
"return",
"false",
";",
"}",
"var",
"deps",
"=",
"{",
"request",
":",
"request",
",",
"reply",
":",
"reply",
",",
"model",
":",
"model",
",",
"routeInfo",
":",
"routeInfo",
"}",
";",
"return",
"me",
".",
"pancakes",
".",
"cook",
"(",
"page",
".",
"serverPreprocessing",
",",
"{",
"dependencies",
":",
"deps",
"}",
")",
";",
"}",
";",
"}"
] | Execute the server preprocessing method and return true if the preprocessor
handled the request
@param request
@param reply
@returns {Function} | [
"Execute",
"the",
"server",
"preprocessing",
"method",
"and",
"return",
"true",
"if",
"the",
"preprocessor",
"handled",
"the",
"request"
] | 1167cd7564cd8949c446c6fd8d95185f52b14492 | https://github.com/gethuman/pancakes-hapi/blob/1167cd7564cd8949c446c6fd8d95185f52b14492/lib/pancakes.hapi.web.js#L97-L106 |
50,484 | gethuman/pancakes-hapi | lib/pancakes.hapi.web.js | getWebRouteHandler | function getWebRouteHandler(opts) {
var webRouteHandler = this.pancakes.webRouteHandler;
var me = this;
return function handleWebRoute(request, reply, urlOverride, returnCode) {
var appName = request.app.name;
var url = urlOverride || request.url.pathname;
var routeInfo = null;
var referrer = request && request.headers && request.headers.referer ? request.headers.referer : '';
var routeHelper = me.pancakes.cook('routeHelper');
// var newrelic = require('newrelic');
Q.fcall(function () {
routeInfo = webRouteHandler.getRouteInfo(appName, url, request.query, request.app.lang, request.user, referrer);
// newrelic.setTransactionName(routeInfo.appName + '||' + routeInfo.lang + '||' + routeInfo.urlPattern);
// if redirect URL exists, just redirect right away
if (routeInfo.redirect) {
// make sure tokens in the redirect URL are replaced
var redirectUrl = routeInfo.redirect;
_.each(routeInfo.tokens, function (value, key) {
redirectUrl = redirectUrl.replace('{' + key + '}', value);
});
if (redirectUrl.indexOf('{') >= 0) {
//throw new Error('Redirect URL has token that was not replaced: ' + redirectUrl);
// we can't just throw errors in here
console.log('Bad redirect: ' + redirectUrl);
reply(new Error('So sorry, but there is an error here right now, and we are trying to fix it. Please try again later.'));
return new Q();
}
// do full url for all redirects
if (redirectUrl.indexOf('http') !== 0) {
redirectUrl = (routeHelper.getBaseUrl(routeInfo.appName) + '') + redirectUrl;
}
reply().redirect(redirectUrl).permanent(true);
return new Q();
}
// if the app is handling this request, don't do anything
if (opts.preProcess && opts.preProcess(request, reply)) {
return new Q();
}
var callbacks = {
serverPreprocessing: me.getServerPreProcessing(request, reply),
addToModel: opts.addToModel,
pageCacheService: opts.pageCacheService
};
return webRouteHandler.processWebRequest(routeInfo, callbacks)
.then(function (renderedPage) {
// if no rendered page, it means request was handled earlier somewhere (ex. serverPreprocess redirect)
if (!renderedPage) {
//console.log('No rendered page for ' + url);
return false;
}
var response = reply(renderedPage).code(returnCode || 200);
// add content type if in the route info
if (routeInfo.contentType) {
response.header('Content-Type', routeInfo.contentType);
}
// as long as the nocache attribute is NOT set, add cache headers (sorry for double negative :-))
if (!routeInfo.nocache) {
response.header('cache-control', 'public, max-age=60');
}
return true;
});
})
.catch(function (err) {
console.error(err);
reply(err);
});
};
} | javascript | function getWebRouteHandler(opts) {
var webRouteHandler = this.pancakes.webRouteHandler;
var me = this;
return function handleWebRoute(request, reply, urlOverride, returnCode) {
var appName = request.app.name;
var url = urlOverride || request.url.pathname;
var routeInfo = null;
var referrer = request && request.headers && request.headers.referer ? request.headers.referer : '';
var routeHelper = me.pancakes.cook('routeHelper');
// var newrelic = require('newrelic');
Q.fcall(function () {
routeInfo = webRouteHandler.getRouteInfo(appName, url, request.query, request.app.lang, request.user, referrer);
// newrelic.setTransactionName(routeInfo.appName + '||' + routeInfo.lang + '||' + routeInfo.urlPattern);
// if redirect URL exists, just redirect right away
if (routeInfo.redirect) {
// make sure tokens in the redirect URL are replaced
var redirectUrl = routeInfo.redirect;
_.each(routeInfo.tokens, function (value, key) {
redirectUrl = redirectUrl.replace('{' + key + '}', value);
});
if (redirectUrl.indexOf('{') >= 0) {
//throw new Error('Redirect URL has token that was not replaced: ' + redirectUrl);
// we can't just throw errors in here
console.log('Bad redirect: ' + redirectUrl);
reply(new Error('So sorry, but there is an error here right now, and we are trying to fix it. Please try again later.'));
return new Q();
}
// do full url for all redirects
if (redirectUrl.indexOf('http') !== 0) {
redirectUrl = (routeHelper.getBaseUrl(routeInfo.appName) + '') + redirectUrl;
}
reply().redirect(redirectUrl).permanent(true);
return new Q();
}
// if the app is handling this request, don't do anything
if (opts.preProcess && opts.preProcess(request, reply)) {
return new Q();
}
var callbacks = {
serverPreprocessing: me.getServerPreProcessing(request, reply),
addToModel: opts.addToModel,
pageCacheService: opts.pageCacheService
};
return webRouteHandler.processWebRequest(routeInfo, callbacks)
.then(function (renderedPage) {
// if no rendered page, it means request was handled earlier somewhere (ex. serverPreprocess redirect)
if (!renderedPage) {
//console.log('No rendered page for ' + url);
return false;
}
var response = reply(renderedPage).code(returnCode || 200);
// add content type if in the route info
if (routeInfo.contentType) {
response.header('Content-Type', routeInfo.contentType);
}
// as long as the nocache attribute is NOT set, add cache headers (sorry for double negative :-))
if (!routeInfo.nocache) {
response.header('cache-control', 'public, max-age=60');
}
return true;
});
})
.catch(function (err) {
console.error(err);
reply(err);
});
};
} | [
"function",
"getWebRouteHandler",
"(",
"opts",
")",
"{",
"var",
"webRouteHandler",
"=",
"this",
".",
"pancakes",
".",
"webRouteHandler",
";",
"var",
"me",
"=",
"this",
";",
"return",
"function",
"handleWebRoute",
"(",
"request",
",",
"reply",
",",
"urlOverride",
",",
"returnCode",
")",
"{",
"var",
"appName",
"=",
"request",
".",
"app",
".",
"name",
";",
"var",
"url",
"=",
"urlOverride",
"||",
"request",
".",
"url",
".",
"pathname",
";",
"var",
"routeInfo",
"=",
"null",
";",
"var",
"referrer",
"=",
"request",
"&&",
"request",
".",
"headers",
"&&",
"request",
".",
"headers",
".",
"referer",
"?",
"request",
".",
"headers",
".",
"referer",
":",
"''",
";",
"var",
"routeHelper",
"=",
"me",
".",
"pancakes",
".",
"cook",
"(",
"'routeHelper'",
")",
";",
"// var newrelic = require('newrelic');",
"Q",
".",
"fcall",
"(",
"function",
"(",
")",
"{",
"routeInfo",
"=",
"webRouteHandler",
".",
"getRouteInfo",
"(",
"appName",
",",
"url",
",",
"request",
".",
"query",
",",
"request",
".",
"app",
".",
"lang",
",",
"request",
".",
"user",
",",
"referrer",
")",
";",
"// newrelic.setTransactionName(routeInfo.appName + '||' + routeInfo.lang + '||' + routeInfo.urlPattern);",
"// if redirect URL exists, just redirect right away",
"if",
"(",
"routeInfo",
".",
"redirect",
")",
"{",
"// make sure tokens in the redirect URL are replaced",
"var",
"redirectUrl",
"=",
"routeInfo",
".",
"redirect",
";",
"_",
".",
"each",
"(",
"routeInfo",
".",
"tokens",
",",
"function",
"(",
"value",
",",
"key",
")",
"{",
"redirectUrl",
"=",
"redirectUrl",
".",
"replace",
"(",
"'{'",
"+",
"key",
"+",
"'}'",
",",
"value",
")",
";",
"}",
")",
";",
"if",
"(",
"redirectUrl",
".",
"indexOf",
"(",
"'{'",
")",
">=",
"0",
")",
"{",
"//throw new Error('Redirect URL has token that was not replaced: ' + redirectUrl);",
"// we can't just throw errors in here",
"console",
".",
"log",
"(",
"'Bad redirect: '",
"+",
"redirectUrl",
")",
";",
"reply",
"(",
"new",
"Error",
"(",
"'So sorry, but there is an error here right now, and we are trying to fix it. Please try again later.'",
")",
")",
";",
"return",
"new",
"Q",
"(",
")",
";",
"}",
"// do full url for all redirects",
"if",
"(",
"redirectUrl",
".",
"indexOf",
"(",
"'http'",
")",
"!==",
"0",
")",
"{",
"redirectUrl",
"=",
"(",
"routeHelper",
".",
"getBaseUrl",
"(",
"routeInfo",
".",
"appName",
")",
"+",
"''",
")",
"+",
"redirectUrl",
";",
"}",
"reply",
"(",
")",
".",
"redirect",
"(",
"redirectUrl",
")",
".",
"permanent",
"(",
"true",
")",
";",
"return",
"new",
"Q",
"(",
")",
";",
"}",
"// if the app is handling this request, don't do anything",
"if",
"(",
"opts",
".",
"preProcess",
"&&",
"opts",
".",
"preProcess",
"(",
"request",
",",
"reply",
")",
")",
"{",
"return",
"new",
"Q",
"(",
")",
";",
"}",
"var",
"callbacks",
"=",
"{",
"serverPreprocessing",
":",
"me",
".",
"getServerPreProcessing",
"(",
"request",
",",
"reply",
")",
",",
"addToModel",
":",
"opts",
".",
"addToModel",
",",
"pageCacheService",
":",
"opts",
".",
"pageCacheService",
"}",
";",
"return",
"webRouteHandler",
".",
"processWebRequest",
"(",
"routeInfo",
",",
"callbacks",
")",
".",
"then",
"(",
"function",
"(",
"renderedPage",
")",
"{",
"// if no rendered page, it means request was handled earlier somewhere (ex. serverPreprocess redirect)",
"if",
"(",
"!",
"renderedPage",
")",
"{",
"//console.log('No rendered page for ' + url);",
"return",
"false",
";",
"}",
"var",
"response",
"=",
"reply",
"(",
"renderedPage",
")",
".",
"code",
"(",
"returnCode",
"||",
"200",
")",
";",
"// add content type if in the route info",
"if",
"(",
"routeInfo",
".",
"contentType",
")",
"{",
"response",
".",
"header",
"(",
"'Content-Type'",
",",
"routeInfo",
".",
"contentType",
")",
";",
"}",
"// as long as the nocache attribute is NOT set, add cache headers (sorry for double negative :-))",
"if",
"(",
"!",
"routeInfo",
".",
"nocache",
")",
"{",
"response",
".",
"header",
"(",
"'cache-control'",
",",
"'public, max-age=60'",
")",
";",
"}",
"return",
"true",
";",
"}",
")",
";",
"}",
")",
".",
"catch",
"(",
"function",
"(",
"err",
")",
"{",
"console",
".",
"error",
"(",
"err",
")",
";",
"reply",
"(",
"err",
")",
";",
"}",
")",
";",
"}",
";",
"}"
] | Render the web route for one of the dynamic routes. These routes are based off of
the .app config files for each app.
@param opts | [
"Render",
"the",
"web",
"route",
"for",
"one",
"of",
"the",
"dynamic",
"routes",
".",
"These",
"routes",
"are",
"based",
"off",
"of",
"the",
".",
"app",
"config",
"files",
"for",
"each",
"app",
"."
] | 1167cd7564cd8949c446c6fd8d95185f52b14492 | https://github.com/gethuman/pancakes-hapi/blob/1167cd7564cd8949c446c6fd8d95185f52b14492/lib/pancakes.hapi.web.js#L114-L196 |
50,485 | konfirm/node-wanted | lib/wanted.js | error | function error(message) {
if (EventEmitter.listenerCount(wanted, 'error') > 0) {
return wanted.emit('error', message);
}
throw new Error(message);
} | javascript | function error(message) {
if (EventEmitter.listenerCount(wanted, 'error') > 0) {
return wanted.emit('error', message);
}
throw new Error(message);
} | [
"function",
"error",
"(",
"message",
")",
"{",
"if",
"(",
"EventEmitter",
".",
"listenerCount",
"(",
"wanted",
",",
"'error'",
")",
">",
"0",
")",
"{",
"return",
"wanted",
".",
"emit",
"(",
"'error'",
",",
"message",
")",
";",
"}",
"throw",
"new",
"Error",
"(",
"message",
")",
";",
"}"
] | Trigger an error emission or throw it, depending on where a listener for error emission is present
@name error
@access internal
@param string message
@return void | [
"Trigger",
"an",
"error",
"emission",
"or",
"throw",
"it",
"depending",
"on",
"where",
"a",
"listener",
"for",
"error",
"emission",
"is",
"present"
] | 797cf41bde7bf67f74bcd59a97cc28ddb084e2ca | https://github.com/konfirm/node-wanted/blob/797cf41bde7bf67f74bcd59a97cc28ddb084e2ca/lib/wanted.js#L52-L58 |
50,486 | konfirm/node-wanted | lib/wanted.js | processed | function processed(module) {
pool.processed.push(module);
if (!module.installed) {
pool.install.push(module);
}
setImmediate(next);
} | javascript | function processed(module) {
pool.processed.push(module);
if (!module.installed) {
pool.install.push(module);
}
setImmediate(next);
} | [
"function",
"processed",
"(",
"module",
")",
"{",
"pool",
".",
"processed",
".",
"push",
"(",
"module",
")",
";",
"if",
"(",
"!",
"module",
".",
"installed",
")",
"{",
"pool",
".",
"install",
".",
"push",
"(",
"module",
")",
";",
"}",
"setImmediate",
"(",
"next",
")",
";",
"}"
] | Remove a module from the queue
@name processed
@access internal
@param object module
@return void | [
"Remove",
"a",
"module",
"from",
"the",
"queue"
] | 797cf41bde7bf67f74bcd59a97cc28ddb084e2ca | https://github.com/konfirm/node-wanted/blob/797cf41bde7bf67f74bcd59a97cc28ddb084e2ca/lib/wanted.js#L67-L75 |
50,487 | konfirm/node-wanted | lib/wanted.js | next | function next() {
var module;
if (pool.queue.length <= 0) {
if (pool.install.length) {
error('Update needed: ' + pool.install.map(function(module) {
return module.name;
}).join(', '));
}
else {
wanted.emit('ready', pool.processed.map(shallow));
}
return reset();
}
module = pool.queue.shift();
fileExists(module.path + '/package.json', function(file) {
var json;
if (file) {
json = require(file);
module.installed = json.version;
module.upgrade = !semver.satisfies(json.version, module.version);
}
if (!module.installed || module.upgrade) {
request(module);
}
else {
module.current = true;
wanted.emit('current', shallow(module));
processed(module);
}
});
} | javascript | function next() {
var module;
if (pool.queue.length <= 0) {
if (pool.install.length) {
error('Update needed: ' + pool.install.map(function(module) {
return module.name;
}).join(', '));
}
else {
wanted.emit('ready', pool.processed.map(shallow));
}
return reset();
}
module = pool.queue.shift();
fileExists(module.path + '/package.json', function(file) {
var json;
if (file) {
json = require(file);
module.installed = json.version;
module.upgrade = !semver.satisfies(json.version, module.version);
}
if (!module.installed || module.upgrade) {
request(module);
}
else {
module.current = true;
wanted.emit('current', shallow(module));
processed(module);
}
});
} | [
"function",
"next",
"(",
")",
"{",
"var",
"module",
";",
"if",
"(",
"pool",
".",
"queue",
".",
"length",
"<=",
"0",
")",
"{",
"if",
"(",
"pool",
".",
"install",
".",
"length",
")",
"{",
"error",
"(",
"'Update needed: '",
"+",
"pool",
".",
"install",
".",
"map",
"(",
"function",
"(",
"module",
")",
"{",
"return",
"module",
".",
"name",
";",
"}",
")",
".",
"join",
"(",
"', '",
")",
")",
";",
"}",
"else",
"{",
"wanted",
".",
"emit",
"(",
"'ready'",
",",
"pool",
".",
"processed",
".",
"map",
"(",
"shallow",
")",
")",
";",
"}",
"return",
"reset",
"(",
")",
";",
"}",
"module",
"=",
"pool",
".",
"queue",
".",
"shift",
"(",
")",
";",
"fileExists",
"(",
"module",
".",
"path",
"+",
"'/package.json'",
",",
"function",
"(",
"file",
")",
"{",
"var",
"json",
";",
"if",
"(",
"file",
")",
"{",
"json",
"=",
"require",
"(",
"file",
")",
";",
"module",
".",
"installed",
"=",
"json",
".",
"version",
";",
"module",
".",
"upgrade",
"=",
"!",
"semver",
".",
"satisfies",
"(",
"json",
".",
"version",
",",
"module",
".",
"version",
")",
";",
"}",
"if",
"(",
"!",
"module",
".",
"installed",
"||",
"module",
".",
"upgrade",
")",
"{",
"request",
"(",
"module",
")",
";",
"}",
"else",
"{",
"module",
".",
"current",
"=",
"true",
";",
"wanted",
".",
"emit",
"(",
"'current'",
",",
"shallow",
"(",
"module",
")",
")",
";",
"processed",
"(",
"module",
")",
";",
"}",
"}",
")",
";",
"}"
] | Pick the next item from the queue and process it
@name next
@return void | [
"Pick",
"the",
"next",
"item",
"from",
"the",
"queue",
"and",
"process",
"it"
] | 797cf41bde7bf67f74bcd59a97cc28ddb084e2ca | https://github.com/konfirm/node-wanted/blob/797cf41bde7bf67f74bcd59a97cc28ddb084e2ca/lib/wanted.js#L82-L119 |
50,488 | konfirm/node-wanted | lib/wanted.js | fileExists | function fileExists(file, handle) {
fs.exists(file, function(exists) {
handle.apply(null, exists ? [file] : []);
});
} | javascript | function fileExists(file, handle) {
fs.exists(file, function(exists) {
handle.apply(null, exists ? [file] : []);
});
} | [
"function",
"fileExists",
"(",
"file",
",",
"handle",
")",
"{",
"fs",
".",
"exists",
"(",
"file",
",",
"function",
"(",
"exists",
")",
"{",
"handle",
".",
"apply",
"(",
"null",
",",
"exists",
"?",
"[",
"file",
"]",
":",
"[",
"]",
")",
";",
"}",
")",
";",
"}"
] | Simple wrapper around fs.exists, allowing us to provide the filename in case it does exist
@name fileExists
@access internal
@param string file
@param function handle
@return void | [
"Simple",
"wrapper",
"around",
"fs",
".",
"exists",
"allowing",
"us",
"to",
"provide",
"the",
"filename",
"in",
"case",
"it",
"does",
"exist"
] | 797cf41bde7bf67f74bcd59a97cc28ddb084e2ca | https://github.com/konfirm/node-wanted/blob/797cf41bde7bf67f74bcd59a97cc28ddb084e2ca/lib/wanted.js#L170-L174 |
50,489 | konfirm/node-wanted | lib/wanted.js | shallow | function shallow(module) {
return {
name: module.name,
version: module.version,
installed: module.installed,
scope: module.scope,
state: module.current ? 'current' : (module.upgrade ? 'upgrade' : 'install')
};
} | javascript | function shallow(module) {
return {
name: module.name,
version: module.version,
installed: module.installed,
scope: module.scope,
state: module.current ? 'current' : (module.upgrade ? 'upgrade' : 'install')
};
} | [
"function",
"shallow",
"(",
"module",
")",
"{",
"return",
"{",
"name",
":",
"module",
".",
"name",
",",
"version",
":",
"module",
".",
"version",
",",
"installed",
":",
"module",
".",
"installed",
",",
"scope",
":",
"module",
".",
"scope",
",",
"state",
":",
"module",
".",
"current",
"?",
"'current'",
":",
"(",
"module",
".",
"upgrade",
"?",
"'upgrade'",
":",
"'install'",
")",
"}",
";",
"}"
] | Reduce the internal module configuration for external exposure
@name shallow
@param Object module
@return Object shallow module | [
"Reduce",
"the",
"internal",
"module",
"configuration",
"for",
"external",
"exposure"
] | 797cf41bde7bf67f74bcd59a97cc28ddb084e2ca | https://github.com/konfirm/node-wanted/blob/797cf41bde7bf67f74bcd59a97cc28ddb084e2ca/lib/wanted.js#L255-L263 |
50,490 | syntheticore/declaire | src/bootstrap.js | function(name) {
var handler = function(e) {
//XXX add id to element
_declaireLog.push(e);
};
var html = document.getElementsByTagName('html')[0];
html.addEventListener(name, handler);
return handler;
} | javascript | function(name) {
var handler = function(e) {
//XXX add id to element
_declaireLog.push(e);
};
var html = document.getElementsByTagName('html')[0];
html.addEventListener(name, handler);
return handler;
} | [
"function",
"(",
"name",
")",
"{",
"var",
"handler",
"=",
"function",
"(",
"e",
")",
"{",
"//XXX add id to element",
"_declaireLog",
".",
"push",
"(",
"e",
")",
";",
"}",
";",
"var",
"html",
"=",
"document",
".",
"getElementsByTagName",
"(",
"'html'",
")",
"[",
"0",
"]",
";",
"html",
".",
"addEventListener",
"(",
"name",
",",
"handler",
")",
";",
"return",
"handler",
";",
"}"
] | Listen for events on html element and save these to the log | [
"Listen",
"for",
"events",
"on",
"html",
"element",
"and",
"save",
"these",
"to",
"the",
"log"
] | cb5ea205eeb3aa26fd0c6348e86d840c04e9ba9f | https://github.com/syntheticore/declaire/blob/cb5ea205eeb3aa26fd0c6348e86d840c04e9ba9f/src/bootstrap.js#L6-L14 |
|
50,491 | scrapjs/rela | lib/server.js | Server | function Server(opts){
// Shorthand, no "new" required.
if (!(this instanceof Server))
return new Server(...arguments);
if (typeof opts !== 'object')
opts = {};
this.clients = opts.dummies || [];
this.server = opts.server || new SocketServer(socket => {
let client = new Client(socket);
this.clients.push(client);
this.emit('connection', client);
client._socket.once('data', handshake.bind(client));
client.on('handshake-done', () => {
client._socket.on('data', message.bind(client));
});
});
} | javascript | function Server(opts){
// Shorthand, no "new" required.
if (!(this instanceof Server))
return new Server(...arguments);
if (typeof opts !== 'object')
opts = {};
this.clients = opts.dummies || [];
this.server = opts.server || new SocketServer(socket => {
let client = new Client(socket);
this.clients.push(client);
this.emit('connection', client);
client._socket.once('data', handshake.bind(client));
client.on('handshake-done', () => {
client._socket.on('data', message.bind(client));
});
});
} | [
"function",
"Server",
"(",
"opts",
")",
"{",
"// Shorthand, no \"new\" required.",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Server",
")",
")",
"return",
"new",
"Server",
"(",
"...",
"arguments",
")",
";",
"if",
"(",
"typeof",
"opts",
"!==",
"'object'",
")",
"opts",
"=",
"{",
"}",
";",
"this",
".",
"clients",
"=",
"opts",
".",
"dummies",
"||",
"[",
"]",
";",
"this",
".",
"server",
"=",
"opts",
".",
"server",
"||",
"new",
"SocketServer",
"(",
"socket",
"=>",
"{",
"let",
"client",
"=",
"new",
"Client",
"(",
"socket",
")",
";",
"this",
".",
"clients",
".",
"push",
"(",
"client",
")",
";",
"this",
".",
"emit",
"(",
"'connection'",
",",
"client",
")",
";",
"client",
".",
"_socket",
".",
"once",
"(",
"'data'",
",",
"handshake",
".",
"bind",
"(",
"client",
")",
")",
";",
"client",
".",
"on",
"(",
"'handshake-done'",
",",
"(",
")",
"=>",
"{",
"client",
".",
"_socket",
".",
"on",
"(",
"'data'",
",",
"message",
".",
"bind",
"(",
"client",
")",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}"
] | The server object, Rela. | [
"The",
"server",
"object",
"Rela",
"."
] | 7e3ed535fea68a3292bad9d9ce220360c45389e8 | https://github.com/scrapjs/rela/blob/7e3ed535fea68a3292bad9d9ce220360c45389e8/lib/server.js#L17-L37 |
50,492 | xiamidaxia/xiami | meteor/minimongo/selector_modifier.js | function (obj, keys) {
return _.all(obj, function (v, k) {
return _.contains(keys, k);
});
} | javascript | function (obj, keys) {
return _.all(obj, function (v, k) {
return _.contains(keys, k);
});
} | [
"function",
"(",
"obj",
",",
"keys",
")",
"{",
"return",
"_",
".",
"all",
"(",
"obj",
",",
"function",
"(",
"v",
",",
"k",
")",
"{",
"return",
"_",
".",
"contains",
"(",
"keys",
",",
"k",
")",
";",
"}",
")",
";",
"}"
] | A helper to ensure object has only certain keys | [
"A",
"helper",
"to",
"ensure",
"object",
"has",
"only",
"certain",
"keys"
] | 6fcee92c493c12bf8fd67c7068e67fa6a72a306b | https://github.com/xiamidaxia/xiami/blob/6fcee92c493c12bf8fd67c7068e67fa6a72a306b/meteor/minimongo/selector_modifier.js#L214-L218 |
|
50,493 | alexpods/ClazzJS | src/components/meta/Methods.js | function(clazz, metaData) {
this.applyMethods(clazz, metaData.clazz_methods || {});
this.applyMethods(clazz.prototype, metaData.methods || {});
} | javascript | function(clazz, metaData) {
this.applyMethods(clazz, metaData.clazz_methods || {});
this.applyMethods(clazz.prototype, metaData.methods || {});
} | [
"function",
"(",
"clazz",
",",
"metaData",
")",
"{",
"this",
".",
"applyMethods",
"(",
"clazz",
",",
"metaData",
".",
"clazz_methods",
"||",
"{",
"}",
")",
";",
"this",
".",
"applyMethods",
"(",
"clazz",
".",
"prototype",
",",
"metaData",
".",
"methods",
"||",
"{",
"}",
")",
";",
"}"
] | Applies methods to clazz and its prototype
@param {clazz} clazz Clazz
@param {object} metaData Meta data with properties 'methods' and 'clazz_methods'
@this {metaProcessor} | [
"Applies",
"methods",
"to",
"clazz",
"and",
"its",
"prototype"
] | 2f94496019669813c8246d48fcceb12a3e68a870 | https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Methods.js#L15-L18 |
|
50,494 | alexpods/ClazzJS | src/components/meta/Methods.js | function(object, methods) {
_.each(methods, function(method, name) {
if (!_.isFunction(method)) {
throw new Error('Method "' + name + '" must be a function!');
}
object[name] = method
});
} | javascript | function(object, methods) {
_.each(methods, function(method, name) {
if (!_.isFunction(method)) {
throw new Error('Method "' + name + '" must be a function!');
}
object[name] = method
});
} | [
"function",
"(",
"object",
",",
"methods",
")",
"{",
"_",
".",
"each",
"(",
"methods",
",",
"function",
"(",
"method",
",",
"name",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isFunction",
"(",
"method",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Method \"'",
"+",
"name",
"+",
"'\" must be a function!'",
")",
";",
"}",
"object",
"[",
"name",
"]",
"=",
"method",
"}",
")",
";",
"}"
] | Applies methods to specified object
@param {object} object Object for methods applying
@param {object} methods Hash of methods
@this {Error} if method is not a funciton
@this {metaProcessor} | [
"Applies",
"methods",
"to",
"specified",
"object"
] | 2f94496019669813c8246d48fcceb12a3e68a870 | https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Methods.js#L30-L37 |
|
50,495 | cli-kit/cli-locale | index.js | sanitize | function sanitize(lang, filter) {
if(!(typeof lang == 'string')) return lang;
lang = lang.replace(/\..*$/, '').toLowerCase();
if(typeof filter == 'function') {
lang = filter(lang);
}
return lang;
} | javascript | function sanitize(lang, filter) {
if(!(typeof lang == 'string')) return lang;
lang = lang.replace(/\..*$/, '').toLowerCase();
if(typeof filter == 'function') {
lang = filter(lang);
}
return lang;
} | [
"function",
"sanitize",
"(",
"lang",
",",
"filter",
")",
"{",
"if",
"(",
"!",
"(",
"typeof",
"lang",
"==",
"'string'",
")",
")",
"return",
"lang",
";",
"lang",
"=",
"lang",
".",
"replace",
"(",
"/",
"\\..*$",
"/",
",",
"''",
")",
".",
"toLowerCase",
"(",
")",
";",
"if",
"(",
"typeof",
"filter",
"==",
"'function'",
")",
"{",
"lang",
"=",
"filter",
"(",
"lang",
")",
";",
"}",
"return",
"lang",
";",
"}"
] | Sanitize the value of an LC variable removing any character
encoding portion, such that en_GB.UTF-8 becomes en_gb.
@param lang A language identifier extracted from an LC variable.
@param filter A filter function.
@return A sanitized language identifier. | [
"Sanitize",
"the",
"value",
"of",
"an",
"LC",
"variable",
"removing",
"any",
"character",
"encoding",
"portion",
"such",
"that",
"en_GB",
".",
"UTF",
"-",
"8",
"becomes",
"en_gb",
"."
] | 5e1c759d551207de80b4bd9206101df077f61a14 | https://github.com/cli-kit/cli-locale/blob/5e1c759d551207de80b4bd9206101df077f61a14/index.js#L12-L19 |
50,496 | cli-kit/cli-locale | index.js | find | function find(search, filter, strict) {
var lang, search = search || [], i, k, v, re = /^(LC_|LANG)/;
for(i = 0;i < search.length;i++) {
lang = sanitize(process.env[search[i]] || '', filter);
if(lang) return c(lang);
}
// nothing found in search array, find first available
for(k in process.env) {
v = process.env[k];
if(re.test(k) && v) {
lang = sanitize(v, filter);
if(lang) break;
}
}
if(!lang) lang = c(sanitize(process.env.LANG, filter));
return c(lang) || (!strict ? language : null);
} | javascript | function find(search, filter, strict) {
var lang, search = search || [], i, k, v, re = /^(LC_|LANG)/;
for(i = 0;i < search.length;i++) {
lang = sanitize(process.env[search[i]] || '', filter);
if(lang) return c(lang);
}
// nothing found in search array, find first available
for(k in process.env) {
v = process.env[k];
if(re.test(k) && v) {
lang = sanitize(v, filter);
if(lang) break;
}
}
if(!lang) lang = c(sanitize(process.env.LANG, filter));
return c(lang) || (!strict ? language : null);
} | [
"function",
"find",
"(",
"search",
",",
"filter",
",",
"strict",
")",
"{",
"var",
"lang",
",",
"search",
"=",
"search",
"||",
"[",
"]",
",",
"i",
",",
"k",
",",
"v",
",",
"re",
"=",
"/",
"^(LC_|LANG)",
"/",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"search",
".",
"length",
";",
"i",
"++",
")",
"{",
"lang",
"=",
"sanitize",
"(",
"process",
".",
"env",
"[",
"search",
"[",
"i",
"]",
"]",
"||",
"''",
",",
"filter",
")",
";",
"if",
"(",
"lang",
")",
"return",
"c",
"(",
"lang",
")",
";",
"}",
"// nothing found in search array, find first available",
"for",
"(",
"k",
"in",
"process",
".",
"env",
")",
"{",
"v",
"=",
"process",
".",
"env",
"[",
"k",
"]",
";",
"if",
"(",
"re",
".",
"test",
"(",
"k",
")",
"&&",
"v",
")",
"{",
"lang",
"=",
"sanitize",
"(",
"v",
",",
"filter",
")",
";",
"if",
"(",
"lang",
")",
"break",
";",
"}",
"}",
"if",
"(",
"!",
"lang",
")",
"lang",
"=",
"c",
"(",
"sanitize",
"(",
"process",
".",
"env",
".",
"LANG",
",",
"filter",
")",
")",
";",
"return",
"c",
"(",
"lang",
")",
"||",
"(",
"!",
"strict",
"?",
"language",
":",
"null",
")",
";",
"}"
] | Find the value of an LC environment variable and return a
sanitized represention of the locale.
If no variable value is found in the search array then this
method returns the first available LC variable.
@param search An array of LC variables to prefer.
@param filter A filter function.
@param strict A boolean indicating that the default language
should never be returned.
@return A language identifier. | [
"Find",
"the",
"value",
"of",
"an",
"LC",
"environment",
"variable",
"and",
"return",
"a",
"sanitized",
"represention",
"of",
"the",
"locale",
"."
] | 5e1c759d551207de80b4bd9206101df077f61a14 | https://github.com/cli-kit/cli-locale/blob/5e1c759d551207de80b4bd9206101df077f61a14/index.js#L45-L61 |
50,497 | aMarCruz/flatten-brunch-map | index.js | flattenBrunchMap | function flattenBrunchMap (sourceFile, compiled, sourceMap) {
let asString = false
let prevMap = sourceFile.map
let newMap = sourceMap
// make sure the current map is an object
if (prevMap && (typeof prevMap == 'string' || prevMap instanceof String)) {
prevMap = JSON.parse(prevMap)
}
const result = { data: compiled }
if (newMap) {
// make sure the new map is an object
if (typeof newMap == 'string' || newMap instanceof String) {
asString = true
} else {
newMap = JSON.stringify(sourceMap) // normalize
}
newMap = JSON.parse(newMap)
// check the required mappings property
if (typeof newMap.mappings != 'string') {
throw new Error('Source map to be applied is missing the "mappings" property')
}
// sources defaults to current source file
if (!newMap.sources || !newMap.sources[0]) {
newMap.sources = [sourceFile.path]
}
// have a valid previous map?
if (prevMap && prevMap.mappings) {
if (!newMap.file && prevMap.file) {
newMap.file = prevMap.file
}
result.map = transfer(newMap, prevMap, asString)
} else {
// return the received source map already normalized
result.map = asString ? JSON.stringify(newMap) : newMap
}
} else if (prevMap) {
// no new map, return the previous source map as-is
result.map = sourceFile.map
}
return result
} | javascript | function flattenBrunchMap (sourceFile, compiled, sourceMap) {
let asString = false
let prevMap = sourceFile.map
let newMap = sourceMap
// make sure the current map is an object
if (prevMap && (typeof prevMap == 'string' || prevMap instanceof String)) {
prevMap = JSON.parse(prevMap)
}
const result = { data: compiled }
if (newMap) {
// make sure the new map is an object
if (typeof newMap == 'string' || newMap instanceof String) {
asString = true
} else {
newMap = JSON.stringify(sourceMap) // normalize
}
newMap = JSON.parse(newMap)
// check the required mappings property
if (typeof newMap.mappings != 'string') {
throw new Error('Source map to be applied is missing the "mappings" property')
}
// sources defaults to current source file
if (!newMap.sources || !newMap.sources[0]) {
newMap.sources = [sourceFile.path]
}
// have a valid previous map?
if (prevMap && prevMap.mappings) {
if (!newMap.file && prevMap.file) {
newMap.file = prevMap.file
}
result.map = transfer(newMap, prevMap, asString)
} else {
// return the received source map already normalized
result.map = asString ? JSON.stringify(newMap) : newMap
}
} else if (prevMap) {
// no new map, return the previous source map as-is
result.map = sourceFile.map
}
return result
} | [
"function",
"flattenBrunchMap",
"(",
"sourceFile",
",",
"compiled",
",",
"sourceMap",
")",
"{",
"let",
"asString",
"=",
"false",
"let",
"prevMap",
"=",
"sourceFile",
".",
"map",
"let",
"newMap",
"=",
"sourceMap",
"// make sure the current map is an object",
"if",
"(",
"prevMap",
"&&",
"(",
"typeof",
"prevMap",
"==",
"'string'",
"||",
"prevMap",
"instanceof",
"String",
")",
")",
"{",
"prevMap",
"=",
"JSON",
".",
"parse",
"(",
"prevMap",
")",
"}",
"const",
"result",
"=",
"{",
"data",
":",
"compiled",
"}",
"if",
"(",
"newMap",
")",
"{",
"// make sure the new map is an object",
"if",
"(",
"typeof",
"newMap",
"==",
"'string'",
"||",
"newMap",
"instanceof",
"String",
")",
"{",
"asString",
"=",
"true",
"}",
"else",
"{",
"newMap",
"=",
"JSON",
".",
"stringify",
"(",
"sourceMap",
")",
"// normalize",
"}",
"newMap",
"=",
"JSON",
".",
"parse",
"(",
"newMap",
")",
"// check the required mappings property",
"if",
"(",
"typeof",
"newMap",
".",
"mappings",
"!=",
"'string'",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Source map to be applied is missing the \"mappings\" property'",
")",
"}",
"// sources defaults to current source file",
"if",
"(",
"!",
"newMap",
".",
"sources",
"||",
"!",
"newMap",
".",
"sources",
"[",
"0",
"]",
")",
"{",
"newMap",
".",
"sources",
"=",
"[",
"sourceFile",
".",
"path",
"]",
"}",
"// have a valid previous map?",
"if",
"(",
"prevMap",
"&&",
"prevMap",
".",
"mappings",
")",
"{",
"if",
"(",
"!",
"newMap",
".",
"file",
"&&",
"prevMap",
".",
"file",
")",
"{",
"newMap",
".",
"file",
"=",
"prevMap",
".",
"file",
"}",
"result",
".",
"map",
"=",
"transfer",
"(",
"newMap",
",",
"prevMap",
",",
"asString",
")",
"}",
"else",
"{",
"// return the received source map already normalized",
"result",
".",
"map",
"=",
"asString",
"?",
"JSON",
".",
"stringify",
"(",
"newMap",
")",
":",
"newMap",
"}",
"}",
"else",
"if",
"(",
"prevMap",
")",
"{",
"// no new map, return the previous source map as-is",
"result",
".",
"map",
"=",
"sourceFile",
".",
"map",
"}",
"return",
"result",
"}"
] | Return a re-mapped source map string
@param {object} [sourceFile] - The param received by the plugin
@param {string} compiled - Processed or compiled code
@param {object|string} sourceMap - Generated source map
@returns {object} The resulting file object with flatten source map, if any. | [
"Return",
"a",
"re",
"-",
"mapped",
"source",
"map",
"string"
] | 4b37048700403bf74b7bc1e76f26e82e6b973356 | https://github.com/aMarCruz/flatten-brunch-map/blob/4b37048700403bf74b7bc1e76f26e82e6b973356/index.js#L46-L97 |
50,498 | iwillwen/watchman.js | dist/watchman.js | pathToRegExp | function pathToRegExp(path) {
if (path instanceof RegExp) {
return {
keys: [],
regexp: path
};
}
if (path instanceof Array) {
path = '(' + path.join('|') + ')';
}
var rtn = {
keys: [],
regexp: null
};
rtn.regexp = new RegExp((isHashRouter(path) ? '' : '^') + path.replace(/([\/\(]+):/g, '(?:').replace(/\(\?:(\w+)((\(.*?\))*)/g, function (_, key, optional) {
rtn.keys.push(key);
var match = null;
if (optional) {
match = optional.replace(/\(|\)/g, '');
} else {
match = '/?([^/]+)';
}
return '(?:' + match + '?)';
})
// fix double closing brackets, are there any better cases?
// make a commit and send us a pull request. XD
.replace('))', ')').replace(/\*/g, '(.*)') + '((#.+)?)$', 'i');
return rtn;
} | javascript | function pathToRegExp(path) {
if (path instanceof RegExp) {
return {
keys: [],
regexp: path
};
}
if (path instanceof Array) {
path = '(' + path.join('|') + ')';
}
var rtn = {
keys: [],
regexp: null
};
rtn.regexp = new RegExp((isHashRouter(path) ? '' : '^') + path.replace(/([\/\(]+):/g, '(?:').replace(/\(\?:(\w+)((\(.*?\))*)/g, function (_, key, optional) {
rtn.keys.push(key);
var match = null;
if (optional) {
match = optional.replace(/\(|\)/g, '');
} else {
match = '/?([^/]+)';
}
return '(?:' + match + '?)';
})
// fix double closing brackets, are there any better cases?
// make a commit and send us a pull request. XD
.replace('))', ')').replace(/\*/g, '(.*)') + '((#.+)?)$', 'i');
return rtn;
} | [
"function",
"pathToRegExp",
"(",
"path",
")",
"{",
"if",
"(",
"path",
"instanceof",
"RegExp",
")",
"{",
"return",
"{",
"keys",
":",
"[",
"]",
",",
"regexp",
":",
"path",
"}",
";",
"}",
"if",
"(",
"path",
"instanceof",
"Array",
")",
"{",
"path",
"=",
"'('",
"+",
"path",
".",
"join",
"(",
"'|'",
")",
"+",
"')'",
";",
"}",
"var",
"rtn",
"=",
"{",
"keys",
":",
"[",
"]",
",",
"regexp",
":",
"null",
"}",
";",
"rtn",
".",
"regexp",
"=",
"new",
"RegExp",
"(",
"(",
"isHashRouter",
"(",
"path",
")",
"?",
"''",
":",
"'^'",
")",
"+",
"path",
".",
"replace",
"(",
"/",
"([\\/\\(]+):",
"/",
"g",
",",
"'(?:'",
")",
".",
"replace",
"(",
"/",
"\\(\\?:(\\w+)((\\(.*?\\))*)",
"/",
"g",
",",
"function",
"(",
"_",
",",
"key",
",",
"optional",
")",
"{",
"rtn",
".",
"keys",
".",
"push",
"(",
"key",
")",
";",
"var",
"match",
"=",
"null",
";",
"if",
"(",
"optional",
")",
"{",
"match",
"=",
"optional",
".",
"replace",
"(",
"/",
"\\(|\\)",
"/",
"g",
",",
"''",
")",
";",
"}",
"else",
"{",
"match",
"=",
"'/?([^/]+)'",
";",
"}",
"return",
"'(?:'",
"+",
"match",
"+",
"'?)'",
";",
"}",
")",
"// fix double closing brackets, are there any better cases?",
"// make a commit and send us a pull request. XD",
".",
"replace",
"(",
"'))'",
",",
"')'",
")",
".",
"replace",
"(",
"/",
"\\*",
"/",
"g",
",",
"'(.*)'",
")",
"+",
"'((#.+)?)$'",
",",
"'i'",
")",
";",
"return",
"rtn",
";",
"}"
] | Convert the path string to a RegExp object
@param {String} path path
@return {RegExp} RegExp object | [
"Convert",
"the",
"path",
"string",
"to",
"a",
"RegExp",
"object"
] | 54b380f53311aa03422cf7ce4e41a5fb7a2c067a | https://github.com/iwillwen/watchman.js/blob/54b380f53311aa03422cf7ce4e41a5fb7a2c067a/dist/watchman.js#L303-L334 |
50,499 | iwillwen/watchman.js | dist/watchman.js | paramsParser | function paramsParser(url, rule) {
var matches = rule.regexp.exec(url).slice(1);
var keys = rule.keys;
var params = {};
for (var i = 0; i < keys.length; i++) {
params[keys[i]] = matches[i];
}
return params;
} | javascript | function paramsParser(url, rule) {
var matches = rule.regexp.exec(url).slice(1);
var keys = rule.keys;
var params = {};
for (var i = 0; i < keys.length; i++) {
params[keys[i]] = matches[i];
}
return params;
} | [
"function",
"paramsParser",
"(",
"url",
",",
"rule",
")",
"{",
"var",
"matches",
"=",
"rule",
".",
"regexp",
".",
"exec",
"(",
"url",
")",
".",
"slice",
"(",
"1",
")",
";",
"var",
"keys",
"=",
"rule",
".",
"keys",
";",
"var",
"params",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
"length",
";",
"i",
"++",
")",
"{",
"params",
"[",
"keys",
"[",
"i",
"]",
"]",
"=",
"matches",
"[",
"i",
"]",
";",
"}",
"return",
"params",
";",
"}"
] | url params parser
@param {String} url current url
@param {Object} rule matched rule
@return {Object} params | [
"url",
"params",
"parser"
] | 54b380f53311aa03422cf7ce4e41a5fb7a2c067a | https://github.com/iwillwen/watchman.js/blob/54b380f53311aa03422cf7ce4e41a5fb7a2c067a/dist/watchman.js#L402-L412 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.