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
|
---|---|---|---|---|---|---|---|---|---|---|---|
57,700 | 5long/roil | src/console/simpleyui.js | function(plugin) {
var ns = plugin,
plugins = this._plugins;
if (L.isFunction(plugin)) {
ns = plugin.NS;
if (ns && (!plugins[ns] || plugins[ns] !== plugin)) {
ns = null;
}
}
if (ns) {
if (this[ns]) {
this[ns].destroy();
delete this[ns];
}
if (plugins[ns]) {
delete plugins[ns];
}
}
} | javascript | function(plugin) {
var ns = plugin,
plugins = this._plugins;
if (L.isFunction(plugin)) {
ns = plugin.NS;
if (ns && (!plugins[ns] || plugins[ns] !== plugin)) {
ns = null;
}
}
if (ns) {
if (this[ns]) {
this[ns].destroy();
delete this[ns];
}
if (plugins[ns]) {
delete plugins[ns];
}
}
} | [
"function",
"(",
"plugin",
")",
"{",
"var",
"ns",
"=",
"plugin",
",",
"plugins",
"=",
"this",
".",
"_plugins",
";",
"if",
"(",
"L",
".",
"isFunction",
"(",
"plugin",
")",
")",
"{",
"ns",
"=",
"plugin",
".",
"NS",
";",
"if",
"(",
"ns",
"&&",
"(",
"!",
"plugins",
"[",
"ns",
"]",
"||",
"plugins",
"[",
"ns",
"]",
"!==",
"plugin",
")",
")",
"{",
"ns",
"=",
"null",
";",
"}",
"}",
"if",
"(",
"ns",
")",
"{",
"if",
"(",
"this",
"[",
"ns",
"]",
")",
"{",
"this",
"[",
"ns",
"]",
".",
"destroy",
"(",
")",
";",
"delete",
"this",
"[",
"ns",
"]",
";",
"}",
"if",
"(",
"plugins",
"[",
"ns",
"]",
")",
"{",
"delete",
"plugins",
"[",
"ns",
"]",
";",
"}",
"}",
"}"
] | Unplugs and destroys a plugin already instantiated with the host.
@method _unplug
@private
@param {String | Function} plugin The namespace for the plugin, or a plugin class with the static NS property defined. | [
"Unplugs",
"and",
"destroys",
"a",
"plugin",
"already",
"instantiated",
"with",
"the",
"host",
"."
] | 37b14072a7aea17accc7f4e5e04dedc90a1358de | https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L10236-L10256 |
|
57,701 | 5long/roil | src/console/simpleyui.js | function() {
var str = this[UID] + ': not bound to a node',
node = this._node,
attrs, id, className;
if (node) {
attrs = node.attributes;
id = (attrs && attrs.id) ? node.getAttribute('id') : null;
className = (attrs && attrs.className) ? node.getAttribute('className') : null;
str = node[NODE_NAME];
if (id) {
str += '#' + id;
}
if (className) {
str += '.' + className.replace(' ', '.');
}
// TODO: add yuid?
str += ' ' + this[UID];
}
return str;
} | javascript | function() {
var str = this[UID] + ': not bound to a node',
node = this._node,
attrs, id, className;
if (node) {
attrs = node.attributes;
id = (attrs && attrs.id) ? node.getAttribute('id') : null;
className = (attrs && attrs.className) ? node.getAttribute('className') : null;
str = node[NODE_NAME];
if (id) {
str += '#' + id;
}
if (className) {
str += '.' + className.replace(' ', '.');
}
// TODO: add yuid?
str += ' ' + this[UID];
}
return str;
} | [
"function",
"(",
")",
"{",
"var",
"str",
"=",
"this",
"[",
"UID",
"]",
"+",
"': not bound to a node'",
",",
"node",
"=",
"this",
".",
"_node",
",",
"attrs",
",",
"id",
",",
"className",
";",
"if",
"(",
"node",
")",
"{",
"attrs",
"=",
"node",
".",
"attributes",
";",
"id",
"=",
"(",
"attrs",
"&&",
"attrs",
".",
"id",
")",
"?",
"node",
".",
"getAttribute",
"(",
"'id'",
")",
":",
"null",
";",
"className",
"=",
"(",
"attrs",
"&&",
"attrs",
".",
"className",
")",
"?",
"node",
".",
"getAttribute",
"(",
"'className'",
")",
":",
"null",
";",
"str",
"=",
"node",
"[",
"NODE_NAME",
"]",
";",
"if",
"(",
"id",
")",
"{",
"str",
"+=",
"'#'",
"+",
"id",
";",
"}",
"if",
"(",
"className",
")",
"{",
"str",
"+=",
"'.'",
"+",
"className",
".",
"replace",
"(",
"' '",
",",
"'.'",
")",
";",
"}",
"// TODO: add yuid?",
"str",
"+=",
"' '",
"+",
"this",
"[",
"UID",
"]",
";",
"}",
"return",
"str",
";",
"}"
] | The method called when outputting Node instances as strings
@method toString
@return {String} A string representation of the Node instance | [
"The",
"method",
"called",
"when",
"outputting",
"Node",
"instances",
"as",
"strings"
] | 37b14072a7aea17accc7f4e5e04dedc90a1358de | https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L10794-L10817 |
|
57,702 | 5long/roil | src/console/simpleyui.js | function(attr) {
var attrConfig = Y_Node.ATTRS[attr],
val;
if (attrConfig && attrConfig.getter) {
val = attrConfig.getter.call(this);
} else if (Y_Node.re_aria.test(attr)) {
val = this._node.getAttribute(attr, 2);
} else {
val = Y_Node.DEFAULT_GETTER.apply(this, arguments);
}
return val;
} | javascript | function(attr) {
var attrConfig = Y_Node.ATTRS[attr],
val;
if (attrConfig && attrConfig.getter) {
val = attrConfig.getter.call(this);
} else if (Y_Node.re_aria.test(attr)) {
val = this._node.getAttribute(attr, 2);
} else {
val = Y_Node.DEFAULT_GETTER.apply(this, arguments);
}
return val;
} | [
"function",
"(",
"attr",
")",
"{",
"var",
"attrConfig",
"=",
"Y_Node",
".",
"ATTRS",
"[",
"attr",
"]",
",",
"val",
";",
"if",
"(",
"attrConfig",
"&&",
"attrConfig",
".",
"getter",
")",
"{",
"val",
"=",
"attrConfig",
".",
"getter",
".",
"call",
"(",
"this",
")",
";",
"}",
"else",
"if",
"(",
"Y_Node",
".",
"re_aria",
".",
"test",
"(",
"attr",
")",
")",
"{",
"val",
"=",
"this",
".",
"_node",
".",
"getAttribute",
"(",
"attr",
",",
"2",
")",
";",
"}",
"else",
"{",
"val",
"=",
"Y_Node",
".",
"DEFAULT_GETTER",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"}",
"return",
"val",
";",
"}"
] | Helper method for get.
@method _get
@private
@param {String} attr The attribute
@return {any} The current value of the attribute | [
"Helper",
"method",
"for",
"get",
"."
] | 37b14072a7aea17accc7f4e5e04dedc90a1358de | https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L10852-L10865 |
|
57,703 | 5long/roil | src/console/simpleyui.js | function(attrMap) {
if (this._setAttrs) { // use Attribute imple
this._setAttrs(attrMap);
} else { // use setters inline
Y.Object.each(attrMap, function(v, n) {
this.set(n, v);
}, this);
}
return this;
} | javascript | function(attrMap) {
if (this._setAttrs) { // use Attribute imple
this._setAttrs(attrMap);
} else { // use setters inline
Y.Object.each(attrMap, function(v, n) {
this.set(n, v);
}, this);
}
return this;
} | [
"function",
"(",
"attrMap",
")",
"{",
"if",
"(",
"this",
".",
"_setAttrs",
")",
"{",
"// use Attribute imple",
"this",
".",
"_setAttrs",
"(",
"attrMap",
")",
";",
"}",
"else",
"{",
"// use setters inline",
"Y",
".",
"Object",
".",
"each",
"(",
"attrMap",
",",
"function",
"(",
"v",
",",
"n",
")",
"{",
"this",
".",
"set",
"(",
"n",
",",
"v",
")",
";",
"}",
",",
"this",
")",
";",
"}",
"return",
"this",
";",
"}"
] | Sets multiple attributes.
@method setAttrs
@param {Object} attrMap an object of name/value pairs to set
@chainable | [
"Sets",
"multiple",
"attributes",
"."
] | 37b14072a7aea17accc7f4e5e04dedc90a1358de | https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L10902-L10912 |
|
57,704 | 5long/roil | src/console/simpleyui.js | function(attrs) {
var ret = {};
if (this._getAttrs) { // use Attribute imple
this._getAttrs(attrs);
} else { // use setters inline
Y.Array.each(attrs, function(v, n) {
ret[v] = this.get(v);
}, this);
}
return ret;
} | javascript | function(attrs) {
var ret = {};
if (this._getAttrs) { // use Attribute imple
this._getAttrs(attrs);
} else { // use setters inline
Y.Array.each(attrs, function(v, n) {
ret[v] = this.get(v);
}, this);
}
return ret;
} | [
"function",
"(",
"attrs",
")",
"{",
"var",
"ret",
"=",
"{",
"}",
";",
"if",
"(",
"this",
".",
"_getAttrs",
")",
"{",
"// use Attribute imple",
"this",
".",
"_getAttrs",
"(",
"attrs",
")",
";",
"}",
"else",
"{",
"// use setters inline",
"Y",
".",
"Array",
".",
"each",
"(",
"attrs",
",",
"function",
"(",
"v",
",",
"n",
")",
"{",
"ret",
"[",
"v",
"]",
"=",
"this",
".",
"get",
"(",
"v",
")",
";",
"}",
",",
"this",
")",
";",
"}",
"return",
"ret",
";",
"}"
] | Returns an object containing the values for the requested attributes.
@method getAttrs
@param {Array} attrs an array of attributes to get values
@return {Object} An object with attribute name/value pairs. | [
"Returns",
"an",
"object",
"containing",
"the",
"values",
"for",
"the",
"requested",
"attributes",
"."
] | 37b14072a7aea17accc7f4e5e04dedc90a1358de | https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L10920-L10931 |
|
57,705 | 5long/roil | src/console/simpleyui.js | function(doc) {
var node = this._node;
doc = (doc) ? doc._node || doc : node[OWNER_DOCUMENT];
if (doc.documentElement) {
return Y_DOM.contains(doc.documentElement, node);
}
} | javascript | function(doc) {
var node = this._node;
doc = (doc) ? doc._node || doc : node[OWNER_DOCUMENT];
if (doc.documentElement) {
return Y_DOM.contains(doc.documentElement, node);
}
} | [
"function",
"(",
"doc",
")",
"{",
"var",
"node",
"=",
"this",
".",
"_node",
";",
"doc",
"=",
"(",
"doc",
")",
"?",
"doc",
".",
"_node",
"||",
"doc",
":",
"node",
"[",
"OWNER_DOCUMENT",
"]",
";",
"if",
"(",
"doc",
".",
"documentElement",
")",
"{",
"return",
"Y_DOM",
".",
"contains",
"(",
"doc",
".",
"documentElement",
",",
"node",
")",
";",
"}",
"}"
] | Determines whether the node is appended to the document.
@method inDoc
@param {Node|HTMLElement} doc optional An optional document to check against.
Defaults to current document.
@return {Boolean} Whether or not this node is appended to the document. | [
"Determines",
"whether",
"the",
"node",
"is",
"appended",
"to",
"the",
"document",
"."
] | 37b14072a7aea17accc7f4e5e04dedc90a1358de | https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L10965-L10971 |
|
57,706 | 5long/roil | src/console/simpleyui.js | function(fn, testSelf) {
return Y.one(Y_DOM.ancestor(this._node, _wrapFn(fn), testSelf));
} | javascript | function(fn, testSelf) {
return Y.one(Y_DOM.ancestor(this._node, _wrapFn(fn), testSelf));
} | [
"function",
"(",
"fn",
",",
"testSelf",
")",
"{",
"return",
"Y",
".",
"one",
"(",
"Y_DOM",
".",
"ancestor",
"(",
"this",
".",
"_node",
",",
"_wrapFn",
"(",
"fn",
")",
",",
"testSelf",
")",
")",
";",
"}"
] | Returns the nearest ancestor that passes the test applied by supplied boolean method.
@method ancestor
@param {String | Function} fn A selector string or boolean method for testing elements.
@param {Boolean} testSelf optional Whether or not to include the element in the scan
If a function is used, it receives the current node being tested as the only argument.
@return {Node} The matching Node instance or null if not found | [
"Returns",
"the",
"nearest",
"ancestor",
"that",
"passes",
"the",
"test",
"applied",
"by",
"supplied",
"boolean",
"method",
"."
] | 37b14072a7aea17accc7f4e5e04dedc90a1358de | https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L10992-L10994 |
|
57,707 | 5long/roil | src/console/simpleyui.js | function(fn, all) {
return Y.one(Y_DOM.elementByAxis(this._node, 'previousSibling', _wrapFn(fn), all));
} | javascript | function(fn, all) {
return Y.one(Y_DOM.elementByAxis(this._node, 'previousSibling', _wrapFn(fn), all));
} | [
"function",
"(",
"fn",
",",
"all",
")",
"{",
"return",
"Y",
".",
"one",
"(",
"Y_DOM",
".",
"elementByAxis",
"(",
"this",
".",
"_node",
",",
"'previousSibling'",
",",
"_wrapFn",
"(",
"fn",
")",
",",
"all",
")",
")",
";",
"}"
] | Returns the previous matching sibling.
Returns the nearest element node sibling if no method provided.
@method previous
@param {String | Function} fn A selector or boolean method for testing elements.
If a function is used, it receives the current node being tested as the only argument.
@return {Node} Node instance or null if not found | [
"Returns",
"the",
"previous",
"matching",
"sibling",
".",
"Returns",
"the",
"nearest",
"element",
"node",
"sibling",
"if",
"no",
"method",
"provided",
"."
] | 37b14072a7aea17accc7f4e5e04dedc90a1358de | https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L11004-L11006 |
|
57,708 | 5long/roil | src/console/simpleyui.js | function(content, where) {
var node = this._node;
if (content) {
if (typeof where === 'number') { // allow index
where = this._node.childNodes[where];
} else if (where && where._node) { // Node
where = where._node;
}
if (typeof content !== 'string') { // allow Node or NodeList/Array instances
if (content._node) { // Node
content = content._node;
} else if (content._nodes || (!content.nodeType && content.length)) { // NodeList or Array
content = Y.all(content);
Y.each(content._nodes, function(n) {
Y_DOM.addHTML(node, n, where);
});
return this; // NOTE: early return
}
}
Y_DOM.addHTML(node, content, where);
} else {
}
return this;
} | javascript | function(content, where) {
var node = this._node;
if (content) {
if (typeof where === 'number') { // allow index
where = this._node.childNodes[where];
} else if (where && where._node) { // Node
where = where._node;
}
if (typeof content !== 'string') { // allow Node or NodeList/Array instances
if (content._node) { // Node
content = content._node;
} else if (content._nodes || (!content.nodeType && content.length)) { // NodeList or Array
content = Y.all(content);
Y.each(content._nodes, function(n) {
Y_DOM.addHTML(node, n, where);
});
return this; // NOTE: early return
}
}
Y_DOM.addHTML(node, content, where);
} else {
}
return this;
} | [
"function",
"(",
"content",
",",
"where",
")",
"{",
"var",
"node",
"=",
"this",
".",
"_node",
";",
"if",
"(",
"content",
")",
"{",
"if",
"(",
"typeof",
"where",
"===",
"'number'",
")",
"{",
"// allow index",
"where",
"=",
"this",
".",
"_node",
".",
"childNodes",
"[",
"where",
"]",
";",
"}",
"else",
"if",
"(",
"where",
"&&",
"where",
".",
"_node",
")",
"{",
"// Node",
"where",
"=",
"where",
".",
"_node",
";",
"}",
"if",
"(",
"typeof",
"content",
"!==",
"'string'",
")",
"{",
"// allow Node or NodeList/Array instances",
"if",
"(",
"content",
".",
"_node",
")",
"{",
"// Node",
"content",
"=",
"content",
".",
"_node",
";",
"}",
"else",
"if",
"(",
"content",
".",
"_nodes",
"||",
"(",
"!",
"content",
".",
"nodeType",
"&&",
"content",
".",
"length",
")",
")",
"{",
"// NodeList or Array",
"content",
"=",
"Y",
".",
"all",
"(",
"content",
")",
";",
"Y",
".",
"each",
"(",
"content",
".",
"_nodes",
",",
"function",
"(",
"n",
")",
"{",
"Y_DOM",
".",
"addHTML",
"(",
"node",
",",
"n",
",",
"where",
")",
";",
"}",
")",
";",
"return",
"this",
";",
"// NOTE: early return",
"}",
"}",
"Y_DOM",
".",
"addHTML",
"(",
"node",
",",
"content",
",",
"where",
")",
";",
"}",
"else",
"{",
"}",
"return",
"this",
";",
"}"
] | Inserts the content before the reference node.
@method insert
@param {String | Y.Node | HTMLElement} content The content to insert
@param {Int | Y.Node | HTMLElement | String} where The position to insert at.
Possible "where" arguments
<dl>
<dt>Y.Node</dt>
<dd>The Node to insert before</dd>
<dt>HTMLElement</dt>
<dd>The element to insert before</dd>
<dt>Int</dt>
<dd>The index of the child element to insert before</dd>
<dt>"replace"</dt>
<dd>Replaces the existing HTML</dd>
<dt>"before"</dt>
<dd>Inserts before the existing HTML</dd>
<dt>"before"</dt>
<dd>Inserts content before the node</dd>
<dt>"after"</dt>
<dd>Inserts content after the node</dd>
</dl>
@chainable | [
"Inserts",
"the",
"content",
"before",
"the",
"reference",
"node",
"."
] | 37b14072a7aea17accc7f4e5e04dedc90a1358de | https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L11248-L11274 |
|
57,709 | 5long/roil | src/console/simpleyui.js | function(content) {
if (content) {
if (content._node) { // map to DOMNode
content = content._node;
} else if (content._nodes) { // convert DOMNodeList to documentFragment
content = Y_DOM._nl2frag(content._nodes);
}
}
Y_DOM.addHTML(this._node, content, 'replace');
return this;
} | javascript | function(content) {
if (content) {
if (content._node) { // map to DOMNode
content = content._node;
} else if (content._nodes) { // convert DOMNodeList to documentFragment
content = Y_DOM._nl2frag(content._nodes);
}
}
Y_DOM.addHTML(this._node, content, 'replace');
return this;
} | [
"function",
"(",
"content",
")",
"{",
"if",
"(",
"content",
")",
"{",
"if",
"(",
"content",
".",
"_node",
")",
"{",
"// map to DOMNode",
"content",
"=",
"content",
".",
"_node",
";",
"}",
"else",
"if",
"(",
"content",
".",
"_nodes",
")",
"{",
"// convert DOMNodeList to documentFragment",
"content",
"=",
"Y_DOM",
".",
"_nl2frag",
"(",
"content",
".",
"_nodes",
")",
";",
"}",
"}",
"Y_DOM",
".",
"addHTML",
"(",
"this",
".",
"_node",
",",
"content",
",",
"'replace'",
")",
";",
"return",
"this",
";",
"}"
] | Replaces the node's current content with the content.
@method setContent
@param {String | Y.Node | HTMLElement} content The content to insert
@chainable | [
"Replaces",
"the",
"node",
"s",
"current",
"content",
"with",
"the",
"content",
"."
] | 37b14072a7aea17accc7f4e5e04dedc90a1358de | https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L11302-L11314 |
|
57,710 | 5long/roil | src/console/simpleyui.js | function(fn, context) {
var instance = this;
return Y.Array.some(this._nodes, function(node, index) {
node = Y.one(node);
context = context || node;
return fn.call(context, node, index, instance);
});
} | javascript | function(fn, context) {
var instance = this;
return Y.Array.some(this._nodes, function(node, index) {
node = Y.one(node);
context = context || node;
return fn.call(context, node, index, instance);
});
} | [
"function",
"(",
"fn",
",",
"context",
")",
"{",
"var",
"instance",
"=",
"this",
";",
"return",
"Y",
".",
"Array",
".",
"some",
"(",
"this",
".",
"_nodes",
",",
"function",
"(",
"node",
",",
"index",
")",
"{",
"node",
"=",
"Y",
".",
"one",
"(",
"node",
")",
";",
"context",
"=",
"context",
"||",
"node",
";",
"return",
"fn",
".",
"call",
"(",
"context",
",",
"node",
",",
"index",
",",
"instance",
")",
";",
"}",
")",
";",
"}"
] | Executes the function once for each node until a true value is returned.
@method some
@param {Function} fn The function to apply. It receives 3 arguments:
the current node instance, the node's index, and the NodeList instance
@param {Object} context optional An optional context to execute the function from.
Default context is the current Node instance
@return {Boolean} Whether or not the function returned true for any node. | [
"Executes",
"the",
"function",
"once",
"for",
"each",
"node",
"until",
"a",
"true",
"value",
"is",
"returned",
"."
] | 37b14072a7aea17accc7f4e5e04dedc90a1358de | https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L11586-L11593 |
|
57,711 | 5long/roil | src/console/simpleyui.js | function() {
var doc,
nodes = this._nodes,
query = this._query,
root = this._queryRoot;
if (query) {
if (!root) {
if (nodes && nodes[0] && nodes[0].ownerDocument) {
root = nodes[0].ownerDocument;
}
}
this._nodes = Y.Selector.query(query, root);
}
return this;
} | javascript | function() {
var doc,
nodes = this._nodes,
query = this._query,
root = this._queryRoot;
if (query) {
if (!root) {
if (nodes && nodes[0] && nodes[0].ownerDocument) {
root = nodes[0].ownerDocument;
}
}
this._nodes = Y.Selector.query(query, root);
}
return this;
} | [
"function",
"(",
")",
"{",
"var",
"doc",
",",
"nodes",
"=",
"this",
".",
"_nodes",
",",
"query",
"=",
"this",
".",
"_query",
",",
"root",
"=",
"this",
".",
"_queryRoot",
";",
"if",
"(",
"query",
")",
"{",
"if",
"(",
"!",
"root",
")",
"{",
"if",
"(",
"nodes",
"&&",
"nodes",
"[",
"0",
"]",
"&&",
"nodes",
"[",
"0",
"]",
".",
"ownerDocument",
")",
"{",
"root",
"=",
"nodes",
"[",
"0",
"]",
".",
"ownerDocument",
";",
"}",
"}",
"this",
".",
"_nodes",
"=",
"Y",
".",
"Selector",
".",
"query",
"(",
"query",
",",
"root",
")",
";",
"}",
"return",
"this",
";",
"}"
] | Reruns the initial query, when created using a selector query
@method refresh
@chainable | [
"Reruns",
"the",
"initial",
"query",
"when",
"created",
"using",
"a",
"selector",
"query"
] | 37b14072a7aea17accc7f4e5e04dedc90a1358de | https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L11676-L11693 |
|
57,712 | 5long/roil | src/console/simpleyui.js | function(type, fn, context) {
return Y.on.apply(Y, this._prepEvtArgs.apply(this, arguments));
} | javascript | function(type, fn, context) {
return Y.on.apply(Y, this._prepEvtArgs.apply(this, arguments));
} | [
"function",
"(",
"type",
",",
"fn",
",",
"context",
")",
"{",
"return",
"Y",
".",
"on",
".",
"apply",
"(",
"Y",
",",
"this",
".",
"_prepEvtArgs",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
")",
";",
"}"
] | Applies an event listener to each Node bound to the NodeList.
@method on
@param {String} type The event being listened for
@param {Function} fn The handler to call when the event fires
@param {Object} context The context to call the handler with.
Default is the NodeList instance.
@return {Object} Returns an event handle that can later be use to detach().
@see Event.on | [
"Applies",
"an",
"event",
"listener",
"to",
"each",
"Node",
"bound",
"to",
"the",
"NodeList",
"."
] | 37b14072a7aea17accc7f4e5e04dedc90a1358de | https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L11720-L11722 |
|
57,713 | 5long/roil | src/console/simpleyui.js | function (s,reviver) {
// Replace certain Unicode characters that are otherwise handled
// incorrectly by some browser implementations.
// NOTE: This modifies the input if such characters are found!
s = s.replace(_UNICODE_EXCEPTIONS, _escapeException);
// Test for any remaining invalid characters
if (!_UNSAFE.test(s.replace(_ESCAPES,'@').
replace(_VALUES,']').
replace(_BRACKETS,''))) {
// Eval the text into a JavaScript data structure, apply any
// reviver function, and return
return _revive( _eval('(' + s + ')'), reviver );
}
throw new SyntaxError('JSON.parse');
} | javascript | function (s,reviver) {
// Replace certain Unicode characters that are otherwise handled
// incorrectly by some browser implementations.
// NOTE: This modifies the input if such characters are found!
s = s.replace(_UNICODE_EXCEPTIONS, _escapeException);
// Test for any remaining invalid characters
if (!_UNSAFE.test(s.replace(_ESCAPES,'@').
replace(_VALUES,']').
replace(_BRACKETS,''))) {
// Eval the text into a JavaScript data structure, apply any
// reviver function, and return
return _revive( _eval('(' + s + ')'), reviver );
}
throw new SyntaxError('JSON.parse');
} | [
"function",
"(",
"s",
",",
"reviver",
")",
"{",
"// Replace certain Unicode characters that are otherwise handled",
"// incorrectly by some browser implementations.",
"// NOTE: This modifies the input if such characters are found!",
"s",
"=",
"s",
".",
"replace",
"(",
"_UNICODE_EXCEPTIONS",
",",
"_escapeException",
")",
";",
"// Test for any remaining invalid characters",
"if",
"(",
"!",
"_UNSAFE",
".",
"test",
"(",
"s",
".",
"replace",
"(",
"_ESCAPES",
",",
"'@'",
")",
".",
"replace",
"(",
"_VALUES",
",",
"']'",
")",
".",
"replace",
"(",
"_BRACKETS",
",",
"''",
")",
")",
")",
"{",
"// Eval the text into a JavaScript data structure, apply any",
"// reviver function, and return",
"return",
"_revive",
"(",
"_eval",
"(",
"'('",
"+",
"s",
"+",
"')'",
")",
",",
"reviver",
")",
";",
"}",
"throw",
"new",
"SyntaxError",
"(",
"'JSON.parse'",
")",
";",
"}"
] | Alias to native browser implementation of the JSON object if available.
@property Native
@type {Object}
@private | [
"Alias",
"to",
"native",
"browser",
"implementation",
"of",
"the",
"JSON",
"object",
"if",
"available",
"."
] | 37b14072a7aea17accc7f4e5e04dedc90a1358de | https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L13915-L13932 |
|
57,714 | rsdoiel/tbone | depreciated/tbone_util.js | function (s) {
return s.replace(re_NewLine, NewLine).replace(re_quot, quot).replace(re_apos, apos).replace(re_acute, acute).replace(re_sbquo, sbquo).replace(re_bdquo, bdquo).replace(re_hellip, hellip).replace(re_dagger, dagger).replace(re_Dagger, Dagger).replace(re_lsquo, lsquo).replace(re_rsquo, rsquo).replace(re_ldquo, ldquo).replace(re_rdquo, rdquo).replace(re_bull, bull).replace(re_ndash, ndash).replace(re_mdash, mdash).replace(re_copy, copyright_mark).replace(re_nbsp, nbsp).replace(re_laquo, laquo).replace(re_raquo, raquo);
} | javascript | function (s) {
return s.replace(re_NewLine, NewLine).replace(re_quot, quot).replace(re_apos, apos).replace(re_acute, acute).replace(re_sbquo, sbquo).replace(re_bdquo, bdquo).replace(re_hellip, hellip).replace(re_dagger, dagger).replace(re_Dagger, Dagger).replace(re_lsquo, lsquo).replace(re_rsquo, rsquo).replace(re_ldquo, ldquo).replace(re_rdquo, rdquo).replace(re_bull, bull).replace(re_ndash, ndash).replace(re_mdash, mdash).replace(re_copy, copyright_mark).replace(re_nbsp, nbsp).replace(re_laquo, laquo).replace(re_raquo, raquo);
} | [
"function",
"(",
"s",
")",
"{",
"return",
"s",
".",
"replace",
"(",
"re_NewLine",
",",
"NewLine",
")",
".",
"replace",
"(",
"re_quot",
",",
"quot",
")",
".",
"replace",
"(",
"re_apos",
",",
"apos",
")",
".",
"replace",
"(",
"re_acute",
",",
"acute",
")",
".",
"replace",
"(",
"re_sbquo",
",",
"sbquo",
")",
".",
"replace",
"(",
"re_bdquo",
",",
"bdquo",
")",
".",
"replace",
"(",
"re_hellip",
",",
"hellip",
")",
".",
"replace",
"(",
"re_dagger",
",",
"dagger",
")",
".",
"replace",
"(",
"re_Dagger",
",",
"Dagger",
")",
".",
"replace",
"(",
"re_lsquo",
",",
"lsquo",
")",
".",
"replace",
"(",
"re_rsquo",
",",
"rsquo",
")",
".",
"replace",
"(",
"re_ldquo",
",",
"ldquo",
")",
".",
"replace",
"(",
"re_rdquo",
",",
"rdquo",
")",
".",
"replace",
"(",
"re_bull",
",",
"bull",
")",
".",
"replace",
"(",
"re_ndash",
",",
"ndash",
")",
".",
"replace",
"(",
"re_mdash",
",",
"mdash",
")",
".",
"replace",
"(",
"re_copy",
",",
"copyright_mark",
")",
".",
"replace",
"(",
"re_nbsp",
",",
"nbsp",
")",
".",
"replace",
"(",
"re_laquo",
",",
"laquo",
")",
".",
"replace",
"(",
"re_raquo",
",",
"raquo",
")",
";",
"}"
] | HTML_UTIL 5 entity and utility methods | [
"HTML_UTIL",
"5",
"entity",
"and",
"utility",
"methods"
] | f05d2bba81d40f2b792a247dadce7d1a45342227 | https://github.com/rsdoiel/tbone/blob/f05d2bba81d40f2b792a247dadce7d1a45342227/depreciated/tbone_util.js#L260-L262 |
|
57,715 | kchapelier/migl-pool | src/pool.js | function (options) {
poolId++;
return new Pool(
options.name ? options.name + ' (pool #' + poolId + ')' : 'pool #' + poolId,
options.factory,
options.initialize || noop,
options.firstAllocationNumber || 20,
options.allocationNumber || 1
);
} | javascript | function (options) {
poolId++;
return new Pool(
options.name ? options.name + ' (pool #' + poolId + ')' : 'pool #' + poolId,
options.factory,
options.initialize || noop,
options.firstAllocationNumber || 20,
options.allocationNumber || 1
);
} | [
"function",
"(",
"options",
")",
"{",
"poolId",
"++",
";",
"return",
"new",
"Pool",
"(",
"options",
".",
"name",
"?",
"options",
".",
"name",
"+",
"' (pool #'",
"+",
"poolId",
"+",
"')'",
":",
"'pool #'",
"+",
"poolId",
",",
"options",
".",
"factory",
",",
"options",
".",
"initialize",
"||",
"noop",
",",
"options",
".",
"firstAllocationNumber",
"||",
"20",
",",
"options",
".",
"allocationNumber",
"||",
"1",
")",
";",
"}"
] | Create an object pool
@param {Object} options Pool options (name, factory, initialize, firstAllocationNumber, allocationNumber)
@returns {Pool} Instance of the object pool | [
"Create",
"an",
"object",
"pool"
] | d8ee91d577d53df40cae34e9e6efa84abb9d5cfb | https://github.com/kchapelier/migl-pool/blob/d8ee91d577d53df40cae34e9e6efa84abb9d5cfb/src/pool.js#L105-L115 |
|
57,716 | AndreasMadsen/immortal | lib/core/streams.js | RelayStream | function RelayStream(option) {
Stream.apply(this, arguments);
this.writable = true;
this.readable = true;
this.store = [];
this.paused = !!option.paused;
this.closed = false;
} | javascript | function RelayStream(option) {
Stream.apply(this, arguments);
this.writable = true;
this.readable = true;
this.store = [];
this.paused = !!option.paused;
this.closed = false;
} | [
"function",
"RelayStream",
"(",
"option",
")",
"{",
"Stream",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"this",
".",
"writable",
"=",
"true",
";",
"this",
".",
"readable",
"=",
"true",
";",
"this",
".",
"store",
"=",
"[",
"]",
";",
"this",
".",
"paused",
"=",
"!",
"!",
"option",
".",
"paused",
";",
"this",
".",
"closed",
"=",
"false",
";",
"}"
] | This constructor will simply relay data
by purpose this do not support .end or .close | [
"This",
"constructor",
"will",
"simply",
"relay",
"data",
"by",
"purpose",
"this",
"do",
"not",
"support",
".",
"end",
"or",
".",
"close"
] | c1ab5a4287a543fdfd980604a9e9927d663a9ef2 | https://github.com/AndreasMadsen/immortal/blob/c1ab5a4287a543fdfd980604a9e9927d663a9ef2/lib/core/streams.js#L24-L32 |
57,717 | redisjs/jsr-validate | lib/index.js | validate | function validate(cmd, args, info) {
info = info || {};
var conf = info.conf || {}
, authrequired = typeof conf.requirepass === 'string'
, db = info.db
, result;
// handle quit command special case
if(cmd === COMMANDS.QUIT) {
// reply with an object that mimics succesful validation
info.command = {
cmd: cmd, args: args, def: Constants.MAP.quit, arity: true};
return info;
// validate command is known
}else{
info.command = validators.command(cmd, args, info);
}
// check args length (arity)
info.command.arity = validators.arity(cmd, args, info);
// handle authentication requests
if(cmd === COMMANDS.AUTH) {
info.conn.authenticated =
validators.auth(cmd, args, info);
// handle unauthenticated requests when auth is enabled
}else if(authrequired && !info.conn.authenticated) {
throw AuthRequired;
}
// check operation on the correct type of value
// this validation extracts keys, looks up the values
// to determine the type of the existing value
// the val array (or null) is assigned to the command
// info object so that calling code may re-use it and
// save looking up keys and values again where necessary
info.command.value = validators.type(cmd, args, info);
return info;
} | javascript | function validate(cmd, args, info) {
info = info || {};
var conf = info.conf || {}
, authrequired = typeof conf.requirepass === 'string'
, db = info.db
, result;
// handle quit command special case
if(cmd === COMMANDS.QUIT) {
// reply with an object that mimics succesful validation
info.command = {
cmd: cmd, args: args, def: Constants.MAP.quit, arity: true};
return info;
// validate command is known
}else{
info.command = validators.command(cmd, args, info);
}
// check args length (arity)
info.command.arity = validators.arity(cmd, args, info);
// handle authentication requests
if(cmd === COMMANDS.AUTH) {
info.conn.authenticated =
validators.auth(cmd, args, info);
// handle unauthenticated requests when auth is enabled
}else if(authrequired && !info.conn.authenticated) {
throw AuthRequired;
}
// check operation on the correct type of value
// this validation extracts keys, looks up the values
// to determine the type of the existing value
// the val array (or null) is assigned to the command
// info object so that calling code may re-use it and
// save looking up keys and values again where necessary
info.command.value = validators.type(cmd, args, info);
return info;
} | [
"function",
"validate",
"(",
"cmd",
",",
"args",
",",
"info",
")",
"{",
"info",
"=",
"info",
"||",
"{",
"}",
";",
"var",
"conf",
"=",
"info",
".",
"conf",
"||",
"{",
"}",
",",
"authrequired",
"=",
"typeof",
"conf",
".",
"requirepass",
"===",
"'string'",
",",
"db",
"=",
"info",
".",
"db",
",",
"result",
";",
"// handle quit command special case",
"if",
"(",
"cmd",
"===",
"COMMANDS",
".",
"QUIT",
")",
"{",
"// reply with an object that mimics succesful validation",
"info",
".",
"command",
"=",
"{",
"cmd",
":",
"cmd",
",",
"args",
":",
"args",
",",
"def",
":",
"Constants",
".",
"MAP",
".",
"quit",
",",
"arity",
":",
"true",
"}",
";",
"return",
"info",
";",
"// validate command is known",
"}",
"else",
"{",
"info",
".",
"command",
"=",
"validators",
".",
"command",
"(",
"cmd",
",",
"args",
",",
"info",
")",
";",
"}",
"// check args length (arity)",
"info",
".",
"command",
".",
"arity",
"=",
"validators",
".",
"arity",
"(",
"cmd",
",",
"args",
",",
"info",
")",
";",
"// handle authentication requests",
"if",
"(",
"cmd",
"===",
"COMMANDS",
".",
"AUTH",
")",
"{",
"info",
".",
"conn",
".",
"authenticated",
"=",
"validators",
".",
"auth",
"(",
"cmd",
",",
"args",
",",
"info",
")",
";",
"// handle unauthenticated requests when auth is enabled",
"}",
"else",
"if",
"(",
"authrequired",
"&&",
"!",
"info",
".",
"conn",
".",
"authenticated",
")",
"{",
"throw",
"AuthRequired",
";",
"}",
"// check operation on the correct type of value",
"// this validation extracts keys, looks up the values",
"// to determine the type of the existing value",
"// the val array (or null) is assigned to the command",
"// info object so that calling code may re-use it and",
"// save looking up keys and values again where necessary",
"info",
".",
"command",
".",
"value",
"=",
"validators",
".",
"type",
"(",
"cmd",
",",
"args",
",",
"info",
")",
";",
"return",
"info",
";",
"}"
] | Performs complete validation for an incoming command.
The command name should be lowercase.
@param cmd The command name.
@param args The command arguments.
@param info The configuration and current database pointer. | [
"Performs",
"complete",
"validation",
"for",
"an",
"incoming",
"command",
"."
] | 2e0dddafb32c019ef9293a35b96cdd78dd8e4ae5 | https://github.com/redisjs/jsr-validate/blob/2e0dddafb32c019ef9293a35b96cdd78dd8e4ae5/lib/index.js#L16-L55 |
57,718 | adiwidjaja/frontend-pagebuilder | js/tinymce/plugins/spellchecker/plugin.js | indexOf | function indexOf(match) {
var i = matches.length;
while (i--) {
if (matches[i] === match) {
return i;
}
}
return -1;
} | javascript | function indexOf(match) {
var i = matches.length;
while (i--) {
if (matches[i] === match) {
return i;
}
}
return -1;
} | [
"function",
"indexOf",
"(",
"match",
")",
"{",
"var",
"i",
"=",
"matches",
".",
"length",
";",
"while",
"(",
"i",
"--",
")",
"{",
"if",
"(",
"matches",
"[",
"i",
"]",
"===",
"match",
")",
"{",
"return",
"i",
";",
"}",
"}",
"return",
"-",
"1",
";",
"}"
] | Returns the index of a specific match object or -1 if it isn't found.
@param {Match} match Text match object.
@return {Number} Index of match or -1 if it isn't found. | [
"Returns",
"the",
"index",
"of",
"a",
"specific",
"match",
"object",
"or",
"-",
"1",
"if",
"it",
"isn",
"t",
"found",
"."
] | a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f | https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/plugins/spellchecker/plugin.js#L356-L365 |
57,719 | adiwidjaja/frontend-pagebuilder | js/tinymce/plugins/spellchecker/plugin.js | filter | function filter(callback) {
var filteredMatches = [];
each(function (match, i) {
if (callback(match, i)) {
filteredMatches.push(match);
}
});
matches = filteredMatches;
/*jshint validthis:true*/
return this;
} | javascript | function filter(callback) {
var filteredMatches = [];
each(function (match, i) {
if (callback(match, i)) {
filteredMatches.push(match);
}
});
matches = filteredMatches;
/*jshint validthis:true*/
return this;
} | [
"function",
"filter",
"(",
"callback",
")",
"{",
"var",
"filteredMatches",
"=",
"[",
"]",
";",
"each",
"(",
"function",
"(",
"match",
",",
"i",
")",
"{",
"if",
"(",
"callback",
"(",
"match",
",",
"i",
")",
")",
"{",
"filteredMatches",
".",
"push",
"(",
"match",
")",
";",
"}",
"}",
")",
";",
"matches",
"=",
"filteredMatches",
";",
"/*jshint validthis:true*/",
"return",
"this",
";",
"}"
] | Filters the matches. If the callback returns true it stays if not it gets removed.
@param {Function} callback Callback to execute for each match.
@return {DomTextMatcher} Current DomTextMatcher instance. | [
"Filters",
"the",
"matches",
".",
"If",
"the",
"callback",
"returns",
"true",
"it",
"stays",
"if",
"not",
"it",
"gets",
"removed",
"."
] | a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f | https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/plugins/spellchecker/plugin.js#L373-L386 |
57,720 | adiwidjaja/frontend-pagebuilder | js/tinymce/plugins/spellchecker/plugin.js | each | function each(callback) {
for (var i = 0, l = matches.length; i < l; i++) {
if (callback(matches[i], i) === false) {
break;
}
}
/*jshint validthis:true*/
return this;
} | javascript | function each(callback) {
for (var i = 0, l = matches.length; i < l; i++) {
if (callback(matches[i], i) === false) {
break;
}
}
/*jshint validthis:true*/
return this;
} | [
"function",
"each",
"(",
"callback",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"matches",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"if",
"(",
"callback",
"(",
"matches",
"[",
"i",
"]",
",",
"i",
")",
"===",
"false",
")",
"{",
"break",
";",
"}",
"}",
"/*jshint validthis:true*/",
"return",
"this",
";",
"}"
] | Executes the specified callback for each match.
@param {Function} callback Callback to execute for each match.
@return {DomTextMatcher} Current DomTextMatcher instance. | [
"Executes",
"the",
"specified",
"callback",
"for",
"each",
"match",
"."
] | a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f | https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/plugins/spellchecker/plugin.js#L394-L403 |
57,721 | adiwidjaja/frontend-pagebuilder | js/tinymce/plugins/spellchecker/plugin.js | find | function find(regex, data) {
if (text && regex.global) {
while ((m = regex.exec(text))) {
matches.push(createMatch(m, data));
}
}
return this;
} | javascript | function find(regex, data) {
if (text && regex.global) {
while ((m = regex.exec(text))) {
matches.push(createMatch(m, data));
}
}
return this;
} | [
"function",
"find",
"(",
"regex",
",",
"data",
")",
"{",
"if",
"(",
"text",
"&&",
"regex",
".",
"global",
")",
"{",
"while",
"(",
"(",
"m",
"=",
"regex",
".",
"exec",
"(",
"text",
")",
")",
")",
"{",
"matches",
".",
"push",
"(",
"createMatch",
"(",
"m",
",",
"data",
")",
")",
";",
"}",
"}",
"return",
"this",
";",
"}"
] | Finds the specified regexp and adds them to the matches collection.
@param {RegExp} regex Global regexp to search the current node by.
@param {Object} [data] Optional custom data element for the match.
@return {DomTextMatcher} Current DomTextMatcher instance. | [
"Finds",
"the",
"specified",
"regexp",
"and",
"adds",
"them",
"to",
"the",
"matches",
"collection",
"."
] | a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f | https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/plugins/spellchecker/plugin.js#L428-L436 |
57,722 | adiwidjaja/frontend-pagebuilder | js/tinymce/plugins/spellchecker/plugin.js | unwrap | function unwrap(match) {
var i, elements = getWrappersByIndex(match ? indexOf(match) : null);
i = elements.length;
while (i--) {
unwrapElement(elements[i]);
}
return this;
} | javascript | function unwrap(match) {
var i, elements = getWrappersByIndex(match ? indexOf(match) : null);
i = elements.length;
while (i--) {
unwrapElement(elements[i]);
}
return this;
} | [
"function",
"unwrap",
"(",
"match",
")",
"{",
"var",
"i",
",",
"elements",
"=",
"getWrappersByIndex",
"(",
"match",
"?",
"indexOf",
"(",
"match",
")",
":",
"null",
")",
";",
"i",
"=",
"elements",
".",
"length",
";",
"while",
"(",
"i",
"--",
")",
"{",
"unwrapElement",
"(",
"elements",
"[",
"i",
"]",
")",
";",
"}",
"return",
"this",
";",
"}"
] | Unwraps the specified match object or all matches if unspecified.
@param {Object} [match] Optional match object.
@return {DomTextMatcher} Current DomTextMatcher instance. | [
"Unwraps",
"the",
"specified",
"match",
"object",
"or",
"all",
"matches",
"if",
"unspecified",
"."
] | a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f | https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/plugins/spellchecker/plugin.js#L444-L453 |
57,723 | adiwidjaja/frontend-pagebuilder | js/tinymce/plugins/spellchecker/plugin.js | add | function add(start, length, data) {
matches.push({
start: start,
end: start + length,
text: text.substr(start, length),
data: data
});
return this;
} | javascript | function add(start, length, data) {
matches.push({
start: start,
end: start + length,
text: text.substr(start, length),
data: data
});
return this;
} | [
"function",
"add",
"(",
"start",
",",
"length",
",",
"data",
")",
"{",
"matches",
".",
"push",
"(",
"{",
"start",
":",
"start",
",",
"end",
":",
"start",
"+",
"length",
",",
"text",
":",
"text",
".",
"substr",
"(",
"start",
",",
"length",
")",
",",
"data",
":",
"data",
"}",
")",
";",
"return",
"this",
";",
"}"
] | Adds match the specified range for example a grammar line.
@param {Number} start Start offset.
@param {Number} length Length of the text.
@param {Object} data Custom data object for match.
@return {DomTextMatcher} Current DomTextMatcher instance. | [
"Adds",
"match",
"the",
"specified",
"range",
"for",
"example",
"a",
"grammar",
"line",
"."
] | a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f | https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/plugins/spellchecker/plugin.js#L484-L493 |
57,724 | adiwidjaja/frontend-pagebuilder | js/tinymce/plugins/spellchecker/plugin.js | rangeFromMatch | function rangeFromMatch(match) {
var wrappers = getWrappersByIndex(indexOf(match));
var rng = editor.dom.createRng();
rng.setStartBefore(wrappers[0]);
rng.setEndAfter(wrappers[wrappers.length - 1]);
return rng;
} | javascript | function rangeFromMatch(match) {
var wrappers = getWrappersByIndex(indexOf(match));
var rng = editor.dom.createRng();
rng.setStartBefore(wrappers[0]);
rng.setEndAfter(wrappers[wrappers.length - 1]);
return rng;
} | [
"function",
"rangeFromMatch",
"(",
"match",
")",
"{",
"var",
"wrappers",
"=",
"getWrappersByIndex",
"(",
"indexOf",
"(",
"match",
")",
")",
";",
"var",
"rng",
"=",
"editor",
".",
"dom",
".",
"createRng",
"(",
")",
";",
"rng",
".",
"setStartBefore",
"(",
"wrappers",
"[",
"0",
"]",
")",
";",
"rng",
".",
"setEndAfter",
"(",
"wrappers",
"[",
"wrappers",
".",
"length",
"-",
"1",
"]",
")",
";",
"return",
"rng",
";",
"}"
] | Returns a DOM range for the specified match.
@param {Object} match Match object to get range for.
@return {DOMRange} DOM Range for the specified match. | [
"Returns",
"a",
"DOM",
"range",
"for",
"the",
"specified",
"match",
"."
] | a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f | https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/plugins/spellchecker/plugin.js#L501-L509 |
57,725 | adiwidjaja/frontend-pagebuilder | js/tinymce/plugins/spellchecker/plugin.js | replace | function replace(match, text) {
var rng = rangeFromMatch(match);
rng.deleteContents();
if (text.length > 0) {
rng.insertNode(editor.dom.doc.createTextNode(text));
}
return rng;
} | javascript | function replace(match, text) {
var rng = rangeFromMatch(match);
rng.deleteContents();
if (text.length > 0) {
rng.insertNode(editor.dom.doc.createTextNode(text));
}
return rng;
} | [
"function",
"replace",
"(",
"match",
",",
"text",
")",
"{",
"var",
"rng",
"=",
"rangeFromMatch",
"(",
"match",
")",
";",
"rng",
".",
"deleteContents",
"(",
")",
";",
"if",
"(",
"text",
".",
"length",
">",
"0",
")",
"{",
"rng",
".",
"insertNode",
"(",
"editor",
".",
"dom",
".",
"doc",
".",
"createTextNode",
"(",
"text",
")",
")",
";",
"}",
"return",
"rng",
";",
"}"
] | Replaces the specified match with the specified text.
@param {Object} match Match object to replace.
@param {String} text Text to replace the match with.
@return {DOMRange} DOM range produced after the replace. | [
"Replaces",
"the",
"specified",
"match",
"with",
"the",
"specified",
"text",
"."
] | a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f | https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/plugins/spellchecker/plugin.js#L518-L528 |
57,726 | adiwidjaja/frontend-pagebuilder | js/tinymce/plugins/spellchecker/plugin.js | markErrors | function markErrors(data) {
var suggestions;
if (data.words) {
hasDictionarySupport = !!data.dictionary;
suggestions = data.words;
} else {
// Fallback to old format
suggestions = data;
}
editor.setProgressState(false);
if (isEmpty(suggestions)) {
var message = editor.translate('No misspellings found.');
editor.notificationManager.open({ text: message, type: 'info' });
started = false;
return;
}
lastSuggestions = suggestions;
getTextMatcher().find(getWordCharPattern()).filter(function (match) {
return !!suggestions[match.text];
}).wrap(function (match) {
return editor.dom.create('span', {
"class": 'mce-spellchecker-word',
"data-mce-bogus": 1,
"data-mce-word": match.text
});
});
started = true;
editor.fire('SpellcheckStart');
} | javascript | function markErrors(data) {
var suggestions;
if (data.words) {
hasDictionarySupport = !!data.dictionary;
suggestions = data.words;
} else {
// Fallback to old format
suggestions = data;
}
editor.setProgressState(false);
if (isEmpty(suggestions)) {
var message = editor.translate('No misspellings found.');
editor.notificationManager.open({ text: message, type: 'info' });
started = false;
return;
}
lastSuggestions = suggestions;
getTextMatcher().find(getWordCharPattern()).filter(function (match) {
return !!suggestions[match.text];
}).wrap(function (match) {
return editor.dom.create('span', {
"class": 'mce-spellchecker-word',
"data-mce-bogus": 1,
"data-mce-word": match.text
});
});
started = true;
editor.fire('SpellcheckStart');
} | [
"function",
"markErrors",
"(",
"data",
")",
"{",
"var",
"suggestions",
";",
"if",
"(",
"data",
".",
"words",
")",
"{",
"hasDictionarySupport",
"=",
"!",
"!",
"data",
".",
"dictionary",
";",
"suggestions",
"=",
"data",
".",
"words",
";",
"}",
"else",
"{",
"// Fallback to old format",
"suggestions",
"=",
"data",
";",
"}",
"editor",
".",
"setProgressState",
"(",
"false",
")",
";",
"if",
"(",
"isEmpty",
"(",
"suggestions",
")",
")",
"{",
"var",
"message",
"=",
"editor",
".",
"translate",
"(",
"'No misspellings found.'",
")",
";",
"editor",
".",
"notificationManager",
".",
"open",
"(",
"{",
"text",
":",
"message",
",",
"type",
":",
"'info'",
"}",
")",
";",
"started",
"=",
"false",
";",
"return",
";",
"}",
"lastSuggestions",
"=",
"suggestions",
";",
"getTextMatcher",
"(",
")",
".",
"find",
"(",
"getWordCharPattern",
"(",
")",
")",
".",
"filter",
"(",
"function",
"(",
"match",
")",
"{",
"return",
"!",
"!",
"suggestions",
"[",
"match",
".",
"text",
"]",
";",
"}",
")",
".",
"wrap",
"(",
"function",
"(",
"match",
")",
"{",
"return",
"editor",
".",
"dom",
".",
"create",
"(",
"'span'",
",",
"{",
"\"class\"",
":",
"'mce-spellchecker-word'",
",",
"\"data-mce-bogus\"",
":",
"1",
",",
"\"data-mce-word\"",
":",
"match",
".",
"text",
"}",
")",
";",
"}",
")",
";",
"started",
"=",
"true",
";",
"editor",
".",
"fire",
"(",
"'SpellcheckStart'",
")",
";",
"}"
] | Find the specified words and marks them. It will also show suggestions for those words.
@example
editor.plugins.spellchecker.markErrors({
dictionary: true,
words: {
"word1": ["suggestion 1", "Suggestion 2"]
}
});
@param {Object} data Data object containing the words with suggestions. | [
"Find",
"the",
"specified",
"words",
"and",
"marks",
"them",
".",
"It",
"will",
"also",
"show",
"suggestions",
"for",
"those",
"words",
"."
] | a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f | https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/plugins/spellchecker/plugin.js#L1075-L1109 |
57,727 | skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/htmlparser/element.js | function( filter, context ) {
var element = this,
originalName, name;
context = element.getFilterContext( context );
// Do not process elements with data-cke-processor attribute set to off.
if ( context.off )
return true;
// Filtering if it's the root node.
if ( !element.parent )
filter.onRoot( context, element );
while ( true ) {
originalName = element.name;
if ( !( name = filter.onElementName( context, originalName ) ) ) {
this.remove();
return false;
}
element.name = name;
if ( !( element = filter.onElement( context, element ) ) ) {
this.remove();
return false;
}
// New element has been returned - replace current one
// and process it (stop processing this and return false, what
// means that element has been removed).
if ( element !== this ) {
this.replaceWith( element );
return false;
}
// If name has been changed - continue loop, so in next iteration
// filters for new name will be applied to this element.
// If name hasn't been changed - stop.
if ( element.name == originalName )
break;
// If element has been replaced with something of a
// different type, then make the replacement filter itself.
if ( element.type != CKEDITOR.NODE_ELEMENT ) {
this.replaceWith( element );
return false;
}
// This indicate that the element has been dropped by
// filter but not the children.
if ( !element.name ) {
this.replaceWithChildren();
return false;
}
}
var attributes = element.attributes,
a, value, newAttrName;
for ( a in attributes ) {
newAttrName = a;
value = attributes[ a ];
// Loop until name isn't modified.
// A little bit senseless, but IE would do that anyway
// because it iterates with for-in loop even over properties
// created during its run.
while ( true ) {
if ( !( newAttrName = filter.onAttributeName( context, a ) ) ) {
delete attributes[ a ];
break;
} else if ( newAttrName != a ) {
delete attributes[ a ];
a = newAttrName;
continue;
} else {
break;
}
}
if ( newAttrName ) {
if ( ( value = filter.onAttribute( context, element, newAttrName, value ) ) === false )
delete attributes[ newAttrName ];
else
attributes[ newAttrName ] = value;
}
}
if ( !element.isEmpty )
this.filterChildren( filter, false, context );
return true;
} | javascript | function( filter, context ) {
var element = this,
originalName, name;
context = element.getFilterContext( context );
// Do not process elements with data-cke-processor attribute set to off.
if ( context.off )
return true;
// Filtering if it's the root node.
if ( !element.parent )
filter.onRoot( context, element );
while ( true ) {
originalName = element.name;
if ( !( name = filter.onElementName( context, originalName ) ) ) {
this.remove();
return false;
}
element.name = name;
if ( !( element = filter.onElement( context, element ) ) ) {
this.remove();
return false;
}
// New element has been returned - replace current one
// and process it (stop processing this and return false, what
// means that element has been removed).
if ( element !== this ) {
this.replaceWith( element );
return false;
}
// If name has been changed - continue loop, so in next iteration
// filters for new name will be applied to this element.
// If name hasn't been changed - stop.
if ( element.name == originalName )
break;
// If element has been replaced with something of a
// different type, then make the replacement filter itself.
if ( element.type != CKEDITOR.NODE_ELEMENT ) {
this.replaceWith( element );
return false;
}
// This indicate that the element has been dropped by
// filter but not the children.
if ( !element.name ) {
this.replaceWithChildren();
return false;
}
}
var attributes = element.attributes,
a, value, newAttrName;
for ( a in attributes ) {
newAttrName = a;
value = attributes[ a ];
// Loop until name isn't modified.
// A little bit senseless, but IE would do that anyway
// because it iterates with for-in loop even over properties
// created during its run.
while ( true ) {
if ( !( newAttrName = filter.onAttributeName( context, a ) ) ) {
delete attributes[ a ];
break;
} else if ( newAttrName != a ) {
delete attributes[ a ];
a = newAttrName;
continue;
} else {
break;
}
}
if ( newAttrName ) {
if ( ( value = filter.onAttribute( context, element, newAttrName, value ) ) === false )
delete attributes[ newAttrName ];
else
attributes[ newAttrName ] = value;
}
}
if ( !element.isEmpty )
this.filterChildren( filter, false, context );
return true;
} | [
"function",
"(",
"filter",
",",
"context",
")",
"{",
"var",
"element",
"=",
"this",
",",
"originalName",
",",
"name",
";",
"context",
"=",
"element",
".",
"getFilterContext",
"(",
"context",
")",
";",
"// Do not process elements with data-cke-processor attribute set to off.",
"if",
"(",
"context",
".",
"off",
")",
"return",
"true",
";",
"// Filtering if it's the root node.",
"if",
"(",
"!",
"element",
".",
"parent",
")",
"filter",
".",
"onRoot",
"(",
"context",
",",
"element",
")",
";",
"while",
"(",
"true",
")",
"{",
"originalName",
"=",
"element",
".",
"name",
";",
"if",
"(",
"!",
"(",
"name",
"=",
"filter",
".",
"onElementName",
"(",
"context",
",",
"originalName",
")",
")",
")",
"{",
"this",
".",
"remove",
"(",
")",
";",
"return",
"false",
";",
"}",
"element",
".",
"name",
"=",
"name",
";",
"if",
"(",
"!",
"(",
"element",
"=",
"filter",
".",
"onElement",
"(",
"context",
",",
"element",
")",
")",
")",
"{",
"this",
".",
"remove",
"(",
")",
";",
"return",
"false",
";",
"}",
"// New element has been returned - replace current one",
"// and process it (stop processing this and return false, what",
"// means that element has been removed).",
"if",
"(",
"element",
"!==",
"this",
")",
"{",
"this",
".",
"replaceWith",
"(",
"element",
")",
";",
"return",
"false",
";",
"}",
"// If name has been changed - continue loop, so in next iteration",
"// filters for new name will be applied to this element.",
"// If name hasn't been changed - stop.",
"if",
"(",
"element",
".",
"name",
"==",
"originalName",
")",
"break",
";",
"// If element has been replaced with something of a",
"// different type, then make the replacement filter itself.",
"if",
"(",
"element",
".",
"type",
"!=",
"CKEDITOR",
".",
"NODE_ELEMENT",
")",
"{",
"this",
".",
"replaceWith",
"(",
"element",
")",
";",
"return",
"false",
";",
"}",
"// This indicate that the element has been dropped by",
"// filter but not the children.",
"if",
"(",
"!",
"element",
".",
"name",
")",
"{",
"this",
".",
"replaceWithChildren",
"(",
")",
";",
"return",
"false",
";",
"}",
"}",
"var",
"attributes",
"=",
"element",
".",
"attributes",
",",
"a",
",",
"value",
",",
"newAttrName",
";",
"for",
"(",
"a",
"in",
"attributes",
")",
"{",
"newAttrName",
"=",
"a",
";",
"value",
"=",
"attributes",
"[",
"a",
"]",
";",
"// Loop until name isn't modified.",
"// A little bit senseless, but IE would do that anyway",
"// because it iterates with for-in loop even over properties",
"// created during its run.",
"while",
"(",
"true",
")",
"{",
"if",
"(",
"!",
"(",
"newAttrName",
"=",
"filter",
".",
"onAttributeName",
"(",
"context",
",",
"a",
")",
")",
")",
"{",
"delete",
"attributes",
"[",
"a",
"]",
";",
"break",
";",
"}",
"else",
"if",
"(",
"newAttrName",
"!=",
"a",
")",
"{",
"delete",
"attributes",
"[",
"a",
"]",
";",
"a",
"=",
"newAttrName",
";",
"continue",
";",
"}",
"else",
"{",
"break",
";",
"}",
"}",
"if",
"(",
"newAttrName",
")",
"{",
"if",
"(",
"(",
"value",
"=",
"filter",
".",
"onAttribute",
"(",
"context",
",",
"element",
",",
"newAttrName",
",",
"value",
")",
")",
"===",
"false",
")",
"delete",
"attributes",
"[",
"newAttrName",
"]",
";",
"else",
"attributes",
"[",
"newAttrName",
"]",
"=",
"value",
";",
"}",
"}",
"if",
"(",
"!",
"element",
".",
"isEmpty",
")",
"this",
".",
"filterChildren",
"(",
"filter",
",",
"false",
",",
"context",
")",
";",
"return",
"true",
";",
"}"
] | Filters this element and its children with the given filter.
@since 4.1
@param {CKEDITOR.htmlParser.filter} filter
@returns {Boolean} The method returns `false` when this element has
been removed or replaced with another. This information means that
{@link #filterChildren} has to repeat the filter on the current
position in parent's children array. | [
"Filters",
"this",
"element",
"and",
"its",
"children",
"with",
"the",
"given",
"filter",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/htmlparser/element.js#L160-L254 |
|
57,728 | skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/htmlparser/element.js | function( writer, filter ) {
if ( filter )
this.filter( filter );
var name = this.name,
attribsArray = [],
attributes = this.attributes,
attrName,
attr, i, l;
// Open element tag.
writer.openTag( name, attributes );
// Copy all attributes to an array.
for ( attrName in attributes )
attribsArray.push( [ attrName, attributes[ attrName ] ] );
// Sort the attributes by name.
if ( writer.sortAttributes )
attribsArray.sort( sortAttribs );
// Send the attributes.
for ( i = 0, l = attribsArray.length; i < l; i++ ) {
attr = attribsArray[ i ];
writer.attribute( attr[ 0 ], attr[ 1 ] );
}
// Close the tag.
writer.openTagClose( name, this.isEmpty );
this.writeChildrenHtml( writer );
// Close the element.
if ( !this.isEmpty )
writer.closeTag( name );
} | javascript | function( writer, filter ) {
if ( filter )
this.filter( filter );
var name = this.name,
attribsArray = [],
attributes = this.attributes,
attrName,
attr, i, l;
// Open element tag.
writer.openTag( name, attributes );
// Copy all attributes to an array.
for ( attrName in attributes )
attribsArray.push( [ attrName, attributes[ attrName ] ] );
// Sort the attributes by name.
if ( writer.sortAttributes )
attribsArray.sort( sortAttribs );
// Send the attributes.
for ( i = 0, l = attribsArray.length; i < l; i++ ) {
attr = attribsArray[ i ];
writer.attribute( attr[ 0 ], attr[ 1 ] );
}
// Close the tag.
writer.openTagClose( name, this.isEmpty );
this.writeChildrenHtml( writer );
// Close the element.
if ( !this.isEmpty )
writer.closeTag( name );
} | [
"function",
"(",
"writer",
",",
"filter",
")",
"{",
"if",
"(",
"filter",
")",
"this",
".",
"filter",
"(",
"filter",
")",
";",
"var",
"name",
"=",
"this",
".",
"name",
",",
"attribsArray",
"=",
"[",
"]",
",",
"attributes",
"=",
"this",
".",
"attributes",
",",
"attrName",
",",
"attr",
",",
"i",
",",
"l",
";",
"// Open element tag.",
"writer",
".",
"openTag",
"(",
"name",
",",
"attributes",
")",
";",
"// Copy all attributes to an array.",
"for",
"(",
"attrName",
"in",
"attributes",
")",
"attribsArray",
".",
"push",
"(",
"[",
"attrName",
",",
"attributes",
"[",
"attrName",
"]",
"]",
")",
";",
"// Sort the attributes by name.",
"if",
"(",
"writer",
".",
"sortAttributes",
")",
"attribsArray",
".",
"sort",
"(",
"sortAttribs",
")",
";",
"// Send the attributes.",
"for",
"(",
"i",
"=",
"0",
",",
"l",
"=",
"attribsArray",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"attr",
"=",
"attribsArray",
"[",
"i",
"]",
";",
"writer",
".",
"attribute",
"(",
"attr",
"[",
"0",
"]",
",",
"attr",
"[",
"1",
"]",
")",
";",
"}",
"// Close the tag.",
"writer",
".",
"openTagClose",
"(",
"name",
",",
"this",
".",
"isEmpty",
")",
";",
"this",
".",
"writeChildrenHtml",
"(",
"writer",
")",
";",
"// Close the element.",
"if",
"(",
"!",
"this",
".",
"isEmpty",
")",
"writer",
".",
"closeTag",
"(",
"name",
")",
";",
"}"
] | Writes the element HTML to the CKEDITOR.htmlWriter.
@param {CKEDITOR.htmlParser.basicWriter} writer The writer to which HTML will be written.
@param {CKEDITOR.htmlParser.filter} [filter] The filter to be applied to this node.
**Note:** It is unsafe to filter an offline (not appended) node. | [
"Writes",
"the",
"element",
"HTML",
"to",
"the",
"CKEDITOR",
".",
"htmlWriter",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/htmlparser/element.js#L274-L309 |
|
57,729 | skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/htmlparser/element.js | function() {
var children = this.children;
for ( var i = children.length; i; )
children[ --i ].insertAfter( this );
this.remove();
} | javascript | function() {
var children = this.children;
for ( var i = children.length; i; )
children[ --i ].insertAfter( this );
this.remove();
} | [
"function",
"(",
")",
"{",
"var",
"children",
"=",
"this",
".",
"children",
";",
"for",
"(",
"var",
"i",
"=",
"children",
".",
"length",
";",
"i",
";",
")",
"children",
"[",
"--",
"i",
"]",
".",
"insertAfter",
"(",
"this",
")",
";",
"this",
".",
"remove",
"(",
")",
";",
"}"
] | Replaces this element with its children.
@since 4.1 | [
"Replaces",
"this",
"element",
"with",
"its",
"children",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/htmlparser/element.js#L324-L331 |
|
57,730 | skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/htmlparser/element.js | function( condition ) {
if ( !condition )
return this.children.length ? this.children[ 0 ] : null;
if ( typeof condition != 'function' )
condition = nameCondition( condition );
for ( var i = 0, l = this.children.length; i < l; ++i ) {
if ( condition( this.children[ i ] ) )
return this.children[ i ];
}
return null;
} | javascript | function( condition ) {
if ( !condition )
return this.children.length ? this.children[ 0 ] : null;
if ( typeof condition != 'function' )
condition = nameCondition( condition );
for ( var i = 0, l = this.children.length; i < l; ++i ) {
if ( condition( this.children[ i ] ) )
return this.children[ i ];
}
return null;
} | [
"function",
"(",
"condition",
")",
"{",
"if",
"(",
"!",
"condition",
")",
"return",
"this",
".",
"children",
".",
"length",
"?",
"this",
".",
"children",
"[",
"0",
"]",
":",
"null",
";",
"if",
"(",
"typeof",
"condition",
"!=",
"'function'",
")",
"condition",
"=",
"nameCondition",
"(",
"condition",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"this",
".",
"children",
".",
"length",
";",
"i",
"<",
"l",
";",
"++",
"i",
")",
"{",
"if",
"(",
"condition",
"(",
"this",
".",
"children",
"[",
"i",
"]",
")",
")",
"return",
"this",
".",
"children",
"[",
"i",
"]",
";",
"}",
"return",
"null",
";",
"}"
] | Gets this element's first child. If `condition` is given, this method returns
the first child which satisfies that condition.
@since 4.3
@param {String/Object/Function} condition Name of a child, a hash of names, or a validator function.
@returns {CKEDITOR.htmlParser.node} | [
"Gets",
"this",
"element",
"s",
"first",
"child",
".",
"If",
"condition",
"is",
"given",
"this",
"method",
"returns",
"the",
"first",
"child",
"which",
"satisfies",
"that",
"condition",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/htmlparser/element.js#L366-L378 |
|
57,731 | skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/htmlparser/element.js | function( html ) {
var children = this.children = CKEDITOR.htmlParser.fragment.fromHtml( html ).children;
for ( var i = 0, l = children.length; i < l; ++i )
children[ i ].parent = this;
} | javascript | function( html ) {
var children = this.children = CKEDITOR.htmlParser.fragment.fromHtml( html ).children;
for ( var i = 0, l = children.length; i < l; ++i )
children[ i ].parent = this;
} | [
"function",
"(",
"html",
")",
"{",
"var",
"children",
"=",
"this",
".",
"children",
"=",
"CKEDITOR",
".",
"htmlParser",
".",
"fragment",
".",
"fromHtml",
"(",
"html",
")",
".",
"children",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"children",
".",
"length",
";",
"i",
"<",
"l",
";",
"++",
"i",
")",
"children",
"[",
"i",
"]",
".",
"parent",
"=",
"this",
";",
"}"
] | Sets this element's inner HTML.
@since 4.3
@param {String} html | [
"Sets",
"this",
"element",
"s",
"inner",
"HTML",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/htmlparser/element.js#L398-L403 |
|
57,732 | skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/htmlparser/element.js | function( index ) {
var cloneChildren = this.children.splice( index, this.children.length - index ),
clone = this.clone();
for ( var i = 0; i < cloneChildren.length; ++i )
cloneChildren[ i ].parent = clone;
clone.children = cloneChildren;
if ( cloneChildren[ 0 ] )
cloneChildren[ 0 ].previous = null;
if ( index > 0 )
this.children[ index - 1 ].next = null;
this.parent.add( clone, this.getIndex() + 1 );
return clone;
} | javascript | function( index ) {
var cloneChildren = this.children.splice( index, this.children.length - index ),
clone = this.clone();
for ( var i = 0; i < cloneChildren.length; ++i )
cloneChildren[ i ].parent = clone;
clone.children = cloneChildren;
if ( cloneChildren[ 0 ] )
cloneChildren[ 0 ].previous = null;
if ( index > 0 )
this.children[ index - 1 ].next = null;
this.parent.add( clone, this.getIndex() + 1 );
return clone;
} | [
"function",
"(",
"index",
")",
"{",
"var",
"cloneChildren",
"=",
"this",
".",
"children",
".",
"splice",
"(",
"index",
",",
"this",
".",
"children",
".",
"length",
"-",
"index",
")",
",",
"clone",
"=",
"this",
".",
"clone",
"(",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"cloneChildren",
".",
"length",
";",
"++",
"i",
")",
"cloneChildren",
"[",
"i",
"]",
".",
"parent",
"=",
"clone",
";",
"clone",
".",
"children",
"=",
"cloneChildren",
";",
"if",
"(",
"cloneChildren",
"[",
"0",
"]",
")",
"cloneChildren",
"[",
"0",
"]",
".",
"previous",
"=",
"null",
";",
"if",
"(",
"index",
">",
"0",
")",
"this",
".",
"children",
"[",
"index",
"-",
"1",
"]",
".",
"next",
"=",
"null",
";",
"this",
".",
"parent",
".",
"add",
"(",
"clone",
",",
"this",
".",
"getIndex",
"(",
")",
"+",
"1",
")",
";",
"return",
"clone",
";",
"}"
] | Splits this element at the given index.
@since 4.3
@param {Number} index Index at which the element will be split — `0` means the beginning,
`1` after first child node, etc.
@returns {CKEDITOR.htmlParser.element} The new element following this one. | [
"Splits",
"this",
"element",
"at",
"the",
"given",
"index",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/htmlparser/element.js#L425-L443 |
|
57,733 | skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/htmlparser/element.js | function( className ) {
var classes = this.attributes[ 'class' ];
if ( !classes )
return;
// We can safely assume that className won't break regexp.
// http://stackoverflow.com/questions/448981/what-characters-are-valid-in-css-class-names
classes = CKEDITOR.tools.trim( classes.replace( new RegExp( '(?:\\s+|^)' + className + '(?:\\s+|$)' ), ' ' ) );
if ( classes )
this.attributes[ 'class' ] = classes;
else
delete this.attributes[ 'class' ];
} | javascript | function( className ) {
var classes = this.attributes[ 'class' ];
if ( !classes )
return;
// We can safely assume that className won't break regexp.
// http://stackoverflow.com/questions/448981/what-characters-are-valid-in-css-class-names
classes = CKEDITOR.tools.trim( classes.replace( new RegExp( '(?:\\s+|^)' + className + '(?:\\s+|$)' ), ' ' ) );
if ( classes )
this.attributes[ 'class' ] = classes;
else
delete this.attributes[ 'class' ];
} | [
"function",
"(",
"className",
")",
"{",
"var",
"classes",
"=",
"this",
".",
"attributes",
"[",
"'class'",
"]",
";",
"if",
"(",
"!",
"classes",
")",
"return",
";",
"// We can safely assume that className won't break regexp.",
"// http://stackoverflow.com/questions/448981/what-characters-are-valid-in-css-class-names",
"classes",
"=",
"CKEDITOR",
".",
"tools",
".",
"trim",
"(",
"classes",
".",
"replace",
"(",
"new",
"RegExp",
"(",
"'(?:\\\\s+|^)'",
"+",
"className",
"+",
"'(?:\\\\s+|$)'",
")",
",",
"' '",
")",
")",
";",
"if",
"(",
"classes",
")",
"this",
".",
"attributes",
"[",
"'class'",
"]",
"=",
"classes",
";",
"else",
"delete",
"this",
".",
"attributes",
"[",
"'class'",
"]",
";",
"}"
] | Removes a class name from the list of classes.
@since 4.3
@param {String} className The class name to be removed. | [
"Removes",
"a",
"class",
"name",
"from",
"the",
"list",
"of",
"classes",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/htmlparser/element.js#L466-L480 |
|
57,734 | mcccclean/node-gamesprites | lib/formatters.js | function(outname, imagedata) {
var frames = [];
var animations = {};
// first pass: set up frame for each image, ensure an animation array is present
imagedata.forEach(function(im) {
var ox = Math.floor(im.width / 2);
var oy = Math.floor(im.height / 2);
im.frame = frames.length;
frames.push([im.x, im.y, im.width, im.height, 0, im.ox, im.oy]);
if(!animations[im.animname]) {
animations[im.animname] = { frames: [] };
}
});
// re-sort the images to frame order and then push their frame indices
// into the respective arrays.
imagedata.sort(function(a, b) { return a.animidx - b.animidx; });
imagedata.forEach(function(im) {
animations[im.animname].frames.push(im.frame);
});
// put all the data in its appropriate groups and JSONify
var data = {
frames: frames,
animations: animations,
images: [ outname + ".png" ]
};
return JSON.stringify(data, null, 2);
} | javascript | function(outname, imagedata) {
var frames = [];
var animations = {};
// first pass: set up frame for each image, ensure an animation array is present
imagedata.forEach(function(im) {
var ox = Math.floor(im.width / 2);
var oy = Math.floor(im.height / 2);
im.frame = frames.length;
frames.push([im.x, im.y, im.width, im.height, 0, im.ox, im.oy]);
if(!animations[im.animname]) {
animations[im.animname] = { frames: [] };
}
});
// re-sort the images to frame order and then push their frame indices
// into the respective arrays.
imagedata.sort(function(a, b) { return a.animidx - b.animidx; });
imagedata.forEach(function(im) {
animations[im.animname].frames.push(im.frame);
});
// put all the data in its appropriate groups and JSONify
var data = {
frames: frames,
animations: animations,
images: [ outname + ".png" ]
};
return JSON.stringify(data, null, 2);
} | [
"function",
"(",
"outname",
",",
"imagedata",
")",
"{",
"var",
"frames",
"=",
"[",
"]",
";",
"var",
"animations",
"=",
"{",
"}",
";",
"// first pass: set up frame for each image, ensure an animation array is present",
"imagedata",
".",
"forEach",
"(",
"function",
"(",
"im",
")",
"{",
"var",
"ox",
"=",
"Math",
".",
"floor",
"(",
"im",
".",
"width",
"/",
"2",
")",
";",
"var",
"oy",
"=",
"Math",
".",
"floor",
"(",
"im",
".",
"height",
"/",
"2",
")",
";",
"im",
".",
"frame",
"=",
"frames",
".",
"length",
";",
"frames",
".",
"push",
"(",
"[",
"im",
".",
"x",
",",
"im",
".",
"y",
",",
"im",
".",
"width",
",",
"im",
".",
"height",
",",
"0",
",",
"im",
".",
"ox",
",",
"im",
".",
"oy",
"]",
")",
";",
"if",
"(",
"!",
"animations",
"[",
"im",
".",
"animname",
"]",
")",
"{",
"animations",
"[",
"im",
".",
"animname",
"]",
"=",
"{",
"frames",
":",
"[",
"]",
"}",
";",
"}",
"}",
")",
";",
"// re-sort the images to frame order and then push their frame indices",
"// into the respective arrays.",
"imagedata",
".",
"sort",
"(",
"function",
"(",
"a",
",",
"b",
")",
"{",
"return",
"a",
".",
"animidx",
"-",
"b",
".",
"animidx",
";",
"}",
")",
";",
"imagedata",
".",
"forEach",
"(",
"function",
"(",
"im",
")",
"{",
"animations",
"[",
"im",
".",
"animname",
"]",
".",
"frames",
".",
"push",
"(",
"im",
".",
"frame",
")",
";",
"}",
")",
";",
"// put all the data in its appropriate groups and JSONify",
"var",
"data",
"=",
"{",
"frames",
":",
"frames",
",",
"animations",
":",
"animations",
",",
"images",
":",
"[",
"outname",
"+",
"\".png\"",
"]",
"}",
";",
"return",
"JSON",
".",
"stringify",
"(",
"data",
",",
"null",
",",
"2",
")",
";",
"}"
] | format for CreateJS framework | [
"format",
"for",
"CreateJS",
"framework"
] | 9c430065cda394c82f8074b7bf6b07ff807c1431 | https://github.com/mcccclean/node-gamesprites/blob/9c430065cda394c82f8074b7bf6b07ff807c1431/lib/formatters.js#L4-L33 |
|
57,735 | the-simian/phaser-shim-loader | index.js | phaserShim | function phaserShim(source) {
this.cacheable && this.cacheable();
source = source
.replace(/"object"==typeof exports/, 'false')
.replace(/(var\s+\w+\s*=\s*)Phaser(\s*\|\|\s*\{)/, 'var PIXI = exports.PIXI; $1Phaser$2')
.replace(/typeof module !== 'undefined' && module\.exports/g, "false /* typeof module !== 'undefined' && module.exports */")
.replace(/require\('nw\.gui'\)/g, "undefined /* require('nw.gui') */")
.replace(/(p2\.Body\.prototype)/, 'var Phaser = require("Phaser").Phaser; var p2 = require("p2"); $1');
source = 'var document = global.document;\n\n' + source;
return source;
} | javascript | function phaserShim(source) {
this.cacheable && this.cacheable();
source = source
.replace(/"object"==typeof exports/, 'false')
.replace(/(var\s+\w+\s*=\s*)Phaser(\s*\|\|\s*\{)/, 'var PIXI = exports.PIXI; $1Phaser$2')
.replace(/typeof module !== 'undefined' && module\.exports/g, "false /* typeof module !== 'undefined' && module.exports */")
.replace(/require\('nw\.gui'\)/g, "undefined /* require('nw.gui') */")
.replace(/(p2\.Body\.prototype)/, 'var Phaser = require("Phaser").Phaser; var p2 = require("p2"); $1');
source = 'var document = global.document;\n\n' + source;
return source;
} | [
"function",
"phaserShim",
"(",
"source",
")",
"{",
"this",
".",
"cacheable",
"&&",
"this",
".",
"cacheable",
"(",
")",
";",
"source",
"=",
"source",
".",
"replace",
"(",
"/",
"\"object\"==typeof exports",
"/",
",",
"'false'",
")",
".",
"replace",
"(",
"/",
"(var\\s+\\w+\\s*=\\s*)Phaser(\\s*\\|\\|\\s*\\{)",
"/",
",",
"'var PIXI = exports.PIXI; $1Phaser$2'",
")",
".",
"replace",
"(",
"/",
"typeof module !== 'undefined' && module\\.exports",
"/",
"g",
",",
"\"false /* typeof module !== 'undefined' && module.exports */\"",
")",
".",
"replace",
"(",
"/",
"require\\('nw\\.gui'\\)",
"/",
"g",
",",
"\"undefined /* require('nw.gui') */\"",
")",
".",
"replace",
"(",
"/",
"(p2\\.Body\\.prototype)",
"/",
",",
"'var Phaser = require(\"Phaser\").Phaser; var p2 = require(\"p2\"); $1'",
")",
";",
"source",
"=",
"'var document = global.document;\\n\\n'",
"+",
"source",
";",
"return",
"source",
";",
"}"
] | phaser-webpack-loader | [
"phaser",
"-",
"webpack",
"-",
"loader"
] | ff22b8903de18d6d9eff1765722366892daf929a | https://github.com/the-simian/phaser-shim-loader/blob/ff22b8903de18d6d9eff1765722366892daf929a/index.js#L5-L18 |
57,736 | SilentCicero/ethdeploy-provider-zero-client | index.js | function(providerObject) {
const fixedProviderObject = Object.assign({}, providerObject);
const oldGetAccountsMethod = providerObject.getAccounts;
// fix get accounts
if (typeof fixedProviderObject.getAccounts !== 'undefined') {
fixedProviderObject.getAccounts = function(getAccountsCallback) {
const oldCallback = getAccountsCallback;
// build fixed callback with lowercased accounts
const fixedCallback = function(accountsError, accountsResult) {
const fixedAccountsResult = accountsResult.slice(0);
// if no error, fixed result
if (!accountsError) {
fixedAccountsResult.map(function(item) {
return String(item.toLowerCase());
});
}
// fire oldd callback with new fix
oldCallback(accountsError, fixedAccountsResult);
}
// fire get accounts method
oldGetAccountsMethod(fixedCallback);
};
}
// return fixed provider object
return fixedProviderObject;
} | javascript | function(providerObject) {
const fixedProviderObject = Object.assign({}, providerObject);
const oldGetAccountsMethod = providerObject.getAccounts;
// fix get accounts
if (typeof fixedProviderObject.getAccounts !== 'undefined') {
fixedProviderObject.getAccounts = function(getAccountsCallback) {
const oldCallback = getAccountsCallback;
// build fixed callback with lowercased accounts
const fixedCallback = function(accountsError, accountsResult) {
const fixedAccountsResult = accountsResult.slice(0);
// if no error, fixed result
if (!accountsError) {
fixedAccountsResult.map(function(item) {
return String(item.toLowerCase());
});
}
// fire oldd callback with new fix
oldCallback(accountsError, fixedAccountsResult);
}
// fire get accounts method
oldGetAccountsMethod(fixedCallback);
};
}
// return fixed provider object
return fixedProviderObject;
} | [
"function",
"(",
"providerObject",
")",
"{",
"const",
"fixedProviderObject",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"providerObject",
")",
";",
"const",
"oldGetAccountsMethod",
"=",
"providerObject",
".",
"getAccounts",
";",
"// fix get accounts",
"if",
"(",
"typeof",
"fixedProviderObject",
".",
"getAccounts",
"!==",
"'undefined'",
")",
"{",
"fixedProviderObject",
".",
"getAccounts",
"=",
"function",
"(",
"getAccountsCallback",
")",
"{",
"const",
"oldCallback",
"=",
"getAccountsCallback",
";",
"// build fixed callback with lowercased accounts",
"const",
"fixedCallback",
"=",
"function",
"(",
"accountsError",
",",
"accountsResult",
")",
"{",
"const",
"fixedAccountsResult",
"=",
"accountsResult",
".",
"slice",
"(",
"0",
")",
";",
"// if no error, fixed result",
"if",
"(",
"!",
"accountsError",
")",
"{",
"fixedAccountsResult",
".",
"map",
"(",
"function",
"(",
"item",
")",
"{",
"return",
"String",
"(",
"item",
".",
"toLowerCase",
"(",
")",
")",
";",
"}",
")",
";",
"}",
"// fire oldd callback with new fix",
"oldCallback",
"(",
"accountsError",
",",
"fixedAccountsResult",
")",
";",
"}",
"// fire get accounts method",
"oldGetAccountsMethod",
"(",
"fixedCallback",
")",
";",
"}",
";",
"}",
"// return fixed provider object",
"return",
"fixedProviderObject",
";",
"}"
] | fix getAccounts method | [
"fix",
"getAccounts",
"method"
] | d0b777c47cd5fa61fa3cae5055ecb29a16b95f84 | https://github.com/SilentCicero/ethdeploy-provider-zero-client/blob/d0b777c47cd5fa61fa3cae5055ecb29a16b95f84/index.js#L6-L37 |
|
57,737 | SilentCicero/ethdeploy-provider-zero-client | index.js | function(accountsError, accountsResult) {
const fixedAccountsResult = accountsResult.slice(0);
// if no error, fixed result
if (!accountsError) {
fixedAccountsResult.map(function(item) {
return String(item.toLowerCase());
});
}
// fire oldd callback with new fix
oldCallback(accountsError, fixedAccountsResult);
} | javascript | function(accountsError, accountsResult) {
const fixedAccountsResult = accountsResult.slice(0);
// if no error, fixed result
if (!accountsError) {
fixedAccountsResult.map(function(item) {
return String(item.toLowerCase());
});
}
// fire oldd callback with new fix
oldCallback(accountsError, fixedAccountsResult);
} | [
"function",
"(",
"accountsError",
",",
"accountsResult",
")",
"{",
"const",
"fixedAccountsResult",
"=",
"accountsResult",
".",
"slice",
"(",
"0",
")",
";",
"// if no error, fixed result",
"if",
"(",
"!",
"accountsError",
")",
"{",
"fixedAccountsResult",
".",
"map",
"(",
"function",
"(",
"item",
")",
"{",
"return",
"String",
"(",
"item",
".",
"toLowerCase",
"(",
")",
")",
";",
"}",
")",
";",
"}",
"// fire oldd callback with new fix",
"oldCallback",
"(",
"accountsError",
",",
"fixedAccountsResult",
")",
";",
"}"
] | build fixed callback with lowercased accounts | [
"build",
"fixed",
"callback",
"with",
"lowercased",
"accounts"
] | d0b777c47cd5fa61fa3cae5055ecb29a16b95f84 | https://github.com/SilentCicero/ethdeploy-provider-zero-client/blob/d0b777c47cd5fa61fa3cae5055ecb29a16b95f84/index.js#L16-L28 |
|
57,738 | SilentCicero/ethdeploy-provider-zero-client | index.js | function(rawTx) {
const rawTxMutation = Object.assign({}, rawTx);
// fix rawTx gaslimit
if (typeof rawTxMutation.gas !== 'undefined') {
rawTxMutation.gasLimit = rawTxMutation.gas;
delete rawTxMutation.gas;
}
// fix data by prefixing it with zero
if (typeof rawTxMutation.data !== 'undefined'
&& rawTxMutation.data.slice(0, 2) !== '0x') {
rawTxMutation.data = '0x' + rawTxMutation.data;
}
// return new mutated raw tx object
return rawTxMutation;
} | javascript | function(rawTx) {
const rawTxMutation = Object.assign({}, rawTx);
// fix rawTx gaslimit
if (typeof rawTxMutation.gas !== 'undefined') {
rawTxMutation.gasLimit = rawTxMutation.gas;
delete rawTxMutation.gas;
}
// fix data by prefixing it with zero
if (typeof rawTxMutation.data !== 'undefined'
&& rawTxMutation.data.slice(0, 2) !== '0x') {
rawTxMutation.data = '0x' + rawTxMutation.data;
}
// return new mutated raw tx object
return rawTxMutation;
} | [
"function",
"(",
"rawTx",
")",
"{",
"const",
"rawTxMutation",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"rawTx",
")",
";",
"// fix rawTx gaslimit",
"if",
"(",
"typeof",
"rawTxMutation",
".",
"gas",
"!==",
"'undefined'",
")",
"{",
"rawTxMutation",
".",
"gasLimit",
"=",
"rawTxMutation",
".",
"gas",
";",
"delete",
"rawTxMutation",
".",
"gas",
";",
"}",
"// fix data by prefixing it with zero",
"if",
"(",
"typeof",
"rawTxMutation",
".",
"data",
"!==",
"'undefined'",
"&&",
"rawTxMutation",
".",
"data",
".",
"slice",
"(",
"0",
",",
"2",
")",
"!==",
"'0x'",
")",
"{",
"rawTxMutation",
".",
"data",
"=",
"'0x'",
"+",
"rawTxMutation",
".",
"data",
";",
"}",
"// return new mutated raw tx object",
"return",
"rawTxMutation",
";",
"}"
] | fix ethereumjs-tx rawTx object | [
"fix",
"ethereumjs",
"-",
"tx",
"rawTx",
"object"
] | d0b777c47cd5fa61fa3cae5055ecb29a16b95f84 | https://github.com/SilentCicero/ethdeploy-provider-zero-client/blob/d0b777c47cd5fa61fa3cae5055ecb29a16b95f84/index.js#L40-L57 |
|
57,739 | SilentCicero/ethdeploy-provider-zero-client | index.js | function(providerObject) {
const fixedProviderObject = Object.assign({}, providerObject);
// object has signTransaction
if (typeof fixedProviderObject.signTransaction !== 'undefined') {
// store old sign transaction method
const oldSignTransactionMethod = fixedProviderObject.signTransaction;
// build new provider object signTransaciton method
fixedProviderObject.signTransaction = function(rawTx, cb) {
// fire old callback
oldSignTransactionMethod(fixEthereumJSTxObject(rawTx), cb);
};
}
// return fixed provider object
return fixedProviderObject;
} | javascript | function(providerObject) {
const fixedProviderObject = Object.assign({}, providerObject);
// object has signTransaction
if (typeof fixedProviderObject.signTransaction !== 'undefined') {
// store old sign transaction method
const oldSignTransactionMethod = fixedProviderObject.signTransaction;
// build new provider object signTransaciton method
fixedProviderObject.signTransaction = function(rawTx, cb) {
// fire old callback
oldSignTransactionMethod(fixEthereumJSTxObject(rawTx), cb);
};
}
// return fixed provider object
return fixedProviderObject;
} | [
"function",
"(",
"providerObject",
")",
"{",
"const",
"fixedProviderObject",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"providerObject",
")",
";",
"// object has signTransaction",
"if",
"(",
"typeof",
"fixedProviderObject",
".",
"signTransaction",
"!==",
"'undefined'",
")",
"{",
"// store old sign transaction method",
"const",
"oldSignTransactionMethod",
"=",
"fixedProviderObject",
".",
"signTransaction",
";",
"// build new provider object signTransaciton method",
"fixedProviderObject",
".",
"signTransaction",
"=",
"function",
"(",
"rawTx",
",",
"cb",
")",
"{",
"// fire old callback",
"oldSignTransactionMethod",
"(",
"fixEthereumJSTxObject",
"(",
"rawTx",
")",
",",
"cb",
")",
";",
"}",
";",
"}",
"// return fixed provider object",
"return",
"fixedProviderObject",
";",
"}"
] | fix signTransaction method with rawTx fix | [
"fix",
"signTransaction",
"method",
"with",
"rawTx",
"fix"
] | d0b777c47cd5fa61fa3cae5055ecb29a16b95f84 | https://github.com/SilentCicero/ethdeploy-provider-zero-client/blob/d0b777c47cd5fa61fa3cae5055ecb29a16b95f84/index.js#L60-L77 |
|
57,740 | Qwerios/madlib-xmldom | lib/browser.js | function(xmlString) {
var error, parser, xmlDoc;
if ((typeof Ti !== "undefined" && Ti !== null) && Ti.XML) {
try {
xmlDoc = Ti.XML.parseString(xmlString);
} catch (_error) {
error = _error;
xmlDoc = null;
}
return xmlDoc;
} else if (window.DOMParser != null) {
try {
parser = new window.DOMParser();
xmlDoc = parser.parseFromString(xmlString, "text/xml");
} catch (_error) {
error = _error;
xmlDoc = null;
}
return xmlDoc;
} else if (window.ActiveXObject && window.GetObject) {
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = "false";
try {
xmlDoc.loadXML(xmlString);
} catch (_error) {
error = _error;
xmlDoc = null;
}
return xmlDoc;
} else {
throw new Error("No XML parser available");
}
} | javascript | function(xmlString) {
var error, parser, xmlDoc;
if ((typeof Ti !== "undefined" && Ti !== null) && Ti.XML) {
try {
xmlDoc = Ti.XML.parseString(xmlString);
} catch (_error) {
error = _error;
xmlDoc = null;
}
return xmlDoc;
} else if (window.DOMParser != null) {
try {
parser = new window.DOMParser();
xmlDoc = parser.parseFromString(xmlString, "text/xml");
} catch (_error) {
error = _error;
xmlDoc = null;
}
return xmlDoc;
} else if (window.ActiveXObject && window.GetObject) {
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = "false";
try {
xmlDoc.loadXML(xmlString);
} catch (_error) {
error = _error;
xmlDoc = null;
}
return xmlDoc;
} else {
throw new Error("No XML parser available");
}
} | [
"function",
"(",
"xmlString",
")",
"{",
"var",
"error",
",",
"parser",
",",
"xmlDoc",
";",
"if",
"(",
"(",
"typeof",
"Ti",
"!==",
"\"undefined\"",
"&&",
"Ti",
"!==",
"null",
")",
"&&",
"Ti",
".",
"XML",
")",
"{",
"try",
"{",
"xmlDoc",
"=",
"Ti",
".",
"XML",
".",
"parseString",
"(",
"xmlString",
")",
";",
"}",
"catch",
"(",
"_error",
")",
"{",
"error",
"=",
"_error",
";",
"xmlDoc",
"=",
"null",
";",
"}",
"return",
"xmlDoc",
";",
"}",
"else",
"if",
"(",
"window",
".",
"DOMParser",
"!=",
"null",
")",
"{",
"try",
"{",
"parser",
"=",
"new",
"window",
".",
"DOMParser",
"(",
")",
";",
"xmlDoc",
"=",
"parser",
".",
"parseFromString",
"(",
"xmlString",
",",
"\"text/xml\"",
")",
";",
"}",
"catch",
"(",
"_error",
")",
"{",
"error",
"=",
"_error",
";",
"xmlDoc",
"=",
"null",
";",
"}",
"return",
"xmlDoc",
";",
"}",
"else",
"if",
"(",
"window",
".",
"ActiveXObject",
"&&",
"window",
".",
"GetObject",
")",
"{",
"xmlDoc",
"=",
"new",
"ActiveXObject",
"(",
"\"Microsoft.XMLDOM\"",
")",
";",
"xmlDoc",
".",
"async",
"=",
"\"false\"",
";",
"try",
"{",
"xmlDoc",
".",
"loadXML",
"(",
"xmlString",
")",
";",
"}",
"catch",
"(",
"_error",
")",
"{",
"error",
"=",
"_error",
";",
"xmlDoc",
"=",
"null",
";",
"}",
"return",
"xmlDoc",
";",
"}",
"else",
"{",
"throw",
"new",
"Error",
"(",
"\"No XML parser available\"",
")",
";",
"}",
"}"
] | Turns the provided XML string into an XML DOM Document using whatever
native means of doing so is available
@function parse
@param {String} xmlString A valid string containing XML
@return {DOM} An XML DOM Document instance | [
"Turns",
"the",
"provided",
"XML",
"string",
"into",
"an",
"XML",
"DOM",
"Document",
"using",
"whatever",
"native",
"means",
"of",
"doing",
"so",
"is",
"available"
] | e1bed72403519830c1e0255f2faa774ffecbed3d | https://github.com/Qwerios/madlib-xmldom/blob/e1bed72403519830c1e0255f2faa774ffecbed3d/lib/browser.js#L30-L62 |
|
57,741 | Qwerios/madlib-xmldom | lib/browser.js | function(xmlNode) {
var noNativeXml, noXMLSerializer;
if ((typeof Ti !== "undefined" && Ti !== null) && Ti.XML) {
return Ti.XML.serializeToString(xmlNode);
} else {
try {
return (new XMLSerializer()).serializeToString(xmlNode);
} catch (_error) {
noXMLSerializer = _error;
try {
return xmlNode.xml;
} catch (_error) {
noNativeXml = _error;
throw new Error("No XML serialization support");
}
}
}
} | javascript | function(xmlNode) {
var noNativeXml, noXMLSerializer;
if ((typeof Ti !== "undefined" && Ti !== null) && Ti.XML) {
return Ti.XML.serializeToString(xmlNode);
} else {
try {
return (new XMLSerializer()).serializeToString(xmlNode);
} catch (_error) {
noXMLSerializer = _error;
try {
return xmlNode.xml;
} catch (_error) {
noNativeXml = _error;
throw new Error("No XML serialization support");
}
}
}
} | [
"function",
"(",
"xmlNode",
")",
"{",
"var",
"noNativeXml",
",",
"noXMLSerializer",
";",
"if",
"(",
"(",
"typeof",
"Ti",
"!==",
"\"undefined\"",
"&&",
"Ti",
"!==",
"null",
")",
"&&",
"Ti",
".",
"XML",
")",
"{",
"return",
"Ti",
".",
"XML",
".",
"serializeToString",
"(",
"xmlNode",
")",
";",
"}",
"else",
"{",
"try",
"{",
"return",
"(",
"new",
"XMLSerializer",
"(",
")",
")",
".",
"serializeToString",
"(",
"xmlNode",
")",
";",
"}",
"catch",
"(",
"_error",
")",
"{",
"noXMLSerializer",
"=",
"_error",
";",
"try",
"{",
"return",
"xmlNode",
".",
"xml",
";",
"}",
"catch",
"(",
"_error",
")",
"{",
"noNativeXml",
"=",
"_error",
";",
"throw",
"new",
"Error",
"(",
"\"No XML serialization support\"",
")",
";",
"}",
"}",
"}",
"}"
] | Turns the provided XML DOM Node into an XML string using whatever
native means of doing so is available
@function serialize
@param {DOM Node} The XML Node that is to be serialized
@return {String} An XML string representation of the node and its children | [
"Turns",
"the",
"provided",
"XML",
"DOM",
"Node",
"into",
"an",
"XML",
"string",
"using",
"whatever",
"native",
"means",
"of",
"doing",
"so",
"is",
"available"
] | e1bed72403519830c1e0255f2faa774ffecbed3d | https://github.com/Qwerios/madlib-xmldom/blob/e1bed72403519830c1e0255f2faa774ffecbed3d/lib/browser.js#L74-L91 |
|
57,742 | nomocas/yamvish | lib/context.js | function(space, type, path, value, index) {
// console.log('context.notifyUpstream : ', space, type, path, value, index);
for (var i = 0, len = space._upstreams.length; i < len; ++i) {
var upstream = space._upstreams[i];
if (!upstream) {
// maybe it's because upstreams length has change so update it
// (probably a (or more) previous listener has removed some listeners through cascade)
len = space._upstreams.length;
continue;
}
// path is local to notified node. value is the modified value. index is the one from modification point.
upstream.call(this, value, type, path, index);
}
} | javascript | function(space, type, path, value, index) {
// console.log('context.notifyUpstream : ', space, type, path, value, index);
for (var i = 0, len = space._upstreams.length; i < len; ++i) {
var upstream = space._upstreams[i];
if (!upstream) {
// maybe it's because upstreams length has change so update it
// (probably a (or more) previous listener has removed some listeners through cascade)
len = space._upstreams.length;
continue;
}
// path is local to notified node. value is the modified value. index is the one from modification point.
upstream.call(this, value, type, path, index);
}
} | [
"function",
"(",
"space",
",",
"type",
",",
"path",
",",
"value",
",",
"index",
")",
"{",
"// console.log('context.notifyUpstream : ', space, type, path, value, index);",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"space",
".",
"_upstreams",
".",
"length",
";",
"i",
"<",
"len",
";",
"++",
"i",
")",
"{",
"var",
"upstream",
"=",
"space",
".",
"_upstreams",
"[",
"i",
"]",
";",
"if",
"(",
"!",
"upstream",
")",
"{",
"// maybe it's because upstreams length has change so update it",
"// (probably a (or more) previous listener has removed some listeners through cascade)",
"len",
"=",
"space",
".",
"_upstreams",
".",
"length",
";",
"continue",
";",
"}",
"// path is local to notified node. value is the modified value. index is the one from modification point.",
"upstream",
".",
"call",
"(",
"this",
",",
"value",
",",
"type",
",",
"path",
",",
"index",
")",
";",
"}",
"}"
] | notification from root to modification point.
Normaly for internal use. | [
"notification",
"from",
"root",
"to",
"modification",
"point",
".",
"Normaly",
"for",
"internal",
"use",
"."
] | 017a536bb6bafddf1b31c0c7af6f723be58e9f0e | https://github.com/nomocas/yamvish/blob/017a536bb6bafddf1b31c0c7af6f723be58e9f0e/lib/context.js#L433-L446 |
|
57,743 | b3nsn0w/murmur-random | index.js | random | function random (seed) {
/**
* Creates a subgenerator from the current one
*
* @param {string} key Key of the subgenerator
* @param {...number} params Parameters affecting the subgenerator's seed
*/
function subgen (key, ...params) {
return random(createSeed([...seed, keygen(key), ...params], seed.length))
}
/**
* Retrieves a value from the random generator
*
* **Warning:** keys are cached indefinitely, keep them constant
*
* @param {string} key Key of the random value
* @param {...number} params Parameters affecting the value
*/
function value (key, ...params) {
return murmur([...seed, keygen(key), ...params])
}
return { seed, subgen, value, util }
} | javascript | function random (seed) {
/**
* Creates a subgenerator from the current one
*
* @param {string} key Key of the subgenerator
* @param {...number} params Parameters affecting the subgenerator's seed
*/
function subgen (key, ...params) {
return random(createSeed([...seed, keygen(key), ...params], seed.length))
}
/**
* Retrieves a value from the random generator
*
* **Warning:** keys are cached indefinitely, keep them constant
*
* @param {string} key Key of the random value
* @param {...number} params Parameters affecting the value
*/
function value (key, ...params) {
return murmur([...seed, keygen(key), ...params])
}
return { seed, subgen, value, util }
} | [
"function",
"random",
"(",
"seed",
")",
"{",
"/**\n * Creates a subgenerator from the current one\n *\n * @param {string} key Key of the subgenerator\n * @param {...number} params Parameters affecting the subgenerator's seed\n */",
"function",
"subgen",
"(",
"key",
",",
"...",
"params",
")",
"{",
"return",
"random",
"(",
"createSeed",
"(",
"[",
"...",
"seed",
",",
"keygen",
"(",
"key",
")",
",",
"...",
"params",
"]",
",",
"seed",
".",
"length",
")",
")",
"}",
"/**\n * Retrieves a value from the random generator\n *\n * **Warning:** keys are cached indefinitely, keep them constant\n *\n * @param {string} key Key of the random value\n * @param {...number} params Parameters affecting the value\n */",
"function",
"value",
"(",
"key",
",",
"...",
"params",
")",
"{",
"return",
"murmur",
"(",
"[",
"...",
"seed",
",",
"keygen",
"(",
"key",
")",
",",
"...",
"params",
"]",
")",
"}",
"return",
"{",
"seed",
",",
"subgen",
",",
"value",
",",
"util",
"}",
"}"
] | Creates a deterministic random generator
@param {...number} seed Raw seed of the random generator | [
"Creates",
"a",
"deterministic",
"random",
"generator"
] | 240977106f74fc20583ef0c4f95aaf862a8b3bdc | https://github.com/b3nsn0w/murmur-random/blob/240977106f74fc20583ef0c4f95aaf862a8b3bdc/index.js#L17-L43 |
57,744 | b3nsn0w/murmur-random | index.js | subgen | function subgen (key, ...params) {
return random(createSeed([...seed, keygen(key), ...params], seed.length))
} | javascript | function subgen (key, ...params) {
return random(createSeed([...seed, keygen(key), ...params], seed.length))
} | [
"function",
"subgen",
"(",
"key",
",",
"...",
"params",
")",
"{",
"return",
"random",
"(",
"createSeed",
"(",
"[",
"...",
"seed",
",",
"keygen",
"(",
"key",
")",
",",
"...",
"params",
"]",
",",
"seed",
".",
"length",
")",
")",
"}"
] | Creates a subgenerator from the current one
@param {string} key Key of the subgenerator
@param {...number} params Parameters affecting the subgenerator's seed | [
"Creates",
"a",
"subgenerator",
"from",
"the",
"current",
"one"
] | 240977106f74fc20583ef0c4f95aaf862a8b3bdc | https://github.com/b3nsn0w/murmur-random/blob/240977106f74fc20583ef0c4f95aaf862a8b3bdc/index.js#L25-L27 |
57,745 | Industryswarm/isnode-mod-data | lib/mongodb/mongodb/lib/operations/mongo_client_ops.js | logout | function logout(mongoClient, dbName, callback) {
mongoClient.topology.logout(dbName, err => {
if (err) return callback(err);
callback(null, true);
});
} | javascript | function logout(mongoClient, dbName, callback) {
mongoClient.topology.logout(dbName, err => {
if (err) return callback(err);
callback(null, true);
});
} | [
"function",
"logout",
"(",
"mongoClient",
",",
"dbName",
",",
"callback",
")",
"{",
"mongoClient",
".",
"topology",
".",
"logout",
"(",
"dbName",
",",
"err",
"=>",
"{",
"if",
"(",
"err",
")",
"return",
"callback",
"(",
"err",
")",
";",
"callback",
"(",
"null",
",",
"true",
")",
";",
"}",
")",
";",
"}"
] | Logout user from server, fire off on all connections and remove all auth info.
@method
@param {MongoClient} mongoClient The MongoClient instance on which to logout.
@param {object} [options] Optional settings. See MongoClient.prototype.logout for a list of options.
@param {Db~resultCallback} [callback] The command result callback | [
"Logout",
"user",
"from",
"server",
"fire",
"off",
"on",
"all",
"connections",
"and",
"remove",
"all",
"auth",
"info",
"."
] | 5adc639b88a0d72cbeef23a6b5df7f4540745089 | https://github.com/Industryswarm/isnode-mod-data/blob/5adc639b88a0d72cbeef23a6b5df7f4540745089/lib/mongodb/mongodb/lib/operations/mongo_client_ops.js#L483-L488 |
57,746 | Industryswarm/isnode-mod-data | lib/mongodb/mongodb/lib/operations/mongo_client_ops.js | validOptions | function validOptions(options) {
const _validOptions = validOptionNames.concat(legacyOptionNames);
for (const name in options) {
if (ignoreOptionNames.indexOf(name) !== -1) {
continue;
}
if (_validOptions.indexOf(name) === -1 && options.validateOptions) {
return new MongoError(`option ${name} is not supported`);
} else if (_validOptions.indexOf(name) === -1) {
console.warn(`the options [${name}] is not supported`);
}
if (legacyOptionNames.indexOf(name) !== -1) {
console.warn(
`the server/replset/mongos/db options are deprecated, ` +
`all their options are supported at the top level of the options object [${validOptionNames}]`
);
}
}
} | javascript | function validOptions(options) {
const _validOptions = validOptionNames.concat(legacyOptionNames);
for (const name in options) {
if (ignoreOptionNames.indexOf(name) !== -1) {
continue;
}
if (_validOptions.indexOf(name) === -1 && options.validateOptions) {
return new MongoError(`option ${name} is not supported`);
} else if (_validOptions.indexOf(name) === -1) {
console.warn(`the options [${name}] is not supported`);
}
if (legacyOptionNames.indexOf(name) !== -1) {
console.warn(
`the server/replset/mongos/db options are deprecated, ` +
`all their options are supported at the top level of the options object [${validOptionNames}]`
);
}
}
} | [
"function",
"validOptions",
"(",
"options",
")",
"{",
"const",
"_validOptions",
"=",
"validOptionNames",
".",
"concat",
"(",
"legacyOptionNames",
")",
";",
"for",
"(",
"const",
"name",
"in",
"options",
")",
"{",
"if",
"(",
"ignoreOptionNames",
".",
"indexOf",
"(",
"name",
")",
"!==",
"-",
"1",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"_validOptions",
".",
"indexOf",
"(",
"name",
")",
"===",
"-",
"1",
"&&",
"options",
".",
"validateOptions",
")",
"{",
"return",
"new",
"MongoError",
"(",
"`",
"${",
"name",
"}",
"`",
")",
";",
"}",
"else",
"if",
"(",
"_validOptions",
".",
"indexOf",
"(",
"name",
")",
"===",
"-",
"1",
")",
"{",
"console",
".",
"warn",
"(",
"`",
"${",
"name",
"}",
"`",
")",
";",
"}",
"if",
"(",
"legacyOptionNames",
".",
"indexOf",
"(",
"name",
")",
"!==",
"-",
"1",
")",
"{",
"console",
".",
"warn",
"(",
"`",
"`",
"+",
"`",
"${",
"validOptionNames",
"}",
"`",
")",
";",
"}",
"}",
"}"
] | Validate options object | [
"Validate",
"options",
"object"
] | 5adc639b88a0d72cbeef23a6b5df7f4540745089 | https://github.com/Industryswarm/isnode-mod-data/blob/5adc639b88a0d72cbeef23a6b5df7f4540745089/lib/mongodb/mongodb/lib/operations/mongo_client_ops.js#L623-L644 |
57,747 | boljen/node-buffer-to-messages | index.js | Converter | function Converter() {
// Validate arguments
if (arguments.length === 1) {
this._bl = 2;
if (typeof arguments[0] !== "function")
throw new TypeError("Converter requires at least a callback function");
else
this._fx = arguments[0];
} else if (arguments.length >= 2) {
this._bl = arguments[0];
if (this._bl !== 1 && this._bl !== 2 && this._bl !== 4)
throw new TypeError("Prefix length must be 1, 2 or 4");
if (typeof arguments[1] !== "function")
throw new TypeError("Converter requires a callback function");
else
this._fx = arguments[1];
} else {
throw new Error("cannot construct a converter without a callback");
}
this.flush();
} | javascript | function Converter() {
// Validate arguments
if (arguments.length === 1) {
this._bl = 2;
if (typeof arguments[0] !== "function")
throw new TypeError("Converter requires at least a callback function");
else
this._fx = arguments[0];
} else if (arguments.length >= 2) {
this._bl = arguments[0];
if (this._bl !== 1 && this._bl !== 2 && this._bl !== 4)
throw new TypeError("Prefix length must be 1, 2 or 4");
if (typeof arguments[1] !== "function")
throw new TypeError("Converter requires a callback function");
else
this._fx = arguments[1];
} else {
throw new Error("cannot construct a converter without a callback");
}
this.flush();
} | [
"function",
"Converter",
"(",
")",
"{",
"// Validate arguments",
"if",
"(",
"arguments",
".",
"length",
"===",
"1",
")",
"{",
"this",
".",
"_bl",
"=",
"2",
";",
"if",
"(",
"typeof",
"arguments",
"[",
"0",
"]",
"!==",
"\"function\"",
")",
"throw",
"new",
"TypeError",
"(",
"\"Converter requires at least a callback function\"",
")",
";",
"else",
"this",
".",
"_fx",
"=",
"arguments",
"[",
"0",
"]",
";",
"}",
"else",
"if",
"(",
"arguments",
".",
"length",
">=",
"2",
")",
"{",
"this",
".",
"_bl",
"=",
"arguments",
"[",
"0",
"]",
";",
"if",
"(",
"this",
".",
"_bl",
"!==",
"1",
"&&",
"this",
".",
"_bl",
"!==",
"2",
"&&",
"this",
".",
"_bl",
"!==",
"4",
")",
"throw",
"new",
"TypeError",
"(",
"\"Prefix length must be 1, 2 or 4\"",
")",
";",
"if",
"(",
"typeof",
"arguments",
"[",
"1",
"]",
"!==",
"\"function\"",
")",
"throw",
"new",
"TypeError",
"(",
"\"Converter requires a callback function\"",
")",
";",
"else",
"this",
".",
"_fx",
"=",
"arguments",
"[",
"1",
"]",
";",
"}",
"else",
"{",
"throw",
"new",
"Error",
"(",
"\"cannot construct a converter without a callback\"",
")",
";",
"}",
"this",
".",
"flush",
"(",
")",
";",
"}"
] | Takes in a series of Buffers and calls back whenever a fixed-length
message has been completely processed.
@param {Integer} [prefixLength] - The length in bytes of the size prefix.
This argument is optional. The default length is 2 bytes, but can also be 1
or 4 bytes.
@param {Function} callback - This will be called every time a new message has
been completely processed. | [
"Takes",
"in",
"a",
"series",
"of",
"Buffers",
"and",
"calls",
"back",
"whenever",
"a",
"fixed",
"-",
"length",
"message",
"has",
"been",
"completely",
"processed",
"."
] | 9362c1677fd284d54040e56de99800a80494522e | https://github.com/boljen/node-buffer-to-messages/blob/9362c1677fd284d54040e56de99800a80494522e/index.js#L15-L43 |
57,748 | open-nata/nata-device | src/actions/ActionFactory.js | getCommonActions | function getCommonActions(device) {
const actions = []
actions.push(new BackAction(device))
actions.push(new HomeAction(device))
actions.push(new MenuAction(device))
actions.push()
return actions
} | javascript | function getCommonActions(device) {
const actions = []
actions.push(new BackAction(device))
actions.push(new HomeAction(device))
actions.push(new MenuAction(device))
actions.push()
return actions
} | [
"function",
"getCommonActions",
"(",
"device",
")",
"{",
"const",
"actions",
"=",
"[",
"]",
"actions",
".",
"push",
"(",
"new",
"BackAction",
"(",
"device",
")",
")",
"actions",
".",
"push",
"(",
"new",
"HomeAction",
"(",
"device",
")",
")",
"actions",
".",
"push",
"(",
"new",
"MenuAction",
"(",
"device",
")",
")",
"actions",
".",
"push",
"(",
")",
"return",
"actions",
"}"
] | back, home, menu actions | [
"back",
"home",
"menu",
"actions"
] | c2c1292fb0f634eab72e6770ee5b835b67186405 | https://github.com/open-nata/nata-device/blob/c2c1292fb0f634eab72e6770ee5b835b67186405/src/actions/ActionFactory.js#L59-L67 |
57,749 | richRemer/twixt-mutation | mutation.js | mutation | function mutation(target, handler) {
target.addEventListener("mutation", function(evt) {
handler.call(this, this, evt.mutations);
});
} | javascript | function mutation(target, handler) {
target.addEventListener("mutation", function(evt) {
handler.call(this, this, evt.mutations);
});
} | [
"function",
"mutation",
"(",
"target",
",",
"handler",
")",
"{",
"target",
".",
"addEventListener",
"(",
"\"mutation\"",
",",
"function",
"(",
"evt",
")",
"{",
"handler",
".",
"call",
"(",
"this",
",",
"this",
",",
"evt",
".",
"mutations",
")",
";",
"}",
")",
";",
"}"
] | Attach mutation event handler.
@param {EventTarget} target
@param {function} handler | [
"Attach",
"mutation",
"event",
"handler",
"."
] | e0b5f3883281888fa21a73a6d190e9d6dfef34e7 | https://github.com/richRemer/twixt-mutation/blob/e0b5f3883281888fa21a73a6d190e9d6dfef34e7/mutation.js#L6-L10 |
57,750 | dennismckinnon/tmsp-server | lib/tmspReader.js | Request | function Request(reqBytes){
var parsed;
var err
try {
parsed = types.Request.decode(reqBytes);
} catch (e) {
err = e;
}
//Check for request errors here
if(err){
this.BadRequest = true;
this.errCode = types.CodeType.EncodingError;
this.errMsg = "The request failed to be decoded"
} else if(!types.methodLookup[parsed.type]){
//Request type not recognized
//Make a request object for the error
this.BadRequest = true;
this.errCode = types.CodeType.UnknownRequest;
this.errMsg = "The request type was not understood"
} else {
this.BadRequest = false;
this.type = parsed.type;
this.method = types.methodLookup[this.type];
this.data = parsed.data.buffer.slice(parsed.data.offset);
this.dataLength = parsed.data.limit - parsed.data.offset;
this.dataLittle = parsed.data.littleEndian;
this.key = parsed.key;
this.value = parsed.value;
}
} | javascript | function Request(reqBytes){
var parsed;
var err
try {
parsed = types.Request.decode(reqBytes);
} catch (e) {
err = e;
}
//Check for request errors here
if(err){
this.BadRequest = true;
this.errCode = types.CodeType.EncodingError;
this.errMsg = "The request failed to be decoded"
} else if(!types.methodLookup[parsed.type]){
//Request type not recognized
//Make a request object for the error
this.BadRequest = true;
this.errCode = types.CodeType.UnknownRequest;
this.errMsg = "The request type was not understood"
} else {
this.BadRequest = false;
this.type = parsed.type;
this.method = types.methodLookup[this.type];
this.data = parsed.data.buffer.slice(parsed.data.offset);
this.dataLength = parsed.data.limit - parsed.data.offset;
this.dataLittle = parsed.data.littleEndian;
this.key = parsed.key;
this.value = parsed.value;
}
} | [
"function",
"Request",
"(",
"reqBytes",
")",
"{",
"var",
"parsed",
";",
"var",
"err",
"try",
"{",
"parsed",
"=",
"types",
".",
"Request",
".",
"decode",
"(",
"reqBytes",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"err",
"=",
"e",
";",
"}",
"//Check for request errors here",
"if",
"(",
"err",
")",
"{",
"this",
".",
"BadRequest",
"=",
"true",
";",
"this",
".",
"errCode",
"=",
"types",
".",
"CodeType",
".",
"EncodingError",
";",
"this",
".",
"errMsg",
"=",
"\"The request failed to be decoded\"",
"}",
"else",
"if",
"(",
"!",
"types",
".",
"methodLookup",
"[",
"parsed",
".",
"type",
"]",
")",
"{",
"//Request type not recognized",
"//Make a request object for the error",
"this",
".",
"BadRequest",
"=",
"true",
";",
"this",
".",
"errCode",
"=",
"types",
".",
"CodeType",
".",
"UnknownRequest",
";",
"this",
".",
"errMsg",
"=",
"\"The request type was not understood\"",
"}",
"else",
"{",
"this",
".",
"BadRequest",
"=",
"false",
";",
"this",
".",
"type",
"=",
"parsed",
".",
"type",
";",
"this",
".",
"method",
"=",
"types",
".",
"methodLookup",
"[",
"this",
".",
"type",
"]",
";",
"this",
".",
"data",
"=",
"parsed",
".",
"data",
".",
"buffer",
".",
"slice",
"(",
"parsed",
".",
"data",
".",
"offset",
")",
";",
"this",
".",
"dataLength",
"=",
"parsed",
".",
"data",
".",
"limit",
"-",
"parsed",
".",
"data",
".",
"offset",
";",
"this",
".",
"dataLittle",
"=",
"parsed",
".",
"data",
".",
"littleEndian",
";",
"this",
".",
"key",
"=",
"parsed",
".",
"key",
";",
"this",
".",
"value",
"=",
"parsed",
".",
"value",
";",
"}",
"}"
] | The Request object unlike in http requests is static So this stream is built to return it rather then the standard buffer. this means any consumer of this stream would need to take account of this fact | [
"The",
"Request",
"object",
"unlike",
"in",
"http",
"requests",
"is",
"static",
"So",
"this",
"stream",
"is",
"built",
"to",
"return",
"it",
"rather",
"then",
"the",
"standard",
"buffer",
".",
"this",
"means",
"any",
"consumer",
"of",
"this",
"stream",
"would",
"need",
"to",
"take",
"account",
"of",
"this",
"fact"
] | 24d054c5a3eeacc6552645a2e3a7ed353112b171 | https://github.com/dennismckinnon/tmsp-server/blob/24d054c5a3eeacc6552645a2e3a7ed353112b171/lib/tmspReader.js#L133-L166 |
57,751 | jeremyckahn/bezierizer | dist/jquery.dragon.js | fire | function fire (event, $el, evt) {
var handler = $el.data('dragon-opts')[event];
// Patch the proxied Event Object
evt.target = $el[0];
if (handler) {
handler(evt);
}
$el.trigger(event);
} | javascript | function fire (event, $el, evt) {
var handler = $el.data('dragon-opts')[event];
// Patch the proxied Event Object
evt.target = $el[0];
if (handler) {
handler(evt);
}
$el.trigger(event);
} | [
"function",
"fire",
"(",
"event",
",",
"$el",
",",
"evt",
")",
"{",
"var",
"handler",
"=",
"$el",
".",
"data",
"(",
"'dragon-opts'",
")",
"[",
"event",
"]",
";",
"// Patch the proxied Event Object",
"evt",
".",
"target",
"=",
"$el",
"[",
"0",
"]",
";",
"if",
"(",
"handler",
")",
"{",
"handler",
"(",
"evt",
")",
";",
"}",
"$el",
".",
"trigger",
"(",
"event",
")",
";",
"}"
] | Yep, you only get to bind one event handler. Much faster this way. | [
"Yep",
"you",
"only",
"get",
"to",
"bind",
"one",
"event",
"handler",
".",
"Much",
"faster",
"this",
"way",
"."
] | f1886b556279875bbb0da5051f7b716727b28768 | https://github.com/jeremyckahn/bezierizer/blob/f1886b556279875bbb0da5051f7b716727b28768/dist/jquery.dragon.js#L209-L218 |
57,752 | mnichols/ankh | lib/component-model.js | ComponentModel | function ComponentModel(key, impl, cfg) {
this.key = key
/**
* @property {Any} impl The implementation to use for `resolve`
* */
this.impl =impl
this._cfg = cfg || {}
/**
* @property {Array} inject The {String} dependencies array a service may declare
* */
this.inject = (this.impl.inject || [])
/**
* @property {String} initializable The method to invoke on an resolved service just after resolution, but before returning
* injecting any dependencies found on that method
* */
this.initializable = (this.impl.initializable || false)
/**
* @property {String} startable The method to invoke on an resolved services when started. Usually during an app bootstrap.
* */
this.startable = (this.impl.startable || false)
} | javascript | function ComponentModel(key, impl, cfg) {
this.key = key
/**
* @property {Any} impl The implementation to use for `resolve`
* */
this.impl =impl
this._cfg = cfg || {}
/**
* @property {Array} inject The {String} dependencies array a service may declare
* */
this.inject = (this.impl.inject || [])
/**
* @property {String} initializable The method to invoke on an resolved service just after resolution, but before returning
* injecting any dependencies found on that method
* */
this.initializable = (this.impl.initializable || false)
/**
* @property {String} startable The method to invoke on an resolved services when started. Usually during an app bootstrap.
* */
this.startable = (this.impl.startable || false)
} | [
"function",
"ComponentModel",
"(",
"key",
",",
"impl",
",",
"cfg",
")",
"{",
"this",
".",
"key",
"=",
"key",
"/**\n * @property {Any} impl The implementation to use for `resolve`\n * */",
"this",
".",
"impl",
"=",
"impl",
"this",
".",
"_cfg",
"=",
"cfg",
"||",
"{",
"}",
"/**\n * @property {Array} inject The {String} dependencies array a service may declare\n * */",
"this",
".",
"inject",
"=",
"(",
"this",
".",
"impl",
".",
"inject",
"||",
"[",
"]",
")",
"/**\n * @property {String} initializable The method to invoke on an resolved service just after resolution, but before returning\n * injecting any dependencies found on that method\n * */",
"this",
".",
"initializable",
"=",
"(",
"this",
".",
"impl",
".",
"initializable",
"||",
"false",
")",
"/**\n * @property {String} startable The method to invoke on an resolved services when started. Usually during an app bootstrap.\n * */",
"this",
".",
"startable",
"=",
"(",
"this",
".",
"impl",
".",
"startable",
"||",
"false",
")",
"}"
] | Describes the model for resolving a service
@class ComponentModel | [
"Describes",
"the",
"model",
"for",
"resolving",
"a",
"service"
] | b5f6eae24b2dece4025b4f11cea7f1560d3b345f | https://github.com/mnichols/ankh/blob/b5f6eae24b2dece4025b4f11cea7f1560d3b345f/lib/component-model.js#L9-L29 |
57,753 | JohnnieFucker/dreamix-admin | lib/modules/monitorLog.js | fetchLogs | function fetchLogs(root, msg, callback) {
const number = msg.number;
const logfile = msg.logfile;
const serverId = msg.serverId;
const filePath = path.join(root, getLogFileName(logfile, serverId));
const endLogs = [];
exec(`tail -n ${number} ${filePath}`, (error, output) => {
const endOut = [];
output = output.replace(/^\s+|\s+$/g, '').split(/\s+/);
for (let i = 5; i < output.length; i += 6) {
endOut.push(output[i]);
}
const endLength = endOut.length;
for (let j = 0; j < endLength; j++) {
const map = {};
let json;
try {
json = JSON.parse(endOut[j]);
} catch (e) {
logger.error(`the log cannot parsed to json, ${e}`);
continue; // eslint-disable-line
}
map.time = json.time;
map.route = json.route || json.service;
map.serverId = serverId;
map.timeUsed = json.timeUsed;
map.params = endOut[j];
endLogs.push(map);
}
callback({ logfile: logfile, dataArray: endLogs });
});
} | javascript | function fetchLogs(root, msg, callback) {
const number = msg.number;
const logfile = msg.logfile;
const serverId = msg.serverId;
const filePath = path.join(root, getLogFileName(logfile, serverId));
const endLogs = [];
exec(`tail -n ${number} ${filePath}`, (error, output) => {
const endOut = [];
output = output.replace(/^\s+|\s+$/g, '').split(/\s+/);
for (let i = 5; i < output.length; i += 6) {
endOut.push(output[i]);
}
const endLength = endOut.length;
for (let j = 0; j < endLength; j++) {
const map = {};
let json;
try {
json = JSON.parse(endOut[j]);
} catch (e) {
logger.error(`the log cannot parsed to json, ${e}`);
continue; // eslint-disable-line
}
map.time = json.time;
map.route = json.route || json.service;
map.serverId = serverId;
map.timeUsed = json.timeUsed;
map.params = endOut[j];
endLogs.push(map);
}
callback({ logfile: logfile, dataArray: endLogs });
});
} | [
"function",
"fetchLogs",
"(",
"root",
",",
"msg",
",",
"callback",
")",
"{",
"const",
"number",
"=",
"msg",
".",
"number",
";",
"const",
"logfile",
"=",
"msg",
".",
"logfile",
";",
"const",
"serverId",
"=",
"msg",
".",
"serverId",
";",
"const",
"filePath",
"=",
"path",
".",
"join",
"(",
"root",
",",
"getLogFileName",
"(",
"logfile",
",",
"serverId",
")",
")",
";",
"const",
"endLogs",
"=",
"[",
"]",
";",
"exec",
"(",
"`",
"${",
"number",
"}",
"${",
"filePath",
"}",
"`",
",",
"(",
"error",
",",
"output",
")",
"=>",
"{",
"const",
"endOut",
"=",
"[",
"]",
";",
"output",
"=",
"output",
".",
"replace",
"(",
"/",
"^\\s+|\\s+$",
"/",
"g",
",",
"''",
")",
".",
"split",
"(",
"/",
"\\s+",
"/",
")",
";",
"for",
"(",
"let",
"i",
"=",
"5",
";",
"i",
"<",
"output",
".",
"length",
";",
"i",
"+=",
"6",
")",
"{",
"endOut",
".",
"push",
"(",
"output",
"[",
"i",
"]",
")",
";",
"}",
"const",
"endLength",
"=",
"endOut",
".",
"length",
";",
"for",
"(",
"let",
"j",
"=",
"0",
";",
"j",
"<",
"endLength",
";",
"j",
"++",
")",
"{",
"const",
"map",
"=",
"{",
"}",
";",
"let",
"json",
";",
"try",
"{",
"json",
"=",
"JSON",
".",
"parse",
"(",
"endOut",
"[",
"j",
"]",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"`",
"${",
"e",
"}",
"`",
")",
";",
"continue",
";",
"// eslint-disable-line",
"}",
"map",
".",
"time",
"=",
"json",
".",
"time",
";",
"map",
".",
"route",
"=",
"json",
".",
"route",
"||",
"json",
".",
"service",
";",
"map",
".",
"serverId",
"=",
"serverId",
";",
"map",
".",
"timeUsed",
"=",
"json",
".",
"timeUsed",
";",
"map",
".",
"params",
"=",
"endOut",
"[",
"j",
"]",
";",
"endLogs",
".",
"push",
"(",
"map",
")",
";",
"}",
"callback",
"(",
"{",
"logfile",
":",
"logfile",
",",
"dataArray",
":",
"endLogs",
"}",
")",
";",
"}",
")",
";",
"}"
] | get the latest logs | [
"get",
"the",
"latest",
"logs"
] | fc169e2481d5a7456725fb33f7a7907e0776ef79 | https://github.com/JohnnieFucker/dreamix-admin/blob/fc169e2481d5a7456725fb33f7a7907e0776ef79/lib/modules/monitorLog.js#L13-L48 |
57,754 | Wiredcraft/carcass-config | proto/config.js | function(parser) {
return highland.map(function(item) {
if (_.isFunction(parser)) {
return parser(item);
}
if (_.isObject(parser) && (parser.parse != null)) {
return parser.parse(item);
}
return item;
});
} | javascript | function(parser) {
return highland.map(function(item) {
if (_.isFunction(parser)) {
return parser(item);
}
if (_.isObject(parser) && (parser.parse != null)) {
return parser.parse(item);
}
return item;
});
} | [
"function",
"(",
"parser",
")",
"{",
"return",
"highland",
".",
"map",
"(",
"function",
"(",
"item",
")",
"{",
"if",
"(",
"_",
".",
"isFunction",
"(",
"parser",
")",
")",
"{",
"return",
"parser",
"(",
"item",
")",
";",
"}",
"if",
"(",
"_",
".",
"isObject",
"(",
"parser",
")",
"&&",
"(",
"parser",
".",
"parse",
"!=",
"null",
")",
")",
"{",
"return",
"parser",
".",
"parse",
"(",
"item",
")",
";",
"}",
"return",
"item",
";",
"}",
")",
";",
"}"
] | Builder; returns a function which can be used to map a stream with a
given parser.
@param {Function|Object} parser can be either a function or an object, in
which case the parser.parse() will be used.
@return {Function} curried map().
@private | [
"Builder",
";",
"returns",
"a",
"function",
"which",
"can",
"be",
"used",
"to",
"map",
"a",
"stream",
"with",
"a",
"given",
"parser",
"."
] | bb1dce284acfb40d2c23a989fe7b5ee4e2221bab | https://github.com/Wiredcraft/carcass-config/blob/bb1dce284acfb40d2c23a989fe7b5ee4e2221bab/proto/config.js#L45-L55 |
|
57,755 | Wiredcraft/carcass-config | proto/config.js | function(done) {
var p, parser, stream, _i, _len;
parser = this.parser();
stream = highland(this.source());
if (_.isArray(parser)) {
for (_i = 0, _len = parser.length; _i < _len; _i++) {
p = parser[_i];
stream = this._mapWith(p)(stream).flatten().compact();
}
} else {
stream = this._mapWith(parser)(stream).flatten().compact();
}
stream = stream.reduce({}, _.merge);
if (done == null) {
return stream;
}
stream.pull(done);
return this;
} | javascript | function(done) {
var p, parser, stream, _i, _len;
parser = this.parser();
stream = highland(this.source());
if (_.isArray(parser)) {
for (_i = 0, _len = parser.length; _i < _len; _i++) {
p = parser[_i];
stream = this._mapWith(p)(stream).flatten().compact();
}
} else {
stream = this._mapWith(parser)(stream).flatten().compact();
}
stream = stream.reduce({}, _.merge);
if (done == null) {
return stream;
}
stream.pull(done);
return this;
} | [
"function",
"(",
"done",
")",
"{",
"var",
"p",
",",
"parser",
",",
"stream",
",",
"_i",
",",
"_len",
";",
"parser",
"=",
"this",
".",
"parser",
"(",
")",
";",
"stream",
"=",
"highland",
"(",
"this",
".",
"source",
"(",
")",
")",
";",
"if",
"(",
"_",
".",
"isArray",
"(",
"parser",
")",
")",
"{",
"for",
"(",
"_i",
"=",
"0",
",",
"_len",
"=",
"parser",
".",
"length",
";",
"_i",
"<",
"_len",
";",
"_i",
"++",
")",
"{",
"p",
"=",
"parser",
"[",
"_i",
"]",
";",
"stream",
"=",
"this",
".",
"_mapWith",
"(",
"p",
")",
"(",
"stream",
")",
".",
"flatten",
"(",
")",
".",
"compact",
"(",
")",
";",
"}",
"}",
"else",
"{",
"stream",
"=",
"this",
".",
"_mapWith",
"(",
"parser",
")",
"(",
"stream",
")",
".",
"flatten",
"(",
")",
".",
"compact",
"(",
")",
";",
"}",
"stream",
"=",
"stream",
".",
"reduce",
"(",
"{",
"}",
",",
"_",
".",
"merge",
")",
";",
"if",
"(",
"done",
"==",
"null",
")",
"{",
"return",
"stream",
";",
"}",
"stream",
".",
"pull",
"(",
"done",
")",
";",
"return",
"this",
";",
"}"
] | Loads all the sources and parses with a given parser, and merges the
results together.
Bad results (false, null, undefined) are skipped.
@param {Function|null} done the callback, if provided, will be called
with the result, and if not provided, the stream will be returned.
@return {this|stream} depends on whether a callback is provided.
@private | [
"Loads",
"all",
"the",
"sources",
"and",
"parses",
"with",
"a",
"given",
"parser",
"and",
"merges",
"the",
"results",
"together",
"."
] | bb1dce284acfb40d2c23a989fe7b5ee4e2221bab | https://github.com/Wiredcraft/carcass-config/blob/bb1dce284acfb40d2c23a989fe7b5ee4e2221bab/proto/config.js#L70-L88 |
|
57,756 | LOKE/loke-config | lib/merge-into.js | mergeInto | function mergeInto(target, source) {
var a = target;
var b = source;
if (a && b) {
for (var key in b) {
if (!(key in a)) {
continue;
}
if (typeof b[key] === 'object' && !Array.isArray(b[key]) && b[key] !== null) {
mergeInto(a[key], b[key]);
} else {
a[key] = b[key];
}
}
}
return a;
} | javascript | function mergeInto(target, source) {
var a = target;
var b = source;
if (a && b) {
for (var key in b) {
if (!(key in a)) {
continue;
}
if (typeof b[key] === 'object' && !Array.isArray(b[key]) && b[key] !== null) {
mergeInto(a[key], b[key]);
} else {
a[key] = b[key];
}
}
}
return a;
} | [
"function",
"mergeInto",
"(",
"target",
",",
"source",
")",
"{",
"var",
"a",
"=",
"target",
";",
"var",
"b",
"=",
"source",
";",
"if",
"(",
"a",
"&&",
"b",
")",
"{",
"for",
"(",
"var",
"key",
"in",
"b",
")",
"{",
"if",
"(",
"!",
"(",
"key",
"in",
"a",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"typeof",
"b",
"[",
"key",
"]",
"===",
"'object'",
"&&",
"!",
"Array",
".",
"isArray",
"(",
"b",
"[",
"key",
"]",
")",
"&&",
"b",
"[",
"key",
"]",
"!==",
"null",
")",
"{",
"mergeInto",
"(",
"a",
"[",
"key",
"]",
",",
"b",
"[",
"key",
"]",
")",
";",
"}",
"else",
"{",
"a",
"[",
"key",
"]",
"=",
"b",
"[",
"key",
"]",
";",
"}",
"}",
"}",
"return",
"a",
";",
"}"
] | Merges properties from source into target.
target will be modified as a result of this function.
@param {Object} target The target object to merge the source into.
Source values will override those in the target object.
@param {Object} source The source object to get override values from.
@return {Object} The target object (with source values merged into it) | [
"Merges",
"properties",
"from",
"source",
"into",
"target",
".",
"target",
"will",
"be",
"modified",
"as",
"a",
"result",
"of",
"this",
"function",
"."
] | 84c207b2724c919bc6dde5efd7e7328591908cce | https://github.com/LOKE/loke-config/blob/84c207b2724c919bc6dde5efd7e7328591908cce/lib/merge-into.js#L12-L29 |
57,757 | epii-io/epii-node-render | kernel/assist.js | tryWatch | function tryWatch(target, callback) {
if (!target) {
return logger.halt('invalid watch target')
}
if (!callback || typeof callback !== 'function') {
return logger.halt('invalid watch callback')
}
return fs.watch(
target, { persistent: true, recursive: true},
function (e, file) {
// todo: exact watch
callback(e, file)
}
)
} | javascript | function tryWatch(target, callback) {
if (!target) {
return logger.halt('invalid watch target')
}
if (!callback || typeof callback !== 'function') {
return logger.halt('invalid watch callback')
}
return fs.watch(
target, { persistent: true, recursive: true},
function (e, file) {
// todo: exact watch
callback(e, file)
}
)
} | [
"function",
"tryWatch",
"(",
"target",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"target",
")",
"{",
"return",
"logger",
".",
"halt",
"(",
"'invalid watch target'",
")",
"}",
"if",
"(",
"!",
"callback",
"||",
"typeof",
"callback",
"!==",
"'function'",
")",
"{",
"return",
"logger",
".",
"halt",
"(",
"'invalid watch callback'",
")",
"}",
"return",
"fs",
".",
"watch",
"(",
"target",
",",
"{",
"persistent",
":",
"true",
",",
"recursive",
":",
"true",
"}",
",",
"function",
"(",
"e",
",",
"file",
")",
"{",
"// todo: exact watch",
"callback",
"(",
"e",
",",
"file",
")",
"}",
")",
"}"
] | try to watch with custom callback
@param {String} target
@param {Function} callback
@return {Object} fs.Watcher | [
"try",
"to",
"watch",
"with",
"custom",
"callback"
] | e8afa57066251e173b3a6455d47218c95f30f563 | https://github.com/epii-io/epii-node-render/blob/e8afa57066251e173b3a6455d47218c95f30f563/kernel/assist.js#L30-L45 |
57,758 | epii-io/epii-node-render | kernel/assist.js | getBabelConfig | function getBabelConfig(env) {
var babelrcPath = path.join(__dirname, '.babelrc')
var babelrc = JSON.parse(fs.readFileSync(babelrcPath))
babelrc.presets = resolve(
babelrc.presets.map(preset => 'babel-preset-' + preset)
)
if (!babelrc.plugins) babelrc.plugins = []
return babelrc
} | javascript | function getBabelConfig(env) {
var babelrcPath = path.join(__dirname, '.babelrc')
var babelrc = JSON.parse(fs.readFileSync(babelrcPath))
babelrc.presets = resolve(
babelrc.presets.map(preset => 'babel-preset-' + preset)
)
if (!babelrc.plugins) babelrc.plugins = []
return babelrc
} | [
"function",
"getBabelConfig",
"(",
"env",
")",
"{",
"var",
"babelrcPath",
"=",
"path",
".",
"join",
"(",
"__dirname",
",",
"'.babelrc'",
")",
"var",
"babelrc",
"=",
"JSON",
".",
"parse",
"(",
"fs",
".",
"readFileSync",
"(",
"babelrcPath",
")",
")",
"babelrc",
".",
"presets",
"=",
"resolve",
"(",
"babelrc",
".",
"presets",
".",
"map",
"(",
"preset",
"=>",
"'babel-preset-'",
"+",
"preset",
")",
")",
"if",
"(",
"!",
"babelrc",
".",
"plugins",
")",
"babelrc",
".",
"plugins",
"=",
"[",
"]",
"return",
"babelrc",
"}"
] | get babel config
@param {String} env
@return {Object} babel config | [
"get",
"babel",
"config"
] | e8afa57066251e173b3a6455d47218c95f30f563 | https://github.com/epii-io/epii-node-render/blob/e8afa57066251e173b3a6455d47218c95f30f563/kernel/assist.js#L53-L61 |
57,759 | tniedbala/jxh | lib/renderUtility.js | isNested | function isNested(obj) {
if (getType(obj)==='object') {
for (let tag in obj) {
if (tag != TEXT && !ATTRTAG.test(tag)) {
return true;
}
}
}
} | javascript | function isNested(obj) {
if (getType(obj)==='object') {
for (let tag in obj) {
if (tag != TEXT && !ATTRTAG.test(tag)) {
return true;
}
}
}
} | [
"function",
"isNested",
"(",
"obj",
")",
"{",
"if",
"(",
"getType",
"(",
"obj",
")",
"===",
"'object'",
")",
"{",
"for",
"(",
"let",
"tag",
"in",
"obj",
")",
"{",
"if",
"(",
"tag",
"!=",
"TEXT",
"&&",
"!",
"ATTRTAG",
".",
"test",
"(",
"tag",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"}"
] | test if object contains nested elements | [
"test",
"if",
"object",
"contains",
"nested",
"elements"
] | 83d699b126c5c7099ffea1f86ccacf5ec50ee6a9 | https://github.com/tniedbala/jxh/blob/83d699b126c5c7099ffea1f86ccacf5ec50ee6a9/lib/renderUtility.js#L83-L91 |
57,760 | tniedbala/jxh | lib/renderUtility.js | getAttributes | function getAttributes(obj) {
let attrString = '';
let attrArray = Object.keys(obj);
for (let tag of attrArray) {
if (tag != ATTR && ATTRTAG.test(tag)) {
attrString += ` ${tag.replace('_', '')}="${obj[tag]}"`;
}
}
if (ATTR in obj) {
attrString += ' ' + obj[ATTR];
}
return attrString;
} | javascript | function getAttributes(obj) {
let attrString = '';
let attrArray = Object.keys(obj);
for (let tag of attrArray) {
if (tag != ATTR && ATTRTAG.test(tag)) {
attrString += ` ${tag.replace('_', '')}="${obj[tag]}"`;
}
}
if (ATTR in obj) {
attrString += ' ' + obj[ATTR];
}
return attrString;
} | [
"function",
"getAttributes",
"(",
"obj",
")",
"{",
"let",
"attrString",
"=",
"''",
";",
"let",
"attrArray",
"=",
"Object",
".",
"keys",
"(",
"obj",
")",
";",
"for",
"(",
"let",
"tag",
"of",
"attrArray",
")",
"{",
"if",
"(",
"tag",
"!=",
"ATTR",
"&&",
"ATTRTAG",
".",
"test",
"(",
"tag",
")",
")",
"{",
"attrString",
"+=",
"`",
"${",
"tag",
".",
"replace",
"(",
"'_'",
",",
"''",
")",
"}",
"${",
"obj",
"[",
"tag",
"]",
"}",
"`",
";",
"}",
"}",
"if",
"(",
"ATTR",
"in",
"obj",
")",
"{",
"attrString",
"+=",
"' '",
"+",
"obj",
"[",
"ATTR",
"]",
";",
"}",
"return",
"attrString",
";",
"}"
] | return attribute string | [
"return",
"attribute",
"string"
] | 83d699b126c5c7099ffea1f86ccacf5ec50ee6a9 | https://github.com/tniedbala/jxh/blob/83d699b126c5c7099ffea1f86ccacf5ec50ee6a9/lib/renderUtility.js#L93-L105 |
57,761 | tniedbala/jxh | lib/renderUtility.js | getType | function getType(obj) {
let typeStr = typeof(obj);
if (obj) {
return Array.isArray(obj) ? 'array' : typeStr;
} else {
switch (typeStr) {
case 'number':
return obj === 0 ? 'number' : 'NaN';
case 'object':
return 'null';
default:
return typeStr;
}
}
} | javascript | function getType(obj) {
let typeStr = typeof(obj);
if (obj) {
return Array.isArray(obj) ? 'array' : typeStr;
} else {
switch (typeStr) {
case 'number':
return obj === 0 ? 'number' : 'NaN';
case 'object':
return 'null';
default:
return typeStr;
}
}
} | [
"function",
"getType",
"(",
"obj",
")",
"{",
"let",
"typeStr",
"=",
"typeof",
"(",
"obj",
")",
";",
"if",
"(",
"obj",
")",
"{",
"return",
"Array",
".",
"isArray",
"(",
"obj",
")",
"?",
"'array'",
":",
"typeStr",
";",
"}",
"else",
"{",
"switch",
"(",
"typeStr",
")",
"{",
"case",
"'number'",
":",
"return",
"obj",
"===",
"0",
"?",
"'number'",
":",
"'NaN'",
";",
"case",
"'object'",
":",
"return",
"'null'",
";",
"default",
":",
"return",
"typeStr",
";",
"}",
"}",
"}"
] | returns type of obj, specifying array, NaN & null values | [
"returns",
"type",
"of",
"obj",
"specifying",
"array",
"NaN",
"&",
"null",
"values"
] | 83d699b126c5c7099ffea1f86ccacf5ec50ee6a9 | https://github.com/tniedbala/jxh/blob/83d699b126c5c7099ffea1f86ccacf5ec50ee6a9/lib/renderUtility.js#L115-L129 |
57,762 | henrytao-me/grunt-express-middleware | lib/util.js | injectWatcher | function injectWatcher(handler) {
return function(module, filename) {
fs.watchFile(filename, watcher);
handler(module, filename);
};
} | javascript | function injectWatcher(handler) {
return function(module, filename) {
fs.watchFile(filename, watcher);
handler(module, filename);
};
} | [
"function",
"injectWatcher",
"(",
"handler",
")",
"{",
"return",
"function",
"(",
"module",
",",
"filename",
")",
"{",
"fs",
".",
"watchFile",
"(",
"filename",
",",
"watcher",
")",
";",
"handler",
"(",
"module",
",",
"filename",
")",
";",
"}",
";",
"}"
] | hijack each module extension handler, and watch the file | [
"hijack",
"each",
"module",
"extension",
"handler",
"and",
"watch",
"the",
"file"
] | 26a902c60a4569dc65bf544ad91bd63d30f58c04 | https://github.com/henrytao-me/grunt-express-middleware/blob/26a902c60a4569dc65bf544ad91bd63d30f58c04/lib/util.js#L26-L31 |
57,763 | skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/scriptloader.js | loadNext | function loadNext() {
var script;
if ( ( script = pending[ 0 ] ) )
this.load( script.scriptUrl, script.callback, CKEDITOR, 0 );
} | javascript | function loadNext() {
var script;
if ( ( script = pending[ 0 ] ) )
this.load( script.scriptUrl, script.callback, CKEDITOR, 0 );
} | [
"function",
"loadNext",
"(",
")",
"{",
"var",
"script",
";",
"if",
"(",
"(",
"script",
"=",
"pending",
"[",
"0",
"]",
")",
")",
"this",
".",
"load",
"(",
"script",
".",
"scriptUrl",
",",
"script",
".",
"callback",
",",
"CKEDITOR",
",",
"0",
")",
";",
"}"
] | Loads the very first script from queue and removes it. | [
"Loads",
"the",
"very",
"first",
"script",
"from",
"queue",
"and",
"removes",
"it",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/scriptloader.js#L173-L178 |
57,764 | skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/scriptloader.js | callbackWrapper | function callbackWrapper() {
callback && callback.apply( this, arguments );
// Removed the just loaded script from the queue.
pending.shift();
loadNext.call( that );
} | javascript | function callbackWrapper() {
callback && callback.apply( this, arguments );
// Removed the just loaded script from the queue.
pending.shift();
loadNext.call( that );
} | [
"function",
"callbackWrapper",
"(",
")",
"{",
"callback",
"&&",
"callback",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"// Removed the just loaded script from the queue.",
"pending",
".",
"shift",
"(",
")",
";",
"loadNext",
".",
"call",
"(",
"that",
")",
";",
"}"
] | This callback calls the standard callback for the script and loads the very next script from pending list. | [
"This",
"callback",
"calls",
"the",
"standard",
"callback",
"for",
"the",
"script",
"and",
"loads",
"the",
"very",
"next",
"script",
"from",
"pending",
"list",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/scriptloader.js#L185-L192 |
57,765 | darrencruse/sugarlisp-core | lexer.js | Lexer | function Lexer(sourcetext, filename, options) {
options = options || {};
this.options = options || {};
this.dialects = []; // the "stack" dialects are pushed/popped from
if(filename) {
this.filename = filename;
this.fileext = utils.getFileExt(filename, "sugar");
}
this.set_source_text(sourcetext);
} | javascript | function Lexer(sourcetext, filename, options) {
options = options || {};
this.options = options || {};
this.dialects = []; // the "stack" dialects are pushed/popped from
if(filename) {
this.filename = filename;
this.fileext = utils.getFileExt(filename, "sugar");
}
this.set_source_text(sourcetext);
} | [
"function",
"Lexer",
"(",
"sourcetext",
",",
"filename",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"this",
".",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"this",
".",
"dialects",
"=",
"[",
"]",
";",
"// the \"stack\" dialects are pushed/popped from",
"if",
"(",
"filename",
")",
"{",
"this",
".",
"filename",
"=",
"filename",
";",
"this",
".",
"fileext",
"=",
"utils",
".",
"getFileExt",
"(",
"filename",
",",
"\"sugar\"",
")",
";",
"}",
"this",
".",
"set_source_text",
"(",
"sourcetext",
")",
";",
"}"
] | A Lexer for the source text we are scanning
note: Lexer has been done as a javacript prototypal
class with instances that hold all state for a
given source file as it's being read and transpiled.
This is in contrast to the other sugarlisp modules
which are pretty much stateless collections of
functions. The main exception to this is the
"transpiler-context" which is the non-source-file
related state of the transpiler (essentially a
"singleton"). | [
"A",
"Lexer",
"for",
"the",
"source",
"text",
"we",
"are",
"scanning"
] | c6ff983ebc3d60268054d6fe046db4aff6c5f78c | https://github.com/darrencruse/sugarlisp-core/blob/c6ff983ebc3d60268054d6fe046db4aff6c5f78c/lexer.js#L33-L42 |
57,766 | darrencruse/sugarlisp-core | lexer.js | regexes_for_category | function regexes_for_category(lexer, category) {
var REs = [];
var done = false;
for(var i = 0; !done && i < lexer.dialects.length; i++) {
var dialect = lexer.dialects[i];
if(dialect.lextab) {
var categoryentry = dialect.lextab.find(function(lextabentry) {
return lextabentry.category == category;
});
if(categoryentry) {
REs.push(categoryentry.match);
// if they've set entry.replace=true this dialect's
// entry replaces other dialects' entries:
done = categoryentry.replace;
}
}
}
return REs;
} | javascript | function regexes_for_category(lexer, category) {
var REs = [];
var done = false;
for(var i = 0; !done && i < lexer.dialects.length; i++) {
var dialect = lexer.dialects[i];
if(dialect.lextab) {
var categoryentry = dialect.lextab.find(function(lextabentry) {
return lextabentry.category == category;
});
if(categoryentry) {
REs.push(categoryentry.match);
// if they've set entry.replace=true this dialect's
// entry replaces other dialects' entries:
done = categoryentry.replace;
}
}
}
return REs;
} | [
"function",
"regexes_for_category",
"(",
"lexer",
",",
"category",
")",
"{",
"var",
"REs",
"=",
"[",
"]",
";",
"var",
"done",
"=",
"false",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"!",
"done",
"&&",
"i",
"<",
"lexer",
".",
"dialects",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"dialect",
"=",
"lexer",
".",
"dialects",
"[",
"i",
"]",
";",
"if",
"(",
"dialect",
".",
"lextab",
")",
"{",
"var",
"categoryentry",
"=",
"dialect",
".",
"lextab",
".",
"find",
"(",
"function",
"(",
"lextabentry",
")",
"{",
"return",
"lextabentry",
".",
"category",
"==",
"category",
";",
"}",
")",
";",
"if",
"(",
"categoryentry",
")",
"{",
"REs",
".",
"push",
"(",
"categoryentry",
".",
"match",
")",
";",
"// if they've set entry.replace=true this dialect's",
"// entry replaces other dialects' entries:",
"done",
"=",
"categoryentry",
".",
"replace",
";",
"}",
"}",
"}",
"return",
"REs",
";",
"}"
] | utility function accumulates all the regular expressions
for a given token category and returns them in an array | [
"utility",
"function",
"accumulates",
"all",
"the",
"regular",
"expressions",
"for",
"a",
"given",
"token",
"category",
"and",
"returns",
"them",
"in",
"an",
"array"
] | c6ff983ebc3d60268054d6fe046db4aff6c5f78c | https://github.com/darrencruse/sugarlisp-core/blob/c6ff983ebc3d60268054d6fe046db4aff6c5f78c/lexer.js#L585-L604 |
57,767 | darrencruse/sugarlisp-core | lexer.js | oncharincategory | function oncharincategory(lexer, lookahead, categoryREs) {
var c = lexer.peek_char(lookahead);
return categoryREs.find(function(re) {
// because we're matching a single char...
re.lastIndex = 0; // make sure we start from the start
return re.test(c);
});
} | javascript | function oncharincategory(lexer, lookahead, categoryREs) {
var c = lexer.peek_char(lookahead);
return categoryREs.find(function(re) {
// because we're matching a single char...
re.lastIndex = 0; // make sure we start from the start
return re.test(c);
});
} | [
"function",
"oncharincategory",
"(",
"lexer",
",",
"lookahead",
",",
"categoryREs",
")",
"{",
"var",
"c",
"=",
"lexer",
".",
"peek_char",
"(",
"lookahead",
")",
";",
"return",
"categoryREs",
".",
"find",
"(",
"function",
"(",
"re",
")",
"{",
"// because we're matching a single char...",
"re",
".",
"lastIndex",
"=",
"0",
";",
"// make sure we start from the start",
"return",
"re",
".",
"test",
"(",
"c",
")",
";",
"}",
")",
";",
"}"
] | is the source sitting on a char matching a specified token category? | [
"is",
"the",
"source",
"sitting",
"on",
"a",
"char",
"matching",
"a",
"specified",
"token",
"category?"
] | c6ff983ebc3d60268054d6fe046db4aff6c5f78c | https://github.com/darrencruse/sugarlisp-core/blob/c6ff983ebc3d60268054d6fe046db4aff6c5f78c/lexer.js#L609-L616 |
57,768 | darrencruse/sugarlisp-core | lexer.js | next_lextab_token | function next_lextab_token(lexer) {
var token;
if(lexer.eos()) {
return undefined;
}
// skip leading whitespace or comments...
lexer.skip_filler();
var previouslyPeeked = lexer.getPeekedToken();
if(previouslyPeeked) {
return previouslyPeeked;
}
lexer.mark_token_start();
trace(lexer.message_src_loc("", lexer, {file:false}));
// try and match all token categories except punctuation (and
// the default handler). Note that single character punctuation
// should take a back seat to longer symbols e.g. '...' should
// match before '.'.
token = match_in_lextabs(lexer, {omit: ['punctuation','default']});
if(!token) {
// okay now try again matching punctuation characters.
token = match_in_lextabs(lexer, {include: ['punctuation']});
}
if(!token) {
// ok go ahead and try any default handler(s)
token = match_in_lextabs(lexer, {include: ['default']});
}
// we expect they will use an explicit default lextab entry, but JIC:
if(!token) {
trace('their lextab has no default handler - defaulting to next word');
token = lexer.next_word_token();
if(token) {
token.category = 'symbol';
}
}
return token;
} | javascript | function next_lextab_token(lexer) {
var token;
if(lexer.eos()) {
return undefined;
}
// skip leading whitespace or comments...
lexer.skip_filler();
var previouslyPeeked = lexer.getPeekedToken();
if(previouslyPeeked) {
return previouslyPeeked;
}
lexer.mark_token_start();
trace(lexer.message_src_loc("", lexer, {file:false}));
// try and match all token categories except punctuation (and
// the default handler). Note that single character punctuation
// should take a back seat to longer symbols e.g. '...' should
// match before '.'.
token = match_in_lextabs(lexer, {omit: ['punctuation','default']});
if(!token) {
// okay now try again matching punctuation characters.
token = match_in_lextabs(lexer, {include: ['punctuation']});
}
if(!token) {
// ok go ahead and try any default handler(s)
token = match_in_lextabs(lexer, {include: ['default']});
}
// we expect they will use an explicit default lextab entry, but JIC:
if(!token) {
trace('their lextab has no default handler - defaulting to next word');
token = lexer.next_word_token();
if(token) {
token.category = 'symbol';
}
}
return token;
} | [
"function",
"next_lextab_token",
"(",
"lexer",
")",
"{",
"var",
"token",
";",
"if",
"(",
"lexer",
".",
"eos",
"(",
")",
")",
"{",
"return",
"undefined",
";",
"}",
"// skip leading whitespace or comments...",
"lexer",
".",
"skip_filler",
"(",
")",
";",
"var",
"previouslyPeeked",
"=",
"lexer",
".",
"getPeekedToken",
"(",
")",
";",
"if",
"(",
"previouslyPeeked",
")",
"{",
"return",
"previouslyPeeked",
";",
"}",
"lexer",
".",
"mark_token_start",
"(",
")",
";",
"trace",
"(",
"lexer",
".",
"message_src_loc",
"(",
"\"\"",
",",
"lexer",
",",
"{",
"file",
":",
"false",
"}",
")",
")",
";",
"// try and match all token categories except punctuation (and",
"// the default handler). Note that single character punctuation",
"// should take a back seat to longer symbols e.g. '...' should",
"// match before '.'.",
"token",
"=",
"match_in_lextabs",
"(",
"lexer",
",",
"{",
"omit",
":",
"[",
"'punctuation'",
",",
"'default'",
"]",
"}",
")",
";",
"if",
"(",
"!",
"token",
")",
"{",
"// okay now try again matching punctuation characters.",
"token",
"=",
"match_in_lextabs",
"(",
"lexer",
",",
"{",
"include",
":",
"[",
"'punctuation'",
"]",
"}",
")",
";",
"}",
"if",
"(",
"!",
"token",
")",
"{",
"// ok go ahead and try any default handler(s)",
"token",
"=",
"match_in_lextabs",
"(",
"lexer",
",",
"{",
"include",
":",
"[",
"'default'",
"]",
"}",
")",
";",
"}",
"// we expect they will use an explicit default lextab entry, but JIC:",
"if",
"(",
"!",
"token",
")",
"{",
"trace",
"(",
"'their lextab has no default handler - defaulting to next word'",
")",
";",
"token",
"=",
"lexer",
".",
"next_word_token",
"(",
")",
";",
"if",
"(",
"token",
")",
"{",
"token",
".",
"category",
"=",
"'symbol'",
";",
"}",
"}",
"return",
"token",
";",
"}"
] | Get the next token under the current source position according
to the lextab entries of the current dialects. | [
"Get",
"the",
"next",
"token",
"under",
"the",
"current",
"source",
"position",
"according",
"to",
"the",
"lextab",
"entries",
"of",
"the",
"current",
"dialects",
"."
] | c6ff983ebc3d60268054d6fe046db4aff6c5f78c | https://github.com/darrencruse/sugarlisp-core/blob/c6ff983ebc3d60268054d6fe046db4aff6c5f78c/lexer.js#L830-L873 |
57,769 | darrencruse/sugarlisp-core | lexer.js | match_in_lextabs | function match_in_lextabs(lexer, options) {
options = options || {};
var token;
var replaced = {};
// for each dialect's lextab...
for(var d = 0; !token && d < lexer.dialects.length; d++) {
var dialect = lexer.dialects[d];
if(!dialect.lextab) {
continue; // no lextab for the dialect so move on
}
// check each entry in order...
// NOTE I AM IGNORING THE 'PRIORITY' PROPERTY RIGHT NOW - MAYBE I CAN DELETE THEM!?
debug('matching in ' + dialect.name + ' lextable');
for(var l = 0; !token && l < dialect.lextab.length; l++) {
var entry = dialect.lextab[l];
// we don't match tokens against "replaced" categories
if(!replaced[entry.category] &&
// and if they've specified categories to include...
(!options.include ||
// only consider those
(options.include.contains(entry.category) ||
(options.include.contains("default") && entry.default))) &&
// or if they've specified categories to omit...
(!options.omit ||
// make sure we skip over those
((!options.omit.contains(entry.category) &&
!(options.omit.contains("default") && entry.default)))))
{
// most functions "match" (with a regex)
// but they can also just "read" (with a function)
if(typeof entry.read !== 'function') {
// are we on a token matching this entry's pattern?
//trace('matching ' + entry.category + ' pattern');
var matchedText = lexer.on(entry.match);
if(matchedText) {
trace('matched ' + entry.category + ' pattern');
// advance the current position
lexer.next_char(matchedText.length);
// create and return the token object (including line/col info)
token = lexer.create_token(matchedText, entry.category);
}
}
else {
// note we use a "read" function for our default entry
// used when nothing else matches. Such entries can
// still set a token category, but they should set
// "default: true" (so we know to consider them last).
trace('invoking ' + entry.category + ' read function');
token = entry.read(lexer);
if(token) {
trace('read from ' + entry.category + ' read function');
token.category = entry.category;
}
}
}
if(entry.replace) {
// remember that this category has been replaced
replaced[entry.category] = true;
}
}
}
return token;
} | javascript | function match_in_lextabs(lexer, options) {
options = options || {};
var token;
var replaced = {};
// for each dialect's lextab...
for(var d = 0; !token && d < lexer.dialects.length; d++) {
var dialect = lexer.dialects[d];
if(!dialect.lextab) {
continue; // no lextab for the dialect so move on
}
// check each entry in order...
// NOTE I AM IGNORING THE 'PRIORITY' PROPERTY RIGHT NOW - MAYBE I CAN DELETE THEM!?
debug('matching in ' + dialect.name + ' lextable');
for(var l = 0; !token && l < dialect.lextab.length; l++) {
var entry = dialect.lextab[l];
// we don't match tokens against "replaced" categories
if(!replaced[entry.category] &&
// and if they've specified categories to include...
(!options.include ||
// only consider those
(options.include.contains(entry.category) ||
(options.include.contains("default") && entry.default))) &&
// or if they've specified categories to omit...
(!options.omit ||
// make sure we skip over those
((!options.omit.contains(entry.category) &&
!(options.omit.contains("default") && entry.default)))))
{
// most functions "match" (with a regex)
// but they can also just "read" (with a function)
if(typeof entry.read !== 'function') {
// are we on a token matching this entry's pattern?
//trace('matching ' + entry.category + ' pattern');
var matchedText = lexer.on(entry.match);
if(matchedText) {
trace('matched ' + entry.category + ' pattern');
// advance the current position
lexer.next_char(matchedText.length);
// create and return the token object (including line/col info)
token = lexer.create_token(matchedText, entry.category);
}
}
else {
// note we use a "read" function for our default entry
// used when nothing else matches. Such entries can
// still set a token category, but they should set
// "default: true" (so we know to consider them last).
trace('invoking ' + entry.category + ' read function');
token = entry.read(lexer);
if(token) {
trace('read from ' + entry.category + ' read function');
token.category = entry.category;
}
}
}
if(entry.replace) {
// remember that this category has been replaced
replaced[entry.category] = true;
}
}
}
return token;
} | [
"function",
"match_in_lextabs",
"(",
"lexer",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"var",
"token",
";",
"var",
"replaced",
"=",
"{",
"}",
";",
"// for each dialect's lextab...",
"for",
"(",
"var",
"d",
"=",
"0",
";",
"!",
"token",
"&&",
"d",
"<",
"lexer",
".",
"dialects",
".",
"length",
";",
"d",
"++",
")",
"{",
"var",
"dialect",
"=",
"lexer",
".",
"dialects",
"[",
"d",
"]",
";",
"if",
"(",
"!",
"dialect",
".",
"lextab",
")",
"{",
"continue",
";",
"// no lextab for the dialect so move on",
"}",
"// check each entry in order...",
"// NOTE I AM IGNORING THE 'PRIORITY' PROPERTY RIGHT NOW - MAYBE I CAN DELETE THEM!?",
"debug",
"(",
"'matching in '",
"+",
"dialect",
".",
"name",
"+",
"' lextable'",
")",
";",
"for",
"(",
"var",
"l",
"=",
"0",
";",
"!",
"token",
"&&",
"l",
"<",
"dialect",
".",
"lextab",
".",
"length",
";",
"l",
"++",
")",
"{",
"var",
"entry",
"=",
"dialect",
".",
"lextab",
"[",
"l",
"]",
";",
"// we don't match tokens against \"replaced\" categories",
"if",
"(",
"!",
"replaced",
"[",
"entry",
".",
"category",
"]",
"&&",
"// and if they've specified categories to include...",
"(",
"!",
"options",
".",
"include",
"||",
"// only consider those",
"(",
"options",
".",
"include",
".",
"contains",
"(",
"entry",
".",
"category",
")",
"||",
"(",
"options",
".",
"include",
".",
"contains",
"(",
"\"default\"",
")",
"&&",
"entry",
".",
"default",
")",
")",
")",
"&&",
"// or if they've specified categories to omit...",
"(",
"!",
"options",
".",
"omit",
"||",
"// make sure we skip over those",
"(",
"(",
"!",
"options",
".",
"omit",
".",
"contains",
"(",
"entry",
".",
"category",
")",
"&&",
"!",
"(",
"options",
".",
"omit",
".",
"contains",
"(",
"\"default\"",
")",
"&&",
"entry",
".",
"default",
")",
")",
")",
")",
")",
"{",
"// most functions \"match\" (with a regex)",
"// but they can also just \"read\" (with a function)",
"if",
"(",
"typeof",
"entry",
".",
"read",
"!==",
"'function'",
")",
"{",
"// are we on a token matching this entry's pattern?",
"//trace('matching ' + entry.category + ' pattern');",
"var",
"matchedText",
"=",
"lexer",
".",
"on",
"(",
"entry",
".",
"match",
")",
";",
"if",
"(",
"matchedText",
")",
"{",
"trace",
"(",
"'matched '",
"+",
"entry",
".",
"category",
"+",
"' pattern'",
")",
";",
"// advance the current position",
"lexer",
".",
"next_char",
"(",
"matchedText",
".",
"length",
")",
";",
"// create and return the token object (including line/col info)",
"token",
"=",
"lexer",
".",
"create_token",
"(",
"matchedText",
",",
"entry",
".",
"category",
")",
";",
"}",
"}",
"else",
"{",
"// note we use a \"read\" function for our default entry",
"// used when nothing else matches. Such entries can",
"// still set a token category, but they should set",
"// \"default: true\" (so we know to consider them last).",
"trace",
"(",
"'invoking '",
"+",
"entry",
".",
"category",
"+",
"' read function'",
")",
";",
"token",
"=",
"entry",
".",
"read",
"(",
"lexer",
")",
";",
"if",
"(",
"token",
")",
"{",
"trace",
"(",
"'read from '",
"+",
"entry",
".",
"category",
"+",
"' read function'",
")",
";",
"token",
".",
"category",
"=",
"entry",
".",
"category",
";",
"}",
"}",
"}",
"if",
"(",
"entry",
".",
"replace",
")",
"{",
"// remember that this category has been replaced",
"replaced",
"[",
"entry",
".",
"category",
"]",
"=",
"true",
";",
"}",
"}",
"}",
"return",
"token",
";",
"}"
] | Helper function returns a token for the source text
under the current position based on the nearest match
in the active dialect's lextabs.
You can optionally omit specified token categories from consideration
("options.omit"), or include only specified token categories for
consideration ("options.include").
You can also use the word "default" in options.omit/options.include
to refer to default lextab entries indicated with "default: true" | [
"Helper",
"function",
"returns",
"a",
"token",
"for",
"the",
"source",
"text",
"under",
"the",
"current",
"position",
"based",
"on",
"the",
"nearest",
"match",
"in",
"the",
"active",
"dialect",
"s",
"lextabs",
"."
] | c6ff983ebc3d60268054d6fe046db4aff6c5f78c | https://github.com/darrencruse/sugarlisp-core/blob/c6ff983ebc3d60268054d6fe046db4aff6c5f78c/lexer.js#L887-L954 |
57,770 | darrencruse/sugarlisp-core | lexer.js | formatTokenDump | function formatTokenDump(tokens, formatter, resultPrefix, resultSuffix) {
var tokensSexpStr = "";
var currentLine = -999;
tokens.forEach(function(token, index) {
// skip the wrapping () it's annoying in the dump
if(!((index === 0 && token.text === "(") ||
(index === tokens.length-1 && token.text === ")")))
{
// add a return if this starts a different line:
if(currentLine !== -999 && token.line !== currentLine) {
tokensSexpStr += '\n';
}
tokensSexpStr += formatter(token);
currentLine = token.line;
}
});
return (resultPrefix ? resultPrefix : "") +
tokensSexpStr +
(resultSuffix ? resultSuffix : "");
} | javascript | function formatTokenDump(tokens, formatter, resultPrefix, resultSuffix) {
var tokensSexpStr = "";
var currentLine = -999;
tokens.forEach(function(token, index) {
// skip the wrapping () it's annoying in the dump
if(!((index === 0 && token.text === "(") ||
(index === tokens.length-1 && token.text === ")")))
{
// add a return if this starts a different line:
if(currentLine !== -999 && token.line !== currentLine) {
tokensSexpStr += '\n';
}
tokensSexpStr += formatter(token);
currentLine = token.line;
}
});
return (resultPrefix ? resultPrefix : "") +
tokensSexpStr +
(resultSuffix ? resultSuffix : "");
} | [
"function",
"formatTokenDump",
"(",
"tokens",
",",
"formatter",
",",
"resultPrefix",
",",
"resultSuffix",
")",
"{",
"var",
"tokensSexpStr",
"=",
"\"\"",
";",
"var",
"currentLine",
"=",
"-",
"999",
";",
"tokens",
".",
"forEach",
"(",
"function",
"(",
"token",
",",
"index",
")",
"{",
"// skip the wrapping () it's annoying in the dump",
"if",
"(",
"!",
"(",
"(",
"index",
"===",
"0",
"&&",
"token",
".",
"text",
"===",
"\"(\"",
")",
"||",
"(",
"index",
"===",
"tokens",
".",
"length",
"-",
"1",
"&&",
"token",
".",
"text",
"===",
"\")\"",
")",
")",
")",
"{",
"// add a return if this starts a different line:",
"if",
"(",
"currentLine",
"!==",
"-",
"999",
"&&",
"token",
".",
"line",
"!==",
"currentLine",
")",
"{",
"tokensSexpStr",
"+=",
"'\\n'",
";",
"}",
"tokensSexpStr",
"+=",
"formatter",
"(",
"token",
")",
";",
"currentLine",
"=",
"token",
".",
"line",
";",
"}",
"}",
")",
";",
"return",
"(",
"resultPrefix",
"?",
"resultPrefix",
":",
"\"\"",
")",
"+",
"tokensSexpStr",
"+",
"(",
"resultSuffix",
"?",
"resultSuffix",
":",
"\"\"",
")",
";",
"}"
] | format the token dump into a string
note: we put all the tokens from a line on a line to make this easier
to match up with the original source when debugging problems.
@tokens = an array of tokens
@formatter = a function which takes a token and returns a string.
@resultPrefix = optional string to prepend to the result
@resultSuffix = optional string to append to the result
@returns the formatted string. | [
"format",
"the",
"token",
"dump",
"into",
"a",
"string"
] | c6ff983ebc3d60268054d6fe046db4aff6c5f78c | https://github.com/darrencruse/sugarlisp-core/blob/c6ff983ebc3d60268054d6fe046db4aff6c5f78c/lexer.js#L1214-L1234 |
57,771 | faiton/benchmark | lib/suite.js | Suite | function Suite(name, fn){
if (! (this instanceof Suite))
return new Suite(name, fn);
return this.initialize(name, fn);
} | javascript | function Suite(name, fn){
if (! (this instanceof Suite))
return new Suite(name, fn);
return this.initialize(name, fn);
} | [
"function",
"Suite",
"(",
"name",
",",
"fn",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Suite",
")",
")",
"return",
"new",
"Suite",
"(",
"name",
",",
"fn",
")",
";",
"return",
"this",
".",
"initialize",
"(",
"name",
",",
"fn",
")",
";",
"}"
] | Suite constructor.
@constructor
@param {String} name
@param {Function} fn
@return {Suite}
@api public | [
"Suite",
"constructor",
"."
] | 678a10b69002c2b4a656527fbe457448ff402f40 | https://github.com/faiton/benchmark/blob/678a10b69002c2b4a656527fbe457448ff402f40/lib/suite.js#L33-L38 |
57,772 | ojj11/morphic | destructure.js | generateNamedFieldExtractors | function generateNamedFieldExtractors(input) {
var names = input.filter(function(matcher, index, array) {
// has a name?
return matcher.name;
});
// has duplicates?
names.forEach(function(matcher, index, array) {
var isDuplicate = array.slice(0, index).some(function(previousMatcher) {
return previousMatcher.name == matcher.name;
});
if (isDuplicate) {
throw new Error("duplicate named field '" + matcher.name + "'");
}
});
return names;
} | javascript | function generateNamedFieldExtractors(input) {
var names = input.filter(function(matcher, index, array) {
// has a name?
return matcher.name;
});
// has duplicates?
names.forEach(function(matcher, index, array) {
var isDuplicate = array.slice(0, index).some(function(previousMatcher) {
return previousMatcher.name == matcher.name;
});
if (isDuplicate) {
throw new Error("duplicate named field '" + matcher.name + "'");
}
});
return names;
} | [
"function",
"generateNamedFieldExtractors",
"(",
"input",
")",
"{",
"var",
"names",
"=",
"input",
".",
"filter",
"(",
"function",
"(",
"matcher",
",",
"index",
",",
"array",
")",
"{",
"// has a name?",
"return",
"matcher",
".",
"name",
";",
"}",
")",
";",
"// has duplicates?",
"names",
".",
"forEach",
"(",
"function",
"(",
"matcher",
",",
"index",
",",
"array",
")",
"{",
"var",
"isDuplicate",
"=",
"array",
".",
"slice",
"(",
"0",
",",
"index",
")",
".",
"some",
"(",
"function",
"(",
"previousMatcher",
")",
"{",
"return",
"previousMatcher",
".",
"name",
"==",
"matcher",
".",
"name",
";",
"}",
")",
";",
"if",
"(",
"isDuplicate",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"duplicate named field '\"",
"+",
"matcher",
".",
"name",
"+",
"\"'\"",
")",
";",
"}",
"}",
")",
";",
"return",
"names",
";",
"}"
] | this will flatten the input into a list of named field extractors, should be run over output of generateMatchers | [
"this",
"will",
"flatten",
"the",
"input",
"into",
"a",
"list",
"of",
"named",
"field",
"extractors",
"should",
"be",
"run",
"over",
"output",
"of",
"generateMatchers"
] | 1ec6fd2f299e50866b9165c2545c430519f522ef | https://github.com/ojj11/morphic/blob/1ec6fd2f299e50866b9165c2545c430519f522ef/destructure.js#L44-L59 |
57,773 | ojj11/morphic | destructure.js | extractNamedFields | function extractNamedFields(fields, input) {
var output = Object.create(null);
fields.forEach(function(field) {
var subObject = input;
for (var i = 0; i < field.path.length; i += 1) {
if (subObject == undefined) {
throw new Error("Unreachable: matched input will always have fields");
}
subObject = subObject[field.path[i]];
}
switch (field.typeShortcut) {
// type matcher:
case 1:
subObject = global[field.type](subObject);
break;
// literal matcher:
case 3:
subObject = field.object;
break;
}
output[field.name] = subObject;
});
return output;
} | javascript | function extractNamedFields(fields, input) {
var output = Object.create(null);
fields.forEach(function(field) {
var subObject = input;
for (var i = 0; i < field.path.length; i += 1) {
if (subObject == undefined) {
throw new Error("Unreachable: matched input will always have fields");
}
subObject = subObject[field.path[i]];
}
switch (field.typeShortcut) {
// type matcher:
case 1:
subObject = global[field.type](subObject);
break;
// literal matcher:
case 3:
subObject = field.object;
break;
}
output[field.name] = subObject;
});
return output;
} | [
"function",
"extractNamedFields",
"(",
"fields",
",",
"input",
")",
"{",
"var",
"output",
"=",
"Object",
".",
"create",
"(",
"null",
")",
";",
"fields",
".",
"forEach",
"(",
"function",
"(",
"field",
")",
"{",
"var",
"subObject",
"=",
"input",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"field",
".",
"path",
".",
"length",
";",
"i",
"+=",
"1",
")",
"{",
"if",
"(",
"subObject",
"==",
"undefined",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"Unreachable: matched input will always have fields\"",
")",
";",
"}",
"subObject",
"=",
"subObject",
"[",
"field",
".",
"path",
"[",
"i",
"]",
"]",
";",
"}",
"switch",
"(",
"field",
".",
"typeShortcut",
")",
"{",
"// type matcher:",
"case",
"1",
":",
"subObject",
"=",
"global",
"[",
"field",
".",
"type",
"]",
"(",
"subObject",
")",
";",
"break",
";",
"// literal matcher:",
"case",
"3",
":",
"subObject",
"=",
"field",
".",
"object",
";",
"break",
";",
"}",
"output",
"[",
"field",
".",
"name",
"]",
"=",
"subObject",
";",
"}",
")",
";",
"return",
"output",
";",
"}"
] | extract out the named fields from an input | [
"extract",
"out",
"the",
"named",
"fields",
"from",
"an",
"input"
] | 1ec6fd2f299e50866b9165c2545c430519f522ef | https://github.com/ojj11/morphic/blob/1ec6fd2f299e50866b9165c2545c430519f522ef/destructure.js#L62-L85 |
57,774 | nomocas/yamvish | lib/parsers/html-to-template.js | rawContent | function rawContent(tagName, string, templ, innerTemplate) {
var index = string.indexOf('</' + tagName + '>'),
raw;
if (index === -1)
throw new Error(tagName + ' tag badly closed.');
if (index) { // more than 0
raw = string.substring(0, index);
if (tagName === 'templ') // produce local api-like handler
{
innerTemplate.templFunc = new Function(raw);
} else
innerTemplate.raw(raw);
}
return string.substring(index + tagName.length + 3);
} | javascript | function rawContent(tagName, string, templ, innerTemplate) {
var index = string.indexOf('</' + tagName + '>'),
raw;
if (index === -1)
throw new Error(tagName + ' tag badly closed.');
if (index) { // more than 0
raw = string.substring(0, index);
if (tagName === 'templ') // produce local api-like handler
{
innerTemplate.templFunc = new Function(raw);
} else
innerTemplate.raw(raw);
}
return string.substring(index + tagName.length + 3);
} | [
"function",
"rawContent",
"(",
"tagName",
",",
"string",
",",
"templ",
",",
"innerTemplate",
")",
"{",
"var",
"index",
"=",
"string",
".",
"indexOf",
"(",
"'</'",
"+",
"tagName",
"+",
"'>'",
")",
",",
"raw",
";",
"if",
"(",
"index",
"===",
"-",
"1",
")",
"throw",
"new",
"Error",
"(",
"tagName",
"+",
"' tag badly closed.'",
")",
";",
"if",
"(",
"index",
")",
"{",
"// more than 0",
"raw",
"=",
"string",
".",
"substring",
"(",
"0",
",",
"index",
")",
";",
"if",
"(",
"tagName",
"===",
"'templ'",
")",
"// produce local api-like handler",
"{",
"innerTemplate",
".",
"templFunc",
"=",
"new",
"Function",
"(",
"raw",
")",
";",
"}",
"else",
"innerTemplate",
".",
"raw",
"(",
"raw",
")",
";",
"}",
"return",
"string",
".",
"substring",
"(",
"index",
"+",
"tagName",
".",
"length",
"+",
"3",
")",
";",
"}"
] | raw inner content of tag | [
"raw",
"inner",
"content",
"of",
"tag"
] | 017a536bb6bafddf1b31c0c7af6f723be58e9f0e | https://github.com/nomocas/yamvish/blob/017a536bb6bafddf1b31c0c7af6f723be58e9f0e/lib/parsers/html-to-template.js#L21-L35 |
57,775 | srouse/cssmodeler | example/dist/csssystem/styleguide/cmod_styleguide.js | function(markupList) {
("production" !== "development" ? invariant(
ExecutionEnvironment.canUseDOM,
'dangerouslyRenderMarkup(...): Cannot render markup in a worker ' +
'thread. Make sure `window` and `document` are available globally ' +
'before requiring React when unit testing or use ' +
'React.renderToString for server rendering.'
) : invariant(ExecutionEnvironment.canUseDOM));
var nodeName;
var markupByNodeName = {};
// Group markup by `nodeName` if a wrap is necessary, else by '*'.
for (var i = 0; i < markupList.length; i++) {
("production" !== "development" ? invariant(
markupList[i],
'dangerouslyRenderMarkup(...): Missing markup.'
) : invariant(markupList[i]));
nodeName = getNodeName(markupList[i]);
nodeName = getMarkupWrap(nodeName) ? nodeName : '*';
markupByNodeName[nodeName] = markupByNodeName[nodeName] || [];
markupByNodeName[nodeName][i] = markupList[i];
}
var resultList = [];
var resultListAssignmentCount = 0;
for (nodeName in markupByNodeName) {
if (!markupByNodeName.hasOwnProperty(nodeName)) {
continue;
}
var markupListByNodeName = markupByNodeName[nodeName];
// This for-in loop skips the holes of the sparse array. The order of
// iteration should follow the order of assignment, which happens to match
// numerical index order, but we don't rely on that.
var resultIndex;
for (resultIndex in markupListByNodeName) {
if (markupListByNodeName.hasOwnProperty(resultIndex)) {
var markup = markupListByNodeName[resultIndex];
// Push the requested markup with an additional RESULT_INDEX_ATTR
// attribute. If the markup does not start with a < character, it
// will be discarded below (with an appropriate console.error).
markupListByNodeName[resultIndex] = markup.replace(
OPEN_TAG_NAME_EXP,
// This index will be parsed back out below.
'$1 ' + RESULT_INDEX_ATTR + '="' + resultIndex + '" '
);
}
}
// Render each group of markup with similar wrapping `nodeName`.
var renderNodes = createNodesFromMarkup(
markupListByNodeName.join(''),
emptyFunction // Do nothing special with <script> tags.
);
for (var j = 0; j < renderNodes.length; ++j) {
var renderNode = renderNodes[j];
if (renderNode.hasAttribute &&
renderNode.hasAttribute(RESULT_INDEX_ATTR)) {
resultIndex = +renderNode.getAttribute(RESULT_INDEX_ATTR);
renderNode.removeAttribute(RESULT_INDEX_ATTR);
("production" !== "development" ? invariant(
!resultList.hasOwnProperty(resultIndex),
'Danger: Assigning to an already-occupied result index.'
) : invariant(!resultList.hasOwnProperty(resultIndex)));
resultList[resultIndex] = renderNode;
// This should match resultList.length and markupList.length when
// we're done.
resultListAssignmentCount += 1;
} else if ("production" !== "development") {
console.error(
'Danger: Discarding unexpected node:',
renderNode
);
}
}
}
// Although resultList was populated out of order, it should now be a dense
// array.
("production" !== "development" ? invariant(
resultListAssignmentCount === resultList.length,
'Danger: Did not assign to every index of resultList.'
) : invariant(resultListAssignmentCount === resultList.length));
("production" !== "development" ? invariant(
resultList.length === markupList.length,
'Danger: Expected markup to render %s nodes, but rendered %s.',
markupList.length,
resultList.length
) : invariant(resultList.length === markupList.length));
return resultList;
} | javascript | function(markupList) {
("production" !== "development" ? invariant(
ExecutionEnvironment.canUseDOM,
'dangerouslyRenderMarkup(...): Cannot render markup in a worker ' +
'thread. Make sure `window` and `document` are available globally ' +
'before requiring React when unit testing or use ' +
'React.renderToString for server rendering.'
) : invariant(ExecutionEnvironment.canUseDOM));
var nodeName;
var markupByNodeName = {};
// Group markup by `nodeName` if a wrap is necessary, else by '*'.
for (var i = 0; i < markupList.length; i++) {
("production" !== "development" ? invariant(
markupList[i],
'dangerouslyRenderMarkup(...): Missing markup.'
) : invariant(markupList[i]));
nodeName = getNodeName(markupList[i]);
nodeName = getMarkupWrap(nodeName) ? nodeName : '*';
markupByNodeName[nodeName] = markupByNodeName[nodeName] || [];
markupByNodeName[nodeName][i] = markupList[i];
}
var resultList = [];
var resultListAssignmentCount = 0;
for (nodeName in markupByNodeName) {
if (!markupByNodeName.hasOwnProperty(nodeName)) {
continue;
}
var markupListByNodeName = markupByNodeName[nodeName];
// This for-in loop skips the holes of the sparse array. The order of
// iteration should follow the order of assignment, which happens to match
// numerical index order, but we don't rely on that.
var resultIndex;
for (resultIndex in markupListByNodeName) {
if (markupListByNodeName.hasOwnProperty(resultIndex)) {
var markup = markupListByNodeName[resultIndex];
// Push the requested markup with an additional RESULT_INDEX_ATTR
// attribute. If the markup does not start with a < character, it
// will be discarded below (with an appropriate console.error).
markupListByNodeName[resultIndex] = markup.replace(
OPEN_TAG_NAME_EXP,
// This index will be parsed back out below.
'$1 ' + RESULT_INDEX_ATTR + '="' + resultIndex + '" '
);
}
}
// Render each group of markup with similar wrapping `nodeName`.
var renderNodes = createNodesFromMarkup(
markupListByNodeName.join(''),
emptyFunction // Do nothing special with <script> tags.
);
for (var j = 0; j < renderNodes.length; ++j) {
var renderNode = renderNodes[j];
if (renderNode.hasAttribute &&
renderNode.hasAttribute(RESULT_INDEX_ATTR)) {
resultIndex = +renderNode.getAttribute(RESULT_INDEX_ATTR);
renderNode.removeAttribute(RESULT_INDEX_ATTR);
("production" !== "development" ? invariant(
!resultList.hasOwnProperty(resultIndex),
'Danger: Assigning to an already-occupied result index.'
) : invariant(!resultList.hasOwnProperty(resultIndex)));
resultList[resultIndex] = renderNode;
// This should match resultList.length and markupList.length when
// we're done.
resultListAssignmentCount += 1;
} else if ("production" !== "development") {
console.error(
'Danger: Discarding unexpected node:',
renderNode
);
}
}
}
// Although resultList was populated out of order, it should now be a dense
// array.
("production" !== "development" ? invariant(
resultListAssignmentCount === resultList.length,
'Danger: Did not assign to every index of resultList.'
) : invariant(resultListAssignmentCount === resultList.length));
("production" !== "development" ? invariant(
resultList.length === markupList.length,
'Danger: Expected markup to render %s nodes, but rendered %s.',
markupList.length,
resultList.length
) : invariant(resultList.length === markupList.length));
return resultList;
} | [
"function",
"(",
"markupList",
")",
"{",
"(",
"\"production\"",
"!==",
"\"development\"",
"?",
"invariant",
"(",
"ExecutionEnvironment",
".",
"canUseDOM",
",",
"'dangerouslyRenderMarkup(...): Cannot render markup in a worker '",
"+",
"'thread. Make sure `window` and `document` are available globally '",
"+",
"'before requiring React when unit testing or use '",
"+",
"'React.renderToString for server rendering.'",
")",
":",
"invariant",
"(",
"ExecutionEnvironment",
".",
"canUseDOM",
")",
")",
";",
"var",
"nodeName",
";",
"var",
"markupByNodeName",
"=",
"{",
"}",
";",
"// Group markup by `nodeName` if a wrap is necessary, else by '*'.",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"markupList",
".",
"length",
";",
"i",
"++",
")",
"{",
"(",
"\"production\"",
"!==",
"\"development\"",
"?",
"invariant",
"(",
"markupList",
"[",
"i",
"]",
",",
"'dangerouslyRenderMarkup(...): Missing markup.'",
")",
":",
"invariant",
"(",
"markupList",
"[",
"i",
"]",
")",
")",
";",
"nodeName",
"=",
"getNodeName",
"(",
"markupList",
"[",
"i",
"]",
")",
";",
"nodeName",
"=",
"getMarkupWrap",
"(",
"nodeName",
")",
"?",
"nodeName",
":",
"'*'",
";",
"markupByNodeName",
"[",
"nodeName",
"]",
"=",
"markupByNodeName",
"[",
"nodeName",
"]",
"||",
"[",
"]",
";",
"markupByNodeName",
"[",
"nodeName",
"]",
"[",
"i",
"]",
"=",
"markupList",
"[",
"i",
"]",
";",
"}",
"var",
"resultList",
"=",
"[",
"]",
";",
"var",
"resultListAssignmentCount",
"=",
"0",
";",
"for",
"(",
"nodeName",
"in",
"markupByNodeName",
")",
"{",
"if",
"(",
"!",
"markupByNodeName",
".",
"hasOwnProperty",
"(",
"nodeName",
")",
")",
"{",
"continue",
";",
"}",
"var",
"markupListByNodeName",
"=",
"markupByNodeName",
"[",
"nodeName",
"]",
";",
"// This for-in loop skips the holes of the sparse array. The order of",
"// iteration should follow the order of assignment, which happens to match",
"// numerical index order, but we don't rely on that.",
"var",
"resultIndex",
";",
"for",
"(",
"resultIndex",
"in",
"markupListByNodeName",
")",
"{",
"if",
"(",
"markupListByNodeName",
".",
"hasOwnProperty",
"(",
"resultIndex",
")",
")",
"{",
"var",
"markup",
"=",
"markupListByNodeName",
"[",
"resultIndex",
"]",
";",
"// Push the requested markup with an additional RESULT_INDEX_ATTR",
"// attribute. If the markup does not start with a < character, it",
"// will be discarded below (with an appropriate console.error).",
"markupListByNodeName",
"[",
"resultIndex",
"]",
"=",
"markup",
".",
"replace",
"(",
"OPEN_TAG_NAME_EXP",
",",
"// This index will be parsed back out below.",
"'$1 '",
"+",
"RESULT_INDEX_ATTR",
"+",
"'=\"'",
"+",
"resultIndex",
"+",
"'\" '",
")",
";",
"}",
"}",
"// Render each group of markup with similar wrapping `nodeName`.",
"var",
"renderNodes",
"=",
"createNodesFromMarkup",
"(",
"markupListByNodeName",
".",
"join",
"(",
"''",
")",
",",
"emptyFunction",
"// Do nothing special with <script> tags.",
")",
";",
"for",
"(",
"var",
"j",
"=",
"0",
";",
"j",
"<",
"renderNodes",
".",
"length",
";",
"++",
"j",
")",
"{",
"var",
"renderNode",
"=",
"renderNodes",
"[",
"j",
"]",
";",
"if",
"(",
"renderNode",
".",
"hasAttribute",
"&&",
"renderNode",
".",
"hasAttribute",
"(",
"RESULT_INDEX_ATTR",
")",
")",
"{",
"resultIndex",
"=",
"+",
"renderNode",
".",
"getAttribute",
"(",
"RESULT_INDEX_ATTR",
")",
";",
"renderNode",
".",
"removeAttribute",
"(",
"RESULT_INDEX_ATTR",
")",
";",
"(",
"\"production\"",
"!==",
"\"development\"",
"?",
"invariant",
"(",
"!",
"resultList",
".",
"hasOwnProperty",
"(",
"resultIndex",
")",
",",
"'Danger: Assigning to an already-occupied result index.'",
")",
":",
"invariant",
"(",
"!",
"resultList",
".",
"hasOwnProperty",
"(",
"resultIndex",
")",
")",
")",
";",
"resultList",
"[",
"resultIndex",
"]",
"=",
"renderNode",
";",
"// This should match resultList.length and markupList.length when",
"// we're done.",
"resultListAssignmentCount",
"+=",
"1",
";",
"}",
"else",
"if",
"(",
"\"production\"",
"!==",
"\"development\"",
")",
"{",
"console",
".",
"error",
"(",
"'Danger: Discarding unexpected node:'",
",",
"renderNode",
")",
";",
"}",
"}",
"}",
"// Although resultList was populated out of order, it should now be a dense",
"// array.",
"(",
"\"production\"",
"!==",
"\"development\"",
"?",
"invariant",
"(",
"resultListAssignmentCount",
"===",
"resultList",
".",
"length",
",",
"'Danger: Did not assign to every index of resultList.'",
")",
":",
"invariant",
"(",
"resultListAssignmentCount",
"===",
"resultList",
".",
"length",
")",
")",
";",
"(",
"\"production\"",
"!==",
"\"development\"",
"?",
"invariant",
"(",
"resultList",
".",
"length",
"===",
"markupList",
".",
"length",
",",
"'Danger: Expected markup to render %s nodes, but rendered %s.'",
",",
"markupList",
".",
"length",
",",
"resultList",
".",
"length",
")",
":",
"invariant",
"(",
"resultList",
".",
"length",
"===",
"markupList",
".",
"length",
")",
")",
";",
"return",
"resultList",
";",
"}"
] | Renders markup into an array of nodes. The markup is expected to render
into a list of root nodes. Also, the length of `resultList` and
`markupList` should be the same.
@param {array<string>} markupList List of markup strings to render.
@return {array<DOMElement>} List of rendered nodes.
@internal | [
"Renders",
"markup",
"into",
"an",
"array",
"of",
"nodes",
".",
"The",
"markup",
"is",
"expected",
"to",
"render",
"into",
"a",
"list",
"of",
"root",
"nodes",
".",
"Also",
"the",
"length",
"of",
"resultList",
"and",
"markupList",
"should",
"be",
"the",
"same",
"."
] | 8682a44736d21877a3237b222587acc2b43924c9 | https://github.com/srouse/cssmodeler/blob/8682a44736d21877a3237b222587acc2b43924c9/example/dist/csssystem/styleguide/cmod_styleguide.js#L2168-L2265 |
|
57,776 | srouse/cssmodeler | example/dist/csssystem/styleguide/cmod_styleguide.js | recomputePluginOrdering | function recomputePluginOrdering() {
if (!EventPluginOrder) {
// Wait until an `EventPluginOrder` is injected.
return;
}
for (var pluginName in namesToPlugins) {
var PluginModule = namesToPlugins[pluginName];
var pluginIndex = EventPluginOrder.indexOf(pluginName);
("production" !== "development" ? invariant(
pluginIndex > -1,
'EventPluginRegistry: Cannot inject event plugins that do not exist in ' +
'the plugin ordering, `%s`.',
pluginName
) : invariant(pluginIndex > -1));
if (EventPluginRegistry.plugins[pluginIndex]) {
continue;
}
("production" !== "development" ? invariant(
PluginModule.extractEvents,
'EventPluginRegistry: Event plugins must implement an `extractEvents` ' +
'method, but `%s` does not.',
pluginName
) : invariant(PluginModule.extractEvents));
EventPluginRegistry.plugins[pluginIndex] = PluginModule;
var publishedEvents = PluginModule.eventTypes;
for (var eventName in publishedEvents) {
("production" !== "development" ? invariant(
publishEventForPlugin(
publishedEvents[eventName],
PluginModule,
eventName
),
'EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.',
eventName,
pluginName
) : invariant(publishEventForPlugin(
publishedEvents[eventName],
PluginModule,
eventName
)));
}
}
} | javascript | function recomputePluginOrdering() {
if (!EventPluginOrder) {
// Wait until an `EventPluginOrder` is injected.
return;
}
for (var pluginName in namesToPlugins) {
var PluginModule = namesToPlugins[pluginName];
var pluginIndex = EventPluginOrder.indexOf(pluginName);
("production" !== "development" ? invariant(
pluginIndex > -1,
'EventPluginRegistry: Cannot inject event plugins that do not exist in ' +
'the plugin ordering, `%s`.',
pluginName
) : invariant(pluginIndex > -1));
if (EventPluginRegistry.plugins[pluginIndex]) {
continue;
}
("production" !== "development" ? invariant(
PluginModule.extractEvents,
'EventPluginRegistry: Event plugins must implement an `extractEvents` ' +
'method, but `%s` does not.',
pluginName
) : invariant(PluginModule.extractEvents));
EventPluginRegistry.plugins[pluginIndex] = PluginModule;
var publishedEvents = PluginModule.eventTypes;
for (var eventName in publishedEvents) {
("production" !== "development" ? invariant(
publishEventForPlugin(
publishedEvents[eventName],
PluginModule,
eventName
),
'EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.',
eventName,
pluginName
) : invariant(publishEventForPlugin(
publishedEvents[eventName],
PluginModule,
eventName
)));
}
}
} | [
"function",
"recomputePluginOrdering",
"(",
")",
"{",
"if",
"(",
"!",
"EventPluginOrder",
")",
"{",
"// Wait until an `EventPluginOrder` is injected.",
"return",
";",
"}",
"for",
"(",
"var",
"pluginName",
"in",
"namesToPlugins",
")",
"{",
"var",
"PluginModule",
"=",
"namesToPlugins",
"[",
"pluginName",
"]",
";",
"var",
"pluginIndex",
"=",
"EventPluginOrder",
".",
"indexOf",
"(",
"pluginName",
")",
";",
"(",
"\"production\"",
"!==",
"\"development\"",
"?",
"invariant",
"(",
"pluginIndex",
">",
"-",
"1",
",",
"'EventPluginRegistry: Cannot inject event plugins that do not exist in '",
"+",
"'the plugin ordering, `%s`.'",
",",
"pluginName",
")",
":",
"invariant",
"(",
"pluginIndex",
">",
"-",
"1",
")",
")",
";",
"if",
"(",
"EventPluginRegistry",
".",
"plugins",
"[",
"pluginIndex",
"]",
")",
"{",
"continue",
";",
"}",
"(",
"\"production\"",
"!==",
"\"development\"",
"?",
"invariant",
"(",
"PluginModule",
".",
"extractEvents",
",",
"'EventPluginRegistry: Event plugins must implement an `extractEvents` '",
"+",
"'method, but `%s` does not.'",
",",
"pluginName",
")",
":",
"invariant",
"(",
"PluginModule",
".",
"extractEvents",
")",
")",
";",
"EventPluginRegistry",
".",
"plugins",
"[",
"pluginIndex",
"]",
"=",
"PluginModule",
";",
"var",
"publishedEvents",
"=",
"PluginModule",
".",
"eventTypes",
";",
"for",
"(",
"var",
"eventName",
"in",
"publishedEvents",
")",
"{",
"(",
"\"production\"",
"!==",
"\"development\"",
"?",
"invariant",
"(",
"publishEventForPlugin",
"(",
"publishedEvents",
"[",
"eventName",
"]",
",",
"PluginModule",
",",
"eventName",
")",
",",
"'EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.'",
",",
"eventName",
",",
"pluginName",
")",
":",
"invariant",
"(",
"publishEventForPlugin",
"(",
"publishedEvents",
"[",
"eventName",
"]",
",",
"PluginModule",
",",
"eventName",
")",
")",
")",
";",
"}",
"}",
"}"
] | Recomputes the plugin list using the injected plugins and plugin ordering.
@private | [
"Recomputes",
"the",
"plugin",
"list",
"using",
"the",
"injected",
"plugins",
"and",
"plugin",
"ordering",
"."
] | 8682a44736d21877a3237b222587acc2b43924c9 | https://github.com/srouse/cssmodeler/blob/8682a44736d21877a3237b222587acc2b43924c9/example/dist/csssystem/styleguide/cmod_styleguide.js#L2947-L2989 |
57,777 | srouse/cssmodeler | example/dist/csssystem/styleguide/cmod_styleguide.js | publishEventForPlugin | function publishEventForPlugin(dispatchConfig, PluginModule, eventName) {
("production" !== "development" ? invariant(
!EventPluginRegistry.eventNameDispatchConfigs.hasOwnProperty(eventName),
'EventPluginHub: More than one plugin attempted to publish the same ' +
'event name, `%s`.',
eventName
) : invariant(!EventPluginRegistry.eventNameDispatchConfigs.hasOwnProperty(eventName)));
EventPluginRegistry.eventNameDispatchConfigs[eventName] = dispatchConfig;
var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames;
if (phasedRegistrationNames) {
for (var phaseName in phasedRegistrationNames) {
if (phasedRegistrationNames.hasOwnProperty(phaseName)) {
var phasedRegistrationName = phasedRegistrationNames[phaseName];
publishRegistrationName(
phasedRegistrationName,
PluginModule,
eventName
);
}
}
return true;
} else if (dispatchConfig.registrationName) {
publishRegistrationName(
dispatchConfig.registrationName,
PluginModule,
eventName
);
return true;
}
return false;
} | javascript | function publishEventForPlugin(dispatchConfig, PluginModule, eventName) {
("production" !== "development" ? invariant(
!EventPluginRegistry.eventNameDispatchConfigs.hasOwnProperty(eventName),
'EventPluginHub: More than one plugin attempted to publish the same ' +
'event name, `%s`.',
eventName
) : invariant(!EventPluginRegistry.eventNameDispatchConfigs.hasOwnProperty(eventName)));
EventPluginRegistry.eventNameDispatchConfigs[eventName] = dispatchConfig;
var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames;
if (phasedRegistrationNames) {
for (var phaseName in phasedRegistrationNames) {
if (phasedRegistrationNames.hasOwnProperty(phaseName)) {
var phasedRegistrationName = phasedRegistrationNames[phaseName];
publishRegistrationName(
phasedRegistrationName,
PluginModule,
eventName
);
}
}
return true;
} else if (dispatchConfig.registrationName) {
publishRegistrationName(
dispatchConfig.registrationName,
PluginModule,
eventName
);
return true;
}
return false;
} | [
"function",
"publishEventForPlugin",
"(",
"dispatchConfig",
",",
"PluginModule",
",",
"eventName",
")",
"{",
"(",
"\"production\"",
"!==",
"\"development\"",
"?",
"invariant",
"(",
"!",
"EventPluginRegistry",
".",
"eventNameDispatchConfigs",
".",
"hasOwnProperty",
"(",
"eventName",
")",
",",
"'EventPluginHub: More than one plugin attempted to publish the same '",
"+",
"'event name, `%s`.'",
",",
"eventName",
")",
":",
"invariant",
"(",
"!",
"EventPluginRegistry",
".",
"eventNameDispatchConfigs",
".",
"hasOwnProperty",
"(",
"eventName",
")",
")",
")",
";",
"EventPluginRegistry",
".",
"eventNameDispatchConfigs",
"[",
"eventName",
"]",
"=",
"dispatchConfig",
";",
"var",
"phasedRegistrationNames",
"=",
"dispatchConfig",
".",
"phasedRegistrationNames",
";",
"if",
"(",
"phasedRegistrationNames",
")",
"{",
"for",
"(",
"var",
"phaseName",
"in",
"phasedRegistrationNames",
")",
"{",
"if",
"(",
"phasedRegistrationNames",
".",
"hasOwnProperty",
"(",
"phaseName",
")",
")",
"{",
"var",
"phasedRegistrationName",
"=",
"phasedRegistrationNames",
"[",
"phaseName",
"]",
";",
"publishRegistrationName",
"(",
"phasedRegistrationName",
",",
"PluginModule",
",",
"eventName",
")",
";",
"}",
"}",
"return",
"true",
";",
"}",
"else",
"if",
"(",
"dispatchConfig",
".",
"registrationName",
")",
"{",
"publishRegistrationName",
"(",
"dispatchConfig",
".",
"registrationName",
",",
"PluginModule",
",",
"eventName",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Publishes an event so that it can be dispatched by the supplied plugin.
@param {object} dispatchConfig Dispatch configuration for the event.
@param {object} PluginModule Plugin publishing the event.
@return {boolean} True if the event was successfully published.
@private | [
"Publishes",
"an",
"event",
"so",
"that",
"it",
"can",
"be",
"dispatched",
"by",
"the",
"supplied",
"plugin",
"."
] | 8682a44736d21877a3237b222587acc2b43924c9 | https://github.com/srouse/cssmodeler/blob/8682a44736d21877a3237b222587acc2b43924c9/example/dist/csssystem/styleguide/cmod_styleguide.js#L2999-L3030 |
57,778 | srouse/cssmodeler | example/dist/csssystem/styleguide/cmod_styleguide.js | function(spec) {
var Constructor = function(props, context) {
// This constructor is overridden by mocks. The argument is used
// by mocks to assert on what gets mounted.
if ("production" !== "development") {
("production" !== "development" ? warning(
this instanceof Constructor,
'Something is calling a React component directly. Use a factory or ' +
'JSX instead. See: https://fb.me/react-legacyfactory'
) : null);
}
// Wire up auto-binding
if (this.__reactAutoBindMap) {
bindAutoBindMethods(this);
}
this.props = props;
this.context = context;
this.state = null;
// ReactClasses doesn't have constructors. Instead, they use the
// getInitialState and componentWillMount methods for initialization.
var initialState = this.getInitialState ? this.getInitialState() : null;
if ("production" !== "development") {
// We allow auto-mocks to proceed as if they're returning null.
if (typeof initialState === 'undefined' &&
this.getInitialState._isMockFunction) {
// This is probably bad practice. Consider warning here and
// deprecating this convenience.
initialState = null;
}
}
("production" !== "development" ? invariant(
typeof initialState === 'object' && !Array.isArray(initialState),
'%s.getInitialState(): must return an object or null',
Constructor.displayName || 'ReactCompositeComponent'
) : invariant(typeof initialState === 'object' && !Array.isArray(initialState)));
this.state = initialState;
};
Constructor.prototype = new ReactClassComponent();
Constructor.prototype.constructor = Constructor;
injectedMixins.forEach(
mixSpecIntoComponent.bind(null, Constructor)
);
mixSpecIntoComponent(Constructor, spec);
// Initialize the defaultProps property after all mixins have been merged
if (Constructor.getDefaultProps) {
Constructor.defaultProps = Constructor.getDefaultProps();
}
if ("production" !== "development") {
// This is a tag to indicate that the use of these method names is ok,
// since it's used with createClass. If it's not, then it's likely a
// mistake so we'll warn you to use the static property, property
// initializer or constructor respectively.
if (Constructor.getDefaultProps) {
Constructor.getDefaultProps.isReactClassApproved = {};
}
if (Constructor.prototype.getInitialState) {
Constructor.prototype.getInitialState.isReactClassApproved = {};
}
}
("production" !== "development" ? invariant(
Constructor.prototype.render,
'createClass(...): Class specification must implement a `render` method.'
) : invariant(Constructor.prototype.render));
if ("production" !== "development") {
("production" !== "development" ? warning(
!Constructor.prototype.componentShouldUpdate,
'%s has a method called ' +
'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' +
'The name is phrased as a question because the function is ' +
'expected to return a value.',
spec.displayName || 'A component'
) : null);
}
// Reduce time spent doing lookups by setting these on the prototype.
for (var methodName in ReactClassInterface) {
if (!Constructor.prototype[methodName]) {
Constructor.prototype[methodName] = null;
}
}
// Legacy hook
Constructor.type = Constructor;
if ("production" !== "development") {
try {
Object.defineProperty(Constructor, 'type', typeDeprecationDescriptor);
} catch (x) {
// IE will fail on defineProperty (es5-shim/sham too)
}
}
return Constructor;
} | javascript | function(spec) {
var Constructor = function(props, context) {
// This constructor is overridden by mocks. The argument is used
// by mocks to assert on what gets mounted.
if ("production" !== "development") {
("production" !== "development" ? warning(
this instanceof Constructor,
'Something is calling a React component directly. Use a factory or ' +
'JSX instead. See: https://fb.me/react-legacyfactory'
) : null);
}
// Wire up auto-binding
if (this.__reactAutoBindMap) {
bindAutoBindMethods(this);
}
this.props = props;
this.context = context;
this.state = null;
// ReactClasses doesn't have constructors. Instead, they use the
// getInitialState and componentWillMount methods for initialization.
var initialState = this.getInitialState ? this.getInitialState() : null;
if ("production" !== "development") {
// We allow auto-mocks to proceed as if they're returning null.
if (typeof initialState === 'undefined' &&
this.getInitialState._isMockFunction) {
// This is probably bad practice. Consider warning here and
// deprecating this convenience.
initialState = null;
}
}
("production" !== "development" ? invariant(
typeof initialState === 'object' && !Array.isArray(initialState),
'%s.getInitialState(): must return an object or null',
Constructor.displayName || 'ReactCompositeComponent'
) : invariant(typeof initialState === 'object' && !Array.isArray(initialState)));
this.state = initialState;
};
Constructor.prototype = new ReactClassComponent();
Constructor.prototype.constructor = Constructor;
injectedMixins.forEach(
mixSpecIntoComponent.bind(null, Constructor)
);
mixSpecIntoComponent(Constructor, spec);
// Initialize the defaultProps property after all mixins have been merged
if (Constructor.getDefaultProps) {
Constructor.defaultProps = Constructor.getDefaultProps();
}
if ("production" !== "development") {
// This is a tag to indicate that the use of these method names is ok,
// since it's used with createClass. If it's not, then it's likely a
// mistake so we'll warn you to use the static property, property
// initializer or constructor respectively.
if (Constructor.getDefaultProps) {
Constructor.getDefaultProps.isReactClassApproved = {};
}
if (Constructor.prototype.getInitialState) {
Constructor.prototype.getInitialState.isReactClassApproved = {};
}
}
("production" !== "development" ? invariant(
Constructor.prototype.render,
'createClass(...): Class specification must implement a `render` method.'
) : invariant(Constructor.prototype.render));
if ("production" !== "development") {
("production" !== "development" ? warning(
!Constructor.prototype.componentShouldUpdate,
'%s has a method called ' +
'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' +
'The name is phrased as a question because the function is ' +
'expected to return a value.',
spec.displayName || 'A component'
) : null);
}
// Reduce time spent doing lookups by setting these on the prototype.
for (var methodName in ReactClassInterface) {
if (!Constructor.prototype[methodName]) {
Constructor.prototype[methodName] = null;
}
}
// Legacy hook
Constructor.type = Constructor;
if ("production" !== "development") {
try {
Object.defineProperty(Constructor, 'type', typeDeprecationDescriptor);
} catch (x) {
// IE will fail on defineProperty (es5-shim/sham too)
}
}
return Constructor;
} | [
"function",
"(",
"spec",
")",
"{",
"var",
"Constructor",
"=",
"function",
"(",
"props",
",",
"context",
")",
"{",
"// This constructor is overridden by mocks. The argument is used",
"// by mocks to assert on what gets mounted.",
"if",
"(",
"\"production\"",
"!==",
"\"development\"",
")",
"{",
"(",
"\"production\"",
"!==",
"\"development\"",
"?",
"warning",
"(",
"this",
"instanceof",
"Constructor",
",",
"'Something is calling a React component directly. Use a factory or '",
"+",
"'JSX instead. See: https://fb.me/react-legacyfactory'",
")",
":",
"null",
")",
";",
"}",
"// Wire up auto-binding",
"if",
"(",
"this",
".",
"__reactAutoBindMap",
")",
"{",
"bindAutoBindMethods",
"(",
"this",
")",
";",
"}",
"this",
".",
"props",
"=",
"props",
";",
"this",
".",
"context",
"=",
"context",
";",
"this",
".",
"state",
"=",
"null",
";",
"// ReactClasses doesn't have constructors. Instead, they use the",
"// getInitialState and componentWillMount methods for initialization.",
"var",
"initialState",
"=",
"this",
".",
"getInitialState",
"?",
"this",
".",
"getInitialState",
"(",
")",
":",
"null",
";",
"if",
"(",
"\"production\"",
"!==",
"\"development\"",
")",
"{",
"// We allow auto-mocks to proceed as if they're returning null.",
"if",
"(",
"typeof",
"initialState",
"===",
"'undefined'",
"&&",
"this",
".",
"getInitialState",
".",
"_isMockFunction",
")",
"{",
"// This is probably bad practice. Consider warning here and",
"// deprecating this convenience.",
"initialState",
"=",
"null",
";",
"}",
"}",
"(",
"\"production\"",
"!==",
"\"development\"",
"?",
"invariant",
"(",
"typeof",
"initialState",
"===",
"'object'",
"&&",
"!",
"Array",
".",
"isArray",
"(",
"initialState",
")",
",",
"'%s.getInitialState(): must return an object or null'",
",",
"Constructor",
".",
"displayName",
"||",
"'ReactCompositeComponent'",
")",
":",
"invariant",
"(",
"typeof",
"initialState",
"===",
"'object'",
"&&",
"!",
"Array",
".",
"isArray",
"(",
"initialState",
")",
")",
")",
";",
"this",
".",
"state",
"=",
"initialState",
";",
"}",
";",
"Constructor",
".",
"prototype",
"=",
"new",
"ReactClassComponent",
"(",
")",
";",
"Constructor",
".",
"prototype",
".",
"constructor",
"=",
"Constructor",
";",
"injectedMixins",
".",
"forEach",
"(",
"mixSpecIntoComponent",
".",
"bind",
"(",
"null",
",",
"Constructor",
")",
")",
";",
"mixSpecIntoComponent",
"(",
"Constructor",
",",
"spec",
")",
";",
"// Initialize the defaultProps property after all mixins have been merged",
"if",
"(",
"Constructor",
".",
"getDefaultProps",
")",
"{",
"Constructor",
".",
"defaultProps",
"=",
"Constructor",
".",
"getDefaultProps",
"(",
")",
";",
"}",
"if",
"(",
"\"production\"",
"!==",
"\"development\"",
")",
"{",
"// This is a tag to indicate that the use of these method names is ok,",
"// since it's used with createClass. If it's not, then it's likely a",
"// mistake so we'll warn you to use the static property, property",
"// initializer or constructor respectively.",
"if",
"(",
"Constructor",
".",
"getDefaultProps",
")",
"{",
"Constructor",
".",
"getDefaultProps",
".",
"isReactClassApproved",
"=",
"{",
"}",
";",
"}",
"if",
"(",
"Constructor",
".",
"prototype",
".",
"getInitialState",
")",
"{",
"Constructor",
".",
"prototype",
".",
"getInitialState",
".",
"isReactClassApproved",
"=",
"{",
"}",
";",
"}",
"}",
"(",
"\"production\"",
"!==",
"\"development\"",
"?",
"invariant",
"(",
"Constructor",
".",
"prototype",
".",
"render",
",",
"'createClass(...): Class specification must implement a `render` method.'",
")",
":",
"invariant",
"(",
"Constructor",
".",
"prototype",
".",
"render",
")",
")",
";",
"if",
"(",
"\"production\"",
"!==",
"\"development\"",
")",
"{",
"(",
"\"production\"",
"!==",
"\"development\"",
"?",
"warning",
"(",
"!",
"Constructor",
".",
"prototype",
".",
"componentShouldUpdate",
",",
"'%s has a method called '",
"+",
"'componentShouldUpdate(). Did you mean shouldComponentUpdate()? '",
"+",
"'The name is phrased as a question because the function is '",
"+",
"'expected to return a value.'",
",",
"spec",
".",
"displayName",
"||",
"'A component'",
")",
":",
"null",
")",
";",
"}",
"// Reduce time spent doing lookups by setting these on the prototype.",
"for",
"(",
"var",
"methodName",
"in",
"ReactClassInterface",
")",
"{",
"if",
"(",
"!",
"Constructor",
".",
"prototype",
"[",
"methodName",
"]",
")",
"{",
"Constructor",
".",
"prototype",
"[",
"methodName",
"]",
"=",
"null",
";",
"}",
"}",
"// Legacy hook",
"Constructor",
".",
"type",
"=",
"Constructor",
";",
"if",
"(",
"\"production\"",
"!==",
"\"development\"",
")",
"{",
"try",
"{",
"Object",
".",
"defineProperty",
"(",
"Constructor",
",",
"'type'",
",",
"typeDeprecationDescriptor",
")",
";",
"}",
"catch",
"(",
"x",
")",
"{",
"// IE will fail on defineProperty (es5-shim/sham too)",
"}",
"}",
"return",
"Constructor",
";",
"}"
] | Creates a composite component class given a class specification.
@param {object} spec Class specification (which must define `render`).
@return {function} Component constructor function.
@public | [
"Creates",
"a",
"composite",
"component",
"class",
"given",
"a",
"class",
"specification",
"."
] | 8682a44736d21877a3237b222587acc2b43924c9 | https://github.com/srouse/cssmodeler/blob/8682a44736d21877a3237b222587acc2b43924c9/example/dist/csssystem/styleguide/cmod_styleguide.js#L5818-L5922 |
|
57,779 | srouse/cssmodeler | example/dist/csssystem/styleguide/cmod_styleguide.js | function(propTypes, props, location) {
// TODO: Stop validating prop types here and only use the element
// validation.
var componentName = this.getName();
for (var propName in propTypes) {
if (propTypes.hasOwnProperty(propName)) {
var error;
try {
// This is intentionally an invariant that gets caught. It's the same
// behavior as without this statement except with a better message.
("production" !== "development" ? invariant(
typeof propTypes[propName] === 'function',
'%s: %s type `%s` is invalid; it must be a function, usually ' +
'from React.PropTypes.',
componentName || 'React class',
ReactPropTypeLocationNames[location],
propName
) : invariant(typeof propTypes[propName] === 'function'));
error = propTypes[propName](props, propName, componentName, location);
} catch (ex) {
error = ex;
}
if (error instanceof Error) {
// We may want to extend this logic for similar errors in
// React.render calls, so I'm abstracting it away into
// a function to minimize refactoring in the future
var addendum = getDeclarationErrorAddendum(this);
if (location === ReactPropTypeLocations.prop) {
// Preface gives us something to blacklist in warning module
("production" !== "development" ? warning(
false,
'Failed Composite propType: %s%s',
error.message,
addendum
) : null);
} else {
("production" !== "development" ? warning(
false,
'Failed Context Types: %s%s',
error.message,
addendum
) : null);
}
}
}
}
} | javascript | function(propTypes, props, location) {
// TODO: Stop validating prop types here and only use the element
// validation.
var componentName = this.getName();
for (var propName in propTypes) {
if (propTypes.hasOwnProperty(propName)) {
var error;
try {
// This is intentionally an invariant that gets caught. It's the same
// behavior as without this statement except with a better message.
("production" !== "development" ? invariant(
typeof propTypes[propName] === 'function',
'%s: %s type `%s` is invalid; it must be a function, usually ' +
'from React.PropTypes.',
componentName || 'React class',
ReactPropTypeLocationNames[location],
propName
) : invariant(typeof propTypes[propName] === 'function'));
error = propTypes[propName](props, propName, componentName, location);
} catch (ex) {
error = ex;
}
if (error instanceof Error) {
// We may want to extend this logic for similar errors in
// React.render calls, so I'm abstracting it away into
// a function to minimize refactoring in the future
var addendum = getDeclarationErrorAddendum(this);
if (location === ReactPropTypeLocations.prop) {
// Preface gives us something to blacklist in warning module
("production" !== "development" ? warning(
false,
'Failed Composite propType: %s%s',
error.message,
addendum
) : null);
} else {
("production" !== "development" ? warning(
false,
'Failed Context Types: %s%s',
error.message,
addendum
) : null);
}
}
}
}
} | [
"function",
"(",
"propTypes",
",",
"props",
",",
"location",
")",
"{",
"// TODO: Stop validating prop types here and only use the element",
"// validation.",
"var",
"componentName",
"=",
"this",
".",
"getName",
"(",
")",
";",
"for",
"(",
"var",
"propName",
"in",
"propTypes",
")",
"{",
"if",
"(",
"propTypes",
".",
"hasOwnProperty",
"(",
"propName",
")",
")",
"{",
"var",
"error",
";",
"try",
"{",
"// This is intentionally an invariant that gets caught. It's the same",
"// behavior as without this statement except with a better message.",
"(",
"\"production\"",
"!==",
"\"development\"",
"?",
"invariant",
"(",
"typeof",
"propTypes",
"[",
"propName",
"]",
"===",
"'function'",
",",
"'%s: %s type `%s` is invalid; it must be a function, usually '",
"+",
"'from React.PropTypes.'",
",",
"componentName",
"||",
"'React class'",
",",
"ReactPropTypeLocationNames",
"[",
"location",
"]",
",",
"propName",
")",
":",
"invariant",
"(",
"typeof",
"propTypes",
"[",
"propName",
"]",
"===",
"'function'",
")",
")",
";",
"error",
"=",
"propTypes",
"[",
"propName",
"]",
"(",
"props",
",",
"propName",
",",
"componentName",
",",
"location",
")",
";",
"}",
"catch",
"(",
"ex",
")",
"{",
"error",
"=",
"ex",
";",
"}",
"if",
"(",
"error",
"instanceof",
"Error",
")",
"{",
"// We may want to extend this logic for similar errors in",
"// React.render calls, so I'm abstracting it away into",
"// a function to minimize refactoring in the future",
"var",
"addendum",
"=",
"getDeclarationErrorAddendum",
"(",
"this",
")",
";",
"if",
"(",
"location",
"===",
"ReactPropTypeLocations",
".",
"prop",
")",
"{",
"// Preface gives us something to blacklist in warning module",
"(",
"\"production\"",
"!==",
"\"development\"",
"?",
"warning",
"(",
"false",
",",
"'Failed Composite propType: %s%s'",
",",
"error",
".",
"message",
",",
"addendum",
")",
":",
"null",
")",
";",
"}",
"else",
"{",
"(",
"\"production\"",
"!==",
"\"development\"",
"?",
"warning",
"(",
"false",
",",
"'Failed Context Types: %s%s'",
",",
"error",
".",
"message",
",",
"addendum",
")",
":",
"null",
")",
";",
"}",
"}",
"}",
"}",
"}"
] | Assert that the props are valid
@param {object} propTypes Map of prop name to a ReactPropType
@param {object} props
@param {string} location e.g. "prop", "context", "child context"
@private | [
"Assert",
"that",
"the",
"props",
"are",
"valid"
] | 8682a44736d21877a3237b222587acc2b43924c9 | https://github.com/srouse/cssmodeler/blob/8682a44736d21877a3237b222587acc2b43924c9/example/dist/csssystem/styleguide/cmod_styleguide.js#L6643-L6690 |
|
57,780 | srouse/cssmodeler | example/dist/csssystem/styleguide/cmod_styleguide.js | warnForPropsMutation | function warnForPropsMutation(propName, element) {
var type = element.type;
var elementName = typeof type === 'string' ? type : type.displayName;
var ownerName = element._owner ?
element._owner.getPublicInstance().constructor.displayName : null;
var warningKey = propName + '|' + elementName + '|' + ownerName;
if (warnedPropsMutations.hasOwnProperty(warningKey)) {
return;
}
warnedPropsMutations[warningKey] = true;
var elementInfo = '';
if (elementName) {
elementInfo = ' <' + elementName + ' />';
}
var ownerInfo = '';
if (ownerName) {
ownerInfo = ' The element was created by ' + ownerName + '.';
}
("production" !== "development" ? warning(
false,
'Don\'t set .props.%s of the React component%s. Instead, specify the ' +
'correct value when initially creating the element or use ' +
'React.cloneElement to make a new element with updated props.%s',
propName,
elementInfo,
ownerInfo
) : null);
} | javascript | function warnForPropsMutation(propName, element) {
var type = element.type;
var elementName = typeof type === 'string' ? type : type.displayName;
var ownerName = element._owner ?
element._owner.getPublicInstance().constructor.displayName : null;
var warningKey = propName + '|' + elementName + '|' + ownerName;
if (warnedPropsMutations.hasOwnProperty(warningKey)) {
return;
}
warnedPropsMutations[warningKey] = true;
var elementInfo = '';
if (elementName) {
elementInfo = ' <' + elementName + ' />';
}
var ownerInfo = '';
if (ownerName) {
ownerInfo = ' The element was created by ' + ownerName + '.';
}
("production" !== "development" ? warning(
false,
'Don\'t set .props.%s of the React component%s. Instead, specify the ' +
'correct value when initially creating the element or use ' +
'React.cloneElement to make a new element with updated props.%s',
propName,
elementInfo,
ownerInfo
) : null);
} | [
"function",
"warnForPropsMutation",
"(",
"propName",
",",
"element",
")",
"{",
"var",
"type",
"=",
"element",
".",
"type",
";",
"var",
"elementName",
"=",
"typeof",
"type",
"===",
"'string'",
"?",
"type",
":",
"type",
".",
"displayName",
";",
"var",
"ownerName",
"=",
"element",
".",
"_owner",
"?",
"element",
".",
"_owner",
".",
"getPublicInstance",
"(",
")",
".",
"constructor",
".",
"displayName",
":",
"null",
";",
"var",
"warningKey",
"=",
"propName",
"+",
"'|'",
"+",
"elementName",
"+",
"'|'",
"+",
"ownerName",
";",
"if",
"(",
"warnedPropsMutations",
".",
"hasOwnProperty",
"(",
"warningKey",
")",
")",
"{",
"return",
";",
"}",
"warnedPropsMutations",
"[",
"warningKey",
"]",
"=",
"true",
";",
"var",
"elementInfo",
"=",
"''",
";",
"if",
"(",
"elementName",
")",
"{",
"elementInfo",
"=",
"' <'",
"+",
"elementName",
"+",
"' />'",
";",
"}",
"var",
"ownerInfo",
"=",
"''",
";",
"if",
"(",
"ownerName",
")",
"{",
"ownerInfo",
"=",
"' The element was created by '",
"+",
"ownerName",
"+",
"'.'",
";",
"}",
"(",
"\"production\"",
"!==",
"\"development\"",
"?",
"warning",
"(",
"false",
",",
"'Don\\'t set .props.%s of the React component%s. Instead, specify the '",
"+",
"'correct value when initially creating the element or use '",
"+",
"'React.cloneElement to make a new element with updated props.%s'",
",",
"propName",
",",
"elementInfo",
",",
"ownerInfo",
")",
":",
"null",
")",
";",
"}"
] | Warn about mutating props when setting `propName` on `element`.
@param {string} propName The string key within props that was set
@param {ReactElement} element | [
"Warn",
"about",
"mutating",
"props",
"when",
"setting",
"propName",
"on",
"element",
"."
] | 8682a44736d21877a3237b222587acc2b43924c9 | https://github.com/srouse/cssmodeler/blob/8682a44736d21877a3237b222587acc2b43924c9/example/dist/csssystem/styleguide/cmod_styleguide.js#L10417-L10447 |
57,781 | srouse/cssmodeler | example/dist/csssystem/styleguide/cmod_styleguide.js | function(object) {
if ("production" !== "development") {
if (typeof object !== 'object' || !object || Array.isArray(object)) {
("production" !== "development" ? warning(
false,
'React.addons.createFragment only accepts a single object.',
object
) : null);
return object;
}
if (ReactElement.isValidElement(object)) {
("production" !== "development" ? warning(
false,
'React.addons.createFragment does not accept a ReactElement ' +
'without a wrapper object.'
) : null);
return object;
}
if (canWarnForReactFragment) {
var proxy = {};
Object.defineProperty(proxy, fragmentKey, {
enumerable: false,
value: object
});
Object.defineProperty(proxy, didWarnKey, {
writable: true,
enumerable: false,
value: false
});
for (var key in object) {
proxyPropertyAccessWithWarning(proxy, key);
}
Object.preventExtensions(proxy);
return proxy;
}
}
return object;
} | javascript | function(object) {
if ("production" !== "development") {
if (typeof object !== 'object' || !object || Array.isArray(object)) {
("production" !== "development" ? warning(
false,
'React.addons.createFragment only accepts a single object.',
object
) : null);
return object;
}
if (ReactElement.isValidElement(object)) {
("production" !== "development" ? warning(
false,
'React.addons.createFragment does not accept a ReactElement ' +
'without a wrapper object.'
) : null);
return object;
}
if (canWarnForReactFragment) {
var proxy = {};
Object.defineProperty(proxy, fragmentKey, {
enumerable: false,
value: object
});
Object.defineProperty(proxy, didWarnKey, {
writable: true,
enumerable: false,
value: false
});
for (var key in object) {
proxyPropertyAccessWithWarning(proxy, key);
}
Object.preventExtensions(proxy);
return proxy;
}
}
return object;
} | [
"function",
"(",
"object",
")",
"{",
"if",
"(",
"\"production\"",
"!==",
"\"development\"",
")",
"{",
"if",
"(",
"typeof",
"object",
"!==",
"'object'",
"||",
"!",
"object",
"||",
"Array",
".",
"isArray",
"(",
"object",
")",
")",
"{",
"(",
"\"production\"",
"!==",
"\"development\"",
"?",
"warning",
"(",
"false",
",",
"'React.addons.createFragment only accepts a single object.'",
",",
"object",
")",
":",
"null",
")",
";",
"return",
"object",
";",
"}",
"if",
"(",
"ReactElement",
".",
"isValidElement",
"(",
"object",
")",
")",
"{",
"(",
"\"production\"",
"!==",
"\"development\"",
"?",
"warning",
"(",
"false",
",",
"'React.addons.createFragment does not accept a ReactElement '",
"+",
"'without a wrapper object.'",
")",
":",
"null",
")",
";",
"return",
"object",
";",
"}",
"if",
"(",
"canWarnForReactFragment",
")",
"{",
"var",
"proxy",
"=",
"{",
"}",
";",
"Object",
".",
"defineProperty",
"(",
"proxy",
",",
"fragmentKey",
",",
"{",
"enumerable",
":",
"false",
",",
"value",
":",
"object",
"}",
")",
";",
"Object",
".",
"defineProperty",
"(",
"proxy",
",",
"didWarnKey",
",",
"{",
"writable",
":",
"true",
",",
"enumerable",
":",
"false",
",",
"value",
":",
"false",
"}",
")",
";",
"for",
"(",
"var",
"key",
"in",
"object",
")",
"{",
"proxyPropertyAccessWithWarning",
"(",
"proxy",
",",
"key",
")",
";",
"}",
"Object",
".",
"preventExtensions",
"(",
"proxy",
")",
";",
"return",
"proxy",
";",
"}",
"}",
"return",
"object",
";",
"}"
] | Wrap a keyed object in an opaque proxy that warns you if you access any of its properties. | [
"Wrap",
"a",
"keyed",
"object",
"in",
"an",
"opaque",
"proxy",
"that",
"warns",
"you",
"if",
"you",
"access",
"any",
"of",
"its",
"properties",
"."
] | 8682a44736d21877a3237b222587acc2b43924c9 | https://github.com/srouse/cssmodeler/blob/8682a44736d21877a3237b222587acc2b43924c9/example/dist/csssystem/styleguide/cmod_styleguide.js#L11065-L11102 |
|
57,782 | srouse/cssmodeler | example/dist/csssystem/styleguide/cmod_styleguide.js | function(container) {
// Various parts of our code (such as ReactCompositeComponent's
// _renderValidatedComponent) assume that calls to render aren't nested;
// verify that that's the case. (Strictly speaking, unmounting won't cause a
// render but we still don't expect to be in a render call here.)
("production" !== "development" ? warning(
ReactCurrentOwner.current == null,
'unmountComponentAtNode(): Render methods should be a pure function of ' +
'props and state; triggering nested component updates from render is ' +
'not allowed. If necessary, trigger nested updates in ' +
'componentDidUpdate.'
) : null);
("production" !== "development" ? invariant(
container && (
(container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE)
),
'unmountComponentAtNode(...): Target container is not a DOM element.'
) : invariant(container && (
(container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE)
)));
var reactRootID = getReactRootID(container);
var component = instancesByReactRootID[reactRootID];
if (!component) {
return false;
}
ReactMount.unmountComponentFromNode(component, container);
delete instancesByReactRootID[reactRootID];
delete containersByReactRootID[reactRootID];
if ("production" !== "development") {
delete rootElementsByReactRootID[reactRootID];
}
return true;
} | javascript | function(container) {
// Various parts of our code (such as ReactCompositeComponent's
// _renderValidatedComponent) assume that calls to render aren't nested;
// verify that that's the case. (Strictly speaking, unmounting won't cause a
// render but we still don't expect to be in a render call here.)
("production" !== "development" ? warning(
ReactCurrentOwner.current == null,
'unmountComponentAtNode(): Render methods should be a pure function of ' +
'props and state; triggering nested component updates from render is ' +
'not allowed. If necessary, trigger nested updates in ' +
'componentDidUpdate.'
) : null);
("production" !== "development" ? invariant(
container && (
(container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE)
),
'unmountComponentAtNode(...): Target container is not a DOM element.'
) : invariant(container && (
(container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE)
)));
var reactRootID = getReactRootID(container);
var component = instancesByReactRootID[reactRootID];
if (!component) {
return false;
}
ReactMount.unmountComponentFromNode(component, container);
delete instancesByReactRootID[reactRootID];
delete containersByReactRootID[reactRootID];
if ("production" !== "development") {
delete rootElementsByReactRootID[reactRootID];
}
return true;
} | [
"function",
"(",
"container",
")",
"{",
"// Various parts of our code (such as ReactCompositeComponent's",
"// _renderValidatedComponent) assume that calls to render aren't nested;",
"// verify that that's the case. (Strictly speaking, unmounting won't cause a",
"// render but we still don't expect to be in a render call here.)",
"(",
"\"production\"",
"!==",
"\"development\"",
"?",
"warning",
"(",
"ReactCurrentOwner",
".",
"current",
"==",
"null",
",",
"'unmountComponentAtNode(): Render methods should be a pure function of '",
"+",
"'props and state; triggering nested component updates from render is '",
"+",
"'not allowed. If necessary, trigger nested updates in '",
"+",
"'componentDidUpdate.'",
")",
":",
"null",
")",
";",
"(",
"\"production\"",
"!==",
"\"development\"",
"?",
"invariant",
"(",
"container",
"&&",
"(",
"(",
"container",
".",
"nodeType",
"===",
"ELEMENT_NODE_TYPE",
"||",
"container",
".",
"nodeType",
"===",
"DOC_NODE_TYPE",
")",
")",
",",
"'unmountComponentAtNode(...): Target container is not a DOM element.'",
")",
":",
"invariant",
"(",
"container",
"&&",
"(",
"(",
"container",
".",
"nodeType",
"===",
"ELEMENT_NODE_TYPE",
"||",
"container",
".",
"nodeType",
"===",
"DOC_NODE_TYPE",
")",
")",
")",
")",
";",
"var",
"reactRootID",
"=",
"getReactRootID",
"(",
"container",
")",
";",
"var",
"component",
"=",
"instancesByReactRootID",
"[",
"reactRootID",
"]",
";",
"if",
"(",
"!",
"component",
")",
"{",
"return",
"false",
";",
"}",
"ReactMount",
".",
"unmountComponentFromNode",
"(",
"component",
",",
"container",
")",
";",
"delete",
"instancesByReactRootID",
"[",
"reactRootID",
"]",
";",
"delete",
"containersByReactRootID",
"[",
"reactRootID",
"]",
";",
"if",
"(",
"\"production\"",
"!==",
"\"development\"",
")",
"{",
"delete",
"rootElementsByReactRootID",
"[",
"reactRootID",
"]",
";",
"}",
"return",
"true",
";",
"}"
] | Unmounts and destroys the React component rendered in the `container`.
@param {DOMElement} container DOM element containing a React component.
@return {boolean} True if a component was found in and unmounted from
`container` | [
"Unmounts",
"and",
"destroys",
"the",
"React",
"component",
"rendered",
"in",
"the",
"container",
"."
] | 8682a44736d21877a3237b222587acc2b43924c9 | https://github.com/srouse/cssmodeler/blob/8682a44736d21877a3237b222587acc2b43924c9/example/dist/csssystem/styleguide/cmod_styleguide.js#L12362-L12396 |
|
57,783 | srouse/cssmodeler | example/dist/csssystem/styleguide/cmod_styleguide.js | function(objName, fnName, func) {
if ("production" !== "development") {
var measuredFunc = null;
var wrapper = function() {
if (ReactPerf.enableMeasure) {
if (!measuredFunc) {
measuredFunc = ReactPerf.storedMeasure(objName, fnName, func);
}
return measuredFunc.apply(this, arguments);
}
return func.apply(this, arguments);
};
wrapper.displayName = objName + '_' + fnName;
return wrapper;
}
return func;
} | javascript | function(objName, fnName, func) {
if ("production" !== "development") {
var measuredFunc = null;
var wrapper = function() {
if (ReactPerf.enableMeasure) {
if (!measuredFunc) {
measuredFunc = ReactPerf.storedMeasure(objName, fnName, func);
}
return measuredFunc.apply(this, arguments);
}
return func.apply(this, arguments);
};
wrapper.displayName = objName + '_' + fnName;
return wrapper;
}
return func;
} | [
"function",
"(",
"objName",
",",
"fnName",
",",
"func",
")",
"{",
"if",
"(",
"\"production\"",
"!==",
"\"development\"",
")",
"{",
"var",
"measuredFunc",
"=",
"null",
";",
"var",
"wrapper",
"=",
"function",
"(",
")",
"{",
"if",
"(",
"ReactPerf",
".",
"enableMeasure",
")",
"{",
"if",
"(",
"!",
"measuredFunc",
")",
"{",
"measuredFunc",
"=",
"ReactPerf",
".",
"storedMeasure",
"(",
"objName",
",",
"fnName",
",",
"func",
")",
";",
"}",
"return",
"measuredFunc",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"}",
"return",
"func",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"}",
";",
"wrapper",
".",
"displayName",
"=",
"objName",
"+",
"'_'",
"+",
"fnName",
";",
"return",
"wrapper",
";",
"}",
"return",
"func",
";",
"}"
] | Use this to wrap methods you want to measure. Zero overhead in production.
@param {string} objName
@param {string} fnName
@param {function} func
@return {function} | [
"Use",
"this",
"to",
"wrap",
"methods",
"you",
"want",
"to",
"measure",
".",
"Zero",
"overhead",
"in",
"production",
"."
] | 8682a44736d21877a3237b222587acc2b43924c9 | https://github.com/srouse/cssmodeler/blob/8682a44736d21877a3237b222587acc2b43924c9/example/dist/csssystem/styleguide/cmod_styleguide.js#L13423-L13439 |
|
57,784 | phated/grunt-enyo | tasks/init/enyo/root/enyo/source/kernel/Object.js | function() {
var acc = arguments.callee.caller;
var nom = ((acc ? acc.nom : "") || "(instance method)") + ":";
enyo.logging.log("log", [nom].concat(enyo.cloneArray(arguments)));
} | javascript | function() {
var acc = arguments.callee.caller;
var nom = ((acc ? acc.nom : "") || "(instance method)") + ":";
enyo.logging.log("log", [nom].concat(enyo.cloneArray(arguments)));
} | [
"function",
"(",
")",
"{",
"var",
"acc",
"=",
"arguments",
".",
"callee",
".",
"caller",
";",
"var",
"nom",
"=",
"(",
"(",
"acc",
"?",
"acc",
".",
"nom",
":",
"\"\"",
")",
"||",
"\"(instance method)\"",
")",
"+",
"\":\"",
";",
"enyo",
".",
"logging",
".",
"log",
"(",
"\"log\"",
",",
"[",
"nom",
"]",
".",
"concat",
"(",
"enyo",
".",
"cloneArray",
"(",
"arguments",
")",
")",
")",
";",
"}"
] | Sends a log message to the console, prepended with the name of the kind
and method from which _log_ was invoked. Multiple arguments are coerced
to String and joined with spaces.
enyo.kind({
name: "MyObject",
kind: enyo.Object,
hello: function() {
this.log("says", "hi");
shows in the console: MyObject.hello: says hi
}
}); | [
"Sends",
"a",
"log",
"message",
"to",
"the",
"console",
"prepended",
"with",
"the",
"name",
"of",
"the",
"kind",
"and",
"method",
"from",
"which",
"_log_",
"was",
"invoked",
".",
"Multiple",
"arguments",
"are",
"coerced",
"to",
"String",
"and",
"joined",
"with",
"spaces",
"."
] | d2990ee4cd85eea8db4108c43086c6d8c3c90c30 | https://github.com/phated/grunt-enyo/blob/d2990ee4cd85eea8db4108c43086c6d8c3c90c30/tasks/init/enyo/root/enyo/source/kernel/Object.js#L77-L81 |
|
57,785 | melvincarvalho/rdf-shell | lib/mv.js | mv | function mv (sourceURI, destURI, callback) {
if (!sourceURI) {
callback(new Error('source URI is required'))
}
if (!destURI) {
callback(new Error('dest URI is required'))
}
util.get(sourceURI, function (err, val, uri) {
util.put(destURI, val, function (err, ret, uri) {
if (!err) {
util.rm(sourceURI, function(err, ret) {
if (!err) {
callback(null, ret, uri)
} else {
callback(err)
}
})
} else {
callback(err)
}
})
})
} | javascript | function mv (sourceURI, destURI, callback) {
if (!sourceURI) {
callback(new Error('source URI is required'))
}
if (!destURI) {
callback(new Error('dest URI is required'))
}
util.get(sourceURI, function (err, val, uri) {
util.put(destURI, val, function (err, ret, uri) {
if (!err) {
util.rm(sourceURI, function(err, ret) {
if (!err) {
callback(null, ret, uri)
} else {
callback(err)
}
})
} else {
callback(err)
}
})
})
} | [
"function",
"mv",
"(",
"sourceURI",
",",
"destURI",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"sourceURI",
")",
"{",
"callback",
"(",
"new",
"Error",
"(",
"'source URI is required'",
")",
")",
"}",
"if",
"(",
"!",
"destURI",
")",
"{",
"callback",
"(",
"new",
"Error",
"(",
"'dest URI is required'",
")",
")",
"}",
"util",
".",
"get",
"(",
"sourceURI",
",",
"function",
"(",
"err",
",",
"val",
",",
"uri",
")",
"{",
"util",
".",
"put",
"(",
"destURI",
",",
"val",
",",
"function",
"(",
"err",
",",
"ret",
",",
"uri",
")",
"{",
"if",
"(",
"!",
"err",
")",
"{",
"util",
".",
"rm",
"(",
"sourceURI",
",",
"function",
"(",
"err",
",",
"ret",
")",
"{",
"if",
"(",
"!",
"err",
")",
"{",
"callback",
"(",
"null",
",",
"ret",
",",
"uri",
")",
"}",
"else",
"{",
"callback",
"(",
"err",
")",
"}",
"}",
")",
"}",
"else",
"{",
"callback",
"(",
"err",
")",
"}",
"}",
")",
"}",
")",
"}"
] | Move rdf from a source to a destination.
@param {string} sourceURI The source URI
@param {string} destURI The dest URI
@param {function} callback Callback with result | [
"Move",
"rdf",
"from",
"a",
"source",
"to",
"a",
"destination",
"."
] | bf2015f6f333855e69a18ce3ec9e917bbddfb425 | https://github.com/melvincarvalho/rdf-shell/blob/bf2015f6f333855e69a18ce3ec9e917bbddfb425/lib/mv.js#L11-L33 |
57,786 | kaliumxyz/euphoria-connection | examples/userlist/index.js | update | function update() {
connection = new Connection(room)
// set our funcitonal code on the ready event, so we are sure that the socket has been created and is connected to the server
connection.on('ready', _ => {
connection.on('snapshot-event', event => {
// get every listener including bots and lurkers
userList = event.data.listing.sort()
render(userList)
connection.close()
})
})
} | javascript | function update() {
connection = new Connection(room)
// set our funcitonal code on the ready event, so we are sure that the socket has been created and is connected to the server
connection.on('ready', _ => {
connection.on('snapshot-event', event => {
// get every listener including bots and lurkers
userList = event.data.listing.sort()
render(userList)
connection.close()
})
})
} | [
"function",
"update",
"(",
")",
"{",
"connection",
"=",
"new",
"Connection",
"(",
"room",
")",
"// set our funcitonal code on the ready event, so we are sure that the socket has been created and is connected to the server",
"connection",
".",
"on",
"(",
"'ready'",
",",
"_",
"=>",
"{",
"connection",
".",
"on",
"(",
"'snapshot-event'",
",",
"event",
"=>",
"{",
"// get every listener including bots and lurkers",
"userList",
"=",
"event",
".",
"data",
".",
"listing",
".",
"sort",
"(",
")",
"render",
"(",
"userList",
")",
"connection",
".",
"close",
"(",
")",
"}",
")",
"}",
")",
"}"
] | Update the userList global with new data from the targeted euphoria room. We use the snapshot even send on a new connect to update the userlist. | [
"Update",
"the",
"userList",
"global",
"with",
"new",
"data",
"from",
"the",
"targeted",
"euphoria",
"room",
".",
"We",
"use",
"the",
"snapshot",
"even",
"send",
"on",
"a",
"new",
"connect",
"to",
"update",
"the",
"userlist",
"."
] | 936cc92117f78d2c8f9560d80b1c416e672c8c42 | https://github.com/kaliumxyz/euphoria-connection/blob/936cc92117f78d2c8f9560d80b1c416e672c8c42/examples/userlist/index.js#L25-L36 |
57,787 | kaliumxyz/euphoria-connection | examples/userlist/index.js | render | function render(list) {
const blank = new Array(process.stdout.rows).fill('\n')
console.log(blank)
readline.cursorTo(process.stdout, 0, 0)
readline.clearScreenDown(process.stdout)
list.forEach( user => {
console.log(`${chalk.hsl(color(user.name),100,50)(user.name)}: ${user.id}`)
})
} | javascript | function render(list) {
const blank = new Array(process.stdout.rows).fill('\n')
console.log(blank)
readline.cursorTo(process.stdout, 0, 0)
readline.clearScreenDown(process.stdout)
list.forEach( user => {
console.log(`${chalk.hsl(color(user.name),100,50)(user.name)}: ${user.id}`)
})
} | [
"function",
"render",
"(",
"list",
")",
"{",
"const",
"blank",
"=",
"new",
"Array",
"(",
"process",
".",
"stdout",
".",
"rows",
")",
".",
"fill",
"(",
"'\\n'",
")",
"console",
".",
"log",
"(",
"blank",
")",
"readline",
".",
"cursorTo",
"(",
"process",
".",
"stdout",
",",
"0",
",",
"0",
")",
"readline",
".",
"clearScreenDown",
"(",
"process",
".",
"stdout",
")",
"list",
".",
"forEach",
"(",
"user",
"=>",
"{",
"console",
".",
"log",
"(",
"`",
"${",
"chalk",
".",
"hsl",
"(",
"color",
"(",
"user",
".",
"name",
")",
",",
"100",
",",
"50",
")",
"(",
"user",
".",
"name",
")",
"}",
"${",
"user",
".",
"id",
"}",
"`",
")",
"}",
")",
"}"
] | Render our list, replace the old console content with our newer content and place the relevant data in the relevant places.
@param {Array} list | [
"Render",
"our",
"list",
"replace",
"the",
"old",
"console",
"content",
"with",
"our",
"newer",
"content",
"and",
"place",
"the",
"relevant",
"data",
"in",
"the",
"relevant",
"places",
"."
] | 936cc92117f78d2c8f9560d80b1c416e672c8c42 | https://github.com/kaliumxyz/euphoria-connection/blob/936cc92117f78d2c8f9560d80b1c416e672c8c42/examples/userlist/index.js#L48-L58 |
57,788 | oskarhagberg/gbgcity | lib/waterflow.js | getMeasureStations | function getMeasureStations(latitude, longitude, params, callback) {
if(!latitude || !longitude) {
callback(new Error("WaterFlow.getMeasureStations: latitude and longitude required"));
return;
}
params = params || {};
params.latitude = latitude;
params.longitude = longitude;
core.callApi('/waterflowservice/GetMeasureStations', params, callback);
} | javascript | function getMeasureStations(latitude, longitude, params, callback) {
if(!latitude || !longitude) {
callback(new Error("WaterFlow.getMeasureStations: latitude and longitude required"));
return;
}
params = params || {};
params.latitude = latitude;
params.longitude = longitude;
core.callApi('/waterflowservice/GetMeasureStations', params, callback);
} | [
"function",
"getMeasureStations",
"(",
"latitude",
",",
"longitude",
",",
"params",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"latitude",
"||",
"!",
"longitude",
")",
"{",
"callback",
"(",
"new",
"Error",
"(",
"\"WaterFlow.getMeasureStations: latitude and longitude required\"",
")",
")",
";",
"return",
";",
"}",
"params",
"=",
"params",
"||",
"{",
"}",
";",
"params",
".",
"latitude",
"=",
"latitude",
";",
"params",
".",
"longitude",
"=",
"longitude",
";",
"core",
".",
"callApi",
"(",
"'/waterflowservice/GetMeasureStations'",
",",
"params",
",",
"callback",
")",
";",
"}"
] | Returns a list of all available measure stations producing water level data.
@memberof module:gbgcity/WaterFlow
@param {String|Number} latitude The latitude of the location around which to explore.
@param {String|Number} longitude The longitude of the location around which to explore.
@param {Object} [params] An object containing additional parameters.
@param {Function} callback The function to call with results, function({Error} error, {Object} results)/
@see http://data.goteborg.se/WaterFlowService/help/operations/GetMeasureStations | [
"Returns",
"a",
"list",
"of",
"all",
"available",
"measure",
"stations",
"producing",
"water",
"level",
"data",
"."
] | d2de903b2fba83cc953ae218905380fef080cb2d | https://github.com/oskarhagberg/gbgcity/blob/d2de903b2fba83cc953ae218905380fef080cb2d/lib/waterflow.js#L24-L33 |
57,789 | oskarhagberg/gbgcity | lib/waterflow.js | getWaterLevel | function getWaterLevel(stationId, startDate, endDate, params, callback) {
if(!stationId) {
callback(new Error("WaterFlow.getWaterLevel: stationId required"));
return;
}
params = params || {};
params.stationid = stationId;
if(!startDate && !endDate) {
startDate = new Date();
startDate.setHours(startDate.getHours() - 4);
startDate = formatDate(startDate);
endDate = new Date();
endDate = formatDate(endDate);
}
params.startdate = startDate;
params.endDate = endDate;
core.callApi('/waterflowservice/GetWaterLevel', params, callback);
} | javascript | function getWaterLevel(stationId, startDate, endDate, params, callback) {
if(!stationId) {
callback(new Error("WaterFlow.getWaterLevel: stationId required"));
return;
}
params = params || {};
params.stationid = stationId;
if(!startDate && !endDate) {
startDate = new Date();
startDate.setHours(startDate.getHours() - 4);
startDate = formatDate(startDate);
endDate = new Date();
endDate = formatDate(endDate);
}
params.startdate = startDate;
params.endDate = endDate;
core.callApi('/waterflowservice/GetWaterLevel', params, callback);
} | [
"function",
"getWaterLevel",
"(",
"stationId",
",",
"startDate",
",",
"endDate",
",",
"params",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"stationId",
")",
"{",
"callback",
"(",
"new",
"Error",
"(",
"\"WaterFlow.getWaterLevel: stationId required\"",
")",
")",
";",
"return",
";",
"}",
"params",
"=",
"params",
"||",
"{",
"}",
";",
"params",
".",
"stationid",
"=",
"stationId",
";",
"if",
"(",
"!",
"startDate",
"&&",
"!",
"endDate",
")",
"{",
"startDate",
"=",
"new",
"Date",
"(",
")",
";",
"startDate",
".",
"setHours",
"(",
"startDate",
".",
"getHours",
"(",
")",
"-",
"4",
")",
";",
"startDate",
"=",
"formatDate",
"(",
"startDate",
")",
";",
"endDate",
"=",
"new",
"Date",
"(",
")",
";",
"endDate",
"=",
"formatDate",
"(",
"endDate",
")",
";",
"}",
"params",
".",
"startdate",
"=",
"startDate",
";",
"params",
".",
"endDate",
"=",
"endDate",
";",
"core",
".",
"callApi",
"(",
"'/waterflowservice/GetWaterLevel'",
",",
"params",
",",
"callback",
")",
";",
"}"
] | Returns a list of water level measuring points given a sertain station and time interval.
@memberof module:gbgcity/WaterFlow
@param {String} stationId
@param {String} [startDate]
@param {String} [endData]
@param {Function} callback The function to call with results, function({Error} error, {Object} results)/
@see http://data.goteborg.se/WaterFlowService/help/operations/GetWaterLevel | [
"Returns",
"a",
"list",
"of",
"water",
"level",
"measuring",
"points",
"given",
"a",
"sertain",
"station",
"and",
"time",
"interval",
"."
] | d2de903b2fba83cc953ae218905380fef080cb2d | https://github.com/oskarhagberg/gbgcity/blob/d2de903b2fba83cc953ae218905380fef080cb2d/lib/waterflow.js#L45-L62 |
57,790 | danielwerthen/funcis | lib/listener.js | matches | function matches(url, command) {
var cap;
if (cap = commandReg.exec(url)) return cap[1] === command;
} | javascript | function matches(url, command) {
var cap;
if (cap = commandReg.exec(url)) return cap[1] === command;
} | [
"function",
"matches",
"(",
"url",
",",
"command",
")",
"{",
"var",
"cap",
";",
"if",
"(",
"cap",
"=",
"commandReg",
".",
"exec",
"(",
"url",
")",
")",
"return",
"cap",
"[",
"1",
"]",
"===",
"command",
";",
"}"
] | Ugliness to support escaped backslashes in windows | [
"Ugliness",
"to",
"support",
"escaped",
"backslashes",
"in",
"windows"
] | 9482ea954e6684e6803c824b4105eac735d83812 | https://github.com/danielwerthen/funcis/blob/9482ea954e6684e6803c824b4105eac735d83812/lib/listener.js#L13-L16 |
57,791 | laconbass/mocha-pending | index.js | Pending | function Pending(runner) {
runner.on('start', function(){
console.log('* ')
console.log('*********************');
console.log('*** Pending tests ***');
console.log('*********************');
console.log('* ')
});
var scope = [];
runner.on('pending', function(test){
var current = [test]
, parent = test.parent
;
// stack suites
while( !!parent ){
current.unshift(parent)
parent = parent.parent;
}
// print titles
current.forEach(function(val, key){
if( val != scope[key] ){
while( scope.length > key ){
scope.pop()
}
console.log( '* ' + Array(key).join(' ') + val.title );
scope.push(val);
}
})
})
} | javascript | function Pending(runner) {
runner.on('start', function(){
console.log('* ')
console.log('*********************');
console.log('*** Pending tests ***');
console.log('*********************');
console.log('* ')
});
var scope = [];
runner.on('pending', function(test){
var current = [test]
, parent = test.parent
;
// stack suites
while( !!parent ){
current.unshift(parent)
parent = parent.parent;
}
// print titles
current.forEach(function(val, key){
if( val != scope[key] ){
while( scope.length > key ){
scope.pop()
}
console.log( '* ' + Array(key).join(' ') + val.title );
scope.push(val);
}
})
})
} | [
"function",
"Pending",
"(",
"runner",
")",
"{",
"runner",
".",
"on",
"(",
"'start'",
",",
"function",
"(",
")",
"{",
"console",
".",
"log",
"(",
"'* '",
")",
"console",
".",
"log",
"(",
"'*********************'",
")",
";",
"console",
".",
"log",
"(",
"'*** Pending tests ***'",
")",
";",
"console",
".",
"log",
"(",
"'*********************'",
")",
";",
"console",
".",
"log",
"(",
"'* '",
")",
"}",
")",
";",
"var",
"scope",
"=",
"[",
"]",
";",
"runner",
".",
"on",
"(",
"'pending'",
",",
"function",
"(",
"test",
")",
"{",
"var",
"current",
"=",
"[",
"test",
"]",
",",
"parent",
"=",
"test",
".",
"parent",
";",
"// stack suites",
"while",
"(",
"!",
"!",
"parent",
")",
"{",
"current",
".",
"unshift",
"(",
"parent",
")",
"parent",
"=",
"parent",
".",
"parent",
";",
"}",
"// print titles",
"current",
".",
"forEach",
"(",
"function",
"(",
"val",
",",
"key",
")",
"{",
"if",
"(",
"val",
"!=",
"scope",
"[",
"key",
"]",
")",
"{",
"while",
"(",
"scope",
".",
"length",
">",
"key",
")",
"{",
"scope",
".",
"pop",
"(",
")",
"}",
"console",
".",
"log",
"(",
"'* '",
"+",
"Array",
"(",
"key",
")",
".",
"join",
"(",
"' '",
")",
"+",
"val",
".",
"title",
")",
";",
"scope",
".",
"push",
"(",
"val",
")",
";",
"}",
"}",
")",
"}",
")",
"}"
] | Initialize a new `Pending` test reporter.
@param {Runner} runner
@api public | [
"Initialize",
"a",
"new",
"Pending",
"test",
"reporter",
"."
] | df0e5ee270cee86596a755ceb1900a83b2fa6e41 | https://github.com/laconbass/mocha-pending/blob/df0e5ee270cee86596a755ceb1900a83b2fa6e41/index.js#L14-L46 |
57,792 | rsdoiel/stn | stn.js | function (d, use_UTC) {
if (typeof d === "string") {
if (d.match(/[0-9][0-9][0-9][0-9][\s]*-[0-1][0-9]-[\s]*[0-3][0-9]/)) {
return d.replace(/\s+/, "");
}
d = new Date(d);
} else if (typeof d === "number") {
d = new Date(d);
} else if (typeof d !== "object" &&
typeof d.getFullYear !== "function") {
throw "Expecting type: " + String(d) + " --> " + typeof d;
}
if (!use_UTC) {
return [
d.getFullYear(),
String("0" + (d.getMonth() + 1)).substr(-2),
String("0" + d.getDate()).substr(-2)
].join("-");
}
return [
d.getUTCFullYear(),
String("0" + (d.getUTCMonth() + 1)).substr(-2),
String("0" + d.getUTCDate()).substr(-2)
].join("-");
} | javascript | function (d, use_UTC) {
if (typeof d === "string") {
if (d.match(/[0-9][0-9][0-9][0-9][\s]*-[0-1][0-9]-[\s]*[0-3][0-9]/)) {
return d.replace(/\s+/, "");
}
d = new Date(d);
} else if (typeof d === "number") {
d = new Date(d);
} else if (typeof d !== "object" &&
typeof d.getFullYear !== "function") {
throw "Expecting type: " + String(d) + " --> " + typeof d;
}
if (!use_UTC) {
return [
d.getFullYear(),
String("0" + (d.getMonth() + 1)).substr(-2),
String("0" + d.getDate()).substr(-2)
].join("-");
}
return [
d.getUTCFullYear(),
String("0" + (d.getUTCMonth() + 1)).substr(-2),
String("0" + d.getUTCDate()).substr(-2)
].join("-");
} | [
"function",
"(",
"d",
",",
"use_UTC",
")",
"{",
"if",
"(",
"typeof",
"d",
"===",
"\"string\"",
")",
"{",
"if",
"(",
"d",
".",
"match",
"(",
"/",
"[0-9][0-9][0-9][0-9][\\s]*-[0-1][0-9]-[\\s]*[0-3][0-9]",
"/",
")",
")",
"{",
"return",
"d",
".",
"replace",
"(",
"/",
"\\s+",
"/",
",",
"\"\"",
")",
";",
"}",
"d",
"=",
"new",
"Date",
"(",
"d",
")",
";",
"}",
"else",
"if",
"(",
"typeof",
"d",
"===",
"\"number\"",
")",
"{",
"d",
"=",
"new",
"Date",
"(",
"d",
")",
";",
"}",
"else",
"if",
"(",
"typeof",
"d",
"!==",
"\"object\"",
"&&",
"typeof",
"d",
".",
"getFullYear",
"!==",
"\"function\"",
")",
"{",
"throw",
"\"Expecting type: \"",
"+",
"String",
"(",
"d",
")",
"+",
"\" --> \"",
"+",
"typeof",
"d",
";",
"}",
"if",
"(",
"!",
"use_UTC",
")",
"{",
"return",
"[",
"d",
".",
"getFullYear",
"(",
")",
",",
"String",
"(",
"\"0\"",
"+",
"(",
"d",
".",
"getMonth",
"(",
")",
"+",
"1",
")",
")",
".",
"substr",
"(",
"-",
"2",
")",
",",
"String",
"(",
"\"0\"",
"+",
"d",
".",
"getDate",
"(",
")",
")",
".",
"substr",
"(",
"-",
"2",
")",
"]",
".",
"join",
"(",
"\"-\"",
")",
";",
"}",
"return",
"[",
"d",
".",
"getUTCFullYear",
"(",
")",
",",
"String",
"(",
"\"0\"",
"+",
"(",
"d",
".",
"getUTCMonth",
"(",
")",
"+",
"1",
")",
")",
".",
"substr",
"(",
"-",
"2",
")",
",",
"String",
"(",
"\"0\"",
"+",
"d",
".",
"getUTCDate",
"(",
")",
")",
".",
"substr",
"(",
"-",
"2",
")",
"]",
".",
"join",
"(",
"\"-\"",
")",
";",
"}"
] | Format a date as YYYY-MM-DD @param Date object @return string in YYYY-MM-DD format | [
"Format",
"a",
"date",
"as",
"YYYY",
"-",
"MM",
"-",
"DD"
] | dffbe22a4a672f262e4c9151edf75fa7e077b8f4 | https://github.com/rsdoiel/stn/blob/dffbe22a4a672f262e4c9151edf75fa7e077b8f4/stn.js#L17-L41 |
|
57,793 | rsdoiel/stn | stn.js | function (options) {
var ky,
default_keys = [
"normalize_date",
"hours",
"save_parse",
"tags",
"map"
],
defaults = {},
map = {};
default_keys.forEach(function (ky) {
defaults[ky] = true;
});
this.defaults = defaults;
this.map = false;
this.parse_tree = {};
this.msgs = [];
if (options !== undefined) {
for (ky in options) {
if (options.hasOwnProperty(ky)) {
if (default_keys.indexOf(ky) >= 0) {
this.defaults[ky] = options[ky];
} else {
map[ky] = options[ky];
}
}
}
if (Object.keys(map).length > 0) {
this.map = map;
}
}
} | javascript | function (options) {
var ky,
default_keys = [
"normalize_date",
"hours",
"save_parse",
"tags",
"map"
],
defaults = {},
map = {};
default_keys.forEach(function (ky) {
defaults[ky] = true;
});
this.defaults = defaults;
this.map = false;
this.parse_tree = {};
this.msgs = [];
if (options !== undefined) {
for (ky in options) {
if (options.hasOwnProperty(ky)) {
if (default_keys.indexOf(ky) >= 0) {
this.defaults[ky] = options[ky];
} else {
map[ky] = options[ky];
}
}
}
if (Object.keys(map).length > 0) {
this.map = map;
}
}
} | [
"function",
"(",
"options",
")",
"{",
"var",
"ky",
",",
"default_keys",
"=",
"[",
"\"normalize_date\"",
",",
"\"hours\"",
",",
"\"save_parse\"",
",",
"\"tags\"",
",",
"\"map\"",
"]",
",",
"defaults",
"=",
"{",
"}",
",",
"map",
"=",
"{",
"}",
";",
"default_keys",
".",
"forEach",
"(",
"function",
"(",
"ky",
")",
"{",
"defaults",
"[",
"ky",
"]",
"=",
"true",
";",
"}",
")",
";",
"this",
".",
"defaults",
"=",
"defaults",
";",
"this",
".",
"map",
"=",
"false",
";",
"this",
".",
"parse_tree",
"=",
"{",
"}",
";",
"this",
".",
"msgs",
"=",
"[",
"]",
";",
"if",
"(",
"options",
"!==",
"undefined",
")",
"{",
"for",
"(",
"ky",
"in",
"options",
")",
"{",
"if",
"(",
"options",
".",
"hasOwnProperty",
"(",
"ky",
")",
")",
"{",
"if",
"(",
"default_keys",
".",
"indexOf",
"(",
"ky",
")",
">=",
"0",
")",
"{",
"this",
".",
"defaults",
"[",
"ky",
"]",
"=",
"options",
"[",
"ky",
"]",
";",
"}",
"else",
"{",
"map",
"[",
"ky",
"]",
"=",
"options",
"[",
"ky",
"]",
";",
"}",
"}",
"}",
"if",
"(",
"Object",
".",
"keys",
"(",
"map",
")",
".",
"length",
">",
"0",
")",
"{",
"this",
".",
"map",
"=",
"map",
";",
"}",
"}",
"}"
] | reset - clear the parse tree sets save_parse to true, sets normalize_date to true sets tags to true sets map ot false @param options - a set of options to override the defaults with on reset. | [
"reset",
"-",
"clear",
"the",
"parse",
"tree",
"sets",
"save_parse",
"to",
"true",
"sets",
"normalize_date",
"to",
"true",
"sets",
"tags",
"to",
"true",
"sets",
"map",
"ot",
"false"
] | dffbe22a4a672f262e4c9151edf75fa7e077b8f4 | https://github.com/rsdoiel/stn/blob/dffbe22a4a672f262e4c9151edf75fa7e077b8f4/stn.js#L66-L99 |
|
57,794 | rsdoiel/stn | stn.js | function (msg) {
var i = this.msgs.length;
this.msgs.push('ERROR: ' + msg);
if ((i + 1) !== this.msgs.length) {
return false;
}
return true;
} | javascript | function (msg) {
var i = this.msgs.length;
this.msgs.push('ERROR: ' + msg);
if ((i + 1) !== this.msgs.length) {
return false;
}
return true;
} | [
"function",
"(",
"msg",
")",
"{",
"var",
"i",
"=",
"this",
".",
"msgs",
".",
"length",
";",
"this",
".",
"msgs",
".",
"push",
"(",
"'ERROR: '",
"+",
"msg",
")",
";",
"if",
"(",
"(",
"i",
"+",
"1",
")",
"!==",
"this",
".",
"msgs",
".",
"length",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | error - collect parse errors into the msgs array.
@param msg - the message to the collection of messages.
@return true on successful add, false otherwise | [
"error",
"-",
"collect",
"parse",
"errors",
"into",
"the",
"msgs",
"array",
"."
] | dffbe22a4a672f262e4c9151edf75fa7e077b8f4 | https://github.com/rsdoiel/stn/blob/dffbe22a4a672f262e4c9151edf75fa7e077b8f4/stn.js#L120-L128 |
|
57,795 | rsdoiel/stn | stn.js | function (no_clear) {
var result;
if (this.msgs === undefined) {
this.msgs = [];
}
result = this.msgs.join("\n");
// set optional default i needed
if (no_clear !== undefined) {
no_clear = false;
}
if (no_clear === true) {
return result;
}
// Clear the messages
this.msgs = [];
return result;
} | javascript | function (no_clear) {
var result;
if (this.msgs === undefined) {
this.msgs = [];
}
result = this.msgs.join("\n");
// set optional default i needed
if (no_clear !== undefined) {
no_clear = false;
}
if (no_clear === true) {
return result;
}
// Clear the messages
this.msgs = [];
return result;
} | [
"function",
"(",
"no_clear",
")",
"{",
"var",
"result",
";",
"if",
"(",
"this",
".",
"msgs",
"===",
"undefined",
")",
"{",
"this",
".",
"msgs",
"=",
"[",
"]",
";",
"}",
"result",
"=",
"this",
".",
"msgs",
".",
"join",
"(",
"\"\\n\"",
")",
";",
"// set optional default i needed",
"if",
"(",
"no_clear",
"!==",
"undefined",
")",
"{",
"no_clear",
"=",
"false",
";",
"}",
"if",
"(",
"no_clear",
"===",
"true",
")",
"{",
"return",
"result",
";",
"}",
"// Clear the messages",
"this",
".",
"msgs",
"=",
"[",
"]",
";",
"return",
"result",
";",
"}"
] | messages - return the msgs array as a single string delimited
by new lines.
@param no_clear (optional, defaults to false)
@return string representing in messages | [
"messages",
"-",
"return",
"the",
"msgs",
"array",
"as",
"a",
"single",
"string",
"delimited",
"by",
"new",
"lines",
"."
] | dffbe22a4a672f262e4c9151edf75fa7e077b8f4 | https://github.com/rsdoiel/stn/blob/dffbe22a4a672f262e4c9151edf75fa7e077b8f4/stn.js#L148-L168 |
|
57,796 | rsdoiel/stn | stn.js | function () {
var self = this,
dates = Object.keys(this.parse_tree),
lines = [];
dates.sort();
dates.forEach(function (dy, i) {
var times = Object.keys(self.parse_tree[dy]);
lines.push(dy);
times.sort();
times.forEach(function (tm) {
var tags = "", maps = "", notes = "", rec;
rec = self.parse_tree[dy][tm];
if (typeof rec === "string") {
notes = rec;
} else {
if (typeof rec.map !== "undefined" &&
rec.map !== false) {
maps = [
rec.map.project_name,
rec.map.task
].join(", ") + "; ";
}
if (typeof rec.tags !== "undefined" &&
rec.tags !== false) {
tags = rec.tags.join(", ") + "; ";
}
if (typeof rec.notes !== "undefined") {
notes = rec.notes;
}
}
lines.push([
tm,
"; ",
tags,
maps,
notes
].join(""));
});
});
return lines.join("\n\n");
} | javascript | function () {
var self = this,
dates = Object.keys(this.parse_tree),
lines = [];
dates.sort();
dates.forEach(function (dy, i) {
var times = Object.keys(self.parse_tree[dy]);
lines.push(dy);
times.sort();
times.forEach(function (tm) {
var tags = "", maps = "", notes = "", rec;
rec = self.parse_tree[dy][tm];
if (typeof rec === "string") {
notes = rec;
} else {
if (typeof rec.map !== "undefined" &&
rec.map !== false) {
maps = [
rec.map.project_name,
rec.map.task
].join(", ") + "; ";
}
if (typeof rec.tags !== "undefined" &&
rec.tags !== false) {
tags = rec.tags.join(", ") + "; ";
}
if (typeof rec.notes !== "undefined") {
notes = rec.notes;
}
}
lines.push([
tm,
"; ",
tags,
maps,
notes
].join(""));
});
});
return lines.join("\n\n");
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
",",
"dates",
"=",
"Object",
".",
"keys",
"(",
"this",
".",
"parse_tree",
")",
",",
"lines",
"=",
"[",
"]",
";",
"dates",
".",
"sort",
"(",
")",
";",
"dates",
".",
"forEach",
"(",
"function",
"(",
"dy",
",",
"i",
")",
"{",
"var",
"times",
"=",
"Object",
".",
"keys",
"(",
"self",
".",
"parse_tree",
"[",
"dy",
"]",
")",
";",
"lines",
".",
"push",
"(",
"dy",
")",
";",
"times",
".",
"sort",
"(",
")",
";",
"times",
".",
"forEach",
"(",
"function",
"(",
"tm",
")",
"{",
"var",
"tags",
"=",
"\"\"",
",",
"maps",
"=",
"\"\"",
",",
"notes",
"=",
"\"\"",
",",
"rec",
";",
"rec",
"=",
"self",
".",
"parse_tree",
"[",
"dy",
"]",
"[",
"tm",
"]",
";",
"if",
"(",
"typeof",
"rec",
"===",
"\"string\"",
")",
"{",
"notes",
"=",
"rec",
";",
"}",
"else",
"{",
"if",
"(",
"typeof",
"rec",
".",
"map",
"!==",
"\"undefined\"",
"&&",
"rec",
".",
"map",
"!==",
"false",
")",
"{",
"maps",
"=",
"[",
"rec",
".",
"map",
".",
"project_name",
",",
"rec",
".",
"map",
".",
"task",
"]",
".",
"join",
"(",
"\", \"",
")",
"+",
"\"; \"",
";",
"}",
"if",
"(",
"typeof",
"rec",
".",
"tags",
"!==",
"\"undefined\"",
"&&",
"rec",
".",
"tags",
"!==",
"false",
")",
"{",
"tags",
"=",
"rec",
".",
"tags",
".",
"join",
"(",
"\", \"",
")",
"+",
"\"; \"",
";",
"}",
"if",
"(",
"typeof",
"rec",
".",
"notes",
"!==",
"\"undefined\"",
")",
"{",
"notes",
"=",
"rec",
".",
"notes",
";",
"}",
"}",
"lines",
".",
"push",
"(",
"[",
"tm",
",",
"\"; \"",
",",
"tags",
",",
"maps",
",",
"notes",
"]",
".",
"join",
"(",
"\"\"",
")",
")",
";",
"}",
")",
";",
"}",
")",
";",
"return",
"lines",
".",
"join",
"(",
"\"\\n\\n\"",
")",
";",
"}"
] | Render parse tree as string. | [
"Render",
"parse",
"tree",
"as",
"string",
"."
] | dffbe22a4a672f262e4c9151edf75fa7e077b8f4 | https://github.com/rsdoiel/stn/blob/dffbe22a4a672f262e4c9151edf75fa7e077b8f4/stn.js#L365-L409 |
|
57,797 | Aratramba/text-file-register | index.js | addFiles | function addFiles(pattern, cb){
glob(pattern, function(err, files){
if(err) throw err;
async.each(files, readFile, function(err){
if(err) throw err;
if(cb) cb();
});
});
} | javascript | function addFiles(pattern, cb){
glob(pattern, function(err, files){
if(err) throw err;
async.each(files, readFile, function(err){
if(err) throw err;
if(cb) cb();
});
});
} | [
"function",
"addFiles",
"(",
"pattern",
",",
"cb",
")",
"{",
"glob",
"(",
"pattern",
",",
"function",
"(",
"err",
",",
"files",
")",
"{",
"if",
"(",
"err",
")",
"throw",
"err",
";",
"async",
".",
"each",
"(",
"files",
",",
"readFile",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"throw",
"err",
";",
"if",
"(",
"cb",
")",
"cb",
"(",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}"
] | Add files to register | [
"Add",
"files",
"to",
"register"
] | 061249f90b08a300ec3647db167957d27a51ccdd | https://github.com/Aratramba/text-file-register/blob/061249f90b08a300ec3647db167957d27a51ccdd/index.js#L32-L41 |
57,798 | camshaft/anvil-cli | lib/local.js | find | function find(source, fn) {
glob('**', {cwd: source, dot: true}, function(err, files) {
fn(err, files);
});
} | javascript | function find(source, fn) {
glob('**', {cwd: source, dot: true}, function(err, files) {
fn(err, files);
});
} | [
"function",
"find",
"(",
"source",
",",
"fn",
")",
"{",
"glob",
"(",
"'**'",
",",
"{",
"cwd",
":",
"source",
",",
"dot",
":",
"true",
"}",
",",
"function",
"(",
"err",
",",
"files",
")",
"{",
"fn",
"(",
"err",
",",
"files",
")",
";",
"}",
")",
";",
"}"
] | Glob source dir
@param {String} source
@param {Function} fn | [
"Glob",
"source",
"dir"
] | 5930e2165698c5577a0bcfa471dd521089acfb78 | https://github.com/camshaft/anvil-cli/blob/5930e2165698c5577a0bcfa471dd521089acfb78/lib/local.js#L106-L110 |
57,799 | camshaft/anvil-cli | lib/local.js | filterIgnored | function filterIgnored(files, ignore, fn) {
fn(null, files.filter(function(file) {
// TODO make more robust
return !~ignore.indexOf(file) && !~ignore.indexOf(file + '/');
}));
} | javascript | function filterIgnored(files, ignore, fn) {
fn(null, files.filter(function(file) {
// TODO make more robust
return !~ignore.indexOf(file) && !~ignore.indexOf(file + '/');
}));
} | [
"function",
"filterIgnored",
"(",
"files",
",",
"ignore",
",",
"fn",
")",
"{",
"fn",
"(",
"null",
",",
"files",
".",
"filter",
"(",
"function",
"(",
"file",
")",
"{",
"// TODO make more robust",
"return",
"!",
"~",
"ignore",
".",
"indexOf",
"(",
"file",
")",
"&&",
"!",
"~",
"ignore",
".",
"indexOf",
"(",
"file",
"+",
"'/'",
")",
";",
"}",
")",
")",
";",
"}"
] | Filter ignored files
@param {Array} files
@param {Array} ignore | [
"Filter",
"ignored",
"files"
] | 5930e2165698c5577a0bcfa471dd521089acfb78 | https://github.com/camshaft/anvil-cli/blob/5930e2165698c5577a0bcfa471dd521089acfb78/lib/local.js#L132-L137 |