repo stringlengths 5 67 | path stringlengths 4 116 | func_name stringlengths 0 58 | original_string stringlengths 52 373k | language stringclasses 1
value | code stringlengths 52 373k | code_tokens list | docstring stringlengths 4 11.8k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 86 226 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
Hustle/parse-mockdb | src/parse-mockdb.js | ensureArray | function ensureArray(object, key) {
if (!object[key]) {
object[key] = [];
}
if (!Array.isArray(object[key])) {
throw new Error("Can't perform array operation on non-array field");
}
} | javascript | function ensureArray(object, key) {
if (!object[key]) {
object[key] = [];
}
if (!Array.isArray(object[key])) {
throw new Error("Can't perform array operation on non-array field");
}
} | [
"function",
"ensureArray",
"(",
"object",
",",
"key",
")",
"{",
"if",
"(",
"!",
"object",
"[",
"key",
"]",
")",
"{",
"object",
"[",
"key",
"]",
"=",
"[",
"]",
";",
"}",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"object",
"[",
"key",
"]",
... | Ensures `object` has an array at `key`. Creates array if `key` doesn't exist. Will throw if value for `key` exists and is not Array. | [
"Ensures",
"object",
"has",
"an",
"array",
"at",
"key",
".",
"Creates",
"array",
"if",
"key",
"doesn",
"t",
"exist",
".",
"Will",
"throw",
"if",
"value",
"for",
"key",
"exists",
"and",
"is",
"not",
"Array",
"."
] | b33a113debcba3c80477b50c7fae557f5941d494 | https://github.com/Hustle/parse-mockdb/blob/b33a113debcba3c80477b50c7fae557f5941d494/src/parse-mockdb.js#L104-L111 | train |
Hustle/parse-mockdb | src/parse-mockdb.js | registerHook | function registerHook(className, hookType, hookFn) {
if (!hooks[className]) {
hooks[className] = {};
}
hooks[className][hookType] = hookFn;
} | javascript | function registerHook(className, hookType, hookFn) {
if (!hooks[className]) {
hooks[className] = {};
}
hooks[className][hookType] = hookFn;
} | [
"function",
"registerHook",
"(",
"className",
",",
"hookType",
",",
"hookFn",
")",
"{",
"if",
"(",
"!",
"hooks",
"[",
"className",
"]",
")",
"{",
"hooks",
"[",
"className",
"]",
"=",
"{",
"}",
";",
"}",
"hooks",
"[",
"className",
"]",
"[",
"hookType"... | Registers a hook on a class denoted by className.
@param {string} className The name of the class to register hook on.
@param {string} hookType One of 'beforeSave', 'afterSave', 'beforeDelete', 'afterDelete'
@param {function} hookFn Function that will be called with `this` bound to hydrated model.
Must return a promis... | [
"Registers",
"a",
"hook",
"on",
"a",
"class",
"denoted",
"by",
"className",
"."
] | b33a113debcba3c80477b50c7fae557f5941d494 | https://github.com/Hustle/parse-mockdb/blob/b33a113debcba3c80477b50c7fae557f5941d494/src/parse-mockdb.js#L205-L211 | train |
Hustle/parse-mockdb | src/parse-mockdb.js | getHook | function getHook(className, hookType) {
if (hooks[className] && hooks[className][hookType]) {
return hooks[className][hookType];
}
return undefined;
} | javascript | function getHook(className, hookType) {
if (hooks[className] && hooks[className][hookType]) {
return hooks[className][hookType];
}
return undefined;
} | [
"function",
"getHook",
"(",
"className",
",",
"hookType",
")",
"{",
"if",
"(",
"hooks",
"[",
"className",
"]",
"&&",
"hooks",
"[",
"className",
"]",
"[",
"hookType",
"]",
")",
"{",
"return",
"hooks",
"[",
"className",
"]",
"[",
"hookType",
"]",
";",
... | Retrieves a previously registered hook.
@param {string} className The name of the class to get the hook on.
@param {string} hookType One of 'beforeSave', 'afterSave', 'beforeDelete', 'afterDelete' | [
"Retrieves",
"a",
"previously",
"registered",
"hook",
"."
] | b33a113debcba3c80477b50c7fae557f5941d494 | https://github.com/Hustle/parse-mockdb/blob/b33a113debcba3c80477b50c7fae557f5941d494/src/parse-mockdb.js#L219-L224 | train |
Hustle/parse-mockdb | src/parse-mockdb.js | extractOps | function extractOps(data) {
const ops = {};
_.forIn(data, (attribute, key) => {
if (isOp(attribute)) {
ops[key] = attribute;
delete data[key];
}
});
return ops;
} | javascript | function extractOps(data) {
const ops = {};
_.forIn(data, (attribute, key) => {
if (isOp(attribute)) {
ops[key] = attribute;
delete data[key];
}
});
return ops;
} | [
"function",
"extractOps",
"(",
"data",
")",
"{",
"const",
"ops",
"=",
"{",
"}",
";",
"_",
".",
"forIn",
"(",
"data",
",",
"(",
"attribute",
",",
"key",
")",
"=>",
"{",
"if",
"(",
"isOp",
"(",
"attribute",
")",
")",
"{",
"ops",
"[",
"key",
"]",
... | Destructive. Takes data for update operation and removes all atomic operations. Returns the extracted ops. | [
"Destructive",
".",
"Takes",
"data",
"for",
"update",
"operation",
"and",
"removes",
"all",
"atomic",
"operations",
".",
"Returns",
"the",
"extracted",
"ops",
"."
] | b33a113debcba3c80477b50c7fae557f5941d494 | https://github.com/Hustle/parse-mockdb/blob/b33a113debcba3c80477b50c7fae557f5941d494/src/parse-mockdb.js#L242-L253 | train |
Hustle/parse-mockdb | src/parse-mockdb.js | applyOps | function applyOps(data, ops, className) {
debugPrint('OPS', ops);
_.forIn(ops, (value, key) => {
const operator = value.__op;
if (operator in UPDATE_OPERATORS) {
UPDATE_OPERATORS[operator](data, key, value, className);
} else {
throw new Error(`Unknown update operator: ${key}`);
}
... | javascript | function applyOps(data, ops, className) {
debugPrint('OPS', ops);
_.forIn(ops, (value, key) => {
const operator = value.__op;
if (operator in UPDATE_OPERATORS) {
UPDATE_OPERATORS[operator](data, key, value, className);
} else {
throw new Error(`Unknown update operator: ${key}`);
}
... | [
"function",
"applyOps",
"(",
"data",
",",
"ops",
",",
"className",
")",
"{",
"debugPrint",
"(",
"'OPS'",
",",
"ops",
")",
";",
"_",
".",
"forIn",
"(",
"ops",
",",
"(",
"value",
",",
"key",
")",
"=>",
"{",
"const",
"operator",
"=",
"value",
".",
"... | Destructive. Applies all the update `ops` to `data`. Throws on unknown update operator. | [
"Destructive",
".",
"Applies",
"all",
"the",
"update",
"ops",
"to",
"data",
".",
"Throws",
"on",
"unknown",
"update",
"operator",
"."
] | b33a113debcba3c80477b50c7fae557f5941d494 | https://github.com/Hustle/parse-mockdb/blob/b33a113debcba3c80477b50c7fae557f5941d494/src/parse-mockdb.js#L257-L272 | train |
Hustle/parse-mockdb | src/parse-mockdb.js | queryFilter | function queryFilter(where) {
if (where.$or) {
return object =>
_.reduce(where.$or, (result, subclause) => result ||
queryFilter(subclause)(object), false);
}
// Go through each key in where clause
return object => _.reduce(where, (result, whereParams, key) => {
const match = evaluateObje... | javascript | function queryFilter(where) {
if (where.$or) {
return object =>
_.reduce(where.$or, (result, subclause) => result ||
queryFilter(subclause)(object), false);
}
// Go through each key in where clause
return object => _.reduce(where, (result, whereParams, key) => {
const match = evaluateObje... | [
"function",
"queryFilter",
"(",
"where",
")",
"{",
"if",
"(",
"where",
".",
"$or",
")",
"{",
"return",
"object",
"=>",
"_",
".",
"reduce",
"(",
"where",
".",
"$or",
",",
"(",
"result",
",",
"subclause",
")",
"=>",
"result",
"||",
"queryFilter",
"(",
... | Returns a function that filters query matches on a where clause | [
"Returns",
"a",
"function",
"that",
"filters",
"query",
"matches",
"on",
"a",
"where",
"clause"
] | b33a113debcba3c80477b50c7fae557f5941d494 | https://github.com/Hustle/parse-mockdb/blob/b33a113debcba3c80477b50c7fae557f5941d494/src/parse-mockdb.js#L445-L457 | train |
Hustle/parse-mockdb | src/parse-mockdb.js | fetchObjectByPointer | function fetchObjectByPointer(pointer) {
const collection = getCollection(pointer.className);
const storedItem = collection[pointer.objectId];
if (storedItem === undefined) {
return undefined;
}
return Object.assign(
{ __type: 'Object', className: pointer.className },
_.cloneDeep(storedItem)
)... | javascript | function fetchObjectByPointer(pointer) {
const collection = getCollection(pointer.className);
const storedItem = collection[pointer.objectId];
if (storedItem === undefined) {
return undefined;
}
return Object.assign(
{ __type: 'Object', className: pointer.className },
_.cloneDeep(storedItem)
)... | [
"function",
"fetchObjectByPointer",
"(",
"pointer",
")",
"{",
"const",
"collection",
"=",
"getCollection",
"(",
"pointer",
".",
"className",
")",
";",
"const",
"storedItem",
"=",
"collection",
"[",
"pointer",
".",
"objectId",
"]",
";",
"if",
"(",
"storedItem",... | Given an object, a pointer, or a JSON representation of a Parse Object,
return a fully fetched version of the Object. | [
"Given",
"an",
"object",
"a",
"pointer",
"or",
"a",
"JSON",
"representation",
"of",
"a",
"Parse",
"Object",
"return",
"a",
"fully",
"fetched",
"version",
"of",
"the",
"Object",
"."
] | b33a113debcba3c80477b50c7fae557f5941d494 | https://github.com/Hustle/parse-mockdb/blob/b33a113debcba3c80477b50c7fae557f5941d494/src/parse-mockdb.js#L512-L524 | train |
Hustle/parse-mockdb | src/parse-mockdb.js | includePaths | function includePaths(object, pathsRemaining) {
debugPrint('INCLUDE', { object, pathsRemaining });
const path = pathsRemaining.shift();
const target = object && object[path];
if (target) {
if (Array.isArray(target)) {
object[path] = target.map(pointer => {
const fetched = fetchObjectByPointer... | javascript | function includePaths(object, pathsRemaining) {
debugPrint('INCLUDE', { object, pathsRemaining });
const path = pathsRemaining.shift();
const target = object && object[path];
if (target) {
if (Array.isArray(target)) {
object[path] = target.map(pointer => {
const fetched = fetchObjectByPointer... | [
"function",
"includePaths",
"(",
"object",
",",
"pathsRemaining",
")",
"{",
"debugPrint",
"(",
"'INCLUDE'",
",",
"{",
"object",
",",
"pathsRemaining",
"}",
")",
";",
"const",
"path",
"=",
"pathsRemaining",
".",
"shift",
"(",
")",
";",
"const",
"target",
"=... | Recursive function that traverses an include path and replaces pointers
with fully fetched objects | [
"Recursive",
"function",
"that",
"traverses",
"an",
"include",
"path",
"and",
"replaces",
"pointers",
"with",
"fully",
"fetched",
"objects"
] | b33a113debcba3c80477b50c7fae557f5941d494 | https://github.com/Hustle/parse-mockdb/blob/b33a113debcba3c80477b50c7fae557f5941d494/src/parse-mockdb.js#L530-L551 | train |
Hustle/parse-mockdb | src/parse-mockdb.js | sortQueryresults | function sortQueryresults(matches, order) {
const orderArray = order.split(',').map(k => {
let dir = 'asc';
let key = k;
if (k.charAt(0) === '-') {
key = k.substring(1);
dir = 'desc';
}
return [item => deserializeQueryParam(item[key]), dir];
});
const keys = orderArray.map(_.fir... | javascript | function sortQueryresults(matches, order) {
const orderArray = order.split(',').map(k => {
let dir = 'asc';
let key = k;
if (k.charAt(0) === '-') {
key = k.substring(1);
dir = 'desc';
}
return [item => deserializeQueryParam(item[key]), dir];
});
const keys = orderArray.map(_.fir... | [
"function",
"sortQueryresults",
"(",
"matches",
",",
"order",
")",
"{",
"const",
"orderArray",
"=",
"order",
".",
"split",
"(",
"','",
")",
".",
"map",
"(",
"k",
"=>",
"{",
"let",
"dir",
"=",
"'asc'",
";",
"let",
"key",
"=",
"k",
";",
"if",
"(",
... | Sort query results if necessary | [
"Sort",
"query",
"results",
"if",
"necessary"
] | b33a113debcba3c80477b50c7fae557f5941d494 | https://github.com/Hustle/parse-mockdb/blob/b33a113debcba3c80477b50c7fae557f5941d494/src/parse-mockdb.js#L578-L595 | train |
Hustle/parse-mockdb | src/parse-mockdb.js | runHook | function runHook(className, hookType, data) {
let hook = getHook(className, hookType);
if (hook) {
const hydrate = (rawData) => {
const modelData = Object.assign({}, rawData, { className });
const modelJSON = _.mapValues(modelData,
// Convert dates into JSON loadable representations
... | javascript | function runHook(className, hookType, data) {
let hook = getHook(className, hookType);
if (hook) {
const hydrate = (rawData) => {
const modelData = Object.assign({}, rawData, { className });
const modelJSON = _.mapValues(modelData,
// Convert dates into JSON loadable representations
... | [
"function",
"runHook",
"(",
"className",
",",
"hookType",
",",
"data",
")",
"{",
"let",
"hook",
"=",
"getHook",
"(",
"className",
",",
"hookType",
")",
";",
"if",
"(",
"hook",
")",
"{",
"const",
"hydrate",
"=",
"(",
"rawData",
")",
"=>",
"{",
"const"... | Executes a registered hook with data provided.
Hydrates the data into an instance of the class named by `className` param and binds it to the
function to be run.
@param {string} className The name of the class to get the hook on.
@param {string} hookType One of 'beforeSave', 'afterSave', 'beforeDelete', 'afterDelete'... | [
"Executes",
"a",
"registered",
"hook",
"with",
"data",
"provided",
"."
] | b33a113debcba3c80477b50c7fae557f5941d494 | https://github.com/Hustle/parse-mockdb/blob/b33a113debcba3c80477b50c7fae557f5941d494/src/parse-mockdb.js#L680-L714 | train |
CiscoDevNet/node-sparkbot | sparkbot/webhook.js | compareWebhooks | function compareWebhooks(webhook, name, targetUrl, resource, event, filter, secret) {
if ((webhook.name !== name)
|| (webhook.targetUrl !== targetUrl)
|| (webhook.resource !== resource)
|| (webhook.event !== event)) {
return false;
}
// they look pretty identifty, let's check optional fields
if (filter) {
i... | javascript | function compareWebhooks(webhook, name, targetUrl, resource, event, filter, secret) {
if ((webhook.name !== name)
|| (webhook.targetUrl !== targetUrl)
|| (webhook.resource !== resource)
|| (webhook.event !== event)) {
return false;
}
// they look pretty identifty, let's check optional fields
if (filter) {
i... | [
"function",
"compareWebhooks",
"(",
"webhook",
",",
"name",
",",
"targetUrl",
",",
"resource",
",",
"event",
",",
"filter",
",",
"secret",
")",
"{",
"if",
"(",
"(",
"webhook",
".",
"name",
"!==",
"name",
")",
"||",
"(",
"webhook",
".",
"targetUrl",
"!=... | returns true if webhooks are identical | [
"returns",
"true",
"if",
"webhooks",
"are",
"identical"
] | d307b2955b7258cf34089041ac12dc48f96db5ca | https://github.com/CiscoDevNet/node-sparkbot/blob/d307b2955b7258cf34089041ac12dc48f96db5ca/sparkbot/webhook.js#L483-L518 | train |
Vincit/dodo.js | lib/errors/http-error.js | HTTPError | function HTTPError(statusCode, data) {
Error.call(this);
Error.captureStackTrace(this, this.constructor);
/**
* Human-readable error name.
*
* @type {String}
*/
this.name = http.STATUS_CODES[statusCode];
/**
* HTTP status code.
*
* @type {Number}
*/
this.statusCode = statusCode;
... | javascript | function HTTPError(statusCode, data) {
Error.call(this);
Error.captureStackTrace(this, this.constructor);
/**
* Human-readable error name.
*
* @type {String}
*/
this.name = http.STATUS_CODES[statusCode];
/**
* HTTP status code.
*
* @type {Number}
*/
this.statusCode = statusCode;
... | [
"function",
"HTTPError",
"(",
"statusCode",
",",
"data",
")",
"{",
"Error",
".",
"call",
"(",
"this",
")",
";",
"Error",
".",
"captureStackTrace",
"(",
"this",
",",
"this",
".",
"constructor",
")",
";",
"/**\n * Human-readable error name.\n *\n * @type {Stri... | Base class for errors.
@param {Number} statusCode
HTTP status code.
@param {*=} data
Any additional data.
@extends Error
@constructor | [
"Base",
"class",
"for",
"errors",
"."
] | 01c4b7a1139af8442dad945bfb21d8bc8ba4031b | https://github.com/Vincit/dodo.js/blob/01c4b7a1139af8442dad945bfb21d8bc8ba4031b/lib/errors/http-error.js#L18-L47 | train |
Vincit/dodo.js | lib/app/plugins.js | function (config) {
return _.map(config.features, function(featureDef) {
var feature = null
, featurePath = null;
var featureId = featureDef.$featureId || featureDef.feature;
// Try to require the feature from each path listed in `config.featurePaths`.
for (var i = 0; i < config.fe... | javascript | function (config) {
return _.map(config.features, function(featureDef) {
var feature = null
, featurePath = null;
var featureId = featureDef.$featureId || featureDef.feature;
// Try to require the feature from each path listed in `config.featurePaths`.
for (var i = 0; i < config.fe... | [
"function",
"(",
"config",
")",
"{",
"return",
"_",
".",
"map",
"(",
"config",
".",
"features",
",",
"function",
"(",
"featureDef",
")",
"{",
"var",
"feature",
"=",
"null",
",",
"featurePath",
"=",
"null",
";",
"var",
"featureId",
"=",
"featureDef",
".... | Load features of configuration to get plugin tasks etc. | [
"Load",
"features",
"of",
"configuration",
"to",
"get",
"plugin",
"tasks",
"etc",
"."
] | 01c4b7a1139af8442dad945bfb21d8bc8ba4031b | https://github.com/Vincit/dodo.js/blob/01c4b7a1139af8442dad945bfb21d8bc8ba4031b/lib/app/plugins.js#L22-L54 | train | |
Hustle/parse-mockdb | src/crypto.js | randomHexString | function randomHexString(size) {
if (size === 0) {
throw new Error('Zero-length randomHexString is useless.');
}
if (size % 2 !== 0) {
throw new Error('randomHexString size must be divisible by 2.');
}
return crypto.randomBytes(size / 2).toString('hex');
} | javascript | function randomHexString(size) {
if (size === 0) {
throw new Error('Zero-length randomHexString is useless.');
}
if (size % 2 !== 0) {
throw new Error('randomHexString size must be divisible by 2.');
}
return crypto.randomBytes(size / 2).toString('hex');
} | [
"function",
"randomHexString",
"(",
"size",
")",
"{",
"if",
"(",
"size",
"===",
"0",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Zero-length randomHexString is useless.'",
")",
";",
"}",
"if",
"(",
"size",
"%",
"2",
"!==",
"0",
")",
"{",
"throw",
"new",
... | Returns a new random hex string of the given even size. | [
"Returns",
"a",
"new",
"random",
"hex",
"string",
"of",
"the",
"given",
"even",
"size",
"."
] | b33a113debcba3c80477b50c7fae557f5941d494 | https://github.com/Hustle/parse-mockdb/blob/b33a113debcba3c80477b50c7fae557f5941d494/src/crypto.js#L5-L13 | train |
erikschlegel/React-Twitter-Typeahead | lib/js/react-typeahead.js | function () {
var defaultMinLength = 2, config = {};
if(!this.props.bloodhound)
this.props.bloodhound = {};
if(!this.props.typeahead)
this.props.typeahead = {};
if(!this.props.datasource)
this.props.datasource = {};
var defaults = {
bloodhound: {
... | javascript | function () {
var defaultMinLength = 2, config = {};
if(!this.props.bloodhound)
this.props.bloodhound = {};
if(!this.props.typeahead)
this.props.typeahead = {};
if(!this.props.datasource)
this.props.datasource = {};
var defaults = {
bloodhound: {
... | [
"function",
"(",
")",
"{",
"var",
"defaultMinLength",
"=",
"2",
",",
"config",
"=",
"{",
"}",
";",
"if",
"(",
"!",
"this",
".",
"props",
".",
"bloodhound",
")",
"this",
".",
"props",
".",
"bloodhound",
"=",
"{",
"}",
";",
"if",
"(",
"!",
"this",
... | 'initOptions' method
This method sets up the typeahead with initial config parameters. The first set is default
and the other set is defined by the | [
"initOptions",
"method",
"This",
"method",
"sets",
"up",
"the",
"typeahead",
"with",
"initial",
"config",
"parameters",
".",
"The",
"first",
"set",
"is",
"default",
"and",
"the",
"other",
"set",
"is",
"defined",
"by",
"the"
] | d0fe9fb751ae113b44a3a8dcd5d29efbf2476713 | https://github.com/erikschlegel/React-Twitter-Typeahead/blob/d0fe9fb751ae113b44a3a8dcd5d29efbf2476713/lib/js/react-typeahead.js#L13-L44 | train | |
erikschlegel/React-Twitter-Typeahead | lib/js/react-typeahead.js | function () {
var self = this,
options = this.initOptions();
var remoteCall = new Bloodhound(options.bloodhound);
options.datasource.source = remoteCall;
var typeaheadInput = React.findDOMNode(self);
if(typeaheadInput)
this.typeahead = $(typeaheadInput).type... | javascript | function () {
var self = this,
options = this.initOptions();
var remoteCall = new Bloodhound(options.bloodhound);
options.datasource.source = remoteCall;
var typeaheadInput = React.findDOMNode(self);
if(typeaheadInput)
this.typeahead = $(typeaheadInput).type... | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
",",
"options",
"=",
"this",
".",
"initOptions",
"(",
")",
";",
"var",
"remoteCall",
"=",
"new",
"Bloodhound",
"(",
"options",
".",
"bloodhound",
")",
";",
"options",
".",
"datasource",
".",
"sourc... | 'componentDidMount' method
Initializes react with the typeahead component. | [
"componentDidMount",
"method",
"Initializes",
"react",
"with",
"the",
"typeahead",
"component",
"."
] | d0fe9fb751ae113b44a3a8dcd5d29efbf2476713 | https://github.com/erikschlegel/React-Twitter-Typeahead/blob/d0fe9fb751ae113b44a3a8dcd5d29efbf2476713/lib/js/react-typeahead.js#L65-L76 | train | |
uber-node/zero-config | read-datacenter.js | readFileOrError | function readFileOrError(uri) {
var content;
try {
content = fs.readFileSync(uri, 'utf8');
} catch (err) {
return Result.Err(err);
}
return Result.Ok(content);
} | javascript | function readFileOrError(uri) {
var content;
try {
content = fs.readFileSync(uri, 'utf8');
} catch (err) {
return Result.Err(err);
}
return Result.Ok(content);
} | [
"function",
"readFileOrError",
"(",
"uri",
")",
"{",
"var",
"content",
";",
"try",
"{",
"content",
"=",
"fs",
".",
"readFileSync",
"(",
"uri",
",",
"'utf8'",
")",
";",
"}",
"catch",
"(",
"err",
")",
"{",
"return",
"Result",
".",
"Err",
"(",
"err",
... | break try catch into small function to avoid v8 de-optimization | [
"break",
"try",
"catch",
"into",
"small",
"function",
"to",
"avoid",
"v8",
"de",
"-",
"optimization"
] | 214e3da207e3f3648f2070ee895b1345ef4415cf | https://github.com/uber-node/zero-config/blob/214e3da207e3f3648f2070ee895b1345ef4415cf/read-datacenter.js#L60-L69 | train |
nyxtom/salient | lib/salient/graph/document.js | DocumentGraph | function DocumentGraph(options) {
this.options = object.extend(defaultOptions, options || {});
this._gloss = new Glossary();
// Parse redis cluster configuration in the form of:
// "host:port,host:port,host:port"
if (this.options.redisCluster) {
var addresses = this.options.redisCluster... | javascript | function DocumentGraph(options) {
this.options = object.extend(defaultOptions, options || {});
this._gloss = new Glossary();
// Parse redis cluster configuration in the form of:
// "host:port,host:port,host:port"
if (this.options.redisCluster) {
var addresses = this.options.redisCluster... | [
"function",
"DocumentGraph",
"(",
"options",
")",
"{",
"this",
".",
"options",
"=",
"object",
".",
"extend",
"(",
"defaultOptions",
",",
"options",
"||",
"{",
"}",
")",
";",
"this",
".",
"_gloss",
"=",
"new",
"Glossary",
"(",
")",
";",
"// Parse redis cl... | DocumentGraph represents a client for processing documents in order to process document text in order to build a graph of connections between document ids, text, parts of speech context and the language as it is presented through the data. | [
"DocumentGraph",
"represents",
"a",
"client",
"for",
"processing",
"documents",
"in",
"order",
"to",
"process",
"document",
"text",
"in",
"order",
"to",
"build",
"a",
"graph",
"of",
"connections",
"between",
"document",
"ids",
"text",
"parts",
"of",
"speech",
... | 56e3e6cded9e5f97d9536aacdcaa588849e6a259 | https://github.com/nyxtom/salient/blob/56e3e6cded9e5f97d9536aacdcaa588849e6a259/lib/salient/graph/document.js#L45-L77 | train |
nyxtom/salient | lib/salient/graph/document.js | function(err, results) {
if (err) {
callback(err);
return;
}
var keyFrequency = parseInt(results[0]);
var docFrequency = parseInt(results[1]);
var keyDocFrequency = results[2];
// ensure that key frequency is relative to the given documen... | javascript | function(err, results) {
if (err) {
callback(err);
return;
}
var keyFrequency = parseInt(results[0]);
var docFrequency = parseInt(results[1]);
var keyDocFrequency = results[2];
// ensure that key frequency is relative to the given documen... | [
"function",
"(",
"err",
",",
"results",
")",
"{",
"if",
"(",
"err",
")",
"{",
"callback",
"(",
"err",
")",
";",
"return",
";",
"}",
"var",
"keyFrequency",
"=",
"parseInt",
"(",
"results",
"[",
"0",
"]",
")",
";",
"var",
"docFrequency",
"=",
"parseI... | Executes and handles results returned from the multi redis command below | [
"Executes",
"and",
"handles",
"results",
"returned",
"from",
"the",
"multi",
"redis",
"command",
"below"
] | 56e3e6cded9e5f97d9536aacdcaa588849e6a259 | https://github.com/nyxtom/salient/blob/56e3e6cded9e5f97d9536aacdcaa588849e6a259/lib/salient/graph/document.js#L709-L735 | train | |
fandogh/nuxt-helpers | lib/axios/plugin.js | onError | function onError(e) {
if (!inBrowser) {
return {};
}
let response = {};
if (e.response) {
response = e.response.data;
}
throw Object.assign({
statusCode: 500,
message: 'Request error'
}, response);
} | javascript | function onError(e) {
if (!inBrowser) {
return {};
}
let response = {};
if (e.response) {
response = e.response.data;
}
throw Object.assign({
statusCode: 500,
message: 'Request error'
}, response);
} | [
"function",
"onError",
"(",
"e",
")",
"{",
"if",
"(",
"!",
"inBrowser",
")",
"{",
"return",
"{",
"}",
";",
"}",
"let",
"response",
"=",
"{",
"}",
";",
"if",
"(",
"e",
".",
"response",
")",
"{",
"response",
"=",
"e",
".",
"response",
".",
"data"... | Throw nice http errors & keep SSR safe | [
"Throw",
"nice",
"http",
"errors",
"&",
"keep",
"SSR",
"safe"
] | 0a4b22fae2737fe452b82681e04a6a34fc591ac2 | https://github.com/fandogh/nuxt-helpers/blob/0a4b22fae2737fe452b82681e04a6a34fc591ac2/lib/axios/plugin.js#L14-L28 | train |
Vincit/dodo.js | lib/app/express/main.js | function(config) {
var app = null;
try {
app = module.exports.createApp(config);
} catch (err) {
// wrap also synchronous error to promise to have consistent API for catching all errors
return Promise.reject(err);
}
return module.exports.startApp(app);
} | javascript | function(config) {
var app = null;
try {
app = module.exports.createApp(config);
} catch (err) {
// wrap also synchronous error to promise to have consistent API for catching all errors
return Promise.reject(err);
}
return module.exports.startApp(app);
} | [
"function",
"(",
"config",
")",
"{",
"var",
"app",
"=",
"null",
";",
"try",
"{",
"app",
"=",
"module",
".",
"exports",
".",
"createApp",
"(",
"config",
")",
";",
"}",
"catch",
"(",
"err",
")",
"{",
"// wrap also synchronous error to promise to have consisten... | Creates and starts the server with the given config.
@param {Object} config
The config object for a service. See README.md for documentation about config files.
@returns {Promise} | [
"Creates",
"and",
"starts",
"the",
"server",
"with",
"the",
"given",
"config",
"."
] | 01c4b7a1139af8442dad945bfb21d8bc8ba4031b | https://github.com/Vincit/dodo.js/blob/01c4b7a1139af8442dad945bfb21d8bc8ba4031b/lib/app/express/main.js#L130-L139 | train | |
Vincit/dodo.js | lib/app/express/main.js | function(app) {
var config = app.config;
var testing = config.profile === 'testing';
var starterPromise = startServer(app).then(logStartup);
if (!testing) {
starterPromise = starterPromise.catch(logError);
}
return starterPromise;
} | javascript | function(app) {
var config = app.config;
var testing = config.profile === 'testing';
var starterPromise = startServer(app).then(logStartup);
if (!testing) {
starterPromise = starterPromise.catch(logError);
}
return starterPromise;
} | [
"function",
"(",
"app",
")",
"{",
"var",
"config",
"=",
"app",
".",
"config",
";",
"var",
"testing",
"=",
"config",
".",
"profile",
"===",
"'testing'",
";",
"var",
"starterPromise",
"=",
"startServer",
"(",
"app",
")",
".",
"then",
"(",
"logStartup",
"... | Starts the given app.
@param {Object} app
An app instance created using `createApp`.
@returns {Promise} | [
"Starts",
"the",
"given",
"app",
"."
] | 01c4b7a1139af8442dad945bfb21d8bc8ba4031b | https://github.com/Vincit/dodo.js/blob/01c4b7a1139af8442dad945bfb21d8bc8ba4031b/lib/app/express/main.js#L149-L157 | train | |
ethjs/ethjs-signer | src/index.js | recover | function recover(rawTx, v, r, s) {
const rawTransaction = typeof(rawTx) === 'string' ? new Buffer(stripHexPrefix(rawTx), 'hex') : rawTx;
const signedTransaction = rlp.decode(rawTransaction);
const raw = [];
transactionFields.forEach((fieldInfo, fieldIndex) => {
raw[fieldIndex] = signedTransaction[fieldInde... | javascript | function recover(rawTx, v, r, s) {
const rawTransaction = typeof(rawTx) === 'string' ? new Buffer(stripHexPrefix(rawTx), 'hex') : rawTx;
const signedTransaction = rlp.decode(rawTransaction);
const raw = [];
transactionFields.forEach((fieldInfo, fieldIndex) => {
raw[fieldIndex] = signedTransaction[fieldInde... | [
"function",
"recover",
"(",
"rawTx",
",",
"v",
",",
"r",
",",
"s",
")",
"{",
"const",
"rawTransaction",
"=",
"typeof",
"(",
"rawTx",
")",
"===",
"'string'",
"?",
"new",
"Buffer",
"(",
"stripHexPrefix",
"(",
"rawTx",
")",
",",
"'hex'",
")",
":",
"rawT... | ECDSA public key recovery from a rawTransaction
@method recover
@param {String|Buffer} rawTransaction either a hex string or buffer instance
@param {Number} v
@param {Buffer} r
@param {Buffer} s
@return {Buffer} publicKey | [
"ECDSA",
"public",
"key",
"recovery",
"from",
"a",
"rawTransaction"
] | 8739b3eb08714da5749175f3f5c1096e3046fe87 | https://github.com/ethjs/ethjs-signer/blob/8739b3eb08714da5749175f3f5c1096e3046fe87/src/index.js#L44-L55 | train |
ethjs/ethjs-signer | src/index.js | sign | function sign(transaction, privateKey, toObject) {
if (typeof transaction !== 'object' || transaction === null) { throw new Error(`[ethjs-signer] transaction input must be a type 'object', got '${typeof(transaction)}'`); }
if (typeof privateKey !== 'string') { throw new Error('[ethjs-signer] private key input must ... | javascript | function sign(transaction, privateKey, toObject) {
if (typeof transaction !== 'object' || transaction === null) { throw new Error(`[ethjs-signer] transaction input must be a type 'object', got '${typeof(transaction)}'`); }
if (typeof privateKey !== 'string') { throw new Error('[ethjs-signer] private key input must ... | [
"function",
"sign",
"(",
"transaction",
",",
"privateKey",
",",
"toObject",
")",
"{",
"if",
"(",
"typeof",
"transaction",
"!==",
"'object'",
"||",
"transaction",
"===",
"null",
")",
"{",
"throw",
"new",
"Error",
"(",
"`",
"${",
"typeof",
"(",
"transaction"... | Will sign a raw transaction and return it either as a serlized hex string or raw tx object.
@method sign
@param {Object} transaction a valid transaction object
@param {String} privateKey a valid 32 byte prefixed hex string private key
@param {Boolean} toObject **Optional**
@returns {String|Object} output either a seri... | [
"Will",
"sign",
"a",
"raw",
"transaction",
"and",
"return",
"it",
"either",
"as",
"a",
"serlized",
"hex",
"string",
"or",
"raw",
"tx",
"object",
"."
] | 8739b3eb08714da5749175f3f5c1096e3046fe87 | https://github.com/ethjs/ethjs-signer/blob/8739b3eb08714da5749175f3f5c1096e3046fe87/src/index.js#L67-L113 | train |
powmedia/mongoose-fixtures | mongoose_fixtures.js | insertCollection | function insertCollection(modelName, data, db, callback) {
callback = callback || {};
//Counters for managing callbacks
var tasks = { total: 0, done: 0 };
//Load model
var Model = db.model(modelName);
//Clear existing collection
Model.collection.remove(function(err) {
... | javascript | function insertCollection(modelName, data, db, callback) {
callback = callback || {};
//Counters for managing callbacks
var tasks = { total: 0, done: 0 };
//Load model
var Model = db.model(modelName);
//Clear existing collection
Model.collection.remove(function(err) {
... | [
"function",
"insertCollection",
"(",
"modelName",
",",
"data",
",",
"db",
",",
"callback",
")",
"{",
"callback",
"=",
"callback",
"||",
"{",
"}",
";",
"//Counters for managing callbacks",
"var",
"tasks",
"=",
"{",
"total",
":",
"0",
",",
"done",
":",
"0",
... | Clears a collection and inserts the given data as new documents
@param {String} The name of the model e.g. User, Post etc.
@param {Object} The data to insert, as an array or object. E.g.:
{ user1: {name: 'Alex'}, user2: {name: 'Bob'} }
or:
[ {name: 'Alex'}, {name:'Bob'} ]
@param {Connection} The mongoose co... | [
"Clears",
"a",
"collection",
"and",
"inserts",
"the",
"given",
"data",
"as",
"new",
"documents"
] | 29e4ff333913636dfee96ed6a9a40bef4551f60d | https://github.com/powmedia/mongoose-fixtures/blob/29e4ff333913636dfee96ed6a9a40bef4551f60d/mongoose_fixtures.js#L66-L108 | train |
powmedia/mongoose-fixtures | mongoose_fixtures.js | loadObject | function loadObject(data, db, callback) {
callback = callback || function() {};
var iterator = function(modelName, next){
insertCollection(modelName, data[modelName], db, next);
};
async.forEachSeries(Object.keys(data), iterator, callback);
} | javascript | function loadObject(data, db, callback) {
callback = callback || function() {};
var iterator = function(modelName, next){
insertCollection(modelName, data[modelName], db, next);
};
async.forEachSeries(Object.keys(data), iterator, callback);
} | [
"function",
"loadObject",
"(",
"data",
",",
"db",
",",
"callback",
")",
"{",
"callback",
"=",
"callback",
"||",
"function",
"(",
")",
"{",
"}",
";",
"var",
"iterator",
"=",
"function",
"(",
"modelName",
",",
"next",
")",
"{",
"insertCollection",
"(",
"... | Loads fixtures from object data
@param {Object} The data to load, keyed by the Mongoose model name e.g.:
{ User: [{name: 'Alex'}, {name: 'Bob'}] }
@param {Connection} The mongoose connection to use
@param {Function} Callback | [
"Loads",
"fixtures",
"from",
"object",
"data"
] | 29e4ff333913636dfee96ed6a9a40bef4551f60d | https://github.com/powmedia/mongoose-fixtures/blob/29e4ff333913636dfee96ed6a9a40bef4551f60d/mongoose_fixtures.js#L119-L125 | train |
powmedia/mongoose-fixtures | mongoose_fixtures.js | loadFile | function loadFile(file, db, callback) {
callback = callback || function() {};
if (file.substr(0, 1) !== '/') {
var parentPath = module.parent.filename.split('/');
parentPath.pop();
file = parentPath.join('/') + '/' + file;
}
load(require(file), db, callback);
} | javascript | function loadFile(file, db, callback) {
callback = callback || function() {};
if (file.substr(0, 1) !== '/') {
var parentPath = module.parent.filename.split('/');
parentPath.pop();
file = parentPath.join('/') + '/' + file;
}
load(require(file), db, callback);
} | [
"function",
"loadFile",
"(",
"file",
",",
"db",
",",
"callback",
")",
"{",
"callback",
"=",
"callback",
"||",
"function",
"(",
")",
"{",
"}",
";",
"if",
"(",
"file",
".",
"substr",
"(",
"0",
",",
"1",
")",
"!==",
"'/'",
")",
"{",
"var",
"parentPa... | Loads fixtures from one file
TODO: Add callback option
@param {String} The full path to the file to load
@param {Connection} The mongoose connection to use
@param {Function} Callback | [
"Loads",
"fixtures",
"from",
"one",
"file"
] | 29e4ff333913636dfee96ed6a9a40bef4551f60d | https://github.com/powmedia/mongoose-fixtures/blob/29e4ff333913636dfee96ed6a9a40bef4551f60d/mongoose_fixtures.js#L137-L147 | train |
powmedia/mongoose-fixtures | mongoose_fixtures.js | loadDir | function loadDir(dir, db, callback) {
callback = callback || function() {};
//Get the absolute dir path if a relative path was given
if (dir.substr(0, 1) !== '/') {
var parentPath = module.parent.filename.split('/');
parentPath.pop();
dir = parentPath.join('/') + '/' + dir;
... | javascript | function loadDir(dir, db, callback) {
callback = callback || function() {};
//Get the absolute dir path if a relative path was given
if (dir.substr(0, 1) !== '/') {
var parentPath = module.parent.filename.split('/');
parentPath.pop();
dir = parentPath.join('/') + '/' + dir;
... | [
"function",
"loadDir",
"(",
"dir",
",",
"db",
",",
"callback",
")",
"{",
"callback",
"=",
"callback",
"||",
"function",
"(",
")",
"{",
"}",
";",
"//Get the absolute dir path if a relative path was given",
"if",
"(",
"dir",
".",
"substr",
"(",
"0",
",",
"1",
... | Loads fixtures from all files in a directory
TODO: Add callback option
@param {String} The directory path to load e.g. 'data/fixtures' or '../data'
@param {Connection} The mongoose connection to use
@param {Function} Callback | [
"Loads",
"fixtures",
"from",
"all",
"files",
"in",
"a",
"directory"
] | 29e4ff333913636dfee96ed6a9a40bef4551f60d | https://github.com/powmedia/mongoose-fixtures/blob/29e4ff333913636dfee96ed6a9a40bef4551f60d/mongoose_fixtures.js#L159-L178 | train |
cultureamp/elm-css-modules-loader | ci/publishElmRelease.js | tagElmRelease | async function tagElmRelease(config, context) {
function exec(command) {
context.logger.log(`Running: ${command}`);
execSync(command);
}
const elmPackageJson = JSON.parse(fs.readFileSync('elm.json'));
await tag(elmPackageJson.version);
const repositoryUrl = await getGitAuthUrl(config);
await push(r... | javascript | async function tagElmRelease(config, context) {
function exec(command) {
context.logger.log(`Running: ${command}`);
execSync(command);
}
const elmPackageJson = JSON.parse(fs.readFileSync('elm.json'));
await tag(elmPackageJson.version);
const repositoryUrl = await getGitAuthUrl(config);
await push(r... | [
"async",
"function",
"tagElmRelease",
"(",
"config",
",",
"context",
")",
"{",
"function",
"exec",
"(",
"command",
")",
"{",
"context",
".",
"logger",
".",
"log",
"(",
"`",
"${",
"command",
"}",
"`",
")",
";",
"execSync",
"(",
"command",
")",
";",
"}... | A semantic release "publish" plugin to create tags and run `elm-package publish`. | [
"A",
"semantic",
"release",
"publish",
"plugin",
"to",
"create",
"tags",
"and",
"run",
"elm",
"-",
"package",
"publish",
"."
] | 93a702e272bed758128b11ee14cb849de0ffa7a2 | https://github.com/cultureamp/elm-css-modules-loader/blob/93a702e272bed758128b11ee14cb849de0ffa7a2/ci/publishElmRelease.js#L9-L28 | train |
mongodb-js/dataset-generator | lib/schema/entry.js | Entry | function Entry (content, name, parent) {
if (!(this instanceof Entry)) return new Entry(content, name, parent);
this._parent = parent; // parent can be a Document or ArrayField
this._schema = parent._schema; // the root Document
this._name = name; // the field name supplied by the user
this._hidden = isHidde... | javascript | function Entry (content, name, parent) {
if (!(this instanceof Entry)) return new Entry(content, name, parent);
this._parent = parent; // parent can be a Document or ArrayField
this._schema = parent._schema; // the root Document
this._name = name; // the field name supplied by the user
this._hidden = isHidde... | [
"function",
"Entry",
"(",
"content",
",",
"name",
",",
"parent",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Entry",
")",
")",
"return",
"new",
"Entry",
"(",
"content",
",",
"name",
",",
"parent",
")",
";",
"this",
".",
"_parent",
"=",
"p... | High level representation of all fields in template schemas
@class
@abstract
@memberOf module:schema
@param {*} content
@param {string} name
@param {(Entry|Schema)} parent | [
"High",
"level",
"representation",
"of",
"all",
"fields",
"in",
"template",
"schemas"
] | 0f56410970a8dc03433477966dafa16a5cbd9cda | https://github.com/mongodb-js/dataset-generator/blob/0f56410970a8dc03433477966dafa16a5cbd9cda/lib/schema/entry.js#L12-L24 | train |
hoodiehq/hoodie-store-client | lib/remove.js | remove | function remove (state, prefix, objectsOrIds, change) {
if (Array.isArray(objectsOrIds)) {
return Promise.all(objectsOrIds.map(markAsDeleted.bind(null, state, change)))
.then(function (docs) {
return updateMany(state, docs, null, prefix)
})
}
return markAsDeleted(state, change, objectsOrIds)
... | javascript | function remove (state, prefix, objectsOrIds, change) {
if (Array.isArray(objectsOrIds)) {
return Promise.all(objectsOrIds.map(markAsDeleted.bind(null, state, change)))
.then(function (docs) {
return updateMany(state, docs, null, prefix)
})
}
return markAsDeleted(state, change, objectsOrIds)
... | [
"function",
"remove",
"(",
"state",
",",
"prefix",
",",
"objectsOrIds",
",",
"change",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"objectsOrIds",
")",
")",
"{",
"return",
"Promise",
".",
"all",
"(",
"objectsOrIds",
".",
"map",
"(",
"markAsDeleted... | removes existing object
@param {String} prefix optional id prefix
@param {Object|Function} objectsOrIds id or object with `._id` property
@param {Object|Function} [change] Change properties or function that
changes existing object
@return {Promise} | [
"removes",
"existing",
"object"
] | a0043e6b73a5ee90675fb02be78edfceef94a6b1 | https://github.com/hoodiehq/hoodie-store-client/blob/a0043e6b73a5ee90675fb02be78edfceef94a6b1/lib/remove.js#L17-L31 | train |
mongodb-js/dataset-generator | lib/schema/field.js | Field | function Field (field, name, parent) {
if (!(this instanceof Field)) return new Field(field, name, parent);
debug('field <%s> being built from <%s>', name, field);
Entry.call(this, field, name, parent);
this._context = parent._context;
this._this = parent._this;
if (typeof this._content !== 'string') {
... | javascript | function Field (field, name, parent) {
if (!(this instanceof Field)) return new Field(field, name, parent);
debug('field <%s> being built from <%s>', name, field);
Entry.call(this, field, name, parent);
this._context = parent._context;
this._this = parent._this;
if (typeof this._content !== 'string') {
... | [
"function",
"Field",
"(",
"field",
",",
"name",
",",
"parent",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Field",
")",
")",
"return",
"new",
"Field",
"(",
"field",
",",
"name",
",",
"parent",
")",
";",
"debug",
"(",
"'field <%s> being built ... | Internal representation of non-object non-array fields in template schema
@class
@augments {Entry}
@memberOf module:schema
@param {(string|number|boolean)} field
@param {string} name
@param {Entry} parent | [
"Internal",
"representation",
"of",
"non",
"-",
"object",
"non",
"-",
"array",
"fields",
"in",
"template",
"schema"
] | 0f56410970a8dc03433477966dafa16a5cbd9cda | https://github.com/mongodb-js/dataset-generator/blob/0f56410970a8dc03433477966dafa16a5cbd9cda/lib/schema/field.js#L19-L34 | train |
gmetais/grunt-yellowlabtools | tasks/lib/conditions.js | function(results) {
var globalScoreSum = 0;
var globalScoreCount = 0;
var rulesScoresSum = {};
var rulesScoresCount = {};
var rulesValuesSum = {};
var rulesValuesCount = {};
results.forEach(function(result) {
// Global score
globalScoreSum += result.scoreProfiles.... | javascript | function(results) {
var globalScoreSum = 0;
var globalScoreCount = 0;
var rulesScoresSum = {};
var rulesScoresCount = {};
var rulesValuesSum = {};
var rulesValuesCount = {};
results.forEach(function(result) {
// Global score
globalScoreSum += result.scoreProfiles.... | [
"function",
"(",
"results",
")",
"{",
"var",
"globalScoreSum",
"=",
"0",
";",
"var",
"globalScoreCount",
"=",
"0",
";",
"var",
"rulesScoresSum",
"=",
"{",
"}",
";",
"var",
"rulesScoresCount",
"=",
"{",
"}",
";",
"var",
"rulesValuesSum",
"=",
"{",
"}",
... | Gets every score or value from all results and calculates their average NOT USED FOR THE MOMENT | [
"Gets",
"every",
"score",
"or",
"value",
"from",
"all",
"results",
"and",
"calculates",
"their",
"average",
"NOT",
"USED",
"FOR",
"THE",
"MOMENT"
] | cf6f73e060529c75c636289337288fda58dc1e9b | https://github.com/gmetais/grunt-yellowlabtools/blob/cf6f73e060529c75c636289337288fda58dc1e9b/tasks/lib/conditions.js#L152-L208 | train | |
gmetais/grunt-yellowlabtools | tasks/lib/conditions.js | function(phrasesArray) {
var deferred = Q.defer();
if (phrasesArray === undefined) {
phrasesArray = [];
}
// Default conditionsObject
var conditionsObject = {
atLeastOneUrl: {
ruleScores: [],
ruleValues: [],
ignoredRules: []
}
};
... | javascript | function(phrasesArray) {
var deferred = Q.defer();
if (phrasesArray === undefined) {
phrasesArray = [];
}
// Default conditionsObject
var conditionsObject = {
atLeastOneUrl: {
ruleScores: [],
ruleValues: [],
ignoredRules: []
}
};
... | [
"function",
"(",
"phrasesArray",
")",
"{",
"var",
"deferred",
"=",
"Q",
".",
"defer",
"(",
")",
";",
"if",
"(",
"phrasesArray",
"===",
"undefined",
")",
"{",
"phrasesArray",
"=",
"[",
"]",
";",
"}",
"// Default conditionsObject",
"var",
"conditionsObject",
... | Reads an array of phrases, understand them and transform them into a conditionsObject | [
"Reads",
"an",
"array",
"of",
"phrases",
"understand",
"them",
"and",
"transform",
"them",
"into",
"a",
"conditionsObject"
] | cf6f73e060529c75c636289337288fda58dc1e9b | https://github.com/gmetais/grunt-yellowlabtools/blob/cf6f73e060529c75c636289337288fda58dc1e9b/tasks/lib/conditions.js#L212-L268 | train | |
christophertrudel/node_acl_knex | lib/knex-backend.js | function(bucket, key, cb){
contract(arguments)
.params('string', 'string|number', 'function')
.end()
;
var table = '';
if (bucket.indexOf('allows') != -1) {
table = this.prefix + this.buckets.permissions;
this.db
.select('key', 'value')
.from(table)
.where({'key': bucket})
.then(f... | javascript | function(bucket, key, cb){
contract(arguments)
.params('string', 'string|number', 'function')
.end()
;
var table = '';
if (bucket.indexOf('allows') != -1) {
table = this.prefix + this.buckets.permissions;
this.db
.select('key', 'value')
.from(table)
.where({'key': bucket})
.then(f... | [
"function",
"(",
"bucket",
",",
"key",
",",
"cb",
")",
"{",
"contract",
"(",
"arguments",
")",
".",
"params",
"(",
"'string'",
",",
"'string|number'",
",",
"'function'",
")",
".",
"end",
"(",
")",
";",
"var",
"table",
"=",
"''",
";",
"if",
"(",
"bu... | Gets the contents at the bucket's key. | [
"Gets",
"the",
"contents",
"at",
"the",
"bucket",
"s",
"key",
"."
] | 38585647267553fbd6e117aca172585d62069fae | https://github.com/christophertrudel/node_acl_knex/blob/38585647267553fbd6e117aca172585d62069fae/lib/knex-backend.js#L57-L89 | train | |
christophertrudel/node_acl_knex | lib/knex-backend.js | function(bucket, keys, cb){
contract(arguments)
.params('string', 'array', 'function')
.end()
;
var table = '';
if (bucket.indexOf('allows') != -1) {
table = this.prefix + this.buckets.permissions;
this.db
.select('key', 'value')
.from(table)
.where({'key': bucket})
.then(function... | javascript | function(bucket, keys, cb){
contract(arguments)
.params('string', 'array', 'function')
.end()
;
var table = '';
if (bucket.indexOf('allows') != -1) {
table = this.prefix + this.buckets.permissions;
this.db
.select('key', 'value')
.from(table)
.where({'key': bucket})
.then(function... | [
"function",
"(",
"bucket",
",",
"keys",
",",
"cb",
")",
"{",
"contract",
"(",
"arguments",
")",
".",
"params",
"(",
"'string'",
",",
"'array'",
",",
"'function'",
")",
".",
"end",
"(",
")",
";",
"var",
"table",
"=",
"''",
";",
"if",
"(",
"bucket",
... | Returns the union of the values in the given keys. | [
"Returns",
"the",
"union",
"of",
"the",
"values",
"in",
"the",
"given",
"keys",
"."
] | 38585647267553fbd6e117aca172585d62069fae | https://github.com/christophertrudel/node_acl_knex/blob/38585647267553fbd6e117aca172585d62069fae/lib/knex-backend.js#L94-L139 | train | |
christophertrudel/node_acl_knex | lib/knex-backend.js | function(transaction, bucket, key, values){
contract(arguments)
.params('array', 'string', 'string|number','string|array|number')
.end()
;
var self = this;
var table = '';
values = Array.isArray(values) ? values : [values]; // we always want to have an array for values
transaction.push(function(... | javascript | function(transaction, bucket, key, values){
contract(arguments)
.params('array', 'string', 'string|number','string|array|number')
.end()
;
var self = this;
var table = '';
values = Array.isArray(values) ? values : [values]; // we always want to have an array for values
transaction.push(function(... | [
"function",
"(",
"transaction",
",",
"bucket",
",",
"key",
",",
"values",
")",
"{",
"contract",
"(",
"arguments",
")",
".",
"params",
"(",
"'array'",
",",
"'string'",
",",
"'string|number'",
",",
"'string|array|number'",
")",
".",
"end",
"(",
")",
";",
"... | Adds values to a given key inside a table. | [
"Adds",
"values",
"to",
"a",
"given",
"key",
"inside",
"a",
"table",
"."
] | 38585647267553fbd6e117aca172585d62069fae | https://github.com/christophertrudel/node_acl_knex/blob/38585647267553fbd6e117aca172585d62069fae/lib/knex-backend.js#L144-L220 | train | |
christophertrudel/node_acl_knex | lib/knex-backend.js | function(transaction, bucket, key, values){
contract(arguments)
.params('array', 'string', 'string|number','string|array')
.end()
;
var self = this;
var table = '';
values = Array.isArray(values) ? values : [values]; // we always want to have an array for values
transaction.push(function(cb){
... | javascript | function(transaction, bucket, key, values){
contract(arguments)
.params('array', 'string', 'string|number','string|array')
.end()
;
var self = this;
var table = '';
values = Array.isArray(values) ? values : [values]; // we always want to have an array for values
transaction.push(function(cb){
... | [
"function",
"(",
"transaction",
",",
"bucket",
",",
"key",
",",
"values",
")",
"{",
"contract",
"(",
"arguments",
")",
".",
"params",
"(",
"'array'",
",",
"'string'",
",",
"'string|number'",
",",
"'string|array'",
")",
".",
"end",
"(",
")",
";",
"var",
... | Removes values from a given key inside a bucket. | [
"Removes",
"values",
"from",
"a",
"given",
"key",
"inside",
"a",
"bucket",
"."
] | 38585647267553fbd6e117aca172585d62069fae | https://github.com/christophertrudel/node_acl_knex/blob/38585647267553fbd6e117aca172585d62069fae/lib/knex-backend.js#L286-L351 | train | |
hoodiehq/hoodie-store-client | lib/find-all.js | findAll | function findAll (state, prefix, filter) {
var options = {
include_docs: true
}
if (prefix) {
options.startkey = prefix
options.endkey = prefix + '\uffff'
}
return state.db.allDocs(options)
.then(function (res) {
var objects = res.rows
.filter(isntDesignDoc)
.map(function (row... | javascript | function findAll (state, prefix, filter) {
var options = {
include_docs: true
}
if (prefix) {
options.startkey = prefix
options.endkey = prefix + '\uffff'
}
return state.db.allDocs(options)
.then(function (res) {
var objects = res.rows
.filter(isntDesignDoc)
.map(function (row... | [
"function",
"findAll",
"(",
"state",
",",
"prefix",
",",
"filter",
")",
"{",
"var",
"options",
"=",
"{",
"include_docs",
":",
"true",
"}",
"if",
"(",
"prefix",
")",
"{",
"options",
".",
"startkey",
"=",
"prefix",
"options",
".",
"endkey",
"=",
"prefix"... | finds all existing objects in local database.
@param {String} prefix optional id prefix
@param {Function} [filter] Function returning `true` for any object
to be returned.
@return {Promise} | [
"finds",
"all",
"existing",
"objects",
"in",
"local",
"database",
"."
] | a0043e6b73a5ee90675fb02be78edfceef94a6b1 | https://github.com/hoodiehq/hoodie-store-client/blob/a0043e6b73a5ee90675fb02be78edfceef94a6b1/lib/find-all.js#L14-L37 | train |
bojand/json-schema-deref-sync | lib/index.js | getRefSchema | function getRefSchema (refVal, refType, parent, options, state) {
const loader = getLoader(refType, options)
if (refType && loader) {
let newVal
let oldBasePath
let loaderValue
let filePath
let fullRefFilePath
if (refType === 'file') {
filePath = utils.getRefFilePath(refVal)
ful... | javascript | function getRefSchema (refVal, refType, parent, options, state) {
const loader = getLoader(refType, options)
if (refType && loader) {
let newVal
let oldBasePath
let loaderValue
let filePath
let fullRefFilePath
if (refType === 'file') {
filePath = utils.getRefFilePath(refVal)
ful... | [
"function",
"getRefSchema",
"(",
"refVal",
",",
"refType",
",",
"parent",
",",
"options",
",",
"state",
")",
"{",
"const",
"loader",
"=",
"getLoader",
"(",
"refType",
",",
"options",
")",
"if",
"(",
"refType",
"&&",
"loader",
")",
"{",
"let",
"newVal",
... | Returns the reference schema that refVal points to.
If the ref val points to a ref within a file, the file is loaded and fully derefed, before we get the
pointing property. Derefed files are cached.
@param refVal
@param refType
@param parent
@param options
@param state
@private | [
"Returns",
"the",
"reference",
"schema",
"that",
"refVal",
"points",
"to",
".",
"If",
"the",
"ref",
"val",
"points",
"to",
"a",
"ref",
"within",
"a",
"file",
"the",
"file",
"is",
"loaded",
"and",
"fully",
"derefed",
"before",
"we",
"get",
"the",
"pointin... | 10b1b3b94ffa27d8312537bbf540a59ac7aeaf27 | https://github.com/bojand/json-schema-deref-sync/blob/10b1b3b94ffa27d8312537bbf540a59ac7aeaf27/lib/index.js#L36-L101 | train |
bojand/json-schema-deref-sync | lib/index.js | addToHistory | function addToHistory (state, type, value) {
let dest
if (type === 'file') {
dest = utils.getRefFilePath(value)
} else {
if (value === '#') {
return false
}
dest = state.current.concat(`:${value}`)
}
if (dest) {
dest = dest.toLowerCase()
if (state.history.indexOf(dest) >= 0) {
... | javascript | function addToHistory (state, type, value) {
let dest
if (type === 'file') {
dest = utils.getRefFilePath(value)
} else {
if (value === '#') {
return false
}
dest = state.current.concat(`:${value}`)
}
if (dest) {
dest = dest.toLowerCase()
if (state.history.indexOf(dest) >= 0) {
... | [
"function",
"addToHistory",
"(",
"state",
",",
"type",
",",
"value",
")",
"{",
"let",
"dest",
"if",
"(",
"type",
"===",
"'file'",
")",
"{",
"dest",
"=",
"utils",
".",
"getRefFilePath",
"(",
"value",
")",
"}",
"else",
"{",
"if",
"(",
"value",
"===",
... | Add to state history
@param {Object} state the state
@param {String} type ref type
@param {String} value ref value
@private | [
"Add",
"to",
"state",
"history"
] | 10b1b3b94ffa27d8312537bbf540a59ac7aeaf27 | https://github.com/bojand/json-schema-deref-sync/blob/10b1b3b94ffa27d8312537bbf540a59ac7aeaf27/lib/index.js#L110-L131 | train |
bojand/json-schema-deref-sync | lib/index.js | setCurrent | function setCurrent (state, type, value) {
let dest
if (type === 'file') {
dest = utils.getRefFilePath(value)
}
if (dest) {
state.current = dest
}
} | javascript | function setCurrent (state, type, value) {
let dest
if (type === 'file') {
dest = utils.getRefFilePath(value)
}
if (dest) {
state.current = dest
}
} | [
"function",
"setCurrent",
"(",
"state",
",",
"type",
",",
"value",
")",
"{",
"let",
"dest",
"if",
"(",
"type",
"===",
"'file'",
")",
"{",
"dest",
"=",
"utils",
".",
"getRefFilePath",
"(",
"value",
")",
"}",
"if",
"(",
"dest",
")",
"{",
"state",
"."... | Set the current into state
@param {Object} state the state
@param {String} type ref type
@param {String} value ref value
@private | [
"Set",
"the",
"current",
"into",
"state"
] | 10b1b3b94ffa27d8312537bbf540a59ac7aeaf27 | https://github.com/bojand/json-schema-deref-sync/blob/10b1b3b94ffa27d8312537bbf540a59ac7aeaf27/lib/index.js#L140-L149 | train |
bojand/json-schema-deref-sync | lib/index.js | checkLocalCircular | function checkLocalCircular (schema) {
const dag = new DAG()
const locals = traverse(schema).reduce(function (acc, node) {
if (!_.isNull(node) && !_.isUndefined(null) && typeof node.$ref === 'string') {
const refType = utils.getRefType(node)
if (refType === 'local') {
const value = utils.get... | javascript | function checkLocalCircular (schema) {
const dag = new DAG()
const locals = traverse(schema).reduce(function (acc, node) {
if (!_.isNull(node) && !_.isUndefined(null) && typeof node.$ref === 'string') {
const refType = utils.getRefType(node)
if (refType === 'local') {
const value = utils.get... | [
"function",
"checkLocalCircular",
"(",
"schema",
")",
"{",
"const",
"dag",
"=",
"new",
"DAG",
"(",
")",
"const",
"locals",
"=",
"traverse",
"(",
"schema",
")",
".",
"reduce",
"(",
"function",
"(",
"acc",
",",
"node",
")",
"{",
"if",
"(",
"!",
"_",
... | Check the schema for local circular refs using DAG
@param {Object} schema the schema
@return {Error|undefined} <code>Error</code> if circular ref, <code>undefined</code> otherwise if OK
@private | [
"Check",
"the",
"schema",
"for",
"local",
"circular",
"refs",
"using",
"DAG"
] | 10b1b3b94ffa27d8312537bbf540a59ac7aeaf27 | https://github.com/bojand/json-schema-deref-sync/blob/10b1b3b94ffa27d8312537bbf540a59ac7aeaf27/lib/index.js#L157-L201 | train |
tykeal/ep_ldapauth | lib/MyLdapAuth.js | MyLdapAuth | function MyLdapAuth(opts) {
this.opts = opts;
assert.ok(opts.url);
assert.ok(opts.searchBase);
assert.ok(opts.searchFilter);
// optional option: tls_ca
this.log = opts.log4js && opts.log4js.getLogger('ldapauth');
var clientOpts = {url: opts.url};
if (opts.log4js && opts.verbose) {
clientOpts.log4... | javascript | function MyLdapAuth(opts) {
this.opts = opts;
assert.ok(opts.url);
assert.ok(opts.searchBase);
assert.ok(opts.searchFilter);
// optional option: tls_ca
this.log = opts.log4js && opts.log4js.getLogger('ldapauth');
var clientOpts = {url: opts.url};
if (opts.log4js && opts.verbose) {
clientOpts.log4... | [
"function",
"MyLdapAuth",
"(",
"opts",
")",
"{",
"this",
".",
"opts",
"=",
"opts",
";",
"assert",
".",
"ok",
"(",
"opts",
".",
"url",
")",
";",
"assert",
".",
"ok",
"(",
"opts",
".",
"searchBase",
")",
";",
"assert",
".",
"ok",
"(",
"opts",
".",
... | Create the MyLdapAuth class which is a former super class of LdapAuth
until I ended up having to reimplement too much of it
@param opts {Object} config options. Keys (required, unless stated
otherwise) are:
url {String} E.g. 'ldaps://ldap.example.com:663'
adminDn {String} E.g. 'uid=myapp,ou=users,o=example.com'
adminP... | [
"Create",
"the",
"MyLdapAuth",
"class",
"which",
"is",
"a",
"former",
"super",
"class",
"of",
"LdapAuth",
"until",
"I",
"ended",
"up",
"having",
"to",
"reimplement",
"too",
"much",
"of",
"it"
] | 8ae8249334461720fe1d83b31f977c61870c878e | https://github.com/tykeal/ep_ldapauth/blob/8ae8249334461720fe1d83b31f977c61870c878e/lib/MyLdapAuth.js#L39-L53 | train |
hoodiehq/hoodie-store-client | lib/push.js | push | function push (state, docsOrIds) {
var pushedObjects = []
var errors = state.db.constructor.Errors
return Promise.resolve(state.remote)
.then(function (remote) {
return new Promise(function (resolve, reject) {
if (Array.isArray(docsOrIds)) {
docsOrIds = docsOrIds.map(toId)
} else {
... | javascript | function push (state, docsOrIds) {
var pushedObjects = []
var errors = state.db.constructor.Errors
return Promise.resolve(state.remote)
.then(function (remote) {
return new Promise(function (resolve, reject) {
if (Array.isArray(docsOrIds)) {
docsOrIds = docsOrIds.map(toId)
} else {
... | [
"function",
"push",
"(",
"state",
",",
"docsOrIds",
")",
"{",
"var",
"pushedObjects",
"=",
"[",
"]",
"var",
"errors",
"=",
"state",
".",
"db",
".",
"constructor",
".",
"Errors",
"return",
"Promise",
".",
"resolve",
"(",
"state",
".",
"remote",
")",
"."... | pushes one or multiple objects from local to remote database
@param {StringOrObject} docsOrIds object or ID of object or array of objects/ids (all optional)
@return {Promise} | [
"pushes",
"one",
"or",
"multiple",
"objects",
"from",
"local",
"to",
"remote",
"database"
] | a0043e6b73a5ee90675fb02be78edfceef94a6b1 | https://github.com/hoodiehq/hoodie-store-client/blob/a0043e6b73a5ee90675fb02be78edfceef94a6b1/lib/push.js#L14-L56 | train |
hoodiehq/hoodie-store-client | lib/with-id-prefix.js | withIdPrefix | function withIdPrefix (state, prefix) {
var emitter = new EventEmitter()
var api = {
add: require('./add').bind(null, state, prefix),
find: require('./find').bind(null, state, prefix),
findAll: require('./find-all').bind(null, state, prefix),
findOrAdd: require('./find-or-add').bind(null, state, pr... | javascript | function withIdPrefix (state, prefix) {
var emitter = new EventEmitter()
var api = {
add: require('./add').bind(null, state, prefix),
find: require('./find').bind(null, state, prefix),
findAll: require('./find-all').bind(null, state, prefix),
findOrAdd: require('./find-or-add').bind(null, state, pr... | [
"function",
"withIdPrefix",
"(",
"state",
",",
"prefix",
")",
"{",
"var",
"emitter",
"=",
"new",
"EventEmitter",
"(",
")",
"var",
"api",
"=",
"{",
"add",
":",
"require",
"(",
"'./add'",
")",
".",
"bind",
"(",
"null",
",",
"state",
",",
"prefix",
")",... | returns API with all CRUD methods scoped to id prefix
@param {String} prefix String all ID’s are implicitly prefixed or
expected to be prefixed with. | [
"returns",
"API",
"with",
"all",
"CRUD",
"methods",
"scoped",
"to",
"id",
"prefix"
] | a0043e6b73a5ee90675fb02be78edfceef94a6b1 | https://github.com/hoodiehq/hoodie-store-client/blob/a0043e6b73a5ee90675fb02be78edfceef94a6b1/lib/with-id-prefix.js#L12-L44 | train |
bojand/json-schema-deref-sync | lib/utils.js | getRefValue | function getRefValue (ref) {
const thing = ref ? (ref.value ? ref.value : ref) : null
if (thing && thing.$ref && typeof thing.$ref === 'string') {
return thing.$ref
}
} | javascript | function getRefValue (ref) {
const thing = ref ? (ref.value ? ref.value : ref) : null
if (thing && thing.$ref && typeof thing.$ref === 'string') {
return thing.$ref
}
} | [
"function",
"getRefValue",
"(",
"ref",
")",
"{",
"const",
"thing",
"=",
"ref",
"?",
"(",
"ref",
".",
"value",
"?",
"ref",
".",
"value",
":",
"ref",
")",
":",
"null",
"if",
"(",
"thing",
"&&",
"thing",
".",
"$ref",
"&&",
"typeof",
"thing",
".",
"$... | Gets the ref value of a search result from prop-search or ref object
@param ref The search result object from prop-search
@returns {*} The value of $ref or undefined if not present in search object
@private | [
"Gets",
"the",
"ref",
"value",
"of",
"a",
"search",
"result",
"from",
"prop",
"-",
"search",
"or",
"ref",
"object"
] | 10b1b3b94ffa27d8312537bbf540a59ac7aeaf27 | https://github.com/bojand/json-schema-deref-sync/blob/10b1b3b94ffa27d8312537bbf540a59ac7aeaf27/lib/utils.js#L13-L18 | train |
bojand/json-schema-deref-sync | lib/utils.js | getRefPathValue | function getRefPathValue (schema, refPath) {
let rpath = refPath
const hashIndex = refPath.indexOf('#')
if (hashIndex >= 0) {
rpath = refPath.substring(hashIndex)
if (rpath.length > 1) {
rpath = refPath.substring(1)
} else {
rpath = ''
}
}
// Walk through each /-separated path com... | javascript | function getRefPathValue (schema, refPath) {
let rpath = refPath
const hashIndex = refPath.indexOf('#')
if (hashIndex >= 0) {
rpath = refPath.substring(hashIndex)
if (rpath.length > 1) {
rpath = refPath.substring(1)
} else {
rpath = ''
}
}
// Walk through each /-separated path com... | [
"function",
"getRefPathValue",
"(",
"schema",
",",
"refPath",
")",
"{",
"let",
"rpath",
"=",
"refPath",
"const",
"hashIndex",
"=",
"refPath",
".",
"indexOf",
"(",
"'#'",
")",
"if",
"(",
"hashIndex",
">=",
"0",
")",
"{",
"rpath",
"=",
"refPath",
".",
"s... | Gets the value at the ref path within schema
@param schema the (root) json schema to search
@param refPath string ref path to get within the schema. Ex. `#/definitions/id`
@returns {*} Returns the value at the path location or undefined if not found within the given schema
@private | [
"Gets",
"the",
"value",
"at",
"the",
"ref",
"path",
"within",
"schema"
] | 10b1b3b94ffa27d8312537bbf540a59ac7aeaf27 | https://github.com/bojand/json-schema-deref-sync/blob/10b1b3b94ffa27d8312537bbf540a59ac7aeaf27/lib/utils.js#L68-L86 | train |
yahoo/mendel | packages/mendel-generator-prune/index.js | pruneModules | function pruneModules(bundle, doneBundles, registry, generator) {
const {groups} = generator.options;
groups.forEach(group => {
const bundles = group.map(bundleId => {
return doneBundles.find(b => b.id === bundleId);
}).filter(Boolean);
pruneGroup(bundles);
});
} | javascript | function pruneModules(bundle, doneBundles, registry, generator) {
const {groups} = generator.options;
groups.forEach(group => {
const bundles = group.map(bundleId => {
return doneBundles.find(b => b.id === bundleId);
}).filter(Boolean);
pruneGroup(bundles);
});
} | [
"function",
"pruneModules",
"(",
"bundle",
",",
"doneBundles",
",",
"registry",
",",
"generator",
")",
"{",
"const",
"{",
"groups",
"}",
"=",
"generator",
".",
"options",
";",
"groups",
".",
"forEach",
"(",
"group",
"=>",
"{",
"const",
"bundles",
"=",
"g... | First argument is not needed; just to make it look like normal generator API | [
"First",
"argument",
"is",
"not",
"needed",
";",
"just",
"to",
"make",
"it",
"look",
"like",
"normal",
"generator",
"API"
] | 4c3d296248fb2a96f0d079eb70702298a44be9bd | https://github.com/yahoo/mendel/blob/4c3d296248fb2a96f0d079eb70702298a44be9bd/packages/mendel-generator-prune/index.js#L4-L12 | train |
hoodiehq/hoodie-store-client | lib/find.js | find | function find (state, prefix, objectsOrIds) {
return Array.isArray(objectsOrIds)
? findMany(state, objectsOrIds, prefix)
: findOne(state, objectsOrIds, prefix)
} | javascript | function find (state, prefix, objectsOrIds) {
return Array.isArray(objectsOrIds)
? findMany(state, objectsOrIds, prefix)
: findOne(state, objectsOrIds, prefix)
} | [
"function",
"find",
"(",
"state",
",",
"prefix",
",",
"objectsOrIds",
")",
"{",
"return",
"Array",
".",
"isArray",
"(",
"objectsOrIds",
")",
"?",
"findMany",
"(",
"state",
",",
"objectsOrIds",
",",
"prefix",
")",
":",
"findOne",
"(",
"state",
",",
"objec... | finds existing object in local database
@param {String} prefix optional id prefix
@param {String|Object|Object[]} objectsOrIds Id of object or object with
`._id` property
@return {Promise} | [
"finds",
"existing",
"object",
"in",
"local",
"database"
] | a0043e6b73a5ee90675fb02be78edfceef94a6b1 | https://github.com/hoodiehq/hoodie-store-client/blob/a0043e6b73a5ee90675fb02be78edfceef94a6b1/lib/find.js#L14-L18 | train |
Robert-W/grunt-ftp-push | tasks/ftp_push.js | getCredentials | function getCredentials(gruntOptions) {
if (gruntOptions.authKey && grunt.file.exists('.ftpauth')) {
return JSON.parse(grunt.file.read('.ftpauth'))[gruntOptions.authKey];
} else if (gruntOptions.username && gruntOptions.password) {
return { username: gruntOptions.username, password: gruntOptions.pas... | javascript | function getCredentials(gruntOptions) {
if (gruntOptions.authKey && grunt.file.exists('.ftpauth')) {
return JSON.parse(grunt.file.read('.ftpauth'))[gruntOptions.authKey];
} else if (gruntOptions.username && gruntOptions.password) {
return { username: gruntOptions.username, password: gruntOptions.pas... | [
"function",
"getCredentials",
"(",
"gruntOptions",
")",
"{",
"if",
"(",
"gruntOptions",
".",
"authKey",
"&&",
"grunt",
".",
"file",
".",
"exists",
"(",
"'.ftpauth'",
")",
")",
"{",
"return",
"JSON",
".",
"parse",
"(",
"grunt",
".",
"file",
".",
"read",
... | Based off of whats in the options, create a credentials object
@param {object} options - grunt options provided to the plugin
@return {object} {username: '...', password: '...'} | [
"Based",
"off",
"of",
"whats",
"in",
"the",
"options",
"create",
"a",
"credentials",
"object"
] | aa3f520c6422d94bcaab69f21f44e26f635c5014 | https://github.com/Robert-W/grunt-ftp-push/blob/aa3f520c6422d94bcaab69f21f44e26f635c5014/tasks/ftp_push.js#L27-L37 | train |
Robert-W/grunt-ftp-push | tasks/ftp_push.js | pushDirectories | function pushDirectories(directories, callback) {
var index = 0;
/**
* Recursive helper used as callback for server.raw(mkd)
* @param {error} err - Error message if something went wrong
*/
var processDir = function processDir (err) {
// Fail if any error other then 550 is present, 550 is ... | javascript | function pushDirectories(directories, callback) {
var index = 0;
/**
* Recursive helper used as callback for server.raw(mkd)
* @param {error} err - Error message if something went wrong
*/
var processDir = function processDir (err) {
// Fail if any error other then 550 is present, 550 is ... | [
"function",
"pushDirectories",
"(",
"directories",
",",
"callback",
")",
"{",
"var",
"index",
"=",
"0",
";",
"/**\n * Recursive helper used as callback for server.raw(mkd)\n * @param {error} err - Error message if something went wrong\n */",
"var",
"processDir",
"=",
"func... | Helper function that uses a recursive style for creating directories until none remain
@param {array} directories - Array of directory paths that will be necessary to upload files
@param {function} callback - function to trigger when all directories have been created | [
"Helper",
"function",
"that",
"uses",
"a",
"recursive",
"style",
"for",
"creating",
"directories",
"until",
"none",
"remain"
] | aa3f520c6422d94bcaab69f21f44e26f635c5014 | https://github.com/Robert-W/grunt-ftp-push/blob/aa3f520c6422d94bcaab69f21f44e26f635c5014/tasks/ftp_push.js#L44-L75 | train |
Robert-W/grunt-ftp-push | tasks/ftp_push.js | uploadFiles | function uploadFiles(files) {
var index = 0,
file = files[index];
/**
* Recursive helper used as callback for server.raw(put)
* @param {error} err - Error message if something went wrong
*/
var processFile = function processFile (err) {
if (err) {
grunt.log.warn(messages.f... | javascript | function uploadFiles(files) {
var index = 0,
file = files[index];
/**
* Recursive helper used as callback for server.raw(put)
* @param {error} err - Error message if something went wrong
*/
var processFile = function processFile (err) {
if (err) {
grunt.log.warn(messages.f... | [
"function",
"uploadFiles",
"(",
"files",
")",
"{",
"var",
"index",
"=",
"0",
",",
"file",
"=",
"files",
"[",
"index",
"]",
";",
"/**\n * Recursive helper used as callback for server.raw(put)\n * @param {error} err - Error message if something went wrong\n */",
"var",
... | Helper function that uses a recursive style for uploading files until none remain
@param {object[]} files - Array of file objects to upload, {src: '...', dest: '...'} | [
"Helper",
"function",
"that",
"uses",
"a",
"recursive",
"style",
"for",
"uploading",
"files",
"until",
"none",
"remain"
] | aa3f520c6422d94bcaab69f21f44e26f635c5014 | https://github.com/Robert-W/grunt-ftp-push/blob/aa3f520c6422d94bcaab69f21f44e26f635c5014/tasks/ftp_push.js#L81-L117 | train |
marcello3d/node-licensecheck | urltolicense.js | getLicenseFromUrl | function getLicenseFromUrl (url) {
var regex = {
opensource: /(http(s)?:\/\/)?(www.)?opensource.org\/licenses\/([A-Za-z0-9\-._]+)$/,
spdx: /(http(s)?:\/\/)?(www.)?spdx.org\/licenses\/([A-Za-z0-9\-._]+)$/
}
for (var re in regex) {
var tokens = url.match(regex[re])
if (tokens) {
var license ... | javascript | function getLicenseFromUrl (url) {
var regex = {
opensource: /(http(s)?:\/\/)?(www.)?opensource.org\/licenses\/([A-Za-z0-9\-._]+)$/,
spdx: /(http(s)?:\/\/)?(www.)?spdx.org\/licenses\/([A-Za-z0-9\-._]+)$/
}
for (var re in regex) {
var tokens = url.match(regex[re])
if (tokens) {
var license ... | [
"function",
"getLicenseFromUrl",
"(",
"url",
")",
"{",
"var",
"regex",
"=",
"{",
"opensource",
":",
"/",
"(http(s)?:\\/\\/)?(www.)?opensource.org\\/licenses\\/([A-Za-z0-9\\-._]+)$",
"/",
",",
"spdx",
":",
"/",
"(http(s)?:\\/\\/)?(www.)?spdx.org\\/licenses\\/([A-Za-z0-9\\-._]+)$... | Find license name from license url | [
"Find",
"license",
"name",
"from",
"license",
"url"
] | 406af818a1a50dbcc8c3a04f46e9d5ed03cf11f7 | https://github.com/marcello3d/node-licensecheck/blob/406af818a1a50dbcc8c3a04f46e9d5ed03cf11f7/urltolicense.js#L5-L30 | train |
cultureamp/elm-css-modules-loader | ci/prepareElmRelease.js | prepareElmRelease | async function prepareElmRelease(config, context) {
function exec(command) {
context.logger.log(`Running: ${command}`);
execSync(command, { shell: '/bin/bash' });
}
exec(`yarn elm diff`);
exec(`yes | yarn elm bump`);
} | javascript | async function prepareElmRelease(config, context) {
function exec(command) {
context.logger.log(`Running: ${command}`);
execSync(command, { shell: '/bin/bash' });
}
exec(`yarn elm diff`);
exec(`yes | yarn elm bump`);
} | [
"async",
"function",
"prepareElmRelease",
"(",
"config",
",",
"context",
")",
"{",
"function",
"exec",
"(",
"command",
")",
"{",
"context",
".",
"logger",
".",
"log",
"(",
"`",
"${",
"command",
"}",
"`",
")",
";",
"execSync",
"(",
"command",
",",
"{",
... | A semantic release "prepare" plugin to update elm-package.json | [
"A",
"semantic",
"release",
"prepare",
"plugin",
"to",
"update",
"elm",
"-",
"package",
".",
"json"
] | 93a702e272bed758128b11ee14cb849de0ffa7a2 | https://github.com/cultureamp/elm-css-modules-loader/blob/93a702e272bed758128b11ee14cb849de0ffa7a2/ci/prepareElmRelease.js#L6-L14 | train |
hoodiehq/hoodie-store-client | lib/update.js | update | function update (state, prefix, objectsOrIds, change) {
if (typeof objectsOrIds !== 'object' && !change) {
return Promise.reject(
new Error('Must provide change')
)
}
return Array.isArray(objectsOrIds)
? updateMany(state, objectsOrIds, change, prefix)
: updateOne(state, objectsOrIds, change... | javascript | function update (state, prefix, objectsOrIds, change) {
if (typeof objectsOrIds !== 'object' && !change) {
return Promise.reject(
new Error('Must provide change')
)
}
return Array.isArray(objectsOrIds)
? updateMany(state, objectsOrIds, change, prefix)
: updateOne(state, objectsOrIds, change... | [
"function",
"update",
"(",
"state",
",",
"prefix",
",",
"objectsOrIds",
",",
"change",
")",
"{",
"if",
"(",
"typeof",
"objectsOrIds",
"!==",
"'object'",
"&&",
"!",
"change",
")",
"{",
"return",
"Promise",
".",
"reject",
"(",
"new",
"Error",
"(",
"'Must p... | updates existing object.
@param {String} prefix optional id prefix
@param {String|Object|Object[]} objectsOrIds id or object (or array of objects) with `._id` property
@param {Object|Function} [change] Changed properties or function
that changes existing object
@return {Pro... | [
"updates",
"existing",
"object",
"."
] | a0043e6b73a5ee90675fb02be78edfceef94a6b1 | https://github.com/hoodiehq/hoodie-store-client/blob/a0043e6b73a5ee90675fb02be78edfceef94a6b1/lib/update.js#L17-L27 | train |
mathigon/boost.js | src/colour.js | getColourAt | function getColourAt(gradient, p) {
p = clamp(p, 0, 0.9999); // FIXME
let r = Math.floor(p * (gradient.length - 1));
let q = p * (gradient.length - 1) - r;
return Colour.mix(gradient[r + 1], gradient[r], q);
} | javascript | function getColourAt(gradient, p) {
p = clamp(p, 0, 0.9999); // FIXME
let r = Math.floor(p * (gradient.length - 1));
let q = p * (gradient.length - 1) - r;
return Colour.mix(gradient[r + 1], gradient[r], q);
} | [
"function",
"getColourAt",
"(",
"gradient",
",",
"p",
")",
"{",
"p",
"=",
"clamp",
"(",
"p",
",",
"0",
",",
"0.9999",
")",
";",
"// FIXME",
"let",
"r",
"=",
"Math",
".",
"floor",
"(",
"p",
"*",
"(",
"gradient",
".",
"length",
"-",
"1",
")",
")"... | Gets the colour of a multi-step gradient at a given percentage p | [
"Gets",
"the",
"colour",
"of",
"a",
"multi",
"-",
"step",
"gradient",
"at",
"a",
"given",
"percentage",
"p"
] | ceffceacffe35de461d6e90f48e058f826d63bb2 | https://github.com/mathigon/boost.js/blob/ceffceacffe35de461d6e90f48e058f826d63bb2/src/colour.js#L34-L39 | train |
marcello3d/node-licensecheck | index.js | matchLicense | function matchLicense (licenseString) {
// Find all textual matches on license text.
var normalized = normalizeText(licenseString)
var matchingLicenses = []
var license
// Check matches of normalized license content against signatures.
for (var i = 0; i < licenses.length; i++) {
license = licenses[i]
... | javascript | function matchLicense (licenseString) {
// Find all textual matches on license text.
var normalized = normalizeText(licenseString)
var matchingLicenses = []
var license
// Check matches of normalized license content against signatures.
for (var i = 0; i < licenses.length; i++) {
license = licenses[i]
... | [
"function",
"matchLicense",
"(",
"licenseString",
")",
"{",
"// Find all textual matches on license text.",
"var",
"normalized",
"=",
"normalizeText",
"(",
"licenseString",
")",
"var",
"matchingLicenses",
"=",
"[",
"]",
"var",
"license",
"// Check matches of normalized lice... | Match a license body or license id against known set of licenses. | [
"Match",
"a",
"license",
"body",
"or",
"license",
"id",
"against",
"known",
"set",
"of",
"licenses",
"."
] | 406af818a1a50dbcc8c3a04f46e9d5ed03cf11f7 | https://github.com/marcello3d/node-licensecheck/blob/406af818a1a50dbcc8c3a04f46e9d5ed03cf11f7/index.js#L24-L62 | train |
marcello3d/node-licensecheck | index.js | getJsonLicense | function getJsonLicense (json) {
var license = 'nomatch'
if (typeof json === 'string') {
license = matchLicense(json) || 'nomatch'
} else {
if (json.url) {
license = { name: json.type, url: json.url }
} else {
license = matchLicense(json.type)
}
}
return license
} | javascript | function getJsonLicense (json) {
var license = 'nomatch'
if (typeof json === 'string') {
license = matchLicense(json) || 'nomatch'
} else {
if (json.url) {
license = { name: json.type, url: json.url }
} else {
license = matchLicense(json.type)
}
}
return license
} | [
"function",
"getJsonLicense",
"(",
"json",
")",
"{",
"var",
"license",
"=",
"'nomatch'",
"if",
"(",
"typeof",
"json",
"===",
"'string'",
")",
"{",
"license",
"=",
"matchLicense",
"(",
"json",
")",
"||",
"'nomatch'",
"}",
"else",
"{",
"if",
"(",
"json",
... | Convert package.json format to a known license. If a developer specifies just the name, we check it against SPDX, according to NPM guidelines. If they supply a URL, we just link to it, preserving name and exact link. | [
"Convert",
"package",
".",
"json",
"format",
"to",
"a",
"known",
"license",
".",
"If",
"a",
"developer",
"specifies",
"just",
"the",
"name",
"we",
"check",
"it",
"against",
"SPDX",
"according",
"to",
"NPM",
"guidelines",
".",
"If",
"they",
"supply",
"a",
... | 406af818a1a50dbcc8c3a04f46e9d5ed03cf11f7 | https://github.com/marcello3d/node-licensecheck/blob/406af818a1a50dbcc8c3a04f46e9d5ed03cf11f7/index.js#L98-L110 | train |
hoodiehq/hoodie-store-client | lib/off.js | off | function off (state, eventName, handler) {
state.emitter.removeListener(eventName, handler)
return state.api
} | javascript | function off (state, eventName, handler) {
state.emitter.removeListener(eventName, handler)
return state.api
} | [
"function",
"off",
"(",
"state",
",",
"eventName",
",",
"handler",
")",
"{",
"state",
".",
"emitter",
".",
"removeListener",
"(",
"eventName",
",",
"handler",
")",
"return",
"state",
".",
"api",
"}"
] | removes a listener for the specified event
It will unsubscribe at most, one instance of a listener for a particular event.
If any single listener has subcribed multiple times to the same event,
then `off` must be called multiple times.
Supported events:
- `add`
- `update`
- `remove`
- `change`
@param {String} even... | [
"removes",
"a",
"listener",
"for",
"the",
"specified",
"event"
] | a0043e6b73a5ee90675fb02be78edfceef94a6b1 | https://github.com/hoodiehq/hoodie-store-client/blob/a0043e6b73a5ee90675fb02be78edfceef94a6b1/lib/off.js#L20-L24 | train |
jantimon/svg-placeholder | lib/svg-generator.js | calculateScaledFontSize | function calculateScaledFontSize(width, height) {
return Math.round(Math.max(12, Math.min(Math.min(width, height) * 0.75, (0.75 * Math.max(width, height)) / 12)));
} | javascript | function calculateScaledFontSize(width, height) {
return Math.round(Math.max(12, Math.min(Math.min(width, height) * 0.75, (0.75 * Math.max(width, height)) / 12)));
} | [
"function",
"calculateScaledFontSize",
"(",
"width",
",",
"height",
")",
"{",
"return",
"Math",
".",
"round",
"(",
"Math",
".",
"max",
"(",
"12",
",",
"Math",
".",
"min",
"(",
"Math",
".",
"min",
"(",
"width",
",",
"height",
")",
"*",
"0.75",
",",
... | Calculate a font which works well for the given width and height
@param width {Number} the width of the image
@param height {Number} the height of the image
@returns {Number} fontSize | [
"Calculate",
"a",
"font",
"which",
"works",
"well",
"for",
"the",
"given",
"width",
"and",
"height"
] | c9b2b1429d20a4ade9bbb26fd42a48279e809d5a | https://github.com/jantimon/svg-placeholder/blob/c9b2b1429d20a4ade9bbb26fd42a48279e809d5a/lib/svg-generator.js#L9-L11 | train |
hoodiehq/hoodie-store-client | lib/update-or-add.js | updateOrAdd | function updateOrAdd (state, prefix, idOrObjectOrArray, newObject) {
return Array.isArray(idOrObjectOrArray)
? updateOrAddMany(state, idOrObjectOrArray, prefix)
: updateOrAddOne(state, idOrObjectOrArray, newObject, prefix)
} | javascript | function updateOrAdd (state, prefix, idOrObjectOrArray, newObject) {
return Array.isArray(idOrObjectOrArray)
? updateOrAddMany(state, idOrObjectOrArray, prefix)
: updateOrAddOne(state, idOrObjectOrArray, newObject, prefix)
} | [
"function",
"updateOrAdd",
"(",
"state",
",",
"prefix",
",",
"idOrObjectOrArray",
",",
"newObject",
")",
"{",
"return",
"Array",
".",
"isArray",
"(",
"idOrObjectOrArray",
")",
"?",
"updateOrAddMany",
"(",
"state",
",",
"idOrObjectOrArray",
",",
"prefix",
")",
... | updates existing object, or creates otherwise.
@param {String} prefix optional id prefix
@param {String|Object|Object[]} - id or object with `._id` property, or
array of properties
@param {Object} [properties] If id passed, properties for new
or existing object
@return {Promise} | [
"updates",
"existing",
"object",
"or",
"creates",
"otherwise",
"."
] | a0043e6b73a5ee90675fb02be78edfceef94a6b1 | https://github.com/hoodiehq/hoodie-store-client/blob/a0043e6b73a5ee90675fb02be78edfceef94a6b1/lib/update-or-add.js#L16-L20 | train |
4ib3r/StompBrokerJS | lib/stomp-utils.js | sendFrame | function sendFrame(socket, _frame) {
var frame = _frame;
if (!_frame.hasOwnProperty('toString')) {
frame = new Frame({
'command': _frame.command,
'headers': _frame.headers,
'body': _frame.body
});
}
socket.send(frame.toStringOrBuffer());
return true;
} | javascript | function sendFrame(socket, _frame) {
var frame = _frame;
if (!_frame.hasOwnProperty('toString')) {
frame = new Frame({
'command': _frame.command,
'headers': _frame.headers,
'body': _frame.body
});
}
socket.send(frame.toStringOrBuffer());
return true;
} | [
"function",
"sendFrame",
"(",
"socket",
",",
"_frame",
")",
"{",
"var",
"frame",
"=",
"_frame",
";",
"if",
"(",
"!",
"_frame",
".",
"hasOwnProperty",
"(",
"'toString'",
")",
")",
"{",
"frame",
"=",
"new",
"Frame",
"(",
"{",
"'command'",
":",
"_frame",
... | Send frame with socket | [
"Send",
"frame",
"with",
"socket"
] | 8d8de4b5232c6fe456ee99237e9f731ce3846ed4 | https://github.com/4ib3r/StompBrokerJS/blob/8d8de4b5232c6fe456ee99237e9f731ce3846ed4/lib/stomp-utils.js#L9-L22 | train |
4ib3r/StompBrokerJS | lib/stomp-utils.js | parseCommand | function parseCommand(data) {
var command,
str = data.toString('utf8', 0, data.length);
command = str.split('\n');
return command[0];
} | javascript | function parseCommand(data) {
var command,
str = data.toString('utf8', 0, data.length);
command = str.split('\n');
return command[0];
} | [
"function",
"parseCommand",
"(",
"data",
")",
"{",
"var",
"command",
",",
"str",
"=",
"data",
".",
"toString",
"(",
"'utf8'",
",",
"0",
",",
"data",
".",
"length",
")",
";",
"command",
"=",
"str",
".",
"split",
"(",
"'\\n'",
")",
";",
"return",
"co... | Parse single command | [
"Parse",
"single",
"command"
] | 8d8de4b5232c6fe456ee99237e9f731ce3846ed4 | https://github.com/4ib3r/StompBrokerJS/blob/8d8de4b5232c6fe456ee99237e9f731ce3846ed4/lib/stomp-utils.js#L25-L31 | train |
hoodiehq/hoodie-store-client | lib/update-all.js | updateAll | function updateAll (state, prefix, changedProperties) {
var type = typeof changedProperties
var docs
if (type !== 'object' && type !== 'function') {
return Promise.reject(new Error('Must provide object or function'))
}
var options = {
include_docs: true
}
if (prefix) {
options.startkey = pr... | javascript | function updateAll (state, prefix, changedProperties) {
var type = typeof changedProperties
var docs
if (type !== 'object' && type !== 'function') {
return Promise.reject(new Error('Must provide object or function'))
}
var options = {
include_docs: true
}
if (prefix) {
options.startkey = pr... | [
"function",
"updateAll",
"(",
"state",
",",
"prefix",
",",
"changedProperties",
")",
"{",
"var",
"type",
"=",
"typeof",
"changedProperties",
"var",
"docs",
"if",
"(",
"type",
"!==",
"'object'",
"&&",
"type",
"!==",
"'function'",
")",
"{",
"return",
"Promise"... | updates all existing docs
@param {String} prefix optional id prefix
@param {Object|Function} change changed properties or function that
alters passed doc
@return {Promise} | [
"updates",
"all",
"existing",
"docs"
] | a0043e6b73a5ee90675fb02be78edfceef94a6b1 | https://github.com/hoodiehq/hoodie-store-client/blob/a0043e6b73a5ee90675fb02be78edfceef94a6b1/lib/update-all.js#L19-L59 | train |
hoodiehq/hoodie-store-client | lib/add.js | add | function add (state, prefix, properties) {
return Array.isArray(properties)
? addMany(state, properties, prefix)
: addOne(state, properties, prefix)
} | javascript | function add (state, prefix, properties) {
return Array.isArray(properties)
? addMany(state, properties, prefix)
: addOne(state, properties, prefix)
} | [
"function",
"add",
"(",
"state",
",",
"prefix",
",",
"properties",
")",
"{",
"return",
"Array",
".",
"isArray",
"(",
"properties",
")",
"?",
"addMany",
"(",
"state",
",",
"properties",
",",
"prefix",
")",
":",
"addOne",
"(",
"state",
",",
"properties",
... | adds one or multiple objects to local database
@param {String} prefix optional id prefix
@param {Object|Object[]} properties Properties of one or
multiple objects
@return {Promise} | [
"adds",
"one",
"or",
"multiple",
"objects",
"to",
"local",
"database"
] | a0043e6b73a5ee90675fb02be78edfceef94a6b1 | https://github.com/hoodiehq/hoodie-store-client/blob/a0043e6b73a5ee90675fb02be78edfceef94a6b1/lib/add.js#L14-L18 | train |
hoodiehq/hoodie-store-client | lib/remove-all.js | removeAll | function removeAll (state, prefix, filter) {
var docs
var options = {
include_docs: true
}
if (prefix) {
options.startkey = prefix
options.endkey = prefix + '\uffff'
}
return state.db.allDocs(options)
.then(function (res) {
docs = res.rows
.filter(isntDesignDoc)
.map(functi... | javascript | function removeAll (state, prefix, filter) {
var docs
var options = {
include_docs: true
}
if (prefix) {
options.startkey = prefix
options.endkey = prefix + '\uffff'
}
return state.db.allDocs(options)
.then(function (res) {
docs = res.rows
.filter(isntDesignDoc)
.map(functi... | [
"function",
"removeAll",
"(",
"state",
",",
"prefix",
",",
"filter",
")",
"{",
"var",
"docs",
"var",
"options",
"=",
"{",
"include_docs",
":",
"true",
"}",
"if",
"(",
"prefix",
")",
"{",
"options",
".",
"startkey",
"=",
"prefix",
"options",
".",
"endke... | removes all existing docs
@param {String} prefix optional id prefix
@param {Function} [filter] Function returning `true` for any doc
to be removed.
@return {Promise} | [
"removes",
"all",
"existing",
"docs"
] | a0043e6b73a5ee90675fb02be78edfceef94a6b1 | https://github.com/hoodiehq/hoodie-store-client/blob/a0043e6b73a5ee90675fb02be78edfceef94a6b1/lib/remove-all.js#L15-L47 | train |
yahoo/mendel | packages/mendel-manifest-extract-bundles/manifest-extract.js | visitBundle | function visitBundle(file) {
if (visitedIndexes[file]) {
return;
}
visitedIndexes[file] = true;
// walk deps
var bundle = manifest.bundles[manifest.indexes[file]];
bundle.data.forEach(function(module) {
Object.keys(module.deps).forEach(function(key... | javascript | function visitBundle(file) {
if (visitedIndexes[file]) {
return;
}
visitedIndexes[file] = true;
// walk deps
var bundle = manifest.bundles[manifest.indexes[file]];
bundle.data.forEach(function(module) {
Object.keys(module.deps).forEach(function(key... | [
"function",
"visitBundle",
"(",
"file",
")",
"{",
"if",
"(",
"visitedIndexes",
"[",
"file",
"]",
")",
"{",
"return",
";",
"}",
"visitedIndexes",
"[",
"file",
"]",
"=",
"true",
";",
"// walk deps",
"var",
"bundle",
"=",
"manifest",
".",
"bundles",
"[",
... | recursive function to visit bundle and it's deps | [
"recursive",
"function",
"to",
"visit",
"bundle",
"and",
"it",
"s",
"deps"
] | 4c3d296248fb2a96f0d079eb70702298a44be9bd | https://github.com/yahoo/mendel/blob/4c3d296248fb2a96f0d079eb70702298a44be9bd/packages/mendel-manifest-extract-bundles/manifest-extract.js#L122-L137 | train |
mongodb-js/dataset-generator | lib/schema/array.js | ArrayField | function ArrayField (array, name, parent) {
if (!(this instanceof ArrayField)) return new ArrayField(array, name, parent);
debug('array <%s> being built', name);
Entry.call(this, array, name, parent);
this._context = parent._context;
this._this = parent._this;
this._currVal = {};
var data = this._content... | javascript | function ArrayField (array, name, parent) {
if (!(this instanceof ArrayField)) return new ArrayField(array, name, parent);
debug('array <%s> being built', name);
Entry.call(this, array, name, parent);
this._context = parent._context;
this._this = parent._this;
this._currVal = {};
var data = this._content... | [
"function",
"ArrayField",
"(",
"array",
",",
"name",
",",
"parent",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"ArrayField",
")",
")",
"return",
"new",
"ArrayField",
"(",
"array",
",",
"name",
",",
"parent",
")",
";",
"debug",
"(",
"'array <%... | Internal representation of Arrays in template schema
@class
@augments {Entry}
@memberOf module:schema
@param {!Array} array Raw user-supplied array
@param {string} name Key corresponding to the field
@param {!Entry} parent Immediate enclosing Entry | [
"Internal",
"representation",
"of",
"Arrays",
"in",
"template",
"schema"
] | 0f56410970a8dc03433477966dafa16a5cbd9cda | https://github.com/mongodb-js/dataset-generator/blob/0f56410970a8dc03433477966dafa16a5cbd9cda/lib/schema/array.js#L20-L64 | train |
hoodiehq/hoodie-store-client | lib/find-or-add.js | findOrAdd | function findOrAdd (state, prefix, idOrObjectOrArray, properties) {
return Array.isArray(idOrObjectOrArray)
? findOrAddMany(state, idOrObjectOrArray, prefix)
: findOrAddOne(state, idOrObjectOrArray, properties, prefix)
} | javascript | function findOrAdd (state, prefix, idOrObjectOrArray, properties) {
return Array.isArray(idOrObjectOrArray)
? findOrAddMany(state, idOrObjectOrArray, prefix)
: findOrAddOne(state, idOrObjectOrArray, properties, prefix)
} | [
"function",
"findOrAdd",
"(",
"state",
",",
"prefix",
",",
"idOrObjectOrArray",
",",
"properties",
")",
"{",
"return",
"Array",
".",
"isArray",
"(",
"idOrObjectOrArray",
")",
"?",
"findOrAddMany",
"(",
"state",
",",
"idOrObjectOrArray",
",",
"prefix",
")",
":"... | tries to find object in local database, otherwise creates new one
with passed properties.
@param {String} prefix optional id prefix
@param {String|Object|Object[]} idOrObject id or object with `._id` property
@param {Object} [properties] Optional properties if id passed
as fi... | [
"tries",
"to",
"find",
"object",
"in",
"local",
"database",
"otherwise",
"creates",
"new",
"one",
"with",
"passed",
"properties",
"."
] | a0043e6b73a5ee90675fb02be78edfceef94a6b1 | https://github.com/hoodiehq/hoodie-store-client/blob/a0043e6b73a5ee90675fb02be78edfceef94a6b1/lib/find-or-add.js#L16-L20 | train |
hoodiehq/hoodie-store-client | lib/pull.js | pull | function pull (state, docsOrIds) {
var pulledObjects = []
var errors = state.db.constructor.Errors
return Promise.resolve(state.remote)
.then(function (remote) {
return new Promise(function (resolve, reject) {
if (Array.isArray(docsOrIds)) {
docsOrIds = docsOrIds.map(toId)
} else {
... | javascript | function pull (state, docsOrIds) {
var pulledObjects = []
var errors = state.db.constructor.Errors
return Promise.resolve(state.remote)
.then(function (remote) {
return new Promise(function (resolve, reject) {
if (Array.isArray(docsOrIds)) {
docsOrIds = docsOrIds.map(toId)
} else {
... | [
"function",
"pull",
"(",
"state",
",",
"docsOrIds",
")",
"{",
"var",
"pulledObjects",
"=",
"[",
"]",
"var",
"errors",
"=",
"state",
".",
"db",
".",
"constructor",
".",
"Errors",
"return",
"Promise",
".",
"resolve",
"(",
"state",
".",
"remote",
")",
"."... | pulls one or multiple objects from remote to local database
@param {StringOrObject} docsOrIds object or ID of object or array of objects/ids (all optional)
@return {Promise} | [
"pulls",
"one",
"or",
"multiple",
"objects",
"from",
"remote",
"to",
"local",
"database"
] | a0043e6b73a5ee90675fb02be78edfceef94a6b1 | https://github.com/hoodiehq/hoodie-store-client/blob/a0043e6b73a5ee90675fb02be78edfceef94a6b1/lib/pull.js#L13-L53 | train |
mongodb-js/dataset-generator | lib/schema/index.js | Schema | function Schema (sc, size) {
if (!(this instanceof Schema)) return new Schema(sc);
debug('======BUILDING PHASE======');
helpers.validate(sc);
debug('schema size=%d being built', size);
this._schema = this;
this._document = helpers.build(sc, '$root', this);
this._state = { // serve as global state
inde... | javascript | function Schema (sc, size) {
if (!(this instanceof Schema)) return new Schema(sc);
debug('======BUILDING PHASE======');
helpers.validate(sc);
debug('schema size=%d being built', size);
this._schema = this;
this._document = helpers.build(sc, '$root', this);
this._state = { // serve as global state
inde... | [
"function",
"Schema",
"(",
"sc",
",",
"size",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Schema",
")",
")",
"return",
"new",
"Schema",
"(",
"sc",
")",
";",
"debug",
"(",
"'======BUILDING PHASE======'",
")",
";",
"helpers",
".",
"validate",
"... | Internal representation of a user-defined schema
@class
@memberOf module:schema
@param {object} sc
@param {number} size | [
"Internal",
"representation",
"of",
"a",
"user",
"-",
"defined",
"schema"
] | 0f56410970a8dc03433477966dafa16a5cbd9cda | https://github.com/mongodb-js/dataset-generator/blob/0f56410970a8dc03433477966dafa16a5cbd9cda/lib/schema/index.js#L17-L30 | train |
jrieken/gulp-tsb | gulpfile.js | reload | function reload(moduleName) {
var id = require.resolve(moduleName);
var mod = require.cache[id];
if (mod) {
var base = path.dirname(mod.filename);
// expunge each module cache entry beneath this folder
var stack = [mod];
while (stack.length) {
var mod = st... | javascript | function reload(moduleName) {
var id = require.resolve(moduleName);
var mod = require.cache[id];
if (mod) {
var base = path.dirname(mod.filename);
// expunge each module cache entry beneath this folder
var stack = [mod];
while (stack.length) {
var mod = st... | [
"function",
"reload",
"(",
"moduleName",
")",
"{",
"var",
"id",
"=",
"require",
".",
"resolve",
"(",
"moduleName",
")",
";",
"var",
"mod",
"=",
"require",
".",
"cache",
"[",
"id",
"]",
";",
"if",
"(",
"mod",
")",
"{",
"var",
"base",
"=",
"path",
... | reload a node module and any children beneath the same folder | [
"reload",
"a",
"node",
"module",
"and",
"any",
"children",
"beneath",
"the",
"same",
"folder"
] | 35f134ab384f5575628b152faa910389581bb4d8 | https://github.com/jrieken/gulp-tsb/blob/35f134ab384f5575628b152faa910389581bb4d8/gulpfile.js#L70-L101 | train |
jmreidy/grunt-mocha-webdriver | tasks/grunt-mocha-wd.js | extractConnectionInfo | function extractConnectionInfo(opts) {
var params = {};
var defaultServer = opts.secureCommands ?
{ hostname: '127.0.0.1', port: 4445 } :
{ hostname: 'ondemand.saucelabs.com', port: 80 };
params.hostname = opts.hostname || defaultServer.hostname;
params.p... | javascript | function extractConnectionInfo(opts) {
var params = {};
var defaultServer = opts.secureCommands ?
{ hostname: '127.0.0.1', port: 4445 } :
{ hostname: 'ondemand.saucelabs.com', port: 80 };
params.hostname = opts.hostname || defaultServer.hostname;
params.p... | [
"function",
"extractConnectionInfo",
"(",
"opts",
")",
"{",
"var",
"params",
"=",
"{",
"}",
";",
"var",
"defaultServer",
"=",
"opts",
".",
"secureCommands",
"?",
"{",
"hostname",
":",
"'127.0.0.1'",
",",
"port",
":",
"4445",
"}",
":",
"{",
"hostname",
":... | Extracts wd connection params from grunt options
Utility function that returns named params
that can be used by wd.remote or wd.promiseChainRemote | [
"Extracts",
"wd",
"connection",
"params",
"from",
"grunt",
"options"
] | f904539e7828a25e818c444939979fdda9849ef2 | https://github.com/jmreidy/grunt-mocha-webdriver/blob/f904539e7828a25e818c444939979fdda9849ef2/tasks/grunt-mocha-wd.js#L160-L177 | train |
jmreidy/grunt-mocha-webdriver | tasks/grunt-mocha-wd.js | initBrowser | function initBrowser(browserOpts, opts, mode, fileGroup, cb) {
var funcName = opts.usePromises ? 'promiseChainRemote': 'remote';
var browser = wd[funcName](extractConnectionInfo(opts));
browser.browserTitle = browserOpts.browserTitle;
browser.mode = mode;
browser.mode = mode;
if (opts.testName)... | javascript | function initBrowser(browserOpts, opts, mode, fileGroup, cb) {
var funcName = opts.usePromises ? 'promiseChainRemote': 'remote';
var browser = wd[funcName](extractConnectionInfo(opts));
browser.browserTitle = browserOpts.browserTitle;
browser.mode = mode;
browser.mode = mode;
if (opts.testName)... | [
"function",
"initBrowser",
"(",
"browserOpts",
",",
"opts",
",",
"mode",
",",
"fileGroup",
",",
"cb",
")",
"{",
"var",
"funcName",
"=",
"opts",
".",
"usePromises",
"?",
"'promiseChainRemote'",
":",
"'remote'",
";",
"var",
"browser",
"=",
"wd",
"[",
"funcNa... | Init a browser | [
"Init",
"a",
"browser"
] | f904539e7828a25e818c444939979fdda9849ef2 | https://github.com/jmreidy/grunt-mocha-webdriver/blob/f904539e7828a25e818c444939979fdda9849ef2/tasks/grunt-mocha-wd.js#L182-L212 | train |
oncojs/oncogrid | src/Histogram.js | getLargestCount | function getLargestCount(domain, type) {
var retVal = 1;
for (var i = 0; i < domain.length; i++) {
retVal = Math.max(retVal, type === 'cnv' ? domain[i].cnv : domain[i].count);
}
return retVal;
} | javascript | function getLargestCount(domain, type) {
var retVal = 1;
for (var i = 0; i < domain.length; i++) {
retVal = Math.max(retVal, type === 'cnv' ? domain[i].cnv : domain[i].count);
}
return retVal;
} | [
"function",
"getLargestCount",
"(",
"domain",
",",
"type",
")",
"{",
"var",
"retVal",
"=",
"1",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"domain",
".",
"length",
";",
"i",
"++",
")",
"{",
"retVal",
"=",
"Math",
".",
"max",
"(",
"re... | Want to find the maximum value so we can label the axis and scale the bars accordingly.
No need to make this function public.
@returns {number} | [
"Want",
"to",
"find",
"the",
"maximum",
"value",
"so",
"we",
"can",
"label",
"the",
"axis",
"and",
"scale",
"the",
"bars",
"accordingly",
".",
"No",
"need",
"to",
"make",
"this",
"function",
"public",
"."
] | 5dfff05be9143e1f3ec1911997ae2cde8df998ac | https://github.com/oncojs/oncogrid/blob/5dfff05be9143e1f3ec1911997ae2cde8df998ac/src/Histogram.js#L26-L34 | train |
autonomoussoftware/metronome-contracts-js | lib/map-values/index.js | mapValues | function mapValues (obj, fn) {
return Object.keys(obj).reduce(function (res, key) {
res[key] = fn(obj[key], key, obj)
return res
}, {})
} | javascript | function mapValues (obj, fn) {
return Object.keys(obj).reduce(function (res, key) {
res[key] = fn(obj[key], key, obj)
return res
}, {})
} | [
"function",
"mapValues",
"(",
"obj",
",",
"fn",
")",
"{",
"return",
"Object",
".",
"keys",
"(",
"obj",
")",
".",
"reduce",
"(",
"function",
"(",
"res",
",",
"key",
")",
"{",
"res",
"[",
"key",
"]",
"=",
"fn",
"(",
"obj",
"[",
"key",
"]",
",",
... | Create a new object with the same keys and values mapped using provided fn.
This is a simplified version of lodash.mapValues.
@param {Object} obj The source object.
@param {Function} fn The function to map the object's values.
@returns {Object} The mapped object. | [
"Create",
"a",
"new",
"object",
"with",
"the",
"same",
"keys",
"and",
"values",
"mapped",
"using",
"provided",
"fn",
"."
] | 84330c74f847161c24c9e3d5e60642950f68bfaa | https://github.com/autonomoussoftware/metronome-contracts-js/blob/84330c74f847161c24c9e3d5e60642950f68bfaa/lib/map-values/index.js#L12-L17 | train |
kwiksand/yobit | index.js | formatParameters | function formatParameters(params)
{
var sortedKeys = [],
formattedParams = ''
// sort the properties of the parameters
sortedKeys = _.keys(params).sort()
// create a string of key value pairs separated by '&' with '=' assignement
for (i = 0; i < sortedKeys.length; i++)
{
if (i ... | javascript | function formatParameters(params)
{
var sortedKeys = [],
formattedParams = ''
// sort the properties of the parameters
sortedKeys = _.keys(params).sort()
// create a string of key value pairs separated by '&' with '=' assignement
for (i = 0; i < sortedKeys.length; i++)
{
if (i ... | [
"function",
"formatParameters",
"(",
"params",
")",
"{",
"var",
"sortedKeys",
"=",
"[",
"]",
",",
"formattedParams",
"=",
"''",
"// sort the properties of the parameters",
"sortedKeys",
"=",
"_",
".",
"keys",
"(",
"params",
")",
".",
"sort",
"(",
")",
"// crea... | This method returns the parameters as key=value pairs separated by & sorted by the key
@param {Object} params The object to encode
@return {String} formatted parameters | [
"This",
"method",
"returns",
"the",
"parameters",
"as",
"key",
"=",
"value",
"pairs",
"separated",
"by",
"&",
"sorted",
"by",
"the",
"key"
] | e9fc16c9d7c80c632a220fbebf755914cbfdffde | https://github.com/kwiksand/yobit/blob/e9fc16c9d7c80c632a220fbebf755914cbfdffde/index.js#L106-L124 | train |
Losant/losant-mqtt-js | lib/device.js | Device | function Device(options) {
EventEmitter.call(this);
// Check required fields.
if(!options || !options.id) {
throw new Error('ID is required.');
}
this.options = options;
this.id = options.id;
// Default the options and remove whitespace.
options.id = (options.id || '').replace(/ /g, '');
optio... | javascript | function Device(options) {
EventEmitter.call(this);
// Check required fields.
if(!options || !options.id) {
throw new Error('ID is required.');
}
this.options = options;
this.id = options.id;
// Default the options and remove whitespace.
options.id = (options.id || '').replace(/ /g, '');
optio... | [
"function",
"Device",
"(",
"options",
")",
"{",
"EventEmitter",
".",
"call",
"(",
"this",
")",
";",
"// Check required fields.",
"if",
"(",
"!",
"options",
"||",
"!",
"options",
".",
"id",
")",
"{",
"throw",
"new",
"Error",
"(",
"'ID is required.'",
")",
... | Device constructor. | [
"Device",
"constructor",
"."
] | 4617e1545a98b1ecb9859bca99e95eb04a1ec196 | https://github.com/Losant/losant-mqtt-js/blob/4617e1545a98b1ecb9859bca99e95eb04a1ec196/lib/device.js#L35-L88 | train |
treasonx/grunt-markdown | tasks/markdown.js | setTemplateContext | function setTemplateContext(contextArray) {
var newTemplateContext = {};
contextArray.forEach(function(item) {
var cleanString = item.slice(options.contextBinderMark.length, -options.contextBinderMark.length),
separatedPairs = cleanString.split(':');
newTemplateContext[separatedP... | javascript | function setTemplateContext(contextArray) {
var newTemplateContext = {};
contextArray.forEach(function(item) {
var cleanString = item.slice(options.contextBinderMark.length, -options.contextBinderMark.length),
separatedPairs = cleanString.split(':');
newTemplateContext[separatedP... | [
"function",
"setTemplateContext",
"(",
"contextArray",
")",
"{",
"var",
"newTemplateContext",
"=",
"{",
"}",
";",
"contextArray",
".",
"forEach",
"(",
"function",
"(",
"item",
")",
"{",
"var",
"cleanString",
"=",
"item",
".",
"slice",
"(",
"options",
".",
... | Apply new template context option to Object | [
"Apply",
"new",
"template",
"context",
"option",
"to",
"Object"
] | ef4a8fd7a4f0335e27e1abccaf61f44b56b253d9 | https://github.com/treasonx/grunt-markdown/blob/ef4a8fd7a4f0335e27e1abccaf61f44b56b253d9/tasks/markdown.js#L62-L72 | train |
treasonx/grunt-markdown | tasks/markdown.js | getTemplateContext | function getTemplateContext(file) {
var sourceFile = grunt.file.read(file),
hasTemplateContext = checkTemplateContext(sourceFile),
pattern = new RegExp('(' + options.contextBinderMark + ')(.*?)(' + options.contextBinderMark + ')', 'g'),
contextArray;
if (!hasTemplateContext) {
... | javascript | function getTemplateContext(file) {
var sourceFile = grunt.file.read(file),
hasTemplateContext = checkTemplateContext(sourceFile),
pattern = new RegExp('(' + options.contextBinderMark + ')(.*?)(' + options.contextBinderMark + ')', 'g'),
contextArray;
if (!hasTemplateContext) {
... | [
"function",
"getTemplateContext",
"(",
"file",
")",
"{",
"var",
"sourceFile",
"=",
"grunt",
".",
"file",
".",
"read",
"(",
"file",
")",
",",
"hasTemplateContext",
"=",
"checkTemplateContext",
"(",
"sourceFile",
")",
",",
"pattern",
"=",
"new",
"RegExp",
"(",... | Collect context items | [
"Collect",
"context",
"items"
] | ef4a8fd7a4f0335e27e1abccaf61f44b56b253d9 | https://github.com/treasonx/grunt-markdown/blob/ef4a8fd7a4f0335e27e1abccaf61f44b56b253d9/tasks/markdown.js#L75-L87 | train |
treasonx/grunt-markdown | tasks/markdown.js | getWorkingPath | function getWorkingPath(file) {
var completePath = JSON.stringify(file).slice(2,-2).split('/'),
lastPathElement = completePath.pop(),
fileDirectory = completePath.splice(lastPathElement).join('/');
return fileDirectory;
} | javascript | function getWorkingPath(file) {
var completePath = JSON.stringify(file).slice(2,-2).split('/'),
lastPathElement = completePath.pop(),
fileDirectory = completePath.splice(lastPathElement).join('/');
return fileDirectory;
} | [
"function",
"getWorkingPath",
"(",
"file",
")",
"{",
"var",
"completePath",
"=",
"JSON",
".",
"stringify",
"(",
"file",
")",
".",
"slice",
"(",
"2",
",",
"-",
"2",
")",
".",
"split",
"(",
"'/'",
")",
",",
"lastPathElement",
"=",
"completePath",
".",
... | Get working path to automaticaly searching for default template. | [
"Get",
"working",
"path",
"to",
"automaticaly",
"searching",
"for",
"default",
"template",
"."
] | ef4a8fd7a4f0335e27e1abccaf61f44b56b253d9 | https://github.com/treasonx/grunt-markdown/blob/ef4a8fd7a4f0335e27e1abccaf61f44b56b253d9/tasks/markdown.js#L89-L96 | train |
treasonx/grunt-markdown | tasks/markdown.js | getTemplate | function getTemplate(workingPath) {
var templateFile = grunt.file.expand({}, workingPath + '/*.' + options.autoTemplateFormat);
return templateFile[0];
} | javascript | function getTemplate(workingPath) {
var templateFile = grunt.file.expand({}, workingPath + '/*.' + options.autoTemplateFormat);
return templateFile[0];
} | [
"function",
"getTemplate",
"(",
"workingPath",
")",
"{",
"var",
"templateFile",
"=",
"grunt",
".",
"file",
".",
"expand",
"(",
"{",
"}",
",",
"workingPath",
"+",
"'/*.'",
"+",
"options",
".",
"autoTemplateFormat",
")",
";",
"return",
"templateFile",
"[",
"... | Automaticaly find temnplate in working directory. | [
"Automaticaly",
"find",
"temnplate",
"in",
"working",
"directory",
"."
] | ef4a8fd7a4f0335e27e1abccaf61f44b56b253d9 | https://github.com/treasonx/grunt-markdown/blob/ef4a8fd7a4f0335e27e1abccaf61f44b56b253d9/tasks/markdown.js#L99-L104 | train |
yuki-torii/yuki-createjs | lib/easeljs-0.8.2.combined.js | DisplayProps | function DisplayProps(visible, alpha, shadow, compositeOperation, matrix) {
this.setValues(visible, alpha, shadow, compositeOperation, matrix);
// public properties:
// assigned in the setValues method.
/**
* Property representing the alpha that will be applied to a display object.
* @property alpha
* ... | javascript | function DisplayProps(visible, alpha, shadow, compositeOperation, matrix) {
this.setValues(visible, alpha, shadow, compositeOperation, matrix);
// public properties:
// assigned in the setValues method.
/**
* Property representing the alpha that will be applied to a display object.
* @property alpha
* ... | [
"function",
"DisplayProps",
"(",
"visible",
",",
"alpha",
",",
"shadow",
",",
"compositeOperation",
",",
"matrix",
")",
"{",
"this",
".",
"setValues",
"(",
"visible",
",",
"alpha",
",",
"shadow",
",",
"compositeOperation",
",",
"matrix",
")",
";",
"// public... | Used for calculating and encapsulating display related properties.
@class DisplayProps
@param {Number} [visible=true] Visible value.
@param {Number} [alpha=1] Alpha value.
@param {Number} [shadow=null] A Shadow instance or null.
@param {Number} [compositeOperation=null] A compositeOperation value or null.
@param {Numbe... | [
"Used",
"for",
"calculating",
"and",
"encapsulating",
"display",
"related",
"properties",
"."
] | 8b3b684782516cc63cd3b337742d90fe85285a90 | https://github.com/yuki-torii/yuki-createjs/blob/8b3b684782516cc63cd3b337742d90fe85285a90/lib/easeljs-0.8.2.combined.js#L2142-L2178 | train |
yuki-torii/yuki-createjs | lib/easeljs-0.8.2.combined.js | Bitmap | function Bitmap(imageOrUri) {
this.DisplayObject_constructor();
// public properties:
/**
* The image to render. This can be an Image, a Canvas, or a Video. Not all browsers (especially
* mobile browsers) support drawing video to a canvas.
* @property image
* @type HTMLImageElement | HTMLCanvasElemen... | javascript | function Bitmap(imageOrUri) {
this.DisplayObject_constructor();
// public properties:
/**
* The image to render. This can be an Image, a Canvas, or a Video. Not all browsers (especially
* mobile browsers) support drawing video to a canvas.
* @property image
* @type HTMLImageElement | HTMLCanvasElemen... | [
"function",
"Bitmap",
"(",
"imageOrUri",
")",
"{",
"this",
".",
"DisplayObject_constructor",
"(",
")",
";",
"// public properties:",
"/**\n\t\t * The image to render. This can be an Image, a Canvas, or a Video. Not all browsers (especially\n\t\t * mobile browsers) support drawing video to ... | A Bitmap represents an Image, Canvas, or Video in the display list. A Bitmap can be instantiated using an existing
HTML element, or a string.
<h4>Example</h4>
var bitmap = new createjs.Bitmap("imagePath.jpg");
<strong>Notes:</strong>
<ol>
<li>When a string path or image tag that is not yet loaded is used, the stage ... | [
"A",
"Bitmap",
"represents",
"an",
"Image",
"Canvas",
"or",
"Video",
"in",
"the",
"display",
"list",
".",
"A",
"Bitmap",
"can",
"be",
"instantiated",
"using",
"an",
"existing",
"HTML",
"element",
"or",
"a",
"string",
"."
] | 8b3b684782516cc63cd3b337742d90fe85285a90 | https://github.com/yuki-torii/yuki-createjs/blob/8b3b684782516cc63cd3b337742d90fe85285a90/lib/easeljs-0.8.2.combined.js#L8738-L8764 | train |
charlieroberts/gibber.audio.lib | scripts/gibber/audio.js | function( target ) {
$.extend( target, Audio.Busses )
$.extend( target, Audio.Oscillators )
$.extend( target, Audio.Synths )
$.extend( target, Audio.Percussion )
$.extend( target, Audio.Envelopes )
$.extend( target, Audio.FX )
$.extend( target, Audio.Seqs )
$.extend( target, A... | javascript | function( target ) {
$.extend( target, Audio.Busses )
$.extend( target, Audio.Oscillators )
$.extend( target, Audio.Synths )
$.extend( target, Audio.Percussion )
$.extend( target, Audio.Envelopes )
$.extend( target, Audio.FX )
$.extend( target, Audio.Seqs )
$.extend( target, A... | [
"function",
"(",
"target",
")",
"{",
"$",
".",
"extend",
"(",
"target",
",",
"Audio",
".",
"Busses",
")",
"$",
".",
"extend",
"(",
"target",
",",
"Audio",
".",
"Oscillators",
")",
"$",
".",
"extend",
"(",
"target",
",",
"Audio",
".",
"Synths",
")",... | only run clear function if initialized can't name export as Gibberish has the same nameAudio | [
"only",
"run",
"clear",
"function",
"if",
"initialized",
"can",
"t",
"name",
"export",
"as",
"Gibberish",
"has",
"the",
"same",
"nameAudio"
] | 3deab46d2b5b7912a1772ceaca160991676f6fc4 | https://github.com/charlieroberts/gibber.audio.lib/blob/3deab46d2b5b7912a1772ceaca160991676f6fc4/scripts/gibber/audio.js#L13-L68 | train | |
charlieroberts/gibber.audio.lib | scripts/gibber/audio.js | function(key, initValue, obj) {
var isTimeProp = Audio.Clock.timeProperties.indexOf( key ) > -1,
prop = obj.properties[ key ] = {
value: isTimeProp ? Audio.Clock.time( initValue ) : initValue,
binops: [],
parent : obj,
name : key,
},
mappingName = key... | javascript | function(key, initValue, obj) {
var isTimeProp = Audio.Clock.timeProperties.indexOf( key ) > -1,
prop = obj.properties[ key ] = {
value: isTimeProp ? Audio.Clock.time( initValue ) : initValue,
binops: [],
parent : obj,
name : key,
},
mappingName = key... | [
"function",
"(",
"key",
",",
"initValue",
",",
"obj",
")",
"{",
"var",
"isTimeProp",
"=",
"Audio",
".",
"Clock",
".",
"timeProperties",
".",
"indexOf",
"(",
"key",
")",
">",
"-",
"1",
",",
"prop",
"=",
"obj",
".",
"properties",
"[",
"key",
"]",
"="... | override for Gibber.Audio.Core method | [
"override",
"for",
"Gibber",
".",
"Audio",
".",
"Core",
"method"
] | 3deab46d2b5b7912a1772ceaca160991676f6fc4 | https://github.com/charlieroberts/gibber.audio.lib/blob/3deab46d2b5b7912a1772ceaca160991676f6fc4/scripts/gibber/audio.js#L150-L188 | train | |
charlieroberts/gibber.audio.lib | scripts/gibber/audio.js | function(ugen) {
ugen.mod = ugen.polyMod;
ugen.removeMod = ugen.removePolyMod;
for( var key in ugen.polyProperties ) {
(function( _key ) {
var value = ugen.polyProperties[ _key ],
isTimeProp = Audio.Clock.timeProperties.indexOf( _key ) > -1
Object.defineProperty(ugen,... | javascript | function(ugen) {
ugen.mod = ugen.polyMod;
ugen.removeMod = ugen.removePolyMod;
for( var key in ugen.polyProperties ) {
(function( _key ) {
var value = ugen.polyProperties[ _key ],
isTimeProp = Audio.Clock.timeProperties.indexOf( _key ) > -1
Object.defineProperty(ugen,... | [
"function",
"(",
"ugen",
")",
"{",
"ugen",
".",
"mod",
"=",
"ugen",
".",
"polyMod",
";",
"ugen",
".",
"removeMod",
"=",
"ugen",
".",
"removePolyMod",
";",
"for",
"(",
"var",
"key",
"in",
"ugen",
".",
"polyProperties",
")",
"{",
"(",
"function",
"(",
... | override for Gibber.Audio method | [
"override",
"for",
"Gibber",
".",
"Audio",
"method"
] | 3deab46d2b5b7912a1772ceaca160991676f6fc4 | https://github.com/charlieroberts/gibber.audio.lib/blob/3deab46d2b5b7912a1772ceaca160991676f6fc4/scripts/gibber/audio.js#L191-L211 | train | |
charlieroberts/gibber.audio.lib | scripts/gibber/audio.js | function( bus, position ) {
if( typeof bus === 'undefined' ) bus = Audio.Master
if( this.destinations.indexOf( bus ) === -1 ){
bus.addConnection( this, 1, position )
if( position !== 0 ) {
this.destinations.push( bus )
}
}
return this
} | javascript | function( bus, position ) {
if( typeof bus === 'undefined' ) bus = Audio.Master
if( this.destinations.indexOf( bus ) === -1 ){
bus.addConnection( this, 1, position )
if( position !== 0 ) {
this.destinations.push( bus )
}
}
return this
} | [
"function",
"(",
"bus",
",",
"position",
")",
"{",
"if",
"(",
"typeof",
"bus",
"===",
"'undefined'",
")",
"bus",
"=",
"Audio",
".",
"Master",
"if",
"(",
"this",
".",
"destinations",
".",
"indexOf",
"(",
"bus",
")",
"===",
"-",
"1",
")",
"{",
"bus",... | override for Gibber.Audio method to use master bus | [
"override",
"for",
"Gibber",
".",
"Audio",
"method",
"to",
"use",
"master",
"bus"
] | 3deab46d2b5b7912a1772ceaca160991676f6fc4 | https://github.com/charlieroberts/gibber.audio.lib/blob/3deab46d2b5b7912a1772ceaca160991676f6fc4/scripts/gibber/audio.js#L213-L224 | train | |
pattern-lab/plugin-node-tab | src/tab-loader.js | findTab | function findTab(patternlab, pattern) {
//read the filetypes from the configuration
const fileTypes = patternlab.config.plugins['plugin-node-tab'].options.tabsToAdd;
//exit if either of these two parameters are missing
if (!patternlab) {
console.error('plugin-node-tab: patternlab object not provided to fi... | javascript | function findTab(patternlab, pattern) {
//read the filetypes from the configuration
const fileTypes = patternlab.config.plugins['plugin-node-tab'].options.tabsToAdd;
//exit if either of these two parameters are missing
if (!patternlab) {
console.error('plugin-node-tab: patternlab object not provided to fi... | [
"function",
"findTab",
"(",
"patternlab",
",",
"pattern",
")",
"{",
"//read the filetypes from the configuration",
"const",
"fileTypes",
"=",
"patternlab",
".",
"config",
".",
"plugins",
"[",
"'plugin-node-tab'",
"]",
".",
"options",
".",
"tabsToAdd",
";",
"//exit i... | The backend method that is called during the patternlab-pattern-write-end event.
Responsible for looking for a companion filetype file alongside a pattern file and outputting it if found.
@param patternlab - the global data store
@param pattern - the pattern object being iterated over | [
"The",
"backend",
"method",
"that",
"is",
"called",
"during",
"the",
"patternlab",
"-",
"pattern",
"-",
"write",
"-",
"end",
"event",
".",
"Responsible",
"for",
"looking",
"for",
"a",
"companion",
"filetype",
"file",
"alongside",
"a",
"pattern",
"file",
"and... | 6c1342f528a0a7a81cc1663940a3be227def0e8c | https://github.com/pattern-lab/plugin-node-tab/blob/6c1342f528a0a7a81cc1663940a3be227def0e8c/src/tab-loader.js#L12-L64 | train |
yuki-torii/yuki-createjs | lib/preloadjs-0.6.2.combined.js | VideoLoader | function VideoLoader(loadItem, preferXHR) {
this.AbstractMediaLoader_constructor(loadItem, preferXHR, createjs.AbstractLoader.VIDEO);
if (createjs.RequestUtils.isVideoTag(loadItem) || createjs.RequestUtils.isVideoTag(loadItem.src)) {
this.setTag(createjs.RequestUtils.isVideoTag(loadItem)?loadItem:loadItem.src);... | javascript | function VideoLoader(loadItem, preferXHR) {
this.AbstractMediaLoader_constructor(loadItem, preferXHR, createjs.AbstractLoader.VIDEO);
if (createjs.RequestUtils.isVideoTag(loadItem) || createjs.RequestUtils.isVideoTag(loadItem.src)) {
this.setTag(createjs.RequestUtils.isVideoTag(loadItem)?loadItem:loadItem.src);... | [
"function",
"VideoLoader",
"(",
"loadItem",
",",
"preferXHR",
")",
"{",
"this",
".",
"AbstractMediaLoader_constructor",
"(",
"loadItem",
",",
"preferXHR",
",",
"createjs",
".",
"AbstractLoader",
".",
"VIDEO",
")",
";",
"if",
"(",
"createjs",
".",
"RequestUtils",... | constructor
A loader for video files.
@class VideoLoader
@param {LoadItem|Object} loadItem
@param {Boolean} preferXHR
@extends AbstractMediaLoader
@constructor | [
"constructor",
"A",
"loader",
"for",
"video",
"files",
"."
] | 8b3b684782516cc63cd3b337742d90fe85285a90 | https://github.com/yuki-torii/yuki-createjs/blob/8b3b684782516cc63cd3b337742d90fe85285a90/lib/preloadjs-0.6.2.combined.js#L6944-L6955 | train |
vail-systems/node-mfcc | src/mfcc.js | powerSpectrum | function powerSpectrum(amplitudes) {
var N = amplitudes.length;
return amplitudes.map(function (a) {
return (a * a) / N;
});
} | javascript | function powerSpectrum(amplitudes) {
var N = amplitudes.length;
return amplitudes.map(function (a) {
return (a * a) / N;
});
} | [
"function",
"powerSpectrum",
"(",
"amplitudes",
")",
"{",
"var",
"N",
"=",
"amplitudes",
".",
"length",
";",
"return",
"amplitudes",
".",
"map",
"(",
"function",
"(",
"a",
")",
"{",
"return",
"(",
"a",
"*",
"a",
")",
"/",
"N",
";",
"}",
")",
";",
... | Estimate the power spectrum density from FFT amplitudes. | [
"Estimate",
"the",
"power",
"spectrum",
"density",
"from",
"FFT",
"amplitudes",
"."
] | f67ca5e3cc7c7fc80cd4bcbed07962dbedc126e1 | https://github.com/vail-systems/node-mfcc/blob/f67ca5e3cc7c7fc80cd4bcbed07962dbedc126e1/src/mfcc.js#L163-L169 | train |
mikestead/swagger-routes | src/fileUtil.js | updateHeader | function updateHeader(fileInfo, data, type, headerLineRegex, options) {
const contents = fs.readFileSync(fileInfo.path, 'utf8') || ''
const body = contents.split('\n')
// assumes all comments at top of template are the header block
const preheader = []
while (body.length && !body[0].trim().match(headerLineRe... | javascript | function updateHeader(fileInfo, data, type, headerLineRegex, options) {
const contents = fs.readFileSync(fileInfo.path, 'utf8') || ''
const body = contents.split('\n')
// assumes all comments at top of template are the header block
const preheader = []
while (body.length && !body[0].trim().match(headerLineRe... | [
"function",
"updateHeader",
"(",
"fileInfo",
",",
"data",
",",
"type",
",",
"headerLineRegex",
",",
"options",
")",
"{",
"const",
"contents",
"=",
"fs",
".",
"readFileSync",
"(",
"fileInfo",
".",
"path",
",",
"'utf8'",
")",
"||",
"''",
"const",
"body",
"... | Keeps the header block of your templated file in sync with your Swagger api.
@param {object} fileInfo info on the file to target
@param {object} data the operation which to gen the header from
@param {string} type the type of file being updated
@param {regex} headerLineRegex regex to find if a line is part of the head... | [
"Keeps",
"the",
"header",
"block",
"of",
"your",
"templated",
"file",
"in",
"sync",
"with",
"your",
"Swagger",
"api",
"."
] | dfa1cd16df18aa26925ce377bfdb5b18f88e2a77 | https://github.com/mikestead/swagger-routes/blob/dfa1cd16df18aa26925ce377bfdb5b18f88e2a77/src/fileUtil.js#L165-L182 | train |
xuzhao9/hexo-theme-greyshade | source/js/slash.js | function(){
$('.entry-content').each(function(i){
var _i = i;
$(this).find('img').each(function(){
var alt = this.alt;
if (alt != ''){
$(this).after('<span class="caption">'+alt+'</span>');
}
$(this).wrap('<a href="'+this.src+'" title="'+alt+'" class="fancybox" rel="gallery'+_i+'" />');
... | javascript | function(){
$('.entry-content').each(function(i){
var _i = i;
$(this).find('img').each(function(){
var alt = this.alt;
if (alt != ''){
$(this).after('<span class="caption">'+alt+'</span>');
}
$(this).wrap('<a href="'+this.src+'" title="'+alt+'" class="fancybox" rel="gallery'+_i+'" />');
... | [
"function",
"(",
")",
"{",
"$",
"(",
"'.entry-content'",
")",
".",
"each",
"(",
"function",
"(",
"i",
")",
"{",
"var",
"_i",
"=",
"i",
";",
"$",
"(",
"this",
")",
".",
"find",
"(",
"'img'",
")",
".",
"each",
"(",
"function",
"(",
")",
"{",
"v... | Append caption after pictures | [
"Append",
"caption",
"after",
"pictures"
] | cdf50d81ea6a24ff178c4e3cc98ffb88fc54c606 | https://github.com/xuzhao9/hexo-theme-greyshade/blob/cdf50d81ea6a24ff178c4e3cc98ffb88fc54c606/source/js/slash.js#L18-L31 | train | |
primefaces/primeui-distribution | plugins/touchswipe.js | init | function init(options) {
//Prep and extend the options
if (options && (options.allowPageScroll === undefined && (options.swipe !== undefined || options.swipeStatus !== undefined))) {
options.allowPageScroll = NONE;
}
//Check for deprecated options
//Ensure that any old click handlers are assigned ... | javascript | function init(options) {
//Prep and extend the options
if (options && (options.allowPageScroll === undefined && (options.swipe !== undefined || options.swipeStatus !== undefined))) {
options.allowPageScroll = NONE;
}
//Check for deprecated options
//Ensure that any old click handlers are assigned ... | [
"function",
"init",
"(",
"options",
")",
"{",
"//Prep and extend the options",
"if",
"(",
"options",
"&&",
"(",
"options",
".",
"allowPageScroll",
"===",
"undefined",
"&&",
"(",
"options",
".",
"swipe",
"!==",
"undefined",
"||",
"options",
".",
"swipeStatus",
... | Initialise the plugin for each DOM element matched
This creates a new instance of the main TouchSwipe class for each DOM element, and then
saves a reference to that instance in the elements data property.
@internal | [
"Initialise",
"the",
"plugin",
"for",
"each",
"DOM",
"element",
"matched",
"This",
"creates",
"a",
"new",
"instance",
"of",
"the",
"main",
"TouchSwipe",
"class",
"for",
"each",
"DOM",
"element",
"and",
"then",
"saves",
"a",
"reference",
"to",
"that",
"instan... | 234d466a6cbc8eb3325eeef27df84e81812bf394 | https://github.com/primefaces/primeui-distribution/blob/234d466a6cbc8eb3325eeef27df84e81812bf394/plugins/touchswipe.js#L381-L412 | train |
primefaces/primeui-distribution | plugins/touchswipe.js | touchStart | function touchStart(jqEvent) {
//If we already in a touch event (a finger already in use) then ignore subsequent ones..
if( getTouchInProgress() )
return;
//Check if this element matches any in the excluded elements selectors, or its parent is excluded, if so, DON'T swipe
if( $(jqEvent.target).clos... | javascript | function touchStart(jqEvent) {
//If we already in a touch event (a finger already in use) then ignore subsequent ones..
if( getTouchInProgress() )
return;
//Check if this element matches any in the excluded elements selectors, or its parent is excluded, if so, DON'T swipe
if( $(jqEvent.target).clos... | [
"function",
"touchStart",
"(",
"jqEvent",
")",
"{",
"//If we already in a touch event (a finger already in use) then ignore subsequent ones..",
"if",
"(",
"getTouchInProgress",
"(",
")",
")",
"return",
";",
"//Check if this element matches any in the excluded elements selectors, or it... | EVENTS
Event handler for a touch start event.
Stops the default click event from triggering and stores where we touched
@inner
@param {object} jqEvent The normalised jQuery event object. | [
"EVENTS",
"Event",
"handler",
"for",
"a",
"touch",
"start",
"event",
".",
"Stops",
"the",
"default",
"click",
"event",
"from",
"triggering",
"and",
"stores",
"where",
"we",
"touched"
] | 234d466a6cbc8eb3325eeef27df84e81812bf394 | https://github.com/primefaces/primeui-distribution/blob/234d466a6cbc8eb3325eeef27df84e81812bf394/plugins/touchswipe.js#L561-L648 | train |
primefaces/primeui-distribution | plugins/touchswipe.js | touchMove | function touchMove(jqEvent) {
//As we use Jquery bind for events, we need to target the original event object
//If these events are being programmatically triggered, we don't have an original event object, so use the Jq one.
var event = jqEvent.originalEvent ? jqEvent.originalEvent : jqEvent;
//If w... | javascript | function touchMove(jqEvent) {
//As we use Jquery bind for events, we need to target the original event object
//If these events are being programmatically triggered, we don't have an original event object, so use the Jq one.
var event = jqEvent.originalEvent ? jqEvent.originalEvent : jqEvent;
//If w... | [
"function",
"touchMove",
"(",
"jqEvent",
")",
"{",
"//As we use Jquery bind for events, we need to target the original event object",
"//If these events are being programmatically triggered, we don't have an original event object, so use the Jq one.",
"var",
"event",
"=",
"jqEvent",
".",
"... | Event handler for a touch move event.
If we change fingers during move, then cancel the event
@inner
@param {object} jqEvent The normalised jQuery event object. | [
"Event",
"handler",
"for",
"a",
"touch",
"move",
"event",
".",
"If",
"we",
"change",
"fingers",
"during",
"move",
"then",
"cancel",
"the",
"event"
] | 234d466a6cbc8eb3325eeef27df84e81812bf394 | https://github.com/primefaces/primeui-distribution/blob/234d466a6cbc8eb3325eeef27df84e81812bf394/plugins/touchswipe.js#L658-L766 | train |
primefaces/primeui-distribution | plugins/touchswipe.js | touchEnd | function touchEnd(jqEvent) {
//As we use Jquery bind for events, we need to target the original event object
//If these events are being programmatically triggered, we don't have an original event object, so use the Jq one.
var event = jqEvent.originalEvent ? jqEvent.originalEvent : jqEvent,
touches = e... | javascript | function touchEnd(jqEvent) {
//As we use Jquery bind for events, we need to target the original event object
//If these events are being programmatically triggered, we don't have an original event object, so use the Jq one.
var event = jqEvent.originalEvent ? jqEvent.originalEvent : jqEvent,
touches = e... | [
"function",
"touchEnd",
"(",
"jqEvent",
")",
"{",
"//As we use Jquery bind for events, we need to target the original event object",
"//If these events are being programmatically triggered, we don't have an original event object, so use the Jq one.",
"var",
"event",
"=",
"jqEvent",
".",
"o... | Event handler for a touch end event.
Calculate the direction and trigger events
@inner
@param {object} jqEvent The normalised jQuery event object. | [
"Event",
"handler",
"for",
"a",
"touch",
"end",
"event",
".",
"Calculate",
"the",
"direction",
"and",
"trigger",
"events"
] | 234d466a6cbc8eb3325eeef27df84e81812bf394 | https://github.com/primefaces/primeui-distribution/blob/234d466a6cbc8eb3325eeef27df84e81812bf394/plugins/touchswipe.js#L776-L829 | train |
primefaces/primeui-distribution | plugins/touchswipe.js | touchCancel | function touchCancel() {
// reset the variables back to default values
fingerCount = 0;
endTime = 0;
startTime = 0;
startTouchesDistance=0;
endTouchesDistance=0;
pinchZoom=1;
//If we were in progress of tracking a possible multi touch end, then re set it.
cancelMultiFingerRelease();
... | javascript | function touchCancel() {
// reset the variables back to default values
fingerCount = 0;
endTime = 0;
startTime = 0;
startTouchesDistance=0;
endTouchesDistance=0;
pinchZoom=1;
//If we were in progress of tracking a possible multi touch end, then re set it.
cancelMultiFingerRelease();
... | [
"function",
"touchCancel",
"(",
")",
"{",
"// reset the variables back to default values",
"fingerCount",
"=",
"0",
";",
"endTime",
"=",
"0",
";",
"startTime",
"=",
"0",
";",
"startTouchesDistance",
"=",
"0",
";",
"endTouchesDistance",
"=",
"0",
";",
"pinchZoom",
... | Event handler for a touch cancel event.
Clears current vars
@inner | [
"Event",
"handler",
"for",
"a",
"touch",
"cancel",
"event",
".",
"Clears",
"current",
"vars"
] | 234d466a6cbc8eb3325eeef27df84e81812bf394 | https://github.com/primefaces/primeui-distribution/blob/234d466a6cbc8eb3325eeef27df84e81812bf394/plugins/touchswipe.js#L838-L851 | train |
primefaces/primeui-distribution | plugins/touchswipe.js | touchLeave | function touchLeave(jqEvent) {
var event = jqEvent.originalEvent ? jqEvent.originalEvent : jqEvent;
//If we have the trigger on leave property set....
if(options.triggerOnTouchLeave) {
phase = getNextPhase( PHASE_END );
triggerHandler(event, phase);
}
} | javascript | function touchLeave(jqEvent) {
var event = jqEvent.originalEvent ? jqEvent.originalEvent : jqEvent;
//If we have the trigger on leave property set....
if(options.triggerOnTouchLeave) {
phase = getNextPhase( PHASE_END );
triggerHandler(event, phase);
}
} | [
"function",
"touchLeave",
"(",
"jqEvent",
")",
"{",
"var",
"event",
"=",
"jqEvent",
".",
"originalEvent",
"?",
"jqEvent",
".",
"originalEvent",
":",
"jqEvent",
";",
"//If we have the trigger on leave property set....",
"if",
"(",
"options",
".",
"triggerOnTouchLeave",... | Event handler for a touch leave event.
This is only triggered on desktops, in touch we work this out manually
as the touchleave event is not supported in webkit
@inner | [
"Event",
"handler",
"for",
"a",
"touch",
"leave",
"event",
".",
"This",
"is",
"only",
"triggered",
"on",
"desktops",
"in",
"touch",
"we",
"work",
"this",
"out",
"manually",
"as",
"the",
"touchleave",
"event",
"is",
"not",
"supported",
"in",
"webkit"
] | 234d466a6cbc8eb3325eeef27df84e81812bf394 | https://github.com/primefaces/primeui-distribution/blob/234d466a6cbc8eb3325eeef27df84e81812bf394/plugins/touchswipe.js#L860-L868 | train |
Subsets and Splits
SQL Console for semeru/code-text-javascript
Retrieves 20,000 non-null code samples labeled as JavaScript, providing a basic overview of the dataset.