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 list | docstring stringlengths 4 11.8k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 86 226 |
|---|---|---|---|---|---|---|---|---|---|---|---|
29,300 | cdapio/ui-schema-parser | lib/schemas.js | parse | function parse(str, opts) {
var parser = new Parser(str, opts);
return {attrs: parser._readProtocol(), imports: parser._imports};
} | javascript | function parse(str, opts) {
var parser = new Parser(str, opts);
return {attrs: parser._readProtocol(), imports: parser._imports};
} | [
"function",
"parse",
"(",
"str",
",",
"opts",
")",
"{",
"var",
"parser",
"=",
"new",
"Parser",
"(",
"str",
",",
"opts",
")",
";",
"return",
"{",
"attrs",
":",
"parser",
".",
"_readProtocol",
"(",
")",
",",
"imports",
":",
"parser",
".",
"_imports",
... | Parse an IDL into attributes.
Not to be confused with `avro.parse` which parses attributes into types. | [
"Parse",
"an",
"IDL",
"into",
"attributes",
"."
] | 7fa333e0fe1208de6adc17e597ec847f5ae84124 | https://github.com/cdapio/ui-schema-parser/blob/7fa333e0fe1208de6adc17e597ec847f5ae84124/lib/schemas.js#L150-L153 |
29,301 | cdapio/ui-schema-parser | lib/schemas.js | Tokenizer | function Tokenizer(str) {
this._str = str;
this._pos = 0;
this._queue = new BoundedQueue(3); // Bounded queue of last emitted tokens.
this._token = undefined; // Current token.
this._doc = undefined; // Javadoc.
} | javascript | function Tokenizer(str) {
this._str = str;
this._pos = 0;
this._queue = new BoundedQueue(3); // Bounded queue of last emitted tokens.
this._token = undefined; // Current token.
this._doc = undefined; // Javadoc.
} | [
"function",
"Tokenizer",
"(",
"str",
")",
"{",
"this",
".",
"_str",
"=",
"str",
";",
"this",
".",
"_pos",
"=",
"0",
";",
"this",
".",
"_queue",
"=",
"new",
"BoundedQueue",
"(",
"3",
")",
";",
"// Bounded queue of last emitted tokens.",
"this",
".",
"_tok... | Helpers.
Simple class to split an input string into tokens.
There are different types of tokens, characterized by their `id`:
+ `number` numbers.
+ `name` references.
+ `string` double-quoted.
+ `operator`, anything else, always single character.
+ `json`, special, must be asked for (the tokenizer doesn't have enough
context to predict these).
This tokenizer also handles Javadoc extraction, via the `addJavadoc` method. | [
"Helpers",
".",
"Simple",
"class",
"to",
"split",
"an",
"input",
"string",
"into",
"tokens",
"."
] | 7fa333e0fe1208de6adc17e597ec847f5ae84124 | https://github.com/cdapio/ui-schema-parser/blob/7fa333e0fe1208de6adc17e597ec847f5ae84124/lib/schemas.js#L172-L178 |
29,302 | cdapio/ui-schema-parser | lib/schemas.js | Parser | function Parser(str, opts) {
this._oneWayVoid = !!(opts && opts.oneWayVoid);
this._reassignJavadoc = !!(opts && opts.reassignJavadoc);
this._imports = [];
this._tk = new Tokenizer(str);
this._tk.next(); // Prime tokenizer.
} | javascript | function Parser(str, opts) {
this._oneWayVoid = !!(opts && opts.oneWayVoid);
this._reassignJavadoc = !!(opts && opts.reassignJavadoc);
this._imports = [];
this._tk = new Tokenizer(str);
this._tk.next(); // Prime tokenizer.
} | [
"function",
"Parser",
"(",
"str",
",",
"opts",
")",
"{",
"this",
".",
"_oneWayVoid",
"=",
"!",
"!",
"(",
"opts",
"&&",
"opts",
".",
"oneWayVoid",
")",
";",
"this",
".",
"_reassignJavadoc",
"=",
"!",
"!",
"(",
"opts",
"&&",
"opts",
".",
"reassignJavad... | Parser from tokens to attributes. | [
"Parser",
"from",
"tokens",
"to",
"attributes",
"."
] | 7fa333e0fe1208de6adc17e597ec847f5ae84124 | https://github.com/cdapio/ui-schema-parser/blob/7fa333e0fe1208de6adc17e597ec847f5ae84124/lib/schemas.js#L359-L365 |
29,303 | cdapio/ui-schema-parser | lib/schemas.js | reassignJavadoc | function reassignJavadoc(from, to) {
if (!(from.doc instanceof Javadoc)) {
// Nothing to transfer.
return from;
}
to.doc = from.doc;
delete from.doc;
return Object.keys(from).length === 1 ? from.type : from;
} | javascript | function reassignJavadoc(from, to) {
if (!(from.doc instanceof Javadoc)) {
// Nothing to transfer.
return from;
}
to.doc = from.doc;
delete from.doc;
return Object.keys(from).length === 1 ? from.type : from;
} | [
"function",
"reassignJavadoc",
"(",
"from",
",",
"to",
")",
"{",
"if",
"(",
"!",
"(",
"from",
".",
"doc",
"instanceof",
"Javadoc",
")",
")",
"{",
"// Nothing to transfer.",
"return",
"from",
";",
"}",
"to",
".",
"doc",
"=",
"from",
".",
"doc",
";",
"... | Transfer a key from an object to another and return the new source.
If the source becomes an object with a single type attribute set, its `type`
attribute is returned instead. | [
"Transfer",
"a",
"key",
"from",
"an",
"object",
"to",
"another",
"and",
"return",
"the",
"new",
"source",
"."
] | 7fa333e0fe1208de6adc17e597ec847f5ae84124 | https://github.com/cdapio/ui-schema-parser/blob/7fa333e0fe1208de6adc17e597ec847f5ae84124/lib/schemas.js#L685-L693 |
29,304 | bitnami/nami-utils | lib/file/xml/get.js | xmlFileGet | function xmlFileGet(file, element, attributeName, options) {
options = _.sanitize(options, {encoding: 'utf-8', retryOnENOENT: true, default: null});
const doc = loadXmlFile(file, options);
const node = getXmlNode(doc, element);
let value;
if (_.isEmpty(attributeName)) {
value = _.map(node.childNodes, 'nodeValue');
} else {
value = node.getAttribute(attributeName);
// Always return an array
value = [value];
}
return _.isUndefined(value) ? options.default : value;
} | javascript | function xmlFileGet(file, element, attributeName, options) {
options = _.sanitize(options, {encoding: 'utf-8', retryOnENOENT: true, default: null});
const doc = loadXmlFile(file, options);
const node = getXmlNode(doc, element);
let value;
if (_.isEmpty(attributeName)) {
value = _.map(node.childNodes, 'nodeValue');
} else {
value = node.getAttribute(attributeName);
// Always return an array
value = [value];
}
return _.isUndefined(value) ? options.default : value;
} | [
"function",
"xmlFileGet",
"(",
"file",
",",
"element",
",",
"attributeName",
",",
"options",
")",
"{",
"options",
"=",
"_",
".",
"sanitize",
"(",
"options",
",",
"{",
"encoding",
":",
"'utf-8'",
",",
"retryOnENOENT",
":",
"true",
",",
"default",
":",
"nu... | Get value from XML file
@function $file~xml/get
@param {string} file - XML File to read the value from
@param {string} element - XPath expression to the element from which to read the attribute (null if text node)
@param {string} attribute - Attribute to get the value from (if empty, will return the text of the node element)
@param {Object} [options]
@param {string} [options.encoding=utf-8] - Encoding used to read the file
@param {string} [options.default=''] - Default value if key not found
@throws Will throw an error if the path is not a file
@throws Will throw an error if the XPath is not valid
@throws Will throw an error if the XPath is not found
@example
// Get 'charset' atribute of node //html/head/meta
$file.ini.get('index.html', '//html/head/meta', 'charset');
// => 'UTF-8' | [
"Get",
"value",
"from",
"XML",
"file"
] | 1b34424b6cb93593db7ba2c238dbfe301ab9defc | https://github.com/bitnami/nami-utils/blob/1b34424b6cb93593db7ba2c238dbfe301ab9defc/lib/file/xml/get.js#L25-L40 |
29,305 | bitnami/nami-utils | lib/file/exists.js | exists | function exists(file) {
try {
fs.lstatSync(file);
return true;
} catch (e) {
if (e.code === 'ENOENT' || e.code === 'ENOTDIR') {
return false;
} else {
throw e;
}
}
} | javascript | function exists(file) {
try {
fs.lstatSync(file);
return true;
} catch (e) {
if (e.code === 'ENOENT' || e.code === 'ENOTDIR') {
return false;
} else {
throw e;
}
}
} | [
"function",
"exists",
"(",
"file",
")",
"{",
"try",
"{",
"fs",
".",
"lstatSync",
"(",
"file",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"if",
"(",
"e",
".",
"code",
"===",
"'ENOENT'",
"||",
"e",
".",
"code",
"===",
"'EN... | Check whether a file exists or not
@memberof $file
@param {string} file
@returns {boolean}
@example
// Check if file exists
$file.exists('/opt/bitnami/properties.ini')
// => true | [
"Check",
"whether",
"a",
"file",
"exists",
"or",
"not"
] | 1b34424b6cb93593db7ba2c238dbfe301ab9defc | https://github.com/bitnami/nami-utils/blob/1b34424b6cb93593db7ba2c238dbfe301ab9defc/lib/file/exists.js#L15-L26 |
29,306 | zetapush/zetapush | packages/cometd/lib/browser/Transports.js | getOverloadedConfigFromEnvironment | function getOverloadedConfigFromEnvironment() {
var env = typeof document === 'undefined' ? {} : document.documentElement.dataset;
var platformUrl = env.zpPlatformUrl;
var appName = env.zpSandboxid;
return {
platformUrl: platformUrl,
appName: appName
};
} | javascript | function getOverloadedConfigFromEnvironment() {
var env = typeof document === 'undefined' ? {} : document.documentElement.dataset;
var platformUrl = env.zpPlatformUrl;
var appName = env.zpSandboxid;
return {
platformUrl: platformUrl,
appName: appName
};
} | [
"function",
"getOverloadedConfigFromEnvironment",
"(",
")",
"{",
"var",
"env",
"=",
"typeof",
"document",
"===",
"'undefined'",
"?",
"{",
"}",
":",
"document",
".",
"documentElement",
".",
"dataset",
";",
"var",
"platformUrl",
"=",
"env",
".",
"zpPlatformUrl",
... | Get overloaded config from environment | [
"Get",
"overloaded",
"config",
"from",
"environment"
] | ad3383b8e332050eaecd55be9bdff6cf76db699e | https://github.com/zetapush/zetapush/blob/ad3383b8e332050eaecd55be9bdff6cf76db699e/packages/cometd/lib/browser/Transports.js#L56-L64 |
29,307 | ArnaudBuchholz/gpf-js | lost+found/src/attributes.js | _gpfDefAttr | function _gpfDefAttr (name, base, definition) {
var
isAlias = name.charAt(0) === "$",
fullName,
result;
if (isAlias) {
name = name.substr(1);
fullName = name + "Attribute";
} else {
fullName = name;
}
result = _gpfDefAttrBase(fullName, base, definition);
if (isAlias) {
_gpfAlias(result, name);
}
return result;
} | javascript | function _gpfDefAttr (name, base, definition) {
var
isAlias = name.charAt(0) === "$",
fullName,
result;
if (isAlias) {
name = name.substr(1);
fullName = name + "Attribute";
} else {
fullName = name;
}
result = _gpfDefAttrBase(fullName, base, definition);
if (isAlias) {
_gpfAlias(result, name);
}
return result;
} | [
"function",
"_gpfDefAttr",
"(",
"name",
",",
"base",
",",
"definition",
")",
"{",
"var",
"isAlias",
"=",
"name",
".",
"charAt",
"(",
"0",
")",
"===",
"\"$\"",
",",
"fullName",
",",
"result",
";",
"if",
"(",
"isAlias",
")",
"{",
"name",
"=",
"name",
... | gpf.define for attributes
@param {String} name Attribute name. If it contains a dot, it is treated as absolute contextual.
Otherwise, it is relative to "gpf.attributes". If starting with $ (and no dot), the contextual name will be the
"gpf.attributes." + name(without $) + "Attribute" and an alias is automatically created
@param {Function|string} [base=undefined] base Base attribute (or contextual name)
@param {Object} [definition=undefined] definition Attribute definition
@return {Function} | [
"gpf",
".",
"define",
"for",
"attributes"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/attributes.js#L81-L97 |
29,308 | ArnaudBuchholz/gpf-js | lost+found/src/attributes.js | function (expectedClass) {
_gpfAssertAttributeClassOnly(expectedClass);
var result = new _gpfA.Array();
result._array = this._array.filter(function (attribute) {
return attribute instanceof expectedClass;
});
return result;
} | javascript | function (expectedClass) {
_gpfAssertAttributeClassOnly(expectedClass);
var result = new _gpfA.Array();
result._array = this._array.filter(function (attribute) {
return attribute instanceof expectedClass;
});
return result;
} | [
"function",
"(",
"expectedClass",
")",
"{",
"_gpfAssertAttributeClassOnly",
"(",
"expectedClass",
")",
";",
"var",
"result",
"=",
"new",
"_gpfA",
".",
"Array",
"(",
")",
";",
"result",
".",
"_array",
"=",
"this",
".",
"_array",
".",
"filter",
"(",
"functio... | Returns a new array with all attributes matching the expected class
@param {Function} expectedClass the class to match
@return {gpf.attributes.Array} | [
"Returns",
"a",
"new",
"array",
"with",
"all",
"attributes",
"matching",
"the",
"expected",
"class"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/attributes.js#L206-L213 | |
29,309 | ArnaudBuchholz/gpf-js | lost+found/src/attributes.js | function (to, callback, param) {
_gpfObjectForEach(this._members, function (attributeArray, member) {
member = _gpfDecodeAttributeMember(member);
attributeArray._array.forEach(function (attribute) {
if (!callback || callback(member, attribute, param)) {
to.add(member, attribute);
}
});
});
return to;
} | javascript | function (to, callback, param) {
_gpfObjectForEach(this._members, function (attributeArray, member) {
member = _gpfDecodeAttributeMember(member);
attributeArray._array.forEach(function (attribute) {
if (!callback || callback(member, attribute, param)) {
to.add(member, attribute);
}
});
});
return to;
} | [
"function",
"(",
"to",
",",
"callback",
",",
"param",
")",
"{",
"_gpfObjectForEach",
"(",
"this",
".",
"_members",
",",
"function",
"(",
"attributeArray",
",",
"member",
")",
"{",
"member",
"=",
"_gpfDecodeAttributeMember",
"(",
"member",
")",
";",
"attribut... | Copy the content of this map to a new one
@param {gpf.attributes.Map} to recipient of the copy
@param {Function} [callback=undefined] callback function to test if the mapping should be added
@param {*} [param=undefined] param additional parameter for the callback
@return {gpf.attributes.Map} to | [
"Copy",
"the",
"content",
"of",
"this",
"map",
"to",
"a",
"new",
"one"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/attributes.js#L257-L267 | |
29,310 | ArnaudBuchholz/gpf-js | lost+found/src/attributes.js | function (classDef) {
var attributes,
Super;
while (classDef) { // !undefined && !null
attributes = classDef._attributes;
if (attributes) {
attributes._copy(this);
}
Super = classDef._Super;
if (Super === Object) { // Can't go upper
break;
} else {
classDef = _gpfGetClassDefinition(Super);
}
}
return this;
} | javascript | function (classDef) {
var attributes,
Super;
while (classDef) { // !undefined && !null
attributes = classDef._attributes;
if (attributes) {
attributes._copy(this);
}
Super = classDef._Super;
if (Super === Object) { // Can't go upper
break;
} else {
classDef = _gpfGetClassDefinition(Super);
}
}
return this;
} | [
"function",
"(",
"classDef",
")",
"{",
"var",
"attributes",
",",
"Super",
";",
"while",
"(",
"classDef",
")",
"{",
"// !undefined && !null",
"attributes",
"=",
"classDef",
".",
"_attributes",
";",
"if",
"(",
"attributes",
")",
"{",
"attributes",
".",
"_copy"... | Fill the map using class definition object
@param {gpf.classDef} classDef class definition
@gpf:chainable | [
"Fill",
"the",
"map",
"using",
"class",
"definition",
"object"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/attributes.js#L301-L317 | |
29,311 | ArnaudBuchholz/gpf-js | lost+found/src/attributes.js | function (member, attribute) {
_gpfAssertAttributeOnly(attribute);
member = _gpfEncodeAttributeMember(member);
var array = this._members[member];
if (undefined === array) {
array = this._members[member] = new _gpfA.Array();
}
array._array.push(attribute);
++this._count;
} | javascript | function (member, attribute) {
_gpfAssertAttributeOnly(attribute);
member = _gpfEncodeAttributeMember(member);
var array = this._members[member];
if (undefined === array) {
array = this._members[member] = new _gpfA.Array();
}
array._array.push(attribute);
++this._count;
} | [
"function",
"(",
"member",
",",
"attribute",
")",
"{",
"_gpfAssertAttributeOnly",
"(",
"attribute",
")",
";",
"member",
"=",
"_gpfEncodeAttributeMember",
"(",
"member",
")",
";",
"var",
"array",
"=",
"this",
".",
"_members",
"[",
"member",
"]",
";",
"if",
... | Associate an attribute to a member
@param {String} member member name
@param {gpf.attributes.Attribute} attribute attribute to map | [
"Associate",
"an",
"attribute",
"to",
"a",
"member"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/attributes.js#L340-L349 | |
29,312 | ArnaudBuchholz/gpf-js | lost+found/src/attributes.js | function (member) {
member = _gpfEncodeAttributeMember(member);
var result = this._members[member];
if (undefined === result || !(result instanceof _gpfA.Array)) {
return _gpfEmptyMemberArray;
}
return result;
} | javascript | function (member) {
member = _gpfEncodeAttributeMember(member);
var result = this._members[member];
if (undefined === result || !(result instanceof _gpfA.Array)) {
return _gpfEmptyMemberArray;
}
return result;
} | [
"function",
"(",
"member",
")",
"{",
"member",
"=",
"_gpfEncodeAttributeMember",
"(",
"member",
")",
";",
"var",
"result",
"=",
"this",
".",
"_members",
"[",
"member",
"]",
";",
"if",
"(",
"undefined",
"===",
"result",
"||",
"!",
"(",
"result",
"instance... | Returns the array of attributes associated to a member
@param {String} member
@return {gpf.attributes.Array} | [
"Returns",
"the",
"array",
"of",
"attributes",
"associated",
"to",
"a",
"member"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/attributes.js#L369-L376 | |
29,313 | ArnaudBuchholz/gpf-js | lost+found/src/attributes.js | function () {
var result = [];
_gpfObjectForEach(this._members, function (attributes, member) {
_gpfIgnore(attributes);
result.push(_gpfDecodeAttributeMember(member));
});
return result;
} | javascript | function () {
var result = [];
_gpfObjectForEach(this._members, function (attributes, member) {
_gpfIgnore(attributes);
result.push(_gpfDecodeAttributeMember(member));
});
return result;
} | [
"function",
"(",
")",
"{",
"var",
"result",
"=",
"[",
"]",
";",
"_gpfObjectForEach",
"(",
"this",
".",
"_members",
",",
"function",
"(",
"attributes",
",",
"member",
")",
"{",
"_gpfIgnore",
"(",
"attributes",
")",
";",
"result",
".",
"push",
"(",
"_gpf... | Returns the list of members stored in this map
@return {String[]} | [
"Returns",
"the",
"list",
"of",
"members",
"stored",
"in",
"this",
"map"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/attributes.js#L383-L390 | |
29,314 | edertone/TurboCommons | TurboCommons-Java/.turboBuilder/Utils.js | loadFileAsString | function loadFileAsString(path, replaceWhiteSpaces){
var file = new java.io.File(path);
var fr = new java.io.FileReader(file);
var br = new java.io.BufferedReader(fr);
var line;
var lines = "";
while((line = br.readLine()) != null){
if(replaceWhiteSpaces){
lines = lines + line.replace(" ", "");
}else{
lines = lines + line;
}
}
return lines;
} | javascript | function loadFileAsString(path, replaceWhiteSpaces){
var file = new java.io.File(path);
var fr = new java.io.FileReader(file);
var br = new java.io.BufferedReader(fr);
var line;
var lines = "";
while((line = br.readLine()) != null){
if(replaceWhiteSpaces){
lines = lines + line.replace(" ", "");
}else{
lines = lines + line;
}
}
return lines;
} | [
"function",
"loadFileAsString",
"(",
"path",
",",
"replaceWhiteSpaces",
")",
"{",
"var",
"file",
"=",
"new",
"java",
".",
"io",
".",
"File",
"(",
"path",
")",
";",
"var",
"fr",
"=",
"new",
"java",
".",
"io",
".",
"FileReader",
"(",
"file",
")",
";",
... | Utility methods used by TurboBuilder
Load all the file contents and return it as a string | [
"Utility",
"methods",
"used",
"by",
"TurboBuilder",
"Load",
"all",
"the",
"file",
"contents",
"and",
"return",
"it",
"as",
"a",
"string"
] | 275d4971ec19d8632b92ac466d9ce5b7db50acfa | https://github.com/edertone/TurboCommons/blob/275d4971ec19d8632b92ac466d9ce5b7db50acfa/TurboCommons-Java/.turboBuilder/Utils.js#L11-L33 |
29,315 | edertone/TurboCommons | TurboCommons-Java/.turboBuilder/Utils.js | getFilesList | function getFilesList(path, includes, excludes){
// Init default vars values
includes = (includes === undefined || includes == null || includes == '') ? "**" : includes;
excludes = (excludes === undefined || excludes == null || excludes == '') ? "" : excludes;
var fs = project.createDataType("fileset");
fs.setDir(new java.io.File(path));
if(includes != ""){
fs.setIncludes(includes);
}
if(excludes != ""){
fs.setExcludes(excludes);
}
var srcFiles = fs.getDirectoryScanner(project).getIncludedFiles();
var result = [];
for (var i = 0; i<srcFiles.length; i++){
result.push(srcFiles[i]);
}
return result;
} | javascript | function getFilesList(path, includes, excludes){
// Init default vars values
includes = (includes === undefined || includes == null || includes == '') ? "**" : includes;
excludes = (excludes === undefined || excludes == null || excludes == '') ? "" : excludes;
var fs = project.createDataType("fileset");
fs.setDir(new java.io.File(path));
if(includes != ""){
fs.setIncludes(includes);
}
if(excludes != ""){
fs.setExcludes(excludes);
}
var srcFiles = fs.getDirectoryScanner(project).getIncludedFiles();
var result = [];
for (var i = 0; i<srcFiles.length; i++){
result.push(srcFiles[i]);
}
return result;
} | [
"function",
"getFilesList",
"(",
"path",
",",
"includes",
",",
"excludes",
")",
"{",
"// Init default vars values\r",
"includes",
"=",
"(",
"includes",
"===",
"undefined",
"||",
"includes",
"==",
"null",
"||",
"includes",
"==",
"''",
")",
"?",
"\"**\"",
":",
... | Get a list with all the files inside the specified path and all of its subfolders.
@param path A full file system path from which we want to get the list of files
@param includes comma- or space-separated list of patterns of files that must be included; all files are included when omitted.
@param excludes comma- or space-separated list of patterns of files that must be excluded; no files (except default excludes) are excluded when omitted.
@returns An array containing all the matching files inside the given path and subfolders. Each array element will be
the full filename plus the relative path to the provided path. For example, if we provide "src/main" as path,
resulting files may be like "php/managers/BigManager.php", ... and so. | [
"Get",
"a",
"list",
"with",
"all",
"the",
"files",
"inside",
"the",
"specified",
"path",
"and",
"all",
"of",
"its",
"subfolders",
"."
] | 275d4971ec19d8632b92ac466d9ce5b7db50acfa | https://github.com/edertone/TurboCommons/blob/275d4971ec19d8632b92ac466d9ce5b7db50acfa/TurboCommons-Java/.turboBuilder/Utils.js#L47-L77 |
29,316 | edertone/TurboCommons | TurboCommons-Java/.turboBuilder/Utils.js | echoWarningsAndErrors | function echoWarningsAndErrors(antWarnings, antErrors){
//Define the echo task to use for warnings and errors
var echo = project.createTask("echo");
var error = new org.apache.tools.ant.taskdefs.Echo.EchoLevel();
error.setValue("error");
echo.setLevel(error);
//Display all the detected warnings
for(var i = 0; i < antWarnings.length; i++){
echo.setMessage("WARNING: " + antWarnings[i]);
echo.perform();
}
//Display all the detected errors
for(i = 0; i < antErrors.length; i++){
echo.setMessage("ERROR: " + antErrors[i]);
echo.perform();
}
//Set a failure to the ant build if errors are present
if(antErrors.length > 0){
project.setProperty("javascript.fail.message", "Source analisis detected errors.");
}
} | javascript | function echoWarningsAndErrors(antWarnings, antErrors){
//Define the echo task to use for warnings and errors
var echo = project.createTask("echo");
var error = new org.apache.tools.ant.taskdefs.Echo.EchoLevel();
error.setValue("error");
echo.setLevel(error);
//Display all the detected warnings
for(var i = 0; i < antWarnings.length; i++){
echo.setMessage("WARNING: " + antWarnings[i]);
echo.perform();
}
//Display all the detected errors
for(i = 0; i < antErrors.length; i++){
echo.setMessage("ERROR: " + antErrors[i]);
echo.perform();
}
//Set a failure to the ant build if errors are present
if(antErrors.length > 0){
project.setProperty("javascript.fail.message", "Source analisis detected errors.");
}
} | [
"function",
"echoWarningsAndErrors",
"(",
"antWarnings",
",",
"antErrors",
")",
"{",
"//Define the echo task to use for warnings and errors\r",
"var",
"echo",
"=",
"project",
".",
"createTask",
"(",
"\"echo\"",
")",
";",
"var",
"error",
"=",
"new",
"org",
".",
"apac... | Output to ant console the warnings and errors if exist | [
"Output",
"to",
"ant",
"console",
"the",
"warnings",
"and",
"errors",
"if",
"exist"
] | 275d4971ec19d8632b92ac466d9ce5b7db50acfa | https://github.com/edertone/TurboCommons/blob/275d4971ec19d8632b92ac466d9ce5b7db50acfa/TurboCommons-Java/.turboBuilder/Utils.js#L83-L110 |
29,317 | jslicense/spdx-satisfies.js | index.js | flatten | function flatten (expression) {
const expanded = Array.from(expandInner(expression))
const flattened = expanded.reduce(function (result, clause) {
return Object.assign(result, clause)
}, {})
return sort([flattened])[0]
} | javascript | function flatten (expression) {
const expanded = Array.from(expandInner(expression))
const flattened = expanded.reduce(function (result, clause) {
return Object.assign(result, clause)
}, {})
return sort([flattened])[0]
} | [
"function",
"flatten",
"(",
"expression",
")",
"{",
"const",
"expanded",
"=",
"Array",
".",
"from",
"(",
"expandInner",
"(",
"expression",
")",
")",
"const",
"flattened",
"=",
"expanded",
".",
"reduce",
"(",
"function",
"(",
"result",
",",
"clause",
")",
... | Flatten the given expression into an array of all licenses mentioned in the expression. | [
"Flatten",
"the",
"given",
"expression",
"into",
"an",
"array",
"of",
"all",
"licenses",
"mentioned",
"in",
"the",
"expression",
"."
] | a4d27d9711a333fecda4c9b83f0d549eb06d5dfc | https://github.com/jslicense/spdx-satisfies.js/blob/a4d27d9711a333fecda4c9b83f0d549eb06d5dfc/index.js#L96-L102 |
29,318 | ArnaudBuchholz/gpf-js | src/factory.js | _gpfNewApply | function _gpfNewApply (Constructor, parameters) {
if (parameters.length > _gpfGenericFactory.length) {
_gpfGenericFactory = _gpfGenerateGenericFactory(parameters.length);
}
return _gpfGenericFactory.apply(Constructor, parameters);
} | javascript | function _gpfNewApply (Constructor, parameters) {
if (parameters.length > _gpfGenericFactory.length) {
_gpfGenericFactory = _gpfGenerateGenericFactory(parameters.length);
}
return _gpfGenericFactory.apply(Constructor, parameters);
} | [
"function",
"_gpfNewApply",
"(",
"Constructor",
",",
"parameters",
")",
"{",
"if",
"(",
"parameters",
".",
"length",
">",
"_gpfGenericFactory",
".",
"length",
")",
"{",
"_gpfGenericFactory",
"=",
"_gpfGenerateGenericFactory",
"(",
"parameters",
".",
"length",
")",... | Call a constructor with an array of parameters.
It is impossible to mix [new](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new)
and [apply](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply)
in the same call.
This helper workarounds this problem.
@param {Function} Constructor Class constructor
@param {Array} parameters Parameters to pass to the constructor
@return {Object} New object
@since 0.1.5 | [
"Call",
"a",
"constructor",
"with",
"an",
"array",
"of",
"parameters",
"."
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/factory.js#L70-L75 |
29,319 | ArnaudBuchholz/gpf-js | src/error.js | function (context) {
var replacements;
if (context) {
replacements = {};
_gpfObjectForEach(context, function (value, key) {
replacements["{" + key + "}"] = value.toString();
});
this.message = _gpfStringReplaceEx(this.message, replacements);
}
} | javascript | function (context) {
var replacements;
if (context) {
replacements = {};
_gpfObjectForEach(context, function (value, key) {
replacements["{" + key + "}"] = value.toString();
});
this.message = _gpfStringReplaceEx(this.message, replacements);
}
} | [
"function",
"(",
"context",
")",
"{",
"var",
"replacements",
";",
"if",
"(",
"context",
")",
"{",
"replacements",
"=",
"{",
"}",
";",
"_gpfObjectForEach",
"(",
"context",
",",
"function",
"(",
"value",
",",
"key",
")",
"{",
"replacements",
"[",
"\"{\"",
... | Build message by substituting context variables
@param {Object} context Dictionary of named keys
@since 0.1.5 | [
"Build",
"message",
"by",
"substituting",
"context",
"variables"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/error.js#L59-L68 | |
29,320 | ArnaudBuchholz/gpf-js | src/error.js | _gpfGenenerateErrorFunction | function _gpfGenenerateErrorFunction (code, name, message) {
var result = _gpfErrorFactory(code, name, message);
result.CODE = code;
result.NAME = name;
result.MESSAGE = message;
return result;
} | javascript | function _gpfGenenerateErrorFunction (code, name, message) {
var result = _gpfErrorFactory(code, name, message);
result.CODE = code;
result.NAME = name;
result.MESSAGE = message;
return result;
} | [
"function",
"_gpfGenenerateErrorFunction",
"(",
"code",
",",
"name",
",",
"message",
")",
"{",
"var",
"result",
"=",
"_gpfErrorFactory",
"(",
"code",
",",
"name",
",",
"message",
")",
";",
"result",
".",
"CODE",
"=",
"code",
";",
"result",
".",
"NAME",
"... | Generates an error class
@param {Number} code Error code
@param {String} name Error name
@param {String} message Error message
@return {Function} New error class
@gpf:closure
@since 0.1.5 | [
"Generates",
"an",
"error",
"class"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/error.js#L103-L109 |
29,321 | ArnaudBuchholz/gpf-js | src/error.js | _gpfErrorDeclare | function _gpfErrorDeclare (source, dictionary) {
_gpfIgnore(source);
_gpfObjectForEach(dictionary, function (message, name) {
var code = ++_gpfLastErrorCode;
gpf.Error["CODE_" + name.toUpperCase()] = code;
gpf.Error[name] = _gpfGenenerateErrorFunction(code, name, message);
});
} | javascript | function _gpfErrorDeclare (source, dictionary) {
_gpfIgnore(source);
_gpfObjectForEach(dictionary, function (message, name) {
var code = ++_gpfLastErrorCode;
gpf.Error["CODE_" + name.toUpperCase()] = code;
gpf.Error[name] = _gpfGenenerateErrorFunction(code, name, message);
});
} | [
"function",
"_gpfErrorDeclare",
"(",
"source",
",",
"dictionary",
")",
"{",
"_gpfIgnore",
"(",
"source",
")",
";",
"_gpfObjectForEach",
"(",
"dictionary",
",",
"function",
"(",
"message",
",",
"name",
")",
"{",
"var",
"code",
"=",
"++",
"_gpfLastErrorCode",
... | Declare error messages.
Each source declares its own errors.
@param {String} source Source name
@param {Object} dictionary Dictionary of error name to message
@since 0.1.5 | [
"Declare",
"error",
"messages",
".",
"Each",
"source",
"declares",
"its",
"own",
"errors",
"."
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/error.js#L122-L129 |
29,322 | Esri/terraformer-geostore | src/helpers/browser/eventemitter.js | EventEmitter | function EventEmitter() {
this._events = { };
this._once = { };
// default to 10 max liseners
this._maxListeners = 10;
this._add = function (event, listener, once) {
var entry = { listener: listener };
if (once) {
entry.once = true;
}
if (this._events[event]) {
this._events[event].push(entry);
} else {
this._events[event] = [ entry ];
}
if (this._maxListeners && this._events[event].count > this._maxListeners && console && console.warn) {
console.warn("EventEmitter Error: Maximum number of listeners");
}
return this;
};
this.on = function (event, listener) {
return this._add(event, listener);
};
this.addListener = this.on;
this.once = function (event, listener) {
return this._add(event, listener, true);
};
this.removeListener = function (event, listener) {
if (!this._events[event]) {
return this;
}
for(var i = this._events.length-1; i--;) {
if (this._events[i].listener === callback) {
this._events.splice(i, 1);
}
}
return this;
};
this.removeAllListeners = function (event) {
this._events[event] = undefined;
return this;
};
this.setMaxListeners = function (count) {
this._maxListeners = count;
return this;
};
this.emit = function () {
var args = Array.prototype.slice.apply(arguments);
var remove = [ ], i;
if (args.length) {
var event = args.shift();
if (this._events[event]) {
for (i = this._events[event].length; i--;) {
this._events[event][i].listener.apply(null, args);
if (this._events[event][i].once) {
remove.push(listener);
}
}
}
for (i = remove.length; i--;) {
this.removeListener(event, remove[i]);
}
}
return this;
};
} | javascript | function EventEmitter() {
this._events = { };
this._once = { };
// default to 10 max liseners
this._maxListeners = 10;
this._add = function (event, listener, once) {
var entry = { listener: listener };
if (once) {
entry.once = true;
}
if (this._events[event]) {
this._events[event].push(entry);
} else {
this._events[event] = [ entry ];
}
if (this._maxListeners && this._events[event].count > this._maxListeners && console && console.warn) {
console.warn("EventEmitter Error: Maximum number of listeners");
}
return this;
};
this.on = function (event, listener) {
return this._add(event, listener);
};
this.addListener = this.on;
this.once = function (event, listener) {
return this._add(event, listener, true);
};
this.removeListener = function (event, listener) {
if (!this._events[event]) {
return this;
}
for(var i = this._events.length-1; i--;) {
if (this._events[i].listener === callback) {
this._events.splice(i, 1);
}
}
return this;
};
this.removeAllListeners = function (event) {
this._events[event] = undefined;
return this;
};
this.setMaxListeners = function (count) {
this._maxListeners = count;
return this;
};
this.emit = function () {
var args = Array.prototype.slice.apply(arguments);
var remove = [ ], i;
if (args.length) {
var event = args.shift();
if (this._events[event]) {
for (i = this._events[event].length; i--;) {
this._events[event][i].listener.apply(null, args);
if (this._events[event][i].once) {
remove.push(listener);
}
}
}
for (i = remove.length; i--;) {
this.removeListener(event, remove[i]);
}
}
return this;
};
} | [
"function",
"EventEmitter",
"(",
")",
"{",
"this",
".",
"_events",
"=",
"{",
"}",
";",
"this",
".",
"_once",
"=",
"{",
"}",
";",
"// default to 10 max liseners",
"this",
".",
"_maxListeners",
"=",
"10",
";",
"this",
".",
"_add",
"=",
"function",
"(",
"... | super light weight EventEmitter implementation | [
"super",
"light",
"weight",
"EventEmitter",
"implementation"
] | 0226a88e570dafcbf185d598eafd9de3f8f27213 | https://github.com/Esri/terraformer-geostore/blob/0226a88e570dafcbf185d598eafd9de3f8f27213/src/helpers/browser/eventemitter.js#L3-L87 |
29,323 | ArnaudBuchholz/gpf-js | src/attributes/check.js | _gpfAttributesCheckAppliedOnBaseClass | function _gpfAttributesCheckAppliedOnBaseClass (classDefinition, ExpectedBaseClass) {
var Extend = classDefinition._extend;
if (Extend !== ExpectedBaseClass) {
_gpfAttributesCheckAppliedOnBaseClassIsInstanceOf(Extend.prototype, ExpectedBaseClass);
}
} | javascript | function _gpfAttributesCheckAppliedOnBaseClass (classDefinition, ExpectedBaseClass) {
var Extend = classDefinition._extend;
if (Extend !== ExpectedBaseClass) {
_gpfAttributesCheckAppliedOnBaseClassIsInstanceOf(Extend.prototype, ExpectedBaseClass);
}
} | [
"function",
"_gpfAttributesCheckAppliedOnBaseClass",
"(",
"classDefinition",
",",
"ExpectedBaseClass",
")",
"{",
"var",
"Extend",
"=",
"classDefinition",
".",
"_extend",
";",
"if",
"(",
"Extend",
"!==",
"ExpectedBaseClass",
")",
"{",
"_gpfAttributesCheckAppliedOnBaseClass... | Ensures attribute is applied on a specific base class
@param {_GpfClassDefinition} classDefinition Class definition
@param {Function} ExpectedBaseClass Expected base class
@throws {gpf.Error.RestrictedBaseClassAttribute}
@since 0.2.8 | [
"Ensures",
"attribute",
"is",
"applied",
"on",
"a",
"specific",
"base",
"class"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/attributes/check.js#L108-L113 |
29,324 | ArnaudBuchholz/gpf-js | src/attributes/check.js | _gpfAttributesCheckAppliedOnlyOnce | function _gpfAttributesCheckAppliedOnlyOnce (member, classDefinition, AttributeClass) {
var attributes = _gpfAttributesCheckGetMemberAttributes(member, classDefinition, AttributeClass);
if (_gpfArrayTail(attributes).length) {
gpf.Error.uniqueAttributeUsedTwice();
}
} | javascript | function _gpfAttributesCheckAppliedOnlyOnce (member, classDefinition, AttributeClass) {
var attributes = _gpfAttributesCheckGetMemberAttributes(member, classDefinition, AttributeClass);
if (_gpfArrayTail(attributes).length) {
gpf.Error.uniqueAttributeUsedTwice();
}
} | [
"function",
"_gpfAttributesCheckAppliedOnlyOnce",
"(",
"member",
",",
"classDefinition",
",",
"AttributeClass",
")",
"{",
"var",
"attributes",
"=",
"_gpfAttributesCheckGetMemberAttributes",
"(",
"member",
",",
"classDefinition",
",",
"AttributeClass",
")",
";",
"if",
"(... | Ensures attribute is used only once
@param {String} member Member name or empty if global to the class
@param {_GpfClassDefinition} classDefinition Class definition
@param {Function} AttributeClass Attribute class
@throws {gpf.Error.UniqueAttributeUsedTwice}
@since 0.2.8 | [
"Ensures",
"attribute",
"is",
"used",
"only",
"once"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/attributes/check.js#L132-L137 |
29,325 | ArnaudBuchholz/gpf-js | lost+found/src/define_/definition/member.js | _GpfClassDefMember | function _GpfClassDefMember (name, defaultValue, type) {
/*jshint validthis:true*/ // constructor
this._name = name;
this._setDefaultValue(defaultValue);
this._setType(type || "undefined");
} | javascript | function _GpfClassDefMember (name, defaultValue, type) {
/*jshint validthis:true*/ // constructor
this._name = name;
this._setDefaultValue(defaultValue);
this._setType(type || "undefined");
} | [
"function",
"_GpfClassDefMember",
"(",
"name",
",",
"defaultValue",
",",
"type",
")",
"{",
"/*jshint validthis:true*/",
"// constructor",
"this",
".",
"_name",
"=",
"name",
";",
"this",
".",
"_setDefaultValue",
"(",
"defaultValue",
")",
";",
"this",
".",
"_setTy... | Class member definition
- Contains a reference to the class definition where the member is defined
- Owns the name, the default value and a reference type
@param {String} name Member name
@param {*} defaultValue Member default / initial value
@param {String} [type=typeof defaultValue] type Member type
@class | [
"Class",
"member",
"definition",
"-",
"Contains",
"a",
"reference",
"to",
"the",
"class",
"definition",
"where",
"the",
"member",
"is",
"defined",
"-",
"Owns",
"the",
"name",
"the",
"default",
"value",
"and",
"a",
"reference",
"type"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/define_/definition/member.js#L25-L30 |
29,326 | ArnaudBuchholz/gpf-js | lost+found/src/define_/definition/class.js | function (member) {
_gpfAsserts({
"Expected a _GpfClassDefMember": member instanceof _GpfClassDefMember,
"Member is already assigned to a class": null === member._classDef
});
this._checkMemberBeforeAdd(member);
this._members[member.getName()] = member;
member._classDef = this;
return this;
} | javascript | function (member) {
_gpfAsserts({
"Expected a _GpfClassDefMember": member instanceof _GpfClassDefMember,
"Member is already assigned to a class": null === member._classDef
});
this._checkMemberBeforeAdd(member);
this._members[member.getName()] = member;
member._classDef = this;
return this;
} | [
"function",
"(",
"member",
")",
"{",
"_gpfAsserts",
"(",
"{",
"\"Expected a _GpfClassDefMember\"",
":",
"member",
"instanceof",
"_GpfClassDefMember",
",",
"\"Member is already assigned to a class\"",
":",
"null",
"===",
"member",
".",
"_classDef",
"}",
")",
";",
"this... | Add a member
@param {_GpfClassDefMember} member Member to add
@gpf:chainable | [
"Add",
"a",
"member"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/define_/definition/class.js#L152-L161 | |
29,327 | SockDrawer/SockBot | lib/utils.js | mergeInner | function mergeInner(base, mixin, mergeArrays) {
if (base === null || typeof base !== 'object' || Array.isArray(base)) {
throw new Error('base must be object');
}
if (mixin === null || typeof mixin !== 'object' || Array.isArray(mixin)) {
throw new Error('mixin must be object');
}
Object.keys(mixin).forEach((name) => {
mergeHelper(base, mixin, name, mergeArrays);
});
} | javascript | function mergeInner(base, mixin, mergeArrays) {
if (base === null || typeof base !== 'object' || Array.isArray(base)) {
throw new Error('base must be object');
}
if (mixin === null || typeof mixin !== 'object' || Array.isArray(mixin)) {
throw new Error('mixin must be object');
}
Object.keys(mixin).forEach((name) => {
mergeHelper(base, mixin, name, mergeArrays);
});
} | [
"function",
"mergeInner",
"(",
"base",
",",
"mixin",
",",
"mergeArrays",
")",
"{",
"if",
"(",
"base",
"===",
"null",
"||",
"typeof",
"base",
"!==",
"'object'",
"||",
"Array",
".",
"isArray",
"(",
"base",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"... | Recursively merge objects
@param {object} base Base object to merge `mixin` into
@param {object} mixin Mixin object to merge into `base`
@param {boolean} [mergeArrays] Merge arrays instead of concatenating them | [
"Recursively",
"merge",
"objects"
] | 043f7e9aa9ec12250889fd825ddcf86709b095a3 | https://github.com/SockDrawer/SockBot/blob/043f7e9aa9ec12250889fd825ddcf86709b095a3/lib/utils.js#L46-L56 |
29,328 | SockDrawer/SockBot | lib/utils.js | mergeHelper | function mergeHelper(base, mixin, name, mergeArrays) {
if (Array.isArray(mixin[name])) {
if (!mergeArrays && base[name] && Array.isArray(base[name])) {
base[name] = base[name].concat(mixin[name]);
} else {
base[name] = mixin[name];
}
} else if (typeof mixin[name] === 'object' && mixin[name] !== null) {
let newBase = base[name] || {};
if (Array.isArray(newBase)) {
newBase = {};
}
mergeInner(newBase, mixin[name], mergeArrays);
base[name] = newBase;
} else {
base[name] = mixin[name];
}
} | javascript | function mergeHelper(base, mixin, name, mergeArrays) {
if (Array.isArray(mixin[name])) {
if (!mergeArrays && base[name] && Array.isArray(base[name])) {
base[name] = base[name].concat(mixin[name]);
} else {
base[name] = mixin[name];
}
} else if (typeof mixin[name] === 'object' && mixin[name] !== null) {
let newBase = base[name] || {};
if (Array.isArray(newBase)) {
newBase = {};
}
mergeInner(newBase, mixin[name], mergeArrays);
base[name] = newBase;
} else {
base[name] = mixin[name];
}
} | [
"function",
"mergeHelper",
"(",
"base",
",",
"mixin",
",",
"name",
",",
"mergeArrays",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"mixin",
"[",
"name",
"]",
")",
")",
"{",
"if",
"(",
"!",
"mergeArrays",
"&&",
"base",
"[",
"name",
"]",
"&&",... | Merge helper - FOR INTERNAL USE ONLY
@param {object} base Base object to merge `mixin` into
@param {object} mixin Mixin object to merge into `base`
@param {string} name Name of property to merge
@param {boolean} [mergeArrays] Merge arrays instead of concatenating them | [
"Merge",
"helper",
"-",
"FOR",
"INTERNAL",
"USE",
"ONLY"
] | 043f7e9aa9ec12250889fd825ddcf86709b095a3 | https://github.com/SockDrawer/SockBot/blob/043f7e9aa9ec12250889fd825ddcf86709b095a3/lib/utils.js#L66-L83 |
29,329 | SockDrawer/SockBot | plugins/summoner.js | handler | function handler(notification) {
debug('summoner received a mention notification!');
return notification.getUser()
.then((user) => {
debug(`summoner responding to summons by ${user.name}`);
const index = Math.floor(Math.random() * messages.length);
const message = messages[index].replace(/%(\w+)%/g, (_, key) => {
let value = user[key];
if (key === 'name' && !value) {
value = user.username;
}
value = value || `%${key}%`;
if (typeof value !== 'string') {
value = `%${key}%`;
}
return value;
});
debug(`summoner replying with: ${message}`);
return forum.Post.reply(notification.topicId, notification.postId, message);
}).catch((err) => {
forum.emit('error', err);
return Promise.reject(err);
});
} | javascript | function handler(notification) {
debug('summoner received a mention notification!');
return notification.getUser()
.then((user) => {
debug(`summoner responding to summons by ${user.name}`);
const index = Math.floor(Math.random() * messages.length);
const message = messages[index].replace(/%(\w+)%/g, (_, key) => {
let value = user[key];
if (key === 'name' && !value) {
value = user.username;
}
value = value || `%${key}%`;
if (typeof value !== 'string') {
value = `%${key}%`;
}
return value;
});
debug(`summoner replying with: ${message}`);
return forum.Post.reply(notification.topicId, notification.postId, message);
}).catch((err) => {
forum.emit('error', err);
return Promise.reject(err);
});
} | [
"function",
"handler",
"(",
"notification",
")",
"{",
"debug",
"(",
"'summoner received a mention notification!'",
")",
";",
"return",
"notification",
".",
"getUser",
"(",
")",
".",
"then",
"(",
"(",
"user",
")",
"=>",
"{",
"debug",
"(",
"`",
"${",
"user",
... | Handle a mention notification.
Choose a random message and reply with it
@param {Notification} notification Notification event to handle
@returns {Promise} Resolves when event is processed | [
"Handle",
"a",
"mention",
"notification",
"."
] | 043f7e9aa9ec12250889fd825ddcf86709b095a3 | https://github.com/SockDrawer/SockBot/blob/043f7e9aa9ec12250889fd825ddcf86709b095a3/plugins/summoner.js#L45-L68 |
29,330 | SockDrawer/SockBot | providers/nodebb/chat.js | sendChat | function sendChat(roomId, content) {
return retryAction(() => forum._emit('modules.chats.send', {
roomId: roomId,
message: content
}), 5);
} | javascript | function sendChat(roomId, content) {
return retryAction(() => forum._emit('modules.chats.send', {
roomId: roomId,
message: content
}), 5);
} | [
"function",
"sendChat",
"(",
"roomId",
",",
"content",
")",
"{",
"return",
"retryAction",
"(",
"(",
")",
"=>",
"forum",
".",
"_emit",
"(",
"'modules.chats.send'",
",",
"{",
"roomId",
":",
"roomId",
",",
"message",
":",
"content",
"}",
")",
",",
"5",
")... | Send a message to the chatroom
@public
@param {number} roomId Chatroom to speak to
@param {string} content Message to send to the chatroom
@returns {Promise} Resolves when message has been sent | [
"Send",
"a",
"message",
"to",
"the",
"chatroom"
] | 043f7e9aa9ec12250889fd825ddcf86709b095a3 | https://github.com/SockDrawer/SockBot/blob/043f7e9aa9ec12250889fd825ddcf86709b095a3/providers/nodebb/chat.js#L22-L27 |
29,331 | SockDrawer/SockBot | providers/nodebb/chat.js | handleChat | function handleChat(payload) {
if (!payload.message) {
return Promise.reject(new Error('Event payload did not include chat message'));
}
const message = ChatRoom.Message.parse(payload.message);
forum.emit('chatMessage', message);
const ids = {
post: -1,
topic: -1,
user: message.from.id,
pm: message.room,
chat: message.id
};
return forum.Commands.get(ids, message.content, (content) => message.reply(content))
.then((command) => command.execute());
} | javascript | function handleChat(payload) {
if (!payload.message) {
return Promise.reject(new Error('Event payload did not include chat message'));
}
const message = ChatRoom.Message.parse(payload.message);
forum.emit('chatMessage', message);
const ids = {
post: -1,
topic: -1,
user: message.from.id,
pm: message.room,
chat: message.id
};
return forum.Commands.get(ids, message.content, (content) => message.reply(content))
.then((command) => command.execute());
} | [
"function",
"handleChat",
"(",
"payload",
")",
"{",
"if",
"(",
"!",
"payload",
".",
"message",
")",
"{",
"return",
"Promise",
".",
"reject",
"(",
"new",
"Error",
"(",
"'Event payload did not include chat message'",
")",
")",
";",
"}",
"const",
"message",
"="... | Handle Chat events from websocket
@private
@param {*} payload websocket event payload
@returns {Promise} resolves when processing has been completed for event | [
"Handle",
"Chat",
"events",
"from",
"websocket"
] | 043f7e9aa9ec12250889fd825ddcf86709b095a3 | https://github.com/SockDrawer/SockBot/blob/043f7e9aa9ec12250889fd825ddcf86709b095a3/providers/nodebb/chat.js#L441-L457 |
29,332 | ArnaudBuchholz/gpf-js | res/sources/source.js | function (dependencies) {
this._dependsOn = dependencies[this._name] || [];
this._dependencyOf = [];
Object.keys(dependencies).forEach(function (name) {
var nameDependencies = dependencies[name];
if (nameDependencies.indexOf(this._name) !== NOT_FOUND) {
this._dependencyOf.push(name);
}
}, this);
} | javascript | function (dependencies) {
this._dependsOn = dependencies[this._name] || [];
this._dependencyOf = [];
Object.keys(dependencies).forEach(function (name) {
var nameDependencies = dependencies[name];
if (nameDependencies.indexOf(this._name) !== NOT_FOUND) {
this._dependencyOf.push(name);
}
}, this);
} | [
"function",
"(",
"dependencies",
")",
"{",
"this",
".",
"_dependsOn",
"=",
"dependencies",
"[",
"this",
".",
"_name",
"]",
"||",
"[",
"]",
";",
"this",
".",
"_dependencyOf",
"=",
"[",
"]",
";",
"Object",
".",
"keys",
"(",
"dependencies",
")",
".",
"f... | Extract from the dependencies dictionary
@param {Object} dependencies dictionary | [
"Extract",
"from",
"the",
"dependencies",
"dictionary"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/res/sources/source.js#L98-L107 | |
29,333 | ArnaudBuchholz/gpf-js | res/sources/source.js | function () {
var result = {
name: this._name
};
if (!this._test) {
result.test = false;
}
if (this._tags.length) {
result.tags = this._tags.join(" ");
}
return result;
} | javascript | function () {
var result = {
name: this._name
};
if (!this._test) {
result.test = false;
}
if (this._tags.length) {
result.tags = this._tags.join(" ");
}
return result;
} | [
"function",
"(",
")",
"{",
"var",
"result",
"=",
"{",
"name",
":",
"this",
".",
"_name",
"}",
";",
"if",
"(",
"!",
"this",
".",
"_test",
")",
"{",
"result",
".",
"test",
"=",
"false",
";",
"}",
"if",
"(",
"this",
".",
"_tags",
".",
"length",
... | Create the exported version of the source
@return {Object} Object to be converted to JSON and saved | [
"Create",
"the",
"exported",
"version",
"of",
"the",
"source"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/res/sources/source.js#L128-L139 | |
29,334 | Esri/terraformer-geostore | src/geostore.js | function(primitive){
completed++;
if ( primitive ){
var geometry = new Terraformer.Primitive(primitive.geometry);
if (shapeGeometryTest(geometry, shape)){
if (self._stream) {
if (completed === found.length) {
if (operationName == "within") {
self._stream.emit("done", primitive);
} else {
self._stream.emit("data", primitive);
}
self._stream.emit("end");
} else {
self._stream.emit("data", primitive);
}
} else {
results.push(primitive);
}
}
if(completed >= found.length){
if(!errors){
if (self._stream) {
self._stream = null;
} else if (callback) {
callback( null, results );
}
} else {
if (callback) {
callback("Could not get all geometries", null);
}
}
}
}
} | javascript | function(primitive){
completed++;
if ( primitive ){
var geometry = new Terraformer.Primitive(primitive.geometry);
if (shapeGeometryTest(geometry, shape)){
if (self._stream) {
if (completed === found.length) {
if (operationName == "within") {
self._stream.emit("done", primitive);
} else {
self._stream.emit("data", primitive);
}
self._stream.emit("end");
} else {
self._stream.emit("data", primitive);
}
} else {
results.push(primitive);
}
}
if(completed >= found.length){
if(!errors){
if (self._stream) {
self._stream = null;
} else if (callback) {
callback( null, results );
}
} else {
if (callback) {
callback("Could not get all geometries", null);
}
}
}
}
} | [
"function",
"(",
"primitive",
")",
"{",
"completed",
"++",
";",
"if",
"(",
"primitive",
")",
"{",
"var",
"geometry",
"=",
"new",
"Terraformer",
".",
"Primitive",
"(",
"primitive",
".",
"geometry",
")",
";",
"if",
"(",
"shapeGeometryTest",
"(",
"geometry",
... | the function to evalute results from the index | [
"the",
"function",
"to",
"evalute",
"results",
"from",
"the",
"index"
] | 0226a88e570dafcbf185d598eafd9de3f8f27213 | https://github.com/Esri/terraformer-geostore/blob/0226a88e570dafcbf185d598eafd9de3f8f27213/src/geostore.js#L219-L254 | |
29,335 | ArnaudBuchholz/gpf-js | src/define/check.js | function () {
var parts = new RegExp("(.*)\\.([^\\.]+)$").exec(this._name),
NAME_PART = 2,
NAMESPACE_PART = 1;
if (parts) {
this._name = parts[NAME_PART];
return parts[NAMESPACE_PART];
}
} | javascript | function () {
var parts = new RegExp("(.*)\\.([^\\.]+)$").exec(this._name),
NAME_PART = 2,
NAMESPACE_PART = 1;
if (parts) {
this._name = parts[NAME_PART];
return parts[NAMESPACE_PART];
}
} | [
"function",
"(",
")",
"{",
"var",
"parts",
"=",
"new",
"RegExp",
"(",
"\"(.*)\\\\.([^\\\\.]+)$\"",
")",
".",
"exec",
"(",
"this",
".",
"_name",
")",
",",
"NAME_PART",
"=",
"2",
",",
"NAMESPACE_PART",
"=",
"1",
";",
"if",
"(",
"parts",
")",
"{",
"this... | If the name is prefixed with a namespace, isolate it and update name property
@return {String|undefined} Namespace contained in the name or undefined if none
@since 0.1.6 | [
"If",
"the",
"name",
"is",
"prefixed",
"with",
"a",
"namespace",
"isolate",
"it",
"and",
"update",
"name",
"property"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/define/check.js#L260-L268 | |
29,336 | ArnaudBuchholz/gpf-js | src/define/check.js | function () {
var namespaces = [
this._initialDefinition.$namespace,
this._extractRelativeNamespaceFromName()
].filter(function (namespacePart) {
return namespacePart;
});
if (namespaces.length) {
this._namespace = namespaces.join(".");
}
} | javascript | function () {
var namespaces = [
this._initialDefinition.$namespace,
this._extractRelativeNamespaceFromName()
].filter(function (namespacePart) {
return namespacePart;
});
if (namespaces.length) {
this._namespace = namespaces.join(".");
}
} | [
"function",
"(",
")",
"{",
"var",
"namespaces",
"=",
"[",
"this",
".",
"_initialDefinition",
".",
"$namespace",
",",
"this",
".",
"_extractRelativeNamespaceFromName",
"(",
")",
"]",
".",
"filter",
"(",
"function",
"(",
"namespacePart",
")",
"{",
"return",
"n... | Compute namespace property
@since 0.1.6 | [
"Compute",
"namespace",
"property"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/define/check.js#L274-L284 | |
29,337 | ArnaudBuchholz/gpf-js | lost+found/src/define_/internal.js | _gpfCleanDefinition | function _gpfCleanDefinition (name, shortcut) {
/*jshint validthis:true*/ // Bound to the definition below
var shortcutValue = this[shortcut];
if (undefined !== shortcutValue) {
this[name] = shortcutValue;
delete this[shortcut];
}
} | javascript | function _gpfCleanDefinition (name, shortcut) {
/*jshint validthis:true*/ // Bound to the definition below
var shortcutValue = this[shortcut];
if (undefined !== shortcutValue) {
this[name] = shortcutValue;
delete this[shortcut];
}
} | [
"function",
"_gpfCleanDefinition",
"(",
"name",
",",
"shortcut",
")",
"{",
"/*jshint validthis:true*/",
"// Bound to the definition below",
"var",
"shortcutValue",
"=",
"this",
"[",
"shortcut",
"]",
";",
"if",
"(",
"undefined",
"!==",
"shortcutValue",
")",
"{",
"thi... | Replace the shortcut with the correct property name | [
"Replace",
"the",
"shortcut",
"with",
"the",
"correct",
"property",
"name"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/define_/internal.js#L18-L25 |
29,338 | popeindustries/buddy | lib/config/index.js | parsePlugins | function parsePlugins(config) {
let plugins = [];
function parse(plugins) {
return plugins.map(plugin => {
if ('string' == typeof plugin) plugin = path.resolve(plugin);
return plugin;
});
}
// Handle plugin paths defined in config file
if (config.plugins) {
plugins.push(...parse(config.plugins));
delete config.plugins;
}
// Handle plugin paths/functions defined in runtime options
if (config.runtimeOptions.plugins) {
plugins.push(...parse(config.runtimeOptions.plugins));
delete config.runtimeOptions.plugins;
}
return plugins;
} | javascript | function parsePlugins(config) {
let plugins = [];
function parse(plugins) {
return plugins.map(plugin => {
if ('string' == typeof plugin) plugin = path.resolve(plugin);
return plugin;
});
}
// Handle plugin paths defined in config file
if (config.plugins) {
plugins.push(...parse(config.plugins));
delete config.plugins;
}
// Handle plugin paths/functions defined in runtime options
if (config.runtimeOptions.plugins) {
plugins.push(...parse(config.runtimeOptions.plugins));
delete config.runtimeOptions.plugins;
}
return plugins;
} | [
"function",
"parsePlugins",
"(",
"config",
")",
"{",
"let",
"plugins",
"=",
"[",
"]",
";",
"function",
"parse",
"(",
"plugins",
")",
"{",
"return",
"plugins",
".",
"map",
"(",
"plugin",
"=>",
"{",
"if",
"(",
"'string'",
"==",
"typeof",
"plugin",
")",
... | Parse plugins defined in 'config'
@param {Config} config
@returns {Array} | [
"Parse",
"plugins",
"defined",
"in",
"config"
] | c38afc2e6915743eb6cfcf5aba59a8699142c7a5 | https://github.com/popeindustries/buddy/blob/c38afc2e6915743eb6cfcf5aba59a8699142c7a5/lib/config/index.js#L320-L342 |
29,339 | ArnaudBuchholz/gpf-js | lost+found/src/define_/params.js | _gpfProcessDefineParamCheckIfRelativeName | function _gpfProcessDefineParamCheckIfRelativeName (rootNamespace, params) {
var name = params[_GPF_DEFINE_PARAM_NAME];
if (-1 === name.indexOf(".")) {
params[_GPF_DEFINE_PARAM_NAME] = rootNamespace + name;
}
} | javascript | function _gpfProcessDefineParamCheckIfRelativeName (rootNamespace, params) {
var name = params[_GPF_DEFINE_PARAM_NAME];
if (-1 === name.indexOf(".")) {
params[_GPF_DEFINE_PARAM_NAME] = rootNamespace + name;
}
} | [
"function",
"_gpfProcessDefineParamCheckIfRelativeName",
"(",
"rootNamespace",
",",
"params",
")",
"{",
"var",
"name",
"=",
"params",
"[",
"_GPF_DEFINE_PARAM_NAME",
"]",
";",
"if",
"(",
"-",
"1",
"===",
"name",
".",
"indexOf",
"(",
"\".\"",
")",
")",
"{",
"p... | Check if the name is relative, if so concatenate to the rootNamespace | [
"Check",
"if",
"the",
"name",
"is",
"relative",
"if",
"so",
"concatenate",
"to",
"the",
"rootNamespace"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/define_/params.js#L26-L31 |
29,340 | ArnaudBuchholz/gpf-js | lost+found/src/define_/params.js | _gpfProcessDefineParamResolveBase | function _gpfProcessDefineParamResolveBase (params) {
var Super = params[_GPF_DEFINE_PARAM_SUPER];
if (!(Super instanceof Function)) {
params[_GPF_DEFINE_PARAM_SUPER] = _gpfContext(Super.toString().split("."));
}
} | javascript | function _gpfProcessDefineParamResolveBase (params) {
var Super = params[_GPF_DEFINE_PARAM_SUPER];
if (!(Super instanceof Function)) {
params[_GPF_DEFINE_PARAM_SUPER] = _gpfContext(Super.toString().split("."));
}
} | [
"function",
"_gpfProcessDefineParamResolveBase",
"(",
"params",
")",
"{",
"var",
"Super",
"=",
"params",
"[",
"_GPF_DEFINE_PARAM_SUPER",
"]",
";",
"if",
"(",
"!",
"(",
"Super",
"instanceof",
"Function",
")",
")",
"{",
"params",
"[",
"_GPF_DEFINE_PARAM_SUPER",
"]... | Convert base parameter from string to contextual object | [
"Convert",
"base",
"parameter",
"from",
"string",
"to",
"contextual",
"object"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/define_/params.js#L48-L53 |
29,341 | ArnaudBuchholz/gpf-js | lost+found/src/define_/params.js | _gpfProcessDefineParamsCheck | function _gpfProcessDefineParamsCheck (params) {
_gpfAsserts({
"name is required (String)": "string" === typeof params[_GPF_DEFINE_PARAM_NAME],
"Super is required and must resolve to a Constructor": params[_GPF_DEFINE_PARAM_SUPER] instanceof Function,
"definition is required (Object)": "object" === typeof params[_GPF_DEFINE_PARAM_DEFINITION]
});
} | javascript | function _gpfProcessDefineParamsCheck (params) {
_gpfAsserts({
"name is required (String)": "string" === typeof params[_GPF_DEFINE_PARAM_NAME],
"Super is required and must resolve to a Constructor": params[_GPF_DEFINE_PARAM_SUPER] instanceof Function,
"definition is required (Object)": "object" === typeof params[_GPF_DEFINE_PARAM_DEFINITION]
});
} | [
"function",
"_gpfProcessDefineParamsCheck",
"(",
"params",
")",
"{",
"_gpfAsserts",
"(",
"{",
"\"name is required (String)\"",
":",
"\"string\"",
"===",
"typeof",
"params",
"[",
"_GPF_DEFINE_PARAM_NAME",
"]",
",",
"\"Super is required and must resolve to a Constructor\"",
":"... | Check that the parameters are correct | [
"Check",
"that",
"the",
"parameters",
"are",
"correct"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/define_/params.js#L56-L62 |
29,342 | ArnaudBuchholz/gpf-js | lost+found/src/define_/params.js | _gpfProcessDefineParams | function _gpfProcessDefineParams (rootNamespace, defaultSuper, params) {
_gpfProcessDefineParamNoSuperUsed(defaultSuper, params);
_gpfProcessDefineParamCheckIfRelativeName(rootNamespace, params);
_gpfProcessDefineParamDefaultSuper(defaultSuper, params);
_gpfProcessDefineParamDefaultDefinition(params);
_gpfProcessDefineParamResolveBase(params);
_gpfProcessDefineParamsCheck(params);
} | javascript | function _gpfProcessDefineParams (rootNamespace, defaultSuper, params) {
_gpfProcessDefineParamNoSuperUsed(defaultSuper, params);
_gpfProcessDefineParamCheckIfRelativeName(rootNamespace, params);
_gpfProcessDefineParamDefaultSuper(defaultSuper, params);
_gpfProcessDefineParamDefaultDefinition(params);
_gpfProcessDefineParamResolveBase(params);
_gpfProcessDefineParamsCheck(params);
} | [
"function",
"_gpfProcessDefineParams",
"(",
"rootNamespace",
",",
"defaultSuper",
",",
"params",
")",
"{",
"_gpfProcessDefineParamNoSuperUsed",
"(",
"defaultSuper",
",",
"params",
")",
";",
"_gpfProcessDefineParamCheckIfRelativeName",
"(",
"rootNamespace",
",",
"params",
... | Process define parameters to inject default values when needed
@param {String} rootNamespace
@param {Function|undefined|String} defaultSuper
@param {Array} params gpf.define parameters:
- {String} name New class contextual name
- {String} [base=undefined] base Base class contextual name
- {Object} [definition=undefined] definition Class definition | [
"Process",
"define",
"parameters",
"to",
"inject",
"default",
"values",
"when",
"needed"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/define_/params.js#L74-L81 |
29,343 | popeindustries/buddy | lib/resolver/resolve.js | find | function find(id, type, sourcedir, options) {
const { cache, fileExtensions, nativeModules } = options;
const pkgDetails = pkg.getDetails(sourcedir, options);
let filepath = isRelativeFilepath(id) ? path.join(sourcedir, id) : id;
filepath = alias.resolve(filepath, pkgDetails && pkgDetails.aliases);
if (filepath === false || nativeModules.includes(filepath)) return false;
if (isAbsoluteFilepath(filepath)) {
filepath = findFilepath(filepath, type, fileExtensions);
filepath = alias.resolve(filepath, pkgDetails && pkgDetails.aliases);
// File doesn't exist or is disabled
if (filepath === '' || filepath === false) return filepath;
// File found
if (isAbsoluteFilepath(filepath)) {
// Cache
cache.setFile(
{
id: pkg.resolveId(pkgDetails, filepath),
path: filepath,
version: pkgDetails.version
},
versionDelimiter
);
return filepath;
}
}
// Update id if it has been resolved as package
if (!isFilepath(filepath)) id = filepath;
// Search paths for matches
pkgDetails.paths.some(sourcepath => {
if (id && sourcedir != sourcepath) {
let fp = path.join(sourcepath, id);
fp = find(fp, type, fp, options);
if (fp !== '') {
filepath = fp;
return true;
}
filepath = '';
}
});
return filepath;
} | javascript | function find(id, type, sourcedir, options) {
const { cache, fileExtensions, nativeModules } = options;
const pkgDetails = pkg.getDetails(sourcedir, options);
let filepath = isRelativeFilepath(id) ? path.join(sourcedir, id) : id;
filepath = alias.resolve(filepath, pkgDetails && pkgDetails.aliases);
if (filepath === false || nativeModules.includes(filepath)) return false;
if (isAbsoluteFilepath(filepath)) {
filepath = findFilepath(filepath, type, fileExtensions);
filepath = alias.resolve(filepath, pkgDetails && pkgDetails.aliases);
// File doesn't exist or is disabled
if (filepath === '' || filepath === false) return filepath;
// File found
if (isAbsoluteFilepath(filepath)) {
// Cache
cache.setFile(
{
id: pkg.resolveId(pkgDetails, filepath),
path: filepath,
version: pkgDetails.version
},
versionDelimiter
);
return filepath;
}
}
// Update id if it has been resolved as package
if (!isFilepath(filepath)) id = filepath;
// Search paths for matches
pkgDetails.paths.some(sourcepath => {
if (id && sourcedir != sourcepath) {
let fp = path.join(sourcepath, id);
fp = find(fp, type, fp, options);
if (fp !== '') {
filepath = fp;
return true;
}
filepath = '';
}
});
return filepath;
} | [
"function",
"find",
"(",
"id",
",",
"type",
",",
"sourcedir",
",",
"options",
")",
"{",
"const",
"{",
"cache",
",",
"fileExtensions",
",",
"nativeModules",
"}",
"=",
"options",
";",
"const",
"pkgDetails",
"=",
"pkg",
".",
"getDetails",
"(",
"sourcedir",
... | Find filepath for 'id' in 'sourcedir' directory
@param {String} id
@param {String} type
@param {String} sourcedir
@param {Object} options
- {Boolean} browser
- {ResolverCache} cache
- {Object} fileExtensions
- {Array} nativeModules
- {Array} sources
@returns {String|Boolean} | [
"Find",
"filepath",
"for",
"id",
"in",
"sourcedir",
"directory"
] | c38afc2e6915743eb6cfcf5aba59a8699142c7a5 | https://github.com/popeindustries/buddy/blob/c38afc2e6915743eb6cfcf5aba59a8699142c7a5/lib/resolver/resolve.js#L53-L100 |
29,344 | ArnaudBuchholz/gpf-js | src/web/tag.js | _gpfWebGetNamespace | function _gpfWebGetNamespace (prefix) {
var namespace = _gpfWebNamespacePrefix[prefix];
if (undefined === namespace) {
gpf.Error.unknownNamespacePrefix();
}
return namespace;
} | javascript | function _gpfWebGetNamespace (prefix) {
var namespace = _gpfWebNamespacePrefix[prefix];
if (undefined === namespace) {
gpf.Error.unknownNamespacePrefix();
}
return namespace;
} | [
"function",
"_gpfWebGetNamespace",
"(",
"prefix",
")",
"{",
"var",
"namespace",
"=",
"_gpfWebNamespacePrefix",
"[",
"prefix",
"]",
";",
"if",
"(",
"undefined",
"===",
"namespace",
")",
"{",
"gpf",
".",
"Error",
".",
"unknownNamespacePrefix",
"(",
")",
";",
"... | Retrieves namespace associated to the prefix or fail
@param {String} prefix Namespace prefix
@return {String} Namespace URI
@throws {gpf.Error.UnknownNamespacePrefix}
@since 0.2.2 | [
"Retrieves",
"namespace",
"associated",
"to",
"the",
"prefix",
"or",
"fail"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/web/tag.js#L146-L152 |
29,345 | ArnaudBuchholz/gpf-js | src/web/tag.js | _gpfWebGetNamespaceAndName | function _gpfWebGetNamespaceAndName (name) {
var EXPECTED_PARTS_COUNT = 2,
NAMESPACE_PREFIX = 0,
NAME = 1,
parts = name.split(":");
if (parts.length === EXPECTED_PARTS_COUNT) {
return {
namespace: _gpfWebGetNamespace(parts[NAMESPACE_PREFIX]),
name: parts[NAME]
};
}
} | javascript | function _gpfWebGetNamespaceAndName (name) {
var EXPECTED_PARTS_COUNT = 2,
NAMESPACE_PREFIX = 0,
NAME = 1,
parts = name.split(":");
if (parts.length === EXPECTED_PARTS_COUNT) {
return {
namespace: _gpfWebGetNamespace(parts[NAMESPACE_PREFIX]),
name: parts[NAME]
};
}
} | [
"function",
"_gpfWebGetNamespaceAndName",
"(",
"name",
")",
"{",
"var",
"EXPECTED_PARTS_COUNT",
"=",
"2",
",",
"NAMESPACE_PREFIX",
"=",
"0",
",",
"NAME",
"=",
"1",
",",
"parts",
"=",
"name",
".",
"split",
"(",
"\":\"",
")",
";",
"if",
"(",
"parts",
".",
... | Resolves prefixed name to namespace and name
@param {String} name Attribute or node name
@return {{namespace, name}|undefined} Namespace and name in a structure if prefixed, undefined otherwise
@since 0.2.2 | [
"Resolves",
"prefixed",
"name",
"to",
"namespace",
"and",
"name"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/web/tag.js#L161-L172 |
29,346 | ArnaudBuchholz/gpf-js | src/web/tag.js | _gpfWebTagFlattenChildren | function _gpfWebTagFlattenChildren (array, callback) {
array.forEach(function (item) {
if (_gpfIsArray(item)) {
_gpfWebTagFlattenChildren(item, callback);
} else {
callback(item);
}
});
} | javascript | function _gpfWebTagFlattenChildren (array, callback) {
array.forEach(function (item) {
if (_gpfIsArray(item)) {
_gpfWebTagFlattenChildren(item, callback);
} else {
callback(item);
}
});
} | [
"function",
"_gpfWebTagFlattenChildren",
"(",
"array",
",",
"callback",
")",
"{",
"array",
".",
"forEach",
"(",
"function",
"(",
"item",
")",
"{",
"if",
"(",
"_gpfIsArray",
"(",
"item",
")",
")",
"{",
"_gpfWebTagFlattenChildren",
"(",
"item",
",",
"callback"... | Apply the callback to each array item,
process recursively if the array item is an array
@param {Array} array array of items
@param {Function} callback Function to apply on each array item
@since 0.2.1 | [
"Apply",
"the",
"callback",
"to",
"each",
"array",
"item",
"process",
"recursively",
"if",
"the",
"array",
"item",
"is",
"an",
"array"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/web/tag.js#L206-L214 |
29,347 | ArnaudBuchholz/gpf-js | src/web/tag.js | function () {
return Object.keys(this._attributes).map(function (name) {
_gpfWebCheckNamespaceSafe(name);
return " " + _gpfWebTagAttributeAlias(name)
+ "=\"" + _gpfStringEscapeForHtml(this._attributes[name]) + "\"";
}, this).join("");
} | javascript | function () {
return Object.keys(this._attributes).map(function (name) {
_gpfWebCheckNamespaceSafe(name);
return " " + _gpfWebTagAttributeAlias(name)
+ "=\"" + _gpfStringEscapeForHtml(this._attributes[name]) + "\"";
}, this).join("");
} | [
"function",
"(",
")",
"{",
"return",
"Object",
".",
"keys",
"(",
"this",
".",
"_attributes",
")",
".",
"map",
"(",
"function",
"(",
"name",
")",
"{",
"_gpfWebCheckNamespaceSafe",
"(",
"name",
")",
";",
"return",
"\" \"",
"+",
"_gpfWebTagAttributeAlias",
"(... | region toString implementation | [
"region",
"toString",
"implementation"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/web/tag.js#L256-L262 | |
29,348 | ArnaudBuchholz/gpf-js | src/web/tag.js | function (node) {
var ownerDocument = node.ownerDocument,
qualified = _gpfWebGetNamespaceAndName(this._nodeName);
if (qualified) {
return ownerDocument.createElementNS(qualified.namespace, qualified.name);
}
return ownerDocument.createElement(this._nodeName);
} | javascript | function (node) {
var ownerDocument = node.ownerDocument,
qualified = _gpfWebGetNamespaceAndName(this._nodeName);
if (qualified) {
return ownerDocument.createElementNS(qualified.namespace, qualified.name);
}
return ownerDocument.createElement(this._nodeName);
} | [
"function",
"(",
"node",
")",
"{",
"var",
"ownerDocument",
"=",
"node",
".",
"ownerDocument",
",",
"qualified",
"=",
"_gpfWebGetNamespaceAndName",
"(",
"this",
".",
"_nodeName",
")",
";",
"if",
"(",
"qualified",
")",
"{",
"return",
"ownerDocument",
".",
"cre... | endregion region appendTo implementation | [
"endregion",
"region",
"appendTo",
"implementation"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/web/tag.js#L294-L301 | |
29,349 | ArnaudBuchholz/gpf-js | src/web/tag.js | function (node) {
var element = this._createElement(node);
this._setAttributesTo(element);
this._appendChildrenTo(element);
return node.appendChild(element);
} | javascript | function (node) {
var element = this._createElement(node);
this._setAttributesTo(element);
this._appendChildrenTo(element);
return node.appendChild(element);
} | [
"function",
"(",
"node",
")",
"{",
"var",
"element",
"=",
"this",
".",
"_createElement",
"(",
"node",
")",
";",
"this",
".",
"_setAttributesTo",
"(",
"element",
")",
";",
"this",
".",
"_appendChildrenTo",
"(",
"element",
")",
";",
"return",
"node",
".",
... | Appends the tag to the provided node
@param {Object} node Expected to be a DOM node
@return {Object} Created node
@since 0.2.1 | [
"Appends",
"the",
"tag",
"to",
"the",
"provided",
"node"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/web/tag.js#L332-L337 | |
29,350 | ArnaudBuchholz/gpf-js | src/web/tag.js | _gpfWebTagCreateFunction | function _gpfWebTagCreateFunction (nodeName) {
if (!nodeName) {
gpf.Error.missingNodeName();
}
return function (firstParam) {
var sliceFrom = 0,
attributes;
if (_gpfIsLiteralObject(firstParam)) {
attributes = firstParam;
++sliceFrom;
}
return new _GpfWebTag(nodeName, attributes, _gpfArraySlice(arguments, sliceFrom));
};
} | javascript | function _gpfWebTagCreateFunction (nodeName) {
if (!nodeName) {
gpf.Error.missingNodeName();
}
return function (firstParam) {
var sliceFrom = 0,
attributes;
if (_gpfIsLiteralObject(firstParam)) {
attributes = firstParam;
++sliceFrom;
}
return new _GpfWebTag(nodeName, attributes, _gpfArraySlice(arguments, sliceFrom));
};
} | [
"function",
"_gpfWebTagCreateFunction",
"(",
"nodeName",
")",
"{",
"if",
"(",
"!",
"nodeName",
")",
"{",
"gpf",
".",
"Error",
".",
"missingNodeName",
"(",
")",
";",
"}",
"return",
"function",
"(",
"firstParam",
")",
"{",
"var",
"sliceFrom",
"=",
"0",
","... | Create a tag generation function
@param {String} nodeName tag name.
May include the namespace prefix svg for [SVG elements](https://developer.mozilla.org/en-US/docs/Web/SVG)
@return {gpf.typedef.tagFunc} The tag generation function
@gpf:closure
@since 0.2.1 | [
"Create",
"a",
"tag",
"generation",
"function"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/web/tag.js#L352-L365 |
29,351 | ArnaudBuchholz/gpf-js | lost+found/src/like.js | function (a, b) {
var done = this._done,
indexOfA,
comparedWith;
indexOfA = done.indexOf(a);
while (-1 < indexOfA) {
comparedWith = this._getPair(done, indexOfA);
if (comparedWith === b) {
return false; // Already compared
}
indexOfA = done.indexOf(a, indexOfA + 1);
}
return true;
} | javascript | function (a, b) {
var done = this._done,
indexOfA,
comparedWith;
indexOfA = done.indexOf(a);
while (-1 < indexOfA) {
comparedWith = this._getPair(done, indexOfA);
if (comparedWith === b) {
return false; // Already compared
}
indexOfA = done.indexOf(a, indexOfA + 1);
}
return true;
} | [
"function",
"(",
"a",
",",
"b",
")",
"{",
"var",
"done",
"=",
"this",
".",
"_done",
",",
"indexOfA",
",",
"comparedWith",
";",
"indexOfA",
"=",
"done",
".",
"indexOf",
"(",
"a",
")",
";",
"while",
"(",
"-",
"1",
"<",
"indexOfA",
")",
"{",
"compar... | Check in the stack of done if parameters were never compared
@param {Object} a
@param {Object} b
@return {Boolean} | [
"Check",
"in",
"the",
"stack",
"of",
"done",
"if",
"parameters",
"were",
"never",
"compared"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/like.js#L54-L67 | |
29,352 | ArnaudBuchholz/gpf-js | lost+found/src/like.js | function (a, b) {
var pending;
if (this._neverCompared(a, b)) {
pending = this._pending;
pending.push(a);
pending.push(b);
}
} | javascript | function (a, b) {
var pending;
if (this._neverCompared(a, b)) {
pending = this._pending;
pending.push(a);
pending.push(b);
}
} | [
"function",
"(",
"a",
",",
"b",
")",
"{",
"var",
"pending",
";",
"if",
"(",
"this",
".",
"_neverCompared",
"(",
"a",
",",
"b",
")",
")",
"{",
"pending",
"=",
"this",
".",
"_pending",
";",
"pending",
".",
"push",
"(",
"a",
")",
";",
"pending",
"... | If a was never compared with b, adds the pair to the pending list.
@param {Object} a
@param {Object} b | [
"If",
"a",
"was",
"never",
"compared",
"with",
"b",
"adds",
"the",
"pair",
"to",
"the",
"pending",
"list",
"."
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/like.js#L75-L82 | |
29,353 | ArnaudBuchholz/gpf-js | lost+found/src/like.js | function () {
var pending = this._pending,
done = this._done,
a,
b;
while (0 !== pending.length) {
b = pending.pop();
a = pending.pop();
done.push(a, b);
if (this._areDifferent(a, b)) {
return false;
}
}
return true;
} | javascript | function () {
var pending = this._pending,
done = this._done,
a,
b;
while (0 !== pending.length) {
b = pending.pop();
a = pending.pop();
done.push(a, b);
if (this._areDifferent(a, b)) {
return false;
}
}
return true;
} | [
"function",
"(",
")",
"{",
"var",
"pending",
"=",
"this",
".",
"_pending",
",",
"done",
"=",
"this",
".",
"_done",
",",
"a",
",",
"b",
";",
"while",
"(",
"0",
"!==",
"pending",
".",
"length",
")",
"{",
"b",
"=",
"pending",
".",
"pop",
"(",
")",... | Process the pending list
@return {Boolean} | [
"Process",
"the",
"pending",
"list"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/like.js#L105-L119 | |
29,354 | ArnaudBuchholz/gpf-js | lost+found/src/like.js | function (a, b) {
var me = this,
membersOfA = Object.keys(a);
// a members comparison with b
if (!membersOfA.every(function (member) {
return me.like(a[member], b[member]);
})) {
return true;
}
// Difference on members count?
return membersOfA.length !== Object.keys(b).length;
} | javascript | function (a, b) {
var me = this,
membersOfA = Object.keys(a);
// a members comparison with b
if (!membersOfA.every(function (member) {
return me.like(a[member], b[member]);
})) {
return true;
}
// Difference on members count?
return membersOfA.length !== Object.keys(b).length;
} | [
"function",
"(",
"a",
",",
"b",
")",
"{",
"var",
"me",
"=",
"this",
",",
"membersOfA",
"=",
"Object",
".",
"keys",
"(",
"a",
")",
";",
"// a members comparison with b",
"if",
"(",
"!",
"membersOfA",
".",
"every",
"(",
"function",
"(",
"member",
")",
... | Check if members are different
@param {*} a
@param {*} b
@returns {Number} | [
"Check",
"if",
"members",
"are",
"different"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/like.js#L128-L139 | |
29,355 | ArnaudBuchholz/gpf-js | lost+found/src/like.js | function (a, b) {
if (null === a || null === b || "object" !== typeof a) {
return false; // Because we know that a !== b
}
this._stack(a, b);
return true;
} | javascript | function (a, b) {
if (null === a || null === b || "object" !== typeof a) {
return false; // Because we know that a !== b
}
this._stack(a, b);
return true;
} | [
"function",
"(",
"a",
",",
"b",
")",
"{",
"if",
"(",
"null",
"===",
"a",
"||",
"null",
"===",
"b",
"||",
"\"object\"",
"!==",
"typeof",
"a",
")",
"{",
"return",
"false",
";",
"// Because we know that a !== b",
"}",
"this",
".",
"_stack",
"(",
"a",
",... | Check if objects are the same
@param {Object} a
@param {Object} b
@returns {boolean} | [
"Check",
"if",
"objects",
"are",
"the",
"same"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/like.js#L176-L182 | |
29,356 | ArnaudBuchholz/gpf-js | lost+found/src/like.js | function (a, b) {
if (a === b) {
return true;
}
if (typeof a !== typeof b) {
return this._alike(a, b);
}
return this._objectLike(a, b);
} | javascript | function (a, b) {
if (a === b) {
return true;
}
if (typeof a !== typeof b) {
return this._alike(a, b);
}
return this._objectLike(a, b);
} | [
"function",
"(",
"a",
",",
"b",
")",
"{",
"if",
"(",
"a",
"===",
"b",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"typeof",
"a",
"!==",
"typeof",
"b",
")",
"{",
"return",
"this",
".",
"_alike",
"(",
"a",
",",
"b",
")",
";",
"}",
"retur... | Internal version of gpf.like
@param {*} a
@param {*} b
@return {Boolean} | [
"Internal",
"version",
"of",
"gpf",
".",
"like"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/like.js#L191-L199 | |
29,357 | ArnaudBuchholz/gpf-js | src/abstract.js | _gpfCreateAbstractFunction | function _gpfCreateAbstractFunction (numberOfParameters) {
return _gpfFunctionBuild({
parameters: _gpfBuildFunctionParameterList(numberOfParameters),
body: "_throw_();"
}, {
_throw_: gpf.Error.abstractMethod
});
} | javascript | function _gpfCreateAbstractFunction (numberOfParameters) {
return _gpfFunctionBuild({
parameters: _gpfBuildFunctionParameterList(numberOfParameters),
body: "_throw_();"
}, {
_throw_: gpf.Error.abstractMethod
});
} | [
"function",
"_gpfCreateAbstractFunction",
"(",
"numberOfParameters",
")",
"{",
"return",
"_gpfFunctionBuild",
"(",
"{",
"parameters",
":",
"_gpfBuildFunctionParameterList",
"(",
"numberOfParameters",
")",
",",
"body",
":",
"\"_throw_();\"",
"}",
",",
"{",
"_throw_",
"... | Build a function that throws the abstractMethod exception
@param {Number} numberOfParameters Defines the signature of the resulting function
@return {Function} Function that throws the abstractMethod exception
@since 0.1.8 | [
"Build",
"a",
"function",
"that",
"throws",
"the",
"abstractMethod",
"exception"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/abstract.js#L36-L43 |
29,358 | ArnaudBuchholz/gpf-js | lost+found/src/dispatch.js | _gpfAddEventListener | function _gpfAddEventListener (event, eventsHandler) {
/*jshint validthis:true*/ // will be invoked as an object method
var listeners = _gpfAllocateEventDispatcherListeners(this);
if (undefined === listeners[event]) {
listeners[event] = [];
}
listeners[event].push(eventsHandler);
return this;
} | javascript | function _gpfAddEventListener (event, eventsHandler) {
/*jshint validthis:true*/ // will be invoked as an object method
var listeners = _gpfAllocateEventDispatcherListeners(this);
if (undefined === listeners[event]) {
listeners[event] = [];
}
listeners[event].push(eventsHandler);
return this;
} | [
"function",
"_gpfAddEventListener",
"(",
"event",
",",
"eventsHandler",
")",
"{",
"/*jshint validthis:true*/",
"// will be invoked as an object method",
"var",
"listeners",
"=",
"_gpfAllocateEventDispatcherListeners",
"(",
"this",
")",
";",
"if",
"(",
"undefined",
"===",
... | Add an event listener to the dispatcher
@param {String} event name
@param {gpf.events.Handler} eventsHandler
@gpf:chainable | [
"Add",
"an",
"event",
"listener",
"to",
"the",
"dispatcher"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/dispatch.js#L26-L34 |
29,359 | ArnaudBuchholz/gpf-js | lost+found/src/dispatch.js | _gpfRemoveEventListener | function _gpfRemoveEventListener (event, eventsHandler) {
/*jshint validthis:true*/ // will be invoked as an object method
var listeners = this._eventDispatcherListeners,
eventListeners,
index;
if (listeners) {
eventListeners = listeners[event];
if (undefined !== eventListeners) {
index = eventListeners.indexOf(eventsHandler);
if (-1 !== index) {
eventListeners.splice(index, 1);
}
}
}
return this;
} | javascript | function _gpfRemoveEventListener (event, eventsHandler) {
/*jshint validthis:true*/ // will be invoked as an object method
var listeners = this._eventDispatcherListeners,
eventListeners,
index;
if (listeners) {
eventListeners = listeners[event];
if (undefined !== eventListeners) {
index = eventListeners.indexOf(eventsHandler);
if (-1 !== index) {
eventListeners.splice(index, 1);
}
}
}
return this;
} | [
"function",
"_gpfRemoveEventListener",
"(",
"event",
",",
"eventsHandler",
")",
"{",
"/*jshint validthis:true*/",
"// will be invoked as an object method",
"var",
"listeners",
"=",
"this",
".",
"_eventDispatcherListeners",
",",
"eventListeners",
",",
"index",
";",
"if",
"... | Remove an event listener from the dispatcher
@param {String} event name
@param {gpf.events.Handler} eventsHandler
@gpf:chainable | [
"Remove",
"an",
"event",
"listener",
"from",
"the",
"dispatcher"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/dispatch.js#L43-L58 |
29,360 | ArnaudBuchholz/gpf-js | lost+found/src/dispatch.js | _gpfTriggerListeners | function _gpfTriggerListeners (eventObj, eventListeners) {
var index,
length = eventListeners.length;
for (index = 0; index < length; ++index) {
_gpfEventsFire.call(eventObj.scope, eventObj, {}, eventListeners[index]);
}
} | javascript | function _gpfTriggerListeners (eventObj, eventListeners) {
var index,
length = eventListeners.length;
for (index = 0; index < length; ++index) {
_gpfEventsFire.call(eventObj.scope, eventObj, {}, eventListeners[index]);
}
} | [
"function",
"_gpfTriggerListeners",
"(",
"eventObj",
",",
"eventListeners",
")",
"{",
"var",
"index",
",",
"length",
"=",
"eventListeners",
".",
"length",
";",
"for",
"(",
"index",
"=",
"0",
";",
"index",
"<",
"length",
";",
"++",
"index",
")",
"{",
"_gp... | Execute the listeners
@param {gpf.events.Event} eventObj
@param {gpf.events.Handler[]} eventListeners | [
"Execute",
"the",
"listeners"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/dispatch.js#L66-L72 |
29,361 | ArnaudBuchholz/gpf-js | lost+found/src/dispatch.js | _gpfDispatchEvent | function _gpfDispatchEvent (event, params) {
/*jshint validthis:true*/ // will be invoked as an object method
var listeners = this._eventDispatcherListeners,
eventObj,
type,
eventListeners;
if (!listeners) {
return this; // No listeners at all
}
if (event instanceof _GpfEvent) {
eventObj = event;
type = event.type;
} else {
type = event;
}
eventListeners = this._eventDispatcherListeners[type];
if (undefined === eventListeners) {
return this; // Nothing listeners for this event
}
if (!eventObj) {
eventObj = new _GpfEvent(type, params, this);
}
_gpfTriggerListeners(eventObj, eventListeners);
return eventObj;
} | javascript | function _gpfDispatchEvent (event, params) {
/*jshint validthis:true*/ // will be invoked as an object method
var listeners = this._eventDispatcherListeners,
eventObj,
type,
eventListeners;
if (!listeners) {
return this; // No listeners at all
}
if (event instanceof _GpfEvent) {
eventObj = event;
type = event.type;
} else {
type = event;
}
eventListeners = this._eventDispatcherListeners[type];
if (undefined === eventListeners) {
return this; // Nothing listeners for this event
}
if (!eventObj) {
eventObj = new _GpfEvent(type, params, this);
}
_gpfTriggerListeners(eventObj, eventListeners);
return eventObj;
} | [
"function",
"_gpfDispatchEvent",
"(",
"event",
",",
"params",
")",
"{",
"/*jshint validthis:true*/",
"// will be invoked as an object method",
"var",
"listeners",
"=",
"this",
".",
"_eventDispatcherListeners",
",",
"eventObj",
",",
"type",
",",
"eventListeners",
";",
"i... | Broadcast the event
@param {String|gpf.events.Event} event name or object
@param {Object} [params={}] event parameters
@return {gpf.events.Event} | [
"Broadcast",
"the",
"event"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/dispatch.js#L81-L105 |
29,362 | ArnaudBuchholz/gpf-js | make/ast.js | function (src) {
// https://github.com/Constellation/escodegen/issues/85
let ast = esprima.parse(src, {
range: true,
tokens: true,
comment: true
});
ast = escodegen.attachComments(ast, ast.comments, ast.tokens);
delete ast.tokens;
delete ast.comments;
return ast;
} | javascript | function (src) {
// https://github.com/Constellation/escodegen/issues/85
let ast = esprima.parse(src, {
range: true,
tokens: true,
comment: true
});
ast = escodegen.attachComments(ast, ast.comments, ast.tokens);
delete ast.tokens;
delete ast.comments;
return ast;
} | [
"function",
"(",
"src",
")",
"{",
"// https://github.com/Constellation/escodegen/issues/85",
"let",
"ast",
"=",
"esprima",
".",
"parse",
"(",
"src",
",",
"{",
"range",
":",
"true",
",",
"tokens",
":",
"true",
",",
"comment",
":",
"true",
"}",
")",
";",
"as... | Transform the source into an AST representation | [
"Transform",
"the",
"source",
"into",
"an",
"AST",
"representation"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/make/ast.js#L284-L295 | |
29,363 | ArnaudBuchholz/gpf-js | make/ast.js | function (ast, setting, debug) {
let optimizer = new Optimizer(ast, setting, debug);
optimizer.analyze();
optimizer.optimize();
return ast;
} | javascript | function (ast, setting, debug) {
let optimizer = new Optimizer(ast, setting, debug);
optimizer.analyze();
optimizer.optimize();
return ast;
} | [
"function",
"(",
"ast",
",",
"setting",
",",
"debug",
")",
"{",
"let",
"optimizer",
"=",
"new",
"Optimizer",
"(",
"ast",
",",
"setting",
",",
"debug",
")",
";",
"optimizer",
".",
"analyze",
"(",
")",
";",
"optimizer",
".",
"optimize",
"(",
")",
";",
... | Detect & apply optimization patterns | [
"Detect",
"&",
"apply",
"optimization",
"patterns"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/make/ast.js#L298-L303 | |
29,364 | makeup-js/makeup-expander | index.js | _onKeyDown | function _onKeyDown(e) {
var keyCode = e.keyCode;
if (keyCode === 13 || keyCode === 32) {
this.keyDownFlag = true; // if host element does not naturally trigger a click event on spacebar, we can force one to trigger here.
// careful! if host already triggers click events naturally, we end up with a "double-click".
if (keyCode === 32 && this.options.simulateSpacebarClick === true) {
this.hostEl.click();
}
}
} | javascript | function _onKeyDown(e) {
var keyCode = e.keyCode;
if (keyCode === 13 || keyCode === 32) {
this.keyDownFlag = true; // if host element does not naturally trigger a click event on spacebar, we can force one to trigger here.
// careful! if host already triggers click events naturally, we end up with a "double-click".
if (keyCode === 32 && this.options.simulateSpacebarClick === true) {
this.hostEl.click();
}
}
} | [
"function",
"_onKeyDown",
"(",
"e",
")",
"{",
"var",
"keyCode",
"=",
"e",
".",
"keyCode",
";",
"if",
"(",
"keyCode",
"===",
"13",
"||",
"keyCode",
"===",
"32",
")",
"{",
"this",
".",
"keyDownFlag",
"=",
"true",
";",
"// if host element does not naturally t... | when options.expandOnClick is true, we set a flag if spacebar or enter are pressed the idea being that this flag is set BEFORE the click event | [
"when",
"options",
".",
"expandOnClick",
"is",
"true",
"we",
"set",
"a",
"flag",
"if",
"spacebar",
"or",
"enter",
"are",
"pressed",
"the",
"idea",
"being",
"that",
"this",
"flag",
"is",
"set",
"BEFORE",
"the",
"click",
"event"
] | 9274abb14e4fd051ddcc609dbc9fe9ac6605631c | https://github.com/makeup-js/makeup-expander/blob/9274abb14e4fd051ddcc609dbc9fe9ac6605631c/index.js#L35-L46 |
29,365 | popeindustries/buddy | lib/utils/string.js | commentStrip | function commentStrip(string) {
// Remove commented lines
string = string.replace(RE_COMMENT_SINGLE_LINE, '');
string = string.replace(RE_COMMENT_MULTI_LINES, '');
return string;
} | javascript | function commentStrip(string) {
// Remove commented lines
string = string.replace(RE_COMMENT_SINGLE_LINE, '');
string = string.replace(RE_COMMENT_MULTI_LINES, '');
return string;
} | [
"function",
"commentStrip",
"(",
"string",
")",
"{",
"// Remove commented lines",
"string",
"=",
"string",
".",
"replace",
"(",
"RE_COMMENT_SINGLE_LINE",
",",
"''",
")",
";",
"string",
"=",
"string",
".",
"replace",
"(",
"RE_COMMENT_MULTI_LINES",
",",
"''",
")",... | Strip comments from 'string'
@param {String} string
@returns {String} | [
"Strip",
"comments",
"from",
"string"
] | c38afc2e6915743eb6cfcf5aba59a8699142c7a5 | https://github.com/popeindustries/buddy/blob/c38afc2e6915743eb6cfcf5aba59a8699142c7a5/lib/utils/string.js#L31-L36 |
29,366 | popeindustries/buddy | lib/utils/string.js | commentWrap | function commentWrap(string, type) {
let open, close;
if (type == 'html') {
open = '<!-- ';
close = ' -->';
} else {
open = '/* ';
close = ' */';
}
return open + string + close;
} | javascript | function commentWrap(string, type) {
let open, close;
if (type == 'html') {
open = '<!-- ';
close = ' -->';
} else {
open = '/* ';
close = ' */';
}
return open + string + close;
} | [
"function",
"commentWrap",
"(",
"string",
",",
"type",
")",
"{",
"let",
"open",
",",
"close",
";",
"if",
"(",
"type",
"==",
"'html'",
")",
"{",
"open",
"=",
"'<!-- '",
";",
"close",
"=",
"' -->'",
";",
"}",
"else",
"{",
"open",
"=",
"'/* '",
";",
... | Wrap 'string' in comment based on 'type'
@param {String} string
@param {String} type
@returns {String} | [
"Wrap",
"string",
"in",
"comment",
"based",
"on",
"type"
] | c38afc2e6915743eb6cfcf5aba59a8699142c7a5 | https://github.com/popeindustries/buddy/blob/c38afc2e6915743eb6cfcf5aba59a8699142c7a5/lib/utils/string.js#L53-L65 |
29,367 | popeindustries/buddy | lib/utils/string.js | indent | function indent(string, column) {
const spaces = new Array(++column).join(COLUMN);
return string.replace(RE_LINE_BEGIN, spaces);
} | javascript | function indent(string, column) {
const spaces = new Array(++column).join(COLUMN);
return string.replace(RE_LINE_BEGIN, spaces);
} | [
"function",
"indent",
"(",
"string",
",",
"column",
")",
"{",
"const",
"spaces",
"=",
"new",
"Array",
"(",
"++",
"column",
")",
".",
"join",
"(",
"COLUMN",
")",
";",
"return",
"string",
".",
"replace",
"(",
"RE_LINE_BEGIN",
",",
"spaces",
")",
";",
"... | Indent the given 'string' a specific number of columns
@param {String} string
@param {Int} column
@returns {String} | [
"Indent",
"the",
"given",
"string",
"a",
"specific",
"number",
"of",
"columns"
] | c38afc2e6915743eb6cfcf5aba59a8699142c7a5 | https://github.com/popeindustries/buddy/blob/c38afc2e6915743eb6cfcf5aba59a8699142c7a5/lib/utils/string.js#L73-L77 |
29,368 | popeindustries/buddy | lib/utils/string.js | uniqueMatch | function uniqueMatch(string, regexp) {
const results = [];
let match;
while ((match = regexp.exec(string))) {
results.push({
context: match[0],
match: match[1] || ''
});
}
// Filter duplicates
return unique(results, isEqual);
} | javascript | function uniqueMatch(string, regexp) {
const results = [];
let match;
while ((match = regexp.exec(string))) {
results.push({
context: match[0],
match: match[1] || ''
});
}
// Filter duplicates
return unique(results, isEqual);
} | [
"function",
"uniqueMatch",
"(",
"string",
",",
"regexp",
")",
"{",
"const",
"results",
"=",
"[",
"]",
";",
"let",
"match",
";",
"while",
"(",
"(",
"match",
"=",
"regexp",
".",
"exec",
"(",
"string",
")",
")",
")",
"{",
"results",
".",
"push",
"(",
... | Match unique occurrences in 'string'
@param {String} string
@param {RegExp} regexp
@returns {Array} | [
"Match",
"unique",
"occurrences",
"in",
"string"
] | c38afc2e6915743eb6cfcf5aba59a8699142c7a5 | https://github.com/popeindustries/buddy/blob/c38afc2e6915743eb6cfcf5aba59a8699142c7a5/lib/utils/string.js#L85-L98 |
29,369 | ArnaudBuchholz/gpf-js | src/host/java.js | _gpfHostJava | function _gpfHostJava () {
_gpfDosPath = String(java.lang.System.getProperty("file.separator")) === "\\";
// Define console APIs
_gpfMainContext.console = _gpfConsoleGenerate(print);
/* istanbul ignore next */ // exit.1
_gpfExit = function (code) {
java.lang.System.exit(code);
};
} | javascript | function _gpfHostJava () {
_gpfDosPath = String(java.lang.System.getProperty("file.separator")) === "\\";
// Define console APIs
_gpfMainContext.console = _gpfConsoleGenerate(print);
/* istanbul ignore next */ // exit.1
_gpfExit = function (code) {
java.lang.System.exit(code);
};
} | [
"function",
"_gpfHostJava",
"(",
")",
"{",
"_gpfDosPath",
"=",
"String",
"(",
"java",
".",
"lang",
".",
"System",
".",
"getProperty",
"(",
"\"file.separator\"",
")",
")",
"===",
"\"\\\\\"",
";",
"// Define console APIs",
"_gpfMainContext",
".",
"console",
"=",
... | Common implementation for Java hosts
@since 0.2.4 | [
"Common",
"implementation",
"for",
"Java",
"hosts"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/host/java.js#L28-L40 |
29,370 | ArnaudBuchholz/gpf-js | lost+found/src/xnode.js | function (name) {
var result, member, mappedName;
if (null === this._attributes) {
this._members();
}
if (undefined === name) {
result = {};
for (member in this._attributes) {
if (this._attributes.hasOwnProperty(member)) {
mappedName = this._attributes[member];
result[mappedName] = this._obj[member];
}
}
return result;
}
for (member in this._attributes) {
if (this._attributes.hasOwnProperty(member)) {
if (name === this._attributes[member]) {
return this._obj[member];
}
}
}
return undefined;
} | javascript | function (name) {
var result, member, mappedName;
if (null === this._attributes) {
this._members();
}
if (undefined === name) {
result = {};
for (member in this._attributes) {
if (this._attributes.hasOwnProperty(member)) {
mappedName = this._attributes[member];
result[mappedName] = this._obj[member];
}
}
return result;
}
for (member in this._attributes) {
if (this._attributes.hasOwnProperty(member)) {
if (name === this._attributes[member]) {
return this._obj[member];
}
}
}
return undefined;
} | [
"function",
"(",
"name",
")",
"{",
"var",
"result",
",",
"member",
",",
"mappedName",
";",
"if",
"(",
"null",
"===",
"this",
".",
"_attributes",
")",
"{",
"this",
".",
"_members",
"(",
")",
";",
"}",
"if",
"(",
"undefined",
"===",
"name",
")",
"{",... | region gpf.interfaces.IXmlConstNode
@implements gpf.interfaces.IXmlConstNode:attributes | [
"region",
"gpf",
".",
"interfaces",
".",
"IXmlConstNode"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/xnode.js#L232-L255 | |
29,371 | ArnaudBuchholz/gpf-js | lost+found/src/xnode.js | _nodeToXml | function _nodeToXml (node, wrapped) {
var
name = node.localName(),
attributes = node.attributes(),
children = node.children(),
text = node.textContent(),
idx;
wrapped.startElement({
uri: "",
localName: name,
qName: name
}, attributes);
// Today the XmlConstNode may not have both children and textual content
if (text) {
wrapped.characters(text);
} else {
for (idx = 0; idx < children.length; ++idx) {
_nodeToXml(children[idx], wrapped);
}
}
wrapped.endElement();
} | javascript | function _nodeToXml (node, wrapped) {
var
name = node.localName(),
attributes = node.attributes(),
children = node.children(),
text = node.textContent(),
idx;
wrapped.startElement({
uri: "",
localName: name,
qName: name
}, attributes);
// Today the XmlConstNode may not have both children and textual content
if (text) {
wrapped.characters(text);
} else {
for (idx = 0; idx < children.length; ++idx) {
_nodeToXml(children[idx], wrapped);
}
}
wrapped.endElement();
} | [
"function",
"_nodeToXml",
"(",
"node",
",",
"wrapped",
")",
"{",
"var",
"name",
"=",
"node",
".",
"localName",
"(",
")",
",",
"attributes",
"=",
"node",
".",
"attributes",
"(",
")",
",",
"children",
"=",
"node",
".",
"children",
"(",
")",
",",
"text"... | Serialize the node into an gpf.interfaces.IXmlContentHandler
@param {gpf.interfaces.IXmlConstNode} node Node to serialize
@param {gpf.interfaces.wrap(IXmlContentHandler)} wrapped XML Content | [
"Serialize",
"the",
"node",
"into",
"an",
"gpf",
".",
"interfaces",
".",
"IXmlContentHandler"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/xnode.js#L405-L426 |
29,372 | ArnaudBuchholz/gpf-js | src/define/detect.js | _gpfDefineBuildTypedEntity | function _gpfDefineBuildTypedEntity (definition) {
var EntityBuilder = _gpfDefineRead$TypedProperties(definition),
entityDefinition;
if (!EntityBuilder) {
EntityBuilder = _gpfDefineCheck$TypeProperty(definition);
}
entityDefinition = new EntityBuilder(definition);
entityDefinition.check();
return entityDefinition;
} | javascript | function _gpfDefineBuildTypedEntity (definition) {
var EntityBuilder = _gpfDefineRead$TypedProperties(definition),
entityDefinition;
if (!EntityBuilder) {
EntityBuilder = _gpfDefineCheck$TypeProperty(definition);
}
entityDefinition = new EntityBuilder(definition);
entityDefinition.check();
return entityDefinition;
} | [
"function",
"_gpfDefineBuildTypedEntity",
"(",
"definition",
")",
"{",
"var",
"EntityBuilder",
"=",
"_gpfDefineRead$TypedProperties",
"(",
"definition",
")",
",",
"entityDefinition",
";",
"if",
"(",
"!",
"EntityBuilder",
")",
"{",
"EntityBuilder",
"=",
"_gpfDefineChec... | Factory to create the correct entity type
@param {Object} definition Entity definition literal object
@return {_GpfEntityDefinition} Entity definition instance
@throws {gpf.Error.InvalidEntityType}
@since 0.1.6 | [
"Factory",
"to",
"create",
"the",
"correct",
"entity",
"type"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/define/detect.js#L78-L87 |
29,373 | ArnaudBuchholz/gpf-js | res/sources/array.js | function (callback, thisArg) {
var me = this;
this._sources.forEach(function (source, index) {
callback(me._update(source), index);
}, thisArg);
} | javascript | function (callback, thisArg) {
var me = this;
this._sources.forEach(function (source, index) {
callback(me._update(source), index);
}, thisArg);
} | [
"function",
"(",
"callback",
",",
"thisArg",
")",
"{",
"var",
"me",
"=",
"this",
";",
"this",
".",
"_sources",
".",
"forEach",
"(",
"function",
"(",
"source",
",",
"index",
")",
"{",
"callback",
"(",
"me",
".",
"_update",
"(",
"source",
")",
",",
"... | Enumerate all sources
@param {Function} callback Called on each source
@param {*} thisArg This context | [
"Enumerate",
"all",
"sources"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/res/sources/array.js#L56-L61 | |
29,374 | ArnaudBuchholz/gpf-js | res/sources/array.js | function (name) {
var result;
this._sources.every(function (source) {
if (source.getName() === name) {
result = this._update(source);
return false;
}
return true;
}, this);
return result;
} | javascript | function (name) {
var result;
this._sources.every(function (source) {
if (source.getName() === name) {
result = this._update(source);
return false;
}
return true;
}, this);
return result;
} | [
"function",
"(",
"name",
")",
"{",
"var",
"result",
";",
"this",
".",
"_sources",
".",
"every",
"(",
"function",
"(",
"source",
")",
"{",
"if",
"(",
"source",
".",
"getName",
"(",
")",
"===",
"name",
")",
"{",
"result",
"=",
"this",
".",
"_update",... | Get the source by name
@param {String} name Name of the source name to retreive
@return {Source|undefined} Source which name matches the parameter | [
"Get",
"the",
"source",
"by",
"name"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/res/sources/array.js#L69-L79 | |
29,375 | ArnaudBuchholz/gpf-js | res/sources/array.js | function (name) {
var dependencies = this.byName(name).getDependencies(),
names = this.getNames(),
minIndex = 1; // 0 being boot
dependencies.forEach(function (dependencyName) {
var index = names.indexOf(dependencyName);
++index;
if (index > minIndex) {
minIndex = index;
}
});
return minIndex;
} | javascript | function (name) {
var dependencies = this.byName(name).getDependencies(),
names = this.getNames(),
minIndex = 1; // 0 being boot
dependencies.forEach(function (dependencyName) {
var index = names.indexOf(dependencyName);
++index;
if (index > minIndex) {
minIndex = index;
}
});
return minIndex;
} | [
"function",
"(",
"name",
")",
"{",
"var",
"dependencies",
"=",
"this",
".",
"byName",
"(",
"name",
")",
".",
"getDependencies",
"(",
")",
",",
"names",
"=",
"this",
".",
"getNames",
"(",
")",
",",
"minIndex",
"=",
"1",
";",
"// 0 being boot",
"dependen... | Based on its dependencies, compute the minimum index of the module.
@param {String} name Source Name
@return {Number} Source index before which the source can't be moved | [
"Based",
"on",
"its",
"dependencies",
"compute",
"the",
"minimum",
"index",
"of",
"the",
"module",
"."
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/res/sources/array.js#L108-L120 | |
29,376 | ArnaudBuchholz/gpf-js | res/sources/array.js | function (sourceName, referenceSourceName) {
var sourceToMove,
sourcePos,
referenceSourcePos;
if (!this._sources.every(function (source, index) {
var name = source.getName();
if (name === sourceName) {
sourceToMove = source;
sourcePos = index;
} else if (name === referenceSourceName) {
referenceSourcePos = index;
}
return sourcePos === undefined || referenceSourcePos === undefined;
})) {
var KEEP_ITEM = 0,
REMOVE_ITEM = 1;
this._sources.splice(sourcePos, REMOVE_ITEM);
if (sourcePos > referenceSourcePos) {
++referenceSourcePos;
}
this._sources.splice(referenceSourcePos, KEEP_ITEM, sourceToMove);
this._rebuildSourcesIndex();
}
} | javascript | function (sourceName, referenceSourceName) {
var sourceToMove,
sourcePos,
referenceSourcePos;
if (!this._sources.every(function (source, index) {
var name = source.getName();
if (name === sourceName) {
sourceToMove = source;
sourcePos = index;
} else if (name === referenceSourceName) {
referenceSourcePos = index;
}
return sourcePos === undefined || referenceSourcePos === undefined;
})) {
var KEEP_ITEM = 0,
REMOVE_ITEM = 1;
this._sources.splice(sourcePos, REMOVE_ITEM);
if (sourcePos > referenceSourcePos) {
++referenceSourcePos;
}
this._sources.splice(referenceSourcePos, KEEP_ITEM, sourceToMove);
this._rebuildSourcesIndex();
}
} | [
"function",
"(",
"sourceName",
",",
"referenceSourceName",
")",
"{",
"var",
"sourceToMove",
",",
"sourcePos",
",",
"referenceSourcePos",
";",
"if",
"(",
"!",
"this",
".",
"_sources",
".",
"every",
"(",
"function",
"(",
"source",
",",
"index",
")",
"{",
"va... | Moves source after the referenced one
@param {String} sourceName Name of the source to move
@param {String} referenceSourceName Name of the source to be used as a position reference | [
"Moves",
"source",
"after",
"the",
"referenced",
"one"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/res/sources/array.js#L150-L173 | |
29,377 | ArnaudBuchholz/gpf-js | res/sources/array.js | function (checkDictionary) {
this._checkDictionary = checkDictionary;
var newSources = Object.keys(checkDictionary)
.filter(function (name) {
return checkDictionary[name] === "new";
})
.map(function (name) {
return new Source(this, {
name: name,
load: false
}, null);
}, this);
// Add missing sources after the last loaded one
if (newSources.length) {
this.sources = this.sources.concat(newSources);
}
} | javascript | function (checkDictionary) {
this._checkDictionary = checkDictionary;
var newSources = Object.keys(checkDictionary)
.filter(function (name) {
return checkDictionary[name] === "new";
})
.map(function (name) {
return new Source(this, {
name: name,
load: false
}, null);
}, this);
// Add missing sources after the last loaded one
if (newSources.length) {
this.sources = this.sources.concat(newSources);
}
} | [
"function",
"(",
"checkDictionary",
")",
"{",
"this",
".",
"_checkDictionary",
"=",
"checkDictionary",
";",
"var",
"newSources",
"=",
"Object",
".",
"keys",
"(",
"checkDictionary",
")",
".",
"filter",
"(",
"function",
"(",
"name",
")",
"{",
"return",
"checkD... | Provide information about sources
@param {Object} checkDictionary Result of the check mechanism | [
"Provide",
"information",
"about",
"sources"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/res/sources/array.js#L192-L208 | |
29,378 | azerion/log4js-logstash | index.js | logstashLayout | function logstashLayout(logEvt, fields) {
var messageData = logEvt.data[0],
log = {
'@timestamp': (new Date()).toISOString(),
'@fields': {
category: logEvt.categoryName,
level: logEvt.level.levelStr
},
'@message' : (toType(messageData) === "string") ? messageData : JSON.stringify(messageData)
}
for (var key in fields) {
if (typeof fields[key] !== 'function') {
log['@fields'][key] = fields[key];
}
}
return JSON.stringify(log) + '\n';
} | javascript | function logstashLayout(logEvt, fields) {
var messageData = logEvt.data[0],
log = {
'@timestamp': (new Date()).toISOString(),
'@fields': {
category: logEvt.categoryName,
level: logEvt.level.levelStr
},
'@message' : (toType(messageData) === "string") ? messageData : JSON.stringify(messageData)
}
for (var key in fields) {
if (typeof fields[key] !== 'function') {
log['@fields'][key] = fields[key];
}
}
return JSON.stringify(log) + '\n';
} | [
"function",
"logstashLayout",
"(",
"logEvt",
",",
"fields",
")",
"{",
"var",
"messageData",
"=",
"logEvt",
".",
"data",
"[",
"0",
"]",
",",
"log",
"=",
"{",
"'@timestamp'",
":",
"(",
"new",
"Date",
"(",
")",
")",
".",
"toISOString",
"(",
")",
",",
... | Simple layout parser for logstash message.
If message type is not string, parser will convert message into string using JSON.stringify.
@param logEvt, fields
@returns {{@timestamp: string, @fields: {category: (categoryName|*), level: (levelStr|*)}}} | [
"Simple",
"layout",
"parser",
"for",
"logstash",
"message",
".",
"If",
"message",
"type",
"is",
"not",
"string",
"parser",
"will",
"convert",
"message",
"into",
"string",
"using",
"JSON",
".",
"stringify",
"."
] | 996e098337c334994d23fb62d0f5ef865fb03861 | https://github.com/azerion/log4js-logstash/blob/996e098337c334994d23fb62d0f5ef865fb03861/index.js#L17-L35 |
29,379 | azerion/log4js-logstash | index.js | logStashAppender | function logStashAppender(config, fields, layout) {
var time = process.hrtime(),
messages = [],
timeOutId = 0;
layout = layout || logstashLayout;
//Setup the connection to logstash
function pushToStash(config, msg) {
var client = net.connect({host: config.host, port: config.port}, function () {
client.write(msg);
client.end();
});
//Fail silently
client.on('error', function (evt) {
if (true === config.debug) {
console.log('An error happened in the logstash appender!', evt);
}
});
}
return function (logEvt) {
//do stuff with the logging event
var data = layout(logEvt, fields);
if (config.batch === true) {
messages.push(data);
clearTimeout(timeOutId);
if ((process.hrtime(time)[0] >= config.batchTimeout || messages.length > config.batchSize)) {
pushToStash(config, messages.join(''));
time = process.hrtime();
messages = [];
} else {
timeOutId = setTimeout(function () {
pushToStash(config, messages.join(''));
time = process.hrtime();
messages = [];
}, 1000);
}
} else {
pushToStash(config, data);
}
};
} | javascript | function logStashAppender(config, fields, layout) {
var time = process.hrtime(),
messages = [],
timeOutId = 0;
layout = layout || logstashLayout;
//Setup the connection to logstash
function pushToStash(config, msg) {
var client = net.connect({host: config.host, port: config.port}, function () {
client.write(msg);
client.end();
});
//Fail silently
client.on('error', function (evt) {
if (true === config.debug) {
console.log('An error happened in the logstash appender!', evt);
}
});
}
return function (logEvt) {
//do stuff with the logging event
var data = layout(logEvt, fields);
if (config.batch === true) {
messages.push(data);
clearTimeout(timeOutId);
if ((process.hrtime(time)[0] >= config.batchTimeout || messages.length > config.batchSize)) {
pushToStash(config, messages.join(''));
time = process.hrtime();
messages = [];
} else {
timeOutId = setTimeout(function () {
pushToStash(config, messages.join(''));
time = process.hrtime();
messages = [];
}, 1000);
}
} else {
pushToStash(config, data);
}
};
} | [
"function",
"logStashAppender",
"(",
"config",
",",
"fields",
",",
"layout",
")",
"{",
"var",
"time",
"=",
"process",
".",
"hrtime",
"(",
")",
",",
"messages",
"=",
"[",
"]",
",",
"timeOutId",
"=",
"0",
";",
"layout",
"=",
"layout",
"||",
"logstashLayo... | The appender, Gives us the function used for log4js.
It Supports batching of commands, we use the json_lines codec for this library,
so the \n are mandatory
@param config
@param fields
@param layout
@returns {Function} | [
"The",
"appender",
"Gives",
"us",
"the",
"function",
"used",
"for",
"log4js",
".",
"It",
"Supports",
"batching",
"of",
"commands",
"we",
"use",
"the",
"json_lines",
"codec",
"for",
"this",
"library",
"so",
"the",
"\\",
"n",
"are",
"mandatory"
] | 996e098337c334994d23fb62d0f5ef865fb03861 | https://github.com/azerion/log4js-logstash/blob/996e098337c334994d23fb62d0f5ef865fb03861/index.js#L47-L90 |
29,380 | azerion/log4js-logstash | index.js | pushToStash | function pushToStash(config, msg) {
var client = net.connect({host: config.host, port: config.port}, function () {
client.write(msg);
client.end();
});
//Fail silently
client.on('error', function (evt) {
if (true === config.debug) {
console.log('An error happened in the logstash appender!', evt);
}
});
} | javascript | function pushToStash(config, msg) {
var client = net.connect({host: config.host, port: config.port}, function () {
client.write(msg);
client.end();
});
//Fail silently
client.on('error', function (evt) {
if (true === config.debug) {
console.log('An error happened in the logstash appender!', evt);
}
});
} | [
"function",
"pushToStash",
"(",
"config",
",",
"msg",
")",
"{",
"var",
"client",
"=",
"net",
".",
"connect",
"(",
"{",
"host",
":",
"config",
".",
"host",
",",
"port",
":",
"config",
".",
"port",
"}",
",",
"function",
"(",
")",
"{",
"client",
".",
... | Setup the connection to logstash | [
"Setup",
"the",
"connection",
"to",
"logstash"
] | 996e098337c334994d23fb62d0f5ef865fb03861 | https://github.com/azerion/log4js-logstash/blob/996e098337c334994d23fb62d0f5ef865fb03861/index.js#L55-L66 |
29,381 | azerion/log4js-logstash | index.js | configure | function configure(config) {
var key,
layout = null,
fields = {},
options = {
port: (typeof config.port === "number") ? config.port : 5959,
host: (typeof config.host === "string") ? config.host : 'localhost',
debug: config.debug || false
};
if (config.batch) {
options.batch = true;
options.batchSize = config.batch.size;
options.batchTimeout = config.batch.timeout;
}
if (config.fields && typeof config.fields === 'object') {
for (key in config.fields) {
if (typeof config.fields[key] !== 'function') {
fields[key] = config.fields[key];
}
}
}
return logStashAppender(options, fields, layout);
} | javascript | function configure(config) {
var key,
layout = null,
fields = {},
options = {
port: (typeof config.port === "number") ? config.port : 5959,
host: (typeof config.host === "string") ? config.host : 'localhost',
debug: config.debug || false
};
if (config.batch) {
options.batch = true;
options.batchSize = config.batch.size;
options.batchTimeout = config.batch.timeout;
}
if (config.fields && typeof config.fields === 'object') {
for (key in config.fields) {
if (typeof config.fields[key] !== 'function') {
fields[key] = config.fields[key];
}
}
}
return logStashAppender(options, fields, layout);
} | [
"function",
"configure",
"(",
"config",
")",
"{",
"var",
"key",
",",
"layout",
"=",
"null",
",",
"fields",
"=",
"{",
"}",
",",
"options",
"=",
"{",
"port",
":",
"(",
"typeof",
"config",
".",
"port",
"===",
"\"number\"",
")",
"?",
"config",
".",
"po... | Config method, calls logStashAppender to return the logging function
@param config
@returns {Function} | [
"Config",
"method",
"calls",
"logStashAppender",
"to",
"return",
"the",
"logging",
"function"
] | 996e098337c334994d23fb62d0f5ef865fb03861 | https://github.com/azerion/log4js-logstash/blob/996e098337c334994d23fb62d0f5ef865fb03861/index.js#L98-L122 |
29,382 | ArnaudBuchholz/gpf-js | src/http/helpers.js | _gpfHttpParseHeaders | function _gpfHttpParseHeaders (headers) {
var result = {};
_gpfArrayForEach(_gpfRegExpForEach(_gpfHttpHeadersParserRE, headers), function (match) {
result[match[_GPF_HTTP_HELPERS_HEADER_NAME]] = match[_GPF_HTTP_HELPERS_HEADER_VALUE];
});
return result;
} | javascript | function _gpfHttpParseHeaders (headers) {
var result = {};
_gpfArrayForEach(_gpfRegExpForEach(_gpfHttpHeadersParserRE, headers), function (match) {
result[match[_GPF_HTTP_HELPERS_HEADER_NAME]] = match[_GPF_HTTP_HELPERS_HEADER_VALUE];
});
return result;
} | [
"function",
"_gpfHttpParseHeaders",
"(",
"headers",
")",
"{",
"var",
"result",
"=",
"{",
"}",
";",
"_gpfArrayForEach",
"(",
"_gpfRegExpForEach",
"(",
"_gpfHttpHeadersParserRE",
",",
"headers",
")",
",",
"function",
"(",
"match",
")",
"{",
"result",
"[",
"match... | Parse HTTP response headers
@param {String} headers Response headers
@return {Object} headers dictionary
@since 0.2.1 | [
"Parse",
"HTTP",
"response",
"headers"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/http/helpers.js#L47-L53 |
29,383 | ArnaudBuchholz/gpf-js | src/http/helpers.js | _gpfHttpGenSetHeaders | function _gpfHttpGenSetHeaders (methodName) {
return function (httpObj, headers) {
if (headers) {
Object.keys(headers).forEach(function (headerName) {
httpObj[methodName](headerName, headers[headerName]);
});
}
};
} | javascript | function _gpfHttpGenSetHeaders (methodName) {
return function (httpObj, headers) {
if (headers) {
Object.keys(headers).forEach(function (headerName) {
httpObj[methodName](headerName, headers[headerName]);
});
}
};
} | [
"function",
"_gpfHttpGenSetHeaders",
"(",
"methodName",
")",
"{",
"return",
"function",
"(",
"httpObj",
",",
"headers",
")",
"{",
"if",
"(",
"headers",
")",
"{",
"Object",
".",
"keys",
"(",
"headers",
")",
".",
"forEach",
"(",
"function",
"(",
"headerName"... | Generates a function that transmit headers to the http object
@param {String} methodName Name of the method to call
@return {Function} Method to set the headers
@gpf:closure
@since 0.2.1 | [
"Generates",
"a",
"function",
"that",
"transmit",
"headers",
"to",
"the",
"http",
"object"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/http/helpers.js#L63-L71 |
29,384 | ArnaudBuchholz/gpf-js | src/http/helpers.js | _gpfHttpGenSend | function _gpfHttpGenSend (methodName) {
return function (httpObj, data) {
if (data) {
httpObj[methodName](data);
} else {
httpObj[methodName]();
}
};
} | javascript | function _gpfHttpGenSend (methodName) {
return function (httpObj, data) {
if (data) {
httpObj[methodName](data);
} else {
httpObj[methodName]();
}
};
} | [
"function",
"_gpfHttpGenSend",
"(",
"methodName",
")",
"{",
"return",
"function",
"(",
"httpObj",
",",
"data",
")",
"{",
"if",
"(",
"data",
")",
"{",
"httpObj",
"[",
"methodName",
"]",
"(",
"data",
")",
";",
"}",
"else",
"{",
"httpObj",
"[",
"methodNam... | Generates a function that implements the http send logic
@param {String} methodName Name of the method to call
@return {Function} Method to trigger the send
@gpf:closure
@since 0.2.1 | [
"Generates",
"a",
"function",
"that",
"implements",
"the",
"http",
"send",
"logic"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/http/helpers.js#L81-L89 |
29,385 | popeindustries/buddy | lib/utils/sourceMap.js | create | function create(content, url) {
url = url || '<source>';
const map = new SourceMapGenerator({ file: url });
const lines = content.split('\n');
for (let l = 1, n = lines.length; l <= n; l++) {
// Skip empty
if (lines[l - 1]) {
map.addMapping({
source: url,
original: { line: l, column: 0 },
generated: { line: l, column: 0 }
});
}
}
map.setSourceContent(url, content);
return map;
} | javascript | function create(content, url) {
url = url || '<source>';
const map = new SourceMapGenerator({ file: url });
const lines = content.split('\n');
for (let l = 1, n = lines.length; l <= n; l++) {
// Skip empty
if (lines[l - 1]) {
map.addMapping({
source: url,
original: { line: l, column: 0 },
generated: { line: l, column: 0 }
});
}
}
map.setSourceContent(url, content);
return map;
} | [
"function",
"create",
"(",
"content",
",",
"url",
")",
"{",
"url",
"=",
"url",
"||",
"'<source>'",
";",
"const",
"map",
"=",
"new",
"SourceMapGenerator",
"(",
"{",
"file",
":",
"url",
"}",
")",
";",
"const",
"lines",
"=",
"content",
".",
"split",
"("... | Create source map from 'content'
@param {String} content
@param {String} [url]
@returns {SourceMapGenerator} | [
"Create",
"source",
"map",
"from",
"content"
] | c38afc2e6915743eb6cfcf5aba59a8699142c7a5 | https://github.com/popeindustries/buddy/blob/c38afc2e6915743eb6cfcf5aba59a8699142c7a5/lib/utils/sourceMap.js#L20-L38 |
29,386 | popeindustries/buddy | lib/utils/sourceMap.js | createFromMap | function createFromMap(mapObject, content, url) {
url = url || '<source>';
if ('string' == typeof mapObject) {
try {
mapObject = JSON.parse(mapObject);
} catch (err) {
mapObject = {
version: 3,
names: [],
mappings: '',
file: ''
};
}
}
if (emptySources(mapObject)) {
mapObject.sources = [url];
mapObject.sourcesContent = [content];
}
return SourceMapGenerator.fromSourceMap(new SourceMapConsumer(mapObject));
} | javascript | function createFromMap(mapObject, content, url) {
url = url || '<source>';
if ('string' == typeof mapObject) {
try {
mapObject = JSON.parse(mapObject);
} catch (err) {
mapObject = {
version: 3,
names: [],
mappings: '',
file: ''
};
}
}
if (emptySources(mapObject)) {
mapObject.sources = [url];
mapObject.sourcesContent = [content];
}
return SourceMapGenerator.fromSourceMap(new SourceMapConsumer(mapObject));
} | [
"function",
"createFromMap",
"(",
"mapObject",
",",
"content",
",",
"url",
")",
"{",
"url",
"=",
"url",
"||",
"'<source>'",
";",
"if",
"(",
"'string'",
"==",
"typeof",
"mapObject",
")",
"{",
"try",
"{",
"mapObject",
"=",
"JSON",
".",
"parse",
"(",
"map... | Create source map from 'mapObject' and 'content'
@param {Object} mapObject
@param {String} content
@param {String} [url]
@returns {SourceMapGenerator} | [
"Create",
"source",
"map",
"from",
"mapObject",
"and",
"content"
] | c38afc2e6915743eb6cfcf5aba59a8699142c7a5 | https://github.com/popeindustries/buddy/blob/c38afc2e6915743eb6cfcf5aba59a8699142c7a5/lib/utils/sourceMap.js#L47-L67 |
29,387 | popeindustries/buddy | lib/utils/sourceMap.js | insert | function insert(outMap, inMap, length, index) {
// Move existing mappings
if (length) {
outMap._mappings.unsortedForEach(mapping => {
if (mapping.generatedLine > index) mapping.generatedLine += length;
});
}
// Add new mappings
if (inMap) {
const inConsumer = new SourceMapConsumer(inMap.toJSON());
inConsumer.eachMapping(mapping => {
outMap.addMapping({
source: mapping.source,
original: mapping.source == null
? null
: {
line: mapping.originalLine,
column: mapping.originalColumn
},
generated: {
line: index + mapping.generatedLine - 1,
column: mapping.generatedColumn
}
});
});
inConsumer.sources.forEach((source, idx) => {
outMap.setSourceContent(source, inConsumer.sourcesContent[idx]);
});
}
} | javascript | function insert(outMap, inMap, length, index) {
// Move existing mappings
if (length) {
outMap._mappings.unsortedForEach(mapping => {
if (mapping.generatedLine > index) mapping.generatedLine += length;
});
}
// Add new mappings
if (inMap) {
const inConsumer = new SourceMapConsumer(inMap.toJSON());
inConsumer.eachMapping(mapping => {
outMap.addMapping({
source: mapping.source,
original: mapping.source == null
? null
: {
line: mapping.originalLine,
column: mapping.originalColumn
},
generated: {
line: index + mapping.generatedLine - 1,
column: mapping.generatedColumn
}
});
});
inConsumer.sources.forEach((source, idx) => {
outMap.setSourceContent(source, inConsumer.sourcesContent[idx]);
});
}
} | [
"function",
"insert",
"(",
"outMap",
",",
"inMap",
",",
"length",
",",
"index",
")",
"{",
"// Move existing mappings",
"if",
"(",
"length",
")",
"{",
"outMap",
".",
"_mappings",
".",
"unsortedForEach",
"(",
"mapping",
"=>",
"{",
"if",
"(",
"mapping",
".",
... | Insert line in 'outMap' with 'inMap' at line 'index'
@param {SourceMapGenerator} outMap
@param {SourceMapGenerator} [inMap]
@param {Number} length
@param {Number} index | [
"Insert",
"line",
"in",
"outMap",
"with",
"inMap",
"at",
"line",
"index"
] | c38afc2e6915743eb6cfcf5aba59a8699142c7a5 | https://github.com/popeindustries/buddy/blob/c38afc2e6915743eb6cfcf5aba59a8699142c7a5/lib/utils/sourceMap.js#L156-L188 |
29,388 | popeindustries/buddy | lib/utils/sourceMap.js | emptySources | function emptySources(map) {
return !map.sources ||
!map.sources.length ||
!map.sourcesContent ||
!map.sourcesContent.length ||
map.sources.length != map.sourcesContent.length;
} | javascript | function emptySources(map) {
return !map.sources ||
!map.sources.length ||
!map.sourcesContent ||
!map.sourcesContent.length ||
map.sources.length != map.sourcesContent.length;
} | [
"function",
"emptySources",
"(",
"map",
")",
"{",
"return",
"!",
"map",
".",
"sources",
"||",
"!",
"map",
".",
"sources",
".",
"length",
"||",
"!",
"map",
".",
"sourcesContent",
"||",
"!",
"map",
".",
"sourcesContent",
".",
"length",
"||",
"map",
".",
... | Determine if 'map' has empty sources
@param {Object} map
@returns {Boolean} | [
"Determine",
"if",
"map",
"has",
"empty",
"sources"
] | c38afc2e6915743eb6cfcf5aba59a8699142c7a5 | https://github.com/popeindustries/buddy/blob/c38afc2e6915743eb6cfcf5aba59a8699142c7a5/lib/utils/sourceMap.js#L195-L201 |
29,389 | SockDrawer/SockBot | providers/nodebb/notification.js | notifyHandler | function notifyHandler(data) {
const notification = Notification.parse(data);
return evalBlacklist(notification)
.then(() => {
forum.emit('log', `Notification ${notification.id}: ${notification.label} received`);
const ids = {
post: notification.postId,
topic: notification.topicId,
user: notification.userId,
pm: -1,
chat: -1
};
return notification.getText()
.then((postData) => forum.Commands.get(ids,
postData, (content) => forum.Post.reply(notification.topicId, notification.postId, content)))
.then((commands) => {
if (commands.commands.length === 0) {
debug(`Emitting events: 'notification' and 'notification:${notification.type}'`);
forum.emit(`notification:${notification.type}`, notification);
forum.emit('notification', notification);
}
return commands;
})
.then((commands) => commands.execute());
}).catch((err) => {
if (err === 'Ignoring notification') {
//We do not process the notification, but we can continue with life
return Promise.resolve();
}
throw err;
});
} | javascript | function notifyHandler(data) {
const notification = Notification.parse(data);
return evalBlacklist(notification)
.then(() => {
forum.emit('log', `Notification ${notification.id}: ${notification.label} received`);
const ids = {
post: notification.postId,
topic: notification.topicId,
user: notification.userId,
pm: -1,
chat: -1
};
return notification.getText()
.then((postData) => forum.Commands.get(ids,
postData, (content) => forum.Post.reply(notification.topicId, notification.postId, content)))
.then((commands) => {
if (commands.commands.length === 0) {
debug(`Emitting events: 'notification' and 'notification:${notification.type}'`);
forum.emit(`notification:${notification.type}`, notification);
forum.emit('notification', notification);
}
return commands;
})
.then((commands) => commands.execute());
}).catch((err) => {
if (err === 'Ignoring notification') {
//We do not process the notification, but we can continue with life
return Promise.resolve();
}
throw err;
});
} | [
"function",
"notifyHandler",
"(",
"data",
")",
"{",
"const",
"notification",
"=",
"Notification",
".",
"parse",
"(",
"data",
")",
";",
"return",
"evalBlacklist",
"(",
"notification",
")",
".",
"then",
"(",
"(",
")",
"=>",
"{",
"forum",
".",
"emit",
"(",
... | Handle notifications that arrive
Parse notification from event and process any commands cound within
@private
@param {*} data Notification data
@returns {Promise} Resolved when any commands contained in notificaiton have been processed | [
"Handle",
"notifications",
"that",
"arrive"
] | 043f7e9aa9ec12250889fd825ddcf86709b095a3 | https://github.com/SockDrawer/SockBot/blob/043f7e9aa9ec12250889fd825ddcf86709b095a3/providers/nodebb/notification.js#L386-L418 |
29,390 | SockDrawer/SockBot | providers/nodebb/notification.js | evalBlacklist | function evalBlacklist(notification) {
return new Promise((resolve, reject) => {
const ignoreCategories = forum.config.core.ignoreCategories || [];
//if there's no blacklist, we can ignore the hit for getting the category
if (ignoreCategories.length) {
if (ignoreCategories.some((elem) => elem.toString() === notification.categoryId.toString())) {
forum.emit('log', `Notification from category ${notification.categoryId} ignored`);
return reject('Ignoring notification');
}
}
return resolve(notification);
});
} | javascript | function evalBlacklist(notification) {
return new Promise((resolve, reject) => {
const ignoreCategories = forum.config.core.ignoreCategories || [];
//if there's no blacklist, we can ignore the hit for getting the category
if (ignoreCategories.length) {
if (ignoreCategories.some((elem) => elem.toString() === notification.categoryId.toString())) {
forum.emit('log', `Notification from category ${notification.categoryId} ignored`);
return reject('Ignoring notification');
}
}
return resolve(notification);
});
} | [
"function",
"evalBlacklist",
"(",
"notification",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"const",
"ignoreCategories",
"=",
"forum",
".",
"config",
".",
"core",
".",
"ignoreCategories",
"||",
"[",
"]",
";",... | Evaluate the blacklist.
Determine if we want to process this notification or not based on config settings
@private
@param {*} notification Notification we are parsing
@returns {Promise} Rejects with "Ignoring notification" if we do not process this. Resolves with the notification
otherwise. | [
"Evaluate",
"the",
"blacklist",
"."
] | 043f7e9aa9ec12250889fd825ddcf86709b095a3 | https://github.com/SockDrawer/SockBot/blob/043f7e9aa9ec12250889fd825ddcf86709b095a3/providers/nodebb/notification.js#L431-L444 |
29,391 | ghempton/ember-script | ember-runtime.js | normalizeTuple | function normalizeTuple(target, path) {
var hasThis = HAS_THIS.test(path),
isGlobal = !hasThis && IS_GLOBAL_PATH.test(path),
key;
if (!target || isGlobal) target = Ember.lookup;
if (hasThis) path = path.slice(5);
if (target === Ember.lookup) {
key = firstKey(path);
target = get(target, key);
path = path.slice(key.length+1);
}
// must return some kind of path to be valid else other things will break.
if (!path || path.length===0) throw new Error('Invalid Path');
return [ target, path ];
} | javascript | function normalizeTuple(target, path) {
var hasThis = HAS_THIS.test(path),
isGlobal = !hasThis && IS_GLOBAL_PATH.test(path),
key;
if (!target || isGlobal) target = Ember.lookup;
if (hasThis) path = path.slice(5);
if (target === Ember.lookup) {
key = firstKey(path);
target = get(target, key);
path = path.slice(key.length+1);
}
// must return some kind of path to be valid else other things will break.
if (!path || path.length===0) throw new Error('Invalid Path');
return [ target, path ];
} | [
"function",
"normalizeTuple",
"(",
"target",
",",
"path",
")",
"{",
"var",
"hasThis",
"=",
"HAS_THIS",
".",
"test",
"(",
"path",
")",
",",
"isGlobal",
"=",
"!",
"hasThis",
"&&",
"IS_GLOBAL_PATH",
".",
"test",
"(",
"path",
")",
",",
"key",
";",
"if",
... | assumes path is already normalized | [
"assumes",
"path",
"is",
"already",
"normalized"
] | af6596868bb84c2d43eca30ca0d90244ef3419fd | https://github.com/ghempton/ember-script/blob/af6596868bb84c2d43eca30ca0d90244ef3419fd/ember-runtime.js#L1957-L1975 |
29,392 | ghempton/ember-script | ember-runtime.js | chainsFor | function chainsFor(obj) {
var m = metaFor(obj), ret = m.chains;
if (!ret) {
ret = m.chains = new ChainNode(null, null, obj);
} else if (ret.value() !== obj) {
ret = m.chains = ret.copy(obj);
}
return ret;
} | javascript | function chainsFor(obj) {
var m = metaFor(obj), ret = m.chains;
if (!ret) {
ret = m.chains = new ChainNode(null, null, obj);
} else if (ret.value() !== obj) {
ret = m.chains = ret.copy(obj);
}
return ret;
} | [
"function",
"chainsFor",
"(",
"obj",
")",
"{",
"var",
"m",
"=",
"metaFor",
"(",
"obj",
")",
",",
"ret",
"=",
"m",
".",
"chains",
";",
"if",
"(",
"!",
"ret",
")",
"{",
"ret",
"=",
"m",
".",
"chains",
"=",
"new",
"ChainNode",
"(",
"null",
",",
... | get the chains for the current object. If the current object has chains inherited from the proto they will be cloned and reconfigured for the current object. | [
"get",
"the",
"chains",
"for",
"the",
"current",
"object",
".",
"If",
"the",
"current",
"object",
"has",
"chains",
"inherited",
"from",
"the",
"proto",
"they",
"will",
"be",
"cloned",
"and",
"reconfigured",
"for",
"the",
"current",
"object",
"."
] | af6596868bb84c2d43eca30ca0d90244ef3419fd | https://github.com/ghempton/ember-script/blob/af6596868bb84c2d43eca30ca0d90244ef3419fd/ember-runtime.js#L3411-L3419 |
29,393 | ghempton/ember-script | ember-runtime.js | function() {
var ret = Ember.A([]);
this.forEach(function(o, idx) { ret[idx] = o; });
return ret ;
} | javascript | function() {
var ret = Ember.A([]);
this.forEach(function(o, idx) { ret[idx] = o; });
return ret ;
} | [
"function",
"(",
")",
"{",
"var",
"ret",
"=",
"Ember",
".",
"A",
"(",
"[",
"]",
")",
";",
"this",
".",
"forEach",
"(",
"function",
"(",
"o",
",",
"idx",
")",
"{",
"ret",
"[",
"idx",
"]",
"=",
"o",
";",
"}",
")",
";",
"return",
"ret",
";",
... | Simply converts the enumerable into a genuine array. The order is not
guaranteed. Corresponds to the method implemented by Prototype.
@method toArray
@return {Array} the enumerable as an array. | [
"Simply",
"converts",
"the",
"enumerable",
"into",
"a",
"genuine",
"array",
".",
"The",
"order",
"is",
"not",
"guaranteed",
".",
"Corresponds",
"to",
"the",
"method",
"implemented",
"by",
"Prototype",
"."
] | af6596868bb84c2d43eca30ca0d90244ef3419fd | https://github.com/ghempton/ember-script/blob/af6596868bb84c2d43eca30ca0d90244ef3419fd/ember-runtime.js#L8340-L8344 | |
29,394 | ghempton/ember-script | ember-runtime.js | function() {
if (Ember.Freezable && Ember.Freezable.detect(this)) {
return get(this, 'isFrozen') ? this : this.copy().freeze();
} else {
throw new Error(Ember.String.fmt("%@ does not support freezing", [this]));
}
} | javascript | function() {
if (Ember.Freezable && Ember.Freezable.detect(this)) {
return get(this, 'isFrozen') ? this : this.copy().freeze();
} else {
throw new Error(Ember.String.fmt("%@ does not support freezing", [this]));
}
} | [
"function",
"(",
")",
"{",
"if",
"(",
"Ember",
".",
"Freezable",
"&&",
"Ember",
".",
"Freezable",
".",
"detect",
"(",
"this",
")",
")",
"{",
"return",
"get",
"(",
"this",
",",
"'isFrozen'",
")",
"?",
"this",
":",
"this",
".",
"copy",
"(",
")",
".... | If the object implements `Ember.Freezable`, then this will return a new
copy if the object is not frozen and the receiver if the object is frozen.
Raises an exception if you try to call this method on a object that does
not support freezing.
You should use this method whenever you want a copy of a freezable object
since a freezable object can simply return itself without actually
consuming more memory.
@method frozenCopy
@return {Object} copy of receiver or receiver | [
"If",
"the",
"object",
"implements",
"Ember",
".",
"Freezable",
"then",
"this",
"will",
"return",
"a",
"new",
"copy",
"if",
"the",
"object",
"is",
"not",
"frozen",
"and",
"the",
"receiver",
"if",
"the",
"object",
"is",
"frozen",
"."
] | af6596868bb84c2d43eca30ca0d90244ef3419fd | https://github.com/ghempton/ember-script/blob/af6596868bb84c2d43eca30ca0d90244ef3419fd/ember-runtime.js#L9082-L9088 | |
29,395 | ghempton/ember-script | ember-runtime.js | function(keyName, increment) {
if (!increment) { increment = 1; }
set(this, keyName, (get(this, keyName) || 0)+increment);
return get(this, keyName);
} | javascript | function(keyName, increment) {
if (!increment) { increment = 1; }
set(this, keyName, (get(this, keyName) || 0)+increment);
return get(this, keyName);
} | [
"function",
"(",
"keyName",
",",
"increment",
")",
"{",
"if",
"(",
"!",
"increment",
")",
"{",
"increment",
"=",
"1",
";",
"}",
"set",
"(",
"this",
",",
"keyName",
",",
"(",
"get",
"(",
"this",
",",
"keyName",
")",
"||",
"0",
")",
"+",
"increment... | Set the value of a property to the current value plus some amount.
```javascript
person.incrementProperty('age');
team.incrementProperty('score', 2);
```
@method incrementProperty
@param {String} keyName The name of the property to increment
@param {Object} increment The amount to increment by. Defaults to 1
@return {Object} The new property value | [
"Set",
"the",
"value",
"of",
"a",
"property",
"to",
"the",
"current",
"value",
"plus",
"some",
"amount",
"."
] | af6596868bb84c2d43eca30ca0d90244ef3419fd | https://github.com/ghempton/ember-script/blob/af6596868bb84c2d43eca30ca0d90244ef3419fd/ember-runtime.js#L10072-L10076 | |
29,396 | ArnaudBuchholz/gpf-js | lost+found/src/define_/classdef.js | _gpfGenSuperMember | function _gpfGenSuperMember (superMethod, method) {
return function GpfSuperableMethod () {
var previousSuper = this._super,
result;
// Add a new ._super() method pointing to the base class member
this._super = superMethod;
try {
// Execute the method
result = method.apply(this, arguments);
} finally {
// Remove it after execution
if (undefined === previousSuper) {
delete this._super;
} else {
this._super = previousSuper;
}
}
return result;
};
} | javascript | function _gpfGenSuperMember (superMethod, method) {
return function GpfSuperableMethod () {
var previousSuper = this._super,
result;
// Add a new ._super() method pointing to the base class member
this._super = superMethod;
try {
// Execute the method
result = method.apply(this, arguments);
} finally {
// Remove it after execution
if (undefined === previousSuper) {
delete this._super;
} else {
this._super = previousSuper;
}
}
return result;
};
} | [
"function",
"_gpfGenSuperMember",
"(",
"superMethod",
",",
"method",
")",
"{",
"return",
"function",
"GpfSuperableMethod",
"(",
")",
"{",
"var",
"previousSuper",
"=",
"this",
".",
"_super",
",",
"result",
";",
"// Add a new ._super() method pointing to the base class me... | Generates a closure in which this._super points to the base method of the overridden member
@param {Function} superMethod
@param {Function} method
@return {Function}
@gpf:closure | [
"Generates",
"a",
"closure",
"in",
"which",
"this",
".",
"_super",
"points",
"to",
"the",
"base",
"method",
"of",
"the",
"overridden",
"member"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/define_/classdef.js#L73-L92 |
29,397 | ArnaudBuchholz/gpf-js | lost+found/src/define_/classdef.js | _GpfOldClassDefinition | function _GpfOldClassDefinition (name, Super, definition) {
/*jshint validthis:true*/ // constructor
this._uid = ++_gpfClassDefUID;
_gpfClassDefinitions[this._uid] = this;
this._Subs = [];
if ("function" === typeof name) {
this._name = name.compatibleName() || "anonymous";
// TODO how do we grab the parent constructor (?)
this._Constructor = name;
} else {
this._name = name;
this._Super = Super;
this._definition = definition;
this._build();
}
} | javascript | function _GpfOldClassDefinition (name, Super, definition) {
/*jshint validthis:true*/ // constructor
this._uid = ++_gpfClassDefUID;
_gpfClassDefinitions[this._uid] = this;
this._Subs = [];
if ("function" === typeof name) {
this._name = name.compatibleName() || "anonymous";
// TODO how do we grab the parent constructor (?)
this._Constructor = name;
} else {
this._name = name;
this._Super = Super;
this._definition = definition;
this._build();
}
} | [
"function",
"_GpfOldClassDefinition",
"(",
"name",
",",
"Super",
",",
"definition",
")",
"{",
"/*jshint validthis:true*/",
"// constructor",
"this",
".",
"_uid",
"=",
"++",
"_gpfClassDefUID",
";",
"_gpfClassDefinitions",
"[",
"this",
".",
"_uid",
"]",
"=",
"this",... | An helper to create class and store its information
@param {String|Function} name
@param {Function} Super
@param {Object} definition
@class gpf.ClassDefinition
@constructor | [
"An",
"helper",
"to",
"create",
"class",
"and",
"store",
"its",
"information"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/define_/classdef.js#L117-L132 |
29,398 | ArnaudBuchholz/gpf-js | lost+found/src/define_/classdef.js | function (member, memberValue, visibility) {
if (undefined === visibility) {
visibility = _GPF_VISIBILITY_PUBLIC;
} else {
visibility = _gpfVisibilityKeywords.indexOf(visibility);
if (-1 === visibility) {
gpf.Error.classInvalidVisibility();
}
}
this._addMember(member, memberValue, visibility);
} | javascript | function (member, memberValue, visibility) {
if (undefined === visibility) {
visibility = _GPF_VISIBILITY_PUBLIC;
} else {
visibility = _gpfVisibilityKeywords.indexOf(visibility);
if (-1 === visibility) {
gpf.Error.classInvalidVisibility();
}
}
this._addMember(member, memberValue, visibility);
} | [
"function",
"(",
"member",
",",
"memberValue",
",",
"visibility",
")",
"{",
"if",
"(",
"undefined",
"===",
"visibility",
")",
"{",
"visibility",
"=",
"_GPF_VISIBILITY_PUBLIC",
";",
"}",
"else",
"{",
"visibility",
"=",
"_gpfVisibilityKeywords",
".",
"indexOf",
... | Adds a member to the class definition.
@param {String} member
@param {*} memberValue
@param {String|number} [visibility=_GPF_VISIBILITY_PUBLIC] visibility | [
"Adds",
"a",
"member",
"to",
"the",
"class",
"definition",
"."
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/define_/classdef.js#L201-L211 | |
29,399 | ArnaudBuchholz/gpf-js | lost+found/src/define_/classdef.js | function (member, memberValue, visibility) {
if (_GPF_VISIBILITY_STATIC === visibility) {
_gpfAssert(undefined === this._Constructor[member], "Static members can't be overridden");
this._Constructor[member] = memberValue;
} else if ("constructor" === member) {
this._addConstructor(memberValue, visibility);
} else {
this._addNonStaticMember(member, memberValue, visibility);
}
} | javascript | function (member, memberValue, visibility) {
if (_GPF_VISIBILITY_STATIC === visibility) {
_gpfAssert(undefined === this._Constructor[member], "Static members can't be overridden");
this._Constructor[member] = memberValue;
} else if ("constructor" === member) {
this._addConstructor(memberValue, visibility);
} else {
this._addNonStaticMember(member, memberValue, visibility);
}
} | [
"function",
"(",
"member",
",",
"memberValue",
",",
"visibility",
")",
"{",
"if",
"(",
"_GPF_VISIBILITY_STATIC",
"===",
"visibility",
")",
"{",
"_gpfAssert",
"(",
"undefined",
"===",
"this",
".",
"_Constructor",
"[",
"member",
"]",
",",
"\"Static members can't b... | Adds a member to the class definition
@param {String} member
@param {*} memberValue
@param {number} visibility | [
"Adds",
"a",
"member",
"to",
"the",
"class",
"definition"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/define_/classdef.js#L220-L229 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.