id int32 0 58k | repo stringlengths 5 67 | path stringlengths 4 116 | func_name stringlengths 0 58 | original_string stringlengths 52 373k | language stringclasses 1
value | code stringlengths 52 373k | code_tokens list | docstring stringlengths 4 11.8k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 86 226 |
|---|---|---|---|---|---|---|---|---|---|---|---|
41,900 | veo-labs/openveo-api | lib/grunt/ngDpTask/ngDpTask.js | buildTree | function buildTree(scripts) {
var chains = [];
var tree = {
children: []
};
var currentTreeNode = tree;
// Get the longest dependency chain for each script with the highest dependency
// as the first element of the chain
scripts.forEach(function(script) {
chains = chains.concat(findLongestDependencyChains(scripts, script));
});
// Sort chains by length with longest chains first
chains.sort(function(chain1, chain2) {
// -1 : chain1 before chain2
// 0 : nothing change
// 1 : chain1 after chain2
if (chain1.length > chain2.length)
return -1;
else if (chain1.length < chain2.length)
return 1;
else return 0;
});
// Add each chain to the tree
chains.forEach(function(chain) {
// Add each element of the chain as a child of its parent
chain.forEach(function(scriptPath) {
var currentScript = findScript(scripts, 'path', scriptPath);
var alreadyExists = false;
if (!currentTreeNode.children)
currentTreeNode.children = [];
// Check if current script does not exist in node children
for (var i = 0; i < currentTreeNode.children.length; i++) {
if (currentTreeNode.children[i].path === currentScript.path) {
alreadyExists = true;
break;
}
}
// Add script to the tree
if (!alreadyExists)
currentTreeNode.children.push(currentScript);
currentTreeNode = currentScript;
});
currentTreeNode = tree;
});
return tree;
} | javascript | function buildTree(scripts) {
var chains = [];
var tree = {
children: []
};
var currentTreeNode = tree;
// Get the longest dependency chain for each script with the highest dependency
// as the first element of the chain
scripts.forEach(function(script) {
chains = chains.concat(findLongestDependencyChains(scripts, script));
});
// Sort chains by length with longest chains first
chains.sort(function(chain1, chain2) {
// -1 : chain1 before chain2
// 0 : nothing change
// 1 : chain1 after chain2
if (chain1.length > chain2.length)
return -1;
else if (chain1.length < chain2.length)
return 1;
else return 0;
});
// Add each chain to the tree
chains.forEach(function(chain) {
// Add each element of the chain as a child of its parent
chain.forEach(function(scriptPath) {
var currentScript = findScript(scripts, 'path', scriptPath);
var alreadyExists = false;
if (!currentTreeNode.children)
currentTreeNode.children = [];
// Check if current script does not exist in node children
for (var i = 0; i < currentTreeNode.children.length; i++) {
if (currentTreeNode.children[i].path === currentScript.path) {
alreadyExists = true;
break;
}
}
// Add script to the tree
if (!alreadyExists)
currentTreeNode.children.push(currentScript);
currentTreeNode = currentScript;
});
currentTreeNode = tree;
});
return tree;
} | [
"function",
"buildTree",
"(",
"scripts",
")",
"{",
"var",
"chains",
"=",
"[",
"]",
";",
"var",
"tree",
"=",
"{",
"children",
":",
"[",
"]",
"}",
";",
"var",
"currentTreeNode",
"=",
"tree",
";",
"// Get the longest dependency chain for each script with the highes... | Builds the dependencies tree.
@method buildTree
@param {Array} scripts The flat list of scripts with for each script:
- **dependencies** The list of dependency names of the script
- **definitions** The list of definition names of the script
- **path** The script path
@return {Array} The list of scripts with their dependencies
@private | [
"Builds",
"the",
"dependencies",
"tree",
"."
] | 493a811e9a5ba4d3e14910facaa7452caba1ab38 | https://github.com/veo-labs/openveo-api/blob/493a811e9a5ba4d3e14910facaa7452caba1ab38/lib/grunt/ngDpTask/ngDpTask.js#L255-L311 |
41,901 | urturn/urturn-expression-api | lib/expression-api/import.js | function(list, name) {
if (Object.prototype.toString.call(list) === '[object Array]' && Object.prototype.toString.call(name) === '[object String]') {
for (var i = 0; i < list.length; i++) {
if (list[i] === name) {
return true;
}
}
}
return false;
} | javascript | function(list, name) {
if (Object.prototype.toString.call(list) === '[object Array]' && Object.prototype.toString.call(name) === '[object String]') {
for (var i = 0; i < list.length; i++) {
if (list[i] === name) {
return true;
}
}
}
return false;
} | [
"function",
"(",
"list",
",",
"name",
")",
"{",
"if",
"(",
"Object",
".",
"prototype",
".",
"toString",
".",
"call",
"(",
"list",
")",
"===",
"'[object Array]'",
"&&",
"Object",
".",
"prototype",
".",
"toString",
".",
"call",
"(",
"name",
")",
"===",
... | Internal function for checking if a string is contained in a given array | [
"Internal",
"function",
"for",
"checking",
"if",
"a",
"string",
"is",
"contained",
"in",
"a",
"given",
"array"
] | 009a272ee670dbbe5eefb5c070ed827dd778bb07 | https://github.com/urturn/urturn-expression-api/blob/009a272ee670dbbe5eefb5c070ed827dd778bb07/lib/expression-api/import.js#L12-L21 | |
41,902 | atsid/circuits-js | js/declare.js | isInstanceOf | function isInstanceOf(cls) {
var i, l, bases = this.constructor._meta.bases;
for (i = 0, l = bases.length; i < l; i += 1) {
if (bases[i] === cls) {
return true;
}
}
return this instanceof cls;
} | javascript | function isInstanceOf(cls) {
var i, l, bases = this.constructor._meta.bases;
for (i = 0, l = bases.length; i < l; i += 1) {
if (bases[i] === cls) {
return true;
}
}
return this instanceof cls;
} | [
"function",
"isInstanceOf",
"(",
"cls",
")",
"{",
"var",
"i",
",",
"l",
",",
"bases",
"=",
"this",
".",
"constructor",
".",
"_meta",
".",
"bases",
";",
"for",
"(",
"i",
"=",
"0",
",",
"l",
"=",
"bases",
".",
"length",
";",
"i",
"<",
"l",
";",
... | emulation of "instanceof" | [
"emulation",
"of",
"instanceof"
] | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/declare.js#L311-L319 |
41,903 | atsid/circuits-js | js/declare.js | safeMixin | function safeMixin(target, source) {
var name, t;
// add props adding metadata for incoming functions skipping a constructor
for (name in source) {
t = source[name];
if ((t !== op[name] || !(name in op)) && name !== cname) {
if (opts.call(t) === "[object Function]") {
// non-trivial function method => attach its name
t.nom = name;
}
target[name] = t;
}
}
return target;
} | javascript | function safeMixin(target, source) {
var name, t;
// add props adding metadata for incoming functions skipping a constructor
for (name in source) {
t = source[name];
if ((t !== op[name] || !(name in op)) && name !== cname) {
if (opts.call(t) === "[object Function]") {
// non-trivial function method => attach its name
t.nom = name;
}
target[name] = t;
}
}
return target;
} | [
"function",
"safeMixin",
"(",
"target",
",",
"source",
")",
"{",
"var",
"name",
",",
"t",
";",
"// add props adding metadata for incoming functions skipping a constructor",
"for",
"(",
"name",
"in",
"source",
")",
"{",
"t",
"=",
"source",
"[",
"name",
"]",
";",
... | implementation of safe mixin function | [
"implementation",
"of",
"safe",
"mixin",
"function"
] | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/declare.js#L332-L346 |
41,904 | cronvel/roots-db | lib/doormen-extensions.js | toLink | function toLink( data ) {
if ( data && typeof data === 'object' ) {
if ( data.constructor.name === 'ObjectID' || data.constructor.name === 'ObjectId' ) {
return { _id: data } ;
}
data._id = toObjectId( data._id ) ;
}
else if ( typeof data === 'string' ) {
try {
data = { _id: mongodb.ObjectID( data ) } ;
}
catch ( error ) {}
}
return data ;
} | javascript | function toLink( data ) {
if ( data && typeof data === 'object' ) {
if ( data.constructor.name === 'ObjectID' || data.constructor.name === 'ObjectId' ) {
return { _id: data } ;
}
data._id = toObjectId( data._id ) ;
}
else if ( typeof data === 'string' ) {
try {
data = { _id: mongodb.ObjectID( data ) } ;
}
catch ( error ) {}
}
return data ;
} | [
"function",
"toLink",
"(",
"data",
")",
"{",
"if",
"(",
"data",
"&&",
"typeof",
"data",
"===",
"'object'",
")",
"{",
"if",
"(",
"data",
".",
"constructor",
".",
"name",
"===",
"'ObjectID'",
"||",
"data",
".",
"constructor",
".",
"name",
"===",
"'Object... | Allow one to pass the whole linked target object | [
"Allow",
"one",
"to",
"pass",
"the",
"whole",
"linked",
"target",
"object"
] | 7945a32677e4243d7a1200b9f47e7d06b7b6b56f | https://github.com/cronvel/roots-db/blob/7945a32677e4243d7a1200b9f47e7d06b7b6b56f/lib/doormen-extensions.js#L146-L162 |
41,905 | studybreak/casio | lib/cql.js | quote | function quote(s) {
if (typeof(s) === 'string') {
return "'" + s.replace(/'/g, "''") + "'";
} else if (s instanceof Array) {
return _.map(s, quote).join(', ');
}
return s;
} | javascript | function quote(s) {
if (typeof(s) === 'string') {
return "'" + s.replace(/'/g, "''") + "'";
} else if (s instanceof Array) {
return _.map(s, quote).join(', ');
}
return s;
} | [
"function",
"quote",
"(",
"s",
")",
"{",
"if",
"(",
"typeof",
"(",
"s",
")",
"===",
"'string'",
")",
"{",
"return",
"\"'\"",
"+",
"s",
".",
"replace",
"(",
"/",
"'",
"/",
"g",
",",
"\"''\"",
")",
"+",
"\"'\"",
";",
"}",
"else",
"if",
"(",
"s"... | escape all single-quotes on strings... | [
"escape",
"all",
"single",
"-",
"quotes",
"on",
"strings",
"..."
] | 814546bdd4c861cc363d5398762035598f6dbc09 | https://github.com/studybreak/casio/blob/814546bdd4c861cc363d5398762035598f6dbc09/lib/cql.js#L5-L13 |
41,906 | Thorinjs/Thorin-store-sql | lib/loader.js | ToJSON | function ToJSON(jsonName) {
if (jsonName === 'result') jsonName = 'default';
let args = Array.prototype.slice.call(arguments);
if (typeof jsonName === 'undefined') {
jsonName = 'default';
} else if (typeof jsonName === 'string') {
args.splice(0, 1); //remove the name.
}
let jsonFn = modelObj.jsons[jsonName],
result = this.dataValues;
if (typeof jsonFn === 'undefined' && jsonName !== 'default') { // silent fallback
if (typeof modelObj.jsons['default'] === 'function') {
result = modelObj.jsons['default'].apply(this, args);
}
} else {
if (typeof modelObj.jsons[jsonName] === 'function') {
result = modelObj.jsons[jsonName].apply(this, args);
} else {
result = this.dataValues;
}
}
if (result === this) {
result = this.dataValues;
}
if (typeof result === 'object' && result != null) {
for (let i = 0; i < modelObj.privateAttributes.length; i++) {
if (typeof result[modelObj.privateAttributes[i]] !== 'undefined') {
delete result[modelObj.privateAttributes[i]];
}
}
}
return result;
} | javascript | function ToJSON(jsonName) {
if (jsonName === 'result') jsonName = 'default';
let args = Array.prototype.slice.call(arguments);
if (typeof jsonName === 'undefined') {
jsonName = 'default';
} else if (typeof jsonName === 'string') {
args.splice(0, 1); //remove the name.
}
let jsonFn = modelObj.jsons[jsonName],
result = this.dataValues;
if (typeof jsonFn === 'undefined' && jsonName !== 'default') { // silent fallback
if (typeof modelObj.jsons['default'] === 'function') {
result = modelObj.jsons['default'].apply(this, args);
}
} else {
if (typeof modelObj.jsons[jsonName] === 'function') {
result = modelObj.jsons[jsonName].apply(this, args);
} else {
result = this.dataValues;
}
}
if (result === this) {
result = this.dataValues;
}
if (typeof result === 'object' && result != null) {
for (let i = 0; i < modelObj.privateAttributes.length; i++) {
if (typeof result[modelObj.privateAttributes[i]] !== 'undefined') {
delete result[modelObj.privateAttributes[i]];
}
}
}
return result;
} | [
"function",
"ToJSON",
"(",
"jsonName",
")",
"{",
"if",
"(",
"jsonName",
"===",
"'result'",
")",
"jsonName",
"=",
"'default'",
";",
"let",
"args",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
")",
";",
"if",
"(",
"typeof"... | wrap the toJSON function to exclude private fields. | [
"wrap",
"the",
"toJSON",
"function",
"to",
"exclude",
"private",
"fields",
"."
] | d863a6cc9902dbc69fbdc3a49ba7a1a6d17613f0 | https://github.com/Thorinjs/Thorin-store-sql/blob/d863a6cc9902dbc69fbdc3a49ba7a1a6d17613f0/lib/loader.js#L199-L231 |
41,907 | cronvel/babel-tower | lib/en.js | switchPersonStr | function switchPersonStr( str ) {
var switchPersonStrVerb = {} ;
return str.replace( /\s+|(i|you|he|she|it|we|they)\s+(\S+)(?=\s)/gi , ( match , pronoun , verb ) => {
if ( ! pronoun ) { return match ; }
var person = null , plural = null , switchedPronoun = null ;
pronoun = pronoun.toLowerCase() ;
verb = verb.toLowerCase() ;
switch ( pronoun ) {
case 'he' :
case 'she' :
case 'it' :
case 'they' :
return match ;
case 'i' : person = 1 ; plural = false ; switchedPronoun = 'you' ; break ;
case 'you' : person = 2 ; switchedPronoun = 'I' ; break ;
case 'we' : person = 1 ; plural = true ; switchedPronoun = 'you' ; break ;
}
if ( ! switchPersonStrVerb[ verb ] ) {
// Damned! We don't know that verb!
return switchedPronoun + ' ' + verb ;
}
return switchedPronoun + ' ' + switchPersonStrVerb[ verb ] ;
} ) ;
} | javascript | function switchPersonStr( str ) {
var switchPersonStrVerb = {} ;
return str.replace( /\s+|(i|you|he|she|it|we|they)\s+(\S+)(?=\s)/gi , ( match , pronoun , verb ) => {
if ( ! pronoun ) { return match ; }
var person = null , plural = null , switchedPronoun = null ;
pronoun = pronoun.toLowerCase() ;
verb = verb.toLowerCase() ;
switch ( pronoun ) {
case 'he' :
case 'she' :
case 'it' :
case 'they' :
return match ;
case 'i' : person = 1 ; plural = false ; switchedPronoun = 'you' ; break ;
case 'you' : person = 2 ; switchedPronoun = 'I' ; break ;
case 'we' : person = 1 ; plural = true ; switchedPronoun = 'you' ; break ;
}
if ( ! switchPersonStrVerb[ verb ] ) {
// Damned! We don't know that verb!
return switchedPronoun + ' ' + verb ;
}
return switchedPronoun + ' ' + switchPersonStrVerb[ verb ] ;
} ) ;
} | [
"function",
"switchPersonStr",
"(",
"str",
")",
"{",
"var",
"switchPersonStrVerb",
"=",
"{",
"}",
";",
"return",
"str",
".",
"replace",
"(",
"/",
"\\s+|(i|you|he|she|it|we|they)\\s+(\\S+)(?=\\s)",
"/",
"gi",
",",
"(",
"match",
",",
"pronoun",
",",
"verb",
")",... | Switch a person, using a string | [
"Switch",
"a",
"person",
"using",
"a",
"string"
] | ad1e73b73eb74ae97cdbff3b782a641a48b57eb6 | https://github.com/cronvel/babel-tower/blob/ad1e73b73eb74ae97cdbff3b782a641a48b57eb6/lib/en.js#L74-L103 |
41,908 | LeisureLink/magicbus | lib/event-dispatcher.js | on | function on(eventNamesOrPatterns, handler) {
if (!eventNamesOrPatterns) {
throw new Error('Must pass at least one event name or matching RegEx');
}
assert.func(handler, 'handler');
if (!Array.isArray(eventNamesOrPatterns)) {
eventNamesOrPatterns = [eventNamesOrPatterns];
}
for (let i = 0; i < eventNamesOrPatterns.length; i++) {
buckets.push({
pattern: ensureRegExp(eventNamesOrPatterns[i]),
handler: handler
});
}
} | javascript | function on(eventNamesOrPatterns, handler) {
if (!eventNamesOrPatterns) {
throw new Error('Must pass at least one event name or matching RegEx');
}
assert.func(handler, 'handler');
if (!Array.isArray(eventNamesOrPatterns)) {
eventNamesOrPatterns = [eventNamesOrPatterns];
}
for (let i = 0; i < eventNamesOrPatterns.length; i++) {
buckets.push({
pattern: ensureRegExp(eventNamesOrPatterns[i]),
handler: handler
});
}
} | [
"function",
"on",
"(",
"eventNamesOrPatterns",
",",
"handler",
")",
"{",
"if",
"(",
"!",
"eventNamesOrPatterns",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Must pass at least one event name or matching RegEx'",
")",
";",
"}",
"assert",
".",
"func",
"(",
"handler",
... | Subscribe to an event
@public
@method
@param {String|RegEx|Array} eventNamesOrPatterns - name(s) of event, or pattern(s) for RegEx matching (required)
@param {Function} handler - event handler (required) | [
"Subscribe",
"to",
"an",
"event"
] | 0370c38ebb8c7917cfd3894263d734aefc2d3d29 | https://github.com/LeisureLink/magicbus/blob/0370c38ebb8c7917cfd3894263d734aefc2d3d29/lib/event-dispatcher.js#L32-L46 |
41,909 | LeisureLink/magicbus | lib/event-dispatcher.js | once | function once(eventNamesOrPatterns, handler) {
if (!eventNamesOrPatterns) {
throw new Error('Must pass at least one event name or matching RegEx');
}
assert.func(handler, 'handler');
if (!Array.isArray(eventNamesOrPatterns)) {
eventNamesOrPatterns = [eventNamesOrPatterns];
}
let deferred = DeferredPromise();
for (let i = 0; i < eventNamesOrPatterns.length; i++) {
buckets.push({
pattern: ensureRegExp(eventNamesOrPatterns[i]),
handler: handler,
once: deferred
});
}
return deferred.promise;
} | javascript | function once(eventNamesOrPatterns, handler) {
if (!eventNamesOrPatterns) {
throw new Error('Must pass at least one event name or matching RegEx');
}
assert.func(handler, 'handler');
if (!Array.isArray(eventNamesOrPatterns)) {
eventNamesOrPatterns = [eventNamesOrPatterns];
}
let deferred = DeferredPromise();
for (let i = 0; i < eventNamesOrPatterns.length; i++) {
buckets.push({
pattern: ensureRegExp(eventNamesOrPatterns[i]),
handler: handler,
once: deferred
});
}
return deferred.promise;
} | [
"function",
"once",
"(",
"eventNamesOrPatterns",
",",
"handler",
")",
"{",
"if",
"(",
"!",
"eventNamesOrPatterns",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Must pass at least one event name or matching RegEx'",
")",
";",
"}",
"assert",
".",
"func",
"(",
"handler"... | Subscribe to an event for one event only
@public
@method
@param {String|RegEx|Array} eventNamesOrPatterns - name(s) of event, or pattern(s) for RegEx matching (required)
@param {Function} handler - event handler (required)
@returns {Promise} a promise that is fulfilled when the event has been processed | [
"Subscribe",
"to",
"an",
"event",
"for",
"one",
"event",
"only"
] | 0370c38ebb8c7917cfd3894263d734aefc2d3d29 | https://github.com/LeisureLink/magicbus/blob/0370c38ebb8c7917cfd3894263d734aefc2d3d29/lib/event-dispatcher.js#L57-L74 |
41,910 | arthmoeros/rik-health | src/health-loader.js | setupHealth | function setupHealth(expressRouter, baseURI, dependenciesDef, logger) {
if (typeof (dependenciesDef) === 'string') {
if (!dependenciesDef.startsWith('/')) {
dependenciesDef = `${process.cwd()}/${dependenciesDef}`;
}
if (!fs.existsSync(dependenciesDef)) {
throw new Error(`Health dependencies file doesn't exists -> ${dependenciesDef}`);
}
if (!dependenciesDef.endsWith('.yml') || !dependenciesDef.endsWith('.yaml')) {
throw new Error(`Health dependencies file is not a YAML file -> ${dependenciesDef}`);
}
dependenciesDef = jsYaml.load(fs.readFileSync(dependenciesDef));
}
expressRouter.get(`/${baseURI}/health`, setupHealthHandler(dependenciesDef, logger));
logger.info(`RIK_HEALTH: Setup a Healthcheck endpoint at '/${baseURI}/health'`);
} | javascript | function setupHealth(expressRouter, baseURI, dependenciesDef, logger) {
if (typeof (dependenciesDef) === 'string') {
if (!dependenciesDef.startsWith('/')) {
dependenciesDef = `${process.cwd()}/${dependenciesDef}`;
}
if (!fs.existsSync(dependenciesDef)) {
throw new Error(`Health dependencies file doesn't exists -> ${dependenciesDef}`);
}
if (!dependenciesDef.endsWith('.yml') || !dependenciesDef.endsWith('.yaml')) {
throw new Error(`Health dependencies file is not a YAML file -> ${dependenciesDef}`);
}
dependenciesDef = jsYaml.load(fs.readFileSync(dependenciesDef));
}
expressRouter.get(`/${baseURI}/health`, setupHealthHandler(dependenciesDef, logger));
logger.info(`RIK_HEALTH: Setup a Healthcheck endpoint at '/${baseURI}/health'`);
} | [
"function",
"setupHealth",
"(",
"expressRouter",
",",
"baseURI",
",",
"dependenciesDef",
",",
"logger",
")",
"{",
"if",
"(",
"typeof",
"(",
"dependenciesDef",
")",
"===",
"'string'",
")",
"{",
"if",
"(",
"!",
"dependenciesDef",
".",
"startsWith",
"(",
"'/'",... | Setup a healthcheck endpoint in the specified Router
@param {express.Router} expressRouter Express Router reference
@param {string} baseURI Base URI where to setup a health endpoint
@param {(any|string)} dependenciesDef dependencies to check (can be an object or a yml file name)
@param {*} logger Logger object that must implement the *info, warn and error* methods | [
"Setup",
"a",
"healthcheck",
"endpoint",
"in",
"the",
"specified",
"Router"
] | ef619216f440c3c8efa7104fc59499c7bf6d174d | https://github.com/arthmoeros/rik-health/blob/ef619216f440c3c8efa7104fc59499c7bf6d174d/src/health-loader.js#L17-L32 |
41,911 | Mammut-FE/nejm | src/util/placeholder/platform/holder.patch.js | function(_id){
var _input = _e._$get(_id);
_cache[_id] = 2;
if (!!_input.value) return;
_e._$setStyle(
_e._$wrapInline(_input,_ropt),
'display','none'
);
} | javascript | function(_id){
var _input = _e._$get(_id);
_cache[_id] = 2;
if (!!_input.value) return;
_e._$setStyle(
_e._$wrapInline(_input,_ropt),
'display','none'
);
} | [
"function",
"(",
"_id",
")",
"{",
"var",
"_input",
"=",
"_e",
".",
"_$get",
"(",
"_id",
")",
";",
"_cache",
"[",
"_id",
"]",
"=",
"2",
";",
"if",
"(",
"!",
"!",
"_input",
".",
"value",
")",
"return",
";",
"_e",
".",
"_$setStyle",
"(",
"_e",
"... | input foucs hide placeholder | [
"input",
"foucs",
"hide",
"placeholder"
] | dfc09ac66a8d67620a7aea65e34d8a179976b3fb | https://github.com/Mammut-FE/nejm/blob/dfc09ac66a8d67620a7aea65e34d8a179976b3fb/src/util/placeholder/platform/holder.patch.js#L30-L38 | |
41,912 | Mammut-FE/nejm | src/util/placeholder/platform/holder.patch.js | function(_input,_clazz){
var _id = _e._$id(_input),
_label = _e._$wrapInline(_input,{
tag:'label',
clazz:_clazz,
nid:_ropt.nid
});
_label.htmlFor = _id;
var _text = _e._$attr(_input,'placeholder')||'';
_label.innerText = _text=='null'?'':_text;
var _height = _input.offsetHeight+'px';
_e._$style(_label,{
left:0,
// width:_input.offsetWidth+'px',
// height:_height,lineHeight:_height,
display:!_input.value?'':'none'
});
} | javascript | function(_input,_clazz){
var _id = _e._$id(_input),
_label = _e._$wrapInline(_input,{
tag:'label',
clazz:_clazz,
nid:_ropt.nid
});
_label.htmlFor = _id;
var _text = _e._$attr(_input,'placeholder')||'';
_label.innerText = _text=='null'?'':_text;
var _height = _input.offsetHeight+'px';
_e._$style(_label,{
left:0,
// width:_input.offsetWidth+'px',
// height:_height,lineHeight:_height,
display:!_input.value?'':'none'
});
} | [
"function",
"(",
"_input",
",",
"_clazz",
")",
"{",
"var",
"_id",
"=",
"_e",
".",
"_$id",
"(",
"_input",
")",
",",
"_label",
"=",
"_e",
".",
"_$wrapInline",
"(",
"_input",
",",
"{",
"tag",
":",
"'label'",
",",
"clazz",
":",
"_clazz",
",",
"nid",
... | wrapper input control | [
"wrapper",
"input",
"control"
] | dfc09ac66a8d67620a7aea65e34d8a179976b3fb | https://github.com/Mammut-FE/nejm/blob/dfc09ac66a8d67620a7aea65e34d8a179976b3fb/src/util/placeholder/platform/holder.patch.js#L59-L76 | |
41,913 | atsid/circuits-js | gulpfile.js | inc | function inc(importance) {
var git = require('gulp-git'),
bump = require('gulp-bump'),
filter = require('gulp-filter'),
tag_version = require('gulp-tag-version');
// get all the files to bump version in
return gulp.src(['./package.json', './bower.json'])
// bump the version number in those files
.pipe(bump({type: importance}))
// save it back to filesystem
.pipe(gulp.dest('./'))
// commit the changed version number
.pipe(git.commit('bumps package version'))
// read only one file to get the version number
.pipe(filter('package.json'))
// **tag it in the repository**
.pipe(tag_version());
} | javascript | function inc(importance) {
var git = require('gulp-git'),
bump = require('gulp-bump'),
filter = require('gulp-filter'),
tag_version = require('gulp-tag-version');
// get all the files to bump version in
return gulp.src(['./package.json', './bower.json'])
// bump the version number in those files
.pipe(bump({type: importance}))
// save it back to filesystem
.pipe(gulp.dest('./'))
// commit the changed version number
.pipe(git.commit('bumps package version'))
// read only one file to get the version number
.pipe(filter('package.json'))
// **tag it in the repository**
.pipe(tag_version());
} | [
"function",
"inc",
"(",
"importance",
")",
"{",
"var",
"git",
"=",
"require",
"(",
"'gulp-git'",
")",
",",
"bump",
"=",
"require",
"(",
"'gulp-bump'",
")",
",",
"filter",
"=",
"require",
"(",
"'gulp-filter'",
")",
",",
"tag_version",
"=",
"require",
"(",... | Versioning tasks
Increments a version value within the package json and bower json | [
"Versioning",
"tasks",
"Increments",
"a",
"version",
"value",
"within",
"the",
"package",
"json",
"and",
"bower",
"json"
] | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/gulpfile.js#L54-L73 |
41,914 | LeisureLink/magicbus | lib/binder.js | Binder | function Binder(topology, logger) {
assert.object(topology, 'connectionInfo');
assert.object(logger, 'logger');
/**
* Ensures the topology is created for a route
* @private
* @param {Object} route - the route
* @returns {Promise} a promise that is fulfilled with the resulting topology names after the topology has been created
*/
const createTopology = (route) => {
logger.silly(`Asserting topology for route ${route.name}`);
return route.pattern.createTopology(topology, route.serviceDomainName, route.appName, route.name);
};
/**
* Bind a publishing route to a consuming route
*
* @public
* @method
* @param {Object} publishingRoute - exchange route (required)
* @param {Object} consumingRoute - consuming route (required)
* @param {Object} options - binding configuration (required)
* @param {String} options.pattern - routing pattern (ex: "#")
* @returns {Promise} a promise that is fulfilled when the bind is finished
*/
const bind = (publishingRoute, consumingRoute, options) => {
let exchangeName;
let queueName;
return createTopology(publishingRoute)
.then((topologyNames) => {
exchangeName = topologyNames.exchangeName;
return createTopology(consumingRoute);
}).then((topologyNames) => {
queueName = topologyNames.queueName;
logger.info('Binding "' + exchangeName + '" to "' + queueName + '" with pattern "' + options.pattern + '"');
return topology.createBinding({
source: exchangeName,
target: queueName,
queue: true,
keys: [options.pattern]
});
});
};
return { bind: bind };
} | javascript | function Binder(topology, logger) {
assert.object(topology, 'connectionInfo');
assert.object(logger, 'logger');
/**
* Ensures the topology is created for a route
* @private
* @param {Object} route - the route
* @returns {Promise} a promise that is fulfilled with the resulting topology names after the topology has been created
*/
const createTopology = (route) => {
logger.silly(`Asserting topology for route ${route.name}`);
return route.pattern.createTopology(topology, route.serviceDomainName, route.appName, route.name);
};
/**
* Bind a publishing route to a consuming route
*
* @public
* @method
* @param {Object} publishingRoute - exchange route (required)
* @param {Object} consumingRoute - consuming route (required)
* @param {Object} options - binding configuration (required)
* @param {String} options.pattern - routing pattern (ex: "#")
* @returns {Promise} a promise that is fulfilled when the bind is finished
*/
const bind = (publishingRoute, consumingRoute, options) => {
let exchangeName;
let queueName;
return createTopology(publishingRoute)
.then((topologyNames) => {
exchangeName = topologyNames.exchangeName;
return createTopology(consumingRoute);
}).then((topologyNames) => {
queueName = topologyNames.queueName;
logger.info('Binding "' + exchangeName + '" to "' + queueName + '" with pattern "' + options.pattern + '"');
return topology.createBinding({
source: exchangeName,
target: queueName,
queue: true,
keys: [options.pattern]
});
});
};
return { bind: bind };
} | [
"function",
"Binder",
"(",
"topology",
",",
"logger",
")",
"{",
"assert",
".",
"object",
"(",
"topology",
",",
"'connectionInfo'",
")",
";",
"assert",
".",
"object",
"(",
"logger",
",",
"'logger'",
")",
";",
"/**\n * Ensures the topology is created for a route\n... | Creates a binder which can be used to bind a publishing route to a consuming route, mainly for use across service domains
@public
@constructor
@param {Object} topology - connected rabbitmq topology
@param {Object} logger - the logger | [
"Creates",
"a",
"binder",
"which",
"can",
"be",
"used",
"to",
"bind",
"a",
"publishing",
"route",
"to",
"a",
"consuming",
"route",
"mainly",
"for",
"use",
"across",
"service",
"domains"
] | 0370c38ebb8c7917cfd3894263d734aefc2d3d29 | https://github.com/LeisureLink/magicbus/blob/0370c38ebb8c7917cfd3894263d734aefc2d3d29/lib/binder.js#L13-L60 |
41,915 | cafjs/caf_platform | lib/cron_security.js | function() {
$._.$.log && $._.$.log.debug('Cron ' + spec.name + ' waking up');
var cb0 = function(err) {
if (err) {
$._.$.log && $._.$.log.debug('pulser_cron ' +
myUtils.errToPrettyStr(err));
} else {
$._.$.log && $._.$.log.debug('security pulsing done.');
}
};
if ($._.$.security && $._.$.security.__ca_pulse__) {
$._.$.security.__ca_pulse__(cb0);
}
} | javascript | function() {
$._.$.log && $._.$.log.debug('Cron ' + spec.name + ' waking up');
var cb0 = function(err) {
if (err) {
$._.$.log && $._.$.log.debug('pulser_cron ' +
myUtils.errToPrettyStr(err));
} else {
$._.$.log && $._.$.log.debug('security pulsing done.');
}
};
if ($._.$.security && $._.$.security.__ca_pulse__) {
$._.$.security.__ca_pulse__(cb0);
}
} | [
"function",
"(",
")",
"{",
"$",
".",
"_",
".",
"$",
".",
"log",
"&&",
"$",
".",
"_",
".",
"$",
".",
"log",
".",
"debug",
"(",
"'Cron '",
"+",
"spec",
".",
"name",
"+",
"' waking up'",
")",
";",
"var",
"cb0",
"=",
"function",
"(",
"err",
")",
... | this function is bound as a method of 'that' | [
"this",
"function",
"is",
"bound",
"as",
"a",
"method",
"of",
"that"
] | 5d7ce3410f631167ca09ee495c4df7d026b0361e | https://github.com/cafjs/caf_platform/blob/5d7ce3410f631167ca09ee495c4df7d026b0361e/lib/cron_security.js#L37-L50 | |
41,916 | atsid/circuits-js | js/ZypSMDReader.js | resolveExtensions | function resolveExtensions(schema) {
var xprops, props;
xprops = getExtendedProperties(schema, []);
//unwind the property stack so that the earliest gets inheritance link
schema.properties = schema.properties || {};
function copyprop(item) { //util to get around jslint complaints about doing this directly in loop
schema.properties[item.key] = item.val;
}
while (xprops.length > 0) {
props = xprops.pop();
props.forEach(copyprop);
}
} | javascript | function resolveExtensions(schema) {
var xprops, props;
xprops = getExtendedProperties(schema, []);
//unwind the property stack so that the earliest gets inheritance link
schema.properties = schema.properties || {};
function copyprop(item) { //util to get around jslint complaints about doing this directly in loop
schema.properties[item.key] = item.val;
}
while (xprops.length > 0) {
props = xprops.pop();
props.forEach(copyprop);
}
} | [
"function",
"resolveExtensions",
"(",
"schema",
")",
"{",
"var",
"xprops",
",",
"props",
";",
"xprops",
"=",
"getExtendedProperties",
"(",
"schema",
",",
"[",
"]",
")",
";",
"//unwind the property stack so that the earliest gets inheritance link\r",
"schema",
".",
"pr... | looks in JSONSchema objects for "extends" and copies properties to children | [
"looks",
"in",
"JSONSchema",
"objects",
"for",
"extends",
"and",
"copies",
"properties",
"to",
"children"
] | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/ZypSMDReader.js#L89-L105 |
41,917 | atsid/circuits-js | js/ZypSMDReader.js | resolveExtendedParameters | function resolveExtendedParameters(obj) {
// assume all references are resolved, just copy parameters down the
// inheritence chain. If I am derived check base first.
if (obj["extends"]) {
resolveExtendedParameters(obj["extends"]);
obj.parameters = obj.parameters || [];
obj.parameters = obj.parameters.concat(obj["extends"].parameters);
}
} | javascript | function resolveExtendedParameters(obj) {
// assume all references are resolved, just copy parameters down the
// inheritence chain. If I am derived check base first.
if (obj["extends"]) {
resolveExtendedParameters(obj["extends"]);
obj.parameters = obj.parameters || [];
obj.parameters = obj.parameters.concat(obj["extends"].parameters);
}
} | [
"function",
"resolveExtendedParameters",
"(",
"obj",
")",
"{",
"// assume all references are resolved, just copy parameters down the\r",
"// inheritence chain. If I am derived check base first.\r",
"if",
"(",
"obj",
"[",
"\"extends\"",
"]",
")",
"{",
"resolveExtendedParameters",
"(... | mix-in parameters for extended schemas | [
"mix",
"-",
"in",
"parameters",
"for",
"extended",
"schemas"
] | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/ZypSMDReader.js#L108-L117 |
41,918 | atsid/circuits-js | js/ZypSMDReader.js | resolveProperties | function resolveProperties(schema) {
logger.debug("Resolving sub-properties for " + schema.id);
// resolve inherited global parameters
resolveExtendedParameters(schema);
Object.keys(schema.services || {}).forEach(function (key) {
var value = schema.services[key];
//value.target = value.target ? schema.target + value.target : schema.target; //TODO: should this build concat paths? that is currently handled in getServiceUrl function
value.returns = value.returns || schema.returns;
value.transport = value.transport || schema.transport;
value.contentType = value.contentType || schema.contentType;
value.envelope = value.envelope || schema.envelope || "URL";
value.description = value.description || "";
if (value.returns) {
resolveExtensions(value.returns);
}
if (value.parameters) {
value.parameters.forEach(function (item) {
item.envelope = item.envelope || value.envelope;
item.description = item.description || "";
});
}
var ext = value["extends"];
if (ext) {
//resolution hasn't been completed or extends object isn't proper JSONSchema
if (!ext.id) {
throw new Error("Parent schema for method [" + key + "] in schema " + schema.id + " is invalid.");
}
//TODO: resolveExtensions for params object properties? not really needed yet (the name is fine for now...)
if (!value.parameters) {
value.parameters = ext.parameters;
} else {
value.parameters = value.parameters.concat(ext.parameters);
}
}
});
if (!schema.tag) {
schema.tag = {};
}
schema.tag.resolved = true;
schema.resolvedProperties = true;
} | javascript | function resolveProperties(schema) {
logger.debug("Resolving sub-properties for " + schema.id);
// resolve inherited global parameters
resolveExtendedParameters(schema);
Object.keys(schema.services || {}).forEach(function (key) {
var value = schema.services[key];
//value.target = value.target ? schema.target + value.target : schema.target; //TODO: should this build concat paths? that is currently handled in getServiceUrl function
value.returns = value.returns || schema.returns;
value.transport = value.transport || schema.transport;
value.contentType = value.contentType || schema.contentType;
value.envelope = value.envelope || schema.envelope || "URL";
value.description = value.description || "";
if (value.returns) {
resolveExtensions(value.returns);
}
if (value.parameters) {
value.parameters.forEach(function (item) {
item.envelope = item.envelope || value.envelope;
item.description = item.description || "";
});
}
var ext = value["extends"];
if (ext) {
//resolution hasn't been completed or extends object isn't proper JSONSchema
if (!ext.id) {
throw new Error("Parent schema for method [" + key + "] in schema " + schema.id + " is invalid.");
}
//TODO: resolveExtensions for params object properties? not really needed yet (the name is fine for now...)
if (!value.parameters) {
value.parameters = ext.parameters;
} else {
value.parameters = value.parameters.concat(ext.parameters);
}
}
});
if (!schema.tag) {
schema.tag = {};
}
schema.tag.resolved = true;
schema.resolvedProperties = true;
} | [
"function",
"resolveProperties",
"(",
"schema",
")",
"{",
"logger",
".",
"debug",
"(",
"\"Resolving sub-properties for \"",
"+",
"schema",
".",
"id",
")",
";",
"// resolve inherited global parameters\r",
"resolveExtendedParameters",
"(",
"schema",
")",
";",
"Object",
... | copies properties from parent as defaults, as well as extensions for params | [
"copies",
"properties",
"from",
"parent",
"as",
"defaults",
"as",
"well",
"as",
"extensions",
"for",
"params"
] | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/ZypSMDReader.js#L120-L171 |
41,919 | atsid/circuits-js | js/ZypSMDReader.js | function () {
var names = [];
Object.keys(this.smd.services || {}).forEach(function (serviceName) {
names.push(serviceName);
});
return names;
} | javascript | function () {
var names = [];
Object.keys(this.smd.services || {}).forEach(function (serviceName) {
names.push(serviceName);
});
return names;
} | [
"function",
"(",
")",
"{",
"var",
"names",
"=",
"[",
"]",
";",
"Object",
".",
"keys",
"(",
"this",
".",
"smd",
".",
"services",
"||",
"{",
"}",
")",
".",
"forEach",
"(",
"function",
"(",
"serviceName",
")",
"{",
"names",
".",
"push",
"(",
"servic... | Gets a list of the service method names defined by the SMD. | [
"Gets",
"a",
"list",
"of",
"the",
"service",
"method",
"names",
"defined",
"by",
"the",
"SMD",
"."
] | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/ZypSMDReader.js#L234-L242 | |
41,920 | atsid/circuits-js | js/ZypSMDReader.js | function () {
var services = [], smdServices = this.smd.services;
Object.keys(smdServices || []).forEach(function (serviceName) {
services.push(smdServices[serviceName]);
});
return services;
} | javascript | function () {
var services = [], smdServices = this.smd.services;
Object.keys(smdServices || []).forEach(function (serviceName) {
services.push(smdServices[serviceName]);
});
return services;
} | [
"function",
"(",
")",
"{",
"var",
"services",
"=",
"[",
"]",
",",
"smdServices",
"=",
"this",
".",
"smd",
".",
"services",
";",
"Object",
".",
"keys",
"(",
"smdServices",
"||",
"[",
"]",
")",
".",
"forEach",
"(",
"function",
"(",
"serviceName",
")",
... | Gets list of service methods in the SMD. These are the actual schema objects. | [
"Gets",
"list",
"of",
"service",
"methods",
"in",
"the",
"SMD",
".",
"These",
"are",
"the",
"actual",
"schema",
"objects",
"."
] | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/ZypSMDReader.js#L247-L255 | |
41,921 | atsid/circuits-js | js/ZypSMDReader.js | function (methodName) {
var names = [], params = this.getParameters(methodName);
params.forEach(function (param) {
names.push(param.name);
});
return names;
} | javascript | function (methodName) {
var names = [], params = this.getParameters(methodName);
params.forEach(function (param) {
names.push(param.name);
});
return names;
} | [
"function",
"(",
"methodName",
")",
"{",
"var",
"names",
"=",
"[",
"]",
",",
"params",
"=",
"this",
".",
"getParameters",
"(",
"methodName",
")",
";",
"params",
".",
"forEach",
"(",
"function",
"(",
"param",
")",
"{",
"names",
".",
"push",
"(",
"para... | Gets a list of parameter names for a specified service. | [
"Gets",
"a",
"list",
"of",
"parameter",
"names",
"for",
"a",
"specified",
"service",
"."
] | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/ZypSMDReader.js#L272-L280 | |
41,922 | atsid/circuits-js | js/ZypSMDReader.js | function (methodName) {
var parameters = this.smd.parameters || [];
parameters = parameters.concat(this.smd.services[methodName].parameters || []);
return parameters;
} | javascript | function (methodName) {
var parameters = this.smd.parameters || [];
parameters = parameters.concat(this.smd.services[methodName].parameters || []);
return parameters;
} | [
"function",
"(",
"methodName",
")",
"{",
"var",
"parameters",
"=",
"this",
".",
"smd",
".",
"parameters",
"||",
"[",
"]",
";",
"parameters",
"=",
"parameters",
".",
"concat",
"(",
"this",
".",
"smd",
".",
"services",
"[",
"methodName",
"]",
".",
"param... | Gets a list of parameters for a specified service. These are the actual objects. | [
"Gets",
"a",
"list",
"of",
"parameters",
"for",
"a",
"specified",
"service",
".",
"These",
"are",
"the",
"actual",
"objects",
"."
] | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/ZypSMDReader.js#L285-L291 | |
41,923 | atsid/circuits-js | js/ZypSMDReader.js | function (methodName, argName) {
var required = this.findParameter(methodName, argName).required;
//default is false, so if "required" is undefined, return false anyway
if (required) {
return true;
}
return false;
} | javascript | function (methodName, argName) {
var required = this.findParameter(methodName, argName).required;
//default is false, so if "required" is undefined, return false anyway
if (required) {
return true;
}
return false;
} | [
"function",
"(",
"methodName",
",",
"argName",
")",
"{",
"var",
"required",
"=",
"this",
".",
"findParameter",
"(",
"methodName",
",",
"argName",
")",
".",
"required",
";",
"//default is false, so if \"required\" is undefined, return false anyway\r",
"if",
"(",
"requi... | Indicates whether the specified argument on a service method is required or not. | [
"Indicates",
"whether",
"the",
"specified",
"argument",
"on",
"a",
"service",
"method",
"is",
"required",
"or",
"not",
"."
] | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/ZypSMDReader.js#L296-L303 | |
41,924 | atsid/circuits-js | js/ZypSMDReader.js | function (methodName, args) {
var service = this.smd.services[methodName],
basePath = this.getRootPath(),
url,
parameters = this.enumerateParameters(service);
//if no service target, it sits at the root
url = basePath + (service.target ? "/" + service.target : "");
//replace path params where required
url = this.replacePathParamsInUrl(url, parameters.PATH, args);
//add any query params
url = this.addQueryParamsToUrl(url, parameters.URL, args);
return url;
} | javascript | function (methodName, args) {
var service = this.smd.services[methodName],
basePath = this.getRootPath(),
url,
parameters = this.enumerateParameters(service);
//if no service target, it sits at the root
url = basePath + (service.target ? "/" + service.target : "");
//replace path params where required
url = this.replacePathParamsInUrl(url, parameters.PATH, args);
//add any query params
url = this.addQueryParamsToUrl(url, parameters.URL, args);
return url;
} | [
"function",
"(",
"methodName",
",",
"args",
")",
"{",
"var",
"service",
"=",
"this",
".",
"smd",
".",
"services",
"[",
"methodName",
"]",
",",
"basePath",
"=",
"this",
".",
"getRootPath",
"(",
")",
",",
"url",
",",
"parameters",
"=",
"this",
".",
"en... | For the specified service, map the args object to the target + parameters to
get a full, functional URL. | [
"For",
"the",
"specified",
"service",
"map",
"the",
"args",
"object",
"to",
"the",
"target",
"+",
"parameters",
"to",
"get",
"a",
"full",
"functional",
"URL",
"."
] | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/ZypSMDReader.js#L309-L327 | |
41,925 | atsid/circuits-js | js/ZypSMDReader.js | function (methodName) {
var params = this.getParameters(methodName),
ret;
params.forEach(function (param) {
if (param && (param.envelope === 'JSON' ||
param.envelope === 'ENTITY')) {
ret = param;
}
});
return ret;
} | javascript | function (methodName) {
var params = this.getParameters(methodName),
ret;
params.forEach(function (param) {
if (param && (param.envelope === 'JSON' ||
param.envelope === 'ENTITY')) {
ret = param;
}
});
return ret;
} | [
"function",
"(",
"methodName",
")",
"{",
"var",
"params",
"=",
"this",
".",
"getParameters",
"(",
"methodName",
")",
",",
"ret",
";",
"params",
".",
"forEach",
"(",
"function",
"(",
"param",
")",
"{",
"if",
"(",
"param",
"&&",
"(",
"param",
".",
"env... | Returns the parameter associated with the payload of a request if there is one.
@param methodName - the service method to return a payload schema for.
@return the payload parameter or undefined | [
"Returns",
"the",
"parameter",
"associated",
"with",
"the",
"payload",
"of",
"a",
"request",
"if",
"there",
"is",
"one",
"."
] | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/ZypSMDReader.js#L436-L446 | |
41,926 | atsid/circuits-js | js/ZypSMDReader.js | function (methodName) {
var smd = this.smd,
method = smd.services[methodName],
payloadName = (method && method.payload) || smd.payload;
return payloadName;
} | javascript | function (methodName) {
var smd = this.smd,
method = smd.services[methodName],
payloadName = (method && method.payload) || smd.payload;
return payloadName;
} | [
"function",
"(",
"methodName",
")",
"{",
"var",
"smd",
"=",
"this",
".",
"smd",
",",
"method",
"=",
"smd",
".",
"services",
"[",
"methodName",
"]",
",",
"payloadName",
"=",
"(",
"method",
"&&",
"method",
".",
"payload",
")",
"||",
"smd",
".",
"payloa... | Returns the name of the primary payload object.
@param methodName - the service method to return a payload schema for.
If the "payload" field is not defined on the method, check the service root. | [
"Returns",
"the",
"name",
"of",
"the",
"primary",
"payload",
"object",
"."
] | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/ZypSMDReader.js#L464-L471 | |
41,927 | atsid/circuits-js | js/ZypSMDReader.js | function (methodName) {
var response = this.getResponseSchema(methodName),
payloadName = this.getResponsePayloadName(methodName),
isList = false;
if (response.type !== "null") {
if ((payloadName && response.properties[payloadName] && response.properties[payloadName].type === "array") ||
(response.type && response.type === "array")) {
isList = true;
}
}
return isList;
} | javascript | function (methodName) {
var response = this.getResponseSchema(methodName),
payloadName = this.getResponsePayloadName(methodName),
isList = false;
if (response.type !== "null") {
if ((payloadName && response.properties[payloadName] && response.properties[payloadName].type === "array") ||
(response.type && response.type === "array")) {
isList = true;
}
}
return isList;
} | [
"function",
"(",
"methodName",
")",
"{",
"var",
"response",
"=",
"this",
".",
"getResponseSchema",
"(",
"methodName",
")",
",",
"payloadName",
"=",
"this",
".",
"getResponsePayloadName",
"(",
"methodName",
")",
",",
"isList",
"=",
"false",
";",
"if",
"(",
... | Returns whether the primary payload is a list, by checking for "array" type on the SMD.
Defaults to false if return type is JSONSchema "null" primitive type. | [
"Returns",
"whether",
"the",
"primary",
"payload",
"is",
"a",
"list",
"by",
"checking",
"for",
"array",
"type",
"on",
"the",
"SMD",
".",
"Defaults",
"to",
"false",
"if",
"return",
"type",
"is",
"JSONSchema",
"null",
"primitive",
"type",
"."
] | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/ZypSMDReader.js#L489-L502 | |
41,928 | LaxarJS/laxar-tooling | src/artifact_listing.js | defaultAssets | function defaultAssets( { name, category, descriptor } ) {
switch( category ) {
case 'themes':
return {
assetUrls: [ descriptor.styleSource || 'css/theme.css' ]
};
case 'layouts':
case 'widgets':
case 'controls':
return {
assetsForTheme: [ descriptor.templateSource || `${name}.html` ],
assetUrlsForTheme: [ descriptor.styleSource || `css/${name}.css` ]
};
default:
return {};
}
} | javascript | function defaultAssets( { name, category, descriptor } ) {
switch( category ) {
case 'themes':
return {
assetUrls: [ descriptor.styleSource || 'css/theme.css' ]
};
case 'layouts':
case 'widgets':
case 'controls':
return {
assetsForTheme: [ descriptor.templateSource || `${name}.html` ],
assetUrlsForTheme: [ descriptor.styleSource || `css/${name}.css` ]
};
default:
return {};
}
} | [
"function",
"defaultAssets",
"(",
"{",
"name",
",",
"category",
",",
"descriptor",
"}",
")",
"{",
"switch",
"(",
"category",
")",
"{",
"case",
"'themes'",
":",
"return",
"{",
"assetUrls",
":",
"[",
"descriptor",
".",
"styleSource",
"||",
"'css/theme.css'",
... | Return the default assets for the given artifact, determined by it's type
and descriptor's `styleSource` and `templateSource` attributes.
@param {Object} artifact an artifact created by the {@link ArtifactCollector}
@return {Object} a partial descriptor containing the artifact's default assets | [
"Return",
"the",
"default",
"assets",
"for",
"the",
"given",
"artifact",
"determined",
"by",
"it",
"s",
"type",
"and",
"descriptor",
"s",
"styleSource",
"and",
"templateSource",
"attributes",
"."
] | 1c4a221994f342ec03a98b68533c4de77ccfeec6 | https://github.com/LaxarJS/laxar-tooling/blob/1c4a221994f342ec03a98b68533c4de77ccfeec6/src/artifact_listing.js#L22-L38 |
41,929 | LaxarJS/laxar-tooling | src/artifact_listing.js | buildAssets | function buildAssets( artifact, themes = [] ) {
const { descriptor } = artifact;
const {
assets,
assetUrls,
assetsForTheme,
assetUrlsForTheme
} = extendAssets( descriptor, defaultAssets( artifact ) );
return Promise.all( [
assetResolver
.resolveAssets( artifact, [ ...assets, ...assetUrls ] )
.then( requireAssets( requireFile, assets, assetUrls ) ),
themes.length <= 0 ? {} : assetResolver
.resolveThemedAssets( artifact, themes, [ ...assetsForTheme, ...assetUrlsForTheme ] )
.then( requireAssets( requireFile, assetsForTheme, assetUrlsForTheme ) )
.then( assets => ( { [ themes[ 0 ].name ]: assets } ) )
] ).then( merge );
} | javascript | function buildAssets( artifact, themes = [] ) {
const { descriptor } = artifact;
const {
assets,
assetUrls,
assetsForTheme,
assetUrlsForTheme
} = extendAssets( descriptor, defaultAssets( artifact ) );
return Promise.all( [
assetResolver
.resolveAssets( artifact, [ ...assets, ...assetUrls ] )
.then( requireAssets( requireFile, assets, assetUrls ) ),
themes.length <= 0 ? {} : assetResolver
.resolveThemedAssets( artifact, themes, [ ...assetsForTheme, ...assetUrlsForTheme ] )
.then( requireAssets( requireFile, assetsForTheme, assetUrlsForTheme ) )
.then( assets => ( { [ themes[ 0 ].name ]: assets } ) )
] ).then( merge );
} | [
"function",
"buildAssets",
"(",
"artifact",
",",
"themes",
"=",
"[",
"]",
")",
"{",
"const",
"{",
"descriptor",
"}",
"=",
"artifact",
";",
"const",
"{",
"assets",
",",
"assetUrls",
",",
"assetsForTheme",
",",
"assetUrlsForTheme",
"}",
"=",
"extendAssets",
... | Build the assets object for an artifact and the given themes.
@memberOf ArtifactListing
@param {Object} artifact
the artifact to generate the asset listing for
@param {Array<Object>} themes
the themes to use for resolving themed artifacts
@return {Object}
the asset listing, containing sub-listings for each theme and entries
for each (available) asset, pointing either to a URL or including
the asset's raw content | [
"Build",
"the",
"assets",
"object",
"for",
"an",
"artifact",
"and",
"the",
"given",
"themes",
"."
] | 1c4a221994f342ec03a98b68533c4de77ccfeec6 | https://github.com/LaxarJS/laxar-tooling/blob/1c4a221994f342ec03a98b68533c4de77ccfeec6/src/artifact_listing.js#L233-L251 |
41,930 | cafjs/caf_cli | lib/Session.js | function() {
var cb = function(err, meta) {
if (err) {
var error =
new Error('BUG: __external_ca_touch__ ' +
'should not return app error');
error['err'] = err;
that.close(error);
} else {
addMethods(meta);
addBackchannel();
timeout = startTimeout();
if (listeners.open) {
listeners.open();
}
}
};
if (firstTime) {
firstTime = false;
queues.rpc.remoteInvoke(webSocket, '__external_ca_touch__', [],
[cb]);
} else {
retry();
}
} | javascript | function() {
var cb = function(err, meta) {
if (err) {
var error =
new Error('BUG: __external_ca_touch__ ' +
'should not return app error');
error['err'] = err;
that.close(error);
} else {
addMethods(meta);
addBackchannel();
timeout = startTimeout();
if (listeners.open) {
listeners.open();
}
}
};
if (firstTime) {
firstTime = false;
queues.rpc.remoteInvoke(webSocket, '__external_ca_touch__', [],
[cb]);
} else {
retry();
}
} | [
"function",
"(",
")",
"{",
"var",
"cb",
"=",
"function",
"(",
"err",
",",
"meta",
")",
"{",
"if",
"(",
"err",
")",
"{",
"var",
"error",
"=",
"new",
"Error",
"(",
"'BUG: __external_ca_touch__ '",
"+",
"'should not return app error'",
")",
";",
"error",
"[... | Internal WebSocket event handlers that delegate to external ones. | [
"Internal",
"WebSocket",
"event",
"handlers",
"that",
"delegate",
"to",
"external",
"ones",
"."
] | cec279882068bc04ee0ee0ca278bb29bd9eefd0f | https://github.com/cafjs/caf_cli/blob/cec279882068bc04ee0ee0ca278bb29bd9eefd0f/lib/Session.js#L413-L437 | |
41,931 | liamray/nexl-engine | nexl-engine/nexl-engine-utils.js | replaceSpecialChars | function replaceSpecialChars(item) {
if (!j79.isString(item)) {
return item;
}
var result = item;
var specialChars = Object.keys(SPECIAL_CHARS_MAP);
for (var index in specialChars) {
result = replaceSpecialChar(result, specialChars[index]);
}
return result;
} | javascript | function replaceSpecialChars(item) {
if (!j79.isString(item)) {
return item;
}
var result = item;
var specialChars = Object.keys(SPECIAL_CHARS_MAP);
for (var index in specialChars) {
result = replaceSpecialChar(result, specialChars[index]);
}
return result;
} | [
"function",
"replaceSpecialChars",
"(",
"item",
")",
"{",
"if",
"(",
"!",
"j79",
".",
"isString",
"(",
"item",
")",
")",
"{",
"return",
"item",
";",
"}",
"var",
"result",
"=",
"item",
";",
"var",
"specialChars",
"=",
"Object",
".",
"keys",
"(",
"SPEC... | string representation of \n, \t characters is replaced with their real value | [
"string",
"representation",
"of",
"\\",
"n",
"\\",
"t",
"characters",
"is",
"replaced",
"with",
"their",
"real",
"value"
] | 47cd168460dbe724626953047b4d3268ba981abf | https://github.com/liamray/nexl-engine/blob/47cd168460dbe724626953047b4d3268ba981abf/nexl-engine/nexl-engine-utils.js#L238-L251 |
41,932 | om-mani-padme-hum/ezobjects | index.js | validateClassConfig | function validateClassConfig(obj) {
/** If configuration is not plain object, throw error */
if ( typeof obj != `object` || obj.constructor.name != `Object` )
throw new Error(`ezobjects.validateClassConfig(): Invalid table configuration argument, must be plain object.`);
/** If configuration has missing or invalid 'className' configuration, throw error */
if ( typeof obj.className !== 'string' || !obj.className.match(/^[A-Za-z_0-9$]+$/) )
throw new Error(`ezobjects.validateClassConfig(): Configuration has missing or invalid 'className', must be string containing characters 'A-Za-z_0-9$'.`);
/** Add properties array if one wasn't set */
if ( !obj.properties )
obj.properties = [];
/** Make sure properties is array */
if ( obj.properties && ( typeof obj.properties != 'object' || obj.properties.constructor.name != 'Array' ) )
throw new Error(`ezobjects.validateClassConfig(): Invalid properties configuration, properties not array.`);
/** Loop through any properties and validate them */
obj.properties.forEach((property) => {
property.className = obj.className;
validatePropertyConfig(property);
});
} | javascript | function validateClassConfig(obj) {
/** If configuration is not plain object, throw error */
if ( typeof obj != `object` || obj.constructor.name != `Object` )
throw new Error(`ezobjects.validateClassConfig(): Invalid table configuration argument, must be plain object.`);
/** If configuration has missing or invalid 'className' configuration, throw error */
if ( typeof obj.className !== 'string' || !obj.className.match(/^[A-Za-z_0-9$]+$/) )
throw new Error(`ezobjects.validateClassConfig(): Configuration has missing or invalid 'className', must be string containing characters 'A-Za-z_0-9$'.`);
/** Add properties array if one wasn't set */
if ( !obj.properties )
obj.properties = [];
/** Make sure properties is array */
if ( obj.properties && ( typeof obj.properties != 'object' || obj.properties.constructor.name != 'Array' ) )
throw new Error(`ezobjects.validateClassConfig(): Invalid properties configuration, properties not array.`);
/** Loop through any properties and validate them */
obj.properties.forEach((property) => {
property.className = obj.className;
validatePropertyConfig(property);
});
} | [
"function",
"validateClassConfig",
"(",
"obj",
")",
"{",
"/** If configuration is not plain object, throw error */",
"if",
"(",
"typeof",
"obj",
"!=",
"`",
"`",
"||",
"obj",
".",
"constructor",
".",
"name",
"!=",
"`",
"`",
")",
"throw",
"new",
"Error",
"(",
"`... | Validate configuration for a class | [
"Validate",
"configuration",
"for",
"a",
"class"
] | 7427695776df8a747c68d5af7844df35d9b30ac2 | https://github.com/om-mani-padme-hum/ezobjects/blob/7427695776df8a747c68d5af7844df35d9b30ac2/index.js#L221-L244 |
41,933 | cafjs/caf_platform | lib/pipeline_main.js | function(req, res) {
return function(err) {
err = err || new Error('wsFinalHandler error');
err.msg = req.body;
var code = json_rpc.ERROR_CODES.methodNotFound;
var error = json_rpc.newSysError(req.body, code,
'Method not found', err);
var response = JSON.stringify(json_rpc.reply(error));
$._.$.log && $._.$.log.trace(response);
res.send(response);
};
} | javascript | function(req, res) {
return function(err) {
err = err || new Error('wsFinalHandler error');
err.msg = req.body;
var code = json_rpc.ERROR_CODES.methodNotFound;
var error = json_rpc.newSysError(req.body, code,
'Method not found', err);
var response = JSON.stringify(json_rpc.reply(error));
$._.$.log && $._.$.log.trace(response);
res.send(response);
};
} | [
"function",
"(",
"req",
",",
"res",
")",
"{",
"return",
"function",
"(",
"err",
")",
"{",
"err",
"=",
"err",
"||",
"new",
"Error",
"(",
"'wsFinalHandler error'",
")",
";",
"err",
".",
"msg",
"=",
"req",
".",
"body",
";",
"var",
"code",
"=",
"json_r... | track connections for fast shutdown | [
"track",
"connections",
"for",
"fast",
"shutdown"
] | 5d7ce3410f631167ca09ee495c4df7d026b0361e | https://github.com/cafjs/caf_platform/blob/5d7ce3410f631167ca09ee495c4df7d026b0361e/lib/pipeline_main.js#L65-L76 | |
41,934 | zazuko/trifid-core | plugins/headers-fix.js | init | function init (router) {
router.use((err, req, res, next) => {
res._headers = res._headers || {}
next(err)
})
} | javascript | function init (router) {
router.use((err, req, res, next) => {
res._headers = res._headers || {}
next(err)
})
} | [
"function",
"init",
"(",
"router",
")",
"{",
"router",
".",
"use",
"(",
"(",
"err",
",",
"req",
",",
"res",
",",
"next",
")",
"=>",
"{",
"res",
".",
"_headers",
"=",
"res",
".",
"_headers",
"||",
"{",
"}",
"next",
"(",
"err",
")",
"}",
")",
"... | workaround for missing headers after hijack
@param router | [
"workaround",
"for",
"missing",
"headers",
"after",
"hijack"
] | 47068ef508971f562e35768d829e15699ce3e19c | https://github.com/zazuko/trifid-core/blob/47068ef508971f562e35768d829e15699ce3e19c/plugins/headers-fix.js#L5-L11 |
41,935 | zazuko/trifid-core | plugins/static-views.js | staticViews | function staticViews (router, options) {
if (!options) {
return
}
Object.keys(options).filter(urlPath => options[urlPath]).forEach((urlPath) => {
const filePath = options[urlPath]
router.get(urlPath, (req, res) => {
res.render(filePath)
})
})
} | javascript | function staticViews (router, options) {
if (!options) {
return
}
Object.keys(options).filter(urlPath => options[urlPath]).forEach((urlPath) => {
const filePath = options[urlPath]
router.get(urlPath, (req, res) => {
res.render(filePath)
})
})
} | [
"function",
"staticViews",
"(",
"router",
",",
"options",
")",
"{",
"if",
"(",
"!",
"options",
")",
"{",
"return",
"}",
"Object",
".",
"keys",
"(",
"options",
")",
".",
"filter",
"(",
"urlPath",
"=>",
"options",
"[",
"urlPath",
"]",
")",
".",
"forEac... | Adds routes for rendering static templates
@param router
@param options | [
"Adds",
"routes",
"for",
"rendering",
"static",
"templates"
] | 47068ef508971f562e35768d829e15699ce3e19c | https://github.com/zazuko/trifid-core/blob/47068ef508971f562e35768d829e15699ce3e19c/plugins/static-views.js#L6-L18 |
41,936 | atsid/circuits-js | js/PluginMatcher.js | function (name, pointcutOrPlugin) {
var method, matchstr;
matchstr = (pointcutOrPlugin && (pointcutOrPlugin.pointcut || pointcutOrPlugin.pattern)) || pointcutOrPlugin;
if ((pointcutOrPlugin && pointcutOrPlugin.pointcut) || typeof (pointcutOrPlugin) === 'string') {
method = this.matchPointcut;
} else {
method = this.matchPattern;
}
return method(name, matchstr);
} | javascript | function (name, pointcutOrPlugin) {
var method, matchstr;
matchstr = (pointcutOrPlugin && (pointcutOrPlugin.pointcut || pointcutOrPlugin.pattern)) || pointcutOrPlugin;
if ((pointcutOrPlugin && pointcutOrPlugin.pointcut) || typeof (pointcutOrPlugin) === 'string') {
method = this.matchPointcut;
} else {
method = this.matchPattern;
}
return method(name, matchstr);
} | [
"function",
"(",
"name",
",",
"pointcutOrPlugin",
")",
"{",
"var",
"method",
",",
"matchstr",
";",
"matchstr",
"=",
"(",
"pointcutOrPlugin",
"&&",
"(",
"pointcutOrPlugin",
".",
"pointcut",
"||",
"pointcutOrPlugin",
".",
"pattern",
")",
")",
"||",
"pointcutOrPl... | Returns a boolean indicating whether the passed in plugin or pointcut matches the given name. If a string is passed
as the second arg it is assumed to be a pointcut. If a plugin object is passed, it is checked for either a
pointcut or a pattern attribute. In either case the method delegates to the matchPointcut or matchPattern method.
@param name - service and method name in dot notation, like "CaseService.readCase".
@param pointcutOrPlugin - pointcut string or plugin for matching against name. | [
"Returns",
"a",
"boolean",
"indicating",
"whether",
"the",
"passed",
"in",
"plugin",
"or",
"pointcut",
"matches",
"the",
"given",
"name",
".",
"If",
"a",
"string",
"is",
"passed",
"as",
"the",
"second",
"arg",
"it",
"is",
"assumed",
"to",
"be",
"a",
"poi... | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/PluginMatcher.js#L41-L52 | |
41,937 | atsid/circuits-js | js/PluginMatcher.js | function (name, pointcut) {
var regexString,
regex,
ret;
pointcut = pointcut || "*.*";
regexString = pointcut.replace(/\./g, "\\.").replace(/\*/g, ".*");
logger.debug("pointcut is: " + pointcut);
//adds word boundaries at either the beginning, end, or both depending on the index of "*" (if any)
//If "*" is not in the string then word boundaries should be added by default
if (pointcut.indexOf("*") !== 0) {
regexString = "\\b" + regexString;
}
if (pointcut.lastIndexOf("*") !== pointcut.length - 1) {
regexString += "\\b";
}
logger.debug("regexString is: " + regexString);
regex = new RegExp(regexString);
logger.debug("PluginMatcher match testing [" + name + "] against regex [" + regexString + "]");
ret = regex.exec(name);
return ret !== null;
} | javascript | function (name, pointcut) {
var regexString,
regex,
ret;
pointcut = pointcut || "*.*";
regexString = pointcut.replace(/\./g, "\\.").replace(/\*/g, ".*");
logger.debug("pointcut is: " + pointcut);
//adds word boundaries at either the beginning, end, or both depending on the index of "*" (if any)
//If "*" is not in the string then word boundaries should be added by default
if (pointcut.indexOf("*") !== 0) {
regexString = "\\b" + regexString;
}
if (pointcut.lastIndexOf("*") !== pointcut.length - 1) {
regexString += "\\b";
}
logger.debug("regexString is: " + regexString);
regex = new RegExp(regexString);
logger.debug("PluginMatcher match testing [" + name + "] against regex [" + regexString + "]");
ret = regex.exec(name);
return ret !== null;
} | [
"function",
"(",
"name",
",",
"pointcut",
")",
"{",
"var",
"regexString",
",",
"regex",
",",
"ret",
";",
"pointcut",
"=",
"pointcut",
"||",
"\"*.*\"",
";",
"regexString",
"=",
"pointcut",
".",
"replace",
"(",
"/",
"\\.",
"/",
"g",
",",
"\"\\\\.\"",
")"... | Returns a boolean indicating whether the passed in plugin's pointcut matches the service and method names provided.
@param name - service and method name in dot notation, like "CaseService.readCase".
@param pointcut - poincut string for matching against names. The pointcut format is "regex-like",
using basic wildcard syntax like common AOP systems. A RegExp is used to match, so normal JS regex symbols can be used, with the following constraints:
1) For simplicity, '*' is automatically replaced with '.*'
2) It is assumed that the pointcut is word-bounded on either side, so developers don't have to worry about grabbing extra characters
3) if the pointcut sent in is null/undefined, it defaults to '*.*'
If "name" contains a wildcard on the method side of the dot notation (e.g. "CaseService.*") then only the first service part of the name is matched
against the service part of the pointcut. | [
"Returns",
"a",
"boolean",
"indicating",
"whether",
"the",
"passed",
"in",
"plugin",
"s",
"pointcut",
"matches",
"the",
"service",
"and",
"method",
"names",
"provided",
"."
] | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/PluginMatcher.js#L66-L94 | |
41,938 | atsid/circuits-js | js/PluginMatcher.js | function (serviceName, methodNames, type, plugins) {
var newPlugins = [];
if (plugins && plugins.length > 0) {
plugins.forEach(function (plugin) {
var match = this.matchingMethodNames(serviceName, methodNames, plugin);
if (match.length && plugin.type === type) {
logger.debug("adding " + plugin.name + " to service only list");
newPlugins.push(plugin);
} else {
logger.debug("not adding " + plugin.name + " to service only list");
}
}, this);
}
return newPlugins;
} | javascript | function (serviceName, methodNames, type, plugins) {
var newPlugins = [];
if (plugins && plugins.length > 0) {
plugins.forEach(function (plugin) {
var match = this.matchingMethodNames(serviceName, methodNames, plugin);
if (match.length && plugin.type === type) {
logger.debug("adding " + plugin.name + " to service only list");
newPlugins.push(plugin);
} else {
logger.debug("not adding " + plugin.name + " to service only list");
}
}, this);
}
return newPlugins;
} | [
"function",
"(",
"serviceName",
",",
"methodNames",
",",
"type",
",",
"plugins",
")",
"{",
"var",
"newPlugins",
"=",
"[",
"]",
";",
"if",
"(",
"plugins",
"&&",
"plugins",
".",
"length",
">",
"0",
")",
"{",
"plugins",
".",
"forEach",
"(",
"function",
... | Returns just the plugins from the given array with pointcuts that match the
any method on a service.
@param serviceName - the name of the service to match against.
@param methodNames - the names of all methods on this service.
@param type - the type of plugin to match.
@param plugins - the array of plugins to use as the domain. | [
"Returns",
"just",
"the",
"plugins",
"from",
"the",
"given",
"array",
"with",
"pointcuts",
"that",
"match",
"the",
"any",
"method",
"on",
"a",
"service",
"."
] | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/PluginMatcher.js#L159-L177 | |
41,939 | atsid/circuits-js | js/PluginMatcher.js | function (serviceName, methodNames, pointCut) {
var fullName, ret = [];
methodNames.forEach(function (name) {
fullName = serviceName + "." + name;
var match = this.match(fullName, pointCut);
if (match) {
ret.push(name);
}
}, this);
return ret;
} | javascript | function (serviceName, methodNames, pointCut) {
var fullName, ret = [];
methodNames.forEach(function (name) {
fullName = serviceName + "." + name;
var match = this.match(fullName, pointCut);
if (match) {
ret.push(name);
}
}, this);
return ret;
} | [
"function",
"(",
"serviceName",
",",
"methodNames",
",",
"pointCut",
")",
"{",
"var",
"fullName",
",",
"ret",
"=",
"[",
"]",
";",
"methodNames",
".",
"forEach",
"(",
"function",
"(",
"name",
")",
"{",
"fullName",
"=",
"serviceName",
"+",
"\".\"",
"+",
... | Returns the method names from the passed array that match the given
pointCut.
@param serviceName - the name of the service to match against.
@param methodNames - array of names to match against.
@param pointCut = the pointcut to match. | [
"Returns",
"the",
"method",
"names",
"from",
"the",
"passed",
"array",
"that",
"match",
"the",
"given",
"pointCut",
"."
] | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/PluginMatcher.js#L187-L199 | |
41,940 | atsid/circuits-js | js/PluginMatcher.js | function (serviceName, methodName, factoryPlugins, servicePlugins, invokePlugins) {
var ret = util.mixin({}, this.defaults), that = this;
Object.keys(ret).forEach(function (key) {
var pf = that.list(serviceName, methodName, key, factoryPlugins),
ps = that.list(serviceName, methodName, key, servicePlugins),
pi = that.list(serviceName, methodName, key, invokePlugins);
ret[key] = [].concat((pf || []), (ps || []), (pi || []));
});
return ret;
} | javascript | function (serviceName, methodName, factoryPlugins, servicePlugins, invokePlugins) {
var ret = util.mixin({}, this.defaults), that = this;
Object.keys(ret).forEach(function (key) {
var pf = that.list(serviceName, methodName, key, factoryPlugins),
ps = that.list(serviceName, methodName, key, servicePlugins),
pi = that.list(serviceName, methodName, key, invokePlugins);
ret[key] = [].concat((pf || []), (ps || []), (pi || []));
});
return ret;
} | [
"function",
"(",
"serviceName",
",",
"methodName",
",",
"factoryPlugins",
",",
"servicePlugins",
",",
"invokePlugins",
")",
"{",
"var",
"ret",
"=",
"util",
".",
"mixin",
"(",
"{",
"}",
",",
"this",
".",
"defaults",
")",
",",
"that",
"=",
"this",
";",
"... | Construct an object containing the arrays of plugins for each phase with precedence and
execution order resolved.
@param {String} serviceName the name of the service to match against.
@param {String} methodName - the name of the method on the service to match against.
@param {Array of circuits.Plugin} factoryPlugins the array of plugins at the factory level.
@param {Array of circuits.Plugin} servicePlugins the array of plugins at the service level.
@param {Array of circuits.Plugin} invokePlugins the array of plugins at the method invocation level.
@return {Object} an object containing an array of plugins for each phase of the service request. | [
"Construct",
"an",
"object",
"containing",
"the",
"arrays",
"of",
"plugins",
"for",
"each",
"phase",
"with",
"precedence",
"and",
"execution",
"order",
"resolved",
"."
] | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/PluginMatcher.js#L213-L225 | |
41,941 | ofidj/fidj | .todo/miapp.tools.sense.js | onWhichEvent | function onWhichEvent(sense, name, nbFinger) {
var prefix = 'Short';
if (sense.hasPaused) prefix = 'Long';
var onEventName = 'on' + prefix + name + nbFinger;
if (a4p.isDefined(sense[onEventName]) && (sense[onEventName] != null)) {
return onEventName;
}
if (sense.options.prefixPriority) {
// the 'Short'/'Long' prefix has priority over the number of fingers : sense-long-tap before sense-tap-2
onEventName = 'on' + prefix + name;
if (a4p.isDefined(sense[onEventName]) && (sense[onEventName] != null)) {
return onEventName;
}
onEventName = 'on' + name + nbFinger;
if (a4p.isDefined(sense[onEventName]) && (sense[onEventName] != null)) {
return onEventName;
}
} else {
// the number of fingers has priority over the 'Short'/'Long' prefix : sense-tap-2 before sense-long-tap
onEventName = 'on' + name + nbFinger;
if (a4p.isDefined(sense[onEventName]) && (sense[onEventName] != null)) {
return onEventName;
}
onEventName = 'on' + prefix + name;
if (a4p.isDefined(sense[onEventName]) && (sense[onEventName] != null)) {
return onEventName;
}
}
onEventName = 'on' + name;
if (a4p.isDefined(sense[onEventName]) && (sense[onEventName] != null)) {
return onEventName;
}
return '';
} | javascript | function onWhichEvent(sense, name, nbFinger) {
var prefix = 'Short';
if (sense.hasPaused) prefix = 'Long';
var onEventName = 'on' + prefix + name + nbFinger;
if (a4p.isDefined(sense[onEventName]) && (sense[onEventName] != null)) {
return onEventName;
}
if (sense.options.prefixPriority) {
// the 'Short'/'Long' prefix has priority over the number of fingers : sense-long-tap before sense-tap-2
onEventName = 'on' + prefix + name;
if (a4p.isDefined(sense[onEventName]) && (sense[onEventName] != null)) {
return onEventName;
}
onEventName = 'on' + name + nbFinger;
if (a4p.isDefined(sense[onEventName]) && (sense[onEventName] != null)) {
return onEventName;
}
} else {
// the number of fingers has priority over the 'Short'/'Long' prefix : sense-tap-2 before sense-long-tap
onEventName = 'on' + name + nbFinger;
if (a4p.isDefined(sense[onEventName]) && (sense[onEventName] != null)) {
return onEventName;
}
onEventName = 'on' + prefix + name;
if (a4p.isDefined(sense[onEventName]) && (sense[onEventName] != null)) {
return onEventName;
}
}
onEventName = 'on' + name;
if (a4p.isDefined(sense[onEventName]) && (sense[onEventName] != null)) {
return onEventName;
}
return '';
} | [
"function",
"onWhichEvent",
"(",
"sense",
",",
"name",
",",
"nbFinger",
")",
"{",
"var",
"prefix",
"=",
"'Short'",
";",
"if",
"(",
"sense",
".",
"hasPaused",
")",
"prefix",
"=",
"'Long'",
";",
"var",
"onEventName",
"=",
"'on'",
"+",
"prefix",
"+",
"nam... | Gesture events utilities | [
"Gesture",
"events",
"utilities"
] | e57ebece54ee68211d43802a8e0feeef098d3e36 | https://github.com/ofidj/fidj/blob/e57ebece54ee68211d43802a8e0feeef098d3e36/.todo/miapp.tools.sense.js#L2438-L2471 |
41,942 | ofidj/fidj | .todo/miapp.tools.sense.js | clearDrops | function clearDrops(sense) {
sense.dropsStarted = [];
sense.dropOver = null;
sense.dropEvt = {
dataType: 'text/plain',
dataTransfer: ''
};
} | javascript | function clearDrops(sense) {
sense.dropsStarted = [];
sense.dropOver = null;
sense.dropEvt = {
dataType: 'text/plain',
dataTransfer: ''
};
} | [
"function",
"clearDrops",
"(",
"sense",
")",
"{",
"sense",
".",
"dropsStarted",
"=",
"[",
"]",
";",
"sense",
".",
"dropOver",
"=",
"null",
";",
"sense",
".",
"dropEvt",
"=",
"{",
"dataType",
":",
"'text/plain'",
",",
"dataTransfer",
":",
"''",
"}",
";"... | Drag and Drop utilities | [
"Drag",
"and",
"Drop",
"utilities"
] | e57ebece54ee68211d43802a8e0feeef098d3e36 | https://github.com/ofidj/fidj/blob/e57ebece54ee68211d43802a8e0feeef098d3e36/.todo/miapp.tools.sense.js#L2493-L2500 |
41,943 | veo-labs/openveo-api | lib/errors/AccessError.js | AccessError | function AccessError(message) {
Error.captureStackTrace(this, this.constructor);
Object.defineProperties(this, {
/**
* Error message.
*
* @property message
* @type String
* @final
*/
message: {value: message, writable: true},
/**
* Error name.
*
* @property name
* @type String
* @final
*/
name: {value: 'AccessError', writable: true}
});
} | javascript | function AccessError(message) {
Error.captureStackTrace(this, this.constructor);
Object.defineProperties(this, {
/**
* Error message.
*
* @property message
* @type String
* @final
*/
message: {value: message, writable: true},
/**
* Error name.
*
* @property name
* @type String
* @final
*/
name: {value: 'AccessError', writable: true}
});
} | [
"function",
"AccessError",
"(",
"message",
")",
"{",
"Error",
".",
"captureStackTrace",
"(",
"this",
",",
"this",
".",
"constructor",
")",
";",
"Object",
".",
"defineProperties",
"(",
"this",
",",
"{",
"/**\n * Error message.\n *\n * @property message\n ... | Defines an AccessError to be thrown when a resource is forbidden.
var openVeoApi = require('@openveo/api');
throw new openVeoApi.errors.AccessError('You do not have permission to access this resource');
@class AccessError
@extends Error
@constructor
@param {String} message The error message | [
"Defines",
"an",
"AccessError",
"to",
"be",
"thrown",
"when",
"a",
"resource",
"is",
"forbidden",
"."
] | 493a811e9a5ba4d3e14910facaa7452caba1ab38 | https://github.com/veo-labs/openveo-api/blob/493a811e9a5ba4d3e14910facaa7452caba1ab38/lib/errors/AccessError.js#L20-L44 |
41,944 | kt3k/bundle-through | lib/through-obj.js | through | function through(transform) {
var th = new Transform({objectMode: true})
th._transform = transform
return th
} | javascript | function through(transform) {
var th = new Transform({objectMode: true})
th._transform = transform
return th
} | [
"function",
"through",
"(",
"transform",
")",
"{",
"var",
"th",
"=",
"new",
"Transform",
"(",
"{",
"objectMode",
":",
"true",
"}",
")",
"th",
".",
"_transform",
"=",
"transform",
"return",
"th",
"}"
] | Returns a transform stream with the given _transform implementation in the object mode.
@return {Transform} | [
"Returns",
"a",
"transform",
"stream",
"with",
"the",
"given",
"_transform",
"implementation",
"in",
"the",
"object",
"mode",
"."
] | e474509585866a894fdae53347e9835e61b8e6d4 | https://github.com/kt3k/bundle-through/blob/e474509585866a894fdae53347e9835e61b8e6d4/lib/through-obj.js#L9-L15 |
41,945 | unfoldingWord-dev/node-door43-client | lib/request.js | read | function read(uri) {
"use strict";
var parsedUrl = url.parse(uri, false, true);
var makeRequest = parsedUrl.protocol === 'https:' ? https.request.bind(https) : http.request.bind(http);
var serverPort = parsedUrl.port ? parsedUrl.port : parsedUrl.protocol === 'https:' ? 443 : 80;
var agent = parsedUrl.protocol === 'https:' ? httpsAgent : httpAgent;
var options = {
host: parsedUrl.host,
path: parsedUrl.path,
agent: agent,
port: serverPort,
method: 'GET',
headers: {'Content-Type': 'application/json'}
};
return new Promise(function (resolve, reject) {
var req = makeRequest(options, function (response) {
var data = '';
response.on('data', function (chunk) {
data += chunk;
});
response.on('end', function () {
resolve({
status: response.statusCode,
data: data
});
});
});
req.on('error', reject);
req.end();
});
} | javascript | function read(uri) {
"use strict";
var parsedUrl = url.parse(uri, false, true);
var makeRequest = parsedUrl.protocol === 'https:' ? https.request.bind(https) : http.request.bind(http);
var serverPort = parsedUrl.port ? parsedUrl.port : parsedUrl.protocol === 'https:' ? 443 : 80;
var agent = parsedUrl.protocol === 'https:' ? httpsAgent : httpAgent;
var options = {
host: parsedUrl.host,
path: parsedUrl.path,
agent: agent,
port: serverPort,
method: 'GET',
headers: {'Content-Type': 'application/json'}
};
return new Promise(function (resolve, reject) {
var req = makeRequest(options, function (response) {
var data = '';
response.on('data', function (chunk) {
data += chunk;
});
response.on('end', function () {
resolve({
status: response.statusCode,
data: data
});
});
});
req.on('error', reject);
req.end();
});
} | [
"function",
"read",
"(",
"uri",
")",
"{",
"\"use strict\"",
";",
"var",
"parsedUrl",
"=",
"url",
".",
"parse",
"(",
"uri",
",",
"false",
",",
"true",
")",
";",
"var",
"makeRequest",
"=",
"parsedUrl",
".",
"protocol",
"===",
"'https:'",
"?",
"https",
".... | Reads the contents of a url as a string.
@param uri {string} the url to read
@returns {Promise.<string>} the url contents | [
"Reads",
"the",
"contents",
"of",
"a",
"url",
"as",
"a",
"string",
"."
] | 18f518368ee89f4baf8943500a1c53ef5efcfb3e | https://github.com/unfoldingWord-dev/node-door43-client/blob/18f518368ee89f4baf8943500a1c53ef5efcfb3e/lib/request.js#L21-L57 |
41,946 | unfoldingWord-dev/node-door43-client | lib/request.js | download | function download(uri, dest, progressCallback) {
"use strict";
progressCallback = progressCallback || function() {};
var parsedUrl = url.parse(uri, false, true);
var makeRequest = parsedUrl.protocol === 'https:' ? https.request.bind(https) : http.request.bind(http);
var serverPort = parsedUrl.port ? parsedUrl.port : parsedUrl.protocol === 'https:' ? 443 : 80;
var agent = parsedUrl.protocol === 'https:' ? httpsAgent : httpAgent;
var file = fs.createWriteStream(dest);
var options = {
host: parsedUrl.host,
path: parsedUrl.path,
agent: agent,
port: serverPort,
method: 'GET'
};
return new Promise(function (resolve, reject) {
var req = makeRequest(options, function (response) {
var size = response.headers['content-length'];
var progress = 0;
response.on('data', function(chunk) {
progress += chunk.length;
progressCallback(size, progress);
});
response.pipe(file);
file.on('finish', function() {
resolve({
status: response.statusCode
});
});
});
req.on('error', function(error) {
file.end();
rimraf.sync(dest);
reject(error);
});
req.end();
});
} | javascript | function download(uri, dest, progressCallback) {
"use strict";
progressCallback = progressCallback || function() {};
var parsedUrl = url.parse(uri, false, true);
var makeRequest = parsedUrl.protocol === 'https:' ? https.request.bind(https) : http.request.bind(http);
var serverPort = parsedUrl.port ? parsedUrl.port : parsedUrl.protocol === 'https:' ? 443 : 80;
var agent = parsedUrl.protocol === 'https:' ? httpsAgent : httpAgent;
var file = fs.createWriteStream(dest);
var options = {
host: parsedUrl.host,
path: parsedUrl.path,
agent: agent,
port: serverPort,
method: 'GET'
};
return new Promise(function (resolve, reject) {
var req = makeRequest(options, function (response) {
var size = response.headers['content-length'];
var progress = 0;
response.on('data', function(chunk) {
progress += chunk.length;
progressCallback(size, progress);
});
response.pipe(file);
file.on('finish', function() {
resolve({
status: response.statusCode
});
});
});
req.on('error', function(error) {
file.end();
rimraf.sync(dest);
reject(error);
});
req.end();
});
} | [
"function",
"download",
"(",
"uri",
",",
"dest",
",",
"progressCallback",
")",
"{",
"\"use strict\"",
";",
"progressCallback",
"=",
"progressCallback",
"||",
"function",
"(",
")",
"{",
"}",
";",
"var",
"parsedUrl",
"=",
"url",
".",
"parse",
"(",
"uri",
","... | Downloads a url to a file.
@param uri {string} the uri to download
@param dest {string}
@param progressCallback {function} receives progress updates
@returns {Promise.<{}|Error>} the status code or an error | [
"Downloads",
"a",
"url",
"to",
"a",
"file",
"."
] | 18f518368ee89f4baf8943500a1c53ef5efcfb3e | https://github.com/unfoldingWord-dev/node-door43-client/blob/18f518368ee89f4baf8943500a1c53ef5efcfb3e/lib/request.js#L67-L111 |
41,947 | bootprint/customize-write-files | lib/write.js | writeStream | async function writeStream (filename, contents) {
await new Promise((resolve, reject) => {
contents.pipe(fs.createWriteStream(filename))
.on('finish', function () {
resolve(filename)
})
.on('error', /* istanbul ignore next */ function (err) {
reject(err)
})
})
return filename
} | javascript | async function writeStream (filename, contents) {
await new Promise((resolve, reject) => {
contents.pipe(fs.createWriteStream(filename))
.on('finish', function () {
resolve(filename)
})
.on('error', /* istanbul ignore next */ function (err) {
reject(err)
})
})
return filename
} | [
"async",
"function",
"writeStream",
"(",
"filename",
",",
"contents",
")",
"{",
"await",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"contents",
".",
"pipe",
"(",
"fs",
".",
"createWriteStream",
"(",
"filename",
")",
")",
".",
... | Write a Readable to a file and
@param {string} filename
@param {stream.Readable} contents
@private
@returns {Promise<string>} a promise for the filename | [
"Write",
"a",
"Readable",
"to",
"a",
"file",
"and"
] | af77ce78b5196f40ce90670bfdb6e1e7e496a415 | https://github.com/bootprint/customize-write-files/blob/af77ce78b5196f40ce90670bfdb6e1e7e496a415/lib/write.js#L43-L54 |
41,948 | AnyFetch/anyfetch-hydrater.js | lib/helpers/child-process.js | downloadFile | function downloadFile(cb) {
if(task.file_path) {
// Download the file
var stream = fs.createWriteStream(path);
// Store error if statusCode !== 200
var err;
stream.on("finish", function() {
cb(err);
});
var urlToDownload = url.parse(task.file_path, false, true);
// deny queries to ElasticSearch and other vulnerable services
if(task.config.forbiddenPorts && task.config.forbiddenPorts.indexOf(urlToDownload.port) !== -1) {
stream.end();
return fs.unlink(path, function() {
cb(new Error('Trying to access forbidden port: ' + urlToDownload.port));
});
}
var req = request(urlToDownload.protocol + "//" + urlToDownload.host)
.get(urlToDownload.path);
// Warning, Black magic.
// Streaming and checking for status code is no easy task...
// Hours spent optimizing: 22
req.end(function() {}).req.once('response', function(res) {
if(res.statusCode !== 200) {
if(res.statusCode === 410) {
err = new Error('410 Gone');
err.skip = true;
}
else {
err = new Error('Error downloading file, got status ' + res.statusCode);
}
stream.end();
this.abort();
}
});
req.pipe(stream);
}
else {
cb(null);
}
} | javascript | function downloadFile(cb) {
if(task.file_path) {
// Download the file
var stream = fs.createWriteStream(path);
// Store error if statusCode !== 200
var err;
stream.on("finish", function() {
cb(err);
});
var urlToDownload = url.parse(task.file_path, false, true);
// deny queries to ElasticSearch and other vulnerable services
if(task.config.forbiddenPorts && task.config.forbiddenPorts.indexOf(urlToDownload.port) !== -1) {
stream.end();
return fs.unlink(path, function() {
cb(new Error('Trying to access forbidden port: ' + urlToDownload.port));
});
}
var req = request(urlToDownload.protocol + "//" + urlToDownload.host)
.get(urlToDownload.path);
// Warning, Black magic.
// Streaming and checking for status code is no easy task...
// Hours spent optimizing: 22
req.end(function() {}).req.once('response', function(res) {
if(res.statusCode !== 200) {
if(res.statusCode === 410) {
err = new Error('410 Gone');
err.skip = true;
}
else {
err = new Error('Error downloading file, got status ' + res.statusCode);
}
stream.end();
this.abort();
}
});
req.pipe(stream);
}
else {
cb(null);
}
} | [
"function",
"downloadFile",
"(",
"cb",
")",
"{",
"if",
"(",
"task",
".",
"file_path",
")",
"{",
"// Download the file",
"var",
"stream",
"=",
"fs",
".",
"createWriteStream",
"(",
"path",
")",
";",
"// Store error if statusCode !== 200",
"var",
"err",
";",
"str... | Download the file from task.file_path, store it in a temporary file if there is file_path | [
"Download",
"the",
"file",
"from",
"task",
".",
"file_path",
"store",
"it",
"in",
"a",
"temporary",
"file",
"if",
"there",
"is",
"file_path"
] | 1e70fdb5d8dcd26382e2a16de747b91a5b3ef3ae | https://github.com/AnyFetch/anyfetch-hydrater.js/blob/1e70fdb5d8dcd26382e2a16de747b91a5b3ef3ae/lib/helpers/child-process.js#L46-L92 |
41,949 | atsid/circuits-js | js/ServiceMethod.js | function (payload, plugins, ioArgs) {
var writePayload = payload || "", intermediate, that = this;
// Very simiplistic payload type coercion
if (this.requestPayloadName && !payload[this.requestPayloadName]) {
payload = {};
payload[this.requestPayloadName] = writePayload;
}
// Allow request plugins to execute
util.executePluginChain(plugins.request, function (plugin) {
intermediate = plugin.fn.call(plugin.scope || plugin, payload, that, ioArgs);
payload = intermediate || payload;
});
writePayload = (this.requestPayloadName && payload[this.requestPayloadName]) || payload;
// Allow write plugins to execute
util.executePluginChain(plugins.write, function (plugin) {
if (util.isArray(writePayload)) {
writePayload.forEach(function (item, idx) {
intermediate = plugin.fn.call(plugin.scope || plugin, item, that);
writePayload[idx] = intermediate || writePayload[idx];
}, that);
} else {
intermediate = plugin.fn.call(plugin.scope || plugin, writePayload, that);
writePayload = intermediate || writePayload;
}
});
if (this.requestPayloadName) {
payload[this.requestPayloadName] = writePayload;
} else {
payload = writePayload;
}
return payload;
} | javascript | function (payload, plugins, ioArgs) {
var writePayload = payload || "", intermediate, that = this;
// Very simiplistic payload type coercion
if (this.requestPayloadName && !payload[this.requestPayloadName]) {
payload = {};
payload[this.requestPayloadName] = writePayload;
}
// Allow request plugins to execute
util.executePluginChain(plugins.request, function (plugin) {
intermediate = plugin.fn.call(plugin.scope || plugin, payload, that, ioArgs);
payload = intermediate || payload;
});
writePayload = (this.requestPayloadName && payload[this.requestPayloadName]) || payload;
// Allow write plugins to execute
util.executePluginChain(plugins.write, function (plugin) {
if (util.isArray(writePayload)) {
writePayload.forEach(function (item, idx) {
intermediate = plugin.fn.call(plugin.scope || plugin, item, that);
writePayload[idx] = intermediate || writePayload[idx];
}, that);
} else {
intermediate = plugin.fn.call(plugin.scope || plugin, writePayload, that);
writePayload = intermediate || writePayload;
}
});
if (this.requestPayloadName) {
payload[this.requestPayloadName] = writePayload;
} else {
payload = writePayload;
}
return payload;
} | [
"function",
"(",
"payload",
",",
"plugins",
",",
"ioArgs",
")",
"{",
"var",
"writePayload",
"=",
"payload",
"||",
"\"\"",
",",
"intermediate",
",",
"that",
"=",
"this",
";",
"// Very simiplistic payload type coercion\r",
"if",
"(",
"this",
".",
"requestPayloadNa... | An internal method used by invoke to massage and perform plugin processing on
a request payload. The method attempts to coerce the payload into the type specified
in the smd and then runs the 'request' and 'write' plugins returning the new payload.
@param {Object} payload - the request data passed to the service method by the client.
@returns {Object} newPayload - the new or modified payload. | [
"An",
"internal",
"method",
"used",
"by",
"invoke",
"to",
"massage",
"and",
"perform",
"plugin",
"processing",
"on",
"a",
"request",
"payload",
".",
"The",
"method",
"attempts",
"to",
"coerce",
"the",
"payload",
"into",
"the",
"type",
"specified",
"in",
"the... | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/ServiceMethod.js#L151-L188 | |
41,950 | atsid/circuits-js | js/ServiceMethod.js | function (statusCode, data, plugins, ioArgs) {
var isList = this.reader.isListResponse(this.name),
//TODO: "any" is JSONSchema default if no type is defined. this should come through a model though so we aren't tacking it on everywhere
returnType = this.reader.getResponseSchema(this.name).type || "any", //this could fail if there is no "returns" block on the method
payload,
that = this,
intermediate,
successfulResponsePattern = '(2|3)\\d\\d';
//only auto-process responses if not JSONSchema "null" primitive type
if (returnType && returnType !== "null") {
if (typeof (data) === "object") {
//first we apply any global response plugins to the raw data
//warning: if the plugin doesn't write it back out with the correct payload name,
//it will cause an issue below
util.executePluginChain(plugins.response, function (plugin) {
// filter plugins on statusPattern
var statusPattern = plugin.statusPattern || successfulResponsePattern,
regex = new RegExp(statusPattern);
if (regex.test(statusCode)) {
intermediate = plugin.fn.call(plugin.scope || plugin, data, that, ioArgs);
data = intermediate || data;
}
});
}
payload = data;
if (this.responsePayloadName && data && data[this.responsePayloadName]) {
payload = data[this.responsePayloadName];
logger.debug("Extracting payload for [" + this.name + "] from [" + this.payloadName + "] property", payload);
}
//apply any read plugins supplied, after receiving the server results
util.executePluginChain(plugins.read, function (plugin) {
// filter plugins on statusPattern
var statusPattern = plugin.statusPattern || successfulResponsePattern,
regex = new RegExp(statusPattern);
if (regex.test(statusCode)) {
if (isList) {
payload.some(function (item, idx) {
intermediate = plugin.fn.call(plugin.scope || plugin, item, that);
payload[idx] = intermediate || payload[idx];
}, that);
} else {
intermediate = plugin.fn.call(plugin.scope || plugin, payload, that);
payload = intermediate || payload;
}
}
});
}
this.data = payload; //hold on to a copy for future use (could be undefined of course)
return payload;
} | javascript | function (statusCode, data, plugins, ioArgs) {
var isList = this.reader.isListResponse(this.name),
//TODO: "any" is JSONSchema default if no type is defined. this should come through a model though so we aren't tacking it on everywhere
returnType = this.reader.getResponseSchema(this.name).type || "any", //this could fail if there is no "returns" block on the method
payload,
that = this,
intermediate,
successfulResponsePattern = '(2|3)\\d\\d';
//only auto-process responses if not JSONSchema "null" primitive type
if (returnType && returnType !== "null") {
if (typeof (data) === "object") {
//first we apply any global response plugins to the raw data
//warning: if the plugin doesn't write it back out with the correct payload name,
//it will cause an issue below
util.executePluginChain(plugins.response, function (plugin) {
// filter plugins on statusPattern
var statusPattern = plugin.statusPattern || successfulResponsePattern,
regex = new RegExp(statusPattern);
if (regex.test(statusCode)) {
intermediate = plugin.fn.call(plugin.scope || plugin, data, that, ioArgs);
data = intermediate || data;
}
});
}
payload = data;
if (this.responsePayloadName && data && data[this.responsePayloadName]) {
payload = data[this.responsePayloadName];
logger.debug("Extracting payload for [" + this.name + "] from [" + this.payloadName + "] property", payload);
}
//apply any read plugins supplied, after receiving the server results
util.executePluginChain(plugins.read, function (plugin) {
// filter plugins on statusPattern
var statusPattern = plugin.statusPattern || successfulResponsePattern,
regex = new RegExp(statusPattern);
if (regex.test(statusCode)) {
if (isList) {
payload.some(function (item, idx) {
intermediate = plugin.fn.call(plugin.scope || plugin, item, that);
payload[idx] = intermediate || payload[idx];
}, that);
} else {
intermediate = plugin.fn.call(plugin.scope || plugin, payload, that);
payload = intermediate || payload;
}
}
});
}
this.data = payload; //hold on to a copy for future use (could be undefined of course)
return payload;
} | [
"function",
"(",
"statusCode",
",",
"data",
",",
"plugins",
",",
"ioArgs",
")",
"{",
"var",
"isList",
"=",
"this",
".",
"reader",
".",
"isListResponse",
"(",
"this",
".",
"name",
")",
",",
"//TODO: \"any\" is JSONSchema default if no type is defined. this should com... | An internal method used by the handler method generated by invoke to perform plugin processing on the
response data.
@param statusCode {Number} The status code from the request
@param data {Object} The response data returned by the provider
@param plugins {Array of circuits.Plugin} The merged plugins for the invocation
@param ioArgs {Object} The object used to generate the request | [
"An",
"internal",
"method",
"used",
"by",
"the",
"handler",
"method",
"generated",
"by",
"invoke",
"to",
"perform",
"plugin",
"processing",
"on",
"the",
"response",
"data",
"."
] | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/ServiceMethod.js#L198-L258 | |
41,951 | hairyhenderson/node-fellowshipone | lib/household_addresses.js | HouseholdAddresses | function HouseholdAddresses (f1, householdID) {
if (!householdID) {
throw new Error('HouseholdAddresses requires a household ID!')
}
Addresses.call(this, f1, {
path: '/Households/' + householdID + '/Addresses'
})
} | javascript | function HouseholdAddresses (f1, householdID) {
if (!householdID) {
throw new Error('HouseholdAddresses requires a household ID!')
}
Addresses.call(this, f1, {
path: '/Households/' + householdID + '/Addresses'
})
} | [
"function",
"HouseholdAddresses",
"(",
"f1",
",",
"householdID",
")",
"{",
"if",
"(",
"!",
"householdID",
")",
"{",
"throw",
"new",
"Error",
"(",
"'HouseholdAddresses requires a household ID!'",
")",
"}",
"Addresses",
".",
"call",
"(",
"this",
",",
"f1",
",",
... | The Addresses object, in a Household context.
@param {Object} f1 - the F1 object
@param {Number} householdID - the Household ID, for context | [
"The",
"Addresses",
"object",
"in",
"a",
"Household",
"context",
"."
] | 5e80eb9ec31fb6dceee1e8c211e7b6e0e373b08b | https://github.com/hairyhenderson/node-fellowshipone/blob/5e80eb9ec31fb6dceee1e8c211e7b6e0e373b08b/lib/household_addresses.js#L10-L17 |
41,952 | Mammut-FE/nejm | src/util/form/form.js | function(v,node){
var format = this.__dataset(node,'format')||'yyyy-MM-dd';
return !v||(!isNaN(this.__doParseDate(v)) && _u._$format(this.__doParseDate(v),format) == v);
} | javascript | function(v,node){
var format = this.__dataset(node,'format')||'yyyy-MM-dd';
return !v||(!isNaN(this.__doParseDate(v)) && _u._$format(this.__doParseDate(v),format) == v);
} | [
"function",
"(",
"v",
",",
"node",
")",
"{",
"var",
"format",
"=",
"this",
".",
"__dataset",
"(",
"node",
",",
"'format'",
")",
"||",
"'yyyy-MM-dd'",
";",
"return",
"!",
"v",
"||",
"(",
"!",
"isNaN",
"(",
"this",
".",
"__doParseDate",
"(",
"v",
")"... | xx-x-xx or xxxx-xx-x | [
"xx",
"-",
"x",
"-",
"xx",
"or",
"xxxx",
"-",
"xx",
"-",
"x"
] | dfc09ac66a8d67620a7aea65e34d8a179976b3fb | https://github.com/Mammut-FE/nejm/blob/dfc09ac66a8d67620a7aea65e34d8a179976b3fb/src/util/form/form.js#L623-L626 | |
41,953 | Mammut-FE/nejm | src/util/form/form.js | function(_node){
var _type = _node.type,
_novalue = !_node.value,
_nocheck = (_type=='checkbox'||
_type=='radio')&&!_node.checked;
if (_nocheck||_novalue) return -1;
} | javascript | function(_node){
var _type = _node.type,
_novalue = !_node.value,
_nocheck = (_type=='checkbox'||
_type=='radio')&&!_node.checked;
if (_nocheck||_novalue) return -1;
} | [
"function",
"(",
"_node",
")",
"{",
"var",
"_type",
"=",
"_node",
".",
"type",
",",
"_novalue",
"=",
"!",
"_node",
".",
"value",
",",
"_nocheck",
"=",
"(",
"_type",
"==",
"'checkbox'",
"||",
"_type",
"==",
"'radio'",
")",
"&&",
"!",
"_node",
".",
"... | value require for text checked require for checkbox or radio | [
"value",
"require",
"for",
"text",
"checked",
"require",
"for",
"checkbox",
"or",
"radio"
] | dfc09ac66a8d67620a7aea65e34d8a179976b3fb | https://github.com/Mammut-FE/nejm/blob/dfc09ac66a8d67620a7aea65e34d8a179976b3fb/src/util/form/form.js#L632-L638 | |
41,954 | Mammut-FE/nejm | src/util/form/form.js | function(_node,_options){
var _reg = this.__treg[_options.type],
_val = _node.value.trim(),
_tested = !!_reg.test&&!_reg.test(_val),
_funced = _u._$isFunction(_reg)&&!_reg.call(this,_val,_node);
if (_tested||_funced) return -2;
} | javascript | function(_node,_options){
var _reg = this.__treg[_options.type],
_val = _node.value.trim(),
_tested = !!_reg.test&&!_reg.test(_val),
_funced = _u._$isFunction(_reg)&&!_reg.call(this,_val,_node);
if (_tested||_funced) return -2;
} | [
"function",
"(",
"_node",
",",
"_options",
")",
"{",
"var",
"_reg",
"=",
"this",
".",
"__treg",
"[",
"_options",
".",
"type",
"]",
",",
"_val",
"=",
"_node",
".",
"value",
".",
"trim",
"(",
")",
",",
"_tested",
"=",
"!",
"!",
"_reg",
".",
"test",... | type supported in _regmap | [
"type",
"supported",
"in",
"_regmap"
] | dfc09ac66a8d67620a7aea65e34d8a179976b3fb | https://github.com/Mammut-FE/nejm/blob/dfc09ac66a8d67620a7aea65e34d8a179976b3fb/src/util/form/form.js#L640-L646 | |
41,955 | Mammut-FE/nejm | src/util/form/form.js | function(_node,_options){
var _number = this.__number(
_node.value,
_options.type,
_options.time
);
if (isNaN(_number)||
_number<_options.min)
return -6;
} | javascript | function(_node,_options){
var _number = this.__number(
_node.value,
_options.type,
_options.time
);
if (isNaN(_number)||
_number<_options.min)
return -6;
} | [
"function",
"(",
"_node",
",",
"_options",
")",
"{",
"var",
"_number",
"=",
"this",
".",
"__number",
"(",
"_node",
".",
"value",
",",
"_options",
".",
"type",
",",
"_options",
".",
"time",
")",
";",
"if",
"(",
"isNaN",
"(",
"_number",
")",
"||",
"_... | min value check | [
"min",
"value",
"check"
] | dfc09ac66a8d67620a7aea65e34d8a179976b3fb | https://github.com/Mammut-FE/nejm/blob/dfc09ac66a8d67620a7aea65e34d8a179976b3fb/src/util/form/form.js#L673-L682 | |
41,956 | Mammut-FE/nejm | src/util/form/form.js | function(_value,_node){
// for multiple select
if (!!_node.multiple){
var _map;
if (!_u._$isArray(_value)){
_map[_value] = _value;
}else{
_map = _u._$array2object(_value);
}
_u._$forEach(
_node.options,function(_option){
_option.selected = _map[_option.value]!=null;
}
);
}else{
_node.value = _getValue(_value);
}
} | javascript | function(_value,_node){
// for multiple select
if (!!_node.multiple){
var _map;
if (!_u._$isArray(_value)){
_map[_value] = _value;
}else{
_map = _u._$array2object(_value);
}
_u._$forEach(
_node.options,function(_option){
_option.selected = _map[_option.value]!=null;
}
);
}else{
_node.value = _getValue(_value);
}
} | [
"function",
"(",
"_value",
",",
"_node",
")",
"{",
"// for multiple select",
"if",
"(",
"!",
"!",
"_node",
".",
"multiple",
")",
"{",
"var",
"_map",
";",
"if",
"(",
"!",
"_u",
".",
"_$isArray",
"(",
"_value",
")",
")",
"{",
"_map",
"[",
"_value",
"... | set select value | [
"set",
"select",
"value"
] | dfc09ac66a8d67620a7aea65e34d8a179976b3fb | https://github.com/Mammut-FE/nejm/blob/dfc09ac66a8d67620a7aea65e34d8a179976b3fb/src/util/form/form.js#L920-L937 | |
41,957 | Mammut-FE/nejm | src/util/form/form.js | function(_value,_node){
if (_reg0.test(_node.type||'')){
// radio/checkbox
_node.checked = _value==_node.value;
}else if(_node.tagName=='SELECT'){
// for select node
_doSetSelect(_value,_node);
}else{
// other
_node.value = _getValue(_value);
}
} | javascript | function(_value,_node){
if (_reg0.test(_node.type||'')){
// radio/checkbox
_node.checked = _value==_node.value;
}else if(_node.tagName=='SELECT'){
// for select node
_doSetSelect(_value,_node);
}else{
// other
_node.value = _getValue(_value);
}
} | [
"function",
"(",
"_value",
",",
"_node",
")",
"{",
"if",
"(",
"_reg0",
".",
"test",
"(",
"_node",
".",
"type",
"||",
"''",
")",
")",
"{",
"// radio/checkbox",
"_node",
".",
"checked",
"=",
"_value",
"==",
"_node",
".",
"value",
";",
"}",
"else",
"i... | set node value | [
"set",
"node",
"value"
] | dfc09ac66a8d67620a7aea65e34d8a179976b3fb | https://github.com/Mammut-FE/nejm/blob/dfc09ac66a8d67620a7aea65e34d8a179976b3fb/src/util/form/form.js#L939-L950 | |
41,958 | urturn/urturn-expression-api | dist/iframe.js | function(callbackUUID, result) {
var callback = apiListeners[callbackUUID];
if (callback) {
if ( !(result && result instanceof Array )) {
if(window.console && console.error){
console.error('received result is not an array.', result);
}
}
callback.apply(this, result);
delete apiListeners[callbackUUID];
}
} | javascript | function(callbackUUID, result) {
var callback = apiListeners[callbackUUID];
if (callback) {
if ( !(result && result instanceof Array )) {
if(window.console && console.error){
console.error('received result is not an array.', result);
}
}
callback.apply(this, result);
delete apiListeners[callbackUUID];
}
} | [
"function",
"(",
"callbackUUID",
",",
"result",
")",
"{",
"var",
"callback",
"=",
"apiListeners",
"[",
"callbackUUID",
"]",
";",
"if",
"(",
"callback",
")",
"{",
"if",
"(",
"!",
"(",
"result",
"&&",
"result",
"instanceof",
"Array",
")",
")",
"{",
"if",... | Events called when callback are received from post message.
@private
@param callBackUUID the uuid of the callback to call
@param result the result parameter to the caallback | [
"Events",
"called",
"when",
"callback",
"are",
"received",
"from",
"post",
"message",
"."
] | 009a272ee670dbbe5eefb5c070ed827dd778bb07 | https://github.com/urturn/urturn-expression-api/blob/009a272ee670dbbe5eefb5c070ed827dd778bb07/dist/iframe.js#L2636-L2647 | |
41,959 | urturn/urturn-expression-api | dist/iframe.js | function(options, callback, errorCallback){
if(typeof options == 'function'){
callback = options;
options = {};
}
UT.Expression._callAPI(
'document.textInput',
[options.value || null, options.max || null, options.multiline || false],
callback
);
} | javascript | function(options, callback, errorCallback){
if(typeof options == 'function'){
callback = options;
options = {};
}
UT.Expression._callAPI(
'document.textInput',
[options.value || null, options.max || null, options.multiline || false],
callback
);
} | [
"function",
"(",
"options",
",",
"callback",
",",
"errorCallback",
")",
"{",
"if",
"(",
"typeof",
"options",
"==",
"'function'",
")",
"{",
"callback",
"=",
"options",
";",
"options",
"=",
"{",
"}",
";",
"}",
"UT",
".",
"Expression",
".",
"_callAPI",
"(... | Public Functions
Native text input for mobile.
if options is passed, it might contains:
- value, the default value,
- max, the number of chars allowed,
- multiline, if true, allow for a multiline text input
The callback will be passed the resulting string or null
if no value have been selected.
XXX: Need to be supported on desktop as well | [
"Public",
"Functions",
"Native",
"text",
"input",
"for",
"mobile",
"."
] | 009a272ee670dbbe5eefb5c070ed827dd778bb07 | https://github.com/urturn/urturn-expression-api/blob/009a272ee670dbbe5eefb5c070ed827dd778bb07/dist/iframe.js#L2927-L2937 | |
41,960 | urturn/urturn-expression-api | dist/iframe.js | function(options, callback) {
if(typeof options === 'function') {
callback = options;
options = {};
}
if(options.items) {
options.users = options.users || [];
for(var i = 0; i < options.items.length ; i++){
options.users.push(options.items[i]._key);
}
delete options.items;
}
if(options.title) {
options.label = options.title;
delete options.title;
}
if (!self.context.player || !options.users || options.users.length === 0 ) {
callback.apply(self);
} else {
UT.Expression._callAPI('dialog.users', [options], function(){
callback.apply(self);
});
}
} | javascript | function(options, callback) {
if(typeof options === 'function') {
callback = options;
options = {};
}
if(options.items) {
options.users = options.users || [];
for(var i = 0; i < options.items.length ; i++){
options.users.push(options.items[i]._key);
}
delete options.items;
}
if(options.title) {
options.label = options.title;
delete options.title;
}
if (!self.context.player || !options.users || options.users.length === 0 ) {
callback.apply(self);
} else {
UT.Expression._callAPI('dialog.users', [options], function(){
callback.apply(self);
});
}
} | [
"function",
"(",
"options",
",",
"callback",
")",
"{",
"if",
"(",
"typeof",
"options",
"===",
"'function'",
")",
"{",
"callback",
"=",
"options",
";",
"options",
"=",
"{",
"}",
";",
"}",
"if",
"(",
"options",
".",
"items",
")",
"{",
"options",
".",
... | Send a request to list users with the given ids. | [
"Send",
"a",
"request",
"to",
"list",
"users",
"with",
"the",
"given",
"ids",
"."
] | 009a272ee670dbbe5eefb5c070ed827dd778bb07 | https://github.com/urturn/urturn-expression-api/blob/009a272ee670dbbe5eefb5c070ed827dd778bb07/dist/iframe.js#L3056-L3079 | |
41,961 | hairyhenderson/node-fellowshipone | lib/f1.js | F1 | function F1 (config) {
var valErrors = jjv.validate(configSchema, config)
if (valErrors && valErrors.validation) {
throw new Error('Validation errors: ' +
JSON.stringify(valErrors.validation, null, 3))
}
this.config = config
} | javascript | function F1 (config) {
var valErrors = jjv.validate(configSchema, config)
if (valErrors && valErrors.validation) {
throw new Error('Validation errors: ' +
JSON.stringify(valErrors.validation, null, 3))
}
this.config = config
} | [
"function",
"F1",
"(",
"config",
")",
"{",
"var",
"valErrors",
"=",
"jjv",
".",
"validate",
"(",
"configSchema",
",",
"config",
")",
"if",
"(",
"valErrors",
"&&",
"valErrors",
".",
"validation",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Validation errors: ... | F1 utility class
@constructor
@param config The config option | [
"F1",
"utility",
"class"
] | 5e80eb9ec31fb6dceee1e8c211e7b6e0e373b08b | https://github.com/hairyhenderson/node-fellowshipone/blob/5e80eb9ec31fb6dceee1e8c211e7b6e0e373b08b/lib/f1.js#L14-L22 |
41,962 | 1stdibs/backbone-base-and-form-view | backbone-formview.js | function (optionCollection, key, model, collection) {
if (optionCollection) {
return strTo(optionCollection, model, Collection) || collection;
}
return strTo(key, model, Collection) || null;
} | javascript | function (optionCollection, key, model, collection) {
if (optionCollection) {
return strTo(optionCollection, model, Collection) || collection;
}
return strTo(key, model, Collection) || null;
} | [
"function",
"(",
"optionCollection",
",",
"key",
",",
"model",
",",
"collection",
")",
"{",
"if",
"(",
"optionCollection",
")",
"{",
"return",
"strTo",
"(",
"optionCollection",
",",
"model",
",",
"Collection",
")",
"||",
"collection",
";",
"}",
"return",
"... | Similar to getSubModel except for collections and does not pass the parent collection if no option collection is specified and the schema key cannot locate a sub collection, then null is returned | [
"Similar",
"to",
"getSubModel",
"except",
"for",
"collections",
"and",
"does",
"not",
"pass",
"the",
"parent",
"collection",
"if",
"no",
"option",
"collection",
"is",
"specified",
"and",
"the",
"schema",
"key",
"cannot",
"locate",
"a",
"sub",
"collection",
"th... | 9c49f9ac059ba3177b61f7395151de78b506e8f7 | https://github.com/1stdibs/backbone-base-and-form-view/blob/9c49f9ac059ba3177b61f7395151de78b506e8f7/backbone-formview.js#L122-L127 | |
41,963 | 1stdibs/backbone-base-and-form-view | backbone-formview.js | function (alias, construct) {
var aliases = {};
var currAliases = Backbone.FormView.prototype.fieldAlias;
if (construct) {
aliases[alias] = construct;
} else { aliases = alias; }
defaults(currAliases, aliases);
} | javascript | function (alias, construct) {
var aliases = {};
var currAliases = Backbone.FormView.prototype.fieldAlias;
if (construct) {
aliases[alias] = construct;
} else { aliases = alias; }
defaults(currAliases, aliases);
} | [
"function",
"(",
"alias",
",",
"construct",
")",
"{",
"var",
"aliases",
"=",
"{",
"}",
";",
"var",
"currAliases",
"=",
"Backbone",
".",
"FormView",
".",
"prototype",
".",
"fieldAlias",
";",
"if",
"(",
"construct",
")",
"{",
"aliases",
"[",
"alias",
"]"... | Add a Field Alias to the list of field aliases. For example
You have a view constructor DateFieldView and you want to
make it easy to put that field in a schema, you can use this
static function to add an allias 'Date' for that constructor
@memberOf Backbone.FormView
@param {String} alias Name of the alias
@param {String|Function} construct Constructor used for the field | [
"Add",
"a",
"Field",
"Alias",
"to",
"the",
"list",
"of",
"field",
"aliases",
".",
"For",
"example",
"You",
"have",
"a",
"view",
"constructor",
"DateFieldView",
"and",
"you",
"want",
"to",
"make",
"it",
"easy",
"to",
"put",
"that",
"field",
"in",
"a",
"... | 9c49f9ac059ba3177b61f7395151de78b506e8f7 | https://github.com/1stdibs/backbone-base-and-form-view/blob/9c49f9ac059ba3177b61f7395151de78b506e8f7/backbone-formview.js#L404-L411 | |
41,964 | 1stdibs/backbone-base-and-form-view | backbone-formview.js | function (schema) {
if (!this.rowConfig.options) { this.rowConfig.options = {}; }
this.rowConfig.options.schema = schema || this.options.rowSchema || this.rowSchema;
return this;
} | javascript | function (schema) {
if (!this.rowConfig.options) { this.rowConfig.options = {}; }
this.rowConfig.options.schema = schema || this.options.rowSchema || this.rowSchema;
return this;
} | [
"function",
"(",
"schema",
")",
"{",
"if",
"(",
"!",
"this",
".",
"rowConfig",
".",
"options",
")",
"{",
"this",
".",
"rowConfig",
".",
"options",
"=",
"{",
"}",
";",
"}",
"this",
".",
"rowConfig",
".",
"options",
".",
"schema",
"=",
"schema",
"||"... | Set the schema used for each row.
@memberOf Backbone.CollectionFormView#
@param {object} [schema]
@return {Backbone.CollectionFormView} | [
"Set",
"the",
"schema",
"used",
"for",
"each",
"row",
"."
] | 9c49f9ac059ba3177b61f7395151de78b506e8f7 | https://github.com/1stdibs/backbone-base-and-form-view/blob/9c49f9ac059ba3177b61f7395151de78b506e8f7/backbone-formview.js#L534-L538 | |
41,965 | 1stdibs/backbone-base-and-form-view | backbone-formview.js | function () {
this.subs.detachElems();
this.$el.html(this.template(this._getTemplateVars()));
if (!this.getRows() || !this.getRows().length) {
this.setupRows();
}
this.subs.renderByKey('row', { appendTo: this.getRowWrapper() });
return this;
} | javascript | function () {
this.subs.detachElems();
this.$el.html(this.template(this._getTemplateVars()));
if (!this.getRows() || !this.getRows().length) {
this.setupRows();
}
this.subs.renderByKey('row', { appendTo: this.getRowWrapper() });
return this;
} | [
"function",
"(",
")",
"{",
"this",
".",
"subs",
".",
"detachElems",
"(",
")",
";",
"this",
".",
"$el",
".",
"html",
"(",
"this",
".",
"template",
"(",
"this",
".",
"_getTemplateVars",
"(",
")",
")",
")",
";",
"if",
"(",
"!",
"this",
".",
"getRows... | Like Backbone.FormView.render, except that each a subView will be rendered
for each field in the schema and for each model in the collection.
Each model in the collection will have a 'row' associated with it,
and each row will contain each of the fields in the schema.
@memberOf Backbone.CollectionFormView#
@return {Backbone.CollectionFormView} | [
"Like",
"Backbone",
".",
"FormView",
".",
"render",
"except",
"that",
"each",
"a",
"subView",
"will",
"be",
"rendered",
"for",
"each",
"field",
"in",
"the",
"schema",
"and",
"for",
"each",
"model",
"in",
"the",
"collection",
".",
"Each",
"model",
"in",
"... | 9c49f9ac059ba3177b61f7395151de78b506e8f7 | https://github.com/1stdibs/backbone-base-and-form-view/blob/9c49f9ac059ba3177b61f7395151de78b506e8f7/backbone-formview.js#L547-L555 | |
41,966 | 1stdibs/backbone-base-and-form-view | backbone-formview.js | function (obj) {
var model = (obj instanceof Model) ? obj : null;
var view = (!model && obj instanceof Backbone.View) ? obj : null;
var arr = (!model && !view && isArray(obj)) ? obj : null;
if (arr) {
each(arr, this.deleteRow, this);
return this;
}
if (!view) {
view = this.subs.get(model);
} else if (!model) {
model = view.model;
}
this.subs.remove(view);
this.collection.remove(model);
return this;
} | javascript | function (obj) {
var model = (obj instanceof Model) ? obj : null;
var view = (!model && obj instanceof Backbone.View) ? obj : null;
var arr = (!model && !view && isArray(obj)) ? obj : null;
if (arr) {
each(arr, this.deleteRow, this);
return this;
}
if (!view) {
view = this.subs.get(model);
} else if (!model) {
model = view.model;
}
this.subs.remove(view);
this.collection.remove(model);
return this;
} | [
"function",
"(",
"obj",
")",
"{",
"var",
"model",
"=",
"(",
"obj",
"instanceof",
"Model",
")",
"?",
"obj",
":",
"null",
";",
"var",
"view",
"=",
"(",
"!",
"model",
"&&",
"obj",
"instanceof",
"Backbone",
".",
"View",
")",
"?",
"obj",
":",
"null",
... | Removes a row or rows from the CollectionFormView and
corresponding collection.
@memberOf Backbone.CollectionFormView#
@param {Backbone.Model|Backbone.View|Backbone.View[]|Backbone.Model[]} obj
Used to find models in the collection and views in the subViewManager
and remove them.
@return {Backbone.CollectionFormView} | [
"Removes",
"a",
"row",
"or",
"rows",
"from",
"the",
"CollectionFormView",
"and",
"corresponding",
"collection",
"."
] | 9c49f9ac059ba3177b61f7395151de78b506e8f7 | https://github.com/1stdibs/backbone-base-and-form-view/blob/9c49f9ac059ba3177b61f7395151de78b506e8f7/backbone-formview.js#L600-L619 | |
41,967 | 1stdibs/backbone-base-and-form-view | backbone-formview.js | function () {
var $input;
var id = this.inputId;
var attrs = this.addId ? { id : id, name: id } : {};
var valForInput = this.getValueForInput();
$input = Backbone.$('<' + this.elementType + '>');
if (this.elementType === 'input') { attrs.type = 'text'; }
if (this.placeholder) { attrs.placeholder = this.placeholder; }
$input.attr(extend(attrs, this.inputAttrs));
if (this.inputClass) { $input.attr('class', this.inputClass); }
this.getInputWrapper().html($input);
if (this._shouldSetValueOnInput(valForInput)) { $input.val(valForInput); }
this.isDisabled = null;
return this;
} | javascript | function () {
var $input;
var id = this.inputId;
var attrs = this.addId ? { id : id, name: id } : {};
var valForInput = this.getValueForInput();
$input = Backbone.$('<' + this.elementType + '>');
if (this.elementType === 'input') { attrs.type = 'text'; }
if (this.placeholder) { attrs.placeholder = this.placeholder; }
$input.attr(extend(attrs, this.inputAttrs));
if (this.inputClass) { $input.attr('class', this.inputClass); }
this.getInputWrapper().html($input);
if (this._shouldSetValueOnInput(valForInput)) { $input.val(valForInput); }
this.isDisabled = null;
return this;
} | [
"function",
"(",
")",
"{",
"var",
"$input",
";",
"var",
"id",
"=",
"this",
".",
"inputId",
";",
"var",
"attrs",
"=",
"this",
".",
"addId",
"?",
"{",
"id",
":",
"id",
",",
"name",
":",
"id",
"}",
":",
"{",
"}",
";",
"var",
"valForInput",
"=",
... | Renders the field input and places it in the wrapper in
the element with the 'data-input' attribute
@memberOf Backbone.fields.FieldView#
@return {Backbone.fields.FieldView} | [
"Renders",
"the",
"field",
"input",
"and",
"places",
"it",
"in",
"the",
"wrapper",
"in",
"the",
"element",
"with",
"the",
"data",
"-",
"input",
"attribute"
] | 9c49f9ac059ba3177b61f7395151de78b506e8f7 | https://github.com/1stdibs/backbone-base-and-form-view/blob/9c49f9ac059ba3177b61f7395151de78b506e8f7/backbone-formview.js#L893-L907 | |
41,968 | 1stdibs/backbone-base-and-form-view | backbone-formview.js | function () {
var possibleVals = result(this, 'possibleVals');
var key;
var i = 0;
var possibleVal;
var $checkbox;
var isSelected;
var $inputWrapper = this.getInputWrapper().empty();
for (key in possibleVals) {
if (possibleVals.hasOwnProperty(key)) {
possibleVal = this._parsePossibleVal(possibleVals, key);
isSelected = this.isSelected(possibleVal.value);
$checkbox = this._renderInput(possibleVal, isSelected, i);
$inputWrapper.append($checkbox);
i++;
}
}
return this;
} | javascript | function () {
var possibleVals = result(this, 'possibleVals');
var key;
var i = 0;
var possibleVal;
var $checkbox;
var isSelected;
var $inputWrapper = this.getInputWrapper().empty();
for (key in possibleVals) {
if (possibleVals.hasOwnProperty(key)) {
possibleVal = this._parsePossibleVal(possibleVals, key);
isSelected = this.isSelected(possibleVal.value);
$checkbox = this._renderInput(possibleVal, isSelected, i);
$inputWrapper.append($checkbox);
i++;
}
}
return this;
} | [
"function",
"(",
")",
"{",
"var",
"possibleVals",
"=",
"result",
"(",
"this",
",",
"'possibleVals'",
")",
";",
"var",
"key",
";",
"var",
"i",
"=",
"0",
";",
"var",
"possibleVal",
";",
"var",
"$checkbox",
";",
"var",
"isSelected",
";",
"var",
"$inputWra... | Renders the radio inputs and appends them to the input wrapper.
@memberOf Backbone.fields.RadioListView#
@return {Backbone.fields.RadioListView} | [
"Renders",
"the",
"radio",
"inputs",
"and",
"appends",
"them",
"to",
"the",
"input",
"wrapper",
"."
] | 9c49f9ac059ba3177b61f7395151de78b506e8f7 | https://github.com/1stdibs/backbone-base-and-form-view/blob/9c49f9ac059ba3177b61f7395151de78b506e8f7/backbone-formview.js#L1076-L1095 | |
41,969 | 1stdibs/backbone-base-and-form-view | backbone-formview.js | function (key) {
var modelVal = this.getModelVal();
modelVal = this.multiple ? modelVal : [modelVal];
return (_.indexOf(_.map(modelVal, toStr), toStr(key)) > -1);
} | javascript | function (key) {
var modelVal = this.getModelVal();
modelVal = this.multiple ? modelVal : [modelVal];
return (_.indexOf(_.map(modelVal, toStr), toStr(key)) > -1);
} | [
"function",
"(",
"key",
")",
"{",
"var",
"modelVal",
"=",
"this",
".",
"getModelVal",
"(",
")",
";",
"modelVal",
"=",
"this",
".",
"multiple",
"?",
"modelVal",
":",
"[",
"modelVal",
"]",
";",
"return",
"(",
"_",
".",
"indexOf",
"(",
"_",
".",
"map"... | Returns true or false if the option should be selected
@memberOf Backbone.fields.SelectListView#
@param {string} key The key of the possibleVal that is being tested
@return {boolean} | [
"Returns",
"true",
"or",
"false",
"if",
"the",
"option",
"should",
"be",
"selected"
] | 9c49f9ac059ba3177b61f7395151de78b506e8f7 | https://github.com/1stdibs/backbone-base-and-form-view/blob/9c49f9ac059ba3177b61f7395151de78b506e8f7/backbone-formview.js#L1185-L1189 | |
41,970 | 1stdibs/backbone-base-and-form-view | backbone-formview.js | function () {
var possibleVals = result(this, 'possibleVals');
var id = this.inputId;
var $select = Backbone.$('<' + this.elementType + '>')
.attr(extend((this.addId ? { id: id, name: id } : {}), this.inputAttrs));
this.getInputWrapper().html($select);
if (this.multiple) { $select.attr('multiple', 'multiple'); }
if (this.inputClass) { $select.addClass(this.inputClass); }
if (this.placeholder) {
$select.append('<option value="">' + this.placeholder + '</option>');
}
return this._renderInput($select, possibleVals);
} | javascript | function () {
var possibleVals = result(this, 'possibleVals');
var id = this.inputId;
var $select = Backbone.$('<' + this.elementType + '>')
.attr(extend((this.addId ? { id: id, name: id } : {}), this.inputAttrs));
this.getInputWrapper().html($select);
if (this.multiple) { $select.attr('multiple', 'multiple'); }
if (this.inputClass) { $select.addClass(this.inputClass); }
if (this.placeholder) {
$select.append('<option value="">' + this.placeholder + '</option>');
}
return this._renderInput($select, possibleVals);
} | [
"function",
"(",
")",
"{",
"var",
"possibleVals",
"=",
"result",
"(",
"this",
",",
"'possibleVals'",
")",
";",
"var",
"id",
"=",
"this",
".",
"inputId",
";",
"var",
"$select",
"=",
"Backbone",
".",
"$",
"(",
"'<'",
"+",
"this",
".",
"elementType",
"+... | Renders the select element and the options
@memberOf Backbone.fields.SelectListView#
@return {Backbone.fields.SelectListView} | [
"Renders",
"the",
"select",
"element",
"and",
"the",
"options"
] | 9c49f9ac059ba3177b61f7395151de78b506e8f7 | https://github.com/1stdibs/backbone-base-and-form-view/blob/9c49f9ac059ba3177b61f7395151de78b506e8f7/backbone-formview.js#L1195-L1208 | |
41,971 | 1stdibs/backbone-base-and-form-view | backbone-formview.js | function (possibleVal, isChecked, index) {
var $listItem;
var $label;
var id = this.inputId;
var attributes = { type: 'checkbox', value: possibleVal.value};
if (this.addId) { extend(attributes, { name: id, id: (id + '-' + index) }); }
attributes = extend(attributes, this.inputAttrs);
if (this.inputClass) { attributes.class = this.inputClass; }
if (isChecked) { attributes.checked = 'checked'; }
$listItem = Backbone.$('<input>').attr(attributes);
$label = Backbone.$('<label>').attr(defaults(this.labelAttrs || {}, { 'class': 'checkbox' }));
return $label.append($listItem).append(possibleVal.display);
} | javascript | function (possibleVal, isChecked, index) {
var $listItem;
var $label;
var id = this.inputId;
var attributes = { type: 'checkbox', value: possibleVal.value};
if (this.addId) { extend(attributes, { name: id, id: (id + '-' + index) }); }
attributes = extend(attributes, this.inputAttrs);
if (this.inputClass) { attributes.class = this.inputClass; }
if (isChecked) { attributes.checked = 'checked'; }
$listItem = Backbone.$('<input>').attr(attributes);
$label = Backbone.$('<label>').attr(defaults(this.labelAttrs || {}, { 'class': 'checkbox' }));
return $label.append($listItem).append(possibleVal.display);
} | [
"function",
"(",
"possibleVal",
",",
"isChecked",
",",
"index",
")",
"{",
"var",
"$listItem",
";",
"var",
"$label",
";",
"var",
"id",
"=",
"this",
".",
"inputId",
";",
"var",
"attributes",
"=",
"{",
"type",
":",
"'checkbox'",
",",
"value",
":",
"possib... | Renders and returns a single checkbox in a CheckList
@memberOf Backbone.fields.CheckListView#
@param {string} possibleVal the key from possibleVals
@param {boolean} isChecked if the box should be checked or not
@param {number} index the index of the checkbox
@return {$} | [
"Renders",
"and",
"returns",
"a",
"single",
"checkbox",
"in",
"a",
"CheckList"
] | 9c49f9ac059ba3177b61f7395151de78b506e8f7 | https://github.com/1stdibs/backbone-base-and-form-view/blob/9c49f9ac059ba3177b61f7395151de78b506e8f7/backbone-formview.js#L1326-L1339 | |
41,972 | feedhenry/fh-component-metrics | lib/clients/redis.js | RedisClient | function RedisClient(opts) {
opts = opts || {};
BaseClient.apply(this, arguments);
this.recordsToKeep = opts.recordsToKeep || 1000;
this.namespace = opts.namespace || 'stats';
this.client = opts.redisClient;
} | javascript | function RedisClient(opts) {
opts = opts || {};
BaseClient.apply(this, arguments);
this.recordsToKeep = opts.recordsToKeep || 1000;
this.namespace = opts.namespace || 'stats';
this.client = opts.redisClient;
} | [
"function",
"RedisClient",
"(",
"opts",
")",
"{",
"opts",
"=",
"opts",
"||",
"{",
"}",
";",
"BaseClient",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"this",
".",
"recordsToKeep",
"=",
"opts",
".",
"recordsToKeep",
"||",
"1000",
";",
"this",... | A client that can send metrics data to a redis backend
@param {Object} opts
@param {Object} opts.redisClient an instance of the redis nodejs client.
@param {Number} opts.recordsToKeep the number of records to keep for each metric. Default is 1000.
@param {String} opts.namespace name space for each metric key. It will be used to prefix each metric key followed by ':'. Default is `stats`. So each metric key will be like `stats:<metric key>`. | [
"A",
"client",
"that",
"can",
"send",
"metrics",
"data",
"to",
"a",
"redis",
"backend"
] | c97a1a82ff0144f2a7c2abecbc22084fade1cbc8 | https://github.com/feedhenry/fh-component-metrics/blob/c97a1a82ff0144f2a7c2abecbc22084fade1cbc8/lib/clients/redis.js#L15-L21 |
41,973 | Mammut-FE/nejm | src/util/flash/flash.js | function(_options){
// bugfix for ie title with flash
_title = document.title;
var _parent = _e._$get(_options.parent)||document.body,
_html = _t0._$get(_seed_html,_options);
_parent.insertAdjacentHTML(
!_options.hidden?'beforeEnd':'afterBegin',_html
);
} | javascript | function(_options){
// bugfix for ie title with flash
_title = document.title;
var _parent = _e._$get(_options.parent)||document.body,
_html = _t0._$get(_seed_html,_options);
_parent.insertAdjacentHTML(
!_options.hidden?'beforeEnd':'afterBegin',_html
);
} | [
"function",
"(",
"_options",
")",
"{",
"// bugfix for ie title with flash",
"_title",
"=",
"document",
".",
"title",
";",
"var",
"_parent",
"=",
"_e",
".",
"_$get",
"(",
"_options",
".",
"parent",
")",
"||",
"document",
".",
"body",
",",
"_html",
"=",
"_t0... | append flash element | [
"append",
"flash",
"element"
] | dfc09ac66a8d67620a7aea65e34d8a179976b3fb | https://github.com/Mammut-FE/nejm/blob/dfc09ac66a8d67620a7aea65e34d8a179976b3fb/src/util/flash/flash.js#L111-L119 | |
41,974 | Mammut-FE/nejm | src/util/flash/flash.js | function(_id,_event){
var _type = _event.type.toLowerCase();
_t1.requestAnimationFrame(function(){
_v._$dispatchEvent(_id,_type);
});
} | javascript | function(_id,_event){
var _type = _event.type.toLowerCase();
_t1.requestAnimationFrame(function(){
_v._$dispatchEvent(_id,_type);
});
} | [
"function",
"(",
"_id",
",",
"_event",
")",
"{",
"var",
"_type",
"=",
"_event",
".",
"type",
".",
"toLowerCase",
"(",
")",
";",
"_t1",
".",
"requestAnimationFrame",
"(",
"function",
"(",
")",
"{",
"_v",
".",
"_$dispatchEvent",
"(",
"_id",
",",
"_type",... | listen flash mouse event | [
"listen",
"flash",
"mouse",
"event"
] | dfc09ac66a8d67620a7aea65e34d8a179976b3fb | https://github.com/Mammut-FE/nejm/blob/dfc09ac66a8d67620a7aea65e34d8a179976b3fb/src/util/flash/flash.js#L121-L126 | |
41,975 | Mammut-FE/nejm | src/util/flash/flash.js | function(_options){
// init flash vars
var _id = _options.id,
_params = _options.params;
if (!_params){
_params = {};
_options.params = _params;
}
var _vars = _params.flashvars||'';
_vars += (!_vars?'':'&')+('id='+_id);
// delegate mouse event bubble
if (!_options.hidden&&(!!_options.target||
_h.__canFlashEventBubble(_params.wmode))){
var _tid = _e._$id(_options.target)||
_e._$id(_options.parent);
_cache[_id+'-tgt'] = _tid;
}
_params.flashvars = _vars;
// check event callback
_u._$loop(_options,function(_value,_key){
if (_u._$isFunction(_value)&&_key!='onready'){
_cache[_id+'-'+_key] = _value;
}
});
} | javascript | function(_options){
// init flash vars
var _id = _options.id,
_params = _options.params;
if (!_params){
_params = {};
_options.params = _params;
}
var _vars = _params.flashvars||'';
_vars += (!_vars?'':'&')+('id='+_id);
// delegate mouse event bubble
if (!_options.hidden&&(!!_options.target||
_h.__canFlashEventBubble(_params.wmode))){
var _tid = _e._$id(_options.target)||
_e._$id(_options.parent);
_cache[_id+'-tgt'] = _tid;
}
_params.flashvars = _vars;
// check event callback
_u._$loop(_options,function(_value,_key){
if (_u._$isFunction(_value)&&_key!='onready'){
_cache[_id+'-'+_key] = _value;
}
});
} | [
"function",
"(",
"_options",
")",
"{",
"// init flash vars",
"var",
"_id",
"=",
"_options",
".",
"id",
",",
"_params",
"=",
"_options",
".",
"params",
";",
"if",
"(",
"!",
"_params",
")",
"{",
"_params",
"=",
"{",
"}",
";",
"_options",
".",
"params",
... | init flash event | [
"init",
"flash",
"event"
] | dfc09ac66a8d67620a7aea65e34d8a179976b3fb | https://github.com/Mammut-FE/nejm/blob/dfc09ac66a8d67620a7aea65e34d8a179976b3fb/src/util/flash/flash.js#L151-L175 | |
41,976 | veo-labs/openveo-api | lib/providers/EntityProvider.js | EntityProvider | function EntityProvider(storage, location) {
EntityProvider.super_.call(this, storage);
Object.defineProperties(this, {
/**
* The location of the entities in the storage.
*
* @property location
* @type String
* @final
*/
location: {value: location}
});
if (Object.prototype.toString.call(this.location) !== '[object String]')
throw new TypeError('location must be a string');
} | javascript | function EntityProvider(storage, location) {
EntityProvider.super_.call(this, storage);
Object.defineProperties(this, {
/**
* The location of the entities in the storage.
*
* @property location
* @type String
* @final
*/
location: {value: location}
});
if (Object.prototype.toString.call(this.location) !== '[object String]')
throw new TypeError('location must be a string');
} | [
"function",
"EntityProvider",
"(",
"storage",
",",
"location",
")",
"{",
"EntityProvider",
".",
"super_",
".",
"call",
"(",
"this",
",",
"storage",
")",
";",
"Object",
".",
"defineProperties",
"(",
"this",
",",
"{",
"/**\n * The location of the entities in the... | Defines a provider holding a single type of resources.
An entity provider manages a single type of resources. These resources are stored into the given storage / location.
@class EntityProvider
@extends Provider
@constructor
@param {Storage} storage The storage to use to store provider entities
@param {String} location The location of the entities in the storage
@throws {TypeError} If storage and / or location is not valid | [
"Defines",
"a",
"provider",
"holding",
"a",
"single",
"type",
"of",
"resources",
"."
] | 493a811e9a5ba4d3e14910facaa7452caba1ab38 | https://github.com/veo-labs/openveo-api/blob/493a811e9a5ba4d3e14910facaa7452caba1ab38/lib/providers/EntityProvider.js#L22-L40 |
41,977 | veo-labs/openveo-api | lib/providers/EntityProvider.js | getEntities | function getEntities(callback) {
self.get(filter, fields, null, page, sort, function(error, entities, pagination) {
if (error) return callback(error);
allEntities = allEntities.concat(entities);
if (page < pagination.pages - 1) {
// There are other pages
// Get next page
page++;
getEntities(callback);
} else {
// No more pages
// End it
callback(null);
}
});
} | javascript | function getEntities(callback) {
self.get(filter, fields, null, page, sort, function(error, entities, pagination) {
if (error) return callback(error);
allEntities = allEntities.concat(entities);
if (page < pagination.pages - 1) {
// There are other pages
// Get next page
page++;
getEntities(callback);
} else {
// No more pages
// End it
callback(null);
}
});
} | [
"function",
"getEntities",
"(",
"callback",
")",
"{",
"self",
".",
"get",
"(",
"filter",
",",
"fields",
",",
"null",
",",
"page",
",",
"sort",
",",
"function",
"(",
"error",
",",
"entities",
",",
"pagination",
")",
"{",
"if",
"(",
"error",
")",
"retu... | Fetches all entities iterating on all pages.
@param {Function} callback The function to call when it's done | [
"Fetches",
"all",
"entities",
"iterating",
"on",
"all",
"pages",
"."
] | 493a811e9a5ba4d3e14910facaa7452caba1ab38 | https://github.com/veo-labs/openveo-api/blob/493a811e9a5ba4d3e14910facaa7452caba1ab38/lib/providers/EntityProvider.js#L121-L141 |
41,978 | coz-labo/coz-handlebars-engine | shim/node/engine.js | registerHelper | function registerHelper(name, helper) {
var s = this;
s.helpers = s.helpers || {};
s.helpers[name] = helper;
return s;
} | javascript | function registerHelper(name, helper) {
var s = this;
s.helpers = s.helpers || {};
s.helpers[name] = helper;
return s;
} | [
"function",
"registerHelper",
"(",
"name",
",",
"helper",
")",
"{",
"var",
"s",
"=",
"this",
";",
"s",
".",
"helpers",
"=",
"s",
".",
"helpers",
"||",
"{",
"}",
";",
"s",
".",
"helpers",
"[",
"name",
"]",
"=",
"helper",
";",
"return",
"s",
";",
... | Register a helper.
@param {string} name - Name of the helper.
@param {function} helper - Helper function.
@returns {HandlebarsEngine} - Returns self. | [
"Register",
"a",
"helper",
"."
] | 47c7d984ad3e97fc130f65ad9954c0a797f3be9e | https://github.com/coz-labo/coz-handlebars-engine/blob/47c7d984ad3e97fc130f65ad9954c0a797f3be9e/shim/node/engine.js#L73-L78 |
41,979 | coz-labo/coz-handlebars-engine | shim/node/engine.js | registerHelpers | function registerHelpers(helpers) {
var s = this;
var names = Object.keys(helpers || {});
for (var i = 0, len = names.length; i < len; i++) {
var name = names[i];
s.registerHelper(name, helpers[name]);
}
return s;
} | javascript | function registerHelpers(helpers) {
var s = this;
var names = Object.keys(helpers || {});
for (var i = 0, len = names.length; i < len; i++) {
var name = names[i];
s.registerHelper(name, helpers[name]);
}
return s;
} | [
"function",
"registerHelpers",
"(",
"helpers",
")",
"{",
"var",
"s",
"=",
"this",
";",
"var",
"names",
"=",
"Object",
".",
"keys",
"(",
"helpers",
"||",
"{",
"}",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"names",
".",
"length"... | Register multiple helpers.
@param {object} helpers - Helpers to register.
@returns {HandlebarsEngine} - Returns self. | [
"Register",
"multiple",
"helpers",
"."
] | 47c7d984ad3e97fc130f65ad9954c0a797f3be9e | https://github.com/coz-labo/coz-handlebars-engine/blob/47c7d984ad3e97fc130f65ad9954c0a797f3be9e/shim/node/engine.js#L85-L95 |
41,980 | veo-labs/openveo-api | lib/socket/SocketNamespace.js | SocketNamespace | function SocketNamespace() {
var self = this;
var namespace = null;
Object.defineProperties(this, {
/**
* The list of messages' handlers.
*
* @property handlers
* @type Object
*/
handlers: {value: {}},
/**
* The list of middlewares.
*
* @property middlewares
* @type Array
*/
middlewares: {value: []},
/**
* The socket namespace.
*
* @property namespace
* @type Namespace
*/
namespace: {
get: function() {
return namespace;
},
set: function(newNamespace) {
namespace = newNamespace;
mountHandlers.call(self);
mountMiddlewares.call(self);
}
}
});
} | javascript | function SocketNamespace() {
var self = this;
var namespace = null;
Object.defineProperties(this, {
/**
* The list of messages' handlers.
*
* @property handlers
* @type Object
*/
handlers: {value: {}},
/**
* The list of middlewares.
*
* @property middlewares
* @type Array
*/
middlewares: {value: []},
/**
* The socket namespace.
*
* @property namespace
* @type Namespace
*/
namespace: {
get: function() {
return namespace;
},
set: function(newNamespace) {
namespace = newNamespace;
mountHandlers.call(self);
mountMiddlewares.call(self);
}
}
});
} | [
"function",
"SocketNamespace",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"namespace",
"=",
"null",
";",
"Object",
".",
"defineProperties",
"(",
"this",
",",
"{",
"/**\n * The list of messages' handlers.\n *\n * @property handlers\n * @type Obj... | Defines socket.io namespace wrapper.
SocketNamespace wraps a socket.io namespace to be able to connect the namespace to the server after
adding handlers to it.
Creating a Namespace using socket.io can't be done without creating the server
and attaching the namespace to it.
var openVeoApi = require('@openveo/api');
var namespace = new openVeoApi.socket.SocketNamespace();
var server = new openVeoApi.socket.SocketServer();
// Add a middleware
namespace.use(function(socket, next) {
console.log('Called for every message');
});
// Listen to a message
namespace.on('test.message', function(data) {
console.log('test.message received');
console.log(data);
});
// Add namespace to server
server.addNamespace('/myName', namespace);
// Start server
server.listen(80, function() {
console.log('Socket server started');
namespace.emit('test.message', 'some data');
});
@class SocketNamespace
@constructor | [
"Defines",
"socket",
".",
"io",
"namespace",
"wrapper",
"."
] | 493a811e9a5ba4d3e14910facaa7452caba1ab38 | https://github.com/veo-labs/openveo-api/blob/493a811e9a5ba4d3e14910facaa7452caba1ab38/lib/socket/SocketNamespace.js#L72-L113 |
41,981 | atsid/circuits-js | js/NativeJsonpDataProvider.js | function (params) {
var element = document.createElement('script'),
headElement = document.getElementsByTagName('head')[0],
load = params.load,
error = params.error,
jsonpCallback = params.jsonpCallback,
timeout = params.timeout || 10000,
timeoutId,
handleError = function (err) {
window.clearTimeout(timeoutId);
delete window[jsonpCallback];
headElement.removeChild(element);
if (error) {
error("500", {message: err});
}
};
window[jsonpCallback] = function (data) {
window.clearTimeout(timeoutId);
// TODO: add response validation here
load("200", data);
delete window[jsonpCallback];
headElement.removeChild(element);
};
// Error handlers fall back to timeout.
element.onerror = handleError;
element.onreadystatechange = function () {
var readyState = element.readyState;
if (readyState !== 'loaded') {
handleError({type: 'error'});
}
};
timeoutId = window.setTimeout(handleError, timeout, 'timeout');
element.type = 'text/javascript';
element.src = this.updateQueryString(params.jsonpUrl, params.callbackName, jsonpCallback);
element.id = jsonpCallback;
element.async = true;
element.charset = 'utf-8';
headElement.appendChild(element);
} | javascript | function (params) {
var element = document.createElement('script'),
headElement = document.getElementsByTagName('head')[0],
load = params.load,
error = params.error,
jsonpCallback = params.jsonpCallback,
timeout = params.timeout || 10000,
timeoutId,
handleError = function (err) {
window.clearTimeout(timeoutId);
delete window[jsonpCallback];
headElement.removeChild(element);
if (error) {
error("500", {message: err});
}
};
window[jsonpCallback] = function (data) {
window.clearTimeout(timeoutId);
// TODO: add response validation here
load("200", data);
delete window[jsonpCallback];
headElement.removeChild(element);
};
// Error handlers fall back to timeout.
element.onerror = handleError;
element.onreadystatechange = function () {
var readyState = element.readyState;
if (readyState !== 'loaded') {
handleError({type: 'error'});
}
};
timeoutId = window.setTimeout(handleError, timeout, 'timeout');
element.type = 'text/javascript';
element.src = this.updateQueryString(params.jsonpUrl, params.callbackName, jsonpCallback);
element.id = jsonpCallback;
element.async = true;
element.charset = 'utf-8';
headElement.appendChild(element);
} | [
"function",
"(",
"params",
")",
"{",
"var",
"element",
"=",
"document",
".",
"createElement",
"(",
"'script'",
")",
",",
"headElement",
"=",
"document",
".",
"getElementsByTagName",
"(",
"'head'",
")",
"[",
"0",
"]",
",",
"load",
"=",
"params",
".",
"loa... | Adds script tag to header of page to make jsonp request and invokes the callback.
@param {object} params | [
"Adds",
"script",
"tag",
"to",
"header",
"of",
"page",
"to",
"make",
"jsonp",
"request",
"and",
"invokes",
"the",
"callback",
"."
] | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/NativeJsonpDataProvider.js#L72-L115 | |
41,982 | atsid/circuits-js | js/NativeJsonpDataProvider.js | function (url, key, value) {
var regex = new RegExp("([?|&])" + key + "=.*?(&|#|$)(.*)", "gi"),
separator,
hash;
if (regex.test(url)) {
url = url.replace(regex, '$1' + key + "=" + value + '$2$3');
} else {
separator = url.indexOf('?') !== -1 ? '&' : '?';
hash = url.split('#');
url = hash[0] + separator + key + '=' + value;
}
return url;
} | javascript | function (url, key, value) {
var regex = new RegExp("([?|&])" + key + "=.*?(&|#|$)(.*)", "gi"),
separator,
hash;
if (regex.test(url)) {
url = url.replace(regex, '$1' + key + "=" + value + '$2$3');
} else {
separator = url.indexOf('?') !== -1 ? '&' : '?';
hash = url.split('#');
url = hash[0] + separator + key + '=' + value;
}
return url;
} | [
"function",
"(",
"url",
",",
"key",
",",
"value",
")",
"{",
"var",
"regex",
"=",
"new",
"RegExp",
"(",
"\"([?|&])\"",
"+",
"key",
"+",
"\"=.*?(&|#|$)(.*)\"",
",",
"\"gi\"",
")",
",",
"separator",
",",
"hash",
";",
"if",
"(",
"regex",
".",
"test",
"("... | Appends the callback parameter to the existing url
@param {string} url
@param {string} key
@param {string} value
@returns {string} | [
"Appends",
"the",
"callback",
"parameter",
"to",
"the",
"existing",
"url"
] | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/NativeJsonpDataProvider.js#L124-L137 | |
41,983 | jonschlinkert/template-render | index.js | norender | function norender(app, ext, file, locals) {
return !app.engines.hasOwnProperty(ext)
|| app.isTrue('norender') || app.isFalse('render')
|| file.norender === true || file.render === false
|| locals.norender === true || locals.render === false;
} | javascript | function norender(app, ext, file, locals) {
return !app.engines.hasOwnProperty(ext)
|| app.isTrue('norender') || app.isFalse('render')
|| file.norender === true || file.render === false
|| locals.norender === true || locals.render === false;
} | [
"function",
"norender",
"(",
"app",
",",
"ext",
",",
"file",
",",
"locals",
")",
"{",
"return",
"!",
"app",
".",
"engines",
".",
"hasOwnProperty",
"(",
"ext",
")",
"||",
"app",
".",
"isTrue",
"(",
"'norender'",
")",
"||",
"app",
".",
"isFalse",
"(",
... | Push the `file` through if the user has specfied
not to render it. | [
"Push",
"the",
"file",
"through",
"if",
"the",
"user",
"has",
"specfied",
"not",
"to",
"render",
"it",
"."
] | 43d9aca25c834f9d8a895fe96aa987762c69e8ca | https://github.com/jonschlinkert/template-render/blob/43d9aca25c834f9d8a895fe96aa987762c69e8ca/index.js#L67-L72 |
41,984 | get-focus/deprecated-focus-graph | src/middlewares/validate.js | validateProperty | function validateProperty(property, validator) {
let isValid;
if (!validator) {
return void 0;
}
if (!property) {
return void 0;
}
const {value} = property;
const {options} = validator;
const isValueNullOrUndefined = isNull(value) || isUndefined(value );
isValid = (() => {
switch (validator.type) {
case 'required':
const prevalidString = '' === property.value ? false : true;
const prevalidDate = true;
return true === validator.value ? (!isNull(value) && !isUndefined(value) && prevalidString && prevalidDate) : true;
case 'regex':
if (isValueNullOrUndefined) {
return true;
}
return validator.value.test(value);
case 'email':
if (isValueNullOrUndefined) {
return true;
}
return emailValidation(value, options);
case 'number':
return numberValidation(value, options);
case 'string':
const stringToValidate = value || '';
return stringLength(stringToValidate, options);
case 'date':
return dateValidation(value, options);
case 'function':
return validator.value(value, options);
case 'checkbox':
return (isUndefined(value) || isNull(value)) ? false : true;
default:
return void 0;
}
})();
if (isUndefined(isValid) || isNull(isValid)) {
console.warn(`The validator of type: ${validator.type} is not defined`);
} else if (false === isValid) {
//Add the name of the property.
return getErrorLabel(validator.type, property.modelName + '.' + property.name, options); //"The property " + property.name + " is invalid.";
}
} | javascript | function validateProperty(property, validator) {
let isValid;
if (!validator) {
return void 0;
}
if (!property) {
return void 0;
}
const {value} = property;
const {options} = validator;
const isValueNullOrUndefined = isNull(value) || isUndefined(value );
isValid = (() => {
switch (validator.type) {
case 'required':
const prevalidString = '' === property.value ? false : true;
const prevalidDate = true;
return true === validator.value ? (!isNull(value) && !isUndefined(value) && prevalidString && prevalidDate) : true;
case 'regex':
if (isValueNullOrUndefined) {
return true;
}
return validator.value.test(value);
case 'email':
if (isValueNullOrUndefined) {
return true;
}
return emailValidation(value, options);
case 'number':
return numberValidation(value, options);
case 'string':
const stringToValidate = value || '';
return stringLength(stringToValidate, options);
case 'date':
return dateValidation(value, options);
case 'function':
return validator.value(value, options);
case 'checkbox':
return (isUndefined(value) || isNull(value)) ? false : true;
default:
return void 0;
}
})();
if (isUndefined(isValid) || isNull(isValid)) {
console.warn(`The validator of type: ${validator.type} is not defined`);
} else if (false === isValid) {
//Add the name of the property.
return getErrorLabel(validator.type, property.modelName + '.' + property.name, options); //"The property " + property.name + " is invalid.";
}
} | [
"function",
"validateProperty",
"(",
"property",
",",
"validator",
")",
"{",
"let",
"isValid",
";",
"if",
"(",
"!",
"validator",
")",
"{",
"return",
"void",
"0",
";",
"}",
"if",
"(",
"!",
"property",
")",
"{",
"return",
"void",
"0",
";",
"}",
"const"... | Validate a property.
@param {object} property - The property to validate.
@param {function} validator - The validator to apply.
@return {object} - The property validation status. | [
"Validate",
"a",
"property",
"."
] | 40fa139456d9c1c91af67870df484fe5eb353291 | https://github.com/get-focus/deprecated-focus-graph/blob/40fa139456d9c1c91af67870df484fe5eb353291/src/middlewares/validate.js#L97-L145 |
41,985 | ofidj/fidj | .todo/miapp.tools.js | function (evt,stopBubble) {
'use strict';
//console.log('fidjBlockMove');
// All but scrollable element = .c4p-container-scroll-y
//if (evt.preventDefault) evt.preventDefault() ;
//if (evt.preventDefault && !$(evt.target).parents('.c4p-container-scroll-y')[0]) {
// evt.preventDefault();
//}
if (evt.preventDefault && !$('.c4p-container-scroll-y').has($(evt.target)).length) {
evt.preventDefault();
}
if (stopBubble && evt.stopPropagation) evt.stopPropagation();
if (stopBubble && !evt.cancelBubble) evt.cancelBubble = true;
} | javascript | function (evt,stopBubble) {
'use strict';
//console.log('fidjBlockMove');
// All but scrollable element = .c4p-container-scroll-y
//if (evt.preventDefault) evt.preventDefault() ;
//if (evt.preventDefault && !$(evt.target).parents('.c4p-container-scroll-y')[0]) {
// evt.preventDefault();
//}
if (evt.preventDefault && !$('.c4p-container-scroll-y').has($(evt.target)).length) {
evt.preventDefault();
}
if (stopBubble && evt.stopPropagation) evt.stopPropagation();
if (stopBubble && !evt.cancelBubble) evt.cancelBubble = true;
} | [
"function",
"(",
"evt",
",",
"stopBubble",
")",
"{",
"'use strict'",
";",
"//console.log('fidjBlockMove');",
"// All but scrollable element = .c4p-container-scroll-y",
"//if (evt.preventDefault) evt.preventDefault() ;",
"//if (evt.preventDefault && !$(evt.target).parents('.c4p-container-scro... | Invoke the function immediately to create this class. Usefull | [
"Invoke",
"the",
"function",
"immediately",
"to",
"create",
"this",
"class",
".",
"Usefull"
] | e57ebece54ee68211d43802a8e0feeef098d3e36 | https://github.com/ofidj/fidj/blob/e57ebece54ee68211d43802a8e0feeef098d3e36/.todo/miapp.tools.js#L371-L387 | |
41,986 | ofidj/fidj | .todo/miapp.tools.js | fidjDateParse | function fidjDateParse(date) {
if (!date || typeof date != 'string' || date == '') return false;
// Date (choose 0 in date to force an error if parseInt fails)
var yearS = parseInt(date.substr(0,4), 10) || 0;
var monthS = parseInt(date.substr(5,2), 10) || 0;
var dayS = parseInt(date.substr(8,2), 10) || 0;
var hourS = parseInt(date.substr(11,2), 10) || 0;
var minuteS = parseInt(date.substr(14,2),10) || 0;
var secS = parseInt(date.substr(17,2),10) || 0;
/*
BEWARE : here are the ONLY formats supported by all browsers in creating a Date object
var d = new Date(2011, 01, 07); // yyyy, mm-1, dd
var d = new Date(2011, 01, 07, 11, 05, 00); // yyyy, mm-1, dd, hh, mm, ss
var d = new Date("02/07/2011"); // "mm/dd/yyyy"
var d = new Date("02/07/2011 11:05:00"); // "mm/dd/yyyy hh:mm:ss"
var d = new Date(1297076700000); // milliseconds
var d = new Date("Mon Feb 07 2011 11:05:00 GMT"); // ""Day Mon dd yyyy hh:mm:ss GMT/UTC
*/
var newDate = new Date(yearS, monthS-1, dayS, hourS, minuteS, secS, 0);
if ((newDate.getFullYear() !== yearS) || (newDate.getMonth() !== (monthS-1)) || (newDate.getDate() !== dayS)) {
// Invalid date
return false;
}
return newDate;
} | javascript | function fidjDateParse(date) {
if (!date || typeof date != 'string' || date == '') return false;
// Date (choose 0 in date to force an error if parseInt fails)
var yearS = parseInt(date.substr(0,4), 10) || 0;
var monthS = parseInt(date.substr(5,2), 10) || 0;
var dayS = parseInt(date.substr(8,2), 10) || 0;
var hourS = parseInt(date.substr(11,2), 10) || 0;
var minuteS = parseInt(date.substr(14,2),10) || 0;
var secS = parseInt(date.substr(17,2),10) || 0;
/*
BEWARE : here are the ONLY formats supported by all browsers in creating a Date object
var d = new Date(2011, 01, 07); // yyyy, mm-1, dd
var d = new Date(2011, 01, 07, 11, 05, 00); // yyyy, mm-1, dd, hh, mm, ss
var d = new Date("02/07/2011"); // "mm/dd/yyyy"
var d = new Date("02/07/2011 11:05:00"); // "mm/dd/yyyy hh:mm:ss"
var d = new Date(1297076700000); // milliseconds
var d = new Date("Mon Feb 07 2011 11:05:00 GMT"); // ""Day Mon dd yyyy hh:mm:ss GMT/UTC
*/
var newDate = new Date(yearS, monthS-1, dayS, hourS, minuteS, secS, 0);
if ((newDate.getFullYear() !== yearS) || (newDate.getMonth() !== (monthS-1)) || (newDate.getDate() !== dayS)) {
// Invalid date
return false;
}
return newDate;
} | [
"function",
"fidjDateParse",
"(",
"date",
")",
"{",
"if",
"(",
"!",
"date",
"||",
"typeof",
"date",
"!=",
"'string'",
"||",
"date",
"==",
"''",
")",
"return",
"false",
";",
"// Date (choose 0 in date to force an error if parseInt fails)",
"var",
"yearS",
"=",
"p... | Parse a date string to create a Date object
@param {string} date string at format "yyyy-MM-dd HH:mm:ss"
@returns {Date} Date object or false if invalid date | [
"Parse",
"a",
"date",
"string",
"to",
"create",
"a",
"Date",
"object"
] | e57ebece54ee68211d43802a8e0feeef098d3e36 | https://github.com/ofidj/fidj/blob/e57ebece54ee68211d43802a8e0feeef098d3e36/.todo/miapp.tools.js#L1576-L1601 |
41,987 | ofidj/fidj | .todo/miapp.tools.js | function (position) {
var lat = position.coords.latitude;
var lng = position.coords.longitude;
geo_codeLatLng(lat, lng);
} | javascript | function (position) {
var lat = position.coords.latitude;
var lng = position.coords.longitude;
geo_codeLatLng(lat, lng);
} | [
"function",
"(",
"position",
")",
"{",
"var",
"lat",
"=",
"position",
".",
"coords",
".",
"latitude",
";",
"var",
"lng",
"=",
"position",
".",
"coords",
".",
"longitude",
";",
"geo_codeLatLng",
"(",
"lat",
",",
"lng",
")",
";",
"}"
] | Get the latitude and the longitude; | [
"Get",
"the",
"latitude",
"and",
"the",
"longitude",
";"
] | e57ebece54ee68211d43802a8e0feeef098d3e36 | https://github.com/ofidj/fidj/blob/e57ebece54ee68211d43802a8e0feeef098d3e36/.todo/miapp.tools.js#L3818-L3822 | |
41,988 | lighterio/ltl | ltl.js | function (name) {
var filters = ltl.filters
var filter = filters[name]
if (!filter) {
try {
filter = filters[name] = ltl.scope[name] || (typeof require !== 'undefined' ? require(name) : null)
} catch (ignore) {
}
}
if (!filter) {
var todo = 'Set window.ltl.filters.' + name + ' to function that accepts a state object and returns a string of HTML.'
todo += 'Or run the following:\n cd ' + process.cwd() + '\n npm install --save ' + name
throw new Error('[Ltl] Unknown filter: "' + name + '". ' + todo)
}
return filter
} | javascript | function (name) {
var filters = ltl.filters
var filter = filters[name]
if (!filter) {
try {
filter = filters[name] = ltl.scope[name] || (typeof require !== 'undefined' ? require(name) : null)
} catch (ignore) {
}
}
if (!filter) {
var todo = 'Set window.ltl.filters.' + name + ' to function that accepts a state object and returns a string of HTML.'
todo += 'Or run the following:\n cd ' + process.cwd() + '\n npm install --save ' + name
throw new Error('[Ltl] Unknown filter: "' + name + '". ' + todo)
}
return filter
} | [
"function",
"(",
"name",
")",
"{",
"var",
"filters",
"=",
"ltl",
".",
"filters",
"var",
"filter",
"=",
"filters",
"[",
"name",
"]",
"if",
"(",
"!",
"filter",
")",
"{",
"try",
"{",
"filter",
"=",
"filters",
"[",
"name",
"]",
"=",
"ltl",
".",
"scop... | Get a module for filtering. | [
"Get",
"a",
"module",
"for",
"filtering",
"."
] | 98ecafbf42b3003ba451ed8e9759ac9eeab09d46 | https://github.com/lighterio/ltl/blob/98ecafbf42b3003ba451ed8e9759ac9eeab09d46/ltl.js#L56-L71 | |
41,989 | emeryrose/coalescent | lib/middleware/courier.js | Courier | function Courier(opts) {
stream.Transform.call(this, { objectMode: true });
this.options = merge(Object.create(Courier.DEFAULTS), opts || {});
} | javascript | function Courier(opts) {
stream.Transform.call(this, { objectMode: true });
this.options = merge(Object.create(Courier.DEFAULTS), opts || {});
} | [
"function",
"Courier",
"(",
"opts",
")",
"{",
"stream",
".",
"Transform",
".",
"call",
"(",
"this",
",",
"{",
"objectMode",
":",
"true",
"}",
")",
";",
"this",
".",
"options",
"=",
"merge",
"(",
"Object",
".",
"create",
"(",
"Courier",
".",
"DEFAULTS... | JSON parsing middleware designed for easy message routing
@constructor
@param {object} options | [
"JSON",
"parsing",
"middleware",
"designed",
"for",
"easy",
"message",
"routing"
] | 5e722d4e1c16b9a9e959b281f6bb07713c60c46a | https://github.com/emeryrose/coalescent/blob/5e722d4e1c16b9a9e959b281f6bb07713c60c46a/lib/middleware/courier.js#L25-L29 |
41,990 | emeryrose/coalescent | lib/middleware/smartrelay.js | SmartRelay | function SmartRelay(socket, options) {
stream.Transform.call(this, {});
this.options = merge(Object.create(SmartRelay.DEFAULTS), options || {});
this.socket = socket;
this.recentData = [];
this.peers = function () {
return [];
};
} | javascript | function SmartRelay(socket, options) {
stream.Transform.call(this, {});
this.options = merge(Object.create(SmartRelay.DEFAULTS), options || {});
this.socket = socket;
this.recentData = [];
this.peers = function () {
return [];
};
} | [
"function",
"SmartRelay",
"(",
"socket",
",",
"options",
")",
"{",
"stream",
".",
"Transform",
".",
"call",
"(",
"this",
",",
"{",
"}",
")",
";",
"this",
".",
"options",
"=",
"merge",
"(",
"Object",
".",
"create",
"(",
"SmartRelay",
".",
"DEFAULTS",
... | Smarter implementation of a gossip protocol
@constructor
@param {object} socket
@param {object} options | [
"Smarter",
"implementation",
"of",
"a",
"gossip",
"protocol"
] | 5e722d4e1c16b9a9e959b281f6bb07713c60c46a | https://github.com/emeryrose/coalescent/blob/5e722d4e1c16b9a9e959b281f6bb07713c60c46a/lib/middleware/smartrelay.js#L24-L34 |
41,991 | ortoo/angular-resource | src/model.js | save | function save() {
var res = this;
res.$created = true;
return this.$loc.$save(this.$toObject()).then(function() {
emitter.emit('updated', res);
if (!res.$resolved) {
res.$deferred.resolve(res);
res.$resolved = true;
}
return res;
});
} | javascript | function save() {
var res = this;
res.$created = true;
return this.$loc.$save(this.$toObject()).then(function() {
emitter.emit('updated', res);
if (!res.$resolved) {
res.$deferred.resolve(res);
res.$resolved = true;
}
return res;
});
} | [
"function",
"save",
"(",
")",
"{",
"var",
"res",
"=",
"this",
";",
"res",
".",
"$created",
"=",
"true",
";",
"return",
"this",
".",
"$loc",
".",
"$save",
"(",
"this",
".",
"$toObject",
"(",
")",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
... | The promise resolves once the save has been committed | [
"The",
"promise",
"resolves",
"once",
"the",
"save",
"has",
"been",
"committed"
] | c4a23525237a89d7e36268c6f683f5f57e138c66 | https://github.com/ortoo/angular-resource/blob/c4a23525237a89d7e36268c6f683f5f57e138c66/src/model.js#L109-L120 |
41,992 | ortoo/angular-resource | src/model.js | updateOrCreate | function updateOrCreate(val) {
var res = _resources[val._id];
if (!res) {
res = new Resource(val, false, new Date().getTime());
} else {
res.$updateServer(val);
}
return res;
} | javascript | function updateOrCreate(val) {
var res = _resources[val._id];
if (!res) {
res = new Resource(val, false, new Date().getTime());
} else {
res.$updateServer(val);
}
return res;
} | [
"function",
"updateOrCreate",
"(",
"val",
")",
"{",
"var",
"res",
"=",
"_resources",
"[",
"val",
".",
"_id",
"]",
";",
"if",
"(",
"!",
"res",
")",
"{",
"res",
"=",
"new",
"Resource",
"(",
"val",
",",
"false",
",",
"new",
"Date",
"(",
")",
".",
... | updates or creates a model depending on whether we know about it already. This is usually used when we recieve a response with model data from the server using a non-standard method | [
"updates",
"or",
"creates",
"a",
"model",
"depending",
"on",
"whether",
"we",
"know",
"about",
"it",
"already",
".",
"This",
"is",
"usually",
"used",
"when",
"we",
"recieve",
"a",
"response",
"with",
"model",
"data",
"from",
"the",
"server",
"using",
"a",
... | c4a23525237a89d7e36268c6f683f5f57e138c66 | https://github.com/ortoo/angular-resource/blob/c4a23525237a89d7e36268c6f683f5f57e138c66/src/model.js#L228-L237 |
41,993 | atsid/circuits-js | js/ServiceFactory.js | function (modelName, plugins) {
logger.debug("Getting service for model: " + modelName);
var smd = this.config.resolverByModel(modelName);
return this.getService(smd, plugins);
} | javascript | function (modelName, plugins) {
logger.debug("Getting service for model: " + modelName);
var smd = this.config.resolverByModel(modelName);
return this.getService(smd, plugins);
} | [
"function",
"(",
"modelName",
",",
"plugins",
")",
"{",
"logger",
".",
"debug",
"(",
"\"Getting service for model: \"",
"+",
"modelName",
")",
";",
"var",
"smd",
"=",
"this",
".",
"config",
".",
"resolverByModel",
"(",
"modelName",
")",
";",
"return",
"this"... | Returns an instance of a Service that can provide crud operations for a model.
@param modelName - the model that will be served.
@param plugins - plugins for read/write and other operations, which modify default service method behavior
@return {circuits/Service} - the realized service. | [
"Returns",
"an",
"instance",
"of",
"a",
"Service",
"that",
"can",
"provide",
"crud",
"operations",
"for",
"a",
"model",
"."
] | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/ServiceFactory.js#L75-L79 | |
41,994 | atsid/circuits-js | js/ServiceFactory.js | function (serviceName, plugins) {
logger.debug("Getting service: " + serviceName);
var smd = this.config.resolver(serviceName);
return this.getService(smd, plugins);
} | javascript | function (serviceName, plugins) {
logger.debug("Getting service: " + serviceName);
var smd = this.config.resolver(serviceName);
return this.getService(smd, plugins);
} | [
"function",
"(",
"serviceName",
",",
"plugins",
")",
"{",
"logger",
".",
"debug",
"(",
"\"Getting service: \"",
"+",
"serviceName",
")",
";",
"var",
"smd",
"=",
"this",
".",
"config",
".",
"resolver",
"(",
"serviceName",
")",
";",
"return",
"this",
".",
... | Returns an instance of a Service using its name.
@param serviceName - the string name of the service that can be resolved to an smd by the configured resolver.
@param plugins - plugins for read/write and other operations, which modify default service method behavior
@return {circuits.Service} - the realized service. | [
"Returns",
"an",
"instance",
"of",
"a",
"Service",
"using",
"its",
"name",
"."
] | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/ServiceFactory.js#L88-L92 | |
41,995 | atsid/circuits-js | js/ServiceFactory.js | function (smd, plugins) {
var reader = this.newReader(smd),
provider = this.config.provider,
matcher = this.pluginMatcher,
sentPlugins = plugins || [],
mixinPlugins = [],
pertinentMethods,
service;
mixinPlugins = mixinPlugins.concat(
this.pluginMatcher.listForServiceOnly(util.serviceName(reader.getSchemaId()),
reader.getMethodNames(), "mixin", this.config.plugins),
this.pluginMatcher.listForServiceOnly(util.serviceName(reader.getSchemaId()),
reader.getMethodNames(), "mixin", sentPlugins)
);
service = new Service(reader, provider, this.config.plugins, sentPlugins);
logger.debug("Mixin plugins for " + service.name, mixinPlugins);
util.executePluginChain(mixinPlugins, function (plugin) {
// get method names to pass to mixin plugin.
pertinentMethods = matcher.matchingMethodNames(service.name, reader.getMethodNames(), plugin);
plugin.fn.call(plugin.scope || plugin, service, pertinentMethods);
});
return service;
} | javascript | function (smd, plugins) {
var reader = this.newReader(smd),
provider = this.config.provider,
matcher = this.pluginMatcher,
sentPlugins = plugins || [],
mixinPlugins = [],
pertinentMethods,
service;
mixinPlugins = mixinPlugins.concat(
this.pluginMatcher.listForServiceOnly(util.serviceName(reader.getSchemaId()),
reader.getMethodNames(), "mixin", this.config.plugins),
this.pluginMatcher.listForServiceOnly(util.serviceName(reader.getSchemaId()),
reader.getMethodNames(), "mixin", sentPlugins)
);
service = new Service(reader, provider, this.config.plugins, sentPlugins);
logger.debug("Mixin plugins for " + service.name, mixinPlugins);
util.executePluginChain(mixinPlugins, function (plugin) {
// get method names to pass to mixin plugin.
pertinentMethods = matcher.matchingMethodNames(service.name, reader.getMethodNames(), plugin);
plugin.fn.call(plugin.scope || plugin, service, pertinentMethods);
});
return service;
} | [
"function",
"(",
"smd",
",",
"plugins",
")",
"{",
"var",
"reader",
"=",
"this",
".",
"newReader",
"(",
"smd",
")",
",",
"provider",
"=",
"this",
".",
"config",
".",
"provider",
",",
"matcher",
"=",
"this",
".",
"pluginMatcher",
",",
"sentPlugins",
"=",... | Returns an instance of a Service using its SMD.
@param smd - the SMD instance to use for service parameters
@param callbacks - load and error handlers for each service method, or optionally globally. Empty defaults will be mixed in to avoid errors.
@param plugins - plugins for read/write and other operations, which modify default service method behavior
@return {circuits.Service} - the realized service. | [
"Returns",
"an",
"instance",
"of",
"a",
"Service",
"using",
"its",
"SMD",
"."
] | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/ServiceFactory.js#L115-L143 | |
41,996 | atsid/circuits-js | js/ServiceFactory.js | function (smd) {
// zyp format by default.
var ret = new ZypSMDReader(smd, this.config.resolver);
if (!smd.SMDVersion) {
//not zyp then fail.
throw new Error("Argument is not an SMD.");
}
return ret;
} | javascript | function (smd) {
// zyp format by default.
var ret = new ZypSMDReader(smd, this.config.resolver);
if (!smd.SMDVersion) {
//not zyp then fail.
throw new Error("Argument is not an SMD.");
}
return ret;
} | [
"function",
"(",
"smd",
")",
"{",
"// zyp format by default.",
"var",
"ret",
"=",
"new",
"ZypSMDReader",
"(",
"smd",
",",
"this",
".",
"config",
".",
"resolver",
")",
";",
"if",
"(",
"!",
"smd",
".",
"SMDVersion",
")",
"{",
"//not zyp then fail.",
"throw",... | Retrieves a reader capable of handling the passed service descriptor.
@param {Object} smd - the service descriptor to retrieve a reader for. | [
"Retrieves",
"a",
"reader",
"capable",
"of",
"handling",
"the",
"passed",
"service",
"descriptor",
"."
] | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/ServiceFactory.js#L187-L195 | |
41,997 | artdecocode/promto | build/index.js | createPromiseWithTimeout | async function createPromiseWithTimeout(promise, timeout, desc) {
if (!(promise instanceof Promise))
throw new Error('Promise expected')
if (!timeout)
throw new Error('Timeout must be a number')
if (timeout < 0)
throw new Error('Timeout cannot be negative')
const { promise: toPromise, timeout: to } = makeTimeoutPromise(desc, timeout)
try {
return await Promise.race([
promise,
toPromise,
])
} finally {
clearTimeout(to)
}
} | javascript | async function createPromiseWithTimeout(promise, timeout, desc) {
if (!(promise instanceof Promise))
throw new Error('Promise expected')
if (!timeout)
throw new Error('Timeout must be a number')
if (timeout < 0)
throw new Error('Timeout cannot be negative')
const { promise: toPromise, timeout: to } = makeTimeoutPromise(desc, timeout)
try {
return await Promise.race([
promise,
toPromise,
])
} finally {
clearTimeout(to)
}
} | [
"async",
"function",
"createPromiseWithTimeout",
"(",
"promise",
",",
"timeout",
",",
"desc",
")",
"{",
"if",
"(",
"!",
"(",
"promise",
"instanceof",
"Promise",
")",
")",
"throw",
"new",
"Error",
"(",
"'Promise expected'",
")",
"if",
"(",
"!",
"timeout",
"... | Create a promise which will be rejected after a timeout.
@param {!Promise} promise A promise to race with
@param {number} timeout Timeout in ms after which to reject
@param {string} [desc] Description of a promise to be printed in error
@returns {!Promise} A promise with a timeout | [
"Create",
"a",
"promise",
"which",
"will",
"be",
"rejected",
"after",
"a",
"timeout",
"."
] | 1a66afc43611e078f8ab4ed41aa10a675d395682 | https://github.com/artdecocode/promto/blob/1a66afc43611e078f8ab4ed41aa10a675d395682/build/index.js#L25-L42 |
41,998 | konfirm/node-is-type | source/type.js | ancestry | function ancestry(input) {
const proto = input && typeof input === 'object' ? Object.getPrototypeOf(input) : null;
return proto ? ancestry(proto).concat(proto) : [];
} | javascript | function ancestry(input) {
const proto = input && typeof input === 'object' ? Object.getPrototypeOf(input) : null;
return proto ? ancestry(proto).concat(proto) : [];
} | [
"function",
"ancestry",
"(",
"input",
")",
"{",
"const",
"proto",
"=",
"input",
"&&",
"typeof",
"input",
"===",
"'object'",
"?",
"Object",
".",
"getPrototypeOf",
"(",
"input",
")",
":",
"null",
";",
"return",
"proto",
"?",
"ancestry",
"(",
"proto",
")",
... | Obtain the prototype chain for the given input
@param {any} input
@return {array} ancestry | [
"Obtain",
"the",
"prototype",
"chain",
"for",
"the",
"given",
"input"
] | daaa18de5ccfbca7661357bcee855bb7df26c5c8 | https://github.com/konfirm/node-is-type/blob/daaa18de5ccfbca7661357bcee855bb7df26c5c8/source/type.js#L11-L15 |
41,999 | konfirm/node-is-type | source/type.js | typeInAncestry | function typeInAncestry(type, input) {
return ancestry(input)
.reduce((carry, obj) => carry || Type.objectName(obj) === type, false);
} | javascript | function typeInAncestry(type, input) {
return ancestry(input)
.reduce((carry, obj) => carry || Type.objectName(obj) === type, false);
} | [
"function",
"typeInAncestry",
"(",
"type",
",",
"input",
")",
"{",
"return",
"ancestry",
"(",
"input",
")",
".",
"reduce",
"(",
"(",
"carry",
",",
"obj",
")",
"=>",
"carry",
"||",
"Type",
".",
"objectName",
"(",
"obj",
")",
"===",
"type",
",",
"false... | Verify whether the given type resides in the prototype chain of the input
@param {string} type
@param {any} input
@return {boolean} type in chain | [
"Verify",
"whether",
"the",
"given",
"type",
"resides",
"in",
"the",
"prototype",
"chain",
"of",
"the",
"input"
] | daaa18de5ccfbca7661357bcee855bb7df26c5c8 | https://github.com/konfirm/node-is-type/blob/daaa18de5ccfbca7661357bcee855bb7df26c5c8/source/type.js#L24-L27 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.