id int32 0 58k | repo stringlengths 5 67 | path stringlengths 4 116 | func_name stringlengths 0 58 | original_string stringlengths 52 373k | language stringclasses 1 value | code stringlengths 52 373k | code_tokens list | docstring stringlengths 4 11.8k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 86 226 |
|---|---|---|---|---|---|---|---|---|---|---|---|
33,200 | freiksenet/react-kinetic | vendor/kinetic-v5.1.0.js | function(config) {
var cb = config.callback;
config.callback = function(dataUrl) {
Kinetic.Util._getImage(dataUrl, function(img) {
cb(img);
});
};
this.toDataURL(config);
} | javascript | function(config) {
var cb = config.callback;
config.callback = function(dataUrl) {
Kinetic.Util._getImage(dataUrl, function(img) {
cb(img);
});
};
this.toDataURL(config);
} | [
"function",
"(",
"config",
")",
"{",
"var",
"cb",
"=",
"config",
".",
"callback",
";",
"config",
".",
"callback",
"=",
"function",
"(",
"dataUrl",
")",
"{",
"Kinetic",
".",
"Util",
".",
"_getImage",
"(",
"dataUrl",
",",
"function",
"(",
"img",
")",
"... | converts stage into an image.
@method
@memberof Kinetic.Stage.prototype
@param {Object} config
@param {Function} config.callback function executed when the composite has completed
@param {String} [config.mimeType] can be "image/png" or "image/jpeg".
"image/png" is the default
@param {Number} [config.x] x position of canvas section
@param {Number} [config.y] y position of canvas section
@param {Number} [config.width] width of canvas section
@param {Number} [config.height] height of canvas section
@param {Number} [config.quality] jpeg quality. If using an "image/jpeg" mimeType,
you can specify the quality from 0 to 1, where 0 is very poor quality and 1
is very high quality | [
"converts",
"stage",
"into",
"an",
"image",
"."
] | de0db477141e26d9a07162ef096984bb3f068cec | https://github.com/freiksenet/react-kinetic/blob/de0db477141e26d9a07162ef096984bb3f068cec/vendor/kinetic-v5.1.0.js#L9244-L9253 | |
33,201 | freiksenet/react-kinetic | vendor/kinetic-v5.1.0.js | function(layer) {
if (arguments.length > 1) {
for (var i = 0; i < arguments.length; i++) {
this.add(arguments[i]);
}
return;
}
Kinetic.Container.prototype.add.call(this, layer);
layer._setCanvasSize(this.width(), this.height());
// draw layer and append canvas to container
layer.draw();
this.content.appendChild(layer.canvas._canvas);
// chainable
return this;
} | javascript | function(layer) {
if (arguments.length > 1) {
for (var i = 0; i < arguments.length; i++) {
this.add(arguments[i]);
}
return;
}
Kinetic.Container.prototype.add.call(this, layer);
layer._setCanvasSize(this.width(), this.height());
// draw layer and append canvas to container
layer.draw();
this.content.appendChild(layer.canvas._canvas);
// chainable
return this;
} | [
"function",
"(",
"layer",
")",
"{",
"if",
"(",
"arguments",
".",
"length",
">",
"1",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"arguments",
".",
"length",
";",
"i",
"++",
")",
"{",
"this",
".",
"add",
"(",
"arguments",
"[",
"... | add layer or layers to stage
@method
@memberof Kinetic.Stage.prototype
@param {...Kinetic.Layer} layer
@example
stage.add(layer1, layer2, layer3); | [
"add",
"layer",
"or",
"layers",
"to",
"stage"
] | de0db477141e26d9a07162ef096984bb3f068cec | https://github.com/freiksenet/react-kinetic/blob/de0db477141e26d9a07162ef096984bb3f068cec/vendor/kinetic-v5.1.0.js#L9311-L9327 | |
33,202 | freiksenet/react-kinetic | vendor/kinetic-v5.1.0.js | function(index) {
Kinetic.Node.prototype.setZIndex.call(this, index);
var stage = this.getStage();
if(stage) {
stage.content.removeChild(this.getCanvas()._canvas);
if(index < stage.getChildren().length - 1) {
stage.content.insertBefore(this.getCanvas()._canvas, stage.getChildren()[index + 1].getCanvas()._canvas);
}
else {
stage.content.appendChild(this.getCanvas()._canvas);
}
}
return this;
} | javascript | function(index) {
Kinetic.Node.prototype.setZIndex.call(this, index);
var stage = this.getStage();
if(stage) {
stage.content.removeChild(this.getCanvas()._canvas);
if(index < stage.getChildren().length - 1) {
stage.content.insertBefore(this.getCanvas()._canvas, stage.getChildren()[index + 1].getCanvas()._canvas);
}
else {
stage.content.appendChild(this.getCanvas()._canvas);
}
}
return this;
} | [
"function",
"(",
"index",
")",
"{",
"Kinetic",
".",
"Node",
".",
"prototype",
".",
"setZIndex",
".",
"call",
"(",
"this",
",",
"index",
")",
";",
"var",
"stage",
"=",
"this",
".",
"getStage",
"(",
")",
";",
"if",
"(",
"stage",
")",
"{",
"stage",
... | extend Node.prototype.setZIndex | [
"extend",
"Node",
".",
"prototype",
".",
"setZIndex"
] | de0db477141e26d9a07162ef096984bb3f068cec | https://github.com/freiksenet/react-kinetic/blob/de0db477141e26d9a07162ef096984bb3f068cec/vendor/kinetic-v5.1.0.js#L9750-L9764 | |
33,203 | freiksenet/react-kinetic | vendor/kinetic-v5.1.0.js | function() {
Kinetic.Node.prototype.moveToTop.call(this);
var stage = this.getStage();
if(stage) {
stage.content.removeChild(this.getCanvas()._canvas);
stage.content.appendChild(this.getCanvas()._canvas);
}
} | javascript | function() {
Kinetic.Node.prototype.moveToTop.call(this);
var stage = this.getStage();
if(stage) {
stage.content.removeChild(this.getCanvas()._canvas);
stage.content.appendChild(this.getCanvas()._canvas);
}
} | [
"function",
"(",
")",
"{",
"Kinetic",
".",
"Node",
".",
"prototype",
".",
"moveToTop",
".",
"call",
"(",
"this",
")",
";",
"var",
"stage",
"=",
"this",
".",
"getStage",
"(",
")",
";",
"if",
"(",
"stage",
")",
"{",
"stage",
".",
"content",
".",
"r... | extend Node.prototype.moveToTop | [
"extend",
"Node",
".",
"prototype",
".",
"moveToTop"
] | de0db477141e26d9a07162ef096984bb3f068cec | https://github.com/freiksenet/react-kinetic/blob/de0db477141e26d9a07162ef096984bb3f068cec/vendor/kinetic-v5.1.0.js#L9766-L9773 | |
33,204 | freiksenet/react-kinetic | vendor/kinetic-v5.1.0.js | function() {
if(Kinetic.Node.prototype.moveDown.call(this)) {
var stage = this.getStage();
if(stage) {
var children = stage.getChildren();
stage.content.removeChild(this.getCanvas()._canvas);
stage.content.insertBefore(this.getCanvas()._canvas, children[this.index + 1].getCanvas()._canvas);
}
}
} | javascript | function() {
if(Kinetic.Node.prototype.moveDown.call(this)) {
var stage = this.getStage();
if(stage) {
var children = stage.getChildren();
stage.content.removeChild(this.getCanvas()._canvas);
stage.content.insertBefore(this.getCanvas()._canvas, children[this.index + 1].getCanvas()._canvas);
}
}
} | [
"function",
"(",
")",
"{",
"if",
"(",
"Kinetic",
".",
"Node",
".",
"prototype",
".",
"moveDown",
".",
"call",
"(",
"this",
")",
")",
"{",
"var",
"stage",
"=",
"this",
".",
"getStage",
"(",
")",
";",
"if",
"(",
"stage",
")",
"{",
"var",
"children"... | extend Node.prototype.moveDown | [
"extend",
"Node",
".",
"prototype",
".",
"moveDown"
] | de0db477141e26d9a07162ef096984bb3f068cec | https://github.com/freiksenet/react-kinetic/blob/de0db477141e26d9a07162ef096984bb3f068cec/vendor/kinetic-v5.1.0.js#L9791-L9800 | |
33,205 | freiksenet/react-kinetic | vendor/kinetic-v5.1.0.js | function() {
return this.attrs.height === AUTO ? (this.getTextHeight() * this.textArr.length * this.getLineHeight()) + this.getPadding() * 2 : this.attrs.height;
} | javascript | function() {
return this.attrs.height === AUTO ? (this.getTextHeight() * this.textArr.length * this.getLineHeight()) + this.getPadding() * 2 : this.attrs.height;
} | [
"function",
"(",
")",
"{",
"return",
"this",
".",
"attrs",
".",
"height",
"===",
"AUTO",
"?",
"(",
"this",
".",
"getTextHeight",
"(",
")",
"*",
"this",
".",
"textArr",
".",
"length",
"*",
"this",
".",
"getLineHeight",
"(",
")",
")",
"+",
"this",
".... | get the height of the text area, which takes into account multi-line text, line heights, and padding
@method
@memberof Kinetic.Text.prototype
@returns {Number} | [
"get",
"the",
"height",
"of",
"the",
"text",
"area",
"which",
"takes",
"into",
"account",
"multi",
"-",
"line",
"text",
"line",
"heights",
"and",
"padding"
] | de0db477141e26d9a07162ef096984bb3f068cec | https://github.com/freiksenet/react-kinetic/blob/de0db477141e26d9a07162ef096984bb3f068cec/vendor/kinetic-v5.1.0.js#L11700-L11702 | |
33,206 | polarch/JSAmbisonics | examples/hoa-panner-sofa2D.js | loadSample | function loadSample(url, doAfterLoading) {
var fetchSound = new XMLHttpRequest(); // Load the Sound with XMLHttpRequest
fetchSound.open("GET", url, true); // Path to Audio File
fetchSound.responseType = "arraybuffer"; // Read as Binary Data
fetchSound.onload = function() {
context.decodeAudioData(fetchSound.response, doAfterLoading);
}
fetchSound.send();
} | javascript | function loadSample(url, doAfterLoading) {
var fetchSound = new XMLHttpRequest(); // Load the Sound with XMLHttpRequest
fetchSound.open("GET", url, true); // Path to Audio File
fetchSound.responseType = "arraybuffer"; // Read as Binary Data
fetchSound.onload = function() {
context.decodeAudioData(fetchSound.response, doAfterLoading);
}
fetchSound.send();
} | [
"function",
"loadSample",
"(",
"url",
",",
"doAfterLoading",
")",
"{",
"var",
"fetchSound",
"=",
"new",
"XMLHttpRequest",
"(",
")",
";",
"// Load the Sound with XMLHttpRequest",
"fetchSound",
".",
"open",
"(",
"\"GET\"",
",",
"url",
",",
"true",
")",
";",
"// ... | function to load samples | [
"function",
"to",
"load",
"samples"
] | bd02150b5c7cb5446b212bb58970c096116c0027 | https://github.com/polarch/JSAmbisonics/blob/bd02150b5c7cb5446b212bb58970c096116c0027/examples/hoa-panner-sofa2D.js#L67-L75 |
33,207 | goFrendiAsgard/chimera-framework | lib/mongo.js | execute | function execute (configs, fn, ...args) {
if ('verbose' in configs && configs.verbose) {
const isoDate = (new Date()).toISOString()
console.error(COLOR_FG_YELLOW + '[' + isoDate + '] Start mongo.execute: ' + JSON.stringify([configs, fn, args]) + COLOR_RESET)
}
const dbConfigs = util.getDeepCopiedObject(configs)
const mongoUrl = 'mongoUrl' in dbConfigs ? dbConfigs.mongoUrl : ''
const dbOption = 'dbOption' in dbConfigs ? dbConfigs.dbOption : {}
const options = 'options' in dbConfigs ? dbConfigs.options : {}
const collectionName = 'collectionName' in dbConfigs ? dbConfigs.collectionName : ''
delete dbConfigs.mongoUrl
delete dbConfigs.dbOption
delete dbConfigs.collectionName
let manager
// wrap last argument in newCallback
const callback = args[args.length - 1]
const newCallback = (error, result) => {
if ('verbose' in configs && configs.verbose) {
const isoDate = (new Date()).toISOString()
console.error(COLOR_FG_YELLOW + '[' + isoDate + '] Finish mongo.execute: ' + JSON.stringify([configs, fn, args]) + COLOR_RESET)
}
manager.close()
callback(error, result)
}
args[args.length - 1] = newCallback
manager = getCompleteManager(mongoUrl, dbOption, options, (error, manager) => {
if (error) {
return newCallback(error)
}
const collection = getCompleteCollection(manager, collectionName, dbConfigs)
try {
return collection[fn](...args)
} catch (error) {
return newCallback(error)
}
})
} | javascript | function execute (configs, fn, ...args) {
if ('verbose' in configs && configs.verbose) {
const isoDate = (new Date()).toISOString()
console.error(COLOR_FG_YELLOW + '[' + isoDate + '] Start mongo.execute: ' + JSON.stringify([configs, fn, args]) + COLOR_RESET)
}
const dbConfigs = util.getDeepCopiedObject(configs)
const mongoUrl = 'mongoUrl' in dbConfigs ? dbConfigs.mongoUrl : ''
const dbOption = 'dbOption' in dbConfigs ? dbConfigs.dbOption : {}
const options = 'options' in dbConfigs ? dbConfigs.options : {}
const collectionName = 'collectionName' in dbConfigs ? dbConfigs.collectionName : ''
delete dbConfigs.mongoUrl
delete dbConfigs.dbOption
delete dbConfigs.collectionName
let manager
// wrap last argument in newCallback
const callback = args[args.length - 1]
const newCallback = (error, result) => {
if ('verbose' in configs && configs.verbose) {
const isoDate = (new Date()).toISOString()
console.error(COLOR_FG_YELLOW + '[' + isoDate + '] Finish mongo.execute: ' + JSON.stringify([configs, fn, args]) + COLOR_RESET)
}
manager.close()
callback(error, result)
}
args[args.length - 1] = newCallback
manager = getCompleteManager(mongoUrl, dbOption, options, (error, manager) => {
if (error) {
return newCallback(error)
}
const collection = getCompleteCollection(manager, collectionName, dbConfigs)
try {
return collection[fn](...args)
} catch (error) {
return newCallback(error)
}
})
} | [
"function",
"execute",
"(",
"configs",
",",
"fn",
",",
"...",
"args",
")",
"{",
"if",
"(",
"'verbose'",
"in",
"configs",
"&&",
"configs",
".",
"verbose",
")",
"{",
"const",
"isoDate",
"=",
"(",
"new",
"Date",
"(",
")",
")",
".",
"toISOString",
"(",
... | run something and close the db manager afterward | [
"run",
"something",
"and",
"close",
"the",
"db",
"manager",
"afterward"
] | cfa0c98af685de8696e30f507eba66a72e684b66 | https://github.com/goFrendiAsgard/chimera-framework/blob/cfa0c98af685de8696e30f507eba66a72e684b66/lib/mongo.js#L22-L58 |
33,208 | assemble/assemble-less | vendor/less-1.3.3/lib/less/tree/dimension.js | function (op, other) {
return new(tree.Dimension)
(tree.operate(op, this.value, other.value),
this.unit || other.unit);
} | javascript | function (op, other) {
return new(tree.Dimension)
(tree.operate(op, this.value, other.value),
this.unit || other.unit);
} | [
"function",
"(",
"op",
",",
"other",
")",
"{",
"return",
"new",
"(",
"tree",
".",
"Dimension",
")",
"(",
"tree",
".",
"operate",
"(",
"op",
",",
"this",
".",
"value",
",",
"other",
".",
"value",
")",
",",
"this",
".",
"unit",
"||",
"other",
".",
... | In an operation between two Dimensions, we default to the first Dimension's unit, so `1px + 2em` will yield `3px`. In the future, we could implement some unit conversions such that `100cm + 10mm` would yield `101cm`. | [
"In",
"an",
"operation",
"between",
"two",
"Dimensions",
"we",
"default",
"to",
"the",
"first",
"Dimension",
"s",
"unit",
"so",
"1px",
"+",
"2em",
"will",
"yield",
"3px",
".",
"In",
"the",
"future",
"we",
"could",
"implement",
"some",
"unit",
"conversions"... | 529d24823b60cb77584a45a765c0291786163a75 | https://github.com/assemble/assemble-less/blob/529d24823b60cb77584a45a765c0291786163a75/vendor/less-1.3.3/lib/less/tree/dimension.js#L27-L31 | |
33,209 | goFrendiAsgard/chimera-framework | lib/util.js | getPatchedObject | function getPatchedObject (obj, patcher, clone = true) {
if (!patcher) {
return obj
}
let newObj, newPatcher
if (clone) {
newObj = getDeepCopiedObject(obj)
newPatcher = getDeepCopiedObject(patcher)
} else {
newObj = obj
newPatcher = patcher
}
// patch
const keys = Object.keys(newPatcher)
for (let i = 0; i < keys.length; i++) {
const key = keys[i]
if ((key in newObj) && isRealObject(newObj[key]) && isRealObject(newPatcher[key])) {
// recursive patch for if value type is newObject
try {
newObj[key] = getPatchedObject(newObj[key], newPatcher[key], false)
} catch (error) {
// do nothing, just skip
}
} else {
// simple replacement if value type is not newObject
newObj[key] = newPatcher[key]
}
}
return newObj
} | javascript | function getPatchedObject (obj, patcher, clone = true) {
if (!patcher) {
return obj
}
let newObj, newPatcher
if (clone) {
newObj = getDeepCopiedObject(obj)
newPatcher = getDeepCopiedObject(patcher)
} else {
newObj = obj
newPatcher = patcher
}
// patch
const keys = Object.keys(newPatcher)
for (let i = 0; i < keys.length; i++) {
const key = keys[i]
if ((key in newObj) && isRealObject(newObj[key]) && isRealObject(newPatcher[key])) {
// recursive patch for if value type is newObject
try {
newObj[key] = getPatchedObject(newObj[key], newPatcher[key], false)
} catch (error) {
// do nothing, just skip
}
} else {
// simple replacement if value type is not newObject
newObj[key] = newPatcher[key]
}
}
return newObj
} | [
"function",
"getPatchedObject",
"(",
"obj",
",",
"patcher",
",",
"clone",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"patcher",
")",
"{",
"return",
"obj",
"}",
"let",
"newObj",
",",
"newPatcher",
"if",
"(",
"clone",
")",
"{",
"newObj",
"=",
"getDeepCopiedO... | patch object with patcher | [
"patch",
"object",
"with",
"patcher"
] | cfa0c98af685de8696e30f507eba66a72e684b66 | https://github.com/goFrendiAsgard/chimera-framework/blob/cfa0c98af685de8696e30f507eba66a72e684b66/lib/util.js#L87-L116 |
33,210 | EE/angular-ui-tree-filter | dist/angular-ui-tree-filter.js | visit | function visit(collection, pattern, address) {
collection = collection || [];
var foundSoFar = false;
collection.forEach(function (collectionItem) {
foundSoFar = foundSoFar || testForField(collectionItem, pattern, address);
});
return foundSoFar;
} | javascript | function visit(collection, pattern, address) {
collection = collection || [];
var foundSoFar = false;
collection.forEach(function (collectionItem) {
foundSoFar = foundSoFar || testForField(collectionItem, pattern, address);
});
return foundSoFar;
} | [
"function",
"visit",
"(",
"collection",
",",
"pattern",
",",
"address",
")",
"{",
"collection",
"=",
"collection",
"||",
"[",
"]",
";",
"var",
"foundSoFar",
"=",
"false",
";",
"collection",
".",
"forEach",
"(",
"function",
"(",
"collectionItem",
")",
"{",
... | Iterates through given collection if flag is not true and sets a flag to true on first match.
@param {Array} collection
@param {string} pattern
@param {string} address
@returns {boolean} | [
"Iterates",
"through",
"given",
"collection",
"if",
"flag",
"is",
"not",
"true",
"and",
"sets",
"a",
"flag",
"to",
"true",
"on",
"first",
"match",
"."
] | 6a9772edd2a806df63ec6483826af66ad428cf73 | https://github.com/EE/angular-ui-tree-filter/blob/6a9772edd2a806df63ec6483826af66ad428cf73/dist/angular-ui-tree-filter.js#L39-L48 |
33,211 | EE/angular-ui-tree-filter | dist/angular-ui-tree-filter.js | resolveAddress | function resolveAddress(object, path) {
var parts = path.split('.');
if (object === undefined) {
return;
}
return parts.length < 2 ? object[parts[0]] : resolveAddress(object[parts[0]], parts.slice(1).join('.'));
} | javascript | function resolveAddress(object, path) {
var parts = path.split('.');
if (object === undefined) {
return;
}
return parts.length < 2 ? object[parts[0]] : resolveAddress(object[parts[0]], parts.slice(1).join('.'));
} | [
"function",
"resolveAddress",
"(",
"object",
",",
"path",
")",
"{",
"var",
"parts",
"=",
"path",
".",
"split",
"(",
"'.'",
")",
";",
"if",
"(",
"object",
"===",
"undefined",
")",
"{",
"return",
";",
"}",
"return",
"parts",
".",
"length",
"<",
"2",
... | Resolves object value from dot-delimited address.
@param object
@param path
@returns {*} | [
"Resolves",
"object",
"value",
"from",
"dot",
"-",
"delimited",
"address",
"."
] | 6a9772edd2a806df63ec6483826af66ad428cf73 | https://github.com/EE/angular-ui-tree-filter/blob/6a9772edd2a806df63ec6483826af66ad428cf73/dist/angular-ui-tree-filter.js#L57-L65 |
33,212 | bfred-it/list-github-dir-content | index.js | api | async function api(endpoint, token) {
token = token ? `&access_token=${token}` : '';
const response = await fetch(`https://api.github.com/repos/${endpoint}${token}`);
return response.json();
} | javascript | async function api(endpoint, token) {
token = token ? `&access_token=${token}` : '';
const response = await fetch(`https://api.github.com/repos/${endpoint}${token}`);
return response.json();
} | [
"async",
"function",
"api",
"(",
"endpoint",
",",
"token",
")",
"{",
"token",
"=",
"token",
"?",
"`",
"${",
"token",
"}",
"`",
":",
"''",
";",
"const",
"response",
"=",
"await",
"fetch",
"(",
"`",
"${",
"endpoint",
"}",
"${",
"token",
"}",
"`",
"... | Automatically excluded in browser bundles | [
"Automatically",
"excluded",
"in",
"browser",
"bundles"
] | f175f5b9498f32cc9e656d40109442d454436a58 | https://github.com/bfred-it/list-github-dir-content/blob/f175f5b9498f32cc9e656d40109442d454436a58/index.js#L3-L7 |
33,213 | pkoretic/pdf417-generator | lib/bcmath.js | bcadd | function bcadd(left_operand, right_operand, scale) {
var first, second, result;
if (typeof(scale) == 'undefined') {
scale = libbcmath.scale;
}
scale = ((scale < 0) ? 0 : scale);
// create objects
first = libbcmath.bc_init_num();
second = libbcmath.bc_init_num();
result = libbcmath.bc_init_num();
first = libbcmath.php_str2num(left_operand.toString());
second = libbcmath.php_str2num(right_operand.toString());
// normalize arguments to same scale.
if (first.n_scale > second.n_scale) second.setScale(first.n_scale);
if (second.n_scale > first.n_scale) first.setScale(second.n_scale);
result = libbcmath.bc_add(first, second, scale);
if (result.n_scale > scale) {
result.n_scale = scale;
}
return result.toString();
} | javascript | function bcadd(left_operand, right_operand, scale) {
var first, second, result;
if (typeof(scale) == 'undefined') {
scale = libbcmath.scale;
}
scale = ((scale < 0) ? 0 : scale);
// create objects
first = libbcmath.bc_init_num();
second = libbcmath.bc_init_num();
result = libbcmath.bc_init_num();
first = libbcmath.php_str2num(left_operand.toString());
second = libbcmath.php_str2num(right_operand.toString());
// normalize arguments to same scale.
if (first.n_scale > second.n_scale) second.setScale(first.n_scale);
if (second.n_scale > first.n_scale) first.setScale(second.n_scale);
result = libbcmath.bc_add(first, second, scale);
if (result.n_scale > scale) {
result.n_scale = scale;
}
return result.toString();
} | [
"function",
"bcadd",
"(",
"left_operand",
",",
"right_operand",
",",
"scale",
")",
"{",
"var",
"first",
",",
"second",
",",
"result",
";",
"if",
"(",
"typeof",
"(",
"scale",
")",
"==",
"'undefined'",
")",
"{",
"scale",
"=",
"libbcmath",
".",
"scale",
"... | PHP Implementation of the libbcmath functions
Designed to replicate the PHP functions exactly.
Also includes new function: bcround
bcadd - Add two arbitrary precision numbers
Sums left_operand and right_operand.
@param string left_operand The left operand, as a string
@param string right_operand The right operand, as a string.
@param int [scale] The optional parameter is used to set the number of digits after the decimal place in the result. You can also set the global scale for all functions by using bcscale()
@return string | [
"PHP",
"Implementation",
"of",
"the",
"libbcmath",
"functions"
] | bcb0af69d822446aa4e195019a35d0967626a13b | https://github.com/pkoretic/pdf417-generator/blob/bcb0af69d822446aa4e195019a35d0967626a13b/lib/bcmath.js#L21-L48 |
33,214 | pkoretic/pdf417-generator | lib/bcmath.js | bcsub | function bcsub(left_operand, right_operand, scale) {
var first, second, result;
if (typeof(scale) == 'undefined') {
scale = libbcmath.scale;
}
scale = ((scale < 0) ? 0 : scale);
// create objects
first = libbcmath.bc_init_num();
second = libbcmath.bc_init_num();
result = libbcmath.bc_init_num();
first = libbcmath.php_str2num(left_operand.toString());
second = libbcmath.php_str2num(right_operand.toString());
// normalize arguments to same scale.
if (first.n_scale > second.n_scale) second.setScale(first.n_scale);
if (second.n_scale > first.n_scale) first.setScale(second.n_scale);
result = libbcmath.bc_sub(first, second, scale);
if (result.n_scale > scale) {
result.n_scale = scale;
}
return result.toString();
} | javascript | function bcsub(left_operand, right_operand, scale) {
var first, second, result;
if (typeof(scale) == 'undefined') {
scale = libbcmath.scale;
}
scale = ((scale < 0) ? 0 : scale);
// create objects
first = libbcmath.bc_init_num();
second = libbcmath.bc_init_num();
result = libbcmath.bc_init_num();
first = libbcmath.php_str2num(left_operand.toString());
second = libbcmath.php_str2num(right_operand.toString());
// normalize arguments to same scale.
if (first.n_scale > second.n_scale) second.setScale(first.n_scale);
if (second.n_scale > first.n_scale) first.setScale(second.n_scale);
result = libbcmath.bc_sub(first, second, scale);
if (result.n_scale > scale) {
result.n_scale = scale;
}
return result.toString();
} | [
"function",
"bcsub",
"(",
"left_operand",
",",
"right_operand",
",",
"scale",
")",
"{",
"var",
"first",
",",
"second",
",",
"result",
";",
"if",
"(",
"typeof",
"(",
"scale",
")",
"==",
"'undefined'",
")",
"{",
"scale",
"=",
"libbcmath",
".",
"scale",
"... | bcsub - Subtract one arbitrary precision number from another
Returns difference between the left operand and the right operand.
@param string left_operand The left operand, as a string
@param string right_operand The right operand, as a string.
@param int [scale] The optional parameter is used to set the number of digits after the decimal place in the result. You can also set the global scale for all functions by using bcscale()
@return string | [
"bcsub",
"-",
"Subtract",
"one",
"arbitrary",
"precision",
"number",
"from",
"another",
"Returns",
"difference",
"between",
"the",
"left",
"operand",
"and",
"the",
"right",
"operand",
"."
] | bcb0af69d822446aa4e195019a35d0967626a13b | https://github.com/pkoretic/pdf417-generator/blob/bcb0af69d822446aa4e195019a35d0967626a13b/lib/bcmath.js#L59-L87 |
33,215 | pkoretic/pdf417-generator | lib/bcmath.js | bccomp | function bccomp(left_operand, right_operand, scale) {
var first, second; //bc_num
if (typeof(scale) == 'undefined') {
scale = libbcmath.scale;
}
scale = ((scale < 0) ? 0 : scale);
first = libbcmath.bc_init_num();
second = libbcmath.bc_init_num();
first = libbcmath.bc_str2num(left_operand.toString(), scale); // note bc_ not php_str2num
second = libbcmath.bc_str2num(right_operand.toString(), scale); // note bc_ not php_str2num
return libbcmath.bc_compare(first, second, scale);
} | javascript | function bccomp(left_operand, right_operand, scale) {
var first, second; //bc_num
if (typeof(scale) == 'undefined') {
scale = libbcmath.scale;
}
scale = ((scale < 0) ? 0 : scale);
first = libbcmath.bc_init_num();
second = libbcmath.bc_init_num();
first = libbcmath.bc_str2num(left_operand.toString(), scale); // note bc_ not php_str2num
second = libbcmath.bc_str2num(right_operand.toString(), scale); // note bc_ not php_str2num
return libbcmath.bc_compare(first, second, scale);
} | [
"function",
"bccomp",
"(",
"left_operand",
",",
"right_operand",
",",
"scale",
")",
"{",
"var",
"first",
",",
"second",
";",
"//bc_num",
"if",
"(",
"typeof",
"(",
"scale",
")",
"==",
"'undefined'",
")",
"{",
"scale",
"=",
"libbcmath",
".",
"scale",
";",
... | bccomp - Compare two arbitrary precision numers
@param string left_operand The left operand, as a string
@param string right_operand The right operand, as a string.
@param int [scale] The optional parameter is used to set the number of digits after the decimal place in the result. You can also set the global scale for all functions by using bcscale()
@return int 0: Left/Right are equal, 1 if left > right, -1 otherwise | [
"bccomp",
"-",
"Compare",
"two",
"arbitrary",
"precision",
"numers"
] | bcb0af69d822446aa4e195019a35d0967626a13b | https://github.com/pkoretic/pdf417-generator/blob/bcb0af69d822446aa4e195019a35d0967626a13b/lib/bcmath.js#L97-L112 |
33,216 | pkoretic/pdf417-generator | lib/bcmath.js | bcscale | function bcscale(scale) {
scale = parseInt(scale, 10);
if (isNaN(scale)) {
return false;
}
if (scale < 0) {
return false;
}
libbcmath.scale = scale;
return true;
} | javascript | function bcscale(scale) {
scale = parseInt(scale, 10);
if (isNaN(scale)) {
return false;
}
if (scale < 0) {
return false;
}
libbcmath.scale = scale;
return true;
} | [
"function",
"bcscale",
"(",
"scale",
")",
"{",
"scale",
"=",
"parseInt",
"(",
"scale",
",",
"10",
")",
";",
"if",
"(",
"isNaN",
"(",
"scale",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"scale",
"<",
"0",
")",
"{",
"return",
"false",
... | bcscale - Set default scale parameter for all bc math functions
@param int scale The scale factor (0 to infinate)
@return bool | [
"bcscale",
"-",
"Set",
"default",
"scale",
"parameter",
"for",
"all",
"bc",
"math",
"functions"
] | bcb0af69d822446aa4e195019a35d0967626a13b | https://github.com/pkoretic/pdf417-generator/blob/bcb0af69d822446aa4e195019a35d0967626a13b/lib/bcmath.js#L119-L129 |
33,217 | pkoretic/pdf417-generator | lib/bcmath.js | bcdiv | function bcdiv(left_operand, right_operand, scale) {
var first, second, result;
if (typeof(scale) == 'undefined') {
scale = libbcmath.scale;
}
scale = ((scale < 0) ? 0 : scale);
// create objects
first = libbcmath.bc_init_num();
second = libbcmath.bc_init_num();
result = libbcmath.bc_init_num();
first = libbcmath.php_str2num(left_operand.toString());
second = libbcmath.php_str2num(right_operand.toString());
// normalize arguments to same scale.
if (first.n_scale > second.n_scale) second.setScale(first.n_scale);
if (second.n_scale > first.n_scale) first.setScale(second.n_scale);
result = libbcmath.bc_divide(first, second, scale);
if (result === -1) {
// error
throw new Error(11, "(BC) Division by zero");
}
if (result.n_scale > scale) {
result.n_scale = scale;
}
return result.toString();
} | javascript | function bcdiv(left_operand, right_operand, scale) {
var first, second, result;
if (typeof(scale) == 'undefined') {
scale = libbcmath.scale;
}
scale = ((scale < 0) ? 0 : scale);
// create objects
first = libbcmath.bc_init_num();
second = libbcmath.bc_init_num();
result = libbcmath.bc_init_num();
first = libbcmath.php_str2num(left_operand.toString());
second = libbcmath.php_str2num(right_operand.toString());
// normalize arguments to same scale.
if (first.n_scale > second.n_scale) second.setScale(first.n_scale);
if (second.n_scale > first.n_scale) first.setScale(second.n_scale);
result = libbcmath.bc_divide(first, second, scale);
if (result === -1) {
// error
throw new Error(11, "(BC) Division by zero");
}
if (result.n_scale > scale) {
result.n_scale = scale;
}
return result.toString();
} | [
"function",
"bcdiv",
"(",
"left_operand",
",",
"right_operand",
",",
"scale",
")",
"{",
"var",
"first",
",",
"second",
",",
"result",
";",
"if",
"(",
"typeof",
"(",
"scale",
")",
"==",
"'undefined'",
")",
"{",
"scale",
"=",
"libbcmath",
".",
"scale",
"... | bcdiv - Divide two arbitrary precision numbers
@param string left_operand The left operand, as a string
@param string right_operand The right operand, as a string.
@param int [scale] The optional parameter is used to set the number of digits after the decimal place in the result. You can also set the global scale for all functions by using bcscale()
@return string The result as a string | [
"bcdiv",
"-",
"Divide",
"two",
"arbitrary",
"precision",
"numbers"
] | bcb0af69d822446aa4e195019a35d0967626a13b | https://github.com/pkoretic/pdf417-generator/blob/bcb0af69d822446aa4e195019a35d0967626a13b/lib/bcmath.js#L140-L170 |
33,218 | pkoretic/pdf417-generator | lib/bcmath.js | bcmul | function bcmul(left_operand, right_operand, scale) {
var first, second, result;
if (typeof(scale) == 'undefined') {
scale = libbcmath.scale;
}
scale = ((scale < 0) ? 0 : scale);
// create objects
first = libbcmath.bc_init_num();
second = libbcmath.bc_init_num();
result = libbcmath.bc_init_num();
first = libbcmath.php_str2num(left_operand.toString());
second = libbcmath.php_str2num(right_operand.toString());
// normalize arguments to same scale.
if (first.n_scale > second.n_scale) second.setScale(first.n_scale);
if (second.n_scale > first.n_scale) first.setScale(second.n_scale);
result = libbcmath.bc_multiply(first, second, scale);
if (result.n_scale > scale) {
result.n_scale = scale;
}
return result.toString();
} | javascript | function bcmul(left_operand, right_operand, scale) {
var first, second, result;
if (typeof(scale) == 'undefined') {
scale = libbcmath.scale;
}
scale = ((scale < 0) ? 0 : scale);
// create objects
first = libbcmath.bc_init_num();
second = libbcmath.bc_init_num();
result = libbcmath.bc_init_num();
first = libbcmath.php_str2num(left_operand.toString());
second = libbcmath.php_str2num(right_operand.toString());
// normalize arguments to same scale.
if (first.n_scale > second.n_scale) second.setScale(first.n_scale);
if (second.n_scale > first.n_scale) first.setScale(second.n_scale);
result = libbcmath.bc_multiply(first, second, scale);
if (result.n_scale > scale) {
result.n_scale = scale;
}
return result.toString();
} | [
"function",
"bcmul",
"(",
"left_operand",
",",
"right_operand",
",",
"scale",
")",
"{",
"var",
"first",
",",
"second",
",",
"result",
";",
"if",
"(",
"typeof",
"(",
"scale",
")",
"==",
"'undefined'",
")",
"{",
"scale",
"=",
"libbcmath",
".",
"scale",
"... | bcdiv - Multiply two arbitrary precision number
@param string left_operand The left operand, as a string
@param string right_operand The right operand, as a string.
@param int [scale] The optional parameter is used to set the number of digits after the decimal place in the result. You can also set the global scale for all functions by using bcscale()
@return string The result as a string | [
"bcdiv",
"-",
"Multiply",
"two",
"arbitrary",
"precision",
"number"
] | bcb0af69d822446aa4e195019a35d0967626a13b | https://github.com/pkoretic/pdf417-generator/blob/bcb0af69d822446aa4e195019a35d0967626a13b/lib/bcmath.js#L180-L207 |
33,219 | hammerjs/simulator | index.js | ensureAnArray | function ensureAnArray (arr) {
if (Object.prototype.toString.call(arr) === '[object Array]') {
return arr;
} else if (arr === null || arr === void 0) {
return [];
} else {
return [arr];
}
} | javascript | function ensureAnArray (arr) {
if (Object.prototype.toString.call(arr) === '[object Array]') {
return arr;
} else if (arr === null || arr === void 0) {
return [];
} else {
return [arr];
}
} | [
"function",
"ensureAnArray",
"(",
"arr",
")",
"{",
"if",
"(",
"Object",
".",
"prototype",
".",
"toString",
".",
"call",
"(",
"arr",
")",
"===",
"'[object Array]'",
")",
"{",
"return",
"arr",
";",
"}",
"else",
"if",
"(",
"arr",
"===",
"null",
"||",
"a... | return unchanged if array passed, otherwise wrap in an array
@param {Object|Array|Null} arr any object
@return {Array} | [
"return",
"unchanged",
"if",
"array",
"passed",
"otherwise",
"wrap",
"in",
"an",
"array"
] | 31a05ccd9314247d4e404e18e310b9e3b4642056 | https://github.com/hammerjs/simulator/blob/31a05ccd9314247d4e404e18e310b9e3b4642056/index.js#L7-L15 |
33,220 | hammerjs/simulator | index.js | renderTouches | function renderTouches(touches, element) {
touches.forEach(function(touch) {
var el = document.createElement('div');
el.style.width = '20px';
el.style.height = '20px';
el.style.background = 'red';
el.style.position = 'fixed';
el.style.top = touch.y +'px';
el.style.left = touch.x +'px';
el.style.borderRadius = '100%';
el.style.border = 'solid 2px #000';
el.style.zIndex = 6000;
element.appendChild(el);
setTimeout(function() {
el && el.parentNode && el.parentNode.removeChild(el);
el = null;
}, 100);
});
} | javascript | function renderTouches(touches, element) {
touches.forEach(function(touch) {
var el = document.createElement('div');
el.style.width = '20px';
el.style.height = '20px';
el.style.background = 'red';
el.style.position = 'fixed';
el.style.top = touch.y +'px';
el.style.left = touch.x +'px';
el.style.borderRadius = '100%';
el.style.border = 'solid 2px #000';
el.style.zIndex = 6000;
element.appendChild(el);
setTimeout(function() {
el && el.parentNode && el.parentNode.removeChild(el);
el = null;
}, 100);
});
} | [
"function",
"renderTouches",
"(",
"touches",
",",
"element",
")",
"{",
"touches",
".",
"forEach",
"(",
"function",
"(",
"touch",
")",
"{",
"var",
"el",
"=",
"document",
".",
"createElement",
"(",
"'div'",
")",
";",
"el",
".",
"style",
".",
"width",
"="... | render the touches
@param touches
@param element
@param type | [
"render",
"the",
"touches"
] | 31a05ccd9314247d4e404e18e310b9e3b4642056 | https://github.com/hammerjs/simulator/blob/31a05ccd9314247d4e404e18e310b9e3b4642056/index.js#L226-L245 |
33,221 | hammerjs/simulator | index.js | trigger | function trigger(touches, element, type) {
return Simulator.events[Simulator.type].trigger(touches, element, type);
} | javascript | function trigger(touches, element, type) {
return Simulator.events[Simulator.type].trigger(touches, element, type);
} | [
"function",
"trigger",
"(",
"touches",
",",
"element",
",",
"type",
")",
"{",
"return",
"Simulator",
".",
"events",
"[",
"Simulator",
".",
"type",
"]",
".",
"trigger",
"(",
"touches",
",",
"element",
",",
"type",
")",
";",
"}"
] | trigger the touch events
@param touches
@param element
@param type
@returns {*} | [
"trigger",
"the",
"touch",
"events"
] | 31a05ccd9314247d4e404e18e310b9e3b4642056 | https://github.com/hammerjs/simulator/blob/31a05ccd9314247d4e404e18e310b9e3b4642056/index.js#L254-L256 |
33,222 | nathanboktae/mocha-phantomjs-core | mocha-phantomjs-core.js | function(msg, errno) {
if (output && config.file) {
output.close()
}
if (msg) {
stderr.writeLine(msg)
}
return phantom.exit(errno || 1)
} | javascript | function(msg, errno) {
if (output && config.file) {
output.close()
}
if (msg) {
stderr.writeLine(msg)
}
return phantom.exit(errno || 1)
} | [
"function",
"(",
"msg",
",",
"errno",
")",
"{",
"if",
"(",
"output",
"&&",
"config",
".",
"file",
")",
"{",
"output",
".",
"close",
"(",
")",
"}",
"if",
"(",
"msg",
")",
"{",
"stderr",
".",
"writeLine",
"(",
"msg",
")",
"}",
"return",
"phantom",
... | Create and configure the client page | [
"Create",
"and",
"configure",
"the",
"client",
"page"
] | 562125f41e4248a9ae19b91ed2e23a95f92262e9 | https://github.com/nathanboktae/mocha-phantomjs-core/blob/562125f41e4248a9ae19b91ed2e23a95f92262e9/mocha-phantomjs-core.js#L39-L47 | |
33,223 | pkoretic/pdf417-generator | lib/libbcmath.js | function() {
this.n_sign = null; // sign
this.n_len = null; /* (int) The number of digits before the decimal point. */
this.n_scale = null; /* (int) The number of digits after the decimal point. */
//this.n_refs = null; /* (int) The number of pointers to this number. */
//this.n_text = null; /* ?? Linked list for available list. */
this.n_value = null; /* array as value, where 1.23 = [1,2,3] */
this.toString = function() {
var r, tmp;
tmp=this.n_value.join('');
// add minus sign (if applicable) then add the integer part
r = ((this.n_sign == libbcmath.PLUS) ? '' : this.n_sign) + tmp.substr(0, this.n_len);
// if decimal places, add a . and the decimal part
if (this.n_scale > 0) {
r += '.' + tmp.substr(this.n_len, this.n_scale);
}
return r;
};
this.setScale = function(newScale) {
while (this.n_scale < newScale) {
this.n_value.push(0);
this.n_scale++;
}
while (this.n_scale > newScale) {
this.n_value.pop();
this.n_scale--;
}
return this;
}
} | javascript | function() {
this.n_sign = null; // sign
this.n_len = null; /* (int) The number of digits before the decimal point. */
this.n_scale = null; /* (int) The number of digits after the decimal point. */
//this.n_refs = null; /* (int) The number of pointers to this number. */
//this.n_text = null; /* ?? Linked list for available list. */
this.n_value = null; /* array as value, where 1.23 = [1,2,3] */
this.toString = function() {
var r, tmp;
tmp=this.n_value.join('');
// add minus sign (if applicable) then add the integer part
r = ((this.n_sign == libbcmath.PLUS) ? '' : this.n_sign) + tmp.substr(0, this.n_len);
// if decimal places, add a . and the decimal part
if (this.n_scale > 0) {
r += '.' + tmp.substr(this.n_len, this.n_scale);
}
return r;
};
this.setScale = function(newScale) {
while (this.n_scale < newScale) {
this.n_value.push(0);
this.n_scale++;
}
while (this.n_scale > newScale) {
this.n_value.pop();
this.n_scale--;
}
return this;
}
} | [
"function",
"(",
")",
"{",
"this",
".",
"n_sign",
"=",
"null",
";",
"// sign",
"this",
".",
"n_len",
"=",
"null",
";",
"/* (int) The number of digits before the decimal point. */",
"this",
".",
"n_scale",
"=",
"null",
";",
"/* (int) The number of digits after the deci... | default scale
Basic number structure | [
"default",
"scale",
"Basic",
"number",
"structure"
] | bcb0af69d822446aa4e195019a35d0967626a13b | https://github.com/pkoretic/pdf417-generator/blob/bcb0af69d822446aa4e195019a35d0967626a13b/lib/libbcmath.js#L31-L64 | |
33,224 | pkoretic/pdf417-generator | lib/libbcmath.js | function(str) {
var p;
p = str.indexOf('.');
if (p==-1) {
return libbcmath.bc_str2num(str, 0);
} else {
return libbcmath.bc_str2num(str, (str.length-p));
}
} | javascript | function(str) {
var p;
p = str.indexOf('.');
if (p==-1) {
return libbcmath.bc_str2num(str, 0);
} else {
return libbcmath.bc_str2num(str, (str.length-p));
}
} | [
"function",
"(",
"str",
")",
"{",
"var",
"p",
";",
"p",
"=",
"str",
".",
"indexOf",
"(",
"'.'",
")",
";",
"if",
"(",
"p",
"==",
"-",
"1",
")",
"{",
"return",
"libbcmath",
".",
"bc_str2num",
"(",
"str",
",",
"0",
")",
";",
"}",
"else",
"{",
... | Convert to bc_num detecting scale | [
"Convert",
"to",
"bc_num",
"detecting",
"scale"
] | bcb0af69d822446aa4e195019a35d0967626a13b | https://github.com/pkoretic/pdf417-generator/blob/bcb0af69d822446aa4e195019a35d0967626a13b/lib/libbcmath.js#L105-L114 | |
33,225 | pkoretic/pdf417-generator | lib/libbcmath.js | function(r, ptr, chr, len) {
var i;
for (i=0;i<len;i++) {
r[ptr+i] = chr;
}
} | javascript | function(r, ptr, chr, len) {
var i;
for (i=0;i<len;i++) {
r[ptr+i] = chr;
}
} | [
"function",
"(",
"r",
",",
"ptr",
",",
"chr",
",",
"len",
")",
"{",
"var",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"r",
"[",
"ptr",
"+",
"i",
"]",
"=",
"chr",
";",
"}",
"}"
] | replicate c function
@param array return (by reference)
@param string char to fill
@param int length to fill | [
"replicate",
"c",
"function"
] | bcb0af69d822446aa4e195019a35d0967626a13b | https://github.com/pkoretic/pdf417-generator/blob/bcb0af69d822446aa4e195019a35d0967626a13b/lib/libbcmath.js#L256-L261 | |
33,226 | pkoretic/pdf417-generator | lib/libbcmath.js | function(num) {
var count; // int
var nptr; // int
/* Quick check. */
//if (num == BCG(_zero_)) return TRUE;
/* Initialize */
count = num.n_len + num.n_scale;
nptr = 0; //num->n_value;
/* The check */
while ((count > 0) && (num.n_value[nptr++] === 0)) {
count--;
}
if (count !== 0) {
return false;
} else {
return true;
}
} | javascript | function(num) {
var count; // int
var nptr; // int
/* Quick check. */
//if (num == BCG(_zero_)) return TRUE;
/* Initialize */
count = num.n_len + num.n_scale;
nptr = 0; //num->n_value;
/* The check */
while ((count > 0) && (num.n_value[nptr++] === 0)) {
count--;
}
if (count !== 0) {
return false;
} else {
return true;
}
} | [
"function",
"(",
"num",
")",
"{",
"var",
"count",
";",
"// int",
"var",
"nptr",
";",
"// int",
"/* Quick check. */",
"//if (num == BCG(_zero_)) return TRUE;",
"/* Initialize */",
"count",
"=",
"num",
".",
"n_len",
"+",
"num",
".",
"n_scale",
";",
"nptr",
"=",
... | Determine if the number specified is zero or not
@param bc_num num number to check
@return boolean true when zero, false when not zero. | [
"Determine",
"if",
"the",
"number",
"specified",
"is",
"zero",
"or",
"not"
] | bcb0af69d822446aa4e195019a35d0967626a13b | https://github.com/pkoretic/pdf417-generator/blob/bcb0af69d822446aa4e195019a35d0967626a13b/lib/libbcmath.js#L282-L303 | |
33,227 | Suor/pg-bricks | index.js | Conf | function Conf(config, _pg) {
if (typeof config === 'string') config = {connectionString: config};
this._config = config;
this._pg = _pg || pg;
this._pool = this._pg.Pool(config);
} | javascript | function Conf(config, _pg) {
if (typeof config === 'string') config = {connectionString: config};
this._config = config;
this._pg = _pg || pg;
this._pool = this._pg.Pool(config);
} | [
"function",
"Conf",
"(",
"config",
",",
"_pg",
")",
"{",
"if",
"(",
"typeof",
"config",
"===",
"'string'",
")",
"config",
"=",
"{",
"connectionString",
":",
"config",
"}",
";",
"this",
".",
"_config",
"=",
"config",
";",
"this",
".",
"_pg",
"=",
"_pg... | A Conf object | [
"A",
"Conf",
"object"
] | 023538ab7ece9c0abba1102db9a437820d1173df | https://github.com/Suor/pg-bricks/blob/023538ab7ece9c0abba1102db9a437820d1173df/index.js#L154-L159 |
33,228 | remy/twitterlib | twitterlib.js | function (tweets, search, includeHighlighted) {
var updated = [], tmp, i = 0;
if (typeof search == 'string') {
search = this.format(search);
}
for (i = 0; i < tweets.length; i++) {
if (this.match(tweets[i], search, includeHighlighted)) {
updated.push(tweets[i]);
}
}
return updated;
} | javascript | function (tweets, search, includeHighlighted) {
var updated = [], tmp, i = 0;
if (typeof search == 'string') {
search = this.format(search);
}
for (i = 0; i < tweets.length; i++) {
if (this.match(tweets[i], search, includeHighlighted)) {
updated.push(tweets[i]);
}
}
return updated;
} | [
"function",
"(",
"tweets",
",",
"search",
",",
"includeHighlighted",
")",
"{",
"var",
"updated",
"=",
"[",
"]",
",",
"tmp",
",",
"i",
"=",
"0",
";",
"if",
"(",
"typeof",
"search",
"==",
"'string'",
")",
"{",
"search",
"=",
"this",
".",
"format",
"(... | tweets typeof Array | [
"tweets",
"typeof",
"Array"
] | ccfa3c43a44e175d258f9773a7f76196a107e527 | https://github.com/remy/twitterlib/blob/ccfa3c43a44e175d258f9773a7f76196a107e527/twitterlib.js#L350-L364 | |
33,229 | ahmed-wagdi/angular-joyride | js/joyride.js | function(){
angular.element(document.querySelector('body')).removeClass('jr_active jr_overlay_show');
removeJoyride();
scope.joyride.current = 0;
scope.joyride.transitionStep = true;
if (typeof scope.joyride.config.onFinish === "function") {
scope.joyride.config.onFinish();
}
if (document.querySelector(".jr_target")) {
angular.element(document.querySelector(".jr_target")).removeClass('jr_target');
}
} | javascript | function(){
angular.element(document.querySelector('body')).removeClass('jr_active jr_overlay_show');
removeJoyride();
scope.joyride.current = 0;
scope.joyride.transitionStep = true;
if (typeof scope.joyride.config.onFinish === "function") {
scope.joyride.config.onFinish();
}
if (document.querySelector(".jr_target")) {
angular.element(document.querySelector(".jr_target")).removeClass('jr_target');
}
} | [
"function",
"(",
")",
"{",
"angular",
".",
"element",
"(",
"document",
".",
"querySelector",
"(",
"'body'",
")",
")",
".",
"removeClass",
"(",
"'jr_active jr_overlay_show'",
")",
";",
"removeJoyride",
"(",
")",
";",
"scope",
".",
"joyride",
".",
"current",
... | Reset variables after joyride ends | [
"Reset",
"variables",
"after",
"joyride",
"ends"
] | e2b48d7ceea9d3480ba7c619c7ac71fb5c1fc6f7 | https://github.com/ahmed-wagdi/angular-joyride/blob/e2b48d7ceea9d3480ba7c619c7ac71fb5c1fc6f7/js/joyride.js#L243-L254 | |
33,230 | dtoubelis/sails-cassandra | lib/adapter.js | function (connection, collections, cb) {
if (!connection.identity) return cb(Errors.IdentityMissing);
if (connections[connection.identity]) return cb(Errors.IdentityDuplicate);
// Store the connection
connections[connection.identity] = {
config: connection,
collections: collections,
client: null
};
// connect to database
new Connection(connection, function (err, client) {
if (err) return cb(err);
connections[connection.identity].client = client;
// Build up a registry of collections
Object.keys(collections).forEach(function (key) {
connections[connection.identity].collections[key] = new Collection(collections[key], client);
});
// execute callback
cb();
});
} | javascript | function (connection, collections, cb) {
if (!connection.identity) return cb(Errors.IdentityMissing);
if (connections[connection.identity]) return cb(Errors.IdentityDuplicate);
// Store the connection
connections[connection.identity] = {
config: connection,
collections: collections,
client: null
};
// connect to database
new Connection(connection, function (err, client) {
if (err) return cb(err);
connections[connection.identity].client = client;
// Build up a registry of collections
Object.keys(collections).forEach(function (key) {
connections[connection.identity].collections[key] = new Collection(collections[key], client);
});
// execute callback
cb();
});
} | [
"function",
"(",
"connection",
",",
"collections",
",",
"cb",
")",
"{",
"if",
"(",
"!",
"connection",
".",
"identity",
")",
"return",
"cb",
"(",
"Errors",
".",
"IdentityMissing",
")",
";",
"if",
"(",
"connections",
"[",
"connection",
".",
"identity",
"]"... | Register a connection and the collections assigned to it.
@param {Connection} connection
@param {Object} collections
@param {Function} cb | [
"Register",
"a",
"connection",
"and",
"the",
"collections",
"assigned",
"to",
"it",
"."
] | 78c3f5437f92cf0fdc20b7dac819e6c51b56331d | https://github.com/dtoubelis/sails-cassandra/blob/78c3f5437f92cf0fdc20b7dac819e6c51b56331d/lib/adapter.js#L57-L86 | |
33,231 | dtoubelis/sails-cassandra | lib/adapter.js | function(cb) {
var collection = connectionObject.collections[collectionName];
if (!collection) return cb(Errors.CollectionNotRegistered);
collection.dropTable(function(err) {
// ignore "table does not exist" error
if (err && err.code === 8704) return cb();
if (err) return cb(err);
cb();
});
} | javascript | function(cb) {
var collection = connectionObject.collections[collectionName];
if (!collection) return cb(Errors.CollectionNotRegistered);
collection.dropTable(function(err) {
// ignore "table does not exist" error
if (err && err.code === 8704) return cb();
if (err) return cb(err);
cb();
});
} | [
"function",
"(",
"cb",
")",
"{",
"var",
"collection",
"=",
"connectionObject",
".",
"collections",
"[",
"collectionName",
"]",
";",
"if",
"(",
"!",
"collection",
")",
"return",
"cb",
"(",
"Errors",
".",
"CollectionNotRegistered",
")",
";",
"collection",
".",... | drop the main table | [
"drop",
"the",
"main",
"table"
] | 78c3f5437f92cf0fdc20b7dac819e6c51b56331d | https://github.com/dtoubelis/sails-cassandra/blob/78c3f5437f92cf0fdc20b7dac819e6c51b56331d/lib/adapter.js#L197-L208 | |
33,232 | Magillem/generator-jhipster-pages | generators/app/files.js | addDropdownToMenu | function addDropdownToMenu(dropdownName, routerName, glyphiconName, enableTranslation, clientFramework) {
let navbarPath;
try {
if (clientFramework === 'angular1') {
navbarPath = `${CLIENT_MAIN_SRC_DIR}app/layouts/navbar/navbar.html`;
jhipsterUtils.rewriteFile({
file: navbarPath,
needle: 'jhipster-needle-add-element-to-menu',
splicable: [ `<li ng-class="{active: vm.$state.includes('${dropdownName}')}" ng-switch-when="true" uib-dropdown class="dropdown pointer">
<a class="dropdown-toggle" uib-dropdown-toggle href="" id="${dropdownName}-menu">
<span>
<span class="glyphicon glyphicon-${glyphiconName}"></span>
<span class="hidden-sm" data-translate="global.menu.${dropdownName}.main">
${dropdownName}
</span>
<b class="caret"></b>
</span>
</a>
<ul class="dropdown-menu" uib-dropdown-menu>
<li ui-sref-active="active">
<a ui-sref="${routerName}" ng-click="vm.collapseNavbar()">
<span class="glyphicon glyphicon-${glyphiconName}"></span>
<span${enableTranslation ? ` data-translate="global.menu.${routerName}"` : ''}>${_.startCase(routerName)}</span>
</a>
</li>
<!-- jhipster-needle-add-element-to-${dropdownName} - JHipster will add elements to the ${dropdownName} here -->
</ul>
</li>`
]
}, this);
} else {
navbarPath = `${CLIENT_MAIN_SRC_DIR}app/layouts/navbar/navbar.component.html`;
jhipsterUtils.rewriteFile({
file: navbarPath,
needle: 'jhipster-needle-add-element-to-menu',
splicable: [`<li *ngSwitchCase="true" ngbDropdown class="nav-item dropdown pointer">
<a class="nav-link dropdown-toggle" routerLinkActive="active" ngbDropdownToggle href="javascript:void(0);" id="${dropdownName}-menu">
<span>
<i class="fa fa-${glyphiconName}" aria-hidden="true"></i>
<span>${dropdownName}</span>
</span>
</a>
<ul class="dropdown-menu" ngbDropdownMenu>
<li>
<a class="dropdown-item" routerLink="${routerName}" routerLinkActive="active" [routerLinkActiveOptions]="{ exact: true }" (click)="collapseNavbar()">
<i class="fa fa-${glyphiconName}" aria-hidden="true"></i>
<span${enableTranslation ? ` jhiTranslate="global.menu.${routerName}"` : ''}>${_.startCase(routerName)}</span>
</a>
</li>
<!-- jhipster-needle-add-element-to-${dropdownName} - JHipster will add elements to the ${dropdownName} here -->
</ul>
</li>`
]
}, this);
}
} catch (e) {
this.log(`${chalk.yellow('\nUnable to find ') + navbarPath + chalk.yellow(' or missing required jhipster-needle. Reference to ') + dropdownName} ${chalk.yellow('not added to menu.\n')}`);
this.debug('Error:', e);
this.log('Error:', e);
}
} | javascript | function addDropdownToMenu(dropdownName, routerName, glyphiconName, enableTranslation, clientFramework) {
let navbarPath;
try {
if (clientFramework === 'angular1') {
navbarPath = `${CLIENT_MAIN_SRC_DIR}app/layouts/navbar/navbar.html`;
jhipsterUtils.rewriteFile({
file: navbarPath,
needle: 'jhipster-needle-add-element-to-menu',
splicable: [ `<li ng-class="{active: vm.$state.includes('${dropdownName}')}" ng-switch-when="true" uib-dropdown class="dropdown pointer">
<a class="dropdown-toggle" uib-dropdown-toggle href="" id="${dropdownName}-menu">
<span>
<span class="glyphicon glyphicon-${glyphiconName}"></span>
<span class="hidden-sm" data-translate="global.menu.${dropdownName}.main">
${dropdownName}
</span>
<b class="caret"></b>
</span>
</a>
<ul class="dropdown-menu" uib-dropdown-menu>
<li ui-sref-active="active">
<a ui-sref="${routerName}" ng-click="vm.collapseNavbar()">
<span class="glyphicon glyphicon-${glyphiconName}"></span>
<span${enableTranslation ? ` data-translate="global.menu.${routerName}"` : ''}>${_.startCase(routerName)}</span>
</a>
</li>
<!-- jhipster-needle-add-element-to-${dropdownName} - JHipster will add elements to the ${dropdownName} here -->
</ul>
</li>`
]
}, this);
} else {
navbarPath = `${CLIENT_MAIN_SRC_DIR}app/layouts/navbar/navbar.component.html`;
jhipsterUtils.rewriteFile({
file: navbarPath,
needle: 'jhipster-needle-add-element-to-menu',
splicable: [`<li *ngSwitchCase="true" ngbDropdown class="nav-item dropdown pointer">
<a class="nav-link dropdown-toggle" routerLinkActive="active" ngbDropdownToggle href="javascript:void(0);" id="${dropdownName}-menu">
<span>
<i class="fa fa-${glyphiconName}" aria-hidden="true"></i>
<span>${dropdownName}</span>
</span>
</a>
<ul class="dropdown-menu" ngbDropdownMenu>
<li>
<a class="dropdown-item" routerLink="${routerName}" routerLinkActive="active" [routerLinkActiveOptions]="{ exact: true }" (click)="collapseNavbar()">
<i class="fa fa-${glyphiconName}" aria-hidden="true"></i>
<span${enableTranslation ? ` jhiTranslate="global.menu.${routerName}"` : ''}>${_.startCase(routerName)}</span>
</a>
</li>
<!-- jhipster-needle-add-element-to-${dropdownName} - JHipster will add elements to the ${dropdownName} here -->
</ul>
</li>`
]
}, this);
}
} catch (e) {
this.log(`${chalk.yellow('\nUnable to find ') + navbarPath + chalk.yellow(' or missing required jhipster-needle. Reference to ') + dropdownName} ${chalk.yellow('not added to menu.\n')}`);
this.debug('Error:', e);
this.log('Error:', e);
}
} | [
"function",
"addDropdownToMenu",
"(",
"dropdownName",
",",
"routerName",
",",
"glyphiconName",
",",
"enableTranslation",
",",
"clientFramework",
")",
"{",
"let",
"navbarPath",
";",
"try",
"{",
"if",
"(",
"clientFramework",
"===",
"'angular1'",
")",
"{",
"navbarPat... | Add a new dropdown element, at the root of the menu.
@param {string} dropdownName - The name of the AngularJS router that is added to the menu.
@param {string} glyphiconName - The name of the Glyphicon (from Bootstrap) that will be displayed.
@param {boolean} enableTranslation - If translations are enabled or not
@param {string} clientFramework - The name of the client framework | [
"Add",
"a",
"new",
"dropdown",
"element",
"at",
"the",
"root",
"of",
"the",
"menu",
"."
] | 276dc08adc28626705fa251709def03de61a10ac | https://github.com/Magillem/generator-jhipster-pages/blob/276dc08adc28626705fa251709def03de61a10ac/generators/app/files.js#L463-L523 |
33,233 | Magillem/generator-jhipster-pages | generators/app/files.js | addPageSetsModule | function addPageSetsModule(clientFramework) {
let appModulePath;
try {
if (clientFramework !== 'angular1') {
appModulePath = `${CLIENT_MAIN_SRC_DIR}app/app.module.ts`;
const fullPath = path.join(process.cwd(), appModulePath);
let args = {
file: appModulePath
};
args.haystack = this.fs.read(fullPath);
args.needle = `import { ${this.angularXAppName}EntityModule } from './entities/entity.module';`;
args.splicable = [`import { ${this.angularXAppName}PageSetsModule } from './pages/page-sets.module';`]
args.haystack = jhipsterUtils.rewrite(args);
args.needle = `${this.angularXAppName}AccountModule,`;
args.splicable = [`${this.angularXAppName}PageSetsModule,`]
args.haystack = jhipsterUtils.rewrite(args);
this.fs.write(fullPath, args.haystack);
}
} catch (e) {
this.log(`${chalk.yellow('\nUnable to find ') + appModulePath + chalk.yellow('. Reference to PageSets module not added to App module.\n')}`);
this.log('Error:', e);
}
} | javascript | function addPageSetsModule(clientFramework) {
let appModulePath;
try {
if (clientFramework !== 'angular1') {
appModulePath = `${CLIENT_MAIN_SRC_DIR}app/app.module.ts`;
const fullPath = path.join(process.cwd(), appModulePath);
let args = {
file: appModulePath
};
args.haystack = this.fs.read(fullPath);
args.needle = `import { ${this.angularXAppName}EntityModule } from './entities/entity.module';`;
args.splicable = [`import { ${this.angularXAppName}PageSetsModule } from './pages/page-sets.module';`]
args.haystack = jhipsterUtils.rewrite(args);
args.needle = `${this.angularXAppName}AccountModule,`;
args.splicable = [`${this.angularXAppName}PageSetsModule,`]
args.haystack = jhipsterUtils.rewrite(args);
this.fs.write(fullPath, args.haystack);
}
} catch (e) {
this.log(`${chalk.yellow('\nUnable to find ') + appModulePath + chalk.yellow('. Reference to PageSets module not added to App module.\n')}`);
this.log('Error:', e);
}
} | [
"function",
"addPageSetsModule",
"(",
"clientFramework",
")",
"{",
"let",
"appModulePath",
";",
"try",
"{",
"if",
"(",
"clientFramework",
"!==",
"'angular1'",
")",
"{",
"appModulePath",
"=",
"`",
"${",
"CLIENT_MAIN_SRC_DIR",
"}",
"`",
";",
"const",
"fullPath",
... | Add pageSets module to app module.
@param {string} clientFramework - The name of the client framework | [
"Add",
"pageSets",
"module",
"to",
"app",
"module",
"."
] | 276dc08adc28626705fa251709def03de61a10ac | https://github.com/Magillem/generator-jhipster-pages/blob/276dc08adc28626705fa251709def03de61a10ac/generators/app/files.js#L575-L603 |
33,234 | senecajs/seneca-auth | lib/express-auth.js | trigger_service_login | function trigger_service_login (msg, respond) {
var seneca = this
if (!msg.user) {
return respond(null, {ok: false, why: 'no-user'})
}
var user_data = msg.user
var q = {}
if (user_data.identifier) {
q[msg.service + '_id'] = user_data.identifier
user_data[msg.service + '_id'] = user_data.identifier
}
else {
return respond(null, {ok: false, why: 'no-identifier'})
}
seneca.act("role: 'user', get: 'user'", q, function (err, data) {
if (err) return respond(null, {ok: false, why: 'no-identifier'})
if (!data.ok) return respond(null, {ok: false, why: data.why})
var user = data.user
if (!user) {
seneca.act("role:'user',cmd:'register'", user_data, function (err, out) {
if (err) {
return respond(null, {ok: false, why: err})
}
respond(null, out.user)
})
}
else {
seneca.act("role:'user',cmd:'update'", user_data, function (err, out) {
if (err) {
return respond(null, {ok: false, why: err})
}
respond(null, out.user)
})
}
})
} | javascript | function trigger_service_login (msg, respond) {
var seneca = this
if (!msg.user) {
return respond(null, {ok: false, why: 'no-user'})
}
var user_data = msg.user
var q = {}
if (user_data.identifier) {
q[msg.service + '_id'] = user_data.identifier
user_data[msg.service + '_id'] = user_data.identifier
}
else {
return respond(null, {ok: false, why: 'no-identifier'})
}
seneca.act("role: 'user', get: 'user'", q, function (err, data) {
if (err) return respond(null, {ok: false, why: 'no-identifier'})
if (!data.ok) return respond(null, {ok: false, why: data.why})
var user = data.user
if (!user) {
seneca.act("role:'user',cmd:'register'", user_data, function (err, out) {
if (err) {
return respond(null, {ok: false, why: err})
}
respond(null, out.user)
})
}
else {
seneca.act("role:'user',cmd:'update'", user_data, function (err, out) {
if (err) {
return respond(null, {ok: false, why: err})
}
respond(null, out.user)
})
}
})
} | [
"function",
"trigger_service_login",
"(",
"msg",
",",
"respond",
")",
"{",
"var",
"seneca",
"=",
"this",
"if",
"(",
"!",
"msg",
".",
"user",
")",
"{",
"return",
"respond",
"(",
"null",
",",
"{",
"ok",
":",
"false",
",",
"why",
":",
"'no-user'",
"}",
... | LOGOUT END default service login trigger | [
"LOGOUT",
"END",
"default",
"service",
"login",
"trigger"
] | 537716d2a07c9be6e3aa5ae6529929704c97338b | https://github.com/senecajs/seneca-auth/blob/537716d2a07c9be6e3aa5ae6529929704c97338b/lib/express-auth.js#L278-L320 |
33,235 | JedWatson/react-component-gulp-tasks | index.js | readPackageJSON | function readPackageJSON () {
var pkg = JSON.parse(require('fs').readFileSync('./package.json'));
var dependencies = pkg.dependencies ? Object.keys(pkg.dependencies) : [];
var peerDependencies = pkg.peerDependencies ? Object.keys(pkg.peerDependencies) : [];
return {
name: pkg.name,
deps: dependencies.concat(peerDependencies),
aliasify: pkg.aliasify
};
} | javascript | function readPackageJSON () {
var pkg = JSON.parse(require('fs').readFileSync('./package.json'));
var dependencies = pkg.dependencies ? Object.keys(pkg.dependencies) : [];
var peerDependencies = pkg.peerDependencies ? Object.keys(pkg.peerDependencies) : [];
return {
name: pkg.name,
deps: dependencies.concat(peerDependencies),
aliasify: pkg.aliasify
};
} | [
"function",
"readPackageJSON",
"(",
")",
"{",
"var",
"pkg",
"=",
"JSON",
".",
"parse",
"(",
"require",
"(",
"'fs'",
")",
".",
"readFileSync",
"(",
"'./package.json'",
")",
")",
";",
"var",
"dependencies",
"=",
"pkg",
".",
"dependencies",
"?",
"Object",
"... | Extract package.json metadata | [
"Extract",
"package",
".",
"json",
"metadata"
] | 8a6d636b72fcb10ecd9d633343193923d7447d8d | https://github.com/JedWatson/react-component-gulp-tasks/blob/8a6d636b72fcb10ecd9d633343193923d7447d8d/index.js#L6-L16 |
33,236 | JedWatson/react-component-gulp-tasks | index.js | initTasks | function initTasks (gulp, config) {
var pkg = readPackageJSON();
var name = capitalize(camelCase(config.component.pkgName || pkg.name));
config = defaults(config, { aliasify: pkg.aliasify });
config.component = defaults(config.component, {
pkgName: pkg.name,
dependencies: pkg.deps,
name: name,
src: 'src',
lib: 'lib',
dist: 'dist',
file: (config.component.name || name) + '.js'
});
if (config.example) {
if (config.example === true) config.example = {};
defaults(config.example, {
src: 'example/src',
dist: 'example/dist',
files: ['index.html'],
scripts: ['example.js'],
less: ['example.less']
});
}
require('./tasks/bump')(gulp, config);
require('./tasks/dev')(gulp, config);
require('./tasks/dist')(gulp, config);
require('./tasks/release')(gulp, config);
var buildTasks = ['build:dist'];
var cleanTasks = ['clean:dist'];
if (config.component.lib) {
require('./tasks/lib')(gulp, config);
buildTasks.push('build:lib');
cleanTasks.push('clean:lib');
}
if (config.example) {
require('./tasks/examples')(gulp, config);
buildTasks.push('build:examples');
cleanTasks.push('clean:examples');
}
gulp.task('build', buildTasks);
gulp.task('clean', cleanTasks);
} | javascript | function initTasks (gulp, config) {
var pkg = readPackageJSON();
var name = capitalize(camelCase(config.component.pkgName || pkg.name));
config = defaults(config, { aliasify: pkg.aliasify });
config.component = defaults(config.component, {
pkgName: pkg.name,
dependencies: pkg.deps,
name: name,
src: 'src',
lib: 'lib',
dist: 'dist',
file: (config.component.name || name) + '.js'
});
if (config.example) {
if (config.example === true) config.example = {};
defaults(config.example, {
src: 'example/src',
dist: 'example/dist',
files: ['index.html'],
scripts: ['example.js'],
less: ['example.less']
});
}
require('./tasks/bump')(gulp, config);
require('./tasks/dev')(gulp, config);
require('./tasks/dist')(gulp, config);
require('./tasks/release')(gulp, config);
var buildTasks = ['build:dist'];
var cleanTasks = ['clean:dist'];
if (config.component.lib) {
require('./tasks/lib')(gulp, config);
buildTasks.push('build:lib');
cleanTasks.push('clean:lib');
}
if (config.example) {
require('./tasks/examples')(gulp, config);
buildTasks.push('build:examples');
cleanTasks.push('clean:examples');
}
gulp.task('build', buildTasks);
gulp.task('clean', cleanTasks);
} | [
"function",
"initTasks",
"(",
"gulp",
",",
"config",
")",
"{",
"var",
"pkg",
"=",
"readPackageJSON",
"(",
")",
";",
"var",
"name",
"=",
"capitalize",
"(",
"camelCase",
"(",
"config",
".",
"component",
".",
"pkgName",
"||",
"pkg",
".",
"name",
")",
")",... | This package exports a function that binds tasks to a gulp instance
based on the provided config. | [
"This",
"package",
"exports",
"a",
"function",
"that",
"binds",
"tasks",
"to",
"a",
"gulp",
"instance",
"based",
"on",
"the",
"provided",
"config",
"."
] | 8a6d636b72fcb10ecd9d633343193923d7447d8d | https://github.com/JedWatson/react-component-gulp-tasks/blob/8a6d636b72fcb10ecd9d633343193923d7447d8d/index.js#L22-L71 |
33,237 | stdarg/tcp-port-used | index.js | makeOptionsObj | function makeOptionsObj(port, host, inUse, retryTimeMs, timeOutMs) {
var opts = {};
opts.port = port;
opts.host = host;
opts.inUse = inUse;
opts.retryTimeMs = retryTimeMs;
opts.timeOutMs = timeOutMs;
return opts;
} | javascript | function makeOptionsObj(port, host, inUse, retryTimeMs, timeOutMs) {
var opts = {};
opts.port = port;
opts.host = host;
opts.inUse = inUse;
opts.retryTimeMs = retryTimeMs;
opts.timeOutMs = timeOutMs;
return opts;
} | [
"function",
"makeOptionsObj",
"(",
"port",
",",
"host",
",",
"inUse",
",",
"retryTimeMs",
",",
"timeOutMs",
")",
"{",
"var",
"opts",
"=",
"{",
"}",
";",
"opts",
".",
"port",
"=",
"port",
";",
"opts",
".",
"host",
"=",
"host",
";",
"opts",
".",
"inU... | Creates an options object from all the possible arguments
@private
@param {Number} port a valid TCP port number
@param {String} host The DNS name or IP address.
@param {Boolean} status The desired in use status to wait for: false === not in use, true === in use
@param {Number} retryTimeMs the retry interval in milliseconds - defaultis is 200ms
@param {Number} timeOutMs the amount of time to wait until port is free default is 1000ms
@return {Object} An options object with all the above parameters as properties. | [
"Creates",
"an",
"options",
"object",
"from",
"all",
"the",
"possible",
"arguments"
] | 23356dede7d2bb198cc07f47215d763c225a96c8 | https://github.com/stdarg/tcp-port-used/blob/23356dede7d2bb198cc07f47215d763c225a96c8/index.js#L47-L55 |
33,238 | senecajs/seneca-auth | lib/hapi-auth.js | cmd_logout | function cmd_logout (msg, respond) {
var req = msg.req$
// get token from request
req.seneca.act("role: 'auth', get: 'token'", {tokenkey: options.tokenkey}, function (err, clienttoken) {
if (err) {
return req.seneca.act('role: auth, do: respond', {err: err, action: 'logout', req: req}, respond)
}
if (!clienttoken) {
return req.seneca.act('role: auth, do: respond', {err: err, action: 'logout', req: req}, respond)
}
clienttoken = clienttoken.token
// delete token
req.seneca.act("role: 'auth', set: 'token'", {tokenkey: options.tokenkey}, function (err) {
if (err) {
return req.seneca.act('role: auth, do: respond', {err: err, action: 'logout', req: req}, respond)
}
req.seneca.act("role:'user',cmd:'logout'", {token: clienttoken}, function (err) {
if (err) {
req.seneca.log('error ', err)
}
req.cookieAuth.clear()
delete req.seneca.user
delete req.seneca.login
return req.seneca.act('role: auth, do: respond', {err: err, action: 'logout', req: req}, respond)
})
})
})
} | javascript | function cmd_logout (msg, respond) {
var req = msg.req$
// get token from request
req.seneca.act("role: 'auth', get: 'token'", {tokenkey: options.tokenkey}, function (err, clienttoken) {
if (err) {
return req.seneca.act('role: auth, do: respond', {err: err, action: 'logout', req: req}, respond)
}
if (!clienttoken) {
return req.seneca.act('role: auth, do: respond', {err: err, action: 'logout', req: req}, respond)
}
clienttoken = clienttoken.token
// delete token
req.seneca.act("role: 'auth', set: 'token'", {tokenkey: options.tokenkey}, function (err) {
if (err) {
return req.seneca.act('role: auth, do: respond', {err: err, action: 'logout', req: req}, respond)
}
req.seneca.act("role:'user',cmd:'logout'", {token: clienttoken}, function (err) {
if (err) {
req.seneca.log('error ', err)
}
req.cookieAuth.clear()
delete req.seneca.user
delete req.seneca.login
return req.seneca.act('role: auth, do: respond', {err: err, action: 'logout', req: req}, respond)
})
})
})
} | [
"function",
"cmd_logout",
"(",
"msg",
",",
"respond",
")",
"{",
"var",
"req",
"=",
"msg",
".",
"req$",
"// get token from request",
"req",
".",
"seneca",
".",
"act",
"(",
"\"role: 'auth', get: 'token'\"",
",",
"{",
"tokenkey",
":",
"options",
".",
"tokenkey",
... | LOGIN END LOGOUT START | [
"LOGIN",
"END",
"LOGOUT",
"START"
] | 537716d2a07c9be6e3aa5ae6529929704c97338b | https://github.com/senecajs/seneca-auth/blob/537716d2a07c9be6e3aa5ae6529929704c97338b/lib/hapi-auth.js#L146-L177 |
33,239 | jonschlinkert/extract-comments | index.js | extract | function extract(str, options, tranformFn) {
let extractor = new Extractor(options, tranformFn);
return extractor.extract(str);
} | javascript | function extract(str, options, tranformFn) {
let extractor = new Extractor(options, tranformFn);
return extractor.extract(str);
} | [
"function",
"extract",
"(",
"str",
",",
"options",
",",
"tranformFn",
")",
"{",
"let",
"extractor",
"=",
"new",
"Extractor",
"(",
"options",
",",
"tranformFn",
")",
";",
"return",
"extractor",
".",
"extract",
"(",
"str",
")",
";",
"}"
] | Extract comments from the given `string`.
```js
const extract = require('extract-comments');
console.log(extract(string, options));
```
@param {String} `string`
@param {Object} `options` Pass `first: true` to return after the first comment is found.
@param {Function} `tranformFn` (optional) Tranform function to modify each comment
@return {Array} Returns an array of comment objects
@api public | [
"Extract",
"comments",
"from",
"the",
"given",
"string",
"."
] | cc42e9f52a2502c6654d435e91e41ebebfbef4b2 | https://github.com/jonschlinkert/extract-comments/blob/cc42e9f52a2502c6654d435e91e41ebebfbef4b2/index.js#L26-L29 |
33,240 | stefanjudis/grunt-photobox | tasks/lib/photobox.js | function( grunt, options, callback ) {
this.callback = callback;
this.diffCount = 0;
this.grunt = grunt;
this.options = options;
this.options.indexPath = this.getIndexPath();
this.pictureCount = 0;
if ( typeof options.template === 'string' ) {
this.template = options.template;
} else if ( typeof options.template === 'object' ) {
this.template = options.template.name;
}
this.movePictures();
this.pictures = this.getPreparedPictures();
} | javascript | function( grunt, options, callback ) {
this.callback = callback;
this.diffCount = 0;
this.grunt = grunt;
this.options = options;
this.options.indexPath = this.getIndexPath();
this.pictureCount = 0;
if ( typeof options.template === 'string' ) {
this.template = options.template;
} else if ( typeof options.template === 'object' ) {
this.template = options.template.name;
}
this.movePictures();
this.pictures = this.getPreparedPictures();
} | [
"function",
"(",
"grunt",
",",
"options",
",",
"callback",
")",
"{",
"this",
".",
"callback",
"=",
"callback",
";",
"this",
".",
"diffCount",
"=",
"0",
";",
"this",
".",
"grunt",
"=",
"grunt",
";",
"this",
".",
"options",
"=",
"options",
";",
"this",... | Constructor for PhotoBox
@param {Object} grunt grunt
@param {Object} options plugin options
@param {Function} callback callback
@tested | [
"Constructor",
"for",
"PhotoBox"
] | 9d91025d554a997953deb655de808b40399bc805 | https://github.com/stefanjudis/grunt-photobox/blob/9d91025d554a997953deb655de808b40399bc805/tasks/lib/photobox.js#L26-L42 | |
33,241 | asakusuma/ember-spaniel | index.js | function(treeType) {
if (treeType === 'vendor') {
// The treeForVendor returns a different value based on whether or not
// this addon is a nested dependency
return caclculateCacheKeyForTree(treeType, this, [!this.parent.parent]);
} else {
return this._super.cacheKeyForTree.call(this, treeType);
}
} | javascript | function(treeType) {
if (treeType === 'vendor') {
// The treeForVendor returns a different value based on whether or not
// this addon is a nested dependency
return caclculateCacheKeyForTree(treeType, this, [!this.parent.parent]);
} else {
return this._super.cacheKeyForTree.call(this, treeType);
}
} | [
"function",
"(",
"treeType",
")",
"{",
"if",
"(",
"treeType",
"===",
"'vendor'",
")",
"{",
"// The treeForVendor returns a different value based on whether or not",
"// this addon is a nested dependency",
"return",
"caclculateCacheKeyForTree",
"(",
"treeType",
",",
"this",
",... | ember-rollup implements a custom treeForVendor hook, we restore the caching for that hook here | [
"ember",
"-",
"rollup",
"implements",
"a",
"custom",
"treeForVendor",
"hook",
"we",
"restore",
"the",
"caching",
"for",
"that",
"hook",
"here"
] | 26bb0917eebf710e662199cc1c2cc5c4eb37c42e | https://github.com/asakusuma/ember-spaniel/blob/26bb0917eebf710e662199cc1c2cc5c4eb37c42e/index.js#L15-L23 | |
33,242 | pixelandtonic/garnishjs | dist/garnish.js | function(elem) {
this.getOffset._offset = $(elem).offset();
if (Garnish.$scrollContainer[0] !== Garnish.$win[0]) {
this.getOffset._offset.top += Garnish.$scrollContainer.scrollTop();
this.getOffset._offset.left += Garnish.$scrollContainer.scrollLeft();
}
return this.getOffset._offset;
} | javascript | function(elem) {
this.getOffset._offset = $(elem).offset();
if (Garnish.$scrollContainer[0] !== Garnish.$win[0]) {
this.getOffset._offset.top += Garnish.$scrollContainer.scrollTop();
this.getOffset._offset.left += Garnish.$scrollContainer.scrollLeft();
}
return this.getOffset._offset;
} | [
"function",
"(",
"elem",
")",
"{",
"this",
".",
"getOffset",
".",
"_offset",
"=",
"$",
"(",
"elem",
")",
".",
"offset",
"(",
")",
";",
"if",
"(",
"Garnish",
".",
"$scrollContainer",
"[",
"0",
"]",
"!==",
"Garnish",
".",
"$win",
"[",
"0",
"]",
")"... | Returns the offset of an element within the scroll container, whether that's the window or something else | [
"Returns",
"the",
"offset",
"of",
"an",
"element",
"within",
"the",
"scroll",
"container",
"whether",
"that",
"s",
"the",
"window",
"or",
"something",
"else"
] | 3e57331081c277eeac9a022feeadac5da3f4a2f9 | https://github.com/pixelandtonic/garnishjs/blob/3e57331081c277eeac9a022feeadac5da3f4a2f9/dist/garnish.js#L300-L309 | |
33,243 | pixelandtonic/garnishjs | dist/garnish.js | function(source, target) {
var $source = $(source),
$target = $(target);
$target.css({
fontFamily: $source.css('fontFamily'),
fontSize: $source.css('fontSize'),
fontWeight: $source.css('fontWeight'),
letterSpacing: $source.css('letterSpacing'),
lineHeight: $source.css('lineHeight'),
textAlign: $source.css('textAlign'),
textIndent: $source.css('textIndent'),
whiteSpace: $source.css('whiteSpace'),
wordSpacing: $source.css('wordSpacing'),
wordWrap: $source.css('wordWrap')
});
} | javascript | function(source, target) {
var $source = $(source),
$target = $(target);
$target.css({
fontFamily: $source.css('fontFamily'),
fontSize: $source.css('fontSize'),
fontWeight: $source.css('fontWeight'),
letterSpacing: $source.css('letterSpacing'),
lineHeight: $source.css('lineHeight'),
textAlign: $source.css('textAlign'),
textIndent: $source.css('textIndent'),
whiteSpace: $source.css('whiteSpace'),
wordSpacing: $source.css('wordSpacing'),
wordWrap: $source.css('wordWrap')
});
} | [
"function",
"(",
"source",
",",
"target",
")",
"{",
"var",
"$source",
"=",
"$",
"(",
"source",
")",
",",
"$target",
"=",
"$",
"(",
"target",
")",
";",
"$target",
".",
"css",
"(",
"{",
"fontFamily",
":",
"$source",
".",
"css",
"(",
"'fontFamily'",
"... | Copies text styles from one element to another.
@param {object} source The source element. Can be either an actual element or a jQuery collection.
@param {object} target The target element. Can be either an actual element or a jQuery collection. | [
"Copies",
"text",
"styles",
"from",
"one",
"element",
"to",
"another",
"."
] | 3e57331081c277eeac9a022feeadac5da3f4a2f9 | https://github.com/pixelandtonic/garnishjs/blob/3e57331081c277eeac9a022feeadac5da3f4a2f9/dist/garnish.js#L360-L376 | |
33,244 | pixelandtonic/garnishjs | dist/garnish.js | function() {
Garnish.getBodyScrollTop._scrollTop = document.body.scrollTop;
if (Garnish.getBodyScrollTop._scrollTop < 0) {
Garnish.getBodyScrollTop._scrollTop = 0;
}
else {
Garnish.getBodyScrollTop._maxScrollTop = Garnish.$bod.outerHeight() - Garnish.$win.height();
if (Garnish.getBodyScrollTop._scrollTop > Garnish.getBodyScrollTop._maxScrollTop) {
Garnish.getBodyScrollTop._scrollTop = Garnish.getBodyScrollTop._maxScrollTop;
}
}
return Garnish.getBodyScrollTop._scrollTop;
} | javascript | function() {
Garnish.getBodyScrollTop._scrollTop = document.body.scrollTop;
if (Garnish.getBodyScrollTop._scrollTop < 0) {
Garnish.getBodyScrollTop._scrollTop = 0;
}
else {
Garnish.getBodyScrollTop._maxScrollTop = Garnish.$bod.outerHeight() - Garnish.$win.height();
if (Garnish.getBodyScrollTop._scrollTop > Garnish.getBodyScrollTop._maxScrollTop) {
Garnish.getBodyScrollTop._scrollTop = Garnish.getBodyScrollTop._maxScrollTop;
}
}
return Garnish.getBodyScrollTop._scrollTop;
} | [
"function",
"(",
")",
"{",
"Garnish",
".",
"getBodyScrollTop",
".",
"_scrollTop",
"=",
"document",
".",
"body",
".",
"scrollTop",
";",
"if",
"(",
"Garnish",
".",
"getBodyScrollTop",
".",
"_scrollTop",
"<",
"0",
")",
"{",
"Garnish",
".",
"getBodyScrollTop",
... | Returns the body's real scrollTop, discarding any window banding in Safari.
@return {number} | [
"Returns",
"the",
"body",
"s",
"real",
"scrollTop",
"discarding",
"any",
"window",
"banding",
"in",
"Safari",
"."
] | 3e57331081c277eeac9a022feeadac5da3f4a2f9 | https://github.com/pixelandtonic/garnishjs/blob/3e57331081c277eeac9a022feeadac5da3f4a2f9/dist/garnish.js#L383-L398 | |
33,245 | pixelandtonic/garnishjs | dist/garnish.js | function(container, elem) {
var $elem;
if (typeof elem === 'undefined') {
$elem = $(container);
$container = $elem.scrollParent();
}
else {
var $container = $(container);
$elem = $(elem);
}
if ($container.prop('nodeName') === 'HTML' || $container[0] === Garnish.$doc[0]) {
$container = Garnish.$win;
}
var scrollTop = $container.scrollTop(),
elemOffset = $elem.offset().top;
var elemScrollOffset;
if ($container[0] === window) {
elemScrollOffset = elemOffset - scrollTop;
}
else {
elemScrollOffset = elemOffset - $container.offset().top;
}
var targetScrollTop = false;
// Is the element above the fold?
if (elemScrollOffset < 0) {
targetScrollTop = scrollTop + elemScrollOffset - 10;
}
else {
var elemHeight = $elem.outerHeight(),
containerHeight = ($container[0] === window ? window.innerHeight : $container[0].clientHeight);
// Is it below the fold?
if (elemScrollOffset + elemHeight > containerHeight) {
targetScrollTop = scrollTop + (elemScrollOffset - (containerHeight - elemHeight)) + 10;
}
}
if (targetScrollTop !== false) {
// Velocity only allows you to scroll to an arbitrary position if you're scrolling the main window
if ($container[0] === window) {
$('html').velocity('scroll', {
offset: targetScrollTop + 'px',
mobileHA: false
});
}
else {
$container.scrollTop(targetScrollTop);
}
}
} | javascript | function(container, elem) {
var $elem;
if (typeof elem === 'undefined') {
$elem = $(container);
$container = $elem.scrollParent();
}
else {
var $container = $(container);
$elem = $(elem);
}
if ($container.prop('nodeName') === 'HTML' || $container[0] === Garnish.$doc[0]) {
$container = Garnish.$win;
}
var scrollTop = $container.scrollTop(),
elemOffset = $elem.offset().top;
var elemScrollOffset;
if ($container[0] === window) {
elemScrollOffset = elemOffset - scrollTop;
}
else {
elemScrollOffset = elemOffset - $container.offset().top;
}
var targetScrollTop = false;
// Is the element above the fold?
if (elemScrollOffset < 0) {
targetScrollTop = scrollTop + elemScrollOffset - 10;
}
else {
var elemHeight = $elem.outerHeight(),
containerHeight = ($container[0] === window ? window.innerHeight : $container[0].clientHeight);
// Is it below the fold?
if (elemScrollOffset + elemHeight > containerHeight) {
targetScrollTop = scrollTop + (elemScrollOffset - (containerHeight - elemHeight)) + 10;
}
}
if (targetScrollTop !== false) {
// Velocity only allows you to scroll to an arbitrary position if you're scrolling the main window
if ($container[0] === window) {
$('html').velocity('scroll', {
offset: targetScrollTop + 'px',
mobileHA: false
});
}
else {
$container.scrollTop(targetScrollTop);
}
}
} | [
"function",
"(",
"container",
",",
"elem",
")",
"{",
"var",
"$elem",
";",
"if",
"(",
"typeof",
"elem",
"===",
"'undefined'",
")",
"{",
"$elem",
"=",
"$",
"(",
"container",
")",
";",
"$container",
"=",
"$elem",
".",
"scrollParent",
"(",
")",
";",
"}",... | Scrolls a container element to an element within it.
@param {object} container Either an actual element or a jQuery collection.
@param {object} elem Either an actual element or a jQuery collection. | [
"Scrolls",
"a",
"container",
"element",
"to",
"an",
"element",
"within",
"it",
"."
] | 3e57331081c277eeac9a022feeadac5da3f4a2f9 | https://github.com/pixelandtonic/garnishjs/blob/3e57331081c277eeac9a022feeadac5da3f4a2f9/dist/garnish.js#L434-L490 | |
33,246 | pixelandtonic/garnishjs | dist/garnish.js | function(elem, prop) {
var $elem = $(elem);
if (!prop) {
prop = 'margin-left';
}
var startingPoint = parseInt($elem.css(prop));
if (isNaN(startingPoint)) {
startingPoint = 0;
}
for (var i = 0; i <= Garnish.SHAKE_STEPS; i++) {
(function(i) {
setTimeout(function() {
Garnish.shake._properties = {};
Garnish.shake._properties[prop] = startingPoint + (i % 2 ? -1 : 1) * (10 - i);
$elem.velocity(Garnish.shake._properties, Garnish.SHAKE_STEP_DURATION);
}, (Garnish.SHAKE_STEP_DURATION * i));
})(i);
}
} | javascript | function(elem, prop) {
var $elem = $(elem);
if (!prop) {
prop = 'margin-left';
}
var startingPoint = parseInt($elem.css(prop));
if (isNaN(startingPoint)) {
startingPoint = 0;
}
for (var i = 0; i <= Garnish.SHAKE_STEPS; i++) {
(function(i) {
setTimeout(function() {
Garnish.shake._properties = {};
Garnish.shake._properties[prop] = startingPoint + (i % 2 ? -1 : 1) * (10 - i);
$elem.velocity(Garnish.shake._properties, Garnish.SHAKE_STEP_DURATION);
}, (Garnish.SHAKE_STEP_DURATION * i));
})(i);
}
} | [
"function",
"(",
"elem",
",",
"prop",
")",
"{",
"var",
"$elem",
"=",
"$",
"(",
"elem",
")",
";",
"if",
"(",
"!",
"prop",
")",
"{",
"prop",
"=",
"'margin-left'",
";",
"}",
"var",
"startingPoint",
"=",
"parseInt",
"(",
"$elem",
".",
"css",
"(",
"pr... | Shakes an element.
@param {object} elem Either an actual element or a jQuery collection.
@param {string} prop The property that should be adjusted (default is 'margin-left'). | [
"Shakes",
"an",
"element",
"."
] | 3e57331081c277eeac9a022feeadac5da3f4a2f9 | https://github.com/pixelandtonic/garnishjs/blob/3e57331081c277eeac9a022feeadac5da3f4a2f9/dist/garnish.js#L501-L522 | |
33,247 | pixelandtonic/garnishjs | dist/garnish.js | function(container) {
var postData = {},
arrayInputCounters = {},
$inputs = Garnish.findInputs(container);
var inputName;
for (var i = 0; i < $inputs.length; i++) {
var $input = $inputs.eq(i);
if ($input.prop('disabled')) {
continue;
}
inputName = $input.attr('name');
if (!inputName) {
continue;
}
var inputVal = Garnish.getInputPostVal($input);
if (inputVal === null) {
continue;
}
var isArrayInput = (inputName.substr(-2) === '[]');
if (isArrayInput) {
// Get the cropped input name
var croppedName = inputName.substring(0, inputName.length - 2);
// Prep the input counter
if (typeof arrayInputCounters[croppedName] === 'undefined') {
arrayInputCounters[croppedName] = 0;
}
}
if (!Garnish.isArray(inputVal)) {
inputVal = [inputVal];
}
for (var j = 0; j < inputVal.length; j++) {
if (isArrayInput) {
inputName = croppedName + '[' + arrayInputCounters[croppedName] + ']';
arrayInputCounters[croppedName]++;
}
postData[inputName] = inputVal[j];
}
}
return postData;
} | javascript | function(container) {
var postData = {},
arrayInputCounters = {},
$inputs = Garnish.findInputs(container);
var inputName;
for (var i = 0; i < $inputs.length; i++) {
var $input = $inputs.eq(i);
if ($input.prop('disabled')) {
continue;
}
inputName = $input.attr('name');
if (!inputName) {
continue;
}
var inputVal = Garnish.getInputPostVal($input);
if (inputVal === null) {
continue;
}
var isArrayInput = (inputName.substr(-2) === '[]');
if (isArrayInput) {
// Get the cropped input name
var croppedName = inputName.substring(0, inputName.length - 2);
// Prep the input counter
if (typeof arrayInputCounters[croppedName] === 'undefined') {
arrayInputCounters[croppedName] = 0;
}
}
if (!Garnish.isArray(inputVal)) {
inputVal = [inputVal];
}
for (var j = 0; j < inputVal.length; j++) {
if (isArrayInput) {
inputName = croppedName + '[' + arrayInputCounters[croppedName] + ']';
arrayInputCounters[croppedName]++;
}
postData[inputName] = inputVal[j];
}
}
return postData;
} | [
"function",
"(",
"container",
")",
"{",
"var",
"postData",
"=",
"{",
"}",
",",
"arrayInputCounters",
"=",
"{",
"}",
",",
"$inputs",
"=",
"Garnish",
".",
"findInputs",
"(",
"container",
")",
";",
"var",
"inputName",
";",
"for",
"(",
"var",
"i",
"=",
"... | Returns the post data within a container.
@param {object} container
@return {array} | [
"Returns",
"the",
"post",
"data",
"within",
"a",
"container",
"."
] | 3e57331081c277eeac9a022feeadac5da3f4a2f9 | https://github.com/pixelandtonic/garnishjs/blob/3e57331081c277eeac9a022feeadac5da3f4a2f9/dist/garnish.js#L606-L657 | |
33,248 | pixelandtonic/garnishjs | dist/garnish.js | function(ev) {
ev.preventDefault();
this.realMouseX = ev.pageX;
this.realMouseY = ev.pageY;
if (this.settings.axis !== Garnish.Y_AXIS) {
this.mouseX = ev.pageX;
}
if (this.settings.axis !== Garnish.X_AXIS) {
this.mouseY = ev.pageY;
}
this.mouseDistX = this.mouseX - this.mousedownX;
this.mouseDistY = this.mouseY - this.mousedownY;
if (!this.dragging) {
// Has the mouse moved far enough to initiate dragging yet?
this._handleMouseMove._mouseDist = Garnish.getDist(this.mousedownX, this.mousedownY, this.realMouseX, this.realMouseY);
if (this._handleMouseMove._mouseDist >= Garnish.BaseDrag.minMouseDist) {
this.startDragging();
}
}
if (this.dragging) {
this.drag(true);
}
} | javascript | function(ev) {
ev.preventDefault();
this.realMouseX = ev.pageX;
this.realMouseY = ev.pageY;
if (this.settings.axis !== Garnish.Y_AXIS) {
this.mouseX = ev.pageX;
}
if (this.settings.axis !== Garnish.X_AXIS) {
this.mouseY = ev.pageY;
}
this.mouseDistX = this.mouseX - this.mousedownX;
this.mouseDistY = this.mouseY - this.mousedownY;
if (!this.dragging) {
// Has the mouse moved far enough to initiate dragging yet?
this._handleMouseMove._mouseDist = Garnish.getDist(this.mousedownX, this.mousedownY, this.realMouseX, this.realMouseY);
if (this._handleMouseMove._mouseDist >= Garnish.BaseDrag.minMouseDist) {
this.startDragging();
}
}
if (this.dragging) {
this.drag(true);
}
} | [
"function",
"(",
"ev",
")",
"{",
"ev",
".",
"preventDefault",
"(",
")",
";",
"this",
".",
"realMouseX",
"=",
"ev",
".",
"pageX",
";",
"this",
".",
"realMouseY",
"=",
"ev",
".",
"pageY",
";",
"if",
"(",
"this",
".",
"settings",
".",
"axis",
"!==",
... | Handle Mouse Move | [
"Handle",
"Mouse",
"Move"
] | 3e57331081c277eeac9a022feeadac5da3f4a2f9 | https://github.com/pixelandtonic/garnishjs/blob/3e57331081c277eeac9a022feeadac5da3f4a2f9/dist/garnish.js#L1407-L1436 | |
33,249 | pixelandtonic/garnishjs | dist/garnish.js | function($newDraggee) {
if (!$newDraggee.length) {
return;
}
if (!this.settings.collapseDraggees) {
var oldLength = this.$draggee.length;
}
this.$draggee = $(this.$draggee.toArray().concat($newDraggee.toArray()));
// Create new helpers?
if (!this.settings.collapseDraggees) {
var newLength = this.$draggee.length;
for (var i = oldLength; i < newLength; i++) {
this._createHelper(i);
}
}
if (this.settings.removeDraggee || this.settings.collapseDraggees) {
$newDraggee.hide();
}
else {
$newDraggee.css('visibility', 'hidden');
}
} | javascript | function($newDraggee) {
if (!$newDraggee.length) {
return;
}
if (!this.settings.collapseDraggees) {
var oldLength = this.$draggee.length;
}
this.$draggee = $(this.$draggee.toArray().concat($newDraggee.toArray()));
// Create new helpers?
if (!this.settings.collapseDraggees) {
var newLength = this.$draggee.length;
for (var i = oldLength; i < newLength; i++) {
this._createHelper(i);
}
}
if (this.settings.removeDraggee || this.settings.collapseDraggees) {
$newDraggee.hide();
}
else {
$newDraggee.css('visibility', 'hidden');
}
} | [
"function",
"(",
"$newDraggee",
")",
"{",
"if",
"(",
"!",
"$newDraggee",
".",
"length",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"this",
".",
"settings",
".",
"collapseDraggees",
")",
"{",
"var",
"oldLength",
"=",
"this",
".",
"$draggee",
".",
"... | Appends additional items to the draggee. | [
"Appends",
"additional",
"items",
"to",
"the",
"draggee",
"."
] | 3e57331081c277eeac9a022feeadac5da3f4a2f9 | https://github.com/pixelandtonic/garnishjs/blob/3e57331081c277eeac9a022feeadac5da3f4a2f9/dist/garnish.js#L1836-L1862 | |
33,250 | pixelandtonic/garnishjs | dist/garnish.js | function() {
this._returningHelpersToDraggees = true;
for (var i = 0; i < this.helpers.length; i++) {
var $draggee = this.$draggee.eq(i),
$helper = this.helpers[i];
$draggee.css({
display: this.draggeeDisplay,
visibility: 'hidden'
});
var draggeeOffset = $draggee.offset();
var callback;
if (i === 0) {
callback = $.proxy(this, '_showDraggee');
}
else {
callback = null;
}
$helper.velocity({left: draggeeOffset.left, top: draggeeOffset.top}, Garnish.FX_DURATION, callback);
}
} | javascript | function() {
this._returningHelpersToDraggees = true;
for (var i = 0; i < this.helpers.length; i++) {
var $draggee = this.$draggee.eq(i),
$helper = this.helpers[i];
$draggee.css({
display: this.draggeeDisplay,
visibility: 'hidden'
});
var draggeeOffset = $draggee.offset();
var callback;
if (i === 0) {
callback = $.proxy(this, '_showDraggee');
}
else {
callback = null;
}
$helper.velocity({left: draggeeOffset.left, top: draggeeOffset.top}, Garnish.FX_DURATION, callback);
}
} | [
"function",
"(",
")",
"{",
"this",
".",
"_returningHelpersToDraggees",
"=",
"true",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"helpers",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"$draggee",
"=",
"this",
".",
"$dragge... | Return Helpers to Draggees | [
"Return",
"Helpers",
"to",
"Draggees"
] | 3e57331081c277eeac9a022feeadac5da3f4a2f9 | https://github.com/pixelandtonic/garnishjs/blob/3e57331081c277eeac9a022feeadac5da3f4a2f9/dist/garnish.js#L1921-L1945 | |
33,251 | pixelandtonic/garnishjs | dist/garnish.js | function() {
// Has the mouse moved?
if (this.mouseX !== this.lastMouseX || this.mouseY !== this.lastMouseY) {
// Get the new target helper positions
for (this._updateHelperPos._i = 0; this._updateHelperPos._i < this.helpers.length; this._updateHelperPos._i++) {
this.helperTargets[this._updateHelperPos._i] = this._getHelperTarget(this._updateHelperPos._i);
}
this.lastMouseX = this.mouseX;
this.lastMouseY = this.mouseY;
}
// Gravitate helpers toward their target positions
for (this._updateHelperPos._j = 0; this._updateHelperPos._j < this.helpers.length; this._updateHelperPos._j++) {
this._updateHelperPos._lag = this.settings.helperLagBase + (this.helperLagIncrement * this._updateHelperPos._j);
this.helperPositions[this._updateHelperPos._j] = {
left: this.helperPositions[this._updateHelperPos._j].left + ((this.helperTargets[this._updateHelperPos._j].left - this.helperPositions[this._updateHelperPos._j].left) / this._updateHelperPos._lag),
top: this.helperPositions[this._updateHelperPos._j].top + ((this.helperTargets[this._updateHelperPos._j].top - this.helperPositions[this._updateHelperPos._j].top) / this._updateHelperPos._lag)
};
this.helpers[this._updateHelperPos._j].css(this.helperPositions[this._updateHelperPos._j]);
}
// Let's do this again on the next frame!
this.updateHelperPosFrame = Garnish.requestAnimationFrame(this.updateHelperPosProxy);
} | javascript | function() {
// Has the mouse moved?
if (this.mouseX !== this.lastMouseX || this.mouseY !== this.lastMouseY) {
// Get the new target helper positions
for (this._updateHelperPos._i = 0; this._updateHelperPos._i < this.helpers.length; this._updateHelperPos._i++) {
this.helperTargets[this._updateHelperPos._i] = this._getHelperTarget(this._updateHelperPos._i);
}
this.lastMouseX = this.mouseX;
this.lastMouseY = this.mouseY;
}
// Gravitate helpers toward their target positions
for (this._updateHelperPos._j = 0; this._updateHelperPos._j < this.helpers.length; this._updateHelperPos._j++) {
this._updateHelperPos._lag = this.settings.helperLagBase + (this.helperLagIncrement * this._updateHelperPos._j);
this.helperPositions[this._updateHelperPos._j] = {
left: this.helperPositions[this._updateHelperPos._j].left + ((this.helperTargets[this._updateHelperPos._j].left - this.helperPositions[this._updateHelperPos._j].left) / this._updateHelperPos._lag),
top: this.helperPositions[this._updateHelperPos._j].top + ((this.helperTargets[this._updateHelperPos._j].top - this.helperPositions[this._updateHelperPos._j].top) / this._updateHelperPos._lag)
};
this.helpers[this._updateHelperPos._j].css(this.helperPositions[this._updateHelperPos._j]);
}
// Let's do this again on the next frame!
this.updateHelperPosFrame = Garnish.requestAnimationFrame(this.updateHelperPosProxy);
} | [
"function",
"(",
")",
"{",
"// Has the mouse moved?",
"if",
"(",
"this",
".",
"mouseX",
"!==",
"this",
".",
"lastMouseX",
"||",
"this",
".",
"mouseY",
"!==",
"this",
".",
"lastMouseY",
")",
"{",
"// Get the new target helper positions",
"for",
"(",
"this",
"."... | Update Helper Position | [
"Update",
"Helper",
"Position"
] | 3e57331081c277eeac9a022feeadac5da3f4a2f9 | https://github.com/pixelandtonic/garnishjs/blob/3e57331081c277eeac9a022feeadac5da3f4a2f9/dist/garnish.js#L2012-L2038 | |
33,252 | pixelandtonic/garnishjs | dist/garnish.js | function(i) {
return {
left: this.getHelperTargetX() + (this.settings.helperSpacingX * i),
top: this.getHelperTargetY() + (this.settings.helperSpacingY * i)
};
} | javascript | function(i) {
return {
left: this.getHelperTargetX() + (this.settings.helperSpacingX * i),
top: this.getHelperTargetY() + (this.settings.helperSpacingY * i)
};
} | [
"function",
"(",
"i",
")",
"{",
"return",
"{",
"left",
":",
"this",
".",
"getHelperTargetX",
"(",
")",
"+",
"(",
"this",
".",
"settings",
".",
"helperSpacingX",
"*",
"i",
")",
",",
"top",
":",
"this",
".",
"getHelperTargetY",
"(",
")",
"+",
"(",
"t... | Get the helper position for a draggee helper | [
"Get",
"the",
"helper",
"position",
"for",
"a",
"draggee",
"helper"
] | 3e57331081c277eeac9a022feeadac5da3f4a2f9 | https://github.com/pixelandtonic/garnishjs/blob/3e57331081c277eeac9a022feeadac5da3f4a2f9/dist/garnish.js#L2043-L2048 | |
33,253 | pixelandtonic/garnishjs | dist/garnish.js | function() {
for (var i = 0; i < this.helpers.length; i++) {
(function($draggeeHelper) {
$draggeeHelper.velocity('fadeOut', {
duration: Garnish.FX_DURATION,
complete: function() {
$draggeeHelper.remove();
}
});
})(this.helpers[i]);
}
} | javascript | function() {
for (var i = 0; i < this.helpers.length; i++) {
(function($draggeeHelper) {
$draggeeHelper.velocity('fadeOut', {
duration: Garnish.FX_DURATION,
complete: function() {
$draggeeHelper.remove();
}
});
})(this.helpers[i]);
}
} | [
"function",
"(",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"helpers",
".",
"length",
";",
"i",
"++",
")",
"{",
"(",
"function",
"(",
"$draggeeHelper",
")",
"{",
"$draggeeHelper",
".",
"velocity",
"(",
"'fadeOut'",
",",... | Fade Out Helpers | [
"Fade",
"Out",
"Helpers"
] | 3e57331081c277eeac9a022feeadac5da3f4a2f9 | https://github.com/pixelandtonic/garnishjs/blob/3e57331081c277eeac9a022feeadac5da3f4a2f9/dist/garnish.js#L2185-L2196 | |
33,254 | pixelandtonic/garnishjs | dist/garnish.js | function(bodyContents) {
// Cleanup
this.$main.html('');
if (this.$header) {
this.$hud.removeClass('has-header');
this.$header.remove();
this.$header = null;
}
if (this.$footer) {
this.$hud.removeClass('has-footer');
this.$footer.remove();
this.$footer = null;
}
// Append the new body contents
this.$main.append(bodyContents);
// Look for a header and footer
var $header = this.$main.find('.' + this.settings.headerClass + ':first'),
$footer = this.$main.find('.' + this.settings.footerClass + ':first');
if ($header.length) {
this.$header = $header.insertBefore(this.$mainContainer);
this.$hud.addClass('has-header');
}
if ($footer.length) {
this.$footer = $footer.insertAfter(this.$mainContainer);
this.$hud.addClass('has-footer');
}
} | javascript | function(bodyContents) {
// Cleanup
this.$main.html('');
if (this.$header) {
this.$hud.removeClass('has-header');
this.$header.remove();
this.$header = null;
}
if (this.$footer) {
this.$hud.removeClass('has-footer');
this.$footer.remove();
this.$footer = null;
}
// Append the new body contents
this.$main.append(bodyContents);
// Look for a header and footer
var $header = this.$main.find('.' + this.settings.headerClass + ':first'),
$footer = this.$main.find('.' + this.settings.footerClass + ':first');
if ($header.length) {
this.$header = $header.insertBefore(this.$mainContainer);
this.$hud.addClass('has-header');
}
if ($footer.length) {
this.$footer = $footer.insertAfter(this.$mainContainer);
this.$hud.addClass('has-footer');
}
} | [
"function",
"(",
"bodyContents",
")",
"{",
"// Cleanup",
"this",
".",
"$main",
".",
"html",
"(",
"''",
")",
";",
"if",
"(",
"this",
".",
"$header",
")",
"{",
"this",
".",
"$hud",
".",
"removeClass",
"(",
"'has-header'",
")",
";",
"this",
".",
"$heade... | Update the body contents | [
"Update",
"the",
"body",
"contents"
] | 3e57331081c277eeac9a022feeadac5da3f4a2f9 | https://github.com/pixelandtonic/garnishjs/blob/3e57331081c277eeac9a022feeadac5da3f4a2f9/dist/garnish.js#L2850-L2882 | |
33,255 | pixelandtonic/garnishjs | dist/garnish.js | function($item, preventScroll) {
if (preventScroll) {
var scrollLeft = Garnish.$doc.scrollLeft(),
scrollTop = Garnish.$doc.scrollTop();
$item.focus();
window.scrollTo(scrollLeft, scrollTop);
}
else {
$item.focus();
}
this.$focusedItem = $item;
this.trigger('focusItem', {item: $item});
} | javascript | function($item, preventScroll) {
if (preventScroll) {
var scrollLeft = Garnish.$doc.scrollLeft(),
scrollTop = Garnish.$doc.scrollTop();
$item.focus();
window.scrollTo(scrollLeft, scrollTop);
}
else {
$item.focus();
}
this.$focusedItem = $item;
this.trigger('focusItem', {item: $item});
} | [
"function",
"(",
"$item",
",",
"preventScroll",
")",
"{",
"if",
"(",
"preventScroll",
")",
"{",
"var",
"scrollLeft",
"=",
"Garnish",
".",
"$doc",
".",
"scrollLeft",
"(",
")",
",",
"scrollTop",
"=",
"Garnish",
".",
"$doc",
".",
"scrollTop",
"(",
")",
";... | Sets the focus on an item. | [
"Sets",
"the",
"focus",
"on",
"an",
"item",
"."
] | 3e57331081c277eeac9a022feeadac5da3f4a2f9 | https://github.com/pixelandtonic/garnishjs/blob/3e57331081c277eeac9a022feeadac5da3f4a2f9/dist/garnish.js#L5390-L5403 | |
33,256 | pixelandtonic/garnishjs | dist/garnish.js | function(ev) {
// ignore right clicks
if (ev.which !== Garnish.PRIMARY_CLICK) {
return;
}
// Enfore the filter
if (this.settings.filter && !$(ev.target).is(this.settings.filter)) {
return;
}
var $item = $($.data(ev.currentTarget, 'select-item'));
// was this a click?
if (
!this._actAsCheckbox(ev) && !ev.shiftKey &&
ev.currentTarget === this.mousedownTarget
) {
// If this is already selected, wait a moment to see if this is a double click before making any rash decisions
if (this.isSelected($item)) {
this.clearMouseUpTimeout();
this.mouseUpTimeout = setTimeout($.proxy(function() {
this.deselectOthers($item);
}, this), 300);
}
else {
this.deselectAll();
this.selectItem($item, true, true);
}
}
} | javascript | function(ev) {
// ignore right clicks
if (ev.which !== Garnish.PRIMARY_CLICK) {
return;
}
// Enfore the filter
if (this.settings.filter && !$(ev.target).is(this.settings.filter)) {
return;
}
var $item = $($.data(ev.currentTarget, 'select-item'));
// was this a click?
if (
!this._actAsCheckbox(ev) && !ev.shiftKey &&
ev.currentTarget === this.mousedownTarget
) {
// If this is already selected, wait a moment to see if this is a double click before making any rash decisions
if (this.isSelected($item)) {
this.clearMouseUpTimeout();
this.mouseUpTimeout = setTimeout($.proxy(function() {
this.deselectOthers($item);
}, this), 300);
}
else {
this.deselectAll();
this.selectItem($item, true, true);
}
}
} | [
"function",
"(",
"ev",
")",
"{",
"// ignore right clicks",
"if",
"(",
"ev",
".",
"which",
"!==",
"Garnish",
".",
"PRIMARY_CLICK",
")",
"{",
"return",
";",
"}",
"// Enfore the filter",
"if",
"(",
"this",
".",
"settings",
".",
"filter",
"&&",
"!",
"$",
"("... | On Mouse Up | [
"On",
"Mouse",
"Up"
] | 3e57331081c277eeac9a022feeadac5da3f4a2f9 | https://github.com/pixelandtonic/garnishjs/blob/3e57331081c277eeac9a022feeadac5da3f4a2f9/dist/garnish.js#L5454-L5485 | |
33,257 | pixelandtonic/garnishjs | dist/garnish.js | function(item) {
var $handle = $.data(item, 'select-handle');
if ($handle) {
$handle.removeData('select-item');
this.removeAllListeners($handle);
}
$.removeData(item, 'select');
$.removeData(item, 'select-handle');
if (this.$focusedItem && this.$focusedItem[0] === item) {
this.$focusedItem = null;
}
} | javascript | function(item) {
var $handle = $.data(item, 'select-handle');
if ($handle) {
$handle.removeData('select-item');
this.removeAllListeners($handle);
}
$.removeData(item, 'select');
$.removeData(item, 'select-handle');
if (this.$focusedItem && this.$focusedItem[0] === item) {
this.$focusedItem = null;
}
} | [
"function",
"(",
"item",
")",
"{",
"var",
"$handle",
"=",
"$",
".",
"data",
"(",
"item",
",",
"'select-handle'",
")",
";",
"if",
"(",
"$handle",
")",
"{",
"$handle",
".",
"removeData",
"(",
"'select-item'",
")",
";",
"this",
".",
"removeAllListeners",
... | Deinitialize an item. | [
"Deinitialize",
"an",
"item",
"."
] | 3e57331081c277eeac9a022feeadac5da3f4a2f9 | https://github.com/pixelandtonic/garnishjs/blob/3e57331081c277eeac9a022feeadac5da3f4a2f9/dist/garnish.js#L5716-L5730 | |
33,258 | contentful/contentful-extension-cli | lib/command/update.js | loadCurrentVersion | function loadCurrentVersion (options, context) {
return new Extension(options, context).read()
.then(function (response) {
let version = response.sys.version;
options.version = version;
return options;
});
} | javascript | function loadCurrentVersion (options, context) {
return new Extension(options, context).read()
.then(function (response) {
let version = response.sys.version;
options.version = version;
return options;
});
} | [
"function",
"loadCurrentVersion",
"(",
"options",
",",
"context",
")",
"{",
"return",
"new",
"Extension",
"(",
"options",
",",
"context",
")",
".",
"read",
"(",
")",
".",
"then",
"(",
"function",
"(",
"response",
")",
"{",
"let",
"version",
"=",
"respons... | GETs the extension from the server and extends `options` with the
current version. | [
"GETs",
"the",
"extension",
"from",
"the",
"server",
"and",
"extends",
"options",
"with",
"the",
"current",
"version",
"."
] | 5405485695a0e920eb30a99a43d80bdc8778b5bd | https://github.com/contentful/contentful-extension-cli/blob/5405485695a0e920eb30a99a43d80bdc8778b5bd/lib/command/update.js#L58-L66 |
33,259 | pixelandtonic/garnishjs | gulpfile.js | function(err) {
notify.onError({
title: "Garnish",
message: "Error: <%= error.message %>",
sound: "Beep"
})(err);
console.log( 'plumber error!' );
this.emit('end');
} | javascript | function(err) {
notify.onError({
title: "Garnish",
message: "Error: <%= error.message %>",
sound: "Beep"
})(err);
console.log( 'plumber error!' );
this.emit('end');
} | [
"function",
"(",
"err",
")",
"{",
"notify",
".",
"onError",
"(",
"{",
"title",
":",
"\"Garnish\"",
",",
"message",
":",
"\"Error: <%= error.message %>\"",
",",
"sound",
":",
"\"Beep\"",
"}",
")",
"(",
"err",
")",
";",
"console",
".",
"log",
"(",
"'plumbe... | error notification settings for plumber | [
"error",
"notification",
"settings",
"for",
"plumber"
] | 3e57331081c277eeac9a022feeadac5da3f4a2f9 | https://github.com/pixelandtonic/garnishjs/blob/3e57331081c277eeac9a022feeadac5da3f4a2f9/gulpfile.js#L28-L39 | |
33,260 | dylang/random-puppy | index.js | all | function all(subreddit) {
const eventEmitter = new EventEmitter();
function emitRandomImage(subreddit) {
randomPuppy(subreddit).then(imageUrl => {
eventEmitter.emit('data', imageUrl + '#' + subreddit);
if (eventEmitter.listeners('data').length) {
setTimeout(() => emitRandomImage(subreddit), 200);
}
});
}
emitRandomImage(subreddit);
return eventEmitter;
} | javascript | function all(subreddit) {
const eventEmitter = new EventEmitter();
function emitRandomImage(subreddit) {
randomPuppy(subreddit).then(imageUrl => {
eventEmitter.emit('data', imageUrl + '#' + subreddit);
if (eventEmitter.listeners('data').length) {
setTimeout(() => emitRandomImage(subreddit), 200);
}
});
}
emitRandomImage(subreddit);
return eventEmitter;
} | [
"function",
"all",
"(",
"subreddit",
")",
"{",
"const",
"eventEmitter",
"=",
"new",
"EventEmitter",
"(",
")",
";",
"function",
"emitRandomImage",
"(",
"subreddit",
")",
"{",
"randomPuppy",
"(",
"subreddit",
")",
".",
"then",
"(",
"imageUrl",
"=>",
"{",
"ev... | silly feature to play with observables | [
"silly",
"feature",
"to",
"play",
"with",
"observables"
] | cf003bea00816ae03fd368bbeb7d3fbab6f2002b | https://github.com/dylang/random-puppy/blob/cf003bea00816ae03fd368bbeb7d3fbab6f2002b/index.js#L37-L51 |
33,261 | punkave/mongo-dump-stream | index.js | function(dbOrUri, stream, callback) {
if (arguments.length === 2) {
callback = stream;
stream = undefined;
}
if (!stream) {
stream = process.stdout;
}
var db;
var out = stream;
var endOfCollection = crypto.pseudoRandomBytes(8).toString('base64');
write({
type: 'mongo-dump-stream',
version: '2',
endOfCollection: endOfCollection
});
return async.series({
connect: function(callback) {
if (typeof(dbOrUri) !== 'string') {
// Already a mongodb connection
db = dbOrUri;
return setImmediate(callback);
}
return mongodb.MongoClient.connect(dbOrUri, function(err, _db) {
if (err) {
return callback(err);
}
db = _db;
return callback(null);
});
},
getCollections: function(callback) {
return db.collections(function(err, _collections) {
if (err) {
return callback(err);
}
collections = _collections;
return callback(null);
});
},
dumpCollections: function(callback) {
return async.eachSeries(collections, function(collection, callback) {
if (collection.collectionName.match(/^system\./)) {
return setImmediate(callback);
}
return async.series({
getIndexes: function(callback) {
return collection.indexInformation({ full: true }, function(err, info) {
if (err) {
return callback(err);
}
write({
type: 'collection',
name: collection.collectionName,
indexes: info
});
return callback(null);
});
},
getDocuments: function(callback) {
var cursor = collection.find({}, { raw: true });
iterate();
function iterate() {
return cursor.nextObject(function(err, item) {
if (err) {
return callback(err);
}
if (!item) {
write({
// Ensures we don't confuse this with
// a legitimate database object
endOfCollection: endOfCollection
});
return callback(null);
}
// v2: just a series of actual data documents
out.write(item);
// If we didn't have the raw BSON document,
// we could do this instead, but it would be very slow
// write({
// type: 'document',
// document: item
// });
return setImmediate(iterate);
});
}
},
}, callback);
}, callback);
},
endDatabase: function(callback) {
write({
type: 'endDatabase'
}, callback);
}
}, function(err) {
if (err) {
return callback(err);
}
return callback(null);
});
function write(o, callback) {
out.write(BSON.serialize(o, false, true, false), callback);
}
} | javascript | function(dbOrUri, stream, callback) {
if (arguments.length === 2) {
callback = stream;
stream = undefined;
}
if (!stream) {
stream = process.stdout;
}
var db;
var out = stream;
var endOfCollection = crypto.pseudoRandomBytes(8).toString('base64');
write({
type: 'mongo-dump-stream',
version: '2',
endOfCollection: endOfCollection
});
return async.series({
connect: function(callback) {
if (typeof(dbOrUri) !== 'string') {
// Already a mongodb connection
db = dbOrUri;
return setImmediate(callback);
}
return mongodb.MongoClient.connect(dbOrUri, function(err, _db) {
if (err) {
return callback(err);
}
db = _db;
return callback(null);
});
},
getCollections: function(callback) {
return db.collections(function(err, _collections) {
if (err) {
return callback(err);
}
collections = _collections;
return callback(null);
});
},
dumpCollections: function(callback) {
return async.eachSeries(collections, function(collection, callback) {
if (collection.collectionName.match(/^system\./)) {
return setImmediate(callback);
}
return async.series({
getIndexes: function(callback) {
return collection.indexInformation({ full: true }, function(err, info) {
if (err) {
return callback(err);
}
write({
type: 'collection',
name: collection.collectionName,
indexes: info
});
return callback(null);
});
},
getDocuments: function(callback) {
var cursor = collection.find({}, { raw: true });
iterate();
function iterate() {
return cursor.nextObject(function(err, item) {
if (err) {
return callback(err);
}
if (!item) {
write({
// Ensures we don't confuse this with
// a legitimate database object
endOfCollection: endOfCollection
});
return callback(null);
}
// v2: just a series of actual data documents
out.write(item);
// If we didn't have the raw BSON document,
// we could do this instead, but it would be very slow
// write({
// type: 'document',
// document: item
// });
return setImmediate(iterate);
});
}
},
}, callback);
}, callback);
},
endDatabase: function(callback) {
write({
type: 'endDatabase'
}, callback);
}
}, function(err) {
if (err) {
return callback(err);
}
return callback(null);
});
function write(o, callback) {
out.write(BSON.serialize(o, false, true, false), callback);
}
} | [
"function",
"(",
"dbOrUri",
",",
"stream",
",",
"callback",
")",
"{",
"if",
"(",
"arguments",
".",
"length",
"===",
"2",
")",
"{",
"callback",
"=",
"stream",
";",
"stream",
"=",
"undefined",
";",
"}",
"if",
"(",
"!",
"stream",
")",
"{",
"stream",
"... | If you leave out "stream" it'll be stdout | [
"If",
"you",
"leave",
"out",
"stream",
"it",
"ll",
"be",
"stdout"
] | ef0edec544ebd727b5376c8bac06f0f967a6d1c7 | https://github.com/punkave/mongo-dump-stream/blob/ef0edec544ebd727b5376c8bac06f0f967a6d1c7/index.js#L16-L122 | |
33,262 | wooorm/markdown-escapes | index.js | escapes | function escapes(options) {
var settings = options || {}
if (settings.commonmark) {
return commonmark
}
return settings.gfm ? gfm : defaults
} | javascript | function escapes(options) {
var settings = options || {}
if (settings.commonmark) {
return commonmark
}
return settings.gfm ? gfm : defaults
} | [
"function",
"escapes",
"(",
"options",
")",
"{",
"var",
"settings",
"=",
"options",
"||",
"{",
"}",
"if",
"(",
"settings",
".",
"commonmark",
")",
"{",
"return",
"commonmark",
"}",
"return",
"settings",
".",
"gfm",
"?",
"gfm",
":",
"defaults",
"}"
] | Get markdown escapes. | [
"Get",
"markdown",
"escapes",
"."
] | 129e65017ee4ac1eb1ed7bc2e0160ed3bbc473d8 | https://github.com/wooorm/markdown-escapes/blob/129e65017ee4ac1eb1ed7bc2e0160ed3bbc473d8/index.js#L49-L57 |
33,263 | agirorn/node-hid-stream | lib/keyboard-parser.js | parseModifiers | function parseModifiers(packet, bits) {
/* eslint-disable no-bitwise */
/* eslint-disable no-param-reassign */
packet.modifiers.l_control = ((bits & 1) !== 0);
packet.modifiers.l_shift = ((bits & 2) !== 0);
packet.modifiers.l_alt = ((bits & 4) !== 0);
packet.modifiers.l_meta = ((bits & 8) !== 0);
packet.modifiers.r_control = ((bits & 16) !== 0);
packet.modifiers.r_shift = ((bits & 32) !== 0);
packet.modifiers.r_alt = ((bits & 64) !== 0);
packet.modifiers.r_meta = ((bits & 128) !== 0);
/* eslint-enable no-bitwise */
/* eslint-enable no-param-reassign */
} | javascript | function parseModifiers(packet, bits) {
/* eslint-disable no-bitwise */
/* eslint-disable no-param-reassign */
packet.modifiers.l_control = ((bits & 1) !== 0);
packet.modifiers.l_shift = ((bits & 2) !== 0);
packet.modifiers.l_alt = ((bits & 4) !== 0);
packet.modifiers.l_meta = ((bits & 8) !== 0);
packet.modifiers.r_control = ((bits & 16) !== 0);
packet.modifiers.r_shift = ((bits & 32) !== 0);
packet.modifiers.r_alt = ((bits & 64) !== 0);
packet.modifiers.r_meta = ((bits & 128) !== 0);
/* eslint-enable no-bitwise */
/* eslint-enable no-param-reassign */
} | [
"function",
"parseModifiers",
"(",
"packet",
",",
"bits",
")",
"{",
"/* eslint-disable no-bitwise */",
"/* eslint-disable no-param-reassign */",
"packet",
".",
"modifiers",
".",
"l_control",
"=",
"(",
"(",
"bits",
"&",
"1",
")",
"!==",
"0",
")",
";",
"packet",
"... | Convert modifier key bits into
array of human-readable identifiers | [
"Convert",
"modifier",
"key",
"bits",
"into",
"array",
"of",
"human",
"-",
"readable",
"identifiers"
] | 3cbb1e0f85fc920f83618cd6c929d811df9b230c | https://github.com/agirorn/node-hid-stream/blob/3cbb1e0f85fc920f83618cd6c929d811df9b230c/lib/keyboard-parser.js#L22-L35 |
33,264 | agirorn/node-hid-stream | lib/keyboard-parser.js | parseKeyCodes | function parseKeyCodes(arr, keys) {
if (typeof keys !== 'object') { return false; }
keys.forEach((key) => {
if (key > 3) { arr.keyCodes.push(key); }
});
return true;
} | javascript | function parseKeyCodes(arr, keys) {
if (typeof keys !== 'object') { return false; }
keys.forEach((key) => {
if (key > 3) { arr.keyCodes.push(key); }
});
return true;
} | [
"function",
"parseKeyCodes",
"(",
"arr",
",",
"keys",
")",
"{",
"if",
"(",
"typeof",
"keys",
"!==",
"'object'",
")",
"{",
"return",
"false",
";",
"}",
"keys",
".",
"forEach",
"(",
"(",
"key",
")",
"=>",
"{",
"if",
"(",
"key",
">",
"3",
")",
"{",
... | Slice HID keycodes into separate array | [
"Slice",
"HID",
"keycodes",
"into",
"separate",
"array"
] | 3cbb1e0f85fc920f83618cd6c929d811df9b230c | https://github.com/agirorn/node-hid-stream/blob/3cbb1e0f85fc920f83618cd6c929d811df9b230c/lib/keyboard-parser.js#L41-L49 |
33,265 | agirorn/node-hid-stream | lib/keyboard-parser.js | parseErrorState | function parseErrorState(packet, state) {
let states = 0;
state.forEach((s) => {
if (s === 1) {
states += 1;
}
});
if (states >= 6) {
packet.errorStatus = true; // eslint-disable-line no-param-reassign
}
} | javascript | function parseErrorState(packet, state) {
let states = 0;
state.forEach((s) => {
if (s === 1) {
states += 1;
}
});
if (states >= 6) {
packet.errorStatus = true; // eslint-disable-line no-param-reassign
}
} | [
"function",
"parseErrorState",
"(",
"packet",
",",
"state",
")",
"{",
"let",
"states",
"=",
"0",
";",
"state",
".",
"forEach",
"(",
"(",
"s",
")",
"=>",
"{",
"if",
"(",
"s",
"===",
"1",
")",
"{",
"states",
"+=",
"1",
";",
"}",
"}",
")",
";",
... | Detect keyboard rollover error
This occurs when the user has pressed too many keys for the
particular device to handle | [
"Detect",
"keyboard",
"rollover",
"error",
"This",
"occurs",
"when",
"the",
"user",
"has",
"pressed",
"too",
"many",
"keys",
"for",
"the",
"particular",
"device",
"to",
"handle"
] | 3cbb1e0f85fc920f83618cd6c929d811df9b230c | https://github.com/agirorn/node-hid-stream/blob/3cbb1e0f85fc920f83618cd6c929d811df9b230c/lib/keyboard-parser.js#L222-L234 |
33,266 | seanmonstar/intel | lib/record.js | stack | function stack(e) {
return {
toString: function() {
// first line is err.message, which we already show, so start from
// second line
return e.stack.substr(e.stack.indexOf('\n'));
},
toJSON: function() {
return stacktrace.parse(e);
}
};
} | javascript | function stack(e) {
return {
toString: function() {
// first line is err.message, which we already show, so start from
// second line
return e.stack.substr(e.stack.indexOf('\n'));
},
toJSON: function() {
return stacktrace.parse(e);
}
};
} | [
"function",
"stack",
"(",
"e",
")",
"{",
"return",
"{",
"toString",
":",
"function",
"(",
")",
"{",
"// first line is err.message, which we already show, so start from",
"// second line",
"return",
"e",
".",
"stack",
".",
"substr",
"(",
"e",
".",
"stack",
".",
"... | stack formatter helper | [
"stack",
"formatter",
"helper"
] | 65e77bc379924fef0dda1f75adc611325028381d | https://github.com/seanmonstar/intel/blob/65e77bc379924fef0dda1f75adc611325028381d/lib/record.js#L20-L31 |
33,267 | watson/original-url | index.js | getFirstHeader | function getFirstHeader (req, header) {
const value = req.headers[header]
return (Array.isArray(value) ? value[0] : value).split(', ')[0]
} | javascript | function getFirstHeader (req, header) {
const value = req.headers[header]
return (Array.isArray(value) ? value[0] : value).split(', ')[0]
} | [
"function",
"getFirstHeader",
"(",
"req",
",",
"header",
")",
"{",
"const",
"value",
"=",
"req",
".",
"headers",
"[",
"header",
"]",
"return",
"(",
"Array",
".",
"isArray",
"(",
"value",
")",
"?",
"value",
"[",
"0",
"]",
":",
"value",
")",
".",
"sp... | In case there's more than one header of a given name, we want the first one as it should be the one that was added by the first proxy in the chain | [
"In",
"case",
"there",
"s",
"more",
"than",
"one",
"header",
"of",
"a",
"given",
"name",
"we",
"want",
"the",
"first",
"one",
"as",
"it",
"should",
"be",
"the",
"one",
"that",
"was",
"added",
"by",
"the",
"first",
"proxy",
"in",
"the",
"chain"
] | 4447ad715030695b5a9627765e211e018e99c38c | https://github.com/watson/original-url/blob/4447ad715030695b5a9627765e211e018e99c38c/index.js#L88-L91 |
33,268 | brunschgi/terrificjs | src/Application.js | Application | function Application(ctx, config) {
// validate params
if (!ctx && !config) {
// both empty
ctx = document;
config = {};
}
else if (Utils.isNode(config)) {
// reverse order of arguments
var tmpConfig = config;
config = ctx;
ctx = tmpConfig;
}
else if (!Utils.isNode(ctx) && !config) {
// only config is given
config = ctx;
ctx = document;
}
else if (Utils.isNode(ctx) && !config) {
// only ctx is given
config = {};
}
var defaults = {
namespace: Module
};
config = Utils.extend(defaults, config);
/**
* The context node.
*
* @property _ctx
* @type Node
*/
this._ctx = Utils.getElement(ctx);
/**
* The configuration.
*
* @property config
* @type Object
*/
this._config = config;
/**
* The sandbox to get the resources from.
* The singleton is shared between all modules.
*
* @property _sandbox
* @type Sandbox
*/
this._sandbox = new Sandbox(this);
/**
* Contains references to all modules on the page.
*
* @property _modules
* @type Object
*/
this._modules = {};
/**
* The next unique module id to use.
*
* @property id
* @type Number
*/
this._id = 1;
} | javascript | function Application(ctx, config) {
// validate params
if (!ctx && !config) {
// both empty
ctx = document;
config = {};
}
else if (Utils.isNode(config)) {
// reverse order of arguments
var tmpConfig = config;
config = ctx;
ctx = tmpConfig;
}
else if (!Utils.isNode(ctx) && !config) {
// only config is given
config = ctx;
ctx = document;
}
else if (Utils.isNode(ctx) && !config) {
// only ctx is given
config = {};
}
var defaults = {
namespace: Module
};
config = Utils.extend(defaults, config);
/**
* The context node.
*
* @property _ctx
* @type Node
*/
this._ctx = Utils.getElement(ctx);
/**
* The configuration.
*
* @property config
* @type Object
*/
this._config = config;
/**
* The sandbox to get the resources from.
* The singleton is shared between all modules.
*
* @property _sandbox
* @type Sandbox
*/
this._sandbox = new Sandbox(this);
/**
* Contains references to all modules on the page.
*
* @property _modules
* @type Object
*/
this._modules = {};
/**
* The next unique module id to use.
*
* @property id
* @type Number
*/
this._id = 1;
} | [
"function",
"Application",
"(",
"ctx",
",",
"config",
")",
"{",
"// validate params",
"if",
"(",
"!",
"ctx",
"&&",
"!",
"config",
")",
"{",
"// both empty",
"ctx",
"=",
"document",
";",
"config",
"=",
"{",
"}",
";",
"}",
"else",
"if",
"(",
"Utils",
"... | Responsible for application-wide issues such as the creation of modules.
@author Remo Brunschwiler
@namespace T
@class Application
@constructor
@param {Node} ctx
The context node
@param {Object} config
The configuration
/* global Sandbox, Utils, Module | [
"Responsible",
"for",
"application",
"-",
"wide",
"issues",
"such",
"as",
"the",
"creation",
"of",
"modules",
"."
] | 4e9055ffb99bec24b2014c9389c20682a23a209f | https://github.com/brunschgi/terrificjs/blob/4e9055ffb99bec24b2014c9389c20682a23a209f/src/Application.js#L28-L97 |
33,269 | Zimbra-Community/js-zimbra | lib/utils/preauth.js | function (options, callback) {
LOG.debug('preauth#createPreauth called');
LOG.debug('Validating options');
try {
options = new preauthOptions.CreatePreauth().validate(options);
} catch (err) {
if (err.name === 'InvalidOption') {
LOG.error('Invalid options specified: %s', err.message);
callback(
commonErrors.InvalidOption(
undefined,
{
message: err.message
}
)
);
} else {
LOG.error('System error: %s', err.message);
callback(
commonErrors.SystemError(
undefined,
{
message: err.message
}
)
);
}
return;
}
var timestamp = options.timestamp;
if (!timestamp) {
timestamp = new Date().getTime();
}
LOG.debug('Generating preauth key');
var pakCreator = crypto.createHmac('sha1', options.key)
.setEncoding('hex');
pakCreator.write(
util.format(
'%s|%s|%s|%s',
options.byValue,
options.by,
options.expires,
timestamp
)
);
pakCreator.end();
var pak = pakCreator.read();
LOG.debug('Returning preauth key %s', pak);
callback(null, pak);
} | javascript | function (options, callback) {
LOG.debug('preauth#createPreauth called');
LOG.debug('Validating options');
try {
options = new preauthOptions.CreatePreauth().validate(options);
} catch (err) {
if (err.name === 'InvalidOption') {
LOG.error('Invalid options specified: %s', err.message);
callback(
commonErrors.InvalidOption(
undefined,
{
message: err.message
}
)
);
} else {
LOG.error('System error: %s', err.message);
callback(
commonErrors.SystemError(
undefined,
{
message: err.message
}
)
);
}
return;
}
var timestamp = options.timestamp;
if (!timestamp) {
timestamp = new Date().getTime();
}
LOG.debug('Generating preauth key');
var pakCreator = crypto.createHmac('sha1', options.key)
.setEncoding('hex');
pakCreator.write(
util.format(
'%s|%s|%s|%s',
options.byValue,
options.by,
options.expires,
timestamp
)
);
pakCreator.end();
var pak = pakCreator.read();
LOG.debug('Returning preauth key %s', pak);
callback(null, pak);
} | [
"function",
"(",
"options",
",",
"callback",
")",
"{",
"LOG",
".",
"debug",
"(",
"'preauth#createPreauth called'",
")",
";",
"LOG",
".",
"debug",
"(",
"'Validating options'",
")",
";",
"try",
"{",
"options",
"=",
"new",
"preauthOptions",
".",
"CreatePreauth",
... | Create a preauth value
@param {CreatePreauthOptions} options options for createPreauth
@param {callback} callback run with optional error (see throws) and
preauth key
@throws {InvalidOptionError}
@throws {SystemError} | [
"Create",
"a",
"preauth",
"value"
] | dc073847a04da093b848463942731d15d256f00d | https://github.com/Zimbra-Community/js-zimbra/blob/dc073847a04da093b848463942731d15d256f00d/lib/utils/preauth.js#L25-L97 | |
33,270 | NathanaelA/nativescript-liveedit | liveedit.ios.js | loadCss | function loadCss() {
var cssFileName = fs.path.join(fs.knownFolders.currentApp().path, application.cssFile);
var applicationCss;
if (FSA.fileExists(cssFileName)) {
FSA.readText(cssFileName, function (r) { applicationCss = r; });
//noinspection JSUnusedAssignment
application.cssSelectorsCache = styleScope.StyleScope.createSelectorsFromCss(applicationCss, cssFileName);
// Add New CSS to Current Page
var f = frameCommon.topmost();
if (f && f.currentPage) {
f.currentPage._resetCssValues();
f.currentPage._styleScope = new styleScope.StyleScope();
//noinspection JSUnusedAssignment
f.currentPage._addCssInternal(applicationCss, cssFileName);
f.currentPage._refreshCss();
}
}
} | javascript | function loadCss() {
var cssFileName = fs.path.join(fs.knownFolders.currentApp().path, application.cssFile);
var applicationCss;
if (FSA.fileExists(cssFileName)) {
FSA.readText(cssFileName, function (r) { applicationCss = r; });
//noinspection JSUnusedAssignment
application.cssSelectorsCache = styleScope.StyleScope.createSelectorsFromCss(applicationCss, cssFileName);
// Add New CSS to Current Page
var f = frameCommon.topmost();
if (f && f.currentPage) {
f.currentPage._resetCssValues();
f.currentPage._styleScope = new styleScope.StyleScope();
//noinspection JSUnusedAssignment
f.currentPage._addCssInternal(applicationCss, cssFileName);
f.currentPage._refreshCss();
}
}
} | [
"function",
"loadCss",
"(",
")",
"{",
"var",
"cssFileName",
"=",
"fs",
".",
"path",
".",
"join",
"(",
"fs",
".",
"knownFolders",
".",
"currentApp",
"(",
")",
".",
"path",
",",
"application",
".",
"cssFile",
")",
";",
"var",
"applicationCss",
";",
"if",... | This is the loadCss helper function to replace the one on Application | [
"This",
"is",
"the",
"loadCss",
"helper",
"function",
"to",
"replace",
"the",
"one",
"on",
"Application"
] | 40fc852012d36f08d10669d4a79fc7a260a1618d | https://github.com/NathanaelA/nativescript-liveedit/blob/40fc852012d36f08d10669d4a79fc7a260a1618d/liveedit.ios.js#L354-L373 |
33,271 | NathanaelA/nativescript-liveedit | liveedit.ios.js | loadPageCss | function loadPageCss(cssFile) {
var cssFileName;
// Eliminate the ./ on the file if present so that we can add the full path
if (cssFile.startsWith("./")) {
cssFile = cssFile.substring(2);
}
if (cssFile.startsWith(UpdaterSingleton.currentAppPath())) {
cssFileName = cssFile;
} else {
cssFileName = fs.path.join(UpdaterSingleton.currentAppPath(), cssFile);
}
var applicationCss;
if (FSA.fileExists(cssFileName)) {
FSA.readText(cssFileName, function (r) { applicationCss = r; });
// Add New CSS to Current Page
var f = frameCommon.topmost();
if (f && f.currentPage) {
f.currentPage._resetCssValues();
f.currentPage._styleScope = new styleScope.StyleScope();
//noinspection JSUnusedAssignment
f.currentPage._addCssInternal(applicationCss, cssFileName);
f.currentPage._refreshCss();
}
}
} | javascript | function loadPageCss(cssFile) {
var cssFileName;
// Eliminate the ./ on the file if present so that we can add the full path
if (cssFile.startsWith("./")) {
cssFile = cssFile.substring(2);
}
if (cssFile.startsWith(UpdaterSingleton.currentAppPath())) {
cssFileName = cssFile;
} else {
cssFileName = fs.path.join(UpdaterSingleton.currentAppPath(), cssFile);
}
var applicationCss;
if (FSA.fileExists(cssFileName)) {
FSA.readText(cssFileName, function (r) { applicationCss = r; });
// Add New CSS to Current Page
var f = frameCommon.topmost();
if (f && f.currentPage) {
f.currentPage._resetCssValues();
f.currentPage._styleScope = new styleScope.StyleScope();
//noinspection JSUnusedAssignment
f.currentPage._addCssInternal(applicationCss, cssFileName);
f.currentPage._refreshCss();
}
}
} | [
"function",
"loadPageCss",
"(",
"cssFile",
")",
"{",
"var",
"cssFileName",
";",
"// Eliminate the ./ on the file if present so that we can add the full path",
"if",
"(",
"cssFile",
".",
"startsWith",
"(",
"\"./\"",
")",
")",
"{",
"cssFile",
"=",
"cssFile",
".",
"subst... | Override a single page's css
@param cssFile | [
"Override",
"a",
"single",
"page",
"s",
"css"
] | 40fc852012d36f08d10669d4a79fc7a260a1618d | https://github.com/NathanaelA/nativescript-liveedit/blob/40fc852012d36f08d10669d4a79fc7a260a1618d/liveedit.ios.js#L379-L407 |
33,272 | Zimbra-Community/js-zimbra | lib/api/response.js | ResponseApi | function ResponseApi(constructorOptions) {
LOG.debug('Instantiating new response object');
LOG.debug('Validating options');
try {
this.options =
new responseOptions.Constructor().validate(constructorOptions);
} catch (err) {
LOG.error('Received error: %s', err);
throw(err);
}
this.response = {};
this.isBatch = false;
this._createResponseView();
} | javascript | function ResponseApi(constructorOptions) {
LOG.debug('Instantiating new response object');
LOG.debug('Validating options');
try {
this.options =
new responseOptions.Constructor().validate(constructorOptions);
} catch (err) {
LOG.error('Received error: %s', err);
throw(err);
}
this.response = {};
this.isBatch = false;
this._createResponseView();
} | [
"function",
"ResponseApi",
"(",
"constructorOptions",
")",
"{",
"LOG",
".",
"debug",
"(",
"'Instantiating new response object'",
")",
";",
"LOG",
".",
"debug",
"(",
"'Validating options'",
")",
";",
"try",
"{",
"this",
".",
"options",
"=",
"new",
"responseOption... | Response-handling API
@param {ResponseConstructorOptions} constructorOptions
Options for the constructor
@constructor
@throws {NoBatchResponse}
@throws {InvalidOptionError} | [
"Response",
"-",
"handling",
"API"
] | dc073847a04da093b848463942731d15d256f00d | https://github.com/Zimbra-Community/js-zimbra/blob/dc073847a04da093b848463942731d15d256f00d/lib/api/response.js#L22-L45 |
33,273 | lirown/graphql-custom-directive | src/index.js | wrapFieldsWithMiddleware | function wrapFieldsWithMiddleware(type, deepWrap = true, typeMet = {}) {
if (!type) {
return;
}
let fields = type._fields;
typeMet[type.name] = true;
for (let label in fields) {
let field = fields[label];
if (field && !typeMet[field.type.name]) {
if (!!field && typeof field == 'object') {
field.resolve = resolveMiddlewareWrapper(
field.resolve,
field.directives,
);
if (field.type._fields && deepWrap) {
wrapFieldsWithMiddleware(field.type, deepWrap, typeMet);
} else if (field.type.ofType && field.type.ofType._fields && deepWrap) {
let child = field.type;
while (child.ofType) {
child = child.ofType;
}
if (child._fields) {
wrapFieldsWithMiddleware(child._fields);
}
}
}
}
}
} | javascript | function wrapFieldsWithMiddleware(type, deepWrap = true, typeMet = {}) {
if (!type) {
return;
}
let fields = type._fields;
typeMet[type.name] = true;
for (let label in fields) {
let field = fields[label];
if (field && !typeMet[field.type.name]) {
if (!!field && typeof field == 'object') {
field.resolve = resolveMiddlewareWrapper(
field.resolve,
field.directives,
);
if (field.type._fields && deepWrap) {
wrapFieldsWithMiddleware(field.type, deepWrap, typeMet);
} else if (field.type.ofType && field.type.ofType._fields && deepWrap) {
let child = field.type;
while (child.ofType) {
child = child.ofType;
}
if (child._fields) {
wrapFieldsWithMiddleware(child._fields);
}
}
}
}
}
} | [
"function",
"wrapFieldsWithMiddleware",
"(",
"type",
",",
"deepWrap",
"=",
"true",
",",
"typeMet",
"=",
"{",
"}",
")",
"{",
"if",
"(",
"!",
"type",
")",
"{",
"return",
";",
"}",
"let",
"fields",
"=",
"type",
".",
"_fields",
";",
"typeMet",
"[",
"type... | Scanning the shema and wrapping the resolve of each field with the support
of the graphql custom directives resolve execution | [
"Scanning",
"the",
"shema",
"and",
"wrapping",
"the",
"resolve",
"of",
"each",
"field",
"with",
"the",
"support",
"of",
"the",
"graphql",
"custom",
"directives",
"resolve",
"execution"
] | 90b5a3641fda77cd484936a1e79909938955ee09 | https://github.com/lirown/graphql-custom-directive/blob/90b5a3641fda77cd484936a1e79909938955ee09/src/index.js#L144-L173 |
33,274 | NathanaelA/nativescript-liveedit | liveedit.android.js | reloadPage | function reloadPage(page, isModal) {
if (!LiveEditSingleton.enabled()) {
return;
}
var t = frameCommon.topmost();
if (!t) {
return;
}
if (!page) {
if (!t.currentEntry || !t.currentEntry.entry) {
return;
}
page = t.currentEntry.entry.moduleName;
if (!page) {
return;
}
}
if (LiveEditSingleton.isSuspended()) {
LiveEditSingleton._suspendedNavigate(page, isModal);
return;
}
if (isModal) {
reloadModal(page);
return;
}
var ext = "";
if (!page.endsWith(".js") && !page.endsWith(".xml")) {
ext = ".js";
}
var nextPage;
if (t._currentEntry && t._currentEntry.entry) {
nextPage = t._currentEntry.entry;
nextPage.animated = false;
} else {
nextPage = {moduleName: page, animated: false};
}
if (!nextPage.context) {
nextPage.context = {};
}
if (t._currentEntry && t._currentEntry.create) {
nextPage.create = t._currentEntry.create;
}
nextPage.context.liveSync = true;
nextPage.context.liveEdit = true;
// Disable it in the backstack
//nextPage.backstackVisible = false;
// Attempt to Go back, so that this is the one left in the queue
if (t.canGoBack()) {
//t._popFromFrameStack();
t.goBack();
} else {
nextPage.clearHistory = true;
}
// This should be before we navigate so that it is removed from the cache just before
// In case the goBack goes to the same page; we want it to return to the prior version in the cache; then
// we clear it so that we go to a new version.
__clearRequireCachedItem(LiveEditSingleton.currentAppPath() + page + ext);
__clearRequireCachedItem(LiveEditSingleton.currentAppPath() + "*" + LiveEditSingleton.currentAppPath() + page);
if (fileResolver.clearCache) {
fileResolver.clearCache();
}
// Navigate back to this page
try {
t.navigate(nextPage);
}
catch (err) {
console.log(err);
}
} | javascript | function reloadPage(page, isModal) {
if (!LiveEditSingleton.enabled()) {
return;
}
var t = frameCommon.topmost();
if (!t) {
return;
}
if (!page) {
if (!t.currentEntry || !t.currentEntry.entry) {
return;
}
page = t.currentEntry.entry.moduleName;
if (!page) {
return;
}
}
if (LiveEditSingleton.isSuspended()) {
LiveEditSingleton._suspendedNavigate(page, isModal);
return;
}
if (isModal) {
reloadModal(page);
return;
}
var ext = "";
if (!page.endsWith(".js") && !page.endsWith(".xml")) {
ext = ".js";
}
var nextPage;
if (t._currentEntry && t._currentEntry.entry) {
nextPage = t._currentEntry.entry;
nextPage.animated = false;
} else {
nextPage = {moduleName: page, animated: false};
}
if (!nextPage.context) {
nextPage.context = {};
}
if (t._currentEntry && t._currentEntry.create) {
nextPage.create = t._currentEntry.create;
}
nextPage.context.liveSync = true;
nextPage.context.liveEdit = true;
// Disable it in the backstack
//nextPage.backstackVisible = false;
// Attempt to Go back, so that this is the one left in the queue
if (t.canGoBack()) {
//t._popFromFrameStack();
t.goBack();
} else {
nextPage.clearHistory = true;
}
// This should be before we navigate so that it is removed from the cache just before
// In case the goBack goes to the same page; we want it to return to the prior version in the cache; then
// we clear it so that we go to a new version.
__clearRequireCachedItem(LiveEditSingleton.currentAppPath() + page + ext);
__clearRequireCachedItem(LiveEditSingleton.currentAppPath() + "*" + LiveEditSingleton.currentAppPath() + page);
if (fileResolver.clearCache) {
fileResolver.clearCache();
}
// Navigate back to this page
try {
t.navigate(nextPage);
}
catch (err) {
console.log(err);
}
} | [
"function",
"reloadPage",
"(",
"page",
",",
"isModal",
")",
"{",
"if",
"(",
"!",
"LiveEditSingleton",
".",
"enabled",
"(",
")",
")",
"{",
"return",
";",
"}",
"var",
"t",
"=",
"frameCommon",
".",
"topmost",
"(",
")",
";",
"if",
"(",
"!",
"t",
")",
... | This is a helper function to reload the current page
@param page | [
"This",
"is",
"a",
"helper",
"function",
"to",
"reload",
"the",
"current",
"page"
] | 40fc852012d36f08d10669d4a79fc7a260a1618d | https://github.com/NathanaelA/nativescript-liveedit/blob/40fc852012d36f08d10669d4a79fc7a260a1618d/liveedit.android.js#L789-L873 |
33,275 | NathanaelA/nativescript-liveedit | support/watcher.js | isWatching | function isWatching(fileName) {
for (var i=0;i<watching.length;i++) {
if (fileName.endsWith(watching[i])) {
return true;
}
}
//noinspection RedundantIfStatementJS
if (fileName.toLowerCase().lastIndexOf("restart.livesync") === (fileName.length - 16)) {
return true;
}
//noinspection RedundantIfStatementJS
if (fileName.toLowerCase().lastIndexOf("restart.liveedit") === (fileName.length - 16)) {
return true;
}
return false;
} | javascript | function isWatching(fileName) {
for (var i=0;i<watching.length;i++) {
if (fileName.endsWith(watching[i])) {
return true;
}
}
//noinspection RedundantIfStatementJS
if (fileName.toLowerCase().lastIndexOf("restart.livesync") === (fileName.length - 16)) {
return true;
}
//noinspection RedundantIfStatementJS
if (fileName.toLowerCase().lastIndexOf("restart.liveedit") === (fileName.length - 16)) {
return true;
}
return false;
} | [
"function",
"isWatching",
"(",
"fileName",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"watching",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"fileName",
".",
"endsWith",
"(",
"watching",
"[",
"i",
"]",
")",
")",
"{",
"r... | isWatching - will respond true if watching this file type.
@param fileName
@returns {boolean} | [
"isWatching",
"-",
"will",
"respond",
"true",
"if",
"watching",
"this",
"file",
"type",
"."
] | 40fc852012d36f08d10669d4a79fc7a260a1618d | https://github.com/NathanaelA/nativescript-liveedit/blob/40fc852012d36f08d10669d4a79fc7a260a1618d/support/watcher.js#L206-L221 |
33,276 | NathanaelA/nativescript-liveedit | support/watcher.js | normalPushADB | function normalPushADB(fileName, options, callback) {
if (typeof options === "function") {
callback = options;
options = null;
}
var srcFile = fileName;
if (options && typeof options.srcFile === "string") {
srcFile = options.srcFile;
}
var check = false;
if (options && options.check) {
check = true;
}
var quiet = false;
if (options && options.quiet) {
quiet = true;
}
var path = "/data/data/" + projectData.nativescript.id + "/files/" + fileName;
cp.exec('adb push "'+srcFile+'" "' + path + '"', {timeout: 10000}, function(err, sout, serr) {
if (err) {
if (sout.indexOf('Permission denied') > 0) { pushADB = backupPushADB; console.log("Using backup method for updates!"); }
if (serr.indexOf('Permission denied') > 0) { pushADB = backupPushADB; console.log("Using backup method for updates!"); }
if (check !== true) {
console.log("Failed to Push to Device: ", fileName);
console.log(err);
//console.log(sout);
//console.log(serr);
}
} else if (check !== true && quiet === false ) {
console.log("Pushed to Device: ", fileName);
}
if (callback) {
callback(err);
}
});
} | javascript | function normalPushADB(fileName, options, callback) {
if (typeof options === "function") {
callback = options;
options = null;
}
var srcFile = fileName;
if (options && typeof options.srcFile === "string") {
srcFile = options.srcFile;
}
var check = false;
if (options && options.check) {
check = true;
}
var quiet = false;
if (options && options.quiet) {
quiet = true;
}
var path = "/data/data/" + projectData.nativescript.id + "/files/" + fileName;
cp.exec('adb push "'+srcFile+'" "' + path + '"', {timeout: 10000}, function(err, sout, serr) {
if (err) {
if (sout.indexOf('Permission denied') > 0) { pushADB = backupPushADB; console.log("Using backup method for updates!"); }
if (serr.indexOf('Permission denied') > 0) { pushADB = backupPushADB; console.log("Using backup method for updates!"); }
if (check !== true) {
console.log("Failed to Push to Device: ", fileName);
console.log(err);
//console.log(sout);
//console.log(serr);
}
} else if (check !== true && quiet === false ) {
console.log("Pushed to Device: ", fileName);
}
if (callback) {
callback(err);
}
});
} | [
"function",
"normalPushADB",
"(",
"fileName",
",",
"options",
",",
"callback",
")",
"{",
"if",
"(",
"typeof",
"options",
"===",
"\"function\"",
")",
"{",
"callback",
"=",
"options",
";",
"options",
"=",
"null",
";",
"}",
"var",
"srcFile",
"=",
"fileName",
... | This runs the adb command so that we can push the file up to the emulator or device
@param fileName
@param options
@param callback | [
"This",
"runs",
"the",
"adb",
"command",
"so",
"that",
"we",
"can",
"push",
"the",
"file",
"up",
"to",
"the",
"emulator",
"or",
"device"
] | 40fc852012d36f08d10669d4a79fc7a260a1618d | https://github.com/NathanaelA/nativescript-liveedit/blob/40fc852012d36f08d10669d4a79fc7a260a1618d/support/watcher.js#L329-L367 |
33,277 | NathanaelA/nativescript-liveedit | support/watcher.js | getWatcher | function getWatcher(dir) {
return function (event, fileName) {
if (event === "rename") {
verifyWatches();
if (fileName) {
if (!fs.existsSync(dir + fileName)) { return; }
var dirStat;
try {
dirStat = fs.statSync(dir + fileName);
} catch (err) {
// This means the File disappeared out from under me...
return;
}
if (dirStat.isDirectory()) {
if (!watchingFolders[dir + fileName]) {
console.log("Adding new directory to watch: ", dir + fileName);
setupWatchers(dir + fileName);
}
return;
}
} else {
checkForChangedFolders(dir);
}
return;
}
if (!fileName) {
fileName = checkForChangedFiles(dir);
if (fileName) {
checkCache(fileName);
}
}
else {
if (isWatching(fileName)) {
if (!fs.existsSync(dir + fileName)) {
return;
}
var stat;
try {
stat = fs.statSync(dir + fileName);
}
catch (e) {
// This means the file disappeared between exists and stat...
return;
}
if (stat.size === 0) { return; }
if (timeStamps[dir + fileName] === undefined || timeStamps[dir + fileName] !== stat.mtime.getTime()) {
//console.log("Found 2: ", event, dir+fileName, stat.mtime.getTime(), stat.mtime, stat.ctime.getTime(), stat.size);
timeStamps[dir + fileName] = stat.mtime.getTime();
checkCache(dir + fileName);
}
}
}
};
} | javascript | function getWatcher(dir) {
return function (event, fileName) {
if (event === "rename") {
verifyWatches();
if (fileName) {
if (!fs.existsSync(dir + fileName)) { return; }
var dirStat;
try {
dirStat = fs.statSync(dir + fileName);
} catch (err) {
// This means the File disappeared out from under me...
return;
}
if (dirStat.isDirectory()) {
if (!watchingFolders[dir + fileName]) {
console.log("Adding new directory to watch: ", dir + fileName);
setupWatchers(dir + fileName);
}
return;
}
} else {
checkForChangedFolders(dir);
}
return;
}
if (!fileName) {
fileName = checkForChangedFiles(dir);
if (fileName) {
checkCache(fileName);
}
}
else {
if (isWatching(fileName)) {
if (!fs.existsSync(dir + fileName)) {
return;
}
var stat;
try {
stat = fs.statSync(dir + fileName);
}
catch (e) {
// This means the file disappeared between exists and stat...
return;
}
if (stat.size === 0) { return; }
if (timeStamps[dir + fileName] === undefined || timeStamps[dir + fileName] !== stat.mtime.getTime()) {
//console.log("Found 2: ", event, dir+fileName, stat.mtime.getTime(), stat.mtime, stat.ctime.getTime(), stat.size);
timeStamps[dir + fileName] = stat.mtime.getTime();
checkCache(dir + fileName);
}
}
}
};
} | [
"function",
"getWatcher",
"(",
"dir",
")",
"{",
"return",
"function",
"(",
"event",
",",
"fileName",
")",
"{",
"if",
"(",
"event",
"===",
"\"rename\"",
")",
"{",
"verifyWatches",
"(",
")",
";",
"if",
"(",
"fileName",
")",
"{",
"if",
"(",
"!",
"fs",
... | This is the watcher callback to verify the file actually changed
@param dir
@returns {Function} | [
"This",
"is",
"the",
"watcher",
"callback",
"to",
"verify",
"the",
"file",
"actually",
"changed"
] | 40fc852012d36f08d10669d4a79fc7a260a1618d | https://github.com/NathanaelA/nativescript-liveedit/blob/40fc852012d36f08d10669d4a79fc7a260a1618d/support/watcher.js#L616-L673 |
33,278 | NathanaelA/nativescript-liveedit | support/watcher.js | setupWatchers | function setupWatchers(path) {
// We want to track the watchers now and return if we are already watching this folder
if (watchingFolders[path]) { return; }
watchingFolders[path] = fs.watch(path, getWatcher(path + "/"));
watchingFolders[path].on('error', function() { verifyWatches(); });
var fileList = fs.readdirSync(path);
var stats;
for (var i = 0; i < fileList.length; i++) {
try {
stats = fs.statSync(path + "/" + fileList[i]);
}
catch (e) {
continue;
}
if (isWatching(fileList[i])) {
timeStamps[path + "/" + fileList[i]] = stats.mtime.getTime();
} else {
if (stats.isDirectory()) {
if (fileList[i] === "node_modules") {
watchingFolders[path + "/" + fileList[i]] = true;
continue;
}
if (fileList[i] === "tns_modules") {
watchingFolders[path + "/" + fileList[i]] = true;
continue;
}
if (fileList[i] === "App_Resources") {
watchingFolders[path + "/" + fileList[i]] = true;
continue;
}
setupWatchers(path + "/" + fileList[i]);
}
}
}
} | javascript | function setupWatchers(path) {
// We want to track the watchers now and return if we are already watching this folder
if (watchingFolders[path]) { return; }
watchingFolders[path] = fs.watch(path, getWatcher(path + "/"));
watchingFolders[path].on('error', function() { verifyWatches(); });
var fileList = fs.readdirSync(path);
var stats;
for (var i = 0; i < fileList.length; i++) {
try {
stats = fs.statSync(path + "/" + fileList[i]);
}
catch (e) {
continue;
}
if (isWatching(fileList[i])) {
timeStamps[path + "/" + fileList[i]] = stats.mtime.getTime();
} else {
if (stats.isDirectory()) {
if (fileList[i] === "node_modules") {
watchingFolders[path + "/" + fileList[i]] = true;
continue;
}
if (fileList[i] === "tns_modules") {
watchingFolders[path + "/" + fileList[i]] = true;
continue;
}
if (fileList[i] === "App_Resources") {
watchingFolders[path + "/" + fileList[i]] = true;
continue;
}
setupWatchers(path + "/" + fileList[i]);
}
}
}
} | [
"function",
"setupWatchers",
"(",
"path",
")",
"{",
"// We want to track the watchers now and return if we are already watching this folder",
"if",
"(",
"watchingFolders",
"[",
"path",
"]",
")",
"{",
"return",
";",
"}",
"watchingFolders",
"[",
"path",
"]",
"=",
"fs",
... | This setups a watcher on a directory
@param path | [
"This",
"setups",
"a",
"watcher",
"on",
"a",
"directory"
] | 40fc852012d36f08d10669d4a79fc7a260a1618d | https://github.com/NathanaelA/nativescript-liveedit/blob/40fc852012d36f08d10669d4a79fc7a260a1618d/support/watcher.js#L679-L714 |
33,279 | Zimbra-Community/js-zimbra | lib/api/communication.js | CommunicationApi | function CommunicationApi(constructorOptions) {
LOG.debug('Instantiating communication API');
LOG.debug('Validating constructor options');
// Sanitize option eventually throwing an InvalidOption
try {
this.options =
new communicationOptions.Constructor().validate(constructorOptions);
} catch (err) {
throw(
err
);
}
if (this.options.token !== '') {
LOG.debug('Setting predefined token');
this.token = this.options.token;
} else {
this.token = null;
}
} | javascript | function CommunicationApi(constructorOptions) {
LOG.debug('Instantiating communication API');
LOG.debug('Validating constructor options');
// Sanitize option eventually throwing an InvalidOption
try {
this.options =
new communicationOptions.Constructor().validate(constructorOptions);
} catch (err) {
throw(
err
);
}
if (this.options.token !== '') {
LOG.debug('Setting predefined token');
this.token = this.options.token;
} else {
this.token = null;
}
} | [
"function",
"CommunicationApi",
"(",
"constructorOptions",
")",
"{",
"LOG",
".",
"debug",
"(",
"'Instantiating communication API'",
")",
";",
"LOG",
".",
"debug",
"(",
"'Validating constructor options'",
")",
";",
"// Sanitize option eventually throwing an InvalidOption",
"... | Communications-Handling API
@param {CommunicationConstructorOptions} constructorOptions
Options for constructor
@constructor
@throws {InvalidOptionError} | [
"Communications",
"-",
"Handling",
"API"
] | dc073847a04da093b848463942731d15d256f00d | https://github.com/Zimbra-Community/js-zimbra/blob/dc073847a04da093b848463942731d15d256f00d/lib/api/communication.js#L27-L59 |
33,280 | Zimbra-Community/js-zimbra | lib/api/request.js | RequestApi | function RequestApi(constructorOptions) {
LOG.debug('Instantiating new Request object');
LOG.debug('Validating options');
try {
this.options =
new requestOptions.Constructor().validate(constructorOptions);
} catch (err) {
LOG.error('Received error: %s', err);
throw(
err
);
}
this.requests = [];
this.batchId = 1;
} | javascript | function RequestApi(constructorOptions) {
LOG.debug('Instantiating new Request object');
LOG.debug('Validating options');
try {
this.options =
new requestOptions.Constructor().validate(constructorOptions);
} catch (err) {
LOG.error('Received error: %s', err);
throw(
err
);
}
this.requests = [];
this.batchId = 1;
} | [
"function",
"RequestApi",
"(",
"constructorOptions",
")",
"{",
"LOG",
".",
"debug",
"(",
"'Instantiating new Request object'",
")",
";",
"LOG",
".",
"debug",
"(",
"'Validating options'",
")",
";",
"try",
"{",
"this",
".",
"options",
"=",
"new",
"requestOptions",... | Request-handling API
@param {ResponseConstructorOptions} Options for the
constructor
@constructor
@throws {InvalidOptionError} | [
"Request",
"-",
"handling",
"API"
] | dc073847a04da093b848463942731d15d256f00d | https://github.com/Zimbra-Community/js-zimbra/blob/dc073847a04da093b848463942731d15d256f00d/lib/api/request.js#L23-L46 |
33,281 | fent/node-torrent | lib/hasher.js | round | function round(num, dec) {
var pow = Math.pow(10, dec);
return Math.round(num * pow) / pow;
} | javascript | function round(num, dec) {
var pow = Math.pow(10, dec);
return Math.round(num * pow) / pow;
} | [
"function",
"round",
"(",
"num",
",",
"dec",
")",
"{",
"var",
"pow",
"=",
"Math",
".",
"pow",
"(",
"10",
",",
"dec",
")",
";",
"return",
"Math",
".",
"round",
"(",
"num",
"*",
"pow",
")",
"/",
"pow",
";",
"}"
] | Rounds a number to given decimal place.
@param {Number} num
@param {Number} dec
@return {Number} | [
"Rounds",
"a",
"number",
"to",
"given",
"decimal",
"place",
"."
] | a6784b78867d3f026a54c0445abf2e18dc82323c | https://github.com/fent/node-torrent/blob/a6784b78867d3f026a54c0445abf2e18dc82323c/lib/hasher.js#L38-L41 |
33,282 | c9/vfs-http-adapter | restful.js | jsonEncoder | function jsonEncoder(input, path) {
var output = new Stream();
output.readable = true;
var first = true;
input.on("data", function (entry) {
if (path) {
entry.href = path + entry.name;
var mime = entry.linkStat ? entry.linkStat.mime : entry.mime;
if (mime && mime.match(/(directory|folder)$/)) {
entry.href += "/";
}
}
if (first) {
output.emit("data", "[\n " + JSON.stringify(entry));
first = false;
} else {
output.emit("data", ",\n " + JSON.stringify(entry));
}
});
input.on("end", function () {
if (first) output.emit("data", "[]");
else output.emit("data", "\n]");
output.emit("end");
});
if (input.pause) {
output.pause = function () {
input.pause();
};
}
if (input.resume) {
output.resume = function () {
input.resume();
};
}
return output;
} | javascript | function jsonEncoder(input, path) {
var output = new Stream();
output.readable = true;
var first = true;
input.on("data", function (entry) {
if (path) {
entry.href = path + entry.name;
var mime = entry.linkStat ? entry.linkStat.mime : entry.mime;
if (mime && mime.match(/(directory|folder)$/)) {
entry.href += "/";
}
}
if (first) {
output.emit("data", "[\n " + JSON.stringify(entry));
first = false;
} else {
output.emit("data", ",\n " + JSON.stringify(entry));
}
});
input.on("end", function () {
if (first) output.emit("data", "[]");
else output.emit("data", "\n]");
output.emit("end");
});
if (input.pause) {
output.pause = function () {
input.pause();
};
}
if (input.resume) {
output.resume = function () {
input.resume();
};
}
return output;
} | [
"function",
"jsonEncoder",
"(",
"input",
",",
"path",
")",
"{",
"var",
"output",
"=",
"new",
"Stream",
"(",
")",
";",
"output",
".",
"readable",
"=",
"true",
";",
"var",
"first",
"=",
"true",
";",
"input",
".",
"on",
"(",
"\"data\"",
",",
"function",... | Returns a json stream that wraps input object stream | [
"Returns",
"a",
"json",
"stream",
"that",
"wraps",
"input",
"object",
"stream"
] | 89b1253e0f10c0a2edacd9a69d99cb20f95bfa73 | https://github.com/c9/vfs-http-adapter/blob/89b1253e0f10c0a2edacd9a69d99cb20f95bfa73/restful.js#L26-L61 |
33,283 | TheRusskiy/pusher-redux | lib/pusher-redux.js | function (options) {
var result = {
type: options.actionType
};
if (options.channelName) {
result.channel = options.channelName
}
if (options.eventName) {
result.event = options.eventName
}
if (options.data) {
result.data = options.data
}
if (options.additionalParams) {
result.additionalParams = options.additionalParams
}
return result;
} | javascript | function (options) {
var result = {
type: options.actionType
};
if (options.channelName) {
result.channel = options.channelName
}
if (options.eventName) {
result.event = options.eventName
}
if (options.data) {
result.data = options.data
}
if (options.additionalParams) {
result.additionalParams = options.additionalParams
}
return result;
} | [
"function",
"(",
"options",
")",
"{",
"var",
"result",
"=",
"{",
"type",
":",
"options",
".",
"actionType",
"}",
";",
"if",
"(",
"options",
".",
"channelName",
")",
"{",
"result",
".",
"channel",
"=",
"options",
".",
"channelName",
"}",
"if",
"(",
"o... | create redux action | [
"create",
"redux",
"action"
] | 683a9c3cbdea0d8f0b29f547250c4ab6468bddd6 | https://github.com/TheRusskiy/pusher-redux/blob/683a9c3cbdea0d8f0b29f547250c4ab6468bddd6/lib/pusher-redux.js#L23-L40 | |
33,284 | cozy/cozy-emails | client/plugins/keyboard/js/mousetrap.js | _characterFromEvent | function _characterFromEvent(e) {
// for keypress events we should return the character as is
if (e.type == 'keypress') {
var character = String.fromCharCode(e.which);
// if the shift key is not pressed then it is safe to assume
// that we want the character to be lowercase. this means if
// you accidentally have caps lock on then your key bindings
// will continue to work
//
// the only side effect that might not be desired is if you
// bind something like 'A' cause you want to trigger an
// event when capital A is pressed caps lock will no longer
// trigger the event. shift+a will though.
if (!e.shiftKey) {
character = character.toLowerCase();
}
return character;
}
// for non keypress events the special maps are needed
if (_MAP[e.which]) {
return _MAP[e.which];
}
if (_KEYCODE_MAP[e.which]) {
return _KEYCODE_MAP[e.which];
}
// if it is not in the special map
// with keydown and keyup events the character seems to always
// come in as an uppercase character whether you are pressing shift
// or not. we should make sure it is always lowercase for comparisons
return String.fromCharCode(e.which).toLowerCase();
} | javascript | function _characterFromEvent(e) {
// for keypress events we should return the character as is
if (e.type == 'keypress') {
var character = String.fromCharCode(e.which);
// if the shift key is not pressed then it is safe to assume
// that we want the character to be lowercase. this means if
// you accidentally have caps lock on then your key bindings
// will continue to work
//
// the only side effect that might not be desired is if you
// bind something like 'A' cause you want to trigger an
// event when capital A is pressed caps lock will no longer
// trigger the event. shift+a will though.
if (!e.shiftKey) {
character = character.toLowerCase();
}
return character;
}
// for non keypress events the special maps are needed
if (_MAP[e.which]) {
return _MAP[e.which];
}
if (_KEYCODE_MAP[e.which]) {
return _KEYCODE_MAP[e.which];
}
// if it is not in the special map
// with keydown and keyup events the character seems to always
// come in as an uppercase character whether you are pressing shift
// or not. we should make sure it is always lowercase for comparisons
return String.fromCharCode(e.which).toLowerCase();
} | [
"function",
"_characterFromEvent",
"(",
"e",
")",
"{",
"// for keypress events we should return the character as is",
"if",
"(",
"e",
".",
"type",
"==",
"'keypress'",
")",
"{",
"var",
"character",
"=",
"String",
".",
"fromCharCode",
"(",
"e",
".",
"which",
")",
... | takes the event and returns the key character
@param {Event} e
@return {string} | [
"takes",
"the",
"event",
"and",
"returns",
"the",
"key",
"character"
] | e31b4e724e6310a3e0451ab1703857287aef1f6f | https://github.com/cozy/cozy-emails/blob/e31b4e724e6310a3e0451ab1703857287aef1f6f/client/plugins/keyboard/js/mousetrap.js#L180-L217 |
33,285 | cozy/cozy-emails | client/plugins/keyboard/js/mousetrap.js | _eventModifiers | function _eventModifiers(e) {
var modifiers = [];
if (e.shiftKey) {
modifiers.push('shift');
}
if (e.altKey) {
modifiers.push('alt');
}
if (e.ctrlKey) {
modifiers.push('ctrl');
}
if (e.metaKey) {
modifiers.push('meta');
}
return modifiers;
} | javascript | function _eventModifiers(e) {
var modifiers = [];
if (e.shiftKey) {
modifiers.push('shift');
}
if (e.altKey) {
modifiers.push('alt');
}
if (e.ctrlKey) {
modifiers.push('ctrl');
}
if (e.metaKey) {
modifiers.push('meta');
}
return modifiers;
} | [
"function",
"_eventModifiers",
"(",
"e",
")",
"{",
"var",
"modifiers",
"=",
"[",
"]",
";",
"if",
"(",
"e",
".",
"shiftKey",
")",
"{",
"modifiers",
".",
"push",
"(",
"'shift'",
")",
";",
"}",
"if",
"(",
"e",
".",
"altKey",
")",
"{",
"modifiers",
"... | takes a key event and figures out what the modifiers are
@param {Event} e
@returns {Array} | [
"takes",
"a",
"key",
"event",
"and",
"figures",
"out",
"what",
"the",
"modifiers",
"are"
] | e31b4e724e6310a3e0451ab1703857287aef1f6f | https://github.com/cozy/cozy-emails/blob/e31b4e724e6310a3e0451ab1703857287aef1f6f/client/plugins/keyboard/js/mousetrap.js#L236-L256 |
33,286 | cozy/cozy-emails | client/plugins/keyboard/js/mousetrap.js | _pickBestAction | function _pickBestAction(key, modifiers, action) {
// if no action was picked in we should try to pick the one
// that we think would work best for this key
if (!action) {
action = _getReverseMap()[key] ? 'keydown' : 'keypress';
}
// modifier keys don't work as expected with keypress,
// switch to keydown
if (action == 'keypress' && modifiers.length) {
action = 'keydown';
}
return action;
} | javascript | function _pickBestAction(key, modifiers, action) {
// if no action was picked in we should try to pick the one
// that we think would work best for this key
if (!action) {
action = _getReverseMap()[key] ? 'keydown' : 'keypress';
}
// modifier keys don't work as expected with keypress,
// switch to keydown
if (action == 'keypress' && modifiers.length) {
action = 'keydown';
}
return action;
} | [
"function",
"_pickBestAction",
"(",
"key",
",",
"modifiers",
",",
"action",
")",
"{",
"// if no action was picked in we should try to pick the one",
"// that we think would work best for this key",
"if",
"(",
"!",
"action",
")",
"{",
"action",
"=",
"_getReverseMap",
"(",
... | picks the best action based on the key combination
@param {string} key - character for key
@param {Array} modifiers
@param {string=} action passed in | [
"picks",
"the",
"best",
"action",
"based",
"on",
"the",
"key",
"combination"
] | e31b4e724e6310a3e0451ab1703857287aef1f6f | https://github.com/cozy/cozy-emails/blob/e31b4e724e6310a3e0451ab1703857287aef1f6f/client/plugins/keyboard/js/mousetrap.js#L330-L345 |
33,287 | cozy/cozy-emails | client/plugins/keyboard/js/mousetrap.js | _resetSequences | function _resetSequences(doNotReset) {
doNotReset = doNotReset || {};
var activeSequences = false,
key;
for (key in _sequenceLevels) {
if (doNotReset[key]) {
activeSequences = true;
continue;
}
_sequenceLevels[key] = 0;
}
if (!activeSequences) {
_nextExpectedAction = false;
}
} | javascript | function _resetSequences(doNotReset) {
doNotReset = doNotReset || {};
var activeSequences = false,
key;
for (key in _sequenceLevels) {
if (doNotReset[key]) {
activeSequences = true;
continue;
}
_sequenceLevels[key] = 0;
}
if (!activeSequences) {
_nextExpectedAction = false;
}
} | [
"function",
"_resetSequences",
"(",
"doNotReset",
")",
"{",
"doNotReset",
"=",
"doNotReset",
"||",
"{",
"}",
";",
"var",
"activeSequences",
"=",
"false",
",",
"key",
";",
"for",
"(",
"key",
"in",
"_sequenceLevels",
")",
"{",
"if",
"(",
"doNotReset",
"[",
... | resets all sequence counters except for the ones passed in
@param {Object} doNotReset
@returns void | [
"resets",
"all",
"sequence",
"counters",
"except",
"for",
"the",
"ones",
"passed",
"in"
] | e31b4e724e6310a3e0451ab1703857287aef1f6f | https://github.com/cozy/cozy-emails/blob/e31b4e724e6310a3e0451ab1703857287aef1f6f/client/plugins/keyboard/js/mousetrap.js#L497-L514 |
33,288 | cozy/cozy-emails | client/plugins/keyboard/js/mousetrap.js | _handleKeyEvent | function _handleKeyEvent(e) {
// normalize e.which for key events
// @see http://stackoverflow.com/questions/4285627/javascript-keycode-vs-charcode-utter-confusion
if (typeof e.which !== 'number') {
e.which = e.keyCode;
}
var character = _characterFromEvent(e);
// no character found then stop
if (!character) {
return;
}
// need to use === for the character check because the character can be 0
if (e.type == 'keyup' && _ignoreNextKeyup === character) {
_ignoreNextKeyup = false;
return;
}
self.handleKey(character, _eventModifiers(e), e);
} | javascript | function _handleKeyEvent(e) {
// normalize e.which for key events
// @see http://stackoverflow.com/questions/4285627/javascript-keycode-vs-charcode-utter-confusion
if (typeof e.which !== 'number') {
e.which = e.keyCode;
}
var character = _characterFromEvent(e);
// no character found then stop
if (!character) {
return;
}
// need to use === for the character check because the character can be 0
if (e.type == 'keyup' && _ignoreNextKeyup === character) {
_ignoreNextKeyup = false;
return;
}
self.handleKey(character, _eventModifiers(e), e);
} | [
"function",
"_handleKeyEvent",
"(",
"e",
")",
"{",
"// normalize e.which for key events",
"// @see http://stackoverflow.com/questions/4285627/javascript-keycode-vs-charcode-utter-confusion",
"if",
"(",
"typeof",
"e",
".",
"which",
"!==",
"'number'",
")",
"{",
"e",
".",
"which... | handles a keydown event
@param {Event} e
@returns void | [
"handles",
"a",
"keydown",
"event"
] | e31b4e724e6310a3e0451ab1703857287aef1f6f | https://github.com/cozy/cozy-emails/blob/e31b4e724e6310a3e0451ab1703857287aef1f6f/client/plugins/keyboard/js/mousetrap.js#L705-L727 |
33,289 | cozy/cozy-emails | client/plugins/keyboard/js/mousetrap.js | _bindSingle | function _bindSingle(combination, callback, action, sequenceName, level) {
// store a direct mapped reference for use with Mousetrap.trigger
self._directMap[combination + ':' + action] = callback;
// make sure multiple spaces in a row become a single space
combination = combination.replace(/\s+/g, ' ');
var sequence = combination.split(' ');
var info;
// if this pattern is a sequence of keys then run through this method
// to reprocess each pattern one key at a time
if (sequence.length > 1) {
_bindSequence(combination, sequence, callback, action);
return;
}
info = _getKeyInfo(combination, action);
// make sure to initialize array if this is the first time
// a callback is added for this key
self._callbacks[info.key] = self._callbacks[info.key] || [];
// remove an existing match if there is one
_getMatches(info.key, info.modifiers, {type: info.action}, sequenceName, combination, level);
// add this call back to the array
// if it is a sequence put it at the beginning
// if not put it at the end
//
// this is important because the way these are processed expects
// the sequence ones to come first
self._callbacks[info.key][sequenceName ? 'unshift' : 'push']({
callback: callback,
modifiers: info.modifiers,
action: info.action,
seq: sequenceName,
level: level,
combo: combination
});
} | javascript | function _bindSingle(combination, callback, action, sequenceName, level) {
// store a direct mapped reference for use with Mousetrap.trigger
self._directMap[combination + ':' + action] = callback;
// make sure multiple spaces in a row become a single space
combination = combination.replace(/\s+/g, ' ');
var sequence = combination.split(' ');
var info;
// if this pattern is a sequence of keys then run through this method
// to reprocess each pattern one key at a time
if (sequence.length > 1) {
_bindSequence(combination, sequence, callback, action);
return;
}
info = _getKeyInfo(combination, action);
// make sure to initialize array if this is the first time
// a callback is added for this key
self._callbacks[info.key] = self._callbacks[info.key] || [];
// remove an existing match if there is one
_getMatches(info.key, info.modifiers, {type: info.action}, sequenceName, combination, level);
// add this call back to the array
// if it is a sequence put it at the beginning
// if not put it at the end
//
// this is important because the way these are processed expects
// the sequence ones to come first
self._callbacks[info.key][sequenceName ? 'unshift' : 'push']({
callback: callback,
modifiers: info.modifiers,
action: info.action,
seq: sequenceName,
level: level,
combo: combination
});
} | [
"function",
"_bindSingle",
"(",
"combination",
",",
"callback",
",",
"action",
",",
"sequenceName",
",",
"level",
")",
"{",
"// store a direct mapped reference for use with Mousetrap.trigger",
"self",
".",
"_directMap",
"[",
"combination",
"+",
"':'",
"+",
"action",
"... | binds a single keyboard combination
@param {string} combination
@param {Function} callback
@param {string=} action
@param {string=} sequenceName - name of sequence if part of sequence
@param {number=} level - what part of the sequence the command is
@returns void | [
"binds",
"a",
"single",
"keyboard",
"combination"
] | e31b4e724e6310a3e0451ab1703857287aef1f6f | https://github.com/cozy/cozy-emails/blob/e31b4e724e6310a3e0451ab1703857287aef1f6f/client/plugins/keyboard/js/mousetrap.js#L820-L861 |
33,290 | cozy/cozy-emails | client/vendor/talkerjs-1.0.1.js | function(remoteWindow, remoteOrigin) {
this.remoteWindow = remoteWindow;
this.remoteOrigin = remoteOrigin;
this.timeout = 3000;
this.handshaken = false;
this.handshake = pinkySwearPromise();
this._id = 0;
this._queue = [];
this._sent = {};
var _this = this;
window.addEventListener('message', function(messageEvent) { _this._receiveMessage(messageEvent) }, false);
this._sendHandshake();
return this;
} | javascript | function(remoteWindow, remoteOrigin) {
this.remoteWindow = remoteWindow;
this.remoteOrigin = remoteOrigin;
this.timeout = 3000;
this.handshaken = false;
this.handshake = pinkySwearPromise();
this._id = 0;
this._queue = [];
this._sent = {};
var _this = this;
window.addEventListener('message', function(messageEvent) { _this._receiveMessage(messageEvent) }, false);
this._sendHandshake();
return this;
} | [
"function",
"(",
"remoteWindow",
",",
"remoteOrigin",
")",
"{",
"this",
".",
"remoteWindow",
"=",
"remoteWindow",
";",
"this",
".",
"remoteOrigin",
"=",
"remoteOrigin",
";",
"this",
".",
"timeout",
"=",
"3000",
";",
"this",
".",
"handshaken",
"=",
"false",
... | region Public Methods
Talker
Used to open a communication line between this window and a remote window via postMessage.
@param remoteWindow - The remote `window` object to post/receive messages to/from.
@property {Window} remoteWindow - The remote window object this Talker is communicating with
@property {string} remoteOrigin - The protocol, host, and port you expect the remote to be
@property {number} timeout - The number of milliseconds to wait before assuming no response will be received.
@property {boolean} handshaken - Whether we've received a handshake from the remote window
@property {function(Talker.Message)} onMessage - Will be called with every non-handshake, non-response message from the remote window
@property {Promise} handshake - Will be resolved when a handshake is newly established with the remote window.
@returns {Talker}
@constructor | [
"region",
"Public",
"Methods",
"Talker",
"Used",
"to",
"open",
"a",
"communication",
"line",
"between",
"this",
"window",
"and",
"a",
"remote",
"window",
"via",
"postMessage",
"."
] | e31b4e724e6310a3e0451ab1703857287aef1f6f | https://github.com/cozy/cozy-emails/blob/e31b4e724e6310a3e0451ab1703857287aef1f6f/client/vendor/talkerjs-1.0.1.js#L127-L143 | |
33,291 | natefaubion/adt.js | adt.js | function () {
var args = arguments;
var len = names.length;
if (this instanceof ctr) {
if (args.length !== len) {
throw new Error(
'Unexpected number of arguments for ' + ctr.className + ': ' +
'got ' + args.length + ', but need ' + len + '.'
);
}
var i = 0, n;
for (; n = names[i]; i++) {
this[n] = constraints[n](args[i], n, ctr);
}
} else {
return args.length < len
? partial(ctr, toArray(args))
: ctrApply(ctr, args);
}
} | javascript | function () {
var args = arguments;
var len = names.length;
if (this instanceof ctr) {
if (args.length !== len) {
throw new Error(
'Unexpected number of arguments for ' + ctr.className + ': ' +
'got ' + args.length + ', but need ' + len + '.'
);
}
var i = 0, n;
for (; n = names[i]; i++) {
this[n] = constraints[n](args[i], n, ctr);
}
} else {
return args.length < len
? partial(ctr, toArray(args))
: ctrApply(ctr, args);
}
} | [
"function",
"(",
")",
"{",
"var",
"args",
"=",
"arguments",
";",
"var",
"len",
"=",
"names",
".",
"length",
";",
"if",
"(",
"this",
"instanceof",
"ctr",
")",
"{",
"if",
"(",
"args",
".",
"length",
"!==",
"len",
")",
"{",
"throw",
"new",
"Error",
... | A record's constructor can be called without `new` and will also throw an error if called with the wrong number of arguments. Its arguments can be curried as long as it isn't called with the `new` keyword. | [
"A",
"record",
"s",
"constructor",
"can",
"be",
"called",
"without",
"new",
"and",
"will",
"also",
"throw",
"an",
"error",
"if",
"called",
"with",
"the",
"wrong",
"number",
"of",
"arguments",
".",
"Its",
"arguments",
"can",
"be",
"curried",
"as",
"long",
... | 0163b8ea3b3f8f3f8c6ea53c672f3a670c4ce9d6 | https://github.com/natefaubion/adt.js/blob/0163b8ea3b3f8f3f8c6ea53c672f3a670c4ce9d6/adt.js#L194-L213 | |
33,292 | natefaubion/adt.js | adt.js | function () {
var ctr = this.constructor;
var names = ctr.__names__;
var args = [], i = 0, n, val;
for (; n = names[i]; i++) {
val = this[n];
args[i] = val instanceof adt.__Base__
? val.clone()
: adt.nativeClone(val);
}
return ctr.apply(null, args);
} | javascript | function () {
var ctr = this.constructor;
var names = ctr.__names__;
var args = [], i = 0, n, val;
for (; n = names[i]; i++) {
val = this[n];
args[i] = val instanceof adt.__Base__
? val.clone()
: adt.nativeClone(val);
}
return ctr.apply(null, args);
} | [
"function",
"(",
")",
"{",
"var",
"ctr",
"=",
"this",
".",
"constructor",
";",
"var",
"names",
"=",
"ctr",
".",
"__names__",
";",
"var",
"args",
"=",
"[",
"]",
",",
"i",
"=",
"0",
",",
"n",
",",
"val",
";",
"for",
"(",
";",
"n",
"=",
"names",... | Clones any value that is an adt.js type, delegating other JS values to `adt.nativeClone`. | [
"Clones",
"any",
"value",
"that",
"is",
"an",
"adt",
".",
"js",
"type",
"delegating",
"other",
"JS",
"values",
"to",
"adt",
".",
"nativeClone",
"."
] | 0163b8ea3b3f8f3f8c6ea53c672f3a670c4ce9d6 | https://github.com/natefaubion/adt.js/blob/0163b8ea3b3f8f3f8c6ea53c672f3a670c4ce9d6/adt.js#L268-L279 | |
33,293 | natefaubion/adt.js | adt.js | function (that) {
var ctr = this.constructor;
if (this === that) return true;
if (!(that instanceof ctr)) return false;
var names = ctr.__names__;
var i = 0, len = names.length;
var vala, valb, n;
for (; i < len; i++) {
n = names[i], vala = this[n], valb = that[n];
if (vala instanceof adt.__Base__) {
if (!vala.equals(valb)) return false;
} else if (!adt.nativeEquals(vala, valb)) return false;
}
return true;
} | javascript | function (that) {
var ctr = this.constructor;
if (this === that) return true;
if (!(that instanceof ctr)) return false;
var names = ctr.__names__;
var i = 0, len = names.length;
var vala, valb, n;
for (; i < len; i++) {
n = names[i], vala = this[n], valb = that[n];
if (vala instanceof adt.__Base__) {
if (!vala.equals(valb)) return false;
} else if (!adt.nativeEquals(vala, valb)) return false;
}
return true;
} | [
"function",
"(",
"that",
")",
"{",
"var",
"ctr",
"=",
"this",
".",
"constructor",
";",
"if",
"(",
"this",
"===",
"that",
")",
"return",
"true",
";",
"if",
"(",
"!",
"(",
"that",
"instanceof",
"ctr",
")",
")",
"return",
"false",
";",
"var",
"names",... | Recursively compares all adt.js types, delegating other JS values to `adt.nativeEquals`. | [
"Recursively",
"compares",
"all",
"adt",
".",
"js",
"types",
"delegating",
"other",
"JS",
"values",
"to",
"adt",
".",
"nativeEquals",
"."
] | 0163b8ea3b3f8f3f8c6ea53c672f3a670c4ce9d6 | https://github.com/natefaubion/adt.js/blob/0163b8ea3b3f8f3f8c6ea53c672f3a670c4ce9d6/adt.js#L283-L297 | |
33,294 | natefaubion/adt.js | adt.js | function (field) {
var ctr = this.constructor;
var names = ctr.__names__;
var constraints = ctr.__constraints__;
if (typeof field === 'number') {
if (field < 0 || field > names.length - 1) {
throw new Error('Field index out of range: ' + field);
}
field = names[field];
} else {
if (!constraints.hasOwnProperty(field)) {
throw new Error('Field name does not exist: ' + field);
}
}
return this[field];
} | javascript | function (field) {
var ctr = this.constructor;
var names = ctr.__names__;
var constraints = ctr.__constraints__;
if (typeof field === 'number') {
if (field < 0 || field > names.length - 1) {
throw new Error('Field index out of range: ' + field);
}
field = names[field];
} else {
if (!constraints.hasOwnProperty(field)) {
throw new Error('Field name does not exist: ' + field);
}
}
return this[field];
} | [
"function",
"(",
"field",
")",
"{",
"var",
"ctr",
"=",
"this",
".",
"constructor",
";",
"var",
"names",
"=",
"ctr",
".",
"__names__",
";",
"var",
"constraints",
"=",
"ctr",
".",
"__constraints__",
";",
"if",
"(",
"typeof",
"field",
"===",
"'number'",
"... | Overloaded to take either strings or numbers. Throws an error if the key can't be found. | [
"Overloaded",
"to",
"take",
"either",
"strings",
"or",
"numbers",
".",
"Throws",
"an",
"error",
"if",
"the",
"key",
"can",
"t",
"be",
"found",
"."
] | 0163b8ea3b3f8f3f8c6ea53c672f3a670c4ce9d6 | https://github.com/natefaubion/adt.js/blob/0163b8ea3b3f8f3f8c6ea53c672f3a670c4ce9d6/adt.js#L301-L316 | |
33,295 | natefaubion/adt.js | adt.js | addOrder | function addOrder (that) {
if (that.constructor) that = that.constructor;
that.__order__ = order++;
return that;
} | javascript | function addOrder (that) {
if (that.constructor) that = that.constructor;
that.__order__ = order++;
return that;
} | [
"function",
"addOrder",
"(",
"that",
")",
"{",
"if",
"(",
"that",
".",
"constructor",
")",
"that",
"=",
"that",
".",
"constructor",
";",
"that",
".",
"__order__",
"=",
"order",
"++",
";",
"return",
"that",
";",
"}"
] | Helper to add the order meta attribute to a type. | [
"Helper",
"to",
"add",
"the",
"order",
"meta",
"attribute",
"to",
"a",
"type",
"."
] | 0163b8ea3b3f8f3f8c6ea53c672f3a670c4ce9d6 | https://github.com/natefaubion/adt.js/blob/0163b8ea3b3f8f3f8c6ea53c672f3a670c4ce9d6/adt.js#L378-L382 |
33,296 | wachunga/omega | r.js | makeRequire | function makeRequire(relModuleMap, enableBuildCallback, altRequire) {
var modRequire = makeContextModuleFunc(altRequire || context.require, relModuleMap, enableBuildCallback);
mixin(modRequire, {
nameToUrl: makeContextModuleFunc(context.nameToUrl, relModuleMap),
toUrl: makeContextModuleFunc(context.toUrl, relModuleMap),
defined: makeContextModuleFunc(context.requireDefined, relModuleMap),
specified: makeContextModuleFunc(context.requireSpecified, relModuleMap),
isBrowser: req.isBrowser
});
return modRequire;
} | javascript | function makeRequire(relModuleMap, enableBuildCallback, altRequire) {
var modRequire = makeContextModuleFunc(altRequire || context.require, relModuleMap, enableBuildCallback);
mixin(modRequire, {
nameToUrl: makeContextModuleFunc(context.nameToUrl, relModuleMap),
toUrl: makeContextModuleFunc(context.toUrl, relModuleMap),
defined: makeContextModuleFunc(context.requireDefined, relModuleMap),
specified: makeContextModuleFunc(context.requireSpecified, relModuleMap),
isBrowser: req.isBrowser
});
return modRequire;
} | [
"function",
"makeRequire",
"(",
"relModuleMap",
",",
"enableBuildCallback",
",",
"altRequire",
")",
"{",
"var",
"modRequire",
"=",
"makeContextModuleFunc",
"(",
"altRequire",
"||",
"context",
".",
"require",
",",
"relModuleMap",
",",
"enableBuildCallback",
")",
";",... | Helper function that creates a require function object to give to
modules that ask for it as a dependency. It needs to be specific
per module because of the implication of path mappings that may
need to be relative to the module name. | [
"Helper",
"function",
"that",
"creates",
"a",
"require",
"function",
"object",
"to",
"give",
"to",
"modules",
"that",
"ask",
"for",
"it",
"as",
"a",
"dependency",
".",
"It",
"needs",
"to",
"be",
"specific",
"per",
"module",
"because",
"of",
"the",
"implica... | c5ecf4ed058d2198065f17c3313b0884e8efa6a9 | https://github.com/wachunga/omega/blob/c5ecf4ed058d2198065f17c3313b0884e8efa6a9/r.js#L500-L511 |
33,297 | wachunga/omega | r.js | makeArgCallback | function makeArgCallback(manager, i) {
return function (value) {
//Only do the work if it has not been done
//already for a dependency. Cycle breaking
//logic in forceExec could mean this function
//is called more than once for a given dependency.
if (!manager.depDone[i]) {
manager.depDone[i] = true;
manager.deps[i] = value;
manager.depCount -= 1;
if (!manager.depCount) {
//All done, execute!
execManager(manager);
}
}
};
} | javascript | function makeArgCallback(manager, i) {
return function (value) {
//Only do the work if it has not been done
//already for a dependency. Cycle breaking
//logic in forceExec could mean this function
//is called more than once for a given dependency.
if (!manager.depDone[i]) {
manager.depDone[i] = true;
manager.deps[i] = value;
manager.depCount -= 1;
if (!manager.depCount) {
//All done, execute!
execManager(manager);
}
}
};
} | [
"function",
"makeArgCallback",
"(",
"manager",
",",
"i",
")",
"{",
"return",
"function",
"(",
"value",
")",
"{",
"//Only do the work if it has not been done",
"//already for a dependency. Cycle breaking",
"//logic in forceExec could mean this function",
"//is called more than once ... | Helper that creates a callack function that is called when a dependency
is ready, and sets the i-th dependency for the manager as the
value passed to the callback generated by this function. | [
"Helper",
"that",
"creates",
"a",
"callack",
"function",
"that",
"is",
"called",
"when",
"a",
"dependency",
"is",
"ready",
"and",
"sets",
"the",
"i",
"-",
"th",
"dependency",
"for",
"the",
"manager",
"as",
"the",
"value",
"passed",
"to",
"the",
"callback",... | c5ecf4ed058d2198065f17c3313b0884e8efa6a9 | https://github.com/wachunga/omega/blob/c5ecf4ed058d2198065f17c3313b0884e8efa6a9/r.js#L629-L645 |
33,298 | wachunga/omega | r.js | addWait | function addWait(manager) {
if (!waiting[manager.id]) {
waiting[manager.id] = manager;
waitAry.push(manager);
context.waitCount += 1;
}
} | javascript | function addWait(manager) {
if (!waiting[manager.id]) {
waiting[manager.id] = manager;
waitAry.push(manager);
context.waitCount += 1;
}
} | [
"function",
"addWait",
"(",
"manager",
")",
"{",
"if",
"(",
"!",
"waiting",
"[",
"manager",
".",
"id",
"]",
")",
"{",
"waiting",
"[",
"manager",
".",
"id",
"]",
"=",
"manager",
";",
"waitAry",
".",
"push",
"(",
"manager",
")",
";",
"context",
".",
... | Adds the manager to the waiting queue. Only fully
resolved items should be in the waiting queue. | [
"Adds",
"the",
"manager",
"to",
"the",
"waiting",
"queue",
".",
"Only",
"fully",
"resolved",
"items",
"should",
"be",
"in",
"the",
"waiting",
"queue",
"."
] | c5ecf4ed058d2198065f17c3313b0884e8efa6a9 | https://github.com/wachunga/omega/blob/c5ecf4ed058d2198065f17c3313b0884e8efa6a9/r.js#L739-L745 |
33,299 | wachunga/omega | r.js | toAstArray | function toAstArray(ary) {
var output = [
'array',
[]
],
i, item;
for (i = 0; (item = ary[i]); i++) {
output[1].push([
'string',
item
]);
}
return output;
} | javascript | function toAstArray(ary) {
var output = [
'array',
[]
],
i, item;
for (i = 0; (item = ary[i]); i++) {
output[1].push([
'string',
item
]);
}
return output;
} | [
"function",
"toAstArray",
"(",
"ary",
")",
"{",
"var",
"output",
"=",
"[",
"'array'",
",",
"[",
"]",
"]",
",",
"i",
",",
"item",
";",
"for",
"(",
"i",
"=",
"0",
";",
"(",
"item",
"=",
"ary",
"[",
"i",
"]",
")",
";",
"i",
"++",
")",
"{",
"... | Converts a regular JS array of strings to an AST node that
represents that array.
@param {Array} ary
@param {Node} an AST node that represents an array of strings. | [
"Converts",
"a",
"regular",
"JS",
"array",
"of",
"strings",
"to",
"an",
"AST",
"node",
"that",
"represents",
"that",
"array",
"."
] | c5ecf4ed058d2198065f17c3313b0884e8efa6a9 | https://github.com/wachunga/omega/blob/c5ecf4ed058d2198065f17c3313b0884e8efa6a9/r.js#L6614-L6629 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.