repo stringlengths 5 67 | path stringlengths 4 116 | func_name stringlengths 0 58 | original_string stringlengths 52 373k | language stringclasses 1
value | code stringlengths 52 373k | code_tokens list | docstring stringlengths 4 11.8k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 86 226 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
jldec/pub-src-redis | pub-src-redis.js | clear | function clear(options, cb) {
if (typeof options === 'function') { cb = options; options = {}; }
debug('clear ' + key);
connect();
redis.del(key, cb);
} | javascript | function clear(options, cb) {
if (typeof options === 'function') { cb = options; options = {}; }
debug('clear ' + key);
connect();
redis.del(key, cb);
} | [
"function",
"clear",
"(",
"options",
",",
"cb",
")",
"{",
"if",
"(",
"typeof",
"options",
"===",
"'function'",
")",
"{",
"cb",
"=",
"options",
";",
"options",
"=",
"{",
"}",
";",
"}",
"debug",
"(",
"'clear '",
"+",
"key",
")",
";",
"connect",
"(",
... | redis-specific api - used for testing | [
"redis",
"-",
"specific",
"api",
"-",
"used",
"for",
"testing"
] | d18e13fde82ff969571f59790e15098a5edbd89e | https://github.com/jldec/pub-src-redis/blob/d18e13fde82ff969571f59790e15098a5edbd89e/pub-src-redis.js#L165-L170 | train |
iamjamilspain/titanium-jsduck | titanium-jsduck.js | runHelp | function runHelp(){
var messageHelp = "Usage: titanium-jsduck [command] [parameters]\n\n";
messageHelp += "Commands:\n\tinstall \n\t\t- Installs JSDuck inside a Titanium Mobile Project.";
messageHelp += "\n\topen \n\t\t- Opens Documentation in Safari Browser";
messageHelp += "\n\topen firefox \n\t\t- Opens ... | javascript | function runHelp(){
var messageHelp = "Usage: titanium-jsduck [command] [parameters]\n\n";
messageHelp += "Commands:\n\tinstall \n\t\t- Installs JSDuck inside a Titanium Mobile Project.";
messageHelp += "\n\topen \n\t\t- Opens Documentation in Safari Browser";
messageHelp += "\n\topen firefox \n\t\t- Opens ... | [
"function",
"runHelp",
"(",
")",
"{",
"var",
"messageHelp",
"=",
"\"Usage: titanium-jsduck [command] [parameters]\\n\\n\"",
";",
"messageHelp",
"+=",
"\"Commands:\\n\\tinstall \\n\\t\\t- Installs JSDuck inside a Titanium Mobile Project.\"",
";",
"messageHelp",
"+=",
"\"\\n\\topen \\n... | Main Command Methods | [
"Main",
"Command",
"Methods"
] | f79ffa1c6386c16dfb59710d9a6a94cfc66439f6 | https://github.com/iamjamilspain/titanium-jsduck/blob/f79ffa1c6386c16dfb59710d9a6a94cfc66439f6/titanium-jsduck.js#L151-L164 | train |
tolokoban/ToloFrameWork | lib/pathutils.js | file | function file( path, content ) {
try {
if ( typeof content === 'undefined' ) {
if ( !FS.existsSync( path ) ) return null;
return FS.readFileSync( path );
}
const dir = Path.dirname( path );
mkdir( dir );
FS.writeFileSync( path, content );
retur... | javascript | function file( path, content ) {
try {
if ( typeof content === 'undefined' ) {
if ( !FS.existsSync( path ) ) return null;
return FS.readFileSync( path );
}
const dir = Path.dirname( path );
mkdir( dir );
FS.writeFileSync( path, content );
retur... | [
"function",
"file",
"(",
"path",
",",
"content",
")",
"{",
"try",
"{",
"if",
"(",
"typeof",
"content",
"===",
"'undefined'",
")",
"{",
"if",
"(",
"!",
"FS",
".",
"existsSync",
"(",
"path",
")",
")",
"return",
"null",
";",
"return",
"FS",
".",
"read... | Read or write the content of a file.
If `content` is undefined, the content is read, otherwise it is
written.
If the file to be written is in a non-existent subfolder, the whole
path will be created with the `mkdir`function.
@param {string} path - Path of the file to read or write.
@param {string} content -... | [
"Read",
"or",
"write",
"the",
"content",
"of",
"a",
"file",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/lib/pathutils.js#L168-L182 | train |
tolokoban/ToloFrameWork | lib/pathutils.js | touch | function touch( path ) {
if ( FS.existsSync( path ) ) {
const content = FS.readFileSync( path );
FS.writeFileSync( path, content );
console.log( `File has been touched: ${path.yellow} (${(size(path) * BYTES_TO_KB).toFixed(1)} kb)` );
return true;
}
return false;
} | javascript | function touch( path ) {
if ( FS.existsSync( path ) ) {
const content = FS.readFileSync( path );
FS.writeFileSync( path, content );
console.log( `File has been touched: ${path.yellow} (${(size(path) * BYTES_TO_KB).toFixed(1)} kb)` );
return true;
}
return false;
} | [
"function",
"touch",
"(",
"path",
")",
"{",
"if",
"(",
"FS",
".",
"existsSync",
"(",
"path",
")",
")",
"{",
"const",
"content",
"=",
"FS",
".",
"readFileSync",
"(",
"path",
")",
";",
"FS",
".",
"writeFileSync",
"(",
"path",
",",
"content",
")",
";"... | Set current date as modification time to a file.
@param {string} path - Path of the file to touch.
@returns {boolean} `true` is the file exists. | [
"Set",
"current",
"date",
"as",
"modification",
"time",
"to",
"a",
"file",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/lib/pathutils.js#L207-L215 | train |
RealGeeks/mallet | index.js | invokeArrayArg | function invokeArrayArg(arg, fn, context) {
if (Array.isArray(arg)) {
arg.forEach(context[fn], context);
return true;
}
return false;
} | javascript | function invokeArrayArg(arg, fn, context) {
if (Array.isArray(arg)) {
arg.forEach(context[fn], context);
return true;
}
return false;
} | [
"function",
"invokeArrayArg",
"(",
"arg",
",",
"fn",
",",
"context",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"arg",
")",
")",
"{",
"arg",
".",
"forEach",
"(",
"context",
"[",
"fn",
"]",
",",
"context",
")",
";",
"return",
"true",
";",
... | if the argument is an array, we want to execute the fn on each entry
if it aint an array we don't want to do a thing.
this is used by all the methods that accept a single and array argument.
@param {*|Array} arg
@param {String} fn
@param {Object} [context]
@returns {Boolean} | [
"if",
"the",
"argument",
"is",
"an",
"array",
"we",
"want",
"to",
"execute",
"the",
"fn",
"on",
"each",
"entry",
"if",
"it",
"aint",
"an",
"array",
"we",
"don",
"t",
"want",
"to",
"do",
"a",
"thing",
".",
"this",
"is",
"used",
"by",
"all",
"the",
... | 12b8a1b0ab014386c1d0e7980a51afc2089ccdd4 | https://github.com/RealGeeks/mallet/blob/12b8a1b0ab014386c1d0e7980a51afc2089ccdd4/index.js#L40-L46 | train |
RealGeeks/mallet | index.js | prefixed | function prefixed(obj, property) {
var prefix;
var prop;
var camelProp = property[0].toUpperCase() + property.slice(1);
var i = 0;
while (i < VENDOR_PREFIXES.length) {
prefix = VENDOR_PREFIXES[i];
prop = (prefix) ? prefix + camelProp : property;
if (prop in obj) {
return prop;
}
i+... | javascript | function prefixed(obj, property) {
var prefix;
var prop;
var camelProp = property[0].toUpperCase() + property.slice(1);
var i = 0;
while (i < VENDOR_PREFIXES.length) {
prefix = VENDOR_PREFIXES[i];
prop = (prefix) ? prefix + camelProp : property;
if (prop in obj) {
return prop;
}
i+... | [
"function",
"prefixed",
"(",
"obj",
",",
"property",
")",
"{",
"var",
"prefix",
";",
"var",
"prop",
";",
"var",
"camelProp",
"=",
"property",
"[",
"0",
"]",
".",
"toUpperCase",
"(",
")",
"+",
"property",
".",
"slice",
"(",
"1",
")",
";",
"var",
"i"... | get the prefixed property
@param {Object} obj
@param {String} property
@returns {String|Undefined} prefixed | [
"get",
"the",
"prefixed",
"property"
] | 12b8a1b0ab014386c1d0e7980a51afc2089ccdd4 | https://github.com/RealGeeks/mallet/blob/12b8a1b0ab014386c1d0e7980a51afc2089ccdd4/index.js#L191-L207 | train |
RealGeeks/mallet | index.js | computeInputData | function computeInputData(manager, input) {
var session = manager.session;
var pointers = input.pointers;
var pointersLength = pointers.length;
// store the first input to calculate the distance and direction
if (!session.firstInput) {
session.firstInput = simpleCloneInputData(input);
}
// to comput... | javascript | function computeInputData(manager, input) {
var session = manager.session;
var pointers = input.pointers;
var pointersLength = pointers.length;
// store the first input to calculate the distance and direction
if (!session.firstInput) {
session.firstInput = simpleCloneInputData(input);
}
// to comput... | [
"function",
"computeInputData",
"(",
"manager",
",",
"input",
")",
"{",
"var",
"session",
"=",
"manager",
".",
"session",
";",
"var",
"pointers",
"=",
"input",
".",
"pointers",
";",
"var",
"pointersLength",
"=",
"pointers",
".",
"length",
";",
"// store the ... | extend the data with some usable properties like scale, rotate, velocity etc
@param {Object} manager
@param {Object} input | [
"extend",
"the",
"data",
"with",
"some",
"usable",
"properties",
"like",
"scale",
"rotate",
"velocity",
"etc"
] | 12b8a1b0ab014386c1d0e7980a51afc2089ccdd4 | https://github.com/RealGeeks/mallet/blob/12b8a1b0ab014386c1d0e7980a51afc2089ccdd4/index.js#L363-L405 | train |
RealGeeks/mallet | index.js | getDirection | function getDirection(x, y) {
if (x === y) {
return DIRECTION_NONE;
}
if (abs(x) >= abs(y)) {
return x > 0 ? DIRECTION_LEFT : DIRECTION_RIGHT;
}
return y > 0 ? DIRECTION_UP : DIRECTION_DOWN;
} | javascript | function getDirection(x, y) {
if (x === y) {
return DIRECTION_NONE;
}
if (abs(x) >= abs(y)) {
return x > 0 ? DIRECTION_LEFT : DIRECTION_RIGHT;
}
return y > 0 ? DIRECTION_UP : DIRECTION_DOWN;
} | [
"function",
"getDirection",
"(",
"x",
",",
"y",
")",
"{",
"if",
"(",
"x",
"===",
"y",
")",
"{",
"return",
"DIRECTION_NONE",
";",
"}",
"if",
"(",
"abs",
"(",
"x",
")",
">=",
"abs",
"(",
"y",
")",
")",
"{",
"return",
"x",
">",
"0",
"?",
"DIRECT... | get the direction between two points
@param {Number} x
@param {Number} y
@return {Number} direction | [
"get",
"the",
"direction",
"between",
"two",
"points"
] | 12b8a1b0ab014386c1d0e7980a51afc2089ccdd4 | https://github.com/RealGeeks/mallet/blob/12b8a1b0ab014386c1d0e7980a51afc2089ccdd4/index.js#L545-L554 | train |
RealGeeks/mallet | index.js | getDistance | function getDistance(p1, p2, props) {
if (!props) {
props = PROPS_XY;
}
var x = p2[props[0]] - p1[props[0]];
var y = p2[props[1]] - p1[props[1]];
return Math.sqrt((x * x) + (y * y));
} | javascript | function getDistance(p1, p2, props) {
if (!props) {
props = PROPS_XY;
}
var x = p2[props[0]] - p1[props[0]];
var y = p2[props[1]] - p1[props[1]];
return Math.sqrt((x * x) + (y * y));
} | [
"function",
"getDistance",
"(",
"p1",
",",
"p2",
",",
"props",
")",
"{",
"if",
"(",
"!",
"props",
")",
"{",
"props",
"=",
"PROPS_XY",
";",
"}",
"var",
"x",
"=",
"p2",
"[",
"props",
"[",
"0",
"]",
"]",
"-",
"p1",
"[",
"props",
"[",
"0",
"]",
... | calculate the absolute distance between two points
@param {Object} p1 {x, y}
@param {Object} p2 {x, y}
@param {Array} [props] containing x and y keys
@return {Number} distance | [
"calculate",
"the",
"absolute",
"distance",
"between",
"two",
"points"
] | 12b8a1b0ab014386c1d0e7980a51afc2089ccdd4 | https://github.com/RealGeeks/mallet/blob/12b8a1b0ab014386c1d0e7980a51afc2089ccdd4/index.js#L563-L571 | train |
RealGeeks/mallet | index.js | getRotation | function getRotation(start, end) {
return getAngle(end[1], end[0], PROPS_CLIENT_XY) - getAngle(start[1], start[0], PROPS_CLIENT_XY);
} | javascript | function getRotation(start, end) {
return getAngle(end[1], end[0], PROPS_CLIENT_XY) - getAngle(start[1], start[0], PROPS_CLIENT_XY);
} | [
"function",
"getRotation",
"(",
"start",
",",
"end",
")",
"{",
"return",
"getAngle",
"(",
"end",
"[",
"1",
"]",
",",
"end",
"[",
"0",
"]",
",",
"PROPS_CLIENT_XY",
")",
"-",
"getAngle",
"(",
"start",
"[",
"1",
"]",
",",
"start",
"[",
"0",
"]",
","... | calculate the rotation degrees between two pointersets
@param {Array} start array of pointers
@param {Array} end array of pointers
@return {Number} rotation | [
"calculate",
"the",
"rotation",
"degrees",
"between",
"two",
"pointersets"
] | 12b8a1b0ab014386c1d0e7980a51afc2089ccdd4 | https://github.com/RealGeeks/mallet/blob/12b8a1b0ab014386c1d0e7980a51afc2089ccdd4/index.js#L595-L597 | train |
RealGeeks/mallet | index.js | TouchMouseInput | function TouchMouseInput() {
Input.apply(this, arguments);
var handler = this.handler.bind(this);
this.touch = new TouchInput(this.manager, handler);
this.mouse = new MouseInput(this.manager, handler);
} | javascript | function TouchMouseInput() {
Input.apply(this, arguments);
var handler = this.handler.bind(this);
this.touch = new TouchInput(this.manager, handler);
this.mouse = new MouseInput(this.manager, handler);
} | [
"function",
"TouchMouseInput",
"(",
")",
"{",
"Input",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"var",
"handler",
"=",
"this",
".",
"handler",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"touch",
"=",
"new",
"TouchInput",
"(",
"thi... | Combined touch and mouse input
Touch has a higher priority then mouse, and while touching no mouse events are allowed.
This because touch devices also emit mouse events while doing a touch.
@constructor
@extends Input | [
"Combined",
"touch",
"and",
"mouse",
"input"
] | 12b8a1b0ab014386c1d0e7980a51afc2089ccdd4 | https://github.com/RealGeeks/mallet/blob/12b8a1b0ab014386c1d0e7980a51afc2089ccdd4/index.js#L935-L941 | train |
RealGeeks/mallet | index.js | TMEhandler | function TMEhandler(manager, inputEvent, inputData) {
var isTouch = (inputData.pointerType == INPUT_TYPE_TOUCH);
var isMouse = (inputData.pointerType == INPUT_TYPE_MOUSE);
// when we're in a touch event, so block all upcoming mouse events
// most mobile browser also emit mouseevents, right after touch... | javascript | function TMEhandler(manager, inputEvent, inputData) {
var isTouch = (inputData.pointerType == INPUT_TYPE_TOUCH);
var isMouse = (inputData.pointerType == INPUT_TYPE_MOUSE);
// when we're in a touch event, so block all upcoming mouse events
// most mobile browser also emit mouseevents, right after touch... | [
"function",
"TMEhandler",
"(",
"manager",
",",
"inputEvent",
",",
"inputData",
")",
"{",
"var",
"isTouch",
"=",
"(",
"inputData",
".",
"pointerType",
"==",
"INPUT_TYPE_TOUCH",
")",
";",
"var",
"isMouse",
"=",
"(",
"inputData",
".",
"pointerType",
"==",
"INPU... | handle mouse and touch events
@param {Mallet} manager
@param {String} inputEvent
@param {Object} inputData | [
"handle",
"mouse",
"and",
"touch",
"events"
] | 12b8a1b0ab014386c1d0e7980a51afc2089ccdd4 | https://github.com/RealGeeks/mallet/blob/12b8a1b0ab014386c1d0e7980a51afc2089ccdd4/index.js#L950-L968 | train |
RealGeeks/mallet | index.js | function (value) {
// find out the touch-action by the event handlers
if (value == TOUCH_ACTION_COMPUTE) {
value = this.compute();
}
if (NATIVE_TOUCH_ACTION) {
this.manager.element.style[PREFIXED_TOUCH_ACTION] = value;
}
this.actions = value.toLowerCase().trim();
} | javascript | function (value) {
// find out the touch-action by the event handlers
if (value == TOUCH_ACTION_COMPUTE) {
value = this.compute();
}
if (NATIVE_TOUCH_ACTION) {
this.manager.element.style[PREFIXED_TOUCH_ACTION] = value;
}
this.actions = value.toLowerCase().trim();
} | [
"function",
"(",
"value",
")",
"{",
"// find out the touch-action by the event handlers",
"if",
"(",
"value",
"==",
"TOUCH_ACTION_COMPUTE",
")",
"{",
"value",
"=",
"this",
".",
"compute",
"(",
")",
";",
"}",
"if",
"(",
"NATIVE_TOUCH_ACTION",
")",
"{",
"this",
... | set the touchAction value on the element or enable the polyfill
@param {String} value | [
"set",
"the",
"touchAction",
"value",
"on",
"the",
"element",
"or",
"enable",
"the",
"polyfill"
] | 12b8a1b0ab014386c1d0e7980a51afc2089ccdd4 | https://github.com/RealGeeks/mallet/blob/12b8a1b0ab014386c1d0e7980a51afc2089ccdd4/index.js#L1007-L1017 | train | |
RealGeeks/mallet | index.js | function () {
var actions = [];
this.manager.recognizers.forEach(function (recognizer) {
if (boolOrFn(recognizer.options.enable, [recognizer])) {
actions = actions.concat(recognizer.getTouchAction());
}
});
return cleanTouchActions(actions.join(' '));
} | javascript | function () {
var actions = [];
this.manager.recognizers.forEach(function (recognizer) {
if (boolOrFn(recognizer.options.enable, [recognizer])) {
actions = actions.concat(recognizer.getTouchAction());
}
});
return cleanTouchActions(actions.join(' '));
} | [
"function",
"(",
")",
"{",
"var",
"actions",
"=",
"[",
"]",
";",
"this",
".",
"manager",
".",
"recognizers",
".",
"forEach",
"(",
"function",
"(",
"recognizer",
")",
"{",
"if",
"(",
"boolOrFn",
"(",
"recognizer",
".",
"options",
".",
"enable",
",",
"... | compute the value for the touchAction property based on the recognizer's settings
@returns {String} value | [
"compute",
"the",
"value",
"for",
"the",
"touchAction",
"property",
"based",
"on",
"the",
"recognizer",
"s",
"settings"
] | 12b8a1b0ab014386c1d0e7980a51afc2089ccdd4 | https://github.com/RealGeeks/mallet/blob/12b8a1b0ab014386c1d0e7980a51afc2089ccdd4/index.js#L1030-L1038 | train | |
RealGeeks/mallet | index.js | function (input) {
// not needed with native support for the touchAction property
if (NATIVE_TOUCH_ACTION) {
return;
}
var srcEvent = input.srcEvent;
var direction = input.offsetDirection;
// if the touch action did prevented once this session
if (this.manager.session.prevented) {
... | javascript | function (input) {
// not needed with native support for the touchAction property
if (NATIVE_TOUCH_ACTION) {
return;
}
var srcEvent = input.srcEvent;
var direction = input.offsetDirection;
// if the touch action did prevented once this session
if (this.manager.session.prevented) {
... | [
"function",
"(",
"input",
")",
"{",
"// not needed with native support for the touchAction property",
"if",
"(",
"NATIVE_TOUCH_ACTION",
")",
"{",
"return",
";",
"}",
"var",
"srcEvent",
"=",
"input",
".",
"srcEvent",
";",
"var",
"direction",
"=",
"input",
".",
"off... | this method is called on each input cycle and provides the preventing of the browser behavior
@param {Object} input | [
"this",
"method",
"is",
"called",
"on",
"each",
"input",
"cycle",
"and",
"provides",
"the",
"preventing",
"of",
"the",
"browser",
"behavior"
] | 12b8a1b0ab014386c1d0e7980a51afc2089ccdd4 | https://github.com/RealGeeks/mallet/blob/12b8a1b0ab014386c1d0e7980a51afc2089ccdd4/index.js#L1044-L1069 | train | |
RealGeeks/mallet | index.js | Mallet | function Mallet(element, options) {
options = options || {};
options.recognizers = ifUndefined(options.recognizers, Mallet.defaults.preset);
return new Manager(element, options);
} | javascript | function Mallet(element, options) {
options = options || {};
options.recognizers = ifUndefined(options.recognizers, Mallet.defaults.preset);
return new Manager(element, options);
} | [
"function",
"Mallet",
"(",
"element",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"options",
".",
"recognizers",
"=",
"ifUndefined",
"(",
"options",
".",
"recognizers",
",",
"Mallet",
".",
"defaults",
".",
"preset",
")",
";"... | Simple way to create an manager with a default set of recognizers.
@param {HTMLElement} element
@param {Object} [options]
@constructor | [
"Simple",
"way",
"to",
"create",
"an",
"manager",
"with",
"a",
"default",
"set",
"of",
"recognizers",
"."
] | 12b8a1b0ab014386c1d0e7980a51afc2089ccdd4 | https://github.com/RealGeeks/mallet/blob/12b8a1b0ab014386c1d0e7980a51afc2089ccdd4/index.js#L1893-L1897 | train |
pattern-library/pattern-library-utilities | lib/gulp-tasks/browsersync.js | function () {
'use strict';
// default options for pattern-importer
var options = {
environment: {
config: {
server: {
baseDir: './app'
},
host: 'localhost',
port: 8001,
debugInfo: false,
open: true
}
},
showConsoleLog: true,
... | javascript | function () {
'use strict';
// default options for pattern-importer
var options = {
environment: {
config: {
server: {
baseDir: './app'
},
host: 'localhost',
port: 8001,
debugInfo: false,
open: true
}
},
showConsoleLog: true,
... | [
"function",
"(",
")",
"{",
"'use strict'",
";",
"// default options for pattern-importer",
"var",
"options",
"=",
"{",
"environment",
":",
"{",
"config",
":",
"{",
"server",
":",
"{",
"baseDir",
":",
"'./app'",
"}",
",",
"host",
":",
"'localhost'",
",",
"por... | Function to get default options for an implementation of browser-sync
@return {Object} options an object of default browser-sync options | [
"Function",
"to",
"get",
"default",
"options",
"for",
"an",
"implementation",
"of",
"browser",
"-",
"sync"
] | a0198f7bb698eb5b859576b11afa3d0ebd3e5911 | https://github.com/pattern-library/pattern-library-utilities/blob/a0198f7bb698eb5b859576b11afa3d0ebd3e5911/lib/gulp-tasks/browsersync.js#L17-L40 | train | |
Nazariglez/perenquen | lib/pixi/src/filters/bloom/BloomFilter.js | BloomFilter | function BloomFilter()
{
core.AbstractFilter.call(this);
this.blurXFilter = new BlurXFilter();
this.blurYFilter = new BlurYFilter();
this.defaultFilter = new core.AbstractFilter();
} | javascript | function BloomFilter()
{
core.AbstractFilter.call(this);
this.blurXFilter = new BlurXFilter();
this.blurYFilter = new BlurYFilter();
this.defaultFilter = new core.AbstractFilter();
} | [
"function",
"BloomFilter",
"(",
")",
"{",
"core",
".",
"AbstractFilter",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"blurXFilter",
"=",
"new",
"BlurXFilter",
"(",
")",
";",
"this",
".",
"blurYFilter",
"=",
"new",
"BlurYFilter",
"(",
")",
";",
"th... | The BloomFilter applies a Gaussian blur to an object.
The strength of the blur can be set for x- and y-axis separately.
@class
@extends AbstractFilter
@memberof PIXI.filters | [
"The",
"BloomFilter",
"applies",
"a",
"Gaussian",
"blur",
"to",
"an",
"object",
".",
"The",
"strength",
"of",
"the",
"blur",
"can",
"be",
"set",
"for",
"x",
"-",
"and",
"y",
"-",
"axis",
"separately",
"."
] | e023964d05afeefebdcac4e2044819fdfa3899ae | https://github.com/Nazariglez/perenquen/blob/e023964d05afeefebdcac4e2044819fdfa3899ae/lib/pixi/src/filters/bloom/BloomFilter.js#L13-L21 | train |
weekeight/gulp-joycss | joycss/lib/common/stdclass.js | on | function on(ev, fn, context){
var arg = arguments;
var slice = [].slice;
var evs = ev.split(',');
var i = 0;
var evt = '';
var __fn = fn;
fn = function wrapOn(e){
context = context || this;
__fn.apply(context, [e].concat(slice.call(arg, 3)));
};
while(evs[i]){
evt ... | javascript | function on(ev, fn, context){
var arg = arguments;
var slice = [].slice;
var evs = ev.split(',');
var i = 0;
var evt = '';
var __fn = fn;
fn = function wrapOn(e){
context = context || this;
__fn.apply(context, [e].concat(slice.call(arg, 3)));
};
while(evs[i]){
evt ... | [
"function",
"on",
"(",
"ev",
",",
"fn",
",",
"context",
")",
"{",
"var",
"arg",
"=",
"arguments",
";",
"var",
"slice",
"=",
"[",
"]",
".",
"slice",
";",
"var",
"evs",
"=",
"ev",
".",
"split",
"(",
"','",
")",
";",
"var",
"i",
"=",
"0",
";",
... | the same to function on, bind event on self, the only
change is add the ability of bind mult event
@example this.on('a, b, c', fn);
@note the dismember is ', ', do not lost the blank space
@param ev {string} event string, dismember by ', ',semicolon add an
blank space
@param fn {function} function executed when the eve... | [
"the",
"same",
"to",
"function",
"on",
"bind",
"event",
"on",
"self",
"the",
"only",
"change",
"is",
"add",
"the",
"ability",
"of",
"bind",
"mult",
"event"
] | 5dc7a1276bcca878c2ac513efe6442fc47a36e29 | https://github.com/weekeight/gulp-joycss/blob/5dc7a1276bcca878c2ac513efe6442fc47a36e29/joycss/lib/common/stdclass.js#L201-L220 | train |
cahangon/is-aksara | index.js | isSandhanganWyanjana | function isSandhanganWyanjana(position, input) {
var chr = input.charAt(position),
length = input.length,
prevChr = input.charAt(position - 1),
nextChr;
// pacar = false
if (position == length - 1) {
return false;
}
// paras = false
if (isSwara(prevChr)) {
... | javascript | function isSandhanganWyanjana(position, input) {
var chr = input.charAt(position),
length = input.length,
prevChr = input.charAt(position - 1),
nextChr;
// pacar = false
if (position == length - 1) {
return false;
}
// paras = false
if (isSwara(prevChr)) {
... | [
"function",
"isSandhanganWyanjana",
"(",
"position",
",",
"input",
")",
"{",
"var",
"chr",
"=",
"input",
".",
"charAt",
"(",
"position",
")",
",",
"length",
"=",
"input",
".",
"length",
",",
"prevChr",
"=",
"input",
".",
"charAt",
"(",
"position",
"-",
... | Mendeteksi sisipan ra, re, ya
@param {Number} position Posisi dari karakter yang hendak diperiksa
@param {String} input Kalimat yang hendak diperiksa
@return {Boolean} | [
"Mendeteksi",
"sisipan",
"ra",
"re",
"ya"
] | a8ebc4d2bea00a2e3bc52c6699c9aa100c2964c3 | https://github.com/cahangon/is-aksara/blob/a8ebc4d2bea00a2e3bc52c6699c9aa100c2964c3/index.js#L126-L160 | train |
byron-dupreez/rcc-ioredis-adapter | rcc-ioredis-adapter.js | isMovedError | function isMovedError(error) {
// Check if error message contains something like: "MOVED 14190 127.0.0.1:6379"
return !!isInstanceOf(error, ReplyError) && error.message && error.message.startsWith('MOVED ');
} | javascript | function isMovedError(error) {
// Check if error message contains something like: "MOVED 14190 127.0.0.1:6379"
return !!isInstanceOf(error, ReplyError) && error.message && error.message.startsWith('MOVED ');
} | [
"function",
"isMovedError",
"(",
"error",
")",
"{",
"// Check if error message contains something like: \"MOVED 14190 127.0.0.1:6379\"",
"return",
"!",
"!",
"isInstanceOf",
"(",
"error",
",",
"ReplyError",
")",
"&&",
"error",
".",
"message",
"&&",
"error",
".",
"message... | Returns true if the given error indicates that the key attempted was moved to a new host and port; otherwise returns
false.
@param {Error|ReplyError} error - an error thrown by a RedisClient instance
@return {boolean} true if moved; false otherwise | [
"Returns",
"true",
"if",
"the",
"given",
"error",
"indicates",
"that",
"the",
"key",
"attempted",
"was",
"moved",
"to",
"a",
"new",
"host",
"and",
"port",
";",
"otherwise",
"returns",
"false",
"."
] | 8acf43bff7231d4d310abb2580bcfc75ab5c1e0b | https://github.com/byron-dupreez/rcc-ioredis-adapter/blob/8acf43bff7231d4d310abb2580bcfc75ab5c1e0b/rcc-ioredis-adapter.js#L107-L110 | train |
byron-dupreez/rcc-ioredis-adapter | rcc-ioredis-adapter.js | resolveHostAndPortFromMovedError | function resolveHostAndPortFromMovedError(movedError) {
// Attempt to resolve the new host & port from the error message
if (isMovedError(movedError)) {
return movedError.message.substring(movedError.message.lastIndexOf(' ') + 1).split(':');
}
throw new Error(`Unexpected ioredis client "moved" ReplyError - ... | javascript | function resolveHostAndPortFromMovedError(movedError) {
// Attempt to resolve the new host & port from the error message
if (isMovedError(movedError)) {
return movedError.message.substring(movedError.message.lastIndexOf(' ') + 1).split(':');
}
throw new Error(`Unexpected ioredis client "moved" ReplyError - ... | [
"function",
"resolveHostAndPortFromMovedError",
"(",
"movedError",
")",
"{",
"// Attempt to resolve the new host & port from the error message",
"if",
"(",
"isMovedError",
"(",
"movedError",
")",
")",
"{",
"return",
"movedError",
".",
"message",
".",
"substring",
"(",
"mo... | Extracts the new host and port from the given RedisClient "moved" ReplyError.
@param {ReplyError|Error} movedError - a ReplyError thrown by a RedisClient instance that indicates the redis server
has moved
@return {[string, number|string]} the new host and port | [
"Extracts",
"the",
"new",
"host",
"and",
"port",
"from",
"the",
"given",
"RedisClient",
"moved",
"ReplyError",
"."
] | 8acf43bff7231d4d310abb2580bcfc75ab5c1e0b | https://github.com/byron-dupreez/rcc-ioredis-adapter/blob/8acf43bff7231d4d310abb2580bcfc75ab5c1e0b/rcc-ioredis-adapter.js#L118-L124 | train |
lujintan/clitoolkit | src/PluginEngine.js | function(name){
for (var i = 0, len = _pluginList.length ; i < len ; i++){
var plugin = _pluginList[i];
if (name === plugin.name) {
return true;
}
}
return false;
} | javascript | function(name){
for (var i = 0, len = _pluginList.length ; i < len ; i++){
var plugin = _pluginList[i];
if (name === plugin.name) {
return true;
}
}
return false;
} | [
"function",
"(",
"name",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"_pluginList",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"var",
"plugin",
"=",
"_pluginList",
"[",
"i",
"]",
";",
"if",
"(",
"name",
"=... | weather the plugin is exist in plugin's list or not
@param {String} name the plugin's name
@return {Boolean} | [
"weather",
"the",
"plugin",
"is",
"exist",
"in",
"plugin",
"s",
"list",
"or",
"not"
] | 0745f6ebd5b290f5462c64fd49959f6374ec5c2a | https://github.com/lujintan/clitoolkit/blob/0745f6ebd5b290f5462c64fd49959f6374ec5c2a/src/PluginEngine.js#L18-L26 | train | |
lujintan/clitoolkit | src/PluginEngine.js | function(name, pa){
var pa = pa || name;
if (!this.isExist(name)){
var realPath = path.join(_pluginBase, pa, 'main.js');
var pluginReg;
if (!fs.existsSync(realPath)) {
pluginReg = require(pa);
} else {
pluginReg = require(f... | javascript | function(name, pa){
var pa = pa || name;
if (!this.isExist(name)){
var realPath = path.join(_pluginBase, pa, 'main.js');
var pluginReg;
if (!fs.existsSync(realPath)) {
pluginReg = require(pa);
} else {
pluginReg = require(f... | [
"function",
"(",
"name",
",",
"pa",
")",
"{",
"var",
"pa",
"=",
"pa",
"||",
"name",
";",
"if",
"(",
"!",
"this",
".",
"isExist",
"(",
"name",
")",
")",
"{",
"var",
"realPath",
"=",
"path",
".",
"join",
"(",
"_pluginBase",
",",
"pa",
",",
"'main... | register the plugin
@param {String} path the plugin's path
@return {void} | [
"register",
"the",
"plugin"
] | 0745f6ebd5b290f5462c64fd49959f6374ec5c2a | https://github.com/lujintan/clitoolkit/blob/0745f6ebd5b290f5462c64fd49959f6374ec5c2a/src/PluginEngine.js#L33-L49 | train | |
lujintan/clitoolkit | src/PluginEngine.js | function(name){
for (var i = 0, len = _pluginList.length ; i < len ; i++){
var plugin = _pluginList[i];
if (name === plugin.name) {
_pluginList.splice(i, 1);
return;
}
}
} | javascript | function(name){
for (var i = 0, len = _pluginList.length ; i < len ; i++){
var plugin = _pluginList[i];
if (name === plugin.name) {
_pluginList.splice(i, 1);
return;
}
}
} | [
"function",
"(",
"name",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"_pluginList",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"var",
"plugin",
"=",
"_pluginList",
"[",
"i",
"]",
";",
"if",
"(",
"name",
"=... | remove the plugin by name
@param {String} name plugin's name
@return {void} | [
"remove",
"the",
"plugin",
"by",
"name"
] | 0745f6ebd5b290f5462c64fd49959f6374ec5c2a | https://github.com/lujintan/clitoolkit/blob/0745f6ebd5b290f5462c64fd49959f6374ec5c2a/src/PluginEngine.js#L56-L64 | train | |
lujintan/clitoolkit | src/PluginEngine.js | function(plugins, pluginBase){
var _this = this;
if (typeof pluginBase === 'string') {
_pluginBase = pluginBase;
}
plugins.forEach(function(plugin, index){
var name;
var path;
if (typeof plugin === 'string'){
name =... | javascript | function(plugins, pluginBase){
var _this = this;
if (typeof pluginBase === 'string') {
_pluginBase = pluginBase;
}
plugins.forEach(function(plugin, index){
var name;
var path;
if (typeof plugin === 'string'){
name =... | [
"function",
"(",
"plugins",
",",
"pluginBase",
")",
"{",
"var",
"_this",
"=",
"this",
";",
"if",
"(",
"typeof",
"pluginBase",
"===",
"'string'",
")",
"{",
"_pluginBase",
"=",
"pluginBase",
";",
"}",
"plugins",
".",
"forEach",
"(",
"function",
"(",
"plugi... | initial the plugins by plugin's config
@param {Object} plugins plugin's config
@return {Promise} | [
"initial",
"the",
"plugins",
"by",
"plugin",
"s",
"config"
] | 0745f6ebd5b290f5462c64fd49959f6374ec5c2a | https://github.com/lujintan/clitoolkit/blob/0745f6ebd5b290f5462c64fd49959f6374ec5c2a/src/PluginEngine.js#L71-L88 | train | |
Two-Screen/grunt-zipstream | tasks/lib/zipstream.js | callbackOnce | function callbackOnce(err, arg) {
var cb = callback;
callback = null;
if (cb) { cb(err, arg); }
} | javascript | function callbackOnce(err, arg) {
var cb = callback;
callback = null;
if (cb) { cb(err, arg); }
} | [
"function",
"callbackOnce",
"(",
"err",
",",
"arg",
")",
"{",
"var",
"cb",
"=",
"callback",
";",
"callback",
"=",
"null",
";",
"if",
"(",
"cb",
")",
"{",
"cb",
"(",
"err",
",",
"arg",
")",
";",
"}",
"}"
] | Helper to call back only once. | [
"Helper",
"to",
"call",
"back",
"only",
"once",
"."
] | c975cc1facafd56aad6db63c2462066481092fed | https://github.com/Two-Screen/grunt-zipstream/blob/c975cc1facafd56aad6db63c2462066481092fed/tasks/lib/zipstream.js#L30-L34 | train |
Two-Screen/grunt-zipstream | tasks/lib/zipstream.js | createErrorHandler | function createErrorHandler(verb) {
return function(err) {
if (!callback) { return; }
grunt.verbose.error();
grunt.fail.warn("Failed to " + verb + ": " + err.message);
callbackOnce(err);
};
} | javascript | function createErrorHandler(verb) {
return function(err) {
if (!callback) { return; }
grunt.verbose.error();
grunt.fail.warn("Failed to " + verb + ": " + err.message);
callbackOnce(err);
};
} | [
"function",
"createErrorHandler",
"(",
"verb",
")",
"{",
"return",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"!",
"callback",
")",
"{",
"return",
";",
"}",
"grunt",
".",
"verbose",
".",
"error",
"(",
")",
";",
"grunt",
".",
"fail",
".",
"warn",
... | Helper to create a stream error handler function. | [
"Helper",
"to",
"create",
"a",
"stream",
"error",
"handler",
"function",
"."
] | c975cc1facafd56aad6db63c2462066481092fed | https://github.com/Two-Screen/grunt-zipstream/blob/c975cc1facafd56aad6db63c2462066481092fed/tasks/lib/zipstream.js#L37-L44 | train |
andrewscwei/requiem | src/dom/getStyle.js | getStyle | function getStyle(element, key, isComputed, isolateUnits) {
assertType(element, Node, false, 'Invalid element specified');
if (typeof isComputed !== 'boolean') isComputed = false;
if (typeof isolateUnits !== 'boolean') isolateUnits = false;
let value = (isComputed) ? window.getComputedStyle(element, null).getP... | javascript | function getStyle(element, key, isComputed, isolateUnits) {
assertType(element, Node, false, 'Invalid element specified');
if (typeof isComputed !== 'boolean') isComputed = false;
if (typeof isolateUnits !== 'boolean') isolateUnits = false;
let value = (isComputed) ? window.getComputedStyle(element, null).getP... | [
"function",
"getStyle",
"(",
"element",
",",
"key",
",",
"isComputed",
",",
"isolateUnits",
")",
"{",
"assertType",
"(",
"element",
",",
"Node",
",",
"false",
",",
"'Invalid element specified'",
")",
";",
"if",
"(",
"typeof",
"isComputed",
"!==",
"'boolean'",
... | Gets the value of an inline CSS rule of a Node by its name.
@param {Node} element - Target element.
@param {string} key - Name of the CSS rule in camelCase.
@param {boolean} [isComputed=false] - Specifies whether the styles are
computed.
@param {boolean} [isolateUnits=false] - Specifies whether value and units are
sep... | [
"Gets",
"the",
"value",
"of",
"an",
"inline",
"CSS",
"rule",
"of",
"a",
"Node",
"by",
"its",
"name",
"."
] | c4182bfffc9841c6de5718f689ad3c2060511777 | https://github.com/andrewscwei/requiem/blob/c4182bfffc9841c6de5718f689ad3c2060511777/src/dom/getStyle.js#L23-L45 | train |
fronteerio/node-embdr | lib/embdr.js | Embdr | function Embdr(key) {
if (!(this instanceof Embdr)) {
return new Embdr(key);
}
this._api = {
'auth': null,
'host': Embdr.DEFAULT_HOST,
'port': Embdr.DEFAULT_PORT,
'basePath': Embdr.DEFAULT_BASE_PATH,
'protocol': Embdr.DEFAULT_PROTOCOL
};
this.setApiK... | javascript | function Embdr(key) {
if (!(this instanceof Embdr)) {
return new Embdr(key);
}
this._api = {
'auth': null,
'host': Embdr.DEFAULT_HOST,
'port': Embdr.DEFAULT_PORT,
'basePath': Embdr.DEFAULT_BASE_PATH,
'protocol': Embdr.DEFAULT_PROTOCOL
};
this.setApiK... | [
"function",
"Embdr",
"(",
"key",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Embdr",
")",
")",
"{",
"return",
"new",
"Embdr",
"(",
"key",
")",
";",
"}",
"this",
".",
"_api",
"=",
"{",
"'auth'",
":",
"null",
",",
"'host'",
":",
"Embdr",
... | Create a new Embdr instance
@constructor
@param {string} key The API key that allows for uploading to the Embdr REST API | [
"Create",
"a",
"new",
"Embdr",
"instance"
] | 050916baa37b069d894fdd4db3b80f110ad8c51e | https://github.com/fronteerio/node-embdr/blob/050916baa37b069d894fdd4db3b80f110ad8c51e/lib/embdr.js#L42-L57 | train |
pinicarus/piquouze | examples/node6.js | function (a, b, c, d, e, ...args) {
return [a, b, c, d, e].concat(args);
} | javascript | function (a, b, c, d, e, ...args) {
return [a, b, c, d, e].concat(args);
} | [
"function",
"(",
"a",
",",
"b",
",",
"c",
",",
"d",
",",
"e",
",",
"...",
"args",
")",
"{",
"return",
"[",
"a",
",",
"b",
",",
"c",
",",
"d",
",",
"e",
"]",
".",
"concat",
"(",
"args",
")",
";",
"}"
] | Override a dependency. | [
"Override",
"a",
"dependency",
"."
] | 608e3a0a655d0504831a092ecee90ff66b0ce752 | https://github.com/pinicarus/piquouze/blob/608e3a0a655d0504831a092ecee90ff66b0ce752/examples/node6.js#L25-L27 | train | |
raitucarp/flattenr | index.js | flat | function flat(current, name, object, separator) {
var data = {}
// iterate object
for (var x in object) {
var key = [name, x].join(separator)
data[key] = object[x]
}
// iterate through data
for (var i in data) {
if (typeof data[i] !== "object") {
current[i] =... | javascript | function flat(current, name, object, separator) {
var data = {}
// iterate object
for (var x in object) {
var key = [name, x].join(separator)
data[key] = object[x]
}
// iterate through data
for (var i in data) {
if (typeof data[i] !== "object") {
current[i] =... | [
"function",
"flat",
"(",
"current",
",",
"name",
",",
"object",
",",
"separator",
")",
"{",
"var",
"data",
"=",
"{",
"}",
"// iterate object",
"for",
"(",
"var",
"x",
"in",
"object",
")",
"{",
"var",
"key",
"=",
"[",
"name",
",",
"x",
"]",
".",
"... | flat an object to be more save use | [
"flat",
"an",
"object",
"to",
"be",
"more",
"save",
"use"
] | ea9adac2c3092c884c056ef72bbdd40a812cb19d | https://github.com/raitucarp/flattenr/blob/ea9adac2c3092c884c056ef72bbdd40a812cb19d/index.js#L2-L21 | train |
raitucarp/flattenr | index.js | function(data, pattern) {
var result = {}
// iterate thorough data
for (var i in data) {
// create context data
var _data = data[i]
// if key match with pattern
if (i.match(pattern)) {
// add matched data
result[i] = _data
}
// if va... | javascript | function(data, pattern) {
var result = {}
// iterate thorough data
for (var i in data) {
// create context data
var _data = data[i]
// if key match with pattern
if (i.match(pattern)) {
// add matched data
result[i] = _data
}
// if va... | [
"function",
"(",
"data",
",",
"pattern",
")",
"{",
"var",
"result",
"=",
"{",
"}",
"// iterate thorough data",
"for",
"(",
"var",
"i",
"in",
"data",
")",
"{",
"// create context data",
"var",
"_data",
"=",
"data",
"[",
"i",
"]",
"// if key match with pattern... | matchPattern find pattern in data | [
"matchPattern",
"find",
"pattern",
"in",
"data"
] | ea9adac2c3092c884c056ef72bbdd40a812cb19d | https://github.com/raitucarp/flattenr/blob/ea9adac2c3092c884c056ef72bbdd40a812cb19d/index.js#L28-L48 | train | |
0of/ver-iterator | lib/iterator.js | VersionIterable | function VersionIterable(task) {
var _ref = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var name = _ref.name;
var _ref$range = _ref.range;
var range = _ref$range === undefined ? '*' : _ref$range;
var _ref$dir = _ref.dir;
var dir = _ref$dir ==... | javascript | function VersionIterable(task) {
var _ref = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var name = _ref.name;
var _ref$range = _ref.range;
var range = _ref$range === undefined ? '*' : _ref$range;
var _ref$dir = _ref.dir;
var dir = _ref$dir ==... | [
"function",
"VersionIterable",
"(",
"task",
")",
"{",
"var",
"_ref",
"=",
"arguments",
".",
"length",
"<=",
"1",
"||",
"arguments",
"[",
"1",
"]",
"===",
"undefined",
"?",
"{",
"}",
":",
"arguments",
"[",
"1",
"]",
";",
"var",
"name",
"=",
"_ref",
... | construct iterable published versions via npm
@param {Function} [task] ({name, version}) => {}
@param {Object} [opts]
@param {String} [opts.name] package name or git URL
@param {String|Function} [opts.range] iterating version ranges in semver format
or customized version filter
@param {String} [opts.dir] installing pa... | [
"construct",
"iterable",
"published",
"versions",
"via",
"npm"
] | a51726c02dfd14488190860f4d90903574ed8e37 | https://github.com/0of/ver-iterator/blob/a51726c02dfd14488190860f4d90903574ed8e37/lib/iterator.js#L64-L101 | train |
mikolalysenko/splat-points-2d | splat.js | splatPoints | function splatPoints(out, points, weights, radius) {
doSplat(
points.hi(points.shape[0], 1),
ndarray(weights.data,
[weights.shape[0], 1],
[weights.stride[0], 0],
weights.offset),
out,
radius,
dirichlet)
} | javascript | function splatPoints(out, points, weights, radius) {
doSplat(
points.hi(points.shape[0], 1),
ndarray(weights.data,
[weights.shape[0], 1],
[weights.stride[0], 0],
weights.offset),
out,
radius,
dirichlet)
} | [
"function",
"splatPoints",
"(",
"out",
",",
"points",
",",
"weights",
",",
"radius",
")",
"{",
"doSplat",
"(",
"points",
".",
"hi",
"(",
"points",
".",
"shape",
"[",
"0",
"]",
",",
"1",
")",
",",
"ndarray",
"(",
"weights",
".",
"data",
",",
"[",
... | Splat a list of points to a grid with the given weights | [
"Splat",
"a",
"list",
"of",
"points",
"to",
"a",
"grid",
"with",
"the",
"given",
"weights"
] | 1a5b151df78e370877c1117ceabb70c32b309591 | https://github.com/mikolalysenko/splat-points-2d/blob/1a5b151df78e370877c1117ceabb70c32b309591/splat.js#L44-L54 | train |
warncke/immutable-core | lib/immutable-function.js | functionWrapperFunction | function functionWrapperFunction () {
// call original function - catching errors for logging
try {
var res = functionObj.apply(this, arguments)
}
catch (error) {
var err = error
}
// if log client then do logging
if (options.logClient) {
... | javascript | function functionWrapperFunction () {
// call original function - catching errors for logging
try {
var res = functionObj.apply(this, arguments)
}
catch (error) {
var err = error
}
// if log client then do logging
if (options.logClient) {
... | [
"function",
"functionWrapperFunction",
"(",
")",
"{",
"// call original function - catching errors for logging",
"try",
"{",
"var",
"res",
"=",
"functionObj",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
"}",
"catch",
"(",
"error",
")",
"{",
"var",
"err",
"... | create wrapper function that will do logging and call original | [
"create",
"wrapper",
"function",
"that",
"will",
"do",
"logging",
"and",
"call",
"original"
] | fd8f6c2194ee98b61c5e79b534fb5fb3f6f20d3d | https://github.com/warncke/immutable-core/blob/fd8f6c2194ee98b61c5e79b534fb5fb3f6f20d3d/lib/immutable-function.js#L48-L84 | train |
pattern-library/pattern-library-utilities | lib/gulp-tasks/doxx.js | function () {
'use strict';
// default options for doxx gulp task
var options = {
config: {
title: 'Project Title',
urlPrefix: null,
template: path.join(__dirname, '../templates/doxx.template.jade')
},
src: [
'!./node_modules/**/*',
'./**/*.js'
],
dest: './docs'... | javascript | function () {
'use strict';
// default options for doxx gulp task
var options = {
config: {
title: 'Project Title',
urlPrefix: null,
template: path.join(__dirname, '../templates/doxx.template.jade')
},
src: [
'!./node_modules/**/*',
'./**/*.js'
],
dest: './docs'... | [
"function",
"(",
")",
"{",
"'use strict'",
";",
"// default options for doxx gulp task",
"var",
"options",
"=",
"{",
"config",
":",
"{",
"title",
":",
"'Project Title'",
",",
"urlPrefix",
":",
"null",
",",
"template",
":",
"path",
".",
"join",
"(",
"__dirname"... | Function to get default options for an implementation of gulp-doxx
@return {Object} options an object of default doxx options | [
"Function",
"to",
"get",
"default",
"options",
"for",
"an",
"implementation",
"of",
"gulp",
"-",
"doxx"
] | a0198f7bb698eb5b859576b11afa3d0ebd3e5911 | https://github.com/pattern-library/pattern-library-utilities/blob/a0198f7bb698eb5b859576b11afa3d0ebd3e5911/lib/gulp-tasks/doxx.js#L18-L39 | train | |
derdesign/protos | lib/controller.js | function(v, o) {
if (re.test(v)) {
o[k] = v; // Set params to be returned when matching
return true;
} else {
return false;
}
} | javascript | function(v, o) {
if (re.test(v)) {
o[k] = v; // Set params to be returned when matching
return true;
} else {
return false;
}
} | [
"function",
"(",
"v",
",",
"o",
")",
"{",
"if",
"(",
"re",
".",
"test",
"(",
"v",
")",
")",
"{",
"o",
"[",
"k",
"]",
"=",
"v",
";",
"// Set params to be returned when matching",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
... | new closure, to maintain value | [
"new",
"closure",
"to",
"maintain",
"value"
] | 0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9 | https://github.com/derdesign/protos/blob/0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9/lib/controller.js#L733-L740 | train | |
tolokoban/ToloFrameWork | ker/mod/wdg.js | Widget | function Widget(options) {
this.__data = {};
try {
var e;
if (typeof options === 'undefined') options = {};
if (typeof options.innerHTML !== 'undefined' && typeof options.childNodes !== 'undefined') {
// On passe directement un élément.
options = {element: options};
}
if (typeof opti... | javascript | function Widget(options) {
this.__data = {};
try {
var e;
if (typeof options === 'undefined') options = {};
if (typeof options.innerHTML !== 'undefined' && typeof options.childNodes !== 'undefined') {
// On passe directement un élément.
options = {element: options};
}
if (typeof opti... | [
"function",
"Widget",
"(",
"options",
")",
"{",
"this",
".",
"__data",
"=",
"{",
"}",
";",
"try",
"{",
"var",
"e",
";",
"if",
"(",
"typeof",
"options",
"===",
"'undefined'",
")",
"options",
"=",
"{",
"}",
";",
"if",
"(",
"typeof",
"options",
".",
... | Widgets inherit this class. | [
"Widgets",
"inherit",
"this",
"class",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/wdg.js#L6-L34 | train |
tolokoban/ToloFrameWork | ker/mod/wdg.js | function(v) {
if (v === undefined) return this._element;
if (typeof v === 'string') {
v = window.document.querySelector(v);
}
this._element = v;
return this;
} | javascript | function(v) {
if (v === undefined) return this._element;
if (typeof v === 'string') {
v = window.document.querySelector(v);
}
this._element = v;
return this;
} | [
"function",
"(",
"v",
")",
"{",
"if",
"(",
"v",
"===",
"undefined",
")",
"return",
"this",
".",
"_element",
";",
"if",
"(",
"typeof",
"v",
"===",
"'string'",
")",
"{",
"v",
"=",
"window",
".",
"document",
".",
"querySelector",
"(",
"v",
")",
";",
... | Accessor for attribute element
@return element | [
"Accessor",
"for",
"attribute",
"element"
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/wdg.js#L41-L48 | train | |
tolokoban/ToloFrameWork | ker/mod/wdg.js | function() {
var e = this._element;
if (e) {
var p = e.parentNode;
if (p) {
p.removeChild(e);
}
}
return this;
} | javascript | function() {
var e = this._element;
if (e) {
var p = e.parentNode;
if (p) {
p.removeChild(e);
}
}
return this;
} | [
"function",
"(",
")",
"{",
"var",
"e",
"=",
"this",
".",
"_element",
";",
"if",
"(",
"e",
")",
"{",
"var",
"p",
"=",
"e",
".",
"parentNode",
";",
"if",
"(",
"p",
")",
"{",
"p",
".",
"removeChild",
"(",
"e",
")",
";",
"}",
"}",
"return",
"th... | Remove this element from its parent.
@memberof wdg | [
"Remove",
"this",
"element",
"from",
"its",
"parent",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/wdg.js#L62-L71 | train | |
tolokoban/ToloFrameWork | ker/mod/wdg.js | function() {
var i, arg;
for (i = 0 ; i < arguments.length ; i++) {
arg = arguments[i];
if (typeof arg === 'number') arg = "" + arg;
if (typeof arg === 'undefined' || typeof arg === 'null'
|| (typeof arg !== 'object' && typeof arg !== 'string')) {
console.error("[Widget.appen... | javascript | function() {
var i, arg;
for (i = 0 ; i < arguments.length ; i++) {
arg = arguments[i];
if (typeof arg === 'number') arg = "" + arg;
if (typeof arg === 'undefined' || typeof arg === 'null'
|| (typeof arg !== 'object' && typeof arg !== 'string')) {
console.error("[Widget.appen... | [
"function",
"(",
")",
"{",
"var",
"i",
",",
"arg",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"arguments",
".",
"length",
";",
"i",
"++",
")",
"{",
"arg",
"=",
"arguments",
"[",
"i",
"]",
";",
"if",
"(",
"typeof",
"arg",
"===",
"'number'"... | Append children to this widget. | [
"Append",
"children",
"to",
"this",
"widget",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/wdg.js#L251-L294 | train | |
tolokoban/ToloFrameWork | ker/mod/wdg.js | function(parent) {
if (!parent) return this;
if (typeof parent.append === 'function') {
parent.append(this);
} else if (typeof parent.appendChild === 'function') {
parent.appendChild(this._element);
this.onAppend();
}
return this;
} | javascript | function(parent) {
if (!parent) return this;
if (typeof parent.append === 'function') {
parent.append(this);
} else if (typeof parent.appendChild === 'function') {
parent.appendChild(this._element);
this.onAppend();
}
return this;
} | [
"function",
"(",
"parent",
")",
"{",
"if",
"(",
"!",
"parent",
")",
"return",
"this",
";",
"if",
"(",
"typeof",
"parent",
".",
"append",
"===",
"'function'",
")",
"{",
"parent",
".",
"append",
"(",
"this",
")",
";",
"}",
"else",
"if",
"(",
"typeof"... | Append this widget to a parent.
@param parent
@memberof wdg | [
"Append",
"this",
"widget",
"to",
"a",
"parent",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/wdg.js#L301-L310 | train | |
tolokoban/ToloFrameWork | ker/mod/wdg.js | function() {
// (!) On préfère retirer les éléments un par un du DOM plutôt que d'utiliser simplement
// this.html("").
// En effet, le code simplifié a des conséquences inattendues dans IE9 et IE10 au moins.
// Le bug des markers qui disparaissaients sur les cartes de Trail-Passion 4 a été corrigé
... | javascript | function() {
// (!) On préfère retirer les éléments un par un du DOM plutôt que d'utiliser simplement
// this.html("").
// En effet, le code simplifié a des conséquences inattendues dans IE9 et IE10 au moins.
// Le bug des markers qui disparaissaients sur les cartes de Trail-Passion 4 a été corrigé
... | [
"function",
"(",
")",
"{",
"// (!) On préfère retirer les éléments un par un du DOM plutôt que d'utiliser simplement",
"// this.html(\"\").",
"// En effet, le code simplifié a des conséquences inattendues dans IE9 et IE10 au moins.",
"// Le bug des markers qui disparaissaients sur les cartes de Trail-... | Remove all children of this widget.
Any argument passed will be appended to this widget.
@memberof wdg | [
"Remove",
"all",
"children",
"of",
"this",
"widget",
".",
"Any",
"argument",
"passed",
"will",
"be",
"appended",
"to",
"this",
"widget",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/wdg.js#L384-L401 | train | |
tolokoban/ToloFrameWork | ker/mod/wdg.js | function() {
var e = this._element;
if (!e) return null;
if (typeof e.getBoundingClientRect !== 'function') {
console.error("[wdg.rect] This element has non `getBoundingClientRect` function:", e);
}
var r = e.getBoundingClientRect();
if( typeof r.width === 'undefined' ) r.width = r.right -... | javascript | function() {
var e = this._element;
if (!e) return null;
if (typeof e.getBoundingClientRect !== 'function') {
console.error("[wdg.rect] This element has non `getBoundingClientRect` function:", e);
}
var r = e.getBoundingClientRect();
if( typeof r.width === 'undefined' ) r.width = r.right -... | [
"function",
"(",
")",
"{",
"var",
"e",
"=",
"this",
".",
"_element",
";",
"if",
"(",
"!",
"e",
")",
"return",
"null",
";",
"if",
"(",
"typeof",
"e",
".",
"getBoundingClientRect",
"!==",
"'function'",
")",
"{",
"console",
".",
"error",
"(",
"\"[wdg.re... | Returns the bounds of the underlying element.
@memberof wdg | [
"Returns",
"the",
"bounds",
"of",
"the",
"underlying",
"element",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/wdg.js#L474-L484 | train | |
vmarkdown/vremark-parse | packages/mdast-util-to-hast/lib/revert.js | revert | function revert(h, node) {
var subtype = node.referenceType
var suffix = ']'
var contents
var head
var tail
if (subtype === 'collapsed') {
suffix += '[]'
} else if (subtype === 'full') {
suffix += '[' + node.identifier + ']'
}
if (node.type === 'imageReference') {
... | javascript | function revert(h, node) {
var subtype = node.referenceType
var suffix = ']'
var contents
var head
var tail
if (subtype === 'collapsed') {
suffix += '[]'
} else if (subtype === 'full') {
suffix += '[' + node.identifier + ']'
}
if (node.type === 'imageReference') {
... | [
"function",
"revert",
"(",
"h",
",",
"node",
")",
"{",
"var",
"subtype",
"=",
"node",
".",
"referenceType",
"var",
"suffix",
"=",
"']'",
"var",
"contents",
"var",
"head",
"var",
"tail",
"if",
"(",
"subtype",
"===",
"'collapsed'",
")",
"{",
"suffix",
"+... | Return the content of a reference without definition as markdown. | [
"Return",
"the",
"content",
"of",
"a",
"reference",
"without",
"definition",
"as",
"markdown",
"."
] | d7b353dcb5d021eeceb40f3c505ece893202db7a | https://github.com/vmarkdown/vremark-parse/blob/d7b353dcb5d021eeceb40f3c505ece893202db7a/packages/mdast-util-to-hast/lib/revert.js#L9-L44 | train |
straticjs/gulp-attach-to-template | index.js | function(callback) {
// TODO: don't wait until the end. Instead, emit immediately upon finding the template
if (!templateFile) throw new Error('template not found in stream');
templateFile.data = templateFile.data || {};
files.forEach(function(file) {
var newFile = templateFile.clone();
newFile.data.f... | javascript | function(callback) {
// TODO: don't wait until the end. Instead, emit immediately upon finding the template
if (!templateFile) throw new Error('template not found in stream');
templateFile.data = templateFile.data || {};
files.forEach(function(file) {
var newFile = templateFile.clone();
newFile.data.f... | [
"function",
"(",
"callback",
")",
"{",
"// TODO: don't wait until the end. Instead, emit immediately upon finding the template",
"if",
"(",
"!",
"templateFile",
")",
"throw",
"new",
"Error",
"(",
"'template not found in stream'",
")",
";",
"templateFile",
".",
"data",
"=",
... | Wait until all files have come through, then attach the non-template files | [
"Wait",
"until",
"all",
"files",
"have",
"come",
"through",
"then",
"attach",
"the",
"non",
"-",
"template",
"files"
] | 417309e94db8491a96fd4a52b483f4db7dcc1290 | https://github.com/straticjs/gulp-attach-to-template/blob/417309e94db8491a96fd4a52b483f4db7dcc1290/index.js#L39-L56 | train | |
finvernizzi/mplane_http_transport | mplane_http_transport.js | registerSpecification | function registerSpecification(specification, remoteDN , options , callback){
// Serialize the capability Object
var post_data = {};
post_data[remoteDN] = JSON.parse(specification.to_dict());
post_data = JSON.stringify(post_data);
var proto = https;
var post_options = {
path: SUPERVISOR... | javascript | function registerSpecification(specification, remoteDN , options , callback){
// Serialize the capability Object
var post_data = {};
post_data[remoteDN] = JSON.parse(specification.to_dict());
post_data = JSON.stringify(post_data);
var proto = https;
var post_options = {
path: SUPERVISOR... | [
"function",
"registerSpecification",
"(",
"specification",
",",
"remoteDN",
",",
"options",
",",
"callback",
")",
"{",
"// Serialize the capability Object",
"var",
"post_data",
"=",
"{",
"}",
";",
"post_data",
"[",
"remoteDN",
"]",
"=",
"JSON",
".",
"parse",
"("... | Register with a POST a specification to the supervisor
@param specification an mPlane Spcification
options MUST include (or an INVALID parameters error is thrown):
- options.host
- options.port
- options.caFile
- options.keyFile
- options.certFile | [
"Register",
"with",
"a",
"POST",
"a",
"specification",
"to",
"the",
"supervisor"
] | 1102d8e1458c3010f3b126b536434114c790b180 | https://github.com/finvernizzi/mplane_http_transport/blob/1102d8e1458c3010f3b126b536434114c790b180/mplane_http_transport.js#L191-L234 | train |
finvernizzi/mplane_http_transport | mplane_http_transport.js | showResults | function showResults(redeem , options , callback){
if (typeof redeem !== 'object')
redeem = new mplane.Redemption(redeem);
var post_data = redeem.to_dict();
var post_options = {
path: SUPERVISOR_PATH_SHOW_RESULT,
method: 'POST',
host: options.host,
port: options.p... | javascript | function showResults(redeem , options , callback){
if (typeof redeem !== 'object')
redeem = new mplane.Redemption(redeem);
var post_data = redeem.to_dict();
var post_options = {
path: SUPERVISOR_PATH_SHOW_RESULT,
method: 'POST',
host: options.host,
port: options.p... | [
"function",
"showResults",
"(",
"redeem",
",",
"options",
",",
"callback",
")",
"{",
"if",
"(",
"typeof",
"redeem",
"!==",
"'object'",
")",
"redeem",
"=",
"new",
"mplane",
".",
"Redemption",
"(",
"redeem",
")",
";",
"var",
"post_data",
"=",
"redeem",
"."... | Given a redeem, ask if results are ready
@param redeem
@param options
@param callback | [
"Given",
"a",
"redeem",
"ask",
"if",
"results",
"are",
"ready"
] | 1102d8e1458c3010f3b126b536434114c790b180 | https://github.com/finvernizzi/mplane_http_transport/blob/1102d8e1458c3010f3b126b536434114c790b180/mplane_http_transport.js#L294-L337 | train |
finvernizzi/mplane_http_transport | mplane_http_transport.js | showCapabilities | function showCapabilities( options, callback){
options.url = 'https://'+options.host+':'+options.port+SUPERVISOR_PATH_SHOW_CAPABILITY;
options.ca = ssl_files.readCaChain(options.caFile);
options.key = ssl_files.readFileContent(options.keyFile);
options.cert = ssl_files.readFileContent(options.certFile)... | javascript | function showCapabilities( options, callback){
options.url = 'https://'+options.host+':'+options.port+SUPERVISOR_PATH_SHOW_CAPABILITY;
options.ca = ssl_files.readCaChain(options.caFile);
options.key = ssl_files.readFileContent(options.keyFile);
options.cert = ssl_files.readFileContent(options.certFile)... | [
"function",
"showCapabilities",
"(",
"options",
",",
"callback",
")",
"{",
"options",
".",
"url",
"=",
"'https://'",
"+",
"options",
".",
"host",
"+",
"':'",
"+",
"options",
".",
"port",
"+",
"SUPERVISOR_PATH_SHOW_CAPABILITY",
";",
"options",
".",
"ca",
"=",... | Contact the supervisor for requesting all the registered capabilities
@param options
@param callback | [
"Contact",
"the",
"supervisor",
"for",
"requesting",
"all",
"the",
"registered",
"capabilities"
] | 1102d8e1458c3010f3b126b536434114c790b180 | https://github.com/finvernizzi/mplane_http_transport/blob/1102d8e1458c3010f3b126b536434114c790b180/mplane_http_transport.js#L344-L359 | train |
finvernizzi/mplane_http_transport | mplane_http_transport.js | info | function info(options , callback){
options.url = 'https://'+options.host+':'+options.port+SUPERVISOR_PATH_INFO;
options.key = ssl_files.readFileContent(options.keyFile);
options.cert = ssl_files.readFileContent(options.certFile);
options.ca = ssl_files.readCaChain(options.ca);
request(options, fun... | javascript | function info(options , callback){
options.url = 'https://'+options.host+':'+options.port+SUPERVISOR_PATH_INFO;
options.key = ssl_files.readFileContent(options.keyFile);
options.cert = ssl_files.readFileContent(options.certFile);
options.ca = ssl_files.readCaChain(options.ca);
request(options, fun... | [
"function",
"info",
"(",
"options",
",",
"callback",
")",
"{",
"options",
".",
"url",
"=",
"'https://'",
"+",
"options",
".",
"host",
"+",
"':'",
"+",
"options",
".",
"port",
"+",
"SUPERVISOR_PATH_INFO",
";",
"options",
".",
"key",
"=",
"ssl_files",
".",... | Reads supervisor informations | [
"Reads",
"supervisor",
"informations"
] | 1102d8e1458c3010f3b126b536434114c790b180 | https://github.com/finvernizzi/mplane_http_transport/blob/1102d8e1458c3010f3b126b536434114c790b180/mplane_http_transport.js#L362-L376 | train |
jedrichards/twitreq | lib/twitreq.js | genReq | function genReq (options,cb) {
log(options.verbose,"Starting twitreq ...");
if ( typeof options.protocol === "undefined" ) {
options.protocol = PROTOCOL;
}
if ( typeof options.host === "undefined" ) {
options.host = HOST;
}
if ( typeof options.oAuthSignatureMethod === "undefi... | javascript | function genReq (options,cb) {
log(options.verbose,"Starting twitreq ...");
if ( typeof options.protocol === "undefined" ) {
options.protocol = PROTOCOL;
}
if ( typeof options.host === "undefined" ) {
options.host = HOST;
}
if ( typeof options.oAuthSignatureMethod === "undefi... | [
"function",
"genReq",
"(",
"options",
",",
"cb",
")",
"{",
"log",
"(",
"options",
".",
"verbose",
",",
"\"Starting twitreq ...\"",
")",
";",
"if",
"(",
"typeof",
"options",
".",
"protocol",
"===",
"\"undefined\"",
")",
"{",
"options",
".",
"protocol",
"=",... | Generate a Node HTTP request options object based on a valid set of options. | [
"Generate",
"a",
"Node",
"HTTP",
"request",
"options",
"object",
"based",
"on",
"a",
"valid",
"set",
"of",
"options",
"."
] | 6d6a1702acc812b333401db7aba0aa003904b76b | https://github.com/jedrichards/twitreq/blob/6d6a1702acc812b333401db7aba0aa003904b76b/lib/twitreq.js#L47-L107 | train |
jedrichards/twitreq | lib/twitreq.js | genQueryString | function genQueryString (options) {
if ( !options.queryParams ) {
return "";
}
log(options.verbose,"Now generating query string value ...");
var queryStringParams = [];
Object.keys(options.queryParams).forEach(function (key) {
queryStringParams.push(createEncodedParam(key,options... | javascript | function genQueryString (options) {
if ( !options.queryParams ) {
return "";
}
log(options.verbose,"Now generating query string value ...");
var queryStringParams = [];
Object.keys(options.queryParams).forEach(function (key) {
queryStringParams.push(createEncodedParam(key,options... | [
"function",
"genQueryString",
"(",
"options",
")",
"{",
"if",
"(",
"!",
"options",
".",
"queryParams",
")",
"{",
"return",
"\"\"",
";",
"}",
"log",
"(",
"options",
".",
"verbose",
",",
"\"Now generating query string value ...\"",
")",
";",
"var",
"queryStringP... | Generate a percent encoded query string from the supplied options. | [
"Generate",
"a",
"percent",
"encoded",
"query",
"string",
"from",
"the",
"supplied",
"options",
"."
] | 6d6a1702acc812b333401db7aba0aa003904b76b | https://github.com/jedrichards/twitreq/blob/6d6a1702acc812b333401db7aba0aa003904b76b/lib/twitreq.js#L112-L141 | train |
jedrichards/twitreq | lib/twitreq.js | percentEncode | function percentEncode (value) {
var result = encodeURIComponent(value);
return result.replace(/\!/g, "%21")
.replace(/\'/g, "%27")
.replace(/\(/g, "%28")
.replace(/\)/g, "%29")
.replace(/\*/g, "%2A");
} | javascript | function percentEncode (value) {
var result = encodeURIComponent(value);
return result.replace(/\!/g, "%21")
.replace(/\'/g, "%27")
.replace(/\(/g, "%28")
.replace(/\)/g, "%29")
.replace(/\*/g, "%2A");
} | [
"function",
"percentEncode",
"(",
"value",
")",
"{",
"var",
"result",
"=",
"encodeURIComponent",
"(",
"value",
")",
";",
"return",
"result",
".",
"replace",
"(",
"/",
"\\!",
"/",
"g",
",",
"\"%21\"",
")",
".",
"replace",
"(",
"/",
"\\'",
"/",
"g",
",... | Return a RFC3986 compliant percent encoded string. | [
"Return",
"a",
"RFC3986",
"compliant",
"percent",
"encoded",
"string",
"."
] | 6d6a1702acc812b333401db7aba0aa003904b76b | https://github.com/jedrichards/twitreq/blob/6d6a1702acc812b333401db7aba0aa003904b76b/lib/twitreq.js#L267-L274 | train |
scrapjs/hmu-plugin | lib/index.js | error | function error(err) {
this.log(`${chalk.red(`${err.name.toLowerCase()}:`)} ${err.message}`);
} | javascript | function error(err) {
this.log(`${chalk.red(`${err.name.toLowerCase()}:`)} ${err.message}`);
} | [
"function",
"error",
"(",
"err",
")",
"{",
"this",
".",
"log",
"(",
"`",
"${",
"chalk",
".",
"red",
"(",
"`",
"${",
"err",
".",
"name",
".",
"toLowerCase",
"(",
")",
"}",
"`",
")",
"}",
"${",
"err",
".",
"message",
"}",
"`",
")",
";",
"}"
] | Log plugin error | [
"Log",
"plugin",
"error"
] | d96f71274646304ad158c9834ee210c7141a8099 | https://github.com/scrapjs/hmu-plugin/blob/d96f71274646304ad158c9834ee210c7141a8099/lib/index.js#L22-L24 | train |
scrapjs/hmu-plugin | lib/index.js | status | function status(url, code, mod) {
return this.get(url, mod).then(req => req.statusCode === code);
} | javascript | function status(url, code, mod) {
return this.get(url, mod).then(req => req.statusCode === code);
} | [
"function",
"status",
"(",
"url",
",",
"code",
",",
"mod",
")",
"{",
"return",
"this",
".",
"get",
"(",
"url",
",",
"mod",
")",
".",
"then",
"(",
"req",
"=>",
"req",
".",
"statusCode",
"===",
"code",
")",
";",
"}"
] | Fast status checking | [
"Fast",
"status",
"checking"
] | d96f71274646304ad158c9834ee210c7141a8099 | https://github.com/scrapjs/hmu-plugin/blob/d96f71274646304ad158c9834ee210c7141a8099/lib/index.js#L35-L37 | train |
squid-app/config | index.js | Config | function Config( defaults, extend, envName )
{
// Constants
// -------------
// test instance uniqueness
this._UID = _.uniqueId('config_')
this._DEFAULTENV = 'default'
// CORE's settings
// ------------------------
// default app configuration
var confDefault = this.getConfigParam( defau... | javascript | function Config( defaults, extend, envName )
{
// Constants
// -------------
// test instance uniqueness
this._UID = _.uniqueId('config_')
this._DEFAULTENV = 'default'
// CORE's settings
// ------------------------
// default app configuration
var confDefault = this.getConfigParam( defau... | [
"function",
"Config",
"(",
"defaults",
",",
"extend",
",",
"envName",
")",
"{",
"// Constants",
"// -------------",
"// test instance uniqueness",
"this",
".",
"_UID",
"=",
"_",
".",
"uniqueId",
"(",
"'config_'",
")",
"this",
".",
"_DEFAULTENV",
"=",
"'default'"... | Initialize Config Class @params {mixed} object or file path @params {mixed} object or file path @return {object} Config instance | [
"Initialize",
"Config",
"Class"
] | 476b589fb5d74b4093e6c3ebf0edcd8bfad16884 | https://github.com/squid-app/config/blob/476b589fb5d74b4093e6c3ebf0edcd8bfad16884/index.js#L24-L52 | train |
vesln/obsessed | lib/async-runner.js | AsyncRunner | function AsyncRunner(times, fn) {
Runner.apply(this, arguments);
this.pause = 0;
this.end = noop;
this.times = times;
} | javascript | function AsyncRunner(times, fn) {
Runner.apply(this, arguments);
this.pause = 0;
this.end = noop;
this.times = times;
} | [
"function",
"AsyncRunner",
"(",
"times",
",",
"fn",
")",
"{",
"Runner",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"this",
".",
"pause",
"=",
"0",
";",
"this",
".",
"end",
"=",
"noop",
";",
"this",
".",
"times",
"=",
"times",
";",
"}"... | Async task runner.
@param {String|Number} times
@param {Function} [optional] task to execute
@constructor | [
"Async",
"task",
"runner",
"."
] | 4878dfafdea241bff9ad5c57acc2395a4f3487a6 | https://github.com/vesln/obsessed/blob/4878dfafdea241bff9ad5c57acc2395a4f3487a6/lib/async-runner.js#L22-L28 | train |
tab58/minimatrix | src/utils.js | printMatrix2 | function printMatrix2 (m) {
const tStr = m.elements.map(formatPrintNumber);
const matrixString = `
+- -+
| ${tStr[0]} ${tStr[2]} |
| ${tStr[1]} ${tStr[3]} |
+- -+`;
return matrixString;
} | javascript | function printMatrix2 (m) {
const tStr = m.elements.map(formatPrintNumber);
const matrixString = `
+- -+
| ${tStr[0]} ${tStr[2]} |
| ${tStr[1]} ${tStr[3]} |
+- -+`;
return matrixString;
} | [
"function",
"printMatrix2",
"(",
"m",
")",
"{",
"const",
"tStr",
"=",
"m",
".",
"elements",
".",
"map",
"(",
"formatPrintNumber",
")",
";",
"const",
"matrixString",
"=",
"`",
"${",
"tStr",
"[",
"0",
"]",
"}",
"${",
"tStr",
"[",
"2",
"]",
"}",
"${",... | Pretty prints a Matrix2.
@memberof Utils
@param {Matrix2} m The 2x2 matrix.
@returns {string} The formatted string. | [
"Pretty",
"prints",
"a",
"Matrix2",
"."
] | 542f1d964b7ae92f96b1069ff5f3495561fe75cd | https://github.com/tab58/minimatrix/blob/542f1d964b7ae92f96b1069ff5f3495561fe75cd/src/utils.js#L47-L55 | train |
tab58/minimatrix | src/utils.js | printMatrix3 | function printMatrix3 (m) {
const tStr = m.elements.map(formatPrintNumber);
const matrixString = `
+- -+
| ${tStr[0]} ${tStr[3]} ${tStr[6]} |
| ${tStr[1]} ${tStr[4]} ${tStr[7]} |
| ${tStr[2]} ${tStr[5]} ${tStr[8]} |
+- -+`;
return matrixString;
} | javascript | function printMatrix3 (m) {
const tStr = m.elements.map(formatPrintNumber);
const matrixString = `
+- -+
| ${tStr[0]} ${tStr[3]} ${tStr[6]} |
| ${tStr[1]} ${tStr[4]} ${tStr[7]} |
| ${tStr[2]} ${tStr[5]} ${tStr[8]} |
+- -+`;
return matrixString;
} | [
"function",
"printMatrix3",
"(",
"m",
")",
"{",
"const",
"tStr",
"=",
"m",
".",
"elements",
".",
"map",
"(",
"formatPrintNumber",
")",
";",
"const",
"matrixString",
"=",
"`",
"${",
"tStr",
"[",
"0",
"]",
"}",
"${",
"tStr",
"[",
"3",
"]",
"}",
"${",... | Pretty prints a Matrix3.
@memberof Utils
@param {Matrix2} m The 3x3 matrix.
@returns {string} The formatted string. | [
"Pretty",
"prints",
"a",
"Matrix3",
"."
] | 542f1d964b7ae92f96b1069ff5f3495561fe75cd | https://github.com/tab58/minimatrix/blob/542f1d964b7ae92f96b1069ff5f3495561fe75cd/src/utils.js#L63-L72 | train |
benoror/node-pate | lib/pate.js | xpathFn | function xpathFn(token, rootEl, ns) {
var split = token.trim().split('@');
var retVal = rootEl;
var path = split[0].replace(/\/$/, "") || null;
var attr = split[1] || null;
if(path)
retVal = retVal.get(path, ns);
if(attr) {
retVal = retVal ? retVal.attr(attr) : "";
ret... | javascript | function xpathFn(token, rootEl, ns) {
var split = token.trim().split('@');
var retVal = rootEl;
var path = split[0].replace(/\/$/, "") || null;
var attr = split[1] || null;
if(path)
retVal = retVal.get(path, ns);
if(attr) {
retVal = retVal ? retVal.attr(attr) : "";
ret... | [
"function",
"xpathFn",
"(",
"token",
",",
"rootEl",
",",
"ns",
")",
"{",
"var",
"split",
"=",
"token",
".",
"trim",
"(",
")",
".",
"split",
"(",
"'@'",
")",
";",
"var",
"retVal",
"=",
"rootEl",
";",
"var",
"path",
"=",
"split",
"[",
"0",
"]",
"... | XPatch matcher function | [
"XPatch",
"matcher",
"function"
] | 869a6e82f588563d5dea6c892cb011505bba7ed3 | https://github.com/benoror/node-pate/blob/869a6e82f588563d5dea6c892cb011505bba7ed3/lib/pate.js#L46-L64 | train |
benoror/node-pate | lib/pate.js | evalFn | function evalFn(token, format_lib) {
var splited = token.trim().split(/[\(\)]/g);
if (splited.length < 3)
return token;
if (!format_lib)
return token
var fnstring = splited[0];
var fnparams = splited.slice(1, splited.length - 1);
var fn = format_lib[fnstring];
if (typeof ... | javascript | function evalFn(token, format_lib) {
var splited = token.trim().split(/[\(\)]/g);
if (splited.length < 3)
return token;
if (!format_lib)
return token
var fnstring = splited[0];
var fnparams = splited.slice(1, splited.length - 1);
var fn = format_lib[fnstring];
if (typeof ... | [
"function",
"evalFn",
"(",
"token",
",",
"format_lib",
")",
"{",
"var",
"splited",
"=",
"token",
".",
"trim",
"(",
")",
".",
"split",
"(",
"/",
"[\\(\\)]",
"/",
"g",
")",
";",
"if",
"(",
"splited",
".",
"length",
"<",
"3",
")",
"return",
"token",
... | Eval matcher function | [
"Eval",
"matcher",
"function"
] | 869a6e82f588563d5dea6c892cb011505bba7ed3 | https://github.com/benoror/node-pate/blob/869a6e82f588563d5dea6c892cb011505bba7ed3/lib/pate.js#L69-L86 | train |
RikardLegge/modulin-fetch | src/modulin/css/modulizeCss.js | generateClassNameSubstitutions | function generateClassNameSubstitutions(tokens, substitutionPattern, substitutions) {
tokens.forEach((tokenList)=> {
var token = tokenList[0];
generateSubstitution(token, substitutionPattern, substitutions);
});
} | javascript | function generateClassNameSubstitutions(tokens, substitutionPattern, substitutions) {
tokens.forEach((tokenList)=> {
var token = tokenList[0];
generateSubstitution(token, substitutionPattern, substitutions);
});
} | [
"function",
"generateClassNameSubstitutions",
"(",
"tokens",
",",
"substitutionPattern",
",",
"substitutions",
")",
"{",
"tokens",
".",
"forEach",
"(",
"(",
"tokenList",
")",
"=>",
"{",
"var",
"token",
"=",
"tokenList",
"[",
"0",
"]",
";",
"generateSubstitution"... | Generate an array of substitutions keyed by class name
@param tokens Token[]
@param substitutionPattern string
@param substitutions {{string: string[]}}
@returns {{string: string}} | [
"Generate",
"an",
"array",
"of",
"substitutions",
"keyed",
"by",
"class",
"name"
] | 1a31b6b6957cfc7f608e233f10ac5050cd15bb5f | https://github.com/RikardLegge/modulin-fetch/blob/1a31b6b6957cfc7f608e233f10ac5050cd15bb5f/src/modulin/css/modulizeCss.js#L111-L116 | train |
RikardLegge/modulin-fetch | src/modulin/css/modulizeCss.js | generateSubstitution | function generateSubstitution(token, substitutionPattern, substitutions) {
var substitution = substitutionPattern.replace(/{([^}]+)}/ig, (all, group)=> {
switch (group) {
case 'namespace':
return token.namespace;
case 'name':
return token.className;
case 'random':
return ... | javascript | function generateSubstitution(token, substitutionPattern, substitutions) {
var substitution = substitutionPattern.replace(/{([^}]+)}/ig, (all, group)=> {
switch (group) {
case 'namespace':
return token.namespace;
case 'name':
return token.className;
case 'random':
return ... | [
"function",
"generateSubstitution",
"(",
"token",
",",
"substitutionPattern",
",",
"substitutions",
")",
"{",
"var",
"substitution",
"=",
"substitutionPattern",
".",
"replace",
"(",
"/",
"{([^}]+)}",
"/",
"ig",
",",
"(",
"all",
",",
"group",
")",
"=>",
"{",
... | Generate a substitution for the class or id selector
@param token Token
@param substitutionPattern string
@param substitutions {{string: string[]}}
@returns {string} | [
"Generate",
"a",
"substitution",
"for",
"the",
"class",
"or",
"id",
"selector"
] | 1a31b6b6957cfc7f608e233f10ac5050cd15bb5f | https://github.com/RikardLegge/modulin-fetch/blob/1a31b6b6957cfc7f608e233f10ac5050cd15bb5f/src/modulin/css/modulizeCss.js#L126-L145 | train |
dpjanes/iotdb-errors | errors.js | Timestamp | function Timestamp(message, code_id) {
Error.call(this);
this.message = message || "timestamp out of date";
this.code_id = code_id || null;
this.statusCode = 409;
} | javascript | function Timestamp(message, code_id) {
Error.call(this);
this.message = message || "timestamp out of date";
this.code_id = code_id || null;
this.statusCode = 409;
} | [
"function",
"Timestamp",
"(",
"message",
",",
"code_id",
")",
"{",
"Error",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"message",
"=",
"message",
"||",
"\"timestamp out of date\"",
";",
"this",
".",
"code_id",
"=",
"code_id",
"||",
"null",
";",
"th... | Timestanp was out of date | [
"Timestanp",
"was",
"out",
"of",
"date"
] | 15abf13b7666c4afc505b365bcf562cb85c44f84 | https://github.com/dpjanes/iotdb-errors/blob/15abf13b7666c4afc505b365bcf562cb85c44f84/errors.js#L73-L78 | train |
dpjanes/iotdb-errors | errors.js | NotReady | function NotReady(message, code_id) {
Error.call(this);
this.message = message || "resource is not ready yet";
this.code_id = code_id || null;
this.statusCode = 423;
} | javascript | function NotReady(message, code_id) {
Error.call(this);
this.message = message || "resource is not ready yet";
this.code_id = code_id || null;
this.statusCode = 423;
} | [
"function",
"NotReady",
"(",
"message",
",",
"code_id",
")",
"{",
"Error",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"message",
"=",
"message",
"||",
"\"resource is not ready yet\"",
";",
"this",
".",
"code_id",
"=",
"code_id",
"||",
"null",
";",
... | waiting for some processing to happen | [
"waiting",
"for",
"some",
"processing",
"to",
"happen"
] | 15abf13b7666c4afc505b365bcf562cb85c44f84 | https://github.com/dpjanes/iotdb-errors/blob/15abf13b7666c4afc505b365bcf562cb85c44f84/errors.js#L121-L126 | train |
dpjanes/iotdb-errors | errors.js | Locked | function Locked(message, code_id) {
Error.call(this);
this.message = message || "resource is locked"
this.code_id = code_id || null;
this.statusCode = 423;
} | javascript | function Locked(message, code_id) {
Error.call(this);
this.message = message || "resource is locked"
this.code_id = code_id || null;
this.statusCode = 423;
} | [
"function",
"Locked",
"(",
"message",
",",
"code_id",
")",
"{",
"Error",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"message",
"=",
"message",
"||",
"\"resource is locked\"",
"this",
".",
"code_id",
"=",
"code_id",
"||",
"null",
";",
"this",
".",
... | Resource is Locked | [
"Resource",
"is",
"Locked"
] | 15abf13b7666c4afc505b365bcf562cb85c44f84 | https://github.com/dpjanes/iotdb-errors/blob/15abf13b7666c4afc505b365bcf562cb85c44f84/errors.js#L133-L138 | train |
dpjanes/iotdb-errors | errors.js | NeverImplemented | function NeverImplemented(message, code_id) {
Error.call(this);
this.message = message || "never will be implemented";
this.code_id = code_id || null;
this.statusCode = 501;
} | javascript | function NeverImplemented(message, code_id) {
Error.call(this);
this.message = message || "never will be implemented";
this.code_id = code_id || null;
this.statusCode = 501;
} | [
"function",
"NeverImplemented",
"(",
"message",
",",
"code_id",
")",
"{",
"Error",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"message",
"=",
"message",
"||",
"\"never will be implemented\"",
";",
"this",
".",
"code_id",
"=",
"code_id",
"||",
"null",
... | This is not implemented and never will be implemented | [
"This",
"is",
"not",
"implemented",
"and",
"never",
"will",
"be",
"implemented"
] | 15abf13b7666c4afc505b365bcf562cb85c44f84 | https://github.com/dpjanes/iotdb-errors/blob/15abf13b7666c4afc505b365bcf562cb85c44f84/errors.js#L181-L186 | train |
dpjanes/iotdb-errors | errors.js | SetupRequired | function SetupRequired(message, code_id) {
Error.call(this);
this.message = message || "setup required";
this.code_id = code_id || null;
this.statusCode = 500;
} | javascript | function SetupRequired(message, code_id) {
Error.call(this);
this.message = message || "setup required";
this.code_id = code_id || null;
this.statusCode = 500;
} | [
"function",
"SetupRequired",
"(",
"message",
",",
"code_id",
")",
"{",
"Error",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"message",
"=",
"message",
"||",
"\"setup required\"",
";",
"this",
".",
"code_id",
"=",
"code_id",
"||",
"null",
";",
"this"... | Additional setup is required | [
"Additional",
"setup",
"is",
"required"
] | 15abf13b7666c4afc505b365bcf562cb85c44f84 | https://github.com/dpjanes/iotdb-errors/blob/15abf13b7666c4afc505b365bcf562cb85c44f84/errors.js#L193-L198 | train |
dpjanes/iotdb-errors | errors.js | Internal | function Internal(message, code_id) {
Error.call(this);
this.message = message || "internal error";
this.code_id = code_id || null;
this.statusCode = 500;
} | javascript | function Internal(message, code_id) {
Error.call(this);
this.message = message || "internal error";
this.code_id = code_id || null;
this.statusCode = 500;
} | [
"function",
"Internal",
"(",
"message",
",",
"code_id",
")",
"{",
"Error",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"message",
"=",
"message",
"||",
"\"internal error\"",
";",
"this",
".",
"code_id",
"=",
"code_id",
"||",
"null",
";",
"this",
"... | Some sort of internal error | [
"Some",
"sort",
"of",
"internal",
"error"
] | 15abf13b7666c4afc505b365bcf562cb85c44f84 | https://github.com/dpjanes/iotdb-errors/blob/15abf13b7666c4afc505b365bcf562cb85c44f84/errors.js#L205-L210 | train |
dpjanes/iotdb-errors | errors.js | Unavailable | function Unavailable(message, code_id) {
Error.call(this);
this.message = message || "temporarily unavailable";
this.code_id = code_id || null;
this.statusCode = 503;
} | javascript | function Unavailable(message, code_id) {
Error.call(this);
this.message = message || "temporarily unavailable";
this.code_id = code_id || null;
this.statusCode = 503;
} | [
"function",
"Unavailable",
"(",
"message",
",",
"code_id",
")",
"{",
"Error",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"message",
"=",
"message",
"||",
"\"temporarily unavailable\"",
";",
"this",
".",
"code_id",
"=",
"code_id",
"||",
"null",
";",
... | Can't do this right now | [
"Can",
"t",
"do",
"this",
"right",
"now"
] | 15abf13b7666c4afc505b365bcf562cb85c44f84 | https://github.com/dpjanes/iotdb-errors/blob/15abf13b7666c4afc505b365bcf562cb85c44f84/errors.js#L217-L222 | train |
angelini/lozigo | lib/lozigo.js | function() {
var that = this;
var boundEmitComplete = emitComplete.bind(this);
EventEmitter.call(this);
this.middleware = [];
this.server = net.createServer(function(conn) {
var buffer = '';
var info = null;
conn.on('data', function(data) {
buffer += data;
if(!info) {
if(... | javascript | function() {
var that = this;
var boundEmitComplete = emitComplete.bind(this);
EventEmitter.call(this);
this.middleware = [];
this.server = net.createServer(function(conn) {
var buffer = '';
var info = null;
conn.on('data', function(data) {
buffer += data;
if(!info) {
if(... | [
"function",
"(",
")",
"{",
"var",
"that",
"=",
"this",
";",
"var",
"boundEmitComplete",
"=",
"emitComplete",
".",
"bind",
"(",
"this",
")",
";",
"EventEmitter",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"middleware",
"=",
"[",
"]",
";",
"this"... | Main Lozigo Object | [
"Main",
"Lozigo",
"Object"
] | bcca0cda8a7786493def08fd7189b1edb07091f9 | https://github.com/angelini/lozigo/blob/bcca0cda8a7786493def08fd7189b1edb07091f9/lib/lozigo.js#L55-L96 | train | |
nbrownus/ppunit | lib/reporters/XUnit.js | function (ppunit, writer) {
writer.useColors = false
BaseReporter.call(this, ppunit, writer)
var self = this
ppunit.on('finish', function () {
writer.write(
self.tag(
'testsuite'
, {
name: 'PPUnit Tests'
, tests: ... | javascript | function (ppunit, writer) {
writer.useColors = false
BaseReporter.call(this, ppunit, writer)
var self = this
ppunit.on('finish', function () {
writer.write(
self.tag(
'testsuite'
, {
name: 'PPUnit Tests'
, tests: ... | [
"function",
"(",
"ppunit",
",",
"writer",
")",
"{",
"writer",
".",
"useColors",
"=",
"false",
"BaseReporter",
".",
"call",
"(",
"this",
",",
"ppunit",
",",
"writer",
")",
"var",
"self",
"=",
"this",
"ppunit",
".",
"on",
"(",
"'finish'",
",",
"function"... | Outputs xunit compatible xml for reporting test stats
@extends BaseReporter | [
"Outputs",
"xunit",
"compatible",
"xml",
"for",
"reporting",
"test",
"stats"
] | dcce602497d9548ce9085a8db115e65561dcc3de | https://github.com/nbrownus/ppunit/blob/dcce602497d9548ce9085a8db115e65561dcc3de/lib/reporters/XUnit.js#L11-L44 | train | |
Crafity/crafity-storage | lib/providers/CouchDB.Provider.js | CouchDB | function CouchDB(config, nano) {
if (!config) {
throw new Error("Expected a CouchDB configuration");
}
if (!config.url) {
throw new Error("Expected a url in the CouchDB configuration");
}
if (!config.database) {
throw new Error("Expected a database name in the CouchDB configuration");
}
if (!config.design... | javascript | function CouchDB(config, nano) {
if (!config) {
throw new Error("Expected a CouchDB configuration");
}
if (!config.url) {
throw new Error("Expected a url in the CouchDB configuration");
}
if (!config.database) {
throw new Error("Expected a database name in the CouchDB configuration");
}
if (!config.design... | [
"function",
"CouchDB",
"(",
"config",
",",
"nano",
")",
"{",
"if",
"(",
"!",
"config",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"Expected a CouchDB configuration\"",
")",
";",
"}",
"if",
"(",
"!",
"config",
".",
"url",
")",
"{",
"throw",
"new",
"Error... | CouchDB Provider Constructor
@constructor | [
"CouchDB",
"Provider",
"Constructor"
] | 1bea8268bc3deb85f9b07c63ce9ab3c5b989efe0 | https://github.com/Crafity/crafity-storage/blob/1bea8268bc3deb85f9b07c63ce9ab3c5b989efe0/lib/providers/CouchDB.Provider.js#L23-L54 | train |
panezhang/ejs-extension-plus | lib/loader/ScriptLoader.class.js | function (path) {
var foundPath = self.PathTool.findLibScript(path);
if (foundPath) {
self.scriptList.push(foundPath);
} else {
self.logger.warn('script:%s not found!', path);
}
} | javascript | function (path) {
var foundPath = self.PathTool.findLibScript(path);
if (foundPath) {
self.scriptList.push(foundPath);
} else {
self.logger.warn('script:%s not found!', path);
}
} | [
"function",
"(",
"path",
")",
"{",
"var",
"foundPath",
"=",
"self",
".",
"PathTool",
".",
"findLibScript",
"(",
"path",
")",
";",
"if",
"(",
"foundPath",
")",
"{",
"self",
".",
"scriptList",
".",
"push",
"(",
"foundPath",
")",
";",
"}",
"else",
"{",
... | path to the static dir or id | [
"path",
"to",
"the",
"static",
"dir",
"or",
"id"
] | 802cfc643eb1a42d6341ef2fa7c3a91efc64a16e | https://github.com/panezhang/ejs-extension-plus/blob/802cfc643eb1a42d6341ef2fa7c3a91efc64a16e/lib/loader/ScriptLoader.class.js#L40-L47 | train | |
tauren/arrayize | index.js | arrayize | function arrayize(values) {
// return empty array if values is empty
if (typeof values === 'undefined' || values === null ) {
return [];
}
// return array of values, converting to array if necessary
return util.isArray(values) ? values : [values];
} | javascript | function arrayize(values) {
// return empty array if values is empty
if (typeof values === 'undefined' || values === null ) {
return [];
}
// return array of values, converting to array if necessary
return util.isArray(values) ? values : [values];
} | [
"function",
"arrayize",
"(",
"values",
")",
"{",
"// return empty array if values is empty",
"if",
"(",
"typeof",
"values",
"===",
"'undefined'",
"||",
"values",
"===",
"null",
")",
"{",
"return",
"[",
"]",
";",
"}",
"// return array of values, converting to array if ... | Make sure to always return an array. If passed undefined or null,
return an empty array. If an array is passed, then return the
array. If passed anything else, return an array containing
that value.
@param {*} values Array of values or a single value
@return {Array} Array of values | [
"Make",
"sure",
"to",
"always",
"return",
"an",
"array",
".",
"If",
"passed",
"undefined",
"or",
"null",
"return",
"an",
"empty",
"array",
".",
"If",
"an",
"array",
"is",
"passed",
"then",
"return",
"the",
"array",
".",
"If",
"passed",
"anything",
"else"... | f5c08bee330ffa011b18e13adbecc80d2112af33 | https://github.com/tauren/arrayize/blob/f5c08bee330ffa011b18e13adbecc80d2112af33/index.js#L14-L21 | train |
terminalvelocity/sails-generate-seeds-backend | lib/before.js | function() {
// Combine random and case-specific factors into a base string
var factors = {
creationDate: (new Date()).getTime(),
random: Math.random() * (Math.random() * 1000),
nodeVersion: process.version
};
var basestring = '';
_.each(factors, function (val) {
basestring += val;
});
//... | javascript | function() {
// Combine random and case-specific factors into a base string
var factors = {
creationDate: (new Date()).getTime(),
random: Math.random() * (Math.random() * 1000),
nodeVersion: process.version
};
var basestring = '';
_.each(factors, function (val) {
basestring += val;
});
//... | [
"function",
"(",
")",
"{",
"// Combine random and case-specific factors into a base string",
"var",
"factors",
"=",
"{",
"creationDate",
":",
"(",
"new",
"Date",
"(",
")",
")",
".",
"getTime",
"(",
")",
",",
"random",
":",
"Math",
".",
"random",
"(",
")",
"*... | Generate session secret
@return {[type]} [description] | [
"Generate",
"session",
"secret"
] | 9197acae0328163e0caba5ab2b61e38102c03193 | https://github.com/terminalvelocity/sails-generate-seeds-backend/blob/9197acae0328163e0caba5ab2b61e38102c03193/lib/before.js#L16-L35 | train | |
sinfo/ampersand-io-collection | ampersand-io-collection.js | function (id, options, cb) {
if (arguments.length !== 3) {
cb = options;
options = {};
}
var self = this;
var model = this.get(id);
if (model){
return cb(null, model);
}
function done() {
var model = self.get(id);
if (model) {
if (cb){
cb(null,... | javascript | function (id, options, cb) {
if (arguments.length !== 3) {
cb = options;
options = {};
}
var self = this;
var model = this.get(id);
if (model){
return cb(null, model);
}
function done() {
var model = self.get(id);
if (model) {
if (cb){
cb(null,... | [
"function",
"(",
"id",
",",
"options",
",",
"cb",
")",
"{",
"if",
"(",
"arguments",
".",
"length",
"!==",
"3",
")",
"{",
"cb",
"=",
"options",
";",
"options",
"=",
"{",
"}",
";",
"}",
"var",
"self",
"=",
"this",
";",
"var",
"model",
"=",
"this"... | Get or fetch a model by Id. | [
"Get",
"or",
"fetch",
"a",
"model",
"by",
"Id",
"."
] | 81cd1ce246e5a84fe7ba881e8fa441e2f5cbbd67 | https://github.com/sinfo/ampersand-io-collection/blob/81cd1ce246e5a84fe7ba881e8fa441e2f5cbbd67/ampersand-io-collection.js#L106-L133 | train | |
sinfo/ampersand-io-collection | ampersand-io-collection.js | function(err, model, response, options){
if (options.cb){
options.cb(err, model, response);
}
if (err){
model.trigger('error', err, model, options);
}
} | javascript | function(err, model, response, options){
if (options.cb){
options.cb(err, model, response);
}
if (err){
model.trigger('error', err, model, options);
}
} | [
"function",
"(",
"err",
",",
"model",
",",
"response",
",",
"options",
")",
"{",
"if",
"(",
"options",
".",
"cb",
")",
"{",
"options",
".",
"cb",
"(",
"err",
",",
"model",
",",
"response",
")",
";",
"}",
"if",
"(",
"err",
")",
"{",
"model",
"."... | Aux func used to trigger errors if they exist and use the optional callback function if given | [
"Aux",
"func",
"used",
"to",
"trigger",
"errors",
"if",
"they",
"exist",
"and",
"use",
"the",
"optional",
"callback",
"function",
"if",
"given"
] | 81cd1ce246e5a84fe7ba881e8fa441e2f5cbbd67 | https://github.com/sinfo/ampersand-io-collection/blob/81cd1ce246e5a84fe7ba881e8fa441e2f5cbbd67/ampersand-io-collection.js#L163-L170 | train | |
el2iot2/grunt-hogan | example/Gruntfile.js | function(fileName) {
//Grab the path package here locally for clarity
var _path = require('path');
//'yada/yada/multi1.html' -> 'multi1'
var name = _path
.basename(
fileName,
_path.extname(fileName));
... | javascript | function(fileName) {
//Grab the path package here locally for clarity
var _path = require('path');
//'yada/yada/multi1.html' -> 'multi1'
var name = _path
.basename(
fileName,
_path.extname(fileName));
... | [
"function",
"(",
"fileName",
")",
"{",
"//Grab the path package here locally for clarity",
"var",
"_path",
"=",
"require",
"(",
"'path'",
")",
";",
"//'yada/yada/multi1.html' -> 'multi1'",
"var",
"name",
"=",
"_path",
".",
"basename",
"(",
"fileName",
",",
"_path",
... | Specify a custom name function | [
"Specify",
"a",
"custom",
"name",
"function"
] | 47962b7f63593c61fa0e2b0158f10bc6f8d51ca8 | https://github.com/el2iot2/grunt-hogan/blob/47962b7f63593c61fa0e2b0158f10bc6f8d51ca8/example/Gruntfile.js#L64-L76 | train | |
joneit/synonomous | index.js | function(name, transformations) {
var synonyms = [];
if (typeof name === 'string' && name) {
transformations = transformations || this.transformations;
if (!Array.isArray(transformations)) {
transformations = Object.keys(transformations);
}
... | javascript | function(name, transformations) {
var synonyms = [];
if (typeof name === 'string' && name) {
transformations = transformations || this.transformations;
if (!Array.isArray(transformations)) {
transformations = Object.keys(transformations);
}
... | [
"function",
"(",
"name",
",",
"transformations",
")",
"{",
"var",
"synonyms",
"=",
"[",
"]",
";",
"if",
"(",
"typeof",
"name",
"===",
"'string'",
"&&",
"name",
")",
"{",
"transformations",
"=",
"transformations",
"||",
"this",
".",
"transformations",
";",
... | default for all instances, settable by Synonomous.prototype.dictPath setter
If `name` is a string and non-blank, returns an array containing unique non-blank synonyms of `name` generated by the transformer functions named in `this.transformations`.
@param {string} name - String to make synonyms of.
@parma {string[]|ob... | [
"default",
"for",
"all",
"instances",
"settable",
"by",
"Synonomous",
".",
"prototype",
".",
"dictPath",
"setter",
"If",
"name",
"is",
"a",
"string",
"and",
"non",
"-",
"blank",
"returns",
"an",
"array",
"containing",
"unique",
"non",
"-",
"blank",
"synonyms... | 38e1a540ef796050fa32ad4c229820d729648d1c | https://github.com/joneit/synonomous/blob/38e1a540ef796050fa32ad4c229820d729648d1c/index.js#L113-L131 | train | |
sintaxi/yonder | lib/yonder.js | function(req, rsp, cb){
fs.readFile(path.resolve(routerPath), function(err, buff){
if (buff) {
var arrs = buff2arrs(buff)
return cb(arrs)
} else {
return cb(null)
}
})
} | javascript | function(req, rsp, cb){
fs.readFile(path.resolve(routerPath), function(err, buff){
if (buff) {
var arrs = buff2arrs(buff)
return cb(arrs)
} else {
return cb(null)
}
})
} | [
"function",
"(",
"req",
",",
"rsp",
",",
"cb",
")",
"{",
"fs",
".",
"readFile",
"(",
"path",
".",
"resolve",
"(",
"routerPath",
")",
",",
"function",
"(",
"err",
",",
"buff",
")",
"{",
"if",
"(",
"buff",
")",
"{",
"var",
"arrs",
"=",
"buff2arrs",... | returns array of routes. | [
"returns",
"array",
"of",
"routes",
"."
] | 6f50b36bf17cc348672089ecc71ad0f8d3f33698 | https://github.com/sintaxi/yonder/blob/6f50b36bf17cc348672089ecc71ad0f8d3f33698/lib/yonder.js#L119-L128 | train | |
byron-dupreez/aws-stream-consumer-core | batch.js | discardIfOverAttempted | function discardIfOverAttempted(tasksByName, count) {
if (tasksByName) {
taskUtils.getTasks(tasksByName).forEach(task => {
const n = task.discardIfOverAttempted(maxNumberOfAttempts, true);
if (count) overAttempted += n;
});
}
} | javascript | function discardIfOverAttempted(tasksByName, count) {
if (tasksByName) {
taskUtils.getTasks(tasksByName).forEach(task => {
const n = task.discardIfOverAttempted(maxNumberOfAttempts, true);
if (count) overAttempted += n;
});
}
} | [
"function",
"discardIfOverAttempted",
"(",
"tasksByName",
",",
"count",
")",
"{",
"if",
"(",
"tasksByName",
")",
"{",
"taskUtils",
".",
"getTasks",
"(",
"tasksByName",
")",
".",
"forEach",
"(",
"task",
"=>",
"{",
"const",
"n",
"=",
"task",
".",
"discardIfO... | Mark any over-attempted tasks as discarded | [
"Mark",
"any",
"over",
"-",
"attempted",
"tasks",
"as",
"discarded"
] | 9b256084297f80d373bcf483aaf68a9da176b3d7 | https://github.com/byron-dupreez/aws-stream-consumer-core/blob/9b256084297f80d373bcf483aaf68a9da176b3d7/batch.js#L683-L690 | train |
nateGeorge/google-ims | index.js | Client | function Client (id, apiKey) {
if (!(this instanceof Client)) {
return new Client(id, apiKey);
}
this.endpoint = 'https://www.googleapis.com';
this.apiKey = apiKey;
this.id = id;
} | javascript | function Client (id, apiKey) {
if (!(this instanceof Client)) {
return new Client(id, apiKey);
}
this.endpoint = 'https://www.googleapis.com';
this.apiKey = apiKey;
this.id = id;
} | [
"function",
"Client",
"(",
"id",
",",
"apiKey",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Client",
")",
")",
"{",
"return",
"new",
"Client",
"(",
"id",
",",
"apiKey",
")",
";",
"}",
"this",
".",
"endpoint",
"=",
"'https://www.googleapis.com... | Google Images Client | [
"Google",
"Images",
"Client"
] | 60df00899a45c2b06fcd1e7767025aa1d252f420 | https://github.com/nateGeorge/google-ims/blob/60df00899a45c2b06fcd1e7767025aa1d252f420/index.js#L14-L22 | train |
sendanor/nor-ref | src/ref.js | is_https | function is_https(req) {
if(req.headers && req.headers['x-forwarded-proto'] && req.headers['x-forwarded-proto'] === 'https') { return true; }
return (req && req.connection && req.connection.encrypted) ? true : false;
} | javascript | function is_https(req) {
if(req.headers && req.headers['x-forwarded-proto'] && req.headers['x-forwarded-proto'] === 'https') { return true; }
return (req && req.connection && req.connection.encrypted) ? true : false;
} | [
"function",
"is_https",
"(",
"req",
")",
"{",
"if",
"(",
"req",
".",
"headers",
"&&",
"req",
".",
"headers",
"[",
"'x-forwarded-proto'",
"]",
"&&",
"req",
".",
"headers",
"[",
"'x-forwarded-proto'",
"]",
"===",
"'https'",
")",
"{",
"return",
"true",
";",... | Check if connection is HTTPS | [
"Check",
"if",
"connection",
"is",
"HTTPS"
] | 879667125e12317f63f99fea0344eb9dc298fdeb | https://github.com/sendanor/nor-ref/blob/879667125e12317f63f99fea0344eb9dc298fdeb/src/ref.js#L10-L13 | train |
jcare44/node-logmatic | src/logmatic.js | function(message) {
if (!_.isObject(message)) {
message = {
message: message
};
}
try {
message = JSON.stringify(_.defaultsDeep({}, message, this.config.defaultProps));
} catch (e) {
return this.logger.error('Logmatic - error while parsing log message. Not sending', e);
... | javascript | function(message) {
if (!_.isObject(message)) {
message = {
message: message
};
}
try {
message = JSON.stringify(_.defaultsDeep({}, message, this.config.defaultProps));
} catch (e) {
return this.logger.error('Logmatic - error while parsing log message. Not sending', e);
... | [
"function",
"(",
"message",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isObject",
"(",
"message",
")",
")",
"{",
"message",
"=",
"{",
"message",
":",
"message",
"}",
";",
"}",
"try",
"{",
"message",
"=",
"JSON",
".",
"stringify",
"(",
"_",
".",
"defaul... | Send log message
@param {object|any} message | [
"Send",
"log",
"message"
] | 5cbe6c5d0ae67929b3d159facb4f81c3cc8e6db5 | https://github.com/jcare44/node-logmatic/blob/5cbe6c5d0ae67929b3d159facb4f81c3cc8e6db5/src/logmatic.js#L84-L102 | train | |
dalekjs/dalek-driver-sauce | lib/commands/execute.js | function (script, args, hash) {
this.actionQueue.push(this.webdriverClient.execute.bind(this.webdriverClient, {script: script.toString(), arguments: args}));
this.actionQueue.push(this._setExecuteCb.bind(this, script.toString(), args, hash));
return this;
} | javascript | function (script, args, hash) {
this.actionQueue.push(this.webdriverClient.execute.bind(this.webdriverClient, {script: script.toString(), arguments: args}));
this.actionQueue.push(this._setExecuteCb.bind(this, script.toString(), args, hash));
return this;
} | [
"function",
"(",
"script",
",",
"args",
",",
"hash",
")",
"{",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"webdriverClient",
".",
"execute",
".",
"bind",
"(",
"this",
".",
"webdriverClient",
",",
"{",
"script",
":",
"script",
".",
"toSt... | Executes a JavaScript function
@method execute
@param {function} script Script to execute
@param {array} args Arguments to pass to the function
@param {string} hash Unique hash of that fn call
@chainable | [
"Executes",
"a",
"JavaScript",
"function"
] | 4b3ef87a0c35a91db8456d074b0d47a3e0df58f7 | https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/lib/commands/execute.js#L50-L54 | train | |
dalekjs/dalek-driver-sauce | lib/commands/execute.js | function (script, args, hash, data) {
var deferred = Q.defer();
this.events.emit('driver:message', {key: 'execute', value: JSON.parse(data).value, uuid: hash, hash: hash});
deferred.resolve();
return deferred.promise;
} | javascript | function (script, args, hash, data) {
var deferred = Q.defer();
this.events.emit('driver:message', {key: 'execute', value: JSON.parse(data).value, uuid: hash, hash: hash});
deferred.resolve();
return deferred.promise;
} | [
"function",
"(",
"script",
",",
"args",
",",
"hash",
",",
"data",
")",
"{",
"var",
"deferred",
"=",
"Q",
".",
"defer",
"(",
")",
";",
"this",
".",
"events",
".",
"emit",
"(",
"'driver:message'",
",",
"{",
"key",
":",
"'execute'",
",",
"value",
":",... | Sends out an event with the results of the `execute` call
@method _setExecuteCb
@param {function} script Script to execute
@param {array} args Arguments to pass to the function
@param {string} hash Unique hash of that fn call
@param {string} result Serialized JSON with the results of the call
@return {object} promise ... | [
"Sends",
"out",
"an",
"event",
"with",
"the",
"results",
"of",
"the",
"execute",
"call"
] | 4b3ef87a0c35a91db8456d074b0d47a3e0df58f7 | https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/lib/commands/execute.js#L68-L73 | train | |
dalekjs/dalek-driver-sauce | lib/commands/execute.js | function (script, args, timeout, hash) {
this.actionQueue.push(this.webdriverClient.execute.bind(this.webdriverClient, {script: script.toString(), arguments: args}));
this.actionQueue.push(this._waitForCb.bind(this, script.toString(), args, timeout, hash));
return this;
} | javascript | function (script, args, timeout, hash) {
this.actionQueue.push(this.webdriverClient.execute.bind(this.webdriverClient, {script: script.toString(), arguments: args}));
this.actionQueue.push(this._waitForCb.bind(this, script.toString(), args, timeout, hash));
return this;
} | [
"function",
"(",
"script",
",",
"args",
",",
"timeout",
",",
"hash",
")",
"{",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"webdriverClient",
".",
"execute",
".",
"bind",
"(",
"this",
".",
"webdriverClient",
",",
"{",
"script",
":",
"scr... | Executes a JavaScript function until the timeout rans out or
the function returns true
@method execute
@param {function} script Script to execute
@param {array} args Arguments to pass to the function
@param {integer} timeout Timeout of the function
@param {string} hash Unique hash of that fn call
@chainable | [
"Executes",
"a",
"JavaScript",
"function",
"until",
"the",
"timeout",
"rans",
"out",
"or",
"the",
"function",
"returns",
"true"
] | 4b3ef87a0c35a91db8456d074b0d47a3e0df58f7 | https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/lib/commands/execute.js#L87-L91 | train | |
dalekjs/dalek-driver-sauce | lib/commands/execute.js | function (script, args, timeout, hash, data) {
var deferred = Q.defer();
var ret = JSON.parse(data);
var checker = function (yData) {
if (JSON.parse(yData).value.userRet === true) {
this.events.emit('driver:message', {key: 'waitFor', value: '', uuid: hash, hash: hash});
deferred.resolv... | javascript | function (script, args, timeout, hash, data) {
var deferred = Q.defer();
var ret = JSON.parse(data);
var checker = function (yData) {
if (JSON.parse(yData).value.userRet === true) {
this.events.emit('driver:message', {key: 'waitFor', value: '', uuid: hash, hash: hash});
deferred.resolv... | [
"function",
"(",
"script",
",",
"args",
",",
"timeout",
",",
"hash",
",",
"data",
")",
"{",
"var",
"deferred",
"=",
"Q",
".",
"defer",
"(",
")",
";",
"var",
"ret",
"=",
"JSON",
".",
"parse",
"(",
"data",
")",
";",
"var",
"checker",
"=",
"function... | Sends out an event with the results of the `waitFor` call
@method _setExecuteCb
@param {function} script Script to execute
@param {array} args Arguments to pass to the function
@param {integer} timeout Timeout of the function
@param {string} hash Unique hash of that fn call
@param {string} data Serialized JSON with th... | [
"Sends",
"out",
"an",
"event",
"with",
"the",
"results",
"of",
"the",
"waitFor",
"call"
] | 4b3ef87a0c35a91db8456d074b0d47a3e0df58f7 | https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/lib/commands/execute.js#L106-L133 | train | |
dgalvez/Tere | node-http-proxy/lib/node-http-proxy/http-proxy.js | onUpgrade | function onUpgrade (reverseProxy, proxySocket) {
if (!reverseProxy) {
proxySocket.end();
socket.end();
return;
}
//
// Any incoming data on this WebSocket to the proxy target
// will be written to the `reverseProxy` socket.
//
proxySocket.on('data', listeners.onIncoming = ... | javascript | function onUpgrade (reverseProxy, proxySocket) {
if (!reverseProxy) {
proxySocket.end();
socket.end();
return;
}
//
// Any incoming data on this WebSocket to the proxy target
// will be written to the `reverseProxy` socket.
//
proxySocket.on('data', listeners.onIncoming = ... | [
"function",
"onUpgrade",
"(",
"reverseProxy",
",",
"proxySocket",
")",
"{",
"if",
"(",
"!",
"reverseProxy",
")",
"{",
"proxySocket",
".",
"end",
"(",
")",
";",
"socket",
".",
"end",
"(",
")",
";",
"return",
";",
"}",
"//",
"// Any incoming data on this Web... | On `upgrade` from the Agent socket, listen to the appropriate events. | [
"On",
"upgrade",
"from",
"the",
"Agent",
"socket",
"listen",
"to",
"the",
"appropriate",
"events",
"."
] | 0b0dcfb1871fea668ad987807e3ed3d8365ab885 | https://github.com/dgalvez/Tere/blob/0b0dcfb1871fea668ad987807e3ed3d8365ab885/node-http-proxy/lib/node-http-proxy/http-proxy.js#L475-L573 | train |
dgalvez/Tere | node-http-proxy/lib/node-http-proxy/http-proxy.js | detach | function detach() {
proxySocket.destroySoon();
proxySocket.removeListener('end', listeners.onIncomingClose);
proxySocket.removeListener('data', listeners.onIncoming);
reverseProxy.incoming.socket.destroySoon();
reverseProxy.incoming.socket.removeListener('end', listeners.onOutgoingClose);
... | javascript | function detach() {
proxySocket.destroySoon();
proxySocket.removeListener('end', listeners.onIncomingClose);
proxySocket.removeListener('data', listeners.onIncoming);
reverseProxy.incoming.socket.destroySoon();
reverseProxy.incoming.socket.removeListener('end', listeners.onOutgoingClose);
... | [
"function",
"detach",
"(",
")",
"{",
"proxySocket",
".",
"destroySoon",
"(",
")",
";",
"proxySocket",
".",
"removeListener",
"(",
"'end'",
",",
"listeners",
".",
"onIncomingClose",
")",
";",
"proxySocket",
".",
"removeListener",
"(",
"'data'",
",",
"listeners"... | Helper function to detach all event listeners from `reverseProxy` and `proxySocket`. | [
"Helper",
"function",
"to",
"detach",
"all",
"event",
"listeners",
"from",
"reverseProxy",
"and",
"proxySocket",
"."
] | 0b0dcfb1871fea668ad987807e3ed3d8365ab885 | https://github.com/dgalvez/Tere/blob/0b0dcfb1871fea668ad987807e3ed3d8365ab885/node-http-proxy/lib/node-http-proxy/http-proxy.js#L546-L553 | train |
dgalvez/Tere | node-http-proxy/lib/node-http-proxy/http-proxy.js | proxyError | function proxyError (err) {
reverseProxy.destroy();
process.nextTick(function () {
//
// Destroy the incoming socket in the next tick, in case the error handler
// wants to write to it.
//
socket.destroy();
});
self.emit('webSocketProxyError', req, socket, head);
} | javascript | function proxyError (err) {
reverseProxy.destroy();
process.nextTick(function () {
//
// Destroy the incoming socket in the next tick, in case the error handler
// wants to write to it.
//
socket.destroy();
});
self.emit('webSocketProxyError', req, socket, head);
} | [
"function",
"proxyError",
"(",
"err",
")",
"{",
"reverseProxy",
".",
"destroy",
"(",
")",
";",
"process",
".",
"nextTick",
"(",
"function",
"(",
")",
"{",
"//",
"// Destroy the incoming socket in the next tick, in case the error handler",
"// wants to write to it.",
"//... | On any errors from the `reverseProxy` emit the `webSocketProxyError` and close the appropriate connections. | [
"On",
"any",
"errors",
"from",
"the",
"reverseProxy",
"emit",
"the",
"webSocketProxyError",
"and",
"close",
"the",
"appropriate",
"connections",
"."
] | 0b0dcfb1871fea668ad987807e3ed3d8365ab885 | https://github.com/dgalvez/Tere/blob/0b0dcfb1871fea668ad987807e3ed3d8365ab885/node-http-proxy/lib/node-http-proxy/http-proxy.js#L615-L627 | train |
jaredhanson/crane-amqp | lib/broker.js | Broker | function Broker(options) {
EventEmitter.call(this);
this._exchange = null;
this._queues = {};
this._ctags = {};
this._options = options;
} | javascript | function Broker(options) {
EventEmitter.call(this);
this._exchange = null;
this._queues = {};
this._ctags = {};
this._options = options;
} | [
"function",
"Broker",
"(",
"options",
")",
"{",
"EventEmitter",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"_exchange",
"=",
"null",
";",
"this",
".",
"_queues",
"=",
"{",
"}",
";",
"this",
".",
"_ctags",
"=",
"{",
"}",
";",
"this",
".",
"_... | `Broker` constructor.
@api public | [
"Broker",
"constructor",
"."
] | 2f2a653a5567550d035daf8a2587fac0ebc9d8ce | https://github.com/jaredhanson/crane-amqp/blob/2f2a653a5567550d035daf8a2587fac0ebc9d8ce/lib/broker.js#L26-L33 | train |
ottojs/otto-errors | lib/save.error.js | ErrorSave | function ErrorSave (message) {
Error.call(this);
// Add Information
this.name = 'ErrorSave';
this.type = 'server';
this.status = 500;
if (message) {
this.message = message;
}
} | javascript | function ErrorSave (message) {
Error.call(this);
// Add Information
this.name = 'ErrorSave';
this.type = 'server';
this.status = 500;
if (message) {
this.message = message;
}
} | [
"function",
"ErrorSave",
"(",
"message",
")",
"{",
"Error",
".",
"call",
"(",
"this",
")",
";",
"// Add Information",
"this",
".",
"name",
"=",
"'ErrorSave'",
";",
"this",
".",
"type",
"=",
"'server'",
";",
"this",
".",
"status",
"=",
"500",
";",
"if",... | Error - ErrorSave | [
"Error",
"-",
"ErrorSave"
] | a3c6d98fd5d35ce3c136ed7e1edd2f800af268d9 | https://github.com/ottojs/otto-errors/blob/a3c6d98fd5d35ce3c136ed7e1edd2f800af268d9/lib/save.error.js#L8-L20 | train |
AtlasIQ/makedeb | lib/validate.js | isRealDirectory | function isRealDirectory(p) {
var stats;
try {
stats = fs.statSync(p);
} catch (error) {
// Not a valid path if stat fails.
return false;
}
return (stats.isDirectory());
} | javascript | function isRealDirectory(p) {
var stats;
try {
stats = fs.statSync(p);
} catch (error) {
// Not a valid path if stat fails.
return false;
}
return (stats.isDirectory());
} | [
"function",
"isRealDirectory",
"(",
"p",
")",
"{",
"var",
"stats",
";",
"try",
"{",
"stats",
"=",
"fs",
".",
"statSync",
"(",
"p",
")",
";",
"}",
"catch",
"(",
"error",
")",
"{",
"// Not a valid path if stat fails.",
"return",
"false",
";",
"}",
"return"... | Expects that a path points to a real directory. | [
"Expects",
"that",
"a",
"path",
"points",
"to",
"a",
"real",
"directory",
"."
] | 017719bc0e0d3594a05d7b30af2430c635e49363 | https://github.com/AtlasIQ/makedeb/blob/017719bc0e0d3594a05d7b30af2430c635e49363/lib/validate.js#L15-L25 | train |
dwilhelm89/RandomGeoJSON | index.js | generatePolygon | function generatePolygon() {
var coordNumber = getRandomNumber(3, options.maxCoordCount);
var feature = rawFeature();
feature.geometry.type = 'Polygon';
feature.geometry.coordinates = [
[]
];
var firstCoordinate = generateLonLat();
feature.geometry.coordinates[0].push(firstCoordinate);
addCoordin... | javascript | function generatePolygon() {
var coordNumber = getRandomNumber(3, options.maxCoordCount);
var feature = rawFeature();
feature.geometry.type = 'Polygon';
feature.geometry.coordinates = [
[]
];
var firstCoordinate = generateLonLat();
feature.geometry.coordinates[0].push(firstCoordinate);
addCoordin... | [
"function",
"generatePolygon",
"(",
")",
"{",
"var",
"coordNumber",
"=",
"getRandomNumber",
"(",
"3",
",",
"options",
".",
"maxCoordCount",
")",
";",
"var",
"feature",
"=",
"rawFeature",
"(",
")",
";",
"feature",
".",
"geometry",
".",
"type",
"=",
"'Polygo... | Generates a Polygon
@return {Object} GeoJSON Polygon | [
"Generates",
"a",
"Polygon"
] | 539070dcbf6e67fcb6c4047c24dfb9588a702de9 | https://github.com/dwilhelm89/RandomGeoJSON/blob/539070dcbf6e67fcb6c4047c24dfb9588a702de9/index.js#L42-L58 | train |
dwilhelm89/RandomGeoJSON | index.js | generateLineString | function generateLineString() {
var coordNumber = getRandomNumber(3, options.maxCoordCount);
var feature = rawFeature();
feature.geometry.type = 'LineString';
addCoordinates(feature.geometry.coordinates, coordNumber);
return feature;
} | javascript | function generateLineString() {
var coordNumber = getRandomNumber(3, options.maxCoordCount);
var feature = rawFeature();
feature.geometry.type = 'LineString';
addCoordinates(feature.geometry.coordinates, coordNumber);
return feature;
} | [
"function",
"generateLineString",
"(",
")",
"{",
"var",
"coordNumber",
"=",
"getRandomNumber",
"(",
"3",
",",
"options",
".",
"maxCoordCount",
")",
";",
"var",
"feature",
"=",
"rawFeature",
"(",
")",
";",
"feature",
".",
"geometry",
".",
"type",
"=",
"'Lin... | Generates a LineString
@return {Object} GeoJSON LineString | [
"Generates",
"a",
"LineString"
] | 539070dcbf6e67fcb6c4047c24dfb9588a702de9 | https://github.com/dwilhelm89/RandomGeoJSON/blob/539070dcbf6e67fcb6c4047c24dfb9588a702de9/index.js#L65-L74 | train |
dwilhelm89/RandomGeoJSON | index.js | generateFeatures | function generateFeatures() {
var collection = {
type: 'FeatureCollection',
features: []
};
for (var i = 0; i < options.number; i++) {
collection.features.push(generateFeature(randomType()));
}
return collection;
} | javascript | function generateFeatures() {
var collection = {
type: 'FeatureCollection',
features: []
};
for (var i = 0; i < options.number; i++) {
collection.features.push(generateFeature(randomType()));
}
return collection;
} | [
"function",
"generateFeatures",
"(",
")",
"{",
"var",
"collection",
"=",
"{",
"type",
":",
"'FeatureCollection'",
",",
"features",
":",
"[",
"]",
"}",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"options",
".",
"number",
";",
"i",
"++",
"... | Creates a FeatureCollection and adds features
@return {Object} GeoJSON FeatureCollection | [
"Creates",
"a",
"FeatureCollection",
"and",
"adds",
"features"
] | 539070dcbf6e67fcb6c4047c24dfb9588a702de9 | https://github.com/dwilhelm89/RandomGeoJSON/blob/539070dcbf6e67fcb6c4047c24dfb9588a702de9/index.js#L115-L125 | train |
dwilhelm89/RandomGeoJSON | index.js | addCoordinates | function addCoordinates(coordArray, number) {
for (var i = 0; i < number; i++) {
coordArray.push(generateLonLat());
}
} | javascript | function addCoordinates(coordArray, number) {
for (var i = 0; i < number; i++) {
coordArray.push(generateLonLat());
}
} | [
"function",
"addCoordinates",
"(",
"coordArray",
",",
"number",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"number",
";",
"i",
"++",
")",
"{",
"coordArray",
".",
"push",
"(",
"generateLonLat",
"(",
")",
")",
";",
"}",
"}"
] | Adds a random coordinate to an array
@param {Array} coordArray the coordinate array
@param {Number} number amount of coordinates which should be added | [
"Adds",
"a",
"random",
"coordinate",
"to",
"an",
"array"
] | 539070dcbf6e67fcb6c4047c24dfb9588a702de9 | https://github.com/dwilhelm89/RandomGeoJSON/blob/539070dcbf6e67fcb6c4047c24dfb9588a702de9/index.js#L163-L167 | train |
Subsets and Splits
SQL Console for semeru/code-text-javascript
Retrieves 20,000 non-null code samples labeled as JavaScript, providing a basic overview of the dataset.