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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
Mogztter/opal-node-runtime | src/opal.js | const_lookup_nesting | function const_lookup_nesting(nesting, name) {
var i, ii, result, constant;
if (nesting.length === 0) return;
// If the nesting is not empty the constant is looked up in its elements
// and in order. The ancestors of those elements are ignored.
for (i = 0, ii = nesting.length; i < ii; i++) {
... | javascript | function const_lookup_nesting(nesting, name) {
var i, ii, result, constant;
if (nesting.length === 0) return;
// If the nesting is not empty the constant is looked up in its elements
// and in order. The ancestors of those elements are ignored.
for (i = 0, ii = nesting.length; i < ii; i++) {
... | [
"function",
"const_lookup_nesting",
"(",
"nesting",
",",
"name",
")",
"{",
"var",
"i",
",",
"ii",
",",
"result",
",",
"constant",
";",
"if",
"(",
"nesting",
".",
"length",
"===",
"0",
")",
"return",
";",
"// If the nesting is not empty the constant is looked up ... | Walk up the nesting array looking for the constant | [
"Walk",
"up",
"the",
"nesting",
"array",
"looking",
"for",
"the",
"constant"
] | cde4c78099358ef47cc30b41f699ee56ff40d5e3 | https://github.com/Mogztter/opal-node-runtime/blob/cde4c78099358ef47cc30b41f699ee56ff40d5e3/src/opal.js#L185-L196 | train |
Mogztter/opal-node-runtime | src/opal.js | const_lookup_ancestors | function const_lookup_ancestors(cref, name) {
var i, ii, result, ancestors;
if (cref == null) return;
ancestors = Opal.ancestors(cref);
for (i = 0, ii = ancestors.length; i < ii; i++) {
if (ancestors[i].$$const && $hasOwn.call(ancestors[i].$$const, name)) {
return ancestors[i].$$const[n... | javascript | function const_lookup_ancestors(cref, name) {
var i, ii, result, ancestors;
if (cref == null) return;
ancestors = Opal.ancestors(cref);
for (i = 0, ii = ancestors.length; i < ii; i++) {
if (ancestors[i].$$const && $hasOwn.call(ancestors[i].$$const, name)) {
return ancestors[i].$$const[n... | [
"function",
"const_lookup_ancestors",
"(",
"cref",
",",
"name",
")",
"{",
"var",
"i",
",",
"ii",
",",
"result",
",",
"ancestors",
";",
"if",
"(",
"cref",
"==",
"null",
")",
"return",
";",
"ancestors",
"=",
"Opal",
".",
"ancestors",
"(",
"cref",
")",
... | Walk up the ancestors chain looking for the constant | [
"Walk",
"up",
"the",
"ancestors",
"chain",
"looking",
"for",
"the",
"constant"
] | cde4c78099358ef47cc30b41f699ee56ff40d5e3 | https://github.com/Mogztter/opal-node-runtime/blob/cde4c78099358ef47cc30b41f699ee56ff40d5e3/src/opal.js#L199-L211 | train |
Mogztter/opal-node-runtime | src/opal.js | create_dummy_iclass | function create_dummy_iclass(module) {
var iclass = {},
proto = module.$$prototype;
if (proto.hasOwnProperty('$$dummy')) {
proto = proto.$$define_methods_on;
}
var props = Object.getOwnPropertyNames(proto),
length = props.length, i;
for (i = 0; i < length; i++) {
var p... | javascript | function create_dummy_iclass(module) {
var iclass = {},
proto = module.$$prototype;
if (proto.hasOwnProperty('$$dummy')) {
proto = proto.$$define_methods_on;
}
var props = Object.getOwnPropertyNames(proto),
length = props.length, i;
for (i = 0; i < length; i++) {
var p... | [
"function",
"create_dummy_iclass",
"(",
"module",
")",
"{",
"var",
"iclass",
"=",
"{",
"}",
",",
"proto",
"=",
"module",
".",
"$$prototype",
";",
"if",
"(",
"proto",
".",
"hasOwnProperty",
"(",
"'$$dummy'",
")",
")",
"{",
"proto",
"=",
"proto",
".",
"$... | Dummy iclass doesn't receive updates when the module gets a new method. | [
"Dummy",
"iclass",
"doesn",
"t",
"receive",
"updates",
"when",
"the",
"module",
"gets",
"a",
"new",
"method",
"."
] | cde4c78099358ef47cc30b41f699ee56ff40d5e3 | https://github.com/Mogztter/opal-node-runtime/blob/cde4c78099358ef47cc30b41f699ee56ff40d5e3/src/opal.js#L1092-L1112 | train |
Mogztter/opal-node-runtime | src/opal.js | descending_factorial | function descending_factorial(from, how_many) {
var count = how_many >= 0 ? 1 : 0;
while (how_many) {
count *= from;
from--;
how_many--;
}
return count;
} | javascript | function descending_factorial(from, how_many) {
var count = how_many >= 0 ? 1 : 0;
while (how_many) {
count *= from;
from--;
how_many--;
}
return count;
} | [
"function",
"descending_factorial",
"(",
"from",
",",
"how_many",
")",
"{",
"var",
"count",
"=",
"how_many",
">=",
"0",
"?",
"1",
":",
"0",
";",
"while",
"(",
"how_many",
")",
"{",
"count",
"*=",
"from",
";",
"from",
"--",
";",
"how_many",
"--",
";",... | Returns the product of from, from-1, ..., from - how_many + 1. | [
"Returns",
"the",
"product",
"of",
"from",
"from",
"-",
"1",
"...",
"from",
"-",
"how_many",
"+",
"1",
"."
] | cde4c78099358ef47cc30b41f699ee56ff40d5e3 | https://github.com/Mogztter/opal-node-runtime/blob/cde4c78099358ef47cc30b41f699ee56ff40d5e3/src/opal.js#L13635-L13643 | train |
Mogztter/opal-node-runtime | src/opal.js | cutNumber | function cutNumber() {
if (isFloat()) {
var numerator = parseFloat(cutFloat());
if (str[0] === '/') {
// rational real part
str = str.slice(1);
if (isFloat()) {
var denominator = parseFloat(cutFloat());
return self.$Rational(n... | javascript | function cutNumber() {
if (isFloat()) {
var numerator = parseFloat(cutFloat());
if (str[0] === '/') {
// rational real part
str = str.slice(1);
if (isFloat()) {
var denominator = parseFloat(cutFloat());
return self.$Rational(n... | [
"function",
"cutNumber",
"(",
")",
"{",
"if",
"(",
"isFloat",
"(",
")",
")",
"{",
"var",
"numerator",
"=",
"parseFloat",
"(",
"cutFloat",
"(",
")",
")",
";",
"if",
"(",
"str",
"[",
"0",
"]",
"===",
"'/'",
")",
"{",
"// rational real part",
"str",
"... | handles both floats and rationals | [
"handles",
"both",
"floats",
"and",
"rationals"
] | cde4c78099358ef47cc30b41f699ee56ff40d5e3 | https://github.com/Mogztter/opal-node-runtime/blob/cde4c78099358ef47cc30b41f699ee56ff40d5e3/src/opal.js#L19882-L19905 | train |
Mogztter/opal-node-runtime | src/opal.js | genrand_real | function genrand_real(mt) {
/* mt must be initialized */
var a = genrand_int32(mt), b = genrand_int32(mt);
return int_pair_to_real_exclusive(a, b);
} | javascript | function genrand_real(mt) {
/* mt must be initialized */
var a = genrand_int32(mt), b = genrand_int32(mt);
return int_pair_to_real_exclusive(a, b);
} | [
"function",
"genrand_real",
"(",
"mt",
")",
"{",
"/* mt must be initialized */",
"var",
"a",
"=",
"genrand_int32",
"(",
"mt",
")",
",",
"b",
"=",
"genrand_int32",
"(",
"mt",
")",
";",
"return",
"int_pair_to_real_exclusive",
"(",
"a",
",",
"b",
")",
";",
"}... | generates a random number on [0,1) with 53-bit resolution | [
"generates",
"a",
"random",
"number",
"on",
"[",
"0",
"1",
")",
"with",
"53",
"-",
"bit",
"resolution"
] | cde4c78099358ef47cc30b41f699ee56ff40d5e3 | https://github.com/Mogztter/opal-node-runtime/blob/cde4c78099358ef47cc30b41f699ee56ff40d5e3/src/opal.js#L22784-L22788 | train |
thlorenz/browserify-swap | index.js | browserifySwap | function browserifySwap(file) {
var env = process.env.BROWSERIFYSWAP_ENV
, data = ''
, swapFile;
// no stubbing desired or we already determined that we can't find a swap config => just pipe it through
if (!env || cachedConfig === -1) return through();
if (cachedConfig) {
swapFile = swap(cachedCon... | javascript | function browserifySwap(file) {
var env = process.env.BROWSERIFYSWAP_ENV
, data = ''
, swapFile;
// no stubbing desired or we already determined that we can't find a swap config => just pipe it through
if (!env || cachedConfig === -1) return through();
if (cachedConfig) {
swapFile = swap(cachedCon... | [
"function",
"browserifySwap",
"(",
"file",
")",
"{",
"var",
"env",
"=",
"process",
".",
"env",
".",
"BROWSERIFYSWAP_ENV",
",",
"data",
"=",
"''",
",",
"swapFile",
";",
"// no stubbing desired or we already determined that we can't find a swap config => just pipe it through"... | Looks up browserify_swap configuratios specified for the given file in the environment specified via `BROWSERIFYSWAP_ENV`.
If found the file content is replaced with a require statement to the file to swap in for the original.
Otherwise the file's content is just piped through.
@name browserifySwap
@function
@param {... | [
"Looks",
"up",
"browserify_swap",
"configuratios",
"specified",
"for",
"the",
"given",
"file",
"in",
"the",
"environment",
"specified",
"via",
"BROWSERIFYSWAP_ENV",
"."
] | 2a697cdaec59d2cb83244863616d92dc8eb14137 | https://github.com/thlorenz/browserify-swap/blob/2a697cdaec59d2cb83244863616d92dc8eb14137/index.js#L59-L108 | train |
reelyactive/barterer | lib/responsehandler.js | prepareResponse | function prepareResponse(status, rootUrl, queryPath, data) {
var response = {};
prepareMeta(response, status);
if(rootUrl && queryPath) {
prepareLinks(response, rootUrl, queryPath);
}
if(data) {
prepareData(response, rootUrl, data);
}
return response;
} | javascript | function prepareResponse(status, rootUrl, queryPath, data) {
var response = {};
prepareMeta(response, status);
if(rootUrl && queryPath) {
prepareLinks(response, rootUrl, queryPath);
}
if(data) {
prepareData(response, rootUrl, data);
}
return response;
} | [
"function",
"prepareResponse",
"(",
"status",
",",
"rootUrl",
",",
"queryPath",
",",
"data",
")",
"{",
"var",
"response",
"=",
"{",
"}",
";",
"prepareMeta",
"(",
"response",
",",
"status",
")",
";",
"if",
"(",
"rootUrl",
"&&",
"queryPath",
")",
"{",
"p... | Prepares the JSON for an API query response which is successful
@param {Number} status Integer status code
@param {String} rootUrl The root URL of the original query.
@param {String} queryPath The query path of the original query.
@param {Object} data The data to include in the response | [
"Prepares",
"the",
"JSON",
"for",
"an",
"API",
"query",
"response",
"which",
"is",
"successful"
] | ab4caa541b13c78cca3f4df9dcfc8f17c1c14c2c | https://github.com/reelyactive/barterer/blob/ab4caa541b13c78cca3f4df9dcfc8f17c1c14c2c/lib/responsehandler.js#L26-L36 | train |
reelyactive/barterer | lib/responsehandler.js | prepareMeta | function prepareMeta(response, status) {
switch(status) {
case CODE_OK:
response._meta = { "message": MESSAGE_OK,
"statusCode": CODE_OK };
break;
case CODE_NOTFOUND:
response._meta = { "message": MESSAGE_NOTFOUND,
"statusCode": CODE_NOTFOUND ... | javascript | function prepareMeta(response, status) {
switch(status) {
case CODE_OK:
response._meta = { "message": MESSAGE_OK,
"statusCode": CODE_OK };
break;
case CODE_NOTFOUND:
response._meta = { "message": MESSAGE_NOTFOUND,
"statusCode": CODE_NOTFOUND ... | [
"function",
"prepareMeta",
"(",
"response",
",",
"status",
")",
"{",
"switch",
"(",
"status",
")",
"{",
"case",
"CODE_OK",
":",
"response",
".",
"_meta",
"=",
"{",
"\"message\"",
":",
"MESSAGE_OK",
",",
"\"statusCode\"",
":",
"CODE_OK",
"}",
";",
"break",
... | Prepares and adds the _meta to the given API query response
@param {Object} response JSON representation of the response
@param {Number} status Integer status code | [
"Prepares",
"and",
"adds",
"the",
"_meta",
"to",
"the",
"given",
"API",
"query",
"response"
] | ab4caa541b13c78cca3f4df9dcfc8f17c1c14c2c | https://github.com/reelyactive/barterer/blob/ab4caa541b13c78cca3f4df9dcfc8f17c1c14c2c/lib/responsehandler.js#L44-L66 | train |
reelyactive/barterer | lib/responsehandler.js | prepareLinks | function prepareLinks(response, rootUrl, queryPath) {
var selfLink = { "href": rootUrl + queryPath };
response._links = {};
response._links.self = selfLink;
} | javascript | function prepareLinks(response, rootUrl, queryPath) {
var selfLink = { "href": rootUrl + queryPath };
response._links = {};
response._links.self = selfLink;
} | [
"function",
"prepareLinks",
"(",
"response",
",",
"rootUrl",
",",
"queryPath",
")",
"{",
"var",
"selfLink",
"=",
"{",
"\"href\"",
":",
"rootUrl",
"+",
"queryPath",
"}",
";",
"response",
".",
"_links",
"=",
"{",
"}",
";",
"response",
".",
"_links",
".",
... | Prepares and adds the _links to the given API query response
@param {Object} response JSON representation of the response
@param {String} rootUrl The root URL of the original query.
@param {String} queryPath The query path of the original query. | [
"Prepares",
"and",
"adds",
"the",
"_links",
"to",
"the",
"given",
"API",
"query",
"response"
] | ab4caa541b13c78cca3f4df9dcfc8f17c1c14c2c | https://github.com/reelyactive/barterer/blob/ab4caa541b13c78cca3f4df9dcfc8f17c1c14c2c/lib/responsehandler.js#L75-L79 | train |
watson/mode-s-aircraft-store | lib/cpr.js | cprModFunction | function cprModFunction (a, b) {
let res = a % b
if (res < 0) res += b
return res
} | javascript | function cprModFunction (a, b) {
let res = a % b
if (res < 0) res += b
return res
} | [
"function",
"cprModFunction",
"(",
"a",
",",
"b",
")",
"{",
"let",
"res",
"=",
"a",
"%",
"b",
"if",
"(",
"res",
"<",
"0",
")",
"res",
"+=",
"b",
"return",
"res",
"}"
] | Always positive MOD operation, used for CPR decoding | [
"Always",
"positive",
"MOD",
"operation",
"used",
"for",
"CPR",
"decoding"
] | c8ba99927d5cba1c8fbbf2b90f35cf076360299b | https://github.com/watson/mode-s-aircraft-store/blob/c8ba99927d5cba1c8fbbf2b90f35cf076360299b/lib/cpr.js#L59-L63 | train |
watson/mode-s-aircraft-store | lib/cpr.js | cprNLFunction | function cprNLFunction (lat) {
if (lat < 0) lat = -lat // Table is simmetric about the equator
if (lat < 10.47047130) return 59
if (lat < 14.82817437) return 58
if (lat < 18.18626357) return 57
if (lat < 21.02939493) return 56
if (lat < 23.54504487) return 55
if (lat < 25.82924707) return 54
if (lat < 2... | javascript | function cprNLFunction (lat) {
if (lat < 0) lat = -lat // Table is simmetric about the equator
if (lat < 10.47047130) return 59
if (lat < 14.82817437) return 58
if (lat < 18.18626357) return 57
if (lat < 21.02939493) return 56
if (lat < 23.54504487) return 55
if (lat < 25.82924707) return 54
if (lat < 2... | [
"function",
"cprNLFunction",
"(",
"lat",
")",
"{",
"if",
"(",
"lat",
"<",
"0",
")",
"lat",
"=",
"-",
"lat",
"// Table is simmetric about the equator",
"if",
"(",
"lat",
"<",
"10.47047130",
")",
"return",
"59",
"if",
"(",
"lat",
"<",
"14.82817437",
")",
"... | The NL function uses the precomputed table from 1090-WP-9-14 | [
"The",
"NL",
"function",
"uses",
"the",
"precomputed",
"table",
"from",
"1090",
"-",
"WP",
"-",
"9",
"-",
"14"
] | c8ba99927d5cba1c8fbbf2b90f35cf076360299b | https://github.com/watson/mode-s-aircraft-store/blob/c8ba99927d5cba1c8fbbf2b90f35cf076360299b/lib/cpr.js#L76-L137 | train |
micromatch/bash-glob | index.js | glob | function glob(pattern, options, cb) {
if (typeof options === 'function') {
cb = options;
options = {};
}
if (Array.isArray(pattern)) {
return glob.each.apply(glob, arguments);
}
if (typeof cb !== 'function') {
if (typeof cb !== 'undefined') {
throw new TypeError('expected callback to b... | javascript | function glob(pattern, options, cb) {
if (typeof options === 'function') {
cb = options;
options = {};
}
if (Array.isArray(pattern)) {
return glob.each.apply(glob, arguments);
}
if (typeof cb !== 'function') {
if (typeof cb !== 'undefined') {
throw new TypeError('expected callback to b... | [
"function",
"glob",
"(",
"pattern",
",",
"options",
",",
"cb",
")",
"{",
"if",
"(",
"typeof",
"options",
"===",
"'function'",
")",
"{",
"cb",
"=",
"options",
";",
"options",
"=",
"{",
"}",
";",
"}",
"if",
"(",
"Array",
".",
"isArray",
"(",
"pattern... | Asynchronously returns an array of files that match the given pattern
or patterns.
```js
var glob = require('bash-glob');
glob('*.js', function(err, files) {
if (err) return console.log(err);
console.log(files);
});
```
@param {String|Array} `patterns` One or more glob patterns to use for matching.
@param {Object} `op... | [
"Asynchronously",
"returns",
"an",
"array",
"of",
"files",
"that",
"match",
"the",
"given",
"pattern",
"or",
"patterns",
"."
] | eddb7de28a22d90c9a26389f7c884af5ddaadead | https://github.com/micromatch/bash-glob/blob/eddb7de28a22d90c9a26389f7c884af5ddaadead/index.js#L30-L77 | train |
micromatch/bash-glob | index.js | bash | function bash(pattern, options, cb) {
if (!isGlob(pattern)) {
return nonGlob(pattern, options, cb);
}
if (typeof options === 'function') {
cb = options;
options = undefined;
}
var opts = extend({cwd: process.cwd()}, options);
fs.stat(opts.cwd, function(err, stat) {
if (err) {
cb(han... | javascript | function bash(pattern, options, cb) {
if (!isGlob(pattern)) {
return nonGlob(pattern, options, cb);
}
if (typeof options === 'function') {
cb = options;
options = undefined;
}
var opts = extend({cwd: process.cwd()}, options);
fs.stat(opts.cwd, function(err, stat) {
if (err) {
cb(han... | [
"function",
"bash",
"(",
"pattern",
",",
"options",
",",
"cb",
")",
"{",
"if",
"(",
"!",
"isGlob",
"(",
"pattern",
")",
")",
"{",
"return",
"nonGlob",
"(",
"pattern",
",",
"options",
",",
"cb",
")",
";",
"}",
"if",
"(",
"typeof",
"options",
"===",
... | Base bash function | [
"Base",
"bash",
"function"
] | eddb7de28a22d90c9a26389f7c884af5ddaadead | https://github.com/micromatch/bash-glob/blob/eddb7de28a22d90c9a26389f7c884af5ddaadead/index.js#L244-L283 | train |
micromatch/bash-glob | index.js | normalize | function normalize(val) {
if (Array.isArray(val)) {
val = val.join(' ');
}
return val.split(' ').join('\\ ');
} | javascript | function normalize(val) {
if (Array.isArray(val)) {
val = val.join(' ');
}
return val.split(' ').join('\\ ');
} | [
"function",
"normalize",
"(",
"val",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"val",
")",
")",
"{",
"val",
"=",
"val",
".",
"join",
"(",
"' '",
")",
";",
"}",
"return",
"val",
".",
"split",
"(",
"' '",
")",
".",
"join",
"(",
"'\\\\ '"... | Escape spaces in glob patterns | [
"Escape",
"spaces",
"in",
"glob",
"patterns"
] | eddb7de28a22d90c9a26389f7c884af5ddaadead | https://github.com/micromatch/bash-glob/blob/eddb7de28a22d90c9a26389f7c884af5ddaadead/index.js#L289-L294 | train |
micromatch/bash-glob | index.js | cmd | function cmd(patterns, options) {
var str = normalize(patterns);
var keys = Object.keys(options);
var args = [];
var valid = [
'dotglob',
'extglob',
'failglob',
'globstar',
'nocaseglob',
'nullglob'
];
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
if (valid.index... | javascript | function cmd(patterns, options) {
var str = normalize(patterns);
var keys = Object.keys(options);
var args = [];
var valid = [
'dotglob',
'extglob',
'failglob',
'globstar',
'nocaseglob',
'nullglob'
];
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
if (valid.index... | [
"function",
"cmd",
"(",
"patterns",
",",
"options",
")",
"{",
"var",
"str",
"=",
"normalize",
"(",
"patterns",
")",
";",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"options",
")",
";",
"var",
"args",
"=",
"[",
"]",
";",
"var",
"valid",
"=",
... | Create the command to use | [
"Create",
"the",
"command",
"to",
"use"
] | eddb7de28a22d90c9a26389f7c884af5ddaadead | https://github.com/micromatch/bash-glob/blob/eddb7de28a22d90c9a26389f7c884af5ddaadead/index.js#L300-L322 | train |
micromatch/bash-glob | index.js | handleError | function handleError(err, pattern, options) {
var message = err;
if (typeof err === 'string') {
err = new Error(message.trim());
err.pattern = pattern;
err.options = options;
if (/invalid shell option/.test(err)) {
err.code = 'INVALID_SHELL_OPTION';
}
if (/no match:/.test(err)) {
... | javascript | function handleError(err, pattern, options) {
var message = err;
if (typeof err === 'string') {
err = new Error(message.trim());
err.pattern = pattern;
err.options = options;
if (/invalid shell option/.test(err)) {
err.code = 'INVALID_SHELL_OPTION';
}
if (/no match:/.test(err)) {
... | [
"function",
"handleError",
"(",
"err",
",",
"pattern",
",",
"options",
")",
"{",
"var",
"message",
"=",
"err",
";",
"if",
"(",
"typeof",
"err",
"===",
"'string'",
")",
"{",
"err",
"=",
"new",
"Error",
"(",
"message",
".",
"trim",
"(",
")",
")",
";"... | Handle errors to ensure the correct value is returned based on options | [
"Handle",
"errors",
"to",
"ensure",
"the",
"correct",
"value",
"is",
"returned",
"based",
"on",
"options"
] | eddb7de28a22d90c9a26389f7c884af5ddaadead | https://github.com/micromatch/bash-glob/blob/eddb7de28a22d90c9a26389f7c884af5ddaadead/index.js#L348-L373 | train |
micromatch/bash-glob | index.js | getFiles | function getFiles(res, pattern, options) {
var files = res.split(/\r?\n/).filter(Boolean);
if (files.length === 1 && files[0] === pattern) {
files = [];
} else if (options.realpath === true || options.follow === true) {
files = toAbsolute(files, options);
}
if (files.length === 0) {
if (options.nu... | javascript | function getFiles(res, pattern, options) {
var files = res.split(/\r?\n/).filter(Boolean);
if (files.length === 1 && files[0] === pattern) {
files = [];
} else if (options.realpath === true || options.follow === true) {
files = toAbsolute(files, options);
}
if (files.length === 0) {
if (options.nu... | [
"function",
"getFiles",
"(",
"res",
",",
"pattern",
",",
"options",
")",
"{",
"var",
"files",
"=",
"res",
".",
"split",
"(",
"/",
"\\r?\\n",
"/",
")",
".",
"filter",
"(",
"Boolean",
")",
";",
"if",
"(",
"files",
".",
"length",
"===",
"1",
"&&",
"... | Handle files to ensure the correct value is returned based on options | [
"Handle",
"files",
"to",
"ensure",
"the",
"correct",
"value",
"is",
"returned",
"based",
"on",
"options"
] | eddb7de28a22d90c9a26389f7c884af5ddaadead | https://github.com/micromatch/bash-glob/blob/eddb7de28a22d90c9a26389f7c884af5ddaadead/index.js#L379-L398 | train |
micromatch/bash-glob | index.js | toAbsolute | function toAbsolute(files, options) {
var len = files.length;
var idx = -1;
var arr = [];
while (++idx < len) {
var file = files[idx];
if (!file.trim()) continue;
if (file && options.cwd) {
file = path.resolve(options.cwd, file);
}
if (file && options.realpath === true) {
file =... | javascript | function toAbsolute(files, options) {
var len = files.length;
var idx = -1;
var arr = [];
while (++idx < len) {
var file = files[idx];
if (!file.trim()) continue;
if (file && options.cwd) {
file = path.resolve(options.cwd, file);
}
if (file && options.realpath === true) {
file =... | [
"function",
"toAbsolute",
"(",
"files",
",",
"options",
")",
"{",
"var",
"len",
"=",
"files",
".",
"length",
";",
"var",
"idx",
"=",
"-",
"1",
";",
"var",
"arr",
"=",
"[",
"]",
";",
"while",
"(",
"++",
"idx",
"<",
"len",
")",
"{",
"var",
"file"... | Make symlinks absolute when `options.follow` is defined. | [
"Make",
"symlinks",
"absolute",
"when",
"options",
".",
"follow",
"is",
"defined",
"."
] | eddb7de28a22d90c9a26389f7c884af5ddaadead | https://github.com/micromatch/bash-glob/blob/eddb7de28a22d90c9a26389f7c884af5ddaadead/index.js#L404-L423 | train |
micromatch/bash-glob | index.js | nonGlob | function nonGlob(pattern, options, cb) {
if (options.nullglob) {
cb(null, [pattern]);
return;
}
fs.stat(pattern, callback(null, pattern, options, cb));
return;
} | javascript | function nonGlob(pattern, options, cb) {
if (options.nullglob) {
cb(null, [pattern]);
return;
}
fs.stat(pattern, callback(null, pattern, options, cb));
return;
} | [
"function",
"nonGlob",
"(",
"pattern",
",",
"options",
",",
"cb",
")",
"{",
"if",
"(",
"options",
".",
"nullglob",
")",
"{",
"cb",
"(",
"null",
",",
"[",
"pattern",
"]",
")",
";",
"return",
";",
"}",
"fs",
".",
"stat",
"(",
"pattern",
",",
"callb... | Handle non-globs | [
"Handle",
"non",
"-",
"globs"
] | eddb7de28a22d90c9a26389f7c884af5ddaadead | https://github.com/micromatch/bash-glob/blob/eddb7de28a22d90c9a26389f7c884af5ddaadead/index.js#L461-L468 | train |
micromatch/bash-glob | index.js | emitMatches | function emitMatches(str, pattern, options) {
glob.emit('match', getFiles(str, pattern, options), options.cwd);
} | javascript | function emitMatches(str, pattern, options) {
glob.emit('match', getFiles(str, pattern, options), options.cwd);
} | [
"function",
"emitMatches",
"(",
"str",
",",
"pattern",
",",
"options",
")",
"{",
"glob",
".",
"emit",
"(",
"'match'",
",",
"getFiles",
"(",
"str",
",",
"pattern",
",",
"options",
")",
",",
"options",
".",
"cwd",
")",
";",
"}"
] | Emit matches for a pattern | [
"Emit",
"matches",
"for",
"a",
"pattern"
] | eddb7de28a22d90c9a26389f7c884af5ddaadead | https://github.com/micromatch/bash-glob/blob/eddb7de28a22d90c9a26389f7c884af5ddaadead/index.js#L474-L476 | train |
reelyactive/barterer | lib/barterer.js | Barterer | function Barterer(options) {
var self = this;
options = options || {};
self.routes = {
"/whereis": require('./routes/whereis'),
"/whatat": require('./routes/whatat'),
"/whatnear": require('./routes/whatnear'),
"/": express.static(path.resolve(__dirname + '/../web'))
};
console.log('reelyActi... | javascript | function Barterer(options) {
var self = this;
options = options || {};
self.routes = {
"/whereis": require('./routes/whereis'),
"/whatat": require('./routes/whatat'),
"/whatnear": require('./routes/whatnear'),
"/": express.static(path.resolve(__dirname + '/../web'))
};
console.log('reelyActi... | [
"function",
"Barterer",
"(",
"options",
")",
"{",
"var",
"self",
"=",
"this",
";",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"self",
".",
"routes",
"=",
"{",
"\"/whereis\"",
":",
"require",
"(",
"'./routes/whereis'",
")",
",",
"\"/whatat\"",
":",
... | Barterer Class
API for real-time location and hyperlocal context.
@param {Object} options The options as a JSON object.
@constructor | [
"Barterer",
"Class",
"API",
"for",
"real",
"-",
"time",
"location",
"and",
"hyperlocal",
"context",
"."
] | ab4caa541b13c78cca3f4df9dcfc8f17c1c14c2c | https://github.com/reelyactive/barterer/blob/ab4caa541b13c78cca3f4df9dcfc8f17c1c14c2c/lib/barterer.js#L19-L31 | train |
reelyactive/barterer | lib/barterer.js | isValidOptions | function isValidOptions(options) {
if(!options) {
return false;
}
if(options.hasOwnProperty('ids') && Array.isArray(options.ids)) {
for(var cId = 0; cId < options.ids.length; cId++) {
if(!reelib.identifier.isValid(options.ids[cId])) {
return false;
}
}
return true;
}
else... | javascript | function isValidOptions(options) {
if(!options) {
return false;
}
if(options.hasOwnProperty('ids') && Array.isArray(options.ids)) {
for(var cId = 0; cId < options.ids.length; cId++) {
if(!reelib.identifier.isValid(options.ids[cId])) {
return false;
}
}
return true;
}
else... | [
"function",
"isValidOptions",
"(",
"options",
")",
"{",
"if",
"(",
"!",
"options",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"options",
".",
"hasOwnProperty",
"(",
"'ids'",
")",
"&&",
"Array",
".",
"isArray",
"(",
"options",
".",
"ids",
")",
... | Determine if the given options are valid.
@param {Object} options The given options.
@return {boolean} True if the options are valid, false otherwise. | [
"Determine",
"if",
"the",
"given",
"options",
"are",
"valid",
"."
] | ab4caa541b13c78cca3f4df9dcfc8f17c1c14c2c | https://github.com/reelyactive/barterer/blob/ab4caa541b13c78cca3f4df9dcfc8f17c1c14c2c/lib/barterer.js#L113-L130 | train |
jossmac/react-deprecate | lib/index.js | getComponentName | function getComponentName(target) {
if (target.displayName && typeof target.displayName === 'string') {
return target.displayName;
}
return target.name || 'Component';
} | javascript | function getComponentName(target) {
if (target.displayName && typeof target.displayName === 'string') {
return target.displayName;
}
return target.name || 'Component';
} | [
"function",
"getComponentName",
"(",
"target",
")",
"{",
"if",
"(",
"target",
".",
"displayName",
"&&",
"typeof",
"target",
".",
"displayName",
"===",
"'string'",
")",
"{",
"return",
"target",
".",
"displayName",
";",
"}",
"return",
"target",
".",
"name",
... | attempt to get the wrapped component's name | [
"attempt",
"to",
"get",
"the",
"wrapped",
"component",
"s",
"name"
] | 4a96b1dff81ffd5eadba480d71b5b99fc91375b1 | https://github.com/jossmac/react-deprecate/blob/4a96b1dff81ffd5eadba480d71b5b99fc91375b1/lib/index.js#L28-L34 | train |
jossmac/react-deprecate | lib/index.js | defaultWarningMessage | function defaultWarningMessage(_ref) {
var componentName = _ref.componentName,
prop = _ref.prop,
renamedProps = _ref.renamedProps;
return componentName + ' Warning: Prop "' + prop + '" is deprecated, use "' + renamedProps[prop] + '" instead.';
} | javascript | function defaultWarningMessage(_ref) {
var componentName = _ref.componentName,
prop = _ref.prop,
renamedProps = _ref.renamedProps;
return componentName + ' Warning: Prop "' + prop + '" is deprecated, use "' + renamedProps[prop] + '" instead.';
} | [
"function",
"defaultWarningMessage",
"(",
"_ref",
")",
"{",
"var",
"componentName",
"=",
"_ref",
".",
"componentName",
",",
"prop",
"=",
"_ref",
".",
"prop",
",",
"renamedProps",
"=",
"_ref",
".",
"renamedProps",
";",
"return",
"componentName",
"+",
"' Warning... | deprecation warning for consumer | [
"deprecation",
"warning",
"for",
"consumer"
] | 4a96b1dff81ffd5eadba480d71b5b99fc91375b1 | https://github.com/jossmac/react-deprecate/blob/4a96b1dff81ffd5eadba480d71b5b99fc91375b1/lib/index.js#L37-L43 | train |
jossmac/react-deprecate | lib/index.js | componentDidMount | function componentDidMount() {
var _this2 = this;
Object.keys(renamedProps).forEach(function (prop) {
if (prop in _this2.props) {
console.warn(warningMessage({
componentName: getComponentName(WrappedComponent),
prop: prop,
renamedProps: re... | javascript | function componentDidMount() {
var _this2 = this;
Object.keys(renamedProps).forEach(function (prop) {
if (prop in _this2.props) {
console.warn(warningMessage({
componentName: getComponentName(WrappedComponent),
prop: prop,
renamedProps: re... | [
"function",
"componentDidMount",
"(",
")",
"{",
"var",
"_this2",
"=",
"this",
";",
"Object",
".",
"keys",
"(",
"renamedProps",
")",
".",
"forEach",
"(",
"function",
"(",
"prop",
")",
"{",
"if",
"(",
"prop",
"in",
"_this2",
".",
"props",
")",
"{",
"co... | warn on deprecated props | [
"warn",
"on",
"deprecated",
"props"
] | 4a96b1dff81ffd5eadba480d71b5b99fc91375b1 | https://github.com/jossmac/react-deprecate/blob/4a96b1dff81ffd5eadba480d71b5b99fc91375b1/lib/index.js#L67-L79 | train |
sematext/spm-agent | lib/harvester.js | harvester | function harvester (metricConsumer, agentList) {
var agentsToLoad = []
this.metricConsumer = metricConsumer
this.httpAgent = null
if (agentList) {
agentsToLoad = agentList
}
this.agents = []
for (var x in agentsToLoad) {
try {
var TmpAgentClass = require(agentsToLoad[x])
var tmpAgentIn... | javascript | function harvester (metricConsumer, agentList) {
var agentsToLoad = []
this.metricConsumer = metricConsumer
this.httpAgent = null
if (agentList) {
agentsToLoad = agentList
}
this.agents = []
for (var x in agentsToLoad) {
try {
var TmpAgentClass = require(agentsToLoad[x])
var tmpAgentIn... | [
"function",
"harvester",
"(",
"metricConsumer",
",",
"agentList",
")",
"{",
"var",
"agentsToLoad",
"=",
"[",
"]",
"this",
".",
"metricConsumer",
"=",
"metricConsumer",
"this",
".",
"httpAgent",
"=",
"null",
"if",
"(",
"agentList",
")",
"{",
"agentsToLoad",
"... | This module harvest metrics from agents, registers to all agents and fires own metric events
@metricConsumer - an object that listens on "metric" event. The metric event passes a metric object with (name, value, type, ts) properties
@agentList a list of agents to be created e.g. ['./agents/osAgent.js', './agents/eventL... | [
"This",
"module",
"harvest",
"metrics",
"from",
"agents",
"registers",
"to",
"all",
"agents",
"and",
"fires",
"own",
"metric",
"events"
] | 7b98be0cfc41fb7bf7f7c605e6602148570269a3 | https://github.com/sematext/spm-agent/blob/7b98be0cfc41fb7bf7f7c605e6602148570269a3/lib/harvester.js#L19-L41 | train |
warmsea/node-rfr | lib/rfr.js | coerceRoot | function coerceRoot(root) {
var coerced = root.substring().trim();
var len = coerced.length;
if (len > 0 && coerced[len - 1] !== '/') {
coerced = coerced + '/';
}
return coerced;
} | javascript | function coerceRoot(root) {
var coerced = root.substring().trim();
var len = coerced.length;
if (len > 0 && coerced[len - 1] !== '/') {
coerced = coerced + '/';
}
return coerced;
} | [
"function",
"coerceRoot",
"(",
"root",
")",
"{",
"var",
"coerced",
"=",
"root",
".",
"substring",
"(",
")",
".",
"trim",
"(",
")",
";",
"var",
"len",
"=",
"coerced",
".",
"length",
";",
"if",
"(",
"len",
">",
"0",
"&&",
"coerced",
"[",
"len",
"-"... | Trim a root and add tailing slash if not exists.
@param {String} root A root.
@returns {String} The coerced root.
@private | [
"Trim",
"a",
"root",
"and",
"add",
"tailing",
"slash",
"if",
"not",
"exists",
"."
] | 4c6c62dd5c338824e7eeccb44321942a7c3a8662 | https://github.com/warmsea/node-rfr/blob/4c6c62dd5c338824e7eeccb44321942a7c3a8662/lib/rfr.js#L27-L34 | train |
warmsea/node-rfr | lib/rfr.js | function(callable, root, isMaster) {
rfr = callable.bind(callable);
/**
* A read-only property tells whether this rfr instance is a master one.
* Call `require('rfr')` to get a master rfr instance.
* User created rfr instances, such as `require('rfr')({ root: '...' })` are
* not master ones.
* @type... | javascript | function(callable, root, isMaster) {
rfr = callable.bind(callable);
/**
* A read-only property tells whether this rfr instance is a master one.
* Call `require('rfr')` to get a master rfr instance.
* User created rfr instances, such as `require('rfr')({ root: '...' })` are
* not master ones.
* @type... | [
"function",
"(",
"callable",
",",
"root",
",",
"isMaster",
")",
"{",
"rfr",
"=",
"callable",
".",
"bind",
"(",
"callable",
")",
";",
"/**\n * A read-only property tells whether this rfr instance is a master one.\n * Call `require('rfr')` to get a master rfr instance.\n * Us... | Create a new version of rfr with a function.
@param {Function} callable The rfr require function.
@param {String} root The root for rfr require.
@param {Boolean} isMaster Whether this is a master rfr.
@private | [
"Create",
"a",
"new",
"version",
"of",
"rfr",
"with",
"a",
"function",
"."
] | 4c6c62dd5c338824e7eeccb44321942a7c3a8662 | https://github.com/warmsea/node-rfr/blob/4c6c62dd5c338824e7eeccb44321942a7c3a8662/lib/rfr.js#L59-L122 | train | |
warmsea/node-rfr | lib/rfr.js | createVersion | function createVersion(config) {
if (!(config && (typeof config.root === 'string'
|| config.root === null || config.root === undefined))) {
throw new Error('"config.root" is required and must be a string');
}
var root = config.root;
if (root === null || root === undefined) {
root = defaultRoot;
... | javascript | function createVersion(config) {
if (!(config && (typeof config.root === 'string'
|| config.root === null || config.root === undefined))) {
throw new Error('"config.root" is required and must be a string');
}
var root = config.root;
if (root === null || root === undefined) {
root = defaultRoot;
... | [
"function",
"createVersion",
"(",
"config",
")",
"{",
"if",
"(",
"!",
"(",
"config",
"&&",
"(",
"typeof",
"config",
".",
"root",
"===",
"'string'",
"||",
"config",
".",
"root",
"===",
"null",
"||",
"config",
".",
"root",
"===",
"undefined",
")",
")",
... | Create a new version of rfr.
@param {{root:String}} config config of this version.
@returns {rfr} a new rfr version.
@private | [
"Create",
"a",
"new",
"version",
"of",
"rfr",
"."
] | 4c6c62dd5c338824e7eeccb44321942a7c3a8662 | https://github.com/warmsea/node-rfr/blob/4c6c62dd5c338824e7eeccb44321942a7c3a8662/lib/rfr.js#L130-L147 | train |
hayspec/framework | common/scripts/install-run.js | parsePackageSpecifier | function parsePackageSpecifier(rawPackageSpecifier) {
rawPackageSpecifier = (rawPackageSpecifier || '').trim();
const separatorIndex = rawPackageSpecifier.lastIndexOf('@');
let name;
let version = undefined;
if (separatorIndex === 0) {
// The specifier starts with a scope and doesn't h... | javascript | function parsePackageSpecifier(rawPackageSpecifier) {
rawPackageSpecifier = (rawPackageSpecifier || '').trim();
const separatorIndex = rawPackageSpecifier.lastIndexOf('@');
let name;
let version = undefined;
if (separatorIndex === 0) {
// The specifier starts with a scope and doesn't h... | [
"function",
"parsePackageSpecifier",
"(",
"rawPackageSpecifier",
")",
"{",
"rawPackageSpecifier",
"=",
"(",
"rawPackageSpecifier",
"||",
"''",
")",
".",
"trim",
"(",
")",
";",
"const",
"separatorIndex",
"=",
"rawPackageSpecifier",
".",
"lastIndexOf",
"(",
"'@'",
"... | Parse a package specifier (in the form of name\@version) into name and version parts. | [
"Parse",
"a",
"package",
"specifier",
"(",
"in",
"the",
"form",
"of",
"name",
"\\"
] | 739e2fca2a99ee5cf9f10c658fe0fd0a81129803 | https://github.com/hayspec/framework/blob/739e2fca2a99ee5cf9f10c658fe0fd0a81129803/common/scripts/install-run.js#L26-L47 | train |
hayspec/framework | common/scripts/install-run.js | resolvePackageVersion | function resolvePackageVersion(rushCommonFolder, { name, version }) {
if (!version) {
version = '*'; // If no version is specified, use the latest version
}
if (version.match(/^[a-zA-Z0-9\-\+\.]+$/)) {
// If the version contains only characters that we recognize to be used in static ver... | javascript | function resolvePackageVersion(rushCommonFolder, { name, version }) {
if (!version) {
version = '*'; // If no version is specified, use the latest version
}
if (version.match(/^[a-zA-Z0-9\-\+\.]+$/)) {
// If the version contains only characters that we recognize to be used in static ver... | [
"function",
"resolvePackageVersion",
"(",
"rushCommonFolder",
",",
"{",
"name",
",",
"version",
"}",
")",
"{",
"if",
"(",
"!",
"version",
")",
"{",
"version",
"=",
"'*'",
";",
"// If no version is specified, use the latest version\r",
"}",
"if",
"(",
"version",
... | Resolve a package specifier to a static version | [
"Resolve",
"a",
"package",
"specifier",
"to",
"a",
"static",
"version"
] | 739e2fca2a99ee5cf9f10c658fe0fd0a81129803 | https://github.com/hayspec/framework/blob/739e2fca2a99ee5cf9f10c658fe0fd0a81129803/common/scripts/install-run.js#L51-L96 | train |
hayspec/framework | common/scripts/install-run.js | getNpmPath | function getNpmPath() {
if (!_npmPath) {
try {
if (os.platform() === 'win32') {
// We're on Windows
const whereOutput = childProcess.execSync('where npm', { stdio: [] }).toString();
const lines = whereOutput.split(os.EOL).filter((line) => !!l... | javascript | function getNpmPath() {
if (!_npmPath) {
try {
if (os.platform() === 'win32') {
// We're on Windows
const whereOutput = childProcess.execSync('where npm', { stdio: [] }).toString();
const lines = whereOutput.split(os.EOL).filter((line) => !!l... | [
"function",
"getNpmPath",
"(",
")",
"{",
"if",
"(",
"!",
"_npmPath",
")",
"{",
"try",
"{",
"if",
"(",
"os",
".",
"platform",
"(",
")",
"===",
"'win32'",
")",
"{",
"// We're on Windows\r",
"const",
"whereOutput",
"=",
"childProcess",
".",
"execSync",
"(",... | Get the absolute path to the npm executable | [
"Get",
"the",
"absolute",
"path",
"to",
"the",
"npm",
"executable"
] | 739e2fca2a99ee5cf9f10c658fe0fd0a81129803 | https://github.com/hayspec/framework/blob/739e2fca2a99ee5cf9f10c658fe0fd0a81129803/common/scripts/install-run.js#L101-L126 | train |
justinwilaby/svg-path-interpolator | src/math/utils.js | rotatePoint | function rotatePoint(originX, originY, x, y, radiansX, radiansY) {
const v = {x: x - originX, y: y - originY};
const vx = (v.x * Math.cos(radiansX)) - (v.y * Math.sin(radiansX));
const vy = (v.x * Math.sin(radiansY)) + (v.y * Math.cos(radiansY));
return {x: vx + originX, y: vy + originY};
} | javascript | function rotatePoint(originX, originY, x, y, radiansX, radiansY) {
const v = {x: x - originX, y: y - originY};
const vx = (v.x * Math.cos(radiansX)) - (v.y * Math.sin(radiansX));
const vy = (v.x * Math.sin(radiansY)) + (v.y * Math.cos(radiansY));
return {x: vx + originX, y: vy + originY};
} | [
"function",
"rotatePoint",
"(",
"originX",
",",
"originY",
",",
"x",
",",
"y",
",",
"radiansX",
",",
"radiansY",
")",
"{",
"const",
"v",
"=",
"{",
"x",
":",
"x",
"-",
"originX",
",",
"y",
":",
"y",
"-",
"originY",
"}",
";",
"const",
"vx",
"=",
... | Rotates a point around the given origin
by the specified radians and returns the
rotated point.
@param originX The x coordinate of the point to rotate around.
@param originY The y coordinate of the point to rotate around.
@param x The x coordinate of the point to be rotated.
@param y The y coordinate of the point to b... | [
"Rotates",
"a",
"point",
"around",
"the",
"given",
"origin",
"by",
"the",
"specified",
"radians",
"and",
"returns",
"the",
"rotated",
"point",
"."
] | d88933a89e3dd8eeadd6f5ebb64b341b65d2e42a | https://github.com/justinwilaby/svg-path-interpolator/blob/d88933a89e3dd8eeadd6f5ebb64b341b65d2e42a/src/math/utils.js#L27-L32 | train |
5orenso/geo-lib | lib/geo-lib.js | isPointOnLineSegment | function isPointOnLineSegment(line1p1, line1p2, point) {
if (line1p2.lat <= Math.max(line1p1.lat, point.lat) && line1p2.lat >= Math.min(line1p1.lat, point.lat) &&
line1p2.lon <= Math.max(line1p1.lon, point.lon) && line1p2.lon >= Math.min(line1p1.lon, point.lon)) {
return true;
}
return false... | javascript | function isPointOnLineSegment(line1p1, line1p2, point) {
if (line1p2.lat <= Math.max(line1p1.lat, point.lat) && line1p2.lat >= Math.min(line1p1.lat, point.lat) &&
line1p2.lon <= Math.max(line1p1.lon, point.lon) && line1p2.lon >= Math.min(line1p1.lon, point.lon)) {
return true;
}
return false... | [
"function",
"isPointOnLineSegment",
"(",
"line1p1",
",",
"line1p2",
",",
"point",
")",
"{",
"if",
"(",
"line1p2",
".",
"lat",
"<=",
"Math",
".",
"max",
"(",
"line1p1",
".",
"lat",
",",
"point",
".",
"lat",
")",
"&&",
"line1p2",
".",
"lat",
">=",
"Mat... | Given three colinear points line1p1, line1p2, point, the function checks if point lies on line segment 'line' | [
"Given",
"three",
"colinear",
"points",
"line1p1",
"line1p2",
"point",
"the",
"function",
"checks",
"if",
"point",
"lies",
"on",
"line",
"segment",
"line"
] | be186a133cea75f77e65d3071c66899cbe2a792e | https://github.com/5orenso/geo-lib/blob/be186a133cea75f77e65d3071c66899cbe2a792e/lib/geo-lib.js#L236-L242 | train |
reelyactive/barterer | lib/routes/whatat.js | retrieveWhatAtTransmitter | function retrieveWhatAtTransmitter(req, res) {
if(redirect(req.params.id, '', '', res)) {
return;
}
switch(req.accepts(['json', 'html'])) {
case 'html':
res.sendFile(path.resolve(__dirname + '/../../web/response.html'));
break;
default:
var options = {
query: 'receivedBy',
... | javascript | function retrieveWhatAtTransmitter(req, res) {
if(redirect(req.params.id, '', '', res)) {
return;
}
switch(req.accepts(['json', 'html'])) {
case 'html':
res.sendFile(path.resolve(__dirname + '/../../web/response.html'));
break;
default:
var options = {
query: 'receivedBy',
... | [
"function",
"retrieveWhatAtTransmitter",
"(",
"req",
",",
"res",
")",
"{",
"if",
"(",
"redirect",
"(",
"req",
".",
"params",
".",
"id",
",",
"''",
",",
"''",
",",
"res",
")",
")",
"{",
"return",
";",
"}",
"switch",
"(",
"req",
".",
"accepts",
"(",
... | Retrieve what is decoded by a specific receiver device.
@param {Object} req The HTTP request.
@param {Object} res The HTTP result. | [
"Retrieve",
"what",
"is",
"decoded",
"by",
"a",
"specific",
"receiver",
"device",
"."
] | ab4caa541b13c78cca3f4df9dcfc8f17c1c14c2c | https://github.com/reelyactive/barterer/blob/ab4caa541b13c78cca3f4df9dcfc8f17c1c14c2c/lib/routes/whatat.js#L24-L47 | train |
reelyactive/barterer | lib/server.js | BartererServer | function BartererServer(options) {
options = options || {};
var specifiedHttpPort = options.httpPort || HTTP_PORT;
var httpPort = process.env.PORT || specifiedHttpPort;
var app = express();
var instance = new Barterer(options);
options.app = app;
instance.configureRoutes(options);
app.listen(httpPort... | javascript | function BartererServer(options) {
options = options || {};
var specifiedHttpPort = options.httpPort || HTTP_PORT;
var httpPort = process.env.PORT || specifiedHttpPort;
var app = express();
var instance = new Barterer(options);
options.app = app;
instance.configureRoutes(options);
app.listen(httpPort... | [
"function",
"BartererServer",
"(",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"var",
"specifiedHttpPort",
"=",
"options",
".",
"httpPort",
"||",
"HTTP_PORT",
";",
"var",
"httpPort",
"=",
"process",
".",
"env",
".",
"PORT",
"||",
... | BartererServer Class
Server for barterer, returns an instance of barterer with its own Express
server listening on the given port.
@param {Object} options The options as a JSON object.
@constructor | [
"BartererServer",
"Class",
"Server",
"for",
"barterer",
"returns",
"an",
"instance",
"of",
"barterer",
"with",
"its",
"own",
"Express",
"server",
"listening",
"on",
"the",
"given",
"port",
"."
] | ab4caa541b13c78cca3f4df9dcfc8f17c1c14c2c | https://github.com/reelyactive/barterer/blob/ab4caa541b13c78cca3f4df9dcfc8f17c1c14c2c/lib/server.js#L22-L38 | train |
gritzko/stream-url | src/ZeroServer.js | ZeroServer | function ZeroServer (url, options, callback) {
EventEmitter.call(this);
this.id = null;
//this.streams = {};
if (url) {
this.listen(url, options, callback);
}
} | javascript | function ZeroServer (url, options, callback) {
EventEmitter.call(this);
this.id = null;
//this.streams = {};
if (url) {
this.listen(url, options, callback);
}
} | [
"function",
"ZeroServer",
"(",
"url",
",",
"options",
",",
"callback",
")",
"{",
"EventEmitter",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"id",
"=",
"null",
";",
"//this.streams = {};",
"if",
"(",
"url",
")",
"{",
"this",
".",
"listen",
"(",
... | Fake server for ZeroStreams. | [
"Fake",
"server",
"for",
"ZeroStreams",
"."
] | 1291ed6a628fe4935a9f960e204f26771f13072b | https://github.com/gritzko/stream-url/blob/1291ed6a628fe4935a9f960e204f26771f13072b/src/ZeroServer.js#L6-L13 | train |
ysugimoto/js-dependency-visualizer | visualize/d3Renderer.js | D3Renderer | function D3Renderer(view, graphData, options) {
/**
* View stack
*
* @property view
* @param Array
*/
this.view = view;
/**
* graph Data
*
* @property graph
* @param Object
*/
this.graph = graphDa... | javascript | function D3Renderer(view, graphData, options) {
/**
* View stack
*
* @property view
* @param Array
*/
this.view = view;
/**
* graph Data
*
* @property graph
* @param Object
*/
this.graph = graphDa... | [
"function",
"D3Renderer",
"(",
"view",
",",
"graphData",
",",
"options",
")",
"{",
"/**\n * View stack\n *\n * @property view\n * @param Array\n */",
"this",
".",
"view",
"=",
"view",
";",
"/**\n * graph Data\n *\n * @... | D3Render main class
@class D3Renderer
@constructor
@param {Array} view : d3.select() returns
@param {Object} graphData : DependencyParser::parse() returns
@param {Object} options | [
"D3Render",
"main",
"class"
] | 0dadd6986f5b585cf70ad6925c5aac33cdc15a69 | https://github.com/ysugimoto/js-dependency-visualizer/blob/0dadd6986f5b585cf70ad6925c5aac33cdc15a69/visualize/d3Renderer.js#L48-L160 | train |
lynx-json/lynx-docs | src/cli/stream-utils.js | function (vinyl) {
return path.extname(vinyl.path) === ".lnxs" ? options.spec.dir : options.output;
} | javascript | function (vinyl) {
return path.extname(vinyl.path) === ".lnxs" ? options.spec.dir : options.output;
} | [
"function",
"(",
"vinyl",
")",
"{",
"return",
"path",
".",
"extname",
"(",
"vinyl",
".",
"path",
")",
"===",
"\".lnxs\"",
"?",
"options",
".",
"spec",
".",
"dir",
":",
"options",
".",
"output",
";",
"}"
] | convert from vinyl stream to regular stream | [
"convert",
"from",
"vinyl",
"stream",
"to",
"regular",
"stream"
] | 7f450fc348fedb4ecd16adeaac0e54bedebadec0 | https://github.com/lynx-json/lynx-docs/blob/7f450fc348fedb4ecd16adeaac0e54bedebadec0/src/cli/stream-utils.js#L17-L19 | train | |
bevacqua/mongotape | drop.js | validate | function validate () {
var env = state.env('NODE_ENV');
var uri = state.env('MONGO_URI');
var notTestEnv = env !== 'test';
if (notTestEnv) {
throw new Error('NODE_ENV must be set to "test".');
}
var notTestDb = word.test(uri) === false;
if (notTestDb) {
throw new Error('MONGO_URI must contain "tes... | javascript | function validate () {
var env = state.env('NODE_ENV');
var uri = state.env('MONGO_URI');
var notTestEnv = env !== 'test';
if (notTestEnv) {
throw new Error('NODE_ENV must be set to "test".');
}
var notTestDb = word.test(uri) === false;
if (notTestDb) {
throw new Error('MONGO_URI must contain "tes... | [
"function",
"validate",
"(",
")",
"{",
"var",
"env",
"=",
"state",
".",
"env",
"(",
"'NODE_ENV'",
")",
";",
"var",
"uri",
"=",
"state",
".",
"env",
"(",
"'MONGO_URI'",
")",
";",
"var",
"notTestEnv",
"=",
"env",
"!==",
"'test'",
";",
"if",
"(",
"not... | being able to drop the database is kind of a big deal disallow outside of 'test' environment, and also outside of 'test' database | [
"being",
"able",
"to",
"drop",
"the",
"database",
"is",
"kind",
"of",
"a",
"big",
"deal",
"disallow",
"outside",
"of",
"test",
"environment",
"and",
"also",
"outside",
"of",
"test",
"database"
] | d7124a4bde55c64d5ebfda1526a6d6fbc82c27cc | https://github.com/bevacqua/mongotape/blob/d7124a4bde55c64d5ebfda1526a6d6fbc82c27cc/drop.js#L8-L19 | train |
sematext/spm-agent | lib/index.js | shipMetrics | function shipMetrics (metric) {
try {
this.emit('metric', metric)
this.spmSender.collectMetric(metric)
} catch (ex) {
logger.error('Error in shipMetrics' + ex.stack)
}
} | javascript | function shipMetrics (metric) {
try {
this.emit('metric', metric)
this.spmSender.collectMetric(metric)
} catch (ex) {
logger.error('Error in shipMetrics' + ex.stack)
}
} | [
"function",
"shipMetrics",
"(",
"metric",
")",
"{",
"try",
"{",
"this",
".",
"emit",
"(",
"'metric'",
",",
"metric",
")",
"this",
".",
"spmSender",
".",
"collectMetric",
"(",
"metric",
")",
"}",
"catch",
"(",
"ex",
")",
"{",
"logger",
".",
"error",
"... | Event listener method for metrics, pushing metrics to spmsender module
@param {Object} metric Object | [
"Event",
"listener",
"method",
"for",
"metrics",
"pushing",
"metrics",
"to",
"spmsender",
"module"
] | 7b98be0cfc41fb7bf7f7c605e6602148570269a3 | https://github.com/sematext/spm-agent/blob/7b98be0cfc41fb7bf7f7c605e6602148570269a3/lib/index.js#L37-L44 | train |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function(view){
var viewCid = view.cid;
// delete model index
if (view.model){
delete this._indexByModel[view.model.cid];
}
// delete custom index
_.any(this._indexByCustom, function(cid, key) {
if (cid === viewCid) {
delete this._indexByCustom[key];
... | javascript | function(view){
var viewCid = view.cid;
// delete model index
if (view.model){
delete this._indexByModel[view.model.cid];
}
// delete custom index
_.any(this._indexByCustom, function(cid, key) {
if (cid === viewCid) {
delete this._indexByCustom[key];
... | [
"function",
"(",
"view",
")",
"{",
"var",
"viewCid",
"=",
"view",
".",
"cid",
";",
"// delete model index",
"if",
"(",
"view",
".",
"model",
")",
"{",
"delete",
"this",
".",
"_indexByModel",
"[",
"view",
".",
"model",
".",
"cid",
"]",
";",
"}",
"// d... | Remove a view | [
"Remove",
"a",
"view"
] | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L109-L130 | train | |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function(method, args){
_.each(this._views, function(view){
if (_.isFunction(view[method])){
view[method].apply(view, args || []);
}
});
} | javascript | function(method, args){
_.each(this._views, function(view){
if (_.isFunction(view[method])){
view[method].apply(view, args || []);
}
});
} | [
"function",
"(",
"method",
",",
"args",
")",
"{",
"_",
".",
"each",
"(",
"this",
".",
"_views",
",",
"function",
"(",
"view",
")",
"{",
"if",
"(",
"_",
".",
"isFunction",
"(",
"view",
"[",
"method",
"]",
")",
")",
"{",
"view",
"[",
"method",
"]... | Apply a method on every view in the container, passing parameters to the call method one at a time, like `function.apply`. | [
"Apply",
"a",
"method",
"on",
"every",
"view",
"in",
"the",
"container",
"passing",
"parameters",
"to",
"the",
"call",
"method",
"one",
"at",
"a",
"time",
"like",
"function",
".",
"apply",
"."
] | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L142-L148 | train | |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function(handlers){
_.each(handlers, function(handler, name){
var context = null;
if (_.isObject(handler) && !_.isFunction(handler)){
context = handler.context;
handler = handler.callback;
}
this.setHandler(name, handler, context);
}, this);
} | javascript | function(handlers){
_.each(handlers, function(handler, name){
var context = null;
if (_.isObject(handler) && !_.isFunction(handler)){
context = handler.context;
handler = handler.callback;
}
this.setHandler(name, handler, context);
}, this);
} | [
"function",
"(",
"handlers",
")",
"{",
"_",
".",
"each",
"(",
"handlers",
",",
"function",
"(",
"handler",
",",
"name",
")",
"{",
"var",
"context",
"=",
"null",
";",
"if",
"(",
"_",
".",
"isObject",
"(",
"handler",
")",
"&&",
"!",
"_",
".",
"isFu... | Add multiple handlers using an object literal configuration | [
"Add",
"multiple",
"handlers",
"using",
"an",
"object",
"literal",
"configuration"
] | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L219-L230 | train | |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function(name, handler, context){
var config = {
callback: handler,
context: context
};
this._wreqrHandlers[name] = config;
this.trigger("handler:add", name, handler, context);
} | javascript | function(name, handler, context){
var config = {
callback: handler,
context: context
};
this._wreqrHandlers[name] = config;
this.trigger("handler:add", name, handler, context);
} | [
"function",
"(",
"name",
",",
"handler",
",",
"context",
")",
"{",
"var",
"config",
"=",
"{",
"callback",
":",
"handler",
",",
"context",
":",
"context",
"}",
";",
"this",
".",
"_wreqrHandlers",
"[",
"name",
"]",
"=",
"config",
";",
"this",
".",
"tri... | Add a handler for the given name, with an optional context to run the handler within | [
"Add",
"a",
"handler",
"for",
"the",
"given",
"name",
"with",
"an",
"optional",
"context",
"to",
"run",
"the",
"handler",
"within"
] | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L234-L243 | train | |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function(name){
var config = this._wreqrHandlers[name];
if (!config){
throw new Error("Handler not found for '" + name + "'");
}
return function(){
var args = Array.prototype.slice.apply(arguments);
return config.callback.apply(config.context, args);
};
} | javascript | function(name){
var config = this._wreqrHandlers[name];
if (!config){
throw new Error("Handler not found for '" + name + "'");
}
return function(){
var args = Array.prototype.slice.apply(arguments);
return config.callback.apply(config.context, args);
};
} | [
"function",
"(",
"name",
")",
"{",
"var",
"config",
"=",
"this",
".",
"_wreqrHandlers",
"[",
"name",
"]",
";",
"if",
"(",
"!",
"config",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"Handler not found for '\"",
"+",
"name",
"+",
"\"'\"",
")",
";",
"}",
... | Get the currently registered handler for the specified name. Throws an exception if no handler is found. | [
"Get",
"the",
"currently",
"registered",
"handler",
"for",
"the",
"specified",
"name",
".",
"Throws",
"an",
"exception",
"if",
"no",
"handler",
"is",
"found",
"."
] | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L253-L264 | train | |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function(commandName){
var commands = this._commands[commandName];
// we don't have it, so add it
if (!commands){
// build the configuration
commands = {
command: commandName,
instances: []
};
// store it
this._commands[commandName] = com... | javascript | function(commandName){
var commands = this._commands[commandName];
// we don't have it, so add it
if (!commands){
// build the configuration
commands = {
command: commandName,
instances: []
};
// store it
this._commands[commandName] = com... | [
"function",
"(",
"commandName",
")",
"{",
"var",
"commands",
"=",
"this",
".",
"_commands",
"[",
"commandName",
"]",
";",
"// we don't have it, so add it",
"if",
"(",
"!",
"commands",
")",
"{",
"// build the configuration",
"commands",
"=",
"{",
"command",
":",
... | Get an object literal by command name, that contains the `commandName` and the `instances` of all commands represented as an array of arguments to process | [
"Get",
"an",
"object",
"literal",
"by",
"command",
"name",
"that",
"contains",
"the",
"commandName",
"and",
"the",
"instances",
"of",
"all",
"commands",
"represented",
"as",
"an",
"array",
"of",
"arguments",
"to",
"process"
] | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L303-L320 | train | |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function(name, args){
name = arguments[0];
args = Array.prototype.slice.call(arguments, 1);
if (this.hasHandler(name)){
this.getHandler(name).apply(this, args);
} else {
this.storage.addCommand(name, args);
}
} | javascript | function(name, args){
name = arguments[0];
args = Array.prototype.slice.call(arguments, 1);
if (this.hasHandler(name)){
this.getHandler(name).apply(this, args);
} else {
this.storage.addCommand(name, args);
}
} | [
"function",
"(",
"name",
",",
"args",
")",
"{",
"name",
"=",
"arguments",
"[",
"0",
"]",
";",
"args",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
";",
"if",
"(",
"this",
".",
"hasHandler",
"(",
"nam... | Execute a named command with the supplied args | [
"Execute",
"a",
"named",
"command",
"with",
"the",
"supplied",
"args"
] | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L362-L372 | train | |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function(name, handler, context){
var command = this.storage.getCommands(name);
// loop through and execute all the stored command instances
_.each(command.instances, function(args){
handler.apply(context, args);
});
this.storage.clearCommands(name);
} | javascript | function(name, handler, context){
var command = this.storage.getCommands(name);
// loop through and execute all the stored command instances
_.each(command.instances, function(args){
handler.apply(context, args);
});
this.storage.clearCommands(name);
} | [
"function",
"(",
"name",
",",
"handler",
",",
"context",
")",
"{",
"var",
"command",
"=",
"this",
".",
"storage",
".",
"getCommands",
"(",
"name",
")",
";",
"// loop through and execute all the stored command instances",
"_",
".",
"each",
"(",
"command",
".",
... | Internal method to handle bulk execution of stored commands | [
"Internal",
"method",
"to",
"handle",
"bulk",
"execution",
"of",
"stored",
"commands"
] | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L375-L384 | train | |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function(options){
var storage;
var StorageType = options.storageType || this.storageType;
if (_.isFunction(StorageType)){
storage = new StorageType();
} else {
storage = StorageType;
}
this.storage = storage;
} | javascript | function(options){
var storage;
var StorageType = options.storageType || this.storageType;
if (_.isFunction(StorageType)){
storage = new StorageType();
} else {
storage = StorageType;
}
this.storage = storage;
} | [
"function",
"(",
"options",
")",
"{",
"var",
"storage",
";",
"var",
"StorageType",
"=",
"options",
".",
"storageType",
"||",
"this",
".",
"storageType",
";",
"if",
"(",
"_",
".",
"isFunction",
"(",
"StorageType",
")",
")",
"{",
"storage",
"=",
"new",
"... | Internal method to initialize storage either from the type's `storageType` or the instance `options.storageType`. | [
"Internal",
"method",
"to",
"initialize",
"storage",
"either",
"from",
"the",
"type",
"s",
"storageType",
"or",
"the",
"instance",
"options",
".",
"storageType",
"."
] | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L388-L399 | train | |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function(event) {
// get the method name from the event name
var methodName = 'on' + event.replace(splitter, getEventName);
var method = this[methodName];
// trigger the event, if a trigger method exists
if(_.isFunction(this.trigger)) {
this.trigger.apply(this, arguments);
}
// call ... | javascript | function(event) {
// get the method name from the event name
var methodName = 'on' + event.replace(splitter, getEventName);
var method = this[methodName];
// trigger the event, if a trigger method exists
if(_.isFunction(this.trigger)) {
this.trigger.apply(this, arguments);
}
// call ... | [
"function",
"(",
"event",
")",
"{",
"// get the method name from the event name",
"var",
"methodName",
"=",
"'on'",
"+",
"event",
".",
"replace",
"(",
"splitter",
",",
"getEventName",
")",
";",
"var",
"method",
"=",
"this",
"[",
"methodName",
"]",
";",
"// tri... | actual triggerMethod name | [
"actual",
"triggerMethod",
"name"
] | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L513-L528 | train | |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | iterateEvents | function iterateEvents(target, entity, bindings, functionCallback, stringCallback){
if (!entity || !bindings) { return; }
// allow the bindings to be a function
if (_.isFunction(bindings)){
bindings = bindings.call(target);
}
// iterate the bindings and bind them
_.each(bindings, functio... | javascript | function iterateEvents(target, entity, bindings, functionCallback, stringCallback){
if (!entity || !bindings) { return; }
// allow the bindings to be a function
if (_.isFunction(bindings)){
bindings = bindings.call(target);
}
// iterate the bindings and bind them
_.each(bindings, functio... | [
"function",
"iterateEvents",
"(",
"target",
",",
"entity",
",",
"bindings",
",",
"functionCallback",
",",
"stringCallback",
")",
"{",
"if",
"(",
"!",
"entity",
"||",
"!",
"bindings",
")",
"{",
"return",
";",
"}",
"// allow the bindings to be a function",
"if",
... | generic looping function | [
"generic",
"looping",
"function"
] | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L634-L654 | train |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function(callback, contextOverride){
this._callbacks.push({cb: callback, ctx: contextOverride});
this._deferred.done(function(context, options){
if (contextOverride){ context = contextOverride; }
callback.call(context, options);
});
} | javascript | function(callback, contextOverride){
this._callbacks.push({cb: callback, ctx: contextOverride});
this._deferred.done(function(context, options){
if (contextOverride){ context = contextOverride; }
callback.call(context, options);
});
} | [
"function",
"(",
"callback",
",",
"contextOverride",
")",
"{",
"this",
".",
"_callbacks",
".",
"push",
"(",
"{",
"cb",
":",
"callback",
",",
"ctx",
":",
"contextOverride",
"}",
")",
";",
"this",
".",
"_deferred",
".",
"done",
"(",
"function",
"(",
"con... | Add a callback to be executed. Callbacks added here are guaranteed to execute, even if they are added after the `run` method is called. | [
"Add",
"a",
"callback",
"to",
"be",
"executed",
".",
"Callbacks",
"added",
"here",
"are",
"guaranteed",
"to",
"execute",
"even",
"if",
"they",
"are",
"added",
"after",
"the",
"run",
"method",
"is",
"called",
"."
] | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L684-L691 | train | |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function(){
var callbacks = this._callbacks;
this._deferred = Marionette.$.Deferred();
this._callbacks = [];
_.each(callbacks, function(cb){
this.add(cb.cb, cb.ctx);
}, this);
} | javascript | function(){
var callbacks = this._callbacks;
this._deferred = Marionette.$.Deferred();
this._callbacks = [];
_.each(callbacks, function(cb){
this.add(cb.cb, cb.ctx);
}, this);
} | [
"function",
"(",
")",
"{",
"var",
"callbacks",
"=",
"this",
".",
"_callbacks",
";",
"this",
".",
"_deferred",
"=",
"Marionette",
".",
"$",
".",
"Deferred",
"(",
")",
";",
"this",
".",
"_callbacks",
"=",
"[",
"]",
";",
"_",
".",
"each",
"(",
"callba... | Resets the list of callbacks to be run, allowing the same list to be run multiple times - whenever the `run` method is called. | [
"Resets",
"the",
"list",
"of",
"callbacks",
"to",
"be",
"run",
"allowing",
"the",
"same",
"list",
"to",
"be",
"run",
"multiple",
"times",
"-",
"whenever",
"the",
"run",
"method",
"is",
"called",
"."
] | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L702-L710 | train | |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function(view){
this.ensureEl();
var isViewClosed = view.isClosed || _.isUndefined(view.$el);
var isDifferentView = view !== this.currentView;
if (isDifferentView) {
this.close();
}
view.render();
if (isDifferentView || isViewClosed) {
this.open(view);
}
this.c... | javascript | function(view){
this.ensureEl();
var isViewClosed = view.isClosed || _.isUndefined(view.$el);
var isDifferentView = view !== this.currentView;
if (isDifferentView) {
this.close();
}
view.render();
if (isDifferentView || isViewClosed) {
this.open(view);
}
this.c... | [
"function",
"(",
"view",
")",
"{",
"this",
".",
"ensureEl",
"(",
")",
";",
"var",
"isViewClosed",
"=",
"view",
".",
"isClosed",
"||",
"_",
".",
"isUndefined",
"(",
"view",
".",
"$el",
")",
";",
"var",
"isDifferentView",
"=",
"view",
"!==",
"this",
".... | Displays a backbone view instance inside of the region. Handles calling the `render` method for you. Reads content directly from the `el` attribute. Also calls an optional `onShow` and `close` method on your view, just after showing or just before closing the view, respectively. | [
"Displays",
"a",
"backbone",
"view",
"instance",
"inside",
"of",
"the",
"region",
".",
"Handles",
"calling",
"the",
"render",
"method",
"for",
"you",
".",
"Reads",
"content",
"directly",
"from",
"the",
"el",
"attribute",
".",
"Also",
"calls",
"an",
"optional... | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L860-L882 | train | |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function(){
var view = this.currentView;
if (!view || view.isClosed){ return; }
// call 'close' or 'remove', depending on which is found
if (view.close) { view.close(); }
else if (view.remove) { view.remove(); }
Marionette.triggerMethod.call(this, "close");
delete this.currentView;
} | javascript | function(){
var view = this.currentView;
if (!view || view.isClosed){ return; }
// call 'close' or 'remove', depending on which is found
if (view.close) { view.close(); }
else if (view.remove) { view.remove(); }
Marionette.triggerMethod.call(this, "close");
delete this.currentView;
} | [
"function",
"(",
")",
"{",
"var",
"view",
"=",
"this",
".",
"currentView",
";",
"if",
"(",
"!",
"view",
"||",
"view",
".",
"isClosed",
")",
"{",
"return",
";",
"}",
"// call 'close' or 'remove', depending on which is found",
"if",
"(",
"view",
".",
"close",
... | Close the current view, if there is one. If there is no current view, it does nothing and returns immediately. | [
"Close",
"the",
"current",
"view",
"if",
"there",
"is",
"one",
".",
"If",
"there",
"is",
"no",
"current",
"view",
"it",
"does",
"nothing",
"and",
"returns",
"immediately",
"."
] | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L904-L915 | train | |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function(regionDefinitions, defaults){
var regions = {};
_.each(regionDefinitions, function(definition, name){
if (typeof definition === "string"){
definition = { selector: definition };
}
if (definition.selector){
definition = _.defaults({}, definition, default... | javascript | function(regionDefinitions, defaults){
var regions = {};
_.each(regionDefinitions, function(definition, name){
if (typeof definition === "string"){
definition = { selector: definition };
}
if (definition.selector){
definition = _.defaults({}, definition, default... | [
"function",
"(",
"regionDefinitions",
",",
"defaults",
")",
"{",
"var",
"regions",
"=",
"{",
"}",
";",
"_",
".",
"each",
"(",
"regionDefinitions",
",",
"function",
"(",
"definition",
",",
"name",
")",
"{",
"if",
"(",
"typeof",
"definition",
"===",
"\"str... | Add multiple regions using an object literal, where each key becomes the region name, and each value is the region definition. | [
"Add",
"multiple",
"regions",
"using",
"an",
"object",
"literal",
"where",
"each",
"key",
"becomes",
"the",
"region",
"name",
"and",
"each",
"value",
"is",
"the",
"region",
"definition",
"."
] | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L953-L970 | train | |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function(name, definition){
var region;
var isObject = _.isObject(definition);
var isString = _.isString(definition);
var hasSelector = !!definition.selector;
if (isString || (isObject && hasSelector)){
region = Marionette.Region.buildRegion(definition, Marionette.Region);
... | javascript | function(name, definition){
var region;
var isObject = _.isObject(definition);
var isString = _.isString(definition);
var hasSelector = !!definition.selector;
if (isString || (isObject && hasSelector)){
region = Marionette.Region.buildRegion(definition, Marionette.Region);
... | [
"function",
"(",
"name",
",",
"definition",
")",
"{",
"var",
"region",
";",
"var",
"isObject",
"=",
"_",
".",
"isObject",
"(",
"definition",
")",
";",
"var",
"isString",
"=",
"_",
".",
"isString",
"(",
"definition",
")",
";",
"var",
"hasSelector",
"=",... | Add an individual region to the region manager, and return the region instance | [
"Add",
"an",
"individual",
"region",
"to",
"the",
"region",
"manager",
"and",
"return",
"the",
"region",
"instance"
] | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L974-L992 | train | |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function(){
this.removeRegions();
var args = Array.prototype.slice.call(arguments);
Marionette.Controller.prototype.close.apply(this, args);
} | javascript | function(){
this.removeRegions();
var args = Array.prototype.slice.call(arguments);
Marionette.Controller.prototype.close.apply(this, args);
} | [
"function",
"(",
")",
"{",
"this",
".",
"removeRegions",
"(",
")",
";",
"var",
"args",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
")",
";",
"Marionette",
".",
"Controller",
".",
"prototype",
".",
"close",
".",
"apply",... | Close all regions and shut down the region manager entirely | [
"Close",
"all",
"regions",
"and",
"shut",
"down",
"the",
"region",
"manager",
"entirely"
] | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1023-L1027 | train | |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function(name, region){
region.close();
delete this._regions[name];
this._setLength();
this.triggerMethod("region:remove", name, region);
} | javascript | function(name, region){
region.close();
delete this._regions[name];
this._setLength();
this.triggerMethod("region:remove", name, region);
} | [
"function",
"(",
"name",
",",
"region",
")",
"{",
"region",
".",
"close",
"(",
")",
";",
"delete",
"this",
".",
"_regions",
"[",
"name",
"]",
";",
"this",
".",
"_setLength",
"(",
")",
";",
"this",
".",
"triggerMethod",
"(",
"\"region:remove\"",
",",
... | internal method to remove a region | [
"internal",
"method",
"to",
"remove",
"a",
"region"
] | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1036-L1041 | train | |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function(template, data){
if (!template) {
var error = new Error("Cannot render the template since it's false, null or undefined.");
error.name = "TemplateNotFoundError";
throw error;
}
var templateFunc;
if (typeof template === "function"){
templateFunc = template;
} else {... | javascript | function(template, data){
if (!template) {
var error = new Error("Cannot render the template since it's false, null or undefined.");
error.name = "TemplateNotFoundError";
throw error;
}
var templateFunc;
if (typeof template === "function"){
templateFunc = template;
} else {... | [
"function",
"(",
"template",
",",
"data",
")",
"{",
"if",
"(",
"!",
"template",
")",
"{",
"var",
"error",
"=",
"new",
"Error",
"(",
"\"Cannot render the template since it's false, null or undefined.\"",
")",
";",
"error",
".",
"name",
"=",
"\"TemplateNotFoundError... | Render a template with data. The `template` parameter is passed to the `TemplateCache` object to retrieve the template function. Override this method to provide your own custom rendering and template handling for all of Marionette. | [
"Render",
"a",
"template",
"with",
"data",
".",
"The",
"template",
"parameter",
"is",
"passed",
"to",
"the",
"TemplateCache",
"object",
"to",
"retrieve",
"the",
"template",
"function",
".",
"Override",
"this",
"method",
"to",
"provide",
"your",
"own",
"custom"... | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1178-L1194 | train | |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function(target){
target = target || {};
var templateHelpers = Marionette.getOption(this, "templateHelpers");
if (_.isFunction(templateHelpers)){
templateHelpers = templateHelpers.call(this);
}
return _.extend(target, templateHelpers);
} | javascript | function(target){
target = target || {};
var templateHelpers = Marionette.getOption(this, "templateHelpers");
if (_.isFunction(templateHelpers)){
templateHelpers = templateHelpers.call(this);
}
return _.extend(target, templateHelpers);
} | [
"function",
"(",
"target",
")",
"{",
"target",
"=",
"target",
"||",
"{",
"}",
";",
"var",
"templateHelpers",
"=",
"Marionette",
".",
"getOption",
"(",
"this",
",",
"\"templateHelpers\"",
")",
";",
"if",
"(",
"_",
".",
"isFunction",
"(",
"templateHelpers",
... | Mix in template helper methods. Looks for a `templateHelpers` attribute, which can either be an object literal, or a function that returns an object literal. All methods and attributes from this object are copies to the object passed in. | [
"Mix",
"in",
"template",
"helper",
"methods",
".",
"Looks",
"for",
"a",
"templateHelpers",
"attribute",
"which",
"can",
"either",
"be",
"an",
"object",
"literal",
"or",
"a",
"function",
"that",
"returns",
"an",
"object",
"literal",
".",
"All",
"methods",
"an... | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1232-L1239 | train | |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function(events){
this._delegateDOMEvents(events);
Marionette.bindEntityEvents(this, this.model, Marionette.getOption(this, "modelEvents"));
Marionette.bindEntityEvents(this, this.collection, Marionette.getOption(this, "collectionEvents"));
} | javascript | function(events){
this._delegateDOMEvents(events);
Marionette.bindEntityEvents(this, this.model, Marionette.getOption(this, "modelEvents"));
Marionette.bindEntityEvents(this, this.collection, Marionette.getOption(this, "collectionEvents"));
} | [
"function",
"(",
"events",
")",
"{",
"this",
".",
"_delegateDOMEvents",
"(",
"events",
")",
";",
"Marionette",
".",
"bindEntityEvents",
"(",
"this",
",",
"this",
".",
"model",
",",
"Marionette",
".",
"getOption",
"(",
"this",
",",
"\"modelEvents\"",
")",
"... | Overriding Backbone.View's delegateEvents to handle the `triggers`, `modelEvents`, and `collectionEvents` configuration | [
"Overriding",
"Backbone",
".",
"View",
"s",
"delegateEvents",
"to",
"handle",
"the",
"triggers",
"modelEvents",
"and",
"collectionEvents",
"configuration"
] | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1280-L1284 | train | |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function(events){
events = events || this.events;
if (_.isFunction(events)){ events = events.call(this); }
var combinedEvents = {};
var triggers = this.configureTriggers();
_.extend(combinedEvents, events, triggers);
Backbone.View.prototype.delegateEvents.call(this, combinedEvents);
} | javascript | function(events){
events = events || this.events;
if (_.isFunction(events)){ events = events.call(this); }
var combinedEvents = {};
var triggers = this.configureTriggers();
_.extend(combinedEvents, events, triggers);
Backbone.View.prototype.delegateEvents.call(this, combinedEvents);
} | [
"function",
"(",
"events",
")",
"{",
"events",
"=",
"events",
"||",
"this",
".",
"events",
";",
"if",
"(",
"_",
".",
"isFunction",
"(",
"events",
")",
")",
"{",
"events",
"=",
"events",
".",
"call",
"(",
"this",
")",
";",
"}",
"var",
"combinedEvent... | internal method to delegate DOM events and triggers | [
"internal",
"method",
"to",
"delegate",
"DOM",
"events",
"and",
"triggers"
] | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1287-L1296 | train | |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function(){
var args = Array.prototype.slice.call(arguments);
Backbone.View.prototype.undelegateEvents.apply(this, args);
Marionette.unbindEntityEvents(this, this.model, Marionette.getOption(this, "modelEvents"));
Marionette.unbindEntityEvents(this, this.collection, Marionette.getOption(this, "collecti... | javascript | function(){
var args = Array.prototype.slice.call(arguments);
Backbone.View.prototype.undelegateEvents.apply(this, args);
Marionette.unbindEntityEvents(this, this.model, Marionette.getOption(this, "modelEvents"));
Marionette.unbindEntityEvents(this, this.collection, Marionette.getOption(this, "collecti... | [
"function",
"(",
")",
"{",
"var",
"args",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
")",
";",
"Backbone",
".",
"View",
".",
"prototype",
".",
"undelegateEvents",
".",
"apply",
"(",
"this",
",",
"args",
")",
";",
"Ma... | Overriding Backbone.View's undelegateEvents to handle unbinding the `triggers`, `modelEvents`, and `collectionEvents` config | [
"Overriding",
"Backbone",
".",
"View",
"s",
"undelegateEvents",
"to",
"handle",
"unbinding",
"the",
"triggers",
"modelEvents",
"and",
"collectionEvents",
"config"
] | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1300-L1306 | train | |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function(){
if (this.isClosed) { return; }
// allow the close to be stopped by returning `false`
// from the `onBeforeClose` method
var shouldClose = this.triggerMethod("before:close");
if (shouldClose === false){
return;
}
// mark as closed before doing the actual close, to
// p... | javascript | function(){
if (this.isClosed) { return; }
// allow the close to be stopped by returning `false`
// from the `onBeforeClose` method
var shouldClose = this.triggerMethod("before:close");
if (shouldClose === false){
return;
}
// mark as closed before doing the actual close, to
// p... | [
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"isClosed",
")",
"{",
"return",
";",
"}",
"// allow the close to be stopped by returning `false`",
"// from the `onBeforeClose` method",
"var",
"shouldClose",
"=",
"this",
".",
"triggerMethod",
"(",
"\"before:close\"",
... | Default `close` implementation, for removing a view from the DOM and unbinding it. Regions will call this method for you. You can specify an `onClose` method in your view to add custom code that is called after the view is closed. | [
"Default",
"close",
"implementation",
"for",
"removing",
"a",
"view",
"from",
"the",
"DOM",
"and",
"unbinding",
"it",
".",
"Regions",
"will",
"call",
"this",
"method",
"for",
"you",
".",
"You",
"can",
"specify",
"an",
"onClose",
"method",
"in",
"your",
"vi... | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1315-L1336 | train | |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function(){
if (!this.ui || !this._uiBindings){ return; }
// delete all of the existing ui bindings
_.each(this.ui, function($el, name){
delete this.ui[name];
}, this);
// reset the ui element to the original bindings configuration
this.ui = this._uiBindings;
delete this._uiBindings;... | javascript | function(){
if (!this.ui || !this._uiBindings){ return; }
// delete all of the existing ui bindings
_.each(this.ui, function($el, name){
delete this.ui[name];
}, this);
// reset the ui element to the original bindings configuration
this.ui = this._uiBindings;
delete this._uiBindings;... | [
"function",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"ui",
"||",
"!",
"this",
".",
"_uiBindings",
")",
"{",
"return",
";",
"}",
"// delete all of the existing ui bindings",
"_",
".",
"each",
"(",
"this",
".",
"ui",
",",
"function",
"(",
"$el",
",",
... | This method unbinds the elements specified in the "ui" hash | [
"This",
"method",
"unbinds",
"the",
"elements",
"specified",
"in",
"the",
"ui",
"hash"
] | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1363-L1374 | train | |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function(){
this.isClosed = false;
this.triggerMethod("before:render", this);
this.triggerMethod("item:before:render", this);
var data = this.serializeData();
data = this.mixinTemplateHelpers(data);
var template = this.getTemplate();
var html = Marionette.Renderer.render(template, data);
... | javascript | function(){
this.isClosed = false;
this.triggerMethod("before:render", this);
this.triggerMethod("item:before:render", this);
var data = this.serializeData();
data = this.mixinTemplateHelpers(data);
var template = this.getTemplate();
var html = Marionette.Renderer.render(template, data);
... | [
"function",
"(",
")",
"{",
"this",
".",
"isClosed",
"=",
"false",
";",
"this",
".",
"triggerMethod",
"(",
"\"before:render\"",
",",
"this",
")",
";",
"this",
".",
"triggerMethod",
"(",
"\"item:before:render\"",
",",
"this",
")",
";",
"var",
"data",
"=",
... | Render the view, defaulting to underscore.js templates. You can override this in your view definition to provide a very specific rendering for your view. In general, though, you should override the `Marionette.Renderer` object to change how Marionette renders views. | [
"Render",
"the",
"view",
"defaulting",
"to",
"underscore",
".",
"js",
"templates",
".",
"You",
"can",
"override",
"this",
"in",
"your",
"view",
"definition",
"to",
"provide",
"a",
"very",
"specific",
"rendering",
"for",
"your",
"view",
".",
"In",
"general",
... | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1415-L1434 | train | |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function(){
if (this.isClosed){ return; }
this.triggerMethod('item:before:close');
Marionette.View.prototype.close.apply(this, slice(arguments));
this.triggerMethod('item:closed');
} | javascript | function(){
if (this.isClosed){ return; }
this.triggerMethod('item:before:close');
Marionette.View.prototype.close.apply(this, slice(arguments));
this.triggerMethod('item:closed');
} | [
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"isClosed",
")",
"{",
"return",
";",
"}",
"this",
".",
"triggerMethod",
"(",
"'item:before:close'",
")",
";",
"Marionette",
".",
"View",
".",
"prototype",
".",
"close",
".",
"apply",
"(",
"this",
",",
... | Override the default close event to add a few more events that are triggered. | [
"Override",
"the",
"default",
"close",
"event",
"to",
"add",
"a",
"few",
"more",
"events",
"that",
"are",
"triggered",
"."
] | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1438-L1446 | train | |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function(){
if (this.collection){
this.listenTo(this.collection, "add", this.addChildView, this);
this.listenTo(this.collection, "remove", this.removeItemView, this);
this.listenTo(this.collection, "reset", this.render, this);
}
} | javascript | function(){
if (this.collection){
this.listenTo(this.collection, "add", this.addChildView, this);
this.listenTo(this.collection, "remove", this.removeItemView, this);
this.listenTo(this.collection, "reset", this.render, this);
}
} | [
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"collection",
")",
"{",
"this",
".",
"listenTo",
"(",
"this",
".",
"collection",
",",
"\"add\"",
",",
"this",
".",
"addChildView",
",",
"this",
")",
";",
"this",
".",
"listenTo",
"(",
"this",
".",
... | Configured the initial events that the collection view binds to. Override this method to prevent the initial events, or to add your own initial events. | [
"Configured",
"the",
"initial",
"events",
"that",
"the",
"collection",
"view",
"binds",
"to",
".",
"Override",
"this",
"method",
"to",
"prevent",
"the",
"initial",
"events",
"or",
"to",
"add",
"your",
"own",
"initial",
"events",
"."
] | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1471-L1477 | train | |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function(item, collection, options){
this.closeEmptyView();
var ItemView = this.getItemView(item);
var index = this.collection.indexOf(item);
this.addItemView(item, ItemView, index);
} | javascript | function(item, collection, options){
this.closeEmptyView();
var ItemView = this.getItemView(item);
var index = this.collection.indexOf(item);
this.addItemView(item, ItemView, index);
} | [
"function",
"(",
"item",
",",
"collection",
",",
"options",
")",
"{",
"this",
".",
"closeEmptyView",
"(",
")",
";",
"var",
"ItemView",
"=",
"this",
".",
"getItemView",
"(",
"item",
")",
";",
"var",
"index",
"=",
"this",
".",
"collection",
".",
"indexOf... | Handle a child item added to the collection | [
"Handle",
"a",
"child",
"item",
"added",
"to",
"the",
"collection"
] | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1480-L1485 | train | |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function(){
var ItemView;
this.collection.each(function(item, index){
ItemView = this.getItemView(item);
this.addItemView(item, ItemView, index);
}, this);
} | javascript | function(){
var ItemView;
this.collection.each(function(item, index){
ItemView = this.getItemView(item);
this.addItemView(item, ItemView, index);
}, this);
} | [
"function",
"(",
")",
"{",
"var",
"ItemView",
";",
"this",
".",
"collection",
".",
"each",
"(",
"function",
"(",
"item",
",",
"index",
")",
"{",
"ItemView",
"=",
"this",
".",
"getItemView",
"(",
"item",
")",
";",
"this",
".",
"addItemView",
"(",
"ite... | Internal method to loop through each item in the collection view and show it | [
"Internal",
"method",
"to",
"loop",
"through",
"each",
"item",
"in",
"the",
"collection",
"view",
"and",
"show",
"it"
] | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1536-L1542 | train | |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function(){
var EmptyView = Marionette.getOption(this, "emptyView");
if (EmptyView && !this._showingEmptyView){
this._showingEmptyView = true;
var model = new Backbone.Model();
this.addItemView(model, EmptyView, 0);
}
} | javascript | function(){
var EmptyView = Marionette.getOption(this, "emptyView");
if (EmptyView && !this._showingEmptyView){
this._showingEmptyView = true;
var model = new Backbone.Model();
this.addItemView(model, EmptyView, 0);
}
} | [
"function",
"(",
")",
"{",
"var",
"EmptyView",
"=",
"Marionette",
".",
"getOption",
"(",
"this",
",",
"\"emptyView\"",
")",
";",
"if",
"(",
"EmptyView",
"&&",
"!",
"this",
".",
"_showingEmptyView",
")",
"{",
"this",
".",
"_showingEmptyView",
"=",
"true",
... | Internal method to show an empty view in place of a collection of item views, when the collection is empty | [
"Internal",
"method",
"to",
"show",
"an",
"empty",
"view",
"in",
"place",
"of",
"a",
"collection",
"of",
"item",
"views",
"when",
"the",
"collection",
"is",
"empty"
] | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1547-L1555 | train | |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function(item, ItemView, index){
// get the itemViewOptions if any were specified
var itemViewOptions = Marionette.getOption(this, "itemViewOptions");
if (_.isFunction(itemViewOptions)){
itemViewOptions = itemViewOptions.call(this, item, index);
}
// build the view
var view = this.buildI... | javascript | function(item, ItemView, index){
// get the itemViewOptions if any were specified
var itemViewOptions = Marionette.getOption(this, "itemViewOptions");
if (_.isFunction(itemViewOptions)){
itemViewOptions = itemViewOptions.call(this, item, index);
}
// build the view
var view = this.buildI... | [
"function",
"(",
"item",
",",
"ItemView",
",",
"index",
")",
"{",
"// get the itemViewOptions if any were specified",
"var",
"itemViewOptions",
"=",
"Marionette",
".",
"getOption",
"(",
"this",
",",
"\"itemViewOptions\"",
")",
";",
"if",
"(",
"_",
".",
"isFunction... | Render the child item's view and add it to the HTML for the collection view. | [
"Render",
"the",
"child",
"item",
"s",
"view",
"and",
"add",
"it",
"to",
"the",
"HTML",
"for",
"the",
"collection",
"view",
"."
] | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1582-L1613 | train | |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function(item, ItemViewType, itemViewOptions){
var options = _.extend({model: item}, itemViewOptions);
return new ItemViewType(options);
} | javascript | function(item, ItemViewType, itemViewOptions){
var options = _.extend({model: item}, itemViewOptions);
return new ItemViewType(options);
} | [
"function",
"(",
"item",
",",
"ItemViewType",
",",
"itemViewOptions",
")",
"{",
"var",
"options",
"=",
"_",
".",
"extend",
"(",
"{",
"model",
":",
"item",
"}",
",",
"itemViewOptions",
")",
";",
"return",
"new",
"ItemViewType",
"(",
"options",
")",
";",
... | Build an `itemView` for every model in the collection. | [
"Build",
"an",
"itemView",
"for",
"every",
"model",
"in",
"the",
"collection",
"."
] | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1638-L1641 | train | |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function(view){
// shut down the child view properly,
// including events that the collection has from it
if (view){
this.stopListening(view);
// call 'close' or 'remove', depending on which is found
if (view.close) { view.close(); }
else if (view.remove) { view.remove(); }
... | javascript | function(view){
// shut down the child view properly,
// including events that the collection has from it
if (view){
this.stopListening(view);
// call 'close' or 'remove', depending on which is found
if (view.close) { view.close(); }
else if (view.remove) { view.remove(); }
... | [
"function",
"(",
"view",
")",
"{",
"// shut down the child view properly,",
"// including events that the collection has from it",
"if",
"(",
"view",
")",
"{",
"this",
".",
"stopListening",
"(",
"view",
")",
";",
"// call 'close' or 'remove', depending on which is found",
"if... | Remove the child view and close it | [
"Remove",
"the",
"child",
"view",
"and",
"close",
"it"
] | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1651-L1666 | train | |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function(){
if (this.collection){
this.listenTo(this.collection, "add", this.addChildView, this);
this.listenTo(this.collection, "remove", this.removeItemView, this);
this.listenTo(this.collection, "reset", this._renderChildren, this);
}
} | javascript | function(){
if (this.collection){
this.listenTo(this.collection, "add", this.addChildView, this);
this.listenTo(this.collection, "remove", this.removeItemView, this);
this.listenTo(this.collection, "reset", this._renderChildren, this);
}
} | [
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"collection",
")",
"{",
"this",
".",
"listenTo",
"(",
"this",
".",
"collection",
",",
"\"add\"",
",",
"this",
".",
"addChildView",
",",
"this",
")",
";",
"this",
".",
"listenTo",
"(",
"this",
".",
... | Configured the initial events that the composite view binds to. Override this method to prevent the initial events, or to add your own initial events. | [
"Configured",
"the",
"initial",
"events",
"that",
"the",
"composite",
"view",
"binds",
"to",
".",
"Override",
"this",
"method",
"to",
"prevent",
"the",
"initial",
"events",
"or",
"to",
"add",
"your",
"own",
"initial",
"events",
"."
] | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1730-L1736 | train | |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function(){
this.isRendered = true;
this.isClosed = false;
this.resetItemViewContainer();
this.triggerBeforeRender();
var html = this.renderModel();
this.$el.html(html);
// the ui bindings is done here and not at the end of render since they
// will not be available until after the mode... | javascript | function(){
this.isRendered = true;
this.isClosed = false;
this.resetItemViewContainer();
this.triggerBeforeRender();
var html = this.renderModel();
this.$el.html(html);
// the ui bindings is done here and not at the end of render since they
// will not be available until after the mode... | [
"function",
"(",
")",
"{",
"this",
".",
"isRendered",
"=",
"true",
";",
"this",
".",
"isClosed",
"=",
"false",
";",
"this",
".",
"resetItemViewContainer",
"(",
")",
";",
"this",
".",
"triggerBeforeRender",
"(",
")",
";",
"var",
"html",
"=",
"this",
"."... | Renders the model once, and the collection once. Calling this again will tell the model's view to re-render itself but the collection will not re-render. | [
"Renders",
"the",
"model",
"once",
"and",
"the",
"collection",
"once",
".",
"Calling",
"this",
"again",
"will",
"tell",
"the",
"model",
"s",
"view",
"to",
"re",
"-",
"render",
"itself",
"but",
"the",
"collection",
"will",
"not",
"re",
"-",
"render",
"."
... | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1768-L1787 | train | |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function (options) {
options = options || {};
this._firstRender = true;
this._initializeRegions(options);
Marionette.ItemView.prototype.constructor.call(this, options);
} | javascript | function (options) {
options = options || {};
this._firstRender = true;
this._initializeRegions(options);
Marionette.ItemView.prototype.constructor.call(this, options);
} | [
"function",
"(",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"this",
".",
"_firstRender",
"=",
"true",
";",
"this",
".",
"_initializeRegions",
"(",
"options",
")",
";",
"Marionette",
".",
"ItemView",
".",
"prototype",
".",
"const... | Ensure the regions are available when the `initialize` method is called. | [
"Ensure",
"the",
"regions",
"are",
"available",
"when",
"the",
"initialize",
"method",
"is",
"called",
"."
] | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1865-L1872 | train | |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function(){
if (this.isClosed){
// a previously closed layout means we need to
// completely re-initialize the regions
this._initializeRegions();
}
if (this._firstRender) {
// if this is the first render, don't do anything to
// reset the regions
this._firstRender = fal... | javascript | function(){
if (this.isClosed){
// a previously closed layout means we need to
// completely re-initialize the regions
this._initializeRegions();
}
if (this._firstRender) {
// if this is the first render, don't do anything to
// reset the regions
this._firstRender = fal... | [
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"isClosed",
")",
"{",
"// a previously closed layout means we need to ",
"// completely re-initialize the regions",
"this",
".",
"_initializeRegions",
"(",
")",
";",
"}",
"if",
"(",
"this",
".",
"_firstRender",
")",... | Layout's render will use the existing region objects the first time it is called. Subsequent calls will close the views that the regions are showing and then reset the `el` for the regions to the newly rendered DOM elements. | [
"Layout",
"s",
"render",
"will",
"use",
"the",
"existing",
"region",
"objects",
"the",
"first",
"time",
"it",
"is",
"called",
".",
"Subsequent",
"calls",
"will",
"close",
"the",
"views",
"that",
"the",
"regions",
"are",
"showing",
"and",
"then",
"reset",
"... | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1878-L1899 | train | |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function () {
if (this.isClosed){ return; }
this.regionManager.close();
var args = Array.prototype.slice.apply(arguments);
Marionette.ItemView.prototype.close.apply(this, args);
} | javascript | function () {
if (this.isClosed){ return; }
this.regionManager.close();
var args = Array.prototype.slice.apply(arguments);
Marionette.ItemView.prototype.close.apply(this, args);
} | [
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"isClosed",
")",
"{",
"return",
";",
"}",
"this",
".",
"regionManager",
".",
"close",
"(",
")",
";",
"var",
"args",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"apply",
"(",
"arguments",
")"... | Handle closing regions, and then close the view itself. | [
"Handle",
"closing",
"regions",
"and",
"then",
"close",
"the",
"view",
"itself",
"."
] | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1902-L1907 | train | |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function(regions){
var that = this;
var defaults = {
regionType: Marionette.getOption(this, "regionType"),
parentEl: function(){ return that.$el; }
};
return this.regionManager.addRegions(regions, defaults);
} | javascript | function(regions){
var that = this;
var defaults = {
regionType: Marionette.getOption(this, "regionType"),
parentEl: function(){ return that.$el; }
};
return this.regionManager.addRegions(regions, defaults);
} | [
"function",
"(",
"regions",
")",
"{",
"var",
"that",
"=",
"this",
";",
"var",
"defaults",
"=",
"{",
"regionType",
":",
"Marionette",
".",
"getOption",
"(",
"this",
",",
"\"regionType\"",
")",
",",
"parentEl",
":",
"function",
"(",
")",
"{",
"return",
"... | internal method to build regions | [
"internal",
"method",
"to",
"build",
"regions"
] | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1929-L1938 | train | |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function (options) {
var regions;
this._initRegionManager();
if (_.isFunction(this.regions)) {
regions = this.regions(options);
} else {
regions = this.regions || {};
}
this.addRegions(regions);
} | javascript | function (options) {
var regions;
this._initRegionManager();
if (_.isFunction(this.regions)) {
regions = this.regions(options);
} else {
regions = this.regions || {};
}
this.addRegions(regions);
} | [
"function",
"(",
"options",
")",
"{",
"var",
"regions",
";",
"this",
".",
"_initRegionManager",
"(",
")",
";",
"if",
"(",
"_",
".",
"isFunction",
"(",
"this",
".",
"regions",
")",
")",
"{",
"regions",
"=",
"this",
".",
"regions",
"(",
"options",
")",... | Internal method to initialize the regions that have been defined in a `regions` attribute on this layout. | [
"Internal",
"method",
"to",
"initialize",
"the",
"regions",
"that",
"have",
"been",
"defined",
"in",
"a",
"regions",
"attribute",
"on",
"this",
"layout",
"."
] | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1942-L1953 | train | |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function(){
this.regionManager = new Marionette.RegionManager();
this.listenTo(this.regionManager, "region:add", function(name, region){
this[name] = region;
this.trigger("region:add", name, region);
});
this.listenTo(this.regionManager, "region:remove", function(name, region){
delet... | javascript | function(){
this.regionManager = new Marionette.RegionManager();
this.listenTo(this.regionManager, "region:add", function(name, region){
this[name] = region;
this.trigger("region:add", name, region);
});
this.listenTo(this.regionManager, "region:remove", function(name, region){
delet... | [
"function",
"(",
")",
"{",
"this",
".",
"regionManager",
"=",
"new",
"Marionette",
".",
"RegionManager",
"(",
")",
";",
"this",
".",
"listenTo",
"(",
"this",
".",
"regionManager",
",",
"\"region:add\"",
",",
"function",
"(",
"name",
",",
"region",
")",
"... | Internal method to initialize the region manager and all regions in it | [
"Internal",
"method",
"to",
"initialize",
"the",
"region",
"manager",
"and",
"all",
"regions",
"in",
"it"
] | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1966-L1978 | train | |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function(controller, appRoutes) {
if (!appRoutes){ return; }
var routeNames = _.keys(appRoutes).reverse(); // Backbone requires reverted order of routes
_.each(routeNames, function(route) {
this._addAppRoute(controller, route, appRoutes[route]);
}, this);
} | javascript | function(controller, appRoutes) {
if (!appRoutes){ return; }
var routeNames = _.keys(appRoutes).reverse(); // Backbone requires reverted order of routes
_.each(routeNames, function(route) {
this._addAppRoute(controller, route, appRoutes[route]);
}, this);
} | [
"function",
"(",
"controller",
",",
"appRoutes",
")",
"{",
"if",
"(",
"!",
"appRoutes",
")",
"{",
"return",
";",
"}",
"var",
"routeNames",
"=",
"_",
".",
"keys",
"(",
"appRoutes",
")",
".",
"reverse",
"(",
")",
";",
"// Backbone requires reverted order of ... | Internal method to process the `appRoutes` for the router, and turn them in to routes that trigger the specified method on the specified `controller`. | [
"Internal",
"method",
"to",
"process",
"the",
"appRoutes",
"for",
"the",
"router",
"and",
"turn",
"them",
"in",
"to",
"routes",
"that",
"trigger",
"the",
"specified",
"method",
"on",
"the",
"specified",
"controller",
"."
] | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L2022-L2030 | train | |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function(){
var args = Array.prototype.slice.apply(arguments);
this.commands.execute.apply(this.commands, args);
} | javascript | function(){
var args = Array.prototype.slice.apply(arguments);
this.commands.execute.apply(this.commands, args);
} | [
"function",
"(",
")",
"{",
"var",
"args",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"apply",
"(",
"arguments",
")",
";",
"this",
".",
"commands",
".",
"execute",
".",
"apply",
"(",
"this",
".",
"commands",
",",
"args",
")",
";",
"}"
] | Command execution, facilitated by Backbone.Wreqr.Commands | [
"Command",
"execution",
"facilitated",
"by",
"Backbone",
".",
"Wreqr",
".",
"Commands"
] | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L2069-L2072 | train | |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function(options){
this.triggerMethod("initialize:before", options);
this._initCallbacks.run(options, this);
this.triggerMethod("initialize:after", options);
this.triggerMethod("start", options);
} | javascript | function(options){
this.triggerMethod("initialize:before", options);
this._initCallbacks.run(options, this);
this.triggerMethod("initialize:after", options);
this.triggerMethod("start", options);
} | [
"function",
"(",
"options",
")",
"{",
"this",
".",
"triggerMethod",
"(",
"\"initialize:before\"",
",",
"options",
")",
";",
"this",
".",
"_initCallbacks",
".",
"run",
"(",
"options",
",",
"this",
")",
";",
"this",
".",
"triggerMethod",
"(",
"\"initialize:aft... | kick off all of the application's processes. initializes all of the regions that have been added to the app, and runs all of the initializer functions | [
"kick",
"off",
"all",
"of",
"the",
"application",
"s",
"processes",
".",
"initializes",
"all",
"of",
"the",
"regions",
"that",
"have",
"been",
"added",
"to",
"the",
"app",
"and",
"runs",
"all",
"of",
"the",
"initializer",
"functions"
] | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L2090-L2096 | train | |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function(moduleNames, moduleDefinition){
// slice the args, and add this application object as the
// first argument of the array
var args = slice(arguments);
args.unshift(this);
// see the Marionette.Module object for more information
return Marionette.Module.create.apply(Marionette.Module, ar... | javascript | function(moduleNames, moduleDefinition){
// slice the args, and add this application object as the
// first argument of the array
var args = slice(arguments);
args.unshift(this);
// see the Marionette.Module object for more information
return Marionette.Module.create.apply(Marionette.Module, ar... | [
"function",
"(",
"moduleNames",
",",
"moduleDefinition",
")",
"{",
"// slice the args, and add this application object as the",
"// first argument of the array",
"var",
"args",
"=",
"slice",
"(",
"arguments",
")",
";",
"args",
".",
"unshift",
"(",
"this",
")",
";",
"/... | Create a module, attached to the application | [
"Create",
"a",
"module",
"attached",
"to",
"the",
"application"
] | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L2126-L2134 | train | |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function(){
this._regionManager = new Marionette.RegionManager();
this.listenTo(this._regionManager, "region:add", function(name, region){
this[name] = region;
});
this.listenTo(this._regionManager, "region:remove", function(name, region){
delete this[name];
});
} | javascript | function(){
this._regionManager = new Marionette.RegionManager();
this.listenTo(this._regionManager, "region:add", function(name, region){
this[name] = region;
});
this.listenTo(this._regionManager, "region:remove", function(name, region){
delete this[name];
});
} | [
"function",
"(",
")",
"{",
"this",
".",
"_regionManager",
"=",
"new",
"Marionette",
".",
"RegionManager",
"(",
")",
";",
"this",
".",
"listenTo",
"(",
"this",
".",
"_regionManager",
",",
"\"region:add\"",
",",
"function",
"(",
"name",
",",
"region",
")",
... | Internal method to set up the region manager | [
"Internal",
"method",
"to",
"set",
"up",
"the",
"region",
"manager"
] | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L2137-L2147 | train | |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function(options){
// Prevent re-starting a module that is already started
if (this._isInitialized){ return; }
// start the sub-modules (depth-first hierarchy)
_.each(this.submodules, function(mod){
// check to see if we should start the sub-module with this parent
if (mod.startWithParent){... | javascript | function(options){
// Prevent re-starting a module that is already started
if (this._isInitialized){ return; }
// start the sub-modules (depth-first hierarchy)
_.each(this.submodules, function(mod){
// check to see if we should start the sub-module with this parent
if (mod.startWithParent){... | [
"function",
"(",
"options",
")",
"{",
"// Prevent re-starting a module that is already started",
"if",
"(",
"this",
".",
"_isInitialized",
")",
"{",
"return",
";",
"}",
"// start the sub-modules (depth-first hierarchy)",
"_",
".",
"each",
"(",
"this",
".",
"submodules",... | Start the module, and run all of its initializers | [
"Start",
"the",
"module",
"and",
"run",
"all",
"of",
"its",
"initializers"
] | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L2191-L2210 | train | |
jmorrell/backbone-filtered-collection | examples/map/js/backbone.marionette.js | function(){
// if we are not initialized, don't bother finalizing
if (!this._isInitialized){ return; }
this._isInitialized = false;
Marionette.triggerMethod.call(this, "before:stop");
// stop the sub-modules; depth-first, to make sure the
// sub-modules are stopped / finalized before parents
... | javascript | function(){
// if we are not initialized, don't bother finalizing
if (!this._isInitialized){ return; }
this._isInitialized = false;
Marionette.triggerMethod.call(this, "before:stop");
// stop the sub-modules; depth-first, to make sure the
// sub-modules are stopped / finalized before parents
... | [
"function",
"(",
")",
"{",
"// if we are not initialized, don't bother finalizing",
"if",
"(",
"!",
"this",
".",
"_isInitialized",
")",
"{",
"return",
";",
"}",
"this",
".",
"_isInitialized",
"=",
"false",
";",
"Marionette",
".",
"triggerMethod",
".",
"call",
"(... | Stop this module by running its finalizers and then stop all of the sub-modules for this module | [
"Stop",
"this",
"module",
"by",
"running",
"its",
"finalizers",
"and",
"then",
"stop",
"all",
"of",
"the",
"sub",
"-",
"modules",
"for",
"this",
"module"
] | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L2214-L2233 | train | |
pocka/bitwise64 | index.js | divide | function divide(bit) {
var bitString = ((zeros + zeros) + (Number(bit).toString(2))).slice(-64);
return [
parseInt(bitString.slice(0, 32), 2), // hi
parseInt(bitString.slice(-32), 2) // lo
];
} | javascript | function divide(bit) {
var bitString = ((zeros + zeros) + (Number(bit).toString(2))).slice(-64);
return [
parseInt(bitString.slice(0, 32), 2), // hi
parseInt(bitString.slice(-32), 2) // lo
];
} | [
"function",
"divide",
"(",
"bit",
")",
"{",
"var",
"bitString",
"=",
"(",
"(",
"zeros",
"+",
"zeros",
")",
"+",
"(",
"Number",
"(",
"bit",
")",
".",
"toString",
"(",
"2",
")",
")",
")",
".",
"slice",
"(",
"-",
"64",
")",
";",
"return",
"[",
"... | Divides hi and lo | [
"Divides",
"hi",
"and",
"lo"
] | fe6c2c0fd6072d3c37790bc10fe2f8e9c51553f3 | https://github.com/pocka/bitwise64/blob/fe6c2c0fd6072d3c37790bc10fe2f8e9c51553f3/index.js#L13-L20 | train |
doowb/set-getter | index.js | setGetter | function setGetter(obj, prop, getter) {
var key = toPath(arguments);
return define(obj, key, getter);
} | javascript | function setGetter(obj, prop, getter) {
var key = toPath(arguments);
return define(obj, key, getter);
} | [
"function",
"setGetter",
"(",
"obj",
",",
"prop",
",",
"getter",
")",
"{",
"var",
"key",
"=",
"toPath",
"(",
"arguments",
")",
";",
"return",
"define",
"(",
"obj",
",",
"key",
",",
"getter",
")",
";",
"}"
] | Defines a getter function on an object using property path notation.
```js
var obj = {};
getter(obj, 'foo', function() {
return 'bar';
});
```
@param {Object} `obj` Object to add property to.
@param {String|Array} `prop` Property string or array to add.
@param {Function} `getter` Getter function to add as a property.
... | [
"Defines",
"a",
"getter",
"function",
"on",
"an",
"object",
"using",
"property",
"path",
"notation",
"."
] | 5bc2750fe1c3db9651d936131be187744111378d | https://github.com/doowb/set-getter/blob/5bc2750fe1c3db9651d936131be187744111378d/index.js#L27-L30 | train |
doowb/set-getter | index.js | define | function define(obj, prop, getter) {
if (!~prop.indexOf('.')) {
defineProperty(obj, prop, getter);
return obj;
}
var keys = prop.split('.');
var last = keys.pop();
var target = obj;
var key;
while ((key = keys.shift())) {
while (key.slice(-1) === '\\') {
key = key.slice(0, -1) + '.' + ... | javascript | function define(obj, prop, getter) {
if (!~prop.indexOf('.')) {
defineProperty(obj, prop, getter);
return obj;
}
var keys = prop.split('.');
var last = keys.pop();
var target = obj;
var key;
while ((key = keys.shift())) {
while (key.slice(-1) === '\\') {
key = key.slice(0, -1) + '.' + ... | [
"function",
"define",
"(",
"obj",
",",
"prop",
",",
"getter",
")",
"{",
"if",
"(",
"!",
"~",
"prop",
".",
"indexOf",
"(",
"'.'",
")",
")",
"{",
"defineProperty",
"(",
"obj",
",",
"prop",
",",
"getter",
")",
";",
"return",
"obj",
";",
"}",
"var",
... | Define getter function on object or object hierarchy using dot notation.
@param {Object} `obj` Object to define getter property on.
@param {String} `prop` Property string to define.
@param {Function} `getter` Getter function to define.
@return {Object} Returns original object. | [
"Define",
"getter",
"function",
"on",
"object",
"or",
"object",
"hierarchy",
"using",
"dot",
"notation",
"."
] | 5bc2750fe1c3db9651d936131be187744111378d | https://github.com/doowb/set-getter/blob/5bc2750fe1c3db9651d936131be187744111378d/index.js#L41-L61 | train |
doowb/set-getter | index.js | defineProperty | function defineProperty(obj, prop, getter) {
Object.defineProperty(obj, prop, {
configurable: true,
enumerable: true,
get: getter
});
} | javascript | function defineProperty(obj, prop, getter) {
Object.defineProperty(obj, prop, {
configurable: true,
enumerable: true,
get: getter
});
} | [
"function",
"defineProperty",
"(",
"obj",
",",
"prop",
",",
"getter",
")",
"{",
"Object",
".",
"defineProperty",
"(",
"obj",
",",
"prop",
",",
"{",
"configurable",
":",
"true",
",",
"enumerable",
":",
"true",
",",
"get",
":",
"getter",
"}",
")",
";",
... | Define getter function on object as a configurable and enumerable property.
@param {Object} `obj` Object to define property on.
@param {String} `prop` Property to define.
@param {Function} `getter` Getter function to define. | [
"Define",
"getter",
"function",
"on",
"object",
"as",
"a",
"configurable",
"and",
"enumerable",
"property",
"."
] | 5bc2750fe1c3db9651d936131be187744111378d | https://github.com/doowb/set-getter/blob/5bc2750fe1c3db9651d936131be187744111378d/index.js#L71-L77 | train |
jmorrell/backbone-filtered-collection | src/create-filter.js | function(model) {
for (var i = 0; i < filterFunctions.length; i++) {
if (!filterFunctions[i](model)) {
return false;
}
}
return true;
} | javascript | function(model) {
for (var i = 0; i < filterFunctions.length; i++) {
if (!filterFunctions[i](model)) {
return false;
}
}
return true;
} | [
"function",
"(",
"model",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"filterFunctions",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"!",
"filterFunctions",
"[",
"i",
"]",
"(",
"model",
")",
")",
"{",
"return",
"false",
"... | Iterate through each of the generated filter functions. If any are false, kill the computation and return false. The function is only true if all of the subfunctions are true. | [
"Iterate",
"through",
"each",
"of",
"the",
"generated",
"filter",
"functions",
".",
"If",
"any",
"are",
"false",
"kill",
"the",
"computation",
"and",
"return",
"false",
".",
"The",
"function",
"is",
"only",
"true",
"if",
"all",
"of",
"the",
"subfunctions",
... | 880672e7edbc3eb2151f569fe009d62d03d989c4 | https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/src/create-filter.js#L50-L57 | train | |
darren-lester/nihongo | src/analysers.js | isKyouikuKanji | function isKyouikuKanji(ch) {
return includes(kyouikuKanji.grade1, ch) ||
includes(kyouikuKanji.grade2, ch) ||
includes(kyouikuKanji.grade3, ch) ||
includes(kyouikuKanji.grade4, ch) ||
includes(kyouikuKanji.grade5, ch) ||
includes(kyouikuKanji.grade6, ch);
} | javascript | function isKyouikuKanji(ch) {
return includes(kyouikuKanji.grade1, ch) ||
includes(kyouikuKanji.grade2, ch) ||
includes(kyouikuKanji.grade3, ch) ||
includes(kyouikuKanji.grade4, ch) ||
includes(kyouikuKanji.grade5, ch) ||
includes(kyouikuKanji.grade6, ch);
} | [
"function",
"isKyouikuKanji",
"(",
"ch",
")",
"{",
"return",
"includes",
"(",
"kyouikuKanji",
".",
"grade1",
",",
"ch",
")",
"||",
"includes",
"(",
"kyouikuKanji",
".",
"grade2",
",",
"ch",
")",
"||",
"includes",
"(",
"kyouikuKanji",
".",
"grade3",
",",
... | determine whether a character is a kyouiku kanji character | [
"determine",
"whether",
"a",
"character",
"is",
"a",
"kyouiku",
"kanji",
"character"
] | 2ca0fbfac7aa41c8b5d8476fc6da0ab1f0ea27e7 | https://github.com/darren-lester/nihongo/blob/2ca0fbfac7aa41c8b5d8476fc6da0ab1f0ea27e7/src/analysers.js#L36-L43 | train |
darren-lester/nihongo | src/analysers.js | getKyouikuGrade | function getKyouikuGrade(ch) {
let grade;
if (includes(kyouikuKanji.grade1, ch)) {
grade = 1;
}
else if (includes(kyouikuKanji.grade2, ch)) {
grade = 2;
}
else if (includes(kyouikuKanji.grade3, ch)) {
grade = 3;
}
else if (includes(kyouikuKanji.grade4, ch)) {
... | javascript | function getKyouikuGrade(ch) {
let grade;
if (includes(kyouikuKanji.grade1, ch)) {
grade = 1;
}
else if (includes(kyouikuKanji.grade2, ch)) {
grade = 2;
}
else if (includes(kyouikuKanji.grade3, ch)) {
grade = 3;
}
else if (includes(kyouikuKanji.grade4, ch)) {
... | [
"function",
"getKyouikuGrade",
"(",
"ch",
")",
"{",
"let",
"grade",
";",
"if",
"(",
"includes",
"(",
"kyouikuKanji",
".",
"grade1",
",",
"ch",
")",
")",
"{",
"grade",
"=",
"1",
";",
"}",
"else",
"if",
"(",
"includes",
"(",
"kyouikuKanji",
".",
"grade... | return the grade of a kyouiku kanji | [
"return",
"the",
"grade",
"of",
"a",
"kyouiku",
"kanji"
] | 2ca0fbfac7aa41c8b5d8476fc6da0ab1f0ea27e7 | https://github.com/darren-lester/nihongo/blob/2ca0fbfac7aa41c8b5d8476fc6da0ab1f0ea27e7/src/analysers.js#L51-L74 | train |
darren-lester/nihongo | src/analysers.js | contains | function contains(str) {
return {
hiragana: hasHiragana(str),
katakana: hasKatakana(str),
kanji: hasKanji(str)
};
} | javascript | function contains(str) {
return {
hiragana: hasHiragana(str),
katakana: hasKatakana(str),
kanji: hasKanji(str)
};
} | [
"function",
"contains",
"(",
"str",
")",
"{",
"return",
"{",
"hiragana",
":",
"hasHiragana",
"(",
"str",
")",
",",
"katakana",
":",
"hasKatakana",
"(",
"str",
")",
",",
"kanji",
":",
"hasKanji",
"(",
"str",
")",
"}",
";",
"}"
] | determine whether a string contains hiragana, katakana or kanji characters | [
"determine",
"whether",
"a",
"string",
"contains",
"hiragana",
"katakana",
"or",
"kanji",
"characters"
] | 2ca0fbfac7aa41c8b5d8476fc6da0ab1f0ea27e7 | https://github.com/darren-lester/nihongo/blob/2ca0fbfac7aa41c8b5d8476fc6da0ab1f0ea27e7/src/analysers.js#L103-L109 | 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.