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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
Zefau/nello.io | lib/timewindow.js | TimeWindow | function TimeWindow(connection, locationId, twId)
{
this.connection = connection;
this.locationId = locationId;
this.twId = twId;
} | javascript | function TimeWindow(connection, locationId, twId)
{
this.connection = connection;
this.locationId = locationId;
this.twId = twId;
} | [
"function",
"TimeWindow",
"(",
"connection",
",",
"locationId",
",",
"twId",
")",
"{",
"this",
".",
"connection",
"=",
"connection",
";",
"this",
".",
"locationId",
"=",
"locationId",
";",
"this",
".",
"twId",
"=",
"twId",
";",
"}"
] | The constructor for Nello time windows.
@class TimeWindow
@param {Nello} connection Nello instance
@param {String} locationId ID of the Nello location
@param {String} twId ID of the time window
@returns void
@constructor | [
"The",
"constructor",
"for",
"Nello",
"time",
"windows",
"."
] | 5a2b2cc9b47ffe700c203d3a38435d94e532d8ec | https://github.com/Zefau/nello.io/blob/5a2b2cc9b47ffe700c203d3a38435d94e532d8ec/lib/timewindow.js#L16-L21 | train |
dcodeIO/ascli | ascli.js | ascli | function ascli(title, appendix) {
title = title || ascli.appName;
appendix = appendix || "";
var lines = ["", "", ""], c, a, j, ac = "";
for (var i=0; i<title.length; i++) {
c = title.charAt(i);
if (c == '\x1B') {
while ((c=title.charAt(i)) != 'm') {
ac += c;
... | javascript | function ascli(title, appendix) {
title = title || ascli.appName;
appendix = appendix || "";
var lines = ["", "", ""], c, a, j, ac = "";
for (var i=0; i<title.length; i++) {
c = title.charAt(i);
if (c == '\x1B') {
while ((c=title.charAt(i)) != 'm') {
ac += c;
... | [
"function",
"ascli",
"(",
"title",
",",
"appendix",
")",
"{",
"title",
"=",
"title",
"||",
"ascli",
".",
"appName",
";",
"appendix",
"=",
"appendix",
"||",
"\"\"",
";",
"var",
"lines",
"=",
"[",
"\"\"",
",",
"\"\"",
",",
"\"\"",
"]",
",",
"c",
",",... | For backward compatibility
Builds a banner.
@param {string=} title App name
@param {string=} appendix Appendix, e.g. version
@returns {string} | [
"For",
"backward",
"compatibility",
"Builds",
"a",
"banner",
"."
] | 5972ea9baf6939fc0f47a3435cedd66bc6f66fe1 | https://github.com/dcodeIO/ascli/blob/5972ea9baf6939fc0f47a3435cedd66bc6f66fe1/ascli.js#L37-L59 | train |
glennjones/text-autolinker | lib/utilities.js | function(config) {
// get the options for the right server setup
var out = {},
serverMode = (process.env.NODE_ENV) ? process.env.NODE_ENV : 'development';
// loop object properties and add them to root of out object
for (var key in config.environments[serverMode]) {
if (config.environments[serverMode].ha... | javascript | function(config) {
// get the options for the right server setup
var out = {},
serverMode = (process.env.NODE_ENV) ? process.env.NODE_ENV : 'development';
// loop object properties and add them to root of out object
for (var key in config.environments[serverMode]) {
if (config.environments[serverMode].ha... | [
"function",
"(",
"config",
")",
"{",
"// get the options for the right server setup",
"var",
"out",
"=",
"{",
"}",
",",
"serverMode",
"=",
"(",
"process",
".",
"env",
".",
"NODE_ENV",
")",
"?",
"process",
".",
"env",
".",
"NODE_ENV",
":",
"'development'",
";... | refines configure using server context | [
"refines",
"configure",
"using",
"server",
"context"
] | 1c873d4779d399bf7f2cb2ba72bccf647af659f0 | https://github.com/glennjones/text-autolinker/blob/1c873d4779d399bf7f2cb2ba72bccf647af659f0/lib/utilities.js#L11-L40 | train | |
glennjones/text-autolinker | lib/utilities.js | function(path, callback) {
fs.readFile(path, 'utf8', function(err, data) {
if (!err) {
marked.setOptions({
gfm: true,
tables: true,
breaks: false,
pedantic: false,
sanitize: true,
smartLists: true,
smartypants: false,
langPrefix: 'language-',
highlight: function(cod... | javascript | function(path, callback) {
fs.readFile(path, 'utf8', function(err, data) {
if (!err) {
marked.setOptions({
gfm: true,
tables: true,
breaks: false,
pedantic: false,
sanitize: true,
smartLists: true,
smartypants: false,
langPrefix: 'language-',
highlight: function(cod... | [
"function",
"(",
"path",
",",
"callback",
")",
"{",
"fs",
".",
"readFile",
"(",
"path",
",",
"'utf8'",
",",
"function",
"(",
"err",
",",
"data",
")",
"{",
"if",
"(",
"!",
"err",
")",
"{",
"marked",
".",
"setOptions",
"(",
"{",
"gfm",
":",
"true",... | read a file and converts the markdown to HTML | [
"read",
"a",
"file",
"and",
"converts",
"the",
"markdown",
"to",
"HTML"
] | 1c873d4779d399bf7f2cb2ba72bccf647af659f0 | https://github.com/glennjones/text-autolinker/blob/1c873d4779d399bf7f2cb2ba72bccf647af659f0/lib/utilities.js#L44-L64 | train | |
glennjones/text-autolinker | lib/utilities.js | function(code, err, message) {
code = (code || isNaN(code)) ? code : 500;
err = (err) ? err : '';
message = (message) ? message : '';
return {
'code': code,
'error': err,
'message': message
};
} | javascript | function(code, err, message) {
code = (code || isNaN(code)) ? code : 500;
err = (err) ? err : '';
message = (message) ? message : '';
return {
'code': code,
'error': err,
'message': message
};
} | [
"function",
"(",
"code",
",",
"err",
",",
"message",
")",
"{",
"code",
"=",
"(",
"code",
"||",
"isNaN",
"(",
"code",
")",
")",
"?",
"code",
":",
"500",
";",
"err",
"=",
"(",
"err",
")",
"?",
"err",
":",
"''",
";",
"message",
"=",
"(",
"messag... | return error object | [
"return",
"error",
"object"
] | 1c873d4779d399bf7f2cb2ba72bccf647af659f0 | https://github.com/glennjones/text-autolinker/blob/1c873d4779d399bf7f2cb2ba72bccf647af659f0/lib/utilities.js#L79-L89 | train | |
yanni4night/django | lib/index.js | checkEnv | function checkEnv() {
async.series([
function(cb) {
childProcess.exec(
'python -c "import django; print(django.get_version())"',
function(err, version) {
if (err || !/^1\.7/.test(version)) {
r... | javascript | function checkEnv() {
async.series([
function(cb) {
childProcess.exec(
'python -c "import django; print(django.get_version())"',
function(err, version) {
if (err || !/^1\.7/.test(version)) {
r... | [
"function",
"checkEnv",
"(",
")",
"{",
"async",
".",
"series",
"(",
"[",
"function",
"(",
"cb",
")",
"{",
"childProcess",
".",
"exec",
"(",
"'python -c \"import django; print(django.get_version())\"'",
",",
"function",
"(",
"err",
",",
"version",
")",
"{",
"if... | Check dependencies.
@since 0.1.1
@throws {Error} If checking failed. | [
"Check",
"dependencies",
"."
] | 0aff5cf948373969ed10335c587e0301f4ef18af | https://github.com/yanni4night/django/blob/0aff5cf948373969ed10335c587e0301f4ef18af/lib/index.js#L49-L69 | train |
yanni4night/django | lib/index.js | innerRender | function innerRender(from, template, data, callback) {
var args, proc, out = '',
err = '',
base,
strData;
if (arguments.length < 4) {
callback = data;
data = {};
}
if (!template || template.constructor !== String) {
return callback(new Error('"template" ... | javascript | function innerRender(from, template, data, callback) {
var args, proc, out = '',
err = '',
base,
strData;
if (arguments.length < 4) {
callback = data;
data = {};
}
if (!template || template.constructor !== String) {
return callback(new Error('"template" ... | [
"function",
"innerRender",
"(",
"from",
",",
"template",
",",
"data",
",",
"callback",
")",
"{",
"var",
"args",
",",
"proc",
",",
"out",
"=",
"''",
",",
"err",
"=",
"''",
",",
"base",
",",
"strData",
";",
"if",
"(",
"arguments",
".",
"length",
"<",... | Render from a file or source codes.
@param {String} from source|file
@param {String} template
@param {Object} data
@param {Function} callback
@since 0.1.4 | [
"Render",
"from",
"a",
"file",
"or",
"source",
"codes",
"."
] | 0aff5cf948373969ed10335c587e0301f4ef18af | https://github.com/yanni4night/django/blob/0aff5cf948373969ed10335c587e0301f4ef18af/lib/index.js#L79-L157 | train |
AndiDittrich/Node.fs-magic | lib/untgz.js | untgz | function untgz(istream, dst){
// decompress
const tarStream = istream.pipe(_zlib.createGunzip());
// unpack
return _untar(tarStream, dst);
} | javascript | function untgz(istream, dst){
// decompress
const tarStream = istream.pipe(_zlib.createGunzip());
// unpack
return _untar(tarStream, dst);
} | [
"function",
"untgz",
"(",
"istream",
",",
"dst",
")",
"{",
"// decompress",
"const",
"tarStream",
"=",
"istream",
".",
"pipe",
"(",
"_zlib",
".",
"createGunzip",
"(",
")",
")",
";",
"// unpack",
"return",
"_untar",
"(",
"tarStream",
",",
"dst",
")",
";",... | decompress a tar.gz archive | [
"decompress",
"a",
"tar",
".",
"gz",
"archive"
] | 5e685a550fd956b5b422a0f21c359952e9be114b | https://github.com/AndiDittrich/Node.fs-magic/blob/5e685a550fd956b5b422a0f21c359952e9be114b/lib/untgz.js#L5-L11 | train |
canguruhh/metaversejs | src/encoder.js | encodeInputs | function encodeInputs(inputs, add_address_to_previous_output_index) {
//Initialize buffer and offset
let offset = 0;
var buffer = Buffer.allocUnsafe(100000);
//Write number of inputs
offset += bufferutils.writeVarInt(buffer, inputs.length, offset);
inputs.forEach((input, index) => {
//W... | javascript | function encodeInputs(inputs, add_address_to_previous_output_index) {
//Initialize buffer and offset
let offset = 0;
var buffer = Buffer.allocUnsafe(100000);
//Write number of inputs
offset += bufferutils.writeVarInt(buffer, inputs.length, offset);
inputs.forEach((input, index) => {
//W... | [
"function",
"encodeInputs",
"(",
"inputs",
",",
"add_address_to_previous_output_index",
")",
"{",
"//Initialize buffer and offset",
"let",
"offset",
"=",
"0",
";",
"var",
"buffer",
"=",
"Buffer",
".",
"allocUnsafe",
"(",
"100000",
")",
";",
"//Write number of inputs",... | Encode raw transactions inputs
@param {Array<input>} inputs
@param {Number} add_address_to_previous_output_index (optional) Index of an input thats previous output address should be added (needed for signing).
@returns {Buffer}
@throws {Error} | [
"Encode",
"raw",
"transactions",
"inputs"
] | d79471978d9e4bed277d3c12918a0f0c2a14a498 | https://github.com/canguruhh/metaversejs/blob/d79471978d9e4bed277d3c12918a0f0c2a14a498/src/encoder.js#L53-L104 | train |
canguruhh/metaversejs | src/encoder.js | encodeAttachmentMessage | function encodeAttachmentMessage(buffer, offset, message) {
if (message == undefined)
throw Error('Specify message');
offset += encodeString(buffer, message, offset);
return offset;
} | javascript | function encodeAttachmentMessage(buffer, offset, message) {
if (message == undefined)
throw Error('Specify message');
offset += encodeString(buffer, message, offset);
return offset;
} | [
"function",
"encodeAttachmentMessage",
"(",
"buffer",
",",
"offset",
",",
"message",
")",
"{",
"if",
"(",
"message",
"==",
"undefined",
")",
"throw",
"Error",
"(",
"'Specify message'",
")",
";",
"offset",
"+=",
"encodeString",
"(",
"buffer",
",",
"message",
... | Helper function to encode the attachment for a message.
@param {Buffer} buffer
@param {Number} offset
@param {string} message
@returns {Number} New offset
@throws {Error} | [
"Helper",
"function",
"to",
"encode",
"the",
"attachment",
"for",
"a",
"message",
"."
] | d79471978d9e4bed277d3c12918a0f0c2a14a498 | https://github.com/canguruhh/metaversejs/blob/d79471978d9e4bed277d3c12918a0f0c2a14a498/src/encoder.js#L230-L235 | train |
canguruhh/metaversejs | src/encoder.js | encodeAttachmentMSTTransfer | function encodeAttachmentMSTTransfer(buffer, offset, symbol, quantity) {
if (symbol == undefined)
throw Error('Specify output asset');
if (quantity == undefined)
throw Error('Specify output quanity');
offset = buffer.writeUInt32LE(Constants.MST.STATUS.TRANSFER, offset);
offset += encodeS... | javascript | function encodeAttachmentMSTTransfer(buffer, offset, symbol, quantity) {
if (symbol == undefined)
throw Error('Specify output asset');
if (quantity == undefined)
throw Error('Specify output quanity');
offset = buffer.writeUInt32LE(Constants.MST.STATUS.TRANSFER, offset);
offset += encodeS... | [
"function",
"encodeAttachmentMSTTransfer",
"(",
"buffer",
",",
"offset",
",",
"symbol",
",",
"quantity",
")",
"{",
"if",
"(",
"symbol",
"==",
"undefined",
")",
"throw",
"Error",
"(",
"'Specify output asset'",
")",
";",
"if",
"(",
"quantity",
"==",
"undefined",... | Helper function to encode the attachment for an asset transfer.
@param {Buffer} buffer
@param {Number} offset
@param {String} symbol
@param {Number} quantity
@returns {Number} New offset
@throws {Error} | [
"Helper",
"function",
"to",
"encode",
"the",
"attachment",
"for",
"an",
"asset",
"transfer",
"."
] | d79471978d9e4bed277d3c12918a0f0c2a14a498 | https://github.com/canguruhh/metaversejs/blob/d79471978d9e4bed277d3c12918a0f0c2a14a498/src/encoder.js#L246-L255 | train |
canguruhh/metaversejs | src/encoder.js | encodeAttachmentDid | function encodeAttachmentDid(buffer, offset, attachment_data) {
offset = buffer.writeUInt32LE(attachment_data.status, offset);
offset += encodeString(buffer, attachment_data.symbol, offset);
offset += encodeString(buffer, attachment_data.address, offset);
return offset;
} | javascript | function encodeAttachmentDid(buffer, offset, attachment_data) {
offset = buffer.writeUInt32LE(attachment_data.status, offset);
offset += encodeString(buffer, attachment_data.symbol, offset);
offset += encodeString(buffer, attachment_data.address, offset);
return offset;
} | [
"function",
"encodeAttachmentDid",
"(",
"buffer",
",",
"offset",
",",
"attachment_data",
")",
"{",
"offset",
"=",
"buffer",
".",
"writeUInt32LE",
"(",
"attachment_data",
".",
"status",
",",
"offset",
")",
";",
"offset",
"+=",
"encodeString",
"(",
"buffer",
","... | Helper function to encode the attachment for a new did.
@param {Buffer} buffer
@param {Number} offset
@param {Number} attachment_data
@returns {Number} New offset
@throws {Error} | [
"Helper",
"function",
"to",
"encode",
"the",
"attachment",
"for",
"a",
"new",
"did",
"."
] | d79471978d9e4bed277d3c12918a0f0c2a14a498 | https://github.com/canguruhh/metaversejs/blob/d79471978d9e4bed277d3c12918a0f0c2a14a498/src/encoder.js#L265-L270 | train |
canguruhh/metaversejs | src/encoder.js | encodeAttachmentCert | function encodeAttachmentCert(buffer, offset, attachment_data) {
offset += encodeString(buffer, attachment_data.symbol, offset);
offset += encodeString(buffer, attachment_data.owner, offset);
offset += encodeString(buffer, attachment_data.address, offset);
offset = buffer.writeUInt32LE(attachment_data.c... | javascript | function encodeAttachmentCert(buffer, offset, attachment_data) {
offset += encodeString(buffer, attachment_data.symbol, offset);
offset += encodeString(buffer, attachment_data.owner, offset);
offset += encodeString(buffer, attachment_data.address, offset);
offset = buffer.writeUInt32LE(attachment_data.c... | [
"function",
"encodeAttachmentCert",
"(",
"buffer",
",",
"offset",
",",
"attachment_data",
")",
"{",
"offset",
"+=",
"encodeString",
"(",
"buffer",
",",
"attachment_data",
".",
"symbol",
",",
"offset",
")",
";",
"offset",
"+=",
"encodeString",
"(",
"buffer",
",... | Helper function to encode the attachment for a certificate.
@param {Buffer} buffer
@param {Number} offset
@param {Number} attachment_data
@returns {Number} New offset
@throws {Error} | [
"Helper",
"function",
"to",
"encode",
"the",
"attachment",
"for",
"a",
"certificate",
"."
] | d79471978d9e4bed277d3c12918a0f0c2a14a498 | https://github.com/canguruhh/metaversejs/blob/d79471978d9e4bed277d3c12918a0f0c2a14a498/src/encoder.js#L280-L290 | train |
canguruhh/metaversejs | src/encoder.js | encodeAttachmentAssetIssue | function encodeAttachmentAssetIssue(buffer, offset, attachment_data) {
offset = buffer.writeUInt32LE(attachment_data.status, offset);
//Encode symbol
offset += encodeString(buffer, attachment_data.symbol, offset);
//Encode maximum supply
offset = bufferutils.writeUInt64LE(buffer, attachment_data.max... | javascript | function encodeAttachmentAssetIssue(buffer, offset, attachment_data) {
offset = buffer.writeUInt32LE(attachment_data.status, offset);
//Encode symbol
offset += encodeString(buffer, attachment_data.symbol, offset);
//Encode maximum supply
offset = bufferutils.writeUInt64LE(buffer, attachment_data.max... | [
"function",
"encodeAttachmentAssetIssue",
"(",
"buffer",
",",
"offset",
",",
"attachment_data",
")",
"{",
"offset",
"=",
"buffer",
".",
"writeUInt32LE",
"(",
"attachment_data",
".",
"status",
",",
"offset",
")",
";",
"//Encode symbol",
"offset",
"+=",
"encodeStrin... | Helper function to encode the attachment for a new asset.
@param {Buffer} buffer
@param {Number} offset
@param {Number} attachment_data
@returns {Number} New offset
@throws {Error} | [
"Helper",
"function",
"to",
"encode",
"the",
"attachment",
"for",
"a",
"new",
"asset",
"."
] | d79471978d9e4bed277d3c12918a0f0c2a14a498 | https://github.com/canguruhh/metaversejs/blob/d79471978d9e4bed277d3c12918a0f0c2a14a498/src/encoder.js#L300-L318 | train |
canguruhh/metaversejs | src/encoder.js | writeScriptPayToScriptHash | function writeScriptPayToScriptHash(scripthash, buffer, offset) {
offset = buffer.writeUInt8(23, offset); //Script length
offset = buffer.writeUInt8(OPS.OP_HASH160, offset);
//Write previous output address
offset = buffer.writeUInt8(20, offset); //Address length
offset += Buffer.from(base58check.dec... | javascript | function writeScriptPayToScriptHash(scripthash, buffer, offset) {
offset = buffer.writeUInt8(23, offset); //Script length
offset = buffer.writeUInt8(OPS.OP_HASH160, offset);
//Write previous output address
offset = buffer.writeUInt8(20, offset); //Address length
offset += Buffer.from(base58check.dec... | [
"function",
"writeScriptPayToScriptHash",
"(",
"scripthash",
",",
"buffer",
",",
"offset",
")",
"{",
"offset",
"=",
"buffer",
".",
"writeUInt8",
"(",
"23",
",",
"offset",
")",
";",
"//Script length",
"offset",
"=",
"buffer",
".",
"writeUInt8",
"(",
"OPS",
".... | Write p2sh to the given buffer.
@param {String} scripthash For example multisig address
@param {Buffer} buffer
@param {Number} offset
@returns {Number} new offset | [
"Write",
"p2sh",
"to",
"the",
"given",
"buffer",
"."
] | d79471978d9e4bed277d3c12918a0f0c2a14a498 | https://github.com/canguruhh/metaversejs/blob/d79471978d9e4bed277d3c12918a0f0c2a14a498/src/encoder.js#L372-L381 | train |
canguruhh/metaversejs | src/encoder.js | writeScriptPayToPubKeyHash | function writeScriptPayToPubKeyHash(address, buffer, offset) {
offset = buffer.writeUInt8(25, offset); //Script length
offset = buffer.writeUInt8(OPS.OP_DUP, offset);
offset = buffer.writeUInt8(OPS.OP_HASH160, offset);
//Write previous output address
offset = buffer.writeUInt8(20, offset); //Address... | javascript | function writeScriptPayToPubKeyHash(address, buffer, offset) {
offset = buffer.writeUInt8(25, offset); //Script length
offset = buffer.writeUInt8(OPS.OP_DUP, offset);
offset = buffer.writeUInt8(OPS.OP_HASH160, offset);
//Write previous output address
offset = buffer.writeUInt8(20, offset); //Address... | [
"function",
"writeScriptPayToPubKeyHash",
"(",
"address",
",",
"buffer",
",",
"offset",
")",
"{",
"offset",
"=",
"buffer",
".",
"writeUInt8",
"(",
"25",
",",
"offset",
")",
";",
"//Script length",
"offset",
"=",
"buffer",
".",
"writeUInt8",
"(",
"OPS",
".",
... | Write p2pkh to the given buffer.
@param {String} address
@param {Buffer} buffer
@param {Number} offset
@returns {Number} new offset | [
"Write",
"p2pkh",
"to",
"the",
"given",
"buffer",
"."
] | d79471978d9e4bed277d3c12918a0f0c2a14a498 | https://github.com/canguruhh/metaversejs/blob/d79471978d9e4bed277d3c12918a0f0c2a14a498/src/encoder.js#L390-L401 | train |
canguruhh/metaversejs | src/encoder.js | writeAttenuationScript | function writeAttenuationScript(attenuation_string, from_tx, from_index, address, buffer, offset) {
let attenuation_buffer = Buffer.from(attenuation_string.toString('hex'));
offset += bufferutils.writeVarInt(buffer, 26 + attenuation_string.length + 40, offset);
offset = buffer.writeUInt8(77, offset);
of... | javascript | function writeAttenuationScript(attenuation_string, from_tx, from_index, address, buffer, offset) {
let attenuation_buffer = Buffer.from(attenuation_string.toString('hex'));
offset += bufferutils.writeVarInt(buffer, 26 + attenuation_string.length + 40, offset);
offset = buffer.writeUInt8(77, offset);
of... | [
"function",
"writeAttenuationScript",
"(",
"attenuation_string",
",",
"from_tx",
",",
"from_index",
",",
"address",
",",
"buffer",
",",
"offset",
")",
"{",
"let",
"attenuation_buffer",
"=",
"Buffer",
".",
"from",
"(",
"attenuation_string",
".",
"toString",
"(",
... | Write p2pkh attenuation script to the given buffer.
@param {String} attenuation_string
@param {String} from_tx
@param {number} index
@param {String} address
@param {Buffer} buffer
@param {Number} offset
@returns {Number} new offset | [
"Write",
"p2pkh",
"attenuation",
"script",
"to",
"the",
"given",
"buffer",
"."
] | d79471978d9e4bed277d3c12918a0f0c2a14a498 | https://github.com/canguruhh/metaversejs/blob/d79471978d9e4bed277d3c12918a0f0c2a14a498/src/encoder.js#L413-L435 | train |
canguruhh/metaversejs | src/encoder.js | writeScriptLockedPayToPubKeyHash | function writeScriptLockedPayToPubKeyHash(address, locktime, buffer, offset) {
let locktime_buffer = Buffer.from(locktime, 'hex');
offset = buffer.writeUInt8(27 + locktime_buffer.length, offset); //Script length
offset = buffer.writeUInt8(locktime_buffer.length, offset); //Length of locktime
offset += l... | javascript | function writeScriptLockedPayToPubKeyHash(address, locktime, buffer, offset) {
let locktime_buffer = Buffer.from(locktime, 'hex');
offset = buffer.writeUInt8(27 + locktime_buffer.length, offset); //Script length
offset = buffer.writeUInt8(locktime_buffer.length, offset); //Length of locktime
offset += l... | [
"function",
"writeScriptLockedPayToPubKeyHash",
"(",
"address",
",",
"locktime",
",",
"buffer",
",",
"offset",
")",
"{",
"let",
"locktime_buffer",
"=",
"Buffer",
".",
"from",
"(",
"locktime",
",",
"'hex'",
")",
";",
"offset",
"=",
"buffer",
".",
"writeUInt8",
... | Write locked p2pkh to the given buffer.
@param {String} address
@param {String} locktime little endian hex
@param {Buffer} buffer
@param {Number} offset
@returns {Number} new offset | [
"Write",
"locked",
"p2pkh",
"to",
"the",
"given",
"buffer",
"."
] | d79471978d9e4bed277d3c12918a0f0c2a14a498 | https://github.com/canguruhh/metaversejs/blob/d79471978d9e4bed277d3c12918a0f0c2a14a498/src/encoder.js#L445-L459 | train |
gogoyqj/karma-event-driver-ext | src/event-driver-hooks.js | loadScript | async function loadScript(src) {
let script = document.createElement('script');
script.type = 'text/javascript';
let rs, rj, timer;
script.onload = () => {
script.onload = null;
clearTimeout(timer);
rs();
};
let prom = new Promise((resolve, reject) => {
rs = resol... | javascript | async function loadScript(src) {
let script = document.createElement('script');
script.type = 'text/javascript';
let rs, rj, timer;
script.onload = () => {
script.onload = null;
clearTimeout(timer);
rs();
};
let prom = new Promise((resolve, reject) => {
rs = resol... | [
"async",
"function",
"loadScript",
"(",
"src",
")",
"{",
"let",
"script",
"=",
"document",
".",
"createElement",
"(",
"'script'",
")",
";",
"script",
".",
"type",
"=",
"'text/javascript'",
";",
"let",
"rs",
",",
"rj",
",",
"timer",
";",
"script",
".",
... | load script async
@param {string} src
@return promise | [
"load",
"script",
"async"
] | 82d550e2fe87400b70ea8f3dea33fa91a0b1c587 | https://github.com/gogoyqj/karma-event-driver-ext/blob/82d550e2fe87400b70ea8f3dea33fa91a0b1c587/src/event-driver-hooks.js#L203-L220 | train |
gogoyqj/karma-event-driver-ext | src/event-driver-hooks.js | beforeEachHook | async function beforeEachHook(done) {
browser.__autoStart = browser.__prom = browser.__rejectSerial = browser.__resolveSerial = null;
done && done();
} | javascript | async function beforeEachHook(done) {
browser.__autoStart = browser.__prom = browser.__rejectSerial = browser.__resolveSerial = null;
done && done();
} | [
"async",
"function",
"beforeEachHook",
"(",
"done",
")",
"{",
"browser",
".",
"__autoStart",
"=",
"browser",
".",
"__prom",
"=",
"browser",
".",
"__rejectSerial",
"=",
"browser",
".",
"__resolveSerial",
"=",
"null",
";",
"done",
"&&",
"done",
"(",
")",
";"... | run before each test, reset browser status
@return promise | [
"run",
"before",
"each",
"test",
"reset",
"browser",
"status"
] | 82d550e2fe87400b70ea8f3dea33fa91a0b1c587 | https://github.com/gogoyqj/karma-event-driver-ext/blob/82d550e2fe87400b70ea8f3dea33fa91a0b1c587/src/event-driver-hooks.js#L332-L335 | train |
vfile/vfile-reporter-json | index.js | applicableMessages | function applicableMessages(messages, options) {
var length = messages.length
var index = -1
var result = []
if (options.silent) {
while (++index < length) {
if (messages[index].fatal) {
result.push(messages[index])
}
}
} else {
result = messages.concat()
}
return result
... | javascript | function applicableMessages(messages, options) {
var length = messages.length
var index = -1
var result = []
if (options.silent) {
while (++index < length) {
if (messages[index].fatal) {
result.push(messages[index])
}
}
} else {
result = messages.concat()
}
return result
... | [
"function",
"applicableMessages",
"(",
"messages",
",",
"options",
")",
"{",
"var",
"length",
"=",
"messages",
".",
"length",
"var",
"index",
"=",
"-",
"1",
"var",
"result",
"=",
"[",
"]",
"if",
"(",
"options",
".",
"silent",
")",
"{",
"while",
"(",
... | Get applicable messages. | [
"Get",
"applicable",
"messages",
"."
] | 26d843f681fb33ddf8b826e2908018f1cd82f8a1 | https://github.com/vfile/vfile-reporter-json/blob/26d843f681fb33ddf8b826e2908018f1cd82f8a1/index.js#L86-L102 | train |
addaleax/remarkup | remarkup.js | copyAttributes | function copyAttributes (src, dst, ignored) {
ignored = ignored || [];
const srcAttribs = Object.keys(src.attribs || src.attributes);
for (let i = 0; i < srcAttribs.length; ++i) {
if (!ignored.test(srcAttribs[i], $(dst), $(src))) {
dst.attribs[srcAttribs[i]] = src.attribs[srcAttribs[i]];
}
}
} | javascript | function copyAttributes (src, dst, ignored) {
ignored = ignored || [];
const srcAttribs = Object.keys(src.attribs || src.attributes);
for (let i = 0; i < srcAttribs.length; ++i) {
if (!ignored.test(srcAttribs[i], $(dst), $(src))) {
dst.attribs[srcAttribs[i]] = src.attribs[srcAttribs[i]];
}
}
} | [
"function",
"copyAttributes",
"(",
"src",
",",
"dst",
",",
"ignored",
")",
"{",
"ignored",
"=",
"ignored",
"||",
"[",
"]",
";",
"const",
"srcAttribs",
"=",
"Object",
".",
"keys",
"(",
"src",
".",
"attribs",
"||",
"src",
".",
"attributes",
")",
";",
"... | copy all DOM attributes from src to dst | [
"copy",
"all",
"DOM",
"attributes",
"from",
"src",
"to",
"dst"
] | 7a9a24881d593151bc65b9a851a00672a8e8060e | https://github.com/addaleax/remarkup/blob/7a9a24881d593151bc65b9a851a00672a8e8060e/remarkup.js#L426-L435 | train |
laurent22/joplin-turndown-plugin-gfm | src/tables.js | tableShouldBeSkipped | function tableShouldBeSkipped(tableNode) {
if (!tableNode) return true;
if (!tableNode.rows) return true;
if (tableNode.rows.length <= 1 && tableNode.rows[0].childNodes.length <= 1) return true; // Table with only one cell
if (nodeContainsTable(tableNode)) return true;
return false;
} | javascript | function tableShouldBeSkipped(tableNode) {
if (!tableNode) return true;
if (!tableNode.rows) return true;
if (tableNode.rows.length <= 1 && tableNode.rows[0].childNodes.length <= 1) return true; // Table with only one cell
if (nodeContainsTable(tableNode)) return true;
return false;
} | [
"function",
"tableShouldBeSkipped",
"(",
"tableNode",
")",
"{",
"if",
"(",
"!",
"tableNode",
")",
"return",
"true",
";",
"if",
"(",
"!",
"tableNode",
".",
"rows",
")",
"return",
"true",
";",
"if",
"(",
"tableNode",
".",
"rows",
".",
"length",
"<=",
"1"... | Various conditions under which a table should be skipped - i.e. each cell will be rendered one after the other as if they were paragraphs. | [
"Various",
"conditions",
"under",
"which",
"a",
"table",
"should",
"be",
"skipped",
"-",
"i",
".",
"e",
".",
"each",
"cell",
"will",
"be",
"rendered",
"one",
"after",
"the",
"other",
"as",
"if",
"they",
"were",
"paragraphs",
"."
] | 54f84c12fd29cd4e773a77bec060d5d46bf0815b | https://github.com/laurent22/joplin-turndown-plugin-gfm/blob/54f84c12fd29cd4e773a77bec060d5d46bf0815b/src/tables.js#L126-L132 | train |
AndiDittrich/Node.fs-magic | lib/gzip.js | gzip | async function gzip(input, dst, level=4){
// is input a filename or stream ?
if (typeof input === 'string'){
input = await _fileInputStream(input);
}
// compress
const gzipStream = input.pipe(_zlib.createGzip({
level: level
}));
// write content to file
return _fileOutp... | javascript | async function gzip(input, dst, level=4){
// is input a filename or stream ?
if (typeof input === 'string'){
input = await _fileInputStream(input);
}
// compress
const gzipStream = input.pipe(_zlib.createGzip({
level: level
}));
// write content to file
return _fileOutp... | [
"async",
"function",
"gzip",
"(",
"input",
",",
"dst",
",",
"level",
"=",
"4",
")",
"{",
"// is input a filename or stream ?",
"if",
"(",
"typeof",
"input",
"===",
"'string'",
")",
"{",
"input",
"=",
"await",
"_fileInputStream",
"(",
"input",
")",
";",
"}"... | compress a file | [
"compress",
"a",
"file"
] | 5e685a550fd956b5b422a0f21c359952e9be114b | https://github.com/AndiDittrich/Node.fs-magic/blob/5e685a550fd956b5b422a0f21c359952e9be114b/lib/gzip.js#L6-L19 | train |
brentertz/scapegoat | index.js | function(html) {
if (!html) {
return '';
}
var re = new RegExp('(' + Object.keys(chars).join('|') + ')', 'g');
return String(html).replace(re, function(match) {
return chars[match];
});
} | javascript | function(html) {
if (!html) {
return '';
}
var re = new RegExp('(' + Object.keys(chars).join('|') + ')', 'g');
return String(html).replace(re, function(match) {
return chars[match];
});
} | [
"function",
"(",
"html",
")",
"{",
"if",
"(",
"!",
"html",
")",
"{",
"return",
"''",
";",
"}",
"var",
"re",
"=",
"new",
"RegExp",
"(",
"'('",
"+",
"Object",
".",
"keys",
"(",
"chars",
")",
".",
"join",
"(",
"'|'",
")",
"+",
"')'",
",",
"'g'",... | Unescape special characters in the given string of html.
@param {String} html
@return {String} | [
"Unescape",
"special",
"characters",
"in",
"the",
"given",
"string",
"of",
"html",
"."
] | 671a59ecf01ce604a44bca0fc9b64f5dbe2f487d | https://github.com/brentertz/scapegoat/blob/671a59ecf01ce604a44bca0fc9b64f5dbe2f487d/index.js#L47-L57 | train | |
cognitom/felt | lib/config-builder.js | isInsideDir | function isInsideDir(dir, targetDir) {
if (targetDir == dir) return false
if (targetDir == '.') return dir
const relative = path.relative(targetDir, dir)
if (/^\.\./.test(relative)) return false
return relative
} | javascript | function isInsideDir(dir, targetDir) {
if (targetDir == dir) return false
if (targetDir == '.') return dir
const relative = path.relative(targetDir, dir)
if (/^\.\./.test(relative)) return false
return relative
} | [
"function",
"isInsideDir",
"(",
"dir",
",",
"targetDir",
")",
"{",
"if",
"(",
"targetDir",
"==",
"dir",
")",
"return",
"false",
"if",
"(",
"targetDir",
"==",
"'.'",
")",
"return",
"dir",
"const",
"relative",
"=",
"path",
".",
"relative",
"(",
"targetDir"... | If dir is inside targetDir, return the relative path
If else, return false | [
"If",
"dir",
"is",
"inside",
"targetDir",
"return",
"the",
"relative",
"path",
"If",
"else",
"return",
"false"
] | e97218aef9876ebdb2e6047138afe64ed37a4c83 | https://github.com/cognitom/felt/blob/e97218aef9876ebdb2e6047138afe64ed37a4c83/lib/config-builder.js#L58-L64 | train |
sir-dunxalot/ember-cli-modernizr | vendor/modernizr-development.js | injectElementWithStyles | function injectElementWithStyles( rule, callback, nodes, testnames ) {
var mod = 'modernizr';
var style;
var ret;
var node;
var docOverflow;
var div = createElement('div');
var body = getBody();
if ( parseInt(nodes, 10) ) {
// In order not to give false positives we create a node ... | javascript | function injectElementWithStyles( rule, callback, nodes, testnames ) {
var mod = 'modernizr';
var style;
var ret;
var node;
var docOverflow;
var div = createElement('div');
var body = getBody();
if ( parseInt(nodes, 10) ) {
// In order not to give false positives we create a node ... | [
"function",
"injectElementWithStyles",
"(",
"rule",
",",
"callback",
",",
"nodes",
",",
"testnames",
")",
"{",
"var",
"mod",
"=",
"'modernizr'",
";",
"var",
"style",
";",
"var",
"ret",
";",
"var",
"node",
";",
"var",
"docOverflow",
";",
"var",
"div",
"="... | Inject element with style element and some CSS rules | [
"Inject",
"element",
"with",
"style",
"element",
"and",
"some",
"CSS",
"rules"
] | 264735b535bce1b31648eaf884c7b681606e7f9b | https://github.com/sir-dunxalot/ember-cli-modernizr/blob/264735b535bce1b31648eaf884c7b681606e7f9b/vendor/modernizr-development.js#L5303-L5356 | train |
areslabs/react-native-withcss | src/styleutil.js | legalStyle | function legalStyle(localStyle, legalSet) {
//flatten array, easy for manipulating data
let tmp = flattenArray(localStyle)
let obj = {}
for (let k in tmp) {
//save legal declaration to output
if (legalSet.has(k))
obj[k] = tmp[k];
}
return obj;
} | javascript | function legalStyle(localStyle, legalSet) {
//flatten array, easy for manipulating data
let tmp = flattenArray(localStyle)
let obj = {}
for (let k in tmp) {
//save legal declaration to output
if (legalSet.has(k))
obj[k] = tmp[k];
}
return obj;
} | [
"function",
"legalStyle",
"(",
"localStyle",
",",
"legalSet",
")",
"{",
"//flatten array, easy for manipulating data",
"let",
"tmp",
"=",
"flattenArray",
"(",
"localStyle",
")",
"let",
"obj",
"=",
"{",
"}",
"for",
"(",
"let",
"k",
"in",
"tmp",
")",
"{",
"//s... | constrain style,to remove illegal style warning,for example,
setting fontSize for View may cause warning in debugger mode.
@param localStyle style waiting for constraining.
@param legalSet specify legal style set for specify React Native element,eg. View or Text | [
"constrain",
"style",
"to",
"remove",
"illegal",
"style",
"warning",
"for",
"example",
"setting",
"fontSize",
"for",
"View",
"may",
"cause",
"warning",
"in",
"debugger",
"mode",
"."
] | ed8f1a376e269a3cc37d67accdf4aee16d6abd32 | https://github.com/areslabs/react-native-withcss/blob/ed8f1a376e269a3cc37d67accdf4aee16d6abd32/src/styleutil.js#L15-L25 | train |
areslabs/react-native-withcss | src/styleutil.js | flattenArray | function flattenArray(input, ans = {}) {
if (!input || !Array.isArray(input)) return input || {}
for (let k in input) {
//recursive logic
if (Array.isArray(input[k])) {
ans = flattenArray(input[k], ans)
} else {
ans = Object.assign({}, ans, input[k])
}
... | javascript | function flattenArray(input, ans = {}) {
if (!input || !Array.isArray(input)) return input || {}
for (let k in input) {
//recursive logic
if (Array.isArray(input[k])) {
ans = flattenArray(input[k], ans)
} else {
ans = Object.assign({}, ans, input[k])
}
... | [
"function",
"flattenArray",
"(",
"input",
",",
"ans",
"=",
"{",
"}",
")",
"{",
"if",
"(",
"!",
"input",
"||",
"!",
"Array",
".",
"isArray",
"(",
"input",
")",
")",
"return",
"input",
"||",
"{",
"}",
"for",
"(",
"let",
"k",
"in",
"input",
")",
"... | flatten deep array to plain object
@param input may deep array,e.g. [{color:'red'},[{fontSize:11}]]
@param ans output plain object,e,g. {color:'red',fontSize:11}
@returns plain object mentioned above | [
"flatten",
"deep",
"array",
"to",
"plain",
"object"
] | ed8f1a376e269a3cc37d67accdf4aee16d6abd32 | https://github.com/areslabs/react-native-withcss/blob/ed8f1a376e269a3cc37d67accdf4aee16d6abd32/src/styleutil.js#L33-L44 | train |
areslabs/react-native-withcss | src/styleutil.js | countCharFromStr | function countCharFromStr(str, ch) {
let strArr = [...str];
let count = 0;
for (let k in strArr) {
if (strArr[k] === ch) {
count++
}
}
return count
} | javascript | function countCharFromStr(str, ch) {
let strArr = [...str];
let count = 0;
for (let k in strArr) {
if (strArr[k] === ch) {
count++
}
}
return count
} | [
"function",
"countCharFromStr",
"(",
"str",
",",
"ch",
")",
"{",
"let",
"strArr",
"=",
"[",
"...",
"str",
"]",
";",
"let",
"count",
"=",
"0",
";",
"for",
"(",
"let",
"k",
"in",
"strArr",
")",
"{",
"if",
"(",
"strArr",
"[",
"k",
"]",
"===",
"ch"... | count specific character in string
@param str target string
@param ch specific character
@returns {number} characters count | [
"count",
"specific",
"character",
"in",
"string"
] | ed8f1a376e269a3cc37d67accdf4aee16d6abd32 | https://github.com/areslabs/react-native-withcss/blob/ed8f1a376e269a3cc37d67accdf4aee16d6abd32/src/styleutil.js#L87-L96 | train |
AntonioMA/swagger-boilerplate | lib/setup-process.js | setupProcess | function setupProcess(aLogger, aDaemonize, aLogFile) {
aLogger.log('Setting up process. Run as a daemon:', aDaemonize, 'Logfile:', aLogFile);
// Since we might need to open some files, and that's an asynchronous operation,
// we will return a promise here that will never resolve on the parent (process will die i... | javascript | function setupProcess(aLogger, aDaemonize, aLogFile) {
aLogger.log('Setting up process. Run as a daemon:', aDaemonize, 'Logfile:', aLogFile);
// Since we might need to open some files, and that's an asynchronous operation,
// we will return a promise here that will never resolve on the parent (process will die i... | [
"function",
"setupProcess",
"(",
"aLogger",
",",
"aDaemonize",
",",
"aLogFile",
")",
"{",
"aLogger",
".",
"log",
"(",
"'Setting up process. Run as a daemon:'",
",",
"aDaemonize",
",",
"'Logfile:'",
",",
"aLogFile",
")",
";",
"// Since we might need to open some files, a... | Capture signals and optionally daemonize and change username | [
"Capture",
"signals",
"and",
"optionally",
"daemonize",
"and",
"change",
"username"
] | ce6980060c8194b993b3ab3ed750a25d02e9d66a | https://github.com/AntonioMA/swagger-boilerplate/blob/ce6980060c8194b993b3ab3ed750a25d02e9d66a/lib/setup-process.js#L7-L81 | train |
glennjones/text-autolinker | lib/autolinker.js | parseUrls | function parseUrls(text, options, callback) {
var urls = [],
words,
x = 0,
i;
// is a text string
if (text && utils.isString(text) && text !== '') {
// break texts into words
words = [text];
if (text.indexOf(' ') > -1) {
words = text.split(' ');
}
// finds urls in text
i = words.length;
whi... | javascript | function parseUrls(text, options, callback) {
var urls = [],
words,
x = 0,
i;
// is a text string
if (text && utils.isString(text) && text !== '') {
// break texts into words
words = [text];
if (text.indexOf(' ') > -1) {
words = text.split(' ');
}
// finds urls in text
i = words.length;
whi... | [
"function",
"parseUrls",
"(",
"text",
",",
"options",
",",
"callback",
")",
"{",
"var",
"urls",
"=",
"[",
"]",
",",
"words",
",",
"x",
"=",
"0",
",",
"i",
";",
"// is a text string",
"if",
"(",
"text",
"&&",
"utils",
".",
"isString",
"(",
"text",
"... | parse the text for urls | [
"parse",
"the",
"text",
"for",
"urls"
] | 1c873d4779d399bf7f2cb2ba72bccf647af659f0 | https://github.com/glennjones/text-autolinker/blob/1c873d4779d399bf7f2cb2ba72bccf647af659f0/lib/autolinker.js#L229-L273 | train |
glennjones/text-autolinker | lib/autolinker.js | getExpandedUrl | function getExpandedUrl(url, options) {
var x = 0,
i;
if (options.urls) {
i = options.urls.length;
while (x < i) {
if (options.urls[x].match === url) {
if (options.urls[x].expanded) {
return options.urls[x].expanded;
}
return null;
}
x++;
}
}
return null;
} | javascript | function getExpandedUrl(url, options) {
var x = 0,
i;
if (options.urls) {
i = options.urls.length;
while (x < i) {
if (options.urls[x].match === url) {
if (options.urls[x].expanded) {
return options.urls[x].expanded;
}
return null;
}
x++;
}
}
return null;
} | [
"function",
"getExpandedUrl",
"(",
"url",
",",
"options",
")",
"{",
"var",
"x",
"=",
"0",
",",
"i",
";",
"if",
"(",
"options",
".",
"urls",
")",
"{",
"i",
"=",
"options",
".",
"urls",
".",
"length",
";",
"while",
"(",
"x",
"<",
"i",
")",
"{",
... | gets exteneded urls from options.urls array | [
"gets",
"exteneded",
"urls",
"from",
"options",
".",
"urls",
"array"
] | 1c873d4779d399bf7f2cb2ba72bccf647af659f0 | https://github.com/glennjones/text-autolinker/blob/1c873d4779d399bf7f2cb2ba72bccf647af659f0/lib/autolinker.js#L277-L293 | train |
glennjones/text-autolinker | lib/autolinker.js | constainRestrictedWords | function constainRestrictedWords(text) {
var i,
restictedWords = ['today', 'tomorrow', 'yesterday', 'tonight'];
text = text.toLowerCase();
i = restictedWords.length;
while (i--) {
if (text.indexOf(restictedWords[i]) > -1) {
return true;
}
}
return false;
} | javascript | function constainRestrictedWords(text) {
var i,
restictedWords = ['today', 'tomorrow', 'yesterday', 'tonight'];
text = text.toLowerCase();
i = restictedWords.length;
while (i--) {
if (text.indexOf(restictedWords[i]) > -1) {
return true;
}
}
return false;
} | [
"function",
"constainRestrictedWords",
"(",
"text",
")",
"{",
"var",
"i",
",",
"restictedWords",
"=",
"[",
"'today'",
",",
"'tomorrow'",
",",
"'yesterday'",
",",
"'tonight'",
"]",
";",
"text",
"=",
"text",
".",
"toLowerCase",
"(",
")",
";",
"i",
"=",
"re... | list of words not to let the parser use stops praser returning implied dates against server local time | [
"list",
"of",
"words",
"not",
"to",
"let",
"the",
"parser",
"use",
"stops",
"praser",
"returning",
"implied",
"dates",
"against",
"server",
"local",
"time"
] | 1c873d4779d399bf7f2cb2ba72bccf647af659f0 | https://github.com/glennjones/text-autolinker/blob/1c873d4779d399bf7f2cb2ba72bccf647af659f0/lib/autolinker.js#L413-L425 | train |
glennjones/text-autolinker | lib/autolinker.js | buildISOLocalDate | function buildISOLocalDate (date) {
var out;
if (date.year !== undefined) {
out = date.year;
}
if (date.month !== undefined) {
out += '-' + pad(date.month + 1);
}
if (date.day !== undefined) {
out += '-' + pad(date.day);
}
if (date.hour !== undefined) {
out += 'T' + pad(date.hour);
}
if (date.minute !... | javascript | function buildISOLocalDate (date) {
var out;
if (date.year !== undefined) {
out = date.year;
}
if (date.month !== undefined) {
out += '-' + pad(date.month + 1);
}
if (date.day !== undefined) {
out += '-' + pad(date.day);
}
if (date.hour !== undefined) {
out += 'T' + pad(date.hour);
}
if (date.minute !... | [
"function",
"buildISOLocalDate",
"(",
"date",
")",
"{",
"var",
"out",
";",
"if",
"(",
"date",
".",
"year",
"!==",
"undefined",
")",
"{",
"out",
"=",
"date",
".",
"year",
";",
"}",
"if",
"(",
"date",
".",
"month",
"!==",
"undefined",
")",
"{",
"out"... | builds a local date parsed from text, with no ref to server time | [
"builds",
"a",
"local",
"date",
"parsed",
"from",
"text",
"with",
"no",
"ref",
"to",
"server",
"time"
] | 1c873d4779d399bf7f2cb2ba72bccf647af659f0 | https://github.com/glennjones/text-autolinker/blob/1c873d4779d399bf7f2cb2ba72bccf647af659f0/lib/autolinker.js#L429-L458 | train |
AndiDittrich/Node.fs-magic | lib/FileOutputStream.js | FileOutputStream | function FileOutputStream(istream, destinationFilename, mode=false){
// wrap into Promise
return new Promise(function(resolve, reject){
// file output stream
let ostream = null;
// on complete - chmod
const onComplete = function(){
// file mode defined ?
... | javascript | function FileOutputStream(istream, destinationFilename, mode=false){
// wrap into Promise
return new Promise(function(resolve, reject){
// file output stream
let ostream = null;
// on complete - chmod
const onComplete = function(){
// file mode defined ?
... | [
"function",
"FileOutputStream",
"(",
"istream",
",",
"destinationFilename",
",",
"mode",
"=",
"false",
")",
"{",
"// wrap into Promise",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"// file output stream",
"let",
"ostream"... | write a stream to destination file | [
"write",
"a",
"stream",
"to",
"destination",
"file"
] | 5e685a550fd956b5b422a0f21c359952e9be114b | https://github.com/AndiDittrich/Node.fs-magic/blob/5e685a550fd956b5b422a0f21c359952e9be114b/lib/FileOutputStream.js#L4-L59 | train |
AndiDittrich/Node.fs-magic | lib/FileOutputStream.js | function(){
// file mode defined ?
if (mode){
// set mode of destination file
_fs.chmod(destinationFilename, mode, function(err){
if (err){
reject(err);
}else{
resolve();
... | javascript | function(){
// file mode defined ?
if (mode){
// set mode of destination file
_fs.chmod(destinationFilename, mode, function(err){
if (err){
reject(err);
}else{
resolve();
... | [
"function",
"(",
")",
"{",
"// file mode defined ?",
"if",
"(",
"mode",
")",
"{",
"// set mode of destination file",
"_fs",
".",
"chmod",
"(",
"destinationFilename",
",",
"mode",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"{",
"reject",
... | on complete - chmod | [
"on",
"complete",
"-",
"chmod"
] | 5e685a550fd956b5b422a0f21c359952e9be114b | https://github.com/AndiDittrich/Node.fs-magic/blob/5e685a550fd956b5b422a0f21c359952e9be114b/lib/FileOutputStream.js#L12-L27 | train | |
AntonioMA/swagger-boilerplate | lib/server.js | getServerConfig | function getServerConfig(aCertDir) {
const certFileRead = readFile(aCertDir + '/serverCert.pem');
const keyFileRead = readFile(aCertDir + '/serverKey.pem');
return Promise.all([certFileRead, keyFileRead]).
then(files => [{ cert: files[0], key: files[1] }]);
} | javascript | function getServerConfig(aCertDir) {
const certFileRead = readFile(aCertDir + '/serverCert.pem');
const keyFileRead = readFile(aCertDir + '/serverKey.pem');
return Promise.all([certFileRead, keyFileRead]).
then(files => [{ cert: files[0], key: files[1] }]);
} | [
"function",
"getServerConfig",
"(",
"aCertDir",
")",
"{",
"const",
"certFileRead",
"=",
"readFile",
"(",
"aCertDir",
"+",
"'/serverCert.pem'",
")",
";",
"const",
"keyFileRead",
"=",
"readFile",
"(",
"aCertDir",
"+",
"'/serverKey.pem'",
")",
";",
"return",
"Promi... | At this moment reads the cert and key as serverKey and serverCert, without password, from aCertDir. | [
"At",
"this",
"moment",
"reads",
"the",
"cert",
"and",
"key",
"as",
"serverKey",
"and",
"serverCert",
"without",
"password",
"from",
"aCertDir",
"."
] | ce6980060c8194b993b3ab3ed750a25d02e9d66a | https://github.com/AntonioMA/swagger-boilerplate/blob/ce6980060c8194b993b3ab3ed750a25d02e9d66a/lib/server.js#L26-L31 | train |
plepers/nanogl-node | node.js | function( skipParents ){
skipParents = !!skipParents;
this.updateMatrix();
var invalidWorldMatrix = this._hasInvalidWorldMatrix( skipParents );
if( invalidWorldMatrix ) {
this._computeWorldMatrix( skipParents );
}
for (var i = 0; i < this._children.length; i++) {
var c = this._chi... | javascript | function( skipParents ){
skipParents = !!skipParents;
this.updateMatrix();
var invalidWorldMatrix = this._hasInvalidWorldMatrix( skipParents );
if( invalidWorldMatrix ) {
this._computeWorldMatrix( skipParents );
}
for (var i = 0; i < this._children.length; i++) {
var c = this._chi... | [
"function",
"(",
"skipParents",
")",
"{",
"skipParents",
"=",
"!",
"!",
"skipParents",
";",
"this",
".",
"updateMatrix",
"(",
")",
";",
"var",
"invalidWorldMatrix",
"=",
"this",
".",
"_hasInvalidWorldMatrix",
"(",
"skipParents",
")",
";",
"if",
"(",
"invalid... | update world matrix and descendants. | [
"update",
"world",
"matrix",
"and",
"descendants",
"."
] | 5ca4c3261ae66f79cd6d520f082000af9c3a2ec2 | https://github.com/plepers/nanogl-node/blob/5ca4c3261ae66f79cd6d520f082000af9c3a2ec2/node.js#L125-L141 | train | |
jvictorsoto/tc-wrapper | src/helpers.js | execCmd | function execCmd(cmd, allowedErrors = []) {
debug(`About to execute cmd: ${cmd} with allowed errors: ${JSON.stringify(allowedErrors)}`);
return exec(cmd, {})
.then((result) => {
debug(`Executed successfully cmd: ${cmd}: `, result.stdout);
const { stdout } = result;
return stdout;
})
.c... | javascript | function execCmd(cmd, allowedErrors = []) {
debug(`About to execute cmd: ${cmd} with allowed errors: ${JSON.stringify(allowedErrors)}`);
return exec(cmd, {})
.then((result) => {
debug(`Executed successfully cmd: ${cmd}: `, result.stdout);
const { stdout } = result;
return stdout;
})
.c... | [
"function",
"execCmd",
"(",
"cmd",
",",
"allowedErrors",
"=",
"[",
"]",
")",
"{",
"debug",
"(",
"`",
"${",
"cmd",
"}",
"${",
"JSON",
".",
"stringify",
"(",
"allowedErrors",
")",
"}",
"`",
")",
";",
"return",
"exec",
"(",
"cmd",
",",
"{",
"}",
")"... | Helper function to exec commands. | [
"Helper",
"function",
"to",
"exec",
"commands",
"."
] | 06ff3def7e2125466f4dfdc7696cac9cc08f02d5 | https://github.com/jvictorsoto/tc-wrapper/blob/06ff3def7e2125466f4dfdc7696cac9cc08f02d5/src/helpers.js#L12-L27 | train |
io-monad/line-column | lib/line-column.js | LineColumnFinder | function LineColumnFinder(str, options) {
if (!(this instanceof LineColumnFinder)) {
if (typeof options === "number") {
return (new LineColumnFinder(str)).fromIndex(options);
}
return new LineColumnFinder(str, options);
}
this.str = str || "";
this.lineToIndex = buildLineToIndex(this.str);
... | javascript | function LineColumnFinder(str, options) {
if (!(this instanceof LineColumnFinder)) {
if (typeof options === "number") {
return (new LineColumnFinder(str)).fromIndex(options);
}
return new LineColumnFinder(str, options);
}
this.str = str || "";
this.lineToIndex = buildLineToIndex(this.str);
... | [
"function",
"LineColumnFinder",
"(",
"str",
",",
"options",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"LineColumnFinder",
")",
")",
"{",
"if",
"(",
"typeof",
"options",
"===",
"\"number\"",
")",
"{",
"return",
"(",
"new",
"LineColumnFinder",
"("... | Finder for index and line-column from given string.
You can call this without `new` operator as it returns an instance anyway.
@class
@param {string} str - A string to be parsed.
@param {Object|number} [options] - Options.
This can be an index in the string for shorthand of `lineColumn(str, index)`.
@param {number} [... | [
"Finder",
"for",
"index",
"and",
"line",
"-",
"column",
"from",
"given",
"string",
"."
] | a7a2b4cb6ca58f0d36b900c8e60bf9428aa0bb4e | https://github.com/io-monad/line-column/blob/a7a2b4cb6ca58f0d36b900c8e60bf9428aa0bb4e/lib/line-column.js#L25-L38 | train |
io-monad/line-column | lib/line-column.js | buildLineToIndex | function buildLineToIndex(str) {
var lines = str.split("\n"),
lineToIndex = new Array(lines.length),
index = 0;
for (var i = 0, l = lines.length; i < l; i++) {
lineToIndex[i] = index;
index += lines[i].length + /* "\n".length */ 1;
}
return lineToIndex;
} | javascript | function buildLineToIndex(str) {
var lines = str.split("\n"),
lineToIndex = new Array(lines.length),
index = 0;
for (var i = 0, l = lines.length; i < l; i++) {
lineToIndex[i] = index;
index += lines[i].length + /* "\n".length */ 1;
}
return lineToIndex;
} | [
"function",
"buildLineToIndex",
"(",
"str",
")",
"{",
"var",
"lines",
"=",
"str",
".",
"split",
"(",
"\"\\n\"",
")",
",",
"lineToIndex",
"=",
"new",
"Array",
"(",
"lines",
".",
"length",
")",
",",
"index",
"=",
"0",
";",
"for",
"(",
"var",
"i",
"="... | Build an array of indexes of each line from a string.
@private
@param str {string} An input string.
@return {number[]} Built array of indexes. The key is line number. | [
"Build",
"an",
"array",
"of",
"indexes",
"of",
"each",
"line",
"from",
"a",
"string",
"."
] | a7a2b4cb6ca58f0d36b900c8e60bf9428aa0bb4e | https://github.com/io-monad/line-column/blob/a7a2b4cb6ca58f0d36b900c8e60bf9428aa0bb4e/lib/line-column.js#L112-L122 | train |
io-monad/line-column | lib/line-column.js | findLowerIndexInRangeArray | function findLowerIndexInRangeArray(value, arr) {
if (value >= arr[arr.length - 1]) {
return arr.length - 1;
}
var min = 0, max = arr.length - 2, mid;
while (min < max) {
mid = min + ((max - min) >> 1);
if (value < arr[mid]) {
max = mid - 1;
} else if (value >= arr[mid + 1]) {
min ... | javascript | function findLowerIndexInRangeArray(value, arr) {
if (value >= arr[arr.length - 1]) {
return arr.length - 1;
}
var min = 0, max = arr.length - 2, mid;
while (min < max) {
mid = min + ((max - min) >> 1);
if (value < arr[mid]) {
max = mid - 1;
} else if (value >= arr[mid + 1]) {
min ... | [
"function",
"findLowerIndexInRangeArray",
"(",
"value",
",",
"arr",
")",
"{",
"if",
"(",
"value",
">=",
"arr",
"[",
"arr",
".",
"length",
"-",
"1",
"]",
")",
"{",
"return",
"arr",
".",
"length",
"-",
"1",
";",
"}",
"var",
"min",
"=",
"0",
",",
"m... | Find a lower-bound index of a value in a sorted array of ranges.
Assume `arr = [0, 5, 10, 15, 20]` and
this returns `1` for `value = 7` (5 <= value < 10),
and returns `3` for `value = 18` (15 <= value < 20).
@private
@param arr {number[]} An array of values representing ranges.
@param value {number} A value to ... | [
"Find",
"a",
"lower",
"-",
"bound",
"index",
"of",
"a",
"value",
"in",
"a",
"sorted",
"array",
"of",
"ranges",
"."
] | a7a2b4cb6ca58f0d36b900c8e60bf9428aa0bb4e | https://github.com/io-monad/line-column/blob/a7a2b4cb6ca58f0d36b900c8e60bf9428aa0bb4e/lib/line-column.js#L136-L155 | train |
AndiDittrich/Node.fs-magic | lib/scandir.js | scandir | async function scandir(dir, recursive=true, absolutePaths=false){
// get absolute path
const absPath = _path.resolve(dir);
// stats command executable ? dir/file exists
const stats = await _fs.stat(absPath);
// check if its a directory
if (!stats.isDirectory()){
throw new Error('Reques... | javascript | async function scandir(dir, recursive=true, absolutePaths=false){
// get absolute path
const absPath = _path.resolve(dir);
// stats command executable ? dir/file exists
const stats = await _fs.stat(absPath);
// check if its a directory
if (!stats.isDirectory()){
throw new Error('Reques... | [
"async",
"function",
"scandir",
"(",
"dir",
",",
"recursive",
"=",
"true",
",",
"absolutePaths",
"=",
"false",
")",
"{",
"// get absolute path",
"const",
"absPath",
"=",
"_path",
".",
"resolve",
"(",
"dir",
")",
";",
"// stats command executable ? dir/file exists"... | list files and directories of a given directory | [
"list",
"files",
"and",
"directories",
"of",
"a",
"given",
"directory"
] | 5e685a550fd956b5b422a0f21c359952e9be114b | https://github.com/AndiDittrich/Node.fs-magic/blob/5e685a550fd956b5b422a0f21c359952e9be114b/lib/scandir.js#L5-L67 | train |
Lergin/hive-api | CacheFetch_web.js | fetch | function fetch(request, maxCacheAge) {
if (maxCacheAge === void 0) { maxCacheAge = 60 * 60 * 1000; }
return tslib_1.__awaiter(this, void 0, void 0, function () {
var promise;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
... | javascript | function fetch(request, maxCacheAge) {
if (maxCacheAge === void 0) { maxCacheAge = 60 * 60 * 1000; }
return tslib_1.__awaiter(this, void 0, void 0, function () {
var promise;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
... | [
"function",
"fetch",
"(",
"request",
",",
"maxCacheAge",
")",
"{",
"if",
"(",
"maxCacheAge",
"===",
"void",
"0",
")",
"{",
"maxCacheAge",
"=",
"60",
"*",
"60",
"*",
"1000",
";",
"}",
"return",
"tslib_1",
".",
"__awaiter",
"(",
"this",
",",
"void",
"0... | fetches the request with node-fetch and caches the result. Also only allows one request every 200ms and will put all
other into a waiting query | [
"fetches",
"the",
"request",
"with",
"node",
"-",
"fetch",
"and",
"caches",
"the",
"result",
".",
"Also",
"only",
"allows",
"one",
"request",
"every",
"200ms",
"and",
"will",
"put",
"all",
"other",
"into",
"a",
"waiting",
"query"
] | e514824610c20417ee681982f7ad09abaa9a0572 | https://github.com/Lergin/hive-api/blob/e514824610c20417ee681982f7ad09abaa9a0572/CacheFetch_web.js#L10-L27 | train |
twolfson/grunt-fontsmith | tasks/grunt-fontsmith.js | expandToObject | function expandToObject(input) {
// If the input is a string, encapsulate it as an array
var retObj = input;
if (typeof retObj === 'string') {
retObj = [input];
}
// If the retObj is an array
if (Array.isArray(retObj)) {
// Collect the inputs into an object
var inputArr = retO... | javascript | function expandToObject(input) {
// If the input is a string, encapsulate it as an array
var retObj = input;
if (typeof retObj === 'string') {
retObj = [input];
}
// If the retObj is an array
if (Array.isArray(retObj)) {
// Collect the inputs into an object
var inputArr = retO... | [
"function",
"expandToObject",
"(",
"input",
")",
"{",
"// If the input is a string, encapsulate it as an array",
"var",
"retObj",
"=",
"input",
";",
"if",
"(",
"typeof",
"retObj",
"===",
"'string'",
")",
"{",
"retObj",
"=",
"[",
"input",
"]",
";",
"}",
"// If th... | Helper function for objectifying src into type-first | [
"Helper",
"function",
"for",
"objectifying",
"src",
"into",
"type",
"-",
"first"
] | 49a42b2fd603214f3ba740e85531e4e3aa692ea7 | https://github.com/twolfson/grunt-fontsmith/blob/49a42b2fd603214f3ba740e85531e4e3aa692ea7/tasks/grunt-fontsmith.js#L18-L49 | train |
AndiDittrich/Node.fs-magic | lib/exists.js | exists | function exists(filedir){
// promise wrapper
return new Promise(function(resolve){
// try to stat the file
_fs.stat(filedir, function(err){
resolve(!err)
});
});
} | javascript | function exists(filedir){
// promise wrapper
return new Promise(function(resolve){
// try to stat the file
_fs.stat(filedir, function(err){
resolve(!err)
});
});
} | [
"function",
"exists",
"(",
"filedir",
")",
"{",
"// promise wrapper",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
")",
"{",
"// try to stat the file",
"_fs",
".",
"stat",
"(",
"filedir",
",",
"function",
"(",
"err",
")",
"{",
"resolve",
"(",... | "modern" exists implmentation | [
"modern",
"exists",
"implmentation"
] | 5e685a550fd956b5b422a0f21c359952e9be114b | https://github.com/AndiDittrich/Node.fs-magic/blob/5e685a550fd956b5b422a0f21c359952e9be114b/lib/exists.js#L4-L12 | train |
AntonioMA/swagger-boilerplate | lib/shared/utils.js | trace | function trace() {
var args = Array.prototype.slice.call(arguments);
var traceLevel = args.shift();
if (traceLevel.level & enabledLevels) {
args.unshift('[' + traceLevel.name + '] ' + new Date().toISOString() + ' - ' + aName + ':');
console.log.apply(console, args);
}
} | javascript | function trace() {
var args = Array.prototype.slice.call(arguments);
var traceLevel = args.shift();
if (traceLevel.level & enabledLevels) {
args.unshift('[' + traceLevel.name + '] ' + new Date().toISOString() + ' - ' + aName + ':');
console.log.apply(console, args);
}
} | [
"function",
"trace",
"(",
")",
"{",
"var",
"args",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
")",
";",
"var",
"traceLevel",
"=",
"args",
".",
"shift",
"(",
")",
";",
"if",
"(",
"traceLevel",
".",
"level",
"&",
"en... | The first argument is the level, the rest what we want to log | [
"The",
"first",
"argument",
"is",
"the",
"level",
"the",
"rest",
"what",
"we",
"want",
"to",
"log"
] | ce6980060c8194b993b3ab3ed750a25d02e9d66a | https://github.com/AntonioMA/swagger-boilerplate/blob/ce6980060c8194b993b3ab3ed750a25d02e9d66a/lib/shared/utils.js#L20-L27 | train |
AXErunners/axecore-p2p | lib/messages/commands/filterload.js | FilterloadMessage | function FilterloadMessage(arg, options) {
Message.call(this, options);
this.command = 'filterload';
$.checkArgument(
_.isUndefined(arg) || arg instanceof BloomFilter,
'An instance of BloomFilter or undefined is expected'
);
this.filter = arg;
} | javascript | function FilterloadMessage(arg, options) {
Message.call(this, options);
this.command = 'filterload';
$.checkArgument(
_.isUndefined(arg) || arg instanceof BloomFilter,
'An instance of BloomFilter or undefined is expected'
);
this.filter = arg;
} | [
"function",
"FilterloadMessage",
"(",
"arg",
",",
"options",
")",
"{",
"Message",
".",
"call",
"(",
"this",
",",
"options",
")",
";",
"this",
".",
"command",
"=",
"'filterload'",
";",
"$",
".",
"checkArgument",
"(",
"_",
".",
"isUndefined",
"(",
"arg",
... | Request peer to send inv messages based on a bloom filter
@param {BloomFilter=} arg - An instance of BloomFilter
@param {Object} options
@extends Message
@constructor | [
"Request",
"peer",
"to",
"send",
"inv",
"messages",
"based",
"on",
"a",
"bloom",
"filter"
] | c06d0e1d7b9ed44b7ee3061feb394d3896240da9 | https://github.com/AXErunners/axecore-p2p/blob/c06d0e1d7b9ed44b7ee3061feb394d3896240da9/lib/messages/commands/filterload.js#L18-L26 | train |
simonepri/restify-errors-options | index.js | extendErrorBody | function extendErrorBody(ctor) {
/**
* Parse errror's arguments to extract the 'options' object.
* Extracted from https://github.com/restify/errors/blob/master/lib/helpers.js#L30
* @param {} ctorArgs Arguments of the error.
*/
function parseOptions(ctorArgs) {
function parse() {
let options =... | javascript | function extendErrorBody(ctor) {
/**
* Parse errror's arguments to extract the 'options' object.
* Extracted from https://github.com/restify/errors/blob/master/lib/helpers.js#L30
* @param {} ctorArgs Arguments of the error.
*/
function parseOptions(ctorArgs) {
function parse() {
let options =... | [
"function",
"extendErrorBody",
"(",
"ctor",
")",
"{",
"/**\n * Parse errror's arguments to extract the 'options' object.\n * Extracted from https://github.com/restify/errors/blob/master/lib/helpers.js#L30\n * @param {} ctorArgs Arguments of the error.\n */",
"function",
"parseOptions",
"(... | Adds cuostom options to the error body.
@param {function} ctor Original Cnstructor of the error.
@return {function} Hooked constructor of the error. | [
"Adds",
"cuostom",
"options",
"to",
"the",
"error",
"body",
"."
] | f8412de9ba67ece3a1632f3935bea1c778666b9e | https://github.com/simonepri/restify-errors-options/blob/f8412de9ba67ece3a1632f3935bea1c778666b9e/index.js#L25-L77 | train |
simonepri/restify-errors-options | index.js | patchErrorBody | function patchErrorBody(err, options) {
// Gets the current toJSON to be extended.
const json = err.toJSON();
Object.keys(customOptions).forEach(optName => {
let value = options[optName];
if (value === undefined) {
value = err.body[optName];
if (value === '' || value === undefined) {
... | javascript | function patchErrorBody(err, options) {
// Gets the current toJSON to be extended.
const json = err.toJSON();
Object.keys(customOptions).forEach(optName => {
let value = options[optName];
if (value === undefined) {
value = err.body[optName];
if (value === '' || value === undefined) {
... | [
"function",
"patchErrorBody",
"(",
"err",
",",
"options",
")",
"{",
"// Gets the current toJSON to be extended.",
"const",
"json",
"=",
"err",
".",
"toJSON",
"(",
")",
";",
"Object",
".",
"keys",
"(",
"customOptions",
")",
".",
"forEach",
"(",
"optName",
"=>",... | Monkey patch the error object after his creation.
@param {object} err Error to patch.
@param {object} options Options given by the user. | [
"Monkey",
"patch",
"the",
"error",
"object",
"after",
"his",
"creation",
"."
] | f8412de9ba67ece3a1632f3935bea1c778666b9e | https://github.com/simonepri/restify-errors-options/blob/f8412de9ba67ece3a1632f3935bea1c778666b9e/index.js#L84-L110 | train |
simonepri/restify-errors-options | index.js | patchMakeConstructor | function patchMakeConstructor() {
const func = errors.makeConstructor;
function makeConstructorHook() {
func.apply(null, arguments);
patchError(arguments[0]);
}
errors.makeConstructor = makeConstructorHook;
} | javascript | function patchMakeConstructor() {
const func = errors.makeConstructor;
function makeConstructorHook() {
func.apply(null, arguments);
patchError(arguments[0]);
}
errors.makeConstructor = makeConstructorHook;
} | [
"function",
"patchMakeConstructor",
"(",
")",
"{",
"const",
"func",
"=",
"errors",
".",
"makeConstructor",
";",
"function",
"makeConstructorHook",
"(",
")",
"{",
"func",
".",
"apply",
"(",
"null",
",",
"arguments",
")",
";",
"patchError",
"(",
"arguments",
"... | Adds an hook to the makeConstructor method, | [
"Adds",
"an",
"hook",
"to",
"the",
"makeConstructor",
"method"
] | f8412de9ba67ece3a1632f3935bea1c778666b9e | https://github.com/simonepri/restify-errors-options/blob/f8412de9ba67ece3a1632f3935bea1c778666b9e/index.js#L115-L122 | train |
simonepri/restify-errors-options | index.js | patchMakeErrFromCode | function patchMakeErrFromCode() {
const func = errors.makeErrFromCode;
function makeErrFromCodeHook() {
const err = func.apply(null, arguments);
patchErrorBody(err, {});
return err;
}
errors.makeErrFromCode = makeErrFromCodeHook;
// Deprecated.
// See https://github.com/restify/errors/blob/mast... | javascript | function patchMakeErrFromCode() {
const func = errors.makeErrFromCode;
function makeErrFromCodeHook() {
const err = func.apply(null, arguments);
patchErrorBody(err, {});
return err;
}
errors.makeErrFromCode = makeErrFromCodeHook;
// Deprecated.
// See https://github.com/restify/errors/blob/mast... | [
"function",
"patchMakeErrFromCode",
"(",
")",
"{",
"const",
"func",
"=",
"errors",
".",
"makeErrFromCode",
";",
"function",
"makeErrFromCodeHook",
"(",
")",
"{",
"const",
"err",
"=",
"func",
".",
"apply",
"(",
"null",
",",
"arguments",
")",
";",
"patchErrorB... | Adds an hook to the makeErrFromCode method. | [
"Adds",
"an",
"hook",
"to",
"the",
"makeErrFromCode",
"method",
"."
] | f8412de9ba67ece3a1632f3935bea1c778666b9e | https://github.com/simonepri/restify-errors-options/blob/f8412de9ba67ece3a1632f3935bea1c778666b9e/index.js#L127-L139 | train |
simonepri/restify-errors-options | index.js | addOption | function addOption(optName, optDefault) {
if (typeof optDefault !== 'function') {
const val = optDefault;
optDefault = () => val;
}
customOptions[optName] = optDefault;
} | javascript | function addOption(optName, optDefault) {
if (typeof optDefault !== 'function') {
const val = optDefault;
optDefault = () => val;
}
customOptions[optName] = optDefault;
} | [
"function",
"addOption",
"(",
"optName",
",",
"optDefault",
")",
"{",
"if",
"(",
"typeof",
"optDefault",
"!==",
"'function'",
")",
"{",
"const",
"val",
"=",
"optDefault",
";",
"optDefault",
"=",
"(",
")",
"=>",
"val",
";",
"}",
"customOptions",
"[",
"opt... | Adds custom options to errors' body.
@param {string} optName Name of the option key to add.
@param {} [optDefault] Default value for the option.
If a function is provided it will be called with
(errorCode, errorHttpCode, errorMessage) as parameters.
You can use this behaviour to provide different default for ea... | [
"Adds",
"custom",
"options",
"to",
"errors",
"body",
"."
] | f8412de9ba67ece3a1632f3935bea1c778666b9e | https://github.com/simonepri/restify-errors-options/blob/f8412de9ba67ece3a1632f3935bea1c778666b9e/index.js#L158-L164 | train |
heapsource/mongoose-attachments-localfs | lib/localfs-provider.js | LocalfsStorageAttachments | function LocalfsStorageAttachments(options) {
if(options.removePrefix) {
this.prefix = options.removePrefix;
}
attachments.StorageProvider.call(this, options);
} | javascript | function LocalfsStorageAttachments(options) {
if(options.removePrefix) {
this.prefix = options.removePrefix;
}
attachments.StorageProvider.call(this, options);
} | [
"function",
"LocalfsStorageAttachments",
"(",
"options",
")",
"{",
"if",
"(",
"options",
".",
"removePrefix",
")",
"{",
"this",
".",
"prefix",
"=",
"options",
".",
"removePrefix",
";",
"}",
"attachments",
".",
"StorageProvider",
".",
"call",
"(",
"this",
","... | create constructor and inherit | [
"create",
"constructor",
"and",
"inherit"
] | f00fb1f2d7e28b40f842917f8c41a261e982ea23 | https://github.com/heapsource/mongoose-attachments-localfs/blob/f00fb1f2d7e28b40f842917f8c41a261e982ea23/lib/localfs-provider.js#L27-L32 | train |
LI-NA/optipng.js | demo/js/optipng.js | getMemory | function getMemory(size) {
if (!staticSealed) return staticAlloc(size);
if (!runtimeInitialized) return dynamicAlloc(size);
return _malloc(size);
} | javascript | function getMemory(size) {
if (!staticSealed) return staticAlloc(size);
if (!runtimeInitialized) return dynamicAlloc(size);
return _malloc(size);
} | [
"function",
"getMemory",
"(",
"size",
")",
"{",
"if",
"(",
"!",
"staticSealed",
")",
"return",
"staticAlloc",
"(",
"size",
")",
";",
"if",
"(",
"!",
"runtimeInitialized",
")",
"return",
"dynamicAlloc",
"(",
"size",
")",
";",
"return",
"_malloc",
"(",
"si... | Allocate memory during any stage of startup - static memory early on, dynamic memory later, malloc when ready | [
"Allocate",
"memory",
"during",
"any",
"stage",
"of",
"startup",
"-",
"static",
"memory",
"early",
"on",
"dynamic",
"memory",
"later",
"malloc",
"when",
"ready"
] | 9657fe80a9135e58e20c858515f049c6c76a08e7 | https://github.com/LI-NA/optipng.js/blob/9657fe80a9135e58e20c858515f049c6c76a08e7/demo/js/optipng.js#L691-L695 | train |
LI-NA/optipng.js | demo/js/optipng.js | isDataURI | function isDataURI(filename) {
return String.prototype.startsWith ?
filename.startsWith(dataURIPrefix) :
filename.indexOf(dataURIPrefix) === 0;
} | javascript | function isDataURI(filename) {
return String.prototype.startsWith ?
filename.startsWith(dataURIPrefix) :
filename.indexOf(dataURIPrefix) === 0;
} | [
"function",
"isDataURI",
"(",
"filename",
")",
"{",
"return",
"String",
".",
"prototype",
".",
"startsWith",
"?",
"filename",
".",
"startsWith",
"(",
"dataURIPrefix",
")",
":",
"filename",
".",
"indexOf",
"(",
"dataURIPrefix",
")",
"===",
"0",
";",
"}"
] | Indicates whether filename is a base64 data URI. | [
"Indicates",
"whether",
"filename",
"is",
"a",
"base64",
"data",
"URI",
"."
] | 9657fe80a9135e58e20c858515f049c6c76a08e7 | https://github.com/LI-NA/optipng.js/blob/9657fe80a9135e58e20c858515f049c6c76a08e7/demo/js/optipng.js#L1513-L1517 | train |
LI-NA/optipng.js | demo/js/optipng.js | useRequest | function useRequest() {
var request = Module['memoryInitializerRequest'];
var response = request.response;
if (request.status !== 200 && request.status !== 0) {
var data = tryParseAsDataURI(Module['memoryInitializerRequestURL']);
if (data) {
response = data.buffer... | javascript | function useRequest() {
var request = Module['memoryInitializerRequest'];
var response = request.response;
if (request.status !== 200 && request.status !== 0) {
var data = tryParseAsDataURI(Module['memoryInitializerRequestURL']);
if (data) {
response = data.buffer... | [
"function",
"useRequest",
"(",
")",
"{",
"var",
"request",
"=",
"Module",
"[",
"'memoryInitializerRequest'",
"]",
";",
"var",
"response",
"=",
"request",
".",
"response",
";",
"if",
"(",
"request",
".",
"status",
"!==",
"200",
"&&",
"request",
".",
"status... | a network request has already been created, just use that | [
"a",
"network",
"request",
"has",
"already",
"been",
"created",
"just",
"use",
"that"
] | 9657fe80a9135e58e20c858515f049c6c76a08e7 | https://github.com/LI-NA/optipng.js/blob/9657fe80a9135e58e20c858515f049c6c76a08e7/demo/js/optipng.js#L66452-L66469 | train |
nagarajanchinnasamy/simpledimple | lib/dimple/dimple.v2.1.4.js | function (axis, row) {
var returnField = [];
if (axis !== null) {
if (axis._hasTimeField()) {
returnField.push(axis._parseDate(row[axis.timeField]));
} else if (axis._hasCategories()) {
... | javascript | function (axis, row) {
var returnField = [];
if (axis !== null) {
if (axis._hasTimeField()) {
returnField.push(axis._parseDate(row[axis.timeField]));
} else if (axis._hasCategories()) {
... | [
"function",
"(",
"axis",
",",
"row",
")",
"{",
"var",
"returnField",
"=",
"[",
"]",
";",
"if",
"(",
"axis",
"!==",
"null",
")",
"{",
"if",
"(",
"axis",
".",
"_hasTimeField",
"(",
")",
")",
"{",
"returnField",
".",
"push",
"(",
"axis",
".",
"_pars... | The data for this series | [
"The",
"data",
"for",
"this",
"series"
] | f0ed2797661c2bfeee7ba0696e367051353fd078 | https://github.com/nagarajanchinnasamy/simpledimple/blob/f0ed2797661c2bfeee7ba0696e367051353fd078/lib/dimple/dimple.v2.1.4.js#L736-L748 | train | |
nagarajanchinnasamy/simpledimple | lib/dimple/dimple.v2.1.4.js | function (d, chart, series) {
var returnCx = 0;
if (series.x.measure !== null && series.x.measure !== undefined) {
returnCx = series.x._scale(d.cx);
} else if (series.x._hasCategories() && series.x.categoryFields.length >= 2) {
returnCx = series.x._sca... | javascript | function (d, chart, series) {
var returnCx = 0;
if (series.x.measure !== null && series.x.measure !== undefined) {
returnCx = series.x._scale(d.cx);
} else if (series.x._hasCategories() && series.x.categoryFields.length >= 2) {
returnCx = series.x._sca... | [
"function",
"(",
"d",
",",
"chart",
",",
"series",
")",
"{",
"var",
"returnCx",
"=",
"0",
";",
"if",
"(",
"series",
".",
"x",
".",
"measure",
"!==",
"null",
"&&",
"series",
".",
"x",
".",
"measure",
"!==",
"undefined",
")",
"{",
"returnCx",
"=",
... | Calculate the centre x position | [
"Calculate",
"the",
"centre",
"x",
"position"
] | f0ed2797661c2bfeee7ba0696e367051353fd078 | https://github.com/nagarajanchinnasamy/simpledimple/blob/f0ed2797661c2bfeee7ba0696e367051353fd078/lib/dimple/dimple.v2.1.4.js#L4601-L4611 | train | |
nagarajanchinnasamy/simpledimple | lib/dimple/dimple.v2.1.4.js | function (d, chart, series) {
var returnCy = 0;
if (series.y.measure !== null && series.y.measure !== undefined) {
returnCy = series.y._scale(d.cy);
} else if (series.y.categoryFields !== null && series.y.categoryFields !== undefined && series.y.categoryFields.length ... | javascript | function (d, chart, series) {
var returnCy = 0;
if (series.y.measure !== null && series.y.measure !== undefined) {
returnCy = series.y._scale(d.cy);
} else if (series.y.categoryFields !== null && series.y.categoryFields !== undefined && series.y.categoryFields.length ... | [
"function",
"(",
"d",
",",
"chart",
",",
"series",
")",
"{",
"var",
"returnCy",
"=",
"0",
";",
"if",
"(",
"series",
".",
"y",
".",
"measure",
"!==",
"null",
"&&",
"series",
".",
"y",
".",
"measure",
"!==",
"undefined",
")",
"{",
"returnCy",
"=",
... | Calculate the centre y position | [
"Calculate",
"the",
"centre",
"y",
"position"
] | f0ed2797661c2bfeee7ba0696e367051353fd078 | https://github.com/nagarajanchinnasamy/simpledimple/blob/f0ed2797661c2bfeee7ba0696e367051353fd078/lib/dimple/dimple.v2.1.4.js#L4614-L4624 | train | |
nagarajanchinnasamy/simpledimple | lib/dimple/dimple.v2.1.4.js | function (chart, series) {
var returnXGap = 0;
if ((series.x.measure === null || series.x.measure === undefined) && series.barGap > 0) {
returnXGap = ((chart._widthPixels() / series.x._max) * (series.barGap > 0.99 ? 0.99 : series.barGap)) / 2;
}
return ret... | javascript | function (chart, series) {
var returnXGap = 0;
if ((series.x.measure === null || series.x.measure === undefined) && series.barGap > 0) {
returnXGap = ((chart._widthPixels() / series.x._max) * (series.barGap > 0.99 ? 0.99 : series.barGap)) / 2;
}
return ret... | [
"function",
"(",
"chart",
",",
"series",
")",
"{",
"var",
"returnXGap",
"=",
"0",
";",
"if",
"(",
"(",
"series",
".",
"x",
".",
"measure",
"===",
"null",
"||",
"series",
".",
"x",
".",
"measure",
"===",
"undefined",
")",
"&&",
"series",
".",
"barGa... | Calculate the x gap for bar type charts | [
"Calculate",
"the",
"x",
"gap",
"for",
"bar",
"type",
"charts"
] | f0ed2797661c2bfeee7ba0696e367051353fd078 | https://github.com/nagarajanchinnasamy/simpledimple/blob/f0ed2797661c2bfeee7ba0696e367051353fd078/lib/dimple/dimple.v2.1.4.js#L4646-L4652 | train | |
nagarajanchinnasamy/simpledimple | lib/dimple/dimple.v2.1.4.js | function (d, chart, series) {
var returnXClusterGap = 0;
if (series.x.categoryFields !== null && series.x.categoryFields !== undefined && series.x.categoryFields.length >= 2 && series.clusterBarGap > 0 && !series.x._hasMeasure()) {
returnXClusterGap = (d.width * ((chart._widthPix... | javascript | function (d, chart, series) {
var returnXClusterGap = 0;
if (series.x.categoryFields !== null && series.x.categoryFields !== undefined && series.x.categoryFields.length >= 2 && series.clusterBarGap > 0 && !series.x._hasMeasure()) {
returnXClusterGap = (d.width * ((chart._widthPix... | [
"function",
"(",
"d",
",",
"chart",
",",
"series",
")",
"{",
"var",
"returnXClusterGap",
"=",
"0",
";",
"if",
"(",
"series",
".",
"x",
".",
"categoryFields",
"!==",
"null",
"&&",
"series",
".",
"x",
".",
"categoryFields",
"!==",
"undefined",
"&&",
"ser... | Calculate the x gap for clusters within bar type charts | [
"Calculate",
"the",
"x",
"gap",
"for",
"clusters",
"within",
"bar",
"type",
"charts"
] | f0ed2797661c2bfeee7ba0696e367051353fd078 | https://github.com/nagarajanchinnasamy/simpledimple/blob/f0ed2797661c2bfeee7ba0696e367051353fd078/lib/dimple/dimple.v2.1.4.js#L4655-L4661 | train | |
nagarajanchinnasamy/simpledimple | lib/dimple/dimple.v2.1.4.js | function (chart, series) {
var returnYGap = 0;
if ((series.y.measure === null || series.y.measure === undefined) && series.barGap > 0) {
returnYGap = ((chart._heightPixels() / series.y._max) * (series.barGap > 0.99 ? 0.99 : series.barGap)) / 2;
}
return re... | javascript | function (chart, series) {
var returnYGap = 0;
if ((series.y.measure === null || series.y.measure === undefined) && series.barGap > 0) {
returnYGap = ((chart._heightPixels() / series.y._max) * (series.barGap > 0.99 ? 0.99 : series.barGap)) / 2;
}
return re... | [
"function",
"(",
"chart",
",",
"series",
")",
"{",
"var",
"returnYGap",
"=",
"0",
";",
"if",
"(",
"(",
"series",
".",
"y",
".",
"measure",
"===",
"null",
"||",
"series",
".",
"y",
".",
"measure",
"===",
"undefined",
")",
"&&",
"series",
".",
"barGa... | Calculate the y gap for bar type charts | [
"Calculate",
"the",
"y",
"gap",
"for",
"bar",
"type",
"charts"
] | f0ed2797661c2bfeee7ba0696e367051353fd078 | https://github.com/nagarajanchinnasamy/simpledimple/blob/f0ed2797661c2bfeee7ba0696e367051353fd078/lib/dimple/dimple.v2.1.4.js#L4664-L4670 | train | |
nagarajanchinnasamy/simpledimple | lib/dimple/dimple.v2.1.4.js | function (d, chart, series) {
var returnYClusterGap = 0;
if (series.y.categoryFields !== null && series.y.categoryFields !== undefined && series.y.categoryFields.length >= 2 && series.clusterBarGap > 0 && !series.y._hasMeasure()) {
returnYClusterGap = (d.height * ((chart._heightP... | javascript | function (d, chart, series) {
var returnYClusterGap = 0;
if (series.y.categoryFields !== null && series.y.categoryFields !== undefined && series.y.categoryFields.length >= 2 && series.clusterBarGap > 0 && !series.y._hasMeasure()) {
returnYClusterGap = (d.height * ((chart._heightP... | [
"function",
"(",
"d",
",",
"chart",
",",
"series",
")",
"{",
"var",
"returnYClusterGap",
"=",
"0",
";",
"if",
"(",
"series",
".",
"y",
".",
"categoryFields",
"!==",
"null",
"&&",
"series",
".",
"y",
".",
"categoryFields",
"!==",
"undefined",
"&&",
"ser... | Calculate the y gap for clusters within bar type charts | [
"Calculate",
"the",
"y",
"gap",
"for",
"clusters",
"within",
"bar",
"type",
"charts"
] | f0ed2797661c2bfeee7ba0696e367051353fd078 | https://github.com/nagarajanchinnasamy/simpledimple/blob/f0ed2797661c2bfeee7ba0696e367051353fd078/lib/dimple/dimple.v2.1.4.js#L4673-L4679 | train | |
nagarajanchinnasamy/simpledimple | lib/dimple/dimple.v2.1.4.js | function (d, chart, series) {
var returnX = 0;
if (series.x._hasTimeField()) {
returnX = series.x._scale(d.x) - (dimple._helpers.width(d, chart, series) / 2);
} else if (series.x.measure !== null && series.x.measure !== undefined) {
returnX = series.x.... | javascript | function (d, chart, series) {
var returnX = 0;
if (series.x._hasTimeField()) {
returnX = series.x._scale(d.x) - (dimple._helpers.width(d, chart, series) / 2);
} else if (series.x.measure !== null && series.x.measure !== undefined) {
returnX = series.x.... | [
"function",
"(",
"d",
",",
"chart",
",",
"series",
")",
"{",
"var",
"returnX",
"=",
"0",
";",
"if",
"(",
"series",
".",
"x",
".",
"_hasTimeField",
"(",
")",
")",
"{",
"returnX",
"=",
"series",
".",
"x",
".",
"_scale",
"(",
"d",
".",
"x",
")",
... | Calculate the top left x position for bar type charts | [
"Calculate",
"the",
"top",
"left",
"x",
"position",
"for",
"bar",
"type",
"charts"
] | f0ed2797661c2bfeee7ba0696e367051353fd078 | https://github.com/nagarajanchinnasamy/simpledimple/blob/f0ed2797661c2bfeee7ba0696e367051353fd078/lib/dimple/dimple.v2.1.4.js#L4682-L4692 | train | |
nagarajanchinnasamy/simpledimple | lib/dimple/dimple.v2.1.4.js | function (d, chart, series) {
var returnY = 0;
if (series.y._hasTimeField()) {
returnY = series.y._scale(d.y) - (dimple._helpers.height(d, chart, series) / 2);
} else if (series.y.measure !== null && series.y.measure !== undefined) {
returnY = series.y... | javascript | function (d, chart, series) {
var returnY = 0;
if (series.y._hasTimeField()) {
returnY = series.y._scale(d.y) - (dimple._helpers.height(d, chart, series) / 2);
} else if (series.y.measure !== null && series.y.measure !== undefined) {
returnY = series.y... | [
"function",
"(",
"d",
",",
"chart",
",",
"series",
")",
"{",
"var",
"returnY",
"=",
"0",
";",
"if",
"(",
"series",
".",
"y",
".",
"_hasTimeField",
"(",
")",
")",
"{",
"returnY",
"=",
"series",
".",
"y",
".",
"_scale",
"(",
"d",
".",
"y",
")",
... | Calculate the top left y position for bar type charts | [
"Calculate",
"the",
"top",
"left",
"y",
"position",
"for",
"bar",
"type",
"charts"
] | f0ed2797661c2bfeee7ba0696e367051353fd078 | https://github.com/nagarajanchinnasamy/simpledimple/blob/f0ed2797661c2bfeee7ba0696e367051353fd078/lib/dimple/dimple.v2.1.4.js#L4695-L4705 | train | |
nagarajanchinnasamy/simpledimple | lib/dimple/dimple.v2.1.4.js | function (d, chart, series) {
var returnWidth = 0;
if (series.x.measure !== null && series.x.measure !== undefined) {
returnWidth = Math.abs(series.x._scale((d.x < 0 ? d.x - d.width : d.x + d.width)) - series.x._scale(d.x));
} else if (series.x._hasTimeField()) {
... | javascript | function (d, chart, series) {
var returnWidth = 0;
if (series.x.measure !== null && series.x.measure !== undefined) {
returnWidth = Math.abs(series.x._scale((d.x < 0 ? d.x - d.width : d.x + d.width)) - series.x._scale(d.x));
} else if (series.x._hasTimeField()) {
... | [
"function",
"(",
"d",
",",
"chart",
",",
"series",
")",
"{",
"var",
"returnWidth",
"=",
"0",
";",
"if",
"(",
"series",
".",
"x",
".",
"measure",
"!==",
"null",
"&&",
"series",
".",
"x",
".",
"measure",
"!==",
"undefined",
")",
"{",
"returnWidth",
"... | Calculate the width for bar type charts | [
"Calculate",
"the",
"width",
"for",
"bar",
"type",
"charts"
] | f0ed2797661c2bfeee7ba0696e367051353fd078 | https://github.com/nagarajanchinnasamy/simpledimple/blob/f0ed2797661c2bfeee7ba0696e367051353fd078/lib/dimple/dimple.v2.1.4.js#L4708-L4718 | train | |
nagarajanchinnasamy/simpledimple | lib/dimple/dimple.v2.1.4.js | function (d, chart, series) {
var returnHeight = 0;
if (series.y._hasTimeField()) {
returnHeight = series.y.floatingBarWidth;
} else if (series.y.measure !== null && series.y.measure !== undefined) {
returnHeight = Math.abs(series.y._scale(d.y) - serie... | javascript | function (d, chart, series) {
var returnHeight = 0;
if (series.y._hasTimeField()) {
returnHeight = series.y.floatingBarWidth;
} else if (series.y.measure !== null && series.y.measure !== undefined) {
returnHeight = Math.abs(series.y._scale(d.y) - serie... | [
"function",
"(",
"d",
",",
"chart",
",",
"series",
")",
"{",
"var",
"returnHeight",
"=",
"0",
";",
"if",
"(",
"series",
".",
"y",
".",
"_hasTimeField",
"(",
")",
")",
"{",
"returnHeight",
"=",
"series",
".",
"y",
".",
"floatingBarWidth",
";",
"}",
... | Calculate the height for bar type charts | [
"Calculate",
"the",
"height",
"for",
"bar",
"type",
"charts"
] | f0ed2797661c2bfeee7ba0696e367051353fd078 | https://github.com/nagarajanchinnasamy/simpledimple/blob/f0ed2797661c2bfeee7ba0696e367051353fd078/lib/dimple/dimple.v2.1.4.js#L4721-L4731 | train | |
nagarajanchinnasamy/simpledimple | lib/dimple/dimple.v2.1.4.js | function (d, chart, series) {
var returnOpacity = 0;
if (series.c !== null && series.c !== undefined) {
returnOpacity = d.opacity;
} else {
returnOpacity = chart.getColor(d.aggField.slice(-1)[0]).opacity;
}
return returnOpacity;... | javascript | function (d, chart, series) {
var returnOpacity = 0;
if (series.c !== null && series.c !== undefined) {
returnOpacity = d.opacity;
} else {
returnOpacity = chart.getColor(d.aggField.slice(-1)[0]).opacity;
}
return returnOpacity;... | [
"function",
"(",
"d",
",",
"chart",
",",
"series",
")",
"{",
"var",
"returnOpacity",
"=",
"0",
";",
"if",
"(",
"series",
".",
"c",
"!==",
"null",
"&&",
"series",
".",
"c",
"!==",
"undefined",
")",
"{",
"returnOpacity",
"=",
"d",
".",
"opacity",
";"... | Calculate the opacity for series | [
"Calculate",
"the",
"opacity",
"for",
"series"
] | f0ed2797661c2bfeee7ba0696e367051353fd078 | https://github.com/nagarajanchinnasamy/simpledimple/blob/f0ed2797661c2bfeee7ba0696e367051353fd078/lib/dimple/dimple.v2.1.4.js#L4734-L4742 | train | |
nagarajanchinnasamy/simpledimple | lib/dimple/dimple.v2.1.4.js | function (d, chart, series) {
var returnFill = 0;
if (series.c !== null && series.c !== undefined) {
returnFill = d.fill;
} else {
returnFill = chart.getColor(d.aggField.slice(-1)[0]).fill;
}
return returnFill;
} | javascript | function (d, chart, series) {
var returnFill = 0;
if (series.c !== null && series.c !== undefined) {
returnFill = d.fill;
} else {
returnFill = chart.getColor(d.aggField.slice(-1)[0]).fill;
}
return returnFill;
} | [
"function",
"(",
"d",
",",
"chart",
",",
"series",
")",
"{",
"var",
"returnFill",
"=",
"0",
";",
"if",
"(",
"series",
".",
"c",
"!==",
"null",
"&&",
"series",
".",
"c",
"!==",
"undefined",
")",
"{",
"returnFill",
"=",
"d",
".",
"fill",
";",
"}",
... | Calculate the fill coloring for series | [
"Calculate",
"the",
"fill",
"coloring",
"for",
"series"
] | f0ed2797661c2bfeee7ba0696e367051353fd078 | https://github.com/nagarajanchinnasamy/simpledimple/blob/f0ed2797661c2bfeee7ba0696e367051353fd078/lib/dimple/dimple.v2.1.4.js#L4745-L4753 | train | |
nagarajanchinnasamy/simpledimple | lib/dimple/dimple.v2.1.4.js | function (d, chart, series) {
var stroke = 0;
if (series.c !== null && series.c !== undefined) {
stroke = d.stroke;
} else {
stroke = chart.getColor(d.aggField.slice(-1)[0]).stroke;
}
return stroke;
} | javascript | function (d, chart, series) {
var stroke = 0;
if (series.c !== null && series.c !== undefined) {
stroke = d.stroke;
} else {
stroke = chart.getColor(d.aggField.slice(-1)[0]).stroke;
}
return stroke;
} | [
"function",
"(",
"d",
",",
"chart",
",",
"series",
")",
"{",
"var",
"stroke",
"=",
"0",
";",
"if",
"(",
"series",
".",
"c",
"!==",
"null",
"&&",
"series",
".",
"c",
"!==",
"undefined",
")",
"{",
"stroke",
"=",
"d",
".",
"stroke",
";",
"}",
"els... | Calculate the stroke coloring for series | [
"Calculate",
"the",
"stroke",
"coloring",
"for",
"series"
] | f0ed2797661c2bfeee7ba0696e367051353fd078 | https://github.com/nagarajanchinnasamy/simpledimple/blob/f0ed2797661c2bfeee7ba0696e367051353fd078/lib/dimple/dimple.v2.1.4.js#L4756-L4764 | train | |
nagarajanchinnasamy/simpledimple | lib/dimple/dimple.v2.1.4.js | function (x, y) {
var matrix = selectedShape.node().getCTM(),
position = chart.svg.node().createSVGPoint();
position.x = x || 0;
position.y = y || 0;
return position.matrixTransform(matrix);
} | javascript | function (x, y) {
var matrix = selectedShape.node().getCTM(),
position = chart.svg.node().createSVGPoint();
position.x = x || 0;
position.y = y || 0;
return position.matrixTransform(matrix);
} | [
"function",
"(",
"x",
",",
"y",
")",
"{",
"var",
"matrix",
"=",
"selectedShape",
".",
"node",
"(",
")",
".",
"getCTM",
"(",
")",
",",
"position",
"=",
"chart",
".",
"svg",
".",
"node",
"(",
")",
".",
"createSVGPoint",
"(",
")",
";",
"position",
"... | The margin between the text and the box | [
"The",
"margin",
"between",
"the",
"text",
"and",
"the",
"box"
] | f0ed2797661c2bfeee7ba0696e367051353fd078 | https://github.com/nagarajanchinnasamy/simpledimple/blob/f0ed2797661c2bfeee7ba0696e367051353fd078/lib/dimple/dimple.v2.1.4.js#L5012-L5018 | train | |
linkedin/insframe | InsFrame.js | function() {
// locale InsFrame root folder
homeFolder = __dirname;
console.log(" info -".cyan, "InsFrame root".yellow, homeFolder);
// express config
app.set("view engine", "ejs");
app.set("views", homeFolder + "/views");
app.set("views");
app.set("view options", { l... | javascript | function() {
// locale InsFrame root folder
homeFolder = __dirname;
console.log(" info -".cyan, "InsFrame root".yellow, homeFolder);
// express config
app.set("view engine", "ejs");
app.set("views", homeFolder + "/views");
app.set("views");
app.set("view options", { l... | [
"function",
"(",
")",
"{",
"// locale InsFrame root folder",
"homeFolder",
"=",
"__dirname",
";",
"console",
".",
"log",
"(",
"\" info -\"",
".",
"cyan",
",",
"\"InsFrame root\"",
".",
"yellow",
",",
"homeFolder",
")",
";",
"// express config",
"app",
".",
"s... | Setting up environment | [
"Setting",
"up",
"environment"
] | 1799f0b64f9ce77553bc6ca0e9caa08a79787edc | https://github.com/linkedin/insframe/blob/1799f0b64f9ce77553bc6ca0e9caa08a79787edc/InsFrame.js#L53-L83 | train | |
linkedin/insframe | InsFrame.js | function() {
io = io.listen(app);
io.set("log level", 1);
io.sockets.on("connection", function(socket) {
connections += 1;
console.log(" info -".cyan, ("new connection. Connections: " + connections).yellow);
socket.on("disconnect", function() {
connections -= 1;
... | javascript | function() {
io = io.listen(app);
io.set("log level", 1);
io.sockets.on("connection", function(socket) {
connections += 1;
console.log(" info -".cyan, ("new connection. Connections: " + connections).yellow);
socket.on("disconnect", function() {
connections -= 1;
... | [
"function",
"(",
")",
"{",
"io",
"=",
"io",
".",
"listen",
"(",
"app",
")",
";",
"io",
".",
"set",
"(",
"\"log level\"",
",",
"1",
")",
";",
"io",
".",
"sockets",
".",
"on",
"(",
"\"connection\"",
",",
"function",
"(",
"socket",
")",
"{",
"connec... | Socket io initialization | [
"Socket",
"io",
"initialization"
] | 1799f0b64f9ce77553bc6ca0e9caa08a79787edc | https://github.com/linkedin/insframe/blob/1799f0b64f9ce77553bc6ca0e9caa08a79787edc/InsFrame.js#L173-L190 | train | |
AXErunners/axecore-p2p | lib/messages/commands/pong.js | PongMessage | function PongMessage(arg, options) {
Message.call(this, options);
this.command = 'pong';
$.checkArgument(
_.isUndefined(arg) || (BufferUtil.isBuffer(arg) && arg.length === 8),
'First argument is expected to be an 8 byte buffer'
);
this.nonce = arg || utils.getNonce();
} | javascript | function PongMessage(arg, options) {
Message.call(this, options);
this.command = 'pong';
$.checkArgument(
_.isUndefined(arg) || (BufferUtil.isBuffer(arg) && arg.length === 8),
'First argument is expected to be an 8 byte buffer'
);
this.nonce = arg || utils.getNonce();
} | [
"function",
"PongMessage",
"(",
"arg",
",",
"options",
")",
"{",
"Message",
".",
"call",
"(",
"this",
",",
"options",
")",
";",
"this",
".",
"command",
"=",
"'pong'",
";",
"$",
".",
"checkArgument",
"(",
"_",
".",
"isUndefined",
"(",
"arg",
")",
"||"... | A message in response to a ping message.
@param {Number} arg - A nonce for the Pong message
@param {Object=} options
@extends Message
@constructor | [
"A",
"message",
"in",
"response",
"to",
"a",
"ping",
"message",
"."
] | c06d0e1d7b9ed44b7ee3061feb394d3896240da9 | https://github.com/AXErunners/axecore-p2p/blob/c06d0e1d7b9ed44b7ee3061feb394d3896240da9/lib/messages/commands/pong.js#L19-L27 | train |
c5f7c9/llkp | core.js | txt | function txt(text) {
var name = '"' + text.replace(/"/gm, '\\"') + '"';
return new Pattern(name, function (str, pos) {
if (str.substr(pos, text.length) == text)
return { res: text, end: pos + text.length };
});
} | javascript | function txt(text) {
var name = '"' + text.replace(/"/gm, '\\"') + '"';
return new Pattern(name, function (str, pos) {
if (str.substr(pos, text.length) == text)
return { res: text, end: pos + text.length };
});
} | [
"function",
"txt",
"(",
"text",
")",
"{",
"var",
"name",
"=",
"'\"'",
"+",
"text",
".",
"replace",
"(",
"/",
"\"",
"/",
"gm",
",",
"'\\\\\"'",
")",
"+",
"'\"'",
";",
"return",
"new",
"Pattern",
"(",
"name",
",",
"function",
"(",
"str",
",",
"pos"... | parses a known text | [
"parses",
"a",
"known",
"text"
] | 211799a3781cab541fb4d36ffdfaf7524fcc6e02 | https://github.com/c5f7c9/llkp/blob/211799a3781cab541fb4d36ffdfaf7524fcc6e02/core.js#L27-L33 | train |
c5f7c9/llkp | core.js | rgx | function rgx(regexp) {
return new Pattern(regexp + '', function (str, pos) {
var m = regexp.exec(str.slice(pos));
if (m && m.index === 0) // regex must match at the beginning, so index must be 0
return { res: m[0], end: pos + m[0].length };
});
} | javascript | function rgx(regexp) {
return new Pattern(regexp + '', function (str, pos) {
var m = regexp.exec(str.slice(pos));
if (m && m.index === 0) // regex must match at the beginning, so index must be 0
return { res: m[0], end: pos + m[0].length };
});
} | [
"function",
"rgx",
"(",
"regexp",
")",
"{",
"return",
"new",
"Pattern",
"(",
"regexp",
"+",
"''",
",",
"function",
"(",
"str",
",",
"pos",
")",
"{",
"var",
"m",
"=",
"regexp",
".",
"exec",
"(",
"str",
".",
"slice",
"(",
"pos",
")",
")",
";",
"i... | parses a regular expression | [
"parses",
"a",
"regular",
"expression"
] | 211799a3781cab541fb4d36ffdfaf7524fcc6e02 | https://github.com/c5f7c9/llkp/blob/211799a3781cab541fb4d36ffdfaf7524fcc6e02/core.js#L36-L42 | train |
c5f7c9/llkp | core.js | opt | function opt(pattern, defval) {
return new Pattern(pattern + '?', function (str, pos) {
return pattern.exec(str, pos) || { res: defval, end: pos };
});
} | javascript | function opt(pattern, defval) {
return new Pattern(pattern + '?', function (str, pos) {
return pattern.exec(str, pos) || { res: defval, end: pos };
});
} | [
"function",
"opt",
"(",
"pattern",
",",
"defval",
")",
"{",
"return",
"new",
"Pattern",
"(",
"pattern",
"+",
"'?'",
",",
"function",
"(",
"str",
",",
"pos",
")",
"{",
"return",
"pattern",
".",
"exec",
"(",
"str",
",",
"pos",
")",
"||",
"{",
"res",
... | parses an optional pattern | [
"parses",
"an",
"optional",
"pattern"
] | 211799a3781cab541fb4d36ffdfaf7524fcc6e02 | https://github.com/c5f7c9/llkp/blob/211799a3781cab541fb4d36ffdfaf7524fcc6e02/core.js#L45-L49 | train |
c5f7c9/llkp | core.js | exc | function exc(pattern, except) {
var name = pattern + ' ~ ' + except;
return new Pattern(name, function (str, pos) {
return !except.exec(str, pos) && pattern.exec(str, pos);
});
} | javascript | function exc(pattern, except) {
var name = pattern + ' ~ ' + except;
return new Pattern(name, function (str, pos) {
return !except.exec(str, pos) && pattern.exec(str, pos);
});
} | [
"function",
"exc",
"(",
"pattern",
",",
"except",
")",
"{",
"var",
"name",
"=",
"pattern",
"+",
"' ~ '",
"+",
"except",
";",
"return",
"new",
"Pattern",
"(",
"name",
",",
"function",
"(",
"str",
",",
"pos",
")",
"{",
"return",
"!",
"except",
".",
"... | parses a pattern if it doesn't match another pattern | [
"parses",
"a",
"pattern",
"if",
"it",
"doesn",
"t",
"match",
"another",
"pattern"
] | 211799a3781cab541fb4d36ffdfaf7524fcc6e02 | https://github.com/c5f7c9/llkp/blob/211799a3781cab541fb4d36ffdfaf7524fcc6e02/core.js#L52-L57 | train |
c5f7c9/llkp | core.js | any | function any(/* patterns... */) {
var patterns = [].slice.call(arguments, 0);
var name = '(' + patterns.join(' | ') + ')';
return new Pattern(name, function (str, pos) {
var r, i;
for (i = 0; i < patterns.length && !r; i++)
r = patterns[i].exec(str, pos);... | javascript | function any(/* patterns... */) {
var patterns = [].slice.call(arguments, 0);
var name = '(' + patterns.join(' | ') + ')';
return new Pattern(name, function (str, pos) {
var r, i;
for (i = 0; i < patterns.length && !r; i++)
r = patterns[i].exec(str, pos);... | [
"function",
"any",
"(",
"/* patterns... */",
")",
"{",
"var",
"patterns",
"=",
"[",
"]",
".",
"slice",
".",
"call",
"(",
"arguments",
",",
"0",
")",
";",
"var",
"name",
"=",
"'('",
"+",
"patterns",
".",
"join",
"(",
"' | '",
")",
"+",
"')'",
";",
... | parses any of the given patterns | [
"parses",
"any",
"of",
"the",
"given",
"patterns"
] | 211799a3781cab541fb4d36ffdfaf7524fcc6e02 | https://github.com/c5f7c9/llkp/blob/211799a3781cab541fb4d36ffdfaf7524fcc6e02/core.js#L60-L70 | train |
c5f7c9/llkp | core.js | seq | function seq(/* patterns... */) {
var patterns = [].slice.call(arguments, 0);
var name = '(' + patterns.join(' ') + ')';
return new Pattern(name, function (str, pos) {
var i, r, end = pos, res = [];
for (i = 0; i < patterns.length; i++) {
r = patterns[i]... | javascript | function seq(/* patterns... */) {
var patterns = [].slice.call(arguments, 0);
var name = '(' + patterns.join(' ') + ')';
return new Pattern(name, function (str, pos) {
var i, r, end = pos, res = [];
for (i = 0; i < patterns.length; i++) {
r = patterns[i]... | [
"function",
"seq",
"(",
"/* patterns... */",
")",
"{",
"var",
"patterns",
"=",
"[",
"]",
".",
"slice",
".",
"call",
"(",
"arguments",
",",
"0",
")",
";",
"var",
"name",
"=",
"'('",
"+",
"patterns",
".",
"join",
"(",
"' '",
")",
"+",
"')'",
";",
"... | parses a sequence of patterns | [
"parses",
"a",
"sequence",
"of",
"patterns"
] | 211799a3781cab541fb4d36ffdfaf7524fcc6e02 | https://github.com/c5f7c9/llkp/blob/211799a3781cab541fb4d36ffdfaf7524fcc6e02/core.js#L73-L89 | train |
AXErunners/axecore-p2p | lib/messages/commands/getblocks.js | GetblocksMessage | function GetblocksMessage(arg, options) {
Message.call(this, options);
this.command = 'getblocks';
this.version = options.protocolVersion;
if (!arg) {
arg = {};
}
arg = utils.sanitizeStartStop(arg);
this.starts = arg.starts;
this.stop = arg.stop;
} | javascript | function GetblocksMessage(arg, options) {
Message.call(this, options);
this.command = 'getblocks';
this.version = options.protocolVersion;
if (!arg) {
arg = {};
}
arg = utils.sanitizeStartStop(arg);
this.starts = arg.starts;
this.stop = arg.stop;
} | [
"function",
"GetblocksMessage",
"(",
"arg",
",",
"options",
")",
"{",
"Message",
".",
"call",
"(",
"this",
",",
"options",
")",
";",
"this",
".",
"command",
"=",
"'getblocks'",
";",
"this",
".",
"version",
"=",
"options",
".",
"protocolVersion",
";",
"if... | Query another peer about blocks. It can query for multiple block hashes,
and the response will contain all the chains of blocks starting from those
hashes.
@param {Object=} arg
@param {Array=} arg.starts - Array of buffers or strings with the starting block hashes
@param {Buffer=} arg.stop - Hash of the last block
@par... | [
"Query",
"another",
"peer",
"about",
"blocks",
".",
"It",
"can",
"query",
"for",
"multiple",
"block",
"hashes",
"and",
"the",
"response",
"will",
"contain",
"all",
"the",
"chains",
"of",
"blocks",
"starting",
"from",
"those",
"hashes",
"."
] | c06d0e1d7b9ed44b7ee3061feb394d3896240da9 | https://github.com/AXErunners/axecore-p2p/blob/c06d0e1d7b9ed44b7ee3061feb394d3896240da9/lib/messages/commands/getblocks.js#L22-L32 | train |
AXErunners/axecore-p2p | lib/messages/commands/mnlistdiff.js | MnListDiffMessage | function MnListDiffMessage(arg, options) {
Message.call(this, options);
this.MnListDiff = options.MnListDiff;
this.command = 'mnlistdiff';
$.checkArgument(
_.isUndefined(arg) || arg instanceof this.MnListDiff,
'An instance of MnListDiff or undefined is expected'
);
this.mnlistdiff = arg;
} | javascript | function MnListDiffMessage(arg, options) {
Message.call(this, options);
this.MnListDiff = options.MnListDiff;
this.command = 'mnlistdiff';
$.checkArgument(
_.isUndefined(arg) || arg instanceof this.MnListDiff,
'An instance of MnListDiff or undefined is expected'
);
this.mnlistdiff = arg;
} | [
"function",
"MnListDiffMessage",
"(",
"arg",
",",
"options",
")",
"{",
"Message",
".",
"call",
"(",
"this",
",",
"options",
")",
";",
"this",
".",
"MnListDiff",
"=",
"options",
".",
"MnListDiff",
";",
"this",
".",
"command",
"=",
"'mnlistdiff'",
";",
"$"... | Contains information about a MnListDiff
@param {MnListDiff} arg - An instance of MnListDiff
@param {Object=} options
@param {Function} options.MnListDiff - a MnListDiff constructor
@extends Message
@constructor | [
"Contains",
"information",
"about",
"a",
"MnListDiff"
] | c06d0e1d7b9ed44b7ee3061feb394d3896240da9 | https://github.com/AXErunners/axecore-p2p/blob/c06d0e1d7b9ed44b7ee3061feb394d3896240da9/lib/messages/commands/mnlistdiff.js#L17-L26 | train |
AXErunners/axecore-p2p | lib/pool.js | Pool | function Pool(options) {
/* jshint maxcomplexity: 10 */
/* jshint maxstatements: 20 */
var self = this;
options = options || {};
this.keepalive = false;
this._connectedPeers = {};
this._addrs = [];
this.listenAddr = options.listenAddr !== false;
this.dnsSeed = options.dnsSeed !== false;
this.max... | javascript | function Pool(options) {
/* jshint maxcomplexity: 10 */
/* jshint maxstatements: 20 */
var self = this;
options = options || {};
this.keepalive = false;
this._connectedPeers = {};
this._addrs = [];
this.listenAddr = options.listenAddr !== false;
this.dnsSeed = options.dnsSeed !== false;
this.max... | [
"function",
"Pool",
"(",
"options",
")",
"{",
"/* jshint maxcomplexity: 10 */",
"/* jshint maxstatements: 20 */",
"var",
"self",
"=",
"this",
";",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"this",
".",
"keepalive",
"=",
"false",
";",
"this",
".",
"_conne... | A pool is a collection of Peers. A pool will discover peers from DNS seeds, and
collect information about new peers in the network. When a peer disconnects the pool
will connect to others that are available to maintain a max number of
ongoing peer connections. Peer events are relayed to the pool.
@example
```javascrip... | [
"A",
"pool",
"is",
"a",
"collection",
"of",
"Peers",
".",
"A",
"pool",
"will",
"discover",
"peers",
"from",
"DNS",
"seeds",
"and",
"collect",
"information",
"about",
"new",
"peers",
"in",
"the",
"network",
".",
"When",
"a",
"peer",
"disconnects",
"the",
... | c06d0e1d7b9ed44b7ee3061feb394d3896240da9 | https://github.com/AXErunners/axecore-p2p/blob/c06d0e1d7b9ed44b7ee3061feb394d3896240da9/lib/pool.js#L41-L106 | train |
nbeach/keycoder | dist/keycoder.js | function (keyData) {
this.shift = {};
this.names = Util.clone(Util.whenUndefined(keyData.names, []));
this.character = Util.whenUndefined(keyData.char, null);
this.shift.character = Util.whenUndefined(keyData.shift, Util.whenUndefined(keyData.char, null));... | javascript | function (keyData) {
this.shift = {};
this.names = Util.clone(Util.whenUndefined(keyData.names, []));
this.character = Util.whenUndefined(keyData.char, null);
this.shift.character = Util.whenUndefined(keyData.shift, Util.whenUndefined(keyData.char, null));... | [
"function",
"(",
"keyData",
")",
"{",
"this",
".",
"shift",
"=",
"{",
"}",
";",
"this",
".",
"names",
"=",
"Util",
".",
"clone",
"(",
"Util",
".",
"whenUndefined",
"(",
"keyData",
".",
"names",
",",
"[",
"]",
")",
")",
";",
"this",
".",
"characte... | A representation of a keyboard key. This class cannot be instantiated manually. All instances are generated by the Keycoder module.
@Class Key
@internal
@property {string[]} names - Names that the key is called. Ex. "BACKSPACE", "INSERT"
@property {number} keyCode.ie - IE key code
@property {number} keyCode.mozilla - M... | [
"A",
"representation",
"of",
"a",
"keyboard",
"key",
".",
"This",
"class",
"cannot",
"be",
"instantiated",
"manually",
".",
"All",
"instances",
"are",
"generated",
"by",
"the",
"Keycoder",
"module",
"."
] | ad61e2ff8c1580c4000786ea80adb8d5c081c531 | https://github.com/nbeach/keycoder/blob/ad61e2ff8c1580c4000786ea80adb8d5c081c531/dist/keycoder.js#L724-L739 | train | |
morganherlocker/clipsy | index.js | Barrett | function Barrett(m)
{
// setup Barrett
this.r2 = nbi();
this.q3 = nbi();
Int128.ONE.dlShiftTo(2 * m.t, this.r2);
this.mu = this.r2.divide(m);
this.m = m;
} | javascript | function Barrett(m)
{
// setup Barrett
this.r2 = nbi();
this.q3 = nbi();
Int128.ONE.dlShiftTo(2 * m.t, this.r2);
this.mu = this.r2.divide(m);
this.m = m;
} | [
"function",
"Barrett",
"(",
"m",
")",
"{",
"// setup Barrett",
"this",
".",
"r2",
"=",
"nbi",
"(",
")",
";",
"this",
".",
"q3",
"=",
"nbi",
"(",
")",
";",
"Int128",
".",
"ONE",
".",
"dlShiftTo",
"(",
"2",
"*",
"m",
".",
"t",
",",
"this",
".",
... | Barrett modular reduction | [
"Barrett",
"modular",
"reduction"
] | 9e07c276a82f7eac41024fd2222884e4165a54d4 | https://github.com/morganherlocker/clipsy/blob/9e07c276a82f7eac41024fd2222884e4165a54d4/index.js#L1297-L1305 | train |
AXErunners/axecore-p2p | lib/messages/index.js | Messages | function Messages(options) {
this.builder = Messages.builder(options);
// map message constructors by name
for(var key in this.builder.commandsMap) {
var name = this.builder.commandsMap[key];
this[name] = this.builder.commands[key];
}
if (!options) {
options = {};
}
this.network = options.ne... | javascript | function Messages(options) {
this.builder = Messages.builder(options);
// map message constructors by name
for(var key in this.builder.commandsMap) {
var name = this.builder.commandsMap[key];
this[name] = this.builder.commands[key];
}
if (!options) {
options = {};
}
this.network = options.ne... | [
"function",
"Messages",
"(",
"options",
")",
"{",
"this",
".",
"builder",
"=",
"Messages",
".",
"builder",
"(",
"options",
")",
";",
"// map message constructors by name",
"for",
"(",
"var",
"key",
"in",
"this",
".",
"builder",
".",
"commandsMap",
")",
"{",
... | A factory to build Bitcoin protocol messages.
@param {Object=} options
@param {Network=} options.network
@param {Function=} options.Block - A block constructor
@param {Function=} options.BlockHeader - A block header constructor
@param {Function=} options.MerkleBlock - A merkle block constructor
@param {Function=} optio... | [
"A",
"factory",
"to",
"build",
"Bitcoin",
"protocol",
"messages",
"."
] | c06d0e1d7b9ed44b7ee3061feb394d3896240da9 | https://github.com/AXErunners/axecore-p2p/blob/c06d0e1d7b9ed44b7ee3061feb394d3896240da9/lib/messages/index.js#L19-L32 | train |
NiklasGollenstede/web-ext-utils | utils/index.js | showExtensionTab | async function showExtensionTab(url, match = url) {
match = extension.getURL(match || url); url = extension.getURL(url);
for (const view of extension.getViews({ type: 'tab', })) {
if (view && (typeof match === 'string' ? view.location.href === match : match.test(view.location.href)) && view.tabId != null) {
cons... | javascript | async function showExtensionTab(url, match = url) {
match = extension.getURL(match || url); url = extension.getURL(url);
for (const view of extension.getViews({ type: 'tab', })) {
if (view && (typeof match === 'string' ? view.location.href === match : match.test(view.location.href)) && view.tabId != null) {
cons... | [
"async",
"function",
"showExtensionTab",
"(",
"url",
",",
"match",
"=",
"url",
")",
"{",
"match",
"=",
"extension",
".",
"getURL",
"(",
"match",
"||",
"url",
")",
";",
"url",
"=",
"extension",
".",
"getURL",
"(",
"url",
")",
";",
"for",
"(",
"const",... | Shows or opens a tab containing an extension page.
Shows the fist tab whose .pathname equals 'match' and that has a window.tabId set, or opens a new tab containing 'url' if no such tab is found.
@param {string} url The url to open in the new tab if no existing tab was found.
@param {string} match Op... | [
"Shows",
"or",
"opens",
"a",
"tab",
"containing",
"an",
"extension",
"page",
".",
"Shows",
"the",
"fist",
"tab",
"whose",
".",
"pathname",
"equals",
"match",
"and",
"that",
"has",
"a",
"window",
".",
"tabId",
"set",
"or",
"opens",
"a",
"new",
"tab",
"c... | 395698c633da88db86377d583b9b4eac6d9cc299 | https://github.com/NiklasGollenstede/web-ext-utils/blob/395698c633da88db86377d583b9b4eac6d9cc299/utils/index.js#L79-L88 | train |
AXErunners/axecore-p2p | lib/inventory.js | Inventory | function Inventory(obj) {
this.type = obj.type;
if (!BufferUtil.isBuffer(obj.hash)) {
throw new TypeError('Unexpected hash, expected to be a buffer');
}
this.hash = obj.hash;
} | javascript | function Inventory(obj) {
this.type = obj.type;
if (!BufferUtil.isBuffer(obj.hash)) {
throw new TypeError('Unexpected hash, expected to be a buffer');
}
this.hash = obj.hash;
} | [
"function",
"Inventory",
"(",
"obj",
")",
"{",
"this",
".",
"type",
"=",
"obj",
".",
"type",
";",
"if",
"(",
"!",
"BufferUtil",
".",
"isBuffer",
"(",
"obj",
".",
"hash",
")",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'Unexpected hash, expected to be a... | A constructor for inventory related Bitcoin messages such as
"getdata", "inv" and "notfound".
@param {Object} obj
@param {Number} obj.type - Inventory.TYPE
@param {Buffer} obj.hash - The hash for the inventory
@constructor | [
"A",
"constructor",
"for",
"inventory",
"related",
"Bitcoin",
"messages",
"such",
"as",
"getdata",
"inv",
"and",
"notfound",
"."
] | c06d0e1d7b9ed44b7ee3061feb394d3896240da9 | https://github.com/AXErunners/axecore-p2p/blob/c06d0e1d7b9ed44b7ee3061feb394d3896240da9/lib/inventory.js#L18-L24 | train |
hlapp/wirelesstags-js | lib/util.js | defineLinkedProperty | function defineLinkedProperty(obj, prop, srcProp, readOnly) {
let propName, srcKey;
if (Array.isArray(prop)) {
propName = prop[0];
srcKey = prop[1];
} else {
propName = srcKey = prop;
}
if (typeof srcProp === 'boolean') {
readOnly = srcProp;
srcProp = undefine... | javascript | function defineLinkedProperty(obj, prop, srcProp, readOnly) {
let propName, srcKey;
if (Array.isArray(prop)) {
propName = prop[0];
srcKey = prop[1];
} else {
propName = srcKey = prop;
}
if (typeof srcProp === 'boolean') {
readOnly = srcProp;
srcProp = undefine... | [
"function",
"defineLinkedProperty",
"(",
"obj",
",",
"prop",
",",
"srcProp",
",",
"readOnly",
")",
"{",
"let",
"propName",
",",
"srcKey",
";",
"if",
"(",
"Array",
".",
"isArray",
"(",
"prop",
")",
")",
"{",
"propName",
"=",
"prop",
"[",
"0",
"]",
";"... | Defines a property on the given object whose value will be linked to that
of the property of another object. If the object is an event emitter, a
property set that changes the value will emit an 'update' event for the
object with 3 parameters, the object, the name of the property, and the
new value.
@param {object} ob... | [
"Defines",
"a",
"property",
"on",
"the",
"given",
"object",
"whose",
"value",
"will",
"be",
"linked",
"to",
"that",
"of",
"the",
"property",
"of",
"another",
"object",
".",
"If",
"the",
"object",
"is",
"an",
"event",
"emitter",
"a",
"property",
"set",
"t... | ce63485ce37b33f552ceb2939740a40957a416f3 | https://github.com/hlapp/wirelesstags-js/blob/ce63485ce37b33f552ceb2939740a40957a416f3/lib/util.js#L75-L104 | train |
hlapp/wirelesstags-js | lib/util.js | createFilter | function createFilter(jsonQuery) {
if ('function' === typeof jsonQuery) return jsonQuery;
if ((!jsonQuery) || (Object.keys(jsonQuery).length === 0)) {
return () => true;
}
jsonQuery = Object.assign({}, jsonQuery); // protect against side effects
return function(obj) {
for (let key of... | javascript | function createFilter(jsonQuery) {
if ('function' === typeof jsonQuery) return jsonQuery;
if ((!jsonQuery) || (Object.keys(jsonQuery).length === 0)) {
return () => true;
}
jsonQuery = Object.assign({}, jsonQuery); // protect against side effects
return function(obj) {
for (let key of... | [
"function",
"createFilter",
"(",
"jsonQuery",
")",
"{",
"if",
"(",
"'function'",
"===",
"typeof",
"jsonQuery",
")",
"return",
"jsonQuery",
";",
"if",
"(",
"(",
"!",
"jsonQuery",
")",
"||",
"(",
"Object",
".",
"keys",
"(",
"jsonQuery",
")",
".",
"length",... | Turns the given JSON object into a filter function.
@param {object} [jsonQuery] - An object specifying properties and values
that an object has to match in order to pass the filter. If
omitted, or if the object has no keys, any object will pass the
generated filter.
@returns {function} the generated filter function, a... | [
"Turns",
"the",
"given",
"JSON",
"object",
"into",
"a",
"filter",
"function",
"."
] | ce63485ce37b33f552ceb2939740a40957a416f3 | https://github.com/hlapp/wirelesstags-js/blob/ce63485ce37b33f552ceb2939740a40957a416f3/lib/util.js#L236-L248 | train |
arafato/funcy-azure | lib/utils/env.js | envToObject | function envToObject(fullPath) {
return fs.readFileAsync(fullPath)
.then((file) => {
let envVars = {};
file = file.toString('utf8');
file = file.replace(/ /g, "");
let keyvals = file.split(os.EOL)
for (let i = 0; i <= keyvals.length - 1; ++i) {
... | javascript | function envToObject(fullPath) {
return fs.readFileAsync(fullPath)
.then((file) => {
let envVars = {};
file = file.toString('utf8');
file = file.replace(/ /g, "");
let keyvals = file.split(os.EOL)
for (let i = 0; i <= keyvals.length - 1; ++i) {
... | [
"function",
"envToObject",
"(",
"fullPath",
")",
"{",
"return",
"fs",
".",
"readFileAsync",
"(",
"fullPath",
")",
".",
"then",
"(",
"(",
"file",
")",
"=>",
"{",
"let",
"envVars",
"=",
"{",
"}",
";",
"file",
"=",
"file",
".",
"toString",
"(",
"'utf8'"... | The CLI needs to be invoked from the project folder | [
"The",
"CLI",
"needs",
"to",
"be",
"invoked",
"from",
"the",
"project",
"folder"
] | e2ed1965a2e9da6421b0eefa3a340b38c1ed4eec | https://github.com/arafato/funcy-azure/blob/e2ed1965a2e9da6421b0eefa3a340b38c1ed4eec/lib/utils/env.js#L11-L28 | train |
guileen/node-rts | lib/rts.js | setValue | function setValue(name, stat, value, gran, timestamp, callback) {
if(typeof gran == 'string') {
gran = util.getUnitDesc(gran)
}
var key = getGranKey(name, gran, timestamp);
redis.hset(key, stat, value, callback)
} | javascript | function setValue(name, stat, value, gran, timestamp, callback) {
if(typeof gran == 'string') {
gran = util.getUnitDesc(gran)
}
var key = getGranKey(name, gran, timestamp);
redis.hset(key, stat, value, callback)
} | [
"function",
"setValue",
"(",
"name",
",",
"stat",
",",
"value",
",",
"gran",
",",
"timestamp",
",",
"callback",
")",
"{",
"if",
"(",
"typeof",
"gran",
"==",
"'string'",
")",
"{",
"gran",
"=",
"util",
".",
"getUnitDesc",
"(",
"gran",
")",
"}",
"var",
... | some thing's some statics value in some granularity at some time | [
"some",
"thing",
"s",
"some",
"statics",
"value",
"in",
"some",
"granularity",
"at",
"some",
"time"
] | 22b88c9b81a26e0b7a6e65bf815318fa60f21e55 | https://github.com/guileen/node-rts/blob/22b88c9b81a26e0b7a6e65bf815318fa60f21e55/lib/rts.js#L102-L108 | train |
guileen/node-rts | lib/rts.js | recordUnique | function recordUnique(name, uniqueId, statistics, aggregations, timestamp, callback) {
timestamp = timestamp || Date.now();
// normal record
if(statistics) {
var num = Array.isArray(uniqueId) ? uniqueId.length : 1;
record(name, num, statistics, aggregations, timestamp);
... | javascript | function recordUnique(name, uniqueId, statistics, aggregations, timestamp, callback) {
timestamp = timestamp || Date.now();
// normal record
if(statistics) {
var num = Array.isArray(uniqueId) ? uniqueId.length : 1;
record(name, num, statistics, aggregations, timestamp);
... | [
"function",
"recordUnique",
"(",
"name",
",",
"uniqueId",
",",
"statistics",
",",
"aggregations",
",",
"timestamp",
",",
"callback",
")",
"{",
"timestamp",
"=",
"timestamp",
"||",
"Date",
".",
"now",
"(",
")",
";",
"// normal record",
"if",
"(",
"statistics"... | record unique access, like unique user of a period time.
@param {string | Array} uniqueId one or some uniqueId to be stats | [
"record",
"unique",
"access",
"like",
"unique",
"user",
"of",
"a",
"period",
"time",
"."
] | 22b88c9b81a26e0b7a6e65bf815318fa60f21e55 | https://github.com/guileen/node-rts/blob/22b88c9b81a26e0b7a6e65bf815318fa60f21e55/lib/rts.js#L158-L183 | train |
guileen/node-rts | lib/rts.js | getStat | function getStat(type, name, granCode, fromDate, toDate, callback) {
if(!granCode) throw new Error('granCode is required');
if(!callback && typeof toDate == 'function') {
callback = toDate;
toDate = Date.now();
}
var gran = granMap[granCode] || util.getUnitDesc(gr... | javascript | function getStat(type, name, granCode, fromDate, toDate, callback) {
if(!granCode) throw new Error('granCode is required');
if(!callback && typeof toDate == 'function') {
callback = toDate;
toDate = Date.now();
}
var gran = granMap[granCode] || util.getUnitDesc(gr... | [
"function",
"getStat",
"(",
"type",
",",
"name",
",",
"granCode",
",",
"fromDate",
",",
"toDate",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"granCode",
")",
"throw",
"new",
"Error",
"(",
"'granCode is required'",
")",
";",
"if",
"(",
"!",
"callback",
... | get results of the stats
@param {String} type sum, min, max, avg, count, uni | [
"get",
"results",
"of",
"the",
"stats"
] | 22b88c9b81a26e0b7a6e65bf815318fa60f21e55 | https://github.com/guileen/node-rts/blob/22b88c9b81a26e0b7a6e65bf815318fa60f21e55/lib/rts.js#L190-L225 | train |
AXErunners/axecore-p2p | lib/messages/commands/reject.js | RejectMessage | function RejectMessage(arg, options) {
if (!arg) {
arg = {};
}
Message.call(this, options);
this.command = 'reject';
this.message = arg.message;
this.ccode = arg.ccode;
this.reason = arg.reason;
this.data = arg.data;
} | javascript | function RejectMessage(arg, options) {
if (!arg) {
arg = {};
}
Message.call(this, options);
this.command = 'reject';
this.message = arg.message;
this.ccode = arg.ccode;
this.reason = arg.reason;
this.data = arg.data;
} | [
"function",
"RejectMessage",
"(",
"arg",
",",
"options",
")",
"{",
"if",
"(",
"!",
"arg",
")",
"{",
"arg",
"=",
"{",
"}",
";",
"}",
"Message",
".",
"call",
"(",
"this",
",",
"options",
")",
";",
"this",
".",
"command",
"=",
"'reject'",
";",
"this... | The reject message is sent when messages are rejected.
@see https://en.bitcoin.it/wiki/Protocol_documentation#reject
@param {Object=} arg - properties for the reject message
@param {String=} arg.message - type of message rejected
@param {Number=} arg.ccode - code relating to rejected message
@param {String=} arg.reaso... | [
"The",
"reject",
"message",
"is",
"sent",
"when",
"messages",
"are",
"rejected",
"."
] | c06d0e1d7b9ed44b7ee3061feb394d3896240da9 | https://github.com/AXErunners/axecore-p2p/blob/c06d0e1d7b9ed44b7ee3061feb394d3896240da9/lib/messages/commands/reject.js#L23-L33 | train |
kesuiket/path.js | path.js | join | function join() {
var path = '';
var args = slice.call(arguments, 0);
if (arguments.length <= 1) args.unshift(cwd());
for (var i = 0; i < args.length; i += 1) {
var segment = args[i];
if (!isString(segment)) {
throw new TypeError ('Arguemnts to path.join must be strings');
}
... | javascript | function join() {
var path = '';
var args = slice.call(arguments, 0);
if (arguments.length <= 1) args.unshift(cwd());
for (var i = 0; i < args.length; i += 1) {
var segment = args[i];
if (!isString(segment)) {
throw new TypeError ('Arguemnts to path.join must be strings');
}
... | [
"function",
"join",
"(",
")",
"{",
"var",
"path",
"=",
"''",
";",
"var",
"args",
"=",
"slice",
".",
"call",
"(",
"arguments",
",",
"0",
")",
";",
"if",
"(",
"arguments",
".",
"length",
"<=",
"1",
")",
"args",
".",
"unshift",
"(",
"cwd",
"(",
")... | join the pathes
@param {String} [path1, path2, path3...]
@return {String} joined path | [
"join",
"the",
"pathes"
] | 6f885627aadd589c2784288726f2a4a812d07822 | https://github.com/kesuiket/path.js/blob/6f885627aadd589c2784288726f2a4a812d07822/path.js#L152-L172 | train |
NatLibFi/marc-record-merge-js | lib/main.js | makeSubfieldPairs | function makeSubfieldPairs(subfields1, subfields2, fn_comparator) {
var pairs = [];
if (subfields1.length === subfields2.length) {
subfields2.forEach(function(subfield2) {
return subfields1.some(function(subfield1) {
if (fn_comparator(subfield1, subfield2)) {... | javascript | function makeSubfieldPairs(subfields1, subfields2, fn_comparator) {
var pairs = [];
if (subfields1.length === subfields2.length) {
subfields2.forEach(function(subfield2) {
return subfields1.some(function(subfield1) {
if (fn_comparator(subfield1, subfield2)) {... | [
"function",
"makeSubfieldPairs",
"(",
"subfields1",
",",
"subfields2",
",",
"fn_comparator",
")",
"{",
"var",
"pairs",
"=",
"[",
"]",
";",
"if",
"(",
"subfields1",
".",
"length",
"===",
"subfields2",
".",
"length",
")",
"{",
"subfields2",
".",
"forEach",
"... | Try to make a list of equal pairs from both subfield arrays using a comparator function | [
"Try",
"to",
"make",
"a",
"list",
"of",
"equal",
"pairs",
"from",
"both",
"subfield",
"arrays",
"using",
"a",
"comparator",
"function"
] | e15d84deeb8a5cdc299d248bac135dc2a79f3fe3 | https://github.com/NatLibFi/marc-record-merge-js/blob/e15d84deeb8a5cdc299d248bac135dc2a79f3fe3/lib/main.js#L288-L311 | train |
alphagov/openregister-picker-engine | src/index.js | addWeight | function addWeight (canonicalNodeWithPath, query) {
const cnwp = canonicalNodeWithPath
const name = presentableName(cnwp.node, preferredLocale)
const synonym = cnwp.path
.map(pathNode => presentableName(pathNode.node, pathNode.locale))
.map(nameInPath => nameInPath.toLowerCase())
.pop()
const ind... | javascript | function addWeight (canonicalNodeWithPath, query) {
const cnwp = canonicalNodeWithPath
const name = presentableName(cnwp.node, preferredLocale)
const synonym = cnwp.path
.map(pathNode => presentableName(pathNode.node, pathNode.locale))
.map(nameInPath => nameInPath.toLowerCase())
.pop()
const ind... | [
"function",
"addWeight",
"(",
"canonicalNodeWithPath",
",",
"query",
")",
"{",
"const",
"cnwp",
"=",
"canonicalNodeWithPath",
"const",
"name",
"=",
"presentableName",
"(",
"cnwp",
".",
"node",
",",
"preferredLocale",
")",
"const",
"synonym",
"=",
"cnwp",
".",
... | Takes a canonical node with the path to reach it, and the typed in query. Returns the same node and path, with added weight based on a number of criteria. Higher weight means higher priority, so it should be ranked higher in the list. | [
"Takes",
"a",
"canonical",
"node",
"with",
"the",
"path",
"to",
"reach",
"it",
"and",
"the",
"typed",
"in",
"query",
".",
"Returns",
"the",
"same",
"node",
"and",
"path",
"with",
"added",
"weight",
"based",
"on",
"a",
"number",
"of",
"criteria",
".",
"... | fed0cc61aab3e8c174fe65ea84ca12674e5cd520 | https://github.com/alphagov/openregister-picker-engine/blob/fed0cc61aab3e8c174fe65ea84ca12674e5cd520/src/index.js#L72-L157 | 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.