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
|
---|---|---|---|---|---|---|---|---|---|---|---|
51,100 | wunderbyte/grunt-spiritual-edbml | tasks/things/outliner.js | parse | function parse(script, options, macros) {
var name = script.attr('id');
var text = script.text();
var atts = assistant.directives(script);
return compile(name, text, options, macros, atts);
} | javascript | function parse(script, options, macros) {
var name = script.attr('id');
var text = script.text();
var atts = assistant.directives(script);
return compile(name, text, options, macros, atts);
} | [
"function",
"parse",
"(",
"script",
",",
"options",
",",
"macros",
")",
"{",
"var",
"name",
"=",
"script",
".",
"attr",
"(",
"'id'",
")",
";",
"var",
"text",
"=",
"script",
".",
"text",
"(",
")",
";",
"var",
"atts",
"=",
"assistant",
".",
"directives",
"(",
"script",
")",
";",
"return",
"compile",
"(",
"name",
",",
"text",
",",
"options",
",",
"macros",
",",
"atts",
")",
";",
"}"
] | Parse single script.
@param {$} script
@param {???} macros
@returns {string} | [
"Parse",
"single",
"script",
"."
] | 2ba0aa8042eceee917f1ee48c7881345df3bce46 | https://github.com/wunderbyte/grunt-spiritual-edbml/blob/2ba0aa8042eceee917f1ee48c7881345df3bce46/tasks/things/outliner.js#L120-L125 |
51,101 | wunderbyte/grunt-spiritual-edbml | tasks/things/outliner.js | compile | function compile(name, edbml, options, macros, directives) {
var result = compiler.compile(edbml, options, macros, directives);
return assistant.declare(name, result);
} | javascript | function compile(name, edbml, options, macros, directives) {
var result = compiler.compile(edbml, options, macros, directives);
return assistant.declare(name, result);
} | [
"function",
"compile",
"(",
"name",
",",
"edbml",
",",
"options",
",",
"macros",
",",
"directives",
")",
"{",
"var",
"result",
"=",
"compiler",
".",
"compile",
"(",
"edbml",
",",
"options",
",",
"macros",
",",
"directives",
")",
";",
"return",
"assistant",
".",
"declare",
"(",
"name",
",",
"result",
")",
";",
"}"
] | Compile EDBML to JS with directives.
@param {string} name
@param {string} edbml
@param {Map<string,object>} options
@param {Map<string,object>} options | [
"Compile",
"EDBML",
"to",
"JS",
"with",
"directives",
"."
] | 2ba0aa8042eceee917f1ee48c7881345df3bce46 | https://github.com/wunderbyte/grunt-spiritual-edbml/blob/2ba0aa8042eceee917f1ee48c7881345df3bce46/tasks/things/outliner.js#L134-L137 |
51,102 | epeios-q37/xdhelcq | js/jqte/uncompressed/jquery-te-1.4.0.js | addParams | function addParams(name,command,key,tag,emphasis)
{
var thisCssNo = buttons.length+1;
return buttons.push({name:name, cls:thisCssNo, command:command, key:key, tag:tag, emphasis:emphasis});
} | javascript | function addParams(name,command,key,tag,emphasis)
{
var thisCssNo = buttons.length+1;
return buttons.push({name:name, cls:thisCssNo, command:command, key:key, tag:tag, emphasis:emphasis});
} | [
"function",
"addParams",
"(",
"name",
",",
"command",
",",
"key",
",",
"tag",
",",
"emphasis",
")",
"{",
"var",
"thisCssNo",
"=",
"buttons",
".",
"length",
"+",
"1",
";",
"return",
"buttons",
".",
"push",
"(",
"{",
"name",
":",
"name",
",",
"cls",
":",
"thisCssNo",
",",
"command",
":",
"command",
",",
"key",
":",
"key",
",",
"tag",
":",
"tag",
",",
"emphasis",
":",
"emphasis",
"}",
")",
";",
"}"
] | insertion function for parameters to toolbar | [
"insertion",
"function",
"for",
"parameters",
"to",
"toolbar"
] | 8cffac0650297c313779c9fba545096be24e52a5 | https://github.com/epeios-q37/xdhelcq/blob/8cffac0650297c313779c9fba545096be24e52a5/js/jqte/uncompressed/jquery-te-1.4.0.js#L118-L122 |
51,103 | epeios-q37/xdhelcq | js/jqte/uncompressed/jquery-te-1.4.0.js | selectionGet | function selectionGet()
{
// for webkit, mozilla, opera
if (window.getSelection)
return window.getSelection();
// for ie
else if (document.selection && document.selection.createRange && document.selection.type != "None")
return document.selection.createRange();
} | javascript | function selectionGet()
{
// for webkit, mozilla, opera
if (window.getSelection)
return window.getSelection();
// for ie
else if (document.selection && document.selection.createRange && document.selection.type != "None")
return document.selection.createRange();
} | [
"function",
"selectionGet",
"(",
")",
"{",
"// for webkit, mozilla, opera\r",
"if",
"(",
"window",
".",
"getSelection",
")",
"return",
"window",
".",
"getSelection",
"(",
")",
";",
"// for ie\r",
"else",
"if",
"(",
"document",
".",
"selection",
"&&",
"document",
".",
"selection",
".",
"createRange",
"&&",
"document",
".",
"selection",
".",
"type",
"!=",
"\"None\"",
")",
"return",
"document",
".",
"selection",
".",
"createRange",
"(",
")",
";",
"}"
] | get the selected text as plain format | [
"get",
"the",
"selected",
"text",
"as",
"plain",
"format"
] | 8cffac0650297c313779c9fba545096be24e52a5 | https://github.com/epeios-q37/xdhelcq/blob/8cffac0650297c313779c9fba545096be24e52a5/js/jqte/uncompressed/jquery-te-1.4.0.js#L391-L399 |
51,104 | epeios-q37/xdhelcq | js/jqte/uncompressed/jquery-te-1.4.0.js | selectionSet | function selectionSet(addCommand,thirdParam)
{
var range,
sel = selectionGet();
// for webkit, mozilla, opera
if (window.getSelection)
{
if (sel.anchorNode && sel.getRangeAt)
range = sel.getRangeAt(0);
if(range)
{
sel.removeAllRanges();
sel.addRange(range);
}
if(!thisBrowser.match(/msie/))
document.execCommand('StyleWithCSS', false, false);
document.execCommand(addCommand, false, thirdParam);
}
// for ie
else if (document.selection && document.selection.createRange && document.selection.type != "None")
{
range = document.selection.createRange();
range.execCommand(addCommand, false, thirdParam);
}
// change styles to around tags
affectStyleAround(false,false);
} | javascript | function selectionSet(addCommand,thirdParam)
{
var range,
sel = selectionGet();
// for webkit, mozilla, opera
if (window.getSelection)
{
if (sel.anchorNode && sel.getRangeAt)
range = sel.getRangeAt(0);
if(range)
{
sel.removeAllRanges();
sel.addRange(range);
}
if(!thisBrowser.match(/msie/))
document.execCommand('StyleWithCSS', false, false);
document.execCommand(addCommand, false, thirdParam);
}
// for ie
else if (document.selection && document.selection.createRange && document.selection.type != "None")
{
range = document.selection.createRange();
range.execCommand(addCommand, false, thirdParam);
}
// change styles to around tags
affectStyleAround(false,false);
} | [
"function",
"selectionSet",
"(",
"addCommand",
",",
"thirdParam",
")",
"{",
"var",
"range",
",",
"sel",
"=",
"selectionGet",
"(",
")",
";",
"// for webkit, mozilla, opera\r",
"if",
"(",
"window",
".",
"getSelection",
")",
"{",
"if",
"(",
"sel",
".",
"anchorNode",
"&&",
"sel",
".",
"getRangeAt",
")",
"range",
"=",
"sel",
".",
"getRangeAt",
"(",
"0",
")",
";",
"if",
"(",
"range",
")",
"{",
"sel",
".",
"removeAllRanges",
"(",
")",
";",
"sel",
".",
"addRange",
"(",
"range",
")",
";",
"}",
"if",
"(",
"!",
"thisBrowser",
".",
"match",
"(",
"/",
"msie",
"/",
")",
")",
"document",
".",
"execCommand",
"(",
"'StyleWithCSS'",
",",
"false",
",",
"false",
")",
";",
"document",
".",
"execCommand",
"(",
"addCommand",
",",
"false",
",",
"thirdParam",
")",
";",
"}",
"// for ie\r",
"else",
"if",
"(",
"document",
".",
"selection",
"&&",
"document",
".",
"selection",
".",
"createRange",
"&&",
"document",
".",
"selection",
".",
"type",
"!=",
"\"None\"",
")",
"{",
"range",
"=",
"document",
".",
"selection",
".",
"createRange",
"(",
")",
";",
"range",
".",
"execCommand",
"(",
"addCommand",
",",
"false",
",",
"thirdParam",
")",
";",
"}",
"// change styles to around tags\r",
"affectStyleAround",
"(",
"false",
",",
"false",
")",
";",
"}"
] | the function of changing to the selected text with "execCommand" method | [
"the",
"function",
"of",
"changing",
"to",
"the",
"selected",
"text",
"with",
"execCommand",
"method"
] | 8cffac0650297c313779c9fba545096be24e52a5 | https://github.com/epeios-q37/xdhelcq/blob/8cffac0650297c313779c9fba545096be24e52a5/js/jqte/uncompressed/jquery-te-1.4.0.js#L402-L434 |
51,105 | epeios-q37/xdhelcq | js/jqte/uncompressed/jquery-te-1.4.0.js | replaceSelection | function replaceSelection(tTag,tAttr,tVal) {
// first, prevent to conflict of different jqte editors
if(editor.not(":focus"))
editor.focus();
// for webkit, mozilla, opera
if (window.getSelection)
{
var selObj = selectionGet(), selRange, newElement, documentFragment;
if (selObj.anchorNode && selObj.getRangeAt)
{
selRange = selObj.getRangeAt(0);
// create to new element
newElement = document.createElement(tTag);
// add the attribute to the new element
$(newElement).attr(tAttr,tVal);
// extract to the selected text
documentFragment = selRange.extractContents();
// add the contents to the new element
newElement.appendChild(documentFragment);
selRange.insertNode(newElement);
selObj.removeAllRanges();
// if the attribute is "style", change styles to around tags
if(tAttr=="style")
affectStyleAround($(newElement),tVal);
// for other attributes
else
affectStyleAround($(newElement),false);
}
}
// for ie
else if (document.selection && document.selection.createRange && document.selection.type != "None")
{
var range = document.selection.createRange();
var selectedText = range.htmlText;
var newText = '<'+tTag+' '+tAttr+'="'+tVal+'">'+selectedText+'</'+tTag+'>';
document.selection.createRange().pasteHTML(newText);
}
} | javascript | function replaceSelection(tTag,tAttr,tVal) {
// first, prevent to conflict of different jqte editors
if(editor.not(":focus"))
editor.focus();
// for webkit, mozilla, opera
if (window.getSelection)
{
var selObj = selectionGet(), selRange, newElement, documentFragment;
if (selObj.anchorNode && selObj.getRangeAt)
{
selRange = selObj.getRangeAt(0);
// create to new element
newElement = document.createElement(tTag);
// add the attribute to the new element
$(newElement).attr(tAttr,tVal);
// extract to the selected text
documentFragment = selRange.extractContents();
// add the contents to the new element
newElement.appendChild(documentFragment);
selRange.insertNode(newElement);
selObj.removeAllRanges();
// if the attribute is "style", change styles to around tags
if(tAttr=="style")
affectStyleAround($(newElement),tVal);
// for other attributes
else
affectStyleAround($(newElement),false);
}
}
// for ie
else if (document.selection && document.selection.createRange && document.selection.type != "None")
{
var range = document.selection.createRange();
var selectedText = range.htmlText;
var newText = '<'+tTag+' '+tAttr+'="'+tVal+'">'+selectedText+'</'+tTag+'>';
document.selection.createRange().pasteHTML(newText);
}
} | [
"function",
"replaceSelection",
"(",
"tTag",
",",
"tAttr",
",",
"tVal",
")",
"{",
"// first, prevent to conflict of different jqte editors\r",
"if",
"(",
"editor",
".",
"not",
"(",
"\":focus\"",
")",
")",
"editor",
".",
"focus",
"(",
")",
";",
"// for webkit, mozilla, opera\t\t\t\r",
"if",
"(",
"window",
".",
"getSelection",
")",
"{",
"var",
"selObj",
"=",
"selectionGet",
"(",
")",
",",
"selRange",
",",
"newElement",
",",
"documentFragment",
";",
"if",
"(",
"selObj",
".",
"anchorNode",
"&&",
"selObj",
".",
"getRangeAt",
")",
"{",
"selRange",
"=",
"selObj",
".",
"getRangeAt",
"(",
"0",
")",
";",
"// create to new element\r",
"newElement",
"=",
"document",
".",
"createElement",
"(",
"tTag",
")",
";",
"// add the attribute to the new element\r",
"$",
"(",
"newElement",
")",
".",
"attr",
"(",
"tAttr",
",",
"tVal",
")",
";",
"// extract to the selected text\r",
"documentFragment",
"=",
"selRange",
".",
"extractContents",
"(",
")",
";",
"// add the contents to the new element\r",
"newElement",
".",
"appendChild",
"(",
"documentFragment",
")",
";",
"selRange",
".",
"insertNode",
"(",
"newElement",
")",
";",
"selObj",
".",
"removeAllRanges",
"(",
")",
";",
"// if the attribute is \"style\", change styles to around tags\r",
"if",
"(",
"tAttr",
"==",
"\"style\"",
")",
"affectStyleAround",
"(",
"$",
"(",
"newElement",
")",
",",
"tVal",
")",
";",
"// for other attributes\r",
"else",
"affectStyleAround",
"(",
"$",
"(",
"newElement",
")",
",",
"false",
")",
";",
"}",
"}",
"// for ie\r",
"else",
"if",
"(",
"document",
".",
"selection",
"&&",
"document",
".",
"selection",
".",
"createRange",
"&&",
"document",
".",
"selection",
".",
"type",
"!=",
"\"None\"",
")",
"{",
"var",
"range",
"=",
"document",
".",
"selection",
".",
"createRange",
"(",
")",
";",
"var",
"selectedText",
"=",
"range",
".",
"htmlText",
";",
"var",
"newText",
"=",
"'<'",
"+",
"tTag",
"+",
"' '",
"+",
"tAttr",
"+",
"'=\"'",
"+",
"tVal",
"+",
"'\">'",
"+",
"selectedText",
"+",
"'</'",
"+",
"tTag",
"+",
"'>'",
";",
"document",
".",
"selection",
".",
"createRange",
"(",
")",
".",
"pasteHTML",
"(",
"newText",
")",
";",
"}",
"}"
] | the function of changing to the selected text with tags and tags's attributes | [
"the",
"function",
"of",
"changing",
"to",
"the",
"selected",
"text",
"with",
"tags",
"and",
"tags",
"s",
"attributes"
] | 8cffac0650297c313779c9fba545096be24e52a5 | https://github.com/epeios-q37/xdhelcq/blob/8cffac0650297c313779c9fba545096be24e52a5/js/jqte/uncompressed/jquery-te-1.4.0.js#L437-L485 |
51,106 | epeios-q37/xdhelcq | js/jqte/uncompressed/jquery-te-1.4.0.js | function() {
var node,selection;
if(window.getSelection) {
selection = getSelection();
node = selection.anchorNode;
}
if(!node && document.selection && document.selection.createRange && document.selection.type != "None")
{
selection = document.selection;
var range = selection.getRangeAt ? selection.getRangeAt(0) : selection.createRange();
node = range.commonAncestorContainer ? range.commonAncestorContainer :
range.parentElement ? range.parentElement() : range.item(0);
}
if(node) {
return (node.nodeName == "#text" ? $(node.parentNode) : $(node));
}
else
return false;
} | javascript | function() {
var node,selection;
if(window.getSelection) {
selection = getSelection();
node = selection.anchorNode;
}
if(!node && document.selection && document.selection.createRange && document.selection.type != "None")
{
selection = document.selection;
var range = selection.getRangeAt ? selection.getRangeAt(0) : selection.createRange();
node = range.commonAncestorContainer ? range.commonAncestorContainer :
range.parentElement ? range.parentElement() : range.item(0);
}
if(node) {
return (node.nodeName == "#text" ? $(node.parentNode) : $(node));
}
else
return false;
} | [
"function",
"(",
")",
"{",
"var",
"node",
",",
"selection",
";",
"if",
"(",
"window",
".",
"getSelection",
")",
"{",
"selection",
"=",
"getSelection",
"(",
")",
";",
"node",
"=",
"selection",
".",
"anchorNode",
";",
"}",
"if",
"(",
"!",
"node",
"&&",
"document",
".",
"selection",
"&&",
"document",
".",
"selection",
".",
"createRange",
"&&",
"document",
".",
"selection",
".",
"type",
"!=",
"\"None\"",
")",
"{",
"selection",
"=",
"document",
".",
"selection",
";",
"var",
"range",
"=",
"selection",
".",
"getRangeAt",
"?",
"selection",
".",
"getRangeAt",
"(",
"0",
")",
":",
"selection",
".",
"createRange",
"(",
")",
";",
"node",
"=",
"range",
".",
"commonAncestorContainer",
"?",
"range",
".",
"commonAncestorContainer",
":",
"range",
".",
"parentElement",
"?",
"range",
".",
"parentElement",
"(",
")",
":",
"range",
".",
"item",
"(",
"0",
")",
";",
"}",
"if",
"(",
"node",
")",
"{",
"return",
"(",
"node",
".",
"nodeName",
"==",
"\"#text\"",
"?",
"$",
"(",
"node",
".",
"parentNode",
")",
":",
"$",
"(",
"node",
")",
")",
";",
"}",
"else",
"return",
"false",
";",
"}"
] | the function of getting to the parent tag | [
"the",
"function",
"of",
"getting",
"to",
"the",
"parent",
"tag"
] | 8cffac0650297c313779c9fba545096be24e52a5 | https://github.com/epeios-q37/xdhelcq/blob/8cffac0650297c313779c9fba545096be24e52a5/js/jqte/uncompressed/jquery-te-1.4.0.js#L488-L506 |
|
51,107 | epeios-q37/xdhelcq | js/jqte/uncompressed/jquery-te-1.4.0.js | selectText | function selectText(element)
{
if(element)
{
var element = element[0];
if (document.body.createTextRange)
{
var range = document.body.createTextRange();
range.moveToElementText(element);
range.select();
}
else if (window.getSelection)
{
var selection = window.getSelection();
var range = document.createRange();
if(element != "undefined" && element != null)
{
range.selectNodeContents(element);
selection.removeAllRanges();
selection.addRange(range);
if($(element).is(":empty"))
{
$(element).append(" ");
selectText($(element));
}
}
}
}
} | javascript | function selectText(element)
{
if(element)
{
var element = element[0];
if (document.body.createTextRange)
{
var range = document.body.createTextRange();
range.moveToElementText(element);
range.select();
}
else if (window.getSelection)
{
var selection = window.getSelection();
var range = document.createRange();
if(element != "undefined" && element != null)
{
range.selectNodeContents(element);
selection.removeAllRanges();
selection.addRange(range);
if($(element).is(":empty"))
{
$(element).append(" ");
selectText($(element));
}
}
}
}
} | [
"function",
"selectText",
"(",
"element",
")",
"{",
"if",
"(",
"element",
")",
"{",
"var",
"element",
"=",
"element",
"[",
"0",
"]",
";",
"if",
"(",
"document",
".",
"body",
".",
"createTextRange",
")",
"{",
"var",
"range",
"=",
"document",
".",
"body",
".",
"createTextRange",
"(",
")",
";",
"range",
".",
"moveToElementText",
"(",
"element",
")",
";",
"range",
".",
"select",
"(",
")",
";",
"}",
"else",
"if",
"(",
"window",
".",
"getSelection",
")",
"{",
"var",
"selection",
"=",
"window",
".",
"getSelection",
"(",
")",
";",
"var",
"range",
"=",
"document",
".",
"createRange",
"(",
")",
";",
"if",
"(",
"element",
"!=",
"\"undefined\"",
"&&",
"element",
"!=",
"null",
")",
"{",
"range",
".",
"selectNodeContents",
"(",
"element",
")",
";",
"selection",
".",
"removeAllRanges",
"(",
")",
";",
"selection",
".",
"addRange",
"(",
"range",
")",
";",
"if",
"(",
"$",
"(",
"element",
")",
".",
"is",
"(",
"\":empty\"",
")",
")",
"{",
"$",
"(",
"element",
")",
".",
"append",
"(",
"\" \"",
")",
";",
"selectText",
"(",
"$",
"(",
"element",
")",
")",
";",
"}",
"}",
"}",
"}",
"}"
] | the function of making selected to a element | [
"the",
"function",
"of",
"making",
"selected",
"to",
"a",
"element"
] | 8cffac0650297c313779c9fba545096be24e52a5 | https://github.com/epeios-q37/xdhelcq/blob/8cffac0650297c313779c9fba545096be24e52a5/js/jqte/uncompressed/jquery-te-1.4.0.js#L543-L575 |
51,108 | epeios-q37/xdhelcq | js/jqte/uncompressed/jquery-te-1.4.0.js | selected2link | function selected2link()
{
if(!toolbar.data("sourceOpened"))
{
var selectedTag = getSelectedNode(); // the selected node
var thisHrefLink = "http://"; // default the input value of the link-form-field
// display the link-form-field
linkAreaSwitch(true);
if(selectedTag)
{
var thisTagName = selectedTag.prop('tagName').toLowerCase();
// if tag name of the selected node is "a" and the selected node have "href" attribute
if(thisTagName == "a" && selectedTag.is('[href]'))
{
thisHrefLink = selectedTag.attr('href');
selectedTag.attr(setdatalink,"");
}
// if it don't have "a" tag name
else
replaceSelection("a",setdatalink,"");
}
else
linkinput.val(thisHrefLink).focus();
// the method of displaying-hiding to link-types
linktypeselect.click(function(e)
{
if($(e.target).hasClass(vars.css+"_linktypetext") || $(e.target).hasClass(vars.css+"_linktypearrow"))
linktypeSwitch(true);
});
// the method of selecting to link-types
linktypes.find("a").click(function()
{
var thisLinkType = $(this).attr(vars.css+"-linktype");
linktypes.data("linktype",thisLinkType)
linktypeview.find("."+vars.css+"_linktypetext").html(linktypes.find('a:eq('+linktypes.data("linktype")+')').text());
linkInputSet(thisHrefLink);
linktypeSwitch();
});
linkInputSet(thisHrefLink);
// the method of link-input
linkinput
// auto focus
.focus()
// update to value
.val(thisHrefLink)
// the event of key to enter in link-input
.bind("keypress keyup",function(e)
{
if(e.keyCode==13)
{
linkRecord(jQTE.find("["+setdatalink+"]"));
return false;
}
});
// the event of click link-button
linkbutton.click(function()
{
linkRecord(jQTE.find("["+setdatalink+"]"));
});
}
else
// hide the link-form-field
linkAreaSwitch(false);
} | javascript | function selected2link()
{
if(!toolbar.data("sourceOpened"))
{
var selectedTag = getSelectedNode(); // the selected node
var thisHrefLink = "http://"; // default the input value of the link-form-field
// display the link-form-field
linkAreaSwitch(true);
if(selectedTag)
{
var thisTagName = selectedTag.prop('tagName').toLowerCase();
// if tag name of the selected node is "a" and the selected node have "href" attribute
if(thisTagName == "a" && selectedTag.is('[href]'))
{
thisHrefLink = selectedTag.attr('href');
selectedTag.attr(setdatalink,"");
}
// if it don't have "a" tag name
else
replaceSelection("a",setdatalink,"");
}
else
linkinput.val(thisHrefLink).focus();
// the method of displaying-hiding to link-types
linktypeselect.click(function(e)
{
if($(e.target).hasClass(vars.css+"_linktypetext") || $(e.target).hasClass(vars.css+"_linktypearrow"))
linktypeSwitch(true);
});
// the method of selecting to link-types
linktypes.find("a").click(function()
{
var thisLinkType = $(this).attr(vars.css+"-linktype");
linktypes.data("linktype",thisLinkType)
linktypeview.find("."+vars.css+"_linktypetext").html(linktypes.find('a:eq('+linktypes.data("linktype")+')').text());
linkInputSet(thisHrefLink);
linktypeSwitch();
});
linkInputSet(thisHrefLink);
// the method of link-input
linkinput
// auto focus
.focus()
// update to value
.val(thisHrefLink)
// the event of key to enter in link-input
.bind("keypress keyup",function(e)
{
if(e.keyCode==13)
{
linkRecord(jQTE.find("["+setdatalink+"]"));
return false;
}
});
// the event of click link-button
linkbutton.click(function()
{
linkRecord(jQTE.find("["+setdatalink+"]"));
});
}
else
// hide the link-form-field
linkAreaSwitch(false);
} | [
"function",
"selected2link",
"(",
")",
"{",
"if",
"(",
"!",
"toolbar",
".",
"data",
"(",
"\"sourceOpened\"",
")",
")",
"{",
"var",
"selectedTag",
"=",
"getSelectedNode",
"(",
")",
";",
"// the selected node\r",
"var",
"thisHrefLink",
"=",
"\"http://\"",
";",
"// default the input value of the link-form-field\r",
"// display the link-form-field\r",
"linkAreaSwitch",
"(",
"true",
")",
";",
"if",
"(",
"selectedTag",
")",
"{",
"var",
"thisTagName",
"=",
"selectedTag",
".",
"prop",
"(",
"'tagName'",
")",
".",
"toLowerCase",
"(",
")",
";",
"// if tag name of the selected node is \"a\" and the selected node have \"href\" attribute\r",
"if",
"(",
"thisTagName",
"==",
"\"a\"",
"&&",
"selectedTag",
".",
"is",
"(",
"'[href]'",
")",
")",
"{",
"thisHrefLink",
"=",
"selectedTag",
".",
"attr",
"(",
"'href'",
")",
";",
"selectedTag",
".",
"attr",
"(",
"setdatalink",
",",
"\"\"",
")",
";",
"}",
"// if it don't have \"a\" tag name\r",
"else",
"replaceSelection",
"(",
"\"a\"",
",",
"setdatalink",
",",
"\"\"",
")",
";",
"}",
"else",
"linkinput",
".",
"val",
"(",
"thisHrefLink",
")",
".",
"focus",
"(",
")",
";",
"// the method of displaying-hiding to link-types\r",
"linktypeselect",
".",
"click",
"(",
"function",
"(",
"e",
")",
"{",
"if",
"(",
"$",
"(",
"e",
".",
"target",
")",
".",
"hasClass",
"(",
"vars",
".",
"css",
"+",
"\"_linktypetext\"",
")",
"||",
"$",
"(",
"e",
".",
"target",
")",
".",
"hasClass",
"(",
"vars",
".",
"css",
"+",
"\"_linktypearrow\"",
")",
")",
"linktypeSwitch",
"(",
"true",
")",
";",
"}",
")",
";",
"// the method of selecting to link-types\r",
"linktypes",
".",
"find",
"(",
"\"a\"",
")",
".",
"click",
"(",
"function",
"(",
")",
"{",
"var",
"thisLinkType",
"=",
"$",
"(",
"this",
")",
".",
"attr",
"(",
"vars",
".",
"css",
"+",
"\"-linktype\"",
")",
";",
"linktypes",
".",
"data",
"(",
"\"linktype\"",
",",
"thisLinkType",
")",
"linktypeview",
".",
"find",
"(",
"\".\"",
"+",
"vars",
".",
"css",
"+",
"\"_linktypetext\"",
")",
".",
"html",
"(",
"linktypes",
".",
"find",
"(",
"'a:eq('",
"+",
"linktypes",
".",
"data",
"(",
"\"linktype\"",
")",
"+",
"')'",
")",
".",
"text",
"(",
")",
")",
";",
"linkInputSet",
"(",
"thisHrefLink",
")",
";",
"linktypeSwitch",
"(",
")",
";",
"}",
")",
";",
"linkInputSet",
"(",
"thisHrefLink",
")",
";",
"// the method of link-input\r",
"linkinput",
"// auto focus\r",
".",
"focus",
"(",
")",
"// update to value\r",
".",
"val",
"(",
"thisHrefLink",
")",
"// the event of key to enter in link-input\r",
".",
"bind",
"(",
"\"keypress keyup\"",
",",
"function",
"(",
"e",
")",
"{",
"if",
"(",
"e",
".",
"keyCode",
"==",
"13",
")",
"{",
"linkRecord",
"(",
"jQTE",
".",
"find",
"(",
"\"[\"",
"+",
"setdatalink",
"+",
"\"]\"",
")",
")",
";",
"return",
"false",
";",
"}",
"}",
")",
";",
"// the event of click link-button\r",
"linkbutton",
".",
"click",
"(",
"function",
"(",
")",
"{",
"linkRecord",
"(",
"jQTE",
".",
"find",
"(",
"\"[\"",
"+",
"setdatalink",
"+",
"\"]\"",
")",
")",
";",
"}",
")",
";",
"}",
"else",
"// hide the link-form-field\r",
"linkAreaSwitch",
"(",
"false",
")",
";",
"}"
] | the function of converting text to link | [
"the",
"function",
"of",
"converting",
"text",
"to",
"link"
] | 8cffac0650297c313779c9fba545096be24e52a5 | https://github.com/epeios-q37/xdhelcq/blob/8cffac0650297c313779c9fba545096be24e52a5/js/jqte/uncompressed/jquery-te-1.4.0.js#L578-L656 |
51,109 | epeios-q37/xdhelcq | js/jqte/uncompressed/jquery-te-1.4.0.js | linkAreaSwitch | function linkAreaSwitch(status)
{
// remove all pre-link attribute (mark as "link will be added")
clearSetElement("["+setdatalink+"]:not([href])");
jQTE.find("["+setdatalink+"][href]").removeAttr(setdatalink);
if(status)
{
toolbar.data("linkOpened",true);
linkform.show();
}
else
{
toolbar.data("linkOpened",false);
linkform.hide();
}
linktypeSwitch();
} | javascript | function linkAreaSwitch(status)
{
// remove all pre-link attribute (mark as "link will be added")
clearSetElement("["+setdatalink+"]:not([href])");
jQTE.find("["+setdatalink+"][href]").removeAttr(setdatalink);
if(status)
{
toolbar.data("linkOpened",true);
linkform.show();
}
else
{
toolbar.data("linkOpened",false);
linkform.hide();
}
linktypeSwitch();
} | [
"function",
"linkAreaSwitch",
"(",
"status",
")",
"{",
"// remove all pre-link attribute (mark as \"link will be added\")\r",
"clearSetElement",
"(",
"\"[\"",
"+",
"setdatalink",
"+",
"\"]:not([href])\"",
")",
";",
"jQTE",
".",
"find",
"(",
"\"[\"",
"+",
"setdatalink",
"+",
"\"][href]\"",
")",
".",
"removeAttr",
"(",
"setdatalink",
")",
";",
"if",
"(",
"status",
")",
"{",
"toolbar",
".",
"data",
"(",
"\"linkOpened\"",
",",
"true",
")",
";",
"linkform",
".",
"show",
"(",
")",
";",
"}",
"else",
"{",
"toolbar",
".",
"data",
"(",
"\"linkOpened\"",
",",
"false",
")",
";",
"linkform",
".",
"hide",
"(",
")",
";",
"}",
"linktypeSwitch",
"(",
")",
";",
"}"
] | the function of switching link-form-field | [
"the",
"function",
"of",
"switching",
"link",
"-",
"form",
"-",
"field"
] | 8cffac0650297c313779c9fba545096be24e52a5 | https://github.com/epeios-q37/xdhelcq/blob/8cffac0650297c313779c9fba545096be24e52a5/js/jqte/uncompressed/jquery-te-1.4.0.js#L698-L716 |
51,110 | epeios-q37/xdhelcq | js/jqte/uncompressed/jquery-te-1.4.0.js | linkInputSet | function linkInputSet(thisHrefLink)
{
var currentType = linktypes.data("linktype");
// if selected type of e-mail
if(currentType=="1" && (linkinput.val()=="http://" || linkinput.is("[value^=http://]") || !linkinput.is("[value^=mailto]")))
linkinput.val("mailto:");
else if(currentType!="1" && !linkinput.is("[value^=http://]"))
linkinput.val("http://");
else
linkinput.val(thisHrefLink);
} | javascript | function linkInputSet(thisHrefLink)
{
var currentType = linktypes.data("linktype");
// if selected type of e-mail
if(currentType=="1" && (linkinput.val()=="http://" || linkinput.is("[value^=http://]") || !linkinput.is("[value^=mailto]")))
linkinput.val("mailto:");
else if(currentType!="1" && !linkinput.is("[value^=http://]"))
linkinput.val("http://");
else
linkinput.val(thisHrefLink);
} | [
"function",
"linkInputSet",
"(",
"thisHrefLink",
")",
"{",
"var",
"currentType",
"=",
"linktypes",
".",
"data",
"(",
"\"linktype\"",
")",
";",
"// if selected type of e-mail\r",
"if",
"(",
"currentType",
"==",
"\"1\"",
"&&",
"(",
"linkinput",
".",
"val",
"(",
")",
"==",
"\"http://\"",
"||",
"linkinput",
".",
"is",
"(",
"\"[value^=http://]\"",
")",
"||",
"!",
"linkinput",
".",
"is",
"(",
"\"[value^=mailto]\"",
")",
")",
")",
"linkinput",
".",
"val",
"(",
"\"mailto:\"",
")",
";",
"else",
"if",
"(",
"currentType",
"!=",
"\"1\"",
"&&",
"!",
"linkinput",
".",
"is",
"(",
"\"[value^=http://]\"",
")",
")",
"linkinput",
".",
"val",
"(",
"\"http://\"",
")",
";",
"else",
"linkinput",
".",
"val",
"(",
"thisHrefLink",
")",
";",
"}"
] | the function of updating the link-input according to the link-type | [
"the",
"function",
"of",
"updating",
"the",
"link",
"-",
"input",
"according",
"to",
"the",
"link",
"-",
"type"
] | 8cffac0650297c313779c9fba545096be24e52a5 | https://github.com/epeios-q37/xdhelcq/blob/8cffac0650297c313779c9fba545096be24e52a5/js/jqte/uncompressed/jquery-te-1.4.0.js#L728-L739 |
51,111 | epeios-q37/xdhelcq | js/jqte/uncompressed/jquery-te-1.4.0.js | refuseStyle | function refuseStyle(refStyle)
{
var selectedTag = getSelectedNode(); // the selected node
// if the selected node have attribute of "style" and it have unwanted style
if(selectedTag && selectedTag.is("[style]") && selectedTag.css(refStyle)!="")
{
var refValue = selectedTag.css(refStyle); // first get key of unwanted style
selectedTag.css(refStyle,""); // clear unwanted style
var cleanStyle = selectedTag.attr("style"); // cleaned style
selectedTag.css(refStyle,refValue); // add unwanted style to the selected node again
return cleanStyle; // print cleaned style
}
else
return "";
} | javascript | function refuseStyle(refStyle)
{
var selectedTag = getSelectedNode(); // the selected node
// if the selected node have attribute of "style" and it have unwanted style
if(selectedTag && selectedTag.is("[style]") && selectedTag.css(refStyle)!="")
{
var refValue = selectedTag.css(refStyle); // first get key of unwanted style
selectedTag.css(refStyle,""); // clear unwanted style
var cleanStyle = selectedTag.attr("style"); // cleaned style
selectedTag.css(refStyle,refValue); // add unwanted style to the selected node again
return cleanStyle; // print cleaned style
}
else
return "";
} | [
"function",
"refuseStyle",
"(",
"refStyle",
")",
"{",
"var",
"selectedTag",
"=",
"getSelectedNode",
"(",
")",
";",
"// the selected node\r",
"// if the selected node have attribute of \"style\" and it have unwanted style\r",
"if",
"(",
"selectedTag",
"&&",
"selectedTag",
".",
"is",
"(",
"\"[style]\"",
")",
"&&",
"selectedTag",
".",
"css",
"(",
"refStyle",
")",
"!=",
"\"\"",
")",
"{",
"var",
"refValue",
"=",
"selectedTag",
".",
"css",
"(",
"refStyle",
")",
";",
"// first get key of unwanted style\r",
"selectedTag",
".",
"css",
"(",
"refStyle",
",",
"\"\"",
")",
";",
"// clear unwanted style\r",
"var",
"cleanStyle",
"=",
"selectedTag",
".",
"attr",
"(",
"\"style\"",
")",
";",
"// cleaned style\r",
"selectedTag",
".",
"css",
"(",
"refStyle",
",",
"refValue",
")",
";",
"// add unwanted style to the selected node again\r",
"return",
"cleanStyle",
";",
"// print cleaned style\r",
"}",
"else",
"return",
"\"\"",
";",
"}"
] | the function of refusing some styles | [
"the",
"function",
"of",
"refusing",
"some",
"styles"
] | 8cffac0650297c313779c9fba545096be24e52a5 | https://github.com/epeios-q37/xdhelcq/blob/8cffac0650297c313779c9fba545096be24e52a5/js/jqte/uncompressed/jquery-te-1.4.0.js#L853-L872 |
51,112 | epeios-q37/xdhelcq | js/jqte/uncompressed/jquery-te-1.4.0.js | formatLabelView | function formatLabelView(str)
{
var formatLabel = formatbar.closest("."+vars.css+"_tool").find("."+vars.css+"_tool_label").find("."+vars.css+"_tool_text");
if(str.length > 10)
str = str.substr(0,7) + "...";
// change format label of button
formatLabel.html(str);
} | javascript | function formatLabelView(str)
{
var formatLabel = formatbar.closest("."+vars.css+"_tool").find("."+vars.css+"_tool_label").find("."+vars.css+"_tool_text");
if(str.length > 10)
str = str.substr(0,7) + "...";
// change format label of button
formatLabel.html(str);
} | [
"function",
"formatLabelView",
"(",
"str",
")",
"{",
"var",
"formatLabel",
"=",
"formatbar",
".",
"closest",
"(",
"\".\"",
"+",
"vars",
".",
"css",
"+",
"\"_tool\"",
")",
".",
"find",
"(",
"\".\"",
"+",
"vars",
".",
"css",
"+",
"\"_tool_label\"",
")",
".",
"find",
"(",
"\".\"",
"+",
"vars",
".",
"css",
"+",
"\"_tool_text\"",
")",
";",
"if",
"(",
"str",
".",
"length",
">",
"10",
")",
"str",
"=",
"str",
".",
"substr",
"(",
"0",
",",
"7",
")",
"+",
"\"...\"",
";",
"// change format label of button\r",
"formatLabel",
".",
"html",
"(",
"str",
")",
";",
"}"
] | change format label | [
"change",
"format",
"label"
] | 8cffac0650297c313779c9fba545096be24e52a5 | https://github.com/epeios-q37/xdhelcq/blob/8cffac0650297c313779c9fba545096be24e52a5/js/jqte/uncompressed/jquery-te-1.4.0.js#L912-L921 |
51,113 | epeios-q37/xdhelcq | js/jqte/uncompressed/jquery-te-1.4.0.js | extractToText | function extractToText(strings)
{
var $htmlContent, $htmlPattern, $htmlReplace;
// first remove to unnecessary gaps
$htmlContent = strings.replace(/\n/gim,'').replace(/\r/gim,'').replace(/\t/gim,'').replace(/ /gim,' ');
$htmlPattern = [
/\<span(|\s+.*?)><span(|\s+.*?)>(.*?)<\/span><\/span>/gim, // trim nested spans
/<(\w*[^p])\s*[^\/>]*>\s*<\/\1>/gim, // remove empty or white-spaces tags (ignore paragraphs (<p>) and breaks (<br>))
/\<div(|\s+.*?)>(.*?)\<\/div>/gim, // convert div to p
/\<strong(|\s+.*?)>(.*?)\<\/strong>/gim, // convert strong to b
/\<em(|\s+.*?)>(.*?)\<\/em>/gim // convert em to i
];
$htmlReplace = [
'<span$2>$3</span>',
'',
'<p$1>$2</p>',
'<b$1>$2</b>',
'<i$1>$2</i>'
];
// repeat the cleaning process 5 times
for(c=0; c<5; c++)
{
// create loop as the number of pattern
for(var i = 0; i < $htmlPattern.length; i++)
{
$htmlContent = $htmlContent.replace($htmlPattern[i], $htmlReplace[i]);
}
}
// if paragraph is false (<p>), convert <p> to <br>
if(!vars.p)
$htmlContent = $htmlContent.replace(/\<p(|\s+.*?)>(.*?)\<\/p>/ig, '<br/>$2');
// if break is false (<br>), convert <br> to <p>
if(!vars.br)
{
$htmlPattern = [
/\<br>(.*?)/ig,
/\<br\/>(.*?)/ig
];
$htmlReplace = [
'<p>$1</p>',
'<p>$1</p>'
];
// create loop as the number of pattern (for breaks)
for (var i = 0; i < $htmlPattern.length; i++) {
$htmlContent = $htmlContent.replace($htmlPattern[i], $htmlReplace[i]);
}
}
// if paragraph and break is false (<p> && <br>), convert <p> to <div>
if(!vars.p && !vars.br)
$htmlContent = $htmlContent.replace(/\<p>(.*?)\<\/p>/ig, '<div>$1</div>');
return $htmlContent;
} | javascript | function extractToText(strings)
{
var $htmlContent, $htmlPattern, $htmlReplace;
// first remove to unnecessary gaps
$htmlContent = strings.replace(/\n/gim,'').replace(/\r/gim,'').replace(/\t/gim,'').replace(/ /gim,' ');
$htmlPattern = [
/\<span(|\s+.*?)><span(|\s+.*?)>(.*?)<\/span><\/span>/gim, // trim nested spans
/<(\w*[^p])\s*[^\/>]*>\s*<\/\1>/gim, // remove empty or white-spaces tags (ignore paragraphs (<p>) and breaks (<br>))
/\<div(|\s+.*?)>(.*?)\<\/div>/gim, // convert div to p
/\<strong(|\s+.*?)>(.*?)\<\/strong>/gim, // convert strong to b
/\<em(|\s+.*?)>(.*?)\<\/em>/gim // convert em to i
];
$htmlReplace = [
'<span$2>$3</span>',
'',
'<p$1>$2</p>',
'<b$1>$2</b>',
'<i$1>$2</i>'
];
// repeat the cleaning process 5 times
for(c=0; c<5; c++)
{
// create loop as the number of pattern
for(var i = 0; i < $htmlPattern.length; i++)
{
$htmlContent = $htmlContent.replace($htmlPattern[i], $htmlReplace[i]);
}
}
// if paragraph is false (<p>), convert <p> to <br>
if(!vars.p)
$htmlContent = $htmlContent.replace(/\<p(|\s+.*?)>(.*?)\<\/p>/ig, '<br/>$2');
// if break is false (<br>), convert <br> to <p>
if(!vars.br)
{
$htmlPattern = [
/\<br>(.*?)/ig,
/\<br\/>(.*?)/ig
];
$htmlReplace = [
'<p>$1</p>',
'<p>$1</p>'
];
// create loop as the number of pattern (for breaks)
for (var i = 0; i < $htmlPattern.length; i++) {
$htmlContent = $htmlContent.replace($htmlPattern[i], $htmlReplace[i]);
}
}
// if paragraph and break is false (<p> && <br>), convert <p> to <div>
if(!vars.p && !vars.br)
$htmlContent = $htmlContent.replace(/\<p>(.*?)\<\/p>/ig, '<div>$1</div>');
return $htmlContent;
} | [
"function",
"extractToText",
"(",
"strings",
")",
"{",
"var",
"$htmlContent",
",",
"$htmlPattern",
",",
"$htmlReplace",
";",
"// first remove to unnecessary gaps\r",
"$htmlContent",
"=",
"strings",
".",
"replace",
"(",
"/",
"\\n",
"/",
"gim",
",",
"''",
")",
".",
"replace",
"(",
"/",
"\\r",
"/",
"gim",
",",
"''",
")",
".",
"replace",
"(",
"/",
"\\t",
"/",
"gim",
",",
"''",
")",
".",
"replace",
"(",
"/",
" ",
"/",
"gim",
",",
"' '",
")",
";",
"$htmlPattern",
"=",
"[",
"/",
"\\<span(|\\s+.*?)><span(|\\s+.*?)>(.*?)<\\/span><\\/span>",
"/",
"gim",
",",
"// trim nested spans\r",
"/",
"<(\\w*[^p])\\s*[^\\/>]*>\\s*<\\/\\1>",
"/",
"gim",
",",
"// remove empty or white-spaces tags (ignore paragraphs (<p>) and breaks (<br>))\r",
"/",
"\\<div(|\\s+.*?)>(.*?)\\<\\/div>",
"/",
"gim",
",",
"// convert div to p\r",
"/",
"\\<strong(|\\s+.*?)>(.*?)\\<\\/strong>",
"/",
"gim",
",",
"// convert strong to b\r",
"/",
"\\<em(|\\s+.*?)>(.*?)\\<\\/em>",
"/",
"gim",
"// convert em to i\r",
"]",
";",
"$htmlReplace",
"=",
"[",
"'<span$2>$3</span>'",
",",
"''",
",",
"'<p$1>$2</p>'",
",",
"'<b$1>$2</b>'",
",",
"'<i$1>$2</i>'",
"]",
";",
"// repeat the cleaning process 5 times\r",
"for",
"(",
"c",
"=",
"0",
";",
"c",
"<",
"5",
";",
"c",
"++",
")",
"{",
"// create loop as the number of pattern\r",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"$htmlPattern",
".",
"length",
";",
"i",
"++",
")",
"{",
"$htmlContent",
"=",
"$htmlContent",
".",
"replace",
"(",
"$htmlPattern",
"[",
"i",
"]",
",",
"$htmlReplace",
"[",
"i",
"]",
")",
";",
"}",
"}",
"// if paragraph is false (<p>), convert <p> to <br>\r",
"if",
"(",
"!",
"vars",
".",
"p",
")",
"$htmlContent",
"=",
"$htmlContent",
".",
"replace",
"(",
"/",
"\\<p(|\\s+.*?)>(.*?)\\<\\/p>",
"/",
"ig",
",",
"'<br/>$2'",
")",
";",
"// if break is false (<br>), convert <br> to <p>\r",
"if",
"(",
"!",
"vars",
".",
"br",
")",
"{",
"$htmlPattern",
"=",
"[",
"/",
"\\<br>(.*?)",
"/",
"ig",
",",
"/",
"\\<br\\/>(.*?)",
"/",
"ig",
"]",
";",
"$htmlReplace",
"=",
"[",
"'<p>$1</p>'",
",",
"'<p>$1</p>'",
"]",
";",
"// create loop as the number of pattern (for breaks)\r",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"$htmlPattern",
".",
"length",
";",
"i",
"++",
")",
"{",
"$htmlContent",
"=",
"$htmlContent",
".",
"replace",
"(",
"$htmlPattern",
"[",
"i",
"]",
",",
"$htmlReplace",
"[",
"i",
"]",
")",
";",
"}",
"}",
"// if paragraph and break is false (<p> && <br>), convert <p> to <div>\r",
"if",
"(",
"!",
"vars",
".",
"p",
"&&",
"!",
"vars",
".",
"br",
")",
"$htmlContent",
"=",
"$htmlContent",
".",
"replace",
"(",
"/",
"\\<p>(.*?)\\<\\/p>",
"/",
"ig",
",",
"'<div>$1</div>'",
")",
";",
"return",
"$htmlContent",
";",
"}"
] | the function of insertion a specific form to texts | [
"the",
"function",
"of",
"insertion",
"a",
"specific",
"form",
"to",
"texts"
] | 8cffac0650297c313779c9fba545096be24e52a5 | https://github.com/epeios-q37/xdhelcq/blob/8cffac0650297c313779c9fba545096be24e52a5/js/jqte/uncompressed/jquery-te-1.4.0.js#L924-L985 |
51,114 | epeios-q37/xdhelcq | js/jqte/uncompressed/jquery-te-1.4.0.js | buttonEmphasize | function buttonEmphasize(e)
{
for(var n = 0; n < buttons.length; n++)
{
if(vars[buttons[n].name] && buttons[n].emphasis && buttons[n].tag!='')
detectElement(buttons[n].tag) ? toolbar.find('.'+vars.css+'_tool_'+buttons[n].cls).addClass(emphasize) : $('.'+vars.css+'_tool_'+buttons[n].cls).removeClass(emphasize);
}
// showing text format
if(vars.format && $.isArray(vars.formats))
{
var isFoundFormat = false;
for(var f = 0; f < vars.formats.length; f++)
{
var thisFormat = [];
thisFormat[0] = vars.formats[f][0];
if(vars.formats[f][0].length>0 && detectElement(thisFormat))
{
formatLabelView(vars.formats[f][1]);
isFoundFormat = true;
break;
}
}
if(!isFoundFormat)
formatLabelView(vars.formats[0][1]);
}
// hide all style-fields
styleFieldSwitch("",false);
formatFieldSwitch(false);
} | javascript | function buttonEmphasize(e)
{
for(var n = 0; n < buttons.length; n++)
{
if(vars[buttons[n].name] && buttons[n].emphasis && buttons[n].tag!='')
detectElement(buttons[n].tag) ? toolbar.find('.'+vars.css+'_tool_'+buttons[n].cls).addClass(emphasize) : $('.'+vars.css+'_tool_'+buttons[n].cls).removeClass(emphasize);
}
// showing text format
if(vars.format && $.isArray(vars.formats))
{
var isFoundFormat = false;
for(var f = 0; f < vars.formats.length; f++)
{
var thisFormat = [];
thisFormat[0] = vars.formats[f][0];
if(vars.formats[f][0].length>0 && detectElement(thisFormat))
{
formatLabelView(vars.formats[f][1]);
isFoundFormat = true;
break;
}
}
if(!isFoundFormat)
formatLabelView(vars.formats[0][1]);
}
// hide all style-fields
styleFieldSwitch("",false);
formatFieldSwitch(false);
} | [
"function",
"buttonEmphasize",
"(",
"e",
")",
"{",
"for",
"(",
"var",
"n",
"=",
"0",
";",
"n",
"<",
"buttons",
".",
"length",
";",
"n",
"++",
")",
"{",
"if",
"(",
"vars",
"[",
"buttons",
"[",
"n",
"]",
".",
"name",
"]",
"&&",
"buttons",
"[",
"n",
"]",
".",
"emphasis",
"&&",
"buttons",
"[",
"n",
"]",
".",
"tag",
"!=",
"''",
")",
"detectElement",
"(",
"buttons",
"[",
"n",
"]",
".",
"tag",
")",
"?",
"toolbar",
".",
"find",
"(",
"'.'",
"+",
"vars",
".",
"css",
"+",
"'_tool_'",
"+",
"buttons",
"[",
"n",
"]",
".",
"cls",
")",
".",
"addClass",
"(",
"emphasize",
")",
":",
"$",
"(",
"'.'",
"+",
"vars",
".",
"css",
"+",
"'_tool_'",
"+",
"buttons",
"[",
"n",
"]",
".",
"cls",
")",
".",
"removeClass",
"(",
"emphasize",
")",
";",
"}",
"// showing text format\r",
"if",
"(",
"vars",
".",
"format",
"&&",
"$",
".",
"isArray",
"(",
"vars",
".",
"formats",
")",
")",
"{",
"var",
"isFoundFormat",
"=",
"false",
";",
"for",
"(",
"var",
"f",
"=",
"0",
";",
"f",
"<",
"vars",
".",
"formats",
".",
"length",
";",
"f",
"++",
")",
"{",
"var",
"thisFormat",
"=",
"[",
"]",
";",
"thisFormat",
"[",
"0",
"]",
"=",
"vars",
".",
"formats",
"[",
"f",
"]",
"[",
"0",
"]",
";",
"if",
"(",
"vars",
".",
"formats",
"[",
"f",
"]",
"[",
"0",
"]",
".",
"length",
">",
"0",
"&&",
"detectElement",
"(",
"thisFormat",
")",
")",
"{",
"formatLabelView",
"(",
"vars",
".",
"formats",
"[",
"f",
"]",
"[",
"1",
"]",
")",
";",
"isFoundFormat",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"!",
"isFoundFormat",
")",
"formatLabelView",
"(",
"vars",
".",
"formats",
"[",
"0",
"]",
"[",
"1",
"]",
")",
";",
"}",
"// hide all style-fields\r",
"styleFieldSwitch",
"(",
"\"\"",
",",
"false",
")",
";",
"formatFieldSwitch",
"(",
"false",
")",
";",
"}"
] | the function of highlighting the toolbar buttons according to the cursor position in jqte editor | [
"the",
"function",
"of",
"highlighting",
"the",
"toolbar",
"buttons",
"according",
"to",
"the",
"cursor",
"position",
"in",
"jqte",
"editor"
] | 8cffac0650297c313779c9fba545096be24e52a5 | https://github.com/epeios-q37/xdhelcq/blob/8cffac0650297c313779c9fba545096be24e52a5/js/jqte/uncompressed/jquery-te-1.4.0.js#L1031-L1064 |
51,115 | glo-js/glo-shader | index.js | update | function update (opt) {
// remove old shaders
disposeShaders()
var quiet = opt.quiet
var attributeBindings = opt.attributes
var vertSrc = opt.vertex || defaultVertex
var fragSrc = opt.fragment || defaultFragment
// re-compile source
vertexShader = compileShader(gl, gl.VERTEX_SHADER, vertSrc, quiet, name)
fragmentShader = compileShader(gl, gl.FRAGMENT_SHADER, fragSrc, quiet, name)
// re-link
var shaders = [ vertexShader, fragmentShader ]
linkShaders(gl, program, shaders, attributeBindings, quiet, name)
// extract uniforms and attributes
types = extract(gl, program)
// allow user to inject some dummy uniforms
if (opt.uniforms) {
var inactiveUniforms = []
opt.uniforms.forEach(function (uniform) {
if (indexOfName(types.uniforms, uniform.name) === -1) {
inactiveUniforms.push(uniform)
types.uniforms.push({ name: uniform.name, type: uniform.type })
}
})
// provide UX for inactive uniforms...? TBD
if (!quiet && inactiveUniforms.length > 0) {
var shaderName = name ? (' (' + name + ')') : ''
console.warn('Inactive uniforms in shader' + shaderName + ': '
+ inactiveUniforms
.map(function (x) { return x.name })
.join(', '))
}
}
// normalize sort order by name across Chrome / FF
types.uniforms.sort(compareString)
types.attributes.sort(compareString)
// provide optimized getters/setters
uniforms = reflect(types.uniforms, function (uniform, index) {
return makeUniformProp(uniform, index)
})
// provide attribute locations and type
// (GLSL ES does not support array/struct attributes)
attributes = types.attributes.reduce(function (struct, attrib) {
var name = attrib.name
struct[name] = {
size: dimension(attrib.type),
type: attrib.type,
location: gl.getAttribLocation(program, name)
}
return struct
}, {})
} | javascript | function update (opt) {
// remove old shaders
disposeShaders()
var quiet = opt.quiet
var attributeBindings = opt.attributes
var vertSrc = opt.vertex || defaultVertex
var fragSrc = opt.fragment || defaultFragment
// re-compile source
vertexShader = compileShader(gl, gl.VERTEX_SHADER, vertSrc, quiet, name)
fragmentShader = compileShader(gl, gl.FRAGMENT_SHADER, fragSrc, quiet, name)
// re-link
var shaders = [ vertexShader, fragmentShader ]
linkShaders(gl, program, shaders, attributeBindings, quiet, name)
// extract uniforms and attributes
types = extract(gl, program)
// allow user to inject some dummy uniforms
if (opt.uniforms) {
var inactiveUniforms = []
opt.uniforms.forEach(function (uniform) {
if (indexOfName(types.uniforms, uniform.name) === -1) {
inactiveUniforms.push(uniform)
types.uniforms.push({ name: uniform.name, type: uniform.type })
}
})
// provide UX for inactive uniforms...? TBD
if (!quiet && inactiveUniforms.length > 0) {
var shaderName = name ? (' (' + name + ')') : ''
console.warn('Inactive uniforms in shader' + shaderName + ': '
+ inactiveUniforms
.map(function (x) { return x.name })
.join(', '))
}
}
// normalize sort order by name across Chrome / FF
types.uniforms.sort(compareString)
types.attributes.sort(compareString)
// provide optimized getters/setters
uniforms = reflect(types.uniforms, function (uniform, index) {
return makeUniformProp(uniform, index)
})
// provide attribute locations and type
// (GLSL ES does not support array/struct attributes)
attributes = types.attributes.reduce(function (struct, attrib) {
var name = attrib.name
struct[name] = {
size: dimension(attrib.type),
type: attrib.type,
location: gl.getAttribLocation(program, name)
}
return struct
}, {})
} | [
"function",
"update",
"(",
"opt",
")",
"{",
"// remove old shaders",
"disposeShaders",
"(",
")",
"var",
"quiet",
"=",
"opt",
".",
"quiet",
"var",
"attributeBindings",
"=",
"opt",
".",
"attributes",
"var",
"vertSrc",
"=",
"opt",
".",
"vertex",
"||",
"defaultVertex",
"var",
"fragSrc",
"=",
"opt",
".",
"fragment",
"||",
"defaultFragment",
"// re-compile source",
"vertexShader",
"=",
"compileShader",
"(",
"gl",
",",
"gl",
".",
"VERTEX_SHADER",
",",
"vertSrc",
",",
"quiet",
",",
"name",
")",
"fragmentShader",
"=",
"compileShader",
"(",
"gl",
",",
"gl",
".",
"FRAGMENT_SHADER",
",",
"fragSrc",
",",
"quiet",
",",
"name",
")",
"// re-link",
"var",
"shaders",
"=",
"[",
"vertexShader",
",",
"fragmentShader",
"]",
"linkShaders",
"(",
"gl",
",",
"program",
",",
"shaders",
",",
"attributeBindings",
",",
"quiet",
",",
"name",
")",
"// extract uniforms and attributes",
"types",
"=",
"extract",
"(",
"gl",
",",
"program",
")",
"// allow user to inject some dummy uniforms",
"if",
"(",
"opt",
".",
"uniforms",
")",
"{",
"var",
"inactiveUniforms",
"=",
"[",
"]",
"opt",
".",
"uniforms",
".",
"forEach",
"(",
"function",
"(",
"uniform",
")",
"{",
"if",
"(",
"indexOfName",
"(",
"types",
".",
"uniforms",
",",
"uniform",
".",
"name",
")",
"===",
"-",
"1",
")",
"{",
"inactiveUniforms",
".",
"push",
"(",
"uniform",
")",
"types",
".",
"uniforms",
".",
"push",
"(",
"{",
"name",
":",
"uniform",
".",
"name",
",",
"type",
":",
"uniform",
".",
"type",
"}",
")",
"}",
"}",
")",
"// provide UX for inactive uniforms...? TBD",
"if",
"(",
"!",
"quiet",
"&&",
"inactiveUniforms",
".",
"length",
">",
"0",
")",
"{",
"var",
"shaderName",
"=",
"name",
"?",
"(",
"' ('",
"+",
"name",
"+",
"')'",
")",
":",
"''",
"console",
".",
"warn",
"(",
"'Inactive uniforms in shader'",
"+",
"shaderName",
"+",
"': '",
"+",
"inactiveUniforms",
".",
"map",
"(",
"function",
"(",
"x",
")",
"{",
"return",
"x",
".",
"name",
"}",
")",
".",
"join",
"(",
"', '",
")",
")",
"}",
"}",
"// normalize sort order by name across Chrome / FF",
"types",
".",
"uniforms",
".",
"sort",
"(",
"compareString",
")",
"types",
".",
"attributes",
".",
"sort",
"(",
"compareString",
")",
"// provide optimized getters/setters",
"uniforms",
"=",
"reflect",
"(",
"types",
".",
"uniforms",
",",
"function",
"(",
"uniform",
",",
"index",
")",
"{",
"return",
"makeUniformProp",
"(",
"uniform",
",",
"index",
")",
"}",
")",
"// provide attribute locations and type",
"// (GLSL ES does not support array/struct attributes)",
"attributes",
"=",
"types",
".",
"attributes",
".",
"reduce",
"(",
"function",
"(",
"struct",
",",
"attrib",
")",
"{",
"var",
"name",
"=",
"attrib",
".",
"name",
"struct",
"[",
"name",
"]",
"=",
"{",
"size",
":",
"dimension",
"(",
"attrib",
".",
"type",
")",
",",
"type",
":",
"attrib",
".",
"type",
",",
"location",
":",
"gl",
".",
"getAttribLocation",
"(",
"program",
",",
"name",
")",
"}",
"return",
"struct",
"}",
",",
"{",
"}",
")",
"}"
] | reload shader with new source code | [
"reload",
"shader",
"with",
"new",
"source",
"code"
] | 618a5c7b59dcafe9992656e22bb5aa8b69083e01 | https://github.com/glo-js/glo-shader/blob/618a5c7b59dcafe9992656e22bb5aa8b69083e01/index.js#L73-L134 |
51,116 | GLcadet/react-webpack | utils/index.js | runCommand | function runCommand(cmd, args, options) {
return new Promise((resolve, reject) => {
const spwan = spawn(
cmd,
args,
Object.assign(
{
cwd: process.cwd(),
stdio: 'inherit',
shell: true,
},
options
)
)
spwan.on('exit', () => {
resolve()
})
})
} | javascript | function runCommand(cmd, args, options) {
return new Promise((resolve, reject) => {
const spwan = spawn(
cmd,
args,
Object.assign(
{
cwd: process.cwd(),
stdio: 'inherit',
shell: true,
},
options
)
)
spwan.on('exit', () => {
resolve()
})
})
} | [
"function",
"runCommand",
"(",
"cmd",
",",
"args",
",",
"options",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"const",
"spwan",
"=",
"spawn",
"(",
"cmd",
",",
"args",
",",
"Object",
".",
"assign",
"(",
"{",
"cwd",
":",
"process",
".",
"cwd",
"(",
")",
",",
"stdio",
":",
"'inherit'",
",",
"shell",
":",
"true",
",",
"}",
",",
"options",
")",
")",
"spwan",
".",
"on",
"(",
"'exit'",
",",
"(",
")",
"=>",
"{",
"resolve",
"(",
")",
"}",
")",
"}",
")",
"}"
] | Spawns a child process and runs the specified command
By default, runs in the CWD and inherits stdio
Options are the same as node's child_process.spawn
@param {string} cmd
@param {array<string>} args
@param {object} options | [
"Spawns",
"a",
"child",
"process",
"and",
"runs",
"the",
"specified",
"command",
"By",
"default",
"runs",
"in",
"the",
"CWD",
"and",
"inherits",
"stdio",
"Options",
"are",
"the",
"same",
"as",
"node",
"s",
"child_process",
".",
"spawn"
] | 7fe018edbee94350c532be979aee9cd6b4683d96 | https://github.com/GLcadet/react-webpack/blob/7fe018edbee94350c532be979aee9cd6b4683d96/utils/index.js#L116-L135 |
51,117 | 360fy/plugin-boilerplate | src/PluginLoader.js | existsFile | function existsFile(file, permission) {
return Promise.resolve(fsPromise.accessAsync(file, permission))
.then(() => true)
.catch(() => false);
} | javascript | function existsFile(file, permission) {
return Promise.resolve(fsPromise.accessAsync(file, permission))
.then(() => true)
.catch(() => false);
} | [
"function",
"existsFile",
"(",
"file",
",",
"permission",
")",
"{",
"return",
"Promise",
".",
"resolve",
"(",
"fsPromise",
".",
"accessAsync",
"(",
"file",
",",
"permission",
")",
")",
".",
"then",
"(",
"(",
")",
"=>",
"true",
")",
".",
"catch",
"(",
"(",
")",
"=>",
"false",
")",
";",
"}"
] | eslint-disable-line no-bitwise | [
"eslint",
"-",
"disable",
"-",
"line",
"no",
"-",
"bitwise"
] | 0145f099e68242ed38f7c385584b107e2ff5084f | https://github.com/360fy/plugin-boilerplate/blob/0145f099e68242ed38f7c385584b107e2ff5084f/src/PluginLoader.js#L46-L50 |
51,118 | MaximTovstashev/brest | lib/utils/generate_returnable_error.js | generateReturnableError | function generateReturnableError(error) {
if (_.isError(error)) {
return {
body: {error: error.message},
options: {code: httpCodes.INTERNAL_SERVER_ERROR}
};
}
if (_.isString(error)) {
return {
body: {error},
options: {code: httpCodes.INTERNAL_SERVER_ERROR}
};
}
if (_.isObject(error) && !_.isFunction(error)) {
if (_.isArray(error)) {
return {
body: {error},
options: {code: httpCodes.INTERNAL_SERVER_ERROR}
};
}
let code = error.code || httpCodes.INTERNAL_SERVER_ERROR;
delete error.code;
return {
body: error,
options: {code}
};
}
if (_.isFunction(error)) {
return {
body: {error: 'Incorrect error type "function"'},
options: {code: httpCodes.INTERNAL_SERVER_ERROR}
};
}
return {
body: {error: 'Unexpected error format'},
options: {code: httpCodes.INTERNAL_SERVER_ERROR}
};
} | javascript | function generateReturnableError(error) {
if (_.isError(error)) {
return {
body: {error: error.message},
options: {code: httpCodes.INTERNAL_SERVER_ERROR}
};
}
if (_.isString(error)) {
return {
body: {error},
options: {code: httpCodes.INTERNAL_SERVER_ERROR}
};
}
if (_.isObject(error) && !_.isFunction(error)) {
if (_.isArray(error)) {
return {
body: {error},
options: {code: httpCodes.INTERNAL_SERVER_ERROR}
};
}
let code = error.code || httpCodes.INTERNAL_SERVER_ERROR;
delete error.code;
return {
body: error,
options: {code}
};
}
if (_.isFunction(error)) {
return {
body: {error: 'Incorrect error type "function"'},
options: {code: httpCodes.INTERNAL_SERVER_ERROR}
};
}
return {
body: {error: 'Unexpected error format'},
options: {code: httpCodes.INTERNAL_SERVER_ERROR}
};
} | [
"function",
"generateReturnableError",
"(",
"error",
")",
"{",
"if",
"(",
"_",
".",
"isError",
"(",
"error",
")",
")",
"{",
"return",
"{",
"body",
":",
"{",
"error",
":",
"error",
".",
"message",
"}",
",",
"options",
":",
"{",
"code",
":",
"httpCodes",
".",
"INTERNAL_SERVER_ERROR",
"}",
"}",
";",
"}",
"if",
"(",
"_",
".",
"isString",
"(",
"error",
")",
")",
"{",
"return",
"{",
"body",
":",
"{",
"error",
"}",
",",
"options",
":",
"{",
"code",
":",
"httpCodes",
".",
"INTERNAL_SERVER_ERROR",
"}",
"}",
";",
"}",
"if",
"(",
"_",
".",
"isObject",
"(",
"error",
")",
"&&",
"!",
"_",
".",
"isFunction",
"(",
"error",
")",
")",
"{",
"if",
"(",
"_",
".",
"isArray",
"(",
"error",
")",
")",
"{",
"return",
"{",
"body",
":",
"{",
"error",
"}",
",",
"options",
":",
"{",
"code",
":",
"httpCodes",
".",
"INTERNAL_SERVER_ERROR",
"}",
"}",
";",
"}",
"let",
"code",
"=",
"error",
".",
"code",
"||",
"httpCodes",
".",
"INTERNAL_SERVER_ERROR",
";",
"delete",
"error",
".",
"code",
";",
"return",
"{",
"body",
":",
"error",
",",
"options",
":",
"{",
"code",
"}",
"}",
";",
"}",
"if",
"(",
"_",
".",
"isFunction",
"(",
"error",
")",
")",
"{",
"return",
"{",
"body",
":",
"{",
"error",
":",
"'Incorrect error type \"function\"'",
"}",
",",
"options",
":",
"{",
"code",
":",
"httpCodes",
".",
"INTERNAL_SERVER_ERROR",
"}",
"}",
";",
"}",
"return",
"{",
"body",
":",
"{",
"error",
":",
"'Unexpected error format'",
"}",
",",
"options",
":",
"{",
"code",
":",
"httpCodes",
".",
"INTERNAL_SERVER_ERROR",
"}",
"}",
";",
"}"
] | Generate proper returnable object according to received error type
@param {*} error
@return {Object} | [
"Generate",
"proper",
"returnable",
"object",
"according",
"to",
"received",
"error",
"type"
] | 9b0bd6ee452e55b86cd01d1647f0dff460ad191f | https://github.com/MaximTovstashev/brest/blob/9b0bd6ee452e55b86cd01d1647f0dff460ad191f/lib/utils/generate_returnable_error.js#L12-L49 |
51,119 | vlad-zhukov/jepa | scripts/build.js | build | async function build() {
const clientConfig = await webpackConfig({target: 'web', env: 'prod'});
const serverConfig = await webpackConfig({target: 'node', env: 'prod'});
return new Promise((resolve, reject) => {
console.log('Compiling client...');
// eslint-disable-next-line consistent-return
webpack(clientConfig, (clientError, clientStats) => {
if (clientError) {
return reject(clientError);
}
const clientMessages = formatWebpackMessages(clientStats.toJson({}, true));
if (clientMessages.errors.length) {
return reject(new Error(clientMessages.errors.join('\n\n')));
}
if (
process.env.CI &&
(typeof process.env.CI !== 'string' || process.env.CI.toLowerCase() !== 'false') &&
clientMessages.warnings.length
) {
console.log(
chalk.yellow(
'\nTreating warnings as errors because process.env.CI = true.\n' +
'Most CI servers set it automatically.\n'
)
);
return reject(new Error(clientMessages.warnings.join('\n\n')));
}
console.log(chalk.green('Compiled client successfully.'), '\n');
console.log('Compiling server...');
webpack(serverConfig, (serverError, serverStats) => {
if (serverError) {
return reject(serverError);
}
const serverMessages = formatWebpackMessages(serverStats.toJson({}, true));
if (serverMessages.errors.length) {
return reject(new Error(serverMessages.errors.join('\n\n')));
}
if (
process.env.CI &&
(typeof process.env.CI !== 'string' || process.env.CI.toLowerCase() !== 'false') &&
serverMessages.warnings.length
) {
console.log(
chalk.yellow(
'\nTreating warnings as errors because process.env.CI = true.\n' +
'Most CI servers set it automatically.\n'
)
);
return reject(new Error(serverMessages.warnings.join('\n\n')));
}
console.log(chalk.green('Compiled server successfully.'), '\n');
return resolve({
stats: clientStats,
warnings: Object.assign({}, clientMessages.warnings, serverMessages.warnings),
});
});
});
});
} | javascript | async function build() {
const clientConfig = await webpackConfig({target: 'web', env: 'prod'});
const serverConfig = await webpackConfig({target: 'node', env: 'prod'});
return new Promise((resolve, reject) => {
console.log('Compiling client...');
// eslint-disable-next-line consistent-return
webpack(clientConfig, (clientError, clientStats) => {
if (clientError) {
return reject(clientError);
}
const clientMessages = formatWebpackMessages(clientStats.toJson({}, true));
if (clientMessages.errors.length) {
return reject(new Error(clientMessages.errors.join('\n\n')));
}
if (
process.env.CI &&
(typeof process.env.CI !== 'string' || process.env.CI.toLowerCase() !== 'false') &&
clientMessages.warnings.length
) {
console.log(
chalk.yellow(
'\nTreating warnings as errors because process.env.CI = true.\n' +
'Most CI servers set it automatically.\n'
)
);
return reject(new Error(clientMessages.warnings.join('\n\n')));
}
console.log(chalk.green('Compiled client successfully.'), '\n');
console.log('Compiling server...');
webpack(serverConfig, (serverError, serverStats) => {
if (serverError) {
return reject(serverError);
}
const serverMessages = formatWebpackMessages(serverStats.toJson({}, true));
if (serverMessages.errors.length) {
return reject(new Error(serverMessages.errors.join('\n\n')));
}
if (
process.env.CI &&
(typeof process.env.CI !== 'string' || process.env.CI.toLowerCase() !== 'false') &&
serverMessages.warnings.length
) {
console.log(
chalk.yellow(
'\nTreating warnings as errors because process.env.CI = true.\n' +
'Most CI servers set it automatically.\n'
)
);
return reject(new Error(serverMessages.warnings.join('\n\n')));
}
console.log(chalk.green('Compiled server successfully.'), '\n');
return resolve({
stats: clientStats,
warnings: Object.assign({}, clientMessages.warnings, serverMessages.warnings),
});
});
});
});
} | [
"async",
"function",
"build",
"(",
")",
"{",
"const",
"clientConfig",
"=",
"await",
"webpackConfig",
"(",
"{",
"target",
":",
"'web'",
",",
"env",
":",
"'prod'",
"}",
")",
";",
"const",
"serverConfig",
"=",
"await",
"webpackConfig",
"(",
"{",
"target",
":",
"'node'",
",",
"env",
":",
"'prod'",
"}",
")",
";",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"console",
".",
"log",
"(",
"'Compiling client...'",
")",
";",
"// eslint-disable-next-line consistent-return",
"webpack",
"(",
"clientConfig",
",",
"(",
"clientError",
",",
"clientStats",
")",
"=>",
"{",
"if",
"(",
"clientError",
")",
"{",
"return",
"reject",
"(",
"clientError",
")",
";",
"}",
"const",
"clientMessages",
"=",
"formatWebpackMessages",
"(",
"clientStats",
".",
"toJson",
"(",
"{",
"}",
",",
"true",
")",
")",
";",
"if",
"(",
"clientMessages",
".",
"errors",
".",
"length",
")",
"{",
"return",
"reject",
"(",
"new",
"Error",
"(",
"clientMessages",
".",
"errors",
".",
"join",
"(",
"'\\n\\n'",
")",
")",
")",
";",
"}",
"if",
"(",
"process",
".",
"env",
".",
"CI",
"&&",
"(",
"typeof",
"process",
".",
"env",
".",
"CI",
"!==",
"'string'",
"||",
"process",
".",
"env",
".",
"CI",
".",
"toLowerCase",
"(",
")",
"!==",
"'false'",
")",
"&&",
"clientMessages",
".",
"warnings",
".",
"length",
")",
"{",
"console",
".",
"log",
"(",
"chalk",
".",
"yellow",
"(",
"'\\nTreating warnings as errors because process.env.CI = true.\\n'",
"+",
"'Most CI servers set it automatically.\\n'",
")",
")",
";",
"return",
"reject",
"(",
"new",
"Error",
"(",
"clientMessages",
".",
"warnings",
".",
"join",
"(",
"'\\n\\n'",
")",
")",
")",
";",
"}",
"console",
".",
"log",
"(",
"chalk",
".",
"green",
"(",
"'Compiled client successfully.'",
")",
",",
"'\\n'",
")",
";",
"console",
".",
"log",
"(",
"'Compiling server...'",
")",
";",
"webpack",
"(",
"serverConfig",
",",
"(",
"serverError",
",",
"serverStats",
")",
"=>",
"{",
"if",
"(",
"serverError",
")",
"{",
"return",
"reject",
"(",
"serverError",
")",
";",
"}",
"const",
"serverMessages",
"=",
"formatWebpackMessages",
"(",
"serverStats",
".",
"toJson",
"(",
"{",
"}",
",",
"true",
")",
")",
";",
"if",
"(",
"serverMessages",
".",
"errors",
".",
"length",
")",
"{",
"return",
"reject",
"(",
"new",
"Error",
"(",
"serverMessages",
".",
"errors",
".",
"join",
"(",
"'\\n\\n'",
")",
")",
")",
";",
"}",
"if",
"(",
"process",
".",
"env",
".",
"CI",
"&&",
"(",
"typeof",
"process",
".",
"env",
".",
"CI",
"!==",
"'string'",
"||",
"process",
".",
"env",
".",
"CI",
".",
"toLowerCase",
"(",
")",
"!==",
"'false'",
")",
"&&",
"serverMessages",
".",
"warnings",
".",
"length",
")",
"{",
"console",
".",
"log",
"(",
"chalk",
".",
"yellow",
"(",
"'\\nTreating warnings as errors because process.env.CI = true.\\n'",
"+",
"'Most CI servers set it automatically.\\n'",
")",
")",
";",
"return",
"reject",
"(",
"new",
"Error",
"(",
"serverMessages",
".",
"warnings",
".",
"join",
"(",
"'\\n\\n'",
")",
")",
")",
";",
"}",
"console",
".",
"log",
"(",
"chalk",
".",
"green",
"(",
"'Compiled server successfully.'",
")",
",",
"'\\n'",
")",
";",
"return",
"resolve",
"(",
"{",
"stats",
":",
"clientStats",
",",
"warnings",
":",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"clientMessages",
".",
"warnings",
",",
"serverMessages",
".",
"warnings",
")",
",",
"}",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}"
] | First compile the client. We need it to properly output assets.json (asset manifest file with the correct hashes on file names BEFORE we can start the server compiler. | [
"First",
"compile",
"the",
"client",
".",
"We",
"need",
"it",
"to",
"properly",
"output",
"assets",
".",
"json",
"(",
"asset",
"manifest",
"file",
"with",
"the",
"correct",
"hashes",
"on",
"file",
"names",
"BEFORE",
"we",
"can",
"start",
"the",
"server",
"compiler",
"."
] | 356a23f1838ef27adeca003adec2dd3b8c25343e | https://github.com/vlad-zhukov/jepa/blob/356a23f1838ef27adeca003adec2dd3b8c25343e/scripts/build.js#L10-L76 |
51,120 | jaredhanson/connect-lrdd | lib/link.js | Link | function Link(href, rel, type) {
if (typeof href == 'object') {
var options = href;
this.href = options.href;
this.template = options.template;
this.rel = options.rel;
this.type = options.type;
} else {
this.href = href;
this.rel = rel;
this.type = type;
}
this.titles = new MultiHash();
this.properties = new MultiHash();
} | javascript | function Link(href, rel, type) {
if (typeof href == 'object') {
var options = href;
this.href = options.href;
this.template = options.template;
this.rel = options.rel;
this.type = options.type;
} else {
this.href = href;
this.rel = rel;
this.type = type;
}
this.titles = new MultiHash();
this.properties = new MultiHash();
} | [
"function",
"Link",
"(",
"href",
",",
"rel",
",",
"type",
")",
"{",
"if",
"(",
"typeof",
"href",
"==",
"'object'",
")",
"{",
"var",
"options",
"=",
"href",
";",
"this",
".",
"href",
"=",
"options",
".",
"href",
";",
"this",
".",
"template",
"=",
"options",
".",
"template",
";",
"this",
".",
"rel",
"=",
"options",
".",
"rel",
";",
"this",
".",
"type",
"=",
"options",
".",
"type",
";",
"}",
"else",
"{",
"this",
".",
"href",
"=",
"href",
";",
"this",
".",
"rel",
"=",
"rel",
";",
"this",
".",
"type",
"=",
"type",
";",
"}",
"this",
".",
"titles",
"=",
"new",
"MultiHash",
"(",
")",
";",
"this",
".",
"properties",
"=",
"new",
"MultiHash",
"(",
")",
";",
"}"
] | `Link` constructor.
Constructs a new `Link` with the given `href`, `rel`, and `type`.
Alternatively, the link properties can be given as `options`.
Options:
- `href` uri reference
- `template` uri template
- `rel` link relation
- `type` media type
Examples:
new Link('http://services.example.com/auth');
new Link('http://photos.example.com/gpburdell.jpg', 'http://spec.example.net/photo/1.0', 'image/jpeg');
new Link({ template: 'https://example.com/lrdd/?uri={uri}', rel: 'lrdd', type: 'application/xrd+xml' });
@param {String} href
@param {String} rel
@param {String} type
@api public | [
"Link",
"constructor",
"."
] | 6d1f1f9b98cdd1ebc5fb3f048c4eddf5ef034ec1 | https://github.com/jaredhanson/connect-lrdd/blob/6d1f1f9b98cdd1ebc5fb3f048c4eddf5ef034ec1/lib/link.js#L32-L47 |
51,121 | photokandyStudios/yasmf-emitter | lib/index.js | on | function on(evt, handler) {
var _this = this;
var thisArg = arguments[2] === undefined ? null : arguments[2];
// if multiple events are passed, call our utility method `eachEvt` to deal with this.
// if it returns `true`, we should exit, because we're actually being called recursively.
// If it returns `false`, we're not being called with multiple parameters (this time, anyway),
// and so can continue processing.
if (eachEvt(evt, handler, thisArg, function () {
for (var _len2 = arguments.length, _ = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
_[_key2] = arguments[_key2];
}
return _this.on.apply(_this, _);
})) {
return this;
} // simplify typing; eH = eventHandlers
var eH = this[_eventHandlers];
if (!eH.has(evt)) {
// if we don't have an event category already in the map, create it as a new map
// this map will be of the form bindingObject:methods.
eH.set(evt, new core.Map());
}
// simplify typing; objMap == objectMap (bindingObject:methods)
var objMap = eH.get(evt);
if (!objMap.has(thisArg)) {
// if we don't have `thisArg` in the map, make a set for it. The set is the set of functions
// and we use a set so as to prevent duplicates automatically.
objMap.set(thisArg, new core.Set());
}
var handlerSet = objMap.get(thisArg);
if (typeof handler === "function") {
// add the handler
handlerSet.add(handler);
} else {
// a little error checking!
throw new TypeError("Event handler must be a function.");
}
return this;
} | javascript | function on(evt, handler) {
var _this = this;
var thisArg = arguments[2] === undefined ? null : arguments[2];
// if multiple events are passed, call our utility method `eachEvt` to deal with this.
// if it returns `true`, we should exit, because we're actually being called recursively.
// If it returns `false`, we're not being called with multiple parameters (this time, anyway),
// and so can continue processing.
if (eachEvt(evt, handler, thisArg, function () {
for (var _len2 = arguments.length, _ = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
_[_key2] = arguments[_key2];
}
return _this.on.apply(_this, _);
})) {
return this;
} // simplify typing; eH = eventHandlers
var eH = this[_eventHandlers];
if (!eH.has(evt)) {
// if we don't have an event category already in the map, create it as a new map
// this map will be of the form bindingObject:methods.
eH.set(evt, new core.Map());
}
// simplify typing; objMap == objectMap (bindingObject:methods)
var objMap = eH.get(evt);
if (!objMap.has(thisArg)) {
// if we don't have `thisArg` in the map, make a set for it. The set is the set of functions
// and we use a set so as to prevent duplicates automatically.
objMap.set(thisArg, new core.Set());
}
var handlerSet = objMap.get(thisArg);
if (typeof handler === "function") {
// add the handler
handlerSet.add(handler);
} else {
// a little error checking!
throw new TypeError("Event handler must be a function.");
}
return this;
} | [
"function",
"on",
"(",
"evt",
",",
"handler",
")",
"{",
"var",
"_this",
"=",
"this",
";",
"var",
"thisArg",
"=",
"arguments",
"[",
"2",
"]",
"===",
"undefined",
"?",
"null",
":",
"arguments",
"[",
"2",
"]",
";",
"// if multiple events are passed, call our utility method `eachEvt` to deal with this.",
"// if it returns `true`, we should exit, because we're actually being called recursively.",
"// If it returns `false`, we're not being called with multiple parameters (this time, anyway),",
"// and so can continue processing.",
"if",
"(",
"eachEvt",
"(",
"evt",
",",
"handler",
",",
"thisArg",
",",
"function",
"(",
")",
"{",
"for",
"(",
"var",
"_len2",
"=",
"arguments",
".",
"length",
",",
"_",
"=",
"Array",
"(",
"_len2",
")",
",",
"_key2",
"=",
"0",
";",
"_key2",
"<",
"_len2",
";",
"_key2",
"++",
")",
"{",
"_",
"[",
"_key2",
"]",
"=",
"arguments",
"[",
"_key2",
"]",
";",
"}",
"return",
"_this",
".",
"on",
".",
"apply",
"(",
"_this",
",",
"_",
")",
";",
"}",
")",
")",
"{",
"return",
"this",
";",
"}",
"// simplify typing; eH = eventHandlers",
"var",
"eH",
"=",
"this",
"[",
"_eventHandlers",
"]",
";",
"if",
"(",
"!",
"eH",
".",
"has",
"(",
"evt",
")",
")",
"{",
"// if we don't have an event category already in the map, create it as a new map",
"// this map will be of the form bindingObject:methods.",
"eH",
".",
"set",
"(",
"evt",
",",
"new",
"core",
".",
"Map",
"(",
")",
")",
";",
"}",
"// simplify typing; objMap == objectMap (bindingObject:methods)",
"var",
"objMap",
"=",
"eH",
".",
"get",
"(",
"evt",
")",
";",
"if",
"(",
"!",
"objMap",
".",
"has",
"(",
"thisArg",
")",
")",
"{",
"// if we don't have `thisArg` in the map, make a set for it. The set is the set of functions",
"// and we use a set so as to prevent duplicates automatically.",
"objMap",
".",
"set",
"(",
"thisArg",
",",
"new",
"core",
".",
"Set",
"(",
")",
")",
";",
"}",
"var",
"handlerSet",
"=",
"objMap",
".",
"get",
"(",
"thisArg",
")",
";",
"if",
"(",
"typeof",
"handler",
"===",
"\"function\"",
")",
"{",
"// add the handler",
"handlerSet",
".",
"add",
"(",
"handler",
")",
";",
"}",
"else",
"{",
"// a little error checking!",
"throw",
"new",
"TypeError",
"(",
"\"Event handler must be a function.\"",
")",
";",
"}",
"return",
"this",
";",
"}"
] | Registers a handler for one or more events bound to `thisArg`.
@param {string|Array<string>|Object} evt
@param {function} [handler]
@param {Object} [thisArg]
@throws {TypeError}
@returns {Emitter} | [
"Registers",
"a",
"handler",
"for",
"one",
"or",
"more",
"events",
"bound",
"to",
"thisArg",
"."
] | f972cb6f0304a54a8c16626f2a850a2371384c18 | https://github.com/photokandyStudios/yasmf-emitter/blob/f972cb6f0304a54a8c16626f2a850a2371384c18/lib/index.js#L132-L177 |
51,122 | photokandyStudios/yasmf-emitter | lib/index.js | off | function off(evt, handler) {
var _this2 = this;
var thisArg = arguments[2] === undefined ? null : arguments[2];
// handle multiple events appropriately.
if (eachEvt(evt, handler, thisArg, function () {
for (var _len3 = arguments.length, _ = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
_[_key3] = arguments[_key3];
}
return _this2.off.apply(_this2, _);
})) {
return this;
}if (evt === undefined && handler === undefined && thisArg === null) {
// remove all event handlers. Easiest way to do this is just create a new event map
this[_eventHandlers] = new core.Map();
return this;
}
var eH = this[_eventHandlers];
if (handler === undefined && thisArg === null) {
// remove all handlers for a specific event. Easiest way to do this is just create a new object map
eH.set(evt, new core.Map());
return this;
}
var objMap = eH.get(evt);
if (objMap !== undefined) {
// the following cases apply only if we have an object map for the event -- otherwise we do nothing.
if (typeof handler === "object") {
// remove all handlers in a given event category for a specific object
objMap["delete"](handler);
return this;
}
// only remove if we have the event map in the first place
var handlerSet = objMap.get(thisArg);
if (handlerSet !== undefined) {
handlerSet["delete"](handler);
if (handlerSet.size === 0) {
eH["delete"](objMap);
}
}
}
return this;
} | javascript | function off(evt, handler) {
var _this2 = this;
var thisArg = arguments[2] === undefined ? null : arguments[2];
// handle multiple events appropriately.
if (eachEvt(evt, handler, thisArg, function () {
for (var _len3 = arguments.length, _ = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
_[_key3] = arguments[_key3];
}
return _this2.off.apply(_this2, _);
})) {
return this;
}if (evt === undefined && handler === undefined && thisArg === null) {
// remove all event handlers. Easiest way to do this is just create a new event map
this[_eventHandlers] = new core.Map();
return this;
}
var eH = this[_eventHandlers];
if (handler === undefined && thisArg === null) {
// remove all handlers for a specific event. Easiest way to do this is just create a new object map
eH.set(evt, new core.Map());
return this;
}
var objMap = eH.get(evt);
if (objMap !== undefined) {
// the following cases apply only if we have an object map for the event -- otherwise we do nothing.
if (typeof handler === "object") {
// remove all handlers in a given event category for a specific object
objMap["delete"](handler);
return this;
}
// only remove if we have the event map in the first place
var handlerSet = objMap.get(thisArg);
if (handlerSet !== undefined) {
handlerSet["delete"](handler);
if (handlerSet.size === 0) {
eH["delete"](objMap);
}
}
}
return this;
} | [
"function",
"off",
"(",
"evt",
",",
"handler",
")",
"{",
"var",
"_this2",
"=",
"this",
";",
"var",
"thisArg",
"=",
"arguments",
"[",
"2",
"]",
"===",
"undefined",
"?",
"null",
":",
"arguments",
"[",
"2",
"]",
";",
"// handle multiple events appropriately.",
"if",
"(",
"eachEvt",
"(",
"evt",
",",
"handler",
",",
"thisArg",
",",
"function",
"(",
")",
"{",
"for",
"(",
"var",
"_len3",
"=",
"arguments",
".",
"length",
",",
"_",
"=",
"Array",
"(",
"_len3",
")",
",",
"_key3",
"=",
"0",
";",
"_key3",
"<",
"_len3",
";",
"_key3",
"++",
")",
"{",
"_",
"[",
"_key3",
"]",
"=",
"arguments",
"[",
"_key3",
"]",
";",
"}",
"return",
"_this2",
".",
"off",
".",
"apply",
"(",
"_this2",
",",
"_",
")",
";",
"}",
")",
")",
"{",
"return",
"this",
";",
"}",
"if",
"(",
"evt",
"===",
"undefined",
"&&",
"handler",
"===",
"undefined",
"&&",
"thisArg",
"===",
"null",
")",
"{",
"// remove all event handlers. Easiest way to do this is just create a new event map",
"this",
"[",
"_eventHandlers",
"]",
"=",
"new",
"core",
".",
"Map",
"(",
")",
";",
"return",
"this",
";",
"}",
"var",
"eH",
"=",
"this",
"[",
"_eventHandlers",
"]",
";",
"if",
"(",
"handler",
"===",
"undefined",
"&&",
"thisArg",
"===",
"null",
")",
"{",
"// remove all handlers for a specific event. Easiest way to do this is just create a new object map",
"eH",
".",
"set",
"(",
"evt",
",",
"new",
"core",
".",
"Map",
"(",
")",
")",
";",
"return",
"this",
";",
"}",
"var",
"objMap",
"=",
"eH",
".",
"get",
"(",
"evt",
")",
";",
"if",
"(",
"objMap",
"!==",
"undefined",
")",
"{",
"// the following cases apply only if we have an object map for the event -- otherwise we do nothing.",
"if",
"(",
"typeof",
"handler",
"===",
"\"object\"",
")",
"{",
"// remove all handlers in a given event category for a specific object",
"objMap",
"[",
"\"delete\"",
"]",
"(",
"handler",
")",
";",
"return",
"this",
";",
"}",
"// only remove if we have the event map in the first place",
"var",
"handlerSet",
"=",
"objMap",
".",
"get",
"(",
"thisArg",
")",
";",
"if",
"(",
"handlerSet",
"!==",
"undefined",
")",
"{",
"handlerSet",
"[",
"\"delete\"",
"]",
"(",
"handler",
")",
";",
"if",
"(",
"handlerSet",
".",
"size",
"===",
"0",
")",
"{",
"eH",
"[",
"\"delete\"",
"]",
"(",
"objMap",
")",
";",
"}",
"}",
"}",
"return",
"this",
";",
"}"
] | Removes handlers from an event. This one is a bit complicated, because it supports various
overloads that do slightly different things.
* If `evt`, `handler`, and `thisArg` are supplied, the handler is removed as would be expected.
If no `thisArg` is supplied, the `handler` is removed from the `null` category.
* If `handler` is an object and not a method, it is assumed to be `thisArg`. With no handlers
specified to remove, _all_ handlers within the object map are removed.
* If only an `evt` is specified, all handlers and objects are removed.
* If no parameters are supplied, all handlers are removed for all events.
@param {string|Array<string>|Object} [evt]
@param {function|Object} [handler]
@param {Object} [thisArg]
@returns {Emitter} | [
"Removes",
"handlers",
"from",
"an",
"event",
".",
"This",
"one",
"is",
"a",
"bit",
"complicated",
"because",
"it",
"supports",
"various",
"overloads",
"that",
"do",
"slightly",
"different",
"things",
"."
] | f972cb6f0304a54a8c16626f2a850a2371384c18 | https://github.com/photokandyStudios/yasmf-emitter/blob/f972cb6f0304a54a8c16626f2a850a2371384c18/lib/index.js#L197-L245 |
51,123 | photokandyStudios/yasmf-emitter | lib/index.js | once | function once(evt, handler) {
var thisArg = arguments[2] === undefined ? null : arguments[2];
var wrapper = undefined,
self = this;
// add a wrapper around the handler and listen to the requested event
this.on(evt, wrapper = function () {
for (var _len4 = arguments.length, args = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
args[_key4] = arguments[_key4];
}
try {
handler.apply.apply(handler, [thisArg].concat(args));
} catch (err) {
console.error("ONCE handler received an error: " + err.message + ", " + JSON.stringify(err));
} finally {
// remove the wrapper so that the event doesn't call us again
self.off(evt, wrapper, thisArg);
}
}, thisArg);
} | javascript | function once(evt, handler) {
var thisArg = arguments[2] === undefined ? null : arguments[2];
var wrapper = undefined,
self = this;
// add a wrapper around the handler and listen to the requested event
this.on(evt, wrapper = function () {
for (var _len4 = arguments.length, args = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
args[_key4] = arguments[_key4];
}
try {
handler.apply.apply(handler, [thisArg].concat(args));
} catch (err) {
console.error("ONCE handler received an error: " + err.message + ", " + JSON.stringify(err));
} finally {
// remove the wrapper so that the event doesn't call us again
self.off(evt, wrapper, thisArg);
}
}, thisArg);
} | [
"function",
"once",
"(",
"evt",
",",
"handler",
")",
"{",
"var",
"thisArg",
"=",
"arguments",
"[",
"2",
"]",
"===",
"undefined",
"?",
"null",
":",
"arguments",
"[",
"2",
"]",
";",
"var",
"wrapper",
"=",
"undefined",
",",
"self",
"=",
"this",
";",
"// add a wrapper around the handler and listen to the requested event",
"this",
".",
"on",
"(",
"evt",
",",
"wrapper",
"=",
"function",
"(",
")",
"{",
"for",
"(",
"var",
"_len4",
"=",
"arguments",
".",
"length",
",",
"args",
"=",
"Array",
"(",
"_len4",
")",
",",
"_key4",
"=",
"0",
";",
"_key4",
"<",
"_len4",
";",
"_key4",
"++",
")",
"{",
"args",
"[",
"_key4",
"]",
"=",
"arguments",
"[",
"_key4",
"]",
";",
"}",
"try",
"{",
"handler",
".",
"apply",
".",
"apply",
"(",
"handler",
",",
"[",
"thisArg",
"]",
".",
"concat",
"(",
"args",
")",
")",
";",
"}",
"catch",
"(",
"err",
")",
"{",
"console",
".",
"error",
"(",
"\"ONCE handler received an error: \"",
"+",
"err",
".",
"message",
"+",
"\", \"",
"+",
"JSON",
".",
"stringify",
"(",
"err",
")",
")",
";",
"}",
"finally",
"{",
"// remove the wrapper so that the event doesn't call us again",
"self",
".",
"off",
"(",
"evt",
",",
"wrapper",
",",
"thisArg",
")",
";",
"}",
"}",
",",
"thisArg",
")",
";",
"}"
] | Register a handler that will execute once for an event. Otherwise the same as `on`.
@param {string|Array<string>|Object} evt
@param {function} handler
@param {Object} [thisArg] | [
"Register",
"a",
"handler",
"that",
"will",
"execute",
"once",
"for",
"an",
"event",
".",
"Otherwise",
"the",
"same",
"as",
"on",
"."
] | f972cb6f0304a54a8c16626f2a850a2371384c18 | https://github.com/photokandyStudios/yasmf-emitter/blob/f972cb6f0304a54a8c16626f2a850a2371384c18/lib/index.js#L255-L275 |
51,124 | photokandyStudios/yasmf-emitter | lib/index.js | emitSyncFlag | function emitSyncFlag(evt, args) {
var _this3 = this;
var async = arguments[2] === undefined ? true : arguments[2];
var sender = this,
eH = this[_eventHandlers];
// emit locally first to onEvent handlers
try {
(function () {
var onEvent = "on:" + evt,
sanitizedEvent = evt.replace(/\:/g, "_"),
onSanitizedEvent = "on" + sanitizedEvent,
ProperEventCase = sanitizedEvent[0].toUpperCase() + sanitizedEvent.substr(1),
onProperEventCase = "on" + ProperEventCase,
localHandler = undefined;
if (_this3[onEvent]) {
localHandler = _this3[onEvent];
} else if (_this3[onSanitizedEvent]) {
localHandler = _this3[onSanitizedEvent];
} else if (_this3[onProperEventCase]) {
localHandler = _this3[onProperEventCase];
}
if (localHandler) {
if (async) {
setImmediate(function () {
tryWrapper.apply(undefined, [localHandler.bind(sender), sender, evt].concat(_toConsumableArray(args)));
});
} else {
tryWrapper.apply(undefined, [localHandler.bind(sender), sender, evt].concat(_toConsumableArray(args)));
}
}
})();
} catch (err) {
console.log("EMITTER WARNING: Something broke while trying to call local methods.", err);
}
core.Array.from(eH)
// for all the registered event categories, filter out the events that we really care about
.filter(function (_ref3) {
var _ref32 = _slicedToArray(_ref3, 1);
var potentialEvent = _ref32[0];
if (potentialEvent[0] !== "/") {
// the event isn't a regexp -- do a direct string compare
return potentialEvent === evt;
} else {
// the event IS a regexp. Split on /, which returns an array of [ don't-care, expression, flags ]
var _potentialEvent$split = potentialEvent.split("/");
var _potentialEvent$split2 = _slicedToArray(_potentialEvent$split, 3);
var exp = _potentialEvent$split2[1];
var flags = _potentialEvent$split2[2];
// Return the result of the new regular expression.
// TODO: I suppose we should think about caching the regular expression objects for performance.
return new RegExp(exp, flags).test(evt);
}
})
// and now we want to call each handler
.forEach(function (_ref4) {
var _ref42 = _slicedToArray(_ref4, 2);
var objMap = _ref42[1];
objMap.forEach(function (handlerSet, thisArg) {
if (handlerSet !== undefined) {
handlerSet.forEach(function (handler) {
if (async) {
setImmediate(function () {
tryWrapper.apply(undefined, [handler.bind(thisArg), sender, evt].concat(_toConsumableArray(args)));
});
} else {
tryWrapper.apply(undefined, [handler.bind(thisArg), sender, evt].concat(_toConsumableArray(args)));
}
});
}
});
});
} | javascript | function emitSyncFlag(evt, args) {
var _this3 = this;
var async = arguments[2] === undefined ? true : arguments[2];
var sender = this,
eH = this[_eventHandlers];
// emit locally first to onEvent handlers
try {
(function () {
var onEvent = "on:" + evt,
sanitizedEvent = evt.replace(/\:/g, "_"),
onSanitizedEvent = "on" + sanitizedEvent,
ProperEventCase = sanitizedEvent[0].toUpperCase() + sanitizedEvent.substr(1),
onProperEventCase = "on" + ProperEventCase,
localHandler = undefined;
if (_this3[onEvent]) {
localHandler = _this3[onEvent];
} else if (_this3[onSanitizedEvent]) {
localHandler = _this3[onSanitizedEvent];
} else if (_this3[onProperEventCase]) {
localHandler = _this3[onProperEventCase];
}
if (localHandler) {
if (async) {
setImmediate(function () {
tryWrapper.apply(undefined, [localHandler.bind(sender), sender, evt].concat(_toConsumableArray(args)));
});
} else {
tryWrapper.apply(undefined, [localHandler.bind(sender), sender, evt].concat(_toConsumableArray(args)));
}
}
})();
} catch (err) {
console.log("EMITTER WARNING: Something broke while trying to call local methods.", err);
}
core.Array.from(eH)
// for all the registered event categories, filter out the events that we really care about
.filter(function (_ref3) {
var _ref32 = _slicedToArray(_ref3, 1);
var potentialEvent = _ref32[0];
if (potentialEvent[0] !== "/") {
// the event isn't a regexp -- do a direct string compare
return potentialEvent === evt;
} else {
// the event IS a regexp. Split on /, which returns an array of [ don't-care, expression, flags ]
var _potentialEvent$split = potentialEvent.split("/");
var _potentialEvent$split2 = _slicedToArray(_potentialEvent$split, 3);
var exp = _potentialEvent$split2[1];
var flags = _potentialEvent$split2[2];
// Return the result of the new regular expression.
// TODO: I suppose we should think about caching the regular expression objects for performance.
return new RegExp(exp, flags).test(evt);
}
})
// and now we want to call each handler
.forEach(function (_ref4) {
var _ref42 = _slicedToArray(_ref4, 2);
var objMap = _ref42[1];
objMap.forEach(function (handlerSet, thisArg) {
if (handlerSet !== undefined) {
handlerSet.forEach(function (handler) {
if (async) {
setImmediate(function () {
tryWrapper.apply(undefined, [handler.bind(thisArg), sender, evt].concat(_toConsumableArray(args)));
});
} else {
tryWrapper.apply(undefined, [handler.bind(thisArg), sender, evt].concat(_toConsumableArray(args)));
}
});
}
});
});
} | [
"function",
"emitSyncFlag",
"(",
"evt",
",",
"args",
")",
"{",
"var",
"_this3",
"=",
"this",
";",
"var",
"async",
"=",
"arguments",
"[",
"2",
"]",
"===",
"undefined",
"?",
"true",
":",
"arguments",
"[",
"2",
"]",
";",
"var",
"sender",
"=",
"this",
",",
"eH",
"=",
"this",
"[",
"_eventHandlers",
"]",
";",
"// emit locally first to onEvent handlers",
"try",
"{",
"(",
"function",
"(",
")",
"{",
"var",
"onEvent",
"=",
"\"on:\"",
"+",
"evt",
",",
"sanitizedEvent",
"=",
"evt",
".",
"replace",
"(",
"/",
"\\:",
"/",
"g",
",",
"\"_\"",
")",
",",
"onSanitizedEvent",
"=",
"\"on\"",
"+",
"sanitizedEvent",
",",
"ProperEventCase",
"=",
"sanitizedEvent",
"[",
"0",
"]",
".",
"toUpperCase",
"(",
")",
"+",
"sanitizedEvent",
".",
"substr",
"(",
"1",
")",
",",
"onProperEventCase",
"=",
"\"on\"",
"+",
"ProperEventCase",
",",
"localHandler",
"=",
"undefined",
";",
"if",
"(",
"_this3",
"[",
"onEvent",
"]",
")",
"{",
"localHandler",
"=",
"_this3",
"[",
"onEvent",
"]",
";",
"}",
"else",
"if",
"(",
"_this3",
"[",
"onSanitizedEvent",
"]",
")",
"{",
"localHandler",
"=",
"_this3",
"[",
"onSanitizedEvent",
"]",
";",
"}",
"else",
"if",
"(",
"_this3",
"[",
"onProperEventCase",
"]",
")",
"{",
"localHandler",
"=",
"_this3",
"[",
"onProperEventCase",
"]",
";",
"}",
"if",
"(",
"localHandler",
")",
"{",
"if",
"(",
"async",
")",
"{",
"setImmediate",
"(",
"function",
"(",
")",
"{",
"tryWrapper",
".",
"apply",
"(",
"undefined",
",",
"[",
"localHandler",
".",
"bind",
"(",
"sender",
")",
",",
"sender",
",",
"evt",
"]",
".",
"concat",
"(",
"_toConsumableArray",
"(",
"args",
")",
")",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"tryWrapper",
".",
"apply",
"(",
"undefined",
",",
"[",
"localHandler",
".",
"bind",
"(",
"sender",
")",
",",
"sender",
",",
"evt",
"]",
".",
"concat",
"(",
"_toConsumableArray",
"(",
"args",
")",
")",
")",
";",
"}",
"}",
"}",
")",
"(",
")",
";",
"}",
"catch",
"(",
"err",
")",
"{",
"console",
".",
"log",
"(",
"\"EMITTER WARNING: Something broke while trying to call local methods.\"",
",",
"err",
")",
";",
"}",
"core",
".",
"Array",
".",
"from",
"(",
"eH",
")",
"// for all the registered event categories, filter out the events that we really care about",
".",
"filter",
"(",
"function",
"(",
"_ref3",
")",
"{",
"var",
"_ref32",
"=",
"_slicedToArray",
"(",
"_ref3",
",",
"1",
")",
";",
"var",
"potentialEvent",
"=",
"_ref32",
"[",
"0",
"]",
";",
"if",
"(",
"potentialEvent",
"[",
"0",
"]",
"!==",
"\"/\"",
")",
"{",
"// the event isn't a regexp -- do a direct string compare",
"return",
"potentialEvent",
"===",
"evt",
";",
"}",
"else",
"{",
"// the event IS a regexp. Split on /, which returns an array of [ don't-care, expression, flags ]",
"var",
"_potentialEvent$split",
"=",
"potentialEvent",
".",
"split",
"(",
"\"/\"",
")",
";",
"var",
"_potentialEvent$split2",
"=",
"_slicedToArray",
"(",
"_potentialEvent$split",
",",
"3",
")",
";",
"var",
"exp",
"=",
"_potentialEvent$split2",
"[",
"1",
"]",
";",
"var",
"flags",
"=",
"_potentialEvent$split2",
"[",
"2",
"]",
";",
"// Return the result of the new regular expression.",
"// TODO: I suppose we should think about caching the regular expression objects for performance.",
"return",
"new",
"RegExp",
"(",
"exp",
",",
"flags",
")",
".",
"test",
"(",
"evt",
")",
";",
"}",
"}",
")",
"// and now we want to call each handler",
".",
"forEach",
"(",
"function",
"(",
"_ref4",
")",
"{",
"var",
"_ref42",
"=",
"_slicedToArray",
"(",
"_ref4",
",",
"2",
")",
";",
"var",
"objMap",
"=",
"_ref42",
"[",
"1",
"]",
";",
"objMap",
".",
"forEach",
"(",
"function",
"(",
"handlerSet",
",",
"thisArg",
")",
"{",
"if",
"(",
"handlerSet",
"!==",
"undefined",
")",
"{",
"handlerSet",
".",
"forEach",
"(",
"function",
"(",
"handler",
")",
"{",
"if",
"(",
"async",
")",
"{",
"setImmediate",
"(",
"function",
"(",
")",
"{",
"tryWrapper",
".",
"apply",
"(",
"undefined",
",",
"[",
"handler",
".",
"bind",
"(",
"thisArg",
")",
",",
"sender",
",",
"evt",
"]",
".",
"concat",
"(",
"_toConsumableArray",
"(",
"args",
")",
")",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"tryWrapper",
".",
"apply",
"(",
"undefined",
",",
"[",
"handler",
".",
"bind",
"(",
"thisArg",
")",
",",
"sender",
",",
"evt",
"]",
".",
"concat",
"(",
"_toConsumableArray",
"(",
"args",
")",
")",
")",
";",
"}",
"}",
")",
";",
"}",
"}",
")",
";",
"}",
")",
";",
"}"
] | Emit an event, specifying whether or not the event is synchronous or async.
@param {string} evt
@param {Array<*>} args
@param {boolean} [async] | [
"Emit",
"an",
"event",
"specifying",
"whether",
"or",
"not",
"the",
"event",
"is",
"synchronous",
"or",
"async",
"."
] | f972cb6f0304a54a8c16626f2a850a2371384c18 | https://github.com/photokandyStudios/yasmf-emitter/blob/f972cb6f0304a54a8c16626f2a850a2371384c18/lib/index.js#L286-L370 |
51,125 | photokandyStudios/yasmf-emitter | lib/index.js | allOffFor | function allOffFor(o) {
var eH = this[_eventHandlers];
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = eH[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var _step$value = _slicedToArray(_step.value, 2);
var evt = _step$value[0];
var objMap = _step$value[1];
if (objMap !== undefined) {
objMap["delete"](o);
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator["return"]) {
_iterator["return"]();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
return this;
} | javascript | function allOffFor(o) {
var eH = this[_eventHandlers];
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = eH[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var _step$value = _slicedToArray(_step.value, 2);
var evt = _step$value[0];
var objMap = _step$value[1];
if (objMap !== undefined) {
objMap["delete"](o);
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator["return"]) {
_iterator["return"]();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
return this;
} | [
"function",
"allOffFor",
"(",
"o",
")",
"{",
"var",
"eH",
"=",
"this",
"[",
"_eventHandlers",
"]",
";",
"var",
"_iteratorNormalCompletion",
"=",
"true",
";",
"var",
"_didIteratorError",
"=",
"false",
";",
"var",
"_iteratorError",
"=",
"undefined",
";",
"try",
"{",
"for",
"(",
"var",
"_iterator",
"=",
"eH",
"[",
"Symbol",
".",
"iterator",
"]",
"(",
")",
",",
"_step",
";",
"!",
"(",
"_iteratorNormalCompletion",
"=",
"(",
"_step",
"=",
"_iterator",
".",
"next",
"(",
")",
")",
".",
"done",
")",
";",
"_iteratorNormalCompletion",
"=",
"true",
")",
"{",
"var",
"_step$value",
"=",
"_slicedToArray",
"(",
"_step",
".",
"value",
",",
"2",
")",
";",
"var",
"evt",
"=",
"_step$value",
"[",
"0",
"]",
";",
"var",
"objMap",
"=",
"_step$value",
"[",
"1",
"]",
";",
"if",
"(",
"objMap",
"!==",
"undefined",
")",
"{",
"objMap",
"[",
"\"delete\"",
"]",
"(",
"o",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"err",
")",
"{",
"_didIteratorError",
"=",
"true",
";",
"_iteratorError",
"=",
"err",
";",
"}",
"finally",
"{",
"try",
"{",
"if",
"(",
"!",
"_iteratorNormalCompletion",
"&&",
"_iterator",
"[",
"\"return\"",
"]",
")",
"{",
"_iterator",
"[",
"\"return\"",
"]",
"(",
")",
";",
"}",
"}",
"finally",
"{",
"if",
"(",
"_didIteratorError",
")",
"{",
"throw",
"_iteratorError",
";",
"}",
"}",
"}",
"return",
"this",
";",
"}"
] | Removes all handlers for all events for the supplied object.
@param {Object} o
@returns {Emitter} | [
"Removes",
"all",
"handlers",
"for",
"all",
"events",
"for",
"the",
"supplied",
"object",
"."
] | f972cb6f0304a54a8c16626f2a850a2371384c18 | https://github.com/photokandyStudios/yasmf-emitter/blob/f972cb6f0304a54a8c16626f2a850a2371384c18/lib/index.js#L409-L442 |
51,126 | novadiscovery/nway | lib/buildTree.js | builder | function builder(fromUID, node) {
debug('builder fromUID:%s',fromUID);
// Create a node (or use the provided one)
var node = node || new DepNode((packageId++).toString(), options);
// Get the entry point module object
var fromModule = findModule(fromUID);
// Add entry point to the module
node.addModule(fromModule);
debug(' fromModule.req.length:%s', fromModule.req.length);
// For each module dependency, add module to
// the node
_.each(fromModule.req, function(link) {
var module = findModule(link.uid);
// Duplicate : pass
if(node.hasModule(module.uid)) return;
if(link.async) {
debug(' Add async module (%s) to node %s', link.uid, node.id);
// Async : Create a child node
node.appendChild(builder(link.uid));
} else {
debug(' Add sync module (%s) to node %s', link.uid, node.id);
// Sync : add module
node.addModule(module);
builder(link.uid, node);
}
});
return node;
} | javascript | function builder(fromUID, node) {
debug('builder fromUID:%s',fromUID);
// Create a node (or use the provided one)
var node = node || new DepNode((packageId++).toString(), options);
// Get the entry point module object
var fromModule = findModule(fromUID);
// Add entry point to the module
node.addModule(fromModule);
debug(' fromModule.req.length:%s', fromModule.req.length);
// For each module dependency, add module to
// the node
_.each(fromModule.req, function(link) {
var module = findModule(link.uid);
// Duplicate : pass
if(node.hasModule(module.uid)) return;
if(link.async) {
debug(' Add async module (%s) to node %s', link.uid, node.id);
// Async : Create a child node
node.appendChild(builder(link.uid));
} else {
debug(' Add sync module (%s) to node %s', link.uid, node.id);
// Sync : add module
node.addModule(module);
builder(link.uid, node);
}
});
return node;
} | [
"function",
"builder",
"(",
"fromUID",
",",
"node",
")",
"{",
"debug",
"(",
"'builder fromUID:%s'",
",",
"fromUID",
")",
";",
"// Create a node (or use the provided one)",
"var",
"node",
"=",
"node",
"||",
"new",
"DepNode",
"(",
"(",
"packageId",
"++",
")",
".",
"toString",
"(",
")",
",",
"options",
")",
";",
"// Get the entry point module object",
"var",
"fromModule",
"=",
"findModule",
"(",
"fromUID",
")",
";",
"// Add entry point to the module",
"node",
".",
"addModule",
"(",
"fromModule",
")",
";",
"debug",
"(",
"' fromModule.req.length:%s'",
",",
"fromModule",
".",
"req",
".",
"length",
")",
";",
"// For each module dependency, add module to",
"// the node",
"_",
".",
"each",
"(",
"fromModule",
".",
"req",
",",
"function",
"(",
"link",
")",
"{",
"var",
"module",
"=",
"findModule",
"(",
"link",
".",
"uid",
")",
";",
"// Duplicate : pass",
"if",
"(",
"node",
".",
"hasModule",
"(",
"module",
".",
"uid",
")",
")",
"return",
";",
"if",
"(",
"link",
".",
"async",
")",
"{",
"debug",
"(",
"' Add async module (%s) to node %s'",
",",
"link",
".",
"uid",
",",
"node",
".",
"id",
")",
";",
"// Async : Create a child node",
"node",
".",
"appendChild",
"(",
"builder",
"(",
"link",
".",
"uid",
")",
")",
";",
"}",
"else",
"{",
"debug",
"(",
"' Add sync module (%s) to node %s'",
",",
"link",
".",
"uid",
",",
"node",
".",
"id",
")",
";",
"// Sync : add module",
"node",
".",
"addModule",
"(",
"module",
")",
";",
"builder",
"(",
"link",
".",
"uid",
",",
"node",
")",
";",
"}",
"}",
")",
";",
"return",
"node",
";",
"}"
] | Build a module dependency tree
@param {string} fromUID Entry point module uniq id
@param {DepNode|null} node parent DepNode
@return {DepNode} A DepNode object (traversable as a DepNode tree)
@api public | [
"Build",
"a",
"module",
"dependency",
"tree"
] | fa31c6fe56f2305721e581ac25e8ac9a87e15dda | https://github.com/novadiscovery/nway/blob/fa31c6fe56f2305721e581ac25e8ac9a87e15dda/lib/buildTree.js#L73-L111 |
51,127 | mattfenwick/clojarse-js | lib/ast.js | extract | function extract(token) {
var obj = {};
Object.keys(token).map(function(k) {
if ( !ignore.has(k) ) {
obj[k] = token[k];
}
});
return obj;
} | javascript | function extract(token) {
var obj = {};
Object.keys(token).map(function(k) {
if ( !ignore.has(k) ) {
obj[k] = token[k];
}
});
return obj;
} | [
"function",
"extract",
"(",
"token",
")",
"{",
"var",
"obj",
"=",
"{",
"}",
";",
"Object",
".",
"keys",
"(",
"token",
")",
".",
"map",
"(",
"function",
"(",
"k",
")",
"{",
"if",
"(",
"!",
"ignore",
".",
"has",
"(",
"k",
")",
")",
"{",
"obj",
"[",
"k",
"]",
"=",
"token",
"[",
"k",
"]",
";",
"}",
"}",
")",
";",
"return",
"obj",
";",
"}"
] | make a copy of an object, minus certain keys | [
"make",
"a",
"copy",
"of",
"an",
"object",
"minus",
"certain",
"keys"
] | 750321d5b80bb4c1c4aeedf2b994699d2cdfb979 | https://github.com/mattfenwick/clojarse-js/blob/750321d5b80bb4c1c4aeedf2b994699d2cdfb979/lib/ast.js#L46-L54 |
51,128 | MostlyJS/mostly-poplarjs | src/poplar.js | mergeListeners | function mergeListeners(emitter) {
var events = emitter._events;
_.each(events, function (fns, type) {
if (Array.isArray(fns)) {
_.each(fns, function (fn) {
if (_.isFunction(fn)) {
self.on(type, fn);
}
});
} else if (_.isFunction(fns)) {
self.on(type, fns);
}
});
} | javascript | function mergeListeners(emitter) {
var events = emitter._events;
_.each(events, function (fns, type) {
if (Array.isArray(fns)) {
_.each(fns, function (fn) {
if (_.isFunction(fn)) {
self.on(type, fn);
}
});
} else if (_.isFunction(fns)) {
self.on(type, fns);
}
});
} | [
"function",
"mergeListeners",
"(",
"emitter",
")",
"{",
"var",
"events",
"=",
"emitter",
".",
"_events",
";",
"_",
".",
"each",
"(",
"events",
",",
"function",
"(",
"fns",
",",
"type",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"fns",
")",
")",
"{",
"_",
".",
"each",
"(",
"fns",
",",
"function",
"(",
"fn",
")",
"{",
"if",
"(",
"_",
".",
"isFunction",
"(",
"fn",
")",
")",
"{",
"self",
".",
"on",
"(",
"type",
",",
"fn",
")",
";",
"}",
"}",
")",
";",
"}",
"else",
"if",
"(",
"_",
".",
"isFunction",
"(",
"fns",
")",
")",
"{",
"self",
".",
"on",
"(",
"type",
",",
"fns",
")",
";",
"}",
"}",
")",
";",
"}"
] | look up all ApiBuilder listeners then add it to api | [
"look",
"up",
"all",
"ApiBuilder",
"listeners",
"then",
"add",
"it",
"to",
"api"
] | bda12a72891e8c8d338e7560e7fe9e11ad74a2d9 | https://github.com/MostlyJS/mostly-poplarjs/blob/bda12a72891e8c8d338e7560e7fe9e11ad74a2d9/src/poplar.js#L87-L100 |
51,129 | MostlyJS/mostly-poplarjs | src/poplar.js | mergeMethods | function mergeMethods(builder) {
var methods = builder.methods();
_.each(methods, function (fn, methodName) {
// e.g.: users.getUserInfo
self._methods[util.format('%s.%s', name, methodName)] = fn;
});
} | javascript | function mergeMethods(builder) {
var methods = builder.methods();
_.each(methods, function (fn, methodName) {
// e.g.: users.getUserInfo
self._methods[util.format('%s.%s', name, methodName)] = fn;
});
} | [
"function",
"mergeMethods",
"(",
"builder",
")",
"{",
"var",
"methods",
"=",
"builder",
".",
"methods",
"(",
")",
";",
"_",
".",
"each",
"(",
"methods",
",",
"function",
"(",
"fn",
",",
"methodName",
")",
"{",
"// e.g.: users.getUserInfo",
"self",
".",
"_methods",
"[",
"util",
".",
"format",
"(",
"'%s.%s'",
",",
"name",
",",
"methodName",
")",
"]",
"=",
"fn",
";",
"}",
")",
";",
"}"
] | look up all ApiBuilder methods then add it to api | [
"look",
"up",
"all",
"ApiBuilder",
"methods",
"then",
"add",
"it",
"to",
"api"
] | bda12a72891e8c8d338e7560e7fe9e11ad74a2d9 | https://github.com/MostlyJS/mostly-poplarjs/blob/bda12a72891e8c8d338e7560e7fe9e11ad74a2d9/src/poplar.js#L103-L109 |
51,130 | vesln/surround | lib/surround.js | Surround | function Surround(obj, pattern) {
var self = this;
var regEX = new RegExp(pattern);
for(var fn in obj) {
var orig = obj[fn];
if (typeof(orig) != "function" || !regEX.test(fn))
continue;
// Already surrouneded.
if (obj[fn].__stacks) {
this.stacks = obj[fn].__stacks;
return this;
}
this.stacks = this.defaults();
// The replace of the original function.
obj[fn] = function() {
self.stacks.before
.concat([orig], self.stacks.after)
.forEach(function(fn) {
fn.apply(obj, arguments);
});
};
// Resets the stack and returns the basic func back.
obj[fn].reset = function() {
obj[fn] = orig;
self.stacks = self.defaults();
};
// The stacks are cached in the func itself.
obj[fn].__stacks = this.stacks;
}
} | javascript | function Surround(obj, pattern) {
var self = this;
var regEX = new RegExp(pattern);
for(var fn in obj) {
var orig = obj[fn];
if (typeof(orig) != "function" || !regEX.test(fn))
continue;
// Already surrouneded.
if (obj[fn].__stacks) {
this.stacks = obj[fn].__stacks;
return this;
}
this.stacks = this.defaults();
// The replace of the original function.
obj[fn] = function() {
self.stacks.before
.concat([orig], self.stacks.after)
.forEach(function(fn) {
fn.apply(obj, arguments);
});
};
// Resets the stack and returns the basic func back.
obj[fn].reset = function() {
obj[fn] = orig;
self.stacks = self.defaults();
};
// The stacks are cached in the func itself.
obj[fn].__stacks = this.stacks;
}
} | [
"function",
"Surround",
"(",
"obj",
",",
"pattern",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"regEX",
"=",
"new",
"RegExp",
"(",
"pattern",
")",
";",
"for",
"(",
"var",
"fn",
"in",
"obj",
")",
"{",
"var",
"orig",
"=",
"obj",
"[",
"fn",
"]",
";",
"if",
"(",
"typeof",
"(",
"orig",
")",
"!=",
"\"function\"",
"||",
"!",
"regEX",
".",
"test",
"(",
"fn",
")",
")",
"continue",
";",
"// Already surrouneded.",
"if",
"(",
"obj",
"[",
"fn",
"]",
".",
"__stacks",
")",
"{",
"this",
".",
"stacks",
"=",
"obj",
"[",
"fn",
"]",
".",
"__stacks",
";",
"return",
"this",
";",
"}",
"this",
".",
"stacks",
"=",
"this",
".",
"defaults",
"(",
")",
";",
"// The replace of the original function.",
"obj",
"[",
"fn",
"]",
"=",
"function",
"(",
")",
"{",
"self",
".",
"stacks",
".",
"before",
".",
"concat",
"(",
"[",
"orig",
"]",
",",
"self",
".",
"stacks",
".",
"after",
")",
".",
"forEach",
"(",
"function",
"(",
"fn",
")",
"{",
"fn",
".",
"apply",
"(",
"obj",
",",
"arguments",
")",
";",
"}",
")",
";",
"}",
";",
"// Resets the stack and returns the basic func back.",
"obj",
"[",
"fn",
"]",
".",
"reset",
"=",
"function",
"(",
")",
"{",
"obj",
"[",
"fn",
"]",
"=",
"orig",
";",
"self",
".",
"stacks",
"=",
"self",
".",
"defaults",
"(",
")",
";",
"}",
";",
"// The stacks are cached in the func itself.",
"obj",
"[",
"fn",
"]",
".",
"__stacks",
"=",
"this",
".",
"stacks",
";",
"}",
"}"
] | Surround constructor.
@param {Object} Object
@param {Pattern} pattern
@constructor | [
"Surround",
"constructor",
"."
] | 665c261c0929610b3133a6746341522b59c5065f | https://github.com/vesln/surround/blob/665c261c0929610b3133a6746341522b59c5065f/lib/surround.js#L10-L47 |
51,131 | raincatcher-beta/raincatcher-file | lib/cloud/services/fileService.js | createTemporaryStorageFolder | function createTemporaryStorageFolder() {
fs.mkdir(imageDir, '0775', function(err) {
if (err && err.code !== 'EEXIST') {
console.log(err);
throw new Error(err);
}
});
} | javascript | function createTemporaryStorageFolder() {
fs.mkdir(imageDir, '0775', function(err) {
if (err && err.code !== 'EEXIST') {
console.log(err);
throw new Error(err);
}
});
} | [
"function",
"createTemporaryStorageFolder",
"(",
")",
"{",
"fs",
".",
"mkdir",
"(",
"imageDir",
",",
"'0775'",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
"&&",
"err",
".",
"code",
"!==",
"'EEXIST'",
")",
"{",
"console",
".",
"log",
"(",
"err",
")",
";",
"throw",
"new",
"Error",
"(",
"err",
")",
";",
"}",
"}",
")",
";",
"}"
] | Create temporary storage folder used by mutler to store files before
uploading to permanent storage | [
"Create",
"temporary",
"storage",
"folder",
"used",
"by",
"mutler",
"to",
"store",
"files",
"before",
"uploading",
"to",
"permanent",
"storage"
] | 1a4b5d53505eb381a3d4c0bd384e743c39886c1d | https://github.com/raincatcher-beta/raincatcher-file/blob/1a4b5d53505eb381a3d4c0bd384e743c39886c1d/lib/cloud/services/fileService.js#L15-L22 |
51,132 | raincatcher-beta/raincatcher-file | lib/cloud/services/fileService.js | writeStreamToFile | function writeStreamToFile(fileMeta, stream) {
var deferred = q.defer();
stream.on('end', function() {
deferred.resolve(fileMeta);
});
stream.on('error', function(error) {
deferred.reject(error);
});
var filename = imageDir + '/' + fileMeta.uid;
stream.pipe(fs.createWriteStream(filename));
return deferred.promise;
} | javascript | function writeStreamToFile(fileMeta, stream) {
var deferred = q.defer();
stream.on('end', function() {
deferred.resolve(fileMeta);
});
stream.on('error', function(error) {
deferred.reject(error);
});
var filename = imageDir + '/' + fileMeta.uid;
stream.pipe(fs.createWriteStream(filename));
return deferred.promise;
} | [
"function",
"writeStreamToFile",
"(",
"fileMeta",
",",
"stream",
")",
"{",
"var",
"deferred",
"=",
"q",
".",
"defer",
"(",
")",
";",
"stream",
".",
"on",
"(",
"'end'",
",",
"function",
"(",
")",
"{",
"deferred",
".",
"resolve",
"(",
"fileMeta",
")",
";",
"}",
")",
";",
"stream",
".",
"on",
"(",
"'error'",
",",
"function",
"(",
"error",
")",
"{",
"deferred",
".",
"reject",
"(",
"error",
")",
";",
"}",
")",
";",
"var",
"filename",
"=",
"imageDir",
"+",
"'/'",
"+",
"fileMeta",
".",
"uid",
";",
"stream",
".",
"pipe",
"(",
"fs",
".",
"createWriteStream",
"(",
"filename",
")",
")",
";",
"return",
"deferred",
".",
"promise",
";",
"}"
] | Utility function for saving file in temp folder
@param fileMeta
@param stream | [
"Utility",
"function",
"for",
"saving",
"file",
"in",
"temp",
"folder"
] | 1a4b5d53505eb381a3d4c0bd384e743c39886c1d | https://github.com/raincatcher-beta/raincatcher-file/blob/1a4b5d53505eb381a3d4c0bd384e743c39886c1d/lib/cloud/services/fileService.js#L29-L40 |
51,133 | raincatcher-beta/raincatcher-file | lib/cloud/services/fileService.js | parseBase64Stream | function parseBase64Stream(req) {
var passthrough = false;
var accumulation = '';
var stream = req.pipe(through(function(chunk, enc, callback) {
if (!passthrough) {
accumulation += chunk;
var test = ';base64,';
var index = accumulation.indexOf(test);
if (index > -1) {
passthrough = true;
chunk = accumulation.substr(index + test.length);
}
}
if (passthrough) {
this.push(chunk);
}
callback();
}))
.pipe(base64.decode());
return stream;
} | javascript | function parseBase64Stream(req) {
var passthrough = false;
var accumulation = '';
var stream = req.pipe(through(function(chunk, enc, callback) {
if (!passthrough) {
accumulation += chunk;
var test = ';base64,';
var index = accumulation.indexOf(test);
if (index > -1) {
passthrough = true;
chunk = accumulation.substr(index + test.length);
}
}
if (passthrough) {
this.push(chunk);
}
callback();
}))
.pipe(base64.decode());
return stream;
} | [
"function",
"parseBase64Stream",
"(",
"req",
")",
"{",
"var",
"passthrough",
"=",
"false",
";",
"var",
"accumulation",
"=",
"''",
";",
"var",
"stream",
"=",
"req",
".",
"pipe",
"(",
"through",
"(",
"function",
"(",
"chunk",
",",
"enc",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"passthrough",
")",
"{",
"accumulation",
"+=",
"chunk",
";",
"var",
"test",
"=",
"';base64,'",
";",
"var",
"index",
"=",
"accumulation",
".",
"indexOf",
"(",
"test",
")",
";",
"if",
"(",
"index",
">",
"-",
"1",
")",
"{",
"passthrough",
"=",
"true",
";",
"chunk",
"=",
"accumulation",
".",
"substr",
"(",
"index",
"+",
"test",
".",
"length",
")",
";",
"}",
"}",
"if",
"(",
"passthrough",
")",
"{",
"this",
".",
"push",
"(",
"chunk",
")",
";",
"}",
"callback",
"(",
")",
";",
"}",
")",
")",
".",
"pipe",
"(",
"base64",
".",
"decode",
"(",
")",
")",
";",
"return",
"stream",
";",
"}"
] | Parse Base64 URL into stream that can be saved as file.
@param req | [
"Parse",
"Base64",
"URL",
"into",
"stream",
"that",
"can",
"be",
"saved",
"as",
"file",
"."
] | 1a4b5d53505eb381a3d4c0bd384e743c39886c1d | https://github.com/raincatcher-beta/raincatcher-file/blob/1a4b5d53505eb381a3d4c0bd384e743c39886c1d/lib/cloud/services/fileService.js#L47-L67 |
51,134 | dgeorges/modeljs | src/model.js | function (thisProperty, callbackArgs) {
return function (callback) {
function notifyListener() {
if (Model.asyncEvents) {
setTimeout(function () {
callback.apply(thisProperty, callbackArgs);
}, 0);
} else {
callback.apply(thisProperty, callbackArgs);
}
}
if (Model.TRANSACTION_OPTIONS.flattenCallbacks || Model.TRANSACTION_OPTIONS.flattenCallbacksByHash) {
var callbackExecuted = false;
if (Model.TRANSACTION_OPTIONS.flattenCallbacks) {
if (executedCallbacks.indexOf(callback) === -1) { // Only call callback once
executedCallbacks.push(callback);
notifyListener();
callbackExecuted = true;
}
}
if (Model.TRANSACTION_OPTIONS.flattenCallbacksByHash) {
if (!callback.hash || callbackHashs.indexOf(callback.hash) === -1) { // Only call hash identified callback once
if (callback.hash) {
callbackHashs.push(callback.hash);
}
if (!callbackExecuted) {
notifyListener();
callbackExecuted = true;
}
}
}
} else {
notifyListener();
}
};
} | javascript | function (thisProperty, callbackArgs) {
return function (callback) {
function notifyListener() {
if (Model.asyncEvents) {
setTimeout(function () {
callback.apply(thisProperty, callbackArgs);
}, 0);
} else {
callback.apply(thisProperty, callbackArgs);
}
}
if (Model.TRANSACTION_OPTIONS.flattenCallbacks || Model.TRANSACTION_OPTIONS.flattenCallbacksByHash) {
var callbackExecuted = false;
if (Model.TRANSACTION_OPTIONS.flattenCallbacks) {
if (executedCallbacks.indexOf(callback) === -1) { // Only call callback once
executedCallbacks.push(callback);
notifyListener();
callbackExecuted = true;
}
}
if (Model.TRANSACTION_OPTIONS.flattenCallbacksByHash) {
if (!callback.hash || callbackHashs.indexOf(callback.hash) === -1) { // Only call hash identified callback once
if (callback.hash) {
callbackHashs.push(callback.hash);
}
if (!callbackExecuted) {
notifyListener();
callbackExecuted = true;
}
}
}
} else {
notifyListener();
}
};
} | [
"function",
"(",
"thisProperty",
",",
"callbackArgs",
")",
"{",
"return",
"function",
"(",
"callback",
")",
"{",
"function",
"notifyListener",
"(",
")",
"{",
"if",
"(",
"Model",
".",
"asyncEvents",
")",
"{",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"callback",
".",
"apply",
"(",
"thisProperty",
",",
"callbackArgs",
")",
";",
"}",
",",
"0",
")",
";",
"}",
"else",
"{",
"callback",
".",
"apply",
"(",
"thisProperty",
",",
"callbackArgs",
")",
";",
"}",
"}",
"if",
"(",
"Model",
".",
"TRANSACTION_OPTIONS",
".",
"flattenCallbacks",
"||",
"Model",
".",
"TRANSACTION_OPTIONS",
".",
"flattenCallbacksByHash",
")",
"{",
"var",
"callbackExecuted",
"=",
"false",
";",
"if",
"(",
"Model",
".",
"TRANSACTION_OPTIONS",
".",
"flattenCallbacks",
")",
"{",
"if",
"(",
"executedCallbacks",
".",
"indexOf",
"(",
"callback",
")",
"===",
"-",
"1",
")",
"{",
"// Only call callback once\r",
"executedCallbacks",
".",
"push",
"(",
"callback",
")",
";",
"notifyListener",
"(",
")",
";",
"callbackExecuted",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"Model",
".",
"TRANSACTION_OPTIONS",
".",
"flattenCallbacksByHash",
")",
"{",
"if",
"(",
"!",
"callback",
".",
"hash",
"||",
"callbackHashs",
".",
"indexOf",
"(",
"callback",
".",
"hash",
")",
"===",
"-",
"1",
")",
"{",
"// Only call hash identified callback once\r",
"if",
"(",
"callback",
".",
"hash",
")",
"{",
"callbackHashs",
".",
"push",
"(",
"callback",
".",
"hash",
")",
";",
"}",
"if",
"(",
"!",
"callbackExecuted",
")",
"{",
"notifyListener",
"(",
")",
";",
"callbackExecuted",
"=",
"true",
";",
"}",
"}",
"}",
"}",
"else",
"{",
"notifyListener",
"(",
")",
";",
"}",
"}",
";",
"}"
] | This weird executeCallback function is a bit more complicated than it needs to be but is used to get around the JSLint warning of creating a function within the while loop below | [
"This",
"weird",
"executeCallback",
"function",
"is",
"a",
"bit",
"more",
"complicated",
"than",
"it",
"needs",
"to",
"be",
"but",
"is",
"used",
"to",
"get",
"around",
"the",
"JSLint",
"warning",
"of",
"creating",
"a",
"function",
"within",
"the",
"while",
"loop",
"below"
] | 9a4f40a1c75c3a42cfeb451f9041a8186885f7b0 | https://github.com/dgeorges/modeljs/blob/9a4f40a1c75c3a42cfeb451f9041a8186885f7b0/src/model.js#L218-L255 |
|
51,135 | dgeorges/modeljs | src/model.js | Property | function Property (name, value, parent, metadata) {
var myName = "/" + name;
if (parent) {
myName = parent.getName() + myName;
}
Object.defineProperty(this, "_name", {
value: myName,
enumerable: false
});
Object.defineProperty(this, "_parent", {
value: parent,
enumerable: false,
writable: false,
configurable: true //set to configurable so we can delete it in destroy
});
Object.defineProperty(this, "_metadata", {
value: metadata || {},
enumerable: false
});
Object.defineProperty(this, "_eventListeners", {
value: { //map of eventName to listener array. The following are modeljs Events
propertyChange: [],
modelChange: [],
change: [],
childCreated: [],
childDestroyed: [],
destroy: [],
all: []
},
enumerable: false,
writable: false,
configurable: false
});
var myValue = value;
if (isFunction(myValue)) {
myValue = myValue.bind(parent);
}
//make sure value is valid
if (!this.validateValue(myValue)) {
myValue = undefined;
}
Object.defineProperty(this, "_myValue", {
value: myValue,
enumerable: false,
writable: true
});
} | javascript | function Property (name, value, parent, metadata) {
var myName = "/" + name;
if (parent) {
myName = parent.getName() + myName;
}
Object.defineProperty(this, "_name", {
value: myName,
enumerable: false
});
Object.defineProperty(this, "_parent", {
value: parent,
enumerable: false,
writable: false,
configurable: true //set to configurable so we can delete it in destroy
});
Object.defineProperty(this, "_metadata", {
value: metadata || {},
enumerable: false
});
Object.defineProperty(this, "_eventListeners", {
value: { //map of eventName to listener array. The following are modeljs Events
propertyChange: [],
modelChange: [],
change: [],
childCreated: [],
childDestroyed: [],
destroy: [],
all: []
},
enumerable: false,
writable: false,
configurable: false
});
var myValue = value;
if (isFunction(myValue)) {
myValue = myValue.bind(parent);
}
//make sure value is valid
if (!this.validateValue(myValue)) {
myValue = undefined;
}
Object.defineProperty(this, "_myValue", {
value: myValue,
enumerable: false,
writable: true
});
} | [
"function",
"Property",
"(",
"name",
",",
"value",
",",
"parent",
",",
"metadata",
")",
"{",
"var",
"myName",
"=",
"\"/\"",
"+",
"name",
";",
"if",
"(",
"parent",
")",
"{",
"myName",
"=",
"parent",
".",
"getName",
"(",
")",
"+",
"myName",
";",
"}",
"Object",
".",
"defineProperty",
"(",
"this",
",",
"\"_name\"",
",",
"{",
"value",
":",
"myName",
",",
"enumerable",
":",
"false",
"}",
")",
";",
"Object",
".",
"defineProperty",
"(",
"this",
",",
"\"_parent\"",
",",
"{",
"value",
":",
"parent",
",",
"enumerable",
":",
"false",
",",
"writable",
":",
"false",
",",
"configurable",
":",
"true",
"//set to configurable so we can delete it in destroy\r",
"}",
")",
";",
"Object",
".",
"defineProperty",
"(",
"this",
",",
"\"_metadata\"",
",",
"{",
"value",
":",
"metadata",
"||",
"{",
"}",
",",
"enumerable",
":",
"false",
"}",
")",
";",
"Object",
".",
"defineProperty",
"(",
"this",
",",
"\"_eventListeners\"",
",",
"{",
"value",
":",
"{",
"//map of eventName to listener array. The following are modeljs Events\r",
"propertyChange",
":",
"[",
"]",
",",
"modelChange",
":",
"[",
"]",
",",
"change",
":",
"[",
"]",
",",
"childCreated",
":",
"[",
"]",
",",
"childDestroyed",
":",
"[",
"]",
",",
"destroy",
":",
"[",
"]",
",",
"all",
":",
"[",
"]",
"}",
",",
"enumerable",
":",
"false",
",",
"writable",
":",
"false",
",",
"configurable",
":",
"false",
"}",
")",
";",
"var",
"myValue",
"=",
"value",
";",
"if",
"(",
"isFunction",
"(",
"myValue",
")",
")",
"{",
"myValue",
"=",
"myValue",
".",
"bind",
"(",
"parent",
")",
";",
"}",
"//make sure value is valid\r",
"if",
"(",
"!",
"this",
".",
"validateValue",
"(",
"myValue",
")",
")",
"{",
"myValue",
"=",
"undefined",
";",
"}",
"Object",
".",
"defineProperty",
"(",
"this",
",",
"\"_myValue\"",
",",
"{",
"value",
":",
"myValue",
",",
"enumerable",
":",
"false",
",",
"writable",
":",
"true",
"}",
")",
";",
"}"
] | A Property is a name value pair belonging to a Model.
@class Property
@constructor
@private used internally by the Model.prototype.createProperty method.
@param {[String]} name The name of the property
@param {[String, Boolean, Number, null, Date, Function, Object]} value The Property Value
@param {[Model]} parent The parent property
@param {[Object]} metadata The metadata associated with the property. You can put any metadata you want. However the following keys have special meaning and are reserved for use by the framework.
validator - a function to validate if the new value is valid before it is assigned.
url - the resource this model should use to get it's value. Resource must return json. *Must be used with refreshRate*
refreshRate - the interval used to query the url for changes. must be > 0. minimal value used is 100. -1 indicates to only fetch value once. *Must be used with url* | [
"A",
"Property",
"is",
"a",
"name",
"value",
"pair",
"belonging",
"to",
"a",
"Model",
"."
] | 9a4f40a1c75c3a42cfeb451f9041a8186885f7b0 | https://github.com/dgeorges/modeljs/blob/9a4f40a1c75c3a42cfeb451f9041a8186885f7b0/src/model.js#L441-L494 |
51,136 | dgeorges/modeljs | src/model.js | Model | function Model(json, metadata, parent) {
var jsonModel = json || {},
modelMetadata = metadata || {},
modelName = modelMetadata.name !== undefined? modelMetadata.name : "root",
modelParent = parent || null;
if (modelMetadata.name) { // name is not part of the metadata.
delete modelMetadata.name;
}
//A Model is in itself a Property so lets call our supers constructor
Property.call(this, modelName, jsonModel, modelParent, modelMetadata);
if (this.validateValue(jsonModel)) {
for (var name in jsonModel) {
if (name.match(Model.PROPERTY_METADATA_SERIALIZED_NAME_REGEX)) { // skip special meta data properties
continue;
}
var value = jsonModel[name];
var propertyMetadata = jsonModel[name + Model.PROPERTY_METADATA_SERIALIZED_NAME_SUFFIX];
if (!modelMetadata.thin) {
this.createProperty(name, value, propertyMetadata);
}
}
}
} | javascript | function Model(json, metadata, parent) {
var jsonModel = json || {},
modelMetadata = metadata || {},
modelName = modelMetadata.name !== undefined? modelMetadata.name : "root",
modelParent = parent || null;
if (modelMetadata.name) { // name is not part of the metadata.
delete modelMetadata.name;
}
//A Model is in itself a Property so lets call our supers constructor
Property.call(this, modelName, jsonModel, modelParent, modelMetadata);
if (this.validateValue(jsonModel)) {
for (var name in jsonModel) {
if (name.match(Model.PROPERTY_METADATA_SERIALIZED_NAME_REGEX)) { // skip special meta data properties
continue;
}
var value = jsonModel[name];
var propertyMetadata = jsonModel[name + Model.PROPERTY_METADATA_SERIALIZED_NAME_SUFFIX];
if (!modelMetadata.thin) {
this.createProperty(name, value, propertyMetadata);
}
}
}
} | [
"function",
"Model",
"(",
"json",
",",
"metadata",
",",
"parent",
")",
"{",
"var",
"jsonModel",
"=",
"json",
"||",
"{",
"}",
",",
"modelMetadata",
"=",
"metadata",
"||",
"{",
"}",
",",
"modelName",
"=",
"modelMetadata",
".",
"name",
"!==",
"undefined",
"?",
"modelMetadata",
".",
"name",
":",
"\"root\"",
",",
"modelParent",
"=",
"parent",
"||",
"null",
";",
"if",
"(",
"modelMetadata",
".",
"name",
")",
"{",
"// name is not part of the metadata.\r",
"delete",
"modelMetadata",
".",
"name",
";",
"}",
"//A Model is in itself a Property so lets call our supers constructor\r",
"Property",
".",
"call",
"(",
"this",
",",
"modelName",
",",
"jsonModel",
",",
"modelParent",
",",
"modelMetadata",
")",
";",
"if",
"(",
"this",
".",
"validateValue",
"(",
"jsonModel",
")",
")",
"{",
"for",
"(",
"var",
"name",
"in",
"jsonModel",
")",
"{",
"if",
"(",
"name",
".",
"match",
"(",
"Model",
".",
"PROPERTY_METADATA_SERIALIZED_NAME_REGEX",
")",
")",
"{",
"// skip special meta data properties\r",
"continue",
";",
"}",
"var",
"value",
"=",
"jsonModel",
"[",
"name",
"]",
";",
"var",
"propertyMetadata",
"=",
"jsonModel",
"[",
"name",
"+",
"Model",
".",
"PROPERTY_METADATA_SERIALIZED_NAME_SUFFIX",
"]",
";",
"if",
"(",
"!",
"modelMetadata",
".",
"thin",
")",
"{",
"this",
".",
"createProperty",
"(",
"name",
",",
"value",
",",
"propertyMetadata",
")",
";",
"}",
"}",
"}",
"}"
] | The model Object that wraps the JSON.
@example
For examples see: <b>testPrimitiveSaveLoad</b>, <b>testObjectsSaveLoad</b>, <b>testComplexSaveLoad</b>
<b>testGetNameMethod</b> and <b>testSaveLoadWithMetaData</b>
@class Model
@constructor
@extends Property
@param {Object} json? The json object to be modeled.
@param {Object} metadata? May contain the following:
name - name of the Model, defaults to "root"
*plus any properties accepted by the createProperty method metadata argument or
additional data you want stored in the metadata. | [
"The",
"model",
"Object",
"that",
"wraps",
"the",
"JSON",
"."
] | 9a4f40a1c75c3a42cfeb451f9041a8186885f7b0 | https://github.com/dgeorges/modeljs/blob/9a4f40a1c75c3a42cfeb451f9041a8186885f7b0/src/model.js#L1010-L1038 |
51,137 | dgeorges/modeljs | src/model.js | propergateEvent | function propergateEvent (isAtoB, property /*, ... other event callback arguments */) {
var eventName = arguments[arguments.length-1]; //Since this is registered on the all event the last argument is the orginal Event name.
if (eventName === Model.Event.CHILD_DESTROYED) { //we listen to he destroy action so no need to listen to CHILD_DESTROYED too
return;
}
if(options && (options.eventBlackList || options.eventWhiteList)) {
if (options.eventBlackList && options.eventBlackList.indexOf(eventName) !== -1) {
return;
}
if (options.eventWhiteList && options.eventWhiteList.indexOf(eventName) === -1) {
return;
}
}
var linkedProperty = this;
var newPropDisconnect;
var reversePropergationFunction = isAtoB? propergateDestToSrc: propergateSrcToDest;
// deregister our reverse propergation function and put it back later, so we don't have infinite loop.
if (reversePropergationFunction) { // this will not exist if the connection direction was "one-way"
linkedProperty.off(Model.Event.ALL, reversePropergationFunction);
}
if (eventName === Model.Event.PROPERTY_CHANGE) {
linkedProperty.setValue(property.getValue());
} else if (eventName === Model.Event.CHILD_CREATED) {
var newProperty = arguments[2];
if (Model.isArray(linkedProperty)) {
// newProperty.getShortName() == linkedProperty.length; <- do push when this is true
linkedProperty.push(newProperty.getValue());
newPropDisconnect = connect(newProperty, linkedProperty[newProperty.getShortName()]);
} else {
linkedProperty.createProperty(newProperty.getShortName(), newProperty.getValue(), newProperty.getMetadata());
newPropDisconnect = connect(newProperty, linkedProperty[newProperty.getShortName()]);
}
} else if (eventName === Model.Event.DESTROY) {
if (Model.isArray(linkedProperty._parent) &&
parseInt(linkedProperty.getShortName(), 10) === linkedProperty._parent.length - 1) {
linkedProperty._parent.pop();
} else {
linkedProperty.destroy();
}
} else { //custom event
// remove the first argument, 'isAtoB' which is bound to this function via bind
// also remove the second which is the property event triggered on
// extract the middle
// remove the last argument which is the event name since this method is registared to the Model.Event.ALL event.
var args = [eventName].concat(Array.prototype.slice.call(arguments, 2, arguments.length-1));
Property.prototype.trigger.apply(linkedProperty, args );
}
// only restore the connection if property is not destroyed
if (eventName !== Model.Event.DESTROY && reversePropergationFunction) {
linkedProperty.on(Model.Event.ALL, reversePropergationFunction);
}
return newPropDisconnect; // how do we disconnect this.
} | javascript | function propergateEvent (isAtoB, property /*, ... other event callback arguments */) {
var eventName = arguments[arguments.length-1]; //Since this is registered on the all event the last argument is the orginal Event name.
if (eventName === Model.Event.CHILD_DESTROYED) { //we listen to he destroy action so no need to listen to CHILD_DESTROYED too
return;
}
if(options && (options.eventBlackList || options.eventWhiteList)) {
if (options.eventBlackList && options.eventBlackList.indexOf(eventName) !== -1) {
return;
}
if (options.eventWhiteList && options.eventWhiteList.indexOf(eventName) === -1) {
return;
}
}
var linkedProperty = this;
var newPropDisconnect;
var reversePropergationFunction = isAtoB? propergateDestToSrc: propergateSrcToDest;
// deregister our reverse propergation function and put it back later, so we don't have infinite loop.
if (reversePropergationFunction) { // this will not exist if the connection direction was "one-way"
linkedProperty.off(Model.Event.ALL, reversePropergationFunction);
}
if (eventName === Model.Event.PROPERTY_CHANGE) {
linkedProperty.setValue(property.getValue());
} else if (eventName === Model.Event.CHILD_CREATED) {
var newProperty = arguments[2];
if (Model.isArray(linkedProperty)) {
// newProperty.getShortName() == linkedProperty.length; <- do push when this is true
linkedProperty.push(newProperty.getValue());
newPropDisconnect = connect(newProperty, linkedProperty[newProperty.getShortName()]);
} else {
linkedProperty.createProperty(newProperty.getShortName(), newProperty.getValue(), newProperty.getMetadata());
newPropDisconnect = connect(newProperty, linkedProperty[newProperty.getShortName()]);
}
} else if (eventName === Model.Event.DESTROY) {
if (Model.isArray(linkedProperty._parent) &&
parseInt(linkedProperty.getShortName(), 10) === linkedProperty._parent.length - 1) {
linkedProperty._parent.pop();
} else {
linkedProperty.destroy();
}
} else { //custom event
// remove the first argument, 'isAtoB' which is bound to this function via bind
// also remove the second which is the property event triggered on
// extract the middle
// remove the last argument which is the event name since this method is registared to the Model.Event.ALL event.
var args = [eventName].concat(Array.prototype.slice.call(arguments, 2, arguments.length-1));
Property.prototype.trigger.apply(linkedProperty, args );
}
// only restore the connection if property is not destroyed
if (eventName !== Model.Event.DESTROY && reversePropergationFunction) {
linkedProperty.on(Model.Event.ALL, reversePropergationFunction);
}
return newPropDisconnect; // how do we disconnect this.
} | [
"function",
"propergateEvent",
"(",
"isAtoB",
",",
"property",
"/*, ... other event callback arguments */",
")",
"{",
"var",
"eventName",
"=",
"arguments",
"[",
"arguments",
".",
"length",
"-",
"1",
"]",
";",
"//Since this is registered on the all event the last argument is the orginal Event name.\r",
"if",
"(",
"eventName",
"===",
"Model",
".",
"Event",
".",
"CHILD_DESTROYED",
")",
"{",
"//we listen to he destroy action so no need to listen to CHILD_DESTROYED too\r",
"return",
";",
"}",
"if",
"(",
"options",
"&&",
"(",
"options",
".",
"eventBlackList",
"||",
"options",
".",
"eventWhiteList",
")",
")",
"{",
"if",
"(",
"options",
".",
"eventBlackList",
"&&",
"options",
".",
"eventBlackList",
".",
"indexOf",
"(",
"eventName",
")",
"!==",
"-",
"1",
")",
"{",
"return",
";",
"}",
"if",
"(",
"options",
".",
"eventWhiteList",
"&&",
"options",
".",
"eventWhiteList",
".",
"indexOf",
"(",
"eventName",
")",
"===",
"-",
"1",
")",
"{",
"return",
";",
"}",
"}",
"var",
"linkedProperty",
"=",
"this",
";",
"var",
"newPropDisconnect",
";",
"var",
"reversePropergationFunction",
"=",
"isAtoB",
"?",
"propergateDestToSrc",
":",
"propergateSrcToDest",
";",
"// deregister our reverse propergation function and put it back later, so we don't have infinite loop.\r",
"if",
"(",
"reversePropergationFunction",
")",
"{",
"// this will not exist if the connection direction was \"one-way\"\r",
"linkedProperty",
".",
"off",
"(",
"Model",
".",
"Event",
".",
"ALL",
",",
"reversePropergationFunction",
")",
";",
"}",
"if",
"(",
"eventName",
"===",
"Model",
".",
"Event",
".",
"PROPERTY_CHANGE",
")",
"{",
"linkedProperty",
".",
"setValue",
"(",
"property",
".",
"getValue",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"eventName",
"===",
"Model",
".",
"Event",
".",
"CHILD_CREATED",
")",
"{",
"var",
"newProperty",
"=",
"arguments",
"[",
"2",
"]",
";",
"if",
"(",
"Model",
".",
"isArray",
"(",
"linkedProperty",
")",
")",
"{",
"// newProperty.getShortName() == linkedProperty.length; <- do push when this is true\r",
"linkedProperty",
".",
"push",
"(",
"newProperty",
".",
"getValue",
"(",
")",
")",
";",
"newPropDisconnect",
"=",
"connect",
"(",
"newProperty",
",",
"linkedProperty",
"[",
"newProperty",
".",
"getShortName",
"(",
")",
"]",
")",
";",
"}",
"else",
"{",
"linkedProperty",
".",
"createProperty",
"(",
"newProperty",
".",
"getShortName",
"(",
")",
",",
"newProperty",
".",
"getValue",
"(",
")",
",",
"newProperty",
".",
"getMetadata",
"(",
")",
")",
";",
"newPropDisconnect",
"=",
"connect",
"(",
"newProperty",
",",
"linkedProperty",
"[",
"newProperty",
".",
"getShortName",
"(",
")",
"]",
")",
";",
"}",
"}",
"else",
"if",
"(",
"eventName",
"===",
"Model",
".",
"Event",
".",
"DESTROY",
")",
"{",
"if",
"(",
"Model",
".",
"isArray",
"(",
"linkedProperty",
".",
"_parent",
")",
"&&",
"parseInt",
"(",
"linkedProperty",
".",
"getShortName",
"(",
")",
",",
"10",
")",
"===",
"linkedProperty",
".",
"_parent",
".",
"length",
"-",
"1",
")",
"{",
"linkedProperty",
".",
"_parent",
".",
"pop",
"(",
")",
";",
"}",
"else",
"{",
"linkedProperty",
".",
"destroy",
"(",
")",
";",
"}",
"}",
"else",
"{",
"//custom event\r",
"// remove the first argument, 'isAtoB' which is bound to this function via bind\r",
"// also remove the second which is the property event triggered on\r",
"// extract the middle\r",
"// remove the last argument which is the event name since this method is registared to the Model.Event.ALL event.\r",
"var",
"args",
"=",
"[",
"eventName",
"]",
".",
"concat",
"(",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
",",
"2",
",",
"arguments",
".",
"length",
"-",
"1",
")",
")",
";",
"Property",
".",
"prototype",
".",
"trigger",
".",
"apply",
"(",
"linkedProperty",
",",
"args",
")",
";",
"}",
"// only restore the connection if property is not destroyed\r",
"if",
"(",
"eventName",
"!==",
"Model",
".",
"Event",
".",
"DESTROY",
"&&",
"reversePropergationFunction",
")",
"{",
"linkedProperty",
".",
"on",
"(",
"Model",
".",
"Event",
".",
"ALL",
",",
"reversePropergationFunction",
")",
";",
"}",
"return",
"newPropDisconnect",
";",
"// how do we disconnect this.\r",
"}"
] | This function is registered on the ALL event to propagate its events to the
connected property. FYI 'this' is bound to the source linked property.
@param {Boolean} isAtoB [description]
@param {[type]} property On any event the first argument is the property the event was triggered on.
@return {[type]} [description] | [
"This",
"function",
"is",
"registered",
"on",
"the",
"ALL",
"event",
"to",
"propagate",
"its",
"events",
"to",
"the",
"connected",
"property",
".",
"FYI",
"this",
"is",
"bound",
"to",
"the",
"source",
"linked",
"property",
"."
] | 9a4f40a1c75c3a42cfeb451f9041a8186885f7b0 | https://github.com/dgeorges/modeljs/blob/9a4f40a1c75c3a42cfeb451f9041a8186885f7b0/src/model.js#L1542-L1599 |
51,138 | Canop/file-archive | index.js | writeNewAsync | function writeNewAsync(filepath, data){
return new Promise((resolve, reject)=>{
fs.writeFile(filepath, data ,{ flag: "wx" }, function(err){
if (!err) resolve(true)
else reject(err)
})
})
} | javascript | function writeNewAsync(filepath, data){
return new Promise((resolve, reject)=>{
fs.writeFile(filepath, data ,{ flag: "wx" }, function(err){
if (!err) resolve(true)
else reject(err)
})
})
} | [
"function",
"writeNewAsync",
"(",
"filepath",
",",
"data",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"fs",
".",
"writeFile",
"(",
"filepath",
",",
"data",
",",
"{",
"flag",
":",
"\"wx\"",
"}",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"!",
"err",
")",
"resolve",
"(",
"true",
")",
"else",
"reject",
"(",
"err",
")",
"}",
")",
"}",
")",
"}"
] | return a promise, fail with "EEXIST" when the file already exists | [
"return",
"a",
"promise",
"fail",
"with",
"EEXIST",
"when",
"the",
"file",
"already",
"exists"
] | 0b0aa383964f2dab78655a22a2e53683d79067c0 | https://github.com/Canop/file-archive/blob/0b0aa383964f2dab78655a22a2e53683d79067c0/index.js#L6-L13 |
51,139 | Canop/file-archive | index.js | readdirAsync | function readdirAsync(filepath){
return new Promise((resolve, reject)=>{
fs.readdir(filepath, (err, items)=>{
if (err) reject(err)
else resolve(items)
})
})
} | javascript | function readdirAsync(filepath){
return new Promise((resolve, reject)=>{
fs.readdir(filepath, (err, items)=>{
if (err) reject(err)
else resolve(items)
})
})
} | [
"function",
"readdirAsync",
"(",
"filepath",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"fs",
".",
"readdir",
"(",
"filepath",
",",
"(",
"err",
",",
"items",
")",
"=>",
"{",
"if",
"(",
"err",
")",
"reject",
"(",
"err",
")",
"else",
"resolve",
"(",
"items",
")",
"}",
")",
"}",
")",
"}"
] | simple promisification of fs.readdir | [
"simple",
"promisification",
"of",
"fs",
".",
"readdir"
] | 0b0aa383964f2dab78655a22a2e53683d79067c0 | https://github.com/Canop/file-archive/blob/0b0aa383964f2dab78655a22a2e53683d79067c0/index.js#L16-L23 |
51,140 | cli-kit/cli-middleware | index.js | raise | function raise(err, parameters, cause) {
if(!(err instanceof Error)) {
err = wrap(err, parameters, cause);
}
throw err;
} | javascript | function raise(err, parameters, cause) {
if(!(err instanceof Error)) {
err = wrap(err, parameters, cause);
}
throw err;
} | [
"function",
"raise",
"(",
"err",
",",
"parameters",
",",
"cause",
")",
"{",
"if",
"(",
"!",
"(",
"err",
"instanceof",
"Error",
")",
")",
"{",
"err",
"=",
"wrap",
"(",
"err",
",",
"parameters",
",",
"cause",
")",
";",
"}",
"throw",
"err",
";",
"}"
] | Default raise implementation.
@param err Error instance or string.
@param parameters Message replacement parameters.
@param cause An error that caused this error. | [
"Default",
"raise",
"implementation",
"."
] | 9ade9f64b2995940e2341df92a824b2f93df0228 | https://github.com/cli-kit/cli-middleware/blob/9ade9f64b2995940e2341df92a824b2f93df0228/index.js#L42-L47 |
51,141 | KyleBanks/cluster-utils | lib/Timeout.js | _runIfLocked | function _runIfLocked() {
var self = this;
self._clusterUtils._setLock(self.lockKey, function(err, lock) {
if (err) {
throw err;
} else if (!lock) {
return;
}
process.nextTick(self._func);
});
} | javascript | function _runIfLocked() {
var self = this;
self._clusterUtils._setLock(self.lockKey, function(err, lock) {
if (err) {
throw err;
} else if (!lock) {
return;
}
process.nextTick(self._func);
});
} | [
"function",
"_runIfLocked",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"self",
".",
"_clusterUtils",
".",
"_setLock",
"(",
"self",
".",
"lockKey",
",",
"function",
"(",
"err",
",",
"lock",
")",
"{",
"if",
"(",
"err",
")",
"{",
"throw",
"err",
";",
"}",
"else",
"if",
"(",
"!",
"lock",
")",
"{",
"return",
";",
"}",
"process",
".",
"nextTick",
"(",
"self",
".",
"_func",
")",
";",
"}",
")",
";",
"}"
] | Attempts to run the function provided if a lock can be achieved on the lock key. | [
"Attempts",
"to",
"run",
"the",
"function",
"provided",
"if",
"a",
"lock",
"can",
"be",
"achieved",
"on",
"the",
"lock",
"key",
"."
] | b24814ae413768b4bc671ee71dcc912c999bd20b | https://github.com/KyleBanks/cluster-utils/blob/b24814ae413768b4bc671ee71dcc912c999bd20b/lib/Timeout.js#L37-L49 |
51,142 | gethuman/pancakes-recipe | middleware/mw.auth.cookie.js | registerCookieJar | function registerCookieJar(server) {
var deferred = Q.defer();
server.register({
register: require('yar'),
options: {
cache: {
expiresIn: cookieConfig.ttl
},
cookieOptions: {
clearInvalid: true,
password: cookieConfig.password,
domain: cookieConfig.domain,
isSecure: cookieConfig.isSecure
}
}
}, function (err) {
err ? deferred.reject(err) : deferred.resolve(err);
});
return deferred.promise;
} | javascript | function registerCookieJar(server) {
var deferred = Q.defer();
server.register({
register: require('yar'),
options: {
cache: {
expiresIn: cookieConfig.ttl
},
cookieOptions: {
clearInvalid: true,
password: cookieConfig.password,
domain: cookieConfig.domain,
isSecure: cookieConfig.isSecure
}
}
}, function (err) {
err ? deferred.reject(err) : deferred.resolve(err);
});
return deferred.promise;
} | [
"function",
"registerCookieJar",
"(",
"server",
")",
"{",
"var",
"deferred",
"=",
"Q",
".",
"defer",
"(",
")",
";",
"server",
".",
"register",
"(",
"{",
"register",
":",
"require",
"(",
"'yar'",
")",
",",
"options",
":",
"{",
"cache",
":",
"{",
"expiresIn",
":",
"cookieConfig",
".",
"ttl",
"}",
",",
"cookieOptions",
":",
"{",
"clearInvalid",
":",
"true",
",",
"password",
":",
"cookieConfig",
".",
"password",
",",
"domain",
":",
"cookieConfig",
".",
"domain",
",",
"isSecure",
":",
"cookieConfig",
".",
"isSecure",
"}",
"}",
"}",
",",
"function",
"(",
"err",
")",
"{",
"err",
"?",
"deferred",
".",
"reject",
"(",
"err",
")",
":",
"deferred",
".",
"resolve",
"(",
"err",
")",
";",
"}",
")",
";",
"return",
"deferred",
".",
"promise",
";",
"}"
] | Register the cookie jar using the Hapi yar library
@param server | [
"Register",
"the",
"cookie",
"jar",
"using",
"the",
"Hapi",
"yar",
"library"
] | ea3feb8839e2edaf1b4577c052b8958953db4498 | https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/middleware/mw.auth.cookie.js#L14-L35 |
51,143 | gethuman/pancakes-recipe | middleware/mw.auth.cookie.js | registerJwtCookie | function registerJwtCookie(server) {
server.state('jwt', {
ttl: cookieConfig.ttl,
domain: cookieConfig.domain,
isSecure: cookieConfig.isSecure,
path: '/'
});
} | javascript | function registerJwtCookie(server) {
server.state('jwt', {
ttl: cookieConfig.ttl,
domain: cookieConfig.domain,
isSecure: cookieConfig.isSecure,
path: '/'
});
} | [
"function",
"registerJwtCookie",
"(",
"server",
")",
"{",
"server",
".",
"state",
"(",
"'jwt'",
",",
"{",
"ttl",
":",
"cookieConfig",
".",
"ttl",
",",
"domain",
":",
"cookieConfig",
".",
"domain",
",",
"isSecure",
":",
"cookieConfig",
".",
"isSecure",
",",
"path",
":",
"'/'",
"}",
")",
";",
"}"
] | Register the cookie used for the JSON web token.
This is only used on the webserver since the API
will get the token in the header of the request.
@param server | [
"Register",
"the",
"cookie",
"used",
"for",
"the",
"JSON",
"web",
"token",
".",
"This",
"is",
"only",
"used",
"on",
"the",
"webserver",
"since",
"the",
"API",
"will",
"get",
"the",
"token",
"in",
"the",
"header",
"of",
"the",
"request",
"."
] | ea3feb8839e2edaf1b4577c052b8958953db4498 | https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/middleware/mw.auth.cookie.js#L44-L51 |
51,144 | gethuman/pancakes-recipe | middleware/mw.auth.cookie.js | getJwtFromCookie | function getJwtFromCookie(req, reply) {
var jwt = req.state && req.state.jwt;
if (jwt) {
req.headers = req.headers || {};
req.headers.authorization = jwt;
}
reply.continue();
} | javascript | function getJwtFromCookie(req, reply) {
var jwt = req.state && req.state.jwt;
if (jwt) {
req.headers = req.headers || {};
req.headers.authorization = jwt;
}
reply.continue();
} | [
"function",
"getJwtFromCookie",
"(",
"req",
",",
"reply",
")",
"{",
"var",
"jwt",
"=",
"req",
".",
"state",
"&&",
"req",
".",
"state",
".",
"jwt",
";",
"if",
"(",
"jwt",
")",
"{",
"req",
".",
"headers",
"=",
"req",
".",
"headers",
"||",
"{",
"}",
";",
"req",
".",
"headers",
".",
"authorization",
"=",
"jwt",
";",
"}",
"reply",
".",
"continue",
"(",
")",
";",
"}"
] | Get the JWT token from the cookie and stick it into the request
@param req
@param reply | [
"Get",
"the",
"JWT",
"token",
"from",
"the",
"cookie",
"and",
"stick",
"it",
"into",
"the",
"request"
] | ea3feb8839e2edaf1b4577c052b8958953db4498 | https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/middleware/mw.auth.cookie.js#L58-L66 |
51,145 | gethuman/pancakes-recipe | middleware/mw.auth.cookie.js | init | function init(ctx) {
var server = ctx.server;
return registerCookieJar(server)
.then(function () {
registerJwtCookie(server);
server.ext('onPreAuth', getJwtFromCookie);
return new Q(ctx);
});
} | javascript | function init(ctx) {
var server = ctx.server;
return registerCookieJar(server)
.then(function () {
registerJwtCookie(server);
server.ext('onPreAuth', getJwtFromCookie);
return new Q(ctx);
});
} | [
"function",
"init",
"(",
"ctx",
")",
"{",
"var",
"server",
"=",
"ctx",
".",
"server",
";",
"return",
"registerCookieJar",
"(",
"server",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"registerJwtCookie",
"(",
"server",
")",
";",
"server",
".",
"ext",
"(",
"'onPreAuth'",
",",
"getJwtFromCookie",
")",
";",
"return",
"new",
"Q",
"(",
"ctx",
")",
";",
"}",
")",
";",
"}"
] | Register the cookie jar and move the token from the cookie to the request auth
@param ctx | [
"Register",
"the",
"cookie",
"jar",
"and",
"move",
"the",
"token",
"from",
"the",
"cookie",
"to",
"the",
"request",
"auth"
] | ea3feb8839e2edaf1b4577c052b8958953db4498 | https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/middleware/mw.auth.cookie.js#L72-L82 |
51,146 | ticup/tokepi | index.js | startsWithAny | function startsWithAny(string, vector) {
return _.any(vector.map(function (e) { return _str.startsWith(string, e); }));
} | javascript | function startsWithAny(string, vector) {
return _.any(vector.map(function (e) { return _str.startsWith(string, e); }));
} | [
"function",
"startsWithAny",
"(",
"string",
",",
"vector",
")",
"{",
"return",
"_",
".",
"any",
"(",
"vector",
".",
"map",
"(",
"function",
"(",
"e",
")",
"{",
"return",
"_str",
".",
"startsWith",
"(",
"string",
",",
"e",
")",
";",
"}",
")",
")",
";",
"}"
] | True if the string starts with any element of given vector | [
"True",
"if",
"the",
"string",
"starts",
"with",
"any",
"element",
"of",
"given",
"vector"
] | af2aa446e76f03d32e1fe6833b0397d5915e5521 | https://github.com/ticup/tokepi/blob/af2aa446e76f03d32e1fe6833b0397d5915e5521/index.js#L252-L254 |
51,147 | ticup/tokepi | index.js | endsWithAny | function endsWithAny(string, vector) {
return _.any(vector.map(function (e) { return _str.endsWith(string, e); }));
} | javascript | function endsWithAny(string, vector) {
return _.any(vector.map(function (e) { return _str.endsWith(string, e); }));
} | [
"function",
"endsWithAny",
"(",
"string",
",",
"vector",
")",
"{",
"return",
"_",
".",
"any",
"(",
"vector",
".",
"map",
"(",
"function",
"(",
"e",
")",
"{",
"return",
"_str",
".",
"endsWith",
"(",
"string",
",",
"e",
")",
";",
"}",
")",
")",
";",
"}"
] | True if the string ends with any element of given vector | [
"True",
"if",
"the",
"string",
"ends",
"with",
"any",
"element",
"of",
"given",
"vector"
] | af2aa446e76f03d32e1fe6833b0397d5915e5521 | https://github.com/ticup/tokepi/blob/af2aa446e76f03d32e1fe6833b0397d5915e5521/index.js#L256-L258 |
51,148 | demmer/validate-options | browser/specs/validate-options.spec.js | createReduce | function createReduce(dir) {
// Optimized iterator function as using arguments.length
// in the main function will deoptimize the, see #1991.
function iterator(obj, iteratee, memo, keys, index, length) {
for (; index >= 0 && index < length; index += dir) {
var currentKey = keys ? keys[index] : index;
memo = iteratee(memo, obj[currentKey], currentKey, obj);
}
return memo;
}
return function (obj, iteratee, memo, context) {
iteratee = optimizeCb(iteratee, context, 4);
var keys = !isArrayLike(obj) && _.keys(obj), length = (keys || obj).length, index = dir > 0 ? 0 : length - 1; // Determine the initial value if none is provided.
// Determine the initial value if none is provided.
if (arguments.length < 3) {
memo = obj[keys ? keys[index] : index];
index += dir;
}
return iterator(obj, iteratee, memo, keys, index, length);
};
} | javascript | function createReduce(dir) {
// Optimized iterator function as using arguments.length
// in the main function will deoptimize the, see #1991.
function iterator(obj, iteratee, memo, keys, index, length) {
for (; index >= 0 && index < length; index += dir) {
var currentKey = keys ? keys[index] : index;
memo = iteratee(memo, obj[currentKey], currentKey, obj);
}
return memo;
}
return function (obj, iteratee, memo, context) {
iteratee = optimizeCb(iteratee, context, 4);
var keys = !isArrayLike(obj) && _.keys(obj), length = (keys || obj).length, index = dir > 0 ? 0 : length - 1; // Determine the initial value if none is provided.
// Determine the initial value if none is provided.
if (arguments.length < 3) {
memo = obj[keys ? keys[index] : index];
index += dir;
}
return iterator(obj, iteratee, memo, keys, index, length);
};
} | [
"function",
"createReduce",
"(",
"dir",
")",
"{",
"// Optimized iterator function as using arguments.length",
"// in the main function will deoptimize the, see #1991.",
"function",
"iterator",
"(",
"obj",
",",
"iteratee",
",",
"memo",
",",
"keys",
",",
"index",
",",
"length",
")",
"{",
"for",
"(",
";",
"index",
">=",
"0",
"&&",
"index",
"<",
"length",
";",
"index",
"+=",
"dir",
")",
"{",
"var",
"currentKey",
"=",
"keys",
"?",
"keys",
"[",
"index",
"]",
":",
"index",
";",
"memo",
"=",
"iteratee",
"(",
"memo",
",",
"obj",
"[",
"currentKey",
"]",
",",
"currentKey",
",",
"obj",
")",
";",
"}",
"return",
"memo",
";",
"}",
"return",
"function",
"(",
"obj",
",",
"iteratee",
",",
"memo",
",",
"context",
")",
"{",
"iteratee",
"=",
"optimizeCb",
"(",
"iteratee",
",",
"context",
",",
"4",
")",
";",
"var",
"keys",
"=",
"!",
"isArrayLike",
"(",
"obj",
")",
"&&",
"_",
".",
"keys",
"(",
"obj",
")",
",",
"length",
"=",
"(",
"keys",
"||",
"obj",
")",
".",
"length",
",",
"index",
"=",
"dir",
">",
"0",
"?",
"0",
":",
"length",
"-",
"1",
";",
"// Determine the initial value if none is provided.",
"// Determine the initial value if none is provided.",
"if",
"(",
"arguments",
".",
"length",
"<",
"3",
")",
"{",
"memo",
"=",
"obj",
"[",
"keys",
"?",
"keys",
"[",
"index",
"]",
":",
"index",
"]",
";",
"index",
"+=",
"dir",
";",
"}",
"return",
"iterator",
"(",
"obj",
",",
"iteratee",
",",
"memo",
",",
"keys",
",",
"index",
",",
"length",
")",
";",
"}",
";",
"}"
] | Create a reducing function iterating left or right. Create a reducing function iterating left or right. | [
"Create",
"a",
"reducing",
"function",
"iterating",
"left",
"or",
"right",
".",
"Create",
"a",
"reducing",
"function",
"iterating",
"left",
"or",
"right",
"."
] | af18816366adca0b6da7347dcb31b9336b862a6d | https://github.com/demmer/validate-options/blob/af18816366adca0b6da7347dcb31b9336b862a6d/browser/specs/validate-options.spec.js#L295-L315 |
51,149 | skerit/alchemy | lib/app/helper/socket_helper.js | onResponse | function onResponse(packet) {
if (typeof that.callbacks[packet.respond_to] === 'function') {
try {
if (packet.data) {
packet.data = JSON.undry(packet.data);
}
} catch (err) {
console.log('ERROR UNDRYING PACKET:', err);
return;
}
if (packet.noData) {
that.callbacks[packet.respond_to](packet.err, packet.stream);
} else if (packet.stream) {
that.callbacks[packet.respond_to](packet.err, packet.data, packet.stream);
} else {
that.callbacks[packet.respond_to](packet.err, packet.data);
}
}
delete that.callbacks[packet.respond_to];
} | javascript | function onResponse(packet) {
if (typeof that.callbacks[packet.respond_to] === 'function') {
try {
if (packet.data) {
packet.data = JSON.undry(packet.data);
}
} catch (err) {
console.log('ERROR UNDRYING PACKET:', err);
return;
}
if (packet.noData) {
that.callbacks[packet.respond_to](packet.err, packet.stream);
} else if (packet.stream) {
that.callbacks[packet.respond_to](packet.err, packet.data, packet.stream);
} else {
that.callbacks[packet.respond_to](packet.err, packet.data);
}
}
delete that.callbacks[packet.respond_to];
} | [
"function",
"onResponse",
"(",
"packet",
")",
"{",
"if",
"(",
"typeof",
"that",
".",
"callbacks",
"[",
"packet",
".",
"respond_to",
"]",
"===",
"'function'",
")",
"{",
"try",
"{",
"if",
"(",
"packet",
".",
"data",
")",
"{",
"packet",
".",
"data",
"=",
"JSON",
".",
"undry",
"(",
"packet",
".",
"data",
")",
";",
"}",
"}",
"catch",
"(",
"err",
")",
"{",
"console",
".",
"log",
"(",
"'ERROR UNDRYING PACKET:'",
",",
"err",
")",
";",
"return",
";",
"}",
"if",
"(",
"packet",
".",
"noData",
")",
"{",
"that",
".",
"callbacks",
"[",
"packet",
".",
"respond_to",
"]",
"(",
"packet",
".",
"err",
",",
"packet",
".",
"stream",
")",
";",
"}",
"else",
"if",
"(",
"packet",
".",
"stream",
")",
"{",
"that",
".",
"callbacks",
"[",
"packet",
".",
"respond_to",
"]",
"(",
"packet",
".",
"err",
",",
"packet",
".",
"data",
",",
"packet",
".",
"stream",
")",
";",
"}",
"else",
"{",
"that",
".",
"callbacks",
"[",
"packet",
".",
"respond_to",
"]",
"(",
"packet",
".",
"err",
",",
"packet",
".",
"data",
")",
";",
"}",
"}",
"delete",
"that",
".",
"callbacks",
"[",
"packet",
".",
"respond_to",
"]",
";",
"}"
] | The function that handles responses | [
"The",
"function",
"that",
"handles",
"responses"
] | ede1dad07a5a737d5d1e10c2ff87fdfb057443f8 | https://github.com/skerit/alchemy/blob/ede1dad07a5a737d5d1e10c2ff87fdfb057443f8/lib/app/helper/socket_helper.js#L450-L473 |
51,150 | skerit/alchemy | lib/app/helper/socket_helper.js | onPacket | function onPacket(packet) {
var respond;
try {
if (packet.data && typeof packet.data == 'object') {
packet.data = JSON.undry(packet.data);
}
} catch (err) {
console.log('ERROR UNDRYING PACKET:', err, packet);
return;
}
if (packet.respond) {
respond = function respond(err, data) {
var responsePacket = {};
responsePacket.err = err;
responsePacket.respond_to = packet.id;
responsePacket.data = data;
server.emit('response', responsePacket);
};
}
// See if this is for a specific linkup
if (packet.link) {
if (that.linkups[packet.link]) {
if (packet.stream) {
that.linkups[packet.link].emit(packet.type, packet.data, packet.stream, respond, null);
} else {
that.linkups[packet.link].emit(packet.type, packet.data, respond, null);
}
}
return;
}
if (packet.stream) {
that.emit(packet.type, packet.data, packet.stream, respond, null);
} else {
that.emit(packet.type, packet.data, respond, null);
}
} | javascript | function onPacket(packet) {
var respond;
try {
if (packet.data && typeof packet.data == 'object') {
packet.data = JSON.undry(packet.data);
}
} catch (err) {
console.log('ERROR UNDRYING PACKET:', err, packet);
return;
}
if (packet.respond) {
respond = function respond(err, data) {
var responsePacket = {};
responsePacket.err = err;
responsePacket.respond_to = packet.id;
responsePacket.data = data;
server.emit('response', responsePacket);
};
}
// See if this is for a specific linkup
if (packet.link) {
if (that.linkups[packet.link]) {
if (packet.stream) {
that.linkups[packet.link].emit(packet.type, packet.data, packet.stream, respond, null);
} else {
that.linkups[packet.link].emit(packet.type, packet.data, respond, null);
}
}
return;
}
if (packet.stream) {
that.emit(packet.type, packet.data, packet.stream, respond, null);
} else {
that.emit(packet.type, packet.data, respond, null);
}
} | [
"function",
"onPacket",
"(",
"packet",
")",
"{",
"var",
"respond",
";",
"try",
"{",
"if",
"(",
"packet",
".",
"data",
"&&",
"typeof",
"packet",
".",
"data",
"==",
"'object'",
")",
"{",
"packet",
".",
"data",
"=",
"JSON",
".",
"undry",
"(",
"packet",
".",
"data",
")",
";",
"}",
"}",
"catch",
"(",
"err",
")",
"{",
"console",
".",
"log",
"(",
"'ERROR UNDRYING PACKET:'",
",",
"err",
",",
"packet",
")",
";",
"return",
";",
"}",
"if",
"(",
"packet",
".",
"respond",
")",
"{",
"respond",
"=",
"function",
"respond",
"(",
"err",
",",
"data",
")",
"{",
"var",
"responsePacket",
"=",
"{",
"}",
";",
"responsePacket",
".",
"err",
"=",
"err",
";",
"responsePacket",
".",
"respond_to",
"=",
"packet",
".",
"id",
";",
"responsePacket",
".",
"data",
"=",
"data",
";",
"server",
".",
"emit",
"(",
"'response'",
",",
"responsePacket",
")",
";",
"}",
";",
"}",
"// See if this is for a specific linkup",
"if",
"(",
"packet",
".",
"link",
")",
"{",
"if",
"(",
"that",
".",
"linkups",
"[",
"packet",
".",
"link",
"]",
")",
"{",
"if",
"(",
"packet",
".",
"stream",
")",
"{",
"that",
".",
"linkups",
"[",
"packet",
".",
"link",
"]",
".",
"emit",
"(",
"packet",
".",
"type",
",",
"packet",
".",
"data",
",",
"packet",
".",
"stream",
",",
"respond",
",",
"null",
")",
";",
"}",
"else",
"{",
"that",
".",
"linkups",
"[",
"packet",
".",
"link",
"]",
".",
"emit",
"(",
"packet",
".",
"type",
",",
"packet",
".",
"data",
",",
"respond",
",",
"null",
")",
";",
"}",
"}",
"return",
";",
"}",
"if",
"(",
"packet",
".",
"stream",
")",
"{",
"that",
".",
"emit",
"(",
"packet",
".",
"type",
",",
"packet",
".",
"data",
",",
"packet",
".",
"stream",
",",
"respond",
",",
"null",
")",
";",
"}",
"else",
"{",
"that",
".",
"emit",
"(",
"packet",
".",
"type",
",",
"packet",
".",
"data",
",",
"respond",
",",
"null",
")",
";",
"}",
"}"
] | The function that handles packets | [
"The",
"function",
"that",
"handles",
"packets"
] | ede1dad07a5a737d5d1e10c2ff87fdfb057443f8 | https://github.com/skerit/alchemy/blob/ede1dad07a5a737d5d1e10c2ff87fdfb057443f8/lib/app/helper/socket_helper.js#L476-L519 |
51,151 | christophehurpeau/springbokjs-dom | vendor/web-animations.js | function(inheritedTime) {
this._inheritedTime = inheritedTime;
this._updateTimeMarkers();
// The polyfill uses a sampling model whereby time values are propagated
// down the tree at each sample. However, for the media item, we need to use
// play() and pause().
// Handle the case of being outside our effect interval.
if (this._iterationTime === null) {
this._ensureIsAtUnscaledTime(0);
this._ensurePaused();
return;
}
if (this._iterationTime >= this._intrinsicDuration()) {
// Our iteration time exceeds the media element's duration, so just make
// sure the media element is at the end. It will stop automatically, but
// that could take some time if the seek below is significant, so force
// it.
this._ensureIsAtUnscaledTime(this._intrinsicDuration());
this._ensurePaused();
return;
}
var finalIteration = this._floorWithOpenClosedRange(
this.timing.iterationStart + this.timing._iterations(), 1.0);
var endTimeFraction = this._modulusWithOpenClosedRange(
this.timing.iterationStart + this.timing._iterations(), 1.0);
if (this.currentIteration === finalIteration &&
this._timeFraction === endTimeFraction &&
this._intrinsicDuration() >= this.duration) {
// We have reached the end of our final iteration, but the media element
// is not done.
this._ensureIsAtUnscaledTime(this.duration * endTimeFraction);
this._ensurePaused();
return;
}
// Set the appropriate playback rate.
var playbackRate =
this._media.defaultPlaybackRate * this._netEffectivePlaybackRate();
if (this._media.playbackRate !== playbackRate) {
this._media.playbackRate = playbackRate;
}
// Set the appropriate play/pause state. Note that we may not be able to
// seek to the desired time. In this case, the media element's seek
// algorithm repositions the seek to the nearest seekable time. This is OK,
// but in this case, we don't want to play the media element, as it prevents
// us from synchronising properly.
if (this.player.paused ||
!this._isSeekableUnscaledTime(this._iterationTime)) {
this._ensurePaused();
} else {
this._ensurePlaying();
}
// Seek if required. This could be due to our AnimationPlayer being seeked,
// or video slippage. We need to handle the fact that the video may not play
// at exactly the right speed. There's also a variable delay when the video
// is first played.
// TODO: What's the right value for this delta?
var delta = isDefinedAndNotNull(this._delta) ? this._delta :
0.2 * Math.abs(this._media.playbackRate);
if (Math.abs(this._iterationTime - this._unscaledMediaCurrentTime()) >
delta) {
this._ensureIsAtUnscaledTime(this._iterationTime);
}
} | javascript | function(inheritedTime) {
this._inheritedTime = inheritedTime;
this._updateTimeMarkers();
// The polyfill uses a sampling model whereby time values are propagated
// down the tree at each sample. However, for the media item, we need to use
// play() and pause().
// Handle the case of being outside our effect interval.
if (this._iterationTime === null) {
this._ensureIsAtUnscaledTime(0);
this._ensurePaused();
return;
}
if (this._iterationTime >= this._intrinsicDuration()) {
// Our iteration time exceeds the media element's duration, so just make
// sure the media element is at the end. It will stop automatically, but
// that could take some time if the seek below is significant, so force
// it.
this._ensureIsAtUnscaledTime(this._intrinsicDuration());
this._ensurePaused();
return;
}
var finalIteration = this._floorWithOpenClosedRange(
this.timing.iterationStart + this.timing._iterations(), 1.0);
var endTimeFraction = this._modulusWithOpenClosedRange(
this.timing.iterationStart + this.timing._iterations(), 1.0);
if (this.currentIteration === finalIteration &&
this._timeFraction === endTimeFraction &&
this._intrinsicDuration() >= this.duration) {
// We have reached the end of our final iteration, but the media element
// is not done.
this._ensureIsAtUnscaledTime(this.duration * endTimeFraction);
this._ensurePaused();
return;
}
// Set the appropriate playback rate.
var playbackRate =
this._media.defaultPlaybackRate * this._netEffectivePlaybackRate();
if (this._media.playbackRate !== playbackRate) {
this._media.playbackRate = playbackRate;
}
// Set the appropriate play/pause state. Note that we may not be able to
// seek to the desired time. In this case, the media element's seek
// algorithm repositions the seek to the nearest seekable time. This is OK,
// but in this case, we don't want to play the media element, as it prevents
// us from synchronising properly.
if (this.player.paused ||
!this._isSeekableUnscaledTime(this._iterationTime)) {
this._ensurePaused();
} else {
this._ensurePlaying();
}
// Seek if required. This could be due to our AnimationPlayer being seeked,
// or video slippage. We need to handle the fact that the video may not play
// at exactly the right speed. There's also a variable delay when the video
// is first played.
// TODO: What's the right value for this delta?
var delta = isDefinedAndNotNull(this._delta) ? this._delta :
0.2 * Math.abs(this._media.playbackRate);
if (Math.abs(this._iterationTime - this._unscaledMediaCurrentTime()) >
delta) {
this._ensureIsAtUnscaledTime(this._iterationTime);
}
} | [
"function",
"(",
"inheritedTime",
")",
"{",
"this",
".",
"_inheritedTime",
"=",
"inheritedTime",
";",
"this",
".",
"_updateTimeMarkers",
"(",
")",
";",
"// The polyfill uses a sampling model whereby time values are propagated",
"// down the tree at each sample. However, for the media item, we need to use",
"// play() and pause().",
"// Handle the case of being outside our effect interval.",
"if",
"(",
"this",
".",
"_iterationTime",
"===",
"null",
")",
"{",
"this",
".",
"_ensureIsAtUnscaledTime",
"(",
"0",
")",
";",
"this",
".",
"_ensurePaused",
"(",
")",
";",
"return",
";",
"}",
"if",
"(",
"this",
".",
"_iterationTime",
">=",
"this",
".",
"_intrinsicDuration",
"(",
")",
")",
"{",
"// Our iteration time exceeds the media element's duration, so just make",
"// sure the media element is at the end. It will stop automatically, but",
"// that could take some time if the seek below is significant, so force",
"// it.",
"this",
".",
"_ensureIsAtUnscaledTime",
"(",
"this",
".",
"_intrinsicDuration",
"(",
")",
")",
";",
"this",
".",
"_ensurePaused",
"(",
")",
";",
"return",
";",
"}",
"var",
"finalIteration",
"=",
"this",
".",
"_floorWithOpenClosedRange",
"(",
"this",
".",
"timing",
".",
"iterationStart",
"+",
"this",
".",
"timing",
".",
"_iterations",
"(",
")",
",",
"1.0",
")",
";",
"var",
"endTimeFraction",
"=",
"this",
".",
"_modulusWithOpenClosedRange",
"(",
"this",
".",
"timing",
".",
"iterationStart",
"+",
"this",
".",
"timing",
".",
"_iterations",
"(",
")",
",",
"1.0",
")",
";",
"if",
"(",
"this",
".",
"currentIteration",
"===",
"finalIteration",
"&&",
"this",
".",
"_timeFraction",
"===",
"endTimeFraction",
"&&",
"this",
".",
"_intrinsicDuration",
"(",
")",
">=",
"this",
".",
"duration",
")",
"{",
"// We have reached the end of our final iteration, but the media element",
"// is not done.",
"this",
".",
"_ensureIsAtUnscaledTime",
"(",
"this",
".",
"duration",
"*",
"endTimeFraction",
")",
";",
"this",
".",
"_ensurePaused",
"(",
")",
";",
"return",
";",
"}",
"// Set the appropriate playback rate.",
"var",
"playbackRate",
"=",
"this",
".",
"_media",
".",
"defaultPlaybackRate",
"*",
"this",
".",
"_netEffectivePlaybackRate",
"(",
")",
";",
"if",
"(",
"this",
".",
"_media",
".",
"playbackRate",
"!==",
"playbackRate",
")",
"{",
"this",
".",
"_media",
".",
"playbackRate",
"=",
"playbackRate",
";",
"}",
"// Set the appropriate play/pause state. Note that we may not be able to",
"// seek to the desired time. In this case, the media element's seek",
"// algorithm repositions the seek to the nearest seekable time. This is OK,",
"// but in this case, we don't want to play the media element, as it prevents",
"// us from synchronising properly.",
"if",
"(",
"this",
".",
"player",
".",
"paused",
"||",
"!",
"this",
".",
"_isSeekableUnscaledTime",
"(",
"this",
".",
"_iterationTime",
")",
")",
"{",
"this",
".",
"_ensurePaused",
"(",
")",
";",
"}",
"else",
"{",
"this",
".",
"_ensurePlaying",
"(",
")",
";",
"}",
"// Seek if required. This could be due to our AnimationPlayer being seeked,",
"// or video slippage. We need to handle the fact that the video may not play",
"// at exactly the right speed. There's also a variable delay when the video",
"// is first played.",
"// TODO: What's the right value for this delta?",
"var",
"delta",
"=",
"isDefinedAndNotNull",
"(",
"this",
".",
"_delta",
")",
"?",
"this",
".",
"_delta",
":",
"0.2",
"*",
"Math",
".",
"abs",
"(",
"this",
".",
"_media",
".",
"playbackRate",
")",
";",
"if",
"(",
"Math",
".",
"abs",
"(",
"this",
".",
"_iterationTime",
"-",
"this",
".",
"_unscaledMediaCurrentTime",
"(",
")",
")",
">",
"delta",
")",
"{",
"this",
".",
"_ensureIsAtUnscaledTime",
"(",
"this",
".",
"_iterationTime",
")",
";",
"}",
"}"
] | This is called by the polyfill on each tick when our AnimationPlayer's tree is active. | [
"This",
"is",
"called",
"by",
"the",
"polyfill",
"on",
"each",
"tick",
"when",
"our",
"AnimationPlayer",
"s",
"tree",
"is",
"active",
"."
] | 6e14a87fbe71124a0cbb68d1cb8626689c3b18a1 | https://github.com/christophehurpeau/springbokjs-dom/blob/6e14a87fbe71124a0cbb68d1cb8626689c3b18a1/vendor/web-animations.js#L1574-L1643 |
|
51,152 | christophehurpeau/springbokjs-dom | vendor/web-animations.js | function(offset, composite, easing) {
ASSERT_ENABLED && assert(
typeof offset === 'number' || offset === null,
'Invalid offset value');
ASSERT_ENABLED && assert(
composite === 'add' || composite === 'replace' || composite === null,
'Invalid composite value');
this.offset = offset;
this.composite = composite;
this.easing = easing;
this.cssValues = {};
} | javascript | function(offset, composite, easing) {
ASSERT_ENABLED && assert(
typeof offset === 'number' || offset === null,
'Invalid offset value');
ASSERT_ENABLED && assert(
composite === 'add' || composite === 'replace' || composite === null,
'Invalid composite value');
this.offset = offset;
this.composite = composite;
this.easing = easing;
this.cssValues = {};
} | [
"function",
"(",
"offset",
",",
"composite",
",",
"easing",
")",
"{",
"ASSERT_ENABLED",
"&&",
"assert",
"(",
"typeof",
"offset",
"===",
"'number'",
"||",
"offset",
"===",
"null",
",",
"'Invalid offset value'",
")",
";",
"ASSERT_ENABLED",
"&&",
"assert",
"(",
"composite",
"===",
"'add'",
"||",
"composite",
"===",
"'replace'",
"||",
"composite",
"===",
"null",
",",
"'Invalid composite value'",
")",
";",
"this",
".",
"offset",
"=",
"offset",
";",
"this",
".",
"composite",
"=",
"composite",
";",
"this",
".",
"easing",
"=",
"easing",
";",
"this",
".",
"cssValues",
"=",
"{",
"}",
";",
"}"
] | An internal representation of a keyframe. The Keyframe type from the spec is
just a dictionary and is not exposed.
@constructor | [
"An",
"internal",
"representation",
"of",
"a",
"keyframe",
".",
"The",
"Keyframe",
"type",
"from",
"the",
"spec",
"is",
"just",
"a",
"dictionary",
"and",
"is",
"not",
"exposed",
"."
] | 6e14a87fbe71124a0cbb68d1cb8626689c3b18a1 | https://github.com/christophehurpeau/springbokjs-dom/blob/6e14a87fbe71124a0cbb68d1cb8626689c3b18a1/vendor/web-animations.js#L2278-L2289 |
|
51,153 | christophehurpeau/springbokjs-dom | vendor/web-animations.js | function(property, value, svgMode) {
if (value === 'inherit') {
return value;
}
return getType(property).toCssValue(value, svgMode);
} | javascript | function(property, value, svgMode) {
if (value === 'inherit') {
return value;
}
return getType(property).toCssValue(value, svgMode);
} | [
"function",
"(",
"property",
",",
"value",
",",
"svgMode",
")",
"{",
"if",
"(",
"value",
"===",
"'inherit'",
")",
"{",
"return",
"value",
";",
"}",
"return",
"getType",
"(",
"property",
")",
".",
"toCssValue",
"(",
"value",
",",
"svgMode",
")",
";",
"}"
] | Convert the provided interpolable value for the provided property to a CSS
value string. Note that SVG transforms do not require units for translate
or rotate values while CSS properties require 'px' or 'deg' units. | [
"Convert",
"the",
"provided",
"interpolable",
"value",
"for",
"the",
"provided",
"property",
"to",
"a",
"CSS",
"value",
"string",
".",
"Note",
"that",
"SVG",
"transforms",
"do",
"not",
"require",
"units",
"for",
"translate",
"or",
"rotate",
"values",
"while",
"CSS",
"properties",
"require",
"px",
"or",
"deg",
"units",
"."
] | 6e14a87fbe71124a0cbb68d1cb8626689c3b18a1 | https://github.com/christophehurpeau/springbokjs-dom/blob/6e14a87fbe71124a0cbb68d1cb8626689c3b18a1/vendor/web-animations.js#L4715-L4720 |
|
51,154 | Nazariglez/perenquen | lib/pixi/src/filters/pixelate/PixelateFilter.js | PixelateFilter | function PixelateFilter()
{
core.AbstractFilter.call(this,
// vertex shader
null,
// fragment shader
fs.readFileSync(__dirname + '/pixelate.frag', 'utf8'),
// custom uniforms
{
dimensions: { type: '4fv', value: new Float32Array([0, 0, 0, 0]) },
pixelSize: { type: 'v2', value: { x: 10, y: 10 } }
}
);
} | javascript | function PixelateFilter()
{
core.AbstractFilter.call(this,
// vertex shader
null,
// fragment shader
fs.readFileSync(__dirname + '/pixelate.frag', 'utf8'),
// custom uniforms
{
dimensions: { type: '4fv', value: new Float32Array([0, 0, 0, 0]) },
pixelSize: { type: 'v2', value: { x: 10, y: 10 } }
}
);
} | [
"function",
"PixelateFilter",
"(",
")",
"{",
"core",
".",
"AbstractFilter",
".",
"call",
"(",
"this",
",",
"// vertex shader",
"null",
",",
"// fragment shader",
"fs",
".",
"readFileSync",
"(",
"__dirname",
"+",
"'/pixelate.frag'",
",",
"'utf8'",
")",
",",
"// custom uniforms",
"{",
"dimensions",
":",
"{",
"type",
":",
"'4fv'",
",",
"value",
":",
"new",
"Float32Array",
"(",
"[",
"0",
",",
"0",
",",
"0",
",",
"0",
"]",
")",
"}",
",",
"pixelSize",
":",
"{",
"type",
":",
"'v2'",
",",
"value",
":",
"{",
"x",
":",
"10",
",",
"y",
":",
"10",
"}",
"}",
"}",
")",
";",
"}"
] | This filter applies a pixelate effect making display objects appear 'blocky'.
@class
@extends AbstractFilter
@memberof PIXI.filters | [
"This",
"filter",
"applies",
"a",
"pixelate",
"effect",
"making",
"display",
"objects",
"appear",
"blocky",
"."
] | e023964d05afeefebdcac4e2044819fdfa3899ae | https://github.com/Nazariglez/perenquen/blob/e023964d05afeefebdcac4e2044819fdfa3899ae/lib/pixi/src/filters/pixelate/PixelateFilter.js#L12-L25 |
51,155 | markuz-gj/marked-middleware | index.js | getUrl | function getUrl (url) {
var opt = {
url: url
, timeout: 10000 // 10 seconds
}
;
return new Promise(function(resolve, reject){
request(opt, function(err, res, body){
if (err) { return reject(err); }
resolve(body)
});
});
} | javascript | function getUrl (url) {
var opt = {
url: url
, timeout: 10000 // 10 seconds
}
;
return new Promise(function(resolve, reject){
request(opt, function(err, res, body){
if (err) { return reject(err); }
resolve(body)
});
});
} | [
"function",
"getUrl",
"(",
"url",
")",
"{",
"var",
"opt",
"=",
"{",
"url",
":",
"url",
",",
"timeout",
":",
"10000",
"// 10 seconds",
"}",
";",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"request",
"(",
"opt",
",",
"function",
"(",
"err",
",",
"res",
",",
"body",
")",
"{",
"if",
"(",
"err",
")",
"{",
"return",
"reject",
"(",
"err",
")",
";",
"}",
"resolve",
"(",
"body",
")",
"}",
")",
";",
"}",
")",
";",
"}"
] | A promise wrapper arount `request`. It timeout the request after 10 sec
@private
@param {String} url
@return {Promise} - resolve {String} with the request's body. Could be an `html` or `css`. | [
"A",
"promise",
"wrapper",
"arount",
"request",
".",
"It",
"timeout",
"the",
"request",
"after",
"10",
"sec"
] | 808d475faedef82eb958bfb8097bbcef00e0ff31 | https://github.com/markuz-gj/marked-middleware/blob/808d475faedef82eb958bfb8097bbcef00e0ff31/index.js#L49-L61 |
51,156 | markuz-gj/marked-middleware | index.js | readCss | function readCss () {
return new Promise(function(resolve, reject){
readFile(SRC, {encoding: 'utf8'}, function(err, str){
if (err) { return reject(err); }
resolve(str)
});
});
} | javascript | function readCss () {
return new Promise(function(resolve, reject){
readFile(SRC, {encoding: 'utf8'}, function(err, str){
if (err) { return reject(err); }
resolve(str)
});
});
} | [
"function",
"readCss",
"(",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"readFile",
"(",
"SRC",
",",
"{",
"encoding",
":",
"'utf8'",
"}",
",",
"function",
"(",
"err",
",",
"str",
")",
"{",
"if",
"(",
"err",
")",
"{",
"return",
"reject",
"(",
"err",
")",
";",
"}",
"resolve",
"(",
"str",
")",
"}",
")",
";",
"}",
")",
";",
"}"
] | Read local github's css
@private
@return {Promise} - resolves to a {String} with the local github's css | [
"Read",
"local",
"github",
"s",
"css"
] | 808d475faedef82eb958bfb8097bbcef00e0ff31 | https://github.com/markuz-gj/marked-middleware/blob/808d475faedef82eb958bfb8097bbcef00e0ff31/index.js#L125-L132 |
51,157 | markuz-gj/marked-middleware | index.js | getCss | function getCss () {
return checkTime().then(function(isOld){
if (isOld){
return writeCss().then(function(str){
if (!str) return readCss()
return str
})
}
return readCss()
})
} | javascript | function getCss () {
return checkTime().then(function(isOld){
if (isOld){
return writeCss().then(function(str){
if (!str) return readCss()
return str
})
}
return readCss()
})
} | [
"function",
"getCss",
"(",
")",
"{",
"return",
"checkTime",
"(",
")",
".",
"then",
"(",
"function",
"(",
"isOld",
")",
"{",
"if",
"(",
"isOld",
")",
"{",
"return",
"writeCss",
"(",
")",
".",
"then",
"(",
"function",
"(",
"str",
")",
"{",
"if",
"(",
"!",
"str",
")",
"return",
"readCss",
"(",
")",
"return",
"str",
"}",
")",
"}",
"return",
"readCss",
"(",
")",
"}",
")",
"}"
] | It gets the css local or remote.
@private
@return {Promise} - it passes {String} with github's css to the next `then`. | [
"It",
"gets",
"the",
"css",
"local",
"or",
"remote",
"."
] | 808d475faedef82eb958bfb8097bbcef00e0ff31 | https://github.com/markuz-gj/marked-middleware/blob/808d475faedef82eb958bfb8097bbcef00e0ff31/index.js#L140-L151 |
51,158 | gethuman/pancakes-recipe | batch/db.archive/db.archive.batch.js | archiveResource | function archiveResource(resource, primary, archive) {
if (!resource.archive) { return true; }
var name = resource.name;
primary.bind(name);
archive.bind(name);
// get the archive criteria
var criteria = resource.archive();
log.info('Getting archive docs for ' + name);
// find all the documents that match the archive criteria
return getDocsToArchive(criteria, primary[name])
.then(function (docs) {
log.info('Found ' + docs.length + ' ' + name + ' docs to archive');
// insert all of the documents into the archive database
var deferred = Q.defer();
archive[name].insert(docs, function (err, results) {
err ? deferred.reject(err) : deferred.resolve(results);
});
return deferred.promise;
})
.then(function () {
log.info('Docs inserted into archive DB for ' + name + '. Now deleting docs in main db');
// delete the data from the primary database
var deferred = Q.defer();
primary[name].remove(criteria, function (err, results) {
log.info('Deleting docs complete for ' + name);
err ? deferred.reject(err) : deferred.resolve(results);
});
return deferred.promise;
});
} | javascript | function archiveResource(resource, primary, archive) {
if (!resource.archive) { return true; }
var name = resource.name;
primary.bind(name);
archive.bind(name);
// get the archive criteria
var criteria = resource.archive();
log.info('Getting archive docs for ' + name);
// find all the documents that match the archive criteria
return getDocsToArchive(criteria, primary[name])
.then(function (docs) {
log.info('Found ' + docs.length + ' ' + name + ' docs to archive');
// insert all of the documents into the archive database
var deferred = Q.defer();
archive[name].insert(docs, function (err, results) {
err ? deferred.reject(err) : deferred.resolve(results);
});
return deferred.promise;
})
.then(function () {
log.info('Docs inserted into archive DB for ' + name + '. Now deleting docs in main db');
// delete the data from the primary database
var deferred = Q.defer();
primary[name].remove(criteria, function (err, results) {
log.info('Deleting docs complete for ' + name);
err ? deferred.reject(err) : deferred.resolve(results);
});
return deferred.promise;
});
} | [
"function",
"archiveResource",
"(",
"resource",
",",
"primary",
",",
"archive",
")",
"{",
"if",
"(",
"!",
"resource",
".",
"archive",
")",
"{",
"return",
"true",
";",
"}",
"var",
"name",
"=",
"resource",
".",
"name",
";",
"primary",
".",
"bind",
"(",
"name",
")",
";",
"archive",
".",
"bind",
"(",
"name",
")",
";",
"// get the archive criteria",
"var",
"criteria",
"=",
"resource",
".",
"archive",
"(",
")",
";",
"log",
".",
"info",
"(",
"'Getting archive docs for '",
"+",
"name",
")",
";",
"// find all the documents that match the archive criteria",
"return",
"getDocsToArchive",
"(",
"criteria",
",",
"primary",
"[",
"name",
"]",
")",
".",
"then",
"(",
"function",
"(",
"docs",
")",
"{",
"log",
".",
"info",
"(",
"'Found '",
"+",
"docs",
".",
"length",
"+",
"' '",
"+",
"name",
"+",
"' docs to archive'",
")",
";",
"// insert all of the documents into the archive database",
"var",
"deferred",
"=",
"Q",
".",
"defer",
"(",
")",
";",
"archive",
"[",
"name",
"]",
".",
"insert",
"(",
"docs",
",",
"function",
"(",
"err",
",",
"results",
")",
"{",
"err",
"?",
"deferred",
".",
"reject",
"(",
"err",
")",
":",
"deferred",
".",
"resolve",
"(",
"results",
")",
";",
"}",
")",
";",
"return",
"deferred",
".",
"promise",
";",
"}",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"log",
".",
"info",
"(",
"'Docs inserted into archive DB for '",
"+",
"name",
"+",
"'. Now deleting docs in main db'",
")",
";",
"// delete the data from the primary database",
"var",
"deferred",
"=",
"Q",
".",
"defer",
"(",
")",
";",
"primary",
"[",
"name",
"]",
".",
"remove",
"(",
"criteria",
",",
"function",
"(",
"err",
",",
"results",
")",
"{",
"log",
".",
"info",
"(",
"'Deleting docs complete for '",
"+",
"name",
")",
";",
"err",
"?",
"deferred",
".",
"reject",
"(",
"err",
")",
":",
"deferred",
".",
"resolve",
"(",
"results",
")",
";",
"}",
")",
";",
"return",
"deferred",
".",
"promise",
";",
"}",
")",
";",
"}"
] | Archive a particular resource
@param resource
@param primary
@param archive | [
"Archive",
"a",
"particular",
"resource"
] | ea3feb8839e2edaf1b4577c052b8958953db4498 | https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/batch/db.archive/db.archive.batch.js#L55-L96 |
51,159 | gethuman/pancakes-recipe | batch/db.archive/db.archive.batch.js | getDocsToArchive | function getDocsToArchive(criteria, primaryCollection) {
var deferred = Q.defer();
primaryCollection.find(criteria).toArray(function (err, items) {
err ? deferred.reject(err) : deferred.resolve(items);
});
return deferred.promise;
} | javascript | function getDocsToArchive(criteria, primaryCollection) {
var deferred = Q.defer();
primaryCollection.find(criteria).toArray(function (err, items) {
err ? deferred.reject(err) : deferred.resolve(items);
});
return deferred.promise;
} | [
"function",
"getDocsToArchive",
"(",
"criteria",
",",
"primaryCollection",
")",
"{",
"var",
"deferred",
"=",
"Q",
".",
"defer",
"(",
")",
";",
"primaryCollection",
".",
"find",
"(",
"criteria",
")",
".",
"toArray",
"(",
"function",
"(",
"err",
",",
"items",
")",
"{",
"err",
"?",
"deferred",
".",
"reject",
"(",
"err",
")",
":",
"deferred",
".",
"resolve",
"(",
"items",
")",
";",
"}",
")",
";",
"return",
"deferred",
".",
"promise",
";",
"}"
] | Get the documents to archive
@param criteria
@param primaryCollection | [
"Get",
"the",
"documents",
"to",
"archive"
] | ea3feb8839e2edaf1b4577c052b8958953db4498 | https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/batch/db.archive/db.archive.batch.js#L103-L111 |
51,160 | react-components/react-loading-status-mixin | index.js | function() {
var self = this;
var children = self._children;
var prev = self.state.childrenLoadingStatus;
var isLoading = false;
for (var k in children) {
if (children[k]) {
isLoading = true;
break;
}
}
if (prev === isLoading) return;
self.setState({childrenLoadingStatus: isLoading});
} | javascript | function() {
var self = this;
var children = self._children;
var prev = self.state.childrenLoadingStatus;
var isLoading = false;
for (var k in children) {
if (children[k]) {
isLoading = true;
break;
}
}
if (prev === isLoading) return;
self.setState({childrenLoadingStatus: isLoading});
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"children",
"=",
"self",
".",
"_children",
";",
"var",
"prev",
"=",
"self",
".",
"state",
".",
"childrenLoadingStatus",
";",
"var",
"isLoading",
"=",
"false",
";",
"for",
"(",
"var",
"k",
"in",
"children",
")",
"{",
"if",
"(",
"children",
"[",
"k",
"]",
")",
"{",
"isLoading",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"prev",
"===",
"isLoading",
")",
"return",
";",
"self",
".",
"setState",
"(",
"{",
"childrenLoadingStatus",
":",
"isLoading",
"}",
")",
";",
"}"
] | Helper methods for updaing the child status
@api private | [
"Helper",
"methods",
"for",
"updaing",
"the",
"child",
"status"
] | 9138bd678508c4669aed69cf109bc1e7b6e61f3a | https://github.com/react-components/react-loading-status-mixin/blob/9138bd678508c4669aed69cf109bc1e7b6e61f3a/index.js#L96-L111 |
|
51,161 | react-components/react-loading-status-mixin | index.js | function(isLoaded) {
var self = this;
var isLoading = !isLoaded;
var state = self.state;
var prev = state.loadingStatus;
isLoading = isLoading || false;
state.loadingStatus = isLoading;
self._notifyParentLoadingStatus(prev, !self.isLoaded());
} | javascript | function(isLoaded) {
var self = this;
var isLoading = !isLoaded;
var state = self.state;
var prev = state.loadingStatus;
isLoading = isLoading || false;
state.loadingStatus = isLoading;
self._notifyParentLoadingStatus(prev, !self.isLoaded());
} | [
"function",
"(",
"isLoaded",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"isLoading",
"=",
"!",
"isLoaded",
";",
"var",
"state",
"=",
"self",
".",
"state",
";",
"var",
"prev",
"=",
"state",
".",
"loadingStatus",
";",
"isLoading",
"=",
"isLoading",
"||",
"false",
";",
"state",
".",
"loadingStatus",
"=",
"isLoading",
";",
"self",
".",
"_notifyParentLoadingStatus",
"(",
"prev",
",",
"!",
"self",
".",
"isLoaded",
"(",
")",
")",
";",
"}"
] | child
Set the loaded status for the component
@param {Boolean} isLoaded
@api public | [
"child",
"Set",
"the",
"loaded",
"status",
"for",
"the",
"component"
] | 9138bd678508c4669aed69cf109bc1e7b6e61f3a | https://github.com/react-components/react-loading-status-mixin/blob/9138bd678508c4669aed69cf109bc1e7b6e61f3a/index.js#L131-L141 |
|
51,162 | react-components/react-loading-status-mixin | index.js | createScheduleStatusUpdate | function createScheduleStatusUpdate() {
var isChanging = false;
var shouldUpdate = false;
function update(self, fn) {
raf(function() {
if (self.isMounted()) fn();
isChanging = false;
if (shouldUpdate) update(self, fn);
shouldUpdate = false;
});
}
return function _scheduleStatusUpdate(fn) {
if (isChanging) return shouldUpdate = true;
var self = this;
isChanging = true;
update(self, fn || self._updateChildrenLoadingStatus);
};
} | javascript | function createScheduleStatusUpdate() {
var isChanging = false;
var shouldUpdate = false;
function update(self, fn) {
raf(function() {
if (self.isMounted()) fn();
isChanging = false;
if (shouldUpdate) update(self, fn);
shouldUpdate = false;
});
}
return function _scheduleStatusUpdate(fn) {
if (isChanging) return shouldUpdate = true;
var self = this;
isChanging = true;
update(self, fn || self._updateChildrenLoadingStatus);
};
} | [
"function",
"createScheduleStatusUpdate",
"(",
")",
"{",
"var",
"isChanging",
"=",
"false",
";",
"var",
"shouldUpdate",
"=",
"false",
";",
"function",
"update",
"(",
"self",
",",
"fn",
")",
"{",
"raf",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"self",
".",
"isMounted",
"(",
")",
")",
"fn",
"(",
")",
";",
"isChanging",
"=",
"false",
";",
"if",
"(",
"shouldUpdate",
")",
"update",
"(",
"self",
",",
"fn",
")",
";",
"shouldUpdate",
"=",
"false",
";",
"}",
")",
";",
"}",
"return",
"function",
"_scheduleStatusUpdate",
"(",
"fn",
")",
"{",
"if",
"(",
"isChanging",
")",
"return",
"shouldUpdate",
"=",
"true",
";",
"var",
"self",
"=",
"this",
";",
"isChanging",
"=",
"true",
";",
"update",
"(",
"self",
",",
"fn",
"||",
"self",
".",
"_updateChildrenLoadingStatus",
")",
";",
"}",
";",
"}"
] | Create a schedule status update function that is debounced | [
"Create",
"a",
"schedule",
"status",
"update",
"function",
"that",
"is",
"debounced"
] | 9138bd678508c4669aed69cf109bc1e7b6e61f3a | https://github.com/react-components/react-loading-status-mixin/blob/9138bd678508c4669aed69cf109bc1e7b6e61f3a/index.js#L170-L189 |
51,163 | shellzie/grunt-boot-server-async | tasks/boot_server_async.js | function(chunk){
if(printOutput){
if (chunk.indexOf(options.matchString) !== -1) {
child_process.stdout.removeListener('data', detachIfStarted);
printOutput = false;
done();
}
}
} | javascript | function(chunk){
if(printOutput){
if (chunk.indexOf(options.matchString) !== -1) {
child_process.stdout.removeListener('data', detachIfStarted);
printOutput = false;
done();
}
}
} | [
"function",
"(",
"chunk",
")",
"{",
"if",
"(",
"printOutput",
")",
"{",
"if",
"(",
"chunk",
".",
"indexOf",
"(",
"options",
".",
"matchString",
")",
"!==",
"-",
"1",
")",
"{",
"child_process",
".",
"stdout",
".",
"removeListener",
"(",
"'data'",
",",
"detachIfStarted",
")",
";",
"printOutput",
"=",
"false",
";",
"done",
"(",
")",
";",
"}",
"}",
"}"
] | detach the listener, which listens for changes in stdout, once matchString is output to terminal. otherwise, process will hang. | [
"detach",
"the",
"listener",
"which",
"listens",
"for",
"changes",
"in",
"stdout",
"once",
"matchString",
"is",
"output",
"to",
"terminal",
".",
"otherwise",
"process",
"will",
"hang",
"."
] | a992c7ccb0f837ee1a4e471fd66764b9cb22f132 | https://github.com/shellzie/grunt-boot-server-async/blob/a992c7ccb0f837ee1a4e471fd66764b9cb22f132/tasks/boot_server_async.js#L70-L78 |
|
51,164 | andrewscwei/requiem | src/dom/getClassIndex.js | getClassIndex | function getClassIndex(element, className) {
assertType(element, Node, false, 'Invalid element specified');
assertType(className, 'string', false, `Invalid class name: ${className}`);
let classList = element.className.split(' ');
return classList.indexOf(className);
} | javascript | function getClassIndex(element, className) {
assertType(element, Node, false, 'Invalid element specified');
assertType(className, 'string', false, `Invalid class name: ${className}`);
let classList = element.className.split(' ');
return classList.indexOf(className);
} | [
"function",
"getClassIndex",
"(",
"element",
",",
"className",
")",
"{",
"assertType",
"(",
"element",
",",
"Node",
",",
"false",
",",
"'Invalid element specified'",
")",
";",
"assertType",
"(",
"className",
",",
"'string'",
",",
"false",
",",
"`",
"${",
"className",
"}",
"`",
")",
";",
"let",
"classList",
"=",
"element",
".",
"className",
".",
"split",
"(",
"' '",
")",
";",
"return",
"classList",
".",
"indexOf",
"(",
"className",
")",
";",
"}"
] | Gets the index of a specified class in a DOM element,
@param {Node} element - Target element.
@param {string} className - Target class name.
@return {number} Index of given class name. -1 if not found.
@alias module:requiem~dom.getClassIndex | [
"Gets",
"the",
"index",
"of",
"a",
"specified",
"class",
"in",
"a",
"DOM",
"element"
] | c4182bfffc9841c6de5718f689ad3c2060511777 | https://github.com/andrewscwei/requiem/blob/c4182bfffc9841c6de5718f689ad3c2060511777/src/dom/getClassIndex.js#L17-L22 |
51,165 | vkiding/jud-vue-render | src/render/browser/render/register.js | registerModuleEventListener | function registerModuleEventListener (name, module, meta) {
if (name !== 'globalEvent') {
module['addEventListener'] = function (evt, callbackId, options) {
return addEventListener.call(this, name, evt, callbackId, options)
}
module['removeAllEventListeners'] = function (evt) {
return removeAllEventListeners.call(this, name, evt)
}
; [{
name: 'addEventListener',
args: ['string', 'function', 'object']
}, {
name: 'removeAllEventListeners',
args: ['string']
}].forEach(info => meta[name].push(info))
}
} | javascript | function registerModuleEventListener (name, module, meta) {
if (name !== 'globalEvent') {
module['addEventListener'] = function (evt, callbackId, options) {
return addEventListener.call(this, name, evt, callbackId, options)
}
module['removeAllEventListeners'] = function (evt) {
return removeAllEventListeners.call(this, name, evt)
}
; [{
name: 'addEventListener',
args: ['string', 'function', 'object']
}, {
name: 'removeAllEventListeners',
args: ['string']
}].forEach(info => meta[name].push(info))
}
} | [
"function",
"registerModuleEventListener",
"(",
"name",
",",
"module",
",",
"meta",
")",
"{",
"if",
"(",
"name",
"!==",
"'globalEvent'",
")",
"{",
"module",
"[",
"'addEventListener'",
"]",
"=",
"function",
"(",
"evt",
",",
"callbackId",
",",
"options",
")",
"{",
"return",
"addEventListener",
".",
"call",
"(",
"this",
",",
"name",
",",
"evt",
",",
"callbackId",
",",
"options",
")",
"}",
"module",
"[",
"'removeAllEventListeners'",
"]",
"=",
"function",
"(",
"evt",
")",
"{",
"return",
"removeAllEventListeners",
".",
"call",
"(",
"this",
",",
"name",
",",
"evt",
")",
"}",
";",
"[",
"{",
"name",
":",
"'addEventListener'",
",",
"args",
":",
"[",
"'string'",
",",
"'function'",
",",
"'object'",
"]",
"}",
",",
"{",
"name",
":",
"'removeAllEventListeners'",
",",
"args",
":",
"[",
"'string'",
"]",
"}",
"]",
".",
"forEach",
"(",
"info",
"=>",
"meta",
"[",
"name",
"]",
".",
"push",
"(",
"info",
")",
")",
"}",
"}"
] | register module event listener for every api module except 'globalEvent'. | [
"register",
"module",
"event",
"listener",
"for",
"every",
"api",
"module",
"except",
"globalEvent",
"."
] | 07d8ab08d0ef86cf2819e5f2bf1f4b06381f4d47 | https://github.com/vkiding/jud-vue-render/blob/07d8ab08d0ef86cf2819e5f2bf1f4b06381f4d47/src/render/browser/render/register.js#L10-L26 |
51,166 | pzlr/build-core | lib/validators.js | declaration | function declaration(obj) {
const
{error, value} = joi.validate(obj, declarationSchema);
if (error) {
throw new TypeError(`Invalid declaration object: ${error.message}`);
}
return value;
} | javascript | function declaration(obj) {
const
{error, value} = joi.validate(obj, declarationSchema);
if (error) {
throw new TypeError(`Invalid declaration object: ${error.message}`);
}
return value;
} | [
"function",
"declaration",
"(",
"obj",
")",
"{",
"const",
"{",
"error",
",",
"value",
"}",
"=",
"joi",
".",
"validate",
"(",
"obj",
",",
"declarationSchema",
")",
";",
"if",
"(",
"error",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"`",
"${",
"error",
".",
"message",
"}",
"`",
")",
";",
"}",
"return",
"value",
";",
"}"
] | Validates the specified package declaration
@template {T}
@param {T} obj
@returns {T} | [
"Validates",
"the",
"specified",
"package",
"declaration"
] | 11e20eda500682b9fa62c7804c66be1714df0df4 | https://github.com/pzlr/build-core/blob/11e20eda500682b9fa62c7804c66be1714df0df4/lib/validators.js#L70-L79 |
51,167 | redisjs/jsr-server | lib/command/server/client.js | getname | function getname(req, res) {
res.send(null, req.conn.client.name);
} | javascript | function getname(req, res) {
res.send(null, req.conn.client.name);
} | [
"function",
"getname",
"(",
"req",
",",
"res",
")",
"{",
"res",
".",
"send",
"(",
"null",
",",
"req",
".",
"conn",
".",
"client",
".",
"name",
")",
";",
"}"
] | Respond to the GETNAME subcommand. | [
"Respond",
"to",
"the",
"GETNAME",
"subcommand",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/server/client.js#L22-L24 |
51,168 | redisjs/jsr-server | lib/command/server/client.js | setname | function setname(req, res) {
req.conn.client.name = req.args[0];
res.send(null, Constants.OK);
} | javascript | function setname(req, res) {
req.conn.client.name = req.args[0];
res.send(null, Constants.OK);
} | [
"function",
"setname",
"(",
"req",
",",
"res",
")",
"{",
"req",
".",
"conn",
".",
"client",
".",
"name",
"=",
"req",
".",
"args",
"[",
"0",
"]",
";",
"res",
".",
"send",
"(",
"null",
",",
"Constants",
".",
"OK",
")",
";",
"}"
] | Respond to the SETNAME subcommand. | [
"Respond",
"to",
"the",
"SETNAME",
"subcommand",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/server/client.js#L29-L32 |
51,169 | redisjs/jsr-server | lib/command/server/client.js | list | function list(req, res) {
var s = '';
this.state.connections.forEach(function(conn) {
s += conn.toString();
})
res.send(null, s);
} | javascript | function list(req, res) {
var s = '';
this.state.connections.forEach(function(conn) {
s += conn.toString();
})
res.send(null, s);
} | [
"function",
"list",
"(",
"req",
",",
"res",
")",
"{",
"var",
"s",
"=",
"''",
";",
"this",
".",
"state",
".",
"connections",
".",
"forEach",
"(",
"function",
"(",
"conn",
")",
"{",
"s",
"+=",
"conn",
".",
"toString",
"(",
")",
";",
"}",
")",
"res",
".",
"send",
"(",
"null",
",",
"s",
")",
";",
"}"
] | Respond to the LIST subcommand. | [
"Respond",
"to",
"the",
"LIST",
"subcommand",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/server/client.js#L37-L43 |
51,170 | redisjs/jsr-server | lib/command/server/client.js | pause | function pause(req, res) {
res.send(null, Constants.OK);
this.state.pause(req.args[0]);
} | javascript | function pause(req, res) {
res.send(null, Constants.OK);
this.state.pause(req.args[0]);
} | [
"function",
"pause",
"(",
"req",
",",
"res",
")",
"{",
"res",
".",
"send",
"(",
"null",
",",
"Constants",
".",
"OK",
")",
";",
"this",
".",
"state",
".",
"pause",
"(",
"req",
".",
"args",
"[",
"0",
"]",
")",
";",
"}"
] | Respond to the PAUSE subcommand. | [
"Respond",
"to",
"the",
"PAUSE",
"subcommand",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/server/client.js#L48-L51 |
51,171 | redisjs/jsr-server | lib/command/server/client.js | kill | function kill(req, res) {
// TODO: implement filters
var conn;
// single ip:port
if(req.args.length === 1) {
conn = req.args[0];
// shouldn't get here, however there is a possible
// race condition whereby the target connection quits
// between validate and execute
if(!conn) return res.send(null, null);
// suicide
if(conn.id === req.conn.id) {
conn.write(Constants.OK, function onWrite() {
conn.close();
})
// killing another connection
}else{
//console.dir('closing another connection...');
conn.close(function onClose() {
res.send(null, Constants.OK);
})
}
}
} | javascript | function kill(req, res) {
// TODO: implement filters
var conn;
// single ip:port
if(req.args.length === 1) {
conn = req.args[0];
// shouldn't get here, however there is a possible
// race condition whereby the target connection quits
// between validate and execute
if(!conn) return res.send(null, null);
// suicide
if(conn.id === req.conn.id) {
conn.write(Constants.OK, function onWrite() {
conn.close();
})
// killing another connection
}else{
//console.dir('closing another connection...');
conn.close(function onClose() {
res.send(null, Constants.OK);
})
}
}
} | [
"function",
"kill",
"(",
"req",
",",
"res",
")",
"{",
"// TODO: implement filters",
"var",
"conn",
";",
"// single ip:port",
"if",
"(",
"req",
".",
"args",
".",
"length",
"===",
"1",
")",
"{",
"conn",
"=",
"req",
".",
"args",
"[",
"0",
"]",
";",
"// shouldn't get here, however there is a possible",
"// race condition whereby the target connection quits",
"// between validate and execute",
"if",
"(",
"!",
"conn",
")",
"return",
"res",
".",
"send",
"(",
"null",
",",
"null",
")",
";",
"// suicide",
"if",
"(",
"conn",
".",
"id",
"===",
"req",
".",
"conn",
".",
"id",
")",
"{",
"conn",
".",
"write",
"(",
"Constants",
".",
"OK",
",",
"function",
"onWrite",
"(",
")",
"{",
"conn",
".",
"close",
"(",
")",
";",
"}",
")",
"// killing another connection",
"}",
"else",
"{",
"//console.dir('closing another connection...');",
"conn",
".",
"close",
"(",
"function",
"onClose",
"(",
")",
"{",
"res",
".",
"send",
"(",
"null",
",",
"Constants",
".",
"OK",
")",
";",
"}",
")",
"}",
"}",
"}"
] | Respond to the KILL subcommand. | [
"Respond",
"to",
"the",
"KILL",
"subcommand",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/server/client.js#L56-L81 |
51,172 | redisjs/jsr-server | lib/command/server/client.js | validate | function validate(cmd, args, info) {
AbstractCommand.prototype.validate.apply(this, arguments);
var sub = info.command.sub
, cmd = ('' + sub.cmd)
, args = sub.args
, timeout
, conn;
if(cmd === Constants.SUBCOMMAND.client.pause.name) {
timeout = parseInt('' + args[0]);
// redis returns: 'timeout is' ...
// but we are not creating another error just yet!
if(isNaN(timeout)) {
throw IntegerRange;
}
args[0] = timeout;
}else if(cmd === Constants.SUBCOMMAND.client.kill.name) {
// kill by ip:port
if(args.length === 1) {
conn = this.state.getByAddr('' + args[0]);
if(!conn) {
throw NoSuchClient;
}
//console.dir('found kill connection');
args[0] = conn;
}
}else if(cmd === Constants.SUBCOMMAND.client.setname.name) {
// redis appears to allow every thing but whitespace
if(/\s+/.test(args[0])) {
throw ClientName;
}
}
} | javascript | function validate(cmd, args, info) {
AbstractCommand.prototype.validate.apply(this, arguments);
var sub = info.command.sub
, cmd = ('' + sub.cmd)
, args = sub.args
, timeout
, conn;
if(cmd === Constants.SUBCOMMAND.client.pause.name) {
timeout = parseInt('' + args[0]);
// redis returns: 'timeout is' ...
// but we are not creating another error just yet!
if(isNaN(timeout)) {
throw IntegerRange;
}
args[0] = timeout;
}else if(cmd === Constants.SUBCOMMAND.client.kill.name) {
// kill by ip:port
if(args.length === 1) {
conn = this.state.getByAddr('' + args[0]);
if(!conn) {
throw NoSuchClient;
}
//console.dir('found kill connection');
args[0] = conn;
}
}else if(cmd === Constants.SUBCOMMAND.client.setname.name) {
// redis appears to allow every thing but whitespace
if(/\s+/.test(args[0])) {
throw ClientName;
}
}
} | [
"function",
"validate",
"(",
"cmd",
",",
"args",
",",
"info",
")",
"{",
"AbstractCommand",
".",
"prototype",
".",
"validate",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"var",
"sub",
"=",
"info",
".",
"command",
".",
"sub",
",",
"cmd",
"=",
"(",
"''",
"+",
"sub",
".",
"cmd",
")",
",",
"args",
"=",
"sub",
".",
"args",
",",
"timeout",
",",
"conn",
";",
"if",
"(",
"cmd",
"===",
"Constants",
".",
"SUBCOMMAND",
".",
"client",
".",
"pause",
".",
"name",
")",
"{",
"timeout",
"=",
"parseInt",
"(",
"''",
"+",
"args",
"[",
"0",
"]",
")",
";",
"// redis returns: 'timeout is' ...",
"// but we are not creating another error just yet!",
"if",
"(",
"isNaN",
"(",
"timeout",
")",
")",
"{",
"throw",
"IntegerRange",
";",
"}",
"args",
"[",
"0",
"]",
"=",
"timeout",
";",
"}",
"else",
"if",
"(",
"cmd",
"===",
"Constants",
".",
"SUBCOMMAND",
".",
"client",
".",
"kill",
".",
"name",
")",
"{",
"// kill by ip:port",
"if",
"(",
"args",
".",
"length",
"===",
"1",
")",
"{",
"conn",
"=",
"this",
".",
"state",
".",
"getByAddr",
"(",
"''",
"+",
"args",
"[",
"0",
"]",
")",
";",
"if",
"(",
"!",
"conn",
")",
"{",
"throw",
"NoSuchClient",
";",
"}",
"//console.dir('found kill connection');",
"args",
"[",
"0",
"]",
"=",
"conn",
";",
"}",
"}",
"else",
"if",
"(",
"cmd",
"===",
"Constants",
".",
"SUBCOMMAND",
".",
"client",
".",
"setname",
".",
"name",
")",
"{",
"// redis appears to allow every thing but whitespace",
"if",
"(",
"/",
"\\s+",
"/",
".",
"test",
"(",
"args",
"[",
"0",
"]",
")",
")",
"{",
"throw",
"ClientName",
";",
"}",
"}",
"}"
] | Validate the CLIENT subcommands. | [
"Validate",
"the",
"CLIENT",
"subcommands",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/server/client.js#L86-L118 |
51,173 | solid-live/solidbot | lib/bots/inbox.js | checkInbox | function checkInbox(uri, cert) {
console.log('checking inbox for:', uri, cert)
shell.ls([null, null, uri, cert], function(err, ret) {
if (err) {
console.error(err)
} else {
console.log(ret)
}
})
} | javascript | function checkInbox(uri, cert) {
console.log('checking inbox for:', uri, cert)
shell.ls([null, null, uri, cert], function(err, ret) {
if (err) {
console.error(err)
} else {
console.log(ret)
}
})
} | [
"function",
"checkInbox",
"(",
"uri",
",",
"cert",
")",
"{",
"console",
".",
"log",
"(",
"'checking inbox for:'",
",",
"uri",
",",
"cert",
")",
"shell",
".",
"ls",
"(",
"[",
"null",
",",
"null",
",",
"uri",
",",
"cert",
"]",
",",
"function",
"(",
"err",
",",
"ret",
")",
"{",
"if",
"(",
"err",
")",
"{",
"console",
".",
"error",
"(",
"err",
")",
"}",
"else",
"{",
"console",
".",
"log",
"(",
"ret",
")",
"}",
"}",
")",
"}"
] | check a given inbox
@param {string} uri The inbox to check.
@param {string} cert Certificate location. | [
"check",
"a",
"given",
"inbox"
] | c91bfef38ab01f7f88fb6bf1b1bc4875aea0ceda | https://github.com/solid-live/solidbot/blob/c91bfef38ab01f7f88fb6bf1b1bc4875aea0ceda/lib/bots/inbox.js#L59-L69 |
51,174 | kryo2k/connect-mongoose | index.js | MongooseStore | function MongooseStore(session, mongooseModel) {
var
self = this;
if(!session || !session.Store) {
throw 'express-session was not passed in constructor.';
}
if(!mongooseModel || !mongooseModel.findById) {
throw 'Mongoose Model was not passed in constructor.';
}
var Store = session.Store;
/**
* MongooseStore session store constructor
*/
function MStore(config) {
var
me = this,
// define our options for this store instance
opts = _.extend({}, defaults, config),
// default (un)serializer using JSON
serializer = JSON.stringify,
unserializer = JSON.parse;
// call superclass method
Store.call(me, opts);
var
defExpireTime = opts.defaultExpirationTime,
propSid = opts.propertySessionId,
propData = opts.propertyData,
propLastActive = opts.propertyLastActivity;
// creates/updates a query to search for a certain property
function _applyProp(property, value, obj) {
obj = obj || {};
obj[property] = value;
return obj;
}
// checks a session document's expiration date to see if it's still valid
function _checkExpiration(session) {
return !session[propLastActive] || new Date < (session[propLastActive].getTime() + defExpireTime);
}
_.extend(me, {
// get session data by session id:
get: function (sid, callback) {
var cb = callback || _.noop;
// ensureIndex is already called on start-up
mongooseModel.findOne(_applyProp(propSid, sid), function(err, doc) {
if(err || !doc) { // exit immediately
cb(err, null);
return;
}
if(_checkExpiration(doc) && doc[propData] !== undefined) { // we're still valid:
cb(null, unserializer(doc[propData]));
}
else { // needs clean-up
me.destroy(sid, cb);
}
});
},
// set session data by session id:
set: function (sid, session, callback) {
var rec = {};
// apply our properties:
_applyProp(propSid, sid, rec);
_applyProp(propData, serializer(session), rec);
// opportunity to do:
_applyProp(propLastActive, new Date(), rec);
mongooseModel.findOneAndUpdate(_applyProp(propSid, sid), rec, {upsert: true}, function(err){
(callback||_.noop)(err);
});
},
// destroy session by session id:
destroy: function (sid, callback) {
mongooseModel.findOneAndRemove(_applyProp(propSid, sid), function(err) {
(callback||_.noop)(err);
});
},
// get the number of total sessions:
length: function (callback) {
mongooseModel.count({}, callback||_.noop);
},
// clear all stored sessions:
clear: function (callback) {
mongooseModel.remove({}, callback||_.noop);
}
});
return me;
}
// inherit by default from connect memory store:
util.inherits(MStore, Store);
// return preconfigured mongoose store:
return MStore;
} | javascript | function MongooseStore(session, mongooseModel) {
var
self = this;
if(!session || !session.Store) {
throw 'express-session was not passed in constructor.';
}
if(!mongooseModel || !mongooseModel.findById) {
throw 'Mongoose Model was not passed in constructor.';
}
var Store = session.Store;
/**
* MongooseStore session store constructor
*/
function MStore(config) {
var
me = this,
// define our options for this store instance
opts = _.extend({}, defaults, config),
// default (un)serializer using JSON
serializer = JSON.stringify,
unserializer = JSON.parse;
// call superclass method
Store.call(me, opts);
var
defExpireTime = opts.defaultExpirationTime,
propSid = opts.propertySessionId,
propData = opts.propertyData,
propLastActive = opts.propertyLastActivity;
// creates/updates a query to search for a certain property
function _applyProp(property, value, obj) {
obj = obj || {};
obj[property] = value;
return obj;
}
// checks a session document's expiration date to see if it's still valid
function _checkExpiration(session) {
return !session[propLastActive] || new Date < (session[propLastActive].getTime() + defExpireTime);
}
_.extend(me, {
// get session data by session id:
get: function (sid, callback) {
var cb = callback || _.noop;
// ensureIndex is already called on start-up
mongooseModel.findOne(_applyProp(propSid, sid), function(err, doc) {
if(err || !doc) { // exit immediately
cb(err, null);
return;
}
if(_checkExpiration(doc) && doc[propData] !== undefined) { // we're still valid:
cb(null, unserializer(doc[propData]));
}
else { // needs clean-up
me.destroy(sid, cb);
}
});
},
// set session data by session id:
set: function (sid, session, callback) {
var rec = {};
// apply our properties:
_applyProp(propSid, sid, rec);
_applyProp(propData, serializer(session), rec);
// opportunity to do:
_applyProp(propLastActive, new Date(), rec);
mongooseModel.findOneAndUpdate(_applyProp(propSid, sid), rec, {upsert: true}, function(err){
(callback||_.noop)(err);
});
},
// destroy session by session id:
destroy: function (sid, callback) {
mongooseModel.findOneAndRemove(_applyProp(propSid, sid), function(err) {
(callback||_.noop)(err);
});
},
// get the number of total sessions:
length: function (callback) {
mongooseModel.count({}, callback||_.noop);
},
// clear all stored sessions:
clear: function (callback) {
mongooseModel.remove({}, callback||_.noop);
}
});
return me;
}
// inherit by default from connect memory store:
util.inherits(MStore, Store);
// return preconfigured mongoose store:
return MStore;
} | [
"function",
"MongooseStore",
"(",
"session",
",",
"mongooseModel",
")",
"{",
"var",
"self",
"=",
"this",
";",
"if",
"(",
"!",
"session",
"||",
"!",
"session",
".",
"Store",
")",
"{",
"throw",
"'express-session was not passed in constructor.'",
";",
"}",
"if",
"(",
"!",
"mongooseModel",
"||",
"!",
"mongooseModel",
".",
"findById",
")",
"{",
"throw",
"'Mongoose Model was not passed in constructor.'",
";",
"}",
"var",
"Store",
"=",
"session",
".",
"Store",
";",
"/**\n * MongooseStore session store constructor\n */",
"function",
"MStore",
"(",
"config",
")",
"{",
"var",
"me",
"=",
"this",
",",
"// define our options for this store instance",
"opts",
"=",
"_",
".",
"extend",
"(",
"{",
"}",
",",
"defaults",
",",
"config",
")",
",",
"// default (un)serializer using JSON",
"serializer",
"=",
"JSON",
".",
"stringify",
",",
"unserializer",
"=",
"JSON",
".",
"parse",
";",
"// call superclass method",
"Store",
".",
"call",
"(",
"me",
",",
"opts",
")",
";",
"var",
"defExpireTime",
"=",
"opts",
".",
"defaultExpirationTime",
",",
"propSid",
"=",
"opts",
".",
"propertySessionId",
",",
"propData",
"=",
"opts",
".",
"propertyData",
",",
"propLastActive",
"=",
"opts",
".",
"propertyLastActivity",
";",
"// creates/updates a query to search for a certain property",
"function",
"_applyProp",
"(",
"property",
",",
"value",
",",
"obj",
")",
"{",
"obj",
"=",
"obj",
"||",
"{",
"}",
";",
"obj",
"[",
"property",
"]",
"=",
"value",
";",
"return",
"obj",
";",
"}",
"// checks a session document's expiration date to see if it's still valid",
"function",
"_checkExpiration",
"(",
"session",
")",
"{",
"return",
"!",
"session",
"[",
"propLastActive",
"]",
"||",
"new",
"Date",
"<",
"(",
"session",
"[",
"propLastActive",
"]",
".",
"getTime",
"(",
")",
"+",
"defExpireTime",
")",
";",
"}",
"_",
".",
"extend",
"(",
"me",
",",
"{",
"// get session data by session id:",
"get",
":",
"function",
"(",
"sid",
",",
"callback",
")",
"{",
"var",
"cb",
"=",
"callback",
"||",
"_",
".",
"noop",
";",
"// ensureIndex is already called on start-up",
"mongooseModel",
".",
"findOne",
"(",
"_applyProp",
"(",
"propSid",
",",
"sid",
")",
",",
"function",
"(",
"err",
",",
"doc",
")",
"{",
"if",
"(",
"err",
"||",
"!",
"doc",
")",
"{",
"// exit immediately",
"cb",
"(",
"err",
",",
"null",
")",
";",
"return",
";",
"}",
"if",
"(",
"_checkExpiration",
"(",
"doc",
")",
"&&",
"doc",
"[",
"propData",
"]",
"!==",
"undefined",
")",
"{",
"// we're still valid:",
"cb",
"(",
"null",
",",
"unserializer",
"(",
"doc",
"[",
"propData",
"]",
")",
")",
";",
"}",
"else",
"{",
"// needs clean-up",
"me",
".",
"destroy",
"(",
"sid",
",",
"cb",
")",
";",
"}",
"}",
")",
";",
"}",
",",
"// set session data by session id:",
"set",
":",
"function",
"(",
"sid",
",",
"session",
",",
"callback",
")",
"{",
"var",
"rec",
"=",
"{",
"}",
";",
"// apply our properties:",
"_applyProp",
"(",
"propSid",
",",
"sid",
",",
"rec",
")",
";",
"_applyProp",
"(",
"propData",
",",
"serializer",
"(",
"session",
")",
",",
"rec",
")",
";",
"// opportunity to do:",
"_applyProp",
"(",
"propLastActive",
",",
"new",
"Date",
"(",
")",
",",
"rec",
")",
";",
"mongooseModel",
".",
"findOneAndUpdate",
"(",
"_applyProp",
"(",
"propSid",
",",
"sid",
")",
",",
"rec",
",",
"{",
"upsert",
":",
"true",
"}",
",",
"function",
"(",
"err",
")",
"{",
"(",
"callback",
"||",
"_",
".",
"noop",
")",
"(",
"err",
")",
";",
"}",
")",
";",
"}",
",",
"// destroy session by session id:",
"destroy",
":",
"function",
"(",
"sid",
",",
"callback",
")",
"{",
"mongooseModel",
".",
"findOneAndRemove",
"(",
"_applyProp",
"(",
"propSid",
",",
"sid",
")",
",",
"function",
"(",
"err",
")",
"{",
"(",
"callback",
"||",
"_",
".",
"noop",
")",
"(",
"err",
")",
";",
"}",
")",
";",
"}",
",",
"// get the number of total sessions:",
"length",
":",
"function",
"(",
"callback",
")",
"{",
"mongooseModel",
".",
"count",
"(",
"{",
"}",
",",
"callback",
"||",
"_",
".",
"noop",
")",
";",
"}",
",",
"// clear all stored sessions:",
"clear",
":",
"function",
"(",
"callback",
")",
"{",
"mongooseModel",
".",
"remove",
"(",
"{",
"}",
",",
"callback",
"||",
"_",
".",
"noop",
")",
";",
"}",
"}",
")",
";",
"return",
"me",
";",
"}",
"// inherit by default from connect memory store:",
"util",
".",
"inherits",
"(",
"MStore",
",",
"Store",
")",
";",
"// return preconfigured mongoose store:",
"return",
"MStore",
";",
"}"
] | MongooseStore bootstrap constructor
@param {Express} Session Instance of express-session
@param {Model} mongooseModel Model to use for sessions
@return {Function} | [
"MongooseStore",
"bootstrap",
"constructor"
] | 74672a6bac57abe765dea423256407c4dacb8225 | https://github.com/kryo2k/connect-mongoose/blob/74672a6bac57abe765dea423256407c4dacb8225/index.js#L36-L150 |
51,175 | AckerApple/ack-host | modules/web.js | web | function web(){
this.router = routers
this.data = {}
this.data.portStruct = this.data.portStruct || {}
this.data.routers = {}
this.data.isClearRequires = this.data.isClearRequires || this.isProductionMode
this.data.consoleAll = this.data.consoleAll
this.data.consoleNonProductionErrors = true
return this
} | javascript | function web(){
this.router = routers
this.data = {}
this.data.portStruct = this.data.portStruct || {}
this.data.routers = {}
this.data.isClearRequires = this.data.isClearRequires || this.isProductionMode
this.data.consoleAll = this.data.consoleAll
this.data.consoleNonProductionErrors = true
return this
} | [
"function",
"web",
"(",
")",
"{",
"this",
".",
"router",
"=",
"routers",
"this",
".",
"data",
"=",
"{",
"}",
"this",
".",
"data",
".",
"portStruct",
"=",
"this",
".",
"data",
".",
"portStruct",
"||",
"{",
"}",
"this",
".",
"data",
".",
"routers",
"=",
"{",
"}",
"this",
".",
"data",
".",
"isClearRequires",
"=",
"this",
".",
"data",
".",
"isClearRequires",
"||",
"this",
".",
"isProductionMode",
"this",
".",
"data",
".",
"consoleAll",
"=",
"this",
".",
"data",
".",
"consoleAll",
"this",
".",
"data",
".",
"consoleNonProductionErrors",
"=",
"true",
"return",
"this",
"}"
] | request object CLASS
@scope: isClearRequires, consoleAll | [
"request",
"object",
"CLASS"
] | b8ff0563e236499a2b9add5bf1d3849b9137a520 | https://github.com/AckerApple/ack-host/blob/b8ff0563e236499a2b9add5bf1d3849b9137a520/modules/web.js#L19-L30 |
51,176 | jonschlinkert/test-helpers | index.js | helpers | function helpers (options) {
extend(helpers, Options.prototype);
var opts = extend({}, options);
helpers.option('dir', opts.dir || 'test');
helpers.option('fixtures', helpers.options.dir + '/fixtures');
helpers.option('actual', helpers.options.dir + '/actual');
helpers.config(opts);
return helpers;
} | javascript | function helpers (options) {
extend(helpers, Options.prototype);
var opts = extend({}, options);
helpers.option('dir', opts.dir || 'test');
helpers.option('fixtures', helpers.options.dir + '/fixtures');
helpers.option('actual', helpers.options.dir + '/actual');
helpers.config(opts);
return helpers;
} | [
"function",
"helpers",
"(",
"options",
")",
"{",
"extend",
"(",
"helpers",
",",
"Options",
".",
"prototype",
")",
";",
"var",
"opts",
"=",
"extend",
"(",
"{",
"}",
",",
"options",
")",
";",
"helpers",
".",
"option",
"(",
"'dir'",
",",
"opts",
".",
"dir",
"||",
"'test'",
")",
";",
"helpers",
".",
"option",
"(",
"'fixtures'",
",",
"helpers",
".",
"options",
".",
"dir",
"+",
"'/fixtures'",
")",
";",
"helpers",
".",
"option",
"(",
"'actual'",
",",
"helpers",
".",
"options",
".",
"dir",
"+",
"'/actual'",
")",
";",
"helpers",
".",
"config",
"(",
"opts",
")",
";",
"return",
"helpers",
";",
"}"
] | Initialize `helpers` with default `options`.
```js
var helpers = require('test-helpers')
helpers({dir: 'test'})
```
@method `helpers`
@param {Object} `options` Default options to use.
@api public | [
"Initialize",
"helpers",
"with",
"default",
"options",
"."
] | d13879220299ca7c1bb00d64ff51b5c4e87d4020 | https://github.com/jonschlinkert/test-helpers/blob/d13879220299ca7c1bb00d64ff51b5c4e87d4020/index.js#L31-L40 |
51,177 | nachos/nachos-config | lib/index.js | NachosConfig | function NachosConfig() {
var defaults = {
packages: nachosHome('packages'),
server: 'http://nachosjs.herokuapp.com',
defaults: {
shell: 'shell',
exts: {}
},
startup: []
};
debug('creating new settings file with these defaults: %j', defaults);
SettingsFile.call(this, 'nachos', {
globalDefaults: defaults
});
} | javascript | function NachosConfig() {
var defaults = {
packages: nachosHome('packages'),
server: 'http://nachosjs.herokuapp.com',
defaults: {
shell: 'shell',
exts: {}
},
startup: []
};
debug('creating new settings file with these defaults: %j', defaults);
SettingsFile.call(this, 'nachos', {
globalDefaults: defaults
});
} | [
"function",
"NachosConfig",
"(",
")",
"{",
"var",
"defaults",
"=",
"{",
"packages",
":",
"nachosHome",
"(",
"'packages'",
")",
",",
"server",
":",
"'http://nachosjs.herokuapp.com'",
",",
"defaults",
":",
"{",
"shell",
":",
"'shell'",
",",
"exts",
":",
"{",
"}",
"}",
",",
"startup",
":",
"[",
"]",
"}",
";",
"debug",
"(",
"'creating new settings file with these defaults: %j'",
",",
"defaults",
")",
";",
"SettingsFile",
".",
"call",
"(",
"this",
",",
"'nachos'",
",",
"{",
"globalDefaults",
":",
"defaults",
"}",
")",
";",
"}"
] | Creating a settings file with nachos defaults
@constructor | [
"Creating",
"a",
"settings",
"file",
"with",
"nachos",
"defaults"
] | 310d6b2b0157e611d8a88bf55cc2a473966d8b8e | https://github.com/nachos/nachos-config/blob/310d6b2b0157e611d8a88bf55cc2a473966d8b8e/lib/index.js#L14-L30 |
51,178 | MakerCollider/node-red-contrib-smartnode-hook | html/scripts/highchart/modules/funnel.src.js | function () {
var data = this.data,
labelDistance = this.options.dataLabels.distance,
leftSide,
sign,
point,
i = data.length,
x,
y;
// In the original pie label anticollision logic, the slots are distributed
// from one labelDistance above to one labelDistance below the pie. In funnels
// we don't want this.
this.center[2] -= 2 * labelDistance;
// Set the label position array for each point.
while (i--) {
point = data[i];
leftSide = point.half;
sign = leftSide ? 1 : -1;
y = point.plotY;
x = this.getX(y, leftSide);
// set the anchor point for data labels
point.labelPos = [
0, // first break of connector
y, // a/a
x + (labelDistance - 5) * sign, // second break, right outside point shape
y, // a/a
x + labelDistance * sign, // landing point for connector
y, // a/a
leftSide ? 'right' : 'left', // alignment
0 // center angle
];
}
seriesTypes.pie.prototype.drawDataLabels.call(this);
} | javascript | function () {
var data = this.data,
labelDistance = this.options.dataLabels.distance,
leftSide,
sign,
point,
i = data.length,
x,
y;
// In the original pie label anticollision logic, the slots are distributed
// from one labelDistance above to one labelDistance below the pie. In funnels
// we don't want this.
this.center[2] -= 2 * labelDistance;
// Set the label position array for each point.
while (i--) {
point = data[i];
leftSide = point.half;
sign = leftSide ? 1 : -1;
y = point.plotY;
x = this.getX(y, leftSide);
// set the anchor point for data labels
point.labelPos = [
0, // first break of connector
y, // a/a
x + (labelDistance - 5) * sign, // second break, right outside point shape
y, // a/a
x + labelDistance * sign, // landing point for connector
y, // a/a
leftSide ? 'right' : 'left', // alignment
0 // center angle
];
}
seriesTypes.pie.prototype.drawDataLabels.call(this);
} | [
"function",
"(",
")",
"{",
"var",
"data",
"=",
"this",
".",
"data",
",",
"labelDistance",
"=",
"this",
".",
"options",
".",
"dataLabels",
".",
"distance",
",",
"leftSide",
",",
"sign",
",",
"point",
",",
"i",
"=",
"data",
".",
"length",
",",
"x",
",",
"y",
";",
"// In the original pie label anticollision logic, the slots are distributed",
"// from one labelDistance above to one labelDistance below the pie. In funnels",
"// we don't want this.",
"this",
".",
"center",
"[",
"2",
"]",
"-=",
"2",
"*",
"labelDistance",
";",
"// Set the label position array for each point.",
"while",
"(",
"i",
"--",
")",
"{",
"point",
"=",
"data",
"[",
"i",
"]",
";",
"leftSide",
"=",
"point",
".",
"half",
";",
"sign",
"=",
"leftSide",
"?",
"1",
":",
"-",
"1",
";",
"y",
"=",
"point",
".",
"plotY",
";",
"x",
"=",
"this",
".",
"getX",
"(",
"y",
",",
"leftSide",
")",
";",
"// set the anchor point for data labels",
"point",
".",
"labelPos",
"=",
"[",
"0",
",",
"// first break of connector",
"y",
",",
"// a/a",
"x",
"+",
"(",
"labelDistance",
"-",
"5",
")",
"*",
"sign",
",",
"// second break, right outside point shape",
"y",
",",
"// a/a",
"x",
"+",
"labelDistance",
"*",
"sign",
",",
"// landing point for connector",
"y",
",",
"// a/a",
"leftSide",
"?",
"'right'",
":",
"'left'",
",",
"// alignment",
"0",
"// center angle",
"]",
";",
"}",
"seriesTypes",
".",
"pie",
".",
"prototype",
".",
"drawDataLabels",
".",
"call",
"(",
"this",
")",
";",
"}"
] | Extend the pie data label method | [
"Extend",
"the",
"pie",
"data",
"label",
"method"
] | 245c267e832968bad880ca009929043e82c7bc25 | https://github.com/MakerCollider/node-red-contrib-smartnode-hook/blob/245c267e832968bad880ca009929043e82c7bc25/html/scripts/highchart/modules/funnel.src.js#L256-L293 |
|
51,179 | gethuman/jyt | lib/jyt.plugins.js | addPluginsToScope | function addPluginsToScope(scope) {
var name;
for (name in plugins) {
if (plugins.hasOwnProperty(name)) {
scope[name] = plugins[name];
}
}
} | javascript | function addPluginsToScope(scope) {
var name;
for (name in plugins) {
if (plugins.hasOwnProperty(name)) {
scope[name] = plugins[name];
}
}
} | [
"function",
"addPluginsToScope",
"(",
"scope",
")",
"{",
"var",
"name",
";",
"for",
"(",
"name",
"in",
"plugins",
")",
"{",
"if",
"(",
"plugins",
".",
"hasOwnProperty",
"(",
"name",
")",
")",
"{",
"scope",
"[",
"name",
"]",
"=",
"plugins",
"[",
"name",
"]",
";",
"}",
"}",
"}"
] | Add all existing plugins to the input scope
@param scope | [
"Add",
"all",
"existing",
"plugins",
"to",
"the",
"input",
"scope"
] | 716be37e09217b4be917e179389f752212a428b3 | https://github.com/gethuman/jyt/blob/716be37e09217b4be917e179389f752212a428b3/lib/jyt.plugins.js#L16-L23 |
51,180 | gethuman/jyt | lib/jyt.plugins.js | registerPlugin | function registerPlugin(name, obj) {
if (name && name.length && obj) {
plugins[name] = obj;
}
} | javascript | function registerPlugin(name, obj) {
if (name && name.length && obj) {
plugins[name] = obj;
}
} | [
"function",
"registerPlugin",
"(",
"name",
",",
"obj",
")",
"{",
"if",
"(",
"name",
"&&",
"name",
".",
"length",
"&&",
"obj",
")",
"{",
"plugins",
"[",
"name",
"]",
"=",
"obj",
";",
"}",
"}"
] | Register a new plugin
@param name
@param obj | [
"Register",
"a",
"new",
"plugin"
] | 716be37e09217b4be917e179389f752212a428b3 | https://github.com/gethuman/jyt/blob/716be37e09217b4be917e179389f752212a428b3/lib/jyt.plugins.js#L30-L34 |
51,181 | gethuman/jyt | lib/jyt.plugins.js | init | function init() {
// ex. jif(true, div('blah'))
registerPlugin('jif', function jif(condition, elem) {
if (utils.isArray(elem)) {
elem = runtime.naked(elem, null);
}
return condition ? elem : null;
});
// ex. jeach({}, function (item) {})
registerPlugin('jeach', function jeach(items, cb) {
if (!items || !cb) { return null; }
var ret = [];
for (var i = 0, len = items.length; i < len; ++i) {
ret.push(cb(items[i]));
}
return ret;
});
} | javascript | function init() {
// ex. jif(true, div('blah'))
registerPlugin('jif', function jif(condition, elem) {
if (utils.isArray(elem)) {
elem = runtime.naked(elem, null);
}
return condition ? elem : null;
});
// ex. jeach({}, function (item) {})
registerPlugin('jeach', function jeach(items, cb) {
if (!items || !cb) { return null; }
var ret = [];
for (var i = 0, len = items.length; i < len; ++i) {
ret.push(cb(items[i]));
}
return ret;
});
} | [
"function",
"init",
"(",
")",
"{",
"// ex. jif(true, div('blah'))",
"registerPlugin",
"(",
"'jif'",
",",
"function",
"jif",
"(",
"condition",
",",
"elem",
")",
"{",
"if",
"(",
"utils",
".",
"isArray",
"(",
"elem",
")",
")",
"{",
"elem",
"=",
"runtime",
".",
"naked",
"(",
"elem",
",",
"null",
")",
";",
"}",
"return",
"condition",
"?",
"elem",
":",
"null",
";",
"}",
")",
";",
"// ex. jeach({}, function (item) {})",
"registerPlugin",
"(",
"'jeach'",
",",
"function",
"jeach",
"(",
"items",
",",
"cb",
")",
"{",
"if",
"(",
"!",
"items",
"||",
"!",
"cb",
")",
"{",
"return",
"null",
";",
"}",
"var",
"ret",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"items",
".",
"length",
";",
"i",
"<",
"len",
";",
"++",
"i",
")",
"{",
"ret",
".",
"push",
"(",
"cb",
"(",
"items",
"[",
"i",
"]",
")",
")",
";",
"}",
"return",
"ret",
";",
"}",
")",
";",
"}"
] | Register common plugins | [
"Register",
"common",
"plugins"
] | 716be37e09217b4be917e179389f752212a428b3 | https://github.com/gethuman/jyt/blob/716be37e09217b4be917e179389f752212a428b3/lib/jyt.plugins.js#L39-L61 |
51,182 | sendanor/nor-nopg | src/InternalCursor.js | InternalCursor | function InternalCursor(parent, key) {
debug.assert(parent).is('object');
debug.assert(key).is('defined');
this.cursors = [{'parent':parent, 'key':key}];
} | javascript | function InternalCursor(parent, key) {
debug.assert(parent).is('object');
debug.assert(key).is('defined');
this.cursors = [{'parent':parent, 'key':key}];
} | [
"function",
"InternalCursor",
"(",
"parent",
",",
"key",
")",
"{",
"debug",
".",
"assert",
"(",
"parent",
")",
".",
"is",
"(",
"'object'",
")",
";",
"debug",
".",
"assert",
"(",
"key",
")",
".",
"is",
"(",
"'defined'",
")",
";",
"this",
".",
"cursors",
"=",
"[",
"{",
"'parent'",
":",
"parent",
",",
"'key'",
":",
"key",
"}",
"]",
";",
"}"
] | Internal cursor object | [
"Internal",
"cursor",
"object"
] | 0d99b86c1a1996b5828b56de8de23700df8bbc0c | https://github.com/sendanor/nor-nopg/blob/0d99b86c1a1996b5828b56de8de23700df8bbc0c/src/InternalCursor.js#L8-L12 |
51,183 | defeo/was_framework | lib/db.js | connect_cb | function connect_cb(err, db) {
if (err) {
next(err);
} else {
if (db && db instanceof sqlite) { // Sqlite only
app.db = db;
// Use the query escaping facilities of mysql
app.db.escape = SqliteString.escape;
app.db.escapeId = SqliteString.escapeId;
app.db.format = SqliteString.format;
// Wrap exec with a signature similar to mysql's
// prepared queries
app.db.query = function(sql, values, callback) {
// prepare the statement
if (typeof values == 'function') {
callback = values;
} else {
sql = app.db.format(sql, values);
}
// Log some info
console.log('SQL query:', sql);
// execute the statement
app.db.exec(sql, callback);
};
app.db.end = function() {};
} else { // MySql only
app.db.format = MySqlString.format;
// Wrap qyery with some logging some logging
var _query = app.db.query;
app.db.query = function(sql, values, callback) {
var _sql = sql;
// prepare the statement (just for logging)
if (typeof values != 'function')
_sql = app.db.format(sql, values);
// Log some info
console.log('SQL query:', _sql);
// execute the statement
return _query.call(this, sql, values, callback);
};
}
next();
}
} | javascript | function connect_cb(err, db) {
if (err) {
next(err);
} else {
if (db && db instanceof sqlite) { // Sqlite only
app.db = db;
// Use the query escaping facilities of mysql
app.db.escape = SqliteString.escape;
app.db.escapeId = SqliteString.escapeId;
app.db.format = SqliteString.format;
// Wrap exec with a signature similar to mysql's
// prepared queries
app.db.query = function(sql, values, callback) {
// prepare the statement
if (typeof values == 'function') {
callback = values;
} else {
sql = app.db.format(sql, values);
}
// Log some info
console.log('SQL query:', sql);
// execute the statement
app.db.exec(sql, callback);
};
app.db.end = function() {};
} else { // MySql only
app.db.format = MySqlString.format;
// Wrap qyery with some logging some logging
var _query = app.db.query;
app.db.query = function(sql, values, callback) {
var _sql = sql;
// prepare the statement (just for logging)
if (typeof values != 'function')
_sql = app.db.format(sql, values);
// Log some info
console.log('SQL query:', _sql);
// execute the statement
return _query.call(this, sql, values, callback);
};
}
next();
}
} | [
"function",
"connect_cb",
"(",
"err",
",",
"db",
")",
"{",
"if",
"(",
"err",
")",
"{",
"next",
"(",
"err",
")",
";",
"}",
"else",
"{",
"if",
"(",
"db",
"&&",
"db",
"instanceof",
"sqlite",
")",
"{",
"// Sqlite only",
"app",
".",
"db",
"=",
"db",
";",
"// Use the query escaping facilities of mysql",
"app",
".",
"db",
".",
"escape",
"=",
"SqliteString",
".",
"escape",
";",
"app",
".",
"db",
".",
"escapeId",
"=",
"SqliteString",
".",
"escapeId",
";",
"app",
".",
"db",
".",
"format",
"=",
"SqliteString",
".",
"format",
";",
"// Wrap exec with a signature similar to mysql's",
"// prepared queries",
"app",
".",
"db",
".",
"query",
"=",
"function",
"(",
"sql",
",",
"values",
",",
"callback",
")",
"{",
"// prepare the statement",
"if",
"(",
"typeof",
"values",
"==",
"'function'",
")",
"{",
"callback",
"=",
"values",
";",
"}",
"else",
"{",
"sql",
"=",
"app",
".",
"db",
".",
"format",
"(",
"sql",
",",
"values",
")",
";",
"}",
"// Log some info",
"console",
".",
"log",
"(",
"'SQL query:'",
",",
"sql",
")",
";",
"// execute the statement",
"app",
".",
"db",
".",
"exec",
"(",
"sql",
",",
"callback",
")",
";",
"}",
";",
"app",
".",
"db",
".",
"end",
"=",
"function",
"(",
")",
"{",
"}",
";",
"}",
"else",
"{",
"// MySql only",
"app",
".",
"db",
".",
"format",
"=",
"MySqlString",
".",
"format",
";",
"// Wrap qyery with some logging some logging ",
"var",
"_query",
"=",
"app",
".",
"db",
".",
"query",
";",
"app",
".",
"db",
".",
"query",
"=",
"function",
"(",
"sql",
",",
"values",
",",
"callback",
")",
"{",
"var",
"_sql",
"=",
"sql",
";",
"// prepare the statement (just for logging)",
"if",
"(",
"typeof",
"values",
"!=",
"'function'",
")",
"_sql",
"=",
"app",
".",
"db",
".",
"format",
"(",
"sql",
",",
"values",
")",
";",
"// Log some info",
"console",
".",
"log",
"(",
"'SQL query:'",
",",
"_sql",
")",
";",
"// execute the statement",
"return",
"_query",
".",
"call",
"(",
"this",
",",
"sql",
",",
"values",
",",
"callback",
")",
";",
"}",
";",
"}",
"next",
"(",
")",
";",
"}",
"}"
] | This function is executed after the connection to the database has been established | [
"This",
"function",
"is",
"executed",
"after",
"the",
"connection",
"to",
"the",
"database",
"has",
"been",
"established"
] | ab52bbbf5943e9062fe6ea82f1fea637a11d727a | https://github.com/defeo/was_framework/blob/ab52bbbf5943e9062fe6ea82f1fea637a11d727a/lib/db.js#L28-L70 |
51,184 | xiamidaxia/xiami | meteor/accounts-password/password_server.js | function (user) {
if (user.id)
return {_id: user.id};
else if (user.username)
return {username: user.username};
else if (user.email)
return {"emails.address": user.email};
throw new Error("shouldn't happen (validation missed something)");
} | javascript | function (user) {
if (user.id)
return {_id: user.id};
else if (user.username)
return {username: user.username};
else if (user.email)
return {"emails.address": user.email};
throw new Error("shouldn't happen (validation missed something)");
} | [
"function",
"(",
"user",
")",
"{",
"if",
"(",
"user",
".",
"id",
")",
"return",
"{",
"_id",
":",
"user",
".",
"id",
"}",
";",
"else",
"if",
"(",
"user",
".",
"username",
")",
"return",
"{",
"username",
":",
"user",
".",
"username",
"}",
";",
"else",
"if",
"(",
"user",
".",
"email",
")",
"return",
"{",
"\"emails.address\"",
":",
"user",
".",
"email",
"}",
";",
"throw",
"new",
"Error",
"(",
"\"shouldn't happen (validation missed something)\"",
")",
";",
"}"
] | Users can specify various keys to identify themselves with. @param user {Object} with one of `id`, `username`, or `email`. @returns A selector to pass to mongo to get the user record. | [
"Users",
"can",
"specify",
"various",
"keys",
"to",
"identify",
"themselves",
"with",
"."
] | 6fcee92c493c12bf8fd67c7068e67fa6a72a306b | https://github.com/xiamidaxia/xiami/blob/6fcee92c493c12bf8fd67c7068e67fa6a72a306b/meteor/accounts-password/password_server.js#L18-L26 |
|
51,185 | xiamidaxia/xiami | meteor/accounts-password/password_server.js | function (options) {
// Unknown keys allowed, because a onCreateUserHook can take arbitrary
// options.
check(options, Match.ObjectIncluding({
username: Match.Optional(String),
email: Match.Optional(String),
password: Match.Optional(String),
srp: Match.Optional(SRP.matchVerifier)
}));
var username = options.username;
var email = options.email;
if (!username && !email)
throw new Meteor.Error(400, "Need to set a username or email");
// Raw password. The meteor client doesn't send this, but a DDP
// client that didn't implement SRP could send this. This should
// only be done over SSL.
if (options.password) {
if (options.srp)
throw new Meteor.Error(400, "Don't pass both password and srp in options");
options.srp = SRP.generateVerifier(options.password);
}
var user = {services: {}};
if (options.srp)
user.services.password = {srp: options.srp}; // XXX validate verifier
if (username)
user.username = username;
if (email)
user.emails = [{address: email, verified: false}];
return Accounts.insertUserDoc(options, user);
} | javascript | function (options) {
// Unknown keys allowed, because a onCreateUserHook can take arbitrary
// options.
check(options, Match.ObjectIncluding({
username: Match.Optional(String),
email: Match.Optional(String),
password: Match.Optional(String),
srp: Match.Optional(SRP.matchVerifier)
}));
var username = options.username;
var email = options.email;
if (!username && !email)
throw new Meteor.Error(400, "Need to set a username or email");
// Raw password. The meteor client doesn't send this, but a DDP
// client that didn't implement SRP could send this. This should
// only be done over SSL.
if (options.password) {
if (options.srp)
throw new Meteor.Error(400, "Don't pass both password and srp in options");
options.srp = SRP.generateVerifier(options.password);
}
var user = {services: {}};
if (options.srp)
user.services.password = {srp: options.srp}; // XXX validate verifier
if (username)
user.username = username;
if (email)
user.emails = [{address: email, verified: false}];
return Accounts.insertUserDoc(options, user);
} | [
"function",
"(",
"options",
")",
"{",
"// Unknown keys allowed, because a onCreateUserHook can take arbitrary",
"// options.",
"check",
"(",
"options",
",",
"Match",
".",
"ObjectIncluding",
"(",
"{",
"username",
":",
"Match",
".",
"Optional",
"(",
"String",
")",
",",
"email",
":",
"Match",
".",
"Optional",
"(",
"String",
")",
",",
"password",
":",
"Match",
".",
"Optional",
"(",
"String",
")",
",",
"srp",
":",
"Match",
".",
"Optional",
"(",
"SRP",
".",
"matchVerifier",
")",
"}",
")",
")",
";",
"var",
"username",
"=",
"options",
".",
"username",
";",
"var",
"email",
"=",
"options",
".",
"email",
";",
"if",
"(",
"!",
"username",
"&&",
"!",
"email",
")",
"throw",
"new",
"Meteor",
".",
"Error",
"(",
"400",
",",
"\"Need to set a username or email\"",
")",
";",
"// Raw password. The meteor client doesn't send this, but a DDP",
"// client that didn't implement SRP could send this. This should",
"// only be done over SSL.",
"if",
"(",
"options",
".",
"password",
")",
"{",
"if",
"(",
"options",
".",
"srp",
")",
"throw",
"new",
"Meteor",
".",
"Error",
"(",
"400",
",",
"\"Don't pass both password and srp in options\"",
")",
";",
"options",
".",
"srp",
"=",
"SRP",
".",
"generateVerifier",
"(",
"options",
".",
"password",
")",
";",
"}",
"var",
"user",
"=",
"{",
"services",
":",
"{",
"}",
"}",
";",
"if",
"(",
"options",
".",
"srp",
")",
"user",
".",
"services",
".",
"password",
"=",
"{",
"srp",
":",
"options",
".",
"srp",
"}",
";",
"// XXX validate verifier",
"if",
"(",
"username",
")",
"user",
".",
"username",
"=",
"username",
";",
"if",
"(",
"email",
")",
"user",
".",
"emails",
"=",
"[",
"{",
"address",
":",
"email",
",",
"verified",
":",
"false",
"}",
"]",
";",
"return",
"Accounts",
".",
"insertUserDoc",
"(",
"options",
",",
"user",
")",
";",
"}"
] | Shared createUser function called from the createUser method, both if originates in client or server code. Calls user provided hooks, does the actual user insertion. returns the user id | [
"Shared",
"createUser",
"function",
"called",
"from",
"the",
"createUser",
"method",
"both",
"if",
"originates",
"in",
"client",
"or",
"server",
"code",
".",
"Calls",
"user",
"provided",
"hooks",
"does",
"the",
"actual",
"user",
"insertion",
".",
"returns",
"the",
"user",
"id"
] | 6fcee92c493c12bf8fd67c7068e67fa6a72a306b | https://github.com/xiamidaxia/xiami/blob/6fcee92c493c12bf8fd67c7068e67fa6a72a306b/meteor/accounts-password/password_server.js#L534-L567 |
|
51,186 | Coffeekraken/s-validator-component | dist/js/SValidatorComponent.js | setMessages | function setMessages() {
var messages = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
__messages = _extends({}, __messages, messages);
} | javascript | function setMessages() {
var messages = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
__messages = _extends({}, __messages, messages);
} | [
"function",
"setMessages",
"(",
")",
"{",
"var",
"messages",
"=",
"arguments",
".",
"length",
">",
"0",
"&&",
"arguments",
"[",
"0",
"]",
"!==",
"undefined",
"?",
"arguments",
"[",
"0",
"]",
":",
"{",
"}",
";",
"__messages",
"=",
"_extends",
"(",
"{",
"}",
",",
"__messages",
",",
"messages",
")",
";",
"}"
] | Set the messages
@param {Object} messages An object of messages to override | [
"Set",
"the",
"messages"
] | 84519fc1bb013ccd0a4683dbcf88f2c3e08a5f9c | https://github.com/Coffeekraken/s-validator-component/blob/84519fc1bb013ccd0a4683dbcf88f2c3e08a5f9c/dist/js/SValidatorComponent.js#L779-L783 |
51,187 | artdecocode/which-stream | build/index.js | whichStream | async function whichStream(config) {
const {
source,
destination,
} = config
let { readable, writable } = config
if (!(source || readable))
throw new Error('Please give either a source or readable.')
if (!(destination || writable))
throw new Error('Please give either a destination or writable.')
if (source && !readable) readable = createReadStream(source)
if (destination == '-') {
readable.pipe(process.stdout)
} else if (destination) {
await handleWriteStream(destination, readable, source)
} else if (writable instanceof Writable) {
readable.pipe(writable)
await new Promise((r, j) => {
writable.on('error', j)
writable.on('finish', r)
})
}
} | javascript | async function whichStream(config) {
const {
source,
destination,
} = config
let { readable, writable } = config
if (!(source || readable))
throw new Error('Please give either a source or readable.')
if (!(destination || writable))
throw new Error('Please give either a destination or writable.')
if (source && !readable) readable = createReadStream(source)
if (destination == '-') {
readable.pipe(process.stdout)
} else if (destination) {
await handleWriteStream(destination, readable, source)
} else if (writable instanceof Writable) {
readable.pipe(writable)
await new Promise((r, j) => {
writable.on('error', j)
writable.on('finish', r)
})
}
} | [
"async",
"function",
"whichStream",
"(",
"config",
")",
"{",
"const",
"{",
"source",
",",
"destination",
",",
"}",
"=",
"config",
"let",
"{",
"readable",
",",
"writable",
"}",
"=",
"config",
"if",
"(",
"!",
"(",
"source",
"||",
"readable",
")",
")",
"throw",
"new",
"Error",
"(",
"'Please give either a source or readable.'",
")",
"if",
"(",
"!",
"(",
"destination",
"||",
"writable",
")",
")",
"throw",
"new",
"Error",
"(",
"'Please give either a destination or writable.'",
")",
"if",
"(",
"source",
"&&",
"!",
"readable",
")",
"readable",
"=",
"createReadStream",
"(",
"source",
")",
"if",
"(",
"destination",
"==",
"'-'",
")",
"{",
"readable",
".",
"pipe",
"(",
"process",
".",
"stdout",
")",
"}",
"else",
"if",
"(",
"destination",
")",
"{",
"await",
"handleWriteStream",
"(",
"destination",
",",
"readable",
",",
"source",
")",
"}",
"else",
"if",
"(",
"writable",
"instanceof",
"Writable",
")",
"{",
"readable",
".",
"pipe",
"(",
"writable",
")",
"await",
"new",
"Promise",
"(",
"(",
"r",
",",
"j",
")",
"=>",
"{",
"writable",
".",
"on",
"(",
"'error'",
",",
"j",
")",
"writable",
".",
"on",
"(",
"'finish'",
",",
"r",
")",
"}",
")",
"}",
"}"
] | Handles the flow of streams, and awaits for them to complete. The input can be specified either as a string with the `source` property, or as as stream with the `readable`. The output can also be given either as a string with the `destination`, or as a stream with the `writable`. If destination is passed as the `-`, the output becomes `process.stdout`.
@param {!_whichStream.Config} config The configuration object.
@param {string} [config.source] The path to a source file from which to read data.
@param {!stream.Readable} [config.readable] An optional input stream, if the `source` is not given.
@param {string} [config.destination] The path to an output file. If `-` is given, `process.stdout` will be used. If the path of the input stream is the same as of the output one, the result will be first written to the memory, and only then to the destination file. Moreover, when used with the `readable` specified to overwrite the file from which data is originally read from, the `source` should also be passed.
@param {!stream.Writable} [config.writable] A stream into which to pipe the input stream, if `destination` is not given. | [
"Handles",
"the",
"flow",
"of",
"streams",
"and",
"awaits",
"for",
"them",
"to",
"complete",
".",
"The",
"input",
"can",
"be",
"specified",
"either",
"as",
"a",
"string",
"with",
"the",
"source",
"property",
"or",
"as",
"as",
"stream",
"with",
"the",
"readable",
".",
"The",
"output",
"can",
"also",
"be",
"given",
"either",
"as",
"a",
"string",
"with",
"the",
"destination",
"or",
"as",
"a",
"stream",
"with",
"the",
"writable",
".",
"If",
"destination",
"is",
"passed",
"as",
"the",
"-",
"the",
"output",
"becomes",
"process",
".",
"stdout",
"."
] | f019bbc83af3e272f4985f23a22c6dd1f2f2a54f | https://github.com/artdecocode/which-stream/blob/f019bbc83af3e272f4985f23a22c6dd1f2f2a54f/build/index.js#L16-L41 |
51,188 | 131/phar-stream | index.js | search | function search(stream, needle) {
var ss = new streamsearch(needle),
push = ss.push.bind(ss);
ss.maxMatches = 1;
var defered = defer();
stream.on("data", push);
stream.once("finish", function(){
defered.reject("No stub found in stream")
});
var pos = 0;
ss.on("info", function(isMatch, data, start, end){
if(data)
pos += end - start;
if(!isMatch)
return;
stream.removeListener("data", push);
defered.resolve(pos);
});
return defered;
} | javascript | function search(stream, needle) {
var ss = new streamsearch(needle),
push = ss.push.bind(ss);
ss.maxMatches = 1;
var defered = defer();
stream.on("data", push);
stream.once("finish", function(){
defered.reject("No stub found in stream")
});
var pos = 0;
ss.on("info", function(isMatch, data, start, end){
if(data)
pos += end - start;
if(!isMatch)
return;
stream.removeListener("data", push);
defered.resolve(pos);
});
return defered;
} | [
"function",
"search",
"(",
"stream",
",",
"needle",
")",
"{",
"var",
"ss",
"=",
"new",
"streamsearch",
"(",
"needle",
")",
",",
"push",
"=",
"ss",
".",
"push",
".",
"bind",
"(",
"ss",
")",
";",
"ss",
".",
"maxMatches",
"=",
"1",
";",
"var",
"defered",
"=",
"defer",
"(",
")",
";",
"stream",
".",
"on",
"(",
"\"data\"",
",",
"push",
")",
";",
"stream",
".",
"once",
"(",
"\"finish\"",
",",
"function",
"(",
")",
"{",
"defered",
".",
"reject",
"(",
"\"No stub found in stream\"",
")",
"}",
")",
";",
"var",
"pos",
"=",
"0",
";",
"ss",
".",
"on",
"(",
"\"info\"",
",",
"function",
"(",
"isMatch",
",",
"data",
",",
"start",
",",
"end",
")",
"{",
"if",
"(",
"data",
")",
"pos",
"+=",
"end",
"-",
"start",
";",
"if",
"(",
"!",
"isMatch",
")",
"return",
";",
"stream",
".",
"removeListener",
"(",
"\"data\"",
",",
"push",
")",
";",
"defered",
".",
"resolve",
"(",
"pos",
")",
";",
"}",
")",
";",
"return",
"defered",
";",
"}"
] | search for a stub in a stream, return a promise | [
"search",
"for",
"a",
"stub",
"in",
"a",
"stream",
"return",
"a",
"promise"
] | 0a63b5d0adf3d04315bbd15d60d0cf24cfee68c2 | https://github.com/131/phar-stream/blob/0a63b5d0adf3d04315bbd15d60d0cf24cfee68c2/index.js#L20-L46 |
51,189 | marinvvasilev/appcelerator-githubauth | index.js | Plugin | function Plugin(server) {
this.server = server;
this.config = server.config;
//Check if we have the right config
this.checkConfiguration();
this.settings = this.config.githubAuth;
//Init if not present
if (typeof this.server.passport === "undefined")
this.initGithubAuth();
else
this.passport = this.server.passport;
} | javascript | function Plugin(server) {
this.server = server;
this.config = server.config;
//Check if we have the right config
this.checkConfiguration();
this.settings = this.config.githubAuth;
//Init if not present
if (typeof this.server.passport === "undefined")
this.initGithubAuth();
else
this.passport = this.server.passport;
} | [
"function",
"Plugin",
"(",
"server",
")",
"{",
"this",
".",
"server",
"=",
"server",
";",
"this",
".",
"config",
"=",
"server",
".",
"config",
";",
"//Check if we have the right config",
"this",
".",
"checkConfiguration",
"(",
")",
";",
"this",
".",
"settings",
"=",
"this",
".",
"config",
".",
"githubAuth",
";",
"//Init if not present",
"if",
"(",
"typeof",
"this",
".",
"server",
".",
"passport",
"===",
"\"undefined\"",
")",
"this",
".",
"initGithubAuth",
"(",
")",
";",
"else",
"this",
".",
"passport",
"=",
"this",
".",
"server",
".",
"passport",
";",
"}"
] | Plugin initialization logic
@param Object server
@param Object testConfig - optional - configuration settings for testing purposes | [
"Plugin",
"initialization",
"logic"
] | 07bb77a1bc5720dc584b57b3de782cfc6fd5a06e | https://github.com/marinvvasilev/appcelerator-githubauth/blob/07bb77a1bc5720dc584b57b3de782cfc6fd5a06e/index.js#L9-L20 |
51,190 | nfroidure/common-services | src/lock.js | take | async function take(key) {
const previousLocks = LOCKS_MAP.get(key) || [];
let locksLength = previousLocks.length;
log('debug', `Taking the lock on ${key} (queue length was ${locksLength})`);
let release;
const newLock = {
releasePromise: new Promise(async (resolve, reject) => {
release = resolve;
if (LOCK_TIMEOUT !== Infinity) {
await delay.create(LOCK_TIMEOUT);
reject(new YError('E_LOCK_TIMEOUT'));
}
}),
release,
};
previousLocks.push(newLock);
locksLength++;
if (locksLength > 1) {
await previousLocks[locksLength - 1].releasePromise;
} else {
LOCKS_MAP.set(key, previousLocks);
}
} | javascript | async function take(key) {
const previousLocks = LOCKS_MAP.get(key) || [];
let locksLength = previousLocks.length;
log('debug', `Taking the lock on ${key} (queue length was ${locksLength})`);
let release;
const newLock = {
releasePromise: new Promise(async (resolve, reject) => {
release = resolve;
if (LOCK_TIMEOUT !== Infinity) {
await delay.create(LOCK_TIMEOUT);
reject(new YError('E_LOCK_TIMEOUT'));
}
}),
release,
};
previousLocks.push(newLock);
locksLength++;
if (locksLength > 1) {
await previousLocks[locksLength - 1].releasePromise;
} else {
LOCKS_MAP.set(key, previousLocks);
}
} | [
"async",
"function",
"take",
"(",
"key",
")",
"{",
"const",
"previousLocks",
"=",
"LOCKS_MAP",
".",
"get",
"(",
"key",
")",
"||",
"[",
"]",
";",
"let",
"locksLength",
"=",
"previousLocks",
".",
"length",
";",
"log",
"(",
"'debug'",
",",
"`",
"${",
"key",
"}",
"${",
"locksLength",
"}",
"`",
")",
";",
"let",
"release",
";",
"const",
"newLock",
"=",
"{",
"releasePromise",
":",
"new",
"Promise",
"(",
"async",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"release",
"=",
"resolve",
";",
"if",
"(",
"LOCK_TIMEOUT",
"!==",
"Infinity",
")",
"{",
"await",
"delay",
".",
"create",
"(",
"LOCK_TIMEOUT",
")",
";",
"reject",
"(",
"new",
"YError",
"(",
"'E_LOCK_TIMEOUT'",
")",
")",
";",
"}",
"}",
")",
",",
"release",
",",
"}",
";",
"previousLocks",
".",
"push",
"(",
"newLock",
")",
";",
"locksLength",
"++",
";",
"if",
"(",
"locksLength",
">",
"1",
")",
"{",
"await",
"previousLocks",
"[",
"locksLength",
"-",
"1",
"]",
".",
"releasePromise",
";",
"}",
"else",
"{",
"LOCKS_MAP",
".",
"set",
"(",
"key",
",",
"previousLocks",
")",
";",
"}",
"}"
] | Take the lock on the given resource key
@param {String} key
A unique key for the locked resource
@return {Promise}
A promise to be resolved when the lock
is gained or rejected if the lock release
timeout is reached. | [
"Take",
"the",
"lock",
"on",
"the",
"given",
"resource",
"key"
] | 09df32597fe798777abec0ef1f3a994e91046085 | https://github.com/nfroidure/common-services/blob/09df32597fe798777abec0ef1f3a994e91046085/src/lock.js#L86-L115 |
51,191 | nfroidure/common-services | src/lock.js | release | async function release(key) {
const previousLocks = LOCKS_MAP.get(key) || [];
const locksLength = previousLocks.length;
log(
'debug',
`Releasing the lock on ${key} (queue length was ${locksLength})`,
);
previousLocks.pop().release();
} | javascript | async function release(key) {
const previousLocks = LOCKS_MAP.get(key) || [];
const locksLength = previousLocks.length;
log(
'debug',
`Releasing the lock on ${key} (queue length was ${locksLength})`,
);
previousLocks.pop().release();
} | [
"async",
"function",
"release",
"(",
"key",
")",
"{",
"const",
"previousLocks",
"=",
"LOCKS_MAP",
".",
"get",
"(",
"key",
")",
"||",
"[",
"]",
";",
"const",
"locksLength",
"=",
"previousLocks",
".",
"length",
";",
"log",
"(",
"'debug'",
",",
"`",
"${",
"key",
"}",
"${",
"locksLength",
"}",
"`",
",",
")",
";",
"previousLocks",
".",
"pop",
"(",
")",
".",
"release",
"(",
")",
";",
"}"
] | Release the lock on the given resource key
@param {String} key A unique key for the resource to release
@return {void} | [
"Release",
"the",
"lock",
"on",
"the",
"given",
"resource",
"key"
] | 09df32597fe798777abec0ef1f3a994e91046085 | https://github.com/nfroidure/common-services/blob/09df32597fe798777abec0ef1f3a994e91046085/src/lock.js#L122-L131 |
51,192 | nearform/docker-container | lib/registry.js | service | function service(root, cb) {
var registryPath = config.registryPath || path.join(root, 'registry');
fs.mkdir(registryPath, function(err) {
if (err && err.code !== 'EEXIST') {
logger.error(err);
return cb(err);
}
// swallow errors, it may exists
var server = registry({
dir: registryPath
});
server.on('error', function(err) {
logger.error(err);
});
server.listen(config.registryPort, function(err) {
logger.info({
port: config.registryPort,
path: registryPath
}, 'registry started');
if (typeof err === 'string') {
// err will contains the ip
// TODO remove me as https://github.com/mafintosh/root/issues/12 get fixes
err = null;
}
if (cb) {
cb(err, server);
}
});
});
} | javascript | function service(root, cb) {
var registryPath = config.registryPath || path.join(root, 'registry');
fs.mkdir(registryPath, function(err) {
if (err && err.code !== 'EEXIST') {
logger.error(err);
return cb(err);
}
// swallow errors, it may exists
var server = registry({
dir: registryPath
});
server.on('error', function(err) {
logger.error(err);
});
server.listen(config.registryPort, function(err) {
logger.info({
port: config.registryPort,
path: registryPath
}, 'registry started');
if (typeof err === 'string') {
// err will contains the ip
// TODO remove me as https://github.com/mafintosh/root/issues/12 get fixes
err = null;
}
if (cb) {
cb(err, server);
}
});
});
} | [
"function",
"service",
"(",
"root",
",",
"cb",
")",
"{",
"var",
"registryPath",
"=",
"config",
".",
"registryPath",
"||",
"path",
".",
"join",
"(",
"root",
",",
"'registry'",
")",
";",
"fs",
".",
"mkdir",
"(",
"registryPath",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
"&&",
"err",
".",
"code",
"!==",
"'EEXIST'",
")",
"{",
"logger",
".",
"error",
"(",
"err",
")",
";",
"return",
"cb",
"(",
"err",
")",
";",
"}",
"// swallow errors, it may exists",
"var",
"server",
"=",
"registry",
"(",
"{",
"dir",
":",
"registryPath",
"}",
")",
";",
"server",
".",
"on",
"(",
"'error'",
",",
"function",
"(",
"err",
")",
"{",
"logger",
".",
"error",
"(",
"err",
")",
";",
"}",
")",
";",
"server",
".",
"listen",
"(",
"config",
".",
"registryPort",
",",
"function",
"(",
"err",
")",
"{",
"logger",
".",
"info",
"(",
"{",
"port",
":",
"config",
".",
"registryPort",
",",
"path",
":",
"registryPath",
"}",
",",
"'registry started'",
")",
";",
"if",
"(",
"typeof",
"err",
"===",
"'string'",
")",
"{",
"// err will contains the ip",
"// TODO remove me as https://github.com/mafintosh/root/issues/12 get fixes",
"err",
"=",
"null",
";",
"}",
"if",
"(",
"cb",
")",
"{",
"cb",
"(",
"err",
",",
"server",
")",
";",
"}",
"}",
")",
";",
"}",
")",
";",
"}"
] | Starts the registry | [
"Starts",
"the",
"registry"
] | 724ff6a9d8d3c116f9a6b8239594c4b5cd5e8e17 | https://github.com/nearform/docker-container/blob/724ff6a9d8d3c116f9a6b8239594c4b5cd5e8e17/lib/registry.js#L95-L129 |
51,193 | happen-zhang/cakes | lib/cakes.js | Class | function Class(prop, superClass) {
var ClassType = function() {
function F(args) {
for (var name in ClassType.__prop) {
var val = ClassType.__prop[name];
this[name] = isObject(val) ? extend({}, val) : val;
}
if (isFunction(this.__construct)) {
this.__construct.apply(this, [].slice.call(args));
}
return this;
}
F.prototype = ClassType.prototype;
F.constructor = ClassType;
return new F(arguments);
};
ClassType.extend = function(prop) {
if (isFunction(prop)) {
prop = prop();
}
if (isObject(prop)) {
for (var name in prop) {
var val = prop[name];
if (name === 'parent') {
throw new Error("'parent' method must not be override wrote.");
}
if (isFunction(val)) {
ClassType.prototype[name] = val;
} else {
ClassType.__prop[name] = isObject(val) ? extend({}, val) : val;
}
}
}
return this;
};
ClassType.inherits = function(superClass) {
inherits(ClassType, superClass);
extend(ClassType.__prop, superClass.__prop);
return this;
};
ClassType.prototype.parent = function(methodName, args) {
var super_ = this.constructor.super_;
if (!isFunction(this[methodName]) || !isFunction(super_.prototype[methodName])) {
throw new Error("parent has not method '" + methodName + "'.");
}
if (arguments.length === 1) {
args = [];
} else if (!isArray(args)) {
args = [].slice.call(arguments, 1);
}
while ((this[methodName] === super_.prototype[methodName]) && super_.super_) {
super_ = super_.super_;
}
var method = super_.prototype[methodName];
delete super_.prototype[methodName];
var retResult = method.apply(this, args);
super_.prototype[methodName] = method;
return retResult;
};
ClassType.__prop = {};
if (superClass === true && isFunction(prop)) {
superClass = prop;
prop = undefined;
}
if (isFunction(superClass)) {
ClassType.inherits(superClass);
}
if (prop) {
ClassType.extend(prop);
}
return ClassType;
} | javascript | function Class(prop, superClass) {
var ClassType = function() {
function F(args) {
for (var name in ClassType.__prop) {
var val = ClassType.__prop[name];
this[name] = isObject(val) ? extend({}, val) : val;
}
if (isFunction(this.__construct)) {
this.__construct.apply(this, [].slice.call(args));
}
return this;
}
F.prototype = ClassType.prototype;
F.constructor = ClassType;
return new F(arguments);
};
ClassType.extend = function(prop) {
if (isFunction(prop)) {
prop = prop();
}
if (isObject(prop)) {
for (var name in prop) {
var val = prop[name];
if (name === 'parent') {
throw new Error("'parent' method must not be override wrote.");
}
if (isFunction(val)) {
ClassType.prototype[name] = val;
} else {
ClassType.__prop[name] = isObject(val) ? extend({}, val) : val;
}
}
}
return this;
};
ClassType.inherits = function(superClass) {
inherits(ClassType, superClass);
extend(ClassType.__prop, superClass.__prop);
return this;
};
ClassType.prototype.parent = function(methodName, args) {
var super_ = this.constructor.super_;
if (!isFunction(this[methodName]) || !isFunction(super_.prototype[methodName])) {
throw new Error("parent has not method '" + methodName + "'.");
}
if (arguments.length === 1) {
args = [];
} else if (!isArray(args)) {
args = [].slice.call(arguments, 1);
}
while ((this[methodName] === super_.prototype[methodName]) && super_.super_) {
super_ = super_.super_;
}
var method = super_.prototype[methodName];
delete super_.prototype[methodName];
var retResult = method.apply(this, args);
super_.prototype[methodName] = method;
return retResult;
};
ClassType.__prop = {};
if (superClass === true && isFunction(prop)) {
superClass = prop;
prop = undefined;
}
if (isFunction(superClass)) {
ClassType.inherits(superClass);
}
if (prop) {
ClassType.extend(prop);
}
return ClassType;
} | [
"function",
"Class",
"(",
"prop",
",",
"superClass",
")",
"{",
"var",
"ClassType",
"=",
"function",
"(",
")",
"{",
"function",
"F",
"(",
"args",
")",
"{",
"for",
"(",
"var",
"name",
"in",
"ClassType",
".",
"__prop",
")",
"{",
"var",
"val",
"=",
"ClassType",
".",
"__prop",
"[",
"name",
"]",
";",
"this",
"[",
"name",
"]",
"=",
"isObject",
"(",
"val",
")",
"?",
"extend",
"(",
"{",
"}",
",",
"val",
")",
":",
"val",
";",
"}",
"if",
"(",
"isFunction",
"(",
"this",
".",
"__construct",
")",
")",
"{",
"this",
".",
"__construct",
".",
"apply",
"(",
"this",
",",
"[",
"]",
".",
"slice",
".",
"call",
"(",
"args",
")",
")",
";",
"}",
"return",
"this",
";",
"}",
"F",
".",
"prototype",
"=",
"ClassType",
".",
"prototype",
";",
"F",
".",
"constructor",
"=",
"ClassType",
";",
"return",
"new",
"F",
"(",
"arguments",
")",
";",
"}",
";",
"ClassType",
".",
"extend",
"=",
"function",
"(",
"prop",
")",
"{",
"if",
"(",
"isFunction",
"(",
"prop",
")",
")",
"{",
"prop",
"=",
"prop",
"(",
")",
";",
"}",
"if",
"(",
"isObject",
"(",
"prop",
")",
")",
"{",
"for",
"(",
"var",
"name",
"in",
"prop",
")",
"{",
"var",
"val",
"=",
"prop",
"[",
"name",
"]",
";",
"if",
"(",
"name",
"===",
"'parent'",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"'parent' method must not be override wrote.\"",
")",
";",
"}",
"if",
"(",
"isFunction",
"(",
"val",
")",
")",
"{",
"ClassType",
".",
"prototype",
"[",
"name",
"]",
"=",
"val",
";",
"}",
"else",
"{",
"ClassType",
".",
"__prop",
"[",
"name",
"]",
"=",
"isObject",
"(",
"val",
")",
"?",
"extend",
"(",
"{",
"}",
",",
"val",
")",
":",
"val",
";",
"}",
"}",
"}",
"return",
"this",
";",
"}",
";",
"ClassType",
".",
"inherits",
"=",
"function",
"(",
"superClass",
")",
"{",
"inherits",
"(",
"ClassType",
",",
"superClass",
")",
";",
"extend",
"(",
"ClassType",
".",
"__prop",
",",
"superClass",
".",
"__prop",
")",
";",
"return",
"this",
";",
"}",
";",
"ClassType",
".",
"prototype",
".",
"parent",
"=",
"function",
"(",
"methodName",
",",
"args",
")",
"{",
"var",
"super_",
"=",
"this",
".",
"constructor",
".",
"super_",
";",
"if",
"(",
"!",
"isFunction",
"(",
"this",
"[",
"methodName",
"]",
")",
"||",
"!",
"isFunction",
"(",
"super_",
".",
"prototype",
"[",
"methodName",
"]",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"parent has not method '\"",
"+",
"methodName",
"+",
"\"'.\"",
")",
";",
"}",
"if",
"(",
"arguments",
".",
"length",
"===",
"1",
")",
"{",
"args",
"=",
"[",
"]",
";",
"}",
"else",
"if",
"(",
"!",
"isArray",
"(",
"args",
")",
")",
"{",
"args",
"=",
"[",
"]",
".",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
";",
"}",
"while",
"(",
"(",
"this",
"[",
"methodName",
"]",
"===",
"super_",
".",
"prototype",
"[",
"methodName",
"]",
")",
"&&",
"super_",
".",
"super_",
")",
"{",
"super_",
"=",
"super_",
".",
"super_",
";",
"}",
"var",
"method",
"=",
"super_",
".",
"prototype",
"[",
"methodName",
"]",
";",
"delete",
"super_",
".",
"prototype",
"[",
"methodName",
"]",
";",
"var",
"retResult",
"=",
"method",
".",
"apply",
"(",
"this",
",",
"args",
")",
";",
"super_",
".",
"prototype",
"[",
"methodName",
"]",
"=",
"method",
";",
"return",
"retResult",
";",
"}",
";",
"ClassType",
".",
"__prop",
"=",
"{",
"}",
";",
"if",
"(",
"superClass",
"===",
"true",
"&&",
"isFunction",
"(",
"prop",
")",
")",
"{",
"superClass",
"=",
"prop",
";",
"prop",
"=",
"undefined",
";",
"}",
"if",
"(",
"isFunction",
"(",
"superClass",
")",
")",
"{",
"ClassType",
".",
"inherits",
"(",
"superClass",
")",
";",
"}",
"if",
"(",
"prop",
")",
"{",
"ClassType",
".",
"extend",
"(",
"prop",
")",
";",
"}",
"return",
"ClassType",
";",
"}"
] | Create a class construct function.
@param {Function} prop Custom properties of class
@param {Function} superClass Super class
@return {Function} New class construct function | [
"Create",
"a",
"class",
"construct",
"function",
"."
] | a88a1d8d99b9ba6ec858d982c58c541d9483104f | https://github.com/happen-zhang/cakes/blob/a88a1d8d99b9ba6ec858d982c58c541d9483104f/lib/cakes.js#L38-L128 |
51,194 | sleeplessinc/jsond | index.js | accept | function accept(req, res, cb) {
var u = url.parse(req.url, true),
path = u.pathname
if(/^\/api\/?$/.test(path)) {
messageInit({cb:(cb || nop), req:req, res:res, path:path, query:u.query, u:u})
return;
}
if(req.method == "OPTIONS") {
res.writeHead(200, {
"Access-Control-Allow-Origin": "*", // to support cross-domain script execution of our api
"Access-Control-Max-Age": "0",
})
res.end()
return;
}
www(req, res) // everything else handled by paperboy
} | javascript | function accept(req, res, cb) {
var u = url.parse(req.url, true),
path = u.pathname
if(/^\/api\/?$/.test(path)) {
messageInit({cb:(cb || nop), req:req, res:res, path:path, query:u.query, u:u})
return;
}
if(req.method == "OPTIONS") {
res.writeHead(200, {
"Access-Control-Allow-Origin": "*", // to support cross-domain script execution of our api
"Access-Control-Max-Age": "0",
})
res.end()
return;
}
www(req, res) // everything else handled by paperboy
} | [
"function",
"accept",
"(",
"req",
",",
"res",
",",
"cb",
")",
"{",
"var",
"u",
"=",
"url",
".",
"parse",
"(",
"req",
".",
"url",
",",
"true",
")",
",",
"path",
"=",
"u",
".",
"pathname",
"if",
"(",
"/",
"^\\/api\\/?$",
"/",
".",
"test",
"(",
"path",
")",
")",
"{",
"messageInit",
"(",
"{",
"cb",
":",
"(",
"cb",
"||",
"nop",
")",
",",
"req",
":",
"req",
",",
"res",
":",
"res",
",",
"path",
":",
"path",
",",
"query",
":",
"u",
".",
"query",
",",
"u",
":",
"u",
"}",
")",
"return",
";",
"}",
"if",
"(",
"req",
".",
"method",
"==",
"\"OPTIONS\"",
")",
"{",
"res",
".",
"writeHead",
"(",
"200",
",",
"{",
"\"Access-Control-Allow-Origin\"",
":",
"\"*\"",
",",
"// to support cross-domain script execution of our api",
"\"Access-Control-Max-Age\"",
":",
"\"0\"",
",",
"}",
")",
"res",
".",
"end",
"(",
")",
"return",
";",
"}",
"www",
"(",
"req",
",",
"res",
")",
"// everything else handled by paperboy",
"}"
] | Every request starts here | [
"Every",
"request",
"starts",
"here"
] | 0f65a925d604edd5be74dc75aba19a3c1448307b | https://github.com/sleeplessinc/jsond/blob/0f65a925d604edd5be74dc75aba19a3c1448307b/index.js#L143-L162 |
51,195 | xiamidaxia/xiami | meteor/binary-heap/max-heap.js | function (data) {
var self = this;
self._heap = _.map(data, function (o) {
return { id: o.id, value: o.value };
});
_.each(data, function (o, i) {
self._heapIdx.set(o.id, i);
});
if (! data.length)
return;
// start from the first non-leaf - the parent of the last leaf
for (var i = parentIdx(data.length - 1); i >= 0; i--)
self._downHeap(i);
} | javascript | function (data) {
var self = this;
self._heap = _.map(data, function (o) {
return { id: o.id, value: o.value };
});
_.each(data, function (o, i) {
self._heapIdx.set(o.id, i);
});
if (! data.length)
return;
// start from the first non-leaf - the parent of the last leaf
for (var i = parentIdx(data.length - 1); i >= 0; i--)
self._downHeap(i);
} | [
"function",
"(",
"data",
")",
"{",
"var",
"self",
"=",
"this",
";",
"self",
".",
"_heap",
"=",
"_",
".",
"map",
"(",
"data",
",",
"function",
"(",
"o",
")",
"{",
"return",
"{",
"id",
":",
"o",
".",
"id",
",",
"value",
":",
"o",
".",
"value",
"}",
";",
"}",
")",
";",
"_",
".",
"each",
"(",
"data",
",",
"function",
"(",
"o",
",",
"i",
")",
"{",
"self",
".",
"_heapIdx",
".",
"set",
"(",
"o",
".",
"id",
",",
"i",
")",
";",
"}",
")",
";",
"if",
"(",
"!",
"data",
".",
"length",
")",
"return",
";",
"// start from the first non-leaf - the parent of the last leaf",
"for",
"(",
"var",
"i",
"=",
"parentIdx",
"(",
"data",
".",
"length",
"-",
"1",
")",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"self",
".",
"_downHeap",
"(",
"i",
")",
";",
"}"
] | Builds a new heap in-place in linear time based on passed data | [
"Builds",
"a",
"new",
"heap",
"in",
"-",
"place",
"in",
"linear",
"time",
"based",
"on",
"passed",
"data"
] | 6fcee92c493c12bf8fd67c7068e67fa6a72a306b | https://github.com/xiamidaxia/xiami/blob/6fcee92c493c12bf8fd67c7068e67fa6a72a306b/meteor/binary-heap/max-heap.js#L44-L61 |
|
51,196 | xiamidaxia/xiami | meteor/binary-heap/max-heap.js | function (iterator) {
var self = this;
_.each(self._heap, function (obj) {
return iterator(obj.value, obj.id);
});
} | javascript | function (iterator) {
var self = this;
_.each(self._heap, function (obj) {
return iterator(obj.value, obj.id);
});
} | [
"function",
"(",
"iterator",
")",
"{",
"var",
"self",
"=",
"this",
";",
"_",
".",
"each",
"(",
"self",
".",
"_heap",
",",
"function",
"(",
"obj",
")",
"{",
"return",
"iterator",
"(",
"obj",
".",
"value",
",",
"obj",
".",
"id",
")",
";",
"}",
")",
";",
"}"
] | iterate over values in no particular order | [
"iterate",
"over",
"values",
"in",
"no",
"particular",
"order"
] | 6fcee92c493c12bf8fd67c7068e67fa6a72a306b | https://github.com/xiamidaxia/xiami/blob/6fcee92c493c12bf8fd67c7068e67fa6a72a306b/meteor/binary-heap/max-heap.js#L187-L192 |
|
51,197 | feedhenry/fh-mbaas-middleware | lib/alerts/alerts.js | matchAndIssueAlertEmails | function matchAndIssueAlertEmails(eventDetails, alerts){
underscore.each(alerts, function(alert) {
if (shouldTriggerAlert(eventDetails, alert)){
issueAlertEmail(eventDetails, alert);
}
});
} | javascript | function matchAndIssueAlertEmails(eventDetails, alerts){
underscore.each(alerts, function(alert) {
if (shouldTriggerAlert(eventDetails, alert)){
issueAlertEmail(eventDetails, alert);
}
});
} | [
"function",
"matchAndIssueAlertEmails",
"(",
"eventDetails",
",",
"alerts",
")",
"{",
"underscore",
".",
"each",
"(",
"alerts",
",",
"function",
"(",
"alert",
")",
"{",
"if",
"(",
"shouldTriggerAlert",
"(",
"eventDetails",
",",
"alert",
")",
")",
"{",
"issueAlertEmail",
"(",
"eventDetails",
",",
"alert",
")",
";",
"}",
"}",
")",
";",
"}"
] | Iterate user defined alerts to incoming event message and send emails when appropriate
@param alerts | [
"Iterate",
"user",
"defined",
"alerts",
"to",
"incoming",
"event",
"message",
"and",
"send",
"emails",
"when",
"appropriate"
] | f906e98efbb4b0963bf5137b34b5e0589ba24e69 | https://github.com/feedhenry/fh-mbaas-middleware/blob/f906e98efbb4b0963bf5137b34b5e0589ba24e69/lib/alerts/alerts.js#L13-L19 |
51,198 | feedhenry/fh-mbaas-middleware | lib/alerts/alerts.js | shouldTriggerAlert | function shouldTriggerAlert(eventDetails, alert){
if (alert.alertEnabled){
// Event Message Criteria
var msgEventName = eventDetails.eventType;
var msgEventCategory = eventDetails.eventClass;
var msgEventSeverity = eventDetails.eventLevel;
// Saved Alert Criteria
var alertEventNames = alert.eventNames;
var alertEventCategories = alert.eventCategories;
var alertEventSeverities = alert.eventSeverities;
// Test results
var matchOnAlertEventName = alertEventNames.indexOf(msgEventName) > -1;
var matchOnAlertEventCategory = alertEventCategories.indexOf(msgEventCategory) > -1;
var matchOnAlertSeverity = alertEventSeverities.indexOf(msgEventSeverity) > -1;
// if we match on the above, grab the emails from the Alert and send email (where is template???) and save Notification to Mongo (what is the record format????)
if (matchOnAlertEventName && matchOnAlertEventCategory && matchOnAlertSeverity) {
logger.logger.trace(loggerPrefix +'Match found. Sending emails to: ', alert.emails);
return true;
} else {
logger.logger.trace(loggerPrefix +'No Match found. No emails to send');
return false;
}
} else {
return false;
}
} | javascript | function shouldTriggerAlert(eventDetails, alert){
if (alert.alertEnabled){
// Event Message Criteria
var msgEventName = eventDetails.eventType;
var msgEventCategory = eventDetails.eventClass;
var msgEventSeverity = eventDetails.eventLevel;
// Saved Alert Criteria
var alertEventNames = alert.eventNames;
var alertEventCategories = alert.eventCategories;
var alertEventSeverities = alert.eventSeverities;
// Test results
var matchOnAlertEventName = alertEventNames.indexOf(msgEventName) > -1;
var matchOnAlertEventCategory = alertEventCategories.indexOf(msgEventCategory) > -1;
var matchOnAlertSeverity = alertEventSeverities.indexOf(msgEventSeverity) > -1;
// if we match on the above, grab the emails from the Alert and send email (where is template???) and save Notification to Mongo (what is the record format????)
if (matchOnAlertEventName && matchOnAlertEventCategory && matchOnAlertSeverity) {
logger.logger.trace(loggerPrefix +'Match found. Sending emails to: ', alert.emails);
return true;
} else {
logger.logger.trace(loggerPrefix +'No Match found. No emails to send');
return false;
}
} else {
return false;
}
} | [
"function",
"shouldTriggerAlert",
"(",
"eventDetails",
",",
"alert",
")",
"{",
"if",
"(",
"alert",
".",
"alertEnabled",
")",
"{",
"// Event Message Criteria",
"var",
"msgEventName",
"=",
"eventDetails",
".",
"eventType",
";",
"var",
"msgEventCategory",
"=",
"eventDetails",
".",
"eventClass",
";",
"var",
"msgEventSeverity",
"=",
"eventDetails",
".",
"eventLevel",
";",
"// Saved Alert Criteria",
"var",
"alertEventNames",
"=",
"alert",
".",
"eventNames",
";",
"var",
"alertEventCategories",
"=",
"alert",
".",
"eventCategories",
";",
"var",
"alertEventSeverities",
"=",
"alert",
".",
"eventSeverities",
";",
"// Test results",
"var",
"matchOnAlertEventName",
"=",
"alertEventNames",
".",
"indexOf",
"(",
"msgEventName",
")",
">",
"-",
"1",
";",
"var",
"matchOnAlertEventCategory",
"=",
"alertEventCategories",
".",
"indexOf",
"(",
"msgEventCategory",
")",
">",
"-",
"1",
";",
"var",
"matchOnAlertSeverity",
"=",
"alertEventSeverities",
".",
"indexOf",
"(",
"msgEventSeverity",
")",
">",
"-",
"1",
";",
"// if we match on the above, grab the emails from the Alert and send email (where is template???) and save Notification to Mongo (what is the record format????)",
"if",
"(",
"matchOnAlertEventName",
"&&",
"matchOnAlertEventCategory",
"&&",
"matchOnAlertSeverity",
")",
"{",
"logger",
".",
"logger",
".",
"trace",
"(",
"loggerPrefix",
"+",
"'Match found. Sending emails to: '",
",",
"alert",
".",
"emails",
")",
";",
"return",
"true",
";",
"}",
"else",
"{",
"logger",
".",
"logger",
".",
"trace",
"(",
"loggerPrefix",
"+",
"'No Match found. No emails to send'",
")",
";",
"return",
"false",
";",
"}",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] | Test the Alert and see if we should send an email or not
@param alert | [
"Test",
"the",
"Alert",
"and",
"see",
"if",
"we",
"should",
"send",
"an",
"email",
"or",
"not"
] | f906e98efbb4b0963bf5137b34b5e0589ba24e69 | https://github.com/feedhenry/fh-mbaas-middleware/blob/f906e98efbb4b0963bf5137b34b5e0589ba24e69/lib/alerts/alerts.js#L25-L55 |
51,199 | feedhenry/fh-mbaas-middleware | lib/alerts/alerts.js | handler | function handler (eventDetails){
var Alert = models.getModels().Alert;
logger.logger.trace(loggerPrefix +'Processing Alerts for Event: ', eventDetails);
Alert.queryAlerts(eventDetails.uid, eventDetails.env, eventDetails.domain, function(err, alerts){
if(err) {
logger.logger.warn({ error:err }, loggerPrefix +'Failed to query Alerts for uid and env', uid, env);
} else {
if(alerts && alerts.length > 0){
logger.logger.trace(loggerPrefix +'Found ['+ alerts.length +'] Alerts. Matching and send emails', alerts);
matchAndIssueAlertEmails(eventDetails, alerts);
} else {
logger.logger.trace(loggerPrefix +'No Alerts for event. No emails to send.');
}
}
});
} | javascript | function handler (eventDetails){
var Alert = models.getModels().Alert;
logger.logger.trace(loggerPrefix +'Processing Alerts for Event: ', eventDetails);
Alert.queryAlerts(eventDetails.uid, eventDetails.env, eventDetails.domain, function(err, alerts){
if(err) {
logger.logger.warn({ error:err }, loggerPrefix +'Failed to query Alerts for uid and env', uid, env);
} else {
if(alerts && alerts.length > 0){
logger.logger.trace(loggerPrefix +'Found ['+ alerts.length +'] Alerts. Matching and send emails', alerts);
matchAndIssueAlertEmails(eventDetails, alerts);
} else {
logger.logger.trace(loggerPrefix +'No Alerts for event. No emails to send.');
}
}
});
} | [
"function",
"handler",
"(",
"eventDetails",
")",
"{",
"var",
"Alert",
"=",
"models",
".",
"getModels",
"(",
")",
".",
"Alert",
";",
"logger",
".",
"logger",
".",
"trace",
"(",
"loggerPrefix",
"+",
"'Processing Alerts for Event: '",
",",
"eventDetails",
")",
";",
"Alert",
".",
"queryAlerts",
"(",
"eventDetails",
".",
"uid",
",",
"eventDetails",
".",
"env",
",",
"eventDetails",
".",
"domain",
",",
"function",
"(",
"err",
",",
"alerts",
")",
"{",
"if",
"(",
"err",
")",
"{",
"logger",
".",
"logger",
".",
"warn",
"(",
"{",
"error",
":",
"err",
"}",
",",
"loggerPrefix",
"+",
"'Failed to query Alerts for uid and env'",
",",
"uid",
",",
"env",
")",
";",
"}",
"else",
"{",
"if",
"(",
"alerts",
"&&",
"alerts",
".",
"length",
">",
"0",
")",
"{",
"logger",
".",
"logger",
".",
"trace",
"(",
"loggerPrefix",
"+",
"'Found ['",
"+",
"alerts",
".",
"length",
"+",
"'] Alerts. Matching and send emails'",
",",
"alerts",
")",
";",
"matchAndIssueAlertEmails",
"(",
"eventDetails",
",",
"alerts",
")",
";",
"}",
"else",
"{",
"logger",
".",
"logger",
".",
"trace",
"(",
"loggerPrefix",
"+",
"'No Alerts for event. No emails to send.'",
")",
";",
"}",
"}",
"}",
")",
";",
"}"
] | Handle an EVENT. We will take the EVENT details,
match the Alerts in Mongo that have been setup and
if a match is found, then send the email from the MBaaS
@param msg
@param headers
@param info
@param cb | [
"Handle",
"an",
"EVENT",
".",
"We",
"will",
"take",
"the",
"EVENT",
"details",
"match",
"the",
"Alerts",
"in",
"Mongo",
"that",
"have",
"been",
"setup",
"and",
"if",
"a",
"match",
"is",
"found",
"then",
"send",
"the",
"email",
"from",
"the",
"MBaaS"
] | f906e98efbb4b0963bf5137b34b5e0589ba24e69 | https://github.com/feedhenry/fh-mbaas-middleware/blob/f906e98efbb4b0963bf5137b34b5e0589ba24e69/lib/alerts/alerts.js#L103-L119 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.