repo stringlengths 5 67 | path stringlengths 4 116 | func_name stringlengths 0 58 | original_string stringlengths 52 373k | language stringclasses 1
value | code stringlengths 52 373k | code_tokens list | docstring stringlengths 4 11.8k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 86 226 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
joyent/kang | examples/webconsole/resources/js/jquery/jquery.dataTables.js | _fnBindAction | function _fnBindAction( n, oData, fn )
{
$(n)
.bind( 'click.DT', oData, function (e) {
n.blur(); // Remove focus outline for mouse users
fn(e);
} )
.bind( 'keypress.DT', oData, function (e){
if ( e.which === 13 ) {
fn(e);
} } )
.bind( 'selectstart.DT', function () {
... | javascript | function _fnBindAction( n, oData, fn )
{
$(n)
.bind( 'click.DT', oData, function (e) {
n.blur(); // Remove focus outline for mouse users
fn(e);
} )
.bind( 'keypress.DT', oData, function (e){
if ( e.which === 13 ) {
fn(e);
} } )
.bind( 'selectstart.DT', function () {
... | [
"function",
"_fnBindAction",
"(",
"n",
",",
"oData",
",",
"fn",
")",
"{",
"$",
"(",
"n",
")",
".",
"bind",
"(",
"'click.DT'",
",",
"oData",
",",
"function",
"(",
"e",
")",
"{",
"n",
".",
"blur",
"(",
")",
";",
"// Remove focus outline for mouse users",... | Bind an event handers to allow a click or return key to activate the callback.
This is good for accessability since a return on the keyboard will have the
same effect as a click, if the element has focus.
@param {element} n Element to bind the action to
@param {object} oData Data object to pass to the triggered functio... | [
"Bind",
"an",
"event",
"handers",
"to",
"allow",
"a",
"click",
"or",
"return",
"key",
"to",
"activate",
"the",
"callback",
".",
"This",
"is",
"good",
"for",
"accessability",
"since",
"a",
"return",
"on",
"the",
"keyboard",
"will",
"have",
"the",
"same",
... | 9b138f2b4fb7873b9b0f271516daf36e20c9c037 | https://github.com/joyent/kang/blob/9b138f2b4fb7873b9b0f271516daf36e20c9c037/examples/webconsole/resources/js/jquery/jquery.dataTables.js#L4661-L4676 | train |
joyent/kang | examples/webconsole/resources/js/jquery/jquery.dataTables.js | _fnCallbackReg | function _fnCallbackReg( oSettings, sStore, fn, sName )
{
if ( fn )
{
oSettings[sStore].push( {
"fn": fn,
"sName": sName
} );
}
} | javascript | function _fnCallbackReg( oSettings, sStore, fn, sName )
{
if ( fn )
{
oSettings[sStore].push( {
"fn": fn,
"sName": sName
} );
}
} | [
"function",
"_fnCallbackReg",
"(",
"oSettings",
",",
"sStore",
",",
"fn",
",",
"sName",
")",
"{",
"if",
"(",
"fn",
")",
"{",
"oSettings",
"[",
"sStore",
"]",
".",
"push",
"(",
"{",
"\"fn\"",
":",
"fn",
",",
"\"sName\"",
":",
"sName",
"}",
")",
";",... | Register a callback function. Easily allows a callback function to be added to
an array store of callback functions that can then all be called together.
@param {object} oSettings dataTables settings object
@param {string} sStore Name of the array storeage for the callbacks in oSettings
@param {function} fn Function to... | [
"Register",
"a",
"callback",
"function",
".",
"Easily",
"allows",
"a",
"callback",
"function",
"to",
"be",
"added",
"to",
"an",
"array",
"store",
"of",
"callback",
"functions",
"that",
"can",
"then",
"all",
"be",
"called",
"together",
"."
] | 9b138f2b4fb7873b9b0f271516daf36e20c9c037 | https://github.com/joyent/kang/blob/9b138f2b4fb7873b9b0f271516daf36e20c9c037/examples/webconsole/resources/js/jquery/jquery.dataTables.js#L4688-L4697 | train |
joyent/kang | examples/webconsole/resources/js/jquery/jquery.dataTables.js | function ()
{
if ( this.oFeatures.bServerSide ) {
if ( this.oFeatures.bPaginate === false || this._iDisplayLength == -1 ) {
return this._iDisplayStart+this.aiDisplay.length;
} else {
return Math.min( this._iDisplayStart+this._iDisplayLength,
this._iRecordsDisplay );
}
} else {
r... | javascript | function ()
{
if ( this.oFeatures.bServerSide ) {
if ( this.oFeatures.bPaginate === false || this._iDisplayLength == -1 ) {
return this._iDisplayStart+this.aiDisplay.length;
} else {
return Math.min( this._iDisplayStart+this._iDisplayLength,
this._iRecordsDisplay );
}
} else {
r... | [
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"oFeatures",
".",
"bServerSide",
")",
"{",
"if",
"(",
"this",
".",
"oFeatures",
".",
"bPaginate",
"===",
"false",
"||",
"this",
".",
"_iDisplayLength",
"==",
"-",
"1",
")",
"{",
"return",
"this",
"."... | Set the display end point - aiDisplay index
@type function
@todo Should do away with _iDisplayEnd and calculate it on-the-fly here | [
"Set",
"the",
"display",
"end",
"point",
"-",
"aiDisplay",
"index"
] | 9b138f2b4fb7873b9b0f271516daf36e20c9c037 | https://github.com/joyent/kang/blob/9b138f2b4fb7873b9b0f271516daf36e20c9c037/examples/webconsole/resources/js/jquery/jquery.dataTables.js#L11123-L11135 | train | |
uber-workflow/probot-app-pr-title | validate-title.js | validateSentence | function validateSentence(parsed) {
const sentences = parsed.sentences();
return [
!isSingleSentence(sentences) ? 'Must be one and only one sentence.' : null,
!isNotTooShort(parsed) ? 'Must be at least two words long.' : null,
!isNotPunctuated(sentences) ? 'Must not have any end punctuation.' : null,
... | javascript | function validateSentence(parsed) {
const sentences = parsed.sentences();
return [
!isSingleSentence(sentences) ? 'Must be one and only one sentence.' : null,
!isNotTooShort(parsed) ? 'Must be at least two words long.' : null,
!isNotPunctuated(sentences) ? 'Must not have any end punctuation.' : null,
... | [
"function",
"validateSentence",
"(",
"parsed",
")",
"{",
"const",
"sentences",
"=",
"parsed",
".",
"sentences",
"(",
")",
";",
"return",
"[",
"!",
"isSingleSentence",
"(",
"sentences",
")",
"?",
"'Must be one and only one sentence.'",
":",
"null",
",",
"!",
"i... | Validate text is a single sentence with no end punctuation | [
"Validate",
"text",
"is",
"a",
"single",
"sentence",
"with",
"no",
"end",
"punctuation"
] | c3b29c5c9a9571e3e9a44fc5992003a2e744d69c | https://github.com/uber-workflow/probot-app-pr-title/blob/c3b29c5c9a9571e3e9a44fc5992003a2e744d69c/validate-title.js#L15-L22 | train |
uber-workflow/probot-app-pr-title | validate-title.js | validateFirstTerm | function validateFirstTerm(parsed) {
const term = parsed.terms().data()[0];
return [
!isValidVerb(term) ? 'First word must be imperative verb.' : null,
!isCapitalized(term) ? 'First word must be capitalized.' : null,
].filter(Boolean);
} | javascript | function validateFirstTerm(parsed) {
const term = parsed.terms().data()[0];
return [
!isValidVerb(term) ? 'First word must be imperative verb.' : null,
!isCapitalized(term) ? 'First word must be capitalized.' : null,
].filter(Boolean);
} | [
"function",
"validateFirstTerm",
"(",
"parsed",
")",
"{",
"const",
"term",
"=",
"parsed",
".",
"terms",
"(",
")",
".",
"data",
"(",
")",
"[",
"0",
"]",
";",
"return",
"[",
"!",
"isValidVerb",
"(",
"term",
")",
"?",
"'First word must be imperative verb.'",
... | Validate first word is a capitalized imperative mood verb | [
"Validate",
"first",
"word",
"is",
"a",
"capitalized",
"imperative",
"mood",
"verb"
] | c3b29c5c9a9571e3e9a44fc5992003a2e744d69c | https://github.com/uber-workflow/probot-app-pr-title/blob/c3b29c5c9a9571e3e9a44fc5992003a2e744d69c/validate-title.js#L25-L31 | train |
stream-utils/destroy | index.js | destroy | function destroy (stream) {
if (stream instanceof ReadStream) {
return destroyReadStream(stream)
}
if (!(stream instanceof Stream)) {
return stream
}
if (typeof stream.destroy === 'function') {
stream.destroy()
}
return stream
} | javascript | function destroy (stream) {
if (stream instanceof ReadStream) {
return destroyReadStream(stream)
}
if (!(stream instanceof Stream)) {
return stream
}
if (typeof stream.destroy === 'function') {
stream.destroy()
}
return stream
} | [
"function",
"destroy",
"(",
"stream",
")",
"{",
"if",
"(",
"stream",
"instanceof",
"ReadStream",
")",
"{",
"return",
"destroyReadStream",
"(",
"stream",
")",
"}",
"if",
"(",
"!",
"(",
"stream",
"instanceof",
"Stream",
")",
")",
"{",
"return",
"stream",
"... | Destroy a stream.
@param {object} stream
@public | [
"Destroy",
"a",
"stream",
"."
] | d1a76c640b63ef662d19c8d6211f705eed06f32e | https://github.com/stream-utils/destroy/blob/d1a76c640b63ef662d19c8d6211f705eed06f32e/index.js#L31-L45 | train |
stream-utils/destroy | index.js | destroyReadStream | function destroyReadStream (stream) {
stream.destroy()
if (typeof stream.close === 'function') {
// node.js core bug work-around
stream.on('open', onOpenClose)
}
return stream
} | javascript | function destroyReadStream (stream) {
stream.destroy()
if (typeof stream.close === 'function') {
// node.js core bug work-around
stream.on('open', onOpenClose)
}
return stream
} | [
"function",
"destroyReadStream",
"(",
"stream",
")",
"{",
"stream",
".",
"destroy",
"(",
")",
"if",
"(",
"typeof",
"stream",
".",
"close",
"===",
"'function'",
")",
"{",
"// node.js core bug work-around",
"stream",
".",
"on",
"(",
"'open'",
",",
"onOpenClose",... | Destroy a ReadStream.
@param {object} stream
@private | [
"Destroy",
"a",
"ReadStream",
"."
] | d1a76c640b63ef662d19c8d6211f705eed06f32e | https://github.com/stream-utils/destroy/blob/d1a76c640b63ef662d19c8d6211f705eed06f32e/index.js#L54-L63 | train |
jaredhanson/passport-windowslive | lib/errors/liveconnectapierror.js | LiveConnectAPIError | function LiveConnectAPIError(message, code) {
Error.call(this);
Error.captureStackTrace(this, arguments.callee);
this.name = 'LiveConnectAPIError';
this.message = message;
this.code = code;
} | javascript | function LiveConnectAPIError(message, code) {
Error.call(this);
Error.captureStackTrace(this, arguments.callee);
this.name = 'LiveConnectAPIError';
this.message = message;
this.code = code;
} | [
"function",
"LiveConnectAPIError",
"(",
"message",
",",
"code",
")",
"{",
"Error",
".",
"call",
"(",
"this",
")",
";",
"Error",
".",
"captureStackTrace",
"(",
"this",
",",
"arguments",
".",
"callee",
")",
";",
"this",
".",
"name",
"=",
"'LiveConnectAPIErro... | `LiveConnectAPIError` error.
References:
- http://msdn.microsoft.com/en-us/library/live/hh243648.aspx#error
@constructor
@param {string} [message]
@param {string} [code]
@access public | [
"LiveConnectAPIError",
"error",
"."
] | 47cad2be5830c13d46eb9f1d334990fd8702aa1e | https://github.com/jaredhanson/passport-windowslive/blob/47cad2be5830c13d46eb9f1d334990fd8702aa1e/lib/errors/liveconnectapierror.js#L12-L18 | train |
rniemeyer/knockout-amd-helpers | spec/amdBindings.spec.js | function(observable, value, callback) {
var subscription = observable.subscribe(function() {
subscription.dispose();
setTimeout(function() {
callback();
}, 50);
});
observable(value);
} | javascript | function(observable, value, callback) {
var subscription = observable.subscribe(function() {
subscription.dispose();
setTimeout(function() {
callback();
}, 50);
});
observable(value);
} | [
"function",
"(",
"observable",
",",
"value",
",",
"callback",
")",
"{",
"var",
"subscription",
"=",
"observable",
".",
"subscribe",
"(",
"function",
"(",
")",
"{",
"subscription",
".",
"dispose",
"(",
")",
";",
"setTimeout",
"(",
"function",
"(",
")",
"{... | helper to update an observable, wait, and check result | [
"helper",
"to",
"update",
"an",
"observable",
"wait",
"and",
"check",
"result"
] | 0e4884bb1c95b15be950b8f4474393ac042ecb24 | https://github.com/rniemeyer/knockout-amd-helpers/blob/0e4884bb1c95b15be950b8f4474393ac042ecb24/spec/amdBindings.spec.js#L38-L49 | train | |
rniemeyer/knockout-amd-helpers | ext/curl/curl.js | countdown | function countdown (howMany, lambda, completed) {
var result;
return function () {
if (--howMany >= 0 && lambda) result = lambda.apply(undef, arguments);
// we want ==, not <=, since some callers expect call-once functionality
if (howMany == 0 && completed) completed(result);
return result;
}
} | javascript | function countdown (howMany, lambda, completed) {
var result;
return function () {
if (--howMany >= 0 && lambda) result = lambda.apply(undef, arguments);
// we want ==, not <=, since some callers expect call-once functionality
if (howMany == 0 && completed) completed(result);
return result;
}
} | [
"function",
"countdown",
"(",
"howMany",
",",
"lambda",
",",
"completed",
")",
"{",
"var",
"result",
";",
"return",
"function",
"(",
")",
"{",
"if",
"(",
"--",
"howMany",
">=",
"0",
"&&",
"lambda",
")",
"result",
"=",
"lambda",
".",
"apply",
"(",
"un... | Returns a function that when executed, executes a lambda function,
but only executes it the number of times stated by howMany.
When done executing, it executes the completed function. Each callback
function receives the same parameters that are supplied to the
returned function each time it executes. In other words, t... | [
"Returns",
"a",
"function",
"that",
"when",
"executed",
"executes",
"a",
"lambda",
"function",
"but",
"only",
"executes",
"it",
"the",
"number",
"of",
"times",
"stated",
"by",
"howMany",
".",
"When",
"done",
"executing",
"it",
"executes",
"the",
"completed",
... | 0e4884bb1c95b15be950b8f4474393ac042ecb24 | https://github.com/rniemeyer/knockout-amd-helpers/blob/0e4884bb1c95b15be950b8f4474393ac042ecb24/ext/curl/curl.js#L233-L241 | train |
rniemeyer/knockout-amd-helpers | ext/curl/curl.js | convertPathMatcher | function convertPathMatcher (cfg) {
var pathMap = cfg.pathMap;
cfg.pathRx = new RegExp('^(' +
cfg.pathList.sort(function (a, b) { return pathMap[b].specificity - pathMap[a].specificity; } )
.join('|')
.replace(/\/|\./g, '\\$&') +
')(?=\\/|$)'
);
delete cfg.pathList;
} | javascript | function convertPathMatcher (cfg) {
var pathMap = cfg.pathMap;
cfg.pathRx = new RegExp('^(' +
cfg.pathList.sort(function (a, b) { return pathMap[b].specificity - pathMap[a].specificity; } )
.join('|')
.replace(/\/|\./g, '\\$&') +
')(?=\\/|$)'
);
delete cfg.pathList;
} | [
"function",
"convertPathMatcher",
"(",
"cfg",
")",
"{",
"var",
"pathMap",
"=",
"cfg",
".",
"pathMap",
";",
"cfg",
".",
"pathRx",
"=",
"new",
"RegExp",
"(",
"'^('",
"+",
"cfg",
".",
"pathList",
".",
"sort",
"(",
"function",
"(",
"a",
",",
"b",
")",
... | adds the path matching regexp onto the cfg or plugin cfgs. | [
"adds",
"the",
"path",
"matching",
"regexp",
"onto",
"the",
"cfg",
"or",
"plugin",
"cfgs",
"."
] | 0e4884bb1c95b15be950b8f4474393ac042ecb24 | https://github.com/rniemeyer/knockout-amd-helpers/blob/0e4884bb1c95b15be950b8f4474393ac042ecb24/ext/curl/curl.js#L593-L602 | train |
rniemeyer/knockout-amd-helpers | ext/curl/curl.js | process | function process (ev) {
ev = ev || global.event;
// detect when it's done loading
// ev.type == 'load' is for all browsers except IE6-9
// IE6-9 need to use onreadystatechange and look for
// el.readyState in {loaded, complete} (yes, we need both)
if (ev.type == 'load' || readyStates[el.readySta... | javascript | function process (ev) {
ev = ev || global.event;
// detect when it's done loading
// ev.type == 'load' is for all browsers except IE6-9
// IE6-9 need to use onreadystatechange and look for
// el.readyState in {loaded, complete} (yes, we need both)
if (ev.type == 'load' || readyStates[el.readySta... | [
"function",
"process",
"(",
"ev",
")",
"{",
"ev",
"=",
"ev",
"||",
"global",
".",
"event",
";",
"// detect when it's done loading",
"// ev.type == 'load' is for all browsers except IE6-9",
"// IE6-9 need to use onreadystatechange and look for",
"// el.readyState in {loaded, complet... | initial script processing | [
"initial",
"script",
"processing"
] | 0e4884bb1c95b15be950b8f4474393ac042ecb24 | https://github.com/rniemeyer/knockout-amd-helpers/blob/0e4884bb1c95b15be950b8f4474393ac042ecb24/ext/curl/curl.js#L694-L706 | train |
rniemeyer/knockout-amd-helpers | ext/curl/curl.js | CurlApi | function CurlApi (ids, callback, errback, waitFor) {
var then, ctx;
ctx = core.createContext(userCfg, undef, [].concat(ids));
this['then'] = then = function (resolved, rejected) {
when(ctx,
// return the dependencies as arguments, not an array
function (deps) {
if (resolved) resolved.apply(undef, ... | javascript | function CurlApi (ids, callback, errback, waitFor) {
var then, ctx;
ctx = core.createContext(userCfg, undef, [].concat(ids));
this['then'] = then = function (resolved, rejected) {
when(ctx,
// return the dependencies as arguments, not an array
function (deps) {
if (resolved) resolved.apply(undef, ... | [
"function",
"CurlApi",
"(",
"ids",
",",
"callback",
",",
"errback",
",",
"waitFor",
")",
"{",
"var",
"then",
",",
"ctx",
";",
"ctx",
"=",
"core",
".",
"createContext",
"(",
"userCfg",
",",
"undef",
",",
"[",
"]",
".",
"concat",
"(",
"ids",
")",
")"... | thanks to Joop Ringelberg for helping troubleshoot the API | [
"thanks",
"to",
"Joop",
"Ringelberg",
"for",
"helping",
"troubleshoot",
"the",
"API"
] | 0e4884bb1c95b15be950b8f4474393ac042ecb24 | https://github.com/rniemeyer/knockout-amd-helpers/blob/0e4884bb1c95b15be950b8f4474393ac042ecb24/ext/curl/curl.js#L1153-L1176 | train |
cburgdorf/grunt-html-snapshot | phantomjs/bridge.js | function (arg) {
var args = Array.isArray(arg) ? arg : [].slice.call(arguments);
var channel = options.taskChannelPrefix + '.' + args[0];
args[0] = channel;
fs.write(tmpfile, JSON.stringify(args) + "\n", "a");
} | javascript | function (arg) {
var args = Array.isArray(arg) ? arg : [].slice.call(arguments);
var channel = options.taskChannelPrefix + '.' + args[0];
args[0] = channel;
fs.write(tmpfile, JSON.stringify(args) + "\n", "a");
} | [
"function",
"(",
"arg",
")",
"{",
"var",
"args",
"=",
"Array",
".",
"isArray",
"(",
"arg",
")",
"?",
"arg",
":",
"[",
"]",
".",
"slice",
".",
"call",
"(",
"arguments",
")",
";",
"var",
"channel",
"=",
"options",
".",
"taskChannelPrefix",
"+",
"'.'"... | Messages are sent to the parent by appending them to the tempfile. NOTE, the tempfile appears to be shared between asynchronously running grunt tasks | [
"Messages",
"are",
"sent",
"to",
"the",
"parent",
"by",
"appending",
"them",
"to",
"the",
"tempfile",
".",
"NOTE",
"the",
"tempfile",
"appears",
"to",
"be",
"shared",
"between",
"asynchronously",
"running",
"grunt",
"tasks"
] | c92ba26600414af1b936cd550d394a59dbf120fc | https://github.com/cburgdorf/grunt-html-snapshot/blob/c92ba26600414af1b936cd550d394a59dbf120fc/phantomjs/bridge.js#L15-L20 | train | |
yahoo/ycb | index.js | function(contextObj, options) {
options = options ? mergeDeep(this.options, options, true) : this.options;
var context = this._parseContext(contextObj);
var subKey = options.applySubstitutions !== false ? 'subbed': 'unsubbed';
var collector = this.masterDelta ? cloneDeep(this.masterDelta... | javascript | function(contextObj, options) {
options = options ? mergeDeep(this.options, options, true) : this.options;
var context = this._parseContext(contextObj);
var subKey = options.applySubstitutions !== false ? 'subbed': 'unsubbed';
var collector = this.masterDelta ? cloneDeep(this.masterDelta... | [
"function",
"(",
"contextObj",
",",
"options",
")",
"{",
"options",
"=",
"options",
"?",
"mergeDeep",
"(",
"this",
".",
"options",
",",
"options",
",",
"true",
")",
":",
"this",
".",
"options",
";",
"var",
"context",
"=",
"this",
".",
"_parseContext",
... | Read the file.
@method read
@param contextObj {object}
@param options {object}
@return {object} | [
"Read",
"the",
"file",
"."
] | eb64c56e10f600f0630aad301fa66b9d5e319ed5 | https://github.com/yahoo/ycb/blob/eb64c56e10f600f0630aad301fa66b9d5e319ed5/index.js#L84-L94 | train | |
yahoo/ycb | index.js | function(cur, depth, context, collector, subKey) {
if(depth === context.length) {
mergeDeep(cur[subKey], collector, false);
return;
}
var value = context[depth];
if(value.constructor !== Array) {
var keys = this.precedenceMap[value];
var n ... | javascript | function(cur, depth, context, collector, subKey) {
if(depth === context.length) {
mergeDeep(cur[subKey], collector, false);
return;
}
var value = context[depth];
if(value.constructor !== Array) {
var keys = this.precedenceMap[value];
var n ... | [
"function",
"(",
"cur",
",",
"depth",
",",
"context",
",",
"collector",
",",
"subKey",
")",
"{",
"if",
"(",
"depth",
"===",
"context",
".",
"length",
")",
"{",
"mergeDeep",
"(",
"cur",
"[",
"subKey",
"]",
",",
"collector",
",",
"false",
")",
";",
"... | Recurse through the tree merging configs that apply to the given context.
@param cur {object} the current node.
@param depth {int} current depth in tree.
@param context {array} the context in internal format.
@param collector {object} the config we merge onto.
@param subKey {string} determines if substituted or non-sub... | [
"Recurse",
"through",
"the",
"tree",
"merging",
"configs",
"that",
"apply",
"to",
"the",
"given",
"context",
"."
] | eb64c56e10f600f0630aad301fa66b9d5e319ed5 | https://github.com/yahoo/ycb/blob/eb64c56e10f600f0630aad301fa66b9d5e319ed5/index.js#L105-L133 | train | |
yahoo/ycb | index.js | function(contextObj, options) {
var context = this._parseContext(contextObj);
var subKey = options.applySubstitutions !== false ? 'subbed': 'unsubbed';
var collector = this.masterDelta ? [this.masterDelta[subKey]] : [];
this._readNoMergeHelper(this.tree, 0, context, collector, subKey);
... | javascript | function(contextObj, options) {
var context = this._parseContext(contextObj);
var subKey = options.applySubstitutions !== false ? 'subbed': 'unsubbed';
var collector = this.masterDelta ? [this.masterDelta[subKey]] : [];
this._readNoMergeHelper(this.tree, 0, context, collector, subKey);
... | [
"function",
"(",
"contextObj",
",",
"options",
")",
"{",
"var",
"context",
"=",
"this",
".",
"_parseContext",
"(",
"contextObj",
")",
";",
"var",
"subKey",
"=",
"options",
".",
"applySubstitutions",
"!==",
"false",
"?",
"'subbed'",
":",
"'unsubbed'",
";",
... | Read the configs for the given context and return them in order general to specific.
@method read
@param contextObj {object}
@param options {object}
@return {array} | [
"Read",
"the",
"configs",
"for",
"the",
"given",
"context",
"and",
"return",
"them",
"in",
"order",
"general",
"to",
"specific",
"."
] | eb64c56e10f600f0630aad301fa66b9d5e319ed5 | https://github.com/yahoo/ycb/blob/eb64c56e10f600f0630aad301fa66b9d5e319ed5/index.js#L142-L148 | train | |
yahoo/ycb | index.js | function(cur, depth, context, collector, subKey) {
if(depth === context.length) {
collector.push(cur[subKey]);
return;
}
var value = context[depth];
if(value.constructor !== Array) {
var keys = this.precedenceMap[value];
var n = keys.length... | javascript | function(cur, depth, context, collector, subKey) {
if(depth === context.length) {
collector.push(cur[subKey]);
return;
}
var value = context[depth];
if(value.constructor !== Array) {
var keys = this.precedenceMap[value];
var n = keys.length... | [
"function",
"(",
"cur",
",",
"depth",
",",
"context",
",",
"collector",
",",
"subKey",
")",
"{",
"if",
"(",
"depth",
"===",
"context",
".",
"length",
")",
"{",
"collector",
".",
"push",
"(",
"cur",
"[",
"subKey",
"]",
")",
";",
"return",
";",
"}",
... | Recurse through the tree collecting configs that apply to the given context.
@param cur {object} the current node.
@param depth {number} current depth in tree.
@param context {array} the context in internal format.
@param collector {array} the array we push configs to.
@param subKey {string} determines if substituted o... | [
"Recurse",
"through",
"the",
"tree",
"collecting",
"configs",
"that",
"apply",
"to",
"the",
"given",
"context",
"."
] | eb64c56e10f600f0630aad301fa66b9d5e319ed5 | https://github.com/yahoo/ycb/blob/eb64c56e10f600f0630aad301fa66b9d5e319ed5/index.js#L159-L187 | train | |
yahoo/ycb | index.js | function(contextObj) {
if(contextObj === undefined) {
contextObj = {};
}
var context = new Array(this.dimensionsList.length);
for(var i=0; i<this.dimensionsList.length; i++) {
var dimension = this.dimensionsList[i];
if(contextObj.hasOwnProperty(dimensi... | javascript | function(contextObj) {
if(contextObj === undefined) {
contextObj = {};
}
var context = new Array(this.dimensionsList.length);
for(var i=0; i<this.dimensionsList.length; i++) {
var dimension = this.dimensionsList[i];
if(contextObj.hasOwnProperty(dimensi... | [
"function",
"(",
"contextObj",
")",
"{",
"if",
"(",
"contextObj",
"===",
"undefined",
")",
"{",
"contextObj",
"=",
"{",
"}",
";",
"}",
"var",
"context",
"=",
"new",
"Array",
"(",
"this",
".",
"dimensionsList",
".",
"length",
")",
";",
"for",
"(",
"va... | Converts a context object to equivalent array of numerical values.
@param contextObj {object}
@returns {array}
@private | [
"Converts",
"a",
"context",
"object",
"to",
"equivalent",
"array",
"of",
"numerical",
"values",
"."
] | eb64c56e10f600f0630aad301fa66b9d5e319ed5 | https://github.com/yahoo/ycb/blob/eb64c56e10f600f0630aad301fa66b9d5e319ed5/index.js#L196-L228 | train | |
yahoo/ycb | index.js | function(context) {
var contextObj = {};
for(var i=0; i<context.length; i++) {
if(context[i] !== '0') {
contextObj[this.dimensionsList[i]] = this.numberToValue[context[i]];
}
}
return contextObj;
} | javascript | function(context) {
var contextObj = {};
for(var i=0; i<context.length; i++) {
if(context[i] !== '0') {
contextObj[this.dimensionsList[i]] = this.numberToValue[context[i]];
}
}
return contextObj;
} | [
"function",
"(",
"context",
")",
"{",
"var",
"contextObj",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"context",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"context",
"[",
"i",
"]",
"!==",
"'0'",
")",
"{",
... | Convert internal num array context to context object.
@param context {array}
@returns {object}
@private | [
"Convert",
"internal",
"num",
"array",
"context",
"to",
"context",
"object",
"."
] | eb64c56e10f600f0630aad301fa66b9d5e319ed5 | https://github.com/yahoo/ycb/blob/eb64c56e10f600f0630aad301fa66b9d5e319ed5/index.js#L236-L244 | train | |
yahoo/ycb | index.js | function(config) {
for(var i=0; i<config.length; i++) {
if(config[i].dimensions) {
var dimensions = config[i].dimensions;
this.dimensions = dimensions;
var allDimensions = {};
for(var j=0; j<dimensions.length; j++) {
... | javascript | function(config) {
for(var i=0; i<config.length; i++) {
if(config[i].dimensions) {
var dimensions = config[i].dimensions;
this.dimensions = dimensions;
var allDimensions = {};
for(var j=0; j<dimensions.length; j++) {
... | [
"function",
"(",
"config",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"config",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"config",
"[",
"i",
"]",
".",
"dimensions",
")",
"{",
"var",
"dimensions",
"=",
"config",
"[",
... | Extract dimensions object and dimension -> number map
@param config {object}
@returns {array}
@private | [
"Extract",
"dimensions",
"object",
"and",
"dimension",
"-",
">",
"number",
"map"
] | eb64c56e10f600f0630aad301fa66b9d5e319ed5 | https://github.com/yahoo/ycb/blob/eb64c56e10f600f0630aad301fa66b9d5e319ed5/index.js#L280-L297 | train | |
yahoo/ycb | index.js | function(config, allDimensions, height) {
var usedDimensions = {};
var usedValues = {};
var contexts = {};
configLoop:
for(var i=0; i<config.length; i++) {
if (config[i].settings) {
var setting = config[i].settings;
if(s... | javascript | function(config, allDimensions, height) {
var usedDimensions = {};
var usedValues = {};
var contexts = {};
configLoop:
for(var i=0; i<config.length; i++) {
if (config[i].settings) {
var setting = config[i].settings;
if(s... | [
"function",
"(",
"config",
",",
"allDimensions",
",",
"height",
")",
"{",
"var",
"usedDimensions",
"=",
"{",
"}",
";",
"var",
"usedValues",
"=",
"{",
"}",
";",
"var",
"contexts",
"=",
"{",
"}",
";",
"configLoop",
":",
"for",
"(",
"var",
"i",
"=",
"... | Evaluate settings and determine which dimensions and values are used. Check for unknown dimensions.
Set the master config if it exist.
@param config {object}
@param allDimensions {object}
@param height {number}
@returns {array}
@private | [
"Evaluate",
"settings",
"and",
"determine",
"which",
"dimensions",
"and",
"values",
"are",
"used",
".",
"Check",
"for",
"unknown",
"dimensions",
".",
"Set",
"the",
"master",
"config",
"if",
"it",
"exist",
"."
] | eb64c56e10f600f0630aad301fa66b9d5e319ed5 | https://github.com/yahoo/ycb/blob/eb64c56e10f600f0630aad301fa66b9d5e319ed5/index.js#L308-L358 | train | |
yahoo/ycb | index.js | function(config) {
config = omit(config, 'settings');
var subbed = cloneDeep(config);
var subFlag = this._applySubstitutions(subbed, null, null);
var unsubbed = subFlag ? config : subbed;
return {subbed:subbed, unsubbed:unsubbed};
} | javascript | function(config) {
config = omit(config, 'settings');
var subbed = cloneDeep(config);
var subFlag = this._applySubstitutions(subbed, null, null);
var unsubbed = subFlag ? config : subbed;
return {subbed:subbed, unsubbed:unsubbed};
} | [
"function",
"(",
"config",
")",
"{",
"config",
"=",
"omit",
"(",
"config",
",",
"'settings'",
")",
";",
"var",
"subbed",
"=",
"cloneDeep",
"(",
"config",
")",
";",
"var",
"subFlag",
"=",
"this",
".",
"_applySubstitutions",
"(",
"subbed",
",",
"null",
"... | Convert config to delta.
@param config {object}
@returns {object}
@private | [
"Convert",
"config",
"to",
"delta",
"."
] | eb64c56e10f600f0630aad301fa66b9d5e319ed5 | https://github.com/yahoo/ycb/blob/eb64c56e10f600f0630aad301fa66b9d5e319ed5/index.js#L366-L372 | train | |
yahoo/ycb | index.js | function(dimensions, usedDimensions, usedValues) {
var activeDimensions = new Array(dimensions.length);
var valueCounter = 1;
for(var i=0; i<dimensions.length; i++) {
var dimensionName;
for(dimensionName in dimensions[i]){break}
if(usedDimensions[dimensionName... | javascript | function(dimensions, usedDimensions, usedValues) {
var activeDimensions = new Array(dimensions.length);
var valueCounter = 1;
for(var i=0; i<dimensions.length; i++) {
var dimensionName;
for(dimensionName in dimensions[i]){break}
if(usedDimensions[dimensionName... | [
"function",
"(",
"dimensions",
",",
"usedDimensions",
",",
"usedValues",
")",
"{",
"var",
"activeDimensions",
"=",
"new",
"Array",
"(",
"dimensions",
".",
"length",
")",
";",
"var",
"valueCounter",
"=",
"1",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
... | Evaluate dimensions and omit unused dimensions.
@param dimensions {array}
@param usedDimensions {object}
@param usedValues {object}
@returns {array}
@private | [
"Evaluate",
"dimensions",
"and",
"omit",
"unused",
"dimensions",
"."
] | eb64c56e10f600f0630aad301fa66b9d5e319ed5 | https://github.com/yahoo/ycb/blob/eb64c56e10f600f0630aad301fa66b9d5e319ed5/index.js#L382-L400 | train | |
yahoo/ycb | index.js | function(fullContext, activeDimensions, usedValues, setting) {
var height = this.dimensionsList.length;
var newContext = new Array(height);
for(var i=0; i<height; i++) {
newContext[i] = 0;
}
var activeIndex = 0;
for(i=0; i<fullContext.length; i++) {
... | javascript | function(fullContext, activeDimensions, usedValues, setting) {
var height = this.dimensionsList.length;
var newContext = new Array(height);
for(var i=0; i<height; i++) {
newContext[i] = 0;
}
var activeIndex = 0;
for(i=0; i<fullContext.length; i++) {
... | [
"function",
"(",
"fullContext",
",",
"activeDimensions",
",",
"usedValues",
",",
"setting",
")",
"{",
"var",
"height",
"=",
"this",
".",
"dimensionsList",
".",
"length",
";",
"var",
"newContext",
"=",
"new",
"Array",
"(",
"height",
")",
";",
"for",
"(",
... | Convert config context and omit invalid dimension values.
@param fullContext {array}
@param activeDimensions {array}
@param usedValues {object}
@param setting {object}
@returns {array}
@private | [
"Convert",
"config",
"context",
"and",
"omit",
"invalid",
"dimension",
"values",
"."
] | eb64c56e10f600f0630aad301fa66b9d5e319ed5 | https://github.com/yahoo/ycb/blob/eb64c56e10f600f0630aad301fa66b9d5e319ed5/index.js#L446-L485 | train | |
yahoo/ycb | index.js | function(root, depth, context, delta) {
var i;
var currentValue = context[depth];
var isMulti = currentValue.constructor === Array;
if(depth === context.length-1) {
if(isMulti) {
for(i=0; i<currentValue.length; i++) {
var curDelta = delta;
... | javascript | function(root, depth, context, delta) {
var i;
var currentValue = context[depth];
var isMulti = currentValue.constructor === Array;
if(depth === context.length-1) {
if(isMulti) {
for(i=0; i<currentValue.length; i++) {
var curDelta = delta;
... | [
"function",
"(",
"root",
",",
"depth",
",",
"context",
",",
"delta",
")",
"{",
"var",
"i",
";",
"var",
"currentValue",
"=",
"context",
"[",
"depth",
"]",
";",
"var",
"isMulti",
"=",
"currentValue",
".",
"constructor",
"===",
"Array",
";",
"if",
"(",
... | Insert the given context and delta into the tree.
@param root {object}
@param depth {number}
@param context {array}
@param delta {object}
@private | [
"Insert",
"the",
"given",
"context",
"and",
"delta",
"into",
"the",
"tree",
"."
] | eb64c56e10f600f0630aad301fa66b9d5e319ed5 | https://github.com/yahoo/ycb/blob/eb64c56e10f600f0630aad301fa66b9d5e319ed5/index.js#L495-L530 | train | |
yahoo/ycb | index.js | function (config, base, parent) {
var key,
sub,
find,
item;
base = base || config;
parent = parent || {ref: config, key: null};
var subFlag = false;
for (key in config) {
if (config.hasOwnProperty(key)) {
// If the ... | javascript | function (config, base, parent) {
var key,
sub,
find,
item;
base = base || config;
parent = parent || {ref: config, key: null};
var subFlag = false;
for (key in config) {
if (config.hasOwnProperty(key)) {
// If the ... | [
"function",
"(",
"config",
",",
"base",
",",
"parent",
")",
"{",
"var",
"key",
",",
"sub",
",",
"find",
",",
"item",
";",
"base",
"=",
"base",
"||",
"config",
";",
"parent",
"=",
"parent",
"||",
"{",
"ref",
":",
"config",
",",
"key",
":",
"null",... | This is a first pass at hairball of a function.
@private
@method _applySubstitutions
@param config {object}
@param base {object}
@param parent {object}
@return {boolean} | [
"This",
"is",
"a",
"first",
"pass",
"at",
"hairball",
"of",
"a",
"function",
"."
] | eb64c56e10f600f0630aad301fa66b9d5e319ed5 | https://github.com/yahoo/ycb/blob/eb64c56e10f600f0630aad301fa66b9d5e319ed5/index.js#L542-L619 | train | |
yahoo/ycb | index.js | function (callback) {
if(this.masterDelta && !callback({}, cloneDeep(this.masterDelta))) {
return undefined;
}
this._walkSettingsHelper(this.tree, 0, [], callback, [false]);
} | javascript | function (callback) {
if(this.masterDelta && !callback({}, cloneDeep(this.masterDelta))) {
return undefined;
}
this._walkSettingsHelper(this.tree, 0, [], callback, [false]);
} | [
"function",
"(",
"callback",
")",
"{",
"if",
"(",
"this",
".",
"masterDelta",
"&&",
"!",
"callback",
"(",
"{",
"}",
",",
"cloneDeep",
"(",
"this",
".",
"masterDelta",
")",
")",
")",
"{",
"return",
"undefined",
";",
"}",
"this",
".",
"_walkSettingsHelpe... | Iterates over all the setting sections in the YCB file, calling the
callback for each section.
@method walkSettings
@param callback {function(settings, config)}
@param callback.settings {object} the condition under which section will be used
@param callback.config {object} the configuration in the section
@param callba... | [
"Iterates",
"over",
"all",
"the",
"setting",
"sections",
"in",
"the",
"YCB",
"file",
"calling",
"the",
"callback",
"for",
"each",
"section",
"."
] | eb64c56e10f600f0630aad301fa66b9d5e319ed5 | https://github.com/yahoo/ycb/blob/eb64c56e10f600f0630aad301fa66b9d5e319ed5/index.js#L631-L636 | train | |
yahoo/ycb | index.js | function(cur, depth, context, callback, stop) {
if(stop[0]) {
return true;
}
if(depth === this.dimensionsList.length) {
stop[0] = !callback(this._contextToObject(context), cloneDeep(cur));
return stop[0];
}
var key;
for(key in cur) {
... | javascript | function(cur, depth, context, callback, stop) {
if(stop[0]) {
return true;
}
if(depth === this.dimensionsList.length) {
stop[0] = !callback(this._contextToObject(context), cloneDeep(cur));
return stop[0];
}
var key;
for(key in cur) {
... | [
"function",
"(",
"cur",
",",
"depth",
",",
"context",
",",
"callback",
",",
"stop",
")",
"{",
"if",
"(",
"stop",
"[",
"0",
"]",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"depth",
"===",
"this",
".",
"dimensionsList",
".",
"length",
")",
"{... | Recursive helper for walking the config tree.
@param cur {object}
@param depth {number}
@param context {array}
@param callback {function}
@param stop {array}
@private | [
"Recursive",
"helper",
"for",
"walking",
"the",
"config",
"tree",
"."
] | eb64c56e10f600f0630aad301fa66b9d5e319ed5 | https://github.com/yahoo/ycb/blob/eb64c56e10f600f0630aad301fa66b9d5e319ed5/index.js#L647-L661 | train | |
epeschier/angular-numeric-directive | src/numeric-directive.js | round | function round(value) {
var d = Math.pow(10, decimals);
return Math.round(value * d) / d;
} | javascript | function round(value) {
var d = Math.pow(10, decimals);
return Math.round(value * d) / d;
} | [
"function",
"round",
"(",
"value",
")",
"{",
"var",
"d",
"=",
"Math",
".",
"pow",
"(",
"10",
",",
"decimals",
")",
";",
"return",
"Math",
".",
"round",
"(",
"value",
"*",
"d",
")",
"/",
"d",
";",
"}"
] | Round the value to the closest decimal. | [
"Round",
"the",
"value",
"to",
"the",
"closest",
"decimal",
"."
] | 87ee0e0e7d531133d11410a35c453d788a4d451a | https://github.com/epeschier/angular-numeric-directive/blob/87ee0e0e7d531133d11410a35c453d788a4d451a/src/numeric-directive.js#L124-L127 | train |
epeschier/angular-numeric-directive | src/numeric-directive.js | numberWithCommas | function numberWithCommas(value) {
if (formatting) {
var parts = (""+value).split(decimalSeparator);
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, groupSeparator);
return parts.join(decimalSeparator);
}
el... | javascript | function numberWithCommas(value) {
if (formatting) {
var parts = (""+value).split(decimalSeparator);
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, groupSeparator);
return parts.join(decimalSeparator);
}
el... | [
"function",
"numberWithCommas",
"(",
"value",
")",
"{",
"if",
"(",
"formatting",
")",
"{",
"var",
"parts",
"=",
"(",
"\"\"",
"+",
"value",
")",
".",
"split",
"(",
"decimalSeparator",
")",
";",
"parts",
"[",
"0",
"]",
"=",
"parts",
"[",
"0",
"]",
".... | Format a number with the thousand group separator. | [
"Format",
"a",
"number",
"with",
"the",
"thousand",
"group",
"separator",
"."
] | 87ee0e0e7d531133d11410a35c453d788a4d451a | https://github.com/epeschier/angular-numeric-directive/blob/87ee0e0e7d531133d11410a35c453d788a4d451a/src/numeric-directive.js#L132-L142 | train |
epeschier/angular-numeric-directive | src/numeric-directive.js | formatPrecision | function formatPrecision(value) {
if (!(value || value === 0)) {
return '';
}
var formattedValue = parseFloat(value).toFixed(decimals);
formattedValue = formattedValue.replace('.', decimalSeparator);
return numberWithCom... | javascript | function formatPrecision(value) {
if (!(value || value === 0)) {
return '';
}
var formattedValue = parseFloat(value).toFixed(decimals);
formattedValue = formattedValue.replace('.', decimalSeparator);
return numberWithCom... | [
"function",
"formatPrecision",
"(",
"value",
")",
"{",
"if",
"(",
"!",
"(",
"value",
"||",
"value",
"===",
"0",
")",
")",
"{",
"return",
"''",
";",
"}",
"var",
"formattedValue",
"=",
"parseFloat",
"(",
"value",
")",
".",
"toFixed",
"(",
"decimals",
"... | Format a value with thousand group separator and correct decimal char. | [
"Format",
"a",
"value",
"with",
"thousand",
"group",
"separator",
"and",
"correct",
"decimal",
"char",
"."
] | 87ee0e0e7d531133d11410a35c453d788a4d451a | https://github.com/epeschier/angular-numeric-directive/blob/87ee0e0e7d531133d11410a35c453d788a4d451a/src/numeric-directive.js#L147-L154 | train |
epeschier/angular-numeric-directive | src/numeric-directive.js | parseViewValue | function parseViewValue(value) {
if (angular.isUndefined(value)) {
value = '';
}
value = (""+value).replace(decimalSeparator, '.');
// Handle leading decimal point, like ".5"
if (value.indexOf('.') === 0) {
... | javascript | function parseViewValue(value) {
if (angular.isUndefined(value)) {
value = '';
}
value = (""+value).replace(decimalSeparator, '.');
// Handle leading decimal point, like ".5"
if (value.indexOf('.') === 0) {
... | [
"function",
"parseViewValue",
"(",
"value",
")",
"{",
"if",
"(",
"angular",
".",
"isUndefined",
"(",
"value",
")",
")",
"{",
"value",
"=",
"''",
";",
"}",
"value",
"=",
"(",
"\"\"",
"+",
"value",
")",
".",
"replace",
"(",
"decimalSeparator",
",",
"'.... | Parse the view value. | [
"Parse",
"the",
"view",
"value",
"."
] | 87ee0e0e7d531133d11410a35c453d788a4d451a | https://github.com/epeschier/angular-numeric-directive/blob/87ee0e0e7d531133d11410a35c453d788a4d451a/src/numeric-directive.js#L163-L211 | train |
epeschier/angular-numeric-directive | src/numeric-directive.js | calculateMaxLength | function calculateMaxLength(value) {
var length = 16;
if (!angular.isUndefined(value)) {
length = Math.floor(value).toString().length;
}
if (decimals > 0) {
// Add extra length for the decimals plus one for the decim... | javascript | function calculateMaxLength(value) {
var length = 16;
if (!angular.isUndefined(value)) {
length = Math.floor(value).toString().length;
}
if (decimals > 0) {
// Add extra length for the decimals plus one for the decim... | [
"function",
"calculateMaxLength",
"(",
"value",
")",
"{",
"var",
"length",
"=",
"16",
";",
"if",
"(",
"!",
"angular",
".",
"isUndefined",
"(",
"value",
")",
")",
"{",
"length",
"=",
"Math",
".",
"floor",
"(",
"value",
")",
".",
"toString",
"(",
")",
... | Calculate the maximum input length in characters.
If no maximum the input will be limited to 16; the maximum ECMA script int. | [
"Calculate",
"the",
"maximum",
"input",
"length",
"in",
"characters",
".",
"If",
"no",
"maximum",
"the",
"input",
"will",
"be",
"limited",
"to",
"16",
";",
"the",
"maximum",
"ECMA",
"script",
"int",
"."
] | 87ee0e0e7d531133d11410a35c453d788a4d451a | https://github.com/epeschier/angular-numeric-directive/blob/87ee0e0e7d531133d11410a35c453d788a4d451a/src/numeric-directive.js#L217-L231 | train |
epeschier/angular-numeric-directive | src/numeric-directive.js | minmaxValidator | function minmaxValidator(value, testValue, validityName, limit, compareFunction) {
if (!angular.isUndefined(testValue) && limit) {
if (!ngModelCtrl.$isEmpty(value) && compareFunction) {
return testValue;
} else {
ret... | javascript | function minmaxValidator(value, testValue, validityName, limit, compareFunction) {
if (!angular.isUndefined(testValue) && limit) {
if (!ngModelCtrl.$isEmpty(value) && compareFunction) {
return testValue;
} else {
ret... | [
"function",
"minmaxValidator",
"(",
"value",
",",
"testValue",
",",
"validityName",
",",
"limit",
",",
"compareFunction",
")",
"{",
"if",
"(",
"!",
"angular",
".",
"isUndefined",
"(",
"testValue",
")",
"&&",
"limit",
")",
"{",
"if",
"(",
"!",
"ngModelCtrl"... | Value validator for min and max. | [
"Value",
"validator",
"for",
"min",
"and",
"max",
"."
] | 87ee0e0e7d531133d11410a35c453d788a4d451a | https://github.com/epeschier/angular-numeric-directive/blob/87ee0e0e7d531133d11410a35c453d788a4d451a/src/numeric-directive.js#L236-L250 | train |
pevers/images-scraper | lib/picsearch-images-scraper.js | function(url) {
return new Promise(function (resolve) {
self.roptions.url = url;
request(self.roptions, function (err, response, body) {
if (!err && response.statusCode === 200) {
var $ = cheerio.load(body);
// no results
if (!$('.result').length) {
return resolve(result);
}
... | javascript | function(url) {
return new Promise(function (resolve) {
self.roptions.url = url;
request(self.roptions, function (err, response, body) {
if (!err && response.statusCode === 200) {
var $ = cheerio.load(body);
// no results
if (!$('.result').length) {
return resolve(result);
}
... | [
"function",
"(",
"url",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
")",
"{",
"self",
".",
"roptions",
".",
"url",
"=",
"url",
";",
"request",
"(",
"self",
".",
"roptions",
",",
"function",
"(",
"err",
",",
"response",
",",... | max it to 2000 for default because we can go on indefinitely | [
"max",
"it",
"to",
"2000",
"for",
"default",
"because",
"we",
"can",
"go",
"on",
"indefinitely"
] | 5b97061c958a3ece8392dde813a16399a3b1d6c0 | https://github.com/pevers/images-scraper/blob/5b97061c958a3ece8392dde813a16399a3b1d6c0/lib/picsearch-images-scraper.js#L32-L70 | train | |
emmaguo/angular-poller | angular-poller.js | function(target, options) {
var poller = findPoller(target);
if (!poller) {
poller = new Poller(target, options);
pollers.push(poller);
poller.start();
} else {
... | javascript | function(target, options) {
var poller = findPoller(target);
if (!poller) {
poller = new Poller(target, options);
pollers.push(poller);
poller.start();
} else {
... | [
"function",
"(",
"target",
",",
"options",
")",
"{",
"var",
"poller",
"=",
"findPoller",
"(",
"target",
")",
";",
"if",
"(",
"!",
"poller",
")",
"{",
"poller",
"=",
"new",
"Poller",
"(",
"target",
",",
"options",
")",
";",
"pollers",
".",
"push",
"... | Return a singleton instance of a poller. If poller does
not exist, then register and start it. Otherwise return
it and restart it if necessary.
@param target
@param options
@returns {object} | [
"Return",
"a",
"singleton",
"instance",
"of",
"a",
"poller",
".",
"If",
"poller",
"does",
"not",
"exist",
"then",
"register",
"and",
"start",
"it",
".",
"Otherwise",
"return",
"it",
"and",
"restart",
"it",
"if",
"necessary",
"."
] | c4baaeb0d130f90475cd7bdc3aa54df9294c1507 | https://github.com/emmaguo/angular-poller/blob/c4baaeb0d130f90475cd7bdc3aa54df9294c1507/angular-poller.js#L332-L345 | train | |
emmaguo/angular-poller | angular-poller.js | function() {
angular.forEach(pollers, function(p) {
p.delay = p.idleDelay;
if (angular.isDefined(p.interval)) {
p.restart();
}
});
} | javascript | function() {
angular.forEach(pollers, function(p) {
p.delay = p.idleDelay;
if (angular.isDefined(p.interval)) {
p.restart();
}
});
} | [
"function",
"(",
")",
"{",
"angular",
".",
"forEach",
"(",
"pollers",
",",
"function",
"(",
"p",
")",
"{",
"p",
".",
"delay",
"=",
"p",
".",
"idleDelay",
";",
"if",
"(",
"angular",
".",
"isDefined",
"(",
"p",
".",
"interval",
")",
")",
"{",
"p",
... | Increase all poller interval to idleDelay, and restart the ones
that are already running. | [
"Increase",
"all",
"poller",
"interval",
"to",
"idleDelay",
"and",
"restart",
"the",
"ones",
"that",
"are",
"already",
"running",
"."
] | c4baaeb0d130f90475cd7bdc3aa54df9294c1507 | https://github.com/emmaguo/angular-poller/blob/c4baaeb0d130f90475cd7bdc3aa54df9294c1507/angular-poller.js#L386-L393 | train | |
eface2face/rtcninja.js | lib/RTCPeerConnection.js | runTimerGatheringTimeout | function runTimerGatheringTimeout() {
if (typeof self.options.gatheringTimeout !== 'number') {
return;
}
// If setLocalDescription was already called, it may happen that
// ICE gathering is not needed, so don't run this timer.
if (self.pc.iceGatheringState === 'complete') {
return;
}
debug('setLoca... | javascript | function runTimerGatheringTimeout() {
if (typeof self.options.gatheringTimeout !== 'number') {
return;
}
// If setLocalDescription was already called, it may happen that
// ICE gathering is not needed, so don't run this timer.
if (self.pc.iceGatheringState === 'complete') {
return;
}
debug('setLoca... | [
"function",
"runTimerGatheringTimeout",
"(",
")",
"{",
"if",
"(",
"typeof",
"self",
".",
"options",
".",
"gatheringTimeout",
"!==",
"'number'",
")",
"{",
"return",
";",
"}",
"// If setLocalDescription was already called, it may happen that",
"// ICE gathering is not needed,... | Handle gatheringTimeout. | [
"Handle",
"gatheringTimeout",
"."
] | 9c070d0c77fd71281774cc45bd784a878cc714a5 | https://github.com/eface2face/rtcninja.js/blob/9c070d0c77fd71281774cc45bd784a878cc714a5/lib/RTCPeerConnection.js#L173-L205 | train |
eface2face/rtcninja.js | lib/RTCPeerConnection.js | setConfigurationAndOptions | function setConfigurationAndOptions(pcConfig) {
// Clone pcConfig.
this.pcConfig = merge(true, pcConfig);
// Fix pcConfig.
Adapter.fixPeerConnectionConfig(this.pcConfig);
this.options = {
iceTransportsRelay: (this.pcConfig.iceTransports === 'relay'),
iceTransportsNone: (this.pcConfig.iceTransports === 'none'... | javascript | function setConfigurationAndOptions(pcConfig) {
// Clone pcConfig.
this.pcConfig = merge(true, pcConfig);
// Fix pcConfig.
Adapter.fixPeerConnectionConfig(this.pcConfig);
this.options = {
iceTransportsRelay: (this.pcConfig.iceTransports === 'relay'),
iceTransportsNone: (this.pcConfig.iceTransports === 'none'... | [
"function",
"setConfigurationAndOptions",
"(",
"pcConfig",
")",
"{",
"// Clone pcConfig.",
"this",
".",
"pcConfig",
"=",
"merge",
"(",
"true",
",",
"pcConfig",
")",
";",
"// Fix pcConfig.",
"Adapter",
".",
"fixPeerConnectionConfig",
"(",
"this",
".",
"pcConfig",
"... | Private Helpers. | [
"Private",
"Helpers",
"."
] | 9c070d0c77fd71281774cc45bd784a878cc714a5 | https://github.com/eface2face/rtcninja.js/blob/9c070d0c77fd71281774cc45bd784a878cc714a5/lib/RTCPeerConnection.js#L415-L434 | train |
binarykitchen/videomail-client | src/wrappers/dimension.js | function (height, options) {
if (numberIsInteger(height) && height < 1) {
throw VideomailError.create('Passed limit-height argument cannot be less than 1!', options)
} else {
const limitedHeight = Math.min(
height,
// document.body.scrollHeight,
document.documentElement.clien... | javascript | function (height, options) {
if (numberIsInteger(height) && height < 1) {
throw VideomailError.create('Passed limit-height argument cannot be less than 1!', options)
} else {
const limitedHeight = Math.min(
height,
// document.body.scrollHeight,
document.documentElement.clien... | [
"function",
"(",
"height",
",",
"options",
")",
"{",
"if",
"(",
"numberIsInteger",
"(",
"height",
")",
"&&",
"height",
"<",
"1",
")",
"{",
"throw",
"VideomailError",
".",
"create",
"(",
"'Passed limit-height argument cannot be less than 1!'",
",",
"options",
")"... | this is difficult to compute and is not entirely correct. but good enough for now to ensure some stability. | [
"this",
"is",
"difficult",
"to",
"compute",
"and",
"is",
"not",
"entirely",
"correct",
".",
"but",
"good",
"enough",
"for",
"now",
"to",
"ensure",
"some",
"stability",
"."
] | 8c9ac3488ae2d5e7eaa984d59414f244de4b4c4e | https://github.com/binarykitchen/videomail-client/blob/8c9ac3488ae2d5e7eaa984d59414f244de4b4c4e/src/wrappers/dimension.js#L68-L84 | train | |
feedhenry/fh-sync-js | libs/generated/lawnchair.js | function (callback) {
var cb = this.lambda(callback)
// iterate from chain
if (this.__results) {
for (var i = 0, l = this.__results.length; i < l; i++) cb.call(this, this.__results[i], i)
}
// otherwise iterate the entire collection
else {
this.all(function(r) {
for (var i = ... | javascript | function (callback) {
var cb = this.lambda(callback)
// iterate from chain
if (this.__results) {
for (var i = 0, l = this.__results.length; i < l; i++) cb.call(this, this.__results[i], i)
}
// otherwise iterate the entire collection
else {
this.all(function(r) {
for (var i = ... | [
"function",
"(",
"callback",
")",
"{",
"var",
"cb",
"=",
"this",
".",
"lambda",
"(",
"callback",
")",
"// iterate from chain",
"if",
"(",
"this",
".",
"__results",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"this",
".",
"__results",
... | a classic iterator | [
"a",
"classic",
"iterator"
] | b8f3864485da482df57fbe64904926983ef910a9 | https://github.com/feedhenry/fh-sync-js/blob/b8f3864485da482df57fbe64904926983ef910a9/libs/generated/lawnchair.js#L150-L163 | train | |
feedhenry/fh-sync-js | libs/generated/lawnchair.js | function(name) {
return {
// the key
key: name + '._index_',
// returns the index
all: function() {
var a = storage.getItem(this.key)
if (a) {
a = JSON.parse(a)
}
if (a === null) storage.setItem(this.key, JSON.stringify([])) // lazy init
ret... | javascript | function(name) {
return {
// the key
key: name + '._index_',
// returns the index
all: function() {
var a = storage.getItem(this.key)
if (a) {
a = JSON.parse(a)
}
if (a === null) storage.setItem(this.key, JSON.stringify([])) // lazy init
ret... | [
"function",
"(",
"name",
")",
"{",
"return",
"{",
"// the key",
"key",
":",
"name",
"+",
"'._index_'",
",",
"// returns the index",
"all",
":",
"function",
"(",
")",
"{",
"var",
"a",
"=",
"storage",
".",
"getItem",
"(",
"this",
".",
"key",
")",
"if",
... | the indexer is an encapsulation of the helpers needed to keep an ordered index of the keys | [
"the",
"indexer",
"is",
"an",
"encapsulation",
"of",
"the",
"helpers",
"needed",
"to",
"keep",
"an",
"ordered",
"index",
"of",
"the",
"keys"
] | b8f3864485da482df57fbe64904926983ef910a9 | https://github.com/feedhenry/fh-sync-js/blob/b8f3864485da482df57fbe64904926983ef910a9/libs/generated/lawnchair.js#L315-L352 | train | |
feedhenry/fh-sync-js | libs/generated/lawnchair.js | function(obj, callback, error) {
var that = this
objs = (this.isArray(obj) ? obj : [obj]).map(function(o) {
if (!o.key) {
o.key = that.uuid()
}
return o
}),
ins = "INSERT OR REPLACE INTO " + this.record + " (value, timestamp, id) VALUES (?,?,?)",
win =... | javascript | function(obj, callback, error) {
var that = this
objs = (this.isArray(obj) ? obj : [obj]).map(function(o) {
if (!o.key) {
o.key = that.uuid()
}
return o
}),
ins = "INSERT OR REPLACE INTO " + this.record + " (value, timestamp, id) VALUES (?,?,?)",
win =... | [
"function",
"(",
"obj",
",",
"callback",
",",
"error",
")",
"{",
"var",
"that",
"=",
"this",
"objs",
"=",
"(",
"this",
".",
"isArray",
"(",
"obj",
")",
"?",
"obj",
":",
"[",
"obj",
"]",
")",
".",
"map",
"(",
"function",
"(",
"o",
")",
"{",
"i... | you think thats air you're breathing now? | [
"you",
"think",
"thats",
"air",
"you",
"re",
"breathing",
"now?"
] | b8f3864485da482df57fbe64904926983ef910a9 | https://github.com/feedhenry/fh-sync-js/blob/b8f3864485da482df57fbe64904926983ef910a9/libs/generated/lawnchair.js#L563-L596 | train | |
feedhenry/fh-sync-js | src/sync-client.js | function(options) {
self.consoleLog('sync - init called');
self.config = JSON.parse(JSON.stringify(self.defaults));
for (var i in options) {
self.config[i] = options[i];
}
//prevent multiple monitors from created if init is called multiple times
if(!self.init_is_called){
... | javascript | function(options) {
self.consoleLog('sync - init called');
self.config = JSON.parse(JSON.stringify(self.defaults));
for (var i in options) {
self.config[i] = options[i];
}
//prevent multiple monitors from created if init is called multiple times
if(!self.init_is_called){
... | [
"function",
"(",
"options",
")",
"{",
"self",
".",
"consoleLog",
"(",
"'sync - init called'",
")",
";",
"self",
".",
"config",
"=",
"JSON",
".",
"parse",
"(",
"JSON",
".",
"stringify",
"(",
"self",
".",
"defaults",
")",
")",
";",
"for",
"(",
"var",
"... | PUBLIC FUNCTION IMPLEMENTATIONS | [
"PUBLIC",
"FUNCTION",
"IMPLEMENTATIONS"
] | b8f3864485da482df57fbe64904926983ef910a9 | https://github.com/feedhenry/fh-sync-js/blob/b8f3864485da482df57fbe64904926983ef910a9/src/sync-client.js#L104-L118 | train | |
feedhenry/fh-sync-js | src/sync-client.js | function(config, options) {
// Make sure config is initialised
if( ! config ) {
config = JSON.parse(JSON.stringify(self.defaults));
}
var datasetConfig = JSON.parse(JSON.stringify(config));
var optionsIn = JSON.parse(JSON.stringify(options));
for (var k in optionsIn) {
... | javascript | function(config, options) {
// Make sure config is initialised
if( ! config ) {
config = JSON.parse(JSON.stringify(self.defaults));
}
var datasetConfig = JSON.parse(JSON.stringify(config));
var optionsIn = JSON.parse(JSON.stringify(options));
for (var k in optionsIn) {
... | [
"function",
"(",
"config",
",",
"options",
")",
"{",
"// Make sure config is initialised",
"if",
"(",
"!",
"config",
")",
"{",
"config",
"=",
"JSON",
".",
"parse",
"(",
"JSON",
".",
"stringify",
"(",
"self",
".",
"defaults",
")",
")",
";",
"}",
"var",
... | Sets options for passed in config, if !config then options will be applied to default config.
@param {Object} config - config to which options will be applied
@param {Object} options - options to be applied to the config | [
"Sets",
"options",
"for",
"passed",
"in",
"config",
"if",
"!config",
"then",
"options",
"will",
"be",
"applied",
"to",
"default",
"config",
"."
] | b8f3864485da482df57fbe64904926983ef910a9 | https://github.com/feedhenry/fh-sync-js/blob/b8f3864485da482df57fbe64904926983ef910a9/src/sync-client.js#L200-L214 | train | |
feedhenry/fh-sync-js | src/sync-client.js | function(callback) {
var online = true;
// first, check if navigator.online is available
if(typeof navigator.onLine !== "undefined"){
online = navigator.onLine;
}
// second, check if Phonegap is available and has online info
if(online){
//use phonegap to determin if... | javascript | function(callback) {
var online = true;
// first, check if navigator.online is available
if(typeof navigator.onLine !== "undefined"){
online = navigator.onLine;
}
// second, check if Phonegap is available and has online info
if(online){
//use phonegap to determin if... | [
"function",
"(",
"callback",
")",
"{",
"var",
"online",
"=",
"true",
";",
"// first, check if navigator.online is available",
"if",
"(",
"typeof",
"navigator",
".",
"onLine",
"!==",
"\"undefined\"",
")",
"{",
"online",
"=",
"navigator",
".",
"onLine",
";",
"}",
... | PRIVATE FUNCTIONS
Check if client is online.
Function is used to stop sync from executing requests. | [
"PRIVATE",
"FUNCTIONS",
"Check",
"if",
"client",
"is",
"online",
".",
"Function",
"is",
"used",
"to",
"stop",
"sync",
"from",
"executing",
"requests",
"."
] | b8f3864485da482df57fbe64904926983ef910a9 | https://github.com/feedhenry/fh-sync-js/blob/b8f3864485da482df57fbe64904926983ef910a9/src/sync-client.js#L342-L362 | train | |
pifantastic/teamcity-service-messages | lib/message.js | function (type, args) {
this.type = type;
this.single = false;
// Message is a 'multiple attribute message'.
if (typeof args === 'object' || typeof args === 'undefined') {
this.args = args || {};
}
// Message is a 'single attribute message'.
else {
this.single = true;
this.args = args;
}
if (!this.sing... | javascript | function (type, args) {
this.type = type;
this.single = false;
// Message is a 'multiple attribute message'.
if (typeof args === 'object' || typeof args === 'undefined') {
this.args = args || {};
}
// Message is a 'single attribute message'.
else {
this.single = true;
this.args = args;
}
if (!this.sing... | [
"function",
"(",
"type",
",",
"args",
")",
"{",
"this",
".",
"type",
"=",
"type",
";",
"this",
".",
"single",
"=",
"false",
";",
"// Message is a 'multiple attribute message'.",
"if",
"(",
"typeof",
"args",
"===",
"'object'",
"||",
"typeof",
"args",
"===",
... | Constructs a message formatted for consumption by TeamCity.
@param {String} type
@param {Object} args | [
"Constructs",
"a",
"message",
"formatted",
"for",
"consumption",
"by",
"TeamCity",
"."
] | 5e0d45fc89b3cba9912e8487de889c5442aba24f | https://github.com/pifantastic/teamcity-service-messages/blob/5e0d45fc89b3cba9912e8487de889c5442aba24f/lib/message.js#L23-L45 | train | |
geneontology/amigo | javascript/web/TEBase.js | stage_01 | function stage_01(gp_accs){
// Ready logging.
var logger = new bbop.logger();
logger.DEBUG = true;
function ll(str){ logger.kvetch('JSM01: ' + str); }
ll('');
ll('Stage 01 start...');
// Helpers.
var each = bbop.core.each;
var dump = bbop.core.dump;
// Prep the progress bar an... | javascript | function stage_01(gp_accs){
// Ready logging.
var logger = new bbop.logger();
logger.DEBUG = true;
function ll(str){ logger.kvetch('JSM01: ' + str); }
ll('');
ll('Stage 01 start...');
// Helpers.
var each = bbop.core.each;
var dump = bbop.core.dump;
// Prep the progress bar an... | [
"function",
"stage_01",
"(",
"gp_accs",
")",
"{",
"// Ready logging.",
"var",
"logger",
"=",
"new",
"bbop",
".",
"logger",
"(",
")",
";",
"logger",
".",
"DEBUG",
"=",
"true",
";",
"function",
"ll",
"(",
"str",
")",
"{",
"logger",
".",
"kvetch",
"(",
... | Get the information for the incoming accs, launch stage 02. | [
"Get",
"the",
"information",
"for",
"the",
"incoming",
"accs",
"launch",
"stage",
"02",
"."
] | c12209eff40abf15ad612525633ce7c2a625dfa9 | https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/javascript/web/TEBase.js#L51-L151 | train |
geneontology/amigo | scripts/web-bowser.js | _prep_download_url | function _prep_download_url(){
var engine = new impl_engine(golr_response);
//engine.method('GET');
//engine.use_jsonp(true);
var gman = new golr_manager(gserv, gconf, engine, 'async');
gman.set_personality('annotation');
gman.add_query_filter('document_category', 'annotation', ['*']);
... | javascript | function _prep_download_url(){
var engine = new impl_engine(golr_response);
//engine.method('GET');
//engine.use_jsonp(true);
var gman = new golr_manager(gserv, gconf, engine, 'async');
gman.set_personality('annotation');
gman.add_query_filter('document_category', 'annotation', ['*']);
... | [
"function",
"_prep_download_url",
"(",
")",
"{",
"var",
"engine",
"=",
"new",
"impl_engine",
"(",
"golr_response",
")",
";",
"//engine.method('GET');",
"//engine.use_jsonp(true);",
"var",
"gman",
"=",
"new",
"golr_manager",
"(",
"gserv",
",",
"gconf",
",",
"engine... | Spin up download agents. The download-y bits. | [
"Spin",
"up",
"download",
"agents",
".",
"The",
"download",
"-",
"y",
"bits",
"."
] | c12209eff40abf15ad612525633ce7c2a625dfa9 | https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/scripts/web-bowser.js#L153-L195 | train |
geneontology/amigo | javascript/web/BulkSearch.js | function(identifiers, search_fields){
ll('run search');
search.set_targets(identifiers, search_fields);
//
search.search();
// Scroll to results.
jQuery('html, body').animate({
scrollTop: jQuery('#' + 'results-area').offset().top
}, 500);
} | javascript | function(identifiers, search_fields){
ll('run search');
search.set_targets(identifiers, search_fields);
//
search.search();
// Scroll to results.
jQuery('html, body').animate({
scrollTop: jQuery('#' + 'results-area').offset().top
}, 500);
} | [
"function",
"(",
"identifiers",
",",
"search_fields",
")",
"{",
"ll",
"(",
"'run search'",
")",
";",
"search",
".",
"set_targets",
"(",
"identifiers",
",",
"search_fields",
")",
";",
"// ",
"search",
".",
"search",
"(",
")",
";",
"// Scroll to results.",
"jQ... | Now that we're setup, activate the display button, and make it so that it will only work on "good" input. | [
"Now",
"that",
"we",
"re",
"setup",
"activate",
"the",
"display",
"button",
"and",
"make",
"it",
"so",
"that",
"it",
"will",
"only",
"work",
"on",
"good",
"input",
"."
] | c12209eff40abf15ad612525633ce7c2a625dfa9 | https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/javascript/web/BulkSearch.js#L206-L218 | train | |
Famous/famous-angular | dist/famous-angular.js | function (element) {
if(!element[0]) return false;
//short-circuit most common case
if(IS_FA.test(element[0].tagName)) return true;
//otherwise loop through attributes
var ret = false;
angular.forEach(element[0].attributes, function(attr){
ret = ret || IS_FA.test(attr);
... | javascript | function (element) {
if(!element[0]) return false;
//short-circuit most common case
if(IS_FA.test(element[0].tagName)) return true;
//otherwise loop through attributes
var ret = false;
angular.forEach(element[0].attributes, function(attr){
ret = ret || IS_FA.test(attr);
... | [
"function",
"(",
"element",
")",
"{",
"if",
"(",
"!",
"element",
"[",
"0",
"]",
")",
"return",
"false",
";",
"//short-circuit most common case",
"if",
"(",
"IS_FA",
".",
"test",
"(",
"element",
"[",
"0",
"]",
".",
"tagName",
")",
")",
"return",
"true",... | Check if the element selected is an fa- element
@param {Array} element - derived element
@return {boolean} | [
"Check",
"if",
"the",
"element",
"selected",
"is",
"an",
"fa",
"-",
"element"
] | ce9e495509789295c8d57b7f9a3b8b464994a5b1 | https://github.com/Famous/famous-angular/blob/ce9e495509789295c8d57b7f9a3b8b464994a5b1/dist/famous-angular.js#L219-L231 | train | |
Famous/famous-angular | dist/famous-angular.js | function(a, b) {
if (typeof a === "number") {
return a - b;
}
else {
return a.map(function(x, i) { return x - b[i]; });
}
} | javascript | function(a, b) {
if (typeof a === "number") {
return a - b;
}
else {
return a.map(function(x, i) { return x - b[i]; });
}
} | [
"function",
"(",
"a",
",",
"b",
")",
"{",
"if",
"(",
"typeof",
"a",
"===",
"\"number\"",
")",
"{",
"return",
"a",
"-",
"b",
";",
"}",
"else",
"{",
"return",
"a",
".",
"map",
"(",
"function",
"(",
"x",
",",
"i",
")",
"{",
"return",
"x",
"-",
... | polymorphic subtract for scalars and vectors | [
"polymorphic",
"subtract",
"for",
"scalars",
"and",
"vectors"
] | ce9e495509789295c8d57b7f9a3b8b464994a5b1 | https://github.com/Famous/famous-angular/blob/ce9e495509789295c8d57b7f9a3b8b464994a5b1/dist/famous-angular.js#L917-L924 | train | |
Famous/famous-angular | dist/famous-angular.js | function(A, b) {
// b is a scalar, A is a scalar or a vector
if (typeof A === "number") {
return A * b;
}
else {
return A.map(function(x) { return x * b; });
}
} | javascript | function(A, b) {
// b is a scalar, A is a scalar or a vector
if (typeof A === "number") {
return A * b;
}
else {
return A.map(function(x) { return x * b; });
}
} | [
"function",
"(",
"A",
",",
"b",
")",
"{",
"// b is a scalar, A is a scalar or a vector",
"if",
"(",
"typeof",
"A",
"===",
"\"number\"",
")",
"{",
"return",
"A",
"*",
"b",
";",
"}",
"else",
"{",
"return",
"A",
".",
"map",
"(",
"function",
"(",
"x",
")",... | polymorphic multiply for scalar and vectors | [
"polymorphic",
"multiply",
"for",
"scalar",
"and",
"vectors"
] | ce9e495509789295c8d57b7f9a3b8b464994a5b1 | https://github.com/Famous/famous-angular/blob/ce9e495509789295c8d57b7f9a3b8b464994a5b1/dist/famous-angular.js#L927-L935 | train | |
Famous/famous-angular | dist/famous-angular.js | onTouchStart | function onTouchStart(event) {
var touches = event.touches && event.touches.length ? event.touches : [event];
var x = touches[0].clientX;
var y = touches[0].clientY;
touchCoordinates.push(x, y);
$timeout(function() {
// Remove the allowable region.
for (var i = 0; i < touc... | javascript | function onTouchStart(event) {
var touches = event.touches && event.touches.length ? event.touches : [event];
var x = touches[0].clientX;
var y = touches[0].clientY;
touchCoordinates.push(x, y);
$timeout(function() {
// Remove the allowable region.
for (var i = 0; i < touc... | [
"function",
"onTouchStart",
"(",
"event",
")",
"{",
"var",
"touches",
"=",
"event",
".",
"touches",
"&&",
"event",
".",
"touches",
".",
"length",
"?",
"event",
".",
"touches",
":",
"[",
"event",
"]",
";",
"var",
"x",
"=",
"touches",
"[",
"0",
"]",
... | Global touchstart handler that creates an allowable region for a click event. This allowable region can be removed by preventGhostClick if we want to bust it. | [
"Global",
"touchstart",
"handler",
"that",
"creates",
"an",
"allowable",
"region",
"for",
"a",
"click",
"event",
".",
"This",
"allowable",
"region",
"can",
"be",
"removed",
"by",
"preventGhostClick",
"if",
"we",
"want",
"to",
"bust",
"it",
"."
] | ce9e495509789295c8d57b7f9a3b8b464994a5b1 | https://github.com/Famous/famous-angular/blob/ce9e495509789295c8d57b7f9a3b8b464994a5b1/dist/famous-angular.js#L3353-L3368 | train |
geneontology/amigo | javascript/web/TermDetails.js | _shrink_wrap | function _shrink_wrap(elt_id){
// Now take what we have, and wrap around some expansion code if
// it looks like it is too long.
var _trim_hash = {};
var _trimit = 100;
// Only want to compile once.
var ea_regexp = new RegExp("\<\/a\>", "i"); // detect an <a>
var br_regexp = new RegExp("\<b... | javascript | function _shrink_wrap(elt_id){
// Now take what we have, and wrap around some expansion code if
// it looks like it is too long.
var _trim_hash = {};
var _trimit = 100;
// Only want to compile once.
var ea_regexp = new RegExp("\<\/a\>", "i"); // detect an <a>
var br_regexp = new RegExp("\<b... | [
"function",
"_shrink_wrap",
"(",
"elt_id",
")",
"{",
"// Now take what we have, and wrap around some expansion code if",
"// it looks like it is too long.",
"var",
"_trim_hash",
"=",
"{",
"}",
";",
"var",
"_trimit",
"=",
"100",
";",
"// Only want to compile once.",
"var",
"... | Take and element, look at it's contents, if it's above a certain threshold, shrink with "more..." button, otherwise leave alone. | [
"Take",
"and",
"element",
"look",
"at",
"it",
"s",
"contents",
"if",
"it",
"s",
"above",
"a",
"certain",
"threshold",
"shrink",
"with",
"more",
"...",
"button",
"otherwise",
"leave",
"alone",
"."
] | c12209eff40abf15ad612525633ce7c2a625dfa9 | https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/javascript/web/TermDetails.js#L40-L158 | train |
strapi/strapi-generate-users | files/api/user/services/user.js | function (user, next) {
if (!user.hasOwnProperty('password') || !user.password || this.isHashed(user.password)) {
next(null, user);
} else {
bcrypt.hash(user.password, 10, function (err, hash) {
user.password = hash;
next(err, user);
});
}
} | javascript | function (user, next) {
if (!user.hasOwnProperty('password') || !user.password || this.isHashed(user.password)) {
next(null, user);
} else {
bcrypt.hash(user.password, 10, function (err, hash) {
user.password = hash;
next(err, user);
});
}
} | [
"function",
"(",
"user",
",",
"next",
")",
"{",
"if",
"(",
"!",
"user",
".",
"hasOwnProperty",
"(",
"'password'",
")",
"||",
"!",
"user",
".",
"password",
"||",
"this",
".",
"isHashed",
"(",
"user",
".",
"password",
")",
")",
"{",
"next",
"(",
"nul... | Helper used to hash the password of a `user`.
@param {Object} user
@param {Function} next | [
"Helper",
"used",
"to",
"hash",
"the",
"password",
"of",
"a",
"user",
"."
] | e7e8913165a591c26081706fedaec9dd4c801c50 | https://github.com/strapi/strapi-generate-users/blob/e7e8913165a591c26081706fedaec9dd4c801c50/files/api/user/services/user.js#L25-L34 | train | |
geneontology/amigo | javascript/bin/ringo-opensearch.js | create_request_function | function create_request_function(personality, doc_type,
id_field, label_field, link_type){
return function(request, query) {
// Declare a delayed response.
var response = new Deferred();
//response.wait(5000); // 5s wait for resolution
// New agent on every call.
var go = new bbop.golr.manager.ringo(se... | javascript | function create_request_function(personality, doc_type,
id_field, label_field, link_type){
return function(request, query) {
// Declare a delayed response.
var response = new Deferred();
//response.wait(5000); // 5s wait for resolution
// New agent on every call.
var go = new bbop.golr.manager.ringo(se... | [
"function",
"create_request_function",
"(",
"personality",
",",
"doc_type",
",",
"id_field",
",",
"label_field",
",",
"link_type",
")",
"{",
"return",
"function",
"(",
"request",
",",
"query",
")",
"{",
"// Declare a delayed response.",
"var",
"response",
"=",
"ne... | The request functions I use are very similar. | [
"The",
"request",
"functions",
"I",
"use",
"are",
"very",
"similar",
"."
] | c12209eff40abf15ad612525633ce7c2a625dfa9 | https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/javascript/bin/ringo-opensearch.js#L155-L213 | train |
geneontology/amigo | javascript/web/DrillExp.js | _doc_to_tree_node | function _doc_to_tree_node(doc, parent_id){
var retnode = {};
// ID.
var raw_id = doc['id'];
var safe_id = raw_id; // need to process?
retnode['attr'] = { "id" : safe_id };
// Label (with fallback).
var label = doc['label'];
if( ! label || label == '' ){
label = raw_id;
}else{
... | javascript | function _doc_to_tree_node(doc, parent_id){
var retnode = {};
// ID.
var raw_id = doc['id'];
var safe_id = raw_id; // need to process?
retnode['attr'] = { "id" : safe_id };
// Label (with fallback).
var label = doc['label'];
if( ! label || label == '' ){
label = raw_id;
}else{
... | [
"function",
"_doc_to_tree_node",
"(",
"doc",
",",
"parent_id",
")",
"{",
"var",
"retnode",
"=",
"{",
"}",
";",
"// ID.",
"var",
"raw_id",
"=",
"doc",
"[",
"'id'",
"]",
";",
"var",
"safe_id",
"=",
"raw_id",
";",
"// need to process?",
"retnode",
"[",
"'at... | Return the jsTree node defined by this single argument doc. | [
"Return",
"the",
"jsTree",
"node",
"defined",
"by",
"this",
"single",
"argument",
"doc",
"."
] | c12209eff40abf15ad612525633ce7c2a625dfa9 | https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/javascript/web/DrillExp.js#L161-L233 | train |
geneontology/amigo | javascript/web/Matrix.js | _new_manager | function _new_manager(){
var engine = new jquery_engine(golr_response);
engine.method('GET');
engine.use_jsonp(true);
var manager = new golr_manager(gserv_bulk, gconf, engine, 'async');
return manager;
} | javascript | function _new_manager(){
var engine = new jquery_engine(golr_response);
engine.method('GET');
engine.use_jsonp(true);
var manager = new golr_manager(gserv_bulk, gconf, engine, 'async');
return manager;
} | [
"function",
"_new_manager",
"(",
")",
"{",
"var",
"engine",
"=",
"new",
"jquery_engine",
"(",
"golr_response",
")",
";",
"engine",
".",
"method",
"(",
"'GET'",
")",
";",
"engine",
".",
"use_jsonp",
"(",
"true",
")",
";",
"var",
"manager",
"=",
"new",
"... | default. Create fresh manager. | [
"default",
".",
"Create",
"fresh",
"manager",
"."
] | c12209eff40abf15ad612525633ce7c2a625dfa9 | https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/javascript/web/Matrix.js#L37-L43 | train |
geneontology/amigo | javascript/web/Matrix.js | _get_filters | function _get_filters(filter_manager){
var lstate = filter_manager.get_filter_query_string();
var lparams = bbop.url_parameters(decodeURIComponent(lstate));
var filters_as_strings = [];
us.each(lparams, function(lparam){
if( lparam[0] === 'fq' && lparam[1] ){
filters_as_strings.push(lparam[1]);
... | javascript | function _get_filters(filter_manager){
var lstate = filter_manager.get_filter_query_string();
var lparams = bbop.url_parameters(decodeURIComponent(lstate));
var filters_as_strings = [];
us.each(lparams, function(lparam){
if( lparam[0] === 'fq' && lparam[1] ){
filters_as_strings.push(lparam[1]);
... | [
"function",
"_get_filters",
"(",
"filter_manager",
")",
"{",
"var",
"lstate",
"=",
"filter_manager",
".",
"get_filter_query_string",
"(",
")",
";",
"var",
"lparams",
"=",
"bbop",
".",
"url_parameters",
"(",
"decodeURIComponent",
"(",
"lstate",
")",
")",
";",
"... | Extract the filters being used in the filter manager. | [
"Extract",
"the",
"filters",
"being",
"used",
"in",
"the",
"filter",
"manager",
"."
] | c12209eff40abf15ad612525633ce7c2a625dfa9 | https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/javascript/web/Matrix.js#L48-L61 | train |
geneontology/amigo | javascript/web/Matrix.js | TermInfoStage | function TermInfoStage(term_accs){
// Ready logging.
var logger = new bbop.logger();
logger.DEBUG = true;
function ll(str){ logger.kvetch('JSM01: ' + str); }
ll('TermInfoStage start...');
// Prep the progress bar and hide the order selector until we're
// done.
jQuery("#progress-text")... | javascript | function TermInfoStage(term_accs){
// Ready logging.
var logger = new bbop.logger();
logger.DEBUG = true;
function ll(str){ logger.kvetch('JSM01: ' + str); }
ll('TermInfoStage start...');
// Prep the progress bar and hide the order selector until we're
// done.
jQuery("#progress-text")... | [
"function",
"TermInfoStage",
"(",
"term_accs",
")",
"{",
"// Ready logging.",
"var",
"logger",
"=",
"new",
"bbop",
".",
"logger",
"(",
")",
";",
"logger",
".",
"DEBUG",
"=",
"true",
";",
"function",
"ll",
"(",
"str",
")",
"{",
"logger",
".",
"kvetch",
... | Get the information for the incoming terms, launch stage 02. | [
"Get",
"the",
"information",
"for",
"the",
"incoming",
"terms",
"launch",
"stage",
"02",
"."
] | c12209eff40abf15ad612525633ce7c2a625dfa9 | https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/javascript/web/Matrix.js#L165-L245 | train |
geneontology/amigo | javascript/lib/amigo/api.js | _abstract_solr_filter_template | function _abstract_solr_filter_template(filters){
var allbuf = new Array();
for( var filter_key in filters ){
var filter_val = filters[filter_key];
// If the value looks like an array, iterate over it and
// collect.
if( filter_val &&
filter_val != null &&
typeof filter_val == 'object' &&
... | javascript | function _abstract_solr_filter_template(filters){
var allbuf = new Array();
for( var filter_key in filters ){
var filter_val = filters[filter_key];
// If the value looks like an array, iterate over it and
// collect.
if( filter_val &&
filter_val != null &&
typeof filter_val == 'object' &&
... | [
"function",
"_abstract_solr_filter_template",
"(",
"filters",
")",
"{",
"var",
"allbuf",
"=",
"new",
"Array",
"(",
")",
";",
"for",
"(",
"var",
"filter_key",
"in",
"filters",
")",
"{",
"var",
"filter_val",
"=",
"filters",
"[",
"filter_key",
"]",
";",
"// I... | Similar to the above, but creating a solr filter set. | [
"Similar",
"to",
"the",
"above",
"but",
"creating",
"a",
"solr",
"filter",
"set",
"."
] | c12209eff40abf15ad612525633ce7c2a625dfa9 | https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/javascript/lib/amigo/api.js#L144-L187 | train |
geneontology/amigo | javascript/web/DDBrowse.js | _roots2json | function _roots2json(doc){
var root_id = doc['annotation_class'];
console.log("_roots2json: " +
doc + ', ' +
root_id + ', ' +
entity_counts[root_id]);
// Extract the intersting graphs.
var topo_graph_field = 'topology_graph_json';
var trans_graph_field = 'regulates_transitivity_graph_json';
va... | javascript | function _roots2json(doc){
var root_id = doc['annotation_class'];
console.log("_roots2json: " +
doc + ', ' +
root_id + ', ' +
entity_counts[root_id]);
// Extract the intersting graphs.
var topo_graph_field = 'topology_graph_json';
var trans_graph_field = 'regulates_transitivity_graph_json';
va... | [
"function",
"_roots2json",
"(",
"doc",
")",
"{",
"var",
"root_id",
"=",
"doc",
"[",
"'annotation_class'",
"]",
";",
"console",
".",
"log",
"(",
"\"_roots2json: \"",
"+",
"doc",
"+",
"', '",
"+",
"root_id",
"+",
"', '",
"+",
"entity_counts",
"[",
"root_id",... | Convert a term callback into the proper json. This method is used for the initial graph creation. | [
"Convert",
"a",
"term",
"callback",
"into",
"the",
"proper",
"json",
".",
"This",
"method",
"is",
"used",
"for",
"the",
"initial",
"graph",
"creation",
"."
] | c12209eff40abf15ad612525633ce7c2a625dfa9 | https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/javascript/web/DDBrowse.js#L284-L335 | train |
geneontology/amigo | javascript/web/DDBrowse.js | _resp2json | function _resp2json(doc){
console.log("_resp2json: " + doc);
var kids = []; // ret
// Extract the intersting graphs.
var topo_graph_field = 'topology_graph_json';
var trans_graph_field = 'regulates_transitivity_graph_json';
var topo_graph = new model.graph();
topo_graph.load_base_json(JSON.parse(doc[topo_graph... | javascript | function _resp2json(doc){
console.log("_resp2json: " + doc);
var kids = []; // ret
// Extract the intersting graphs.
var topo_graph_field = 'topology_graph_json';
var trans_graph_field = 'regulates_transitivity_graph_json';
var topo_graph = new model.graph();
topo_graph.load_base_json(JSON.parse(doc[topo_graph... | [
"function",
"_resp2json",
"(",
"doc",
")",
"{",
"console",
".",
"log",
"(",
"\"_resp2json: \"",
"+",
"doc",
")",
";",
"var",
"kids",
"=",
"[",
"]",
";",
"// ret",
"// Extract the intersting graphs.",
"var",
"topo_graph_field",
"=",
"'topology_graph_json'",
";",
... | Convert a term children's into the proper json. | [
"Convert",
"a",
"term",
"children",
"s",
"into",
"the",
"proper",
"json",
"."
] | c12209eff40abf15ad612525633ce7c2a625dfa9 | https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/javascript/web/DDBrowse.js#L338-L391 | train |
geneontology/amigo | javascript/web/DDBrowse.js | function(term_id){
return function(){
// Create manager.
var engine = new jquery_engine(golr_response);
engine.method('GET');
engine.use_jsonp(true);
var manager = new golr_manager(gserv, gconf, engine, 'async');
// Manager settings.
var personality = 'bioentity';
var con... | javascript | function(term_id){
return function(){
// Create manager.
var engine = new jquery_engine(golr_response);
engine.method('GET');
engine.use_jsonp(true);
var manager = new golr_manager(gserv, gconf, engine, 'async');
// Manager settings.
var personality = 'bioentity';
var con... | [
"function",
"(",
"term_id",
")",
"{",
"return",
"function",
"(",
")",
"{",
"// Create manager.",
"var",
"engine",
"=",
"new",
"jquery_engine",
"(",
"golr_response",
")",
";",
"engine",
".",
"method",
"(",
"'GET'",
")",
";",
"engine",
".",
"use_jsonp",
"(",... | Create a new function that returns a promise when called. | [
"Create",
"a",
"new",
"function",
"that",
"returns",
"a",
"promise",
"when",
"called",
"."
] | c12209eff40abf15ad612525633ce7c2a625dfa9 | https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/javascript/web/DDBrowse.js#L507-L530 | train | |
geneontology/amigo | static/js/org/cytoscape.js | function( map ){
var empty = true;
if( map != null ){
for(var i in map){
empty = false;
break;
}
}
return empty;
} | javascript | function( map ){
var empty = true;
if( map != null ){
for(var i in map){
empty = false;
break;
}
}
return empty;
} | [
"function",
"(",
"map",
")",
"{",
"var",
"empty",
"=",
"true",
";",
"if",
"(",
"map",
"!=",
"null",
")",
"{",
"for",
"(",
"var",
"i",
"in",
"map",
")",
"{",
"empty",
"=",
"false",
";",
"break",
";",
"}",
"}",
"return",
"empty",
";",
"}"
] | has anything been set in the map | [
"has",
"anything",
"been",
"set",
"in",
"the",
"map"
] | c12209eff40abf15ad612525633ce7c2a625dfa9 | https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/static/js/org/cytoscape.js#L405-L416 | train | |
geneontology/amigo | static/js/org/cytoscape.js | function( options ){
var obj = options.map;
var keys = options.keys;
var l = keys.length;
var keepChildren = options.keepChildren;
for(var i = 0; i < l; i++){
var key = keys[i];
if( $$.is.plainObject( key ) ){
$$.util.error('Tried to delete map with object... | javascript | function( options ){
var obj = options.map;
var keys = options.keys;
var l = keys.length;
var keepChildren = options.keepChildren;
for(var i = 0; i < l; i++){
var key = keys[i];
if( $$.is.plainObject( key ) ){
$$.util.error('Tried to delete map with object... | [
"function",
"(",
"options",
")",
"{",
"var",
"obj",
"=",
"options",
".",
"map",
";",
"var",
"keys",
"=",
"options",
".",
"keys",
";",
"var",
"l",
"=",
"keys",
".",
"length",
";",
"var",
"keepChildren",
"=",
"options",
".",
"keepChildren",
";",
"for",... | deletes the entry in the map | [
"deletes",
"the",
"entry",
"in",
"the",
"map"
] | c12209eff40abf15ad612525633ce7c2a625dfa9 | https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/static/js/org/cytoscape.js#L484-L514 | train | |
geneontology/amigo | static/js/org/cytoscape.js | function( str ){
var first, last;
// find first non-space char
for( first = 0; first < str.length && str[first] === ' '; first++ ){}
// find last non-space char
for( last = str.length - 1; last > first && str[last] === ' '; last-- ){}
return str.substring(first, last + 1);
} | javascript | function( str ){
var first, last;
// find first non-space char
for( first = 0; first < str.length && str[first] === ' '; first++ ){}
// find last non-space char
for( last = str.length - 1; last > first && str[last] === ' '; last-- ){}
return str.substring(first, last + 1);
} | [
"function",
"(",
"str",
")",
"{",
"var",
"first",
",",
"last",
";",
"// find first non-space char",
"for",
"(",
"first",
"=",
"0",
";",
"first",
"<",
"str",
".",
"length",
"&&",
"str",
"[",
"first",
"]",
"===",
"' '",
";",
"first",
"++",
")",
"{",
... | strip spaces from beginning of string and end of string | [
"strip",
"spaces",
"from",
"beginning",
"of",
"string",
"and",
"end",
"of",
"string"
] | c12209eff40abf15ad612525633ce7c2a625dfa9 | https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/static/js/org/cytoscape.js#L571-L581 | train | |
geneontology/amigo | static/js/org/cytoscape.js | function( params ){
var defaults = {
field: 'data',
event: 'data',
triggerFnName: 'trigger',
triggerEvent: false,
immutableKeys: {} // key => true if immutable
};
params = $$.util.extend({}, defaults, params);
return function removeDataImpl( names ){
... | javascript | function( params ){
var defaults = {
field: 'data',
event: 'data',
triggerFnName: 'trigger',
triggerEvent: false,
immutableKeys: {} // key => true if immutable
};
params = $$.util.extend({}, defaults, params);
return function removeDataImpl( names ){
... | [
"function",
"(",
"params",
")",
"{",
"var",
"defaults",
"=",
"{",
"field",
":",
"'data'",
",",
"event",
":",
"'data'",
",",
"triggerFnName",
":",
"'trigger'",
",",
"triggerEvent",
":",
"false",
",",
"immutableKeys",
":",
"{",
"}",
"// key => true if immutabl... | remove data field | [
"remove",
"data",
"field"
] | c12209eff40abf15ad612525633ce7c2a625dfa9 | https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/static/js/org/cytoscape.js#L3129-L3189 | train | |
geneontology/amigo | static/js/org/cytoscape.js | function(){
return {
classes: [],
colonSelectors: [],
data: [],
group: null,
ids: [],
meta: [],
// fake selectors
collection: null, // a collection to match against
filter: null, // filter function
// these ar... | javascript | function(){
return {
classes: [],
colonSelectors: [],
data: [],
group: null,
ids: [],
meta: [],
// fake selectors
collection: null, // a collection to match against
filter: null, // filter function
// these ar... | [
"function",
"(",
")",
"{",
"return",
"{",
"classes",
":",
"[",
"]",
",",
"colonSelectors",
":",
"[",
"]",
",",
"data",
":",
"[",
"]",
",",
"group",
":",
"null",
",",
"ids",
":",
"[",
"]",
",",
"meta",
":",
"[",
"]",
",",
"// fake selectors",
"c... | storage for parsed queries | [
"storage",
"for",
"parsed",
"queries"
] | c12209eff40abf15ad612525633ce7c2a625dfa9 | https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/static/js/org/cytoscape.js#L3596-L3619 | train | |
geneontology/amigo | static/js/org/cytoscape.js | function( expectation ){
var expr;
var match;
var name;
for( var j = 0; j < exprs.length; j++ ){
var e = exprs[j];
var n = e.name;
// ignore this expression if it doesn't meet the expectation function
if( $$.is.fn( expectation ) && !expec... | javascript | function( expectation ){
var expr;
var match;
var name;
for( var j = 0; j < exprs.length; j++ ){
var e = exprs[j];
var n = e.name;
// ignore this expression if it doesn't meet the expectation function
if( $$.is.fn( expectation ) && !expec... | [
"function",
"(",
"expectation",
")",
"{",
"var",
"expr",
";",
"var",
"match",
";",
"var",
"name",
";",
"for",
"(",
"var",
"j",
"=",
"0",
";",
"j",
"<",
"exprs",
".",
"length",
";",
"j",
"++",
")",
"{",
"var",
"e",
"=",
"exprs",
"[",
"j",
"]",... | of all the expressions, find the first match in the remaining text | [
"of",
"all",
"the",
"expressions",
"find",
"the",
"first",
"match",
"in",
"the",
"remaining",
"text"
] | c12209eff40abf15ad612525633ce7c2a625dfa9 | https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/static/js/org/cytoscape.js#L3813-L3844 | train | |
geneontology/amigo | static/js/org/cytoscape.js | function( roots, fn, directed ){
directed = arguments.length === 1 && !$$.is.fn(fn) ? fn : directed;
fn = $$.is.fn(fn) ? fn : function(){};
var cy = this._private.cy;
var v = $$.is.string(roots) ? this.filter(roots) : roots;
var Q = [];
var connectedEles = [];
var connectedFrom... | javascript | function( roots, fn, directed ){
directed = arguments.length === 1 && !$$.is.fn(fn) ? fn : directed;
fn = $$.is.fn(fn) ? fn : function(){};
var cy = this._private.cy;
var v = $$.is.string(roots) ? this.filter(roots) : roots;
var Q = [];
var connectedEles = [];
var connectedFrom... | [
"function",
"(",
"roots",
",",
"fn",
",",
"directed",
")",
"{",
"directed",
"=",
"arguments",
".",
"length",
"===",
"1",
"&&",
"!",
"$$",
".",
"is",
".",
"fn",
"(",
"fn",
")",
"?",
"fn",
":",
"directed",
";",
"fn",
"=",
"$$",
".",
"is",
".",
... | do a breadth first search from the nodes in the collection from pseudocode on wikipedia | [
"do",
"a",
"breadth",
"first",
"search",
"from",
"the",
"nodes",
"in",
"the",
"collection",
"from",
"pseudocode",
"on",
"wikipedia"
] | c12209eff40abf15ad612525633ce7c2a625dfa9 | https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/static/js/org/cytoscape.js#L8082-L8146 | train | |
geneontology/amigo | static/js/org/cytoscape.js | function(){
var ele = this[0];
if( ele && ele.isNode() ){
var h = ele._private.style.height;
return h.strValue === 'auto' ? ele._private.autoHeight : h.pxValue;
}
} | javascript | function(){
var ele = this[0];
if( ele && ele.isNode() ){
var h = ele._private.style.height;
return h.strValue === 'auto' ? ele._private.autoHeight : h.pxValue;
}
} | [
"function",
"(",
")",
"{",
"var",
"ele",
"=",
"this",
"[",
"0",
"]",
";",
"if",
"(",
"ele",
"&&",
"ele",
".",
"isNode",
"(",
")",
")",
"{",
"var",
"h",
"=",
"ele",
".",
"_private",
".",
"style",
".",
"height",
";",
"return",
"h",
".",
"strVal... | convenience function to get a numerical value for the height of the node | [
"convenience",
"function",
"to",
"get",
"a",
"numerical",
"value",
"for",
"the",
"height",
"of",
"the",
"node"
] | c12209eff40abf15ad612525633ce7c2a625dfa9 | https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/static/js/org/cytoscape.js#L9077-L9084 | train | |
geneontology/amigo | static/js/org/cytoscape.js | function( selector ){
var eles = this;
var roots = [];
for( var i = 0; i < eles.length; i++ ){
var ele = eles[i];
if( !ele.isNode() ){
continue;
}
var hasEdgesPointingIn = ele.connectedEdges('[target = "' + ele.id() + '"][source != "' + ele.id() + '"]').lengt... | javascript | function( selector ){
var eles = this;
var roots = [];
for( var i = 0; i < eles.length; i++ ){
var ele = eles[i];
if( !ele.isNode() ){
continue;
}
var hasEdgesPointingIn = ele.connectedEdges('[target = "' + ele.id() + '"][source != "' + ele.id() + '"]').lengt... | [
"function",
"(",
"selector",
")",
"{",
"var",
"eles",
"=",
"this",
";",
"var",
"roots",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"eles",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"ele",
"=",
"eles",
"[",
"i... | get the root nodes in the DAG | [
"get",
"the",
"root",
"nodes",
"in",
"the",
"DAG"
] | c12209eff40abf15ad612525633ce7c2a625dfa9 | https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/static/js/org/cytoscape.js#L10147-L10164 | train | |
geneontology/amigo | static/js/org/cytoscape.js | function( selector ){
var eles = this;
var fNodes = [];
for( var i = 0; i < eles.length; i++ ){
var ele = eles[i];
var eleId = ele.id();
if( !ele.isNode() ){ continue; }
var edges = ele._private.edges;
for( var j = 0; j < edges.length; j++ ){
var ed... | javascript | function( selector ){
var eles = this;
var fNodes = [];
for( var i = 0; i < eles.length; i++ ){
var ele = eles[i];
var eleId = ele.id();
if( !ele.isNode() ){ continue; }
var edges = ele._private.edges;
for( var j = 0; j < edges.length; j++ ){
var ed... | [
"function",
"(",
"selector",
")",
"{",
"var",
"eles",
"=",
"this",
";",
"var",
"fNodes",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"eles",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"ele",
"=",
"eles",
"[",
"... | normally called children in graph theory these nodes =edges=> forward nodes | [
"normally",
"called",
"children",
"in",
"graph",
"theory",
"these",
"nodes",
"=",
"edges",
"=",
">",
"forward",
"nodes"
] | c12209eff40abf15ad612525633ce7c2a625dfa9 | https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/static/js/org/cytoscape.js#L10168-L10191 | train | |
geneontology/amigo | static/js/org/cytoscape.js | function(node, dragElements) {
node._private.grabbed = true;
node._private.rscratch.inDragLayer = true;
dragElements.push(node);
for (var i=0;i<node._private.edges.length;i++) {
node._private.edges[i]._private.rscratch.inDragLayer = true;
}
//node.trigger(new $$.Event(e, {... | javascript | function(node, dragElements) {
node._private.grabbed = true;
node._private.rscratch.inDragLayer = true;
dragElements.push(node);
for (var i=0;i<node._private.edges.length;i++) {
node._private.edges[i]._private.rscratch.inDragLayer = true;
}
//node.trigger(new $$.Event(e, {... | [
"function",
"(",
"node",
",",
"dragElements",
")",
"{",
"node",
".",
"_private",
".",
"grabbed",
"=",
"true",
";",
"node",
".",
"_private",
".",
"rscratch",
".",
"inDragLayer",
"=",
"true",
";",
"dragElements",
".",
"push",
"(",
"node",
")",
";",
"for"... | adds the given nodes, and its edges to the drag layer | [
"adds",
"the",
"given",
"nodes",
"and",
"its",
"edges",
"to",
"the",
"drag",
"layer"
] | c12209eff40abf15ad612525633ce7c2a625dfa9 | https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/static/js/org/cytoscape.js#L14478-L14489 | train | |
geneontology/amigo | static/js/org/cytoscape.js | function( eles ){
for( var i = 0; i < eles.length; i++ ){
eles[i]._private.grabbed = false;
eles[i]._private.rscratch.inDragLayer = false;
if( eles[i].active() ){ eles[i].unactivate(); }
}
} | javascript | function( eles ){
for( var i = 0; i < eles.length; i++ ){
eles[i]._private.grabbed = false;
eles[i]._private.rscratch.inDragLayer = false;
if( eles[i].active() ){ eles[i].unactivate(); }
}
} | [
"function",
"(",
"eles",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"eles",
".",
"length",
";",
"i",
"++",
")",
"{",
"eles",
"[",
"i",
"]",
".",
"_private",
".",
"grabbed",
"=",
"false",
";",
"eles",
"[",
"i",
"]",
".",
"_pr... | anything in the set of dragged eles should be released | [
"anything",
"in",
"the",
"set",
"of",
"dragged",
"eles",
"should",
"be",
"released"
] | c12209eff40abf15ad612525633ce7c2a625dfa9 | https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/static/js/org/cytoscape.js#L15355-L15361 | train | |
mjeanroy/rollup-plugin-license | src/license-plugin.js | validateOptions | function validateOptions(options) {
const notSupported = _.reject(_.keys(options), (key) => (
OPTIONS.has(key)
));
if (notSupported.length > 0) {
console.warn(`[${PLUGIN_NAME}] Options ${notSupported} are not supported, use following options: ${Array.from(OPTIONS)}`);
}
} | javascript | function validateOptions(options) {
const notSupported = _.reject(_.keys(options), (key) => (
OPTIONS.has(key)
));
if (notSupported.length > 0) {
console.warn(`[${PLUGIN_NAME}] Options ${notSupported} are not supported, use following options: ${Array.from(OPTIONS)}`);
}
} | [
"function",
"validateOptions",
"(",
"options",
")",
"{",
"const",
"notSupported",
"=",
"_",
".",
"reject",
"(",
"_",
".",
"keys",
"(",
"options",
")",
",",
"(",
"key",
")",
"=>",
"(",
"OPTIONS",
".",
"has",
"(",
"key",
")",
")",
")",
";",
"if",
"... | Print for deprecated or unknown options according to the `OPTIONS`
set defined below.
@param {Object} options The initialization option.
@return {void} | [
"Print",
"for",
"deprecated",
"or",
"unknown",
"options",
"according",
"to",
"the",
"OPTIONS",
"set",
"defined",
"below",
"."
] | 39eecef4bde8448b973439929f96cc50bbdb0132 | https://github.com/mjeanroy/rollup-plugin-license/blob/39eecef4bde8448b973439929f96cc50bbdb0132/src/license-plugin.js#L62-L70 | train |
mjeanroy/rollup-plugin-license | src/license-plugin.js | fixSourceMapOptions | function fixSourceMapOptions(options) {
// Rollup <= 0.48 used `sourceMap` in camelcase, so this plugin used
// this convention at the beginning.
// Now, the `sourcemap` key should be used, but legacy version should still
// be able to use the `sourceMap` key.
const newOptions = _.omitBy(options, (value, key)... | javascript | function fixSourceMapOptions(options) {
// Rollup <= 0.48 used `sourceMap` in camelcase, so this plugin used
// this convention at the beginning.
// Now, the `sourcemap` key should be used, but legacy version should still
// be able to use the `sourceMap` key.
const newOptions = _.omitBy(options, (value, key)... | [
"function",
"fixSourceMapOptions",
"(",
"options",
")",
"{",
"// Rollup <= 0.48 used `sourceMap` in camelcase, so this plugin used",
"// this convention at the beginning.",
"// Now, the `sourcemap` key should be used, but legacy version should still",
"// be able to use the `sourceMap` key.",
"c... | Fix option object, replace `sourceMap` with `sourcemap` if needed.
@param {Object} options Original option object.
@return {Object} The new fixed option object. | [
"Fix",
"option",
"object",
"replace",
"sourceMap",
"with",
"sourcemap",
"if",
"needed",
"."
] | 39eecef4bde8448b973439929f96cc50bbdb0132 | https://github.com/mjeanroy/rollup-plugin-license/blob/39eecef4bde8448b973439929f96cc50bbdb0132/src/license-plugin.js#L78-L99 | train |
geneontology/amigo | gulpfile.js | _ping_count | function _ping_count(){
if( count_url && typeof(count_url) === 'string' && count_url !== '' ){
request({
url: count_url
}, function(error, response, body){
if( error || response.statusCode !== 200 ){
console.log('Unable to ping: ' + count_url);
}else{
console.log('Pinged: ' + count_url);
... | javascript | function _ping_count(){
if( count_url && typeof(count_url) === 'string' && count_url !== '' ){
request({
url: count_url
}, function(error, response, body){
if( error || response.statusCode !== 200 ){
console.log('Unable to ping: ' + count_url);
}else{
console.log('Pinged: ' + count_url);
... | [
"function",
"_ping_count",
"(",
")",
"{",
"if",
"(",
"count_url",
"&&",
"typeof",
"(",
"count_url",
")",
"===",
"'string'",
"&&",
"count_url",
"!==",
"''",
")",
"{",
"request",
"(",
"{",
"url",
":",
"count_url",
"}",
",",
"function",
"(",
"error",
",",... | Ping server; used during certain commands. | [
"Ping",
"server",
";",
"used",
"during",
"certain",
"commands",
"."
] | c12209eff40abf15ad612525633ce7c2a625dfa9 | https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/gulpfile.js#L42-L58 | train |
geneontology/amigo | gulpfile.js | _client_compile_task | function _client_compile_task(file) {
var infile = amigo_js_dev_path + '/' +file;
//var outfile = amigo_js_out_path + '/' +file;
var b = browserify(infile);
return b
// not in npm, don't need in browser
.exclude('ringo/httpclient')
.bundle()
// desired output filename to vinyl-source-stream
... | javascript | function _client_compile_task(file) {
var infile = amigo_js_dev_path + '/' +file;
//var outfile = amigo_js_out_path + '/' +file;
var b = browserify(infile);
return b
// not in npm, don't need in browser
.exclude('ringo/httpclient')
.bundle()
// desired output filename to vinyl-source-stream
... | [
"function",
"_client_compile_task",
"(",
"file",
")",
"{",
"var",
"infile",
"=",
"amigo_js_dev_path",
"+",
"'/'",
"+",
"file",
";",
"//var outfile = amigo_js_out_path + '/' +file;",
"var",
"b",
"=",
"browserify",
"(",
"infile",
")",
";",
"return",
"b",
"// not in ... | See what browserify-shim is up to. process.env.BROWSERIFYSHIM_DIAGNOSTICS = 1; Browser runtime environment construction. | [
"See",
"what",
"browserify",
"-",
"shim",
"is",
"up",
"to",
".",
"process",
".",
"env",
".",
"BROWSERIFYSHIM_DIAGNOSTICS",
"=",
"1",
";",
"Browser",
"runtime",
"environment",
"construction",
"."
] | c12209eff40abf15ad612525633ce7c2a625dfa9 | https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/gulpfile.js#L300-L313 | train |
strapi/strapi-generate-users | files/api/user/services/grant.js | getProfile | function getProfile(provider, access_token, callback) {
let fields;
switch (provider) {
case 'facebook':
facebook.query().get('me?fields=name,email').auth(access_token).request(function (err, res, body) {
if (err) {
callback(err);
} else {
callback(null, {
u... | javascript | function getProfile(provider, access_token, callback) {
let fields;
switch (provider) {
case 'facebook':
facebook.query().get('me?fields=name,email').auth(access_token).request(function (err, res, body) {
if (err) {
callback(err);
} else {
callback(null, {
u... | [
"function",
"getProfile",
"(",
"provider",
",",
"access_token",
",",
"callback",
")",
"{",
"let",
"fields",
";",
"switch",
"(",
"provider",
")",
"{",
"case",
"'facebook'",
":",
"facebook",
".",
"query",
"(",
")",
".",
"get",
"(",
"'me?fields=name,email'",
... | Helper to get profiles
@param {String} provider
@param {Function} callback | [
"Helper",
"to",
"get",
"profiles"
] | e7e8913165a591c26081706fedaec9dd4c801c50 | https://github.com/strapi/strapi-generate-users/blob/e7e8913165a591c26081706fedaec9dd4c801c50/files/api/user/services/grant.js#L99-L159 | train |
geneontology/amigo | javascript/npm/bbop-widget-set/lib/display.js | function(){
var retval = false;
var lc = jQuery(this).text().toLowerCase();
if( lc.indexOf(stext) >= 0 ){
retval = true;
}
return retval;
} | javascript | function(){
var retval = false;
var lc = jQuery(this).text().toLowerCase();
if( lc.indexOf(stext) >= 0 ){
retval = true;
}
return retval;
} | [
"function",
"(",
")",
"{",
"var",
"retval",
"=",
"false",
";",
"var",
"lc",
"=",
"jQuery",
"(",
"this",
")",
".",
"text",
"(",
")",
".",
"toLowerCase",
"(",
")",
";",
"if",
"(",
"lc",
".",
"indexOf",
"(",
"stext",
")",
">=",
"0",
")",
"{",
"r... | jQuery filter to match element contents against stext. | [
"jQuery",
"filter",
"to",
"match",
"element",
"contents",
"against",
"stext",
"."
] | c12209eff40abf15ad612525633ce7c2a625dfa9 | https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/javascript/npm/bbop-widget-set/lib/display.js#L383-L390 | train | |
geneontology/amigo | javascript/lib/amigo/ui/interactive.js | _has_item | function _has_item(in_arg_key){
var retval = false;
if( typeof anchor.current_data[in_arg_key] != 'undefined' ){
retval = true;
}
return retval;
} | javascript | function _has_item(in_arg_key){
var retval = false;
if( typeof anchor.current_data[in_arg_key] != 'undefined' ){
retval = true;
}
return retval;
} | [
"function",
"_has_item",
"(",
"in_arg_key",
")",
"{",
"var",
"retval",
"=",
"false",
";",
"if",
"(",
"typeof",
"anchor",
".",
"current_data",
"[",
"in_arg_key",
"]",
"!=",
"'undefined'",
")",
"{",
"retval",
"=",
"true",
";",
"}",
"return",
"retval",
";",... | See if data item exists by key. | [
"See",
"if",
"data",
"item",
"exists",
"by",
"key",
"."
] | c12209eff40abf15ad612525633ce7c2a625dfa9 | https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/javascript/lib/amigo/ui/interactive.js#L73-L79 | train |
geneontology/amigo | javascript/lib/amigo/ui/interactive.js | _add_item | function _add_item(in_arg_key, data){
var retval = false;
if( typeof anchor.current_data[in_arg_key] == 'undefined' ){
// BUG/TODO: this should be a copy.
anchor.current_data[in_arg_key] = data;
//ll("add_item: adding key (w/data): " + in_arg_key);
retval = true;
}
return retval;
} | javascript | function _add_item(in_arg_key, data){
var retval = false;
if( typeof anchor.current_data[in_arg_key] == 'undefined' ){
// BUG/TODO: this should be a copy.
anchor.current_data[in_arg_key] = data;
//ll("add_item: adding key (w/data): " + in_arg_key);
retval = true;
}
return retval;
} | [
"function",
"_add_item",
"(",
"in_arg_key",
",",
"data",
")",
"{",
"var",
"retval",
"=",
"false",
";",
"if",
"(",
"typeof",
"anchor",
".",
"current_data",
"[",
"in_arg_key",
"]",
"==",
"'undefined'",
")",
"{",
"// BUG/TODO: this should be a copy.",
"anchor",
"... | Add a new data item to the model. | [
"Add",
"a",
"new",
"data",
"item",
"to",
"the",
"model",
"."
] | c12209eff40abf15ad612525633ce7c2a625dfa9 | https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/javascript/lib/amigo/ui/interactive.js#L84-L94 | train |
geneontology/amigo | javascript/lib/amigo/ui/interactive.js | _update_value | function _update_value(inkey, intype, inval){
// Update the value in question.
var rval = false;
if( typeof anchor.current_data[inkey] != 'undefined' &&
typeof anchor.current_data[inkey][intype] != 'undefined' ){
anchor.current_data[inkey][intype] = inval;
rval = true;
// ll("\tupdated: " + inkey +
// ... | javascript | function _update_value(inkey, intype, inval){
// Update the value in question.
var rval = false;
if( typeof anchor.current_data[inkey] != 'undefined' &&
typeof anchor.current_data[inkey][intype] != 'undefined' ){
anchor.current_data[inkey][intype] = inval;
rval = true;
// ll("\tupdated: " + inkey +
// ... | [
"function",
"_update_value",
"(",
"inkey",
",",
"intype",
",",
"inval",
")",
"{",
"// Update the value in question.",
"var",
"rval",
"=",
"false",
";",
"if",
"(",
"typeof",
"anchor",
".",
"current_data",
"[",
"inkey",
"]",
"!=",
"'undefined'",
"&&",
"typeof",
... | Update the underlying data structure. Can change count or selected or whatever. | [
"Update",
"the",
"underlying",
"data",
"structure",
".",
"Can",
"change",
"count",
"or",
"selected",
"or",
"whatever",
"."
] | c12209eff40abf15ad612525633ce7c2a625dfa9 | https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/javascript/lib/amigo/ui/interactive.js#L100-L122 | train |
geneontology/amigo | javascript/lib/amigo/ui/interactive.js | _get_selected_items | function _get_selected_items(){
var ret_filters = [];
// Push out the filters that have selected == true.
var all_filters = _get_all_items();
for( var afi = 0; afi < all_filters.length; afi++ ){
var filter_name = all_filters[afi];
var fconf = anchor.current_data[filter_name];
if( fconf &&
typeof... | javascript | function _get_selected_items(){
var ret_filters = [];
// Push out the filters that have selected == true.
var all_filters = _get_all_items();
for( var afi = 0; afi < all_filters.length; afi++ ){
var filter_name = all_filters[afi];
var fconf = anchor.current_data[filter_name];
if( fconf &&
typeof... | [
"function",
"_get_selected_items",
"(",
")",
"{",
"var",
"ret_filters",
"=",
"[",
"]",
";",
"// Push out the filters that have selected == true.",
"var",
"all_filters",
"=",
"_get_all_items",
"(",
")",
";",
"for",
"(",
"var",
"afi",
"=",
"0",
";",
"afi",
"<",
... | Give all selected current filters. | [
"Give",
"all",
"selected",
"current",
"filters",
"."
] | c12209eff40abf15ad612525633ce7c2a625dfa9 | https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/javascript/lib/amigo/ui/interactive.js#L143-L160 | train |
geneontology/amigo | javascript/lib/amigo/ui/interactive.js | _render_label | function _render_label(){
var buf = new Array();
// Add the label.
buf.push('<label for="');
buf.push(anchor.mid);
buf.push('" class="select">');
buf.push(anchor.mlabel);
buf.push('</label>');
return buf.join('');
} | javascript | function _render_label(){
var buf = new Array();
// Add the label.
buf.push('<label for="');
buf.push(anchor.mid);
buf.push('" class="select">');
buf.push(anchor.mlabel);
buf.push('</label>');
return buf.join('');
} | [
"function",
"_render_label",
"(",
")",
"{",
"var",
"buf",
"=",
"new",
"Array",
"(",
")",
";",
"// Add the label.",
"buf",
".",
"push",
"(",
"'<label for=\"'",
")",
";",
"buf",
".",
"push",
"(",
"anchor",
".",
"mid",
")",
";",
"buf",
".",
"push",
"(",... | Render the label to an HTML string. | [
"Render",
"the",
"label",
"to",
"an",
"HTML",
"string",
"."
] | c12209eff40abf15ad612525633ce7c2a625dfa9 | https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/javascript/lib/amigo/ui/interactive.js#L207-L219 | train |
geneontology/amigo | javascript/lib/amigo/ui/interactive.js | _render_option | function _render_option(){
var buf = new Array();
// Sort the items in the mdata array.
// Also keep a lookup for a "special" entry.
// var default_on_p = false;
var mdata_keys = bbop.core.get_keys(anchor.mdata);
function _data_comp(a, b){
// Get the associated data.
var a_data = anchor.mdata[a];
... | javascript | function _render_option(){
var buf = new Array();
// Sort the items in the mdata array.
// Also keep a lookup for a "special" entry.
// var default_on_p = false;
var mdata_keys = bbop.core.get_keys(anchor.mdata);
function _data_comp(a, b){
// Get the associated data.
var a_data = anchor.mdata[a];
... | [
"function",
"_render_option",
"(",
")",
"{",
"var",
"buf",
"=",
"new",
"Array",
"(",
")",
";",
"// Sort the items in the mdata array.",
"// Also keep a lookup for a \"special\" entry.",
"// var default_on_p = false;",
"var",
"mdata_keys",
"=",
"bbop",
".",
"core",
".",
... | Render the options to an HTML string. | [
"Render",
"the",
"options",
"to",
"an",
"HTML",
"string",
"."
] | c12209eff40abf15ad612525633ce7c2a625dfa9 | https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/javascript/lib/amigo/ui/interactive.js#L224-L309 | train |
geneontology/amigo | javascript/lib/amigo/ui/interactive.js | _render_select | function _render_select(){
var buf = new Array();
//
buf.push('<select id="');
buf.push(anchor.mid);
buf.push('" name="');
buf.push(anchor.mname);
buf.push('" multiple size="');
buf.push(anchor.msize);
buf.push('">');
buf.push(_render_option());
//
buf.push('</select>');
return buf.join('');
} | javascript | function _render_select(){
var buf = new Array();
//
buf.push('<select id="');
buf.push(anchor.mid);
buf.push('" name="');
buf.push(anchor.mname);
buf.push('" multiple size="');
buf.push(anchor.msize);
buf.push('">');
buf.push(_render_option());
//
buf.push('</select>');
return buf.join('');
} | [
"function",
"_render_select",
"(",
")",
"{",
"var",
"buf",
"=",
"new",
"Array",
"(",
")",
";",
"//",
"buf",
".",
"push",
"(",
"'<select id=\"'",
")",
";",
"buf",
".",
"push",
"(",
"anchor",
".",
"mid",
")",
";",
"buf",
".",
"push",
"(",
"'\" name=\... | Render the select frame to an HTML string. | [
"Render",
"the",
"select",
"frame",
"to",
"an",
"HTML",
"string",
"."
] | c12209eff40abf15ad612525633ce7c2a625dfa9 | https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/javascript/lib/amigo/ui/interactive.js#L314-L333 | train |
geneontology/amigo | javascript/web/GeneralSearchForwarding.js | forward | function forward(doc){
if( doc && doc['entity'] && doc['category'] ){
// Erase any val, change the placeholder (to try and
// prevent races where the user selects and then hits
// "search" before the forwarding finishes).
jQuery('#' + wired_name).val('');
jQuery('#' + wired_name).attr('place... | javascript | function forward(doc){
if( doc && doc['entity'] && doc['category'] ){
// Erase any val, change the placeholder (to try and
// prevent races where the user selects and then hits
// "search" before the forwarding finishes).
jQuery('#' + wired_name).val('');
jQuery('#' + wired_name).attr('place... | [
"function",
"forward",
"(",
"doc",
")",
"{",
"if",
"(",
"doc",
"&&",
"doc",
"[",
"'entity'",
"]",
"&&",
"doc",
"[",
"'category'",
"]",
")",
"{",
"// Erase any val, change the placeholder (to try and",
"// prevent races where the user selects and then hits",
"// \"search... | Widget, default personality and filter. | [
"Widget",
"default",
"personality",
"and",
"filter",
"."
] | c12209eff40abf15ad612525633ce7c2a625dfa9 | https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/javascript/web/GeneralSearchForwarding.js#L56-L75 | train |
geneontology/amigo | javascript/lib/amigo/ui/widgets.js | _generate_element | function _generate_element(ctype){
var UID = id_base + bbop.core.randomness();
var div_text = '<div id="' + UID + '"></div>';
jQuery("body").append(jQuery(div_text).hide());
var elt = jQuery('#' + UID);
elt.addClass("org_bbop_amigo_ui_widget_base");
elt.addClass("org_bbop_amigo_ui_widget_for_" + ctype);
retu... | javascript | function _generate_element(ctype){
var UID = id_base + bbop.core.randomness();
var div_text = '<div id="' + UID + '"></div>';
jQuery("body").append(jQuery(div_text).hide());
var elt = jQuery('#' + UID);
elt.addClass("org_bbop_amigo_ui_widget_base");
elt.addClass("org_bbop_amigo_ui_widget_for_" + ctype);
retu... | [
"function",
"_generate_element",
"(",
"ctype",
")",
"{",
"var",
"UID",
"=",
"id_base",
"+",
"bbop",
".",
"core",
".",
"randomness",
"(",
")",
";",
"var",
"div_text",
"=",
"'<div id=\"'",
"+",
"UID",
"+",
"'\"></div>'",
";",
"jQuery",
"(",
"\"body\"",
")"... | Generate and destory used tags. | [
"Generate",
"and",
"destory",
"used",
"tags",
"."
] | c12209eff40abf15ad612525633ce7c2a625dfa9 | https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/javascript/lib/amigo/ui/widgets.js#L54-L66 | train |
geneontology/amigo | bin/amigo.js | envelope | function envelope(service_name){
var anchor = this;
anchor._is_a = 'bbop-service-envelope';
// Start the timer.
anchor._start_time = second_count();
// Theoretical good result frame.
anchor._envelope = {
service: 'n/a',
status: 'success',
arguments: {},
comments: [],
data: {}
};
... | javascript | function envelope(service_name){
var anchor = this;
anchor._is_a = 'bbop-service-envelope';
// Start the timer.
anchor._start_time = second_count();
// Theoretical good result frame.
anchor._envelope = {
service: 'n/a',
status: 'success',
arguments: {},
comments: [],
data: {}
};
... | [
"function",
"envelope",
"(",
"service_name",
")",
"{",
"var",
"anchor",
"=",
"this",
";",
"anchor",
".",
"_is_a",
"=",
"'bbop-service-envelope'",
";",
"// Start the timer.",
"anchor",
".",
"_start_time",
"=",
"second_count",
"(",
")",
";",
"// Theoretical good res... | Envelopes are default good. | [
"Envelopes",
"are",
"default",
"good",
"."
] | c12209eff40abf15ad612525633ce7c2a625dfa9 | https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/bin/amigo.js#L83-L105 | train |
geneontology/amigo | bin/amigo.js | _response_json_fail | function _response_json_fail(res, envl, message){
envl.status('failure');
envl.comments(message);
return res.json(envl.structure());
} | javascript | function _response_json_fail(res, envl, message){
envl.status('failure');
envl.comments(message);
return res.json(envl.structure());
} | [
"function",
"_response_json_fail",
"(",
"res",
",",
"envl",
",",
"message",
")",
"{",
"envl",
".",
"status",
"(",
"'failure'",
")",
";",
"envl",
".",
"comments",
"(",
"message",
")",
";",
"return",
"res",
".",
"json",
"(",
"envl",
".",
"structure",
"("... | Failure with a JSON response. | [
"Failure",
"with",
"a",
"JSON",
"response",
"."
] | c12209eff40abf15ad612525633ce7c2a625dfa9 | https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/bin/amigo.js#L260-L264 | train |
geneontology/amigo | bin/amigo.js | _param | function _param(req, param, pdefault){
var ret = null;
// Try the route parameter space.
if( req && req.params && typeof(req.params[param]) !== 'undefined' ){
ret = req.params[param];
}
// Try the get space.
if( ! ret ){
if( req && req.query && req.query[param] && typeof(req.query[param]) ... | javascript | function _param(req, param, pdefault){
var ret = null;
// Try the route parameter space.
if( req && req.params && typeof(req.params[param]) !== 'undefined' ){
ret = req.params[param];
}
// Try the get space.
if( ! ret ){
if( req && req.query && req.query[param] && typeof(req.query[param]) ... | [
"function",
"_param",
"(",
"req",
",",
"param",
",",
"pdefault",
")",
"{",
"var",
"ret",
"=",
"null",
";",
"// Try the route parameter space.",
"if",
"(",
"req",
"&&",
"req",
".",
"params",
"&&",
"typeof",
"(",
"req",
".",
"params",
"[",
"param",
"]",
... | Extract singular arguments; will take first if multiple. | [
"Extract",
"singular",
"arguments",
";",
"will",
"take",
"first",
"if",
"multiple",
"."
] | c12209eff40abf15ad612525633ce7c2a625dfa9 | https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/bin/amigo.js#L267-L308 | train |
geneontology/amigo | bin/amigo.js | _extract | function _extract(req, param){
var ret = [];
// Note: no route parameter possible with lists(?).
// Try the get space.
if( req && req.query && typeof(req.query[param]) !== 'undefined' ){
//console.log('as query');
// Input as list, remove dupes.
var paccs = req.query[param];
if( paccs && ! us.is... | javascript | function _extract(req, param){
var ret = [];
// Note: no route parameter possible with lists(?).
// Try the get space.
if( req && req.query && typeof(req.query[param]) !== 'undefined' ){
//console.log('as query');
// Input as list, remove dupes.
var paccs = req.query[param];
if( paccs && ! us.is... | [
"function",
"_extract",
"(",
"req",
",",
"param",
")",
"{",
"var",
"ret",
"=",
"[",
"]",
";",
"// Note: no route parameter possible with lists(?).",
"// Try the get space.",
"if",
"(",
"req",
"&&",
"req",
".",
"query",
"&&",
"typeof",
"(",
"req",
".",
"query",... | Extract list arguments. | [
"Extract",
"list",
"arguments",
"."
] | c12209eff40abf15ad612525633ce7c2a625dfa9 | https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/bin/amigo.js#L311-L348 | train |
geneontology/amigo | bin/amigo.js | function(cache){
// Frame to hang our results on.
var results = {
"good": [],
"bad": [],
"ugly": []
};
// Break out the two parts of the species cache.
var doc_lookup = cache['documents'];
var str_refs = cache['references'];
// Comb through the cache, carefully, and get the r... | javascript | function(cache){
// Frame to hang our results on.
var results = {
"good": [],
"bad": [],
"ugly": []
};
// Break out the two parts of the species cache.
var doc_lookup = cache['documents'];
var str_refs = cache['references'];
// Comb through the cache, carefully, and get the r... | [
"function",
"(",
"cache",
")",
"{",
"// Frame to hang our results on.",
"var",
"results",
"=",
"{",
"\"good\"",
":",
"[",
"]",
",",
"\"bad\"",
":",
"[",
"]",
",",
"\"ugly\"",
":",
"[",
"]",
"}",
";",
"// Break out the two parts of the species cache.",
"var",
"... | First, let us discuss what will happen when we have a populated cache to work with, one way or another. The cache is | [
"First",
"let",
"us",
"discuss",
"what",
"will",
"happen",
"when",
"we",
"have",
"a",
"populated",
"cache",
"to",
"work",
"with",
"one",
"way",
"or",
"another",
".",
"The",
"cache",
"is"
] | c12209eff40abf15ad612525633ce7c2a625dfa9 | https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/bin/amigo.js#L1116-L1199 | train | |
gmac/sass-thematic | lib/thematic.js | function(open, close) {
this.fieldOpen = (typeof open === 'string' && open.length) ? open : '____';
this.fieldClose = (typeof close === 'string' && close.length) ? close : this.fieldOpen;
var fieldPattern = this.fieldOpen +'(.+?)'+ this.fieldClose;
this.fieldRegex = new RegExp(fieldPattern);
th... | javascript | function(open, close) {
this.fieldOpen = (typeof open === 'string' && open.length) ? open : '____';
this.fieldClose = (typeof close === 'string' && close.length) ? close : this.fieldOpen;
var fieldPattern = this.fieldOpen +'(.+?)'+ this.fieldClose;
this.fieldRegex = new RegExp(fieldPattern);
th... | [
"function",
"(",
"open",
",",
"close",
")",
"{",
"this",
".",
"fieldOpen",
"=",
"(",
"typeof",
"open",
"===",
"'string'",
"&&",
"open",
".",
"length",
")",
"?",
"open",
":",
"'____'",
";",
"this",
".",
"fieldClose",
"=",
"(",
"typeof",
"close",
"==="... | Configures the patterns used as template field literals.
@param {String} open token denoting start of field identifier.
@param {String} close token denoting end of field identifier. | [
"Configures",
"the",
"patterns",
"used",
"as",
"template",
"field",
"literals",
"."
] | a887c15b98ec2c45452340a9bc26c5321add034a | https://github.com/gmac/sass-thematic/blob/a887c15b98ec2c45452340a9bc26c5321add034a/lib/thematic.js#L131-L138 | train | |
gmac/sass-thematic | lib/thematic.js | function(varsData) {
if (isJSON(varsData)) {
// JSON variables
varsData = JSON.parse(varsData);
for (var key in varsData) {
if (varsData.hasOwnProperty(key)) {
this.vars[normalizeVarName(key)] = varsData[key];
}
}
}
else {
// Sass variables
var ... | javascript | function(varsData) {
if (isJSON(varsData)) {
// JSON variables
varsData = JSON.parse(varsData);
for (var key in varsData) {
if (varsData.hasOwnProperty(key)) {
this.vars[normalizeVarName(key)] = varsData[key];
}
}
}
else {
// Sass variables
var ... | [
"function",
"(",
"varsData",
")",
"{",
"if",
"(",
"isJSON",
"(",
"varsData",
")",
")",
"{",
"// JSON variables",
"varsData",
"=",
"JSON",
".",
"parse",
"(",
"varsData",
")",
";",
"for",
"(",
"var",
"key",
"in",
"varsData",
")",
"{",
"if",
"(",
"varsD... | Parses raw Sass variable definitions
into the thematic mapping of vars names to values. | [
"Parses",
"raw",
"Sass",
"variable",
"definitions",
"into",
"the",
"thematic",
"mapping",
"of",
"vars",
"names",
"to",
"values",
"."
] | a887c15b98ec2c45452340a9bc26c5321add034a | https://github.com/gmac/sass-thematic/blob/a887c15b98ec2c45452340a9bc26c5321add034a/lib/thematic.js#L144-L165 | train |
Subsets and Splits
SQL Console for semeru/code-text-javascript
Retrieves 20,000 non-null code samples labeled as JavaScript, providing a basic overview of the dataset.