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
56,500
adiwidjaja/frontend-pagebuilder
js/tinymce/tinymce.jquery.js
function (node, args) { var self = this, impl, doc, oldDoc, htmlSerializer, content, rootNode; // Explorer won't clone contents of script and style and the // selected index of select elements are cleared on a clone operation. if (Env.ie && dom.select('script,style,select,map').length > 0) { content = node.innerHTML; node = node.cloneNode(false); dom.setHTML(node, content); } else { node = node.cloneNode(true); } // Nodes needs to be attached to something in WebKit/Opera // This fix will make DOM ranges and make Sizzle happy! impl = document.implementation; if (impl.createHTMLDocument) { // Create an empty HTML document doc = impl.createHTMLDocument(""); // Add the element or it's children if it's a body element to the new document each(node.nodeName == 'BODY' ? node.childNodes : [node], function (node) { doc.body.appendChild(doc.importNode(node, true)); }); // Grab first child or body element for serialization if (node.nodeName != 'BODY') { node = doc.body.firstChild; } else { node = doc.body; } // set the new document in DOMUtils so createElement etc works oldDoc = dom.doc; dom.doc = doc; } args = args || {}; args.format = args.format || 'html'; // Don't wrap content if we want selected html if (args.selection) { args.forced_root_block = ''; } // Pre process if (!args.no_events) { args.node = node; self.onPreProcess(args); } // Parse HTML content = Zwsp.trim(trim(args.getInner ? node.innerHTML : dom.getOuterHTML(node))); rootNode = htmlParser.parse(content, args); trimTrailingBr(rootNode); // Serialize HTML htmlSerializer = new Serializer(settings, schema); args.content = htmlSerializer.serialize(rootNode); // Post process if (!args.no_events) { self.onPostProcess(args); } // Restore the old document if it was changed if (oldDoc) { dom.doc = oldDoc; } args.node = null; return args.content; }
javascript
function (node, args) { var self = this, impl, doc, oldDoc, htmlSerializer, content, rootNode; // Explorer won't clone contents of script and style and the // selected index of select elements are cleared on a clone operation. if (Env.ie && dom.select('script,style,select,map').length > 0) { content = node.innerHTML; node = node.cloneNode(false); dom.setHTML(node, content); } else { node = node.cloneNode(true); } // Nodes needs to be attached to something in WebKit/Opera // This fix will make DOM ranges and make Sizzle happy! impl = document.implementation; if (impl.createHTMLDocument) { // Create an empty HTML document doc = impl.createHTMLDocument(""); // Add the element or it's children if it's a body element to the new document each(node.nodeName == 'BODY' ? node.childNodes : [node], function (node) { doc.body.appendChild(doc.importNode(node, true)); }); // Grab first child or body element for serialization if (node.nodeName != 'BODY') { node = doc.body.firstChild; } else { node = doc.body; } // set the new document in DOMUtils so createElement etc works oldDoc = dom.doc; dom.doc = doc; } args = args || {}; args.format = args.format || 'html'; // Don't wrap content if we want selected html if (args.selection) { args.forced_root_block = ''; } // Pre process if (!args.no_events) { args.node = node; self.onPreProcess(args); } // Parse HTML content = Zwsp.trim(trim(args.getInner ? node.innerHTML : dom.getOuterHTML(node))); rootNode = htmlParser.parse(content, args); trimTrailingBr(rootNode); // Serialize HTML htmlSerializer = new Serializer(settings, schema); args.content = htmlSerializer.serialize(rootNode); // Post process if (!args.no_events) { self.onPostProcess(args); } // Restore the old document if it was changed if (oldDoc) { dom.doc = oldDoc; } args.node = null; return args.content; }
[ "function", "(", "node", ",", "args", ")", "{", "var", "self", "=", "this", ",", "impl", ",", "doc", ",", "oldDoc", ",", "htmlSerializer", ",", "content", ",", "rootNode", ";", "// Explorer won't clone contents of script and style and the", "// selected index of select elements are cleared on a clone operation.", "if", "(", "Env", ".", "ie", "&&", "dom", ".", "select", "(", "'script,style,select,map'", ")", ".", "length", ">", "0", ")", "{", "content", "=", "node", ".", "innerHTML", ";", "node", "=", "node", ".", "cloneNode", "(", "false", ")", ";", "dom", ".", "setHTML", "(", "node", ",", "content", ")", ";", "}", "else", "{", "node", "=", "node", ".", "cloneNode", "(", "true", ")", ";", "}", "// Nodes needs to be attached to something in WebKit/Opera", "// This fix will make DOM ranges and make Sizzle happy!", "impl", "=", "document", ".", "implementation", ";", "if", "(", "impl", ".", "createHTMLDocument", ")", "{", "// Create an empty HTML document", "doc", "=", "impl", ".", "createHTMLDocument", "(", "\"\"", ")", ";", "// Add the element or it's children if it's a body element to the new document", "each", "(", "node", ".", "nodeName", "==", "'BODY'", "?", "node", ".", "childNodes", ":", "[", "node", "]", ",", "function", "(", "node", ")", "{", "doc", ".", "body", ".", "appendChild", "(", "doc", ".", "importNode", "(", "node", ",", "true", ")", ")", ";", "}", ")", ";", "// Grab first child or body element for serialization", "if", "(", "node", ".", "nodeName", "!=", "'BODY'", ")", "{", "node", "=", "doc", ".", "body", ".", "firstChild", ";", "}", "else", "{", "node", "=", "doc", ".", "body", ";", "}", "// set the new document in DOMUtils so createElement etc works", "oldDoc", "=", "dom", ".", "doc", ";", "dom", ".", "doc", "=", "doc", ";", "}", "args", "=", "args", "||", "{", "}", ";", "args", ".", "format", "=", "args", ".", "format", "||", "'html'", ";", "// Don't wrap content if we want selected html", "if", "(", "args", ".", "selection", ")", "{", "args", ".", "forced_root_block", "=", "''", ";", "}", "// Pre process", "if", "(", "!", "args", ".", "no_events", ")", "{", "args", ".", "node", "=", "node", ";", "self", ".", "onPreProcess", "(", "args", ")", ";", "}", "// Parse HTML", "content", "=", "Zwsp", ".", "trim", "(", "trim", "(", "args", ".", "getInner", "?", "node", ".", "innerHTML", ":", "dom", ".", "getOuterHTML", "(", "node", ")", ")", ")", ";", "rootNode", "=", "htmlParser", ".", "parse", "(", "content", ",", "args", ")", ";", "trimTrailingBr", "(", "rootNode", ")", ";", "// Serialize HTML", "htmlSerializer", "=", "new", "Serializer", "(", "settings", ",", "schema", ")", ";", "args", ".", "content", "=", "htmlSerializer", ".", "serialize", "(", "rootNode", ")", ";", "// Post process", "if", "(", "!", "args", ".", "no_events", ")", "{", "self", ".", "onPostProcess", "(", "args", ")", ";", "}", "// Restore the old document if it was changed", "if", "(", "oldDoc", ")", "{", "dom", ".", "doc", "=", "oldDoc", ";", "}", "args", ".", "node", "=", "null", ";", "return", "args", ".", "content", ";", "}" ]
Serializes the specified browser DOM node into a HTML string. @method serialize @param {DOMNode} node DOM node to serialize. @param {Object} args Arguments option that gets passed to event handlers.
[ "Serializes", "the", "specified", "browser", "DOM", "node", "into", "a", "HTML", "string", "." ]
a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f
https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/tinymce.jquery.js#L23456-L23529
56,501
adiwidjaja/frontend-pagebuilder
js/tinymce/tinymce.jquery.js
function (original, tag) { var nu = Element.fromTag(tag); var attributes = Attr.clone(original); Attr.setAll(nu, attributes); return nu; }
javascript
function (original, tag) { var nu = Element.fromTag(tag); var attributes = Attr.clone(original); Attr.setAll(nu, attributes); return nu; }
[ "function", "(", "original", ",", "tag", ")", "{", "var", "nu", "=", "Element", ".", "fromTag", "(", "tag", ")", ";", "var", "attributes", "=", "Attr", ".", "clone", "(", "original", ")", ";", "Attr", ".", "setAll", "(", "nu", ",", "attributes", ")", ";", "return", "nu", ";", "}" ]
Shallow clone, with a new tag
[ "Shallow", "clone", "with", "a", "new", "tag" ]
a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f
https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/tinymce.jquery.js#L25059-L25066
56,502
adiwidjaja/frontend-pagebuilder
js/tinymce/tinymce.jquery.js
function (original, tag) { var nu = shallowAs(original, tag); // NOTE // previously this used serialisation: // nu.dom().innerHTML = original.dom().innerHTML; // // Clone should be equivalent (and faster), but if TD <-> TH toggle breaks, put it back. var cloneChildren = Traverse.children(deep(original)); InsertAll.append(nu, cloneChildren); return nu; }
javascript
function (original, tag) { var nu = shallowAs(original, tag); // NOTE // previously this used serialisation: // nu.dom().innerHTML = original.dom().innerHTML; // // Clone should be equivalent (and faster), but if TD <-> TH toggle breaks, put it back. var cloneChildren = Traverse.children(deep(original)); InsertAll.append(nu, cloneChildren); return nu; }
[ "function", "(", "original", ",", "tag", ")", "{", "var", "nu", "=", "shallowAs", "(", "original", ",", "tag", ")", ";", "// NOTE", "// previously this used serialisation:", "// nu.dom().innerHTML = original.dom().innerHTML;", "//", "// Clone should be equivalent (and faster), but if TD <-> TH toggle breaks, put it back.", "var", "cloneChildren", "=", "Traverse", ".", "children", "(", "deep", "(", "original", ")", ")", ";", "InsertAll", ".", "append", "(", "nu", ",", "cloneChildren", ")", ";", "return", "nu", ";", "}" ]
Deep clone, with a new tag
[ "Deep", "clone", "with", "a", "new", "tag" ]
a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f
https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/tinymce.jquery.js#L25069-L25082
56,503
adiwidjaja/frontend-pagebuilder
js/tinymce/tinymce.jquery.js
function (original, tag) { var nu = shallowAs(original, tag); Insert.before(original, nu); var children = Traverse.children(original); InsertAll.append(nu, children); Remove.remove(original); return nu; }
javascript
function (original, tag) { var nu = shallowAs(original, tag); Insert.before(original, nu); var children = Traverse.children(original); InsertAll.append(nu, children); Remove.remove(original); return nu; }
[ "function", "(", "original", ",", "tag", ")", "{", "var", "nu", "=", "shallowAs", "(", "original", ",", "tag", ")", ";", "Insert", ".", "before", "(", "original", ",", "nu", ")", ";", "var", "children", "=", "Traverse", ".", "children", "(", "original", ")", ";", "InsertAll", ".", "append", "(", "nu", ",", "children", ")", ";", "Remove", ".", "remove", "(", "original", ")", ";", "return", "nu", ";", "}" ]
Change the tag name, but keep all children
[ "Change", "the", "tag", "name", "but", "keep", "all", "children" ]
a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f
https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/tinymce.jquery.js#L25085-L25093
56,504
adiwidjaja/frontend-pagebuilder
js/tinymce/tinymce.jquery.js
function(arr, f) { var r = []; for (var i = 0; i < arr.length; i++) { var x = arr[i]; if (x.isSome()) { r.push(x.getOrDie()); } else { return Option.none(); } } return Option.some(f.apply(null, r)); }
javascript
function(arr, f) { var r = []; for (var i = 0; i < arr.length; i++) { var x = arr[i]; if (x.isSome()) { r.push(x.getOrDie()); } else { return Option.none(); } } return Option.some(f.apply(null, r)); }
[ "function", "(", "arr", ",", "f", ")", "{", "var", "r", "=", "[", "]", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "arr", ".", "length", ";", "i", "++", ")", "{", "var", "x", "=", "arr", "[", "i", "]", ";", "if", "(", "x", ".", "isSome", "(", ")", ")", "{", "r", ".", "push", "(", "x", ".", "getOrDie", "(", ")", ")", ";", "}", "else", "{", "return", "Option", ".", "none", "(", ")", ";", "}", "}", "return", "Option", ".", "some", "(", "f", ".", "apply", "(", "null", ",", "r", ")", ")", ";", "}" ]
if all elements in arr are 'some', their inner values are passed as arguments to f f must have arity arr.length
[ "if", "all", "elements", "in", "arr", "are", "some", "their", "inner", "values", "are", "passed", "as", "arguments", "to", "f", "f", "must", "have", "arity", "arr", ".", "length" ]
a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f
https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/tinymce.jquery.js#L25213-L25224
56,505
adiwidjaja/frontend-pagebuilder
js/tinymce/tinymce.jquery.js
function (args) { var self = this, rng = self.getRng(), tmpElm = self.dom.create("body"); var se = self.getSel(), whiteSpaceBefore, whiteSpaceAfter, fragment; args = args || {}; whiteSpaceBefore = whiteSpaceAfter = ''; args.get = true; args.format = args.format || 'html'; args.selection = true; self.editor.fire('BeforeGetContent', args); if (args.format === 'text') { return self.isCollapsed() ? '' : Zwsp.trim(rng.text || (se.toString ? se.toString() : '')); } if (rng.cloneContents) { fragment = args.contextual ? FragmentReader.read(self.editor.getBody(), rng).dom() : rng.cloneContents(); if (fragment) { tmpElm.appendChild(fragment); } } else if (rng.item !== undefined || rng.htmlText !== undefined) { // IE will produce invalid markup if elements are present that // it doesn't understand like custom elements or HTML5 elements. // Adding a BR in front of the contents and then remoiving it seems to fix it though. tmpElm.innerHTML = '<br>' + (rng.item ? rng.item(0).outerHTML : rng.htmlText); tmpElm.removeChild(tmpElm.firstChild); } else { tmpElm.innerHTML = rng.toString(); } // Keep whitespace before and after if (/^\s/.test(tmpElm.innerHTML)) { whiteSpaceBefore = ' '; } if (/\s+$/.test(tmpElm.innerHTML)) { whiteSpaceAfter = ' '; } args.getInner = true; args.content = self.isCollapsed() ? '' : whiteSpaceBefore + self.serializer.serialize(tmpElm, args) + whiteSpaceAfter; self.editor.fire('GetContent', args); return args.content; }
javascript
function (args) { var self = this, rng = self.getRng(), tmpElm = self.dom.create("body"); var se = self.getSel(), whiteSpaceBefore, whiteSpaceAfter, fragment; args = args || {}; whiteSpaceBefore = whiteSpaceAfter = ''; args.get = true; args.format = args.format || 'html'; args.selection = true; self.editor.fire('BeforeGetContent', args); if (args.format === 'text') { return self.isCollapsed() ? '' : Zwsp.trim(rng.text || (se.toString ? se.toString() : '')); } if (rng.cloneContents) { fragment = args.contextual ? FragmentReader.read(self.editor.getBody(), rng).dom() : rng.cloneContents(); if (fragment) { tmpElm.appendChild(fragment); } } else if (rng.item !== undefined || rng.htmlText !== undefined) { // IE will produce invalid markup if elements are present that // it doesn't understand like custom elements or HTML5 elements. // Adding a BR in front of the contents and then remoiving it seems to fix it though. tmpElm.innerHTML = '<br>' + (rng.item ? rng.item(0).outerHTML : rng.htmlText); tmpElm.removeChild(tmpElm.firstChild); } else { tmpElm.innerHTML = rng.toString(); } // Keep whitespace before and after if (/^\s/.test(tmpElm.innerHTML)) { whiteSpaceBefore = ' '; } if (/\s+$/.test(tmpElm.innerHTML)) { whiteSpaceAfter = ' '; } args.getInner = true; args.content = self.isCollapsed() ? '' : whiteSpaceBefore + self.serializer.serialize(tmpElm, args) + whiteSpaceAfter; self.editor.fire('GetContent', args); return args.content; }
[ "function", "(", "args", ")", "{", "var", "self", "=", "this", ",", "rng", "=", "self", ".", "getRng", "(", ")", ",", "tmpElm", "=", "self", ".", "dom", ".", "create", "(", "\"body\"", ")", ";", "var", "se", "=", "self", ".", "getSel", "(", ")", ",", "whiteSpaceBefore", ",", "whiteSpaceAfter", ",", "fragment", ";", "args", "=", "args", "||", "{", "}", ";", "whiteSpaceBefore", "=", "whiteSpaceAfter", "=", "''", ";", "args", ".", "get", "=", "true", ";", "args", ".", "format", "=", "args", ".", "format", "||", "'html'", ";", "args", ".", "selection", "=", "true", ";", "self", ".", "editor", ".", "fire", "(", "'BeforeGetContent'", ",", "args", ")", ";", "if", "(", "args", ".", "format", "===", "'text'", ")", "{", "return", "self", ".", "isCollapsed", "(", ")", "?", "''", ":", "Zwsp", ".", "trim", "(", "rng", ".", "text", "||", "(", "se", ".", "toString", "?", "se", ".", "toString", "(", ")", ":", "''", ")", ")", ";", "}", "if", "(", "rng", ".", "cloneContents", ")", "{", "fragment", "=", "args", ".", "contextual", "?", "FragmentReader", ".", "read", "(", "self", ".", "editor", ".", "getBody", "(", ")", ",", "rng", ")", ".", "dom", "(", ")", ":", "rng", ".", "cloneContents", "(", ")", ";", "if", "(", "fragment", ")", "{", "tmpElm", ".", "appendChild", "(", "fragment", ")", ";", "}", "}", "else", "if", "(", "rng", ".", "item", "!==", "undefined", "||", "rng", ".", "htmlText", "!==", "undefined", ")", "{", "// IE will produce invalid markup if elements are present that", "// it doesn't understand like custom elements or HTML5 elements.", "// Adding a BR in front of the contents and then remoiving it seems to fix it though.", "tmpElm", ".", "innerHTML", "=", "'<br>'", "+", "(", "rng", ".", "item", "?", "rng", ".", "item", "(", "0", ")", ".", "outerHTML", ":", "rng", ".", "htmlText", ")", ";", "tmpElm", ".", "removeChild", "(", "tmpElm", ".", "firstChild", ")", ";", "}", "else", "{", "tmpElm", ".", "innerHTML", "=", "rng", ".", "toString", "(", ")", ";", "}", "// Keep whitespace before and after", "if", "(", "/", "^\\s", "/", ".", "test", "(", "tmpElm", ".", "innerHTML", ")", ")", "{", "whiteSpaceBefore", "=", "' '", ";", "}", "if", "(", "/", "\\s+$", "/", ".", "test", "(", "tmpElm", ".", "innerHTML", ")", ")", "{", "whiteSpaceAfter", "=", "' '", ";", "}", "args", ".", "getInner", "=", "true", ";", "args", ".", "content", "=", "self", ".", "isCollapsed", "(", ")", "?", "''", ":", "whiteSpaceBefore", "+", "self", ".", "serializer", ".", "serialize", "(", "tmpElm", ",", "args", ")", "+", "whiteSpaceAfter", ";", "self", ".", "editor", ".", "fire", "(", "'GetContent'", ",", "args", ")", ";", "return", "args", ".", "content", ";", "}" ]
Returns the selected contents using the DOM serializer passed in to this class. @method getContent @param {Object} args Optional settings class with for example output format text or html. @return {String} Selected contents in for example HTML format. @example // Alerts the currently selected contents alert(tinymce.activeEditor.selection.getContent()); // Alerts the currently selected contents as plain text alert(tinymce.activeEditor.selection.getContent({format: 'text'}));
[ "Returns", "the", "selected", "contents", "using", "the", "DOM", "serializer", "passed", "in", "to", "this", "class", "." ]
a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f
https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/tinymce.jquery.js#L25512-L25557
56,506
adiwidjaja/frontend-pagebuilder
js/tinymce/tinymce.jquery.js
function (rng, forward) { var self = this, sel, node, evt; if (!isValidRange(rng)) { return; } // Is IE specific range if (rng.select) { self.explicitRange = null; try { rng.select(); } catch (ex) { // Needed for some odd IE bug #1843306 } return; } if (!self.tridentSel) { sel = self.getSel(); evt = self.editor.fire('SetSelectionRange', { range: rng, forward: forward }); rng = evt.range; if (sel) { self.explicitRange = rng; try { sel.removeAllRanges(); sel.addRange(rng); } catch (ex) { // IE might throw errors here if the editor is within a hidden container and selection is changed } // Forward is set to false and we have an extend function if (forward === false && sel.extend) { sel.collapse(rng.endContainer, rng.endOffset); sel.extend(rng.startContainer, rng.startOffset); } // adding range isn't always successful so we need to check range count otherwise an exception can occur self.selectedRange = sel.rangeCount > 0 ? sel.getRangeAt(0) : null; } // WebKit egde case selecting images works better using setBaseAndExtent when the image is floated if (!rng.collapsed && rng.startContainer === rng.endContainer && sel.setBaseAndExtent && !Env.ie) { if (rng.endOffset - rng.startOffset < 2) { if (rng.startContainer.hasChildNodes()) { node = rng.startContainer.childNodes[rng.startOffset]; if (node && node.tagName === 'IMG') { sel.setBaseAndExtent( rng.startContainer, rng.startOffset, rng.endContainer, rng.endOffset ); // Since the setBaseAndExtent is fixed in more recent Blink versions we // need to detect if it's doing the wrong thing and falling back to the // crazy incorrect behavior api call since that seems to be the only way // to get it to work on Safari WebKit as of 2017-02-23 if (sel.anchorNode !== rng.startContainer || sel.focusNode !== rng.endContainer) { sel.setBaseAndExtent(node, 0, node, 1); } } } } } self.editor.fire('AfterSetSelectionRange', { range: rng, forward: forward }); } else { // Is W3C Range fake range on IE if (rng.cloneRange) { try { self.tridentSel.addRange(rng); } catch (ex) { //IE9 throws an error here if called before selection is placed in the editor } } } }
javascript
function (rng, forward) { var self = this, sel, node, evt; if (!isValidRange(rng)) { return; } // Is IE specific range if (rng.select) { self.explicitRange = null; try { rng.select(); } catch (ex) { // Needed for some odd IE bug #1843306 } return; } if (!self.tridentSel) { sel = self.getSel(); evt = self.editor.fire('SetSelectionRange', { range: rng, forward: forward }); rng = evt.range; if (sel) { self.explicitRange = rng; try { sel.removeAllRanges(); sel.addRange(rng); } catch (ex) { // IE might throw errors here if the editor is within a hidden container and selection is changed } // Forward is set to false and we have an extend function if (forward === false && sel.extend) { sel.collapse(rng.endContainer, rng.endOffset); sel.extend(rng.startContainer, rng.startOffset); } // adding range isn't always successful so we need to check range count otherwise an exception can occur self.selectedRange = sel.rangeCount > 0 ? sel.getRangeAt(0) : null; } // WebKit egde case selecting images works better using setBaseAndExtent when the image is floated if (!rng.collapsed && rng.startContainer === rng.endContainer && sel.setBaseAndExtent && !Env.ie) { if (rng.endOffset - rng.startOffset < 2) { if (rng.startContainer.hasChildNodes()) { node = rng.startContainer.childNodes[rng.startOffset]; if (node && node.tagName === 'IMG') { sel.setBaseAndExtent( rng.startContainer, rng.startOffset, rng.endContainer, rng.endOffset ); // Since the setBaseAndExtent is fixed in more recent Blink versions we // need to detect if it's doing the wrong thing and falling back to the // crazy incorrect behavior api call since that seems to be the only way // to get it to work on Safari WebKit as of 2017-02-23 if (sel.anchorNode !== rng.startContainer || sel.focusNode !== rng.endContainer) { sel.setBaseAndExtent(node, 0, node, 1); } } } } } self.editor.fire('AfterSetSelectionRange', { range: rng, forward: forward }); } else { // Is W3C Range fake range on IE if (rng.cloneRange) { try { self.tridentSel.addRange(rng); } catch (ex) { //IE9 throws an error here if called before selection is placed in the editor } } } }
[ "function", "(", "rng", ",", "forward", ")", "{", "var", "self", "=", "this", ",", "sel", ",", "node", ",", "evt", ";", "if", "(", "!", "isValidRange", "(", "rng", ")", ")", "{", "return", ";", "}", "// Is IE specific range", "if", "(", "rng", ".", "select", ")", "{", "self", ".", "explicitRange", "=", "null", ";", "try", "{", "rng", ".", "select", "(", ")", ";", "}", "catch", "(", "ex", ")", "{", "// Needed for some odd IE bug #1843306", "}", "return", ";", "}", "if", "(", "!", "self", ".", "tridentSel", ")", "{", "sel", "=", "self", ".", "getSel", "(", ")", ";", "evt", "=", "self", ".", "editor", ".", "fire", "(", "'SetSelectionRange'", ",", "{", "range", ":", "rng", ",", "forward", ":", "forward", "}", ")", ";", "rng", "=", "evt", ".", "range", ";", "if", "(", "sel", ")", "{", "self", ".", "explicitRange", "=", "rng", ";", "try", "{", "sel", ".", "removeAllRanges", "(", ")", ";", "sel", ".", "addRange", "(", "rng", ")", ";", "}", "catch", "(", "ex", ")", "{", "// IE might throw errors here if the editor is within a hidden container and selection is changed", "}", "// Forward is set to false and we have an extend function", "if", "(", "forward", "===", "false", "&&", "sel", ".", "extend", ")", "{", "sel", ".", "collapse", "(", "rng", ".", "endContainer", ",", "rng", ".", "endOffset", ")", ";", "sel", ".", "extend", "(", "rng", ".", "startContainer", ",", "rng", ".", "startOffset", ")", ";", "}", "// adding range isn't always successful so we need to check range count otherwise an exception can occur", "self", ".", "selectedRange", "=", "sel", ".", "rangeCount", ">", "0", "?", "sel", ".", "getRangeAt", "(", "0", ")", ":", "null", ";", "}", "// WebKit egde case selecting images works better using setBaseAndExtent when the image is floated", "if", "(", "!", "rng", ".", "collapsed", "&&", "rng", ".", "startContainer", "===", "rng", ".", "endContainer", "&&", "sel", ".", "setBaseAndExtent", "&&", "!", "Env", ".", "ie", ")", "{", "if", "(", "rng", ".", "endOffset", "-", "rng", ".", "startOffset", "<", "2", ")", "{", "if", "(", "rng", ".", "startContainer", ".", "hasChildNodes", "(", ")", ")", "{", "node", "=", "rng", ".", "startContainer", ".", "childNodes", "[", "rng", ".", "startOffset", "]", ";", "if", "(", "node", "&&", "node", ".", "tagName", "===", "'IMG'", ")", "{", "sel", ".", "setBaseAndExtent", "(", "rng", ".", "startContainer", ",", "rng", ".", "startOffset", ",", "rng", ".", "endContainer", ",", "rng", ".", "endOffset", ")", ";", "// Since the setBaseAndExtent is fixed in more recent Blink versions we", "// need to detect if it's doing the wrong thing and falling back to the", "// crazy incorrect behavior api call since that seems to be the only way", "// to get it to work on Safari WebKit as of 2017-02-23", "if", "(", "sel", ".", "anchorNode", "!==", "rng", ".", "startContainer", "||", "sel", ".", "focusNode", "!==", "rng", ".", "endContainer", ")", "{", "sel", ".", "setBaseAndExtent", "(", "node", ",", "0", ",", "node", ",", "1", ")", ";", "}", "}", "}", "}", "}", "self", ".", "editor", ".", "fire", "(", "'AfterSetSelectionRange'", ",", "{", "range", ":", "rng", ",", "forward", ":", "forward", "}", ")", ";", "}", "else", "{", "// Is W3C Range fake range on IE", "if", "(", "rng", ".", "cloneRange", ")", "{", "try", "{", "self", ".", "tridentSel", ".", "addRange", "(", "rng", ")", ";", "}", "catch", "(", "ex", ")", "{", "//IE9 throws an error here if called before selection is placed in the editor", "}", "}", "}", "}" ]
Changes the selection to the specified DOM range. @method setRng @param {Range} rng Range to select. @param {Boolean} forward Optional boolean if the selection is forwards or backwards.
[ "Changes", "the", "selection", "to", "the", "specified", "DOM", "range", "." ]
a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f
https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/tinymce.jquery.js#L26013-L26095
56,507
adiwidjaja/frontend-pagebuilder
js/tinymce/tinymce.jquery.js
function () { var level; if (self.typing) { self.add(); self.typing = false; setTyping(false); } if (index > 0) { level = data[--index]; Levels.applyToEditor(editor, level, true); setDirty(true); editor.fire('undo', { level: level }); } return level; }
javascript
function () { var level; if (self.typing) { self.add(); self.typing = false; setTyping(false); } if (index > 0) { level = data[--index]; Levels.applyToEditor(editor, level, true); setDirty(true); editor.fire('undo', { level: level }); } return level; }
[ "function", "(", ")", "{", "var", "level", ";", "if", "(", "self", ".", "typing", ")", "{", "self", ".", "add", "(", ")", ";", "self", ".", "typing", "=", "false", ";", "setTyping", "(", "false", ")", ";", "}", "if", "(", "index", ">", "0", ")", "{", "level", "=", "data", "[", "--", "index", "]", ";", "Levels", ".", "applyToEditor", "(", "editor", ",", "level", ",", "true", ")", ";", "setDirty", "(", "true", ")", ";", "editor", ".", "fire", "(", "'undo'", ",", "{", "level", ":", "level", "}", ")", ";", "}", "return", "level", ";", "}" ]
Undoes the last action. @method undo @return {Object} Undo level or null if no undo was performed.
[ "Undoes", "the", "last", "action", "." ]
a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f
https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/tinymce.jquery.js#L27014-L27031
56,508
adiwidjaja/frontend-pagebuilder
js/tinymce/tinymce.jquery.js
function (elm, afterDeletePosOpt) { return Options.liftN([Traverse.prevSibling(elm), Traverse.nextSibling(elm), afterDeletePosOpt], function (prev, next, afterDeletePos) { var offset, prevNode = prev.dom(), nextNode = next.dom(); if (NodeType.isText(prevNode) && NodeType.isText(nextNode)) { offset = prevNode.data.length; prevNode.appendData(nextNode.data); Remove.remove(next); Remove.remove(elm); if (afterDeletePos.container() === nextNode) { return new CaretPosition(prevNode, offset); } else { return afterDeletePos; } } else { Remove.remove(elm); return afterDeletePos; } }).orThunk(function () { Remove.remove(elm); return afterDeletePosOpt; }); }
javascript
function (elm, afterDeletePosOpt) { return Options.liftN([Traverse.prevSibling(elm), Traverse.nextSibling(elm), afterDeletePosOpt], function (prev, next, afterDeletePos) { var offset, prevNode = prev.dom(), nextNode = next.dom(); if (NodeType.isText(prevNode) && NodeType.isText(nextNode)) { offset = prevNode.data.length; prevNode.appendData(nextNode.data); Remove.remove(next); Remove.remove(elm); if (afterDeletePos.container() === nextNode) { return new CaretPosition(prevNode, offset); } else { return afterDeletePos; } } else { Remove.remove(elm); return afterDeletePos; } }).orThunk(function () { Remove.remove(elm); return afterDeletePosOpt; }); }
[ "function", "(", "elm", ",", "afterDeletePosOpt", ")", "{", "return", "Options", ".", "liftN", "(", "[", "Traverse", ".", "prevSibling", "(", "elm", ")", ",", "Traverse", ".", "nextSibling", "(", "elm", ")", ",", "afterDeletePosOpt", "]", ",", "function", "(", "prev", ",", "next", ",", "afterDeletePos", ")", "{", "var", "offset", ",", "prevNode", "=", "prev", ".", "dom", "(", ")", ",", "nextNode", "=", "next", ".", "dom", "(", ")", ";", "if", "(", "NodeType", ".", "isText", "(", "prevNode", ")", "&&", "NodeType", ".", "isText", "(", "nextNode", ")", ")", "{", "offset", "=", "prevNode", ".", "data", ".", "length", ";", "prevNode", ".", "appendData", "(", "nextNode", ".", "data", ")", ";", "Remove", ".", "remove", "(", "next", ")", ";", "Remove", ".", "remove", "(", "elm", ")", ";", "if", "(", "afterDeletePos", ".", "container", "(", ")", "===", "nextNode", ")", "{", "return", "new", "CaretPosition", "(", "prevNode", ",", "offset", ")", ";", "}", "else", "{", "return", "afterDeletePos", ";", "}", "}", "else", "{", "Remove", ".", "remove", "(", "elm", ")", ";", "return", "afterDeletePos", ";", "}", "}", ")", ".", "orThunk", "(", "function", "(", ")", "{", "Remove", ".", "remove", "(", "elm", ")", ";", "return", "afterDeletePosOpt", ";", "}", ")", ";", "}" ]
When deleting an element between two text nodes IE 11 doesn't automatically merge the adjacent text nodes
[ "When", "deleting", "an", "element", "between", "two", "text", "nodes", "IE", "11", "doesn", "t", "automatically", "merge", "the", "adjacent", "text", "nodes" ]
a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f
https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/tinymce.jquery.js#L28148-L28170
56,509
adiwidjaja/frontend-pagebuilder
js/tinymce/tinymce.jquery.js
queryCommandValue
function queryCommandValue(command) { var func; if (editor.quirks.isHidden() || editor.removed) { return; } command = command.toLowerCase(); if ((func = commands.value[command])) { return func(command); } // Browser commands try { return editor.getDoc().queryCommandValue(command); } catch (ex) { // Fails sometimes see bug: 1896577 } }
javascript
function queryCommandValue(command) { var func; if (editor.quirks.isHidden() || editor.removed) { return; } command = command.toLowerCase(); if ((func = commands.value[command])) { return func(command); } // Browser commands try { return editor.getDoc().queryCommandValue(command); } catch (ex) { // Fails sometimes see bug: 1896577 } }
[ "function", "queryCommandValue", "(", "command", ")", "{", "var", "func", ";", "if", "(", "editor", ".", "quirks", ".", "isHidden", "(", ")", "||", "editor", ".", "removed", ")", "{", "return", ";", "}", "command", "=", "command", ".", "toLowerCase", "(", ")", ";", "if", "(", "(", "func", "=", "commands", ".", "value", "[", "command", "]", ")", ")", "{", "return", "func", "(", "command", ")", ";", "}", "// Browser commands", "try", "{", "return", "editor", ".", "getDoc", "(", ")", ".", "queryCommandValue", "(", "command", ")", ";", "}", "catch", "(", "ex", ")", "{", "// Fails sometimes see bug: 1896577", "}", "}" ]
Queries the command value for example the current fontsize. @method queryCommandValue @param {String} command Command to check the value of. @return {Object} Command value of false if it's not found.
[ "Queries", "the", "command", "value", "for", "example", "the", "current", "fontsize", "." ]
a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f
https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/tinymce.jquery.js#L30131-L30149
56,510
adiwidjaja/frontend-pagebuilder
js/tinymce/tinymce.jquery.js
function (dom, node) { return node && dom.isBlock(node) && !/^(TD|TH|CAPTION|FORM)$/.test(node.nodeName) && !/^(fixed|absolute)/i.test(node.style.position) && dom.getContentEditable(node) !== "true"; }
javascript
function (dom, node) { return node && dom.isBlock(node) && !/^(TD|TH|CAPTION|FORM)$/.test(node.nodeName) && !/^(fixed|absolute)/i.test(node.style.position) && dom.getContentEditable(node) !== "true"; }
[ "function", "(", "dom", ",", "node", ")", "{", "return", "node", "&&", "dom", ".", "isBlock", "(", "node", ")", "&&", "!", "/", "^(TD|TH|CAPTION|FORM)$", "/", ".", "test", "(", "node", ".", "nodeName", ")", "&&", "!", "/", "^(fixed|absolute)", "/", "i", ".", "test", "(", "node", ".", "style", ".", "position", ")", "&&", "dom", ".", "getContentEditable", "(", "node", ")", "!==", "\"true\"", ";", "}" ]
Returns true if the block can be split into two blocks or not
[ "Returns", "true", "if", "the", "block", "can", "be", "split", "into", "two", "blocks", "or", "not" ]
a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f
https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/tinymce.jquery.js#L41209-L41215
56,511
adiwidjaja/frontend-pagebuilder
js/tinymce/tinymce.jquery.js
moveToCaretPosition
function moveToCaretPosition(root) { var walker, node, rng, lastNode = root, tempElm; if (!root) { return; } // Old IE versions doesn't properly render blocks with br elements in them // For example <p><br></p> wont be rendered correctly in a contentEditable area // until you remove the br producing <p></p> if (Env.ie && Env.ie < 9 && parentBlock && parentBlock.firstChild) { if (parentBlock.firstChild == parentBlock.lastChild && parentBlock.firstChild.tagName == 'BR') { dom.remove(parentBlock.firstChild); } } if (/^(LI|DT|DD)$/.test(root.nodeName)) { var firstChild = firstNonWhiteSpaceNodeSibling(root.firstChild); if (firstChild && /^(UL|OL|DL)$/.test(firstChild.nodeName)) { root.insertBefore(dom.doc.createTextNode('\u00a0'), root.firstChild); } } rng = dom.createRng(); // Normalize whitespace to remove empty text nodes. Fix for: #6904 // Gecko will be able to place the caret in empty text nodes but it won't render propery // Older IE versions will sometimes crash so for now ignore all IE versions if (!Env.ie) { root.normalize(); } if (root.hasChildNodes()) { walker = new TreeWalker(root, root); while ((node = walker.current())) { if (node.nodeType == 3) { rng.setStart(node, 0); rng.setEnd(node, 0); break; } if (moveCaretBeforeOnEnterElementsMap[node.nodeName.toLowerCase()]) { rng.setStartBefore(node); rng.setEndBefore(node); break; } lastNode = node; node = walker.next(); } if (!node) { rng.setStart(lastNode, 0); rng.setEnd(lastNode, 0); } } else { if (root.nodeName == 'BR') { if (root.nextSibling && dom.isBlock(root.nextSibling)) { // Trick on older IE versions to render the caret before the BR between two lists if (!documentMode || documentMode < 9) { tempElm = dom.create('br'); root.parentNode.insertBefore(tempElm, root); } rng.setStartBefore(root); rng.setEndBefore(root); } else { rng.setStartAfter(root); rng.setEndAfter(root); } } else { rng.setStart(root, 0); rng.setEnd(root, 0); } } selection.setRng(rng); // Remove tempElm created for old IE:s dom.remove(tempElm); selection.scrollIntoView(root); }
javascript
function moveToCaretPosition(root) { var walker, node, rng, lastNode = root, tempElm; if (!root) { return; } // Old IE versions doesn't properly render blocks with br elements in them // For example <p><br></p> wont be rendered correctly in a contentEditable area // until you remove the br producing <p></p> if (Env.ie && Env.ie < 9 && parentBlock && parentBlock.firstChild) { if (parentBlock.firstChild == parentBlock.lastChild && parentBlock.firstChild.tagName == 'BR') { dom.remove(parentBlock.firstChild); } } if (/^(LI|DT|DD)$/.test(root.nodeName)) { var firstChild = firstNonWhiteSpaceNodeSibling(root.firstChild); if (firstChild && /^(UL|OL|DL)$/.test(firstChild.nodeName)) { root.insertBefore(dom.doc.createTextNode('\u00a0'), root.firstChild); } } rng = dom.createRng(); // Normalize whitespace to remove empty text nodes. Fix for: #6904 // Gecko will be able to place the caret in empty text nodes but it won't render propery // Older IE versions will sometimes crash so for now ignore all IE versions if (!Env.ie) { root.normalize(); } if (root.hasChildNodes()) { walker = new TreeWalker(root, root); while ((node = walker.current())) { if (node.nodeType == 3) { rng.setStart(node, 0); rng.setEnd(node, 0); break; } if (moveCaretBeforeOnEnterElementsMap[node.nodeName.toLowerCase()]) { rng.setStartBefore(node); rng.setEndBefore(node); break; } lastNode = node; node = walker.next(); } if (!node) { rng.setStart(lastNode, 0); rng.setEnd(lastNode, 0); } } else { if (root.nodeName == 'BR') { if (root.nextSibling && dom.isBlock(root.nextSibling)) { // Trick on older IE versions to render the caret before the BR between two lists if (!documentMode || documentMode < 9) { tempElm = dom.create('br'); root.parentNode.insertBefore(tempElm, root); } rng.setStartBefore(root); rng.setEndBefore(root); } else { rng.setStartAfter(root); rng.setEndAfter(root); } } else { rng.setStart(root, 0); rng.setEnd(root, 0); } } selection.setRng(rng); // Remove tempElm created for old IE:s dom.remove(tempElm); selection.scrollIntoView(root); }
[ "function", "moveToCaretPosition", "(", "root", ")", "{", "var", "walker", ",", "node", ",", "rng", ",", "lastNode", "=", "root", ",", "tempElm", ";", "if", "(", "!", "root", ")", "{", "return", ";", "}", "// Old IE versions doesn't properly render blocks with br elements in them", "// For example <p><br></p> wont be rendered correctly in a contentEditable area", "// until you remove the br producing <p></p>", "if", "(", "Env", ".", "ie", "&&", "Env", ".", "ie", "<", "9", "&&", "parentBlock", "&&", "parentBlock", ".", "firstChild", ")", "{", "if", "(", "parentBlock", ".", "firstChild", "==", "parentBlock", ".", "lastChild", "&&", "parentBlock", ".", "firstChild", ".", "tagName", "==", "'BR'", ")", "{", "dom", ".", "remove", "(", "parentBlock", ".", "firstChild", ")", ";", "}", "}", "if", "(", "/", "^(LI|DT|DD)$", "/", ".", "test", "(", "root", ".", "nodeName", ")", ")", "{", "var", "firstChild", "=", "firstNonWhiteSpaceNodeSibling", "(", "root", ".", "firstChild", ")", ";", "if", "(", "firstChild", "&&", "/", "^(UL|OL|DL)$", "/", ".", "test", "(", "firstChild", ".", "nodeName", ")", ")", "{", "root", ".", "insertBefore", "(", "dom", ".", "doc", ".", "createTextNode", "(", "'\\u00a0'", ")", ",", "root", ".", "firstChild", ")", ";", "}", "}", "rng", "=", "dom", ".", "createRng", "(", ")", ";", "// Normalize whitespace to remove empty text nodes. Fix for: #6904", "// Gecko will be able to place the caret in empty text nodes but it won't render propery", "// Older IE versions will sometimes crash so for now ignore all IE versions", "if", "(", "!", "Env", ".", "ie", ")", "{", "root", ".", "normalize", "(", ")", ";", "}", "if", "(", "root", ".", "hasChildNodes", "(", ")", ")", "{", "walker", "=", "new", "TreeWalker", "(", "root", ",", "root", ")", ";", "while", "(", "(", "node", "=", "walker", ".", "current", "(", ")", ")", ")", "{", "if", "(", "node", ".", "nodeType", "==", "3", ")", "{", "rng", ".", "setStart", "(", "node", ",", "0", ")", ";", "rng", ".", "setEnd", "(", "node", ",", "0", ")", ";", "break", ";", "}", "if", "(", "moveCaretBeforeOnEnterElementsMap", "[", "node", ".", "nodeName", ".", "toLowerCase", "(", ")", "]", ")", "{", "rng", ".", "setStartBefore", "(", "node", ")", ";", "rng", ".", "setEndBefore", "(", "node", ")", ";", "break", ";", "}", "lastNode", "=", "node", ";", "node", "=", "walker", ".", "next", "(", ")", ";", "}", "if", "(", "!", "node", ")", "{", "rng", ".", "setStart", "(", "lastNode", ",", "0", ")", ";", "rng", ".", "setEnd", "(", "lastNode", ",", "0", ")", ";", "}", "}", "else", "{", "if", "(", "root", ".", "nodeName", "==", "'BR'", ")", "{", "if", "(", "root", ".", "nextSibling", "&&", "dom", ".", "isBlock", "(", "root", ".", "nextSibling", ")", ")", "{", "// Trick on older IE versions to render the caret before the BR between two lists", "if", "(", "!", "documentMode", "||", "documentMode", "<", "9", ")", "{", "tempElm", "=", "dom", ".", "create", "(", "'br'", ")", ";", "root", ".", "parentNode", ".", "insertBefore", "(", "tempElm", ",", "root", ")", ";", "}", "rng", ".", "setStartBefore", "(", "root", ")", ";", "rng", ".", "setEndBefore", "(", "root", ")", ";", "}", "else", "{", "rng", ".", "setStartAfter", "(", "root", ")", ";", "rng", ".", "setEndAfter", "(", "root", ")", ";", "}", "}", "else", "{", "rng", ".", "setStart", "(", "root", ",", "0", ")", ";", "rng", ".", "setEnd", "(", "root", ",", "0", ")", ";", "}", "}", "selection", ".", "setRng", "(", "rng", ")", ";", "// Remove tempElm created for old IE:s", "dom", ".", "remove", "(", "tempElm", ")", ";", "selection", ".", "scrollIntoView", "(", "root", ")", ";", "}" ]
Moves the caret to a suitable position within the root for example in the first non pure whitespace text node or before an image
[ "Moves", "the", "caret", "to", "a", "suitable", "position", "within", "the", "root", "for", "example", "in", "the", "first", "non", "pure", "whitespace", "text", "node", "or", "before", "an", "image" ]
a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f
https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/tinymce.jquery.js#L41300-L41383
56,512
adiwidjaja/frontend-pagebuilder
js/tinymce/tinymce.jquery.js
function (editor, clientX, clientY) { var bodyElm = Element.fromDom(editor.getBody()); var targetElm = editor.inline ? bodyElm : Traverse.documentElement(bodyElm); var transposedPoint = transpose(editor.inline, targetElm, clientX, clientY); return isInsideElementContentArea(targetElm, transposedPoint.x, transposedPoint.y); }
javascript
function (editor, clientX, clientY) { var bodyElm = Element.fromDom(editor.getBody()); var targetElm = editor.inline ? bodyElm : Traverse.documentElement(bodyElm); var transposedPoint = transpose(editor.inline, targetElm, clientX, clientY); return isInsideElementContentArea(targetElm, transposedPoint.x, transposedPoint.y); }
[ "function", "(", "editor", ",", "clientX", ",", "clientY", ")", "{", "var", "bodyElm", "=", "Element", ".", "fromDom", "(", "editor", ".", "getBody", "(", ")", ")", ";", "var", "targetElm", "=", "editor", ".", "inline", "?", "bodyElm", ":", "Traverse", ".", "documentElement", "(", "bodyElm", ")", ";", "var", "transposedPoint", "=", "transpose", "(", "editor", ".", "inline", ",", "targetElm", ",", "clientX", ",", "clientY", ")", ";", "return", "isInsideElementContentArea", "(", "targetElm", ",", "transposedPoint", ".", "x", ",", "transposedPoint", ".", "y", ")", ";", "}" ]
Checks if the specified coordinate is within the visual content area excluding the scrollbars
[ "Checks", "if", "the", "specified", "coordinate", "is", "within", "the", "visual", "content", "area", "excluding", "the", "scrollbars" ]
a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f
https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/tinymce.jquery.js#L43027-L43033
56,513
adiwidjaja/frontend-pagebuilder
js/tinymce/tinymce.jquery.js
Editor
function Editor(id, settings, editorManager) { var self = this, documentBaseUrl, baseUri; documentBaseUrl = self.documentBaseUrl = editorManager.documentBaseURL; baseUri = editorManager.baseURI; /** * Name/value collection with editor settings. * * @property settings * @type Object * @example * // Get the value of the theme setting * tinymce.activeEditor.windowManager.alert("You are using the " + tinymce.activeEditor.settings.theme + " theme"); */ settings = EditorSettings.getEditorSettings(self, id, documentBaseUrl, editorManager.defaultSettings, settings); self.settings = settings; AddOnManager.language = settings.language || 'en'; AddOnManager.languageLoad = settings.language_load; AddOnManager.baseURL = editorManager.baseURL; /** * Editor instance id, normally the same as the div/textarea that was replaced. * * @property id * @type String */ self.id = id; /** * State to force the editor to return false on a isDirty call. * * @property isNotDirty * @type Boolean * @deprecated Use editor.setDirty instead. */ self.setDirty(false); /** * Name/Value object containing plugin instances. * * @property plugins * @type Object * @example * // Execute a method inside a plugin directly * tinymce.activeEditor.plugins.someplugin.someMethod(); */ self.plugins = {}; /** * URI object to document configured for the TinyMCE instance. * * @property documentBaseURI * @type tinymce.util.URI * @example * // Get relative URL from the location of document_base_url * tinymce.activeEditor.documentBaseURI.toRelative('/somedir/somefile.htm'); * * // Get absolute URL from the location of document_base_url * tinymce.activeEditor.documentBaseURI.toAbsolute('somefile.htm'); */ self.documentBaseURI = new URI(settings.document_base_url, { base_uri: baseUri }); /** * URI object to current document that holds the TinyMCE editor instance. * * @property baseURI * @type tinymce.util.URI * @example * // Get relative URL from the location of the API * tinymce.activeEditor.baseURI.toRelative('/somedir/somefile.htm'); * * // Get absolute URL from the location of the API * tinymce.activeEditor.baseURI.toAbsolute('somefile.htm'); */ self.baseURI = baseUri; /** * Array with CSS files to load into the iframe. * * @property contentCSS * @type Array */ self.contentCSS = []; /** * Array of CSS styles to add to head of document when the editor loads. * * @property contentStyles * @type Array */ self.contentStyles = []; // Creates all events like onClick, onSetContent etc see Editor.Events.js for the actual logic self.shortcuts = new Shortcuts(self); self.loadedCSS = {}; self.editorCommands = new EditorCommands(self); self.suffix = editorManager.suffix; self.editorManager = editorManager; self.inline = settings.inline; if (settings.cache_suffix) { Env.cacheSuffix = settings.cache_suffix.replace(/^[\?\&]+/, ''); } if (settings.override_viewport === false) { Env.overrideViewPort = false; } // Call setup editorManager.fire('SetupEditor', self); self.execCallback('setup', self); /** * Dom query instance with default scope to the editor document and default element is the body of the editor. * * @property $ * @type tinymce.dom.DomQuery * @example * tinymce.activeEditor.$('p').css('color', 'red'); * tinymce.activeEditor.$().append('<p>new</p>'); */ self.$ = DomQuery.overrideDefaults(function () { return { context: self.inline ? self.getBody() : self.getDoc(), element: self.getBody() }; }); }
javascript
function Editor(id, settings, editorManager) { var self = this, documentBaseUrl, baseUri; documentBaseUrl = self.documentBaseUrl = editorManager.documentBaseURL; baseUri = editorManager.baseURI; /** * Name/value collection with editor settings. * * @property settings * @type Object * @example * // Get the value of the theme setting * tinymce.activeEditor.windowManager.alert("You are using the " + tinymce.activeEditor.settings.theme + " theme"); */ settings = EditorSettings.getEditorSettings(self, id, documentBaseUrl, editorManager.defaultSettings, settings); self.settings = settings; AddOnManager.language = settings.language || 'en'; AddOnManager.languageLoad = settings.language_load; AddOnManager.baseURL = editorManager.baseURL; /** * Editor instance id, normally the same as the div/textarea that was replaced. * * @property id * @type String */ self.id = id; /** * State to force the editor to return false on a isDirty call. * * @property isNotDirty * @type Boolean * @deprecated Use editor.setDirty instead. */ self.setDirty(false); /** * Name/Value object containing plugin instances. * * @property plugins * @type Object * @example * // Execute a method inside a plugin directly * tinymce.activeEditor.plugins.someplugin.someMethod(); */ self.plugins = {}; /** * URI object to document configured for the TinyMCE instance. * * @property documentBaseURI * @type tinymce.util.URI * @example * // Get relative URL from the location of document_base_url * tinymce.activeEditor.documentBaseURI.toRelative('/somedir/somefile.htm'); * * // Get absolute URL from the location of document_base_url * tinymce.activeEditor.documentBaseURI.toAbsolute('somefile.htm'); */ self.documentBaseURI = new URI(settings.document_base_url, { base_uri: baseUri }); /** * URI object to current document that holds the TinyMCE editor instance. * * @property baseURI * @type tinymce.util.URI * @example * // Get relative URL from the location of the API * tinymce.activeEditor.baseURI.toRelative('/somedir/somefile.htm'); * * // Get absolute URL from the location of the API * tinymce.activeEditor.baseURI.toAbsolute('somefile.htm'); */ self.baseURI = baseUri; /** * Array with CSS files to load into the iframe. * * @property contentCSS * @type Array */ self.contentCSS = []; /** * Array of CSS styles to add to head of document when the editor loads. * * @property contentStyles * @type Array */ self.contentStyles = []; // Creates all events like onClick, onSetContent etc see Editor.Events.js for the actual logic self.shortcuts = new Shortcuts(self); self.loadedCSS = {}; self.editorCommands = new EditorCommands(self); self.suffix = editorManager.suffix; self.editorManager = editorManager; self.inline = settings.inline; if (settings.cache_suffix) { Env.cacheSuffix = settings.cache_suffix.replace(/^[\?\&]+/, ''); } if (settings.override_viewport === false) { Env.overrideViewPort = false; } // Call setup editorManager.fire('SetupEditor', self); self.execCallback('setup', self); /** * Dom query instance with default scope to the editor document and default element is the body of the editor. * * @property $ * @type tinymce.dom.DomQuery * @example * tinymce.activeEditor.$('p').css('color', 'red'); * tinymce.activeEditor.$().append('<p>new</p>'); */ self.$ = DomQuery.overrideDefaults(function () { return { context: self.inline ? self.getBody() : self.getDoc(), element: self.getBody() }; }); }
[ "function", "Editor", "(", "id", ",", "settings", ",", "editorManager", ")", "{", "var", "self", "=", "this", ",", "documentBaseUrl", ",", "baseUri", ";", "documentBaseUrl", "=", "self", ".", "documentBaseUrl", "=", "editorManager", ".", "documentBaseURL", ";", "baseUri", "=", "editorManager", ".", "baseURI", ";", "/**\n * Name/value collection with editor settings.\n *\n * @property settings\n * @type Object\n * @example\n * // Get the value of the theme setting\n * tinymce.activeEditor.windowManager.alert(\"You are using the \" + tinymce.activeEditor.settings.theme + \" theme\");\n */", "settings", "=", "EditorSettings", ".", "getEditorSettings", "(", "self", ",", "id", ",", "documentBaseUrl", ",", "editorManager", ".", "defaultSettings", ",", "settings", ")", ";", "self", ".", "settings", "=", "settings", ";", "AddOnManager", ".", "language", "=", "settings", ".", "language", "||", "'en'", ";", "AddOnManager", ".", "languageLoad", "=", "settings", ".", "language_load", ";", "AddOnManager", ".", "baseURL", "=", "editorManager", ".", "baseURL", ";", "/**\n * Editor instance id, normally the same as the div/textarea that was replaced.\n *\n * @property id\n * @type String\n */", "self", ".", "id", "=", "id", ";", "/**\n * State to force the editor to return false on a isDirty call.\n *\n * @property isNotDirty\n * @type Boolean\n * @deprecated Use editor.setDirty instead.\n */", "self", ".", "setDirty", "(", "false", ")", ";", "/**\n * Name/Value object containing plugin instances.\n *\n * @property plugins\n * @type Object\n * @example\n * // Execute a method inside a plugin directly\n * tinymce.activeEditor.plugins.someplugin.someMethod();\n */", "self", ".", "plugins", "=", "{", "}", ";", "/**\n * URI object to document configured for the TinyMCE instance.\n *\n * @property documentBaseURI\n * @type tinymce.util.URI\n * @example\n * // Get relative URL from the location of document_base_url\n * tinymce.activeEditor.documentBaseURI.toRelative('/somedir/somefile.htm');\n *\n * // Get absolute URL from the location of document_base_url\n * tinymce.activeEditor.documentBaseURI.toAbsolute('somefile.htm');\n */", "self", ".", "documentBaseURI", "=", "new", "URI", "(", "settings", ".", "document_base_url", ",", "{", "base_uri", ":", "baseUri", "}", ")", ";", "/**\n * URI object to current document that holds the TinyMCE editor instance.\n *\n * @property baseURI\n * @type tinymce.util.URI\n * @example\n * // Get relative URL from the location of the API\n * tinymce.activeEditor.baseURI.toRelative('/somedir/somefile.htm');\n *\n * // Get absolute URL from the location of the API\n * tinymce.activeEditor.baseURI.toAbsolute('somefile.htm');\n */", "self", ".", "baseURI", "=", "baseUri", ";", "/**\n * Array with CSS files to load into the iframe.\n *\n * @property contentCSS\n * @type Array\n */", "self", ".", "contentCSS", "=", "[", "]", ";", "/**\n * Array of CSS styles to add to head of document when the editor loads.\n *\n * @property contentStyles\n * @type Array\n */", "self", ".", "contentStyles", "=", "[", "]", ";", "// Creates all events like onClick, onSetContent etc see Editor.Events.js for the actual logic", "self", ".", "shortcuts", "=", "new", "Shortcuts", "(", "self", ")", ";", "self", ".", "loadedCSS", "=", "{", "}", ";", "self", ".", "editorCommands", "=", "new", "EditorCommands", "(", "self", ")", ";", "self", ".", "suffix", "=", "editorManager", ".", "suffix", ";", "self", ".", "editorManager", "=", "editorManager", ";", "self", ".", "inline", "=", "settings", ".", "inline", ";", "if", "(", "settings", ".", "cache_suffix", ")", "{", "Env", ".", "cacheSuffix", "=", "settings", ".", "cache_suffix", ".", "replace", "(", "/", "^[\\?\\&]+", "/", ",", "''", ")", ";", "}", "if", "(", "settings", ".", "override_viewport", "===", "false", ")", "{", "Env", ".", "overrideViewPort", "=", "false", ";", "}", "// Call setup", "editorManager", ".", "fire", "(", "'SetupEditor'", ",", "self", ")", ";", "self", ".", "execCallback", "(", "'setup'", ",", "self", ")", ";", "/**\n * Dom query instance with default scope to the editor document and default element is the body of the editor.\n *\n * @property $\n * @type tinymce.dom.DomQuery\n * @example\n * tinymce.activeEditor.$('p').css('color', 'red');\n * tinymce.activeEditor.$().append('<p>new</p>');\n */", "self", ".", "$", "=", "DomQuery", ".", "overrideDefaults", "(", "function", "(", ")", "{", "return", "{", "context", ":", "self", ".", "inline", "?", "self", ".", "getBody", "(", ")", ":", "self", ".", "getDoc", "(", ")", ",", "element", ":", "self", ".", "getBody", "(", ")", "}", ";", "}", ")", ";", "}" ]
Include Editor API docs. @include ../../../../../tools/docs/tinymce.Editor.js Constructs a editor instance by id. @constructor @method Editor @param {String} id Unique id for the editor. @param {Object} settings Settings for the editor. @param {tinymce.EditorManager} editorManager EditorManager instance.
[ "Include", "Editor", "API", "docs", "." ]
a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f
https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/tinymce.jquery.js#L45785-L45916
56,514
adiwidjaja/frontend-pagebuilder
js/tinymce/tinymce.jquery.js
function (text) { if (text && Tools.is(text, 'string')) { var lang = this.settings.language || 'en', i18n = this.editorManager.i18n; text = i18n.data[lang + '.' + text] || text.replace(/\{\#([^\}]+)\}/g, function (a, b) { return i18n.data[lang + '.' + b] || '{#' + b + '}'; }); } return this.editorManager.translate(text); }
javascript
function (text) { if (text && Tools.is(text, 'string')) { var lang = this.settings.language || 'en', i18n = this.editorManager.i18n; text = i18n.data[lang + '.' + text] || text.replace(/\{\#([^\}]+)\}/g, function (a, b) { return i18n.data[lang + '.' + b] || '{#' + b + '}'; }); } return this.editorManager.translate(text); }
[ "function", "(", "text", ")", "{", "if", "(", "text", "&&", "Tools", ".", "is", "(", "text", ",", "'string'", ")", ")", "{", "var", "lang", "=", "this", ".", "settings", ".", "language", "||", "'en'", ",", "i18n", "=", "this", ".", "editorManager", ".", "i18n", ";", "text", "=", "i18n", ".", "data", "[", "lang", "+", "'.'", "+", "text", "]", "||", "text", ".", "replace", "(", "/", "\\{\\#([^\\}]+)\\}", "/", "g", ",", "function", "(", "a", ",", "b", ")", "{", "return", "i18n", ".", "data", "[", "lang", "+", "'.'", "+", "b", "]", "||", "'{#'", "+", "b", "+", "'}'", ";", "}", ")", ";", "}", "return", "this", ".", "editorManager", ".", "translate", "(", "text", ")", ";", "}" ]
Translates the specified string by replacing variables with language pack items it will also check if there is a key matching the input. @method translate @param {String} text String to translate by the language pack data. @return {String} Translated string.
[ "Translates", "the", "specified", "string", "by", "replacing", "variables", "with", "language", "pack", "items", "it", "will", "also", "check", "if", "there", "is", "a", "key", "matching", "the", "input", "." ]
a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f
https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/tinymce.jquery.js#L46056-L46066
56,515
adiwidjaja/frontend-pagebuilder
js/tinymce/tinymce.jquery.js
function (args) { var self = this, content, body = self.getBody(); if (self.removed) { return ''; } // Setup args object args = args || {}; args.format = args.format || 'html'; args.get = true; args.getInner = true; // Do preprocessing if (!args.no_events) { self.fire('BeforeGetContent', args); } // Get raw contents or by default the cleaned contents if (args.format == 'raw') { content = Tools.trim(self.serializer.getTrimmedContent()); } else if (args.format == 'text') { content = body.innerText || body.textContent; } else { content = self.serializer.serialize(body, args); } // Trim whitespace in beginning/end of HTML if (args.format != 'text') { args.content = trim(content); } else { args.content = content; } // Do post processing if (!args.no_events) { self.fire('GetContent', args); } return args.content; }
javascript
function (args) { var self = this, content, body = self.getBody(); if (self.removed) { return ''; } // Setup args object args = args || {}; args.format = args.format || 'html'; args.get = true; args.getInner = true; // Do preprocessing if (!args.no_events) { self.fire('BeforeGetContent', args); } // Get raw contents or by default the cleaned contents if (args.format == 'raw') { content = Tools.trim(self.serializer.getTrimmedContent()); } else if (args.format == 'text') { content = body.innerText || body.textContent; } else { content = self.serializer.serialize(body, args); } // Trim whitespace in beginning/end of HTML if (args.format != 'text') { args.content = trim(content); } else { args.content = content; } // Do post processing if (!args.no_events) { self.fire('GetContent', args); } return args.content; }
[ "function", "(", "args", ")", "{", "var", "self", "=", "this", ",", "content", ",", "body", "=", "self", ".", "getBody", "(", ")", ";", "if", "(", "self", ".", "removed", ")", "{", "return", "''", ";", "}", "// Setup args object", "args", "=", "args", "||", "{", "}", ";", "args", ".", "format", "=", "args", ".", "format", "||", "'html'", ";", "args", ".", "get", "=", "true", ";", "args", ".", "getInner", "=", "true", ";", "// Do preprocessing", "if", "(", "!", "args", ".", "no_events", ")", "{", "self", ".", "fire", "(", "'BeforeGetContent'", ",", "args", ")", ";", "}", "// Get raw contents or by default the cleaned contents", "if", "(", "args", ".", "format", "==", "'raw'", ")", "{", "content", "=", "Tools", ".", "trim", "(", "self", ".", "serializer", ".", "getTrimmedContent", "(", ")", ")", ";", "}", "else", "if", "(", "args", ".", "format", "==", "'text'", ")", "{", "content", "=", "body", ".", "innerText", "||", "body", ".", "textContent", ";", "}", "else", "{", "content", "=", "self", ".", "serializer", ".", "serialize", "(", "body", ",", "args", ")", ";", "}", "// Trim whitespace in beginning/end of HTML", "if", "(", "args", ".", "format", "!=", "'text'", ")", "{", "args", ".", "content", "=", "trim", "(", "content", ")", ";", "}", "else", "{", "args", ".", "content", "=", "content", ";", "}", "// Do post processing", "if", "(", "!", "args", ".", "no_events", ")", "{", "self", ".", "fire", "(", "'GetContent'", ",", "args", ")", ";", "}", "return", "args", ".", "content", ";", "}" ]
Gets the content from the editor instance, this will cleanup the content before it gets returned using the different cleanup rules options. @method getContent @param {Object} args Optional content object, this gets passed around through the whole get process. @return {String} Cleaned content string, normally HTML contents. @example // Get the HTML contents of the currently active editor console.debug(tinymce.activeEditor.getContent()); // Get the raw contents of the currently active editor tinymce.activeEditor.getContent({format: 'raw'}); // Get content of a specific editor: tinymce.get('content id').getContent()
[ "Gets", "the", "content", "from", "the", "editor", "instance", "this", "will", "cleanup", "the", "content", "before", "it", "gets", "returned", "using", "the", "different", "cleanup", "rules", "options", "." ]
a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f
https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/tinymce.jquery.js#L46694-L46734
56,516
skerit/alchemy-styleboost
public/ckeditor/4.4dev/plugins/htmlwriter/plugin.js
function() { // Call the base contructor. this.base(); /** * The characters to be used for each indentation step. * * // Use tab for indentation. * editorInstance.dataProcessor.writer.indentationChars = '\t'; */ this.indentationChars = '\t'; /** * The characters to be used to close "self-closing" elements, like `<br>` or `<img>`. * * // Use HTML4 notation for self-closing elements. * editorInstance.dataProcessor.writer.selfClosingEnd = '>'; */ this.selfClosingEnd = ' />'; /** * The characters to be used for line breaks. * * // Use CRLF for line breaks. * editorInstance.dataProcessor.writer.lineBreakChars = '\r\n'; */ this.lineBreakChars = '\n'; this.sortAttributes = 1; this._.indent = 0; this._.indentation = ''; // Indicate preformatted block context status. (#5789) this._.inPre = 0; this._.rules = {}; var dtd = CKEDITOR.dtd; for ( var e in CKEDITOR.tools.extend( {}, dtd.$nonBodyContent, dtd.$block, dtd.$listItem, dtd.$tableContent ) ) { this.setRules( e, { indent: !dtd[ e ][ '#' ], breakBeforeOpen: 1, breakBeforeClose: !dtd[ e ][ '#' ], breakAfterClose: 1, needsSpace: ( e in dtd.$block ) && !( e in { li: 1, dt: 1, dd: 1 } ) } ); } this.setRules( 'br', { breakAfterOpen: 1 } ); this.setRules( 'title', { indent: 0, breakAfterOpen: 0 } ); this.setRules( 'style', { indent: 0, breakBeforeClose: 1 } ); this.setRules( 'pre', { breakAfterOpen: 1, // Keep line break after the opening tag indent: 0 // Disable indentation on <pre>. } ); }
javascript
function() { // Call the base contructor. this.base(); /** * The characters to be used for each indentation step. * * // Use tab for indentation. * editorInstance.dataProcessor.writer.indentationChars = '\t'; */ this.indentationChars = '\t'; /** * The characters to be used to close "self-closing" elements, like `<br>` or `<img>`. * * // Use HTML4 notation for self-closing elements. * editorInstance.dataProcessor.writer.selfClosingEnd = '>'; */ this.selfClosingEnd = ' />'; /** * The characters to be used for line breaks. * * // Use CRLF for line breaks. * editorInstance.dataProcessor.writer.lineBreakChars = '\r\n'; */ this.lineBreakChars = '\n'; this.sortAttributes = 1; this._.indent = 0; this._.indentation = ''; // Indicate preformatted block context status. (#5789) this._.inPre = 0; this._.rules = {}; var dtd = CKEDITOR.dtd; for ( var e in CKEDITOR.tools.extend( {}, dtd.$nonBodyContent, dtd.$block, dtd.$listItem, dtd.$tableContent ) ) { this.setRules( e, { indent: !dtd[ e ][ '#' ], breakBeforeOpen: 1, breakBeforeClose: !dtd[ e ][ '#' ], breakAfterClose: 1, needsSpace: ( e in dtd.$block ) && !( e in { li: 1, dt: 1, dd: 1 } ) } ); } this.setRules( 'br', { breakAfterOpen: 1 } ); this.setRules( 'title', { indent: 0, breakAfterOpen: 0 } ); this.setRules( 'style', { indent: 0, breakBeforeClose: 1 } ); this.setRules( 'pre', { breakAfterOpen: 1, // Keep line break after the opening tag indent: 0 // Disable indentation on <pre>. } ); }
[ "function", "(", ")", "{", "// Call the base contructor.\r", "this", ".", "base", "(", ")", ";", "/**\r\n\t\t * The characters to be used for each indentation step.\r\n\t\t *\r\n\t\t *\t\t// Use tab for indentation.\r\n\t\t *\t\teditorInstance.dataProcessor.writer.indentationChars = '\\t';\r\n\t\t */", "this", ".", "indentationChars", "=", "'\\t'", ";", "/**\r\n\t\t * The characters to be used to close \"self-closing\" elements, like `<br>` or `<img>`.\r\n\t\t *\r\n\t\t *\t\t// Use HTML4 notation for self-closing elements.\r\n\t\t *\t\teditorInstance.dataProcessor.writer.selfClosingEnd = '>';\r\n\t\t */", "this", ".", "selfClosingEnd", "=", "' />'", ";", "/**\r\n\t\t * The characters to be used for line breaks.\r\n\t\t *\r\n\t\t *\t\t// Use CRLF for line breaks.\r\n\t\t *\t\teditorInstance.dataProcessor.writer.lineBreakChars = '\\r\\n';\r\n\t\t */", "this", ".", "lineBreakChars", "=", "'\\n'", ";", "this", ".", "sortAttributes", "=", "1", ";", "this", ".", "_", ".", "indent", "=", "0", ";", "this", ".", "_", ".", "indentation", "=", "''", ";", "// Indicate preformatted block context status. (#5789)\r", "this", ".", "_", ".", "inPre", "=", "0", ";", "this", ".", "_", ".", "rules", "=", "{", "}", ";", "var", "dtd", "=", "CKEDITOR", ".", "dtd", ";", "for", "(", "var", "e", "in", "CKEDITOR", ".", "tools", ".", "extend", "(", "{", "}", ",", "dtd", ".", "$nonBodyContent", ",", "dtd", ".", "$block", ",", "dtd", ".", "$listItem", ",", "dtd", ".", "$tableContent", ")", ")", "{", "this", ".", "setRules", "(", "e", ",", "{", "indent", ":", "!", "dtd", "[", "e", "]", "[", "'#'", "]", ",", "breakBeforeOpen", ":", "1", ",", "breakBeforeClose", ":", "!", "dtd", "[", "e", "]", "[", "'#'", "]", ",", "breakAfterClose", ":", "1", ",", "needsSpace", ":", "(", "e", "in", "dtd", ".", "$block", ")", "&&", "!", "(", "e", "in", "{", "li", ":", "1", ",", "dt", ":", "1", ",", "dd", ":", "1", "}", ")", "}", ")", ";", "}", "this", ".", "setRules", "(", "'br'", ",", "{", "breakAfterOpen", ":", "1", "}", ")", ";", "this", ".", "setRules", "(", "'title'", ",", "{", "indent", ":", "0", ",", "breakAfterOpen", ":", "0", "}", ")", ";", "this", ".", "setRules", "(", "'style'", ",", "{", "indent", ":", "0", ",", "breakBeforeClose", ":", "1", "}", ")", ";", "this", ".", "setRules", "(", "'pre'", ",", "{", "breakAfterOpen", ":", "1", ",", "// Keep line break after the opening tag\r", "indent", ":", "0", "// Disable indentation on <pre>.\r", "}", ")", ";", "}" ]
Creates an `htmlWriter` class instance. @constructor
[ "Creates", "an", "htmlWriter", "class", "instance", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/htmlwriter/plugin.js#L40-L104
56,517
skerit/alchemy-styleboost
public/ckeditor/4.4dev/plugins/htmlwriter/plugin.js
function( tagName, attributes ) { var rules = this._.rules[ tagName ]; if ( this._.afterCloser && rules && rules.needsSpace && this._.needsSpace ) this._.output.push( '\n' ); if ( this._.indent ) this.indentation(); // Do not break if indenting. else if ( rules && rules.breakBeforeOpen ) { this.lineBreak(); this.indentation(); } this._.output.push( '<', tagName ); this._.afterCloser = 0; }
javascript
function( tagName, attributes ) { var rules = this._.rules[ tagName ]; if ( this._.afterCloser && rules && rules.needsSpace && this._.needsSpace ) this._.output.push( '\n' ); if ( this._.indent ) this.indentation(); // Do not break if indenting. else if ( rules && rules.breakBeforeOpen ) { this.lineBreak(); this.indentation(); } this._.output.push( '<', tagName ); this._.afterCloser = 0; }
[ "function", "(", "tagName", ",", "attributes", ")", "{", "var", "rules", "=", "this", ".", "_", ".", "rules", "[", "tagName", "]", ";", "if", "(", "this", ".", "_", ".", "afterCloser", "&&", "rules", "&&", "rules", ".", "needsSpace", "&&", "this", ".", "_", ".", "needsSpace", ")", "this", ".", "_", ".", "output", ".", "push", "(", "'\\n'", ")", ";", "if", "(", "this", ".", "_", ".", "indent", ")", "this", ".", "indentation", "(", ")", ";", "// Do not break if indenting.\r", "else", "if", "(", "rules", "&&", "rules", ".", "breakBeforeOpen", ")", "{", "this", ".", "lineBreak", "(", ")", ";", "this", ".", "indentation", "(", ")", ";", "}", "this", ".", "_", ".", "output", ".", "push", "(", "'<'", ",", "tagName", ")", ";", "this", ".", "_", ".", "afterCloser", "=", "0", ";", "}" ]
Writes the tag opening part for an opener tag. // Writes '<p'. writer.openTag( 'p', { class : 'MyClass', id : 'MyId' } ); @param {String} tagName The element name for this tag. @param {Object} attributes The attributes defined for this tag. The attributes could be used to inspect the tag.
[ "Writes", "the", "tag", "opening", "part", "for", "an", "opener", "tag", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/htmlwriter/plugin.js#L117-L134
56,518
skerit/alchemy-styleboost
public/ckeditor/4.4dev/plugins/htmlwriter/plugin.js
function( tagName, isSelfClose ) { var rules = this._.rules[ tagName ]; if ( isSelfClose ) { this._.output.push( this.selfClosingEnd ); if ( rules && rules.breakAfterClose ) this._.needsSpace = rules.needsSpace; } else { this._.output.push( '>' ); if ( rules && rules.indent ) this._.indentation += this.indentationChars; } if ( rules && rules.breakAfterOpen ) this.lineBreak(); tagName == 'pre' && ( this._.inPre = 1 ); }
javascript
function( tagName, isSelfClose ) { var rules = this._.rules[ tagName ]; if ( isSelfClose ) { this._.output.push( this.selfClosingEnd ); if ( rules && rules.breakAfterClose ) this._.needsSpace = rules.needsSpace; } else { this._.output.push( '>' ); if ( rules && rules.indent ) this._.indentation += this.indentationChars; } if ( rules && rules.breakAfterOpen ) this.lineBreak(); tagName == 'pre' && ( this._.inPre = 1 ); }
[ "function", "(", "tagName", ",", "isSelfClose", ")", "{", "var", "rules", "=", "this", ".", "_", ".", "rules", "[", "tagName", "]", ";", "if", "(", "isSelfClose", ")", "{", "this", ".", "_", ".", "output", ".", "push", "(", "this", ".", "selfClosingEnd", ")", ";", "if", "(", "rules", "&&", "rules", ".", "breakAfterClose", ")", "this", ".", "_", ".", "needsSpace", "=", "rules", ".", "needsSpace", ";", "}", "else", "{", "this", ".", "_", ".", "output", ".", "push", "(", "'>'", ")", ";", "if", "(", "rules", "&&", "rules", ".", "indent", ")", "this", ".", "_", ".", "indentation", "+=", "this", ".", "indentationChars", ";", "}", "if", "(", "rules", "&&", "rules", ".", "breakAfterOpen", ")", "this", ".", "lineBreak", "(", ")", ";", "tagName", "==", "'pre'", "&&", "(", "this", ".", "_", ".", "inPre", "=", "1", ")", ";", "}" ]
Writes the tag closing part for an opener tag. // Writes '>'. writer.openTagClose( 'p', false ); // Writes ' />'. writer.openTagClose( 'br', true ); @param {String} tagName The element name for this tag. @param {Boolean} isSelfClose Indicates that this is a self-closing tag, like `<br>` or `<img>`.
[ "Writes", "the", "tag", "closing", "part", "for", "an", "opener", "tag", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/htmlwriter/plugin.js#L149-L167
56,519
skerit/alchemy-styleboost
public/ckeditor/4.4dev/plugins/htmlwriter/plugin.js
function( tagName ) { var rules = this._.rules[ tagName ]; if ( rules && rules.indent ) this._.indentation = this._.indentation.substr( this.indentationChars.length ); if ( this._.indent ) this.indentation(); // Do not break if indenting. else if ( rules && rules.breakBeforeClose ) { this.lineBreak(); this.indentation(); } this._.output.push( '</', tagName, '>' ); tagName == 'pre' && ( this._.inPre = 0 ); if ( rules && rules.breakAfterClose ) { this.lineBreak(); this._.needsSpace = rules.needsSpace; } this._.afterCloser = 1; }
javascript
function( tagName ) { var rules = this._.rules[ tagName ]; if ( rules && rules.indent ) this._.indentation = this._.indentation.substr( this.indentationChars.length ); if ( this._.indent ) this.indentation(); // Do not break if indenting. else if ( rules && rules.breakBeforeClose ) { this.lineBreak(); this.indentation(); } this._.output.push( '</', tagName, '>' ); tagName == 'pre' && ( this._.inPre = 0 ); if ( rules && rules.breakAfterClose ) { this.lineBreak(); this._.needsSpace = rules.needsSpace; } this._.afterCloser = 1; }
[ "function", "(", "tagName", ")", "{", "var", "rules", "=", "this", ".", "_", ".", "rules", "[", "tagName", "]", ";", "if", "(", "rules", "&&", "rules", ".", "indent", ")", "this", ".", "_", ".", "indentation", "=", "this", ".", "_", ".", "indentation", ".", "substr", "(", "this", ".", "indentationChars", ".", "length", ")", ";", "if", "(", "this", ".", "_", ".", "indent", ")", "this", ".", "indentation", "(", ")", ";", "// Do not break if indenting.\r", "else", "if", "(", "rules", "&&", "rules", ".", "breakBeforeClose", ")", "{", "this", ".", "lineBreak", "(", ")", ";", "this", ".", "indentation", "(", ")", ";", "}", "this", ".", "_", ".", "output", ".", "push", "(", "'</'", ",", "tagName", ",", "'>'", ")", ";", "tagName", "==", "'pre'", "&&", "(", "this", ".", "_", ".", "inPre", "=", "0", ")", ";", "if", "(", "rules", "&&", "rules", ".", "breakAfterClose", ")", "{", "this", ".", "lineBreak", "(", ")", ";", "this", ".", "_", ".", "needsSpace", "=", "rules", ".", "needsSpace", ";", "}", "this", ".", "_", ".", "afterCloser", "=", "1", ";", "}" ]
Writes a closer tag. // Writes '</p>'. writer.closeTag( 'p' ); @param {String} tagName The element name for this tag.
[ "Writes", "a", "closer", "tag", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/htmlwriter/plugin.js#L198-L221
56,520
skerit/alchemy-styleboost
public/ckeditor/4.4dev/plugins/htmlwriter/plugin.js
function( text ) { if ( this._.indent ) { this.indentation(); !this._.inPre && ( text = CKEDITOR.tools.ltrim( text ) ); } this._.output.push( text ); }
javascript
function( text ) { if ( this._.indent ) { this.indentation(); !this._.inPre && ( text = CKEDITOR.tools.ltrim( text ) ); } this._.output.push( text ); }
[ "function", "(", "text", ")", "{", "if", "(", "this", ".", "_", ".", "indent", ")", "{", "this", ".", "indentation", "(", ")", ";", "!", "this", ".", "_", ".", "inPre", "&&", "(", "text", "=", "CKEDITOR", ".", "tools", ".", "ltrim", "(", "text", ")", ")", ";", "}", "this", ".", "_", ".", "output", ".", "push", "(", "text", ")", ";", "}" ]
Writes text. // Writes 'Hello Word'. writer.text( 'Hello Word' ); @param {String} text The text value
[ "Writes", "text", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/htmlwriter/plugin.js#L231-L238
56,521
skerit/alchemy-styleboost
public/ckeditor/4.4dev/plugins/htmlwriter/plugin.js
function() { this._.output = []; this._.indent = 0; this._.indentation = ''; this._.afterCloser = 0; this._.inPre = 0; }
javascript
function() { this._.output = []; this._.indent = 0; this._.indentation = ''; this._.afterCloser = 0; this._.inPre = 0; }
[ "function", "(", ")", "{", "this", ".", "_", ".", "output", "=", "[", "]", ";", "this", ".", "_", ".", "indent", "=", "0", ";", "this", ".", "_", ".", "indentation", "=", "''", ";", "this", ".", "_", ".", "afterCloser", "=", "0", ";", "this", ".", "_", ".", "inPre", "=", "0", ";", "}" ]
Empties the current output buffer. It also brings back the default values of the writer flags. writer.reset();
[ "Empties", "the", "current", "output", "buffer", ".", "It", "also", "brings", "back", "the", "default", "values", "of", "the", "writer", "flags", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/htmlwriter/plugin.js#L286-L292
56,522
skerit/alchemy-styleboost
assets/scripts/bootstrap-select1.6/bootstrap-select.js
normalizeToBase
function normalizeToBase(text) { var rExps = [ {re: /[\xC0-\xC6]/g, ch: "A"}, {re: /[\xE0-\xE6]/g, ch: "a"}, {re: /[\xC8-\xCB]/g, ch: "E"}, {re: /[\xE8-\xEB]/g, ch: "e"}, {re: /[\xCC-\xCF]/g, ch: "I"}, {re: /[\xEC-\xEF]/g, ch: "i"}, {re: /[\xD2-\xD6]/g, ch: "O"}, {re: /[\xF2-\xF6]/g, ch: "o"}, {re: /[\xD9-\xDC]/g, ch: "U"}, {re: /[\xF9-\xFC]/g, ch: "u"}, {re: /[\xC7-\xE7]/g, ch: "c"}, {re: /[\xD1]/g, ch: "N"}, {re: /[\xF1]/g, ch: "n"} ]; $.each(rExps, function () { text = text.replace(this.re, this.ch); }); return text; }
javascript
function normalizeToBase(text) { var rExps = [ {re: /[\xC0-\xC6]/g, ch: "A"}, {re: /[\xE0-\xE6]/g, ch: "a"}, {re: /[\xC8-\xCB]/g, ch: "E"}, {re: /[\xE8-\xEB]/g, ch: "e"}, {re: /[\xCC-\xCF]/g, ch: "I"}, {re: /[\xEC-\xEF]/g, ch: "i"}, {re: /[\xD2-\xD6]/g, ch: "O"}, {re: /[\xF2-\xF6]/g, ch: "o"}, {re: /[\xD9-\xDC]/g, ch: "U"}, {re: /[\xF9-\xFC]/g, ch: "u"}, {re: /[\xC7-\xE7]/g, ch: "c"}, {re: /[\xD1]/g, ch: "N"}, {re: /[\xF1]/g, ch: "n"} ]; $.each(rExps, function () { text = text.replace(this.re, this.ch); }); return text; }
[ "function", "normalizeToBase", "(", "text", ")", "{", "var", "rExps", "=", "[", "{", "re", ":", "/", "[\\xC0-\\xC6]", "/", "g", ",", "ch", ":", "\"A\"", "}", ",", "{", "re", ":", "/", "[\\xE0-\\xE6]", "/", "g", ",", "ch", ":", "\"a\"", "}", ",", "{", "re", ":", "/", "[\\xC8-\\xCB]", "/", "g", ",", "ch", ":", "\"E\"", "}", ",", "{", "re", ":", "/", "[\\xE8-\\xEB]", "/", "g", ",", "ch", ":", "\"e\"", "}", ",", "{", "re", ":", "/", "[\\xCC-\\xCF]", "/", "g", ",", "ch", ":", "\"I\"", "}", ",", "{", "re", ":", "/", "[\\xEC-\\xEF]", "/", "g", ",", "ch", ":", "\"i\"", "}", ",", "{", "re", ":", "/", "[\\xD2-\\xD6]", "/", "g", ",", "ch", ":", "\"O\"", "}", ",", "{", "re", ":", "/", "[\\xF2-\\xF6]", "/", "g", ",", "ch", ":", "\"o\"", "}", ",", "{", "re", ":", "/", "[\\xD9-\\xDC]", "/", "g", ",", "ch", ":", "\"U\"", "}", ",", "{", "re", ":", "/", "[\\xF9-\\xFC]", "/", "g", ",", "ch", ":", "\"u\"", "}", ",", "{", "re", ":", "/", "[\\xC7-\\xE7]", "/", "g", ",", "ch", ":", "\"c\"", "}", ",", "{", "re", ":", "/", "[\\xD1]", "/", "g", ",", "ch", ":", "\"N\"", "}", ",", "{", "re", ":", "/", "[\\xF1]", "/", "g", ",", "ch", ":", "\"n\"", "}", "]", ";", "$", ".", "each", "(", "rExps", ",", "function", "(", ")", "{", "text", "=", "text", ".", "replace", "(", "this", ".", "re", ",", "this", ".", "ch", ")", ";", "}", ")", ";", "return", "text", ";", "}" ]
Remove all diatrics from the given text. @access private @param {String} text @returns {String}
[ "Remove", "all", "diatrics", "from", "the", "given", "text", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/assets/scripts/bootstrap-select1.6/bootstrap-select.js#L37-L57
56,523
cliffano/buildlight
lib/drivers/usbhid.js
UsbHid
function UsbHid() { var vendorId = 0x0fc5; // always 0x0FC5 for Delcom products var productId = 0xb080; // always 0xB080 for Delcom HID device this.device = this._find(vendorId, productId); this.dataMap = { off: '\x00', green: '\x01', red: '\x02', blue: '\x04', yellow: '\x04' }; }
javascript
function UsbHid() { var vendorId = 0x0fc5; // always 0x0FC5 for Delcom products var productId = 0xb080; // always 0xB080 for Delcom HID device this.device = this._find(vendorId, productId); this.dataMap = { off: '\x00', green: '\x01', red: '\x02', blue: '\x04', yellow: '\x04' }; }
[ "function", "UsbHid", "(", ")", "{", "var", "vendorId", "=", "0x0fc5", ";", "// always 0x0FC5 for Delcom products", "var", "productId", "=", "0xb080", ";", "// always 0xB080 for Delcom HID device", "this", ".", "device", "=", "this", ".", "_find", "(", "vendorId", ",", "productId", ")", ";", "this", ".", "dataMap", "=", "{", "off", ":", "'\\x00'", ",", "green", ":", "'\\x01'", ",", "red", ":", "'\\x02'", ",", "blue", ":", "'\\x04'", ",", "yellow", ":", "'\\x04'", "}", ";", "}" ]
class UsbHid UsbHid driver works by writing a colour data or off data to the device. Data values credit to https://github.com/ileitch/delcom_904008_driver/blob/master/delcom_904008.rb Delcom USB HID doc https://www.delcomproducts.com/productdetails.asp?productnum=900000 Delcom Visual Indicator USB HID datasheet https://www.delcomproducts.com/downloads/USBVIHID.pdf
[ "class", "UsbHid", "UsbHid", "driver", "works", "by", "writing", "a", "colour", "data", "or", "off", "data", "to", "the", "device", "." ]
f6b592acf40d58ea8a43882d4e2abe2ad1819179
https://github.com/cliffano/buildlight/blob/f6b592acf40d58ea8a43882d4e2abe2ad1819179/lib/drivers/usbhid.js#L12-L24
56,524
jonesetc/broccoli-anything-to-js
index.js
ToJSFilter
function ToJSFilter (inputTree, options) { if (!(this instanceof ToJSFilter)) { return new ToJSFilter(inputTree, options); } options = options || {}; options.extensions = options.extensions || ['txt']; options.targetExtension = 'js'; Filter.call(this, inputTree, options); this.trimFiles = options.trimFiles || false; }
javascript
function ToJSFilter (inputTree, options) { if (!(this instanceof ToJSFilter)) { return new ToJSFilter(inputTree, options); } options = options || {}; options.extensions = options.extensions || ['txt']; options.targetExtension = 'js'; Filter.call(this, inputTree, options); this.trimFiles = options.trimFiles || false; }
[ "function", "ToJSFilter", "(", "inputTree", ",", "options", ")", "{", "if", "(", "!", "(", "this", "instanceof", "ToJSFilter", ")", ")", "{", "return", "new", "ToJSFilter", "(", "inputTree", ",", "options", ")", ";", "}", "options", "=", "options", "||", "{", "}", ";", "options", ".", "extensions", "=", "options", ".", "extensions", "||", "[", "'txt'", "]", ";", "options", ".", "targetExtension", "=", "'js'", ";", "Filter", ".", "call", "(", "this", ",", "inputTree", ",", "options", ")", ";", "this", ".", "trimFiles", "=", "options", ".", "trimFiles", "||", "false", ";", "}" ]
Take an input tree with text files in it and return them embedded into new JS module files @class @param {string,broccoliTree} inputTree The tree of files to search for appropriate text files @param {object} options The options object
[ "Take", "an", "input", "tree", "with", "text", "files", "in", "it", "and", "return", "them", "embedded", "into", "new", "JS", "module", "files" ]
1cb101f168670c8bfb426d64af42f4c9e39c4539
https://github.com/jonesetc/broccoli-anything-to-js/blob/1cb101f168670c8bfb426d64af42f4c9e39c4539/index.js#L21-L30
56,525
bmancini55/super-prop
lib/super-prop.js
define
function define(scope, Type, name) { var propName = name || 'super' , propInernalName = '_' + propName; Object.defineProperty(scope, propName, { writeable: false, get: function() { if(!this[propInernalName]) { this[propInernalName] = create(this, Type); } return this[propInernalName]; } }); }
javascript
function define(scope, Type, name) { var propName = name || 'super' , propInernalName = '_' + propName; Object.defineProperty(scope, propName, { writeable: false, get: function() { if(!this[propInernalName]) { this[propInernalName] = create(this, Type); } return this[propInernalName]; } }); }
[ "function", "define", "(", "scope", ",", "Type", ",", "name", ")", "{", "var", "propName", "=", "name", "||", "'super'", ",", "propInernalName", "=", "'_'", "+", "propName", ";", "Object", ".", "defineProperty", "(", "scope", ",", "propName", ",", "{", "writeable", ":", "false", ",", "get", ":", "function", "(", ")", "{", "if", "(", "!", "this", "[", "propInernalName", "]", ")", "{", "this", "[", "propInernalName", "]", "=", "create", "(", "this", ",", "Type", ")", ";", "}", "return", "this", "[", "propInernalName", "]", ";", "}", "}", ")", ";", "}" ]
Attaches a `super` property to an object that contains the methods on the supplied Type bound to the current instance. @api public @param {Object} scope - the instance to bind methos to @param {Function} Type - the prototype of the super Type @param {String} [name] - the name of the property, defaults to 'super'
[ "Attaches", "a", "super", "property", "to", "an", "object", "that", "contains", "the", "methods", "on", "the", "supplied", "Type", "bound", "to", "the", "current", "instance", "." ]
6629d6b0a70ebb60fd333f781a459f0e3b43ede0
https://github.com/bmancini55/super-prop/blob/6629d6b0a70ebb60fd333f781a459f0e3b43ede0/lib/super-prop.js#L16-L29
56,526
bmancini55/super-prop
lib/super-prop.js
create
function create(scope, Type) { // make result the constructor var result = function() { Type.apply(scope, arguments); }; // attach methods to result for(var key in Type.prototype) { if(typeof Type.prototype[key] === 'function') { result[key] = Type.prototype[key].bind(scope); } } return result; }
javascript
function create(scope, Type) { // make result the constructor var result = function() { Type.apply(scope, arguments); }; // attach methods to result for(var key in Type.prototype) { if(typeof Type.prototype[key] === 'function') { result[key] = Type.prototype[key].bind(scope); } } return result; }
[ "function", "create", "(", "scope", ",", "Type", ")", "{", "// make result the constructor", "var", "result", "=", "function", "(", ")", "{", "Type", ".", "apply", "(", "scope", ",", "arguments", ")", ";", "}", ";", "// attach methods to result", "for", "(", "var", "key", "in", "Type", ".", "prototype", ")", "{", "if", "(", "typeof", "Type", ".", "prototype", "[", "key", "]", "===", "'function'", ")", "{", "result", "[", "key", "]", "=", "Type", ".", "prototype", "[", "key", "]", ".", "bind", "(", "scope", ")", ";", "}", "}", "return", "result", ";", "}" ]
Creates an object containing methods of the specificed proptotype that will be bound to the supplied scope. This function also creates a constructor property that is a function call for the supplied prototype @api public @param {Object} scope - the instance to bind methos to @param {Function} Type - the prototype of the super Type
[ "Creates", "an", "object", "containing", "methods", "of", "the", "specificed", "proptotype", "that", "will", "be", "bound", "to", "the", "supplied", "scope", ".", "This", "function", "also", "creates", "a", "constructor", "property", "that", "is", "a", "function", "call", "for", "the", "supplied", "prototype" ]
6629d6b0a70ebb60fd333f781a459f0e3b43ede0
https://github.com/bmancini55/super-prop/blob/6629d6b0a70ebb60fd333f781a459f0e3b43ede0/lib/super-prop.js#L44-L59
56,527
hoodiehq-archive/hoodie-plugins-api
lib/databases.js
function (name) { return new DatabaseAPI(hoodie, { name: name, editable_permissions: true, _id: exports.convertID, prepare: exports.prepareDoc, parse: exports.parseDoc }) }
javascript
function (name) { return new DatabaseAPI(hoodie, { name: name, editable_permissions: true, _id: exports.convertID, prepare: exports.prepareDoc, parse: exports.parseDoc }) }
[ "function", "(", "name", ")", "{", "return", "new", "DatabaseAPI", "(", "hoodie", ",", "{", "name", ":", "name", ",", "editable_permissions", ":", "true", ",", "_id", ":", "exports", ".", "convertID", ",", "prepare", ":", "exports", ".", "prepareDoc", ",", "parse", ":", "exports", ".", "parseDoc", "}", ")", "}" ]
Calling this API with a db name returns a new DatabaseAPI object
[ "Calling", "this", "API", "with", "a", "db", "name", "returns", "a", "new", "DatabaseAPI", "object" ]
25eb96a958b64e30f1092f7e06efab2d7e28f8aa
https://github.com/hoodiehq-archive/hoodie-plugins-api/blob/25eb96a958b64e30f1092f7e06efab2d7e28f8aa/lib/databases.js#L85-L93
56,528
genjs/gutil
lib/util/all.js
all
function all(values, keyName) { if(values instanceof Array) { var results = {}; for(var i=0; i<values.length; i++) { var obj2 = values[i]; var res = get(obj2, keyName); if(res != undefined) { results[res] = 0; } } var results2 = []; for(var result in results) { results2.push(result); } return results2; } }
javascript
function all(values, keyName) { if(values instanceof Array) { var results = {}; for(var i=0; i<values.length; i++) { var obj2 = values[i]; var res = get(obj2, keyName); if(res != undefined) { results[res] = 0; } } var results2 = []; for(var result in results) { results2.push(result); } return results2; } }
[ "function", "all", "(", "values", ",", "keyName", ")", "{", "if", "(", "values", "instanceof", "Array", ")", "{", "var", "results", "=", "{", "}", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "values", ".", "length", ";", "i", "++", ")", "{", "var", "obj2", "=", "values", "[", "i", "]", ";", "var", "res", "=", "get", "(", "obj2", ",", "keyName", ")", ";", "if", "(", "res", "!=", "undefined", ")", "{", "results", "[", "res", "]", "=", "0", ";", "}", "}", "var", "results2", "=", "[", "]", ";", "for", "(", "var", "result", "in", "results", ")", "{", "results2", ".", "push", "(", "result", ")", ";", "}", "return", "results2", ";", "}", "}" ]
Get all values from an array if they are an object with a "keyName" attribute. @param values array @param keyName object attribute name @returns {Array}
[ "Get", "all", "values", "from", "an", "array", "if", "they", "are", "an", "object", "with", "a", "keyName", "attribute", "." ]
c2890fdd030bb9f0cad9f5c7c9da442411c3903a
https://github.com/genjs/gutil/blob/c2890fdd030bb9f0cad9f5c7c9da442411c3903a/lib/util/all.js#L9-L25
56,529
robertblackwell/yake
src/yake/main.js
getTasksFromYakefile
function getTasksFromYakefile(cwd, fileOption) { // find the yakefile and load (actually a dynamic 'require') tasks // first create an empty collection - dont need to use the global collection const tc1 = TC.TaskCollection(); //preload const tc2 = TASKS.loadPreloadedTasks(tc1); const yakefileCandidates = Yakefile.defaultFilenames(); if( fileOption !== undefined ) yakefileCandidates = [fileOption]; const yakeFilePath = Yakefile.recursiveFindFile(cwd, yakefileCandidates); if (yakeFilePath === undefined) { const msg = yakefileCandidates.join(); // console.log(util.inspect(yakefileCandidates)); ERROR.raiseError(`cannot find yakefile among : ${msg}`); } const collection = TASKS.requireTasks(yakeFilePath, tc2); return collection; }
javascript
function getTasksFromYakefile(cwd, fileOption) { // find the yakefile and load (actually a dynamic 'require') tasks // first create an empty collection - dont need to use the global collection const tc1 = TC.TaskCollection(); //preload const tc2 = TASKS.loadPreloadedTasks(tc1); const yakefileCandidates = Yakefile.defaultFilenames(); if( fileOption !== undefined ) yakefileCandidates = [fileOption]; const yakeFilePath = Yakefile.recursiveFindFile(cwd, yakefileCandidates); if (yakeFilePath === undefined) { const msg = yakefileCandidates.join(); // console.log(util.inspect(yakefileCandidates)); ERROR.raiseError(`cannot find yakefile among : ${msg}`); } const collection = TASKS.requireTasks(yakeFilePath, tc2); return collection; }
[ "function", "getTasksFromYakefile", "(", "cwd", ",", "fileOption", ")", "{", "// find the yakefile and load (actually a dynamic 'require') tasks", "// first create an empty collection - dont need to use the global collection", "const", "tc1", "=", "TC", ".", "TaskCollection", "(", ")", ";", "//preload ", "const", "tc2", "=", "TASKS", ".", "loadPreloadedTasks", "(", "tc1", ")", ";", "const", "yakefileCandidates", "=", "Yakefile", ".", "defaultFilenames", "(", ")", ";", "if", "(", "fileOption", "!==", "undefined", ")", "yakefileCandidates", "=", "[", "fileOption", "]", ";", "const", "yakeFilePath", "=", "Yakefile", ".", "recursiveFindFile", "(", "cwd", ",", "yakefileCandidates", ")", ";", "if", "(", "yakeFilePath", "===", "undefined", ")", "{", "const", "msg", "=", "yakefileCandidates", ".", "join", "(", ")", ";", "// console.log(util.inspect(yakefileCandidates));", "ERROR", ".", "raiseError", "(", "`", "${", "msg", "}", "`", ")", ";", "}", "const", "collection", "=", "TASKS", ".", "requireTasks", "(", "yakeFilePath", ",", "tc2", ")", ";", "return", "collection", ";", "}" ]
Collects tasks from the appropriate yakefile. @param {string} cwd The directory from which to start searching for a yakefile @param {string|undefined} fileOption The value of the -c or --file option from the command line @return {TaskCollection} The tasks from yakefile.
[ "Collects", "tasks", "from", "the", "appropriate", "yakefile", "." ]
172b02e29303fb718bac88bbda9b85749c57169c
https://github.com/robertblackwell/yake/blob/172b02e29303fb718bac88bbda9b85749c57169c/src/yake/main.js#L25-L48
56,530
robertblackwell/yake
src/yake/main.js
getTasksFromTaskfile
function getTasksFromTaskfile() { // tasks will already be loaded and are in the global collection so get it const tc = TASKS.globals.globalTaskCollection; //this time the preloads come after the custom tasks - no choice const collection = TASKS.loadPreloadedTasks(tc); return collection; }
javascript
function getTasksFromTaskfile() { // tasks will already be loaded and are in the global collection so get it const tc = TASKS.globals.globalTaskCollection; //this time the preloads come after the custom tasks - no choice const collection = TASKS.loadPreloadedTasks(tc); return collection; }
[ "function", "getTasksFromTaskfile", "(", ")", "{", "// tasks will already be loaded and are in the global collection so get it", "const", "tc", "=", "TASKS", ".", "globals", ".", "globalTaskCollection", ";", "//this time the preloads come after the custom tasks - no choice", "const", "collection", "=", "TASKS", ".", "loadPreloadedTasks", "(", "tc", ")", ";", "return", "collection", ";", "}" ]
In taskfile mode the tasks are defined before the mainline gets called through the use of the YAKE.task function. Hence by the time this function gets called those tasks are already in a global collection. So retreived them, add default tasks return the collection @return {TaskCollection} The tasks from taskfile.
[ "In", "taskfile", "mode", "the", "tasks", "are", "defined", "before", "the", "mainline", "gets", "called", "through", "the", "use", "of", "the", "YAKE", ".", "task", "function", ".", "Hence", "by", "the", "time", "this", "function", "gets", "called", "those", "tasks", "are", "already", "in", "a", "global", "collection", ".", "So", "retreived", "them", "add", "default", "tasks", "return", "the", "collection" ]
172b02e29303fb718bac88bbda9b85749c57169c
https://github.com/robertblackwell/yake/blob/172b02e29303fb718bac88bbda9b85749c57169c/src/yake/main.js#L58-L65
56,531
robertblackwell/yake
src/yake/main.js
getTasksFromArray
function getTasksFromArray(cfgArray) { const tc = TC.TaskCollection(); // tasks are defined in a datascripture - load it const tc2 = TASKS.loadTasksFromArray(cfgArray, tc); //this time the preloads come after the custom tasks - could have done it the other way round const collection = TASKS.loadPreloadedTasks(tc2); return collection; }
javascript
function getTasksFromArray(cfgArray) { const tc = TC.TaskCollection(); // tasks are defined in a datascripture - load it const tc2 = TASKS.loadTasksFromArray(cfgArray, tc); //this time the preloads come after the custom tasks - could have done it the other way round const collection = TASKS.loadPreloadedTasks(tc2); return collection; }
[ "function", "getTasksFromArray", "(", "cfgArray", ")", "{", "const", "tc", "=", "TC", ".", "TaskCollection", "(", ")", ";", "// tasks are defined in a datascripture - load it", "const", "tc2", "=", "TASKS", ".", "loadTasksFromArray", "(", "cfgArray", ",", "tc", ")", ";", "//this time the preloads come after the custom tasks - could have done it the other way round", "const", "collection", "=", "TASKS", ".", "loadPreloadedTasks", "(", "tc2", ")", ";", "return", "collection", ";", "}" ]
IN cfg array use a data structure will have the task definitions. This will be passed to this function @param {array} cfgArray The configuration array @return {TaskCollection} The tasks from array.
[ "IN", "cfg", "array", "use", "a", "data", "structure", "will", "have", "the", "task", "definitions", ".", "This", "will", "be", "passed", "to", "this", "function" ]
172b02e29303fb718bac88bbda9b85749c57169c
https://github.com/robertblackwell/yake/blob/172b02e29303fb718bac88bbda9b85749c57169c/src/yake/main.js#L74-L82
56,532
robertblackwell/yake
src/yake/main.js
tryShowTasks
function tryShowTasks(options, collection) { if (options.getValueFor('showTasks') !== undefined) { REPORTS.printTaskList(collection); return true; } return false; }
javascript
function tryShowTasks(options, collection) { if (options.getValueFor('showTasks') !== undefined) { REPORTS.printTaskList(collection); return true; } return false; }
[ "function", "tryShowTasks", "(", "options", ",", "collection", ")", "{", "if", "(", "options", ".", "getValueFor", "(", "'showTasks'", ")", "!==", "undefined", ")", "{", "REPORTS", ".", "printTaskList", "(", "collection", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Tests command line options for 'showTasks' value. If true reports all tasks and descriptions and returns true to indicate it did something @param {CliOptions} options The options @param {TaskCollection} collection The tasks to displays
[ "Tests", "command", "line", "options", "for", "showTasks", "value", ".", "If", "true", "reports", "all", "tasks", "and", "descriptions", "and", "returns", "true", "to", "indicate", "it", "did", "something" ]
172b02e29303fb718bac88bbda9b85749c57169c
https://github.com/robertblackwell/yake/blob/172b02e29303fb718bac88bbda9b85749c57169c/src/yake/main.js#L91-L99
56,533
robertblackwell/yake
src/yake/main.js
tryRunTask
function tryRunTask(args, collection) { let nameOfTaskToRun = 'default'; const a = args.getArgs(); if (a.length > 0) { nameOfTaskToRun = a[0]; } const firstTask = collection.getByName(nameOfTaskToRun); if (firstTask === undefined) { // console.log('ERROR'); ERROR.raiseError(`task ${nameOfTaskToRun} not found`); } TASKS.invokeTask(collection, firstTask); // console.log(chalk.white.bold(`${firstTask.name()} - completed `) + chalk.green.bold('OK')); }
javascript
function tryRunTask(args, collection) { let nameOfTaskToRun = 'default'; const a = args.getArgs(); if (a.length > 0) { nameOfTaskToRun = a[0]; } const firstTask = collection.getByName(nameOfTaskToRun); if (firstTask === undefined) { // console.log('ERROR'); ERROR.raiseError(`task ${nameOfTaskToRun} not found`); } TASKS.invokeTask(collection, firstTask); // console.log(chalk.white.bold(`${firstTask.name()} - completed `) + chalk.green.bold('OK')); }
[ "function", "tryRunTask", "(", "args", ",", "collection", ")", "{", "let", "nameOfTaskToRun", "=", "'default'", ";", "const", "a", "=", "args", ".", "getArgs", "(", ")", ";", "if", "(", "a", ".", "length", ">", "0", ")", "{", "nameOfTaskToRun", "=", "a", "[", "0", "]", ";", "}", "const", "firstTask", "=", "collection", ".", "getByName", "(", "nameOfTaskToRun", ")", ";", "if", "(", "firstTask", "===", "undefined", ")", "{", "// console.log('ERROR');", "ERROR", ".", "raiseError", "(", "`", "${", "nameOfTaskToRun", "}", "`", ")", ";", "}", "TASKS", ".", "invokeTask", "(", "collection", ",", "firstTask", ")", ";", "// console.log(chalk.white.bold(`${firstTask.name()} - completed `) + chalk.green.bold('OK'));", "}" ]
Looks in the CliArguments parameter and if any strings are found tries to execute those as task names and of course the prerequisites @param {CliArguments} args - The arguments @param {TaskCollection} collection - The collection of tasks from which original taska and prerequisistes will come
[ "Looks", "in", "the", "CliArguments", "parameter", "and", "if", "any", "strings", "are", "found", "tries", "to", "execute", "those", "as", "task", "names", "and", "of", "course", "the", "prerequisites" ]
172b02e29303fb718bac88bbda9b85749c57169c
https://github.com/robertblackwell/yake/blob/172b02e29303fb718bac88bbda9b85749c57169c/src/yake/main.js#L136-L155
56,534
robertblackwell/yake
src/yake/main.js
taskFileMain
function taskFileMain(argv) { if( argv === undefined ) argv = process.argv const [options, args, helpText] = CLI.taskFileParse(argv); const collection = getTasksFromTaskfile(); const p = loadPackageJson(); if( tryShowVersion(options, p.version) ) return; if( tryShowTasks(options, collection) ) return; if( tryShowHelp(options, helpText) ) return; tryRunTask(args, collection); }
javascript
function taskFileMain(argv) { if( argv === undefined ) argv = process.argv const [options, args, helpText] = CLI.taskFileParse(argv); const collection = getTasksFromTaskfile(); const p = loadPackageJson(); if( tryShowVersion(options, p.version) ) return; if( tryShowTasks(options, collection) ) return; if( tryShowHelp(options, helpText) ) return; tryRunTask(args, collection); }
[ "function", "taskFileMain", "(", "argv", ")", "{", "if", "(", "argv", "===", "undefined", ")", "argv", "=", "process", ".", "argv", "const", "[", "options", ",", "args", ",", "helpText", "]", "=", "CLI", ".", "taskFileParse", "(", "argv", ")", ";", "const", "collection", "=", "getTasksFromTaskfile", "(", ")", ";", "const", "p", "=", "loadPackageJson", "(", ")", ";", "if", "(", "tryShowVersion", "(", "options", ",", "p", ".", "version", ")", ")", "return", ";", "if", "(", "tryShowTasks", "(", "options", ",", "collection", ")", ")", "return", ";", "if", "(", "tryShowHelp", "(", "options", ",", "helpText", ")", ")", "return", ";", "tryRunTask", "(", "args", ",", "collection", ")", ";", "}" ]
The mainline of a taskfile. Only depends on the options and arguments on the command line @param {Function} argv The argv
[ "The", "mainline", "of", "a", "taskfile", ".", "Only", "depends", "on", "the", "options", "and", "arguments", "on", "the", "command", "line" ]
172b02e29303fb718bac88bbda9b85749c57169c
https://github.com/robertblackwell/yake/blob/172b02e29303fb718bac88bbda9b85749c57169c/src/yake/main.js#L167-L183
56,535
robertblackwell/yake
src/yake/main.js
yakeFileMain
function yakeFileMain(argv, cwd) { if( cwd === undefined) cwd = process.cwd(); if( argv === undefined ) argv = process.argv const [options, args, helpText] = CLI.CliParse(argv); const collection = getTasksFromYakefile(cwd, options.getValueFor('file')); const p = loadPackageJson(); if( tryShowVersion(options, p.version) ) return; if( tryShowTasks(options, collection) ) return; if( tryShowHelp(options, helpText) ) return; tryRunTask(args, collection); }
javascript
function yakeFileMain(argv, cwd) { if( cwd === undefined) cwd = process.cwd(); if( argv === undefined ) argv = process.argv const [options, args, helpText] = CLI.CliParse(argv); const collection = getTasksFromYakefile(cwd, options.getValueFor('file')); const p = loadPackageJson(); if( tryShowVersion(options, p.version) ) return; if( tryShowTasks(options, collection) ) return; if( tryShowHelp(options, helpText) ) return; tryRunTask(args, collection); }
[ "function", "yakeFileMain", "(", "argv", ",", "cwd", ")", "{", "if", "(", "cwd", "===", "undefined", ")", "cwd", "=", "process", ".", "cwd", "(", ")", ";", "if", "(", "argv", "===", "undefined", ")", "argv", "=", "process", ".", "argv", "const", "[", "options", ",", "args", ",", "helpText", "]", "=", "CLI", ".", "CliParse", "(", "argv", ")", ";", "const", "collection", "=", "getTasksFromYakefile", "(", "cwd", ",", "options", ".", "getValueFor", "(", "'file'", ")", ")", ";", "const", "p", "=", "loadPackageJson", "(", ")", ";", "if", "(", "tryShowVersion", "(", "options", ",", "p", ".", "version", ")", ")", "return", ";", "if", "(", "tryShowTasks", "(", "options", ",", "collection", ")", ")", "return", ";", "if", "(", "tryShowHelp", "(", "options", ",", "helpText", ")", ")", "return", ";", "tryRunTask", "(", "args", ",", "collection", ")", ";", "}" ]
The mainline for use in the yake command. Depends on the options and arguments on the command line plus the directory from which to start the search for a yakefile @param {Function} argv The argv
[ "The", "mainline", "for", "use", "in", "the", "yake", "command", ".", "Depends", "on", "the", "options", "and", "arguments", "on", "the", "command", "line", "plus", "the", "directory", "from", "which", "to", "start", "the", "search", "for", "a", "yakefile" ]
172b02e29303fb718bac88bbda9b85749c57169c
https://github.com/robertblackwell/yake/blob/172b02e29303fb718bac88bbda9b85749c57169c/src/yake/main.js#L191-L208
56,536
leocornus/leocornus-visualdata
src/visual-data.js
function() { var self = this; var insightsPanel = self.buildInsightsPanel(); var media = insightsPanel + '<div class="media">' + ' <div class="media-left">' + // the visual chart as media-object. ' <div class="media-object" id="' + self.getId('chart') + '">Charts</div>' + ' </div>' + ' <div class="media-body">' + ' <div id="' + self.getId('summary') + '">Summary</div>' + ' </div>' + '</div>'; $('#' + self.attrId).html(media); }
javascript
function() { var self = this; var insightsPanel = self.buildInsightsPanel(); var media = insightsPanel + '<div class="media">' + ' <div class="media-left">' + // the visual chart as media-object. ' <div class="media-object" id="' + self.getId('chart') + '">Charts</div>' + ' </div>' + ' <div class="media-body">' + ' <div id="' + self.getId('summary') + '">Summary</div>' + ' </div>' + '</div>'; $('#' + self.attrId).html(media); }
[ "function", "(", ")", "{", "var", "self", "=", "this", ";", "var", "insightsPanel", "=", "self", ".", "buildInsightsPanel", "(", ")", ";", "var", "media", "=", "insightsPanel", "+", "'<div class=\"media\">'", "+", "' <div class=\"media-left\">'", "+", "// the visual chart as media-object.", "' <div class=\"media-object\" id=\"'", "+", "self", ".", "getId", "(", "'chart'", ")", "+", "'\">Charts</div>'", "+", "' </div>'", "+", "' <div class=\"media-body\">'", "+", "' <div id=\"'", "+", "self", ".", "getId", "(", "'summary'", ")", "+", "'\">Summary</div>'", "+", "' </div>'", "+", "'</div>'", ";", "$", "(", "'#'", "+", "self", ".", "attrId", ")", ".", "html", "(", "media", ")", ";", "}" ]
build the dashboard as media object. build the chart, using corresponding jQuery plugins create the summary
[ "build", "the", "dashboard", "as", "media", "object", "." ]
9d9714ca11c126f0250e650f3c1c4086709af3ab
https://github.com/leocornus/leocornus-visualdata/blob/9d9714ca11c126f0250e650f3c1c4086709af3ab/src/visual-data.js#L439-L458
56,537
leocornus/leocornus-visualdata
src/visual-data.js
function() { var self = this; var panel = '<div class="panel panel-success">' + ' <div class="panel-heading">' + ' visual data dashboard mockups' + ' </div>' + ' <div class="panel-body">' + ' <div class="row">' + // the visual chart. ' <div class="col-md-8">' + ' <div id="' + self.getId('chart') + '">Charts</div>' + ' </div>' + // the information column ' <div class="col-md-4">' + ' <div id="' + self.getId('summary') + '">Summary</div>' + ' </div>' + ' </div>' + ' </div>' + ' <div class="panel-footer">' + ' visual data footer mockups' + ' </div>' + '</div>'; $('#' + self.attrId).html(panel); // Draw the chart, $('#' + self.getId('chart')).html('') .bilevelSunburst({date: self.options.date}, self.treemapData); }
javascript
function() { var self = this; var panel = '<div class="panel panel-success">' + ' <div class="panel-heading">' + ' visual data dashboard mockups' + ' </div>' + ' <div class="panel-body">' + ' <div class="row">' + // the visual chart. ' <div class="col-md-8">' + ' <div id="' + self.getId('chart') + '">Charts</div>' + ' </div>' + // the information column ' <div class="col-md-4">' + ' <div id="' + self.getId('summary') + '">Summary</div>' + ' </div>' + ' </div>' + ' </div>' + ' <div class="panel-footer">' + ' visual data footer mockups' + ' </div>' + '</div>'; $('#' + self.attrId).html(panel); // Draw the chart, $('#' + self.getId('chart')).html('') .bilevelSunburst({date: self.options.date}, self.treemapData); }
[ "function", "(", ")", "{", "var", "self", "=", "this", ";", "var", "panel", "=", "'<div class=\"panel panel-success\">'", "+", "' <div class=\"panel-heading\">'", "+", "' visual data dashboard mockups'", "+", "' </div>'", "+", "' <div class=\"panel-body\">'", "+", "' <div class=\"row\">'", "+", "// the visual chart.", "' <div class=\"col-md-8\">'", "+", "' <div id=\"'", "+", "self", ".", "getId", "(", "'chart'", ")", "+", "'\">Charts</div>'", "+", "' </div>'", "+", "// the information column", "' <div class=\"col-md-4\">'", "+", "' <div id=\"'", "+", "self", ".", "getId", "(", "'summary'", ")", "+", "'\">Summary</div>'", "+", "' </div>'", "+", "' </div>'", "+", "' </div>'", "+", "' <div class=\"panel-footer\">'", "+", "' visual data footer mockups'", "+", "' </div>'", "+", "'</div>'", ";", "$", "(", "'#'", "+", "self", ".", "attrId", ")", ".", "html", "(", "panel", ")", ";", "// Draw the chart,", "$", "(", "'#'", "+", "self", ".", "getId", "(", "'chart'", ")", ")", ".", "html", "(", "''", ")", ".", "bilevelSunburst", "(", "{", "date", ":", "self", ".", "options", ".", "date", "}", ",", "self", ".", "treemapData", ")", ";", "}" ]
build the panel as dashboard. Where is data from? build the chart, using corresponding jQuery plugins create the summary FIXME: panel class NOT working well with z-index. panel class seems overlap the z-index most time.
[ "build", "the", "panel", "as", "dashboard", ".", "Where", "is", "data", "from?" ]
9d9714ca11c126f0250e650f3c1c4086709af3ab
https://github.com/leocornus/leocornus-visualdata/blob/9d9714ca11c126f0250e650f3c1c4086709af3ab/src/visual-data.js#L470-L502
56,538
leocornus/leocornus-visualdata
src/visual-data.js
function() { var self = this; // Draw the chart, $('#' + self.getId('chart')).html('') .bilevelSunburst({date: self.options.date}, self.treemapData); }
javascript
function() { var self = this; // Draw the chart, $('#' + self.getId('chart')).html('') .bilevelSunburst({date: self.options.date}, self.treemapData); }
[ "function", "(", ")", "{", "var", "self", "=", "this", ";", "// Draw the chart,", "$", "(", "'#'", "+", "self", ".", "getId", "(", "'chart'", ")", ")", ".", "html", "(", "''", ")", ".", "bilevelSunburst", "(", "{", "date", ":", "self", ".", "options", ".", "date", "}", ",", "self", ".", "treemapData", ")", ";", "}" ]
create this utility function to draw chart, we could use it whenever we need. For example, after we re-arrange the dashboard, we will need re-draw the chart. the chart will re-calculate all positions.
[ "create", "this", "utility", "function", "to", "draw", "chart", "we", "could", "use", "it", "whenever", "we", "need", ".", "For", "example", "after", "we", "re", "-", "arrange", "the", "dashboard", "we", "will", "need", "re", "-", "draw", "the", "chart", ".", "the", "chart", "will", "re", "-", "calculate", "all", "positions", "." ]
9d9714ca11c126f0250e650f3c1c4086709af3ab
https://github.com/leocornus/leocornus-visualdata/blob/9d9714ca11c126f0250e650f3c1c4086709af3ab/src/visual-data.js#L511-L519
56,539
leocornus/leocornus-visualdata
src/visual-data.js
function() { var self = this; var summary = self.tableSummaryBuilder(self.groupsSummary, self.pagesSummary, self.total); $('#' + self.getId('summary')).html(summary); }
javascript
function() { var self = this; var summary = self.tableSummaryBuilder(self.groupsSummary, self.pagesSummary, self.total); $('#' + self.getId('summary')).html(summary); }
[ "function", "(", ")", "{", "var", "self", "=", "this", ";", "var", "summary", "=", "self", ".", "tableSummaryBuilder", "(", "self", ".", "groupsSummary", ",", "self", ".", "pagesSummary", ",", "self", ".", "total", ")", ";", "$", "(", "'#'", "+", "self", ".", "getId", "(", "'summary'", ")", ")", ".", "html", "(", "summary", ")", ";", "}" ]
utility function to build summary. TODO: this should allow developer to customize!
[ "utility", "function", "to", "build", "summary", "." ]
9d9714ca11c126f0250e650f3c1c4086709af3ab
https://github.com/leocornus/leocornus-visualdata/blob/9d9714ca11c126f0250e650f3c1c4086709af3ab/src/visual-data.js#L526-L535
56,540
leocornus/leocornus-visualdata
src/visual-data.js
function(groupName, totalSites, totalPages, totalPageviews) { var format = d3.format(',d'); // build var summary = '<tr>' + '<td>' + groupName + '</td>' + '<td>' + format(totalPageviews) + '</td>' + '<td>' + format(totalPages) + '</td>' + //'<td>' + totalSites + '</td>' + '</tr>'; return summary; }
javascript
function(groupName, totalSites, totalPages, totalPageviews) { var format = d3.format(',d'); // build var summary = '<tr>' + '<td>' + groupName + '</td>' + '<td>' + format(totalPageviews) + '</td>' + '<td>' + format(totalPages) + '</td>' + //'<td>' + totalSites + '</td>' + '</tr>'; return summary; }
[ "function", "(", "groupName", ",", "totalSites", ",", "totalPages", ",", "totalPageviews", ")", "{", "var", "format", "=", "d3", ".", "format", "(", "',d'", ")", ";", "// build", "var", "summary", "=", "'<tr>'", "+", "'<td>'", "+", "groupName", "+", "'</td>'", "+", "'<td>'", "+", "format", "(", "totalPageviews", ")", "+", "'</td>'", "+", "'<td>'", "+", "format", "(", "totalPages", ")", "+", "'</td>'", "+", "//'<td>' + totalSites + '</td>' +", "'</tr>'", ";", "return", "summary", ";", "}" ]
build row for each table.. <tr> <td>MOF</td> <td>2089</td> <td>345</td> </tr>
[ "build", "row", "for", "each", "table", ".." ]
9d9714ca11c126f0250e650f3c1c4086709af3ab
https://github.com/leocornus/leocornus-visualdata/blob/9d9714ca11c126f0250e650f3c1c4086709af3ab/src/visual-data.js#L651-L664
56,541
leocornus/leocornus-visualdata
src/visual-data.js
function() { var self = this; if(this.options.insightsFeeder) { // use the customize insights feeder self.options.insightsFeeder(self); } else { // using the default insights feeder. self.defaultInsightsFeeder(self); } }
javascript
function() { var self = this; if(this.options.insightsFeeder) { // use the customize insights feeder self.options.insightsFeeder(self); } else { // using the default insights feeder. self.defaultInsightsFeeder(self); } }
[ "function", "(", ")", "{", "var", "self", "=", "this", ";", "if", "(", "this", ".", "options", ".", "insightsFeeder", ")", "{", "// use the customize insights feeder", "self", ".", "options", ".", "insightsFeeder", "(", "self", ")", ";", "}", "else", "{", "// using the default insights feeder.", "self", ".", "defaultInsightsFeeder", "(", "self", ")", ";", "}", "}" ]
feed insights.
[ "feed", "insights", "." ]
9d9714ca11c126f0250e650f3c1c4086709af3ab
https://github.com/leocornus/leocornus-visualdata/blob/9d9714ca11c126f0250e650f3c1c4086709af3ab/src/visual-data.js#L707-L718
56,542
leocornus/leocornus-visualdata
src/visual-data.js
function(visualData) { var insightsList = '<li class="list-group-item">The site served' + ' <strong>' + visualData.total[0] + '</strong> total pageviews on' + ' <strong>' + visualData.total[1] + '</strong> pages of' + ' <strong>' + visualData.total[2] + '</strong> sites' + '</li>' + // the first group '<li class="list-group-item">The No. 1 group is <strong>' + visualData.groupsPageviews[0][0] + '</strong>, which has <strong>' + visualData.groupsPageviews[0][1] + '</strong> pageviews' + '</li>' + // the most viewed single page '<li class="list-group-item">The most views single page is <strong>' + visualData.jsonData[0][0] + '</strong>, which has <strong>' + visualData.jsonData[0][2] + '</strong> pageviews' + '</li>'; $('#' + visualData.getId('insightsList')).html(insightsList); }
javascript
function(visualData) { var insightsList = '<li class="list-group-item">The site served' + ' <strong>' + visualData.total[0] + '</strong> total pageviews on' + ' <strong>' + visualData.total[1] + '</strong> pages of' + ' <strong>' + visualData.total[2] + '</strong> sites' + '</li>' + // the first group '<li class="list-group-item">The No. 1 group is <strong>' + visualData.groupsPageviews[0][0] + '</strong>, which has <strong>' + visualData.groupsPageviews[0][1] + '</strong> pageviews' + '</li>' + // the most viewed single page '<li class="list-group-item">The most views single page is <strong>' + visualData.jsonData[0][0] + '</strong>, which has <strong>' + visualData.jsonData[0][2] + '</strong> pageviews' + '</li>'; $('#' + visualData.getId('insightsList')).html(insightsList); }
[ "function", "(", "visualData", ")", "{", "var", "insightsList", "=", "'<li class=\"list-group-item\">The site served'", "+", "' <strong>'", "+", "visualData", ".", "total", "[", "0", "]", "+", "'</strong> total pageviews on'", "+", "' <strong>'", "+", "visualData", ".", "total", "[", "1", "]", "+", "'</strong> pages of'", "+", "' <strong>'", "+", "visualData", ".", "total", "[", "2", "]", "+", "'</strong> sites'", "+", "'</li>'", "+", "// the first group", "'<li class=\"list-group-item\">The No. 1 group is <strong>'", "+", "visualData", ".", "groupsPageviews", "[", "0", "]", "[", "0", "]", "+", "'</strong>, which has <strong>'", "+", "visualData", ".", "groupsPageviews", "[", "0", "]", "[", "1", "]", "+", "'</strong> pageviews'", "+", "'</li>'", "+", "// the most viewed single page", "'<li class=\"list-group-item\">The most views single page is <strong>'", "+", "visualData", ".", "jsonData", "[", "0", "]", "[", "0", "]", "+", "'</strong>, which has <strong>'", "+", "visualData", ".", "jsonData", "[", "0", "]", "[", "2", "]", "+", "'</strong> pageviews'", "+", "'</li>'", ";", "$", "(", "'#'", "+", "visualData", ".", "getId", "(", "'insightsList'", ")", ")", ".", "html", "(", "insightsList", ")", ";", "}" ]
the default Insights feeder.
[ "the", "default", "Insights", "feeder", "." ]
9d9714ca11c126f0250e650f3c1c4086709af3ab
https://github.com/leocornus/leocornus-visualdata/blob/9d9714ca11c126f0250e650f3c1c4086709af3ab/src/visual-data.js#L723-L743
56,543
michaelnisi/speculum
example.js
run
function run (x, cb) { const s = speculum(null, Echo, x) s.on('end', cb) s.on('error', cb) const reader = new Count({ highWaterMark: 0 }, 10) reader.pipe(s).resume() }
javascript
function run (x, cb) { const s = speculum(null, Echo, x) s.on('end', cb) s.on('error', cb) const reader = new Count({ highWaterMark: 0 }, 10) reader.pipe(s).resume() }
[ "function", "run", "(", "x", ",", "cb", ")", "{", "const", "s", "=", "speculum", "(", "null", ",", "Echo", ",", "x", ")", "s", ".", "on", "(", "'end'", ",", "cb", ")", "s", ".", "on", "(", "'error'", ",", "cb", ")", "const", "reader", "=", "new", "Count", "(", "{", "highWaterMark", ":", "0", "}", ",", "10", ")", "reader", ".", "pipe", "(", "s", ")", ".", "resume", "(", ")", "}" ]
Leverage x streams to transform, delayed echoing in this example, data from our readable stream.
[ "Leverage", "x", "streams", "to", "transform", "delayed", "echoing", "in", "this", "example", "data", "from", "our", "readable", "stream", "." ]
b98bfbab7ab3cf57c959967afbdf803c34abf6a6
https://github.com/michaelnisi/speculum/blob/b98bfbab7ab3cf57c959967afbdf803c34abf6a6/example.js#L44-L52
56,544
byu-oit/fully-typed
bin/schema.js
Schema
function Schema(config, data) { const controllers = data.controllers; const length = controllers.length; this.FullyTyped = FullyTyped; // apply controllers to this schema for (let i = 0; i < length; i++) controllers[i].call(this, config); // add additional properties if (config._extension_ && typeof config._extension_ === 'object') { const self = this; Object.keys(config._extension_).forEach(function(key) { self[key] = config._extension_[key]; }); } // store protected data with schema const protect = Object.assign({}, data); // create and store hash const options = getNormalizedSchemaConfiguration(this); protect.hash = crypto .createHash('sha256') .update(JSON.stringify(prepareForHash(options))) .digest('hex'); instances.set(this, protect); /** * @name Schema#config * @type {object} */ Object.defineProperty(this, 'config', { get: function() { return util.copy(config); } }); }
javascript
function Schema(config, data) { const controllers = data.controllers; const length = controllers.length; this.FullyTyped = FullyTyped; // apply controllers to this schema for (let i = 0; i < length; i++) controllers[i].call(this, config); // add additional properties if (config._extension_ && typeof config._extension_ === 'object') { const self = this; Object.keys(config._extension_).forEach(function(key) { self[key] = config._extension_[key]; }); } // store protected data with schema const protect = Object.assign({}, data); // create and store hash const options = getNormalizedSchemaConfiguration(this); protect.hash = crypto .createHash('sha256') .update(JSON.stringify(prepareForHash(options))) .digest('hex'); instances.set(this, protect); /** * @name Schema#config * @type {object} */ Object.defineProperty(this, 'config', { get: function() { return util.copy(config); } }); }
[ "function", "Schema", "(", "config", ",", "data", ")", "{", "const", "controllers", "=", "data", ".", "controllers", ";", "const", "length", "=", "controllers", ".", "length", ";", "this", ".", "FullyTyped", "=", "FullyTyped", ";", "// apply controllers to this schema", "for", "(", "let", "i", "=", "0", ";", "i", "<", "length", ";", "i", "++", ")", "controllers", "[", "i", "]", ".", "call", "(", "this", ",", "config", ")", ";", "// add additional properties", "if", "(", "config", ".", "_extension_", "&&", "typeof", "config", ".", "_extension_", "===", "'object'", ")", "{", "const", "self", "=", "this", ";", "Object", ".", "keys", "(", "config", ".", "_extension_", ")", ".", "forEach", "(", "function", "(", "key", ")", "{", "self", "[", "key", "]", "=", "config", ".", "_extension_", "[", "key", "]", ";", "}", ")", ";", "}", "// store protected data with schema", "const", "protect", "=", "Object", ".", "assign", "(", "{", "}", ",", "data", ")", ";", "// create and store hash", "const", "options", "=", "getNormalizedSchemaConfiguration", "(", "this", ")", ";", "protect", ".", "hash", "=", "crypto", ".", "createHash", "(", "'sha256'", ")", ".", "update", "(", "JSON", ".", "stringify", "(", "prepareForHash", "(", "options", ")", ")", ")", ".", "digest", "(", "'hex'", ")", ";", "instances", ".", "set", "(", "this", ",", "protect", ")", ";", "/**\n * @name Schema#config\n * @type {object}\n */", "Object", ".", "defineProperty", "(", "this", ",", "'config'", ",", "{", "get", ":", "function", "(", ")", "{", "return", "util", ".", "copy", "(", "config", ")", ";", "}", "}", ")", ";", "}" ]
Create a schema instance. @param {Object} config The configuration for the schema. @param {ControllerData} data @constructor
[ "Create", "a", "schema", "instance", "." ]
ed6b3ed88ffc72990acffb765232eaaee261afef
https://github.com/byu-oit/fully-typed/blob/ed6b3ed88ffc72990acffb765232eaaee261afef/bin/schema.js#L32-L69
56,545
victorherraiz/xreq
index.js
build
function build(base, config) { var result = resolver(base); Object.keys(config).forEach(function (key) { var value = config[key]; if (typeof value === "string") { result[key] = resolver(result(value, true)); } else if (Array.isArray(value) && value.length === 2 && typeof value[0] === "string" && typeof value[1] === "object") { result[key] = build(result(value[0], true), value[1]); } else { throw new TypeError("Invalid value at: " + key); } }); return result; }
javascript
function build(base, config) { var result = resolver(base); Object.keys(config).forEach(function (key) { var value = config[key]; if (typeof value === "string") { result[key] = resolver(result(value, true)); } else if (Array.isArray(value) && value.length === 2 && typeof value[0] === "string" && typeof value[1] === "object") { result[key] = build(result(value[0], true), value[1]); } else { throw new TypeError("Invalid value at: " + key); } }); return result; }
[ "function", "build", "(", "base", ",", "config", ")", "{", "var", "result", "=", "resolver", "(", "base", ")", ";", "Object", ".", "keys", "(", "config", ")", ".", "forEach", "(", "function", "(", "key", ")", "{", "var", "value", "=", "config", "[", "key", "]", ";", "if", "(", "typeof", "value", "===", "\"string\"", ")", "{", "result", "[", "key", "]", "=", "resolver", "(", "result", "(", "value", ",", "true", ")", ")", ";", "}", "else", "if", "(", "Array", ".", "isArray", "(", "value", ")", "&&", "value", ".", "length", "===", "2", "&&", "typeof", "value", "[", "0", "]", "===", "\"string\"", "&&", "typeof", "value", "[", "1", "]", "===", "\"object\"", ")", "{", "result", "[", "key", "]", "=", "build", "(", "result", "(", "value", "[", "0", "]", ",", "true", ")", ",", "value", "[", "1", "]", ")", ";", "}", "else", "{", "throw", "new", "TypeError", "(", "\"Invalid value at: \"", "+", "key", ")", ";", "}", "}", ")", ";", "return", "result", ";", "}" ]
Process configuration file
[ "Process", "configuration", "file" ]
fa45fd135753bb4295dbc87ddcad5c9f1fd47bba
https://github.com/victorherraiz/xreq/blob/fa45fd135753bb4295dbc87ddcad5c9f1fd47bba/index.js#L48-L62
56,546
groundwater/node-lib-http-rpc
index.js
populateApiFromInterface
function populateApiFromInterface(api, iface) { Object.keys(iface).forEach(function (key) { api.add(key, iface[key]); }); }
javascript
function populateApiFromInterface(api, iface) { Object.keys(iface).forEach(function (key) { api.add(key, iface[key]); }); }
[ "function", "populateApiFromInterface", "(", "api", ",", "iface", ")", "{", "Object", ".", "keys", "(", "iface", ")", ".", "forEach", "(", "function", "(", "key", ")", "{", "api", ".", "add", "(", "key", ",", "iface", "[", "key", "]", ")", ";", "}", ")", ";", "}" ]
fill api from interface
[ "fill", "api", "from", "interface" ]
02dc58fad64a80184b22886417e1e1701667716b
https://github.com/groundwater/node-lib-http-rpc/blob/02dc58fad64a80184b22886417e1e1701667716b/index.js#L138-L142
56,547
groundwater/node-lib-http-rpc
index.js
router
function router(rpc, handlers, req, res) { var $ = rpc.$; var api = rpc.api; var request = api.handle(req.method, req.url); var dom = domain.create(); // the request handler doesn't exit // TODO: hoist response logic if (!request) { res.statusCode = 404; res.end(); return; } var context = new Context(); // TODO: hoist to own module var handle = request.handle; var params = {}; // TODO: hoist logic to 'union' module var key; for(key in request.params) params[key] = request.params[key]; for(key in request.query) params[key] = request.query[key]; var future = $.future(); future.setWritable(res); future.setReadable(req); // TODO: extract request making logic res.setHeader('Transfer-Encoding' , 'chunked'); res.setHeader('Content-Type' , 'application/json'); dom.on('error', function (err) { var statusCode = err.statusCode; // only catch known errors, re-throw unexpected errors if (!statusCode) throw err; // TODO: hoist response logic res.statusCode = statusCode; res.write(JSON.stringify(err)); res.end(); }); // domain should handle all route errors dom.run(function () { handlers[handle](future, params, context); }); }
javascript
function router(rpc, handlers, req, res) { var $ = rpc.$; var api = rpc.api; var request = api.handle(req.method, req.url); var dom = domain.create(); // the request handler doesn't exit // TODO: hoist response logic if (!request) { res.statusCode = 404; res.end(); return; } var context = new Context(); // TODO: hoist to own module var handle = request.handle; var params = {}; // TODO: hoist logic to 'union' module var key; for(key in request.params) params[key] = request.params[key]; for(key in request.query) params[key] = request.query[key]; var future = $.future(); future.setWritable(res); future.setReadable(req); // TODO: extract request making logic res.setHeader('Transfer-Encoding' , 'chunked'); res.setHeader('Content-Type' , 'application/json'); dom.on('error', function (err) { var statusCode = err.statusCode; // only catch known errors, re-throw unexpected errors if (!statusCode) throw err; // TODO: hoist response logic res.statusCode = statusCode; res.write(JSON.stringify(err)); res.end(); }); // domain should handle all route errors dom.run(function () { handlers[handle](future, params, context); }); }
[ "function", "router", "(", "rpc", ",", "handlers", ",", "req", ",", "res", ")", "{", "var", "$", "=", "rpc", ".", "$", ";", "var", "api", "=", "rpc", ".", "api", ";", "var", "request", "=", "api", ".", "handle", "(", "req", ".", "method", ",", "req", ".", "url", ")", ";", "var", "dom", "=", "domain", ".", "create", "(", ")", ";", "// the request handler doesn't exit", "// TODO: hoist response logic", "if", "(", "!", "request", ")", "{", "res", ".", "statusCode", "=", "404", ";", "res", ".", "end", "(", ")", ";", "return", ";", "}", "var", "context", "=", "new", "Context", "(", ")", ";", "// TODO: hoist to own module", "var", "handle", "=", "request", ".", "handle", ";", "var", "params", "=", "{", "}", ";", "// TODO: hoist logic to 'union' module", "var", "key", ";", "for", "(", "key", "in", "request", ".", "params", ")", "params", "[", "key", "]", "=", "request", ".", "params", "[", "key", "]", ";", "for", "(", "key", "in", "request", ".", "query", ")", "params", "[", "key", "]", "=", "request", ".", "query", "[", "key", "]", ";", "var", "future", "=", "$", ".", "future", "(", ")", ";", "future", ".", "setWritable", "(", "res", ")", ";", "future", ".", "setReadable", "(", "req", ")", ";", "// TODO: extract request making logic", "res", ".", "setHeader", "(", "'Transfer-Encoding'", ",", "'chunked'", ")", ";", "res", ".", "setHeader", "(", "'Content-Type'", ",", "'application/json'", ")", ";", "dom", ".", "on", "(", "'error'", ",", "function", "(", "err", ")", "{", "var", "statusCode", "=", "err", ".", "statusCode", ";", "// only catch known errors, re-throw unexpected errors", "if", "(", "!", "statusCode", ")", "throw", "err", ";", "// TODO: hoist response logic", "res", ".", "statusCode", "=", "statusCode", ";", "res", ".", "write", "(", "JSON", ".", "stringify", "(", "err", ")", ")", ";", "res", ".", "end", "(", ")", ";", "}", ")", ";", "// domain should handle all route errors", "dom", ".", "run", "(", "function", "(", ")", "{", "handlers", "[", "handle", "]", "(", "future", ",", "params", ",", "context", ")", ";", "}", ")", ";", "}" ]
make http router use Function.bind to create a router given an rpc, and set of handlers
[ "make", "http", "router", "use", "Function", ".", "bind", "to", "create", "a", "router", "given", "an", "rpc", "and", "set", "of", "handlers" ]
02dc58fad64a80184b22886417e1e1701667716b
https://github.com/groundwater/node-lib-http-rpc/blob/02dc58fad64a80184b22886417e1e1701667716b/index.js#L146-L194
56,548
nylen/lockd
client/index.js
addSimpleMethod
function addSimpleMethod(name, msg, failureIsError) { LockdClient.prototype[name] = function(objName, cb) { var self = this; self.transport.request(util.format(msg, objName), 1, function(err, lines) { self._processResponseLine(cb, err, lines && lines[0], failureIsError); }); }; }
javascript
function addSimpleMethod(name, msg, failureIsError) { LockdClient.prototype[name] = function(objName, cb) { var self = this; self.transport.request(util.format(msg, objName), 1, function(err, lines) { self._processResponseLine(cb, err, lines && lines[0], failureIsError); }); }; }
[ "function", "addSimpleMethod", "(", "name", ",", "msg", ",", "failureIsError", ")", "{", "LockdClient", ".", "prototype", "[", "name", "]", "=", "function", "(", "objName", ",", "cb", ")", "{", "var", "self", "=", "this", ";", "self", ".", "transport", ".", "request", "(", "util", ".", "format", "(", "msg", ",", "objName", ")", ",", "1", ",", "function", "(", "err", ",", "lines", ")", "{", "self", ".", "_processResponseLine", "(", "cb", ",", "err", ",", "lines", "&&", "lines", "[", "0", "]", ",", "failureIsError", ")", ";", "}", ")", ";", "}", ";", "}" ]
Add a simple method to the client prototype which sends a message to the lockd server and expects a single line back in response.
[ "Add", "a", "simple", "method", "to", "the", "client", "prototype", "which", "sends", "a", "message", "to", "the", "lockd", "server", "and", "expects", "a", "single", "line", "back", "in", "response", "." ]
352e663c81355d5b1b7837ae1afb97d50f39b196
https://github.com/nylen/lockd/blob/352e663c81355d5b1b7837ae1afb97d50f39b196/client/index.js#L49-L57
56,549
ForbesLindesay-Unmaintained/sauce-test
lib/run-single-browser.js
runSingleBrowser
function runSingleBrowser(location, remote, platform, options) { var capabilities = {}; Object.keys(platform).forEach(function (key) { capabilities[key] = platform[key]; }); var extraCapabilities = typeof options.capabilities === 'function' ? options.capabilities(platform) : (options.capabilities || {}); Object.keys(extraCapabilities).forEach(function (key) { capabilities[key] = extraCapabilities[key]; }); return retry(function (err) { var driver = getDriver(remote, capabilities, { mode: 'async', debug: options.debug, httpDebug: options.httpDebug, }); return driver._session().then(function () { return driver; }); }, 4, function (attempt) { return attempt * attempt * 5000; }, {debug: options.debug}).then(function (driver) { return runDriver(location, driver, { name: options.name, jobInfo: typeof options.jobInfo === 'function' ? options.jobInfo(platform) : options.jobInfo, allowExceptions: options.allowExceptions, testComplete: options.testComplete, testPassed: options.testPassed, timeout: options.timeout, debug: options.debug }).then(function (result) { return result; }); }); }
javascript
function runSingleBrowser(location, remote, platform, options) { var capabilities = {}; Object.keys(platform).forEach(function (key) { capabilities[key] = platform[key]; }); var extraCapabilities = typeof options.capabilities === 'function' ? options.capabilities(platform) : (options.capabilities || {}); Object.keys(extraCapabilities).forEach(function (key) { capabilities[key] = extraCapabilities[key]; }); return retry(function (err) { var driver = getDriver(remote, capabilities, { mode: 'async', debug: options.debug, httpDebug: options.httpDebug, }); return driver._session().then(function () { return driver; }); }, 4, function (attempt) { return attempt * attempt * 5000; }, {debug: options.debug}).then(function (driver) { return runDriver(location, driver, { name: options.name, jobInfo: typeof options.jobInfo === 'function' ? options.jobInfo(platform) : options.jobInfo, allowExceptions: options.allowExceptions, testComplete: options.testComplete, testPassed: options.testPassed, timeout: options.timeout, debug: options.debug }).then(function (result) { return result; }); }); }
[ "function", "runSingleBrowser", "(", "location", ",", "remote", ",", "platform", ",", "options", ")", "{", "var", "capabilities", "=", "{", "}", ";", "Object", ".", "keys", "(", "platform", ")", ".", "forEach", "(", "function", "(", "key", ")", "{", "capabilities", "[", "key", "]", "=", "platform", "[", "key", "]", ";", "}", ")", ";", "var", "extraCapabilities", "=", "typeof", "options", ".", "capabilities", "===", "'function'", "?", "options", ".", "capabilities", "(", "platform", ")", ":", "(", "options", ".", "capabilities", "||", "{", "}", ")", ";", "Object", ".", "keys", "(", "extraCapabilities", ")", ".", "forEach", "(", "function", "(", "key", ")", "{", "capabilities", "[", "key", "]", "=", "extraCapabilities", "[", "key", "]", ";", "}", ")", ";", "return", "retry", "(", "function", "(", "err", ")", "{", "var", "driver", "=", "getDriver", "(", "remote", ",", "capabilities", ",", "{", "mode", ":", "'async'", ",", "debug", ":", "options", ".", "debug", ",", "httpDebug", ":", "options", ".", "httpDebug", ",", "}", ")", ";", "return", "driver", ".", "_session", "(", ")", ".", "then", "(", "function", "(", ")", "{", "return", "driver", ";", "}", ")", ";", "}", ",", "4", ",", "function", "(", "attempt", ")", "{", "return", "attempt", "*", "attempt", "*", "5000", ";", "}", ",", "{", "debug", ":", "options", ".", "debug", "}", ")", ".", "then", "(", "function", "(", "driver", ")", "{", "return", "runDriver", "(", "location", ",", "driver", ",", "{", "name", ":", "options", ".", "name", ",", "jobInfo", ":", "typeof", "options", ".", "jobInfo", "===", "'function'", "?", "options", ".", "jobInfo", "(", "platform", ")", ":", "options", ".", "jobInfo", ",", "allowExceptions", ":", "options", ".", "allowExceptions", ",", "testComplete", ":", "options", ".", "testComplete", ",", "testPassed", ":", "options", ".", "testPassed", ",", "timeout", ":", "options", ".", "timeout", ",", "debug", ":", "options", ".", "debug", "}", ")", ".", "then", "(", "function", "(", "result", ")", "{", "return", "result", ";", "}", ")", ";", "}", ")", ";", "}" ]
Run a test in a single browser, then return the result @option {Object} capabilities @option {Boolean} debug @option {Object|Function} jobInfo @option {Boolean} allowExceptions @option {String|Function} testComplete @option {String|Function} testPassed @option {String} timeout Returns: ```js { "passed": true, "duration": "3000" } ``` @param {Location} location @param {Object} remote @param {Object} platform @param {Options} options @returns {Promise}
[ "Run", "a", "test", "in", "a", "single", "browser", "then", "return", "the", "result" ]
7c671b3321dc63aefc00c1c8d49e943ead2e7f5e
https://github.com/ForbesLindesay-Unmaintained/sauce-test/blob/7c671b3321dc63aefc00c1c8d49e943ead2e7f5e/lib/run-single-browser.js#L31-L64
56,550
doowb/transform-cache
index.js
Cache
function Cache (cache, options) { if (arguments.length === 1) { if (cache.hasOwnProperty('normalizeKey') || cache.hasOwnProperty('transform')) { options = cache; cache = {}; } } options = options || {}; this.cache = cache || {}; this.normalizeKey = options.normalizeKey || function (key) { return key; }; this.transform = options.transform || function (value) { return value; }; }
javascript
function Cache (cache, options) { if (arguments.length === 1) { if (cache.hasOwnProperty('normalizeKey') || cache.hasOwnProperty('transform')) { options = cache; cache = {}; } } options = options || {}; this.cache = cache || {}; this.normalizeKey = options.normalizeKey || function (key) { return key; }; this.transform = options.transform || function (value) { return value; }; }
[ "function", "Cache", "(", "cache", ",", "options", ")", "{", "if", "(", "arguments", ".", "length", "===", "1", ")", "{", "if", "(", "cache", ".", "hasOwnProperty", "(", "'normalizeKey'", ")", "||", "cache", ".", "hasOwnProperty", "(", "'transform'", ")", ")", "{", "options", "=", "cache", ";", "cache", "=", "{", "}", ";", "}", "}", "options", "=", "options", "||", "{", "}", ";", "this", ".", "cache", "=", "cache", "||", "{", "}", ";", "this", ".", "normalizeKey", "=", "options", ".", "normalizeKey", "||", "function", "(", "key", ")", "{", "return", "key", ";", "}", ";", "this", ".", "transform", "=", "options", ".", "transform", "||", "function", "(", "value", ")", "{", "return", "value", ";", "}", ";", "}" ]
Create a cache that transforms values when setting. ```js function makeKey = function (key) { return key.toUpperCase(); }; function transform = function (value) { return value.toUpperCase(); }; var cache = new Cache(makeKey, tranform); ``` @param {Object} `cache` Object to store the cache on. @param {Object} `options` @option {Function} `normalizeKey` normalize the `key` when getting and setting @option {Function} `transform` transform the `value` when setting @api public
[ "Create", "a", "cache", "that", "transforms", "values", "when", "setting", "." ]
cbdffe256c4f4c2e96a2f50b3f7ecb86cd7b1415
https://github.com/doowb/transform-cache/blob/cbdffe256c4f4c2e96a2f50b3f7ecb86cd7b1415/index.js#L31-L42
56,551
jsguy/mithril.component.mdl
mithril.component.mdl.js
function(attrs) { attrs = attrs || {}; attrs.state = attrs.state || {}; // Build our class name var cName = cfgClasses("mdl-button--", ["raised", "fab", "mini-fab", "icon", "colored", "primary", "accent"], attrs.state) + cfgClasses("mdl-js-", ["ripple-effect"], attrs.state); return attrsConfig({ className: "mdl-button mdl-js-button" + cName }, attrs); }
javascript
function(attrs) { attrs = attrs || {}; attrs.state = attrs.state || {}; // Build our class name var cName = cfgClasses("mdl-button--", ["raised", "fab", "mini-fab", "icon", "colored", "primary", "accent"], attrs.state) + cfgClasses("mdl-js-", ["ripple-effect"], attrs.state); return attrsConfig({ className: "mdl-button mdl-js-button" + cName }, attrs); }
[ "function", "(", "attrs", ")", "{", "attrs", "=", "attrs", "||", "{", "}", ";", "attrs", ".", "state", "=", "attrs", ".", "state", "||", "{", "}", ";", "//\tBuild our class name", "var", "cName", "=", "cfgClasses", "(", "\"mdl-button--\"", ",", "[", "\"raised\"", ",", "\"fab\"", ",", "\"mini-fab\"", ",", "\"icon\"", ",", "\"colored\"", ",", "\"primary\"", ",", "\"accent\"", "]", ",", "attrs", ".", "state", ")", "+", "cfgClasses", "(", "\"mdl-js-\"", ",", "[", "\"ripple-effect\"", "]", ",", "attrs", ".", "state", ")", ";", "return", "attrsConfig", "(", "{", "className", ":", "\"mdl-button mdl-js-button\"", "+", "cName", "}", ",", "attrs", ")", ";", "}" ]
Set button class names
[ "Set", "button", "class", "names" ]
89a132fd475e55a98b239a229842661745a53372
https://github.com/jsguy/mithril.component.mdl/blob/89a132fd475e55a98b239a229842661745a53372/mithril.component.mdl.js#L173-L184
56,552
jsguy/mithril.component.mdl
mithril.component.mdl.js
function(ctrl, attrs) { attrs = mButton.attrs(attrs); // If there is a href, we assume this is a link button return m(attrs.cfg.href? 'a': 'button', attrExclude(attrs.cfg, ['text']), (attrs.state.fab || attrs.state.icon? m('i', {className: "material-icons"}, attrs.cfg.text): attrs.cfg.text) ); }
javascript
function(ctrl, attrs) { attrs = mButton.attrs(attrs); // If there is a href, we assume this is a link button return m(attrs.cfg.href? 'a': 'button', attrExclude(attrs.cfg, ['text']), (attrs.state.fab || attrs.state.icon? m('i', {className: "material-icons"}, attrs.cfg.text): attrs.cfg.text) ); }
[ "function", "(", "ctrl", ",", "attrs", ")", "{", "attrs", "=", "mButton", ".", "attrs", "(", "attrs", ")", ";", "//\tIf there is a href, we assume this is a link button", "return", "m", "(", "attrs", ".", "cfg", ".", "href", "?", "'a'", ":", "'button'", ",", "attrExclude", "(", "attrs", ".", "cfg", ",", "[", "'text'", "]", ")", ",", "(", "attrs", ".", "state", ".", "fab", "||", "attrs", ".", "state", ".", "icon", "?", "m", "(", "'i'", ",", "{", "className", ":", "\"material-icons\"", "}", ",", "attrs", ".", "cfg", ".", "text", ")", ":", "attrs", ".", "cfg", ".", "text", ")", ")", ";", "}" ]
Always use the attrs, not ctrl, as it isn't returned from the default controller.
[ "Always", "use", "the", "attrs", "not", "ctrl", "as", "it", "isn", "t", "returned", "from", "the", "default", "controller", "." ]
89a132fd475e55a98b239a229842661745a53372
https://github.com/jsguy/mithril.component.mdl/blob/89a132fd475e55a98b239a229842661745a53372/mithril.component.mdl.js#L187-L195
56,553
jsguy/mithril.component.mdl
mithril.component.mdl.js
function(attrs) { attrs = attrs || {}; attrs.state = attrs.state || {}; return attrsConfig({ className: "mdl-js-snackbar mdl-snackbar" }, attrs); }
javascript
function(attrs) { attrs = attrs || {}; attrs.state = attrs.state || {}; return attrsConfig({ className: "mdl-js-snackbar mdl-snackbar" }, attrs); }
[ "function", "(", "attrs", ")", "{", "attrs", "=", "attrs", "||", "{", "}", ";", "attrs", ".", "state", "=", "attrs", ".", "state", "||", "{", "}", ";", "return", "attrsConfig", "(", "{", "className", ":", "\"mdl-js-snackbar mdl-snackbar\"", "}", ",", "attrs", ")", ";", "}" ]
Set the default attrs here
[ "Set", "the", "default", "attrs", "here" ]
89a132fd475e55a98b239a229842661745a53372
https://github.com/jsguy/mithril.component.mdl/blob/89a132fd475e55a98b239a229842661745a53372/mithril.component.mdl.js#L384-L391
56,554
tlid/tlid
src/nodejs/tlid/tlid.js
tlid__xtro
function tlid__xtro(str) { var r = new Object(); r.tlid = "-1"; r.src = str; r.txt = ""; // r.deco = ""; if (tlid__has(str)) { r.tlid = tlid__xtr(str); r.txt = str.replace(r.tlid + " ", "") // try to clear out the double space .replace(r.tlid, "") // if ending the string, well we remove it .replace("@tlid ", ""); //remove the decorator } return r; }
javascript
function tlid__xtro(str) { var r = new Object(); r.tlid = "-1"; r.src = str; r.txt = ""; // r.deco = ""; if (tlid__has(str)) { r.tlid = tlid__xtr(str); r.txt = str.replace(r.tlid + " ", "") // try to clear out the double space .replace(r.tlid, "") // if ending the string, well we remove it .replace("@tlid ", ""); //remove the decorator } return r; }
[ "function", "tlid__xtro", "(", "str", ")", "{", "var", "r", "=", "new", "Object", "(", ")", ";", "r", ".", "tlid", "=", "\"-1\"", ";", "r", ".", "src", "=", "str", ";", "r", ".", "txt", "=", "\"\"", ";", "// r.deco = \"\";", "if", "(", "tlid__has", "(", "str", ")", ")", "{", "r", ".", "tlid", "=", "tlid__xtr", "(", "str", ")", ";", "r", ".", "txt", "=", "str", ".", "replace", "(", "r", ".", "tlid", "+", "\" \"", ",", "\"\"", ")", "// try to clear out the double space", ".", "replace", "(", "r", ".", "tlid", ",", "\"\"", ")", "// if ending the string, well we remove it", ".", "replace", "(", "\"@tlid \"", ",", "\"\"", ")", ";", "//remove the decorator", "}", "return", "r", ";", "}" ]
Extract a structure from the string @param {*} str
[ "Extract", "a", "structure", "from", "the", "string" ]
ddfab991965c1cf01abdde0311e1ee96f8defab3
https://github.com/tlid/tlid/blob/ddfab991965c1cf01abdde0311e1ee96f8defab3/src/nodejs/tlid/tlid.js#L192-L209
56,555
yoannmoinet/requirejs-i18njs
src/i18njs-builder.js
function (obj, fn) { for (var i in obj) { if (typeof obj[i] === 'object') { obj[i] = parse(obj[i], fn); } else { obj[i] = fn(obj[i], i); } } return obj; }
javascript
function (obj, fn) { for (var i in obj) { if (typeof obj[i] === 'object') { obj[i] = parse(obj[i], fn); } else { obj[i] = fn(obj[i], i); } } return obj; }
[ "function", "(", "obj", ",", "fn", ")", "{", "for", "(", "var", "i", "in", "obj", ")", "{", "if", "(", "typeof", "obj", "[", "i", "]", "===", "'object'", ")", "{", "obj", "[", "i", "]", "=", "parse", "(", "obj", "[", "i", "]", ",", "fn", ")", ";", "}", "else", "{", "obj", "[", "i", "]", "=", "fn", "(", "obj", "[", "i", "]", ",", "i", ")", ";", "}", "}", "return", "obj", ";", "}" ]
Simple self iterative function
[ "Simple", "self", "iterative", "function" ]
e33610f8b8d6cf46f9e473c5ffe39b24c277f73e
https://github.com/yoannmoinet/requirejs-i18njs/blob/e33610f8b8d6cf46f9e473c5ffe39b24c277f73e/src/i18njs-builder.js#L11-L20
56,556
yoannmoinet/requirejs-i18njs
src/i18njs-builder.js
changeKeys
function changeKeys (src, dest) { for (var i in src) { if (typeof src[i] === 'object') { dest[escapedSingleQuotes + i + escapedSingleQuotes] = {}; changeKeys(src[i], dest[escapedSingleQuotes + i + escapedSingleQuotes]); } else { dest[escapedSingleQuotes + i + escapedSingleQuotes] = src[i]; } } return dest; }
javascript
function changeKeys (src, dest) { for (var i in src) { if (typeof src[i] === 'object') { dest[escapedSingleQuotes + i + escapedSingleQuotes] = {}; changeKeys(src[i], dest[escapedSingleQuotes + i + escapedSingleQuotes]); } else { dest[escapedSingleQuotes + i + escapedSingleQuotes] = src[i]; } } return dest; }
[ "function", "changeKeys", "(", "src", ",", "dest", ")", "{", "for", "(", "var", "i", "in", "src", ")", "{", "if", "(", "typeof", "src", "[", "i", "]", "===", "'object'", ")", "{", "dest", "[", "escapedSingleQuotes", "+", "i", "+", "escapedSingleQuotes", "]", "=", "{", "}", ";", "changeKeys", "(", "src", "[", "i", "]", ",", "dest", "[", "escapedSingleQuotes", "+", "i", "+", "escapedSingleQuotes", "]", ")", ";", "}", "else", "{", "dest", "[", "escapedSingleQuotes", "+", "i", "+", "escapedSingleQuotes", "]", "=", "src", "[", "i", "]", ";", "}", "}", "return", "dest", ";", "}" ]
Little hack to keep quotes on key names.
[ "Little", "hack", "to", "keep", "quotes", "on", "key", "names", "." ]
e33610f8b8d6cf46f9e473c5ffe39b24c277f73e
https://github.com/yoannmoinet/requirejs-i18njs/blob/e33610f8b8d6cf46f9e473c5ffe39b24c277f73e/src/i18njs-builder.js#L84-L97
56,557
mozilla-services/connect-validation
index.js
errorsMiddleware
function errorsMiddleware(req, res, next) { var errors = []; res.addError = function(location, name, description) { if (["body", "header", "url", "querystring"].indexOf(location) === -1) { throw new Error('"' + location + '" is not a valid location. ' + 'Should be one of "header", "body", "url" or ' + '"querystring".'); } errors.push({ location: location, name: name, description: description }); }; res.sendError = function(location, name, description) { if (typeof location !== "undefined") { res.addError(location, name, description); } res.json(400, {status: "errors", errors: errors}); }; res.hasErrors = function() { return errors.length !== 0; }; next(); }
javascript
function errorsMiddleware(req, res, next) { var errors = []; res.addError = function(location, name, description) { if (["body", "header", "url", "querystring"].indexOf(location) === -1) { throw new Error('"' + location + '" is not a valid location. ' + 'Should be one of "header", "body", "url" or ' + '"querystring".'); } errors.push({ location: location, name: name, description: description }); }; res.sendError = function(location, name, description) { if (typeof location !== "undefined") { res.addError(location, name, description); } res.json(400, {status: "errors", errors: errors}); }; res.hasErrors = function() { return errors.length !== 0; }; next(); }
[ "function", "errorsMiddleware", "(", "req", ",", "res", ",", "next", ")", "{", "var", "errors", "=", "[", "]", ";", "res", ".", "addError", "=", "function", "(", "location", ",", "name", ",", "description", ")", "{", "if", "(", "[", "\"body\"", ",", "\"header\"", ",", "\"url\"", ",", "\"querystring\"", "]", ".", "indexOf", "(", "location", ")", "===", "-", "1", ")", "{", "throw", "new", "Error", "(", "'\"'", "+", "location", "+", "'\" is not a valid location. '", "+", "'Should be one of \"header\", \"body\", \"url\" or '", "+", "'\"querystring\".'", ")", ";", "}", "errors", ".", "push", "(", "{", "location", ":", "location", ",", "name", ":", "name", ",", "description", ":", "description", "}", ")", ";", "}", ";", "res", ".", "sendError", "=", "function", "(", "location", ",", "name", ",", "description", ")", "{", "if", "(", "typeof", "location", "!==", "\"undefined\"", ")", "{", "res", ".", "addError", "(", "location", ",", "name", ",", "description", ")", ";", "}", "res", ".", "json", "(", "400", ",", "{", "status", ":", "\"errors\"", ",", "errors", ":", "errors", "}", ")", ";", "}", ";", "res", ".", "hasErrors", "=", "function", "(", ")", "{", "return", "errors", ".", "length", "!==", "0", ";", "}", ";", "next", "(", ")", ";", "}" ]
The "errors" middleware adds two functions to the response object in order to handle validation. - "addError" adds a new validation error to the response. Should be followed by "sendError()" in order to send the response. - "sendError" adds a new validation error and sends the response right after. Response will be a `400 BAD REQUEST` JSON response. @param {String} location Location where the parameter had been looked for. Should be one of "header", "body", "url" or "querystring". @param {String} name Name of the faulty parameter. @param {String} description Description of the error. You can use directly "sendError" without any parameters to trigger the response.
[ "The", "errors", "middleware", "adds", "two", "functions", "to", "the", "response", "object", "in", "order", "to", "handle", "validation", "." ]
aa32a818b9d744f8f3fb61eb753f099535f3ab33
https://github.com/mozilla-services/connect-validation/blob/aa32a818b9d744f8f3fb61eb753f099535f3ab33/index.js#L24-L48
56,558
Biyaheroes/bh-mj-issue
dependency-react.support.js
function (internalInstance, transaction, updateBatchNumber) { if (internalInstance._updateBatchNumber !== updateBatchNumber) { // The component's enqueued batch number should always be the current // batch or the following one. process.env.NODE_ENV !== 'production' ? warning(internalInstance._updateBatchNumber == null || internalInstance._updateBatchNumber === updateBatchNumber + 1, 'performUpdateIfNecessary: Unexpected batch number (current %s, ' + 'pending %s)', updateBatchNumber, internalInstance._updateBatchNumber) : void 0; return; } if (process.env.NODE_ENV !== 'production') { if (internalInstance._debugID !== 0) { ReactInstrumentation.debugTool.onBeforeUpdateComponent(internalInstance._debugID, internalInstance._currentElement); } } internalInstance.performUpdateIfNecessary(transaction); if (process.env.NODE_ENV !== 'production') { if (internalInstance._debugID !== 0) { ReactInstrumentation.debugTool.onUpdateComponent(internalInstance._debugID); } } }
javascript
function (internalInstance, transaction, updateBatchNumber) { if (internalInstance._updateBatchNumber !== updateBatchNumber) { // The component's enqueued batch number should always be the current // batch or the following one. process.env.NODE_ENV !== 'production' ? warning(internalInstance._updateBatchNumber == null || internalInstance._updateBatchNumber === updateBatchNumber + 1, 'performUpdateIfNecessary: Unexpected batch number (current %s, ' + 'pending %s)', updateBatchNumber, internalInstance._updateBatchNumber) : void 0; return; } if (process.env.NODE_ENV !== 'production') { if (internalInstance._debugID !== 0) { ReactInstrumentation.debugTool.onBeforeUpdateComponent(internalInstance._debugID, internalInstance._currentElement); } } internalInstance.performUpdateIfNecessary(transaction); if (process.env.NODE_ENV !== 'production') { if (internalInstance._debugID !== 0) { ReactInstrumentation.debugTool.onUpdateComponent(internalInstance._debugID); } } }
[ "function", "(", "internalInstance", ",", "transaction", ",", "updateBatchNumber", ")", "{", "if", "(", "internalInstance", ".", "_updateBatchNumber", "!==", "updateBatchNumber", ")", "{", "// The component's enqueued batch number should always be the current", "// batch or the following one.", "process", ".", "env", ".", "NODE_ENV", "!==", "'production'", "?", "warning", "(", "internalInstance", ".", "_updateBatchNumber", "==", "null", "||", "internalInstance", ".", "_updateBatchNumber", "===", "updateBatchNumber", "+", "1", ",", "'performUpdateIfNecessary: Unexpected batch number (current %s, '", "+", "'pending %s)'", ",", "updateBatchNumber", ",", "internalInstance", ".", "_updateBatchNumber", ")", ":", "void", "0", ";", "return", ";", "}", "if", "(", "process", ".", "env", ".", "NODE_ENV", "!==", "'production'", ")", "{", "if", "(", "internalInstance", ".", "_debugID", "!==", "0", ")", "{", "ReactInstrumentation", ".", "debugTool", ".", "onBeforeUpdateComponent", "(", "internalInstance", ".", "_debugID", ",", "internalInstance", ".", "_currentElement", ")", ";", "}", "}", "internalInstance", ".", "performUpdateIfNecessary", "(", "transaction", ")", ";", "if", "(", "process", ".", "env", ".", "NODE_ENV", "!==", "'production'", ")", "{", "if", "(", "internalInstance", ".", "_debugID", "!==", "0", ")", "{", "ReactInstrumentation", ".", "debugTool", ".", "onUpdateComponent", "(", "internalInstance", ".", "_debugID", ")", ";", "}", "}", "}" ]
Flush any dirty changes in a component. @param {ReactComponent} internalInstance @param {ReactReconcileTransaction} transaction @internal
[ "Flush", "any", "dirty", "changes", "in", "a", "component", "." ]
878be949e0a142139e75f579bdaed2cb43511008
https://github.com/Biyaheroes/bh-mj-issue/blob/878be949e0a142139e75f579bdaed2cb43511008/dependency-react.support.js#L2224-L2242
56,559
Biyaheroes/bh-mj-issue
dependency-react.support.js
function (publicInstance, completeState, callback) { var internalInstance = getInternalInstanceReadyForUpdate(publicInstance, 'replaceState'); if (!internalInstance) { return; } internalInstance._pendingStateQueue = [completeState]; internalInstance._pendingReplaceState = true; // Future-proof 15.5 if (callback !== undefined && callback !== null) { ReactUpdateQueue.validateCallback(callback, 'replaceState'); if (internalInstance._pendingCallbacks) { internalInstance._pendingCallbacks.push(callback); } else { internalInstance._pendingCallbacks = [callback]; } } enqueueUpdate(internalInstance); }
javascript
function (publicInstance, completeState, callback) { var internalInstance = getInternalInstanceReadyForUpdate(publicInstance, 'replaceState'); if (!internalInstance) { return; } internalInstance._pendingStateQueue = [completeState]; internalInstance._pendingReplaceState = true; // Future-proof 15.5 if (callback !== undefined && callback !== null) { ReactUpdateQueue.validateCallback(callback, 'replaceState'); if (internalInstance._pendingCallbacks) { internalInstance._pendingCallbacks.push(callback); } else { internalInstance._pendingCallbacks = [callback]; } } enqueueUpdate(internalInstance); }
[ "function", "(", "publicInstance", ",", "completeState", ",", "callback", ")", "{", "var", "internalInstance", "=", "getInternalInstanceReadyForUpdate", "(", "publicInstance", ",", "'replaceState'", ")", ";", "if", "(", "!", "internalInstance", ")", "{", "return", ";", "}", "internalInstance", ".", "_pendingStateQueue", "=", "[", "completeState", "]", ";", "internalInstance", ".", "_pendingReplaceState", "=", "true", ";", "// Future-proof 15.5", "if", "(", "callback", "!==", "undefined", "&&", "callback", "!==", "null", ")", "{", "ReactUpdateQueue", ".", "validateCallback", "(", "callback", ",", "'replaceState'", ")", ";", "if", "(", "internalInstance", ".", "_pendingCallbacks", ")", "{", "internalInstance", ".", "_pendingCallbacks", ".", "push", "(", "callback", ")", ";", "}", "else", "{", "internalInstance", ".", "_pendingCallbacks", "=", "[", "callback", "]", ";", "}", "}", "enqueueUpdate", "(", "internalInstance", ")", ";", "}" ]
Replaces all of the state. Always use this or `setState` to mutate state. You should treat `this.state` as immutable. There is no guarantee that `this.state` will be immediately updated, so accessing `this.state` after calling this method may return the old value. @param {ReactClass} publicInstance The instance that should rerender. @param {object} completeState Next state. @internal
[ "Replaces", "all", "of", "the", "state", ".", "Always", "use", "this", "or", "setState", "to", "mutate", "state", ".", "You", "should", "treat", "this", ".", "state", "as", "immutable", "." ]
878be949e0a142139e75f579bdaed2cb43511008
https://github.com/Biyaheroes/bh-mj-issue/blob/878be949e0a142139e75f579bdaed2cb43511008/dependency-react.support.js#L5635-L5656
56,560
franza/continuate
index.js
cps
function cps(fun) { /** * @param {...*} args * @param {Function} callback */ return function () { var args = Array.prototype.slice.call(arguments); var callback = args.pop(); var result; try { result = fun.apply(this, args); } catch (err) { callback(err); return; } callback(null, result); } }
javascript
function cps(fun) { /** * @param {...*} args * @param {Function} callback */ return function () { var args = Array.prototype.slice.call(arguments); var callback = args.pop(); var result; try { result = fun.apply(this, args); } catch (err) { callback(err); return; } callback(null, result); } }
[ "function", "cps", "(", "fun", ")", "{", "/**\n * @param {...*} args\n * @param {Function} callback\n */", "return", "function", "(", ")", "{", "var", "args", "=", "Array", ".", "prototype", ".", "slice", ".", "call", "(", "arguments", ")", ";", "var", "callback", "=", "args", ".", "pop", "(", ")", ";", "var", "result", ";", "try", "{", "result", "=", "fun", ".", "apply", "(", "this", ",", "args", ")", ";", "}", "catch", "(", "err", ")", "{", "callback", "(", "err", ")", ";", "return", ";", "}", "callback", "(", "null", ",", "result", ")", ";", "}", "}" ]
Returns function that provides results of fun in continuation-passing style @param fun @returns {Function}
[ "Returns", "function", "that", "provides", "results", "of", "fun", "in", "continuation", "-", "passing", "style" ]
008a8a84bb8c89a1f58cd2f6ad3da4bfd73d7d21
https://github.com/franza/continuate/blob/008a8a84bb8c89a1f58cd2f6ad3da4bfd73d7d21/index.js#L6-L23
56,561
AlphaReplica/Connecta
lib/client/source/connectaPeer.js
setIceServers
function setIceServers() { if(stunServers) { for(var num = 0; num < stunServers.length; num++) { connConfig['iceServers'].push({'urls':'stun:'+stunServers[num]}); } } }
javascript
function setIceServers() { if(stunServers) { for(var num = 0; num < stunServers.length; num++) { connConfig['iceServers'].push({'urls':'stun:'+stunServers[num]}); } } }
[ "function", "setIceServers", "(", ")", "{", "if", "(", "stunServers", ")", "{", "for", "(", "var", "num", "=", "0", ";", "num", "<", "stunServers", ".", "length", ";", "num", "++", ")", "{", "connConfig", "[", "'iceServers'", "]", ".", "push", "(", "{", "'urls'", ":", "'stun:'", "+", "stunServers", "[", "num", "]", "}", ")", ";", "}", "}", "}" ]
parses stun server array and returns rtc friendly object
[ "parses", "stun", "server", "array", "and", "returns", "rtc", "friendly", "object" ]
bc0ce3fa1ef5ef07526633da5668dcaff5ef29e0
https://github.com/AlphaReplica/Connecta/blob/bc0ce3fa1ef5ef07526633da5668dcaff5ef29e0/lib/client/source/connectaPeer.js#L23-L32
56,562
AlphaReplica/Connecta
lib/client/source/connectaPeer.js
iceCandidateCallback
function iceCandidateCallback(e) { if(e.candidate != null) { if(scope.onIceCandidate) { scope.onIceCandidate(scope,JSON.stringify({'ice': e.candidate})); } } }
javascript
function iceCandidateCallback(e) { if(e.candidate != null) { if(scope.onIceCandidate) { scope.onIceCandidate(scope,JSON.stringify({'ice': e.candidate})); } } }
[ "function", "iceCandidateCallback", "(", "e", ")", "{", "if", "(", "e", ".", "candidate", "!=", "null", ")", "{", "if", "(", "scope", ".", "onIceCandidate", ")", "{", "scope", ".", "onIceCandidate", "(", "scope", ",", "JSON", ".", "stringify", "(", "{", "'ice'", ":", "e", ".", "candidate", "}", ")", ")", ";", "}", "}", "}" ]
callback for ice candidate
[ "callback", "for", "ice", "candidate" ]
bc0ce3fa1ef5ef07526633da5668dcaff5ef29e0
https://github.com/AlphaReplica/Connecta/blob/bc0ce3fa1ef5ef07526633da5668dcaff5ef29e0/lib/client/source/connectaPeer.js#L35-L44
56,563
AlphaReplica/Connecta
lib/client/source/connectaPeer.js
onStateChange
function onStateChange(e) { if(scope._conn) { if(scope._conn.iceConnectionState == "connected") { if(scope.onConnected) { scope.onConnected(scope); } } if(scope._conn.iceConnectionState == "failed" || scope._conn.iceConnectionState == "disconnected") { if(scope.onConnectionFail) { scope.onConnectionFail(scope); } if(scope.type == "offer") { scope.createOffer(); } } if(scope._conn.iceConnectionState == "closed") { if(scope.onClosed) { scope.onClosed(scope); } scope.dispose(); } } }
javascript
function onStateChange(e) { if(scope._conn) { if(scope._conn.iceConnectionState == "connected") { if(scope.onConnected) { scope.onConnected(scope); } } if(scope._conn.iceConnectionState == "failed" || scope._conn.iceConnectionState == "disconnected") { if(scope.onConnectionFail) { scope.onConnectionFail(scope); } if(scope.type == "offer") { scope.createOffer(); } } if(scope._conn.iceConnectionState == "closed") { if(scope.onClosed) { scope.onClosed(scope); } scope.dispose(); } } }
[ "function", "onStateChange", "(", "e", ")", "{", "if", "(", "scope", ".", "_conn", ")", "{", "if", "(", "scope", ".", "_conn", ".", "iceConnectionState", "==", "\"connected\"", ")", "{", "if", "(", "scope", ".", "onConnected", ")", "{", "scope", ".", "onConnected", "(", "scope", ")", ";", "}", "}", "if", "(", "scope", ".", "_conn", ".", "iceConnectionState", "==", "\"failed\"", "||", "scope", ".", "_conn", ".", "iceConnectionState", "==", "\"disconnected\"", ")", "{", "if", "(", "scope", ".", "onConnectionFail", ")", "{", "scope", ".", "onConnectionFail", "(", "scope", ")", ";", "}", "if", "(", "scope", ".", "type", "==", "\"offer\"", ")", "{", "scope", ".", "createOffer", "(", ")", ";", "}", "}", "if", "(", "scope", ".", "_conn", ".", "iceConnectionState", "==", "\"closed\"", ")", "{", "if", "(", "scope", ".", "onClosed", ")", "{", "scope", ".", "onClosed", "(", "scope", ")", ";", "}", "scope", ".", "dispose", "(", ")", ";", "}", "}", "}" ]
called when ice connection state is changed
[ "called", "when", "ice", "connection", "state", "is", "changed" ]
bc0ce3fa1ef5ef07526633da5668dcaff5ef29e0
https://github.com/AlphaReplica/Connecta/blob/bc0ce3fa1ef5ef07526633da5668dcaff5ef29e0/lib/client/source/connectaPeer.js#L61-L92
56,564
AlphaReplica/Connecta
lib/client/source/connectaPeer.js
remoteStreamCallback
function remoteStreamCallback(e) { scope.remoteStream = e.stream; if(scope.onRemoteStream) { scope.onRemoteStream(scope.remoteStream); } }
javascript
function remoteStreamCallback(e) { scope.remoteStream = e.stream; if(scope.onRemoteStream) { scope.onRemoteStream(scope.remoteStream); } }
[ "function", "remoteStreamCallback", "(", "e", ")", "{", "scope", ".", "remoteStream", "=", "e", ".", "stream", ";", "if", "(", "scope", ".", "onRemoteStream", ")", "{", "scope", ".", "onRemoteStream", "(", "scope", ".", "remoteStream", ")", ";", "}", "}" ]
called when remote stream is connected
[ "called", "when", "remote", "stream", "is", "connected" ]
bc0ce3fa1ef5ef07526633da5668dcaff5ef29e0
https://github.com/AlphaReplica/Connecta/blob/bc0ce3fa1ef5ef07526633da5668dcaff5ef29e0/lib/client/source/connectaPeer.js#L104-L111
56,565
AlphaReplica/Connecta
lib/client/source/connectaPeer.js
ondatachannel
function ondatachannel(e) { if(e) { scope._data = e.channel; } else { scope._data = scope._conn.createDataChannel("data"); } scope._data.onopen = function() { if(scope._data) { if(scope._data.readyState == "open") { if(scope.onChannelState) { scope.onChannelState(scope,'open'); } } } }; scope._data.onmessage = function(e) { if(e.data instanceof ArrayBuffer) { if(scope.onBytesMessage) { scope.onBytesMessage(scope,e.data); } } else { if(scope.onMessage) { var char = Number(e.data[0]); if(char == MessageType.MESSAGE) { scope.onMessage(scope,JSON.parse(e.data.substring(1,e.data.length))); } else { scope.onMessage(scope,e.data); } } } } scope._data.onclose = function(e) { if(scope.onChannelState) { scope.onChannelState(scope,'closed'); } } scope._data.onerror = function(e) { if(scope.onError) { scope.onError(e); } } }
javascript
function ondatachannel(e) { if(e) { scope._data = e.channel; } else { scope._data = scope._conn.createDataChannel("data"); } scope._data.onopen = function() { if(scope._data) { if(scope._data.readyState == "open") { if(scope.onChannelState) { scope.onChannelState(scope,'open'); } } } }; scope._data.onmessage = function(e) { if(e.data instanceof ArrayBuffer) { if(scope.onBytesMessage) { scope.onBytesMessage(scope,e.data); } } else { if(scope.onMessage) { var char = Number(e.data[0]); if(char == MessageType.MESSAGE) { scope.onMessage(scope,JSON.parse(e.data.substring(1,e.data.length))); } else { scope.onMessage(scope,e.data); } } } } scope._data.onclose = function(e) { if(scope.onChannelState) { scope.onChannelState(scope,'closed'); } } scope._data.onerror = function(e) { if(scope.onError) { scope.onError(e); } } }
[ "function", "ondatachannel", "(", "e", ")", "{", "if", "(", "e", ")", "{", "scope", ".", "_data", "=", "e", ".", "channel", ";", "}", "else", "{", "scope", ".", "_data", "=", "scope", ".", "_conn", ".", "createDataChannel", "(", "\"data\"", ")", ";", "}", "scope", ".", "_data", ".", "onopen", "=", "function", "(", ")", "{", "if", "(", "scope", ".", "_data", ")", "{", "if", "(", "scope", ".", "_data", ".", "readyState", "==", "\"open\"", ")", "{", "if", "(", "scope", ".", "onChannelState", ")", "{", "scope", ".", "onChannelState", "(", "scope", ",", "'open'", ")", ";", "}", "}", "}", "}", ";", "scope", ".", "_data", ".", "onmessage", "=", "function", "(", "e", ")", "{", "if", "(", "e", ".", "data", "instanceof", "ArrayBuffer", ")", "{", "if", "(", "scope", ".", "onBytesMessage", ")", "{", "scope", ".", "onBytesMessage", "(", "scope", ",", "e", ".", "data", ")", ";", "}", "}", "else", "{", "if", "(", "scope", ".", "onMessage", ")", "{", "var", "char", "=", "Number", "(", "e", ".", "data", "[", "0", "]", ")", ";", "if", "(", "char", "==", "MessageType", ".", "MESSAGE", ")", "{", "scope", ".", "onMessage", "(", "scope", ",", "JSON", ".", "parse", "(", "e", ".", "data", ".", "substring", "(", "1", ",", "e", ".", "data", ".", "length", ")", ")", ")", ";", "}", "else", "{", "scope", ".", "onMessage", "(", "scope", ",", "e", ".", "data", ")", ";", "}", "}", "}", "}", "scope", ".", "_data", ".", "onclose", "=", "function", "(", "e", ")", "{", "if", "(", "scope", ".", "onChannelState", ")", "{", "scope", ".", "onChannelState", "(", "scope", ",", "'closed'", ")", ";", "}", "}", "scope", ".", "_data", ".", "onerror", "=", "function", "(", "e", ")", "{", "if", "(", "scope", ".", "onError", ")", "{", "scope", ".", "onError", "(", "e", ")", ";", "}", "}", "}" ]
called when datachannel event is invoked, also called manually from offer to create new datachannel
[ "called", "when", "datachannel", "event", "is", "invoked", "also", "called", "manually", "from", "offer", "to", "create", "new", "datachannel" ]
bc0ce3fa1ef5ef07526633da5668dcaff5ef29e0
https://github.com/AlphaReplica/Connecta/blob/bc0ce3fa1ef5ef07526633da5668dcaff5ef29e0/lib/client/source/connectaPeer.js#L114-L179
56,566
ustbhuangyi/gulp-her-templateBuilder
index.js
expandSmartyPathAttr
function expandSmartyPathAttr(content, tagName, attrName, file) { var attrReg = new RegExp('((?:^|\\s)' + her.util.pregQuote(attrName) + '\\s*=\\s*)(([\"\']).*?\\3)', 'ig'); content = tagFilter.filterTag(content, tagName, smarty_left_delimiter, smarty_right_delimiter, function (outter, attr) { attr = attr.replace(attrReg, function (all, preCodeHolder, valueCodeHolder) { var info = her.util.stringQuote(valueCodeHolder); var path = info.rest; var ret = info.quote + her.uri.getId(path, file.dirname).id + info.quote; return preCodeHolder + ret; }); outter = smarty_left_delimiter + tagName + attr + smarty_right_delimiter; return outter; }); return content; }
javascript
function expandSmartyPathAttr(content, tagName, attrName, file) { var attrReg = new RegExp('((?:^|\\s)' + her.util.pregQuote(attrName) + '\\s*=\\s*)(([\"\']).*?\\3)', 'ig'); content = tagFilter.filterTag(content, tagName, smarty_left_delimiter, smarty_right_delimiter, function (outter, attr) { attr = attr.replace(attrReg, function (all, preCodeHolder, valueCodeHolder) { var info = her.util.stringQuote(valueCodeHolder); var path = info.rest; var ret = info.quote + her.uri.getId(path, file.dirname).id + info.quote; return preCodeHolder + ret; }); outter = smarty_left_delimiter + tagName + attr + smarty_right_delimiter; return outter; }); return content; }
[ "function", "expandSmartyPathAttr", "(", "content", ",", "tagName", ",", "attrName", ",", "file", ")", "{", "var", "attrReg", "=", "new", "RegExp", "(", "'((?:^|\\\\s)'", "+", "her", ".", "util", ".", "pregQuote", "(", "attrName", ")", "+", "'\\\\s*=\\\\s*)(([\\\"\\']).*?\\\\3)'", ",", "'ig'", ")", ";", "content", "=", "tagFilter", ".", "filterTag", "(", "content", ",", "tagName", ",", "smarty_left_delimiter", ",", "smarty_right_delimiter", ",", "function", "(", "outter", ",", "attr", ")", "{", "attr", "=", "attr", ".", "replace", "(", "attrReg", ",", "function", "(", "all", ",", "preCodeHolder", ",", "valueCodeHolder", ")", "{", "var", "info", "=", "her", ".", "util", ".", "stringQuote", "(", "valueCodeHolder", ")", ";", "var", "path", "=", "info", ".", "rest", ";", "var", "ret", "=", "info", ".", "quote", "+", "her", ".", "uri", ".", "getId", "(", "path", ",", "file", ".", "dirname", ")", ".", "id", "+", "info", ".", "quote", ";", "return", "preCodeHolder", "+", "ret", ";", "}", ")", ";", "outter", "=", "smarty_left_delimiter", "+", "tagName", "+", "attr", "+", "smarty_right_delimiter", ";", "return", "outter", ";", "}", ")", ";", "return", "content", ";", "}" ]
expand smarty template resource path
[ "expand", "smarty", "template", "resource", "path" ]
9d24217db63efe2f24ed80697ec24ae6d13f9a23
https://github.com/ustbhuangyi/gulp-her-templateBuilder/blob/9d24217db63efe2f24ed80697ec24ae6d13f9a23/index.js#L123-L148
56,567
byu-oit/sans-server-swagger
bin/normalize-request.js
deserializeParameter
function deserializeParameter(server, name, value, schema) { if (!schema) return value; const type = schemaType(schema); if (!type) server.log('req-params', 'Indeterminate schema type for parameter ' + name, schema); if (type === 'array') { const format = schema.hasOwnProperty('collectionFormat') ? schema.collectionFormat : 'csv'; const delimiter = format === 'csv' ? ',' : format === 'ssv' ? ' ' : format === 'tsv' ? '\t' : format === 'pipes' ? '|' : ','; value = value.split(delimiter); if (!schema.items) return value; return value.map(item => { return deserializeParameter(server, 'items for ' + name, item, schema.items); }); } else if (type === 'boolean') { return !(value === 'false' || value === 'null' || value === '0' || value === ''); } else if (type === 'integer' && rxInteger.test(value)) { return parseInt(value); } else if (type === 'number' && rxNumber.test(value)) { return parseFloat(value); } else { return value; } }
javascript
function deserializeParameter(server, name, value, schema) { if (!schema) return value; const type = schemaType(schema); if (!type) server.log('req-params', 'Indeterminate schema type for parameter ' + name, schema); if (type === 'array') { const format = schema.hasOwnProperty('collectionFormat') ? schema.collectionFormat : 'csv'; const delimiter = format === 'csv' ? ',' : format === 'ssv' ? ' ' : format === 'tsv' ? '\t' : format === 'pipes' ? '|' : ','; value = value.split(delimiter); if (!schema.items) return value; return value.map(item => { return deserializeParameter(server, 'items for ' + name, item, schema.items); }); } else if (type === 'boolean') { return !(value === 'false' || value === 'null' || value === '0' || value === ''); } else if (type === 'integer' && rxInteger.test(value)) { return parseInt(value); } else if (type === 'number' && rxNumber.test(value)) { return parseFloat(value); } else { return value; } }
[ "function", "deserializeParameter", "(", "server", ",", "name", ",", "value", ",", "schema", ")", "{", "if", "(", "!", "schema", ")", "return", "value", ";", "const", "type", "=", "schemaType", "(", "schema", ")", ";", "if", "(", "!", "type", ")", "server", ".", "log", "(", "'req-params'", ",", "'Indeterminate schema type for parameter '", "+", "name", ",", "schema", ")", ";", "if", "(", "type", "===", "'array'", ")", "{", "const", "format", "=", "schema", ".", "hasOwnProperty", "(", "'collectionFormat'", ")", "?", "schema", ".", "collectionFormat", ":", "'csv'", ";", "const", "delimiter", "=", "format", "===", "'csv'", "?", "','", ":", "format", "===", "'ssv'", "?", "' '", ":", "format", "===", "'tsv'", "?", "'\\t'", ":", "format", "===", "'pipes'", "?", "'|'", ":", "','", ";", "value", "=", "value", ".", "split", "(", "delimiter", ")", ";", "if", "(", "!", "schema", ".", "items", ")", "return", "value", ";", "return", "value", ".", "map", "(", "item", "=>", "{", "return", "deserializeParameter", "(", "server", ",", "'items for '", "+", "name", ",", "item", ",", "schema", ".", "items", ")", ";", "}", ")", ";", "}", "else", "if", "(", "type", "===", "'boolean'", ")", "{", "return", "!", "(", "value", "===", "'false'", "||", "value", "===", "'null'", "||", "value", "===", "'0'", "||", "value", "===", "''", ")", ";", "}", "else", "if", "(", "type", "===", "'integer'", "&&", "rxInteger", ".", "test", "(", "value", ")", ")", "{", "return", "parseInt", "(", "value", ")", ";", "}", "else", "if", "(", "type", "===", "'number'", "&&", "rxNumber", ".", "test", "(", "value", ")", ")", "{", "return", "parseFloat", "(", "value", ")", ";", "}", "else", "{", "return", "value", ";", "}", "}" ]
Deserialize a single parameter. @param {SansServer} server @param {string} name @param {*} value @param {*} schema @returns {*}
[ "Deserialize", "a", "single", "parameter", "." ]
455e76b8d65451e606e3c7894ff08affbeb447f1
https://github.com/byu-oit/sans-server-swagger/blob/455e76b8d65451e606e3c7894ff08affbeb447f1/bin/normalize-request.js#L150-L180
56,568
byu-oit/sans-server-swagger
bin/normalize-request.js
schemaType
function schemaType(schema) { let type; if (schema.hasOwnProperty('type')) { type = schema.type; } else if (schema.hasOwnProperty('properties') || schema.hasOwnProperty('allOf') || schema.hasOwnProperty('additionalProperties')) { type = 'object'; } else if (schema.hasOwnProperty('items')) { type = 'array'; } switch (type) { case 'array': case 'boolean': case 'file': case 'integer': case 'number': case 'object': case 'string': return type; } }
javascript
function schemaType(schema) { let type; if (schema.hasOwnProperty('type')) { type = schema.type; } else if (schema.hasOwnProperty('properties') || schema.hasOwnProperty('allOf') || schema.hasOwnProperty('additionalProperties')) { type = 'object'; } else if (schema.hasOwnProperty('items')) { type = 'array'; } switch (type) { case 'array': case 'boolean': case 'file': case 'integer': case 'number': case 'object': case 'string': return type; } }
[ "function", "schemaType", "(", "schema", ")", "{", "let", "type", ";", "if", "(", "schema", ".", "hasOwnProperty", "(", "'type'", ")", ")", "{", "type", "=", "schema", ".", "type", ";", "}", "else", "if", "(", "schema", ".", "hasOwnProperty", "(", "'properties'", ")", "||", "schema", ".", "hasOwnProperty", "(", "'allOf'", ")", "||", "schema", ".", "hasOwnProperty", "(", "'additionalProperties'", ")", ")", "{", "type", "=", "'object'", ";", "}", "else", "if", "(", "schema", ".", "hasOwnProperty", "(", "'items'", ")", ")", "{", "type", "=", "'array'", ";", "}", "switch", "(", "type", ")", "{", "case", "'array'", ":", "case", "'boolean'", ":", "case", "'file'", ":", "case", "'integer'", ":", "case", "'number'", ":", "case", "'object'", ":", "case", "'string'", ":", "return", "type", ";", "}", "}" ]
Detect the schema type. @param {Object} schema @returns {string,undefined}
[ "Detect", "the", "schema", "type", "." ]
455e76b8d65451e606e3c7894ff08affbeb447f1
https://github.com/byu-oit/sans-server-swagger/blob/455e76b8d65451e606e3c7894ff08affbeb447f1/bin/normalize-request.js#L187-L207
56,569
eventEmitter/ee-mysql
dep/node-buffalo/lib/objectid.js
ObjectId
function ObjectId(bytes) { if (Buffer.isBuffer(bytes)) { if (bytes.length != 12) throw new Error("Buffer-based ObjectId must be 12 bytes") this.bytes = bytes } else if (typeof bytes == 'string') { if (bytes.length != 24) throw new Error("String-based ObjectId must be 24 bytes") if (!/^[0-9a-f]{24}$/i.test(bytes)) throw new Error("String-based ObjectId must in hex-format:" + bytes) this.bytes = fromHex(bytes) } else if (typeof bytes !== 'undefined') { throw new Error("Unrecognized type: "+bytes) } else { var timestamp = (Date.now() / 1000) & 0xFFFFFFFF inc = ~~inc+1 // keep as integer this.bytes = new Buffer([ timestamp>>24, timestamp>>16, timestamp>>8, timestamp, machineAndPid[0], machineAndPid[1], machineAndPid[2], machineAndPid[3], machineAndPid[4], inc>>16, inc>>8, inc ]) } }
javascript
function ObjectId(bytes) { if (Buffer.isBuffer(bytes)) { if (bytes.length != 12) throw new Error("Buffer-based ObjectId must be 12 bytes") this.bytes = bytes } else if (typeof bytes == 'string') { if (bytes.length != 24) throw new Error("String-based ObjectId must be 24 bytes") if (!/^[0-9a-f]{24}$/i.test(bytes)) throw new Error("String-based ObjectId must in hex-format:" + bytes) this.bytes = fromHex(bytes) } else if (typeof bytes !== 'undefined') { throw new Error("Unrecognized type: "+bytes) } else { var timestamp = (Date.now() / 1000) & 0xFFFFFFFF inc = ~~inc+1 // keep as integer this.bytes = new Buffer([ timestamp>>24, timestamp>>16, timestamp>>8, timestamp, machineAndPid[0], machineAndPid[1], machineAndPid[2], machineAndPid[3], machineAndPid[4], inc>>16, inc>>8, inc ]) } }
[ "function", "ObjectId", "(", "bytes", ")", "{", "if", "(", "Buffer", ".", "isBuffer", "(", "bytes", ")", ")", "{", "if", "(", "bytes", ".", "length", "!=", "12", ")", "throw", "new", "Error", "(", "\"Buffer-based ObjectId must be 12 bytes\"", ")", "this", ".", "bytes", "=", "bytes", "}", "else", "if", "(", "typeof", "bytes", "==", "'string'", ")", "{", "if", "(", "bytes", ".", "length", "!=", "24", ")", "throw", "new", "Error", "(", "\"String-based ObjectId must be 24 bytes\"", ")", "if", "(", "!", "/", "^[0-9a-f]{24}$", "/", "i", ".", "test", "(", "bytes", ")", ")", "throw", "new", "Error", "(", "\"String-based ObjectId must in hex-format:\"", "+", "bytes", ")", "this", ".", "bytes", "=", "fromHex", "(", "bytes", ")", "}", "else", "if", "(", "typeof", "bytes", "!==", "'undefined'", ")", "{", "throw", "new", "Error", "(", "\"Unrecognized type: \"", "+", "bytes", ")", "}", "else", "{", "var", "timestamp", "=", "(", "Date", ".", "now", "(", ")", "/", "1000", ")", "&", "0xFFFFFFFF", "inc", "=", "~", "~", "inc", "+", "1", "// keep as integer", "this", ".", "bytes", "=", "new", "Buffer", "(", "[", "timestamp", ">>", "24", ",", "timestamp", ">>", "16", ",", "timestamp", ">>", "8", ",", "timestamp", ",", "machineAndPid", "[", "0", "]", ",", "machineAndPid", "[", "1", "]", ",", "machineAndPid", "[", "2", "]", ",", "machineAndPid", "[", "3", "]", ",", "machineAndPid", "[", "4", "]", ",", "inc", ">>", "16", ",", "inc", ">>", "8", ",", "inc", "]", ")", "}", "}" ]
32 bit time 24 bit machine id 16 bit pid 24 bit increment
[ "32", "bit", "time", "24", "bit", "machine", "id", "16", "bit", "pid", "24", "bit", "increment" ]
9797bff09a21157fb1dddb68275b01f282a184af
https://github.com/eventEmitter/ee-mysql/blob/9797bff09a21157fb1dddb68275b01f282a184af/dep/node-buffalo/lib/objectid.js#L32-L60
56,570
codenothing/munit
lib/munit.js
function( path ) { var parts = path.split( rpathsplit ), ns = munit.ns, assert; // Grep for nested path module munit.each( parts, function( part ) { if ( assert = ns[ part ] ) { ns = assert.ns; } else { throw new munit.AssertionError( "Module path not found '" + path + "'", munit._getModule ); } }); return assert; }
javascript
function( path ) { var parts = path.split( rpathsplit ), ns = munit.ns, assert; // Grep for nested path module munit.each( parts, function( part ) { if ( assert = ns[ part ] ) { ns = assert.ns; } else { throw new munit.AssertionError( "Module path not found '" + path + "'", munit._getModule ); } }); return assert; }
[ "function", "(", "path", ")", "{", "var", "parts", "=", "path", ".", "split", "(", "rpathsplit", ")", ",", "ns", "=", "munit", ".", "ns", ",", "assert", ";", "// Grep for nested path module", "munit", ".", "each", "(", "parts", ",", "function", "(", "part", ")", "{", "if", "(", "assert", "=", "ns", "[", "part", "]", ")", "{", "ns", "=", "assert", ".", "ns", ";", "}", "else", "{", "throw", "new", "munit", ".", "AssertionError", "(", "\"Module path not found '\"", "+", "path", "+", "\"'\"", ",", "munit", ".", "_getModule", ")", ";", "}", "}", ")", ";", "return", "assert", ";", "}" ]
Gets module on path
[ "Gets", "module", "on", "path" ]
aedf3f31aafc05441970eec49eeeb81174c14033
https://github.com/codenothing/munit/blob/aedf3f31aafc05441970eec49eeeb81174c14033/lib/munit.js#L274-L288
56,571
codenothing/munit
lib/munit.js
function( name, options, callback ) { var ns = munit.ns, parts = name.split( rpathsplit ), finalPart = parts.pop(), opts = munit.extend( true, {}, munit.defaults.settings ), assert = null, path = ''; // Filter through all parents parts.forEach(function( mod ) { // Update the path if ( path.length ) { path += '.'; } path += mod; // Assign assert module if ( ! ns[ mod ] ) { assert = ns[ mod ] = new munit.Assert( path, assert, opts ); } // Trickle down the path assert = ns[ mod ]; ns = assert.ns; opts = munit.extend( true, {}, opts, assert.options ); }); // Module already exists, update it if ( ns[ finalPart ] ) { assert = ns[ finalPart ]; // Test module is already in use, code setup is wrong if ( assert.callback ) { throw new munit.AssertionError( "'" + name + "' module has already been created", munit._createModule ); } assert.options = munit.extend( true, {}, opts, options ); assert.callback = callback; } else { options = munit.extend( true, {}, opts, options ); assert = ns[ finalPart ] = new munit.Assert( name, assert, options, callback ); } // Return the assertion module for use return assert; }
javascript
function( name, options, callback ) { var ns = munit.ns, parts = name.split( rpathsplit ), finalPart = parts.pop(), opts = munit.extend( true, {}, munit.defaults.settings ), assert = null, path = ''; // Filter through all parents parts.forEach(function( mod ) { // Update the path if ( path.length ) { path += '.'; } path += mod; // Assign assert module if ( ! ns[ mod ] ) { assert = ns[ mod ] = new munit.Assert( path, assert, opts ); } // Trickle down the path assert = ns[ mod ]; ns = assert.ns; opts = munit.extend( true, {}, opts, assert.options ); }); // Module already exists, update it if ( ns[ finalPart ] ) { assert = ns[ finalPart ]; // Test module is already in use, code setup is wrong if ( assert.callback ) { throw new munit.AssertionError( "'" + name + "' module has already been created", munit._createModule ); } assert.options = munit.extend( true, {}, opts, options ); assert.callback = callback; } else { options = munit.extend( true, {}, opts, options ); assert = ns[ finalPart ] = new munit.Assert( name, assert, options, callback ); } // Return the assertion module for use return assert; }
[ "function", "(", "name", ",", "options", ",", "callback", ")", "{", "var", "ns", "=", "munit", ".", "ns", ",", "parts", "=", "name", ".", "split", "(", "rpathsplit", ")", ",", "finalPart", "=", "parts", ".", "pop", "(", ")", ",", "opts", "=", "munit", ".", "extend", "(", "true", ",", "{", "}", ",", "munit", ".", "defaults", ".", "settings", ")", ",", "assert", "=", "null", ",", "path", "=", "''", ";", "// Filter through all parents", "parts", ".", "forEach", "(", "function", "(", "mod", ")", "{", "// Update the path", "if", "(", "path", ".", "length", ")", "{", "path", "+=", "'.'", ";", "}", "path", "+=", "mod", ";", "// Assign assert module", "if", "(", "!", "ns", "[", "mod", "]", ")", "{", "assert", "=", "ns", "[", "mod", "]", "=", "new", "munit", ".", "Assert", "(", "path", ",", "assert", ",", "opts", ")", ";", "}", "// Trickle down the path", "assert", "=", "ns", "[", "mod", "]", ";", "ns", "=", "assert", ".", "ns", ";", "opts", "=", "munit", ".", "extend", "(", "true", ",", "{", "}", ",", "opts", ",", "assert", ".", "options", ")", ";", "}", ")", ";", "// Module already exists, update it", "if", "(", "ns", "[", "finalPart", "]", ")", "{", "assert", "=", "ns", "[", "finalPart", "]", ";", "// Test module is already in use, code setup is wrong", "if", "(", "assert", ".", "callback", ")", "{", "throw", "new", "munit", ".", "AssertionError", "(", "\"'\"", "+", "name", "+", "\"' module has already been created\"", ",", "munit", ".", "_createModule", ")", ";", "}", "assert", ".", "options", "=", "munit", ".", "extend", "(", "true", ",", "{", "}", ",", "opts", ",", "options", ")", ";", "assert", ".", "callback", "=", "callback", ";", "}", "else", "{", "options", "=", "munit", ".", "extend", "(", "true", ",", "{", "}", ",", "opts", ",", "options", ")", ";", "assert", "=", "ns", "[", "finalPart", "]", "=", "new", "munit", ".", "Assert", "(", "name", ",", "assert", ",", "options", ",", "callback", ")", ";", "}", "// Return the assertion module for use", "return", "assert", ";", "}" ]
Internal module creation
[ "Internal", "module", "creation" ]
aedf3f31aafc05441970eec49eeeb81174c14033
https://github.com/codenothing/munit/blob/aedf3f31aafc05441970eec49eeeb81174c14033/lib/munit.js#L291-L337
56,572
codenothing/munit
lib/munit.js
function( name, depends, callback ) { if ( ( ! munit.isString( depends ) && ! munit.isArray( depends ) ) || ! depends.length ) { throw new Error( "Depends argument not found" ); } return munit._module( name, { depends: depends }, callback ); }
javascript
function( name, depends, callback ) { if ( ( ! munit.isString( depends ) && ! munit.isArray( depends ) ) || ! depends.length ) { throw new Error( "Depends argument not found" ); } return munit._module( name, { depends: depends }, callback ); }
[ "function", "(", "name", ",", "depends", ",", "callback", ")", "{", "if", "(", "(", "!", "munit", ".", "isString", "(", "depends", ")", "&&", "!", "munit", ".", "isArray", "(", "depends", ")", ")", "||", "!", "depends", ".", "length", ")", "{", "throw", "new", "Error", "(", "\"Depends argument not found\"", ")", ";", "}", "return", "munit", ".", "_module", "(", "name", ",", "{", "depends", ":", "depends", "}", ",", "callback", ")", ";", "}" ]
Creating module with dependencies
[ "Creating", "module", "with", "dependencies" ]
aedf3f31aafc05441970eec49eeeb81174c14033
https://github.com/codenothing/munit/blob/aedf3f31aafc05441970eec49eeeb81174c14033/lib/munit.js#L345-L351
56,573
codenothing/munit
lib/munit.js
function( name, handle ) { if ( munit.isObject( name ) ) { return munit.each( name, function( fn, method ) { munit.custom( method, fn ); }); } // Ensure that name can be used if ( munit.customReserved.indexOf( name ) > -1 ) { throw new Error( "'" + name + "' is a reserved name and cannot be added as a custom assertion test" ); } // Send off to assertion module for attachment munit.Assert.prototype[ name ] = handle; munit.each( munit.ns, function( mod ) { mod.custom( name, handle ); }); }
javascript
function( name, handle ) { if ( munit.isObject( name ) ) { return munit.each( name, function( fn, method ) { munit.custom( method, fn ); }); } // Ensure that name can be used if ( munit.customReserved.indexOf( name ) > -1 ) { throw new Error( "'" + name + "' is a reserved name and cannot be added as a custom assertion test" ); } // Send off to assertion module for attachment munit.Assert.prototype[ name ] = handle; munit.each( munit.ns, function( mod ) { mod.custom( name, handle ); }); }
[ "function", "(", "name", ",", "handle", ")", "{", "if", "(", "munit", ".", "isObject", "(", "name", ")", ")", "{", "return", "munit", ".", "each", "(", "name", ",", "function", "(", "fn", ",", "method", ")", "{", "munit", ".", "custom", "(", "method", ",", "fn", ")", ";", "}", ")", ";", "}", "// Ensure that name can be used", "if", "(", "munit", ".", "customReserved", ".", "indexOf", "(", "name", ")", ">", "-", "1", ")", "{", "throw", "new", "Error", "(", "\"'\"", "+", "name", "+", "\"' is a reserved name and cannot be added as a custom assertion test\"", ")", ";", "}", "// Send off to assertion module for attachment", "munit", ".", "Assert", ".", "prototype", "[", "name", "]", "=", "handle", ";", "munit", ".", "each", "(", "munit", ".", "ns", ",", "function", "(", "mod", ")", "{", "mod", ".", "custom", "(", "name", ",", "handle", ")", ";", "}", ")", ";", "}" ]
Adding custom test comparisons
[ "Adding", "custom", "test", "comparisons" ]
aedf3f31aafc05441970eec49eeeb81174c14033
https://github.com/codenothing/munit/blob/aedf3f31aafc05441970eec49eeeb81174c14033/lib/munit.js#L354-L371
56,574
codenothing/munit
lib/munit.js
function( time ) { var h, m, s; if ( time > TIME_MINUTE ) { m = parseInt( time / TIME_MINUTE, 10 ); s = ( time % TIME_MINUTE ) / TIME_SECOND; return m + 'mins, ' + s + 's'; } else if ( time > TIME_SECOND ) { return ( time / TIME_SECOND ) + 's'; } else { return time + 'ms'; } }
javascript
function( time ) { var h, m, s; if ( time > TIME_MINUTE ) { m = parseInt( time / TIME_MINUTE, 10 ); s = ( time % TIME_MINUTE ) / TIME_SECOND; return m + 'mins, ' + s + 's'; } else if ( time > TIME_SECOND ) { return ( time / TIME_SECOND ) + 's'; } else { return time + 'ms'; } }
[ "function", "(", "time", ")", "{", "var", "h", ",", "m", ",", "s", ";", "if", "(", "time", ">", "TIME_MINUTE", ")", "{", "m", "=", "parseInt", "(", "time", "/", "TIME_MINUTE", ",", "10", ")", ";", "s", "=", "(", "time", "%", "TIME_MINUTE", ")", "/", "TIME_SECOND", ";", "return", "m", "+", "'mins, '", "+", "s", "+", "'s'", ";", "}", "else", "if", "(", "time", ">", "TIME_SECOND", ")", "{", "return", "(", "time", "/", "TIME_SECOND", ")", "+", "'s'", ";", "}", "else", "{", "return", "time", "+", "'ms'", ";", "}", "}" ]
Better timestamp readability
[ "Better", "timestamp", "readability" ]
aedf3f31aafc05441970eec49eeeb81174c14033
https://github.com/codenothing/munit/blob/aedf3f31aafc05441970eec49eeeb81174c14033/lib/munit.js#L374-L388
56,575
codenothing/munit
lib/munit.js
function( string ) { return ( string || '' ).replace( ramp, "&amp;" ) .replace( rquote, "&quot;" ) .replace( rsquote, "&#039;" ) .replace( rlt, "&lt;" ) .replace( rgt, "&gt;" ); }
javascript
function( string ) { return ( string || '' ).replace( ramp, "&amp;" ) .replace( rquote, "&quot;" ) .replace( rsquote, "&#039;" ) .replace( rlt, "&lt;" ) .replace( rgt, "&gt;" ); }
[ "function", "(", "string", ")", "{", "return", "(", "string", "||", "''", ")", ".", "replace", "(", "ramp", ",", "\"&amp;\"", ")", ".", "replace", "(", "rquote", ",", "\"&quot;\"", ")", ".", "replace", "(", "rsquote", ",", "\"&#039;\"", ")", ".", "replace", "(", "rlt", ",", "\"&lt;\"", ")", ".", "replace", "(", "rgt", ",", "\"&gt;\"", ")", ";", "}" ]
Converts strings to be xml safe
[ "Converts", "strings", "to", "be", "xml", "safe" ]
aedf3f31aafc05441970eec49eeeb81174c14033
https://github.com/codenothing/munit/blob/aedf3f31aafc05441970eec49eeeb81174c14033/lib/munit.js#L391-L397
56,576
codenothing/munit
lib/munit.js
function( code, e, message ) { var callback = munit.render.callback; // Force a numeric code for the first parameter if ( ! munit.isNumber( code ) ) { throw new Error( "Numeric code parameter required for munit.exit" ); } // Allow code, message only arguments if ( message === undefined && munit.isString( e ) ) { message = e; e = null; } // Messaging if ( munit.isString( message ) ) { munit.color.red( message ); } // Force an error object for callbacks if ( ! munit.isError( e ) ) { e = new Error( message || 'munit exited' ); } e.code = code; // Only print out stack trace on an active process if ( munit.render.state !== munit.RENDER_STATE_COMPLETE ) { munit.log( e.stack ); } // Callback takes priority if ( callback ) { munit.render.callback = undefined; callback( e, munit ); } // No callback, end the process else { munit._exit( code ); } }
javascript
function( code, e, message ) { var callback = munit.render.callback; // Force a numeric code for the first parameter if ( ! munit.isNumber( code ) ) { throw new Error( "Numeric code parameter required for munit.exit" ); } // Allow code, message only arguments if ( message === undefined && munit.isString( e ) ) { message = e; e = null; } // Messaging if ( munit.isString( message ) ) { munit.color.red( message ); } // Force an error object for callbacks if ( ! munit.isError( e ) ) { e = new Error( message || 'munit exited' ); } e.code = code; // Only print out stack trace on an active process if ( munit.render.state !== munit.RENDER_STATE_COMPLETE ) { munit.log( e.stack ); } // Callback takes priority if ( callback ) { munit.render.callback = undefined; callback( e, munit ); } // No callback, end the process else { munit._exit( code ); } }
[ "function", "(", "code", ",", "e", ",", "message", ")", "{", "var", "callback", "=", "munit", ".", "render", ".", "callback", ";", "// Force a numeric code for the first parameter", "if", "(", "!", "munit", ".", "isNumber", "(", "code", ")", ")", "{", "throw", "new", "Error", "(", "\"Numeric code parameter required for munit.exit\"", ")", ";", "}", "// Allow code, message only arguments", "if", "(", "message", "===", "undefined", "&&", "munit", ".", "isString", "(", "e", ")", ")", "{", "message", "=", "e", ";", "e", "=", "null", ";", "}", "// Messaging", "if", "(", "munit", ".", "isString", "(", "message", ")", ")", "{", "munit", ".", "color", ".", "red", "(", "message", ")", ";", "}", "// Force an error object for callbacks", "if", "(", "!", "munit", ".", "isError", "(", "e", ")", ")", "{", "e", "=", "new", "Error", "(", "message", "||", "'munit exited'", ")", ";", "}", "e", ".", "code", "=", "code", ";", "// Only print out stack trace on an active process", "if", "(", "munit", ".", "render", ".", "state", "!==", "munit", ".", "RENDER_STATE_COMPLETE", ")", "{", "munit", ".", "log", "(", "e", ".", "stack", ")", ";", "}", "// Callback takes priority", "if", "(", "callback", ")", "{", "munit", ".", "render", ".", "callback", "=", "undefined", ";", "callback", "(", "e", ",", "munit", ")", ";", "}", "// No callback, end the process", "else", "{", "munit", ".", "_exit", "(", "code", ")", ";", "}", "}" ]
Helper for printing out errors before exiting
[ "Helper", "for", "printing", "out", "errors", "before", "exiting" ]
aedf3f31aafc05441970eec49eeeb81174c14033
https://github.com/codenothing/munit/blob/aedf3f31aafc05441970eec49eeeb81174c14033/lib/munit.js#L400-L439
56,577
codenothing/munit
lib/munit.js
AssertionError
function AssertionError( message, startFunc ) { var self = this; self.name = 'Assertion Error'; self.message = message; if ( Error.captureStackTrace ) { Error.captureStackTrace( self, startFunc ); } }
javascript
function AssertionError( message, startFunc ) { var self = this; self.name = 'Assertion Error'; self.message = message; if ( Error.captureStackTrace ) { Error.captureStackTrace( self, startFunc ); } }
[ "function", "AssertionError", "(", "message", ",", "startFunc", ")", "{", "var", "self", "=", "this", ";", "self", ".", "name", "=", "'Assertion Error'", ";", "self", ".", "message", "=", "message", ";", "if", "(", "Error", ".", "captureStackTrace", ")", "{", "Error", ".", "captureStackTrace", "(", "self", ",", "startFunc", ")", ";", "}", "}" ]
AssertionError stolen from node src for throwing
[ "AssertionError", "stolen", "from", "node", "src", "for", "throwing" ]
aedf3f31aafc05441970eec49eeeb81174c14033
https://github.com/codenothing/munit/blob/aedf3f31aafc05441970eec49eeeb81174c14033/lib/munit.js#L460-L469
56,578
ilkkahanninen/petiole
packages/petiole/src/actionCreatorBuilders.js
buildFromString
function buildFromString({ declaration, name, mapActionType }) { if (typeof declaration === 'string') { return arg => ({ type: mapActionType(name), [declaration]: arg, }); } return null; }
javascript
function buildFromString({ declaration, name, mapActionType }) { if (typeof declaration === 'string') { return arg => ({ type: mapActionType(name), [declaration]: arg, }); } return null; }
[ "function", "buildFromString", "(", "{", "declaration", ",", "name", ",", "mapActionType", "}", ")", "{", "if", "(", "typeof", "declaration", "===", "'string'", ")", "{", "return", "arg", "=>", "(", "{", "type", ":", "mapActionType", "(", "name", ")", ",", "[", "declaration", "]", ":", "arg", ",", "}", ")", ";", "}", "return", "null", ";", "}" ]
Strings -> simple action creatos with one argument
[ "Strings", "-", ">", "simple", "action", "creatos", "with", "one", "argument" ]
3ec52be7ad159dcf015efc9035a801fa3b52f8a2
https://github.com/ilkkahanninen/petiole/blob/3ec52be7ad159dcf015efc9035a801fa3b52f8a2/packages/petiole/src/actionCreatorBuilders.js#L10-L18
56,579
ilkkahanninen/petiole
packages/petiole/src/actionCreatorBuilders.js
buildFromArray
function buildFromArray({ declaration, name, mapActionType }) { if (Array.isArray(declaration)) { return (...args) => declaration.reduce( (result, key, index) => Object.assign( result, { [key]: args[index] } ), { type: mapActionType(name) } ); } return null; }
javascript
function buildFromArray({ declaration, name, mapActionType }) { if (Array.isArray(declaration)) { return (...args) => declaration.reduce( (result, key, index) => Object.assign( result, { [key]: args[index] } ), { type: mapActionType(name) } ); } return null; }
[ "function", "buildFromArray", "(", "{", "declaration", ",", "name", ",", "mapActionType", "}", ")", "{", "if", "(", "Array", ".", "isArray", "(", "declaration", ")", ")", "{", "return", "(", "...", "args", ")", "=>", "declaration", ".", "reduce", "(", "(", "result", ",", "key", ",", "index", ")", "=>", "Object", ".", "assign", "(", "result", ",", "{", "[", "key", "]", ":", "args", "[", "index", "]", "}", ")", ",", "{", "type", ":", "mapActionType", "(", "name", ")", "}", ")", ";", "}", "return", "null", ";", "}" ]
Arrays -> simple action creators with multiple arguments
[ "Arrays", "-", ">", "simple", "action", "creators", "with", "multiple", "arguments" ]
3ec52be7ad159dcf015efc9035a801fa3b52f8a2
https://github.com/ilkkahanninen/petiole/blob/3ec52be7ad159dcf015efc9035a801fa3b52f8a2/packages/petiole/src/actionCreatorBuilders.js#L21-L32
56,580
ilkkahanninen/petiole
packages/petiole/src/actionCreatorBuilders.js
buildFromObject
function buildFromObject({ declaration, name, mapActionType }) { if (typeof declaration === 'object') { return () => ensureActionType(declaration, name, mapActionType); } return null; }
javascript
function buildFromObject({ declaration, name, mapActionType }) { if (typeof declaration === 'object') { return () => ensureActionType(declaration, name, mapActionType); } return null; }
[ "function", "buildFromObject", "(", "{", "declaration", ",", "name", ",", "mapActionType", "}", ")", "{", "if", "(", "typeof", "declaration", "===", "'object'", ")", "{", "return", "(", ")", "=>", "ensureActionType", "(", "declaration", ",", "name", ",", "mapActionType", ")", ";", "}", "return", "null", ";", "}" ]
Objects -> simplea action creator with fixed payload
[ "Objects", "-", ">", "simplea", "action", "creator", "with", "fixed", "payload" ]
3ec52be7ad159dcf015efc9035a801fa3b52f8a2
https://github.com/ilkkahanninen/petiole/blob/3ec52be7ad159dcf015efc9035a801fa3b52f8a2/packages/petiole/src/actionCreatorBuilders.js#L35-L40
56,581
edcs/searchbar
src/searchbar.js
function () { var html = template(); var div = document.createElement('div'); div.innerHTML = html.trim(); var searchBar = this.applySearcbarEvents(div.firstChild); searchBar = this.setDefaultSearchTerm(searchBar); return searchBar; }
javascript
function () { var html = template(); var div = document.createElement('div'); div.innerHTML = html.trim(); var searchBar = this.applySearcbarEvents(div.firstChild); searchBar = this.setDefaultSearchTerm(searchBar); return searchBar; }
[ "function", "(", ")", "{", "var", "html", "=", "template", "(", ")", ";", "var", "div", "=", "document", ".", "createElement", "(", "'div'", ")", ";", "div", ".", "innerHTML", "=", "html", ".", "trim", "(", ")", ";", "var", "searchBar", "=", "this", ".", "applySearcbarEvents", "(", "div", ".", "firstChild", ")", ";", "searchBar", "=", "this", ".", "setDefaultSearchTerm", "(", "searchBar", ")", ";", "return", "searchBar", ";", "}" ]
Parses the searchbar template into an HTML string. @returns {*}
[ "Parses", "the", "searchbar", "template", "into", "an", "HTML", "string", "." ]
0734208cd098e6ddb00343a6b14c962c3b74749b
https://github.com/edcs/searchbar/blob/0734208cd098e6ddb00343a6b14c962c3b74749b/src/searchbar.js#L32-L42
56,582
edcs/searchbar
src/searchbar.js
function (searchbar) { var that = this; var button = searchbar.querySelector('button[type=submit]'); var search = searchbar.querySelector('input[type=search]'); if (typeof button === 'undefined') { return searchbar; } button.onclick = function (ev) { ev.preventDefault(); that.emitter.emit('search-request', search); }; return searchbar; }
javascript
function (searchbar) { var that = this; var button = searchbar.querySelector('button[type=submit]'); var search = searchbar.querySelector('input[type=search]'); if (typeof button === 'undefined') { return searchbar; } button.onclick = function (ev) { ev.preventDefault(); that.emitter.emit('search-request', search); }; return searchbar; }
[ "function", "(", "searchbar", ")", "{", "var", "that", "=", "this", ";", "var", "button", "=", "searchbar", ".", "querySelector", "(", "'button[type=submit]'", ")", ";", "var", "search", "=", "searchbar", ".", "querySelector", "(", "'input[type=search]'", ")", ";", "if", "(", "typeof", "button", "===", "'undefined'", ")", "{", "return", "searchbar", ";", "}", "button", ".", "onclick", "=", "function", "(", "ev", ")", "{", "ev", ".", "preventDefault", "(", ")", ";", "that", ".", "emitter", ".", "emit", "(", "'search-request'", ",", "search", ")", ";", "}", ";", "return", "searchbar", ";", "}" ]
Applies onclick events to this searchbar. @param searchbar @returns {*}
[ "Applies", "onclick", "events", "to", "this", "searchbar", "." ]
0734208cd098e6ddb00343a6b14c962c3b74749b
https://github.com/edcs/searchbar/blob/0734208cd098e6ddb00343a6b14c962c3b74749b/src/searchbar.js#L50-L65
56,583
bredele/vomit-markdown
index.js
render
function render(code, data) { var js = '```js' + code + '```' return `<div class="vomit-snippet"><div class="column">${marked(js)}</div><div class="column"><script> (function() {${code}document.currentScript.parentElement.appendChild(component(${JSON.stringify(data.data)})) })()</script></div></div>` }
javascript
function render(code, data) { var js = '```js' + code + '```' return `<div class="vomit-snippet"><div class="column">${marked(js)}</div><div class="column"><script> (function() {${code}document.currentScript.parentElement.appendChild(component(${JSON.stringify(data.data)})) })()</script></div></div>` }
[ "function", "render", "(", "code", ",", "data", ")", "{", "var", "js", "=", "'```js'", "+", "code", "+", "'```'", "return", "`", "${", "marked", "(", "js", ")", "}", "${", "code", "}", "${", "JSON", ".", "stringify", "(", "data", ".", "data", ")", "}", "`", "}" ]
Render code and live example. @param {String} code @param {Object} data @api private
[ "Render", "code", "and", "live", "example", "." ]
6ec3ff809167cabe6f0a03464a06d470dbdc9219
https://github.com/bredele/vomit-markdown/blob/6ec3ff809167cabe6f0a03464a06d470dbdc9219/index.js#L41-L46
56,584
huafu/ember-enhanced-router
addon/route.js
route
function route(name, titleToken, options) { var path, match; if (name instanceof RouteMeta) { return name; } if (name) { match = name.match(/^([^@]+)(?:@(.*))?$/); name = match[1]; path = match[2]; if (path === undefined) { path = name === 'index' ? '/' : name; } else if (path === '') { path = '/'; } else if (path === '*') { path = '/*wildcard'; } } else { path = '/'; } return RouteMeta.create({ name: name || 'application', path: path, routerTitleToken: {value: titleToken}, options: options || {} }); }
javascript
function route(name, titleToken, options) { var path, match; if (name instanceof RouteMeta) { return name; } if (name) { match = name.match(/^([^@]+)(?:@(.*))?$/); name = match[1]; path = match[2]; if (path === undefined) { path = name === 'index' ? '/' : name; } else if (path === '') { path = '/'; } else if (path === '*') { path = '/*wildcard'; } } else { path = '/'; } return RouteMeta.create({ name: name || 'application', path: path, routerTitleToken: {value: titleToken}, options: options || {} }); }
[ "function", "route", "(", "name", ",", "titleToken", ",", "options", ")", "{", "var", "path", ",", "match", ";", "if", "(", "name", "instanceof", "RouteMeta", ")", "{", "return", "name", ";", "}", "if", "(", "name", ")", "{", "match", "=", "name", ".", "match", "(", "/", "^([^@]+)(?:@(.*))?$", "/", ")", ";", "name", "=", "match", "[", "1", "]", ";", "path", "=", "match", "[", "2", "]", ";", "if", "(", "path", "===", "undefined", ")", "{", "path", "=", "name", "===", "'index'", "?", "'/'", ":", "name", ";", "}", "else", "if", "(", "path", "===", "''", ")", "{", "path", "=", "'/'", ";", "}", "else", "if", "(", "path", "===", "'*'", ")", "{", "path", "=", "'/*wildcard'", ";", "}", "}", "else", "{", "path", "=", "'/'", ";", "}", "return", "RouteMeta", ".", "create", "(", "{", "name", ":", "name", "||", "'application'", ",", "path", ":", "path", ",", "routerTitleToken", ":", "{", "value", ":", "titleToken", "}", ",", "options", ":", "options", "||", "{", "}", "}", ")", ";", "}" ]
Build the Ember expected map for a route @module ember-enhanced-router @function route @param {string|RouteMeta} [name=null] The name of the route with an optional path after `@`, or null for application route @param {string|Function} [titleToken] The title token for that route, or a function to create it @param {{resetTitle: boolean}} [options] Options @return {RouteMeta}
[ "Build", "the", "Ember", "expected", "map", "for", "a", "route" ]
47aa023dd5069de18ad4dd116ef18dd1f2160fbb
https://github.com/huafu/ember-enhanced-router/blob/47aa023dd5069de18ad4dd116ef18dd1f2160fbb/addon/route.js#L32-L60
56,585
huafu/ember-enhanced-router
addon/route.js
function (target) { if (this.get('isResource') && !this.get('indexChild')) { // add index route if it does not exist this._route('index'); } this.get('children').forEach(function (meta) { var args, methodName, isResource; args = [meta.get('name'), {path: meta.get('path')}]; methodName = meta.get('methodName'); isResource = meta.get('isResource'); if (isResource) { args.push(meta.get('mapFunction')); } console[isResource && console.group ? 'group' : 'log']( '[enhanced-router] defining ' + meta ); target[methodName].apply(target, args); if (isResource && console.group) { console.groupEnd(); } }); }
javascript
function (target) { if (this.get('isResource') && !this.get('indexChild')) { // add index route if it does not exist this._route('index'); } this.get('children').forEach(function (meta) { var args, methodName, isResource; args = [meta.get('name'), {path: meta.get('path')}]; methodName = meta.get('methodName'); isResource = meta.get('isResource'); if (isResource) { args.push(meta.get('mapFunction')); } console[isResource && console.group ? 'group' : 'log']( '[enhanced-router] defining ' + meta ); target[methodName].apply(target, args); if (isResource && console.group) { console.groupEnd(); } }); }
[ "function", "(", "target", ")", "{", "if", "(", "this", ".", "get", "(", "'isResource'", ")", "&&", "!", "this", ".", "get", "(", "'indexChild'", ")", ")", "{", "// add index route if it does not exist", "this", ".", "_route", "(", "'index'", ")", ";", "}", "this", ".", "get", "(", "'children'", ")", ".", "forEach", "(", "function", "(", "meta", ")", "{", "var", "args", ",", "methodName", ",", "isResource", ";", "args", "=", "[", "meta", ".", "get", "(", "'name'", ")", ",", "{", "path", ":", "meta", ".", "get", "(", "'path'", ")", "}", "]", ";", "methodName", "=", "meta", ".", "get", "(", "'methodName'", ")", ";", "isResource", "=", "meta", ".", "get", "(", "'isResource'", ")", ";", "if", "(", "isResource", ")", "{", "args", ".", "push", "(", "meta", ".", "get", "(", "'mapFunction'", ")", ")", ";", "}", "console", "[", "isResource", "&&", "console", ".", "group", "?", "'group'", ":", "'log'", "]", "(", "'[enhanced-router] defining '", "+", "meta", ")", ";", "target", "[", "methodName", "]", ".", "apply", "(", "target", ",", "args", ")", ";", "if", "(", "isResource", "&&", "console", ".", "group", ")", "{", "console", ".", "groupEnd", "(", ")", ";", "}", "}", ")", ";", "}" ]
The method doing the call as Router.map is expecting @method map @param {Ember.Router.recognizer} target
[ "The", "method", "doing", "the", "call", "as", "Router", ".", "map", "is", "expecting" ]
47aa023dd5069de18ad4dd116ef18dd1f2160fbb
https://github.com/huafu/ember-enhanced-router/blob/47aa023dd5069de18ad4dd116ef18dd1f2160fbb/addon/route.js#L304-L325
56,586
huafu/ember-enhanced-router
addon/route.js
function (name, titleToken, options) { var child; if (!this.get('isResource')) { this.set('isResource', true); } child = route(name, titleToken, options, this); child.set('parent', this); this.get('children').pushObject(child); return this; }
javascript
function (name, titleToken, options) { var child; if (!this.get('isResource')) { this.set('isResource', true); } child = route(name, titleToken, options, this); child.set('parent', this); this.get('children').pushObject(child); return this; }
[ "function", "(", "name", ",", "titleToken", ",", "options", ")", "{", "var", "child", ";", "if", "(", "!", "this", ".", "get", "(", "'isResource'", ")", ")", "{", "this", ".", "set", "(", "'isResource'", ",", "true", ")", ";", "}", "child", "=", "route", "(", "name", ",", "titleToken", ",", "options", ",", "this", ")", ";", "child", ".", "set", "(", "'parent'", ",", "this", ")", ";", "this", ".", "get", "(", "'children'", ")", ".", "pushObject", "(", "child", ")", ";", "return", "this", ";", "}" ]
Define a child-route to this route @method route @param {string|RouteMeta} name @param {string} [titleToken] @param {{resetTitle: boolean}} [options] @chainable
[ "Define", "a", "child", "-", "route", "to", "this", "route" ]
47aa023dd5069de18ad4dd116ef18dd1f2160fbb
https://github.com/huafu/ember-enhanced-router/blob/47aa023dd5069de18ad4dd116ef18dd1f2160fbb/addon/route.js#L403-L412
56,587
huafu/ember-enhanced-router
addon/route.js
function () { var routes = Array.prototype.slice.call(arguments); if (routes.length) { Ember.A(routes).forEach(function (child) { this._route(child); }, this); } else { if (!this.get('isResource')) { this.set('isResource', true); } } return this; }
javascript
function () { var routes = Array.prototype.slice.call(arguments); if (routes.length) { Ember.A(routes).forEach(function (child) { this._route(child); }, this); } else { if (!this.get('isResource')) { this.set('isResource', true); } } return this; }
[ "function", "(", ")", "{", "var", "routes", "=", "Array", ".", "prototype", ".", "slice", ".", "call", "(", "arguments", ")", ";", "if", "(", "routes", ".", "length", ")", "{", "Ember", ".", "A", "(", "routes", ")", ".", "forEach", "(", "function", "(", "child", ")", "{", "this", ".", "_route", "(", "child", ")", ";", "}", ",", "this", ")", ";", "}", "else", "{", "if", "(", "!", "this", ".", "get", "(", "'isResource'", ")", ")", "{", "this", ".", "set", "(", "'isResource'", ",", "true", ")", ";", "}", "}", "return", "this", ";", "}" ]
Define many child-routes to this route @method routes @params {RouteMeta} [meta...] @chainable
[ "Define", "many", "child", "-", "routes", "to", "this", "route" ]
47aa023dd5069de18ad4dd116ef18dd1f2160fbb
https://github.com/huafu/ember-enhanced-router/blob/47aa023dd5069de18ad4dd116ef18dd1f2160fbb/addon/route.js#L421-L434
56,588
huafu/ember-enhanced-router
addon/route.js
function (options) { var Router, args; if (this.get('parent')) { throw new Error('Only the root route may be exported as an Ember router.'); } args = slice.call(arguments); if (!args.length || args[args.length - 1] instanceof Ember.Mixin) { args.push(options = {}); } else { options = args[args.length - 1]; } options._enhancedRouterRootMeta = this; Router = Ember.Router.extend.apply(Ember.Router, args); Router.map(this.get('mapFunction')); return Router; }
javascript
function (options) { var Router, args; if (this.get('parent')) { throw new Error('Only the root route may be exported as an Ember router.'); } args = slice.call(arguments); if (!args.length || args[args.length - 1] instanceof Ember.Mixin) { args.push(options = {}); } else { options = args[args.length - 1]; } options._enhancedRouterRootMeta = this; Router = Ember.Router.extend.apply(Ember.Router, args); Router.map(this.get('mapFunction')); return Router; }
[ "function", "(", "options", ")", "{", "var", "Router", ",", "args", ";", "if", "(", "this", ".", "get", "(", "'parent'", ")", ")", "{", "throw", "new", "Error", "(", "'Only the root route may be exported as an Ember router.'", ")", ";", "}", "args", "=", "slice", ".", "call", "(", "arguments", ")", ";", "if", "(", "!", "args", ".", "length", "||", "args", "[", "args", ".", "length", "-", "1", "]", "instanceof", "Ember", ".", "Mixin", ")", "{", "args", ".", "push", "(", "options", "=", "{", "}", ")", ";", "}", "else", "{", "options", "=", "args", "[", "args", ".", "length", "-", "1", "]", ";", "}", "options", ".", "_enhancedRouterRootMeta", "=", "this", ";", "Router", "=", "Ember", ".", "Router", ".", "extend", ".", "apply", "(", "Ember", ".", "Router", ",", "args", ")", ";", "Router", ".", "map", "(", "this", ".", "get", "(", "'mapFunction'", ")", ")", ";", "return", "Router", ";", "}" ]
Transforms this RouteMeta into an Ember router @method toRouter @param {Object} options @return {Ember.Router}
[ "Transforms", "this", "RouteMeta", "into", "an", "Ember", "router" ]
47aa023dd5069de18ad4dd116ef18dd1f2160fbb
https://github.com/huafu/ember-enhanced-router/blob/47aa023dd5069de18ad4dd116ef18dd1f2160fbb/addon/route.js#L452-L468
56,589
rmariuzzo/fuf
fuf.js
fuf
function fuf(target, source, options = {}) { return new Promise((resolve, reject) => { if (!target) { return reject(new Error('the target path is required')) } if (!source) { return reject(new Error('the source path is required')) } if (options && MATCHES.indexOf(options.match) === -1) { return reject(new Error(`options.match should be one of the following values: ${MATCHES.join(', ')}.`)) } options = { ...defaults, ...options } Promise.all([ pglob(target, { nodir: true, ignore: source }), findSourceFiles(source), ]).then(([targetFiles, sourceFiles]) => { // By default all source files are considered unused. const unused = sourceFiles.map(file => ({ ...file })) // We loop through all files looking for unused files matches, when we // found a match we removed it from the unused bag. const results = targetFiles.map(file => { return fs.readFile(file) .then(data => { const matches = findMatches(data.toString(), unused.map(u => u[options.match])) matches.forEach(match => { // Remove match from unused. unused.splice(unused.findIndex(u => u[options.match] === match.needle), 1) // Remove match from source files. sourceFiles.splice(sourceFiles.findIndex(f => f[options.match] === match.needle), 1) }) }) }) Promise .all(results) .then(() => { resolve({ unused }) }) }).catch(reject) }) }
javascript
function fuf(target, source, options = {}) { return new Promise((resolve, reject) => { if (!target) { return reject(new Error('the target path is required')) } if (!source) { return reject(new Error('the source path is required')) } if (options && MATCHES.indexOf(options.match) === -1) { return reject(new Error(`options.match should be one of the following values: ${MATCHES.join(', ')}.`)) } options = { ...defaults, ...options } Promise.all([ pglob(target, { nodir: true, ignore: source }), findSourceFiles(source), ]).then(([targetFiles, sourceFiles]) => { // By default all source files are considered unused. const unused = sourceFiles.map(file => ({ ...file })) // We loop through all files looking for unused files matches, when we // found a match we removed it from the unused bag. const results = targetFiles.map(file => { return fs.readFile(file) .then(data => { const matches = findMatches(data.toString(), unused.map(u => u[options.match])) matches.forEach(match => { // Remove match from unused. unused.splice(unused.findIndex(u => u[options.match] === match.needle), 1) // Remove match from source files. sourceFiles.splice(sourceFiles.findIndex(f => f[options.match] === match.needle), 1) }) }) }) Promise .all(results) .then(() => { resolve({ unused }) }) }).catch(reject) }) }
[ "function", "fuf", "(", "target", ",", "source", ",", "options", "=", "{", "}", ")", "{", "return", "new", "Promise", "(", "(", "resolve", ",", "reject", ")", "=>", "{", "if", "(", "!", "target", ")", "{", "return", "reject", "(", "new", "Error", "(", "'the target path is required'", ")", ")", "}", "if", "(", "!", "source", ")", "{", "return", "reject", "(", "new", "Error", "(", "'the source path is required'", ")", ")", "}", "if", "(", "options", "&&", "MATCHES", ".", "indexOf", "(", "options", ".", "match", ")", "===", "-", "1", ")", "{", "return", "reject", "(", "new", "Error", "(", "`", "${", "MATCHES", ".", "join", "(", "', '", ")", "}", "`", ")", ")", "}", "options", "=", "{", "...", "defaults", ",", "...", "options", "}", "Promise", ".", "all", "(", "[", "pglob", "(", "target", ",", "{", "nodir", ":", "true", ",", "ignore", ":", "source", "}", ")", ",", "findSourceFiles", "(", "source", ")", ",", "]", ")", ".", "then", "(", "(", "[", "targetFiles", ",", "sourceFiles", "]", ")", "=>", "{", "// By default all source files are considered unused.", "const", "unused", "=", "sourceFiles", ".", "map", "(", "file", "=>", "(", "{", "...", "file", "}", ")", ")", "// We loop through all files looking for unused files matches, when we", "// found a match we removed it from the unused bag.", "const", "results", "=", "targetFiles", ".", "map", "(", "file", "=>", "{", "return", "fs", ".", "readFile", "(", "file", ")", ".", "then", "(", "data", "=>", "{", "const", "matches", "=", "findMatches", "(", "data", ".", "toString", "(", ")", ",", "unused", ".", "map", "(", "u", "=>", "u", "[", "options", ".", "match", "]", ")", ")", "matches", ".", "forEach", "(", "match", "=>", "{", "// Remove match from unused.", "unused", ".", "splice", "(", "unused", ".", "findIndex", "(", "u", "=>", "u", "[", "options", ".", "match", "]", "===", "match", ".", "needle", ")", ",", "1", ")", "// Remove match from source files.", "sourceFiles", ".", "splice", "(", "sourceFiles", ".", "findIndex", "(", "f", "=>", "f", "[", "options", ".", "match", "]", "===", "match", ".", "needle", ")", ",", "1", ")", "}", ")", "}", ")", "}", ")", "Promise", ".", "all", "(", "results", ")", ".", "then", "(", "(", ")", "=>", "{", "resolve", "(", "{", "unused", "}", ")", "}", ")", "}", ")", ".", "catch", "(", "reject", ")", "}", ")", "}" ]
Find unused files. @param {string} target The target directory containing files that will be used to look for usage. @param {string} source The source directory containing files that will be determined if unused. @param {FufOptions} options The options. @return {Promise<FindSourceFilesResult[]> Error>}
[ "Find", "unused", "files", "." ]
77743e94fd1df628beee0126fc6ce000b7f7814b
https://github.com/rmariuzzo/fuf/blob/77743e94fd1df628beee0126fc6ce000b7f7814b/fuf.js#L40-L86
56,590
rmariuzzo/fuf
fuf.js
pglob
function pglob(pattern, options) { return new Promise((resolve, reject) => { glob(pattern, options, (error, files) => { if (error) { return reject(error) } resolve(files) }) }) }
javascript
function pglob(pattern, options) { return new Promise((resolve, reject) => { glob(pattern, options, (error, files) => { if (error) { return reject(error) } resolve(files) }) }) }
[ "function", "pglob", "(", "pattern", ",", "options", ")", "{", "return", "new", "Promise", "(", "(", "resolve", ",", "reject", ")", "=>", "{", "glob", "(", "pattern", ",", "options", ",", "(", "error", ",", "files", ")", "=>", "{", "if", "(", "error", ")", "{", "return", "reject", "(", "error", ")", "}", "resolve", "(", "files", ")", "}", ")", "}", ")", "}" ]
Promisify version of glob. @param {string} pattern The glob pattern. @param {Object} options The hash of options. @return {Promise<string[], Error>}
[ "Promisify", "version", "of", "glob", "." ]
77743e94fd1df628beee0126fc6ce000b7f7814b
https://github.com/rmariuzzo/fuf/blob/77743e94fd1df628beee0126fc6ce000b7f7814b/fuf.js#L127-L136
56,591
piranna/jocker
lib/index.js
chrootSpawn
function chrootSpawn(command, argv, opts, callback) { argv = [opts.uid, opts.gid, command].concat(argv) const options = { cwd: opts.cwd, env: opts.env, stdio: 'inherit' } proc.spawn(`${__dirname}/chrootSpawn`, argv, options).on('exit', callback) }
javascript
function chrootSpawn(command, argv, opts, callback) { argv = [opts.uid, opts.gid, command].concat(argv) const options = { cwd: opts.cwd, env: opts.env, stdio: 'inherit' } proc.spawn(`${__dirname}/chrootSpawn`, argv, options).on('exit', callback) }
[ "function", "chrootSpawn", "(", "command", ",", "argv", ",", "opts", ",", "callback", ")", "{", "argv", "=", "[", "opts", ".", "uid", ",", "opts", ".", "gid", ",", "command", "]", ".", "concat", "(", "argv", ")", "const", "options", "=", "{", "cwd", ":", "opts", ".", "cwd", ",", "env", ":", "opts", ".", "env", ",", "stdio", ":", "'inherit'", "}", "proc", ".", "spawn", "(", "`", "${", "__dirname", "}", "`", ",", "argv", ",", "options", ")", ".", "on", "(", "'exit'", ",", "callback", ")", "}" ]
Exec a command on a `chroot`ed directory with un-priviledged permissions @param {String} command Path of the command file inside the home folder @param {String[]} [argv] Command arguments @param {Object} [opts] Extra options @param {Function} callback
[ "Exec", "a", "command", "on", "a", "chroot", "ed", "directory", "with", "un", "-", "priviledged", "permissions" ]
a4c53fb5c1de65a4a490fd04bdae4d03a7f9ca54
https://github.com/piranna/jocker/blob/a4c53fb5c1de65a4a490fd04bdae4d03a7f9ca54/lib/index.js#L26-L38
56,592
piranna/jocker
lib/index.js
mkdirMountInfo
function mkdirMountInfo(info, callback) { utils.mkdirMount(info.path, info.type, info.flags, info.extras, callback) }
javascript
function mkdirMountInfo(info, callback) { utils.mkdirMount(info.path, info.type, info.flags, info.extras, callback) }
[ "function", "mkdirMountInfo", "(", "info", ",", "callback", ")", "{", "utils", ".", "mkdirMount", "(", "info", ".", "path", ",", "info", ".", "type", ",", "info", ".", "flags", ",", "info", ".", "extras", ",", "callback", ")", "}" ]
Mounts the provided path to the device If no device is available then it uses the type @access private @param {Object} info This object holds information about the folder to create @property {String} info.dev Device-File being mounted (located in `/dev`) a.k.a. devFile. @property {String} info.path Directory to mount the device to. @property {String} info.type Filesystem identificator (one of `/proc/filesystems`). @property {Array|Number} info.[flags] Flags for mounting @property {String} info.[extras] The data argument is interpreted by the different file systems. Typically it is a string of comma-separated options understood by this file system @param {Function} callback Function called after the mount operation finishes. Receives only one argument err.
[ "Mounts", "the", "provided", "path", "to", "the", "device" ]
a4c53fb5c1de65a4a490fd04bdae4d03a7f9ca54
https://github.com/piranna/jocker/blob/a4c53fb5c1de65a4a490fd04bdae4d03a7f9ca54/lib/index.js#L62-L65
56,593
piranna/jocker
lib/index.js
create
function create(upperdir, callback) { var workdir = upperdir.split('/') var user = workdir.pop() var workdir = workdir.join('/')+'/.workdirs/'+user mkdirp(workdir, '0100', function(error) { if(error && error.code !== 'EEXIST') return callback(error) // Craft overlayed filesystem var type = 'overlay' var extras = { lowerdir: '/', upperdir: upperdir, workdir : workdir } utils.mkdirMount(upperdir, type, MS_NOSUID, extras, function(error) { if(error) return callback(error) var arr = [ { path: upperdir+'/dev', flags: MS_BIND, extras: {devFile: '/tmp/dev'} }, { path: upperdir+'/proc', flags: MS_BIND, extras: {devFile: '/proc'} }, { path: upperdir+'/tmp', type: 'tmpfs', flags: MS_NODEV | MS_NOSUID } ] each(arr, mkdirMountInfo, callback) }) }) }
javascript
function create(upperdir, callback) { var workdir = upperdir.split('/') var user = workdir.pop() var workdir = workdir.join('/')+'/.workdirs/'+user mkdirp(workdir, '0100', function(error) { if(error && error.code !== 'EEXIST') return callback(error) // Craft overlayed filesystem var type = 'overlay' var extras = { lowerdir: '/', upperdir: upperdir, workdir : workdir } utils.mkdirMount(upperdir, type, MS_NOSUID, extras, function(error) { if(error) return callback(error) var arr = [ { path: upperdir+'/dev', flags: MS_BIND, extras: {devFile: '/tmp/dev'} }, { path: upperdir+'/proc', flags: MS_BIND, extras: {devFile: '/proc'} }, { path: upperdir+'/tmp', type: 'tmpfs', flags: MS_NODEV | MS_NOSUID } ] each(arr, mkdirMountInfo, callback) }) }) }
[ "function", "create", "(", "upperdir", ",", "callback", ")", "{", "var", "workdir", "=", "upperdir", ".", "split", "(", "'/'", ")", "var", "user", "=", "workdir", ".", "pop", "(", ")", "var", "workdir", "=", "workdir", ".", "join", "(", "'/'", ")", "+", "'/.workdirs/'", "+", "user", "mkdirp", "(", "workdir", ",", "'0100'", ",", "function", "(", "error", ")", "{", "if", "(", "error", "&&", "error", ".", "code", "!==", "'EEXIST'", ")", "return", "callback", "(", "error", ")", "// Craft overlayed filesystem", "var", "type", "=", "'overlay'", "var", "extras", "=", "{", "lowerdir", ":", "'/'", ",", "upperdir", ":", "upperdir", ",", "workdir", ":", "workdir", "}", "utils", ".", "mkdirMount", "(", "upperdir", ",", "type", ",", "MS_NOSUID", ",", "extras", ",", "function", "(", "error", ")", "{", "if", "(", "error", ")", "return", "callback", "(", "error", ")", "var", "arr", "=", "[", "{", "path", ":", "upperdir", "+", "'/dev'", ",", "flags", ":", "MS_BIND", ",", "extras", ":", "{", "devFile", ":", "'/tmp/dev'", "}", "}", ",", "{", "path", ":", "upperdir", "+", "'/proc'", ",", "flags", ":", "MS_BIND", ",", "extras", ":", "{", "devFile", ":", "'/proc'", "}", "}", ",", "{", "path", ":", "upperdir", "+", "'/tmp'", ",", "type", ":", "'tmpfs'", ",", "flags", ":", "MS_NODEV", "|", "MS_NOSUID", "}", "]", "each", "(", "arr", ",", "mkdirMountInfo", ",", "callback", ")", "}", ")", "}", ")", "}" ]
Public API Execute the command file @param {String} upperdir Path of the root of the container @param {Function} callback
[ "Public", "API", "Execute", "the", "command", "file" ]
a4c53fb5c1de65a4a490fd04bdae4d03a7f9ca54
https://github.com/piranna/jocker/blob/a4c53fb5c1de65a4a490fd04bdae4d03a7f9ca54/lib/index.js#L78-L123
56,594
richRemer/twixt-class
class.js
clas
function clas(elem, className) { /** * @param {boolean} [val] * @returns {boolean|undefined} */ return function() { if (arguments.length) { elem.classList[arguments[0] ? "add" : "remove"](className); } else { return elem.classList.has(className); } } }
javascript
function clas(elem, className) { /** * @param {boolean} [val] * @returns {boolean|undefined} */ return function() { if (arguments.length) { elem.classList[arguments[0] ? "add" : "remove"](className); } else { return elem.classList.has(className); } } }
[ "function", "clas", "(", "elem", ",", "className", ")", "{", "/**\n * @param {boolean} [val]\n * @returns {boolean|undefined}\n */", "return", "function", "(", ")", "{", "if", "(", "arguments", ".", "length", ")", "{", "elem", ".", "classList", "[", "arguments", "[", "0", "]", "?", "\"add\"", ":", "\"remove\"", "]", "(", "className", ")", ";", "}", "else", "{", "return", "elem", ".", "classList", ".", "has", "(", "className", ")", ";", "}", "}", "}" ]
Create function bound to DOM class. Class will be enabled when function is called with truthy value and disabled when called with falsey value. When called without an argument, the function will return a boolean indicating if the class is set. @param {Element} elem @param {string} className @returns {function}
[ "Create", "function", "bound", "to", "DOM", "class", ".", "Class", "will", "be", "enabled", "when", "function", "is", "called", "with", "truthy", "value", "and", "disabled", "when", "called", "with", "falsey", "value", ".", "When", "called", "without", "an", "argument", "the", "function", "will", "return", "a", "boolean", "indicating", "if", "the", "class", "is", "set", "." ]
1ab36fd6aa7a6bc385e43ba2dbe5b36d5770f658
https://github.com/richRemer/twixt-class/blob/1ab36fd6aa7a6bc385e43ba2dbe5b36d5770f658/class.js#L10-L22
56,595
tamtakoe/validators-constructor
src/validators-constructor.js
formatStr
function formatStr(str, values) { values = values || {}; if (typeof str !== 'string') { return str; } return str.replace(FORMAT_REGEXP, (m0, m1, m2) => (m1 === '%' ? "%{" + m2 + "}" : values[m2])); }
javascript
function formatStr(str, values) { values = values || {}; if (typeof str !== 'string') { return str; } return str.replace(FORMAT_REGEXP, (m0, m1, m2) => (m1 === '%' ? "%{" + m2 + "}" : values[m2])); }
[ "function", "formatStr", "(", "str", ",", "values", ")", "{", "values", "=", "values", "||", "{", "}", ";", "if", "(", "typeof", "str", "!==", "'string'", ")", "{", "return", "str", ";", "}", "return", "str", ".", "replace", "(", "FORMAT_REGEXP", ",", "(", "m0", ",", "m1", ",", "m2", ")", "=>", "(", "m1", "===", "'%'", "?", "\"%{\"", "+", "m2", "+", "\"}\"", ":", "values", "[", "m2", "]", ")", ")", ";", "}" ]
Format string with patterns @param {String} str ("I'm %{age} years old") @param {Object} [values] ({age: 21}) @returns {String} formatted string ("I'm 21 years old")
[ "Format", "string", "with", "patterns" ]
4fa201d6c58da7232633c6b1820dd9d81cd13432
https://github.com/tamtakoe/validators-constructor/blob/4fa201d6c58da7232633c6b1820dd9d81cd13432/src/validators-constructor.js#L117-L125
56,596
skerit/alchemy-styleboost
public/ckeditor/4.4dev/plugins/undo/plugin.js
function( keyCode, strokesPerSnapshotExceeded ) { var keyGroup = UndoManager.getKeyGroup( keyCode ), // Count of keystrokes in current a row. // Note if strokesPerSnapshotExceeded will be exceeded, it'll be restarted. strokesRecorded = this.strokesRecorded[ keyGroup ] + 1; strokesPerSnapshotExceeded = ( strokesPerSnapshotExceeded || strokesRecorded >= this.strokesLimit ); if ( !this.typing ) onTypingStart( this ); if ( strokesPerSnapshotExceeded ) { // Reset the count of strokes, so it'll be later assigned to this.strokesRecorded. strokesRecorded = 0; this.editor.fire( 'saveSnapshot' ); } else { // Fire change event. this.editor.fire( 'change' ); } // Store recorded strokes count. this.strokesRecorded[ keyGroup ] = strokesRecorded; // This prop will tell in next itaration what kind of group was processed previously. this.previousKeyGroup = keyGroup; }
javascript
function( keyCode, strokesPerSnapshotExceeded ) { var keyGroup = UndoManager.getKeyGroup( keyCode ), // Count of keystrokes in current a row. // Note if strokesPerSnapshotExceeded will be exceeded, it'll be restarted. strokesRecorded = this.strokesRecorded[ keyGroup ] + 1; strokesPerSnapshotExceeded = ( strokesPerSnapshotExceeded || strokesRecorded >= this.strokesLimit ); if ( !this.typing ) onTypingStart( this ); if ( strokesPerSnapshotExceeded ) { // Reset the count of strokes, so it'll be later assigned to this.strokesRecorded. strokesRecorded = 0; this.editor.fire( 'saveSnapshot' ); } else { // Fire change event. this.editor.fire( 'change' ); } // Store recorded strokes count. this.strokesRecorded[ keyGroup ] = strokesRecorded; // This prop will tell in next itaration what kind of group was processed previously. this.previousKeyGroup = keyGroup; }
[ "function", "(", "keyCode", ",", "strokesPerSnapshotExceeded", ")", "{", "var", "keyGroup", "=", "UndoManager", ".", "getKeyGroup", "(", "keyCode", ")", ",", "// Count of keystrokes in current a row.\r", "// Note if strokesPerSnapshotExceeded will be exceeded, it'll be restarted.\r", "strokesRecorded", "=", "this", ".", "strokesRecorded", "[", "keyGroup", "]", "+", "1", ";", "strokesPerSnapshotExceeded", "=", "(", "strokesPerSnapshotExceeded", "||", "strokesRecorded", ">=", "this", ".", "strokesLimit", ")", ";", "if", "(", "!", "this", ".", "typing", ")", "onTypingStart", "(", "this", ")", ";", "if", "(", "strokesPerSnapshotExceeded", ")", "{", "// Reset the count of strokes, so it'll be later assigned to this.strokesRecorded.\r", "strokesRecorded", "=", "0", ";", "this", ".", "editor", ".", "fire", "(", "'saveSnapshot'", ")", ";", "}", "else", "{", "// Fire change event.\r", "this", ".", "editor", ".", "fire", "(", "'change'", ")", ";", "}", "// Store recorded strokes count.\r", "this", ".", "strokesRecorded", "[", "keyGroup", "]", "=", "strokesRecorded", ";", "// This prop will tell in next itaration what kind of group was processed previously.\r", "this", ".", "previousKeyGroup", "=", "keyGroup", ";", "}" ]
Handles keystroke support for the undo manager. It is called on `keyup` event for keystrokes that can change the editor content. @param {Number} keyCode The key code. @param {Boolean} [strokesPerSnapshotExceeded] When set to `true`, the method will behave as if the strokes limit was exceeded regardless of the {@link #strokesRecorded} value.
[ "Handles", "keystroke", "support", "for", "the", "undo", "manager", ".", "It", "is", "called", "on", "keyup", "event", "for", "keystrokes", "that", "can", "change", "the", "editor", "content", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/undo/plugin.js#L258-L284
56,597
skerit/alchemy-styleboost
public/ckeditor/4.4dev/plugins/undo/plugin.js
function() { // Stack for all the undo and redo snapshots, they're always created/removed // in consistency. this.snapshots = []; // Current snapshot history index. this.index = -1; this.currentImage = null; this.hasUndo = false; this.hasRedo = false; this.locked = null; this.resetType(); }
javascript
function() { // Stack for all the undo and redo snapshots, they're always created/removed // in consistency. this.snapshots = []; // Current snapshot history index. this.index = -1; this.currentImage = null; this.hasUndo = false; this.hasRedo = false; this.locked = null; this.resetType(); }
[ "function", "(", ")", "{", "// Stack for all the undo and redo snapshots, they're always created/removed\r", "// in consistency.\r", "this", ".", "snapshots", "=", "[", "]", ";", "// Current snapshot history index.\r", "this", ".", "index", "=", "-", "1", ";", "this", ".", "currentImage", "=", "null", ";", "this", ".", "hasUndo", "=", "false", ";", "this", ".", "hasRedo", "=", "false", ";", "this", ".", "locked", "=", "null", ";", "this", ".", "resetType", "(", ")", ";", "}" ]
Resets the undo stack.
[ "Resets", "the", "undo", "stack", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/undo/plugin.js#L300-L315
56,598
skerit/alchemy-styleboost
public/ckeditor/4.4dev/plugins/undo/plugin.js
function( onContentOnly, image, autoFireChange ) { var editor = this.editor; // Do not change snapshots stack when locked, editor is not ready, // editable is not ready or when editor is in mode difference than 'wysiwyg'. if ( this.locked || editor.status != 'ready' || editor.mode != 'wysiwyg' ) return false; var editable = editor.editable(); if ( !editable || editable.status != 'ready' ) return false; var snapshots = this.snapshots; // Get a content image. if ( !image ) image = new Image( editor ); // Do nothing if it was not possible to retrieve an image. if ( image.contents === false ) return false; // Check if this is a duplicate. In such case, do nothing. if ( this.currentImage ) { if ( image.equalsContent( this.currentImage ) ) { if ( onContentOnly ) return false; if ( image.equalsSelection( this.currentImage ) ) return false; } else if ( autoFireChange !== false ) { editor.fire( 'change' ); } } // Drop future snapshots. snapshots.splice( this.index + 1, snapshots.length - this.index - 1 ); // If we have reached the limit, remove the oldest one. if ( snapshots.length == this.limit ) snapshots.shift(); // Add the new image, updating the current index. this.index = snapshots.push( image ) - 1; this.currentImage = image; if ( autoFireChange !== false ) this.refreshState(); return true; }
javascript
function( onContentOnly, image, autoFireChange ) { var editor = this.editor; // Do not change snapshots stack when locked, editor is not ready, // editable is not ready or when editor is in mode difference than 'wysiwyg'. if ( this.locked || editor.status != 'ready' || editor.mode != 'wysiwyg' ) return false; var editable = editor.editable(); if ( !editable || editable.status != 'ready' ) return false; var snapshots = this.snapshots; // Get a content image. if ( !image ) image = new Image( editor ); // Do nothing if it was not possible to retrieve an image. if ( image.contents === false ) return false; // Check if this is a duplicate. In such case, do nothing. if ( this.currentImage ) { if ( image.equalsContent( this.currentImage ) ) { if ( onContentOnly ) return false; if ( image.equalsSelection( this.currentImage ) ) return false; } else if ( autoFireChange !== false ) { editor.fire( 'change' ); } } // Drop future snapshots. snapshots.splice( this.index + 1, snapshots.length - this.index - 1 ); // If we have reached the limit, remove the oldest one. if ( snapshots.length == this.limit ) snapshots.shift(); // Add the new image, updating the current index. this.index = snapshots.push( image ) - 1; this.currentImage = image; if ( autoFireChange !== false ) this.refreshState(); return true; }
[ "function", "(", "onContentOnly", ",", "image", ",", "autoFireChange", ")", "{", "var", "editor", "=", "this", ".", "editor", ";", "// Do not change snapshots stack when locked, editor is not ready,\r", "// editable is not ready or when editor is in mode difference than 'wysiwyg'.\r", "if", "(", "this", ".", "locked", "||", "editor", ".", "status", "!=", "'ready'", "||", "editor", ".", "mode", "!=", "'wysiwyg'", ")", "return", "false", ";", "var", "editable", "=", "editor", ".", "editable", "(", ")", ";", "if", "(", "!", "editable", "||", "editable", ".", "status", "!=", "'ready'", ")", "return", "false", ";", "var", "snapshots", "=", "this", ".", "snapshots", ";", "// Get a content image.\r", "if", "(", "!", "image", ")", "image", "=", "new", "Image", "(", "editor", ")", ";", "// Do nothing if it was not possible to retrieve an image.\r", "if", "(", "image", ".", "contents", "===", "false", ")", "return", "false", ";", "// Check if this is a duplicate. In such case, do nothing.\r", "if", "(", "this", ".", "currentImage", ")", "{", "if", "(", "image", ".", "equalsContent", "(", "this", ".", "currentImage", ")", ")", "{", "if", "(", "onContentOnly", ")", "return", "false", ";", "if", "(", "image", ".", "equalsSelection", "(", "this", ".", "currentImage", ")", ")", "return", "false", ";", "}", "else", "if", "(", "autoFireChange", "!==", "false", ")", "{", "editor", ".", "fire", "(", "'change'", ")", ";", "}", "}", "// Drop future snapshots.\r", "snapshots", ".", "splice", "(", "this", ".", "index", "+", "1", ",", "snapshots", ".", "length", "-", "this", ".", "index", "-", "1", ")", ";", "// If we have reached the limit, remove the oldest one.\r", "if", "(", "snapshots", ".", "length", "==", "this", ".", "limit", ")", "snapshots", ".", "shift", "(", ")", ";", "// Add the new image, updating the current index.\r", "this", ".", "index", "=", "snapshots", ".", "push", "(", "image", ")", "-", "1", ";", "this", ".", "currentImage", "=", "image", ";", "if", "(", "autoFireChange", "!==", "false", ")", "this", ".", "refreshState", "(", ")", ";", "return", "true", ";", "}" ]
Saves a snapshot of the document image for later retrieval. @param {Boolean} onContentOnly If set to `true`, the snapshot will be saved only if the content has changed. @param {CKEDITOR.plugins.undo.Image} image An optional image to save. If skipped, current editor will be used. @param {Boolean} autoFireChange If set to `false`, will not trigger the {@link CKEDITOR.editor#change} event to editor.
[ "Saves", "a", "snapshot", "of", "the", "document", "image", "for", "later", "retrieval", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/undo/plugin.js#L348-L397
56,599
skerit/alchemy-styleboost
public/ckeditor/4.4dev/plugins/undo/plugin.js
function( isUndo ) { var snapshots = this.snapshots, currentImage = this.currentImage, image, i; if ( currentImage ) { if ( isUndo ) { for ( i = this.index - 1; i >= 0; i-- ) { image = snapshots[ i ]; if ( !currentImage.equalsContent( image ) ) { image.index = i; return image; } } } else { for ( i = this.index + 1; i < snapshots.length; i++ ) { image = snapshots[ i ]; if ( !currentImage.equalsContent( image ) ) { image.index = i; return image; } } } } return null; }
javascript
function( isUndo ) { var snapshots = this.snapshots, currentImage = this.currentImage, image, i; if ( currentImage ) { if ( isUndo ) { for ( i = this.index - 1; i >= 0; i-- ) { image = snapshots[ i ]; if ( !currentImage.equalsContent( image ) ) { image.index = i; return image; } } } else { for ( i = this.index + 1; i < snapshots.length; i++ ) { image = snapshots[ i ]; if ( !currentImage.equalsContent( image ) ) { image.index = i; return image; } } } } return null; }
[ "function", "(", "isUndo", ")", "{", "var", "snapshots", "=", "this", ".", "snapshots", ",", "currentImage", "=", "this", ".", "currentImage", ",", "image", ",", "i", ";", "if", "(", "currentImage", ")", "{", "if", "(", "isUndo", ")", "{", "for", "(", "i", "=", "this", ".", "index", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "image", "=", "snapshots", "[", "i", "]", ";", "if", "(", "!", "currentImage", ".", "equalsContent", "(", "image", ")", ")", "{", "image", ".", "index", "=", "i", ";", "return", "image", ";", "}", "}", "}", "else", "{", "for", "(", "i", "=", "this", ".", "index", "+", "1", ";", "i", "<", "snapshots", ".", "length", ";", "i", "++", ")", "{", "image", "=", "snapshots", "[", "i", "]", ";", "if", "(", "!", "currentImage", ".", "equalsContent", "(", "image", ")", ")", "{", "image", ".", "index", "=", "i", ";", "return", "image", ";", "}", "}", "}", "}", "return", "null", ";", "}" ]
Gets the closest available image. @param {Boolean} isUndo If `true`, it will return the previous image. @returns {CKEDITOR.plugins.undo.Image} Next image or `null`.
[ "Gets", "the", "closest", "available", "image", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/undo/plugin.js#L453-L479