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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
andrezsanchez/css-selector-classes | index.js | getCssSelectorClasses | function getCssSelectorClasses(selector) {
var list = []
var ast = cssSelector.parse(selector)
visitRules(ast, function(ruleSet) {
if (ruleSet.classNames) {
list = list.concat(ruleSet.classNames)
}
})
return uniq(list)
} | javascript | function getCssSelectorClasses(selector) {
var list = []
var ast = cssSelector.parse(selector)
visitRules(ast, function(ruleSet) {
if (ruleSet.classNames) {
list = list.concat(ruleSet.classNames)
}
})
return uniq(list)
} | [
"function",
"getCssSelectorClasses",
"(",
"selector",
")",
"{",
"var",
"list",
"=",
"[",
"]",
"var",
"ast",
"=",
"cssSelector",
".",
"parse",
"(",
"selector",
")",
"visitRules",
"(",
"ast",
",",
"function",
"(",
"ruleSet",
")",
"{",
"if",
"(",
"ruleSet",... | Return all the classes in a CSS selector.
@param {String} selector A CSS selector
@return {String[]} An array of every class present in the CSS selector | [
"Return",
"all",
"the",
"classes",
"in",
"a",
"CSS",
"selector",
"."
] | 8f9a4d60067fa2120b296774dd4be2eae1427428 | https://github.com/andrezsanchez/css-selector-classes/blob/8f9a4d60067fa2120b296774dd4be2eae1427428/index.js#L20-L29 | train |
alex-seville/feta | lib/feta.js | loadScript | function loadScript(url) {
s = document.createElement('script');
s.src =url;
document.body.appendChild(s);
} | javascript | function loadScript(url) {
s = document.createElement('script');
s.src =url;
document.body.appendChild(s);
} | [
"function",
"loadScript",
"(",
"url",
")",
"{",
"s",
"=",
"document",
".",
"createElement",
"(",
"'script'",
")",
";",
"s",
".",
"src",
"=",
"url",
";",
"document",
".",
"body",
".",
"appendChild",
"(",
"s",
")",
";",
"}"
] | Unused for now, but might be handy | [
"Unused",
"for",
"now",
"but",
"might",
"be",
"handy"
] | 2ba603320ccba3fec313d26a3a70fab3d6f39e3a | https://github.com/alex-seville/feta/blob/2ba603320ccba3fec313d26a3a70fab3d6f39e3a/lib/feta.js#L15-L19 | train |
mattdesl/kami-texture | index.js | Texture | function Texture(context, options) {
if (!(this instanceof Texture))
return new Texture(context, options);
//sets up base Kami object..
BaseObject.call(this, context);
/**
* When a texture is created, we keep track of the arguments provided to
* its constructor. On context loss and restore, these ... | javascript | function Texture(context, options) {
if (!(this instanceof Texture))
return new Texture(context, options);
//sets up base Kami object..
BaseObject.call(this, context);
/**
* When a texture is created, we keep track of the arguments provided to
* its constructor. On context loss and restore, these ... | [
"function",
"Texture",
"(",
"context",
",",
"options",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Texture",
")",
")",
"return",
"new",
"Texture",
"(",
"context",
",",
"options",
")",
";",
"//sets up base Kami object..",
"BaseObject",
".",
"call",
... | Creates a new texture with the optional width, height, and data.
If the constructor is passed no parameters other than the context, then
it will not be initialized and will be non-renderable. You will need to manually
uploadData or uploadImage yourself.
If the options passed includes 'src', it assumes an image is to ... | [
"Creates",
"a",
"new",
"texture",
"with",
"the",
"optional",
"width",
"height",
"and",
"data",
"."
] | b2659e524fad19aec348a8af519fbbb044116018 | https://github.com/mattdesl/kami-texture/blob/b2659e524fad19aec348a8af519fbbb044116018/index.js#L47-L135 | train |
mattdesl/kami-texture | index.js | function(options) {
var gl = this.gl;
//If no options is provided... this method does nothing.
if (!options)
return;
// width, height, format, dataType, data, genMipmaps
//If 'src' is provided, try to load the image from a path...
if (options.src && typeof options.src==="string") {
var img = new Im... | javascript | function(options) {
var gl = this.gl;
//If no options is provided... this method does nothing.
if (!options)
return;
// width, height, format, dataType, data, genMipmaps
//If 'src' is provided, try to load the image from a path...
if (options.src && typeof options.src==="string") {
var img = new Im... | [
"function",
"(",
"options",
")",
"{",
"var",
"gl",
"=",
"this",
".",
"gl",
";",
"//If no options is provided... this method does nothing.",
"if",
"(",
"!",
"options",
")",
"return",
";",
"// width, height, format, dataType, data, genMipmaps",
"//If 'src' is provided, try to... | This can be called after creating a Texture to load an Image object asynchronously,
or upload image data directly. It takes the same options as the constructor.
Users will generally not need to call this directly.
@protected
@method setup | [
"This",
"can",
"be",
"called",
"after",
"creating",
"a",
"Texture",
"to",
"load",
"an",
"Image",
"object",
"asynchronously",
"or",
"upload",
"image",
"data",
"directly",
".",
"It",
"takes",
"the",
"same",
"options",
"as",
"the",
"constructor",
"."
] | b2659e524fad19aec348a8af519fbbb044116018 | https://github.com/mattdesl/kami-texture/blob/b2659e524fad19aec348a8af519fbbb044116018/index.js#L146-L209 | train | |
mattdesl/kami-texture | index.js | function() {
if (this.id && this.gl)
this.gl.deleteTexture(this.id);
if (this.context)
this.context.removeManagedObject(this);
this.width = this.height = 0;
this.id = null;
this.managedArgs = null;
this.context = null;
this.gl = null;
} | javascript | function() {
if (this.id && this.gl)
this.gl.deleteTexture(this.id);
if (this.context)
this.context.removeManagedObject(this);
this.width = this.height = 0;
this.id = null;
this.managedArgs = null;
this.context = null;
this.gl = null;
} | [
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"id",
"&&",
"this",
".",
"gl",
")",
"this",
".",
"gl",
".",
"deleteTexture",
"(",
"this",
".",
"id",
")",
";",
"if",
"(",
"this",
".",
"context",
")",
"this",
".",
"context",
".",
"removeManagedO... | Destroys this texture by deleting the GL resource,
removing it from the WebGLContext management stack,
setting its size to zero, and id and managed arguments to null.
Trying to use this texture after may lead to undefined behaviour.
@method destroy | [
"Destroys",
"this",
"texture",
"by",
"deleting",
"the",
"GL",
"resource",
"removing",
"it",
"from",
"the",
"WebGLContext",
"management",
"stack",
"setting",
"its",
"size",
"to",
"zero",
"and",
"id",
"and",
"managed",
"arguments",
"to",
"null",
"."
] | b2659e524fad19aec348a8af519fbbb044116018 | https://github.com/mattdesl/kami-texture/blob/b2659e524fad19aec348a8af519fbbb044116018/index.js#L254-L264 | train | |
mattdesl/kami-texture | index.js | function(s, t, ignoreBind) { //TODO: support R wrap mode
if (s && t) {
this.wrapS = s;
this.wrapT = t;
} else
this.wrapS = this.wrapT = s;
//enforce POT rules..
this._checkPOT();
if (!ignoreBind)
this.bind();
var gl = this.gl;
gl.texParameteri(this.target, gl.TEXTURE_WRAP_S, this.wrapS)... | javascript | function(s, t, ignoreBind) { //TODO: support R wrap mode
if (s && t) {
this.wrapS = s;
this.wrapT = t;
} else
this.wrapS = this.wrapT = s;
//enforce POT rules..
this._checkPOT();
if (!ignoreBind)
this.bind();
var gl = this.gl;
gl.texParameteri(this.target, gl.TEXTURE_WRAP_S, this.wrapS)... | [
"function",
"(",
"s",
",",
"t",
",",
"ignoreBind",
")",
"{",
"//TODO: support R wrap mode",
"if",
"(",
"s",
"&&",
"t",
")",
"{",
"this",
".",
"wrapS",
"=",
"s",
";",
"this",
".",
"wrapT",
"=",
"t",
";",
"}",
"else",
"this",
".",
"wrapS",
"=",
"th... | Sets the wrap mode for this texture; if the second argument
is undefined or falsy, then both S and T wrap will use the first
argument.
You can use Texture.Wrap constants for convenience, to avoid needing
a GL reference.
@method setWrap
@param {GLenum} s the S wrap mode
@param {GLenum} t the T wrap mode
@param {Boole... | [
"Sets",
"the",
"wrap",
"mode",
"for",
"this",
"texture",
";",
"if",
"the",
"second",
"argument",
"is",
"undefined",
"or",
"falsy",
"then",
"both",
"S",
"and",
"T",
"wrap",
"will",
"use",
"the",
"first",
"argument",
"."
] | b2659e524fad19aec348a8af519fbbb044116018 | https://github.com/mattdesl/kami-texture/blob/b2659e524fad19aec348a8af519fbbb044116018/index.js#L279-L295 | train | |
mattdesl/kami-texture | index.js | function(min, mag, ignoreBind) {
if (min && mag) {
this.minFilter = min;
this.magFilter = mag;
} else
this.minFilter = this.magFilter = min;
//enforce POT rules..
this._checkPOT();
if (!ignoreBind)
this.bind();
var gl = this.gl;
gl.texParameteri(this.target, gl.TEXTURE_MIN_FILTER, this.... | javascript | function(min, mag, ignoreBind) {
if (min && mag) {
this.minFilter = min;
this.magFilter = mag;
} else
this.minFilter = this.magFilter = min;
//enforce POT rules..
this._checkPOT();
if (!ignoreBind)
this.bind();
var gl = this.gl;
gl.texParameteri(this.target, gl.TEXTURE_MIN_FILTER, this.... | [
"function",
"(",
"min",
",",
"mag",
",",
"ignoreBind",
")",
"{",
"if",
"(",
"min",
"&&",
"mag",
")",
"{",
"this",
".",
"minFilter",
"=",
"min",
";",
"this",
".",
"magFilter",
"=",
"mag",
";",
"}",
"else",
"this",
".",
"minFilter",
"=",
"this",
".... | Sets the min and mag filter for this texture;
if mag is undefined or falsy, then both min and mag will use the
filter specified for min.
You can use Texture.Filter constants for convenience, to avoid needing
a GL reference.
@method setFilter
@param {GLenum} min the minification filter
@param {GLenum} mag the magnifi... | [
"Sets",
"the",
"min",
"and",
"mag",
"filter",
"for",
"this",
"texture",
";",
"if",
"mag",
"is",
"undefined",
"or",
"falsy",
"then",
"both",
"min",
"and",
"mag",
"will",
"use",
"the",
"filter",
"specified",
"for",
"min",
"."
] | b2659e524fad19aec348a8af519fbbb044116018 | https://github.com/mattdesl/kami-texture/blob/b2659e524fad19aec348a8af519fbbb044116018/index.js#L311-L327 | train | |
mattdesl/kami-texture | index.js | function(width, height, format, type, data, genMipmaps) {
var gl = this.gl;
format = format || gl.RGBA;
type = type || gl.UNSIGNED_BYTE;
data = data || null; //make sure falsey value is null for texImage2D
this.width = (width || width==0) ? width : this.width;
this.height = (height || height==0) ? height ... | javascript | function(width, height, format, type, data, genMipmaps) {
var gl = this.gl;
format = format || gl.RGBA;
type = type || gl.UNSIGNED_BYTE;
data = data || null; //make sure falsey value is null for texImage2D
this.width = (width || width==0) ? width : this.width;
this.height = (height || height==0) ? height ... | [
"function",
"(",
"width",
",",
"height",
",",
"format",
",",
"type",
",",
"data",
",",
"genMipmaps",
")",
"{",
"var",
"gl",
"=",
"this",
".",
"gl",
";",
"format",
"=",
"format",
"||",
"gl",
".",
"RGBA",
";",
"type",
"=",
"type",
"||",
"gl",
".",
... | A low-level method to upload the specified ArrayBufferView
to this texture. This will cause the width and height of this
texture to change.
@method uploadData
@param {Number} width the new width of this texture,
defaults to the last used width (or zero)
@param {Number} height the new height of this... | [
"A",
"low",
"-",
"level",
"method",
"to",
"upload",
"the",
"specified",
"ArrayBufferView",
"to",
"this",
"texture",
".",
"This",
"will",
"cause",
"the",
"width",
"and",
"height",
"of",
"this",
"texture",
"to",
"change",
"."
] | b2659e524fad19aec348a8af519fbbb044116018 | https://github.com/mattdesl/kami-texture/blob/b2659e524fad19aec348a8af519fbbb044116018/index.js#L344-L364 | train | |
mattdesl/kami-texture | index.js | function(domObject, format, type, genMipmaps) {
var gl = this.gl;
format = format || gl.RGBA;
type = type || gl.UNSIGNED_BYTE;
this.width = domObject.width;
this.height = domObject.height;
this._checkPOT();
this.bind();
gl.texImage2D(this.target, 0, format, format,
type, domObject);
if ... | javascript | function(domObject, format, type, genMipmaps) {
var gl = this.gl;
format = format || gl.RGBA;
type = type || gl.UNSIGNED_BYTE;
this.width = domObject.width;
this.height = domObject.height;
this._checkPOT();
this.bind();
gl.texImage2D(this.target, 0, format, format,
type, domObject);
if ... | [
"function",
"(",
"domObject",
",",
"format",
",",
"type",
",",
"genMipmaps",
")",
"{",
"var",
"gl",
"=",
"this",
".",
"gl",
";",
"format",
"=",
"format",
"||",
"gl",
".",
"RGBA",
";",
"type",
"=",
"type",
"||",
"gl",
".",
"UNSIGNED_BYTE",
";",
"thi... | Uploads ImageData, HTMLImageElement, HTMLCanvasElement or
HTMLVideoElement.
@method uploadImage
@param {Object} domObject the DOM image container
@param {GLenum} format the format, default gl.RGBA
@param {GLenum} type the data type, default gl.UNSIGNED_BYTE
@param {Boolean} genMipmaps whether to generate mipmaps ... | [
"Uploads",
"ImageData",
"HTMLImageElement",
"HTMLCanvasElement",
"or",
"HTMLVideoElement",
"."
] | b2659e524fad19aec348a8af519fbbb044116018 | https://github.com/mattdesl/kami-texture/blob/b2659e524fad19aec348a8af519fbbb044116018/index.js#L376-L394 | train | |
mattdesl/kami-texture | index.js | function() {
if (!Texture.FORCE_POT) {
//If minFilter is anything but LINEAR or NEAREST
//or if wrapS or wrapT are not CLAMP_TO_EDGE...
var wrongFilter = (this.minFilter !== Texture.Filter.LINEAR && this.minFilter !== Texture.Filter.NEAREST);
var wrongWrap = (this.wrapS !== Texture.Wrap.CLAMP_TO_EDGE || t... | javascript | function() {
if (!Texture.FORCE_POT) {
//If minFilter is anything but LINEAR or NEAREST
//or if wrapS or wrapT are not CLAMP_TO_EDGE...
var wrongFilter = (this.minFilter !== Texture.Filter.LINEAR && this.minFilter !== Texture.Filter.NEAREST);
var wrongWrap = (this.wrapS !== Texture.Wrap.CLAMP_TO_EDGE || t... | [
"function",
"(",
")",
"{",
"if",
"(",
"!",
"Texture",
".",
"FORCE_POT",
")",
"{",
"//If minFilter is anything but LINEAR or NEAREST",
"//or if wrapS or wrapT are not CLAMP_TO_EDGE...",
"var",
"wrongFilter",
"=",
"(",
"this",
".",
"minFilter",
"!==",
"Texture",
".",
"F... | If FORCE_POT is false, we verify this texture to see if it is valid,
as per non-power-of-two rules. If it is non-power-of-two, it must have
a wrap mode of CLAMP_TO_EDGE, and the minification filter must be LINEAR
or NEAREST. If we don't satisfy these needs, an error is thrown.
@method _checkPOT
@private
@return {[typ... | [
"If",
"FORCE_POT",
"is",
"false",
"we",
"verify",
"this",
"texture",
"to",
"see",
"if",
"it",
"is",
"valid",
"as",
"per",
"non",
"-",
"power",
"-",
"of",
"-",
"two",
"rules",
".",
"If",
"it",
"is",
"non",
"-",
"power",
"-",
"of",
"-",
"two",
"it"... | b2659e524fad19aec348a8af519fbbb044116018 | https://github.com/mattdesl/kami-texture/blob/b2659e524fad19aec348a8af519fbbb044116018/index.js#L410-L424 | train | |
phil-taylor/nreports | lib/parameter.js | ReportParameter | function ReportParameter(name, type, value) {
this.parameterTypes = [
"string",
"number",
"boolean",
"datetime",
"date",
"time"
];
this.name = name;
this.type = type;
this.value = value;
this.dependsOn = null; //use when you need cascading values
this.label = null; // display label
this.displa... | javascript | function ReportParameter(name, type, value) {
this.parameterTypes = [
"string",
"number",
"boolean",
"datetime",
"date",
"time"
];
this.name = name;
this.type = type;
this.value = value;
this.dependsOn = null; //use when you need cascading values
this.label = null; // display label
this.displa... | [
"function",
"ReportParameter",
"(",
"name",
",",
"type",
",",
"value",
")",
"{",
"this",
".",
"parameterTypes",
"=",
"[",
"\"string\"",
",",
"\"number\"",
",",
"\"boolean\"",
",",
"\"datetime\"",
",",
"\"date\"",
",",
"\"time\"",
"]",
";",
"this",
".",
"na... | Defines a reporting parameter used when calling your reporting datasource.
@param {String} name
@param {String} type
@param {Boolean|Number|String} value | [
"Defines",
"a",
"reporting",
"parameter",
"used",
"when",
"calling",
"your",
"reporting",
"datasource",
"."
] | ffc7691de1bfb3d81d6dde66fc3c0f95603e7c11 | https://github.com/phil-taylor/nreports/blob/ffc7691de1bfb3d81d6dde66fc3c0f95603e7c11/lib/parameter.js#L7-L27 | train |
quantumpayments/hdwallet | lib/util.js | sha2 | function sha2(str) {
var md = forge.md.sha256.create();
md.update(str);
return md.digest().toHex()
} | javascript | function sha2(str) {
var md = forge.md.sha256.create();
md.update(str);
return md.digest().toHex()
} | [
"function",
"sha2",
"(",
"str",
")",
"{",
"var",
"md",
"=",
"forge",
".",
"md",
".",
"sha256",
".",
"create",
"(",
")",
";",
"md",
".",
"update",
"(",
"str",
")",
";",
"return",
"md",
".",
"digest",
"(",
")",
".",
"toHex",
"(",
")",
"}"
] | sha2 get the sha256 of a string
@param {String} str the string
@return {String} the hash | [
"sha2",
"get",
"the",
"sha256",
"of",
"a",
"string"
] | 9f48062b10ee49f145abcb6c9424b8df96c26cd8 | https://github.com/quantumpayments/hdwallet/blob/9f48062b10ee49f145abcb6c9424b8df96c26cd8/lib/util.js#L23-L27 | train |
quantumpayments/hdwallet | lib/util.js | hashToInts | function hashToInts(hash) {
var arr = []
var num = 4
for (var i = 0; i < 4; i++) {
var part = hash.substr(i*8,8)
var n = parseInt(part, 16) & 0x7fffffff
arr.push(n)
}
return arr
} | javascript | function hashToInts(hash) {
var arr = []
var num = 4
for (var i = 0; i < 4; i++) {
var part = hash.substr(i*8,8)
var n = parseInt(part, 16) & 0x7fffffff
arr.push(n)
}
return arr
} | [
"function",
"hashToInts",
"(",
"hash",
")",
"{",
"var",
"arr",
"=",
"[",
"]",
"var",
"num",
"=",
"4",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"4",
";",
"i",
"++",
")",
"{",
"var",
"part",
"=",
"hash",
".",
"substr",
"(",
"i",
"*",
... | hashToInts get hash to ints minus first bit
@param {String} hash a hex array
@return {Array} 4 numbers | [
"hashToInts",
"get",
"hash",
"to",
"ints",
"minus",
"first",
"bit"
] | 9f48062b10ee49f145abcb6c9424b8df96c26cd8 | https://github.com/quantumpayments/hdwallet/blob/9f48062b10ee49f145abcb6c9424b8df96c26cd8/lib/util.js#L34-L46 | train |
quantumpayments/hdwallet | lib/util.js | mnemonicToPubKey | function mnemonicToPubKey(str) {
var m = new Mnemonic(str);
var xpriv1 = m.toHDPrivateKey(); // no passphrase
var xpub1 = xpriv1.hdPublicKey;
return xpub1
} | javascript | function mnemonicToPubKey(str) {
var m = new Mnemonic(str);
var xpriv1 = m.toHDPrivateKey(); // no passphrase
var xpub1 = xpriv1.hdPublicKey;
return xpub1
} | [
"function",
"mnemonicToPubKey",
"(",
"str",
")",
"{",
"var",
"m",
"=",
"new",
"Mnemonic",
"(",
"str",
")",
";",
"var",
"xpriv1",
"=",
"m",
".",
"toHDPrivateKey",
"(",
")",
";",
"// no passphrase",
"var",
"xpub1",
"=",
"xpriv1",
".",
"hdPublicKey",
";",
... | get a public key from a mnemonic
@param {String} str The mnemonic
@return {Object} The HD Public Key | [
"get",
"a",
"public",
"key",
"from",
"a",
"mnemonic"
] | 9f48062b10ee49f145abcb6c9424b8df96c26cd8 | https://github.com/quantumpayments/hdwallet/blob/9f48062b10ee49f145abcb6c9424b8df96c26cd8/lib/util.js#L53-L62 | train |
quantumpayments/hdwallet | lib/util.js | webidAndPubKeyToAddress | function webidAndPubKeyToAddress(webid, pubKey, testnet) {
if (typeof(pubKey) === 'string') {
pubKey = new bitcore.HDPublicKey(pubKey)
}
var hash = sha2(webid)
var ints = hashToInts(hash)
var dep2 = pubKey.derive(ints[0]).derive(ints[1]).derive(ints[2]).derive(ints[3])
//console.log(dep2);
if (tes... | javascript | function webidAndPubKeyToAddress(webid, pubKey, testnet) {
if (typeof(pubKey) === 'string') {
pubKey = new bitcore.HDPublicKey(pubKey)
}
var hash = sha2(webid)
var ints = hashToInts(hash)
var dep2 = pubKey.derive(ints[0]).derive(ints[1]).derive(ints[2]).derive(ints[3])
//console.log(dep2);
if (tes... | [
"function",
"webidAndPubKeyToAddress",
"(",
"webid",
",",
"pubKey",
",",
"testnet",
")",
"{",
"if",
"(",
"typeof",
"(",
"pubKey",
")",
"===",
"'string'",
")",
"{",
"pubKey",
"=",
"new",
"bitcore",
".",
"HDPublicKey",
"(",
"pubKey",
")",
"}",
"var",
"hash... | get an address from webid and hd pub key
@param {String} webid The WebID
@param {String} pubKey The HD public key
@param {boolean} testnet Use testnet
@return {String} bitcoin address | [
"get",
"an",
"address",
"from",
"webid",
"and",
"hd",
"pub",
"key"
] | 9f48062b10ee49f145abcb6c9424b8df96c26cd8 | https://github.com/quantumpayments/hdwallet/blob/9f48062b10ee49f145abcb6c9424b8df96c26cd8/lib/util.js#L115-L137 | train |
quantumpayments/hdwallet | lib/util.js | webidAndPrivKeyToAddress | function webidAndPrivKeyToAddress(webid, privKey, testnet) {
if (typeof(privKey) === 'string') {
privKey = new bitcore.HDPrivateKey(privKey)
}
var hash = sha2(webid)
var ints = hashToInts(hash)
var dep2 = privKey.derive(ints[0]).derive(ints[1]).derive(ints[2]).derive(ints[3])
//console.log(dep2);
... | javascript | function webidAndPrivKeyToAddress(webid, privKey, testnet) {
if (typeof(privKey) === 'string') {
privKey = new bitcore.HDPrivateKey(privKey)
}
var hash = sha2(webid)
var ints = hashToInts(hash)
var dep2 = privKey.derive(ints[0]).derive(ints[1]).derive(ints[2]).derive(ints[3])
//console.log(dep2);
... | [
"function",
"webidAndPrivKeyToAddress",
"(",
"webid",
",",
"privKey",
",",
"testnet",
")",
"{",
"if",
"(",
"typeof",
"(",
"privKey",
")",
"===",
"'string'",
")",
"{",
"privKey",
"=",
"new",
"bitcore",
".",
"HDPrivateKey",
"(",
"privKey",
")",
"}",
"var",
... | get an address from webid and hd priv key
@param {String} webid The WebID
@param {String} pubKey The HD private key
@param {boolean} testnet Use testnet
@return {String} bitcoin address | [
"get",
"an",
"address",
"from",
"webid",
"and",
"hd",
"priv",
"key"
] | 9f48062b10ee49f145abcb6c9424b8df96c26cd8 | https://github.com/quantumpayments/hdwallet/blob/9f48062b10ee49f145abcb6c9424b8df96c26cd8/lib/util.js#L146-L168 | train |
linyngfly/omelo | lib/connectors/hybrid/switcher.js | function(server, opts) {
EventEmitter.call(this);
this.server = server;
this.wsprocessor = new WSProcessor();
this.tcpprocessor = new TCPProcessor(opts.closeMethod);
this.id = 1;
this.timeout = (opts.timeout || DEFAULT_TIMEOUT) * 1000;
this.setNoDelay = opts.setNoDelay;
if (!opts.ssl) {
this.server... | javascript | function(server, opts) {
EventEmitter.call(this);
this.server = server;
this.wsprocessor = new WSProcessor();
this.tcpprocessor = new TCPProcessor(opts.closeMethod);
this.id = 1;
this.timeout = (opts.timeout || DEFAULT_TIMEOUT) * 1000;
this.setNoDelay = opts.setNoDelay;
if (!opts.ssl) {
this.server... | [
"function",
"(",
"server",
",",
"opts",
")",
"{",
"EventEmitter",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"server",
"=",
"server",
";",
"this",
".",
"wsprocessor",
"=",
"new",
"WSProcessor",
"(",
")",
";",
"this",
".",
"tcpprocessor",
"=",
"... | Switcher for tcp and websocket protocol
@param {Object} server tcp server instance from node.js net module | [
"Switcher",
"for",
"tcp",
"and",
"websocket",
"protocol"
] | fb5f79fa31c69de36bd1c370bad5edfa753ca601 | https://github.com/linyngfly/omelo/blob/fb5f79fa31c69de36bd1c370bad5edfa753ca601/lib/connectors/hybrid/switcher.js#L21-L44 | train | |
deanlandolt/bytespace | namespace.js | Namespace | function Namespace(path, hex) {
this.hex = !!hex
this.keyEncoding = hex ? 'utf8' : 'binary'
this.path = path
this.buffer = bytewise.encode(path)
this.prehooks = []
this.posthooks = []
} | javascript | function Namespace(path, hex) {
this.hex = !!hex
this.keyEncoding = hex ? 'utf8' : 'binary'
this.path = path
this.buffer = bytewise.encode(path)
this.prehooks = []
this.posthooks = []
} | [
"function",
"Namespace",
"(",
"path",
",",
"hex",
")",
"{",
"this",
".",
"hex",
"=",
"!",
"!",
"hex",
"this",
".",
"keyEncoding",
"=",
"hex",
"?",
"'utf8'",
":",
"'binary'",
"this",
".",
"path",
"=",
"path",
"this",
".",
"buffer",
"=",
"bytewise",
... | brand namespace instance to keep track of subspace root | [
"brand",
"namespace",
"instance",
"to",
"keep",
"track",
"of",
"subspace",
"root"
] | 3d3b92d5a8999eedf766fea62bfa7f5643fd467d | https://github.com/deanlandolt/bytespace/blob/3d3b92d5a8999eedf766fea62bfa7f5643fd467d/namespace.js#L12-L20 | train |
gummesson/tiny-csv | index.js | csv | function csv(input, delimiter) {
if (!input) return []
delimiter = delimiter || ','
var lines = toArray(input, /\r?\n/)
var first = lines.shift()
var header = toArray(first, delimiter)
var data = lines.map(function(line) {
var row = toArray(line, delimiter)
return toObject(row, header)
})
r... | javascript | function csv(input, delimiter) {
if (!input) return []
delimiter = delimiter || ','
var lines = toArray(input, /\r?\n/)
var first = lines.shift()
var header = toArray(first, delimiter)
var data = lines.map(function(line) {
var row = toArray(line, delimiter)
return toObject(row, header)
})
r... | [
"function",
"csv",
"(",
"input",
",",
"delimiter",
")",
"{",
"if",
"(",
"!",
"input",
")",
"return",
"[",
"]",
"delimiter",
"=",
"delimiter",
"||",
"','",
"var",
"lines",
"=",
"toArray",
"(",
"input",
",",
"/",
"\\r?\\n",
"/",
")",
"var",
"first",
... | Parse a CSV string into an array of objects.
@param {String} input
@param {String|RegExp} delimiter
@return {Array<Object>}
@api public | [
"Parse",
"a",
"CSV",
"string",
"into",
"an",
"array",
"of",
"objects",
"."
] | 56dca2a417f893380b69009c646ec2b2fc23677f | https://github.com/gummesson/tiny-csv/blob/56dca2a417f893380b69009c646ec2b2fc23677f/index.js#L17-L31 | train |
gummesson/tiny-csv | index.js | toArray | function toArray(line, delimiter) {
var arr = line
.split(delimiter)
.filter(Boolean)
return arr
} | javascript | function toArray(line, delimiter) {
var arr = line
.split(delimiter)
.filter(Boolean)
return arr
} | [
"function",
"toArray",
"(",
"line",
",",
"delimiter",
")",
"{",
"var",
"arr",
"=",
"line",
".",
"split",
"(",
"delimiter",
")",
".",
"filter",
"(",
"Boolean",
")",
"return",
"arr",
"}"
] | Parse a string into an array by splitting it
at `delimiter` and filtering out empty values.
@param {String} line
@param {String|RegExp} delimiter
@return {Array}
@api private | [
"Parse",
"a",
"string",
"into",
"an",
"array",
"by",
"splitting",
"it",
"at",
"delimiter",
"and",
"filtering",
"out",
"empty",
"values",
"."
] | 56dca2a417f893380b69009c646ec2b2fc23677f | https://github.com/gummesson/tiny-csv/blob/56dca2a417f893380b69009c646ec2b2fc23677f/index.js#L44-L49 | train |
gummesson/tiny-csv | index.js | toObject | function toObject(row, header) {
var obj = {}
row.forEach(function(value, key) {
obj[header[key]] = value
})
return obj
} | javascript | function toObject(row, header) {
var obj = {}
row.forEach(function(value, key) {
obj[header[key]] = value
})
return obj
} | [
"function",
"toObject",
"(",
"row",
",",
"header",
")",
"{",
"var",
"obj",
"=",
"{",
"}",
"row",
".",
"forEach",
"(",
"function",
"(",
"value",
",",
"key",
")",
"{",
"obj",
"[",
"header",
"[",
"key",
"]",
"]",
"=",
"value",
"}",
")",
"return",
... | Construct an object by using the items in `row`
as values and the items in `header` as keys.
@param {Array} row
@param {Array} header
@return {Object}
@api private | [
"Construct",
"an",
"object",
"by",
"using",
"the",
"items",
"in",
"row",
"as",
"values",
"and",
"the",
"items",
"in",
"header",
"as",
"keys",
"."
] | 56dca2a417f893380b69009c646ec2b2fc23677f | https://github.com/gummesson/tiny-csv/blob/56dca2a417f893380b69009c646ec2b2fc23677f/index.js#L62-L68 | train |
SilentCicero/wafr | bin/wafr.js | writeContractsFile | function writeContractsFile(contractsFilePath, contractsObject, callback) { // eslint-disable-line
if (typeof contractsFilePath !== 'string') {
return callback();
}
if (utils.filenameExtension(contractsFilePath) !== 'json') {
throw new Error('Your contracts output file must be a JSON file (i.e. --output ... | javascript | function writeContractsFile(contractsFilePath, contractsObject, callback) { // eslint-disable-line
if (typeof contractsFilePath !== 'string') {
return callback();
}
if (utils.filenameExtension(contractsFilePath) !== 'json') {
throw new Error('Your contracts output file must be a JSON file (i.e. --output ... | [
"function",
"writeContractsFile",
"(",
"contractsFilePath",
",",
"contractsObject",
",",
"callback",
")",
"{",
"// eslint-disable-line",
"if",
"(",
"typeof",
"contractsFilePath",
"!==",
"'string'",
")",
"{",
"return",
"callback",
"(",
")",
";",
"}",
"if",
"(",
"... | write contracts file | [
"write",
"contracts",
"file"
] | 2c7483feec5df346d8903cab5badc17143c3876d | https://github.com/SilentCicero/wafr/blob/2c7483feec5df346d8903cab5badc17143c3876d/bin/wafr.js#L48-L64 | train |
SilentCicero/wafr | bin/wafr.js | writeStatsFile | function writeStatsFile(statsFilePath, statsObject, callback) { // eslint-disable-line
if (typeof statsFilePath !== 'string') {
return callback();
}
if (utils.filenameExtension(statsFilePath) !== 'json') {
throw new Error('Your stats output file must be a JSON file (i.e. --stats ./stats.json)');
}
f... | javascript | function writeStatsFile(statsFilePath, statsObject, callback) { // eslint-disable-line
if (typeof statsFilePath !== 'string') {
return callback();
}
if (utils.filenameExtension(statsFilePath) !== 'json') {
throw new Error('Your stats output file must be a JSON file (i.e. --stats ./stats.json)');
}
f... | [
"function",
"writeStatsFile",
"(",
"statsFilePath",
",",
"statsObject",
",",
"callback",
")",
"{",
"// eslint-disable-line",
"if",
"(",
"typeof",
"statsFilePath",
"!==",
"'string'",
")",
"{",
"return",
"callback",
"(",
")",
";",
"}",
"if",
"(",
"utils",
".",
... | write stats file | [
"write",
"stats",
"file"
] | 2c7483feec5df346d8903cab5badc17143c3876d | https://github.com/SilentCicero/wafr/blob/2c7483feec5df346d8903cab5badc17143c3876d/bin/wafr.js#L67-L83 | train |
BenoitAverty/cycle-react-driver | src/makeCycleReactDriver.js | makeCycleReactDriver | function makeCycleReactDriver(element, querySelector) {
if (typeof element === 'undefined') {
throw Error('Missing or invalid react element');
}
if (typeof querySelector !== 'string') {
throw new Error('Missing or invalid querySelector');
}
const source$ = new Rx.ReplaySubject();
const callback = ... | javascript | function makeCycleReactDriver(element, querySelector) {
if (typeof element === 'undefined') {
throw Error('Missing or invalid react element');
}
if (typeof querySelector !== 'string') {
throw new Error('Missing or invalid querySelector');
}
const source$ = new Rx.ReplaySubject();
const callback = ... | [
"function",
"makeCycleReactDriver",
"(",
"element",
",",
"querySelector",
")",
"{",
"if",
"(",
"typeof",
"element",
"===",
"'undefined'",
")",
"{",
"throw",
"Error",
"(",
"'Missing or invalid react element'",
")",
";",
"}",
"if",
"(",
"typeof",
"querySelector",
... | Factory method for the cycle react driver. | [
"Factory",
"method",
"for",
"the",
"cycle",
"react",
"driver",
"."
] | bc5e718ce7ba493792fdbe540c29906c6726404b | https://github.com/BenoitAverty/cycle-react-driver/blob/bc5e718ce7ba493792fdbe540c29906c6726404b/src/makeCycleReactDriver.js#L12-L47 | train |
fcamarlinghi/grunt-esmin | tasks/esmin.js | function (callback, source, dest)
{
compressor.compress(
// Source can either be a file path or source code
source,
// Options
{
charset: 'utf8',
type: 'js',
nomunge: true,
'preserve-semi': true
... | javascript | function (callback, source, dest)
{
compressor.compress(
// Source can either be a file path or source code
source,
// Options
{
charset: 'utf8',
type: 'js',
nomunge: true,
'preserve-semi': true
... | [
"function",
"(",
"callback",
",",
"source",
",",
"dest",
")",
"{",
"compressor",
".",
"compress",
"(",
"// Source can either be a file path or source code ",
"source",
",",
"// Options",
"{",
"charset",
":",
"'utf8'",
",",
"type",
":",
"'js'",
",",
"nomunge",
":... | Minifies the passed extendscript files using YUI. | [
"Minifies",
"the",
"passed",
"extendscript",
"files",
"using",
"YUI",
"."
] | 2e0ec34cfd9791475469076e562b5ed176ff98ce | https://github.com/fcamarlinghi/grunt-esmin/blob/2e0ec34cfd9791475469076e562b5ed176ff98ce/tasks/esmin.js#L35-L63 | train | |
carrascoMDD/protractor-relaunchable | lib/launcher.js | function(task, pid) {
this.task = task;
this.pid = pid;
this.failedCount = 0;
this.buffer = '';
this.exitCode = -1;
this.insertTag = true;
} | javascript | function(task, pid) {
this.task = task;
this.pid = pid;
this.failedCount = 0;
this.buffer = '';
this.exitCode = -1;
this.insertTag = true;
} | [
"function",
"(",
"task",
",",
"pid",
")",
"{",
"this",
".",
"task",
"=",
"task",
";",
"this",
".",
"pid",
"=",
"pid",
";",
"this",
".",
"failedCount",
"=",
"0",
";",
"this",
".",
"buffer",
"=",
"''",
";",
"this",
".",
"exitCode",
"=",
"-",
"1",... | A reporter for a specific task.
@constructor
@param {object} task Task that is being reported.
@param {number} pid PID of process running the task. | [
"A",
"reporter",
"for",
"a",
"specific",
"task",
"."
] | c18e17ecd8b5b036217f87680800c6e14b47361f | https://github.com/carrascoMDD/protractor-relaunchable/blob/c18e17ecd8b5b036217f87680800c6e14b47361f/lib/launcher.js#L236-L243 | train | |
senecajs/seneca-level-store | level-store.js | get_db | function get_db (ent, done) {
var folder = internals.makefolderpath(opts.folder, ent)
var db = dbmap[folder]
if (db) {
return done(null, db)
}
internals.ensurefolder(folder, internals.error(done, function () {
db = dbmap[folder]
if (db) {
return done(null, db)
}
... | javascript | function get_db (ent, done) {
var folder = internals.makefolderpath(opts.folder, ent)
var db = dbmap[folder]
if (db) {
return done(null, db)
}
internals.ensurefolder(folder, internals.error(done, function () {
db = dbmap[folder]
if (db) {
return done(null, db)
}
... | [
"function",
"get_db",
"(",
"ent",
",",
"done",
")",
"{",
"var",
"folder",
"=",
"internals",
".",
"makefolderpath",
"(",
"opts",
".",
"folder",
",",
"ent",
")",
"var",
"db",
"=",
"dbmap",
"[",
"folder",
"]",
"if",
"(",
"db",
")",
"{",
"return",
"don... | Get the levelup reference | [
"Get",
"the",
"levelup",
"reference"
] | 9ab680cf6dab09d32e942348c82362e25d54c0d2 | https://github.com/senecajs/seneca-level-store/blob/9ab680cf6dab09d32e942348c82362e25d54c0d2/level-store.js#L33-L57 | train |
Koyfin/EzetechTechanJS | src/plot/crosshair.js | crosshair | function crosshair(g) {
var group = g.selectAll('g.data.top').data([change], function(d) { return d; }),
groupEnter = group.enter(),
dataEnter = groupEnter.append('g').attr('class', 'data top').style('display', 'none');
group.exit().remove();
dataEnter.append('path').attr('class'... | javascript | function crosshair(g) {
var group = g.selectAll('g.data.top').data([change], function(d) { return d; }),
groupEnter = group.enter(),
dataEnter = groupEnter.append('g').attr('class', 'data top').style('display', 'none');
group.exit().remove();
dataEnter.append('path').attr('class'... | [
"function",
"crosshair",
"(",
"g",
")",
"{",
"var",
"group",
"=",
"g",
".",
"selectAll",
"(",
"'g.data.top'",
")",
".",
"data",
"(",
"[",
"change",
"]",
",",
"function",
"(",
"d",
")",
"{",
"return",
"d",
";",
"}",
")",
",",
"groupEnter",
"=",
"g... | Track changes to this object, to know when to redraw | [
"Track",
"changes",
"to",
"this",
"object",
"to",
"know",
"when",
"to",
"redraw"
] | 9edf5e7401bac127650c64c388e27159e7c03f89 | https://github.com/Koyfin/EzetechTechanJS/blob/9edf5e7401bac127650c64c388e27159e7c03f89/src/plot/crosshair.js#L13-L29 | train |
pqml/dom | lib/Component.js | Component | function Component (props) {
this._parent = null
this._collector = { refs: [], components: [] }
/**
* > Contains all component properties and children. <br>
* > Do not modify it directly, but recreate a new component using `cloneElement` instead
* @type {object}
* @category Properties
*/
this.pr... | javascript | function Component (props) {
this._parent = null
this._collector = { refs: [], components: [] }
/**
* > Contains all component properties and children. <br>
* > Do not modify it directly, but recreate a new component using `cloneElement` instead
* @type {object}
* @category Properties
*/
this.pr... | [
"function",
"Component",
"(",
"props",
")",
"{",
"this",
".",
"_parent",
"=",
"null",
"this",
".",
"_collector",
"=",
"{",
"refs",
":",
"[",
"]",
",",
"components",
":",
"[",
"]",
"}",
"/**\n * > Contains all component properties and children. <br>\n * > Do no... | Create a new Component
@class Component
@param {object} [props={}] Component properties / attributes. Can also contains children.
@constructor | [
"Create",
"a",
"new",
"Component"
] | c9dfc7c8237f7662361fc635af4b1e1302260f44 | https://github.com/pqml/dom/blob/c9dfc7c8237f7662361fc635af4b1e1302260f44/lib/Component.js#L12-L37 | train |
azemoh/jusibe | index.js | Jusibe | function Jusibe(publicKey, accessToken) {
if (!(publicKey || accessToken)) {
throw new Error('Provide both Jusibe PUBLIC_KEY and ACCESS_TOKEN');
}
if (!(this instanceof Jusibe)) {
return new Jusibe(publicKey, accessToken);
}
this.options = {
auth: {
user: publicKey,
pass: accessToken... | javascript | function Jusibe(publicKey, accessToken) {
if (!(publicKey || accessToken)) {
throw new Error('Provide both Jusibe PUBLIC_KEY and ACCESS_TOKEN');
}
if (!(this instanceof Jusibe)) {
return new Jusibe(publicKey, accessToken);
}
this.options = {
auth: {
user: publicKey,
pass: accessToken... | [
"function",
"Jusibe",
"(",
"publicKey",
",",
"accessToken",
")",
"{",
"if",
"(",
"!",
"(",
"publicKey",
"||",
"accessToken",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Provide both Jusibe PUBLIC_KEY and ACCESS_TOKEN'",
")",
";",
"}",
"if",
"(",
"!",
"(",... | Create new Jusibe instances
@param {String} publicKey Jusibe Public Key
@param {String} accessToken Jusibe Access Token
@return {Jusibe} | [
"Create",
"new",
"Jusibe",
"instances"
] | 9ebe6a83ea67b732881dfb952cee066f3f88c782 | https://github.com/azemoh/jusibe/blob/9ebe6a83ea67b732881dfb952cee066f3f88c782/index.js#L10-L26 | train |
nullivex/oose-sdk | helpers/Prism.js | function(opts){
//setup options
this.opts = new ObjectManage({
username: '',
password: '',
domain: 'cdn.oose.io',
prism: {
host: null,
port: 5971
}
})
this.opts.$load(opts)
//set properties
this.api = {}
this.authenticated = false
this.connected = false
this.session = {... | javascript | function(opts){
//setup options
this.opts = new ObjectManage({
username: '',
password: '',
domain: 'cdn.oose.io',
prism: {
host: null,
port: 5971
}
})
this.opts.$load(opts)
//set properties
this.api = {}
this.authenticated = false
this.connected = false
this.session = {... | [
"function",
"(",
"opts",
")",
"{",
"//setup options",
"this",
".",
"opts",
"=",
"new",
"ObjectManage",
"(",
"{",
"username",
":",
"''",
",",
"password",
":",
"''",
",",
"domain",
":",
"'cdn.oose.io'",
",",
"prism",
":",
"{",
"host",
":",
"null",
",",
... | Prism Public Interaction Helper
@param {object} opts
@constructor | [
"Prism",
"Public",
"Interaction",
"Helper"
] | 46a3a950107b904825195b2a6645d9db5a3dd5bd | https://github.com/nullivex/oose-sdk/blob/46a3a950107b904825195b2a6645d9db5a3dd5bd/helpers/Prism.js#L21-L38 | train | |
spacemaus/postvox | vox-server/interchangedb.js | ensureTimestamps | function ensureTimestamps(columns, allowSyncedAt) {
var now = Date.now();
if (!allowSyncedAt || !columns.syncedAt) {
columns.syncedAt = now;
}
if (!columns.createdAt) {
// Take the value from the client, if present:
columns.createdAt = columns.updatedAt;
}
} | javascript | function ensureTimestamps(columns, allowSyncedAt) {
var now = Date.now();
if (!allowSyncedAt || !columns.syncedAt) {
columns.syncedAt = now;
}
if (!columns.createdAt) {
// Take the value from the client, if present:
columns.createdAt = columns.updatedAt;
}
} | [
"function",
"ensureTimestamps",
"(",
"columns",
",",
"allowSyncedAt",
")",
"{",
"var",
"now",
"=",
"Date",
".",
"now",
"(",
")",
";",
"if",
"(",
"!",
"allowSyncedAt",
"||",
"!",
"columns",
".",
"syncedAt",
")",
"{",
"columns",
".",
"syncedAt",
"=",
"no... | Sets the `syncedAt` and `createdAt` timestamps, if they are not set. | [
"Sets",
"the",
"syncedAt",
"and",
"createdAt",
"timestamps",
"if",
"they",
"are",
"not",
"set",
"."
] | de98e5ed37edaee1b1edadf93e15eb8f8d21f457 | https://github.com/spacemaus/postvox/blob/de98e5ed37edaee1b1edadf93e15eb8f8d21f457/vox-server/interchangedb.js#L30-L39 | train |
spacemaus/postvox | vox-server/interchangedb.js | _queryForTargetSessions | function _queryForTargetSessions(url, minDbSeq) {
var where = { isConnected: true };
if (minDbSeq) {
where.connectedAtDbSeq = { gt: minDbSeq };
}
return Session.findAll({
where: where,
attributes: [
'sessionId',
'connectedAtDbSeq',
],
include... | javascript | function _queryForTargetSessions(url, minDbSeq) {
var where = { isConnected: true };
if (minDbSeq) {
where.connectedAtDbSeq = { gt: minDbSeq };
}
return Session.findAll({
where: where,
attributes: [
'sessionId',
'connectedAtDbSeq',
],
include... | [
"function",
"_queryForTargetSessions",
"(",
"url",
",",
"minDbSeq",
")",
"{",
"var",
"where",
"=",
"{",
"isConnected",
":",
"true",
"}",
";",
"if",
"(",
"minDbSeq",
")",
"{",
"where",
".",
"connectedAtDbSeq",
"=",
"{",
"gt",
":",
"minDbSeq",
"}",
";",
... | Queries for sessions that are connected and also have an active route for
the given URL.
@param {String} url The routeUrl to query for.
@param {Number} [minDbSeq] The minimum connectedAtDbSeq to query for. | [
"Queries",
"for",
"sessions",
"that",
"are",
"connected",
"and",
"also",
"have",
"an",
"active",
"route",
"for",
"the",
"given",
"URL",
"."
] | de98e5ed37edaee1b1edadf93e15eb8f8d21f457 | https://github.com/spacemaus/postvox/blob/de98e5ed37edaee1b1edadf93e15eb8f8d21f457/vox-server/interchangedb.js#L260-L289 | train |
MD4/potato-masher | lib/filter.js | _filter | function _filter(data, schema) {
if (typeof data !== 'object' ||
data === null ||
schema === null) {
return data;
}
if (schema instanceof Array) {
return _filterByArraySchema(data, schema);
}
if (typeof schema === 'object') {
return _filterByObjectSchema(data,... | javascript | function _filter(data, schema) {
if (typeof data !== 'object' ||
data === null ||
schema === null) {
return data;
}
if (schema instanceof Array) {
return _filterByArraySchema(data, schema);
}
if (typeof schema === 'object') {
return _filterByObjectSchema(data,... | [
"function",
"_filter",
"(",
"data",
",",
"schema",
")",
"{",
"if",
"(",
"typeof",
"data",
"!==",
"'object'",
"||",
"data",
"===",
"null",
"||",
"schema",
"===",
"null",
")",
"{",
"return",
"data",
";",
"}",
"if",
"(",
"schema",
"instanceof",
"Array",
... | private
Returns a new object with fields from data and present in the given schema
@param data Object to filter
@param schema Fields to keep
@returns {*}
@private | [
"private",
"Returns",
"a",
"new",
"object",
"with",
"fields",
"from",
"data",
"and",
"present",
"in",
"the",
"given",
"schema"
] | 88e21a45350e7204f4102e7186c5beaa8753bd7f | https://github.com/MD4/potato-masher/blob/88e21a45350e7204f4102e7186c5beaa8753bd7f/lib/filter.js#L16-L29 | train |
MD4/potato-masher | lib/filter.js | _filterByArraySchema | function _filterByArraySchema(data, schema) {
return Object
.keys(data)
.filter(function (key) {
return !!~schema.indexOf(key);
})
.reduce(function (memo, key) {
memo[key] = data[key];
return memo;
}, {});
} | javascript | function _filterByArraySchema(data, schema) {
return Object
.keys(data)
.filter(function (key) {
return !!~schema.indexOf(key);
})
.reduce(function (memo, key) {
memo[key] = data[key];
return memo;
}, {});
} | [
"function",
"_filterByArraySchema",
"(",
"data",
",",
"schema",
")",
"{",
"return",
"Object",
".",
"keys",
"(",
"data",
")",
".",
"filter",
"(",
"function",
"(",
"key",
")",
"{",
"return",
"!",
"!",
"~",
"schema",
".",
"indexOf",
"(",
"key",
")",
";"... | Filters an object from an array schema
@param data Object to filter
@param schema Fields to keep
@returns {*}
@private | [
"Filters",
"an",
"object",
"from",
"an",
"array",
"schema"
] | 88e21a45350e7204f4102e7186c5beaa8753bd7f | https://github.com/MD4/potato-masher/blob/88e21a45350e7204f4102e7186c5beaa8753bd7f/lib/filter.js#L38-L48 | train |
MD4/potato-masher | lib/filter.js | _filterByObjectSchema | function _filterByObjectSchema(data, schema) {
return Object
.keys(data)
.filter(function (key) {
return schema.hasOwnProperty(key);
})
.reduce(function (memo, key) {
var value = data[key];
var schemaPart = schema[key];
if (typeof schem... | javascript | function _filterByObjectSchema(data, schema) {
return Object
.keys(data)
.filter(function (key) {
return schema.hasOwnProperty(key);
})
.reduce(function (memo, key) {
var value = data[key];
var schemaPart = schema[key];
if (typeof schem... | [
"function",
"_filterByObjectSchema",
"(",
"data",
",",
"schema",
")",
"{",
"return",
"Object",
".",
"keys",
"(",
"data",
")",
".",
"filter",
"(",
"function",
"(",
"key",
")",
"{",
"return",
"schema",
".",
"hasOwnProperty",
"(",
"key",
")",
";",
"}",
")... | Filters an object from an object schema
@param data Object to filter
@param schema Fields to keep
@returns {*}
@private | [
"Filters",
"an",
"object",
"from",
"an",
"object",
"schema"
] | 88e21a45350e7204f4102e7186c5beaa8753bd7f | https://github.com/MD4/potato-masher/blob/88e21a45350e7204f4102e7186c5beaa8753bd7f/lib/filter.js#L57-L73 | train |
tillarnold/fixed-2d-array | lib/fixed-2d-array.js | Fixed2DArray | function Fixed2DArray(rows, cols, defaultValue) {
if(rows <= 0 || cols <= 0){
throw new Error('fixed-2d-array: Must have more then 0 rows and 0 columns.');
}
this._width = cols;
this._height = rows;
this._grid = [];
for (var i = 0; i < rows; i++) {
this._grid[i] = [];
for (var j = 0; j < cols;... | javascript | function Fixed2DArray(rows, cols, defaultValue) {
if(rows <= 0 || cols <= 0){
throw new Error('fixed-2d-array: Must have more then 0 rows and 0 columns.');
}
this._width = cols;
this._height = rows;
this._grid = [];
for (var i = 0; i < rows; i++) {
this._grid[i] = [];
for (var j = 0; j < cols;... | [
"function",
"Fixed2DArray",
"(",
"rows",
",",
"cols",
",",
"defaultValue",
")",
"{",
"if",
"(",
"rows",
"<=",
"0",
"||",
"cols",
"<=",
"0",
")",
"{",
"throw",
"new",
"Error",
"(",
"'fixed-2d-array: Must have more then 0 rows and 0 columns.'",
")",
";",
"}",
... | An array with a fixed height and width.
@param row {number} number of rows, corresponds to the height.
@param cols {number} number of columns, corresponds to the width.
@param defaultValue the initial value for the array elements
@class | [
"An",
"array",
"with",
"a",
"fixed",
"height",
"and",
"width",
"."
] | 39ffdfab7733157bc677ce068c908364f1a74c16 | https://github.com/tillarnold/fixed-2d-array/blob/39ffdfab7733157bc677ce068c908364f1a74c16/lib/fixed-2d-array.js#L9-L24 | train |
cliffano/cmdt | lib/cli.js | exec | function exec() {
var actions = {
commands: {
init: { action: _init },
run : { action: _run }
}
};
cli.command(__dirname, actions);
} | javascript | function exec() {
var actions = {
commands: {
init: { action: _init },
run : { action: _run }
}
};
cli.command(__dirname, actions);
} | [
"function",
"exec",
"(",
")",
"{",
"var",
"actions",
"=",
"{",
"commands",
":",
"{",
"init",
":",
"{",
"action",
":",
"_init",
"}",
",",
"run",
":",
"{",
"action",
":",
"_run",
"}",
"}",
"}",
";",
"cli",
".",
"command",
"(",
"__dirname",
",",
"... | Execute Cmdt CLI. | [
"Execute",
"Cmdt",
"CLI",
"."
] | 8b8de56a23994a02117069c9c6da5fa1a3176fe5 | https://github.com/cliffano/cmdt/blob/8b8de56a23994a02117069c9c6da5fa1a3176fe5/lib/cli.js#L30-L40 | train |
megahertz/node-comments-parser | index.js | parse | function parse(content, options) {
options = options || {};
options = defaults(options, {
addEsprimaInfo: false,
parseJsDocTags: true,
hideJsDocTags: true,
trim: true
});
var comments = [];
var ast = esprima.parse(content, {
tolerant: true,
comment: true,
tokens: true,
... | javascript | function parse(content, options) {
options = options || {};
options = defaults(options, {
addEsprimaInfo: false,
parseJsDocTags: true,
hideJsDocTags: true,
trim: true
});
var comments = [];
var ast = esprima.parse(content, {
tolerant: true,
comment: true,
tokens: true,
... | [
"function",
"parse",
"(",
"content",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"options",
"=",
"defaults",
"(",
"options",
",",
"{",
"addEsprimaInfo",
":",
"false",
",",
"parseJsDocTags",
":",
"true",
",",
"hideJsDocTags",
... | Return array of comment objects
@param {string} content
@param {Object} [options]
@param {boolean} [options.addEsprimaInfo=false] Add node object which
is generated by Esprima
@param {boolean} [options.parseJsDocTags=true]
@param {boolean} [options.hideJsDocTags=true] False to remove lines
with jsdoc tags
@param {boo... | [
"Return",
"array",
"of",
"comment",
"objects"
] | d849f23bf4210e999a2aa56ebad31588b2199cb5 | https://github.com/megahertz/node-comments-parser/blob/d849f23bf4210e999a2aa56ebad31588b2199cb5/index.js#L18-L66 | train |
megahertz/node-comments-parser | index.js | formatLines | function formatLines(lines, jsDoc, trim) {
jsDoc = undefined === jsDoc || true;
trim = undefined === trim || true;
lines = lines.slice();
for (var i = 0; i < lines.length; i++) {
var line = lines[i] + '';
if (jsDoc) {
line = line.replace(/^\s*\*/, '');
}
if ('right' === trim) {
... | javascript | function formatLines(lines, jsDoc, trim) {
jsDoc = undefined === jsDoc || true;
trim = undefined === trim || true;
lines = lines.slice();
for (var i = 0; i < lines.length; i++) {
var line = lines[i] + '';
if (jsDoc) {
line = line.replace(/^\s*\*/, '');
}
if ('right' === trim) {
... | [
"function",
"formatLines",
"(",
"lines",
",",
"jsDoc",
",",
"trim",
")",
"{",
"jsDoc",
"=",
"undefined",
"===",
"jsDoc",
"||",
"true",
";",
"trim",
"=",
"undefined",
"===",
"trim",
"||",
"true",
";",
"lines",
"=",
"lines",
".",
"slice",
"(",
")",
";"... | Remove whitespace and comment expressions
@param {Array<string>} lines
@param {boolean} [jsDoc=true]
@param {boolean|string} [trim=true] true, false, 'right'
@returns {Array} | [
"Remove",
"whitespace",
"and",
"comment",
"expressions"
] | d849f23bf4210e999a2aa56ebad31588b2199cb5 | https://github.com/megahertz/node-comments-parser/blob/d849f23bf4210e999a2aa56ebad31588b2199cb5/index.js#L75-L99 | train |
megahertz/node-comments-parser | index.js | applyJsDocTags | function applyJsDocTags(comment, removeTagLine) {
removeTagLine = (undefined !== removeTagLine) ? removeTagLine : true;
var lines = [];
comment.tags = [];
for (var i = 0; i < comment.lines.length; i++) {
var line = comment.lines[i];
if ('@' === line.charAt(0)) {
var spacePos = line.indexOf(' ');... | javascript | function applyJsDocTags(comment, removeTagLine) {
removeTagLine = (undefined !== removeTagLine) ? removeTagLine : true;
var lines = [];
comment.tags = [];
for (var i = 0; i < comment.lines.length; i++) {
var line = comment.lines[i];
if ('@' === line.charAt(0)) {
var spacePos = line.indexOf(' ');... | [
"function",
"applyJsDocTags",
"(",
"comment",
",",
"removeTagLine",
")",
"{",
"removeTagLine",
"=",
"(",
"undefined",
"!==",
"removeTagLine",
")",
"?",
"removeTagLine",
":",
"true",
";",
"var",
"lines",
"=",
"[",
"]",
";",
"comment",
".",
"tags",
"=",
"[",... | Find tags in comment, remove this lines and apply as property
@param {Object} comment
@param {boolean} [removeTagLine=true] | [
"Find",
"tags",
"in",
"comment",
"remove",
"this",
"lines",
"and",
"apply",
"as",
"property"
] | d849f23bf4210e999a2aa56ebad31588b2199cb5 | https://github.com/megahertz/node-comments-parser/blob/d849f23bf4210e999a2aa56ebad31588b2199cb5/index.js#L106-L130 | train |
megahertz/node-comments-parser | index.js | defaults | function defaults(object, options) {
object = object || {};
for (var i in options) {
if (undefined === object[i] && options.hasOwnProperty(i)) {
object[i] = options[i];
}
}
return object;
} | javascript | function defaults(object, options) {
object = object || {};
for (var i in options) {
if (undefined === object[i] && options.hasOwnProperty(i)) {
object[i] = options[i];
}
}
return object;
} | [
"function",
"defaults",
"(",
"object",
",",
"options",
")",
"{",
"object",
"=",
"object",
"||",
"{",
"}",
";",
"for",
"(",
"var",
"i",
"in",
"options",
")",
"{",
"if",
"(",
"undefined",
"===",
"object",
"[",
"i",
"]",
"&&",
"options",
".",
"hasOwnP... | Extend object if a property is not defined yet
@param {Object} object
@param {Object} options
@returns {Object} | [
"Extend",
"object",
"if",
"a",
"property",
"is",
"not",
"defined",
"yet"
] | d849f23bf4210e999a2aa56ebad31588b2199cb5 | https://github.com/megahertz/node-comments-parser/blob/d849f23bf4210e999a2aa56ebad31588b2199cb5/index.js#L161-L169 | train |
jakwings/meta-matter | index.js | matter | function matter(str, opts) {
str = formatString(str);
opts = formatOptions(opts);
var result = {src: str, data: null, body: str};
if (!str) {
return result;
}
var strict = !opts.loose;
var header = opts.delims[0];
var footer = opts.delims[1];
var dataStart, dataEnd;
// Front matter must start ... | javascript | function matter(str, opts) {
str = formatString(str);
opts = formatOptions(opts);
var result = {src: str, data: null, body: str};
if (!str) {
return result;
}
var strict = !opts.loose;
var header = opts.delims[0];
var footer = opts.delims[1];
var dataStart, dataEnd;
// Front matter must start ... | [
"function",
"matter",
"(",
"str",
",",
"opts",
")",
"{",
"str",
"=",
"formatString",
"(",
"str",
")",
";",
"opts",
"=",
"formatOptions",
"(",
"opts",
")",
";",
"var",
"result",
"=",
"{",
"src",
":",
"str",
",",
"data",
":",
"null",
",",
"body",
"... | Parse the input string with options.
@param {String} str The string to parse.
@param {Object?} opts
@param {Boolean?} opts.loose Whether to tolerate ambiguous delimiters. Default: false
@param {String?} opts.lang The name of the parser to use if opts.parsers is not a function. Default: 'yaml'
@param {(String|Array)?} ... | [
"Parse",
"the",
"input",
"string",
"with",
"options",
"."
] | c8e3f4daffb09485bd8a18e6337d17fee0a20460 | https://github.com/jakwings/meta-matter/blob/c8e3f4daffb09485bd8a18e6337d17fee0a20460/index.js#L18-L79 | train |
yeptlabs/wns | src/core/base/wnModule.js | function (classesSource)
{
this.e.log&&this.e.log('Importing core classes...','system');
var classesSource = classesSource||global.wns.coreClasses;
var classBuilder = new process.wns.wnBuild(classesSource,this);
this.setComponent('classBuilder',classBuilder);
classBuilder.build();
return this;
} | javascript | function (classesSource)
{
this.e.log&&this.e.log('Importing core classes...','system');
var classesSource = classesSource||global.wns.coreClasses;
var classBuilder = new process.wns.wnBuild(classesSource,this);
this.setComponent('classBuilder',classBuilder);
classBuilder.build();
return this;
} | [
"function",
"(",
"classesSource",
")",
"{",
"this",
".",
"e",
".",
"log",
"&&",
"this",
".",
"e",
".",
"log",
"(",
"'Importing core classes...'",
",",
"'system'",
")",
";",
"var",
"classesSource",
"=",
"classesSource",
"||",
"global",
".",
"wns",
".",
"c... | Compile module's classes.
It gets classes source you give or from the core classes.
@param $classesSource (optional)
@return this | [
"Compile",
"module",
"s",
"classes",
".",
"It",
"gets",
"classes",
"source",
"you",
"give",
"or",
"from",
"the",
"core",
"classes",
"."
] | c42602b062dcf6bbffc22e4365bba2cbf363fe2f | https://github.com/yeptlabs/wns/blob/c42602b062dcf6bbffc22e4365bba2cbf363fe2f/src/core/base/wnModule.js#L142-L152 | train | |
yeptlabs/wns | src/core/base/wnModule.js | function ()
{
var nmPath = this.modulePath + 'node_modules/';
var pkgJson;
var pkgName;
var pkgInfo;
var packageList = {};
var validScript = /[\w|\W]+\.[js|coffee]+$/;
if (fs.existsSync(nmPath))
{
this.e.log&&this.e.log('Importing packages...','system');
var packages = fs.readdirSync(n... | javascript | function ()
{
var nmPath = this.modulePath + 'node_modules/';
var pkgJson;
var pkgName;
var pkgInfo;
var packageList = {};
var validScript = /[\w|\W]+\.[js|coffee]+$/;
if (fs.existsSync(nmPath))
{
this.e.log&&this.e.log('Importing packages...','system');
var packages = fs.readdirSync(n... | [
"function",
"(",
")",
"{",
"var",
"nmPath",
"=",
"this",
".",
"modulePath",
"+",
"'node_modules/'",
";",
"var",
"pkgJson",
";",
"var",
"pkgName",
";",
"var",
"pkgInfo",
";",
"var",
"packageList",
"=",
"{",
"}",
";",
"var",
"validScript",
"=",
"/",
"[\\... | Import package classes from node_modules directory | [
"Import",
"package",
"classes",
"from",
"node_modules",
"directory"
] | c42602b062dcf6bbffc22e4365bba2cbf363fe2f | https://github.com/yeptlabs/wns/blob/c42602b062dcf6bbffc22e4365bba2cbf363fe2f/src/core/base/wnModule.js#L157-L207 | train | |
yeptlabs/wns | src/core/base/wnModule.js | function (packageList)
{
if (!_.isObject(packageList))
return false;
var pkgList = _.keys(packageList);
var pkgRequire;
var pkgName;
var pkgInfo;
var depName;
var depVersion;
var i=0;
var valid;
var error;
while (pkgList.length > 0)
{
valid=true;
error=[];
pkgName=... | javascript | function (packageList)
{
if (!_.isObject(packageList))
return false;
var pkgList = _.keys(packageList);
var pkgRequire;
var pkgName;
var pkgInfo;
var depName;
var depVersion;
var i=0;
var valid;
var error;
while (pkgList.length > 0)
{
valid=true;
error=[];
pkgName=... | [
"function",
"(",
"packageList",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isObject",
"(",
"packageList",
")",
")",
"return",
"false",
";",
"var",
"pkgList",
"=",
"_",
".",
"keys",
"(",
"packageList",
")",
";",
"var",
"pkgRequire",
";",
"var",
"pkgName",
"... | Remove invalid packages from the packageList.
@param object $packageList | [
"Remove",
"invalid",
"packages",
"from",
"the",
"packageList",
"."
] | c42602b062dcf6bbffc22e4365bba2cbf363fe2f | https://github.com/yeptlabs/wns/blob/c42602b062dcf6bbffc22e4365bba2cbf363fe2f/src/core/base/wnModule.js#L213-L261 | train | |
yeptlabs/wns | src/core/base/wnModule.js | function (packageList)
{
var classes;
var className;
var classSource;
var classBuilder = this.getComponent('classBuilder');
for (p in packageList)
{
classes = packageList[p].classes;
for (c in classes)
{
className = c;
classBuilder.addSource(className,classes[c],true);
}
... | javascript | function (packageList)
{
var classes;
var className;
var classSource;
var classBuilder = this.getComponent('classBuilder');
for (p in packageList)
{
classes = packageList[p].classes;
for (c in classes)
{
className = c;
classBuilder.addSource(className,classes[c],true);
}
... | [
"function",
"(",
"packageList",
")",
"{",
"var",
"classes",
";",
"var",
"className",
";",
"var",
"classSource",
";",
"var",
"classBuilder",
"=",
"this",
".",
"getComponent",
"(",
"'classBuilder'",
")",
";",
"for",
"(",
"p",
"in",
"packageList",
")",
"{",
... | Load all packages on the classes of the packageList.
@param object $packageList | [
"Load",
"all",
"packages",
"on",
"the",
"classes",
"of",
"the",
"packageList",
"."
] | c42602b062dcf6bbffc22e4365bba2cbf363fe2f | https://github.com/yeptlabs/wns/blob/c42602b062dcf6bbffc22e4365bba2cbf363fe2f/src/core/base/wnModule.js#L267-L285 | train | |
yeptlabs/wns | src/core/base/wnModule.js | function ()
{
this.e.log&&this.e.log('Importing from config...','system');
var importConfig = this.getConfig('import');
var cb = this.getComponent('classBuilder');
var validScript = /[\w|\W]+\.[js|coffee]+$/;
for (i in importConfig)
{
var path = this.modulePath+importConfig[i];
if (fs.exist... | javascript | function ()
{
this.e.log&&this.e.log('Importing from config...','system');
var importConfig = this.getConfig('import');
var cb = this.getComponent('classBuilder');
var validScript = /[\w|\W]+\.[js|coffee]+$/;
for (i in importConfig)
{
var path = this.modulePath+importConfig[i];
if (fs.exist... | [
"function",
"(",
")",
"{",
"this",
".",
"e",
".",
"log",
"&&",
"this",
".",
"e",
".",
"log",
"(",
"'Importing from config...'",
",",
"'system'",
")",
";",
"var",
"importConfig",
"=",
"this",
".",
"getConfig",
"(",
"'import'",
")",
";",
"var",
"cb",
"... | Import classes from the paths from configuration. | [
"Import",
"classes",
"from",
"the",
"paths",
"from",
"configuration",
"."
] | c42602b062dcf6bbffc22e4365bba2cbf363fe2f | https://github.com/yeptlabs/wns/blob/c42602b062dcf6bbffc22e4365bba2cbf363fe2f/src/core/base/wnModule.js#L290-L316 | train | |
yeptlabs/wns | src/core/base/wnModule.js | function ()
{
for (c in this.c)
{
if (this.c[c].build && this.c[c].build.extend && this.c[c].build.extend.indexOf('wnActiveRecord')!=-1)
{
this.prepareModel(c);
}
}
} | javascript | function ()
{
for (c in this.c)
{
if (this.c[c].build && this.c[c].build.extend && this.c[c].build.extend.indexOf('wnActiveRecord')!=-1)
{
this.prepareModel(c);
}
}
} | [
"function",
"(",
")",
"{",
"for",
"(",
"c",
"in",
"this",
".",
"c",
")",
"{",
"if",
"(",
"this",
".",
"c",
"[",
"c",
"]",
".",
"build",
"&&",
"this",
".",
"c",
"[",
"c",
"]",
".",
"build",
".",
"extend",
"&&",
"this",
".",
"c",
"[",
"c",
... | Prepare all models | [
"Prepare",
"all",
"models"
] | c42602b062dcf6bbffc22e4365bba2cbf363fe2f | https://github.com/yeptlabs/wns/blob/c42602b062dcf6bbffc22e4365bba2cbf363fe2f/src/core/base/wnModule.js#L321-L330 | train | |
yeptlabs/wns | src/core/base/wnModule.js | function (model) {
var c = this.c,
s = this;
this.m[model]=function () {
var modelClass = c[model];
return new modelClass({ autoInit: true }, s.c, s, s.db);
};
} | javascript | function (model) {
var c = this.c,
s = this;
this.m[model]=function () {
var modelClass = c[model];
return new modelClass({ autoInit: true }, s.c, s, s.db);
};
} | [
"function",
"(",
"model",
")",
"{",
"var",
"c",
"=",
"this",
".",
"c",
",",
"s",
"=",
"this",
";",
"this",
".",
"m",
"[",
"model",
"]",
"=",
"function",
"(",
")",
"{",
"var",
"modelClass",
"=",
"c",
"[",
"model",
"]",
";",
"return",
"new",
"m... | Prepare the model
@param $model | [
"Prepare",
"the",
"model"
] | c42602b062dcf6bbffc22e4365bba2cbf363fe2f | https://github.com/yeptlabs/wns/blob/c42602b062dcf6bbffc22e4365bba2cbf363fe2f/src/core/base/wnModule.js#L336-L343 | train | |
yeptlabs/wns | src/core/base/wnModule.js | function (file)
{
if (!_.isString(file))
return false;
var file = file+'';
this.e.log&&this.e.log('Loading module configuration from file: '+file,'system');
if (fs.statSync(file).isFile() && path.extname(file) == '.json')
{
var _data = (fs.readFileSync(file,'utf8').toString())
.replace(... | javascript | function (file)
{
if (!_.isString(file))
return false;
var file = file+'';
this.e.log&&this.e.log('Loading module configuration from file: '+file,'system');
if (fs.statSync(file).isFile() && path.extname(file) == '.json')
{
var _data = (fs.readFileSync(file,'utf8').toString())
.replace(... | [
"function",
"(",
"file",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isString",
"(",
"file",
")",
")",
"return",
"false",
";",
"var",
"file",
"=",
"file",
"+",
"''",
";",
"this",
".",
"e",
".",
"log",
"&&",
"this",
".",
"e",
".",
"log",
"(",
"'Loadi... | Get a JSON configuration from file then send it to the `setConfig`
@param string $file path to the file
@return boolean success? | [
"Get",
"a",
"JSON",
"configuration",
"from",
"file",
"then",
"send",
"it",
"to",
"the",
"setConfig"
] | c42602b062dcf6bbffc22e4365bba2cbf363fe2f | https://github.com/yeptlabs/wns/blob/c42602b062dcf6bbffc22e4365bba2cbf363fe2f/src/core/base/wnModule.js#L381-L401 | train | |
yeptlabs/wns | src/core/base/wnModule.js | function (components)
{
for (c in components)
{
_componentsConfig[c]=_.merge({}, components[c]);
if (this.hasComponent(c))
_.merge(_componentsConfig[c],this.getComponentsConfig[c]);
}
return this;
} | javascript | function (components)
{
for (c in components)
{
_componentsConfig[c]=_.merge({}, components[c]);
if (this.hasComponent(c))
_.merge(_componentsConfig[c],this.getComponentsConfig[c]);
}
return this;
} | [
"function",
"(",
"components",
")",
"{",
"for",
"(",
"c",
"in",
"components",
")",
"{",
"_componentsConfig",
"[",
"c",
"]",
"=",
"_",
".",
"merge",
"(",
"{",
"}",
",",
"components",
"[",
"c",
"]",
")",
";",
"if",
"(",
"this",
".",
"hasComponent",
... | Set new properties to the component configuration.
@param object $components components(id=>component configuration or instances)
Defaults to true, meaning the previously registered component configuration of the same ID
will be merged with the new configuration. If false, the existing configuration will be replaced c... | [
"Set",
"new",
"properties",
"to",
"the",
"component",
"configuration",
"."
] | c42602b062dcf6bbffc22e4365bba2cbf363fe2f | https://github.com/yeptlabs/wns/blob/c42602b062dcf6bbffc22e4365bba2cbf363fe2f/src/core/base/wnModule.js#L410-L419 | train | |
yeptlabs/wns | src/core/base/wnModule.js | function (className,config)
{
var component = this.createClass(className,config);
if (component)
component.setParent(this);
return component;
} | javascript | function (className,config)
{
var component = this.createClass(className,config);
if (component)
component.setParent(this);
return component;
} | [
"function",
"(",
"className",
",",
"config",
")",
"{",
"var",
"component",
"=",
"this",
".",
"createClass",
"(",
"className",
",",
"config",
")",
";",
"if",
"(",
"component",
")",
"component",
".",
"setParent",
"(",
"this",
")",
";",
"return",
"component... | Create a new instance of the component.
@param string $className component class (case-sensitive)
@param string $config component custom config
@return wnModule the module instance, false if the module is disabled or does not exist. | [
"Create",
"a",
"new",
"instance",
"of",
"the",
"component",
"."
] | c42602b062dcf6bbffc22e4365bba2cbf363fe2f | https://github.com/yeptlabs/wns/blob/c42602b062dcf6bbffc22e4365bba2cbf363fe2f/src/core/base/wnModule.js#L494-L500 | train | |
yeptlabs/wns | src/core/base/wnModule.js | function ()
{
this.setConfig({components: this.preload});
var preload = this.getConfig().components;
if (preload != undefined)
{
this.setComponents(preload);
}
return this;
} | javascript | function ()
{
this.setConfig({components: this.preload});
var preload = this.getConfig().components;
if (preload != undefined)
{
this.setComponents(preload);
}
return this;
} | [
"function",
"(",
")",
"{",
"this",
".",
"setConfig",
"(",
"{",
"components",
":",
"this",
".",
"preload",
"}",
")",
";",
"var",
"preload",
"=",
"this",
".",
"getConfig",
"(",
")",
".",
"components",
";",
"if",
"(",
"preload",
"!=",
"undefined",
")",
... | Preload all required components | [
"Preload",
"all",
"required",
"components"
] | c42602b062dcf6bbffc22e4365bba2cbf363fe2f | https://github.com/yeptlabs/wns/blob/c42602b062dcf6bbffc22e4365bba2cbf363fe2f/src/core/base/wnModule.js#L541-L550 | train | |
yeptlabs/wns | src/core/base/wnModule.js | function ()
{
var cps=this.getComponentsConfig();
for (c in cps)
{
var cpnt=this.getComponent(c);
if (cpnt)
this.e.log&&this.e.log('- Started component: '+cps[c].class+(cpnt.getConfig('alias')?' (as '+cpnt.getConfig('alias')+')':''),'system');
}
return this;
} | javascript | function ()
{
var cps=this.getComponentsConfig();
for (c in cps)
{
var cpnt=this.getComponent(c);
if (cpnt)
this.e.log&&this.e.log('- Started component: '+cps[c].class+(cpnt.getConfig('alias')?' (as '+cpnt.getConfig('alias')+')':''),'system');
}
return this;
} | [
"function",
"(",
")",
"{",
"var",
"cps",
"=",
"this",
".",
"getComponentsConfig",
"(",
")",
";",
"for",
"(",
"c",
"in",
"cps",
")",
"{",
"var",
"cpnt",
"=",
"this",
".",
"getComponent",
"(",
"c",
")",
";",
"if",
"(",
"cpnt",
")",
"this",
".",
"... | Start all preloaded components | [
"Start",
"all",
"preloaded",
"components"
] | c42602b062dcf6bbffc22e4365bba2cbf363fe2f | https://github.com/yeptlabs/wns/blob/c42602b062dcf6bbffc22e4365bba2cbf363fe2f/src/core/base/wnModule.js#L555-L565 | train | |
yeptlabs/wns | src/core/base/wnModule.js | function (modules)
{
for (m in modules)
{
_modulesConfig[m]=_.merge({}, modules[m]);
if (this.hasModule(m))
_.merge(_modulesConfig[m],this.getModulesConfig[m]);
}
return this;
} | javascript | function (modules)
{
for (m in modules)
{
_modulesConfig[m]=_.merge({}, modules[m]);
if (this.hasModule(m))
_.merge(_modulesConfig[m],this.getModulesConfig[m]);
}
return this;
} | [
"function",
"(",
"modules",
")",
"{",
"for",
"(",
"m",
"in",
"modules",
")",
"{",
"_modulesConfig",
"[",
"m",
"]",
"=",
"_",
".",
"merge",
"(",
"{",
"}",
",",
"modules",
"[",
"m",
"]",
")",
";",
"if",
"(",
"this",
".",
"hasModule",
"(",
"m",
... | Merge new configuration into the module configuration
@param object $modules application modules(id=>module configuration or instances)
Defaults to true, meaning the previously registered module configuration of the same ID
will be merged with the new configuration. If false, the existing configuration will be replace... | [
"Merge",
"new",
"configuration",
"into",
"the",
"module",
"configuration"
] | c42602b062dcf6bbffc22e4365bba2cbf363fe2f | https://github.com/yeptlabs/wns/blob/c42602b062dcf6bbffc22e4365bba2cbf363fe2f/src/core/base/wnModule.js#L574-L583 | train | |
yeptlabs/wns | src/core/base/wnModule.js | function (id,onLoad)
{
if (_modules[id] != undefined)
return _modules[id];
else if (this.hasComponent('classBuilder'))
{
try {
var config = _modulesConfig[id] || {},
modulePath = config.modulePath || id,
className = config.class;
if (fs.existsSync(this.modulePath+modulePath) &&... | javascript | function (id,onLoad)
{
if (_modules[id] != undefined)
return _modules[id];
else if (this.hasComponent('classBuilder'))
{
try {
var config = _modulesConfig[id] || {},
modulePath = config.modulePath || id,
className = config.class;
if (fs.existsSync(this.modulePath+modulePath) &&... | [
"function",
"(",
"id",
",",
"onLoad",
")",
"{",
"if",
"(",
"_modules",
"[",
"id",
"]",
"!=",
"undefined",
")",
"return",
"_modules",
"[",
"id",
"]",
";",
"else",
"if",
"(",
"this",
".",
"hasComponent",
"(",
"'classBuilder'",
")",
")",
"{",
"try",
"... | Retrieves the named application module.
The module has to be declared in the global modules list. A new instance will be created
when calling this method with the given ID for the first time.
@param string $id application module ID (case-sensitive)
@param function $onLoad function called when app loaded
@return wnModul... | [
"Retrieves",
"the",
"named",
"application",
"module",
".",
"The",
"module",
"has",
"to",
"be",
"declared",
"in",
"the",
"global",
"modules",
"list",
".",
"A",
"new",
"instance",
"will",
"be",
"created",
"when",
"calling",
"this",
"method",
"with",
"the",
"... | c42602b062dcf6bbffc22e4365bba2cbf363fe2f | https://github.com/yeptlabs/wns/blob/c42602b062dcf6bbffc22e4365bba2cbf363fe2f/src/core/base/wnModule.js#L593-L634 | train | |
yeptlabs/wns | src/core/base/wnModule.js | function (className,config,modulePath,npmPath)
{
var module = this.createClass(className,config,modulePath,npmPath);
return module;
} | javascript | function (className,config,modulePath,npmPath)
{
var module = this.createClass(className,config,modulePath,npmPath);
return module;
} | [
"function",
"(",
"className",
",",
"config",
",",
"modulePath",
",",
"npmPath",
")",
"{",
"var",
"module",
"=",
"this",
".",
"createClass",
"(",
"className",
",",
"config",
",",
"modulePath",
",",
"npmPath",
")",
";",
"return",
"module",
";",
"}"
] | Create a new instance of a module.
@param string $className
@param string $modulePath
@param object $config
@param string $npmPath
@return object | [
"Create",
"a",
"new",
"instance",
"of",
"a",
"module",
"."
] | c42602b062dcf6bbffc22e4365bba2cbf363fe2f | https://github.com/yeptlabs/wns/blob/c42602b062dcf6bbffc22e4365bba2cbf363fe2f/src/core/base/wnModule.js#L654-L658 | train | |
yeptlabs/wns | src/core/base/wnModule.js | function (id) {
if (!_.isString(id))
return false;
var module = this.getModule(id),
events;
this.e.log&&this.e.log("Attaching module's events...",'system');
if (module != undefined && (events=module.getEvents()) && !_.isEmpty(events)) {
for (e in events)
{
var evtConfig = {},
eve... | javascript | function (id) {
if (!_.isString(id))
return false;
var module = this.getModule(id),
events;
this.e.log&&this.e.log("Attaching module's events...",'system');
if (module != undefined && (events=module.getEvents()) && !_.isEmpty(events)) {
for (e in events)
{
var evtConfig = {},
eve... | [
"function",
"(",
"id",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isString",
"(",
"id",
")",
")",
"return",
"false",
";",
"var",
"module",
"=",
"this",
".",
"getModule",
"(",
"id",
")",
",",
"events",
";",
"this",
".",
"e",
".",
"log",
"&&",
"this",
... | Attach to this module all bubble-events from loaded modules
This create a Bubble-Event to answer to each event that bubles from the module's modules.
Also attach to all modules' events and handler to dispatch the event.
@param string $id source module id | [
"Attach",
"to",
"this",
"module",
"all",
"bubble",
"-",
"events",
"from",
"loaded",
"modules",
"This",
"create",
"a",
"Bubble",
"-",
"Event",
"to",
"answer",
"to",
"each",
"event",
"that",
"bubles",
"from",
"the",
"module",
"s",
"modules",
".",
"Also",
"... | c42602b062dcf6bbffc22e4365bba2cbf363fe2f | https://github.com/yeptlabs/wns/blob/c42602b062dcf6bbffc22e4365bba2cbf363fe2f/src/core/base/wnModule.js#L684-L724 | train | |
yeptlabs/wns | src/core/base/wnModule.js | function (scripts)
{
var script = {};
for (s in scripts)
{
var ref=scripts[s],
scriptName = s.substr(0,1).toUpperCase()+s.substr(1).toLowerCase(),
s = 'script-'+s.replace('-','.');
script[s]=ref;
script[s].class='wnScript'+scriptName || 'wnScript';
_componentsConfig[s]=_.merge({}, s... | javascript | function (scripts)
{
var script = {};
for (s in scripts)
{
var ref=scripts[s],
scriptName = s.substr(0,1).toUpperCase()+s.substr(1).toLowerCase(),
s = 'script-'+s.replace('-','.');
script[s]=ref;
script[s].class='wnScript'+scriptName || 'wnScript';
_componentsConfig[s]=_.merge({}, s... | [
"function",
"(",
"scripts",
")",
"{",
"var",
"script",
"=",
"{",
"}",
";",
"for",
"(",
"s",
"in",
"scripts",
")",
"{",
"var",
"ref",
"=",
"scripts",
"[",
"s",
"]",
",",
"scriptName",
"=",
"s",
".",
"substr",
"(",
"0",
",",
"1",
")",
".",
"toU... | Set new properties to the respective scripts
@param OBJECT $scripts scripts configurations | [
"Set",
"new",
"properties",
"to",
"the",
"respective",
"scripts"
] | c42602b062dcf6bbffc22e4365bba2cbf363fe2f | https://github.com/yeptlabs/wns/blob/c42602b062dcf6bbffc22e4365bba2cbf363fe2f/src/core/base/wnModule.js#L740-L753 | train | |
yeptlabs/wns | src/core/base/wnModule.js | function (value)
{
if (value != undefined && fs.statSync(value).isDirectory())
{
this.modulePath = value;
this.setConfig('modulePath',value);
}
return this;
} | javascript | function (value)
{
if (value != undefined && fs.statSync(value).isDirectory())
{
this.modulePath = value;
this.setConfig('modulePath',value);
}
return this;
} | [
"function",
"(",
"value",
")",
"{",
"if",
"(",
"value",
"!=",
"undefined",
"&&",
"fs",
".",
"statSync",
"(",
"value",
")",
".",
"isDirectory",
"(",
")",
")",
"{",
"this",
".",
"modulePath",
"=",
"value",
";",
"this",
".",
"setConfig",
"(",
"'modulePa... | Sets the directory that contains the application modules.
@param string $value the directory that contains the application modules. | [
"Sets",
"the",
"directory",
"that",
"contains",
"the",
"application",
"modules",
"."
] | c42602b062dcf6bbffc22e4365bba2cbf363fe2f | https://github.com/yeptlabs/wns/blob/c42602b062dcf6bbffc22e4365bba2cbf363fe2f/src/core/base/wnModule.js#L816-L824 | train | |
microservice-framework/microservice-client | index.js | MicroserviceClient | function MicroserviceClient(settings) {
var self = this;
self.settings = settings;
self.get = bind(self.get, self);
self.post = bind(self.post, self);
self.put = bind(self.put, self);
self.delete = bind(self.delete, self);
self.search = bind(self.search, self);
self._request = bind(self._request, self);... | javascript | function MicroserviceClient(settings) {
var self = this;
self.settings = settings;
self.get = bind(self.get, self);
self.post = bind(self.post, self);
self.put = bind(self.put, self);
self.delete = bind(self.delete, self);
self.search = bind(self.search, self);
self._request = bind(self._request, self);... | [
"function",
"MicroserviceClient",
"(",
"settings",
")",
"{",
"var",
"self",
"=",
"this",
";",
"self",
".",
"settings",
"=",
"settings",
";",
"self",
".",
"get",
"=",
"bind",
"(",
"self",
".",
"get",
",",
"self",
")",
";",
"self",
".",
"post",
"=",
... | Constructor of MicroserviceClientClient object.
.
settings.URL = process.env.SELF_URL;
settings.secureKey = process.env.SECURE_KEY;
settings.accessToken = if microservice-auth used, accessToken can be set here. | [
"Constructor",
"of",
"MicroserviceClientClient",
"object",
".",
".",
"settings",
".",
"URL",
"=",
"process",
".",
"env",
".",
"SELF_URL",
";",
"settings",
".",
"secureKey",
"=",
"process",
".",
"env",
".",
"SECURE_KEY",
";",
"settings",
".",
"accessToken",
"... | 48651abb0b715721210e5acd56149da8623ed3af | https://github.com/microservice-framework/microservice-client/blob/48651abb0b715721210e5acd56149da8623ed3af/index.js#L18-L27 | train |
Wiredcraft/handle-http-error | lib/buildHandler.js | buildHandler | function buildHandler(overrides) {
const parseError = buildHandler.parseError;
const buildError = buildHandler.buildError;
/**
* .
*/
return function handler(error) {
const found = parseError.apply(this, arguments);
if (!found) {
if (error instanceof Error) {
Error.captureStackTrace... | javascript | function buildHandler(overrides) {
const parseError = buildHandler.parseError;
const buildError = buildHandler.buildError;
/**
* .
*/
return function handler(error) {
const found = parseError.apply(this, arguments);
if (!found) {
if (error instanceof Error) {
Error.captureStackTrace... | [
"function",
"buildHandler",
"(",
"overrides",
")",
"{",
"const",
"parseError",
"=",
"buildHandler",
".",
"parseError",
";",
"const",
"buildError",
"=",
"buildHandler",
".",
"buildError",
";",
"/**\n * .\n */",
"return",
"function",
"handler",
"(",
"error",
")"... | Build a handler.
@param {Object} overrides override the error attributes
@return {Function} the handler | [
"Build",
"a",
"handler",
"."
] | 2054c1ade9f5e4b11fd64c432317c815cb97063a | https://github.com/Wiredcraft/handle-http-error/blob/2054c1ade9f5e4b11fd64c432317c815cb97063a/lib/buildHandler.js#L23-L46 | train |
tbremer/verboser | index.js | function (string) {
color = chalk.cyan;
if (args.verbose) {
if (typeof string === "string") {
console.log(color(string));
}
if (isArray(string)) {
console.log(color(arrayToString(string)));
}
}
return this;
} | javascript | function (string) {
color = chalk.cyan;
if (args.verbose) {
if (typeof string === "string") {
console.log(color(string));
}
if (isArray(string)) {
console.log(color(arrayToString(string)));
}
}
return this;
} | [
"function",
"(",
"string",
")",
"{",
"color",
"=",
"chalk",
".",
"cyan",
";",
"if",
"(",
"args",
".",
"verbose",
")",
"{",
"if",
"(",
"typeof",
"string",
"===",
"\"string\"",
")",
"{",
"console",
".",
"log",
"(",
"color",
"(",
"string",
")",
")",
... | verbose.log | [
"verbose",
".",
"log"
] | 2ad328c6f56e21f798b2e1760325a243b4df368a | https://github.com/tbremer/verboser/blob/2ad328c6f56e21f798b2e1760325a243b4df368a/index.js#L67-L78 | train | |
mrdaniellewis/node-stream-collect | index.js | addListener | function addListener(name) {
if (name !== 'collect') {
return;
}
if (this._collecting) {
// Don't add more than once
return;
}
debug('adding collect method', this._readableState.objectMode, this._readableState.encoding);
let collected;
if (this._readableState.objectMode) {
collected = [... | javascript | function addListener(name) {
if (name !== 'collect') {
return;
}
if (this._collecting) {
// Don't add more than once
return;
}
debug('adding collect method', this._readableState.objectMode, this._readableState.encoding);
let collected;
if (this._readableState.objectMode) {
collected = [... | [
"function",
"addListener",
"(",
"name",
")",
"{",
"if",
"(",
"name",
"!==",
"'collect'",
")",
"{",
"return",
";",
"}",
"if",
"(",
"this",
".",
"_collecting",
")",
"{",
"// Don't add more than once",
"return",
";",
"}",
"debug",
"(",
"'adding collect method'"... | When a listener for an event named collect is added start collecting the data | [
"When",
"a",
"listener",
"for",
"an",
"event",
"named",
"collect",
"is",
"added",
"start",
"collecting",
"the",
"data"
] | cd651cdcd46ca9ecd71849cc5e1ed57a533af25f | https://github.com/mrdaniellewis/node-stream-collect/blob/cd651cdcd46ca9ecd71849cc5e1ed57a533af25f/index.js#L9-L50 | train |
mrdaniellewis/node-stream-collect | index.js | addToStream | function addToStream(stream) {
// Don't add more than once
if (stream.listeners('addListener').includes(addListener)) {
return stream;
}
stream.on('newListener', addListener);
return stream;
} | javascript | function addToStream(stream) {
// Don't add more than once
if (stream.listeners('addListener').includes(addListener)) {
return stream;
}
stream.on('newListener', addListener);
return stream;
} | [
"function",
"addToStream",
"(",
"stream",
")",
"{",
"// Don't add more than once",
"if",
"(",
"stream",
".",
"listeners",
"(",
"'addListener'",
")",
".",
"includes",
"(",
"addListener",
")",
")",
"{",
"return",
"stream",
";",
"}",
"stream",
".",
"on",
"(",
... | Add the collect event to the stream
@param {Stream} stream | [
"Add",
"the",
"collect",
"event",
"to",
"the",
"stream"
] | cd651cdcd46ca9ecd71849cc5e1ed57a533af25f | https://github.com/mrdaniellewis/node-stream-collect/blob/cd651cdcd46ca9ecd71849cc5e1ed57a533af25f/index.js#L56-L65 | train |
mrdaniellewis/node-stream-collect | index.js | collect | function collect(stream, encoding, cb = () => {}) {
if (typeof encoding === 'function') {
cb = encoding;
encoding = null;
}
return stream
.pipe(new Collect({ encoding, objectMode: stream._readableState.objectMode }))
.collect()
.then((data) => {
cb(null, data);
return data;
})... | javascript | function collect(stream, encoding, cb = () => {}) {
if (typeof encoding === 'function') {
cb = encoding;
encoding = null;
}
return stream
.pipe(new Collect({ encoding, objectMode: stream._readableState.objectMode }))
.collect()
.then((data) => {
cb(null, data);
return data;
})... | [
"function",
"collect",
"(",
"stream",
",",
"encoding",
",",
"cb",
"=",
"(",
")",
"=>",
"{",
"}",
")",
"{",
"if",
"(",
"typeof",
"encoding",
"===",
"'function'",
")",
"{",
"cb",
"=",
"encoding",
";",
"encoding",
"=",
"null",
";",
"}",
"return",
"str... | Collect all data in a stream and return as a promise or in a callback
@param {Stream} stream A stream
@param {String} [encoding] Stream encoding - optional
@param {Function} cb Callback, the first argument will be the data
@returns {Promise} | [
"Collect",
"all",
"data",
"in",
"a",
"stream",
"and",
"return",
"as",
"a",
"promise",
"or",
"in",
"a",
"callback"
] | cd651cdcd46ca9ecd71849cc5e1ed57a533af25f | https://github.com/mrdaniellewis/node-stream-collect/blob/cd651cdcd46ca9ecd71849cc5e1ed57a533af25f/index.js#L115-L132 | train |
shawnbissell/obicallerid | obicallerid.js | ObiCallerID | function ObiCallerID() {
this.fromRegex = /^INVITE[\S\s]*From:\s*"?([\w\s\.\+\?\$]*?)"?<sip:((.*)@)?(.*)>;.*/;
this.cidRegex = /<7> \[SLIC\] CID to deliver: '([\w\s\.\+\?\$]*?)' (\d*).*/;
this.cnams = {};
this.lastSentTime = new Date();
this.outlookImported = false;
this.addressbookImported = fa... | javascript | function ObiCallerID() {
this.fromRegex = /^INVITE[\S\s]*From:\s*"?([\w\s\.\+\?\$]*?)"?<sip:((.*)@)?(.*)>;.*/;
this.cidRegex = /<7> \[SLIC\] CID to deliver: '([\w\s\.\+\?\$]*?)' (\d*).*/;
this.cnams = {};
this.lastSentTime = new Date();
this.outlookImported = false;
this.addressbookImported = fa... | [
"function",
"ObiCallerID",
"(",
")",
"{",
"this",
".",
"fromRegex",
"=",
"/",
"^INVITE[\\S\\s]*From:\\s*\"?([\\w\\s\\.\\+\\?\\$]*?)\"?<sip:((.*)@)?(.*)>;.*",
"/",
";",
"this",
".",
"cidRegex",
"=",
"/",
"<7> \\[SLIC\\] CID to deliver: '([\\w\\s\\.\\+\\?\\$]*?)' (\\d*).*",
"/",
... | An ObiCallerID object
@constructor | [
"An",
"ObiCallerID",
"object"
] | 923ad68a38d3e170fe784109108bf06d52960df8 | https://github.com/shawnbissell/obicallerid/blob/923ad68a38d3e170fe784109108bf06d52960df8/obicallerid.js#L21-L30 | train |
richardschneider/sally | lib/writer.js | SallyWriter | function SallyWriter(opts)
{
this.sally = require('./sally');
opts = opts || {};
this.path = opts.path || 'sally.log';
this.prefix = opts.prefix || '';
this.digest = undefined;
this.onLog = this.onLog.bind(this);
this.onEpochStart = this.onEpochStart.bind(this);
this.onEpochEnd = this.onEpochEnd.bin... | javascript | function SallyWriter(opts)
{
this.sally = require('./sally');
opts = opts || {};
this.path = opts.path || 'sally.log';
this.prefix = opts.prefix || '';
this.digest = undefined;
this.onLog = this.onLog.bind(this);
this.onEpochStart = this.onEpochStart.bind(this);
this.onEpochEnd = this.onEpochEnd.bin... | [
"function",
"SallyWriter",
"(",
"opts",
")",
"{",
"this",
".",
"sally",
"=",
"require",
"(",
"'./sally'",
")",
";",
"opts",
"=",
"opts",
"||",
"{",
"}",
";",
"this",
".",
"path",
"=",
"opts",
".",
"path",
"||",
"'sally.log'",
";",
"this",
".",
"pre... | AuditFile constructor. | [
"AuditFile",
"constructor",
"."
] | 45f34ab121faced90ca1a2cd2b9b19c7e95c9f54 | https://github.com/richardschneider/sally/blob/45f34ab121faced90ca1a2cd2b9b19c7e95c9f54/lib/writer.js#L13-L33 | train |
linyngfly/omelo | lib/components/proxy.js | function(client, app, sinfos) {
let item;
for (let i = 0, l = sinfos.length; i < l; i++) {
item = sinfos[i];
if (hasProxy(client, item)) {
continue;
}
client.addProxies(getProxyRecords(app, item));
}
} | javascript | function(client, app, sinfos) {
let item;
for (let i = 0, l = sinfos.length; i < l; i++) {
item = sinfos[i];
if (hasProxy(client, item)) {
continue;
}
client.addProxies(getProxyRecords(app, item));
}
} | [
"function",
"(",
"client",
",",
"app",
",",
"sinfos",
")",
"{",
"let",
"item",
";",
"for",
"(",
"let",
"i",
"=",
"0",
",",
"l",
"=",
"sinfos",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"item",
"=",
"sinfos",
"[",
"i",
"]"... | Generate proxy for the server infos.
@param {Object} client rpc client instance
@param {Object} app application context
@param {Array} sinfos server info list | [
"Generate",
"proxy",
"for",
"the",
"server",
"infos",
"."
] | fb5f79fa31c69de36bd1c370bad5edfa753ca601 | https://github.com/linyngfly/omelo/blob/fb5f79fa31c69de36bd1c370bad5edfa753ca601/lib/components/proxy.js#L177-L186 | train | |
linyngfly/omelo | lib/components/proxy.js | function(client, sinfo) {
let proxy = client.proxies;
return !!proxy.sys && !! proxy.sys[sinfo.serverType];
} | javascript | function(client, sinfo) {
let proxy = client.proxies;
return !!proxy.sys && !! proxy.sys[sinfo.serverType];
} | [
"function",
"(",
"client",
",",
"sinfo",
")",
"{",
"let",
"proxy",
"=",
"client",
".",
"proxies",
";",
"return",
"!",
"!",
"proxy",
".",
"sys",
"&&",
"!",
"!",
"proxy",
".",
"sys",
"[",
"sinfo",
".",
"serverType",
"]",
";",
"}"
] | Check a server whether has generated proxy before
@param {Object} client rpc client instance
@param {Object} sinfo server info
@return {Boolean} true or false | [
"Check",
"a",
"server",
"whether",
"has",
"generated",
"proxy",
"before"
] | fb5f79fa31c69de36bd1c370bad5edfa753ca601 | https://github.com/linyngfly/omelo/blob/fb5f79fa31c69de36bd1c370bad5edfa753ca601/lib/components/proxy.js#L195-L198 | train | |
linyngfly/omelo | lib/components/proxy.js | function(app, sinfo) {
let records = [],
appBase = app.getBase(),
record;
// sys remote service path record
if (app.isFrontend(sinfo)) {
record = pathUtil.getSysRemotePath('frontend');
} else {
record = pathUtil.getSysRemotePath('backend');
}
if (record) {
records.push(pathUtil.remotePat... | javascript | function(app, sinfo) {
let records = [],
appBase = app.getBase(),
record;
// sys remote service path record
if (app.isFrontend(sinfo)) {
record = pathUtil.getSysRemotePath('frontend');
} else {
record = pathUtil.getSysRemotePath('backend');
}
if (record) {
records.push(pathUtil.remotePat... | [
"function",
"(",
"app",
",",
"sinfo",
")",
"{",
"let",
"records",
"=",
"[",
"]",
",",
"appBase",
"=",
"app",
".",
"getBase",
"(",
")",
",",
"record",
";",
"// sys remote service path record",
"if",
"(",
"app",
".",
"isFrontend",
"(",
"sinfo",
")",
")",... | Get proxy path for rpc client.
Iterate all the remote service path and create remote path record.
@param {Object} app current application context
@param {Object} sinfo server info, format: {id, serverType, host, port}
@return {Array} remote path record array | [
"Get",
"proxy",
"path",
"for",
"rpc",
"client",
".",
"Iterate",
"all",
"the",
"remote",
"service",
"path",
"and",
"create",
"remote",
"path",
"record",
"."
] | fb5f79fa31c69de36bd1c370bad5edfa753ca601 | https://github.com/linyngfly/omelo/blob/fb5f79fa31c69de36bd1c370bad5edfa753ca601/lib/components/proxy.js#L208-L229 | train | |
clarkmalmgren/angular-onselect | dist/angular-onselect.js | snapToWord | function snapToWord() {
if (isHighlighted()) {
throw new Error("Can't modify range after highlighting");
}
var start = selection.range.startOffset;
var startNode = selection.range.startContainer;
while (startNode.textContent.charAt(start) != ' ' && start > 0) {
... | javascript | function snapToWord() {
if (isHighlighted()) {
throw new Error("Can't modify range after highlighting");
}
var start = selection.range.startOffset;
var startNode = selection.range.startContainer;
while (startNode.textContent.charAt(start) != ' ' && start > 0) {
... | [
"function",
"snapToWord",
"(",
")",
"{",
"if",
"(",
"isHighlighted",
"(",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"Can't modify range after highlighting\"",
")",
";",
"}",
"var",
"start",
"=",
"selection",
".",
"range",
".",
"startOffset",
";",
"var",... | Expand the current range so that both the beginning and end end at word boundaries.
@memeberOf onselect.Selection
@name snapToWord | [
"Expand",
"the",
"current",
"range",
"so",
"that",
"both",
"the",
"beginning",
"and",
"end",
"end",
"at",
"word",
"boundaries",
"."
] | 07a986af1690dc7c98e0b24706ceadb2fe663e9f | https://github.com/clarkmalmgren/angular-onselect/blob/07a986af1690dc7c98e0b24706ceadb2fe663e9f/dist/angular-onselect.js#L204-L229 | train |
clarkmalmgren/angular-onselect | dist/angular-onselect.js | removeHighlight | function removeHighlight() {
for (var h in selection._highlighter) {
var highlighter = selection._highlighter[h];
var parent = highlighter.parentNode;
while (highlighter.firstChild) {
parent.insertBefore(highlighter.firstChild, highlighter);
}
paren... | javascript | function removeHighlight() {
for (var h in selection._highlighter) {
var highlighter = selection._highlighter[h];
var parent = highlighter.parentNode;
while (highlighter.firstChild) {
parent.insertBefore(highlighter.firstChild, highlighter);
}
paren... | [
"function",
"removeHighlight",
"(",
")",
"{",
"for",
"(",
"var",
"h",
"in",
"selection",
".",
"_highlighter",
")",
"{",
"var",
"highlighter",
"=",
"selection",
".",
"_highlighter",
"[",
"h",
"]",
";",
"var",
"parent",
"=",
"highlighter",
".",
"parentNode",... | Remove highlighting if it currently exists.
@memeberOf onselect.Selection
@name removeHighlight | [
"Remove",
"highlighting",
"if",
"it",
"currently",
"exists",
"."
] | 07a986af1690dc7c98e0b24706ceadb2fe663e9f | https://github.com/clarkmalmgren/angular-onselect/blob/07a986af1690dc7c98e0b24706ceadb2fe663e9f/dist/angular-onselect.js#L272-L284 | train |
clarkmalmgren/angular-onselect | dist/angular-onselect.js | shard | function shard() {
var treeNode = new RangeTreeNode();
treeNode.setStart(range.startContainer, range.startOffset);
var current = range.startContainer;
var distance = 0;
while (current != range.endContainer && distance < 50) {
var last = current;
if (current... | javascript | function shard() {
var treeNode = new RangeTreeNode();
treeNode.setStart(range.startContainer, range.startOffset);
var current = range.startContainer;
var distance = 0;
while (current != range.endContainer && distance < 50) {
var last = current;
if (current... | [
"function",
"shard",
"(",
")",
"{",
"var",
"treeNode",
"=",
"new",
"RangeTreeNode",
"(",
")",
";",
"treeNode",
".",
"setStart",
"(",
"range",
".",
"startContainer",
",",
"range",
".",
"startOffset",
")",
";",
"var",
"current",
"=",
"range",
".",
"startCo... | Split the current range into ranges that can actually be highlighted. This is required for doing complex
DOM highlights where the highlight HTML node would need to only partially include a non-text node.
@memberOf onselect.Selection
@name shard
@return {[Range]} the array of ranges | [
"Split",
"the",
"current",
"range",
"into",
"ranges",
"that",
"can",
"actually",
"be",
"highlighted",
".",
"This",
"is",
"required",
"for",
"doing",
"complex",
"DOM",
"highlights",
"where",
"the",
"highlight",
"HTML",
"node",
"would",
"need",
"to",
"only",
"... | 07a986af1690dc7c98e0b24706ceadb2fe663e9f | https://github.com/clarkmalmgren/angular-onselect/blob/07a986af1690dc7c98e0b24706ceadb2fe663e9f/dist/angular-onselect.js#L304-L343 | train |
itsravenous/i3s-db-utils | index.js | getFingerprintsForAnimal | function getFingerprintsForAnimal(animalDir) {
if (!fs.existsSync(animalDir) || !fs.statSync(animalDir).isDirectory()) {
return false;
}
var fgpFiles = fs.readdirSync(animalDir).filter(function (entry) {
return entry.split('.').pop().toLowerCase() == 'fgp';
});
var fgps = [];
fgpFiles.forEach(function (fgpF... | javascript | function getFingerprintsForAnimal(animalDir) {
if (!fs.existsSync(animalDir) || !fs.statSync(animalDir).isDirectory()) {
return false;
}
var fgpFiles = fs.readdirSync(animalDir).filter(function (entry) {
return entry.split('.').pop().toLowerCase() == 'fgp';
});
var fgps = [];
fgpFiles.forEach(function (fgpF... | [
"function",
"getFingerprintsForAnimal",
"(",
"animalDir",
")",
"{",
"if",
"(",
"!",
"fs",
".",
"existsSync",
"(",
"animalDir",
")",
"||",
"!",
"fs",
".",
"statSync",
"(",
"animalDir",
")",
".",
"isDirectory",
"(",
")",
")",
"{",
"return",
"false",
";",
... | Fetches fingerprints for an individual
@param {String} individual ID
@return {Array} | [
"Fetches",
"fingerprints",
"for",
"an",
"individual"
] | 7d3a7d0b2d5345e2a9a3dd9dcaab9ef2e3e72043 | https://github.com/itsravenous/i3s-db-utils/blob/7d3a7d0b2d5345e2a9a3dd9dcaab9ef2e3e72043/index.js#L24-L44 | train |
itsravenous/i3s-db-utils | index.js | getAllFingerprints | function getAllFingerprints(dir) {
var ids = getAnimals();
var fgps = ids.map(function (id) {
return getFingerprintsForAnimal(path.join(dir, id));
}).filter(function (fgp) { return fgp; });
return fgps;
} | javascript | function getAllFingerprints(dir) {
var ids = getAnimals();
var fgps = ids.map(function (id) {
return getFingerprintsForAnimal(path.join(dir, id));
}).filter(function (fgp) { return fgp; });
return fgps;
} | [
"function",
"getAllFingerprints",
"(",
"dir",
")",
"{",
"var",
"ids",
"=",
"getAnimals",
"(",
")",
";",
"var",
"fgps",
"=",
"ids",
".",
"map",
"(",
"function",
"(",
"id",
")",
"{",
"return",
"getFingerprintsForAnimal",
"(",
"path",
".",
"join",
"(",
"d... | Fetches fingerprints for all individuals
@return {Array} | [
"Fetches",
"fingerprints",
"for",
"all",
"individuals"
] | 7d3a7d0b2d5345e2a9a3dd9dcaab9ef2e3e72043 | https://github.com/itsravenous/i3s-db-utils/blob/7d3a7d0b2d5345e2a9a3dd9dcaab9ef2e3e72043/index.js#L50-L56 | train |
itsravenous/i3s-db-utils | index.js | getAnimals | function getAnimals(dir) {
var ids = fs.readdirSync(dir).filter(function (id) {
return fs.statSync(path.join(dir, id)).isDirectory();
});
return ids;
} | javascript | function getAnimals(dir) {
var ids = fs.readdirSync(dir).filter(function (id) {
return fs.statSync(path.join(dir, id)).isDirectory();
});
return ids;
} | [
"function",
"getAnimals",
"(",
"dir",
")",
"{",
"var",
"ids",
"=",
"fs",
".",
"readdirSync",
"(",
"dir",
")",
".",
"filter",
"(",
"function",
"(",
"id",
")",
"{",
"return",
"fs",
".",
"statSync",
"(",
"path",
".",
"join",
"(",
"dir",
",",
"id",
"... | Fetches all individuals
@param {String} DB dir
@return {Array} | [
"Fetches",
"all",
"individuals"
] | 7d3a7d0b2d5345e2a9a3dd9dcaab9ef2e3e72043 | https://github.com/itsravenous/i3s-db-utils/blob/7d3a7d0b2d5345e2a9a3dd9dcaab9ef2e3e72043/index.js#L63-L68 | train |
bmeck/node-devtools | lib/readline2/terminal_util.js | moveCursorRelative | function moveCursorRelative(stream, dx, dy) {
if (dx < 0) {
stream.write('\x1b[' + (-dx) + 'D');
} else if (dx > 0) {
stream.write('\x1b[' + dx + 'C');
}
if (dy < 0) {
stream.write('\x1b[' + (-dy) + 'A');
} else if (dy > 0) {
stream.write('\x1b[' + dy + 'B');
}
} | javascript | function moveCursorRelative(stream, dx, dy) {
if (dx < 0) {
stream.write('\x1b[' + (-dx) + 'D');
} else if (dx > 0) {
stream.write('\x1b[' + dx + 'C');
}
if (dy < 0) {
stream.write('\x1b[' + (-dy) + 'A');
} else if (dy > 0) {
stream.write('\x1b[' + dy + 'B');
}
} | [
"function",
"moveCursorRelative",
"(",
"stream",
",",
"dx",
",",
"dy",
")",
"{",
"if",
"(",
"dx",
"<",
"0",
")",
"{",
"stream",
".",
"write",
"(",
"'\\x1b['",
"+",
"(",
"-",
"dx",
")",
"+",
"'D'",
")",
";",
"}",
"else",
"if",
"(",
"dx",
">",
... | moves the cursor relative to its current location | [
"moves",
"the",
"cursor",
"relative",
"to",
"its",
"current",
"location"
] | 331adcae6090b85a8da126d6707f627524aa9a84 | https://github.com/bmeck/node-devtools/blob/331adcae6090b85a8da126d6707f627524aa9a84/lib/readline2/terminal_util.js#L55-L67 | train |
boylesoftware/x2node-validators | index.js | createValidationErrorMessages | function createValidationErrorMessages(base, subjDef) {
if (!subjDef.validationErrorMessages &&
(base !== standard.VALIDATION_ERROR_MESSAGES))
return base;
const validationErrorMessages = Object.create(base);
for (let messageId in subjDef.validationErrorMessages) {
const messageDef = subjDef.validationErrorM... | javascript | function createValidationErrorMessages(base, subjDef) {
if (!subjDef.validationErrorMessages &&
(base !== standard.VALIDATION_ERROR_MESSAGES))
return base;
const validationErrorMessages = Object.create(base);
for (let messageId in subjDef.validationErrorMessages) {
const messageDef = subjDef.validationErrorM... | [
"function",
"createValidationErrorMessages",
"(",
"base",
",",
"subjDef",
")",
"{",
"if",
"(",
"!",
"subjDef",
".",
"validationErrorMessages",
"&&",
"(",
"base",
"!==",
"standard",
".",
"VALIDATION_ERROR_MESSAGES",
")",
")",
"return",
"base",
";",
"const",
"vali... | Create validation error messages set for the specified container or property.
@private
@param {Object.<string,Object<string,string>>} base Base validation error
messages set from the context.
@param {Object} subjDef Subject definition object possibly containing a
<code>validationErrorMessages</code> attribute.
@return... | [
"Create",
"validation",
"error",
"messages",
"set",
"for",
"the",
"specified",
"container",
"or",
"property",
"."
] | e98a65c13a4092f80e96517c8e8c9523f8e84c63 | https://github.com/boylesoftware/x2node-validators/blob/e98a65c13a4092f80e96517c8e8c9523f8e84c63/index.js#L266-L290 | train |
boylesoftware/x2node-validators | index.js | createValidatorFuncs | function createValidatorFuncs(base, subjDef, subjDescription) {
if (!subjDef.validatorDefs && (base !== standard.VALIDATOR_DEFS))
return base;
const validatorFuncs = Object.create(base);
for (let validatorId in subjDef.validatorDefs) {
const validatorFunc = subjDef.validatorDefs[validatorId];
if ((typeof val... | javascript | function createValidatorFuncs(base, subjDef, subjDescription) {
if (!subjDef.validatorDefs && (base !== standard.VALIDATOR_DEFS))
return base;
const validatorFuncs = Object.create(base);
for (let validatorId in subjDef.validatorDefs) {
const validatorFunc = subjDef.validatorDefs[validatorId];
if ((typeof val... | [
"function",
"createValidatorFuncs",
"(",
"base",
",",
"subjDef",
",",
"subjDescription",
")",
"{",
"if",
"(",
"!",
"subjDef",
".",
"validatorDefs",
"&&",
"(",
"base",
"!==",
"standard",
".",
"VALIDATOR_DEFS",
")",
")",
"return",
"base",
";",
"const",
"valida... | Create validator functions set for the specified container or property.
@private
@param {Object.<string,module:x2node-validators.validator>} base Base
validator functions set from the context.
@param {Object} subjDef Subject definition object possibly containing a
<code>validatorDefs</code> attribute.
@param {string} ... | [
"Create",
"validator",
"functions",
"set",
"for",
"the",
"specified",
"container",
"or",
"property",
"."
] | e98a65c13a4092f80e96517c8e8c9523f8e84c63 | https://github.com/boylesoftware/x2node-validators/blob/e98a65c13a4092f80e96517c8e8c9523f8e84c63/index.js#L304-L320 | train |
r12f/hexo-heading-index | lib/index-maker.js | function (num, uppercase) {
var digits = String(+num).split(""),
key = ["","c","cc","ccc","cd","d","dc","dcc","dccc","cm",
"","x","xx","xxx","xl","l","lx","lxx","lxxx","xc",
"","i","ii","iii","iv","v","vi","vii","viii","ix"],
roman = "",
i = 3;
while (i--)
... | javascript | function (num, uppercase) {
var digits = String(+num).split(""),
key = ["","c","cc","ccc","cd","d","dc","dcc","dccc","cm",
"","x","xx","xxx","xl","l","lx","lxx","lxxx","xc",
"","i","ii","iii","iv","v","vi","vii","viii","ix"],
roman = "",
i = 3;
while (i--)
... | [
"function",
"(",
"num",
",",
"uppercase",
")",
"{",
"var",
"digits",
"=",
"String",
"(",
"+",
"num",
")",
".",
"split",
"(",
"\"\"",
")",
",",
"key",
"=",
"[",
"\"\"",
",",
"\"c\"",
",",
"\"cc\"",
",",
"\"ccc\"",
",",
"\"cd\"",
",",
"\"d\"",
",",... | JavaScript Roman Numeral Converter (Thanks to Steven Levithan @slevithan) http://blog.stevenlevithan.com/archives/javascript-roman-numeral-converter | [
"JavaScript",
"Roman",
"Numeral",
"Converter",
"(",
"Thanks",
"to",
"Steven",
"Levithan"
] | 0bc92fd74bf7110bd07c8cb49ce8cd759dda99c5 | https://github.com/r12f/hexo-heading-index/blob/0bc92fd74bf7110bd07c8cb49ce8cd759dda99c5/lib/index-maker.js#L29-L41 | train | |
soixantecircuits/media-helper | media-helper.js | getMimeType | function getMimeType (media) {
return new Promise((resolve, reject) => {
if (isFile(media)) {
typechecker.detectFile(media, (err, result) => {
err && reject(err)
resolve(result)
})
} else if (isBuffer(media)) {
typechecker.detect(media, (err, result) => {
err && rejec... | javascript | function getMimeType (media) {
return new Promise((resolve, reject) => {
if (isFile(media)) {
typechecker.detectFile(media, (err, result) => {
err && reject(err)
resolve(result)
})
} else if (isBuffer(media)) {
typechecker.detect(media, (err, result) => {
err && rejec... | [
"function",
"getMimeType",
"(",
"media",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"if",
"(",
"isFile",
"(",
"media",
")",
")",
"{",
"typechecker",
".",
"detectFile",
"(",
"media",
",",
"(",
"err",
",",... | Determines the mime-type of a file
@param {string} media - either path, URL or base64 datas.
@returns {Promise} | [
"Determines",
"the",
"mime",
"-",
"type",
"of",
"a",
"file"
] | af032cd54fca424f06c26c8a6110f7f0bfe0fc1b | https://github.com/soixantecircuits/media-helper/blob/af032cd54fca424f06c26c8a6110f7f0bfe0fc1b/media-helper.js#L58-L78 | train |
soixantecircuits/media-helper | media-helper.js | isImage | function isImage (path) {
return new Promise((resolve, reject) => {
getMimeType(path)
.then((type) => {
;(type.indexOf('image') > -1) ? resolve(true) : resolve(false)
})
.catch(err => reject(err))
})
} | javascript | function isImage (path) {
return new Promise((resolve, reject) => {
getMimeType(path)
.then((type) => {
;(type.indexOf('image') > -1) ? resolve(true) : resolve(false)
})
.catch(err => reject(err))
})
} | [
"function",
"isImage",
"(",
"path",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"getMimeType",
"(",
"path",
")",
".",
"then",
"(",
"(",
"type",
")",
"=>",
"{",
";",
"(",
"type",
".",
"indexOf",
"(",
"... | Determines if a file is an image
@param {string} path - Path to a file
@returns {Promise} | [
"Determines",
"if",
"a",
"file",
"is",
"an",
"image"
] | af032cd54fca424f06c26c8a6110f7f0bfe0fc1b | https://github.com/soixantecircuits/media-helper/blob/af032cd54fca424f06c26c8a6110f7f0bfe0fc1b/media-helper.js#L94-L102 | train |
soixantecircuits/media-helper | media-helper.js | urlToBase64 | function urlToBase64 (url) {
return new Promise((resolve, reject) => {
request.get(url, (err, response, body) => {
err && reject(err)
resolve(body.toString('base64'))
})
})
} | javascript | function urlToBase64 (url) {
return new Promise((resolve, reject) => {
request.get(url, (err, response, body) => {
err && reject(err)
resolve(body.toString('base64'))
})
})
} | [
"function",
"urlToBase64",
"(",
"url",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"request",
".",
"get",
"(",
"url",
",",
"(",
"err",
",",
"response",
",",
"body",
")",
"=>",
"{",
"err",
"&&",
"reject"... | Reads an image from url and convert it to base64
@param {string} url
@returns {Promise} | [
"Reads",
"an",
"image",
"from",
"url",
"and",
"convert",
"it",
"to",
"base64"
] | af032cd54fca424f06c26c8a6110f7f0bfe0fc1b | https://github.com/soixantecircuits/media-helper/blob/af032cd54fca424f06c26c8a6110f7f0bfe0fc1b/media-helper.js#L124-L131 | train |
soixantecircuits/media-helper | media-helper.js | toBase64 | function toBase64 (media) {
return new Promise((resolve, reject) => {
if (isBase64(media)) {
resolve(media)
} else if (isURL(media)) {
urlToBase64(media)
.then(data => resolve(data))
.catch(error => reject(error))
} else if (isFile(media)) {
fileToBase64(media)
.then(da... | javascript | function toBase64 (media) {
return new Promise((resolve, reject) => {
if (isBase64(media)) {
resolve(media)
} else if (isURL(media)) {
urlToBase64(media)
.then(data => resolve(data))
.catch(error => reject(error))
} else if (isFile(media)) {
fileToBase64(media)
.then(da... | [
"function",
"toBase64",
"(",
"media",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"if",
"(",
"isBase64",
"(",
"media",
")",
")",
"{",
"resolve",
"(",
"media",
")",
"}",
"else",
"if",
"(",
"isURL",
"(",
... | Reads an image from file or url and convert it to base64
@param {string} media - url or path
@returns {Promise} | [
"Reads",
"an",
"image",
"from",
"file",
"or",
"url",
"and",
"convert",
"it",
"to",
"base64"
] | af032cd54fca424f06c26c8a6110f7f0bfe0fc1b | https://github.com/soixantecircuits/media-helper/blob/af032cd54fca424f06c26c8a6110f7f0bfe0fc1b/media-helper.js#L152-L171 | train |
soixantecircuits/media-helper | media-helper.js | toBuffer | function toBuffer (media) {
return new Promise((resolve, reject) => {
if (isURL(media)) {
toBase64(media)
.then(data => {
toBuffer(data)
.then(data => resolve(data))
.catch(error => reject(error))
})
.catch(error => reject(error))
} else if (isBase64(media)) {
... | javascript | function toBuffer (media) {
return new Promise((resolve, reject) => {
if (isURL(media)) {
toBase64(media)
.then(data => {
toBuffer(data)
.then(data => resolve(data))
.catch(error => reject(error))
})
.catch(error => reject(error))
} else if (isBase64(media)) {
... | [
"function",
"toBuffer",
"(",
"media",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"if",
"(",
"isURL",
"(",
"media",
")",
")",
"{",
"toBase64",
"(",
"media",
")",
".",
"then",
"(",
"data",
"=>",
"{",
"... | Reads an image from file or url and convert it to Buffer
@param {media} media - file, url or path
@returns {Promise} | [
"Reads",
"an",
"image",
"from",
"file",
"or",
"url",
"and",
"convert",
"it",
"to",
"Buffer"
] | af032cd54fca424f06c26c8a6110f7f0bfe0fc1b | https://github.com/soixantecircuits/media-helper/blob/af032cd54fca424f06c26c8a6110f7f0bfe0fc1b/media-helper.js#L188-L213 | train |
chrishayesmu/DubBotBase | src/translator.js | translateDateTimestamp | function translateDateTimestamp(timestamp) {
if (!timestamp) {
LOG.warn("Received an invalid timestamp: {}", timestamp);
return Date.now();
}
return new Date(timestamp);
} | javascript | function translateDateTimestamp(timestamp) {
if (!timestamp) {
LOG.warn("Received an invalid timestamp: {}", timestamp);
return Date.now();
}
return new Date(timestamp);
} | [
"function",
"translateDateTimestamp",
"(",
"timestamp",
")",
"{",
"if",
"(",
"!",
"timestamp",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Received an invalid timestamp: {}\"",
",",
"timestamp",
")",
";",
"return",
"Date",
".",
"now",
"(",
")",
";",
"}",
"return",... | Translates a date string from Dubtrack into a Javascript date.
@param {integer} timestamp - A timestamp from DubAPI
@returns {integer} The UNIX timestamp represented by the string,
or the current time if string is null/empty | [
"Translates",
"a",
"date",
"string",
"from",
"Dubtrack",
"into",
"a",
"Javascript",
"date",
"."
] | 0e4b5e65531c23293d22ac766850c802b1266e48 | https://github.com/chrishayesmu/DubBotBase/blob/0e4b5e65531c23293d22ac766850c802b1266e48/src/translator.js#L25-L32 | train |
chrishayesmu/DubBotBase | src/translator.js | translateRole | function translateRole(role) {
switch (role) {
case "5615fa9ae596154a5c000000":
return Types.UserRole.COOWNER;
case "5615fd84e596150061000003":
return Types.UserRole.MANAGER;
case "52d1ce33c38a06510c000001":
return Types.UserRole.MOD;
case "5615fe1... | javascript | function translateRole(role) {
switch (role) {
case "5615fa9ae596154a5c000000":
return Types.UserRole.COOWNER;
case "5615fd84e596150061000003":
return Types.UserRole.MANAGER;
case "52d1ce33c38a06510c000001":
return Types.UserRole.MOD;
case "5615fe1... | [
"function",
"translateRole",
"(",
"role",
")",
"{",
"switch",
"(",
"role",
")",
"{",
"case",
"\"5615fa9ae596154a5c000000\"",
":",
"return",
"Types",
".",
"UserRole",
".",
"COOWNER",
";",
"case",
"\"5615fd84e596150061000003\"",
":",
"return",
"Types",
".",
"UserR... | Translates the role integer returned by the dubtrack.fm API into an internal model.
@param {integer} roleAsInt - The dubtrack.fm API role
@returns {object} A corresponding object from the UserRole enum | [
"Translates",
"the",
"role",
"integer",
"returned",
"by",
"the",
"dubtrack",
".",
"fm",
"API",
"into",
"an",
"internal",
"model",
"."
] | 0e4b5e65531c23293d22ac766850c802b1266e48 | https://github.com/chrishayesmu/DubBotBase/blob/0e4b5e65531c23293d22ac766850c802b1266e48/src/translator.js#L216-L233 | train |
NumminorihSF/bramqp-wrapper | domain/basic.js | Basic | function Basic(client, channel, done){
EE.call(this);
this.client = client;
this.channel = channel;
this.id = channel.$getId();
this.publishCallbackMethod = DEFAULT_PUBLISH_ANSWER_WAIT_MECHANISM;
this.timeout = DEFAULT_WAIT_TIMEOUT;
this.lastConfirmSendId = 1;
this.lastMessageId = 1;
this.done = done... | javascript | function Basic(client, channel, done){
EE.call(this);
this.client = client;
this.channel = channel;
this.id = channel.$getId();
this.publishCallbackMethod = DEFAULT_PUBLISH_ANSWER_WAIT_MECHANISM;
this.timeout = DEFAULT_WAIT_TIMEOUT;
this.lastConfirmSendId = 1;
this.lastMessageId = 1;
this.done = done... | [
"function",
"Basic",
"(",
"client",
",",
"channel",
",",
"done",
")",
"{",
"EE",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"client",
"=",
"client",
";",
"this",
".",
"channel",
"=",
"channel",
";",
"this",
".",
"id",
"=",
"channel",
".",
"... | Work with basic content.
The Basic class provides methods that support an industry-standard messaging model. Work with channels.
@class Basic
@extends EventEmitter
@param {BRAMQPClient} client Client object that returns from bramqp#openAMQPCommunication() method.
@param {Channel} channel Channel object (should be ope... | [
"Work",
"with",
"basic",
"content",
"."
] | 3e2bd769a2828f7592eba79556c9ef1491177781 | https://github.com/NumminorihSF/bramqp-wrapper/blob/3e2bd769a2828f7592eba79556c9ef1491177781/domain/basic.js#L35-L50 | train |
ironboy/warp-core | include-common-imports.js | getJSFiles | function getJSFiles(folder = srcFolder){
let all = [];
let f = fs.readdirSync(folder);
for(file of f){
all.push(path.join(folder,file))
if(fs.lstatSync(path.join(folder,file)).isDirectory()){
all = all.concat(getJSFiles(path.join(folder,file)));
}
}
return all.filter(x => x.endsWith('.js'));... | javascript | function getJSFiles(folder = srcFolder){
let all = [];
let f = fs.readdirSync(folder);
for(file of f){
all.push(path.join(folder,file))
if(fs.lstatSync(path.join(folder,file)).isDirectory()){
all = all.concat(getJSFiles(path.join(folder,file)));
}
}
return all.filter(x => x.endsWith('.js'));... | [
"function",
"getJSFiles",
"(",
"folder",
"=",
"srcFolder",
")",
"{",
"let",
"all",
"=",
"[",
"]",
";",
"let",
"f",
"=",
"fs",
".",
"readdirSync",
"(",
"folder",
")",
";",
"for",
"(",
"file",
"of",
"f",
")",
"{",
"all",
".",
"push",
"(",
"path",
... | get all js file paths in a folder recursively | [
"get",
"all",
"js",
"file",
"paths",
"in",
"a",
"folder",
"recursively"
] | 0e3556e41e40cdfc0dafdfd4d9e02662010e9379 | https://github.com/ironboy/warp-core/blob/0e3556e41e40cdfc0dafdfd4d9e02662010e9379/include-common-imports.js#L74-L84 | train |
camshaft/reference-count | index.js | Sweep | function Sweep(actor, context) {
this.actor = actor;
this.context = context;
this.prev = context.actors[actor] || {};
this.resources = context.actors[actor] = {};
} | javascript | function Sweep(actor, context) {
this.actor = actor;
this.context = context;
this.prev = context.actors[actor] || {};
this.resources = context.actors[actor] = {};
} | [
"function",
"Sweep",
"(",
"actor",
",",
"context",
")",
"{",
"this",
".",
"actor",
"=",
"actor",
";",
"this",
".",
"context",
"=",
"context",
";",
"this",
".",
"prev",
"=",
"context",
".",
"actors",
"[",
"actor",
"]",
"||",
"{",
"}",
";",
"this",
... | Create a sweep instance
@param {String} actor
@param {Object} prev
@param {Context} context | [
"Create",
"a",
"sweep",
"instance"
] | b08bd3c676af742584e3f0101100f8fad6e33ba3 | https://github.com/camshaft/reference-count/blob/b08bd3c676af742584e3f0101100f8fad6e33ba3/index.js#L54-L59 | train |
iolo/express-toybox | session.js | session | function session(options) {
options = options || {};
DEBUG && debug('configure http session middleware', options);
if (options.store) {
try {
var storeModule = options.store.module;
var SessionStore = require(storeModule)(express);
// replace store options with st... | javascript | function session(options) {
options = options || {};
DEBUG && debug('configure http session middleware', options);
if (options.store) {
try {
var storeModule = options.store.module;
var SessionStore = require(storeModule)(express);
// replace store options with st... | [
"function",
"session",
"(",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"DEBUG",
"&&",
"debug",
"(",
"'configure http session middleware'",
",",
"options",
")",
";",
"if",
"(",
"options",
".",
"store",
")",
"{",
"try",
"{",
"var"... | session middleware.
@param {*} [options]
@param {*} [options.store]
@param {String} [options.store.module]
@param {*} [options.store.options] store specific options
@returns {function} connect/express middleware function
@see https://github.com/expressjs/session | [
"session",
"middleware",
"."
] | c375a1388cfc167017e8dcd2325e71ca86ccb994 | https://github.com/iolo/express-toybox/blob/c375a1388cfc167017e8dcd2325e71ca86ccb994/session.js#L20-L37 | train |
zenparsing/moon-unit | build/moon-unit.js | forEachDesc | function forEachDesc(obj, fn) {
var names = Object.getOwnPropertyNames(obj);
for (var i$0 = 0; i$0 < names.length; ++i$0)
fn(names[i$0], Object.getOwnPropertyDescriptor(obj, names[i$0]));
names = Object.getOwnPropertySymbols(obj);
for (var i$1 = 0; i$1 < names.length; ++i$1)
fn(names... | javascript | function forEachDesc(obj, fn) {
var names = Object.getOwnPropertyNames(obj);
for (var i$0 = 0; i$0 < names.length; ++i$0)
fn(names[i$0], Object.getOwnPropertyDescriptor(obj, names[i$0]));
names = Object.getOwnPropertySymbols(obj);
for (var i$1 = 0; i$1 < names.length; ++i$1)
fn(names... | [
"function",
"forEachDesc",
"(",
"obj",
",",
"fn",
")",
"{",
"var",
"names",
"=",
"Object",
".",
"getOwnPropertyNames",
"(",
"obj",
")",
";",
"for",
"(",
"var",
"i$0",
"=",
"0",
";",
"i$0",
"<",
"names",
".",
"length",
";",
"++",
"i$0",
")",
"fn",
... | Iterates over the descriptors for each own property of an object | [
"Iterates",
"over",
"the",
"descriptors",
"for",
"each",
"own",
"property",
"of",
"an",
"object"
] | 5fbe6805e3d382a0ce9e2913da65613ec33b19cb | https://github.com/zenparsing/moon-unit/blob/5fbe6805e3d382a0ce9e2913da65613ec33b19cb/build/moon-unit.js#L22-L35 | train |
zenparsing/moon-unit | build/moon-unit.js | mergeProperty | function mergeProperty(target, name, desc, enumerable) {
if (desc.get || desc.set) {
var d$0 = { configurable: true };
if (desc.get) d$0.get = desc.get;
if (desc.set) d$0.set = desc.set;
desc = d$0;
}
desc.enumerable = enumerable;
Object.defineProperty(target, name, de... | javascript | function mergeProperty(target, name, desc, enumerable) {
if (desc.get || desc.set) {
var d$0 = { configurable: true };
if (desc.get) d$0.get = desc.get;
if (desc.set) d$0.set = desc.set;
desc = d$0;
}
desc.enumerable = enumerable;
Object.defineProperty(target, name, de... | [
"function",
"mergeProperty",
"(",
"target",
",",
"name",
",",
"desc",
",",
"enumerable",
")",
"{",
"if",
"(",
"desc",
".",
"get",
"||",
"desc",
".",
"set",
")",
"{",
"var",
"d$0",
"=",
"{",
"configurable",
":",
"true",
"}",
";",
"if",
"(",
"desc",
... | Installs a property into an object, merging "get" and "set" functions | [
"Installs",
"a",
"property",
"into",
"an",
"object",
"merging",
"get",
"and",
"set",
"functions"
] | 5fbe6805e3d382a0ce9e2913da65613ec33b19cb | https://github.com/zenparsing/moon-unit/blob/5fbe6805e3d382a0ce9e2913da65613ec33b19cb/build/moon-unit.js#L38-L50 | train |
zenparsing/moon-unit | build/moon-unit.js | mergeProperties | function mergeProperties(target, source, enumerable) {
forEachDesc(source, function(name, desc) { return mergeProperty(target, name, desc, enumerable); });
} | javascript | function mergeProperties(target, source, enumerable) {
forEachDesc(source, function(name, desc) { return mergeProperty(target, name, desc, enumerable); });
} | [
"function",
"mergeProperties",
"(",
"target",
",",
"source",
",",
"enumerable",
")",
"{",
"forEachDesc",
"(",
"source",
",",
"function",
"(",
"name",
",",
"desc",
")",
"{",
"return",
"mergeProperty",
"(",
"target",
",",
"name",
",",
"desc",
",",
"enumerabl... | Installs properties on an object, merging "get" and "set" functions | [
"Installs",
"properties",
"on",
"an",
"object",
"merging",
"get",
"and",
"set",
"functions"
] | 5fbe6805e3d382a0ce9e2913da65613ec33b19cb | https://github.com/zenparsing/moon-unit/blob/5fbe6805e3d382a0ce9e2913da65613ec33b19cb/build/moon-unit.js#L53-L56 | train |
zenparsing/moon-unit | build/moon-unit.js | buildClass | function buildClass(base, def) {
var parent;
if (def === void 0) {
// If no base class is specified, then Object.prototype
// is the parent prototype
def = base;
base = null;
parent = Object.prototype;
} else if (base === null) {
// If the base is null, t... | javascript | function buildClass(base, def) {
var parent;
if (def === void 0) {
// If no base class is specified, then Object.prototype
// is the parent prototype
def = base;
base = null;
parent = Object.prototype;
} else if (base === null) {
// If the base is null, t... | [
"function",
"buildClass",
"(",
"base",
",",
"def",
")",
"{",
"var",
"parent",
";",
"if",
"(",
"def",
"===",
"void",
"0",
")",
"{",
"// If no base class is specified, then Object.prototype",
"// is the parent prototype",
"def",
"=",
"base",
";",
"base",
"=",
"nul... | Builds a class | [
"Builds",
"a",
"class"
] | 5fbe6805e3d382a0ce9e2913da65613ec33b19cb | https://github.com/zenparsing/moon-unit/blob/5fbe6805e3d382a0ce9e2913da65613ec33b19cb/build/moon-unit.js#L59-L118 | train |
zenparsing/moon-unit | build/moon-unit.js | function(target) {
for (var i$2 = 1; i$2 < arguments.length; i$2 += 3) {
var desc$0 = Object.getOwnPropertyDescriptor(arguments[i$2 + 1], "_");
mergeProperty(target, arguments[i$2], desc$0, true);
if (i$2 + 2 < arguments.length)
mergeProperties(target, argu... | javascript | function(target) {
for (var i$2 = 1; i$2 < arguments.length; i$2 += 3) {
var desc$0 = Object.getOwnPropertyDescriptor(arguments[i$2 + 1], "_");
mergeProperty(target, arguments[i$2], desc$0, true);
if (i$2 + 2 < arguments.length)
mergeProperties(target, argu... | [
"function",
"(",
"target",
")",
"{",
"for",
"(",
"var",
"i$2",
"=",
"1",
";",
"i$2",
"<",
"arguments",
".",
"length",
";",
"i$2",
"+=",
"3",
")",
"{",
"var",
"desc$0",
"=",
"Object",
".",
"getOwnPropertyDescriptor",
"(",
"arguments",
"[",
"i$2",
"+",... | Support for computed property names | [
"Support",
"for",
"computed",
"property",
"names"
] | 5fbe6805e3d382a0ce9e2913da65613ec33b19cb | https://github.com/zenparsing/moon-unit/blob/5fbe6805e3d382a0ce9e2913da65613ec33b19cb/build/moon-unit.js#L130-L142 | train | |
zenparsing/moon-unit | build/moon-unit.js | function(iter) {
var front = null, back = null;
return _esdown.computed({
next: function(val) { return send("next", val) },
throw: function(val) { return send("throw", val) },
return: function(val) { return send("return", val) },
}, Symbol.asyncIterator... | javascript | function(iter) {
var front = null, back = null;
return _esdown.computed({
next: function(val) { return send("next", val) },
throw: function(val) { return send("throw", val) },
return: function(val) { return send("return", val) },
}, Symbol.asyncIterator... | [
"function",
"(",
"iter",
")",
"{",
"var",
"front",
"=",
"null",
",",
"back",
"=",
"null",
";",
"return",
"_esdown",
".",
"computed",
"(",
"{",
"next",
":",
"function",
"(",
"val",
")",
"{",
"return",
"send",
"(",
"\"next\"",
",",
"val",
")",
"}",
... | Support for async generators | [
"Support",
"for",
"async",
"generators"
] | 5fbe6805e3d382a0ce9e2913da65613ec33b19cb | https://github.com/zenparsing/moon-unit/blob/5fbe6805e3d382a0ce9e2913da65613ec33b19cb/build/moon-unit.js#L181-L289 | train | |
zenparsing/moon-unit | build/moon-unit.js | function(initial) {
return {
a: initial || [],
// Add items
s: function() {
for (var i$3 = 0; i$3 < arguments.length; ++i$3)
this.a.push(arguments[i$3]);
return this;
},
// Add the contents of i... | javascript | function(initial) {
return {
a: initial || [],
// Add items
s: function() {
for (var i$3 = 0; i$3 < arguments.length; ++i$3)
this.a.push(arguments[i$3]);
return this;
},
// Add the contents of i... | [
"function",
"(",
"initial",
")",
"{",
"return",
"{",
"a",
":",
"initial",
"||",
"[",
"]",
",",
"// Add items",
"s",
":",
"function",
"(",
")",
"{",
"for",
"(",
"var",
"i$3",
"=",
"0",
";",
"i$3",
"<",
"arguments",
".",
"length",
";",
"++",
"i$3",... | Support for spread operations | [
"Support",
"for",
"spread",
"operations"
] | 5fbe6805e3d382a0ce9e2913da65613ec33b19cb | https://github.com/zenparsing/moon-unit/blob/5fbe6805e3d382a0ce9e2913da65613ec33b19cb/build/moon-unit.js#L292-L324 | 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.