repo
stringlengths 5
67
| path
stringlengths 4
116
| func_name
stringlengths 0
58
| original_string
stringlengths 52
373k
| language
stringclasses 1
value | code
stringlengths 52
373k
| code_tokens
sequence | docstring
stringlengths 4
11.8k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 86
226
| partition
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|---|
makeup-js/makeup-expander | docs/static/bundle.js | define | function define(path, factoryOrObject, options) {
/*
$_mod.def('/baz$3.0.0/lib/index', function(require, exports, module, __filename, __dirname) {
// module source code goes here
});
*/
var globals = options && options.globals;
definitions[path] = factoryOrObject;
if (globals) {
var target = win || global;
for (var i=0;i<globals.length; i++) {
var globalVarName = globals[i];
var globalModule = loadedGlobalsByRealPath[path] = requireModule(path);
target[globalVarName] = globalModule.exports;
}
}
} | javascript | function define(path, factoryOrObject, options) {
/*
$_mod.def('/baz$3.0.0/lib/index', function(require, exports, module, __filename, __dirname) {
// module source code goes here
});
*/
var globals = options && options.globals;
definitions[path] = factoryOrObject;
if (globals) {
var target = win || global;
for (var i=0;i<globals.length; i++) {
var globalVarName = globals[i];
var globalModule = loadedGlobalsByRealPath[path] = requireModule(path);
target[globalVarName] = globalModule.exports;
}
}
} | [
"function",
"define",
"(",
"path",
",",
"factoryOrObject",
",",
"options",
")",
"{",
"var",
"globals",
"=",
"options",
"&&",
"options",
".",
"globals",
";",
"definitions",
"[",
"path",
"]",
"=",
"factoryOrObject",
";",
"if",
"(",
"globals",
")",
"{",
"var",
"target",
"=",
"win",
"||",
"global",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"globals",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"globalVarName",
"=",
"globals",
"[",
"i",
"]",
";",
"var",
"globalModule",
"=",
"loadedGlobalsByRealPath",
"[",
"path",
"]",
"=",
"requireModule",
"(",
"path",
")",
";",
"target",
"[",
"globalVarName",
"]",
"=",
"globalModule",
".",
"exports",
";",
"}",
"}",
"}"
] | Defines a packages whose metadata is used by raptor-loader to load the package. | [
"Defines",
"a",
"packages",
"whose",
"metadata",
"is",
"used",
"by",
"raptor",
"-",
"loader",
"to",
"load",
"the",
"package",
"."
] | 9274abb14e4fd051ddcc609dbc9fe9ac6605631c | https://github.com/makeup-js/makeup-expander/blob/9274abb14e4fd051ddcc609dbc9fe9ac6605631c/docs/static/bundle.js#L177-L196 | train |
makeup-js/makeup-expander | docs/static/bundle.js | normalizePathParts | function normalizePathParts(parts) {
// IMPORTANT: It is assumed that parts[0] === "" because this method is used to
// join an absolute path to a relative path
var i;
var len = 0;
var numParts = parts.length;
for (i = 0; i < numParts; i++) {
var part = parts[i];
if (part === '.') {
// ignore parts with just "."
/*
// if the "." is at end of parts (e.g. ["a", "b", "."]) then trim it off
if (i === numParts - 1) {
//len--;
}
*/
} else if (part === '..') {
// overwrite the previous item by decrementing length
len--;
} else {
// add this part to result and increment length
parts[len] = part;
len++;
}
}
if (len === 1) {
// if we end up with just one part that is empty string
// (which can happen if input is ["", "."]) then return
// string with just the leading slash
return '/';
} else if (len > 2) {
// parts i s
// ["", "a", ""]
// ["", "a", "b", ""]
if (parts[len - 1].length === 0) {
// last part is an empty string which would result in trailing slash
len--;
}
}
// truncate parts to remove unused
parts.length = len;
return parts.join('/');
} | javascript | function normalizePathParts(parts) {
// IMPORTANT: It is assumed that parts[0] === "" because this method is used to
// join an absolute path to a relative path
var i;
var len = 0;
var numParts = parts.length;
for (i = 0; i < numParts; i++) {
var part = parts[i];
if (part === '.') {
// ignore parts with just "."
/*
// if the "." is at end of parts (e.g. ["a", "b", "."]) then trim it off
if (i === numParts - 1) {
//len--;
}
*/
} else if (part === '..') {
// overwrite the previous item by decrementing length
len--;
} else {
// add this part to result and increment length
parts[len] = part;
len++;
}
}
if (len === 1) {
// if we end up with just one part that is empty string
// (which can happen if input is ["", "."]) then return
// string with just the leading slash
return '/';
} else if (len > 2) {
// parts i s
// ["", "a", ""]
// ["", "a", "b", ""]
if (parts[len - 1].length === 0) {
// last part is an empty string which would result in trailing slash
len--;
}
}
// truncate parts to remove unused
parts.length = len;
return parts.join('/');
} | [
"function",
"normalizePathParts",
"(",
"parts",
")",
"{",
"var",
"i",
";",
"var",
"len",
"=",
"0",
";",
"var",
"numParts",
"=",
"parts",
".",
"length",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"numParts",
";",
"i",
"++",
")",
"{",
"var",
"part",
"=",
"parts",
"[",
"i",
"]",
";",
"if",
"(",
"part",
"===",
"'.'",
")",
"{",
"}",
"else",
"if",
"(",
"part",
"===",
"'..'",
")",
"{",
"len",
"--",
";",
"}",
"else",
"{",
"parts",
"[",
"len",
"]",
"=",
"part",
";",
"len",
"++",
";",
"}",
"}",
"if",
"(",
"len",
"===",
"1",
")",
"{",
"return",
"'/'",
";",
"}",
"else",
"if",
"(",
"len",
">",
"2",
")",
"{",
"if",
"(",
"parts",
"[",
"len",
"-",
"1",
"]",
".",
"length",
"===",
"0",
")",
"{",
"len",
"--",
";",
"}",
"}",
"parts",
".",
"length",
"=",
"len",
";",
"return",
"parts",
".",
"join",
"(",
"'/'",
")",
";",
"}"
] | This function will take an array of path parts and normalize them by handling handle ".." and "."
and then joining the resultant string.
@param {Array} parts an array of parts that presumedly was split on the "/" character. | [
"This",
"function",
"will",
"take",
"an",
"array",
"of",
"path",
"parts",
"and",
"normalize",
"them",
"by",
"handling",
"handle",
"..",
"and",
".",
"and",
"then",
"joining",
"the",
"resultant",
"string",
"."
] | 9274abb14e4fd051ddcc609dbc9fe9ac6605631c | https://github.com/makeup-js/makeup-expander/blob/9274abb14e4fd051ddcc609dbc9fe9ac6605631c/docs/static/bundle.js#L222-L270 | train |
ArnaudBuchholz/gpf-js | src/context.js | _gpfReduceContext | function _gpfReduceContext (path, reducer) {
var rootContext,
pathToReduce;
if (path[_GPF_START] === "gpf") {
rootContext = gpf;
pathToReduce = _gpfArrayTail(path);
} else {
rootContext = _gpfMainContext;
pathToReduce = path;
}
return pathToReduce.reduce(reducer, rootContext);
} | javascript | function _gpfReduceContext (path, reducer) {
var rootContext,
pathToReduce;
if (path[_GPF_START] === "gpf") {
rootContext = gpf;
pathToReduce = _gpfArrayTail(path);
} else {
rootContext = _gpfMainContext;
pathToReduce = path;
}
return pathToReduce.reduce(reducer, rootContext);
} | [
"function",
"_gpfReduceContext",
"(",
"path",
",",
"reducer",
")",
"{",
"var",
"rootContext",
",",
"pathToReduce",
";",
"if",
"(",
"path",
"[",
"_GPF_START",
"]",
"===",
"\"gpf\"",
")",
"{",
"rootContext",
"=",
"gpf",
";",
"pathToReduce",
"=",
"_gpfArrayTail",
"(",
"path",
")",
";",
"}",
"else",
"{",
"rootContext",
"=",
"_gpfMainContext",
";",
"pathToReduce",
"=",
"path",
";",
"}",
"return",
"pathToReduce",
".",
"reduce",
"(",
"reducer",
",",
"rootContext",
")",
";",
"}"
] | Apply reducer on path | [
"Apply",
"reducer",
"on",
"path"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/context.js#L28-L39 | train |
ArnaudBuchholz/gpf-js | lost+found/src/params.js | function (definitions) {
var
result = [],
len = definitions.length,
idx,
definition;
for (idx = 0; idx < len; ++idx) {
definition = definitions[idx];
if (!(definition instanceof gpf.Parameter)) {
definition = this._createFromObject(definition);
}
result.push(definition);
}
return result;
} | javascript | function (definitions) {
var
result = [],
len = definitions.length,
idx,
definition;
for (idx = 0; idx < len; ++idx) {
definition = definitions[idx];
if (!(definition instanceof gpf.Parameter)) {
definition = this._createFromObject(definition);
}
result.push(definition);
}
return result;
} | [
"function",
"(",
"definitions",
")",
"{",
"var",
"result",
"=",
"[",
"]",
",",
"len",
"=",
"definitions",
".",
"length",
",",
"idx",
",",
"definition",
";",
"for",
"(",
"idx",
"=",
"0",
";",
"idx",
"<",
"len",
";",
"++",
"idx",
")",
"{",
"definition",
"=",
"definitions",
"[",
"idx",
"]",
";",
"if",
"(",
"!",
"(",
"definition",
"instanceof",
"gpf",
".",
"Parameter",
")",
")",
"{",
"definition",
"=",
"this",
".",
"_createFromObject",
"(",
"definition",
")",
";",
"}",
"result",
".",
"push",
"(",
"definition",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Create a list of parameters
@param {Object[]} definitions
@return {gpf.Parameter[]} | [
"Create",
"a",
"list",
"of",
"parameters"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/params.js#L130-L144 | train |
|
ArnaudBuchholz/gpf-js | lost+found/src/params.js | function (definition) {
var
result = new gpf.Parameter(),
typeDefaultValue;
if (definition === gpf.Parameter.VERBOSE
|| definition.prefix === gpf.Parameter.VERBOSE) {
definition = {
name: "verbose",
description: "Enable verbose mode",
type: "boolean",
defaultValue: false,
prefix: gpf.Parameter.VERBOSE
};
} else if (definition === gpf.Parameter.HELP
|| definition.prefix === gpf.Parameter.HELP) {
definition = {
name: "help",
description: "Display help",
type: "boolean",
defaultValue: false,
prefix: gpf.Parameter.HELP
};
}
gpf.json.load(result, definition);
// name is required
if (!result._name) {
gpf.Error.paramsNameRequired();
}
if (!result._multiple) {
/**
* When multiple is used, the default value will be an array
* if not specified.
* Otherwise, we get the default value based on the type
*/
typeDefaultValue = this.DEFAULTS[result._type];
if (undefined === typeDefaultValue) {
gpf.Error.paramsTypeUnknown();
}
if (result.hasOwnProperty("_defaultValue")) {
result._defaultValue =
gpf.value(result._defaultValue, typeDefaultValue,
result._type);
}
}
return result;
} | javascript | function (definition) {
var
result = new gpf.Parameter(),
typeDefaultValue;
if (definition === gpf.Parameter.VERBOSE
|| definition.prefix === gpf.Parameter.VERBOSE) {
definition = {
name: "verbose",
description: "Enable verbose mode",
type: "boolean",
defaultValue: false,
prefix: gpf.Parameter.VERBOSE
};
} else if (definition === gpf.Parameter.HELP
|| definition.prefix === gpf.Parameter.HELP) {
definition = {
name: "help",
description: "Display help",
type: "boolean",
defaultValue: false,
prefix: gpf.Parameter.HELP
};
}
gpf.json.load(result, definition);
// name is required
if (!result._name) {
gpf.Error.paramsNameRequired();
}
if (!result._multiple) {
/**
* When multiple is used, the default value will be an array
* if not specified.
* Otherwise, we get the default value based on the type
*/
typeDefaultValue = this.DEFAULTS[result._type];
if (undefined === typeDefaultValue) {
gpf.Error.paramsTypeUnknown();
}
if (result.hasOwnProperty("_defaultValue")) {
result._defaultValue =
gpf.value(result._defaultValue, typeDefaultValue,
result._type);
}
}
return result;
} | [
"function",
"(",
"definition",
")",
"{",
"var",
"result",
"=",
"new",
"gpf",
".",
"Parameter",
"(",
")",
",",
"typeDefaultValue",
";",
"if",
"(",
"definition",
"===",
"gpf",
".",
"Parameter",
".",
"VERBOSE",
"||",
"definition",
".",
"prefix",
"===",
"gpf",
".",
"Parameter",
".",
"VERBOSE",
")",
"{",
"definition",
"=",
"{",
"name",
":",
"\"verbose\"",
",",
"description",
":",
"\"Enable verbose mode\"",
",",
"type",
":",
"\"boolean\"",
",",
"defaultValue",
":",
"false",
",",
"prefix",
":",
"gpf",
".",
"Parameter",
".",
"VERBOSE",
"}",
";",
"}",
"else",
"if",
"(",
"definition",
"===",
"gpf",
".",
"Parameter",
".",
"HELP",
"||",
"definition",
".",
"prefix",
"===",
"gpf",
".",
"Parameter",
".",
"HELP",
")",
"{",
"definition",
"=",
"{",
"name",
":",
"\"help\"",
",",
"description",
":",
"\"Display help\"",
",",
"type",
":",
"\"boolean\"",
",",
"defaultValue",
":",
"false",
",",
"prefix",
":",
"gpf",
".",
"Parameter",
".",
"HELP",
"}",
";",
"}",
"gpf",
".",
"json",
".",
"load",
"(",
"result",
",",
"definition",
")",
";",
"if",
"(",
"!",
"result",
".",
"_name",
")",
"{",
"gpf",
".",
"Error",
".",
"paramsNameRequired",
"(",
")",
";",
"}",
"if",
"(",
"!",
"result",
".",
"_multiple",
")",
"{",
"typeDefaultValue",
"=",
"this",
".",
"DEFAULTS",
"[",
"result",
".",
"_type",
"]",
";",
"if",
"(",
"undefined",
"===",
"typeDefaultValue",
")",
"{",
"gpf",
".",
"Error",
".",
"paramsTypeUnknown",
"(",
")",
";",
"}",
"if",
"(",
"result",
".",
"hasOwnProperty",
"(",
"\"_defaultValue\"",
")",
")",
"{",
"result",
".",
"_defaultValue",
"=",
"gpf",
".",
"value",
"(",
"result",
".",
"_defaultValue",
",",
"typeDefaultValue",
",",
"result",
".",
"_type",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
] | Create a parameter from the definition object
@param {Object} definition
@return {gpf.Parameter}
@private | [
"Create",
"a",
"parameter",
"from",
"the",
"definition",
"object"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/params.js#L153-L198 | train |
|
ArnaudBuchholz/gpf-js | lost+found/src/params.js | function (parameters, argumentsToParse) {
var
result = {},
len,
idx,
argument,
parameter,
name,
lastNonPrefixIdx = 0;
parameters = gpf.Parameter.create(parameters);
len = argumentsToParse.length;
for (idx = 0; idx < len; ++idx) {
// Check if a prefix was used and find parameter
argument = this.getPrefixValuePair(argumentsToParse[idx]);
if (argument instanceof Array) {
parameter = this.getOnPrefix(parameters, argument[0]);
argument = argument[1];
} else {
parameter = this.getOnPrefix(parameters,
lastNonPrefixIdx);
lastNonPrefixIdx = parameters.indexOf(parameter) + 1;
}
// If no parameter corresponds, ignore
if (!parameter) {
// TODO maybe an error might be more appropriate
continue;
}
// Sometimes, the prefix might be used without value
if (undefined === argument) {
if ("boolean" === parameter._type) {
argument = !parameter._defaultValue;
} else {
// Nothing to do with it
// TODO maybe an error might be more appropriate
continue;
}
}
// Convert the value to match the type
// TODO change when type will be an object
argument = gpf.value(argument, parameter._defaultValue,
parameter._type);
// Assign the corresponding member of the result object
name = parameter._name;
if (parameter._multiple) {
if (undefined === result[name]) {
result[name] = [];
}
result[name].push(argument);
if (parameter._prefix === "") {
--lastNonPrefixIdx;
}
} else {
// The last one wins
result[name] = argument;
}
}
this._finalizeParse(parameters, result);
return result;
} | javascript | function (parameters, argumentsToParse) {
var
result = {},
len,
idx,
argument,
parameter,
name,
lastNonPrefixIdx = 0;
parameters = gpf.Parameter.create(parameters);
len = argumentsToParse.length;
for (idx = 0; idx < len; ++idx) {
// Check if a prefix was used and find parameter
argument = this.getPrefixValuePair(argumentsToParse[idx]);
if (argument instanceof Array) {
parameter = this.getOnPrefix(parameters, argument[0]);
argument = argument[1];
} else {
parameter = this.getOnPrefix(parameters,
lastNonPrefixIdx);
lastNonPrefixIdx = parameters.indexOf(parameter) + 1;
}
// If no parameter corresponds, ignore
if (!parameter) {
// TODO maybe an error might be more appropriate
continue;
}
// Sometimes, the prefix might be used without value
if (undefined === argument) {
if ("boolean" === parameter._type) {
argument = !parameter._defaultValue;
} else {
// Nothing to do with it
// TODO maybe an error might be more appropriate
continue;
}
}
// Convert the value to match the type
// TODO change when type will be an object
argument = gpf.value(argument, parameter._defaultValue,
parameter._type);
// Assign the corresponding member of the result object
name = parameter._name;
if (parameter._multiple) {
if (undefined === result[name]) {
result[name] = [];
}
result[name].push(argument);
if (parameter._prefix === "") {
--lastNonPrefixIdx;
}
} else {
// The last one wins
result[name] = argument;
}
}
this._finalizeParse(parameters, result);
return result;
} | [
"function",
"(",
"parameters",
",",
"argumentsToParse",
")",
"{",
"var",
"result",
"=",
"{",
"}",
",",
"len",
",",
"idx",
",",
"argument",
",",
"parameter",
",",
"name",
",",
"lastNonPrefixIdx",
"=",
"0",
";",
"parameters",
"=",
"gpf",
".",
"Parameter",
".",
"create",
"(",
"parameters",
")",
";",
"len",
"=",
"argumentsToParse",
".",
"length",
";",
"for",
"(",
"idx",
"=",
"0",
";",
"idx",
"<",
"len",
";",
"++",
"idx",
")",
"{",
"argument",
"=",
"this",
".",
"getPrefixValuePair",
"(",
"argumentsToParse",
"[",
"idx",
"]",
")",
";",
"if",
"(",
"argument",
"instanceof",
"Array",
")",
"{",
"parameter",
"=",
"this",
".",
"getOnPrefix",
"(",
"parameters",
",",
"argument",
"[",
"0",
"]",
")",
";",
"argument",
"=",
"argument",
"[",
"1",
"]",
";",
"}",
"else",
"{",
"parameter",
"=",
"this",
".",
"getOnPrefix",
"(",
"parameters",
",",
"lastNonPrefixIdx",
")",
";",
"lastNonPrefixIdx",
"=",
"parameters",
".",
"indexOf",
"(",
"parameter",
")",
"+",
"1",
";",
"}",
"if",
"(",
"!",
"parameter",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"undefined",
"===",
"argument",
")",
"{",
"if",
"(",
"\"boolean\"",
"===",
"parameter",
".",
"_type",
")",
"{",
"argument",
"=",
"!",
"parameter",
".",
"_defaultValue",
";",
"}",
"else",
"{",
"continue",
";",
"}",
"}",
"argument",
"=",
"gpf",
".",
"value",
"(",
"argument",
",",
"parameter",
".",
"_defaultValue",
",",
"parameter",
".",
"_type",
")",
";",
"name",
"=",
"parameter",
".",
"_name",
";",
"if",
"(",
"parameter",
".",
"_multiple",
")",
"{",
"if",
"(",
"undefined",
"===",
"result",
"[",
"name",
"]",
")",
"{",
"result",
"[",
"name",
"]",
"=",
"[",
"]",
";",
"}",
"result",
"[",
"name",
"]",
".",
"push",
"(",
"argument",
")",
";",
"if",
"(",
"parameter",
".",
"_prefix",
"===",
"\"\"",
")",
"{",
"--",
"lastNonPrefixIdx",
";",
"}",
"}",
"else",
"{",
"result",
"[",
"name",
"]",
"=",
"argument",
";",
"}",
"}",
"this",
".",
"_finalizeParse",
"(",
"parameters",
",",
"result",
")",
";",
"return",
"result",
";",
"}"
] | Parse the arguments and return an object with the
recognized parameters. Throws an error if required parameters
are missing.
@param {gpf.Parameter[]|Object[]} parameters
@param {String[]} argumentsToParse
@return {Object} | [
"Parse",
"the",
"arguments",
"and",
"return",
"an",
"object",
"with",
"the",
"recognized",
"parameters",
".",
"Throws",
"an",
"error",
"if",
"required",
"parameters",
"are",
"missing",
"."
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/params.js#L264-L323 | train |
|
ArnaudBuchholz/gpf-js | lost+found/src/params.js | function (parameters, result) {
var
len,
idx,
parameter,
name,
value;
len = parameters.length;
for (idx = 0; idx < len; ++idx) {
parameter = parameters[idx];
name = parameter._name;
if (undefined === result[name]) {
if (parameter._required) {
gpf.Error.paramsRequiredMissing({
name: name
});
}
value = parameter._defaultValue;
if (undefined !== value) {
if (parameter._multiple) {
value = [value];
}
result[name] = value;
} else if (parameter._multiple) {
result[name] = [];
}
}
}
} | javascript | function (parameters, result) {
var
len,
idx,
parameter,
name,
value;
len = parameters.length;
for (idx = 0; idx < len; ++idx) {
parameter = parameters[idx];
name = parameter._name;
if (undefined === result[name]) {
if (parameter._required) {
gpf.Error.paramsRequiredMissing({
name: name
});
}
value = parameter._defaultValue;
if (undefined !== value) {
if (parameter._multiple) {
value = [value];
}
result[name] = value;
} else if (parameter._multiple) {
result[name] = [];
}
}
}
} | [
"function",
"(",
"parameters",
",",
"result",
")",
"{",
"var",
"len",
",",
"idx",
",",
"parameter",
",",
"name",
",",
"value",
";",
"len",
"=",
"parameters",
".",
"length",
";",
"for",
"(",
"idx",
"=",
"0",
";",
"idx",
"<",
"len",
";",
"++",
"idx",
")",
"{",
"parameter",
"=",
"parameters",
"[",
"idx",
"]",
";",
"name",
"=",
"parameter",
".",
"_name",
";",
"if",
"(",
"undefined",
"===",
"result",
"[",
"name",
"]",
")",
"{",
"if",
"(",
"parameter",
".",
"_required",
")",
"{",
"gpf",
".",
"Error",
".",
"paramsRequiredMissing",
"(",
"{",
"name",
":",
"name",
"}",
")",
";",
"}",
"value",
"=",
"parameter",
".",
"_defaultValue",
";",
"if",
"(",
"undefined",
"!==",
"value",
")",
"{",
"if",
"(",
"parameter",
".",
"_multiple",
")",
"{",
"value",
"=",
"[",
"value",
"]",
";",
"}",
"result",
"[",
"name",
"]",
"=",
"value",
";",
"}",
"else",
"if",
"(",
"parameter",
".",
"_multiple",
")",
"{",
"result",
"[",
"name",
"]",
"=",
"[",
"]",
";",
"}",
"}",
"}",
"}"
] | Check that all required fields are set,
apply default values
@param {gpf.Parameter[]} parameters
@param {Object} result
@private | [
"Check",
"that",
"all",
"required",
"fields",
"are",
"set",
"apply",
"default",
"values"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/params.js#L333-L361 | train |
|
ArnaudBuchholz/gpf-js | src/define/class/super.js | _gpfClassSuperCreateWeakBoundWithSameSignature | function _gpfClassSuperCreateWeakBoundWithSameSignature (that, $super, superMethod) {
var definition = _gpfFunctionDescribe(superMethod);
definition.body = "return _superMethod_.apply(this === _$super_ ? _that_ : this, arguments);";
return _gpfFunctionBuild(definition, {
_that_: that,
_$super_: $super,
_superMethod_: superMethod
});
} | javascript | function _gpfClassSuperCreateWeakBoundWithSameSignature (that, $super, superMethod) {
var definition = _gpfFunctionDescribe(superMethod);
definition.body = "return _superMethod_.apply(this === _$super_ ? _that_ : this, arguments);";
return _gpfFunctionBuild(definition, {
_that_: that,
_$super_: $super,
_superMethod_: superMethod
});
} | [
"function",
"_gpfClassSuperCreateWeakBoundWithSameSignature",
"(",
"that",
",",
"$super",
",",
"superMethod",
")",
"{",
"var",
"definition",
"=",
"_gpfFunctionDescribe",
"(",
"superMethod",
")",
";",
"definition",
".",
"body",
"=",
"\"return _superMethod_.apply(this === _$super_ ? _that_ : this, arguments);\"",
";",
"return",
"_gpfFunctionBuild",
"(",
"definition",
",",
"{",
"_that_",
":",
"that",
",",
"_$super_",
":",
"$super",
",",
"_superMethod_",
":",
"superMethod",
"}",
")",
";",
"}"
] | Copy super method signature and apply weak binding.
@param {Object} that Object instance
@param {Function} $super $super member
@param {*} superMethod superMember Member extracted from inherited prototype
@return {Function} $super method
@since 0.1.7 | [
"Copy",
"super",
"method",
"signature",
"and",
"apply",
"weak",
"binding",
"."
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/define/class/super.js#L94-L102 | train |
ArnaudBuchholz/gpf-js | src/define/class/super.js | function (method, methodName, superMembers) {
return {
_method_: method,
_methodName_: methodName,
_superMembers_: superMembers,
_classDef_: this
};
} | javascript | function (method, methodName, superMembers) {
return {
_method_: method,
_methodName_: methodName,
_superMembers_: superMembers,
_classDef_: this
};
} | [
"function",
"(",
"method",
",",
"methodName",
",",
"superMembers",
")",
"{",
"return",
"{",
"_method_",
":",
"method",
",",
"_methodName_",
":",
"methodName",
",",
"_superMembers_",
":",
"superMembers",
",",
"_classDef_",
":",
"this",
"}",
";",
"}"
] | Generates context for the superified method
@param {Function} method Method to superify
@param {String} methodName Name of the method (used to search in object prototype)
@param {String[]} superMembers Detected $super members used in the method
@return {Object} Context of superified method
@since 0.1.7 | [
"Generates",
"context",
"for",
"the",
"superified",
"method"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/define/class/super.js#L194-L201 | train |
|
ArnaudBuchholz/gpf-js | src/define/class/super.js | function (method, methodName, superMembers) {
// Keep signature
var description = _gpfFunctionDescribe(method);
description.body = this._superifiedBody;
return _gpfFunctionBuild(description, this._getSuperifiedContext(method, methodName, superMembers));
} | javascript | function (method, methodName, superMembers) {
// Keep signature
var description = _gpfFunctionDescribe(method);
description.body = this._superifiedBody;
return _gpfFunctionBuild(description, this._getSuperifiedContext(method, methodName, superMembers));
} | [
"function",
"(",
"method",
",",
"methodName",
",",
"superMembers",
")",
"{",
"var",
"description",
"=",
"_gpfFunctionDescribe",
"(",
"method",
")",
";",
"description",
".",
"body",
"=",
"this",
".",
"_superifiedBody",
";",
"return",
"_gpfFunctionBuild",
"(",
"description",
",",
"this",
".",
"_getSuperifiedContext",
"(",
"method",
",",
"methodName",
",",
"superMembers",
")",
")",
";",
"}"
] | Generates the superified version of the method
@param {Function} method Method to superify
@param {String} methodName Name of the method (used to search in object prototype)
@param {String[]} superMembers Detected $super members used in the method
@return {Function} Superified method
@since 0.1.7 | [
"Generates",
"the",
"superified",
"version",
"of",
"the",
"method"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/define/class/super.js#L212-L217 | train |
|
ArnaudBuchholz/gpf-js | src/stream/pipe.js | _gpfStreamPipeToFlushableWrite | function _gpfStreamPipeToFlushableWrite (intermediate, destination) {
var state = _gpfStreamPipeAllocateState(intermediate, destination),
read = _gpfStreamPipeAllocateRead(state),
iFlushableIntermediate = state.iFlushableIntermediate,
iFlushableDestination = state.iFlushableDestination,
iWritableIntermediate = state.iWritableIntermediate;
read();
return {
flush: function () {
return _gpfStreamPipeCheckIfReadError(state) || iFlushableIntermediate.flush()
.then(function () {
return iFlushableDestination.flush();
});
},
write: function (data) {
read();
return _gpfStreamPipeCheckIfReadError(state)
|| _gpfStreamPipeWrapWrite(state, iWritableIntermediate.write(data));
}
};
} | javascript | function _gpfStreamPipeToFlushableWrite (intermediate, destination) {
var state = _gpfStreamPipeAllocateState(intermediate, destination),
read = _gpfStreamPipeAllocateRead(state),
iFlushableIntermediate = state.iFlushableIntermediate,
iFlushableDestination = state.iFlushableDestination,
iWritableIntermediate = state.iWritableIntermediate;
read();
return {
flush: function () {
return _gpfStreamPipeCheckIfReadError(state) || iFlushableIntermediate.flush()
.then(function () {
return iFlushableDestination.flush();
});
},
write: function (data) {
read();
return _gpfStreamPipeCheckIfReadError(state)
|| _gpfStreamPipeWrapWrite(state, iWritableIntermediate.write(data));
}
};
} | [
"function",
"_gpfStreamPipeToFlushableWrite",
"(",
"intermediate",
",",
"destination",
")",
"{",
"var",
"state",
"=",
"_gpfStreamPipeAllocateState",
"(",
"intermediate",
",",
"destination",
")",
",",
"read",
"=",
"_gpfStreamPipeAllocateRead",
"(",
"state",
")",
",",
"iFlushableIntermediate",
"=",
"state",
".",
"iFlushableIntermediate",
",",
"iFlushableDestination",
"=",
"state",
".",
"iFlushableDestination",
",",
"iWritableIntermediate",
"=",
"state",
".",
"iWritableIntermediate",
";",
"read",
"(",
")",
";",
"return",
"{",
"flush",
":",
"function",
"(",
")",
"{",
"return",
"_gpfStreamPipeCheckIfReadError",
"(",
"state",
")",
"||",
"iFlushableIntermediate",
".",
"flush",
"(",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"return",
"iFlushableDestination",
".",
"flush",
"(",
")",
";",
"}",
")",
";",
"}",
",",
"write",
":",
"function",
"(",
"data",
")",
"{",
"read",
"(",
")",
";",
"return",
"_gpfStreamPipeCheckIfReadError",
"(",
"state",
")",
"||",
"_gpfStreamPipeWrapWrite",
"(",
"state",
",",
"iWritableIntermediate",
".",
"write",
"(",
"data",
")",
")",
";",
"}",
"}",
";",
"}"
] | Create a flushable & writable stream by combining the intermediate stream with the writable destination
@param {Object} intermediate Must implements IReadableStream interface.
If it implements the IFlushableStream interface, it is assumed that it retains data
until it receives the Flush. Meaning, the read won't complete until the flush call.
If it does not implement the IFlushableStream, the read may end before the whole sequence
has finished. It means that the next write should trigger a new read and flush must be simulated at
least to pass it to the destination
@param {Object} destination Must implements IWritableStream interface.
If it implements the IFlushableStream, it will be called when the intermediate completes.
@return {Object} Implementing IWritableStream and IFlushableStream
@since 0.2.3 | [
"Create",
"a",
"flushable",
"&",
"writable",
"stream",
"by",
"combining",
"the",
"intermediate",
"stream",
"with",
"the",
"writable",
"destination"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/stream/pipe.js#L93-L118 | train |
ArnaudBuchholz/gpf-js | src/stream/pipe.js | _gpfStreamPipe | function _gpfStreamPipe (source, destination) {
_gpfIgnore(destination);
var iReadableStream = _gpfStreamQueryReadable(source),
iWritableStream = _gpfStreamPipeToWritable(_gpfArrayTail(arguments)),
iFlushableStream = _gpfStreamPipeToFlushable(iWritableStream);
try {
return iReadableStream.read(iWritableStream)
.then(function () {
return iFlushableStream.flush();
});
} catch (e) {
return Promise.reject(e);
}
} | javascript | function _gpfStreamPipe (source, destination) {
_gpfIgnore(destination);
var iReadableStream = _gpfStreamQueryReadable(source),
iWritableStream = _gpfStreamPipeToWritable(_gpfArrayTail(arguments)),
iFlushableStream = _gpfStreamPipeToFlushable(iWritableStream);
try {
return iReadableStream.read(iWritableStream)
.then(function () {
return iFlushableStream.flush();
});
} catch (e) {
return Promise.reject(e);
}
} | [
"function",
"_gpfStreamPipe",
"(",
"source",
",",
"destination",
")",
"{",
"_gpfIgnore",
"(",
"destination",
")",
";",
"var",
"iReadableStream",
"=",
"_gpfStreamQueryReadable",
"(",
"source",
")",
",",
"iWritableStream",
"=",
"_gpfStreamPipeToWritable",
"(",
"_gpfArrayTail",
"(",
"arguments",
")",
")",
",",
"iFlushableStream",
"=",
"_gpfStreamPipeToFlushable",
"(",
"iWritableStream",
")",
";",
"try",
"{",
"return",
"iReadableStream",
".",
"read",
"(",
"iWritableStream",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"return",
"iFlushableStream",
".",
"flush",
"(",
")",
";",
"}",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"return",
"Promise",
".",
"reject",
"(",
"e",
")",
";",
"}",
"}"
] | Pipe streams.
@param {gpf.interfaces.IReadableStream} source Source stream
@param {...gpf.interfaces.IWritableStream} destination Writable streams
@return {Promise} Resolved when reading (and subsequent writings) are done
@since 0.2.3 | [
"Pipe",
"streams",
"."
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/stream/pipe.js#L144-L157 | train |
ArnaudBuchholz/gpf-js | src/boot.js | _gpfLoadSources | function _gpfLoadSources () { //jshint ignore:line
var sourceListContent = _gpfSyncReadForBoot(gpfSourcesPath + "sources.json"),
_gpfSources = _GpfFunc("return " + sourceListContent)(),
allContent = [],
idx = 0;
for (; idx < _gpfSources.length; ++idx) {
_gpfProcessSource(_gpfSources[idx], allContent);
}
return allContent.join("\n");
} | javascript | function _gpfLoadSources () { //jshint ignore:line
var sourceListContent = _gpfSyncReadForBoot(gpfSourcesPath + "sources.json"),
_gpfSources = _GpfFunc("return " + sourceListContent)(),
allContent = [],
idx = 0;
for (; idx < _gpfSources.length; ++idx) {
_gpfProcessSource(_gpfSources[idx], allContent);
}
return allContent.join("\n");
} | [
"function",
"_gpfLoadSources",
"(",
")",
"{",
"var",
"sourceListContent",
"=",
"_gpfSyncReadForBoot",
"(",
"gpfSourcesPath",
"+",
"\"sources.json\"",
")",
",",
"_gpfSources",
"=",
"_GpfFunc",
"(",
"\"return \"",
"+",
"sourceListContent",
")",
"(",
")",
",",
"allContent",
"=",
"[",
"]",
",",
"idx",
"=",
"0",
";",
"for",
"(",
";",
"idx",
"<",
"_gpfSources",
".",
"length",
";",
"++",
"idx",
")",
"{",
"_gpfProcessSource",
"(",
"_gpfSources",
"[",
"idx",
"]",
",",
"allContent",
")",
";",
"}",
"return",
"allContent",
".",
"join",
"(",
"\"\\n\"",
")",
";",
"}"
] | Load content of all sources
@return {String} Consolidated sources
@since 0.1.9 | [
"Load",
"content",
"of",
"all",
"sources"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/boot.js#L299-L308 | train |
ArnaudBuchholz/gpf-js | lost+found/src/attributes/class.js | _gpfBuildPropertyFunc | function _gpfBuildPropertyFunc (template, member) {
var src,
params,
start,
end;
// Replace all occurrences of _MEMBER_ with the right name
src = template.toString().split("_MEMBER_").join(member);
// Extract parameters
start = src.indexOf("(") + 1;
end = src.indexOf(")", start) - 1;
params = src.substr(start, end - start + 1).split(",").map(function (name) {
return name.trim();
});
// Extract body
start = src.indexOf("{") + 1;
end = src.lastIndexOf("}") - 1;
src = src.substr(start, end - start + 1);
return _gpfFunc(params, src);
} | javascript | function _gpfBuildPropertyFunc (template, member) {
var src,
params,
start,
end;
// Replace all occurrences of _MEMBER_ with the right name
src = template.toString().split("_MEMBER_").join(member);
// Extract parameters
start = src.indexOf("(") + 1;
end = src.indexOf(")", start) - 1;
params = src.substr(start, end - start + 1).split(",").map(function (name) {
return name.trim();
});
// Extract body
start = src.indexOf("{") + 1;
end = src.lastIndexOf("}") - 1;
src = src.substr(start, end - start + 1);
return _gpfFunc(params, src);
} | [
"function",
"_gpfBuildPropertyFunc",
"(",
"template",
",",
"member",
")",
"{",
"var",
"src",
",",
"params",
",",
"start",
",",
"end",
";",
"src",
"=",
"template",
".",
"toString",
"(",
")",
".",
"split",
"(",
"\"_MEMBER_\"",
")",
".",
"join",
"(",
"member",
")",
";",
"start",
"=",
"src",
".",
"indexOf",
"(",
"\"(\"",
")",
"+",
"1",
";",
"end",
"=",
"src",
".",
"indexOf",
"(",
"\")\"",
",",
"start",
")",
"-",
"1",
";",
"params",
"=",
"src",
".",
"substr",
"(",
"start",
",",
"end",
"-",
"start",
"+",
"1",
")",
".",
"split",
"(",
"\",\"",
")",
".",
"map",
"(",
"function",
"(",
"name",
")",
"{",
"return",
"name",
".",
"trim",
"(",
")",
";",
"}",
")",
";",
"start",
"=",
"src",
".",
"indexOf",
"(",
"\"{\"",
")",
"+",
"1",
";",
"end",
"=",
"src",
".",
"lastIndexOf",
"(",
"\"}\"",
")",
"-",
"1",
";",
"src",
"=",
"src",
".",
"substr",
"(",
"start",
",",
"end",
"-",
"start",
"+",
"1",
")",
";",
"return",
"_gpfFunc",
"(",
"params",
",",
"src",
")",
";",
"}"
] | Builds a new property function
@param {Boolean} template Template to be used
@param {String} member Value of _MEMBER_
@return {Function} | [
"Builds",
"a",
"new",
"property",
"function"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/attributes/class.js#L60-L78 | train |
Keenpoint/smart-circular | smart-circular.js | function(object, customizer) {
var foundStack = [], //Stack to keep track of discovered objects
queueOfModifiers = [], //Necessary to change our JSON as we take elements from the queue (BFS algorithm)
queue = []; //queue of JSON elements, following the BFS algorithm
//We instantiate our result root.
var result = _.isArray(object) ? [] : {};
//We first put all the JSON source in our queues
queue.push(object);
queueOfModifiers.push(new ObjectEditor(object, ""));
var positionStack;
var nextInsertion;
//BFS algorithm
while(queue.length > 0) {
//JSON to be modified and its editor
var value = queue.shift();
var editor = queueOfModifiers.shift();
//The path that leads to this JSON, so we can build other paths from it
var path = editor.path;
//We first attempt to make any personalized replacements
//If customizer doesn't affect the value, customizer(value) returns undefined and we jump this if
if(customizer !== undefined) {
//By using this variable, customizer(value) is called only once.
var customizedValue = customizer(value);
if(customizedValue !== undefined) value = customizedValue;
}
if(typeof value === "object") {
positionStack = _.chain(foundStack)
.map("value")
.indexOf(value)
.value();
//If the value has already been discovered, we only fix its circular reference
if(positionStack !== -1) {
nextInsertion = foundStack[positionStack].makePathName();
}
else {
//At the first time we discover a certain value, we put it in the stack
foundStack.push(new FoundObject(value, path));
nextInsertion = value;
for(var component in value) {
if(_.has(value, component)) {
queue.push(value[component]);
var newPath = path + "[" + component + "]";
queueOfModifiers.push(new ObjectEditor(result, newPath));
}
}
}
}
//If it's an elementary value, it can't be circular, so we just put this value in our JSON result.
else {
nextInsertion = value;
}
editor.editObject(nextInsertion);
}
return result;
} | javascript | function(object, customizer) {
var foundStack = [], //Stack to keep track of discovered objects
queueOfModifiers = [], //Necessary to change our JSON as we take elements from the queue (BFS algorithm)
queue = []; //queue of JSON elements, following the BFS algorithm
//We instantiate our result root.
var result = _.isArray(object) ? [] : {};
//We first put all the JSON source in our queues
queue.push(object);
queueOfModifiers.push(new ObjectEditor(object, ""));
var positionStack;
var nextInsertion;
//BFS algorithm
while(queue.length > 0) {
//JSON to be modified and its editor
var value = queue.shift();
var editor = queueOfModifiers.shift();
//The path that leads to this JSON, so we can build other paths from it
var path = editor.path;
//We first attempt to make any personalized replacements
//If customizer doesn't affect the value, customizer(value) returns undefined and we jump this if
if(customizer !== undefined) {
//By using this variable, customizer(value) is called only once.
var customizedValue = customizer(value);
if(customizedValue !== undefined) value = customizedValue;
}
if(typeof value === "object") {
positionStack = _.chain(foundStack)
.map("value")
.indexOf(value)
.value();
//If the value has already been discovered, we only fix its circular reference
if(positionStack !== -1) {
nextInsertion = foundStack[positionStack].makePathName();
}
else {
//At the first time we discover a certain value, we put it in the stack
foundStack.push(new FoundObject(value, path));
nextInsertion = value;
for(var component in value) {
if(_.has(value, component)) {
queue.push(value[component]);
var newPath = path + "[" + component + "]";
queueOfModifiers.push(new ObjectEditor(result, newPath));
}
}
}
}
//If it's an elementary value, it can't be circular, so we just put this value in our JSON result.
else {
nextInsertion = value;
}
editor.editObject(nextInsertion);
}
return result;
} | [
"function",
"(",
"object",
",",
"customizer",
")",
"{",
"var",
"foundStack",
"=",
"[",
"]",
",",
"queueOfModifiers",
"=",
"[",
"]",
",",
"queue",
"=",
"[",
"]",
";",
"var",
"result",
"=",
"_",
".",
"isArray",
"(",
"object",
")",
"?",
"[",
"]",
":",
"{",
"}",
";",
"queue",
".",
"push",
"(",
"object",
")",
";",
"queueOfModifiers",
".",
"push",
"(",
"new",
"ObjectEditor",
"(",
"object",
",",
"\"\"",
")",
")",
";",
"var",
"positionStack",
";",
"var",
"nextInsertion",
";",
"while",
"(",
"queue",
".",
"length",
">",
"0",
")",
"{",
"var",
"value",
"=",
"queue",
".",
"shift",
"(",
")",
";",
"var",
"editor",
"=",
"queueOfModifiers",
".",
"shift",
"(",
")",
";",
"var",
"path",
"=",
"editor",
".",
"path",
";",
"if",
"(",
"customizer",
"!==",
"undefined",
")",
"{",
"var",
"customizedValue",
"=",
"customizer",
"(",
"value",
")",
";",
"if",
"(",
"customizedValue",
"!==",
"undefined",
")",
"value",
"=",
"customizedValue",
";",
"}",
"if",
"(",
"typeof",
"value",
"===",
"\"object\"",
")",
"{",
"positionStack",
"=",
"_",
".",
"chain",
"(",
"foundStack",
")",
".",
"map",
"(",
"\"value\"",
")",
".",
"indexOf",
"(",
"value",
")",
".",
"value",
"(",
")",
";",
"if",
"(",
"positionStack",
"!==",
"-",
"1",
")",
"{",
"nextInsertion",
"=",
"foundStack",
"[",
"positionStack",
"]",
".",
"makePathName",
"(",
")",
";",
"}",
"else",
"{",
"foundStack",
".",
"push",
"(",
"new",
"FoundObject",
"(",
"value",
",",
"path",
")",
")",
";",
"nextInsertion",
"=",
"value",
";",
"for",
"(",
"var",
"component",
"in",
"value",
")",
"{",
"if",
"(",
"_",
".",
"has",
"(",
"value",
",",
"component",
")",
")",
"{",
"queue",
".",
"push",
"(",
"value",
"[",
"component",
"]",
")",
";",
"var",
"newPath",
"=",
"path",
"+",
"\"[\"",
"+",
"component",
"+",
"\"]\"",
";",
"queueOfModifiers",
".",
"push",
"(",
"new",
"ObjectEditor",
"(",
"result",
",",
"newPath",
")",
")",
";",
"}",
"}",
"}",
"}",
"else",
"{",
"nextInsertion",
"=",
"value",
";",
"}",
"editor",
".",
"editObject",
"(",
"nextInsertion",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Main function to travel through the JSON and transform the circular references and personalized replacements | [
"Main",
"function",
"to",
"travel",
"through",
"the",
"JSON",
"and",
"transform",
"the",
"circular",
"references",
"and",
"personalized",
"replacements"
] | c73cddc663fd8a9ccb2513408e2161ce60417658 | https://github.com/Keenpoint/smart-circular/blob/c73cddc663fd8a9ccb2513408e2161ce60417658/smart-circular.js#L65-L136 | train |
|
ArnaudBuchholz/gpf-js | src/define/interface/build.js | function (newPrototype) {
_gpfObjectForEach(this._initialDefinition, function (value, memberName) {
if (!memberName.startsWith("$")) {
newPrototype[memberName] = value;
}
}, this);
} | javascript | function (newPrototype) {
_gpfObjectForEach(this._initialDefinition, function (value, memberName) {
if (!memberName.startsWith("$")) {
newPrototype[memberName] = value;
}
}, this);
} | [
"function",
"(",
"newPrototype",
")",
"{",
"_gpfObjectForEach",
"(",
"this",
".",
"_initialDefinition",
",",
"function",
"(",
"value",
",",
"memberName",
")",
"{",
"if",
"(",
"!",
"memberName",
".",
"startsWith",
"(",
"\"$\"",
")",
")",
"{",
"newPrototype",
"[",
"memberName",
"]",
"=",
"value",
";",
"}",
"}",
",",
"this",
")",
";",
"}"
] | Build the new class prototype
@param {Object} newPrototype New class prototype
@since 0.1.7 | [
"Build",
"the",
"new",
"class",
"prototype"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/define/interface/build.js#L36-L42 | train |
|
ArnaudBuchholz/gpf-js | lost+found/src/events.js | _gpfEventsIsValidHandler | function _gpfEventsIsValidHandler (eventHandler) {
var type = typeof eventHandler,
validator = _gpfEventsHandlerValidators[type];
if (validator === undefined) {
return false;
}
return validator(eventHandler);
} | javascript | function _gpfEventsIsValidHandler (eventHandler) {
var type = typeof eventHandler,
validator = _gpfEventsHandlerValidators[type];
if (validator === undefined) {
return false;
}
return validator(eventHandler);
} | [
"function",
"_gpfEventsIsValidHandler",
"(",
"eventHandler",
")",
"{",
"var",
"type",
"=",
"typeof",
"eventHandler",
",",
"validator",
"=",
"_gpfEventsHandlerValidators",
"[",
"type",
"]",
";",
"if",
"(",
"validator",
"===",
"undefined",
")",
"{",
"return",
"false",
";",
"}",
"return",
"validator",
"(",
"eventHandler",
")",
";",
"}"
] | Check if the provided parameter is a valid Event Handler
@param {*} eventHandler Object to test
@return {Boolean} True if the parameter is valid eventHandler | [
"Check",
"if",
"the",
"provided",
"parameter",
"is",
"a",
"valid",
"Event",
"Handler"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/events.js#L75-L82 | train |
ArnaudBuchholz/gpf-js | lost+found/src/events.js | _gpfEventsTriggerHandler | function _gpfEventsTriggerHandler (event, eventsHandler, resolvePromise) {
var eventHandler = _getEventHandler(event, eventsHandler);
eventHandler(event);
if (undefined !== resolvePromise) {
resolvePromise(event);
}
} | javascript | function _gpfEventsTriggerHandler (event, eventsHandler, resolvePromise) {
var eventHandler = _getEventHandler(event, eventsHandler);
eventHandler(event);
if (undefined !== resolvePromise) {
resolvePromise(event);
}
} | [
"function",
"_gpfEventsTriggerHandler",
"(",
"event",
",",
"eventsHandler",
",",
"resolvePromise",
")",
"{",
"var",
"eventHandler",
"=",
"_getEventHandler",
"(",
"event",
",",
"eventsHandler",
")",
";",
"eventHandler",
"(",
"event",
")",
";",
"if",
"(",
"undefined",
"!==",
"resolvePromise",
")",
"{",
"resolvePromise",
"(",
"event",
")",
";",
"}",
"}"
] | Fire the event by triggering the eventsHandler
@param {gpf.events.Event} event event object to fire
@param {gpf.events.Handler} eventsHandler
@param {Function} [resolvePromise=undefined] resolvePromise Promise resolver | [
"Fire",
"the",
"event",
"by",
"triggering",
"the",
"eventsHandler"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/events.js#L169-L175 | train |
ArnaudBuchholz/gpf-js | lost+found/src/events.js | _gpfEventsFire | function _gpfEventsFire (event, params, eventsHandler) {
/*jshint validthis:true*/ // will be invoked with apply
_gpfAssert(_gpfEventsIsValidHandler(eventsHandler), "Expected a valid event handler");
if (!(event instanceof _GpfEvent)) {
event = new gpf.events.Event(event, params, this);
}
return new Promise(function (resolve/*, reject*/) {
// This is used both to limit the number of recursion and increase the efficiency of the algorithm.
if (++_gpfEventsFiring > 10) {
// Too much recursion, use setTimeout to free some space on the stack
setTimeout(_gpfEventsTriggerHandler.bind(null, event, eventsHandler, resolve), 0);
} else {
_gpfEventsTriggerHandler(event, eventsHandler);
resolve(event);
}
--_gpfEventsFiring;
});
} | javascript | function _gpfEventsFire (event, params, eventsHandler) {
/*jshint validthis:true*/ // will be invoked with apply
_gpfAssert(_gpfEventsIsValidHandler(eventsHandler), "Expected a valid event handler");
if (!(event instanceof _GpfEvent)) {
event = new gpf.events.Event(event, params, this);
}
return new Promise(function (resolve/*, reject*/) {
// This is used both to limit the number of recursion and increase the efficiency of the algorithm.
if (++_gpfEventsFiring > 10) {
// Too much recursion, use setTimeout to free some space on the stack
setTimeout(_gpfEventsTriggerHandler.bind(null, event, eventsHandler, resolve), 0);
} else {
_gpfEventsTriggerHandler(event, eventsHandler);
resolve(event);
}
--_gpfEventsFiring;
});
} | [
"function",
"_gpfEventsFire",
"(",
"event",
",",
"params",
",",
"eventsHandler",
")",
"{",
"_gpfAssert",
"(",
"_gpfEventsIsValidHandler",
"(",
"eventsHandler",
")",
",",
"\"Expected a valid event handler\"",
")",
";",
"if",
"(",
"!",
"(",
"event",
"instanceof",
"_GpfEvent",
")",
")",
"{",
"event",
"=",
"new",
"gpf",
".",
"events",
".",
"Event",
"(",
"event",
",",
"params",
",",
"this",
")",
";",
"}",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
")",
"{",
"if",
"(",
"++",
"_gpfEventsFiring",
">",
"10",
")",
"{",
"setTimeout",
"(",
"_gpfEventsTriggerHandler",
".",
"bind",
"(",
"null",
",",
"event",
",",
"eventsHandler",
",",
"resolve",
")",
",",
"0",
")",
";",
"}",
"else",
"{",
"_gpfEventsTriggerHandler",
"(",
"event",
",",
"eventsHandler",
")",
";",
"resolve",
"(",
"event",
")",
";",
"}",
"--",
"_gpfEventsFiring",
";",
"}",
")",
";",
"}"
] | gpf.events.fire implementation
@param {String/gpf.events.Event} event event name or event object to fire
@param {Object} params dictionary of parameters for the event object
creation, they are ignored if an event object is specified
@param {gpf.events.Handler} eventsHandler
@return {Promise<gpf.events.Event>} fulfilled when the event has been fired | [
"gpf",
".",
"events",
".",
"fire",
"implementation"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/events.js#L190-L207 | train |
popeindustries/buddy | lib/utils/filepath.js | exists | function exists(filepath) {
const cached = existsCache.has(filepath);
// Only return positive to allow for generated files
if (cached) return true;
const filepathExists = fs.existsSync(filepath);
if (filepathExists) existsCache.add(filepath);
return filepathExists;
} | javascript | function exists(filepath) {
const cached = existsCache.has(filepath);
// Only return positive to allow for generated files
if (cached) return true;
const filepathExists = fs.existsSync(filepath);
if (filepathExists) existsCache.add(filepath);
return filepathExists;
} | [
"function",
"exists",
"(",
"filepath",
")",
"{",
"const",
"cached",
"=",
"existsCache",
".",
"has",
"(",
"filepath",
")",
";",
"if",
"(",
"cached",
")",
"return",
"true",
";",
"const",
"filepathExists",
"=",
"fs",
".",
"existsSync",
"(",
"filepath",
")",
";",
"if",
"(",
"filepathExists",
")",
"existsCache",
".",
"add",
"(",
"filepath",
")",
";",
"return",
"filepathExists",
";",
"}"
] | Determine if 'filepath' exists
@param {String} filepath
@returns {Boolean} | [
"Determine",
"if",
"filepath",
"exists"
] | c38afc2e6915743eb6cfcf5aba59a8699142c7a5 | https://github.com/popeindustries/buddy/blob/c38afc2e6915743eb6cfcf5aba59a8699142c7a5/lib/utils/filepath.js#L178-L189 | train |
ArnaudBuchholz/gpf-js | src/define/entities.js | _gpfDefineEntitiesAdd | function _gpfDefineEntitiesAdd (entityDefinition) {
_gpfAssert(entityDefinition._instanceBuilder !== null, "Instance builder must be set");
_gpfAssert(!_gpfDefineEntitiesFindByConstructor(entityDefinition.getInstanceBuilder()), "Already added");
_gpfDefinedEntities.push(entityDefinition);
} | javascript | function _gpfDefineEntitiesAdd (entityDefinition) {
_gpfAssert(entityDefinition._instanceBuilder !== null, "Instance builder must be set");
_gpfAssert(!_gpfDefineEntitiesFindByConstructor(entityDefinition.getInstanceBuilder()), "Already added");
_gpfDefinedEntities.push(entityDefinition);
} | [
"function",
"_gpfDefineEntitiesAdd",
"(",
"entityDefinition",
")",
"{",
"_gpfAssert",
"(",
"entityDefinition",
".",
"_instanceBuilder",
"!==",
"null",
",",
"\"Instance builder must be set\"",
")",
";",
"_gpfAssert",
"(",
"!",
"_gpfDefineEntitiesFindByConstructor",
"(",
"entityDefinition",
".",
"getInstanceBuilder",
"(",
")",
")",
",",
"\"Already added\"",
")",
";",
"_gpfDefinedEntities",
".",
"push",
"(",
"entityDefinition",
")",
";",
"}"
] | Store the entity definition to be retreived later
@param {_GpfEntityDefinition} entityDefinition Entity definition
@since 0.2.9 | [
"Store",
"the",
"entity",
"definition",
"to",
"be",
"retreived",
"later"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/define/entities.js#L41-L45 | train |
ArnaudBuchholz/gpf-js | src/fs/nodejs.js | function (unnormalizedPath) {
var path = _gpfPathNormalize(unnormalizedPath);
return new Promise(function (resolve) {
_gpfNodeFs.exists(path, resolve);
})
.then(function (exists) {
if (exists) {
return _gpfFsNodeFsCallWithPath("stat", path)
.then(function (stats) {
return {
fileName: _gpfNodePath.basename(path),
filePath: _gpfPathNormalize(_gpfNodePath.resolve(path)),
size: stats.size,
createdDateTime: stats.ctime,
modifiedDateTime: stats.mtime,
type: _gpfFsNodeGetType(stats)
};
});
}
return {
type: _GPF_FS_TYPES.NOT_FOUND
};
});
} | javascript | function (unnormalizedPath) {
var path = _gpfPathNormalize(unnormalizedPath);
return new Promise(function (resolve) {
_gpfNodeFs.exists(path, resolve);
})
.then(function (exists) {
if (exists) {
return _gpfFsNodeFsCallWithPath("stat", path)
.then(function (stats) {
return {
fileName: _gpfNodePath.basename(path),
filePath: _gpfPathNormalize(_gpfNodePath.resolve(path)),
size: stats.size,
createdDateTime: stats.ctime,
modifiedDateTime: stats.mtime,
type: _gpfFsNodeGetType(stats)
};
});
}
return {
type: _GPF_FS_TYPES.NOT_FOUND
};
});
} | [
"function",
"(",
"unnormalizedPath",
")",
"{",
"var",
"path",
"=",
"_gpfPathNormalize",
"(",
"unnormalizedPath",
")",
";",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
")",
"{",
"_gpfNodeFs",
".",
"exists",
"(",
"path",
",",
"resolve",
")",
";",
"}",
")",
".",
"then",
"(",
"function",
"(",
"exists",
")",
"{",
"if",
"(",
"exists",
")",
"{",
"return",
"_gpfFsNodeFsCallWithPath",
"(",
"\"stat\"",
",",
"path",
")",
".",
"then",
"(",
"function",
"(",
"stats",
")",
"{",
"return",
"{",
"fileName",
":",
"_gpfNodePath",
".",
"basename",
"(",
"path",
")",
",",
"filePath",
":",
"_gpfPathNormalize",
"(",
"_gpfNodePath",
".",
"resolve",
"(",
"path",
")",
")",
",",
"size",
":",
"stats",
".",
"size",
",",
"createdDateTime",
":",
"stats",
".",
"ctime",
",",
"modifiedDateTime",
":",
"stats",
".",
"mtime",
",",
"type",
":",
"_gpfFsNodeGetType",
"(",
"stats",
")",
"}",
";",
"}",
")",
";",
"}",
"return",
"{",
"type",
":",
"_GPF_FS_TYPES",
".",
"NOT_FOUND",
"}",
";",
"}",
")",
";",
"}"
] | region gpf.interfaces.IFileStorage
@gpf:sameas gpf.interfaces.IFileStorage#getInfo
@since 0.1.9 | [
"region",
"gpf",
".",
"interfaces",
".",
"IFileStorage"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/fs/nodejs.js#L133-L157 | train |
|
popeindustries/buddy | packages/buddy-cli/index.js | getOptions | function getOptions () {
return {
compress: ('compress' in program) ? program.compress : false,
debug: ('debug' in program) ? program.debug : false,
deploy: false,
grep: ('grep' in program) ? program.grep : false,
invert: ('invert' in program) ? program.invert : false,
maps: ('maps' in program) ? program.maps : false,
reload: ('reload' in program) ? program.reload : false,
script: ('script' in program) ? program.script : false,
serve: ('serve' in program) ? program.serve : false,
watch: false
};
} | javascript | function getOptions () {
return {
compress: ('compress' in program) ? program.compress : false,
debug: ('debug' in program) ? program.debug : false,
deploy: false,
grep: ('grep' in program) ? program.grep : false,
invert: ('invert' in program) ? program.invert : false,
maps: ('maps' in program) ? program.maps : false,
reload: ('reload' in program) ? program.reload : false,
script: ('script' in program) ? program.script : false,
serve: ('serve' in program) ? program.serve : false,
watch: false
};
} | [
"function",
"getOptions",
"(",
")",
"{",
"return",
"{",
"compress",
":",
"(",
"'compress'",
"in",
"program",
")",
"?",
"program",
".",
"compress",
":",
"false",
",",
"debug",
":",
"(",
"'debug'",
"in",
"program",
")",
"?",
"program",
".",
"debug",
":",
"false",
",",
"deploy",
":",
"false",
",",
"grep",
":",
"(",
"'grep'",
"in",
"program",
")",
"?",
"program",
".",
"grep",
":",
"false",
",",
"invert",
":",
"(",
"'invert'",
"in",
"program",
")",
"?",
"program",
".",
"invert",
":",
"false",
",",
"maps",
":",
"(",
"'maps'",
"in",
"program",
")",
"?",
"program",
".",
"maps",
":",
"false",
",",
"reload",
":",
"(",
"'reload'",
"in",
"program",
")",
"?",
"program",
".",
"reload",
":",
"false",
",",
"script",
":",
"(",
"'script'",
"in",
"program",
")",
"?",
"program",
".",
"script",
":",
"false",
",",
"serve",
":",
"(",
"'serve'",
"in",
"program",
")",
"?",
"program",
".",
"serve",
":",
"false",
",",
"watch",
":",
"false",
"}",
";",
"}"
] | Retrieve options object
@returns {Object} | [
"Retrieve",
"options",
"object"
] | c38afc2e6915743eb6cfcf5aba59a8699142c7a5 | https://github.com/popeindustries/buddy/blob/c38afc2e6915743eb6cfcf5aba59a8699142c7a5/packages/buddy-cli/index.js#L100-L113 | train |
popeindustries/buddy | lib/plugins/react/index.js | define | function define(JSFile, utils) {
return class JSXFile extends JSFile {
/**
* Parse 'content' for dependency references
* @param {String} content
* @returns {Array}
*/
parseDependencyReferences(content) {
const references = super.parseDependencyReferences(content);
references[0].push({ context: "require('react')", match: 'react', id: 'react' });
return references;
}
/**
* Transpile file contents
* @param {Object} buildOptions
* - {Boolean} batch
* - {Boolean} bootstrap
* - {Boolean} boilerplate
* - {Boolean} browser
* - {Boolean} bundle
* - {Boolean} compress
* - {Boolean} helpers
* - {Array} ignoredFiles
* - {Boolean} import
* - {Boolean} watchOnly
* @param {Function} fn(err)
*/
transpile(buildOptions, fn) {
super.transpile(buildOptions, (err) => {
if (err) return fn && fn();
this.prependContent("var React = $m['react'].exports;");
fn();
});
}
};
} | javascript | function define(JSFile, utils) {
return class JSXFile extends JSFile {
/**
* Parse 'content' for dependency references
* @param {String} content
* @returns {Array}
*/
parseDependencyReferences(content) {
const references = super.parseDependencyReferences(content);
references[0].push({ context: "require('react')", match: 'react', id: 'react' });
return references;
}
/**
* Transpile file contents
* @param {Object} buildOptions
* - {Boolean} batch
* - {Boolean} bootstrap
* - {Boolean} boilerplate
* - {Boolean} browser
* - {Boolean} bundle
* - {Boolean} compress
* - {Boolean} helpers
* - {Array} ignoredFiles
* - {Boolean} import
* - {Boolean} watchOnly
* @param {Function} fn(err)
*/
transpile(buildOptions, fn) {
super.transpile(buildOptions, (err) => {
if (err) return fn && fn();
this.prependContent("var React = $m['react'].exports;");
fn();
});
}
};
} | [
"function",
"define",
"(",
"JSFile",
",",
"utils",
")",
"{",
"return",
"class",
"JSXFile",
"extends",
"JSFile",
"{",
"parseDependencyReferences",
"(",
"content",
")",
"{",
"const",
"references",
"=",
"super",
".",
"parseDependencyReferences",
"(",
"content",
")",
";",
"references",
"[",
"0",
"]",
".",
"push",
"(",
"{",
"context",
":",
"\"require('react')\"",
",",
"match",
":",
"'react'",
",",
"id",
":",
"'react'",
"}",
")",
";",
"return",
"references",
";",
"}",
"transpile",
"(",
"buildOptions",
",",
"fn",
")",
"{",
"super",
".",
"transpile",
"(",
"buildOptions",
",",
"(",
"err",
")",
"=>",
"{",
"if",
"(",
"err",
")",
"return",
"fn",
"&&",
"fn",
"(",
")",
";",
"this",
".",
"prependContent",
"(",
"\"var React = $m['react'].exports;\"",
")",
";",
"fn",
"(",
")",
";",
"}",
")",
";",
"}",
"}",
";",
"}"
] | Extend 'JSFile' with new behaviour
@param {Class} JSFile
@param {Object} utils
@returns {Class} | [
"Extend",
"JSFile",
"with",
"new",
"behaviour"
] | c38afc2e6915743eb6cfcf5aba59a8699142c7a5 | https://github.com/popeindustries/buddy/blob/c38afc2e6915743eb6cfcf5aba59a8699142c7a5/lib/plugins/react/index.js#L30-L68 | train |
ArnaudBuchholz/gpf-js | src/literal.js | _gpfIsLiteralObject | function _gpfIsLiteralObject (value) {
return value instanceof Object
&& _gpfObjectToString.call(value) === "[object Object]"
&& Object.getPrototypeOf(value) === Object.getPrototypeOf({});
} | javascript | function _gpfIsLiteralObject (value) {
return value instanceof Object
&& _gpfObjectToString.call(value) === "[object Object]"
&& Object.getPrototypeOf(value) === Object.getPrototypeOf({});
} | [
"function",
"_gpfIsLiteralObject",
"(",
"value",
")",
"{",
"return",
"value",
"instanceof",
"Object",
"&&",
"_gpfObjectToString",
".",
"call",
"(",
"value",
")",
"===",
"\"[object Object]\"",
"&&",
"Object",
".",
"getPrototypeOf",
"(",
"value",
")",
"===",
"Object",
".",
"getPrototypeOf",
"(",
"{",
"}",
")",
";",
"}"
] | Check if the parameter is a literal object
@param {*} value Value to check
@return {Boolean} True if the value is a literal object
@since 0.2.1 | [
"Check",
"if",
"the",
"parameter",
"is",
"a",
"literal",
"object"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/literal.js#L19-L23 | train |
popeindustries/buddy | lib/utils/serverfarm.js | startAppServer | function startAppServer(fn) {
if (!checkingAppServerPort) {
server = fork(appServer.file, [], appServer.options);
server.on('exit', code => {
checkingAppServerPort = false;
server.removeAllListeners();
server = null;
fn(Error('failed to start server'));
});
checkingAppServerPort = true;
waitForPortOpen(appServer.port, fn);
}
} | javascript | function startAppServer(fn) {
if (!checkingAppServerPort) {
server = fork(appServer.file, [], appServer.options);
server.on('exit', code => {
checkingAppServerPort = false;
server.removeAllListeners();
server = null;
fn(Error('failed to start server'));
});
checkingAppServerPort = true;
waitForPortOpen(appServer.port, fn);
}
} | [
"function",
"startAppServer",
"(",
"fn",
")",
"{",
"if",
"(",
"!",
"checkingAppServerPort",
")",
"{",
"server",
"=",
"fork",
"(",
"appServer",
".",
"file",
",",
"[",
"]",
",",
"appServer",
".",
"options",
")",
";",
"server",
".",
"on",
"(",
"'exit'",
",",
"code",
"=>",
"{",
"checkingAppServerPort",
"=",
"false",
";",
"server",
".",
"removeAllListeners",
"(",
")",
";",
"server",
"=",
"null",
";",
"fn",
"(",
"Error",
"(",
"'failed to start server'",
")",
")",
";",
"}",
")",
";",
"checkingAppServerPort",
"=",
"true",
";",
"waitForPortOpen",
"(",
"appServer",
".",
"port",
",",
"fn",
")",
";",
"}",
"}"
] | Start app server
@param {Function} fn(err) | [
"Start",
"app",
"server"
] | c38afc2e6915743eb6cfcf5aba59a8699142c7a5 | https://github.com/popeindustries/buddy/blob/c38afc2e6915743eb6cfcf5aba59a8699142c7a5/lib/utils/serverfarm.js#L151-L164 | train |
SockDrawer/SockBot | plugins/echo.js | echo | function echo(command) {
return command.getUser()
.then((user) => {
const content = (command.parent.text || '').split('\n').map((line) => `> ${line}`);
content.unshift(`@${user.username} said:`);
command.reply(content.join('\n'));
});
} | javascript | function echo(command) {
return command.getUser()
.then((user) => {
const content = (command.parent.text || '').split('\n').map((line) => `> ${line}`);
content.unshift(`@${user.username} said:`);
command.reply(content.join('\n'));
});
} | [
"function",
"echo",
"(",
"command",
")",
"{",
"return",
"command",
".",
"getUser",
"(",
")",
".",
"then",
"(",
"(",
"user",
")",
"=>",
"{",
"const",
"content",
"=",
"(",
"command",
".",
"parent",
".",
"text",
"||",
"''",
")",
".",
"split",
"(",
"'\\n'",
")",
".",
"\\n",
"map",
";",
"(",
"(",
"line",
")",
"=>",
"`",
"${",
"line",
"}",
"`",
")",
"content",
".",
"unshift",
"(",
"`",
"${",
"user",
".",
"username",
"}",
"`",
")",
";",
"}",
")",
";",
"}"
] | Echo the command contents back to the user
@param {Command} command The command that contains the `!echo` command
@returns {Promise} Resolves when processing is complete | [
"Echo",
"the",
"command",
"contents",
"back",
"to",
"the",
"user"
] | 043f7e9aa9ec12250889fd825ddcf86709b095a3 | https://github.com/SockDrawer/SockBot/blob/043f7e9aa9ec12250889fd825ddcf86709b095a3/plugins/echo.js#L24-L31 | train |
ArnaudBuchholz/gpf-js | src/require/configure.js | _gpfRequireConfigureAddOption | function _gpfRequireConfigureAddOption (name, handler, highPriority) {
if (highPriority) {
_gpfRequireConfigureOptionNames.unshift(name);
} else {
_gpfRequireConfigureOptionNames.push(name);
}
_gpfRequireConfigureHandler[name] = handler;
} | javascript | function _gpfRequireConfigureAddOption (name, handler, highPriority) {
if (highPriority) {
_gpfRequireConfigureOptionNames.unshift(name);
} else {
_gpfRequireConfigureOptionNames.push(name);
}
_gpfRequireConfigureHandler[name] = handler;
} | [
"function",
"_gpfRequireConfigureAddOption",
"(",
"name",
",",
"handler",
",",
"highPriority",
")",
"{",
"if",
"(",
"highPriority",
")",
"{",
"_gpfRequireConfigureOptionNames",
".",
"unshift",
"(",
"name",
")",
";",
"}",
"else",
"{",
"_gpfRequireConfigureOptionNames",
".",
"push",
"(",
"name",
")",
";",
"}",
"_gpfRequireConfigureHandler",
"[",
"name",
"]",
"=",
"handler",
";",
"}"
] | Declare a configuration option
@param {String} name Option name
@param {Function} handler Option handler (will receive context and value)
@param {Boolean} [highPriority=false] Option must be handled before the others
@since 0.2.9 | [
"Declare",
"a",
"configuration",
"option"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/require/configure.js#L87-L94 | train |
popeindustries/buddy | lib/config/buddyPlugins.js | loadPluginsFromDir | function loadPluginsFromDir(dir, config) {
try {
fs
.readdirSync(dir)
.filter(resource => {
if (path.basename(dir) != 'plugins') return RE_PLUGIN.test(resource);
return RE_JS_FILE.test(resource) || fs.statSync(path.join(dir, resource)).isDirectory();
})
.forEach(resource => {
registerPlugin(path.join(dir, resource), config);
});
} catch (err) {
/* ignore */
}
} | javascript | function loadPluginsFromDir(dir, config) {
try {
fs
.readdirSync(dir)
.filter(resource => {
if (path.basename(dir) != 'plugins') return RE_PLUGIN.test(resource);
return RE_JS_FILE.test(resource) || fs.statSync(path.join(dir, resource)).isDirectory();
})
.forEach(resource => {
registerPlugin(path.join(dir, resource), config);
});
} catch (err) {
/* ignore */
}
} | [
"function",
"loadPluginsFromDir",
"(",
"dir",
",",
"config",
")",
"{",
"try",
"{",
"fs",
".",
"readdirSync",
"(",
"dir",
")",
".",
"filter",
"(",
"resource",
"=>",
"{",
"if",
"(",
"path",
".",
"basename",
"(",
"dir",
")",
"!=",
"'plugins'",
")",
"return",
"RE_PLUGIN",
".",
"test",
"(",
"resource",
")",
";",
"return",
"RE_JS_FILE",
".",
"test",
"(",
"resource",
")",
"||",
"fs",
".",
"statSync",
"(",
"path",
".",
"join",
"(",
"dir",
",",
"resource",
")",
")",
".",
"isDirectory",
"(",
")",
";",
"}",
")",
".",
"forEach",
"(",
"resource",
"=>",
"{",
"registerPlugin",
"(",
"path",
".",
"join",
"(",
"dir",
",",
"resource",
")",
",",
"config",
")",
";",
"}",
")",
";",
"}",
"catch",
"(",
"err",
")",
"{",
"}",
"}"
] | Load plugins in 'dir'
@param {String} dir
@param {Object} config | [
"Load",
"plugins",
"in",
"dir"
] | c38afc2e6915743eb6cfcf5aba59a8699142c7a5 | https://github.com/popeindustries/buddy/blob/c38afc2e6915743eb6cfcf5aba59a8699142c7a5/lib/config/buddyPlugins.js#L48-L62 | train |
popeindustries/buddy | lib/config/buddyPlugins.js | registerPlugin | function registerPlugin(resource, config, silent) {
let module;
try {
module = 'string' == typeof resource ? require(resource) : resource;
} catch (err) {
return warn(`unable to load plugin ${strong(resource)}`);
}
if (!('register' in module)) return warn(`invalid plugin ${strong(resource)}`);
module.register(config);
if (!silent) print(`registered plugin ${strong(module.name)}`, 0);
} | javascript | function registerPlugin(resource, config, silent) {
let module;
try {
module = 'string' == typeof resource ? require(resource) : resource;
} catch (err) {
return warn(`unable to load plugin ${strong(resource)}`);
}
if (!('register' in module)) return warn(`invalid plugin ${strong(resource)}`);
module.register(config);
if (!silent) print(`registered plugin ${strong(module.name)}`, 0);
} | [
"function",
"registerPlugin",
"(",
"resource",
",",
"config",
",",
"silent",
")",
"{",
"let",
"module",
";",
"try",
"{",
"module",
"=",
"'string'",
"==",
"typeof",
"resource",
"?",
"require",
"(",
"resource",
")",
":",
"resource",
";",
"}",
"catch",
"(",
"err",
")",
"{",
"return",
"warn",
"(",
"`",
"${",
"strong",
"(",
"resource",
")",
"}",
"`",
")",
";",
"}",
"if",
"(",
"!",
"(",
"'register'",
"in",
"module",
")",
")",
"return",
"warn",
"(",
"`",
"${",
"strong",
"(",
"resource",
")",
"}",
"`",
")",
";",
"module",
".",
"register",
"(",
"config",
")",
";",
"if",
"(",
"!",
"silent",
")",
"print",
"(",
"`",
"${",
"strong",
"(",
"module",
".",
"name",
")",
"}",
"`",
",",
"0",
")",
";",
"}"
] | Register plugin 'resource'
@param {String} resource
@param {Object} config
@param {Boolean} [silent]
@returns {null} | [
"Register",
"plugin",
"resource"
] | c38afc2e6915743eb6cfcf5aba59a8699142c7a5 | https://github.com/popeindustries/buddy/blob/c38afc2e6915743eb6cfcf5aba59a8699142c7a5/lib/config/buddyPlugins.js#L71-L84 | train |
ArnaudBuchholz/gpf-js | src/compatibility/json/stringify.js | _gpfJsonStringifyPolyfill | function _gpfJsonStringifyPolyfill (value, replacer, space) {
return _gpfJsonStringifyMapping[typeof value](value, _gpfJsonStringifyCheckReplacer(replacer),
_gpfJsonStringifyCheckSpaceValue(space));
} | javascript | function _gpfJsonStringifyPolyfill (value, replacer, space) {
return _gpfJsonStringifyMapping[typeof value](value, _gpfJsonStringifyCheckReplacer(replacer),
_gpfJsonStringifyCheckSpaceValue(space));
} | [
"function",
"_gpfJsonStringifyPolyfill",
"(",
"value",
",",
"replacer",
",",
"space",
")",
"{",
"return",
"_gpfJsonStringifyMapping",
"[",
"typeof",
"value",
"]",
"(",
"value",
",",
"_gpfJsonStringifyCheckReplacer",
"(",
"replacer",
")",
",",
"_gpfJsonStringifyCheckSpaceValue",
"(",
"space",
")",
")",
";",
"}"
] | JSON.stringify polyfill
@param {*} value The value to convert to a JSON string
@param {Function|Array} [replacer] A function that alters the behavior of the stringification process, or an array of
String and Number objects that serve as a whitelist for selecting/filtering the properties of the value object to be
included in the JSON string
@param {String|Number} [space] A String or Number object that's used to insert white space into the output JSON
string for readability purposes. If this is a Number, it indicates the number of space characters to use as white
space; this number is capped at 10 (if it is greater, the value is just 10).
@return {String} JSON representation of the value
@since 0.1.5 | [
"JSON",
".",
"stringify",
"polyfill"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/compatibility/json/stringify.js#L127-L130 | train |
ArnaudBuchholz/gpf-js | src/function.js | _gpfFunctionDescribe | function _gpfFunctionDescribe (functionToDescribe) {
var result = {};
_gpfFunctionDescribeName(functionToDescribe, result);
_gpfFunctionDescribeSource(functionToDescribe, result);
return result;
} | javascript | function _gpfFunctionDescribe (functionToDescribe) {
var result = {};
_gpfFunctionDescribeName(functionToDescribe, result);
_gpfFunctionDescribeSource(functionToDescribe, result);
return result;
} | [
"function",
"_gpfFunctionDescribe",
"(",
"functionToDescribe",
")",
"{",
"var",
"result",
"=",
"{",
"}",
";",
"_gpfFunctionDescribeName",
"(",
"functionToDescribe",
",",
"result",
")",
";",
"_gpfFunctionDescribeSource",
"(",
"functionToDescribe",
",",
"result",
")",
";",
"return",
"result",
";",
"}"
] | Extract function description
@param {Function} functionToDescribe Function to describe
@return {gpf.typedef._functionDescription} Function description
@since 0.1.6 | [
"Extract",
"function",
"description"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/function.js#L106-L111 | train |
ArnaudBuchholz/gpf-js | lost+found/src/xml.js | function (event) {
var
eventsHandler;
if (event
&& event.type() === _gpfI.IWritableStream.EVENT_ERROR) {
gpfFireEvent.call(this, event, this._eventsHandler);
} else if (0 === this._buffer.length) {
eventsHandler = this._eventsHandler;
this._eventsHandler = null;
gpfFireEvent.call(this, _gpfI.IWritableStream.EVENT_READY, eventsHandler);
} else {
this._stream.write(this._buffer.shift(), this._flushed.bind(this));
}
} | javascript | function (event) {
var
eventsHandler;
if (event
&& event.type() === _gpfI.IWritableStream.EVENT_ERROR) {
gpfFireEvent.call(this, event, this._eventsHandler);
} else if (0 === this._buffer.length) {
eventsHandler = this._eventsHandler;
this._eventsHandler = null;
gpfFireEvent.call(this, _gpfI.IWritableStream.EVENT_READY, eventsHandler);
} else {
this._stream.write(this._buffer.shift(), this._flushed.bind(this));
}
} | [
"function",
"(",
"event",
")",
"{",
"var",
"eventsHandler",
";",
"if",
"(",
"event",
"&&",
"event",
".",
"type",
"(",
")",
"===",
"_gpfI",
".",
"IWritableStream",
".",
"EVENT_ERROR",
")",
"{",
"gpfFireEvent",
".",
"call",
"(",
"this",
",",
"event",
",",
"this",
".",
"_eventsHandler",
")",
";",
"}",
"else",
"if",
"(",
"0",
"===",
"this",
".",
"_buffer",
".",
"length",
")",
"{",
"eventsHandler",
"=",
"this",
".",
"_eventsHandler",
";",
"this",
".",
"_eventsHandler",
"=",
"null",
";",
"gpfFireEvent",
".",
"call",
"(",
"this",
",",
"_gpfI",
".",
"IWritableStream",
".",
"EVENT_READY",
",",
"eventsHandler",
")",
";",
"}",
"else",
"{",
"this",
".",
"_stream",
".",
"write",
"(",
"this",
".",
"_buffer",
".",
"shift",
"(",
")",
",",
"this",
".",
"_flushed",
".",
"bind",
"(",
"this",
")",
")",
";",
"}",
"}"
] | Handle write event on stream
@param {gpf.events.Event} event
@private | [
"Handle",
"write",
"event",
"on",
"stream"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/xml.js#L109-L122 | train |
|
ArnaudBuchholz/gpf-js | lost+found/src/xml.js | function (name) {
var newName;
if (gpf.xml.isValidName(name)) {
return name;
}
// Try with a starting _
newName = "_" + name;
if (!gpf.xml.isValidName(newName)) {
gpf.Error.xmlInvalidName();
}
return newName;
} | javascript | function (name) {
var newName;
if (gpf.xml.isValidName(name)) {
return name;
}
// Try with a starting _
newName = "_" + name;
if (!gpf.xml.isValidName(newName)) {
gpf.Error.xmlInvalidName();
}
return newName;
} | [
"function",
"(",
"name",
")",
"{",
"var",
"newName",
";",
"if",
"(",
"gpf",
".",
"xml",
".",
"isValidName",
"(",
"name",
")",
")",
"{",
"return",
"name",
";",
"}",
"newName",
"=",
"\"_\"",
"+",
"name",
";",
"if",
"(",
"!",
"gpf",
".",
"xml",
".",
"isValidName",
"(",
"newName",
")",
")",
"{",
"gpf",
".",
"Error",
".",
"xmlInvalidName",
"(",
")",
";",
"}",
"return",
"newName",
";",
"}"
] | Make sure that the provided name can be use as an element or
attribute name
@param {String} name
@return {String} a valid attribute/element name | [
"Make",
"sure",
"that",
"the",
"provided",
"name",
"can",
"be",
"use",
"as",
"an",
"element",
"or",
"attribute",
"name"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/xml.js#L364-L375 | train |
|
ArnaudBuchholz/gpf-js | lost+found/src/html.js | function (char) {
var
newState,
tagsOpened = 0 < this._openedTags.length;
if ("#" === char) {
this._hLevel = 1;
newState = this._parseTitle;
} else if ("*" === char || "0" <= char && "9" >= char ) {
if (char !== "*") {
this._numericList = 1;
} else {
this._numericList = 0;
}
newState = this._parseList;
tagsOpened = false; // Wait for disambiguation
} else if (" " !== char && "\t" !== char && "\n" !== char) {
if (tagsOpened) {
this._output(" ");
tagsOpened = false; // Avoid closing below
} else {
this._openTag("p");
}
newState = this._parseContent(char);
if (!newState) {
newState = this._parseContent;
}
}
if (tagsOpened) {
this._closeTags();
}
return newState;
} | javascript | function (char) {
var
newState,
tagsOpened = 0 < this._openedTags.length;
if ("#" === char) {
this._hLevel = 1;
newState = this._parseTitle;
} else if ("*" === char || "0" <= char && "9" >= char ) {
if (char !== "*") {
this._numericList = 1;
} else {
this._numericList = 0;
}
newState = this._parseList;
tagsOpened = false; // Wait for disambiguation
} else if (" " !== char && "\t" !== char && "\n" !== char) {
if (tagsOpened) {
this._output(" ");
tagsOpened = false; // Avoid closing below
} else {
this._openTag("p");
}
newState = this._parseContent(char);
if (!newState) {
newState = this._parseContent;
}
}
if (tagsOpened) {
this._closeTags();
}
return newState;
} | [
"function",
"(",
"char",
")",
"{",
"var",
"newState",
",",
"tagsOpened",
"=",
"0",
"<",
"this",
".",
"_openedTags",
".",
"length",
";",
"if",
"(",
"\"#\"",
"===",
"char",
")",
"{",
"this",
".",
"_hLevel",
"=",
"1",
";",
"newState",
"=",
"this",
".",
"_parseTitle",
";",
"}",
"else",
"if",
"(",
"\"*\"",
"===",
"char",
"||",
"\"0\"",
"<=",
"char",
"&&",
"\"9\"",
">=",
"char",
")",
"{",
"if",
"(",
"char",
"!==",
"\"*\"",
")",
"{",
"this",
".",
"_numericList",
"=",
"1",
";",
"}",
"else",
"{",
"this",
".",
"_numericList",
"=",
"0",
";",
"}",
"newState",
"=",
"this",
".",
"_parseList",
";",
"tagsOpened",
"=",
"false",
";",
"}",
"else",
"if",
"(",
"\" \"",
"!==",
"char",
"&&",
"\"\\t\"",
"!==",
"\\t",
"&&",
"char",
")",
"\"\\n\"",
"!==",
"\\n",
"char",
"{",
"if",
"(",
"tagsOpened",
")",
"{",
"this",
".",
"_output",
"(",
"\" \"",
")",
";",
"tagsOpened",
"=",
"false",
";",
"}",
"else",
"{",
"this",
".",
"_openTag",
"(",
"\"p\"",
")",
";",
"}",
"newState",
"=",
"this",
".",
"_parseContent",
"(",
"char",
")",
";",
"if",
"(",
"!",
"newState",
")",
"{",
"newState",
"=",
"this",
".",
"_parseContent",
";",
"}",
"}",
"}"
] | \r
Initial state
@param {String} char
@protected | [
"\\",
"r",
"Initial",
"state"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/html.js#L124-L155 | train |
|
ArnaudBuchholz/gpf-js | lost+found/src/html.js | function () {
var
url = this._linkUrl.join(""),
text = this._linkText.join("");
if (0 === this._linkType) {
this._output("<a href=\"");
this._output(url);
this._output("\">");
this._output(text);
this._output("</a>");
} else if (1 === this._linkType) {
this._output("<img src=\"");
this._output(url);
this._output("\" alt=\"");
this._output(text);
this._output("\" title=\"");
this._output(text);
this._output("\">");
}
return this._parseContent;
} | javascript | function () {
var
url = this._linkUrl.join(""),
text = this._linkText.join("");
if (0 === this._linkType) {
this._output("<a href=\"");
this._output(url);
this._output("\">");
this._output(text);
this._output("</a>");
} else if (1 === this._linkType) {
this._output("<img src=\"");
this._output(url);
this._output("\" alt=\"");
this._output(text);
this._output("\" title=\"");
this._output(text);
this._output("\">");
}
return this._parseContent;
} | [
"function",
"(",
")",
"{",
"var",
"url",
"=",
"this",
".",
"_linkUrl",
".",
"join",
"(",
"\"\"",
")",
",",
"text",
"=",
"this",
".",
"_linkText",
".",
"join",
"(",
"\"\"",
")",
";",
"if",
"(",
"0",
"===",
"this",
".",
"_linkType",
")",
"{",
"this",
".",
"_output",
"(",
"\"<a href=\\\"\"",
")",
";",
"\\\"",
"this",
".",
"_output",
"(",
"url",
")",
";",
"this",
".",
"_output",
"(",
"\"\\\">\"",
")",
";",
"\\\"",
"}",
"else",
"this",
".",
"_output",
"(",
"text",
")",
";",
"this",
".",
"_output",
"(",
"\"</a>\"",
")",
";",
"}"
] | Finalize link parsing
@return {Function}
@private | [
"Finalize",
"link",
"parsing"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/html.js#L513-L533 | train |
|
ArnaudBuchholz/gpf-js | lost+found/src/html.js | function (event) {
var
reader = event.target,
buffer,
len,
result,
idx;
_gpfAssert(reader === this._reader, "Unexpected change of reader");
if (reader.error) {
gpfFireEvent.call(this,
gpfI.IReadableStream.ERROR,
{
// According to W3C
// http://www.w3.org/TR/domcore/#interface-domerror
error: {
name: reader.error.name,
message: reader.error.message
}
},
this._eventsHandler
);
} else if (reader.readyState === FileReader.DONE) {
buffer = new Int8Array(reader.result);
len = buffer.length;
result = [];
for (idx = 0; idx < len; ++idx) {
result.push(buffer[idx]);
}
gpfFireEvent.call(this, gpfI.IReadableStream.EVENT_DATA, {buffer: result}, this._eventsHandler);
}
} | javascript | function (event) {
var
reader = event.target,
buffer,
len,
result,
idx;
_gpfAssert(reader === this._reader, "Unexpected change of reader");
if (reader.error) {
gpfFireEvent.call(this,
gpfI.IReadableStream.ERROR,
{
// According to W3C
// http://www.w3.org/TR/domcore/#interface-domerror
error: {
name: reader.error.name,
message: reader.error.message
}
},
this._eventsHandler
);
} else if (reader.readyState === FileReader.DONE) {
buffer = new Int8Array(reader.result);
len = buffer.length;
result = [];
for (idx = 0; idx < len; ++idx) {
result.push(buffer[idx]);
}
gpfFireEvent.call(this, gpfI.IReadableStream.EVENT_DATA, {buffer: result}, this._eventsHandler);
}
} | [
"function",
"(",
"event",
")",
"{",
"var",
"reader",
"=",
"event",
".",
"target",
",",
"buffer",
",",
"len",
",",
"result",
",",
"idx",
";",
"_gpfAssert",
"(",
"reader",
"===",
"this",
".",
"_reader",
",",
"\"Unexpected change of reader\"",
")",
";",
"if",
"(",
"reader",
".",
"error",
")",
"{",
"gpfFireEvent",
".",
"call",
"(",
"this",
",",
"gpfI",
".",
"IReadableStream",
".",
"ERROR",
",",
"{",
"error",
":",
"{",
"name",
":",
"reader",
".",
"error",
".",
"name",
",",
"message",
":",
"reader",
".",
"error",
".",
"message",
"}",
"}",
",",
"this",
".",
"_eventsHandler",
")",
";",
"}",
"else",
"if",
"(",
"reader",
".",
"readyState",
"===",
"FileReader",
".",
"DONE",
")",
"{",
"buffer",
"=",
"new",
"Int8Array",
"(",
"reader",
".",
"result",
")",
";",
"len",
"=",
"buffer",
".",
"length",
";",
"result",
"=",
"[",
"]",
";",
"for",
"(",
"idx",
"=",
"0",
";",
"idx",
"<",
"len",
";",
"++",
"idx",
")",
"{",
"result",
".",
"push",
"(",
"buffer",
"[",
"idx",
"]",
")",
";",
"}",
"gpfFireEvent",
".",
"call",
"(",
"this",
",",
"gpfI",
".",
"IReadableStream",
".",
"EVENT_DATA",
",",
"{",
"buffer",
":",
"result",
"}",
",",
"this",
".",
"_eventsHandler",
")",
";",
"}",
"}"
] | Wrapper for the onloadend event handler
@param {DOM Event} event
@private | [
"Wrapper",
"for",
"the",
"onloadend",
"event",
"handler"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/html.js#L678-L708 | train |
|
ArnaudBuchholz/gpf-js | lost+found/src/html.js | function (domObject) {
var selector = this._selector;
if (selector) {
if (this._globalSelector) {
return document.querySelector(selector);
} else {
return domObject.querySelector(selector);
}
}
return undefined;
} | javascript | function (domObject) {
var selector = this._selector;
if (selector) {
if (this._globalSelector) {
return document.querySelector(selector);
} else {
return domObject.querySelector(selector);
}
}
return undefined;
} | [
"function",
"(",
"domObject",
")",
"{",
"var",
"selector",
"=",
"this",
".",
"_selector",
";",
"if",
"(",
"selector",
")",
"{",
"if",
"(",
"this",
".",
"_globalSelector",
")",
"{",
"return",
"document",
".",
"querySelector",
"(",
"selector",
")",
";",
"}",
"else",
"{",
"return",
"domObject",
".",
"querySelector",
"(",
"selector",
")",
";",
"}",
"}",
"return",
"undefined",
";",
"}"
] | Apply selection starting from the provided object
@param {Object} domObject
@return {Object|undefined}
@private | [
"Apply",
"selection",
"starting",
"from",
"the",
"provided",
"object"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/html.js#L754-L764 | train |
|
ArnaudBuchholz/gpf-js | lost+found/src/html.js | _getHandlerAttribute | function _getHandlerAttribute (member, handlerAttributeArray) {
var attribute;
if (1 !== handlerAttributeArray.length()) {
gpf.Error.htmlHandlerMultiplicityError({
member: member
});
}
attribute = handlerAttributeArray.get(0);
if (!(attribute instanceof _HtmEvent)) {
return attribute;
}
return null;
} | javascript | function _getHandlerAttribute (member, handlerAttributeArray) {
var attribute;
if (1 !== handlerAttributeArray.length()) {
gpf.Error.htmlHandlerMultiplicityError({
member: member
});
}
attribute = handlerAttributeArray.get(0);
if (!(attribute instanceof _HtmEvent)) {
return attribute;
}
return null;
} | [
"function",
"_getHandlerAttribute",
"(",
"member",
",",
"handlerAttributeArray",
")",
"{",
"var",
"attribute",
";",
"if",
"(",
"1",
"!==",
"handlerAttributeArray",
".",
"length",
"(",
")",
")",
"{",
"gpf",
".",
"Error",
".",
"htmlHandlerMultiplicityError",
"(",
"{",
"member",
":",
"member",
"}",
")",
";",
"}",
"attribute",
"=",
"handlerAttributeArray",
".",
"get",
"(",
"0",
")",
";",
"if",
"(",
"!",
"(",
"attribute",
"instanceof",
"_HtmEvent",
")",
")",
"{",
"return",
"attribute",
";",
"}",
"return",
"null",
";",
"}"
] | endregion region HTML event handlers mappers through attributes | [
"endregion",
"region",
"HTML",
"event",
"handlers",
"mappers",
"through",
"attributes"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/html.js#L825-L837 | train |
ArnaudBuchholz/gpf-js | lost+found/src/html.js | _onResize | function _onResize () {
_width = window.innerWidth;
_height = window.innerHeight;
var
orientation,
orientationChanged = false,
toRemove = [],
toAdd = [];
if (_width > _height) {
orientation = "gpf-landscape";
} else {
orientation = "gpf-portrait";
}
if (_orientation !== orientation) {
toRemove.push(_orientation);
_orientation = orientation;
toAdd.push(orientation);
orientationChanged = true;
}
gpf.html.alterClass(document.body, toAdd, toRemove);
_broadcaster.broadcastEvent("resize", {
width: _width,
height: _height
});
if (orientationChanged) {
_broadcaster.broadcastEvent("rotate", {
orientation: orientation
});
}
} | javascript | function _onResize () {
_width = window.innerWidth;
_height = window.innerHeight;
var
orientation,
orientationChanged = false,
toRemove = [],
toAdd = [];
if (_width > _height) {
orientation = "gpf-landscape";
} else {
orientation = "gpf-portrait";
}
if (_orientation !== orientation) {
toRemove.push(_orientation);
_orientation = orientation;
toAdd.push(orientation);
orientationChanged = true;
}
gpf.html.alterClass(document.body, toAdd, toRemove);
_broadcaster.broadcastEvent("resize", {
width: _width,
height: _height
});
if (orientationChanged) {
_broadcaster.broadcastEvent("rotate", {
orientation: orientation
});
}
} | [
"function",
"_onResize",
"(",
")",
"{",
"_width",
"=",
"window",
".",
"innerWidth",
";",
"_height",
"=",
"window",
".",
"innerHeight",
";",
"var",
"orientation",
",",
"orientationChanged",
"=",
"false",
",",
"toRemove",
"=",
"[",
"]",
",",
"toAdd",
"=",
"[",
"]",
";",
"if",
"(",
"_width",
">",
"_height",
")",
"{",
"orientation",
"=",
"\"gpf-landscape\"",
";",
"}",
"else",
"{",
"orientation",
"=",
"\"gpf-portrait\"",
";",
"}",
"if",
"(",
"_orientation",
"!==",
"orientation",
")",
"{",
"toRemove",
".",
"push",
"(",
"_orientation",
")",
";",
"_orientation",
"=",
"orientation",
";",
"toAdd",
".",
"push",
"(",
"orientation",
")",
";",
"orientationChanged",
"=",
"true",
";",
"}",
"gpf",
".",
"html",
".",
"alterClass",
"(",
"document",
".",
"body",
",",
"toAdd",
",",
"toRemove",
")",
";",
"_broadcaster",
".",
"broadcastEvent",
"(",
"\"resize\"",
",",
"{",
"width",
":",
"_width",
",",
"height",
":",
"_height",
"}",
")",
";",
"if",
"(",
"orientationChanged",
")",
"{",
"_broadcaster",
".",
"broadcastEvent",
"(",
"\"rotate\"",
",",
"{",
"orientation",
":",
"orientation",
"}",
")",
";",
"}",
"}"
] | HTML Event "resize" listener
@private | [
"HTML",
"Event",
"resize",
"listener"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/html.js#L1126-L1155 | train |
ArnaudBuchholz/gpf-js | lost+found/src/html.js | _onScroll | function _onScroll () {
_scrollY = window.scrollY;
if (_monitorTop && _dynamicCss) {
_updateDynamicCss();
}
_broadcaster.broadcastEvent("scroll", {
top: _scrollY
});
} | javascript | function _onScroll () {
_scrollY = window.scrollY;
if (_monitorTop && _dynamicCss) {
_updateDynamicCss();
}
_broadcaster.broadcastEvent("scroll", {
top: _scrollY
});
} | [
"function",
"_onScroll",
"(",
")",
"{",
"_scrollY",
"=",
"window",
".",
"scrollY",
";",
"if",
"(",
"_monitorTop",
"&&",
"_dynamicCss",
")",
"{",
"_updateDynamicCss",
"(",
")",
";",
"}",
"_broadcaster",
".",
"broadcastEvent",
"(",
"\"scroll\"",
",",
"{",
"top",
":",
"_scrollY",
"}",
")",
";",
"}"
] | HTML Event "scroll" listener
@private | [
"HTML",
"Event",
"scroll",
"listener"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/html.js#L1162-L1170 | train |
back4app/parse-cli-server | spec/helper.js | create | function create(options, callback) {
var t = new TestObject(options);
t.save(null, { success: callback });
} | javascript | function create(options, callback) {
var t = new TestObject(options);
t.save(null, { success: callback });
} | [
"function",
"create",
"(",
"options",
",",
"callback",
")",
"{",
"var",
"t",
"=",
"new",
"TestObject",
"(",
"options",
")",
";",
"t",
".",
"save",
"(",
"null",
",",
"{",
"success",
":",
"callback",
"}",
")",
";",
"}"
] | Convenience method to create a new TestObject with a callback | [
"Convenience",
"method",
"to",
"create",
"a",
"new",
"TestObject",
"with",
"a",
"callback"
] | 188e7b3feeb27e080a57fdd802c226e77fc776ce | https://github.com/back4app/parse-cli-server/blob/188e7b3feeb27e080a57fdd802c226e77fc776ce/spec/helper.js#L224-L227 | train |
back4app/parse-cli-server | spec/helper.js | normalize | function normalize(obj) {
if (obj === null || typeof obj !== 'object') {
return JSON.stringify(obj);
}
if (obj instanceof Array) {
return '[' + obj.map(normalize).join(', ') + ']';
}
var answer = '{';
for (var key of Object.keys(obj).sort()) {
answer += key + ': ';
answer += normalize(obj[key]);
answer += ', ';
}
answer += '}';
return answer;
} | javascript | function normalize(obj) {
if (obj === null || typeof obj !== 'object') {
return JSON.stringify(obj);
}
if (obj instanceof Array) {
return '[' + obj.map(normalize).join(', ') + ']';
}
var answer = '{';
for (var key of Object.keys(obj).sort()) {
answer += key + ': ';
answer += normalize(obj[key]);
answer += ', ';
}
answer += '}';
return answer;
} | [
"function",
"normalize",
"(",
"obj",
")",
"{",
"if",
"(",
"obj",
"===",
"null",
"||",
"typeof",
"obj",
"!==",
"'object'",
")",
"{",
"return",
"JSON",
".",
"stringify",
"(",
"obj",
")",
";",
"}",
"if",
"(",
"obj",
"instanceof",
"Array",
")",
"{",
"return",
"'['",
"+",
"obj",
".",
"map",
"(",
"normalize",
")",
".",
"join",
"(",
"', '",
")",
"+",
"']'",
";",
"}",
"var",
"answer",
"=",
"'{'",
";",
"for",
"(",
"var",
"key",
"of",
"Object",
".",
"keys",
"(",
"obj",
")",
".",
"sort",
"(",
")",
")",
"{",
"answer",
"+=",
"key",
"+",
"': '",
";",
"answer",
"+=",
"normalize",
"(",
"obj",
"[",
"key",
"]",
")",
";",
"answer",
"+=",
"', '",
";",
"}",
"answer",
"+=",
"'}'",
";",
"return",
"answer",
";",
"}"
] | Normalizes a JSON object. | [
"Normalizes",
"a",
"JSON",
"object",
"."
] | 188e7b3feeb27e080a57fdd802c226e77fc776ce | https://github.com/back4app/parse-cli-server/blob/188e7b3feeb27e080a57fdd802c226e77fc776ce/spec/helper.js#L298-L313 | train |
ArnaudBuchholz/gpf-js | src/constants.js | _gpfFuncUnsafe | function _gpfFuncUnsafe (params, source) {
var args;
if (!params.length) {
return _GpfFunc(source);
}
args = [].concat(params);
args.push(source);
return _GpfFunc.apply(null, args);
} | javascript | function _gpfFuncUnsafe (params, source) {
var args;
if (!params.length) {
return _GpfFunc(source);
}
args = [].concat(params);
args.push(source);
return _GpfFunc.apply(null, args);
} | [
"function",
"_gpfFuncUnsafe",
"(",
"params",
",",
"source",
")",
"{",
"var",
"args",
";",
"if",
"(",
"!",
"params",
".",
"length",
")",
"{",
"return",
"_GpfFunc",
"(",
"source",
")",
";",
"}",
"args",
"=",
"[",
"]",
".",
"concat",
"(",
"params",
")",
";",
"args",
".",
"push",
"(",
"source",
")",
";",
"return",
"_GpfFunc",
".",
"apply",
"(",
"null",
",",
"args",
")",
";",
"}"
] | Unprotected version of _gpfFunc | [
"Unprotected",
"version",
"of",
"_gpfFunc"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/constants.js#L69-L77 | train |
ArnaudBuchholz/gpf-js | src/constants.js | _gpfFunc | function _gpfFunc (params, source) {
if (undefined === source) {
return _gpfFuncImpl([], params);
}
return _gpfFuncImpl(params, source);
} | javascript | function _gpfFunc (params, source) {
if (undefined === source) {
return _gpfFuncImpl([], params);
}
return _gpfFuncImpl(params, source);
} | [
"function",
"_gpfFunc",
"(",
"params",
",",
"source",
")",
"{",
"if",
"(",
"undefined",
"===",
"source",
")",
"{",
"return",
"_gpfFuncImpl",
"(",
"[",
"]",
",",
"params",
")",
";",
"}",
"return",
"_gpfFuncImpl",
"(",
"params",
",",
"source",
")",
";",
"}"
] | Create a new function from the source and parameter list.
In DEBUG mode, it catches any error to log the problem.
@param {String[]} [params] params Parameter names list
@param {String} source Body of the function
@return {Function} New function
@since 0.1.5 | [
"Create",
"a",
"new",
"function",
"from",
"the",
"source",
"and",
"parameter",
"list",
".",
"In",
"DEBUG",
"mode",
"it",
"catches",
"any",
"error",
"to",
"log",
"the",
"problem",
"."
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/constants.js#L112-L117 | train |
popeindustries/buddy | lib/utils/stopwatch.js | start | function start(id) {
if (!timers[id]) {
timers[id] = {
start: 0,
elapsed: 0
};
}
timers[id].start = process.hrtime();
} | javascript | function start(id) {
if (!timers[id]) {
timers[id] = {
start: 0,
elapsed: 0
};
}
timers[id].start = process.hrtime();
} | [
"function",
"start",
"(",
"id",
")",
"{",
"if",
"(",
"!",
"timers",
"[",
"id",
"]",
")",
"{",
"timers",
"[",
"id",
"]",
"=",
"{",
"start",
":",
"0",
",",
"elapsed",
":",
"0",
"}",
";",
"}",
"timers",
"[",
"id",
"]",
".",
"start",
"=",
"process",
".",
"hrtime",
"(",
")",
";",
"}"
] | Start timer with 'id'
@param {String} id | [
"Start",
"timer",
"with",
"id"
] | c38afc2e6915743eb6cfcf5aba59a8699142c7a5 | https://github.com/popeindustries/buddy/blob/c38afc2e6915743eb6cfcf5aba59a8699142c7a5/lib/utils/stopwatch.js#L17-L25 | train |
popeindustries/buddy | lib/utils/stopwatch.js | pause | function pause(id) {
if (!timers[id]) return start(id);
timers[id].elapsed += msDiff(process.hrtime(), timers[id].start);
} | javascript | function pause(id) {
if (!timers[id]) return start(id);
timers[id].elapsed += msDiff(process.hrtime(), timers[id].start);
} | [
"function",
"pause",
"(",
"id",
")",
"{",
"if",
"(",
"!",
"timers",
"[",
"id",
"]",
")",
"return",
"start",
"(",
"id",
")",
";",
"timers",
"[",
"id",
"]",
".",
"elapsed",
"+=",
"msDiff",
"(",
"process",
".",
"hrtime",
"(",
")",
",",
"timers",
"[",
"id",
"]",
".",
"start",
")",
";",
"}"
] | Pause timer with 'id'
@param {String} id
@returns {null} | [
"Pause",
"timer",
"with",
"id"
] | c38afc2e6915743eb6cfcf5aba59a8699142c7a5 | https://github.com/popeindustries/buddy/blob/c38afc2e6915743eb6cfcf5aba59a8699142c7a5/lib/utils/stopwatch.js#L32-L36 | train |
popeindustries/buddy | lib/utils/stopwatch.js | stop | function stop(id, formatted) {
const elapsed = timers[id].elapsed + msDiff(process.hrtime(), timers[id].start);
clear(id);
return formatted ? format(elapsed) : elapsed;
} | javascript | function stop(id, formatted) {
const elapsed = timers[id].elapsed + msDiff(process.hrtime(), timers[id].start);
clear(id);
return formatted ? format(elapsed) : elapsed;
} | [
"function",
"stop",
"(",
"id",
",",
"formatted",
")",
"{",
"const",
"elapsed",
"=",
"timers",
"[",
"id",
"]",
".",
"elapsed",
"+",
"msDiff",
"(",
"process",
".",
"hrtime",
"(",
")",
",",
"timers",
"[",
"id",
"]",
".",
"start",
")",
";",
"clear",
"(",
"id",
")",
";",
"return",
"formatted",
"?",
"format",
"(",
"elapsed",
")",
":",
"elapsed",
";",
"}"
] | Stop timer with 'id' and return elapsed
@param {String} id
@param {Boolean} formatted
@returns {Number} | [
"Stop",
"timer",
"with",
"id",
"and",
"return",
"elapsed"
] | c38afc2e6915743eb6cfcf5aba59a8699142c7a5 | https://github.com/popeindustries/buddy/blob/c38afc2e6915743eb6cfcf5aba59a8699142c7a5/lib/utils/stopwatch.js#L44-L49 | train |
popeindustries/buddy | lib/utils/stopwatch.js | msDiff | function msDiff(t1, t2) {
t1 = (t1[0] * 1e9 + t1[1]) / 1e6;
t2 = (t2[0] * 1e9 + t2[1]) / 1e6;
return Math.ceil((t1 - t2) * 100) / 100;
} | javascript | function msDiff(t1, t2) {
t1 = (t1[0] * 1e9 + t1[1]) / 1e6;
t2 = (t2[0] * 1e9 + t2[1]) / 1e6;
return Math.ceil((t1 - t2) * 100) / 100;
} | [
"function",
"msDiff",
"(",
"t1",
",",
"t2",
")",
"{",
"t1",
"=",
"(",
"t1",
"[",
"0",
"]",
"*",
"1e9",
"+",
"t1",
"[",
"1",
"]",
")",
"/",
"1e6",
";",
"t2",
"=",
"(",
"t2",
"[",
"0",
"]",
"*",
"1e9",
"+",
"t2",
"[",
"1",
"]",
")",
"/",
"1e6",
";",
"return",
"Math",
".",
"ceil",
"(",
"(",
"t1",
"-",
"t2",
")",
"*",
"100",
")",
"/",
"100",
";",
"}"
] | Retrieve difference in ms
@param {Array} t1
@param {Array} t2
@returns {Number} | [
"Retrieve",
"difference",
"in",
"ms"
] | c38afc2e6915743eb6cfcf5aba59a8699142c7a5 | https://github.com/popeindustries/buddy/blob/c38afc2e6915743eb6cfcf5aba59a8699142c7a5/lib/utils/stopwatch.js#L65-L69 | train |
ArnaudBuchholz/gpf-js | src/require/load.js | _gpfRequireLoad | function _gpfRequireLoad (name) {
var me = this;
return _gpfLoadOrPreload(me, name)
.then(function (content) {
return me.preprocess({
name: name,
content: content,
type: _gpfPathExtension(name).toLowerCase()
});
})
.then(function (resource) {
return _gpfLoadGetProcessor(resource).call(me, resource.name, resource.content);
});
} | javascript | function _gpfRequireLoad (name) {
var me = this;
return _gpfLoadOrPreload(me, name)
.then(function (content) {
return me.preprocess({
name: name,
content: content,
type: _gpfPathExtension(name).toLowerCase()
});
})
.then(function (resource) {
return _gpfLoadGetProcessor(resource).call(me, resource.name, resource.content);
});
} | [
"function",
"_gpfRequireLoad",
"(",
"name",
")",
"{",
"var",
"me",
"=",
"this",
";",
"return",
"_gpfLoadOrPreload",
"(",
"me",
",",
"name",
")",
".",
"then",
"(",
"function",
"(",
"content",
")",
"{",
"return",
"me",
".",
"preprocess",
"(",
"{",
"name",
":",
"name",
",",
"content",
":",
"content",
",",
"type",
":",
"_gpfPathExtension",
"(",
"name",
")",
".",
"toLowerCase",
"(",
")",
"}",
")",
";",
"}",
")",
".",
"then",
"(",
"function",
"(",
"resource",
")",
"{",
"return",
"_gpfLoadGetProcessor",
"(",
"resource",
")",
".",
"call",
"(",
"me",
",",
"resource",
".",
"name",
",",
"resource",
".",
"content",
")",
";",
"}",
")",
";",
"}"
] | Load the resource
@param {String} name Resource name
@return {Promise<*>} Resolved with the resource result
@since 0.2.2 | [
"Load",
"the",
"resource"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/require/load.js#L50-L63 | train |
ArnaudBuchholz/gpf-js | res/sources/main.js | upToSourceRow | function upToSourceRow (target) {
var current = target;
while (current && (!current.tagName || current.tagName.toLowerCase() !== "tr")) {
current = current.parentNode;
}
return current;
} | javascript | function upToSourceRow (target) {
var current = target;
while (current && (!current.tagName || current.tagName.toLowerCase() !== "tr")) {
current = current.parentNode;
}
return current;
} | [
"function",
"upToSourceRow",
"(",
"target",
")",
"{",
"var",
"current",
"=",
"target",
";",
"while",
"(",
"current",
"&&",
"(",
"!",
"current",
".",
"tagName",
"||",
"current",
".",
"tagName",
".",
"toLowerCase",
"(",
")",
"!==",
"\"tr\"",
")",
")",
"{",
"current",
"=",
"current",
".",
"parentNode",
";",
"}",
"return",
"current",
";",
"}"
] | region HTML page logic Whatever the target node, get the parent TR corresponding to the source row | [
"region",
"HTML",
"page",
"logic",
"Whatever",
"the",
"target",
"node",
"get",
"the",
"parent",
"TR",
"corresponding",
"to",
"the",
"source",
"row"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/res/sources/main.js#L28-L34 | train |
ArnaudBuchholz/gpf-js | res/sources/main.js | refreshSourceRow | function refreshSourceRow (target, source) {
var row = upToSourceRow(target),
newRow = rowFactory(source, source.getIndex());
sourceRows.replaceChild(newRow, row);
updateSourceRow(source);
} | javascript | function refreshSourceRow (target, source) {
var row = upToSourceRow(target),
newRow = rowFactory(source, source.getIndex());
sourceRows.replaceChild(newRow, row);
updateSourceRow(source);
} | [
"function",
"refreshSourceRow",
"(",
"target",
",",
"source",
")",
"{",
"var",
"row",
"=",
"upToSourceRow",
"(",
"target",
")",
",",
"newRow",
"=",
"rowFactory",
"(",
"source",
",",
"source",
".",
"getIndex",
"(",
")",
")",
";",
"sourceRows",
".",
"replaceChild",
"(",
"newRow",
",",
"row",
")",
";",
"updateSourceRow",
"(",
"source",
")",
";",
"}"
] | Regenerate the source row | [
"Regenerate",
"the",
"source",
"row"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/res/sources/main.js#L63-L68 | train |
ArnaudBuchholz/gpf-js | res/sources/main.js | reload | function reload () {
sourceRows.innerHTML = ""; // Clear content
sources.forEach(function (source, index) {
if (flavor && !flavor[index]) {
return;
}
sourceRows.appendChild(rowFactory(source, index));
updateSourceRow(source);
});
} | javascript | function reload () {
sourceRows.innerHTML = ""; // Clear content
sources.forEach(function (source, index) {
if (flavor && !flavor[index]) {
return;
}
sourceRows.appendChild(rowFactory(source, index));
updateSourceRow(source);
});
} | [
"function",
"reload",
"(",
")",
"{",
"sourceRows",
".",
"innerHTML",
"=",
"\"\"",
";",
"sources",
".",
"forEach",
"(",
"function",
"(",
"source",
",",
"index",
")",
"{",
"if",
"(",
"flavor",
"&&",
"!",
"flavor",
"[",
"index",
"]",
")",
"{",
"return",
";",
"}",
"sourceRows",
".",
"appendChild",
"(",
"rowFactory",
"(",
"source",
",",
"index",
")",
")",
";",
"updateSourceRow",
"(",
"source",
")",
";",
"}",
")",
";",
"}"
] | Regenerate all source rows | [
"Regenerate",
"all",
"source",
"rows"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/res/sources/main.js#L71-L80 | train |
ArnaudBuchholz/gpf-js | res/sources/main.js | compare | function compare (checkDictionary, path, pathContent) {
var subPromises = [];
pathContent.forEach(function (name) {
var JS_EXT = ".js",
JS_EXT_LENGTH = JS_EXT.length,
contentFullName = path + name,
contentFullNameLength = contentFullName.length;
if (contentFullNameLength > JS_EXT_LENGTH
&& contentFullName.indexOf(JS_EXT) === contentFullNameLength - JS_EXT_LENGTH) {
contentFullName = contentFullName.substring(START, contentFullNameLength - JS_EXT_LENGTH);
if (checkDictionary[contentFullName] === "obsolete") {
checkDictionary[contentFullName] = "exists";
} else {
checkDictionary[contentFullName] = "new";
}
} else if (name.indexOf(".") === NOT_FOUND) {
subPromises.push(gpf.http.get("/fs/src/" + contentFullName)
.then(function (response) {
return JSON.parse(response.responseText);
})
.then(function (subPathContent) {
return compare(checkDictionary, contentFullName + "/", subPathContent);
}));
}
});
if (!subPromises.length) {
return Promise.resolve();
}
return Promise.all(subPromises);
} | javascript | function compare (checkDictionary, path, pathContent) {
var subPromises = [];
pathContent.forEach(function (name) {
var JS_EXT = ".js",
JS_EXT_LENGTH = JS_EXT.length,
contentFullName = path + name,
contentFullNameLength = contentFullName.length;
if (contentFullNameLength > JS_EXT_LENGTH
&& contentFullName.indexOf(JS_EXT) === contentFullNameLength - JS_EXT_LENGTH) {
contentFullName = contentFullName.substring(START, contentFullNameLength - JS_EXT_LENGTH);
if (checkDictionary[contentFullName] === "obsolete") {
checkDictionary[contentFullName] = "exists";
} else {
checkDictionary[contentFullName] = "new";
}
} else if (name.indexOf(".") === NOT_FOUND) {
subPromises.push(gpf.http.get("/fs/src/" + contentFullName)
.then(function (response) {
return JSON.parse(response.responseText);
})
.then(function (subPathContent) {
return compare(checkDictionary, contentFullName + "/", subPathContent);
}));
}
});
if (!subPromises.length) {
return Promise.resolve();
}
return Promise.all(subPromises);
} | [
"function",
"compare",
"(",
"checkDictionary",
",",
"path",
",",
"pathContent",
")",
"{",
"var",
"subPromises",
"=",
"[",
"]",
";",
"pathContent",
".",
"forEach",
"(",
"function",
"(",
"name",
")",
"{",
"var",
"JS_EXT",
"=",
"\".js\"",
",",
"JS_EXT_LENGTH",
"=",
"JS_EXT",
".",
"length",
",",
"contentFullName",
"=",
"path",
"+",
"name",
",",
"contentFullNameLength",
"=",
"contentFullName",
".",
"length",
";",
"if",
"(",
"contentFullNameLength",
">",
"JS_EXT_LENGTH",
"&&",
"contentFullName",
".",
"indexOf",
"(",
"JS_EXT",
")",
"===",
"contentFullNameLength",
"-",
"JS_EXT_LENGTH",
")",
"{",
"contentFullName",
"=",
"contentFullName",
".",
"substring",
"(",
"START",
",",
"contentFullNameLength",
"-",
"JS_EXT_LENGTH",
")",
";",
"if",
"(",
"checkDictionary",
"[",
"contentFullName",
"]",
"===",
"\"obsolete\"",
")",
"{",
"checkDictionary",
"[",
"contentFullName",
"]",
"=",
"\"exists\"",
";",
"}",
"else",
"{",
"checkDictionary",
"[",
"contentFullName",
"]",
"=",
"\"new\"",
";",
"}",
"}",
"else",
"if",
"(",
"name",
".",
"indexOf",
"(",
"\".\"",
")",
"===",
"NOT_FOUND",
")",
"{",
"subPromises",
".",
"push",
"(",
"gpf",
".",
"http",
".",
"get",
"(",
"\"/fs/src/\"",
"+",
"contentFullName",
")",
".",
"then",
"(",
"function",
"(",
"response",
")",
"{",
"return",
"JSON",
".",
"parse",
"(",
"response",
".",
"responseText",
")",
";",
"}",
")",
".",
"then",
"(",
"function",
"(",
"subPathContent",
")",
"{",
"return",
"compare",
"(",
"checkDictionary",
",",
"contentFullName",
"+",
"\"/\"",
",",
"subPathContent",
")",
";",
"}",
")",
")",
";",
"}",
"}",
")",
";",
"if",
"(",
"!",
"subPromises",
".",
"length",
")",
"{",
"return",
"Promise",
".",
"resolve",
"(",
")",
";",
"}",
"return",
"Promise",
".",
"all",
"(",
"subPromises",
")",
";",
"}"
] | endregion region Compare sources.json with repository | [
"endregion",
"region",
"Compare",
"sources",
".",
"json",
"with",
"repository"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/res/sources/main.js#L181-L210 | train |
zetapush/zetapush | packages/user-management/samples/standard-user-workflow/front/js/signup.js | signupUser | async function signupUser(form) {
await client.connect();
try {
await api.signup(
{
credentials: {
login: form.login.value,
password: form.password.value
},
profile: {
email: form.email.value
}
},
'user'
);
displayMessage(
'Account created',
'Your account has been created, please check your emails to confirm your account',
'is-success'
);
goTo('login');
} catch (e) {
displayMessage('Account not created', `Your account could not been created. Cause: ${e.message}`, 'is-danger');
}
} | javascript | async function signupUser(form) {
await client.connect();
try {
await api.signup(
{
credentials: {
login: form.login.value,
password: form.password.value
},
profile: {
email: form.email.value
}
},
'user'
);
displayMessage(
'Account created',
'Your account has been created, please check your emails to confirm your account',
'is-success'
);
goTo('login');
} catch (e) {
displayMessage('Account not created', `Your account could not been created. Cause: ${e.message}`, 'is-danger');
}
} | [
"async",
"function",
"signupUser",
"(",
"form",
")",
"{",
"await",
"client",
".",
"connect",
"(",
")",
";",
"try",
"{",
"await",
"api",
".",
"signup",
"(",
"{",
"credentials",
":",
"{",
"login",
":",
"form",
".",
"login",
".",
"value",
",",
"password",
":",
"form",
".",
"password",
".",
"value",
"}",
",",
"profile",
":",
"{",
"email",
":",
"form",
".",
"email",
".",
"value",
"}",
"}",
",",
"'user'",
")",
";",
"displayMessage",
"(",
"'Account created'",
",",
"'Your account has been created, please check your emails to confirm your account'",
",",
"'is-success'",
")",
";",
"goTo",
"(",
"'login'",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"displayMessage",
"(",
"'Account not created'",
",",
"`",
"${",
"e",
".",
"message",
"}",
"`",
",",
"'is-danger'",
")",
";",
"}",
"}"
] | Launch the creation of the user account into the application | [
"Launch",
"the",
"creation",
"of",
"the",
"user",
"account",
"into",
"the",
"application"
] | ad3383b8e332050eaecd55be9bdff6cf76db699e | https://github.com/zetapush/zetapush/blob/ad3383b8e332050eaecd55be9bdff6cf76db699e/packages/user-management/samples/standard-user-workflow/front/js/signup.js#L4-L28 | train |
SockDrawer/SockBot | lib/config.js | readYaml | function readYaml(filePath) {
return new Promise((resolve, reject) => {
if (!filePath || typeof filePath !== 'string') {
throw new Error('Path must be a string');
}
fs.readFile(filePath, (err, data) => {
if (err) {
return reject(err);
}
// Remove UTF-8 BOM if present
if (data.length >= 3 && data[0] === 0xef &&
data[1] === 0xbb && data[2] === 0xbf) {
data = data.slice(3);
}
try {
return resolve(yaml.safeLoad(data));
} catch (yamlerr) {
return reject(yamlerr);
}
});
});
} | javascript | function readYaml(filePath) {
return new Promise((resolve, reject) => {
if (!filePath || typeof filePath !== 'string') {
throw new Error('Path must be a string');
}
fs.readFile(filePath, (err, data) => {
if (err) {
return reject(err);
}
// Remove UTF-8 BOM if present
if (data.length >= 3 && data[0] === 0xef &&
data[1] === 0xbb && data[2] === 0xbf) {
data = data.slice(3);
}
try {
return resolve(yaml.safeLoad(data));
} catch (yamlerr) {
return reject(yamlerr);
}
});
});
} | [
"function",
"readYaml",
"(",
"filePath",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"if",
"(",
"!",
"filePath",
"||",
"typeof",
"filePath",
"!==",
"'string'",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Path must be a string'",
")",
";",
"}",
"fs",
".",
"readFile",
"(",
"filePath",
",",
"(",
"err",
",",
"data",
")",
"=>",
"{",
"if",
"(",
"err",
")",
"{",
"return",
"reject",
"(",
"err",
")",
";",
"}",
"if",
"(",
"data",
".",
"length",
">=",
"3",
"&&",
"data",
"[",
"0",
"]",
"===",
"0xef",
"&&",
"data",
"[",
"1",
"]",
"===",
"0xbb",
"&&",
"data",
"[",
"2",
"]",
"===",
"0xbf",
")",
"{",
"data",
"=",
"data",
".",
"slice",
"(",
"3",
")",
";",
"}",
"try",
"{",
"return",
"resolve",
"(",
"yaml",
".",
"safeLoad",
"(",
"data",
")",
")",
";",
"}",
"catch",
"(",
"yamlerr",
")",
"{",
"return",
"reject",
"(",
"yamlerr",
")",
";",
"}",
"}",
")",
";",
"}",
")",
";",
"}"
] | Read and parse configuration file from disc
@param {string} filePath Path of file to read
@param {configComplete} callback Completion callback
@returns {Promise<*>} Resolves tyo YAML parsed configuration file | [
"Read",
"and",
"parse",
"configuration",
"file",
"from",
"disc"
] | 043f7e9aa9ec12250889fd825ddcf86709b095a3 | https://github.com/SockDrawer/SockBot/blob/043f7e9aa9ec12250889fd825ddcf86709b095a3/lib/config.js#L77-L98 | train |
ArnaudBuchholz/gpf-js | src/path.js | _gpfPathJoin | function _gpfPathJoin (path) {
var splitPath = _gpfPathDecompose(path);
_gpfArrayTail(arguments).forEach(_gpfPathAppend.bind(null, splitPath));
return splitPath.join("/");
} | javascript | function _gpfPathJoin (path) {
var splitPath = _gpfPathDecompose(path);
_gpfArrayTail(arguments).forEach(_gpfPathAppend.bind(null, splitPath));
return splitPath.join("/");
} | [
"function",
"_gpfPathJoin",
"(",
"path",
")",
"{",
"var",
"splitPath",
"=",
"_gpfPathDecompose",
"(",
"path",
")",
";",
"_gpfArrayTail",
"(",
"arguments",
")",
".",
"forEach",
"(",
"_gpfPathAppend",
".",
"bind",
"(",
"null",
",",
"splitPath",
")",
")",
";",
"return",
"splitPath",
".",
"join",
"(",
"\"/\"",
")",
";",
"}"
] | Join all arguments together and normalize the resulting path
@param {String} path Base path
@param {...String} relativePath Relative parts to append to the base path
@return {String} Joined path
@throws {gpf.Error.UnreachablePath}
@since 0.1.9 | [
"Join",
"all",
"arguments",
"together",
"and",
"normalize",
"the",
"resulting",
"path"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/path.js#L157-L161 | train |
ArnaudBuchholz/gpf-js | src/path.js | _gpfPathRelative | function _gpfPathRelative (from, to) {
var length,
splitFrom = _gpfPathDecompose(from),
splitTo = _gpfPathDecompose(to);
_gpfPathShiftIdenticalBeginning(splitFrom, splitTo);
// For each remaining part in from, unshift .. in to
length = splitFrom.length;
while (length--) {
splitTo.unshift("..");
}
return splitTo.join("/");
} | javascript | function _gpfPathRelative (from, to) {
var length,
splitFrom = _gpfPathDecompose(from),
splitTo = _gpfPathDecompose(to);
_gpfPathShiftIdenticalBeginning(splitFrom, splitTo);
// For each remaining part in from, unshift .. in to
length = splitFrom.length;
while (length--) {
splitTo.unshift("..");
}
return splitTo.join("/");
} | [
"function",
"_gpfPathRelative",
"(",
"from",
",",
"to",
")",
"{",
"var",
"length",
",",
"splitFrom",
"=",
"_gpfPathDecompose",
"(",
"from",
")",
",",
"splitTo",
"=",
"_gpfPathDecompose",
"(",
"to",
")",
";",
"_gpfPathShiftIdenticalBeginning",
"(",
"splitFrom",
",",
"splitTo",
")",
";",
"length",
"=",
"splitFrom",
".",
"length",
";",
"while",
"(",
"length",
"--",
")",
"{",
"splitTo",
".",
"unshift",
"(",
"\"..\"",
")",
";",
"}",
"return",
"splitTo",
".",
"join",
"(",
"\"/\"",
")",
";",
"}"
] | Solve the relative path from from to to
@param {String} from From path
@param {String} to To path
@return {String} Relative path
@since 0.1.9 | [
"Solve",
"the",
"relative",
"path",
"from",
"from",
"to",
"to"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/path.js#L198-L209 | train |
ArnaudBuchholz/gpf-js | src/path.js | function (path) {
var name = _gpfPathName(path),
pos = name.lastIndexOf(".");
if (pos === _GPF_NOT_FOUND) {
return name;
}
return name.substring(_GPF_START, pos);
} | javascript | function (path) {
var name = _gpfPathName(path),
pos = name.lastIndexOf(".");
if (pos === _GPF_NOT_FOUND) {
return name;
}
return name.substring(_GPF_START, pos);
} | [
"function",
"(",
"path",
")",
"{",
"var",
"name",
"=",
"_gpfPathName",
"(",
"path",
")",
",",
"pos",
"=",
"name",
".",
"lastIndexOf",
"(",
"\".\"",
")",
";",
"if",
"(",
"pos",
"===",
"_GPF_NOT_FOUND",
")",
"{",
"return",
"name",
";",
"}",
"return",
"name",
".",
"substring",
"(",
"_GPF_START",
",",
"pos",
")",
";",
"}"
] | Get the last name of a path without the extension
@param {String} path Path to analyze
@return {String} Name without the extension
@since 0.1.9 | [
"Get",
"the",
"last",
"name",
"of",
"a",
"path",
"without",
"the",
"extension"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/path.js#L254-L261 | train |
|
ForbesLindesay-Unmaintained/transformers | lib/transformers.js | sync | function sync(str, options) {
var tmpl = this.cache(options) || this.cache(options, this.engine.compile(str, options));
return tmpl(options);
} | javascript | function sync(str, options) {
var tmpl = this.cache(options) || this.cache(options, this.engine.compile(str, options));
return tmpl(options);
} | [
"function",
"sync",
"(",
"str",
",",
"options",
")",
"{",
"var",
"tmpl",
"=",
"this",
".",
"cache",
"(",
"options",
")",
"||",
"this",
".",
"cache",
"(",
"options",
",",
"this",
".",
"engine",
".",
"compile",
"(",
"str",
",",
"options",
")",
")",
";",
"return",
"tmpl",
"(",
"options",
")",
";",
"}"
] | Synchronous Templating Languages | [
"Synchronous",
"Templating",
"Languages"
] | c9684a78516784ed169bca12b30b8ea1f73b1e12 | https://github.com/ForbesLindesay-Unmaintained/transformers/blob/c9684a78516784ed169bca12b30b8ea1f73b1e12/lib/transformers.js#L50-L53 | train |
ForbesLindesay-Unmaintained/transformers | lib/transformers.js | function (str, options, cb) {
var ECT = this.engine;
var tmpl = this.cache(options) || this.cache(options, new ECT({ root: { page: str }}));
tmpl.render('page', options, cb);
} | javascript | function (str, options, cb) {
var ECT = this.engine;
var tmpl = this.cache(options) || this.cache(options, new ECT({ root: { page: str }}));
tmpl.render('page', options, cb);
} | [
"function",
"(",
"str",
",",
"options",
",",
"cb",
")",
"{",
"var",
"ECT",
"=",
"this",
".",
"engine",
";",
"var",
"tmpl",
"=",
"this",
".",
"cache",
"(",
"options",
")",
"||",
"this",
".",
"cache",
"(",
"options",
",",
"new",
"ECT",
"(",
"{",
"root",
":",
"{",
"page",
":",
"str",
"}",
"}",
")",
")",
";",
"tmpl",
".",
"render",
"(",
"'page'",
",",
"options",
",",
"cb",
")",
";",
"}"
] | Always runs synchronously | [
"Always",
"runs",
"synchronously"
] | c9684a78516784ed169bca12b30b8ea1f73b1e12 | https://github.com/ForbesLindesay-Unmaintained/transformers/blob/c9684a78516784ed169bca12b30b8ea1f73b1e12/lib/transformers.js#L289-L293 | train |
|
ForbesLindesay-Unmaintained/transformers | lib/transformers.js | function (str, options, cb) {
var tmpl = this.cache(options) || this.cache(options, this.engine.compile(str, options));
tmpl.eval(options, function(str){
cb(null, str);
});
} | javascript | function (str, options, cb) {
var tmpl = this.cache(options) || this.cache(options, this.engine.compile(str, options));
tmpl.eval(options, function(str){
cb(null, str);
});
} | [
"function",
"(",
"str",
",",
"options",
",",
"cb",
")",
"{",
"var",
"tmpl",
"=",
"this",
".",
"cache",
"(",
"options",
")",
"||",
"this",
".",
"cache",
"(",
"options",
",",
"this",
".",
"engine",
".",
"compile",
"(",
"str",
",",
"options",
")",
")",
";",
"tmpl",
".",
"eval",
"(",
"options",
",",
"function",
"(",
"str",
")",
"{",
"cb",
"(",
"null",
",",
"str",
")",
";",
"}",
")",
";",
"}"
] | except when an async function is passed to locals | [
"except",
"when",
"an",
"async",
"function",
"is",
"passed",
"to",
"locals"
] | c9684a78516784ed169bca12b30b8ea1f73b1e12 | https://github.com/ForbesLindesay-Unmaintained/transformers/blob/c9684a78516784ed169bca12b30b8ea1f73b1e12/lib/transformers.js#L339-L344 | train |
|
ForbesLindesay-Unmaintained/transformers | lib/transformers.js | function (str, options, cb) {
var self = this;
if (self.cache(options)) return cb(null, self.cache(options));
if (options.filename) {
options.paths = options.paths || [dirname(options.filename)];
}
// If this.cache is enabled, compress by default
if (options.compress !== true && options.compress !== false) {
options.compress = options.cache || false;
}
var initial = this.engine(str);
// Special handling for stylus js api functions
// given { define: { foo: 'bar', baz: 'quux' } }
// runs initial.define('foo', 'bar').define('baz', 'quux')
var allowed = ['set', 'include', 'import', 'define', 'use'];
var special = {}
var normal = clone(options);
for (var v in options) {
if (allowed.indexOf(v) > -1) { special[v] = options[v]; delete normal[v]; }
}
// special options through their function names
for (var k in special) {
for (var v in special[k]) { initial[k](v, special[k][v]); }
}
// normal options through set()
for (var k in normal) {
initial.set(k, normal[k]);
}
initial.render(function (err, res) {
if (err) return cb(err);
self.cache(options, res);
cb(null, res);
});
} | javascript | function (str, options, cb) {
var self = this;
if (self.cache(options)) return cb(null, self.cache(options));
if (options.filename) {
options.paths = options.paths || [dirname(options.filename)];
}
// If this.cache is enabled, compress by default
if (options.compress !== true && options.compress !== false) {
options.compress = options.cache || false;
}
var initial = this.engine(str);
// Special handling for stylus js api functions
// given { define: { foo: 'bar', baz: 'quux' } }
// runs initial.define('foo', 'bar').define('baz', 'quux')
var allowed = ['set', 'include', 'import', 'define', 'use'];
var special = {}
var normal = clone(options);
for (var v in options) {
if (allowed.indexOf(v) > -1) { special[v] = options[v]; delete normal[v]; }
}
// special options through their function names
for (var k in special) {
for (var v in special[k]) { initial[k](v, special[k][v]); }
}
// normal options through set()
for (var k in normal) {
initial.set(k, normal[k]);
}
initial.render(function (err, res) {
if (err) return cb(err);
self.cache(options, res);
cb(null, res);
});
} | [
"function",
"(",
"str",
",",
"options",
",",
"cb",
")",
"{",
"var",
"self",
"=",
"this",
";",
"if",
"(",
"self",
".",
"cache",
"(",
"options",
")",
")",
"return",
"cb",
"(",
"null",
",",
"self",
".",
"cache",
"(",
"options",
")",
")",
";",
"if",
"(",
"options",
".",
"filename",
")",
"{",
"options",
".",
"paths",
"=",
"options",
".",
"paths",
"||",
"[",
"dirname",
"(",
"options",
".",
"filename",
")",
"]",
";",
"}",
"if",
"(",
"options",
".",
"compress",
"!==",
"true",
"&&",
"options",
".",
"compress",
"!==",
"false",
")",
"{",
"options",
".",
"compress",
"=",
"options",
".",
"cache",
"||",
"false",
";",
"}",
"var",
"initial",
"=",
"this",
".",
"engine",
"(",
"str",
")",
";",
"var",
"allowed",
"=",
"[",
"'set'",
",",
"'include'",
",",
"'import'",
",",
"'define'",
",",
"'use'",
"]",
";",
"var",
"special",
"=",
"{",
"}",
"var",
"normal",
"=",
"clone",
"(",
"options",
")",
";",
"for",
"(",
"var",
"v",
"in",
"options",
")",
"{",
"if",
"(",
"allowed",
".",
"indexOf",
"(",
"v",
")",
">",
"-",
"1",
")",
"{",
"special",
"[",
"v",
"]",
"=",
"options",
"[",
"v",
"]",
";",
"delete",
"normal",
"[",
"v",
"]",
";",
"}",
"}",
"for",
"(",
"var",
"k",
"in",
"special",
")",
"{",
"for",
"(",
"var",
"v",
"in",
"special",
"[",
"k",
"]",
")",
"{",
"initial",
"[",
"k",
"]",
"(",
"v",
",",
"special",
"[",
"k",
"]",
"[",
"v",
"]",
")",
";",
"}",
"}",
"for",
"(",
"var",
"k",
"in",
"normal",
")",
"{",
"initial",
".",
"set",
"(",
"k",
",",
"normal",
"[",
"k",
"]",
")",
";",
"}",
"initial",
".",
"render",
"(",
"function",
"(",
"err",
",",
"res",
")",
"{",
"if",
"(",
"err",
")",
"return",
"cb",
"(",
"err",
")",
";",
"self",
".",
"cache",
"(",
"options",
",",
"res",
")",
";",
"cb",
"(",
"null",
",",
"res",
")",
";",
"}",
")",
";",
"}"
] | always runs synchronously | [
"always",
"runs",
"synchronously"
] | c9684a78516784ed169bca12b30b8ea1f73b1e12 | https://github.com/ForbesLindesay-Unmaintained/transformers/blob/c9684a78516784ed169bca12b30b8ea1f73b1e12/lib/transformers.js#L409-L449 | train |
|
zetapush/zetapush | packages/example/front/js/reset-password.js | askResetPassword | async function askResetPassword(form) {
await client.connect();
try {
await api.askResetPassword(
{
login: form.login.value
},
"user"
);
displayMessage(
"Reset password",
"A link was sent to reset your password",
"is-success"
);
goTo("login");
} catch (e) {
displayMessage(
"Reset password",
`Failed to send the link to reset your password. Cause: ${e.message}`,
"is-danger"
);
}
} | javascript | async function askResetPassword(form) {
await client.connect();
try {
await api.askResetPassword(
{
login: form.login.value
},
"user"
);
displayMessage(
"Reset password",
"A link was sent to reset your password",
"is-success"
);
goTo("login");
} catch (e) {
displayMessage(
"Reset password",
`Failed to send the link to reset your password. Cause: ${e.message}`,
"is-danger"
);
}
} | [
"async",
"function",
"askResetPassword",
"(",
"form",
")",
"{",
"await",
"client",
".",
"connect",
"(",
")",
";",
"try",
"{",
"await",
"api",
".",
"askResetPassword",
"(",
"{",
"login",
":",
"form",
".",
"login",
".",
"value",
"}",
",",
"\"user\"",
")",
";",
"displayMessage",
"(",
"\"Reset password\"",
",",
"\"A link was sent to reset your password\"",
",",
"\"is-success\"",
")",
";",
"goTo",
"(",
"\"login\"",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"displayMessage",
"(",
"\"Reset password\"",
",",
"`",
"${",
"e",
".",
"message",
"}",
"`",
",",
"\"is-danger\"",
")",
";",
"}",
"}"
] | Ask reset password | [
"Ask",
"reset",
"password"
] | ad3383b8e332050eaecd55be9bdff6cf76db699e | https://github.com/zetapush/zetapush/blob/ad3383b8e332050eaecd55be9bdff6cf76db699e/packages/example/front/js/reset-password.js#L4-L27 | train |
zetapush/zetapush | packages/example/front/js/reset-password.js | confirmResetPassword | async function confirmResetPassword(form) {
await client.connect();
try {
console.log("token : ", sessionStorage.getItem("token"));
await api.confirmResetPassword(
{
token: sessionStorage.getItem("token"),
firstPassword: form.firstPassword.value,
secondPassword: form.secondPassword.value
},
"user"
);
displayMessage("Reset password", "Password changed", "is-success");
goTo("login");
sessionStorage.clear();
} catch (e) {
displayMessage(
"Reset password",
`Failed to reset the password. Cause: ${e.message}`,
"is-danger"
);
}
} | javascript | async function confirmResetPassword(form) {
await client.connect();
try {
console.log("token : ", sessionStorage.getItem("token"));
await api.confirmResetPassword(
{
token: sessionStorage.getItem("token"),
firstPassword: form.firstPassword.value,
secondPassword: form.secondPassword.value
},
"user"
);
displayMessage("Reset password", "Password changed", "is-success");
goTo("login");
sessionStorage.clear();
} catch (e) {
displayMessage(
"Reset password",
`Failed to reset the password. Cause: ${e.message}`,
"is-danger"
);
}
} | [
"async",
"function",
"confirmResetPassword",
"(",
"form",
")",
"{",
"await",
"client",
".",
"connect",
"(",
")",
";",
"try",
"{",
"console",
".",
"log",
"(",
"\"token : \"",
",",
"sessionStorage",
".",
"getItem",
"(",
"\"token\"",
")",
")",
";",
"await",
"api",
".",
"confirmResetPassword",
"(",
"{",
"token",
":",
"sessionStorage",
".",
"getItem",
"(",
"\"token\"",
")",
",",
"firstPassword",
":",
"form",
".",
"firstPassword",
".",
"value",
",",
"secondPassword",
":",
"form",
".",
"secondPassword",
".",
"value",
"}",
",",
"\"user\"",
")",
";",
"displayMessage",
"(",
"\"Reset password\"",
",",
"\"Password changed\"",
",",
"\"is-success\"",
")",
";",
"goTo",
"(",
"\"login\"",
")",
";",
"sessionStorage",
".",
"clear",
"(",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"displayMessage",
"(",
"\"Reset password\"",
",",
"`",
"${",
"e",
".",
"message",
"}",
"`",
",",
"\"is-danger\"",
")",
";",
"}",
"}"
] | Confirm reset password | [
"Confirm",
"reset",
"password"
] | ad3383b8e332050eaecd55be9bdff6cf76db699e | https://github.com/zetapush/zetapush/blob/ad3383b8e332050eaecd55be9bdff6cf76db699e/packages/example/front/js/reset-password.js#L32-L54 | train |
ArnaudBuchholz/gpf-js | src/http.js | _gpfHttpSetRequestImplIf | function _gpfHttpSetRequestImplIf (host, httpRequestImpl) {
var result = _gpfHttpRequestImpl;
if (host === _gpfHost) {
_gpfHttpRequestImpl = httpRequestImpl;
}
return result;
} | javascript | function _gpfHttpSetRequestImplIf (host, httpRequestImpl) {
var result = _gpfHttpRequestImpl;
if (host === _gpfHost) {
_gpfHttpRequestImpl = httpRequestImpl;
}
return result;
} | [
"function",
"_gpfHttpSetRequestImplIf",
"(",
"host",
",",
"httpRequestImpl",
")",
"{",
"var",
"result",
"=",
"_gpfHttpRequestImpl",
";",
"if",
"(",
"host",
"===",
"_gpfHost",
")",
"{",
"_gpfHttpRequestImpl",
"=",
"httpRequestImpl",
";",
"}",
"return",
"result",
";",
"}"
] | Set the http request implementation if the host matches
@param {String} host host to test, if matching with the current one, the http request implementation is set
@param {Function} httpRequestImpl http request implementation function
@return {Function} Previous host specific implementation
@since 0.2.6 | [
"Set",
"the",
"http",
"request",
"implementation",
"if",
"the",
"host",
"matches"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/http.js#L55-L61 | train |
ArnaudBuchholz/gpf-js | src/http.js | _gpfProcessAlias | function _gpfProcessAlias (method, url, data) {
if (typeof url === "string") {
return _gpfHttpRequest({
method: method,
url: url,
data: data
});
}
return _gpfHttpRequest(Object.assign({
method: method
}, url));
} | javascript | function _gpfProcessAlias (method, url, data) {
if (typeof url === "string") {
return _gpfHttpRequest({
method: method,
url: url,
data: data
});
}
return _gpfHttpRequest(Object.assign({
method: method
}, url));
} | [
"function",
"_gpfProcessAlias",
"(",
"method",
",",
"url",
",",
"data",
")",
"{",
"if",
"(",
"typeof",
"url",
"===",
"\"string\"",
")",
"{",
"return",
"_gpfHttpRequest",
"(",
"{",
"method",
":",
"method",
",",
"url",
":",
"url",
",",
"data",
":",
"data",
"}",
")",
";",
"}",
"return",
"_gpfHttpRequest",
"(",
"Object",
".",
"assign",
"(",
"{",
"method",
":",
"method",
"}",
",",
"url",
")",
")",
";",
"}"
] | Implementation of aliases
@param {String} method HTTP method to apply
@param {String|gpf.typedef.httpRequestSettings} url Url to send the request to or a request settings object
@param {*} [data] Data to be sent to the server
@return {Promise<gpf.typedef.httpRequestResponse>} HTTP request promise
@since 0.2.1 | [
"Implementation",
"of",
"aliases"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/http.js#L85-L96 | train |
ArnaudBuchholz/gpf-js | src/serial/property.js | _gpfSerialPropertyCheck | function _gpfSerialPropertyCheck (property) {
var clonedProperty = Object.assign(property);
[
_gpfSerialPropertyCheckName,
_gpfSerialPropertyCheckType,
_gpfSerialPropertyCheckRequired,
_gpfSerialPropertyCheckReadOnly
].forEach(function (checkFunction) {
checkFunction(clonedProperty);
});
return clonedProperty;
} | javascript | function _gpfSerialPropertyCheck (property) {
var clonedProperty = Object.assign(property);
[
_gpfSerialPropertyCheckName,
_gpfSerialPropertyCheckType,
_gpfSerialPropertyCheckRequired,
_gpfSerialPropertyCheckReadOnly
].forEach(function (checkFunction) {
checkFunction(clonedProperty);
});
return clonedProperty;
} | [
"function",
"_gpfSerialPropertyCheck",
"(",
"property",
")",
"{",
"var",
"clonedProperty",
"=",
"Object",
".",
"assign",
"(",
"property",
")",
";",
"[",
"_gpfSerialPropertyCheckName",
",",
"_gpfSerialPropertyCheckType",
",",
"_gpfSerialPropertyCheckRequired",
",",
"_gpfSerialPropertyCheckReadOnly",
"]",
".",
"forEach",
"(",
"function",
"(",
"checkFunction",
")",
"{",
"checkFunction",
"(",
"clonedProperty",
")",
";",
"}",
")",
";",
"return",
"clonedProperty",
";",
"}"
] | Check that the serializable property definition is valid.
Returns a copy with defaulted properties.
@param {gpf.typedef.serializableProperty} property Property definition to validate
@return {gpf.typedef.serializableProperty} Completed property definition
@throws {gpf.Error.InvalidSerialName}
@throws {gpf.Error.InvalidSerialType}
@throws {gpf.Error.InvalidSerialRequired}
@since 0.2.8 | [
"Check",
"that",
"the",
"serializable",
"property",
"definition",
"is",
"valid",
".",
"Returns",
"a",
"copy",
"with",
"defaulted",
"properties",
"."
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/serial/property.js#L190-L201 | train |
ArnaudBuchholz/gpf-js | build/gpf-debug.js | _gpfArrayForEachFalsy | function _gpfArrayForEachFalsy(array, callback, thisArg) {
var result, index = 0, length = array.length;
for (; index < length && !result; ++index) {
result = callback.call(thisArg, array[index], index, array);
}
return result;
} | javascript | function _gpfArrayForEachFalsy(array, callback, thisArg) {
var result, index = 0, length = array.length;
for (; index < length && !result; ++index) {
result = callback.call(thisArg, array[index], index, array);
}
return result;
} | [
"function",
"_gpfArrayForEachFalsy",
"(",
"array",
",",
"callback",
",",
"thisArg",
")",
"{",
"var",
"result",
",",
"index",
"=",
"0",
",",
"length",
"=",
"array",
".",
"length",
";",
"for",
"(",
";",
"index",
"<",
"length",
"&&",
"!",
"result",
";",
"++",
"index",
")",
"{",
"result",
"=",
"callback",
".",
"call",
"(",
"thisArg",
",",
"array",
"[",
"index",
"]",
",",
"index",
",",
"array",
")",
";",
"}",
"return",
"result",
";",
"}"
] | _gpfArrayForEach that returns first truthy value computed by the callback
@param {Array} array Array-like object
@param {gpf.typedef.forEachCallback} callback Callback function executed on each array item
@param {*} [thisArg] thisArg Value to use as this when executing callback
@return {*} first truthy value returned by the callback or undefined after all items were enumerated
@since 0.2.2 | [
"_gpfArrayForEach",
"that",
"returns",
"first",
"truthy",
"value",
"computed",
"by",
"the",
"callback"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/build/gpf-debug.js#L394-L400 | train |
ArnaudBuchholz/gpf-js | build/gpf-debug.js | _gpfCompatibilityInstallMethods | function _gpfCompatibilityInstallMethods(typeName, description) {
var on = description.on;
_gpfInstallCompatibleMethods(on, description.methods);
_gpfInstallCompatibleStatics(on, description.statics);
} | javascript | function _gpfCompatibilityInstallMethods(typeName, description) {
var on = description.on;
_gpfInstallCompatibleMethods(on, description.methods);
_gpfInstallCompatibleStatics(on, description.statics);
} | [
"function",
"_gpfCompatibilityInstallMethods",
"(",
"typeName",
",",
"description",
")",
"{",
"var",
"on",
"=",
"description",
".",
"on",
";",
"_gpfInstallCompatibleMethods",
"(",
"on",
",",
"description",
".",
"methods",
")",
";",
"_gpfInstallCompatibleStatics",
"(",
"on",
",",
"description",
".",
"statics",
")",
";",
"}"
] | Define and install compatible methods on standard objects
@param {String} typeName Type name ("Object", "String"...)
@param {_GpfCompatibilityDescription} description Description of compatible methods
@since 0.1.5 | [
"Define",
"and",
"install",
"compatible",
"methods",
"on",
"standard",
"objects"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/build/gpf-debug.js#L664-L668 | train |
ArnaudBuchholz/gpf-js | build/gpf-debug.js | _gpfArrayFromString | function _gpfArrayFromString(array, string) {
var length = string.length, index = 0;
for (; index < length; ++index) {
array.push(string.charAt(index));
}
} | javascript | function _gpfArrayFromString(array, string) {
var length = string.length, index = 0;
for (; index < length; ++index) {
array.push(string.charAt(index));
}
} | [
"function",
"_gpfArrayFromString",
"(",
"array",
",",
"string",
")",
"{",
"var",
"length",
"=",
"string",
".",
"length",
",",
"index",
"=",
"0",
";",
"for",
"(",
";",
"index",
"<",
"length",
";",
"++",
"index",
")",
"{",
"array",
".",
"push",
"(",
"string",
".",
"charAt",
"(",
"index",
")",
")",
";",
"}",
"}"
] | endregion region Array.from | [
"endregion",
"region",
"Array",
".",
"from"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/build/gpf-debug.js#L716-L721 | train |
ArnaudBuchholz/gpf-js | build/gpf-debug.js | function (searchElement) {
var result = -1;
_gpfArrayEveryOwn(this, function (value, index) {
if (value === searchElement) {
result = index;
return false;
}
return true;
}, _gpfArrayGetFromIndex(arguments));
return result;
} | javascript | function (searchElement) {
var result = -1;
_gpfArrayEveryOwn(this, function (value, index) {
if (value === searchElement) {
result = index;
return false;
}
return true;
}, _gpfArrayGetFromIndex(arguments));
return result;
} | [
"function",
"(",
"searchElement",
")",
"{",
"var",
"result",
"=",
"-",
"1",
";",
"_gpfArrayEveryOwn",
"(",
"this",
",",
"function",
"(",
"value",
",",
"index",
")",
"{",
"if",
"(",
"value",
"===",
"searchElement",
")",
"{",
"result",
"=",
"index",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}",
",",
"_gpfArrayGetFromIndex",
"(",
"arguments",
")",
")",
";",
"return",
"result",
";",
"}"
] | Introduced with JavaScript 1.5 | [
"Introduced",
"with",
"JavaScript",
"1",
".",
"5"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/build/gpf-debug.js#L778-L788 | train |
|
ArnaudBuchholz/gpf-js | build/gpf-debug.js | function (callback) {
var REDUCE_INITIAL_VALUE_INDEX = 1, initialValue = arguments[REDUCE_INITIAL_VALUE_INDEX], thisLength = this.length, index = 0, value;
if (undefined === initialValue) {
value = this[index++];
} else {
value = initialValue;
}
for (; index < thisLength; ++index) {
value = callback(value, this[index], index, this);
}
return value;
} | javascript | function (callback) {
var REDUCE_INITIAL_VALUE_INDEX = 1, initialValue = arguments[REDUCE_INITIAL_VALUE_INDEX], thisLength = this.length, index = 0, value;
if (undefined === initialValue) {
value = this[index++];
} else {
value = initialValue;
}
for (; index < thisLength; ++index) {
value = callback(value, this[index], index, this);
}
return value;
} | [
"function",
"(",
"callback",
")",
"{",
"var",
"REDUCE_INITIAL_VALUE_INDEX",
"=",
"1",
",",
"initialValue",
"=",
"arguments",
"[",
"REDUCE_INITIAL_VALUE_INDEX",
"]",
",",
"thisLength",
"=",
"this",
".",
"length",
",",
"index",
"=",
"0",
",",
"value",
";",
"if",
"(",
"undefined",
"===",
"initialValue",
")",
"{",
"value",
"=",
"this",
"[",
"index",
"++",
"]",
";",
"}",
"else",
"{",
"value",
"=",
"initialValue",
";",
"}",
"for",
"(",
";",
"index",
"<",
"thisLength",
";",
"++",
"index",
")",
"{",
"value",
"=",
"callback",
"(",
"value",
",",
"this",
"[",
"index",
"]",
",",
"index",
",",
"this",
")",
";",
"}",
"return",
"value",
";",
"}"
] | Introduced with JavaScript 1.8 | [
"Introduced",
"with",
"JavaScript",
"1",
".",
"8"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/build/gpf-debug.js#L805-L816 | train |
|
ArnaudBuchholz/gpf-js | build/gpf-debug.js | _GpfDate | function _GpfDate() {
var firstArgument = arguments[_GPF_START], values = _gpfIsISO8601String(firstArgument);
if (values) {
return new _GpfGenuineDate(_GpfGenuineDate.UTC.apply(_GpfGenuineDate.UTC, values));
}
return _gpfNewApply(_GpfGenuineDate, arguments);
} | javascript | function _GpfDate() {
var firstArgument = arguments[_GPF_START], values = _gpfIsISO8601String(firstArgument);
if (values) {
return new _GpfGenuineDate(_GpfGenuineDate.UTC.apply(_GpfGenuineDate.UTC, values));
}
return _gpfNewApply(_GpfGenuineDate, arguments);
} | [
"function",
"_GpfDate",
"(",
")",
"{",
"var",
"firstArgument",
"=",
"arguments",
"[",
"_GPF_START",
"]",
",",
"values",
"=",
"_gpfIsISO8601String",
"(",
"firstArgument",
")",
";",
"if",
"(",
"values",
")",
"{",
"return",
"new",
"_GpfGenuineDate",
"(",
"_GpfGenuineDate",
".",
"UTC",
".",
"apply",
"(",
"_GpfGenuineDate",
".",
"UTC",
",",
"values",
")",
")",
";",
"}",
"return",
"_gpfNewApply",
"(",
"_GpfGenuineDate",
",",
"arguments",
")",
";",
"}"
] | Date constructor supporting ISO 8601 format
@constructor
@since 0.1.5 | [
"Date",
"constructor",
"supporting",
"ISO",
"8601",
"format"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/build/gpf-debug.js#L1100-L1106 | train |
ArnaudBuchholz/gpf-js | build/gpf-debug.js | _gpfSortOnDt | function _gpfSortOnDt(a, b) {
if (a.dt === b.dt) {
return a.id - b.id;
}
return a.dt - b.dt;
} | javascript | function _gpfSortOnDt(a, b) {
if (a.dt === b.dt) {
return a.id - b.id;
}
return a.dt - b.dt;
} | [
"function",
"_gpfSortOnDt",
"(",
"a",
",",
"b",
")",
"{",
"if",
"(",
"a",
".",
"dt",
"===",
"b",
".",
"dt",
")",
"{",
"return",
"a",
".",
"id",
"-",
"b",
".",
"id",
";",
"}",
"return",
"a",
".",
"dt",
"-",
"b",
".",
"dt",
";",
"}"
] | Sorting function used to reorder the async queue | [
"Sorting",
"function",
"used",
"to",
"reorder",
"the",
"async",
"queue"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/build/gpf-debug.js#L1368-L1373 | train |
ArnaudBuchholz/gpf-js | build/gpf-debug.js | _gpfJsonParsePolyfill | function _gpfJsonParsePolyfill(text, reviver) {
var result = _gpfFunc("return " + text)();
if (reviver) {
return _gpfJsonParseApplyReviver(result, "", reviver);
}
return result;
} | javascript | function _gpfJsonParsePolyfill(text, reviver) {
var result = _gpfFunc("return " + text)();
if (reviver) {
return _gpfJsonParseApplyReviver(result, "", reviver);
}
return result;
} | [
"function",
"_gpfJsonParsePolyfill",
"(",
"text",
",",
"reviver",
")",
"{",
"var",
"result",
"=",
"_gpfFunc",
"(",
"\"return \"",
"+",
"text",
")",
"(",
")",
";",
"if",
"(",
"reviver",
")",
"{",
"return",
"_gpfJsonParseApplyReviver",
"(",
"result",
",",
"\"\"",
",",
"reviver",
")",
";",
"}",
"return",
"result",
";",
"}"
] | JSON.parse polyfill
@param {*} text The string to parse as JSON
@param {Function} [reviver] Describes how the value originally produced by parsing is transformed,
before being returned
@return {Object} Parsed value
@since 0.1.5 | [
"JSON",
".",
"parse",
"polyfill"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/build/gpf-debug.js#L1432-L1438 | train |
ArnaudBuchholz/gpf-js | build/gpf-debug.js | _gpfDefineClassImport | function _gpfDefineClassImport(InstanceBuilder) {
var entityDefinition = _gpfDefineEntitiesFindByConstructor(InstanceBuilder);
if (entityDefinition) {
return entityDefinition;
}
return _gpfDefineClassImportFrom(InstanceBuilder, _gpfDefineClassImportGetDefinition(InstanceBuilder));
} | javascript | function _gpfDefineClassImport(InstanceBuilder) {
var entityDefinition = _gpfDefineEntitiesFindByConstructor(InstanceBuilder);
if (entityDefinition) {
return entityDefinition;
}
return _gpfDefineClassImportFrom(InstanceBuilder, _gpfDefineClassImportGetDefinition(InstanceBuilder));
} | [
"function",
"_gpfDefineClassImport",
"(",
"InstanceBuilder",
")",
"{",
"var",
"entityDefinition",
"=",
"_gpfDefineEntitiesFindByConstructor",
"(",
"InstanceBuilder",
")",
";",
"if",
"(",
"entityDefinition",
")",
"{",
"return",
"entityDefinition",
";",
"}",
"return",
"_gpfDefineClassImportFrom",
"(",
"InstanceBuilder",
",",
"_gpfDefineClassImportGetDefinition",
"(",
"InstanceBuilder",
")",
")",
";",
"}"
] | Import a class as an entity definition
@param {Function} InstanceBuilder Instance builder (must be an ES6 class)
@return {_GpfEntityDefinition} Entity definition
@since 0.2.9 | [
"Import",
"a",
"class",
"as",
"an",
"entity",
"definition"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/build/gpf-debug.js#L2497-L2503 | train |
ArnaudBuchholz/gpf-js | build/gpf-debug.js | function (name, value) {
var overriddenMember = this._extend.prototype[name];
if (undefined !== overriddenMember) {
this._checkOverridenMember(value, overriddenMember);
}
} | javascript | function (name, value) {
var overriddenMember = this._extend.prototype[name];
if (undefined !== overriddenMember) {
this._checkOverridenMember(value, overriddenMember);
}
} | [
"function",
"(",
"name",
",",
"value",
")",
"{",
"var",
"overriddenMember",
"=",
"this",
".",
"_extend",
".",
"prototype",
"[",
"name",
"]",
";",
"if",
"(",
"undefined",
"!==",
"overriddenMember",
")",
"{",
"this",
".",
"_checkOverridenMember",
"(",
"value",
",",
"overriddenMember",
")",
";",
"}",
"}"
] | Check if the member overrides an inherited one
@param {String} name Member name
@param {*} value Member value
@throws {gpf.Error.InvalidClassOverride}
@since 0.1.7 | [
"Check",
"if",
"the",
"member",
"overrides",
"an",
"inherited",
"one"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/build/gpf-debug.js#L2625-L2630 | train |
|
ArnaudBuchholz/gpf-js | build/gpf-debug.js | function (newPrototype, memberName, value) {
if (typeof value === "function") {
this._addMethodToPrototype(newPrototype, memberName, value);
} else {
newPrototype[memberName] = value;
}
} | javascript | function (newPrototype, memberName, value) {
if (typeof value === "function") {
this._addMethodToPrototype(newPrototype, memberName, value);
} else {
newPrototype[memberName] = value;
}
} | [
"function",
"(",
"newPrototype",
",",
"memberName",
",",
"value",
")",
"{",
"if",
"(",
"typeof",
"value",
"===",
"\"function\"",
")",
"{",
"this",
".",
"_addMethodToPrototype",
"(",
"newPrototype",
",",
"memberName",
",",
"value",
")",
";",
"}",
"else",
"{",
"newPrototype",
"[",
"memberName",
"]",
"=",
"value",
";",
"}",
"}"
] | Add member to the new class prototype
@param {Object} newPrototype New class prototype
@param {String} memberName Member name
@param {*} value Member value
@since 0.1.7 | [
"Add",
"member",
"to",
"the",
"new",
"class",
"prototype"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/build/gpf-debug.js#L3020-L3026 | train |
|
ArnaudBuchholz/gpf-js | build/gpf-debug.js | _gpfInterfaceIsImplementedBy | function _gpfInterfaceIsImplementedBy(interfaceSpecifier, inspectedObject) {
var result = true;
_gpfObjectForEach(interfaceSpecifier.prototype, function (referenceMethod, name) {
if (name === "constructor") {
// ignore
return;
}
if (_gpfInterfaceIsInvalidMethod(referenceMethod, inspectedObject[name])) {
result = false;
}
});
return result;
} | javascript | function _gpfInterfaceIsImplementedBy(interfaceSpecifier, inspectedObject) {
var result = true;
_gpfObjectForEach(interfaceSpecifier.prototype, function (referenceMethod, name) {
if (name === "constructor") {
// ignore
return;
}
if (_gpfInterfaceIsInvalidMethod(referenceMethod, inspectedObject[name])) {
result = false;
}
});
return result;
} | [
"function",
"_gpfInterfaceIsImplementedBy",
"(",
"interfaceSpecifier",
",",
"inspectedObject",
")",
"{",
"var",
"result",
"=",
"true",
";",
"_gpfObjectForEach",
"(",
"interfaceSpecifier",
".",
"prototype",
",",
"function",
"(",
"referenceMethod",
",",
"name",
")",
"{",
"if",
"(",
"name",
"===",
"\"constructor\"",
")",
"{",
"return",
";",
"}",
"if",
"(",
"_gpfInterfaceIsInvalidMethod",
"(",
"referenceMethod",
",",
"inspectedObject",
"[",
"name",
"]",
")",
")",
"{",
"result",
"=",
"false",
";",
"}",
"}",
")",
";",
"return",
"result",
";",
"}"
] | Verify that the object implements the specified interface
@param {Function} interfaceSpecifier Reference interface
@param {Object} inspectedObject Object (or class prototype) to inspect
@return {Boolean} True if implemented
@since 0.1.8 | [
"Verify",
"that",
"the",
"object",
"implements",
"the",
"specified",
"interface"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/build/gpf-debug.js#L3359-L3371 | train |
ArnaudBuchholz/gpf-js | build/gpf-debug.js | _gpfInterfaceQueryThroughIUnknown | function _gpfInterfaceQueryThroughIUnknown(interfaceSpecifier, queriedObject) {
var result = queriedObject.queryInterface(interfaceSpecifier);
_gpfAssert(result === null || _gpfInterfaceIsImplementedBy(interfaceSpecifier, result), "Invalid result of queryInterface (must be null or an object implementing the interface)");
return result;
} | javascript | function _gpfInterfaceQueryThroughIUnknown(interfaceSpecifier, queriedObject) {
var result = queriedObject.queryInterface(interfaceSpecifier);
_gpfAssert(result === null || _gpfInterfaceIsImplementedBy(interfaceSpecifier, result), "Invalid result of queryInterface (must be null or an object implementing the interface)");
return result;
} | [
"function",
"_gpfInterfaceQueryThroughIUnknown",
"(",
"interfaceSpecifier",
",",
"queriedObject",
")",
"{",
"var",
"result",
"=",
"queriedObject",
".",
"queryInterface",
"(",
"interfaceSpecifier",
")",
";",
"_gpfAssert",
"(",
"result",
"===",
"null",
"||",
"_gpfInterfaceIsImplementedBy",
"(",
"interfaceSpecifier",
",",
"result",
")",
",",
"\"Invalid result of queryInterface (must be null or an object implementing the interface)\"",
")",
";",
"return",
"result",
";",
"}"
] | Retrieve an object implementing the expected interface from an object using the IUnknown interface
@param {Function} interfaceSpecifier Reference interface
@param {Object} queriedObject Object to query
@return {Object|null} Object implementing the interface or null
@since 0.1.8 | [
"Retrieve",
"an",
"object",
"implementing",
"the",
"expected",
"interface",
"from",
"an",
"object",
"using",
"the",
"IUnknown",
"interface"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/build/gpf-debug.js#L3380-L3384 | train |
ArnaudBuchholz/gpf-js | build/gpf-debug.js | _gpfInterfaceQueryTryIUnknown | function _gpfInterfaceQueryTryIUnknown(interfaceSpecifier, queriedObject) {
if (_gpfInterfaceIsImplementedBy(gpf.interfaces.IUnknown, queriedObject)) {
return _gpfInterfaceQueryThroughIUnknown(interfaceSpecifier, queriedObject);
}
} | javascript | function _gpfInterfaceQueryTryIUnknown(interfaceSpecifier, queriedObject) {
if (_gpfInterfaceIsImplementedBy(gpf.interfaces.IUnknown, queriedObject)) {
return _gpfInterfaceQueryThroughIUnknown(interfaceSpecifier, queriedObject);
}
} | [
"function",
"_gpfInterfaceQueryTryIUnknown",
"(",
"interfaceSpecifier",
",",
"queriedObject",
")",
"{",
"if",
"(",
"_gpfInterfaceIsImplementedBy",
"(",
"gpf",
".",
"interfaces",
".",
"IUnknown",
",",
"queriedObject",
")",
")",
"{",
"return",
"_gpfInterfaceQueryThroughIUnknown",
"(",
"interfaceSpecifier",
",",
"queriedObject",
")",
";",
"}",
"}"
] | Retrieve an object implementing the expected interface from an object trying the IUnknown interface
@param {Function} interfaceSpecifier Reference interface
@param {Object} queriedObject Object to query
@return {Object|null|undefined} Object implementing the interface or null,
undefined is returned when IUnknown is not implemented
@since 0.1.8 | [
"Retrieve",
"an",
"object",
"implementing",
"the",
"expected",
"interface",
"from",
"an",
"object",
"trying",
"the",
"IUnknown",
"interface"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/build/gpf-debug.js#L3394-L3398 | train |
ArnaudBuchholz/gpf-js | build/gpf-debug.js | _gpfDefineInterface | function _gpfDefineInterface(name, definition) {
var interfaceDefinition = { $interface: "gpf.interfaces.I" + name };
Object.keys(definition).forEach(function (methodName) {
interfaceDefinition[methodName] = _gpfCreateAbstractFunction(definition[methodName]);
});
return _gpfDefine(interfaceDefinition);
} | javascript | function _gpfDefineInterface(name, definition) {
var interfaceDefinition = { $interface: "gpf.interfaces.I" + name };
Object.keys(definition).forEach(function (methodName) {
interfaceDefinition[methodName] = _gpfCreateAbstractFunction(definition[methodName]);
});
return _gpfDefine(interfaceDefinition);
} | [
"function",
"_gpfDefineInterface",
"(",
"name",
",",
"definition",
")",
"{",
"var",
"interfaceDefinition",
"=",
"{",
"$interface",
":",
"\"gpf.interfaces.I\"",
"+",
"name",
"}",
";",
"Object",
".",
"keys",
"(",
"definition",
")",
".",
"forEach",
"(",
"function",
"(",
"methodName",
")",
"{",
"interfaceDefinition",
"[",
"methodName",
"]",
"=",
"_gpfCreateAbstractFunction",
"(",
"definition",
"[",
"methodName",
"]",
")",
";",
"}",
")",
";",
"return",
"_gpfDefine",
"(",
"interfaceDefinition",
")",
";",
"}"
] | Internal interface definition helper
@param {String} name Interface name
@param {Object} definition Interface definition association method names to the number
of parameters
@return {Function} Interface specifier
@since 0.1.9 | [
"Internal",
"interface",
"definition",
"helper"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/build/gpf-debug.js#L3472-L3478 | train |
ArnaudBuchholz/gpf-js | build/gpf-debug.js | _gpfStreamSecureInstallProgressFlag | function _gpfStreamSecureInstallProgressFlag(constructor) {
constructor.prototype[_gpfStreamProgressRead] = false;
constructor.prototype[_gpfStreamProgressWrite] = false;
} | javascript | function _gpfStreamSecureInstallProgressFlag(constructor) {
constructor.prototype[_gpfStreamProgressRead] = false;
constructor.prototype[_gpfStreamProgressWrite] = false;
} | [
"function",
"_gpfStreamSecureInstallProgressFlag",
"(",
"constructor",
")",
"{",
"constructor",
".",
"prototype",
"[",
"_gpfStreamProgressRead",
"]",
"=",
"false",
";",
"constructor",
".",
"prototype",
"[",
"_gpfStreamProgressWrite",
"]",
"=",
"false",
";",
"}"
] | Install the progress flag used by _gpfStreamSecureRead and Write
@param {Function} constructor Class constructor
@since 0.1.9 | [
"Install",
"the",
"progress",
"flag",
"used",
"by",
"_gpfStreamSecureRead",
"and",
"Write"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/build/gpf-debug.js#L3697-L3700 | train |
ArnaudBuchholz/gpf-js | build/gpf-debug.js | _gpfFsExploreEnumerator | function _gpfFsExploreEnumerator(iFileStorage, listOfPaths) {
var pos = GPF_FS_EXPLORE_BEFORE_START, info;
return {
reset: function () {
pos = GPF_FS_EXPLORE_BEFORE_START;
return Promise.resolve();
},
moveNext: function () {
++pos;
info = undefined;
if (pos < listOfPaths.length) {
return iFileStorage.getInfo(listOfPaths[pos]).then(function (fsInfo) {
info = fsInfo;
return info;
});
}
return Promise.resolve();
},
getCurrent: function () {
return info;
}
};
} | javascript | function _gpfFsExploreEnumerator(iFileStorage, listOfPaths) {
var pos = GPF_FS_EXPLORE_BEFORE_START, info;
return {
reset: function () {
pos = GPF_FS_EXPLORE_BEFORE_START;
return Promise.resolve();
},
moveNext: function () {
++pos;
info = undefined;
if (pos < listOfPaths.length) {
return iFileStorage.getInfo(listOfPaths[pos]).then(function (fsInfo) {
info = fsInfo;
return info;
});
}
return Promise.resolve();
},
getCurrent: function () {
return info;
}
};
} | [
"function",
"_gpfFsExploreEnumerator",
"(",
"iFileStorage",
",",
"listOfPaths",
")",
"{",
"var",
"pos",
"=",
"GPF_FS_EXPLORE_BEFORE_START",
",",
"info",
";",
"return",
"{",
"reset",
":",
"function",
"(",
")",
"{",
"pos",
"=",
"GPF_FS_EXPLORE_BEFORE_START",
";",
"return",
"Promise",
".",
"resolve",
"(",
")",
";",
"}",
",",
"moveNext",
":",
"function",
"(",
")",
"{",
"++",
"pos",
";",
"info",
"=",
"undefined",
";",
"if",
"(",
"pos",
"<",
"listOfPaths",
".",
"length",
")",
"{",
"return",
"iFileStorage",
".",
"getInfo",
"(",
"listOfPaths",
"[",
"pos",
"]",
")",
".",
"then",
"(",
"function",
"(",
"fsInfo",
")",
"{",
"info",
"=",
"fsInfo",
";",
"return",
"info",
";",
"}",
")",
";",
"}",
"return",
"Promise",
".",
"resolve",
"(",
")",
";",
"}",
",",
"getCurrent",
":",
"function",
"(",
")",
"{",
"return",
"info",
";",
"}",
"}",
";",
"}"
] | Automate the use of getInfo on a path array to implement IFileStorage.explore
@param {gpf.interfaces.IFileStorage} iFileStorage File storage to get info from
@param {String[]} listOfPaths List of paths to return
@return {gpf.interfaces.IEnumerator} IEnumerator interface
@gpf:closure
@since 0.1.9 | [
"Automate",
"the",
"use",
"of",
"getInfo",
"on",
"a",
"path",
"array",
"to",
"implement",
"IFileStorage",
".",
"explore"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/build/gpf-debug.js#L4203-L4225 | train |
ArnaudBuchholz/gpf-js | build/gpf-debug.js | function (stream, close) {
this._stream = stream;
if (typeof close === "function") {
this._close = close;
}
stream.on("error", this._onError.bind(this));
} | javascript | function (stream, close) {
this._stream = stream;
if (typeof close === "function") {
this._close = close;
}
stream.on("error", this._onError.bind(this));
} | [
"function",
"(",
"stream",
",",
"close",
")",
"{",
"this",
".",
"_stream",
"=",
"stream",
";",
"if",
"(",
"typeof",
"close",
"===",
"\"function\"",
")",
"{",
"this",
".",
"_close",
"=",
"close",
";",
"}",
"stream",
".",
"on",
"(",
"\"error\"",
",",
"this",
".",
"_onError",
".",
"bind",
"(",
"this",
")",
")",
";",
"}"
] | Base class wrapping NodeJS streams
@param {Object} stream NodeJS stream object
@param {Function} [close] Close handler
@constructor gpf.node.BaseStream
@since 0.1.9 | [
"Base",
"class",
"wrapping",
"NodeJS",
"streams"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/build/gpf-debug.js#L4237-L4243 | train |
|
ArnaudBuchholz/gpf-js | build/gpf-debug.js | function (output, chunk) {
var me = this, stream = me._stream;
stream.pause();
output.write(chunk).then(function () {
stream.resume();
}, me._reject);
} | javascript | function (output, chunk) {
var me = this, stream = me._stream;
stream.pause();
output.write(chunk).then(function () {
stream.resume();
}, me._reject);
} | [
"function",
"(",
"output",
",",
"chunk",
")",
"{",
"var",
"me",
"=",
"this",
",",
"stream",
"=",
"me",
".",
"_stream",
";",
"stream",
".",
"pause",
"(",
")",
";",
"output",
".",
"write",
"(",
"chunk",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"stream",
".",
"resume",
"(",
")",
";",
"}",
",",
"me",
".",
"_reject",
")",
";",
"}"
] | endregion
Stream 'data' event handler
@param {gpf.interfaces.IWritableStream} output Output stream
@param {Object} chunk Buffer
@since 0.1.9 | [
"endregion",
"Stream",
"data",
"event",
"handler"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/build/gpf-debug.js#L4338-L4344 | train |
|
ArnaudBuchholz/gpf-js | build/gpf-debug.js | function (e) {
if (e instanceof java.util.NoSuchElementException || e.message.startsWith("java.util.NoSuchElementException")) {
// Empty stream
return Promise.resolve();
}
return Promise.reject(e);
} | javascript | function (e) {
if (e instanceof java.util.NoSuchElementException || e.message.startsWith("java.util.NoSuchElementException")) {
// Empty stream
return Promise.resolve();
}
return Promise.reject(e);
} | [
"function",
"(",
"e",
")",
"{",
"if",
"(",
"e",
"instanceof",
"java",
".",
"util",
".",
"NoSuchElementException",
"||",
"e",
".",
"message",
".",
"startsWith",
"(",
"\"java.util.NoSuchElementException\"",
")",
")",
"{",
"return",
"Promise",
".",
"resolve",
"(",
")",
";",
"}",
"return",
"Promise",
".",
"reject",
"(",
"e",
")",
";",
"}"
] | region gpf.interfaces.IReadableStream
Process error that occurred during the stream reading
@param {Error} e Error coming from read
@return {Promise} Read result replacement
@since 0.2.4 | [
"region",
"gpf",
".",
"interfaces",
".",
"IReadableStream",
"Process",
"error",
"that",
"occurred",
"during",
"the",
"stream",
"reading"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/build/gpf-debug.js#L5471-L5477 | train |
|
ArnaudBuchholz/gpf-js | build/gpf-debug.js | function () {
var me = this;
if (me._readNotWriting) {
me._readNotWriting = false;
me._readWriteToOutput().then(undefined, function (reason) {
me._readReject(reason);
});
}
} | javascript | function () {
var me = this;
if (me._readNotWriting) {
me._readNotWriting = false;
me._readWriteToOutput().then(undefined, function (reason) {
me._readReject(reason);
});
}
} | [
"function",
"(",
")",
"{",
"var",
"me",
"=",
"this",
";",
"if",
"(",
"me",
".",
"_readNotWriting",
")",
"{",
"me",
".",
"_readNotWriting",
"=",
"false",
";",
"me",
".",
"_readWriteToOutput",
"(",
")",
".",
"then",
"(",
"undefined",
",",
"function",
"(",
"reason",
")",
"{",
"me",
".",
"_readReject",
"(",
"reason",
")",
";",
"}",
")",
";",
"}",
"}"
] | Triggers write only if no write is in progress
@since 0.2.3 | [
"Triggers",
"write",
"only",
"if",
"no",
"write",
"is",
"in",
"progress"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/build/gpf-debug.js#L5802-L5810 | train |
|
ArnaudBuchholz/gpf-js | build/gpf-debug.js | function () {
var me = this, lines = me._consolidateLines();
me._buffer.length = 0;
me._pushBackLastLineIfNotEmpty(lines);
_gpfArrayForEach(lines, function (line) {
me._appendToReadBuffer(line);
});
} | javascript | function () {
var me = this, lines = me._consolidateLines();
me._buffer.length = 0;
me._pushBackLastLineIfNotEmpty(lines);
_gpfArrayForEach(lines, function (line) {
me._appendToReadBuffer(line);
});
} | [
"function",
"(",
")",
"{",
"var",
"me",
"=",
"this",
",",
"lines",
"=",
"me",
".",
"_consolidateLines",
"(",
")",
";",
"me",
".",
"_buffer",
".",
"length",
"=",
"0",
";",
"me",
".",
"_pushBackLastLineIfNotEmpty",
"(",
"lines",
")",
";",
"_gpfArrayForEach",
"(",
"lines",
",",
"function",
"(",
"line",
")",
"{",
"me",
".",
"_appendToReadBuffer",
"(",
"line",
")",
";",
"}",
")",
";",
"}"
] | Check if the buffer contains any carriage return and write to output
@since 0.2.1 | [
"Check",
"if",
"the",
"buffer",
"contains",
"any",
"carriage",
"return",
"and",
"write",
"to",
"output"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/build/gpf-debug.js#L5960-L5967 | train |
|
ArnaudBuchholz/gpf-js | build/gpf-debug.js | _gpfRequireWrapGpf | function _gpfRequireWrapGpf(context, name) {
return _gpfRequirePlugWrapper(_gpfRequireAllocateWrapper(), _gpfRequireAllocate(context, { base: _gpfPathParent(name) }));
} | javascript | function _gpfRequireWrapGpf(context, name) {
return _gpfRequirePlugWrapper(_gpfRequireAllocateWrapper(), _gpfRequireAllocate(context, { base: _gpfPathParent(name) }));
} | [
"function",
"_gpfRequireWrapGpf",
"(",
"context",
",",
"name",
")",
"{",
"return",
"_gpfRequirePlugWrapper",
"(",
"_gpfRequireAllocateWrapper",
"(",
")",
",",
"_gpfRequireAllocate",
"(",
"context",
",",
"{",
"base",
":",
"_gpfPathParent",
"(",
"name",
")",
"}",
")",
")",
";",
"}"
] | Wrap gpf to fit the new context and give access to gpf.require.define promise
@param {Object} context Require context
@param {String} name Resource (resolved) name
@return {gpf.typedef._requireWrapper} Wrapper
@since 0.2.2 | [
"Wrap",
"gpf",
"to",
"fit",
"the",
"new",
"context",
"and",
"give",
"access",
"to",
"gpf",
".",
"require",
".",
"define",
"promise"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/build/gpf-debug.js#L6135-L6137 | train |
ArnaudBuchholz/gpf-js | build/gpf-debug.js | _gpfRequireGet | function _gpfRequireGet(name) {
var me = this, promise;
if (me.cache[name]) {
return me.cache[name];
}
promise = _gpfRequireLoad.call(me, name);
me.cache[name] = promise;
return promise["catch"](function (reason) {
_gpfRequireDocumentStack(reason, name);
return Promise.reject(reason);
});
} | javascript | function _gpfRequireGet(name) {
var me = this, promise;
if (me.cache[name]) {
return me.cache[name];
}
promise = _gpfRequireLoad.call(me, name);
me.cache[name] = promise;
return promise["catch"](function (reason) {
_gpfRequireDocumentStack(reason, name);
return Promise.reject(reason);
});
} | [
"function",
"_gpfRequireGet",
"(",
"name",
")",
"{",
"var",
"me",
"=",
"this",
",",
"promise",
";",
"if",
"(",
"me",
".",
"cache",
"[",
"name",
"]",
")",
"{",
"return",
"me",
".",
"cache",
"[",
"name",
"]",
";",
"}",
"promise",
"=",
"_gpfRequireLoad",
".",
"call",
"(",
"me",
",",
"name",
")",
";",
"me",
".",
"cache",
"[",
"name",
"]",
"=",
"promise",
";",
"return",
"promise",
"[",
"\"catch\"",
"]",
"(",
"function",
"(",
"reason",
")",
"{",
"_gpfRequireDocumentStack",
"(",
"reason",
",",
"name",
")",
";",
"return",
"Promise",
".",
"reject",
"(",
"reason",
")",
";",
"}",
")",
";",
"}"
] | Get the cached resource or load it
@param {String} name Resource name
@return {Promise<*>} Resource association
@since 0.2.2 | [
"Get",
"the",
"cached",
"resource",
"or",
"load",
"it"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/build/gpf-debug.js#L6441-L6452 | train |
ArnaudBuchholz/gpf-js | build/gpf-debug.js | _gpfRequireAllocate | function _gpfRequireAllocate(parentContext, options) {
var context = Object.create(parentContext),
// cache content is shared but other properties are protected
require = {};
require.define = _gpfRequireDefine.bind(context);
require.resolve = _gpfRequireResolve.bind(context);
require.configure = _gpfRequireConfigure.bind(context);
if (options) {
require.configure(options);
}
return require;
} | javascript | function _gpfRequireAllocate(parentContext, options) {
var context = Object.create(parentContext),
// cache content is shared but other properties are protected
require = {};
require.define = _gpfRequireDefine.bind(context);
require.resolve = _gpfRequireResolve.bind(context);
require.configure = _gpfRequireConfigure.bind(context);
if (options) {
require.configure(options);
}
return require;
} | [
"function",
"_gpfRequireAllocate",
"(",
"parentContext",
",",
"options",
")",
"{",
"var",
"context",
"=",
"Object",
".",
"create",
"(",
"parentContext",
")",
",",
"require",
"=",
"{",
"}",
";",
"require",
".",
"define",
"=",
"_gpfRequireDefine",
".",
"bind",
"(",
"context",
")",
";",
"require",
".",
"resolve",
"=",
"_gpfRequireResolve",
".",
"bind",
"(",
"context",
")",
";",
"require",
".",
"configure",
"=",
"_gpfRequireConfigure",
".",
"bind",
"(",
"context",
")",
";",
"if",
"(",
"options",
")",
"{",
"require",
".",
"configure",
"(",
"options",
")",
";",
"}",
"return",
"require",
";",
"}"
] | Allocate a new require context with the proper methods
@param {Object} parentContext Context to inherit from
@param {gpf.typedef.requireOptions} [options] Options to configure
@return {Object} Containing {@link gpf.require.define}, {@link gpf.require.resolve} and {@link gpf.require.configure}
@since 0.2.2 | [
"Allocate",
"a",
"new",
"require",
"context",
"with",
"the",
"proper",
"methods"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/build/gpf-debug.js#L6495-L6506 | train |
ArnaudBuchholz/gpf-js | build/gpf-debug.js | function (parserOptions) {
var me = this;
if (parserOptions) {
_gpfArrayForEach([
"header",
"separator",
"quote",
"newLine"
], function (optionName) {
if (parserOptions[optionName]) {
me["_" + optionName] = parserOptions[optionName];
}
});
}
} | javascript | function (parserOptions) {
var me = this;
if (parserOptions) {
_gpfArrayForEach([
"header",
"separator",
"quote",
"newLine"
], function (optionName) {
if (parserOptions[optionName]) {
me["_" + optionName] = parserOptions[optionName];
}
});
}
} | [
"function",
"(",
"parserOptions",
")",
"{",
"var",
"me",
"=",
"this",
";",
"if",
"(",
"parserOptions",
")",
"{",
"_gpfArrayForEach",
"(",
"[",
"\"header\"",
",",
"\"separator\"",
",",
"\"quote\"",
",",
"\"newLine\"",
"]",
",",
"function",
"(",
"optionName",
")",
"{",
"if",
"(",
"parserOptions",
"[",
"optionName",
"]",
")",
"{",
"me",
"[",
"\"_\"",
"+",
"optionName",
"]",
"=",
"parserOptions",
"[",
"optionName",
"]",
";",
"}",
"}",
")",
";",
"}",
"}"
] | region Parser options
Read parser options
@param {gpf.typedef.csvParserOptions} [parserOptions] Parser options
@since 0.2.3 | [
"region",
"Parser",
"options",
"Read",
"parser",
"options"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/build/gpf-debug.js#L6795-L6809 | train |
|
ArnaudBuchholz/gpf-js | build/gpf-debug.js | function () {
var header = this._header;
this._separator = _gpfArrayForEachFalsy(_gpfCsvSeparators, function (separator) {
if (header.includes(separator)) {
return separator;
}
}) || _gpfCsvSeparators[_GPF_START];
} | javascript | function () {
var header = this._header;
this._separator = _gpfArrayForEachFalsy(_gpfCsvSeparators, function (separator) {
if (header.includes(separator)) {
return separator;
}
}) || _gpfCsvSeparators[_GPF_START];
} | [
"function",
"(",
")",
"{",
"var",
"header",
"=",
"this",
".",
"_header",
";",
"this",
".",
"_separator",
"=",
"_gpfArrayForEachFalsy",
"(",
"_gpfCsvSeparators",
",",
"function",
"(",
"separator",
")",
"{",
"if",
"(",
"header",
".",
"includes",
"(",
"separator",
")",
")",
"{",
"return",
"separator",
";",
"}",
"}",
")",
"||",
"_gpfCsvSeparators",
"[",
"_GPF_START",
"]",
";",
"}"
] | Deduce separator from header line
@since 0.2.3 | [
"Deduce",
"separator",
"from",
"header",
"line"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/build/gpf-debug.js#L6828-L6835 | train |
|
ArnaudBuchholz/gpf-js | build/gpf-debug.js | function (match) {
var UNQUOTED = 1, QUOTED = 2;
if (match[UNQUOTED]) {
this._values.push(match[UNQUOTED]);
} else
/* if (match[QUOTED]) */
{
this._values.push(this._unescapeQuoted(match[QUOTED]));
}
} | javascript | function (match) {
var UNQUOTED = 1, QUOTED = 2;
if (match[UNQUOTED]) {
this._values.push(match[UNQUOTED]);
} else
/* if (match[QUOTED]) */
{
this._values.push(this._unescapeQuoted(match[QUOTED]));
}
} | [
"function",
"(",
"match",
")",
"{",
"var",
"UNQUOTED",
"=",
"1",
",",
"QUOTED",
"=",
"2",
";",
"if",
"(",
"match",
"[",
"UNQUOTED",
"]",
")",
"{",
"this",
".",
"_values",
".",
"push",
"(",
"match",
"[",
"UNQUOTED",
"]",
")",
";",
"}",
"else",
"{",
"this",
".",
"_values",
".",
"push",
"(",
"this",
".",
"_unescapeQuoted",
"(",
"match",
"[",
"QUOTED",
"]",
")",
")",
";",
"}",
"}"
] | Add the matching value to the array of values
@param {Object} match Regular expression match
@since 0.2.3 | [
"Add",
"the",
"matching",
"value",
"to",
"the",
"array",
"of",
"values"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/build/gpf-debug.js#L6915-L6924 | train |
|
ArnaudBuchholz/gpf-js | build/gpf-debug.js | function (match) {
var lengthOfMatchedString = match[_GPF_START].length, charAfterValue = this._content.charAt(lengthOfMatchedString);
if (charAfterValue) {
_gpfAssert(charAfterValue === this._separator, "Positive lookahead works");
return this._nextValue(++lengthOfMatchedString);
}
delete this._content;
return false; // No value means end of content
} | javascript | function (match) {
var lengthOfMatchedString = match[_GPF_START].length, charAfterValue = this._content.charAt(lengthOfMatchedString);
if (charAfterValue) {
_gpfAssert(charAfterValue === this._separator, "Positive lookahead works");
return this._nextValue(++lengthOfMatchedString);
}
delete this._content;
return false; // No value means end of content
} | [
"function",
"(",
"match",
")",
"{",
"var",
"lengthOfMatchedString",
"=",
"match",
"[",
"_GPF_START",
"]",
".",
"length",
",",
"charAfterValue",
"=",
"this",
".",
"_content",
".",
"charAt",
"(",
"lengthOfMatchedString",
")",
";",
"if",
"(",
"charAfterValue",
")",
"{",
"_gpfAssert",
"(",
"charAfterValue",
"===",
"this",
".",
"_separator",
",",
"\"Positive lookahead works\"",
")",
";",
"return",
"this",
".",
"_nextValue",
"(",
"++",
"lengthOfMatchedString",
")",
";",
"}",
"delete",
"this",
".",
"_content",
";",
"return",
"false",
";",
"}"
] | Check what appears after the extracted value
@param {Object} match Regular expression match
@return {Boolean} True if some remaining content must be parsed
@since 0.2.3 | [
"Check",
"what",
"appears",
"after",
"the",
"extracted",
"value"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/build/gpf-debug.js#L6943-L6951 | train |
|
ArnaudBuchholz/gpf-js | build/gpf-debug.js | function (line) {
if (this._content) {
this._content = this._content + this._newLine + line;
} else {
this._values = [];
this._content = line;
}
return this._parseContent();
} | javascript | function (line) {
if (this._content) {
this._content = this._content + this._newLine + line;
} else {
this._values = [];
this._content = line;
}
return this._parseContent();
} | [
"function",
"(",
"line",
")",
"{",
"if",
"(",
"this",
".",
"_content",
")",
"{",
"this",
".",
"_content",
"=",
"this",
".",
"_content",
"+",
"this",
".",
"_newLine",
"+",
"line",
";",
"}",
"else",
"{",
"this",
".",
"_values",
"=",
"[",
"]",
";",
"this",
".",
"_content",
"=",
"line",
";",
"}",
"return",
"this",
".",
"_parseContent",
"(",
")",
";",
"}"
] | If some content remains from previous parsing, concatenate it and parse
@param {String} line CSV line
@return {String[]|undefined} Resulting values or undefined if not yet finalized
@since 0.2.3 | [
"If",
"some",
"content",
"remains",
"from",
"previous",
"parsing",
"concatenate",
"it",
"and",
"parse"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/build/gpf-debug.js#L7010-L7018 | train |
|
ArnaudBuchholz/gpf-js | build/gpf-debug.js | function (values) {
var record = {};
_gpfArrayForEach(this._columns, function (name, idx) {
var value = values[idx];
if (value !== undefined) {
record[name] = values[idx];
}
});
return record;
} | javascript | function (values) {
var record = {};
_gpfArrayForEach(this._columns, function (name, idx) {
var value = values[idx];
if (value !== undefined) {
record[name] = values[idx];
}
});
return record;
} | [
"function",
"(",
"values",
")",
"{",
"var",
"record",
"=",
"{",
"}",
";",
"_gpfArrayForEach",
"(",
"this",
".",
"_columns",
",",
"function",
"(",
"name",
",",
"idx",
")",
"{",
"var",
"value",
"=",
"values",
"[",
"idx",
"]",
";",
"if",
"(",
"value",
"!==",
"undefined",
")",
"{",
"record",
"[",
"name",
"]",
"=",
"values",
"[",
"idx",
"]",
";",
"}",
"}",
")",
";",
"return",
"record",
";",
"}"
] | Generate a record from values
@param {String[]} values Array of values
@return {Object} Record based on header names
@since 0.2.3 | [
"Generate",
"a",
"record",
"from",
"values"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/build/gpf-debug.js#L7026-L7035 | train |
|
ArnaudBuchholz/gpf-js | build/gpf-debug.js | function () {
if (this._content) {
var error = new gpf.Error.InvalidCSV();
this._setReadError(error);
return Promise.reject(error);
}
this._completeReadBuffer();
return Promise.resolve();
} | javascript | function () {
if (this._content) {
var error = new gpf.Error.InvalidCSV();
this._setReadError(error);
return Promise.reject(error);
}
this._completeReadBuffer();
return Promise.resolve();
} | [
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"_content",
")",
"{",
"var",
"error",
"=",
"new",
"gpf",
".",
"Error",
".",
"InvalidCSV",
"(",
")",
";",
"this",
".",
"_setReadError",
"(",
"error",
")",
";",
"return",
"Promise",
".",
"reject",
"(",
"error",
")",
";",
"}",
"this",
".",
"_completeReadBuffer",
"(",
")",
";",
"return",
"Promise",
".",
"resolve",
"(",
")",
";",
"}"
] | endregion region gpf.interfaces.IFlushableStream
@gpf:sameas gpf.interfaces.IFlushableStream#flush
@since 0.2.3 | [
"endregion",
"region",
"gpf",
".",
"interfaces",
".",
"IFlushableStream"
] | 0888295c99a1ff285ead60273cc7ef656e7fd812 | https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/build/gpf-debug.js#L7066-L7074 | train |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.