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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
JakubMrozek/eet | lib/eet.js | getHeaderItems | function getHeaderItems (uid, currentDate, prvniZaslani, overeni) {
return {
attributes: {
uuid_zpravy: uid,
dat_odesl: formatDate(currentDate),
prvni_zaslani: formatBool(prvniZaslani, true),
overeni: formatBool(overeni, false)
}
}
} | javascript | function getHeaderItems (uid, currentDate, prvniZaslani, overeni) {
return {
attributes: {
uuid_zpravy: uid,
dat_odesl: formatDate(currentDate),
prvni_zaslani: formatBool(prvniZaslani, true),
overeni: formatBool(overeni, false)
}
}
} | [
"function",
"getHeaderItems",
"(",
"uid",
",",
"currentDate",
",",
"prvniZaslani",
",",
"overeni",
")",
"{",
"return",
"{",
"attributes",
":",
"{",
"uuid_zpravy",
":",
"uid",
",",
"dat_odesl",
":",
"formatDate",
"(",
"currentDate",
")",
",",
"prvni_zaslani",
... | Vygeneruje polozky pro element Hlavicka. | [
"Vygeneruje",
"polozky",
"pro",
"element",
"Hlavicka",
"."
] | 28a8f0b6743308c705eb0c17e985e0ed065b692e | https://github.com/JakubMrozek/eet/blob/28a8f0b6743308c705eb0c17e985e0ed065b692e/lib/eet.js#L114-L123 | train |
JakubMrozek/eet | lib/eet.js | getFooterItems | function getFooterItems (privateKey, items) {
const pkp = generatePKP(
privateKey,
items.dicPopl,
items.idProvoz,
items.idPokl,
items.poradCis,
formatDate(items.datTrzby),
formatNumber(items.celkTrzba)
)
const bkp = generateBKP(pkp)
return {
pkp: {
attributes: {
di... | javascript | function getFooterItems (privateKey, items) {
const pkp = generatePKP(
privateKey,
items.dicPopl,
items.idProvoz,
items.idPokl,
items.poradCis,
formatDate(items.datTrzby),
formatNumber(items.celkTrzba)
)
const bkp = generateBKP(pkp)
return {
pkp: {
attributes: {
di... | [
"function",
"getFooterItems",
"(",
"privateKey",
",",
"items",
")",
"{",
"const",
"pkp",
"=",
"generatePKP",
"(",
"privateKey",
",",
"items",
".",
"dicPopl",
",",
"items",
".",
"idProvoz",
",",
"items",
".",
"idPokl",
",",
"items",
".",
"poradCis",
",",
... | Vygeneruje polozky pro element KontrolniKody. | [
"Vygeneruje",
"polozky",
"pro",
"element",
"KontrolniKody",
"."
] | 28a8f0b6743308c705eb0c17e985e0ed065b692e | https://github.com/JakubMrozek/eet/blob/28a8f0b6743308c705eb0c17e985e0ed065b692e/lib/eet.js#L194-L223 | train |
JakubMrozek/eet | lib/eet.js | getResponseItems | function getResponseItems (response) {
const header = response.Hlavicka.attributes
const body = response.Potvrzeni.attributes
return {
uuid: header.uuid_zpravy,
bkp: header.bkp,
date: new Date(header.dat_prij),
test: body.test === 'true',
fik: body.fik,
warnings: getWarnings(response.Varov... | javascript | function getResponseItems (response) {
const header = response.Hlavicka.attributes
const body = response.Potvrzeni.attributes
return {
uuid: header.uuid_zpravy,
bkp: header.bkp,
date: new Date(header.dat_prij),
test: body.test === 'true',
fik: body.fik,
warnings: getWarnings(response.Varov... | [
"function",
"getResponseItems",
"(",
"response",
")",
"{",
"const",
"header",
"=",
"response",
".",
"Hlavicka",
".",
"attributes",
"const",
"body",
"=",
"response",
".",
"Potvrzeni",
".",
"attributes",
"return",
"{",
"uuid",
":",
"header",
".",
"uuid_zpravy",
... | Zpracuje OK odpoved ze serveru EET. | [
"Zpracuje",
"OK",
"odpoved",
"ze",
"serveru",
"EET",
"."
] | 28a8f0b6743308c705eb0c17e985e0ed065b692e | https://github.com/JakubMrozek/eet/blob/28a8f0b6743308c705eb0c17e985e0ed065b692e/lib/eet.js#L229-L240 | train |
grasshopper-cms/grasshopper-api-js | lib/routes/social/twitter.js | _loadUserFromToken | function _loadUserFromToken(){
return BB
.bind(this)
.then(function() {
return grasshopper.request(this.token).users.current();
})
.then(function(user){
this.user = user;
});
} | javascript | function _loadUserFromToken(){
return BB
.bind(this)
.then(function() {
return grasshopper.request(this.token).users.current();
})
.then(function(user){
this.user = user;
});
} | [
"function",
"_loadUserFromToken",
"(",
")",
"{",
"return",
"BB",
".",
"bind",
"(",
"this",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"return",
"grasshopper",
".",
"request",
"(",
"this",
".",
"token",
")",
".",
"users",
".",
"current",
"(",
"... | Utility function to return the current logged in user. | [
"Utility",
"function",
"to",
"return",
"the",
"current",
"logged",
"in",
"user",
"."
] | 05a952b8b65e3a66c8a27f5d84699ee5cf02844d | https://github.com/grasshopper-cms/grasshopper-api-js/blob/05a952b8b65e3a66c8a27f5d84699ee5cf02844d/lib/routes/social/twitter.js#L62-L71 | train |
grasshopper-cms/grasshopper-api-js | lib/routes/social/twitter.js | _linkIdentity | function _linkIdentity() {
var identityOptions = {
id: this.params.raw.user_id,
accessToken: this.params.access_token,
accessSecret: this.params.access_secret,
screen_name: this.params.raw.screen_name
};
return BB.resolve(grasshopper.request(this.token).u... | javascript | function _linkIdentity() {
var identityOptions = {
id: this.params.raw.user_id,
accessToken: this.params.access_token,
accessSecret: this.params.access_secret,
screen_name: this.params.raw.screen_name
};
return BB.resolve(grasshopper.request(this.token).u... | [
"function",
"_linkIdentity",
"(",
")",
"{",
"var",
"identityOptions",
"=",
"{",
"id",
":",
"this",
".",
"params",
".",
"raw",
".",
"user_id",
",",
"accessToken",
":",
"this",
".",
"params",
".",
"access_token",
",",
"accessSecret",
":",
"this",
".",
"par... | Utility function to link a user's twitter info to the current user. | [
"Utility",
"function",
"to",
"link",
"a",
"user",
"s",
"twitter",
"info",
"to",
"the",
"current",
"user",
"."
] | 05a952b8b65e3a66c8a27f5d84699ee5cf02844d | https://github.com/grasshopper-cms/grasshopper-api-js/blob/05a952b8b65e3a66c8a27f5d84699ee5cf02844d/lib/routes/social/twitter.js#L74-L83 | train |
aaronj1335/webpack-postcss-tools | index.js | makeVarMap | function makeVarMap(filename) {
var map = {vars: {}, media: {}, selector: {}};
function resolveImport(path, basedir) {
if (path[0] === '/')
return path;
if (path[0] === '.')
return pathResolve(join(basedir, path));
// webpack treats anything starting w/ ~ as a module name, which we're
... | javascript | function makeVarMap(filename) {
var map = {vars: {}, media: {}, selector: {}};
function resolveImport(path, basedir) {
if (path[0] === '/')
return path;
if (path[0] === '.')
return pathResolve(join(basedir, path));
// webpack treats anything starting w/ ~ as a module name, which we're
... | [
"function",
"makeVarMap",
"(",
"filename",
")",
"{",
"var",
"map",
"=",
"{",
"vars",
":",
"{",
"}",
",",
"media",
":",
"{",
"}",
",",
"selector",
":",
"{",
"}",
"}",
";",
"function",
"resolveImport",
"(",
"path",
",",
"basedir",
")",
"{",
"if",
"... | create maps of variables and custom media queries
because we want to:
- treat every css file as a separate webpack module
- statically resolve css variables during the build
we run into an issue where we're compiling a css library with variables that
might be overridden by a later stylesheet. we solve this by resolv... | [
"create",
"maps",
"of",
"variables",
"and",
"custom",
"media",
"queries"
] | 9baa0e43cc9929ca94e9cab336089bfb96ffed98 | https://github.com/aaronj1335/webpack-postcss-tools/blob/9baa0e43cc9929ca94e9cab336089bfb96ffed98/index.js#L33-L121 | train |
aaronj1335/webpack-postcss-tools | index.js | prependTildesToImports | function prependTildesToImports(styles) {
styles.eachAtRule(function (atRule) {
if (atRule.name !== 'import')
return;
var stripped = stripQuotes(unwrapUrl(atRule.params));
if (stripped[0] !== '.' && stripped[0] !== '~' && stripped[0] !== '/') {
atRule.params = '"~' + stripped + '"';
}
... | javascript | function prependTildesToImports(styles) {
styles.eachAtRule(function (atRule) {
if (atRule.name !== 'import')
return;
var stripped = stripQuotes(unwrapUrl(atRule.params));
if (stripped[0] !== '.' && stripped[0] !== '~' && stripped[0] !== '/') {
atRule.params = '"~' + stripped + '"';
}
... | [
"function",
"prependTildesToImports",
"(",
"styles",
")",
"{",
"styles",
".",
"eachAtRule",
"(",
"function",
"(",
"atRule",
")",
"{",
"if",
"(",
"atRule",
".",
"name",
"!==",
"'import'",
")",
"return",
";",
"var",
"stripped",
"=",
"stripQuotes",
"(",
"unwr... | prepend a tilde to css module imports
webpack's css-loader [treats css imports as relative paths][url-to-req], not
modules. the easiest way i've found to correct this prepending a `~` to each
import to force webpack to use it's full module lookup machinery.
[url-to-req]: https://github.com/webpack/css-loader/blob/7b5... | [
"prepend",
"a",
"tilde",
"to",
"css",
"module",
"imports"
] | 9baa0e43cc9929ca94e9cab336089bfb96ffed98 | https://github.com/aaronj1335/webpack-postcss-tools/blob/9baa0e43cc9929ca94e9cab336089bfb96ffed98/index.js#L136-L147 | train |
grasshopper-cms/grasshopper-api-js | lib/routes/social/facebook.js | facebookReq | function facebookReq(req, res){
var redirectUrl = _.has(grasshopper.config.identities, 'facebook') ? grasshopper.config.identities.facebook.redirectUrl : 'defaultRoute';
BB.bind({token: req.session.token, params: req.query, res: res, req: req, user: null })
.then(function(){
if(!_.isUndefin... | javascript | function facebookReq(req, res){
var redirectUrl = _.has(grasshopper.config.identities, 'facebook') ? grasshopper.config.identities.facebook.redirectUrl : 'defaultRoute';
BB.bind({token: req.session.token, params: req.query, res: res, req: req, user: null })
.then(function(){
if(!_.isUndefin... | [
"function",
"facebookReq",
"(",
"req",
",",
"res",
")",
"{",
"var",
"redirectUrl",
"=",
"_",
".",
"has",
"(",
"grasshopper",
".",
"config",
".",
"identities",
",",
"'facebook'",
")",
"?",
"grasshopper",
".",
"config",
".",
"identities",
".",
"facebook",
... | Middleware that handles all of the logic for creating and linking social accounts. | [
"Middleware",
"that",
"handles",
"all",
"of",
"the",
"logic",
"for",
"creating",
"and",
"linking",
"social",
"accounts",
"."
] | 05a952b8b65e3a66c8a27f5d84699ee5cf02844d | https://github.com/grasshopper-cms/grasshopper-api-js/blob/05a952b8b65e3a66c8a27f5d84699ee5cf02844d/lib/routes/social/facebook.js#L15-L36 | train |
Aldaviva/mongoose-moment | lib/schema.js | SchemaMoment | function SchemaMoment(key, options) {
SchemaType.call(this, key, options);
this.get(function(val, self){
if(!val){
return val;
} else {
return new Moment(val);
}
});
} | javascript | function SchemaMoment(key, options) {
SchemaType.call(this, key, options);
this.get(function(val, self){
if(!val){
return val;
} else {
return new Moment(val);
}
});
} | [
"function",
"SchemaMoment",
"(",
"key",
",",
"options",
")",
"{",
"SchemaType",
".",
"call",
"(",
"this",
",",
"key",
",",
"options",
")",
";",
"this",
".",
"get",
"(",
"function",
"(",
"val",
",",
"self",
")",
"{",
"if",
"(",
"!",
"val",
")",
"{... | Moment SchemaType constructor.
@param {String} key
@param {Object} options
@inherits SchemaType
@api private | [
"Moment",
"SchemaType",
"constructor",
"."
] | ba36ec59e9a630b21d61d9ad63d9865ff3cb0872 | https://github.com/Aldaviva/mongoose-moment/blob/ba36ec59e9a630b21d61d9ad63d9865ff3cb0872/lib/schema.js#L46-L56 | train |
Battochon/passwordless-postgrestore | lib/postgrestore.js | PostgreStore | function PostgreStore(conString, options) {
if(!conString){
throw new Error('Connection String is missing.');
}
this._options = options || {};
this._options.pgstore = this._options.pgstore || {};
this._difficulty = this._options.pgstore.difficulty || 10;
this._table = this._options.pgstore... | javascript | function PostgreStore(conString, options) {
if(!conString){
throw new Error('Connection String is missing.');
}
this._options = options || {};
this._options.pgstore = this._options.pgstore || {};
this._difficulty = this._options.pgstore.difficulty || 10;
this._table = this._options.pgstore... | [
"function",
"PostgreStore",
"(",
"conString",
",",
"options",
")",
"{",
"if",
"(",
"!",
"conString",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Connection String is missing.'",
")",
";",
"}",
"this",
".",
"_options",
"=",
"options",
"||",
"{",
"}",
";",
"... | Constructor of PostgreStore
@param {String} conString URI as defined by the PostgreSQL specification. Please
check the documentation for details:
https://github.com/brianc/node-postgres
@param {Object} [options] Combines both the options for the PostgreClient as well
as the options for PostgreStore. For the PostgreClie... | [
"Constructor",
"of",
"PostgreStore"
] | feb17613cf4dad8ebfabba54e146d0bc14b390d0 | https://github.com/Battochon/passwordless-postgrestore/blob/feb17613cf4dad8ebfabba54e146d0bc14b390d0/lib/postgrestore.js#L21-L48 | train |
grasshopper-cms/grasshopper-api-js | lib/routes/google.js | oauth | function oauth(httpRequest, httpResponse){
var code = httpRequest.query.code,
redirectUrl = _.has(grasshopper.config.identities, 'google') ? grasshopper.config.identities.google.redirectUrl : 'defaultRoute';
grasshopper.auth('Google', { code: code })
.then(function(token) {
... | javascript | function oauth(httpRequest, httpResponse){
var code = httpRequest.query.code,
redirectUrl = _.has(grasshopper.config.identities, 'google') ? grasshopper.config.identities.google.redirectUrl : 'defaultRoute';
grasshopper.auth('Google', { code: code })
.then(function(token) {
... | [
"function",
"oauth",
"(",
"httpRequest",
",",
"httpResponse",
")",
"{",
"var",
"code",
"=",
"httpRequest",
".",
"query",
".",
"code",
",",
"redirectUrl",
"=",
"_",
".",
"has",
"(",
"grasshopper",
".",
"config",
".",
"identities",
",",
"'google'",
")",
"?... | Method will accept the oauth callback from google, run authentication, then redirect the user to the page that accepts the token. | [
"Method",
"will",
"accept",
"the",
"oauth",
"callback",
"from",
"google",
"run",
"authentication",
"then",
"redirect",
"the",
"user",
"to",
"the",
"page",
"that",
"accepts",
"the",
"token",
"."
] | 05a952b8b65e3a66c8a27f5d84699ee5cf02844d | https://github.com/grasshopper-cms/grasshopper-api-js/blob/05a952b8b65e3a66c8a27f5d84699ee5cf02844d/lib/routes/google.js#L24-L42 | train |
grasshopper-cms/grasshopper-api-js | lib/routes/google.js | url | function url(httpRequest, httpResponse) {
var response = new Response(httpResponse);
grasshopper.googleAuthUrl()
.then(function(url) {
response.writeSuccess(url);
})
.fail(function(message) {
var err = {
code : 400,... | javascript | function url(httpRequest, httpResponse) {
var response = new Response(httpResponse);
grasshopper.googleAuthUrl()
.then(function(url) {
response.writeSuccess(url);
})
.fail(function(message) {
var err = {
code : 400,... | [
"function",
"url",
"(",
"httpRequest",
",",
"httpResponse",
")",
"{",
"var",
"response",
"=",
"new",
"Response",
"(",
"httpResponse",
")",
";",
"grasshopper",
".",
"googleAuthUrl",
"(",
")",
".",
"then",
"(",
"function",
"(",
"url",
")",
"{",
"response",
... | Method will return a google auth url. | [
"Method",
"will",
"return",
"a",
"google",
"auth",
"url",
"."
] | 05a952b8b65e3a66c8a27f5d84699ee5cf02844d | https://github.com/grasshopper-cms/grasshopper-api-js/blob/05a952b8b65e3a66c8a27f5d84699ee5cf02844d/lib/routes/google.js#L47-L63 | train |
grasshopper-cms/grasshopper-api-js | lib/routes/token.js | parseHeader | function parseHeader(authHeader, callback){
try {
var parts=authHeader.split(/:/),
username=parts[0],
password=parts[1];
callback(null, {username: username, password: password});
}
catch(ex){
callback(ex);
}
} | javascript | function parseHeader(authHeader, callback){
try {
var parts=authHeader.split(/:/),
username=parts[0],
password=parts[1];
callback(null, {username: username, password: password});
}
catch(ex){
callback(ex);
}
} | [
"function",
"parseHeader",
"(",
"authHeader",
",",
"callback",
")",
"{",
"try",
"{",
"var",
"parts",
"=",
"authHeader",
".",
"split",
"(",
"/",
":",
"/",
")",
",",
"username",
"=",
"parts",
"[",
"0",
"]",
",",
"password",
"=",
"parts",
"[",
"1",
"]... | Method will pull out the username and password out of the auth header.
@param authHeader String found in the HTTP authentication header.
@param callback | [
"Method",
"will",
"pull",
"out",
"the",
"username",
"and",
"password",
"out",
"of",
"the",
"auth",
"header",
"."
] | 05a952b8b65e3a66c8a27f5d84699ee5cf02844d | https://github.com/grasshopper-cms/grasshopper-api-js/blob/05a952b8b65e3a66c8a27f5d84699ee5cf02844d/lib/routes/token.js#L19-L30 | train |
newrelic/yakaa | https.js | createConnection | function createConnection(port, host, options) {
if (isObject(port)) {
options = port;
}
else if (isObject(host)) {
options = host;
}
else if (isObject(options)) {
options = options;
}
else {
options = {};
}
if (isNumber(port)) {
options.port = port;
}
if (isString(host)) {
... | javascript | function createConnection(port, host, options) {
if (isObject(port)) {
options = port;
}
else if (isObject(host)) {
options = host;
}
else if (isObject(options)) {
options = options;
}
else {
options = {};
}
if (isNumber(port)) {
options.port = port;
}
if (isString(host)) {
... | [
"function",
"createConnection",
"(",
"port",
",",
"host",
",",
"options",
")",
"{",
"if",
"(",
"isObject",
"(",
"port",
")",
")",
"{",
"options",
"=",
"port",
";",
"}",
"else",
"if",
"(",
"isObject",
"(",
"host",
")",
")",
"{",
"options",
"=",
"hos... | HTTPS agents. | [
"HTTPS",
"agents",
"."
] | 8574311a6e35da5122eecef145df386eaa4a6d5e | https://github.com/newrelic/yakaa/blob/8574311a6e35da5122eecef145df386eaa4a6d5e/https.js#L43-L67 | train |
BKWLD/vue-balance-text | index.js | bind | function bind(el, _ref) {
var modifiers = _ref.modifiers;
var target;
// Support children's modifier
target = modifiers.children ? Array.from(el.children) : el;
// Add balance text to the element
Vue.nextTick(function () {
return balanceText(target, {
watch: true... | javascript | function bind(el, _ref) {
var modifiers = _ref.modifiers;
var target;
// Support children's modifier
target = modifiers.children ? Array.from(el.children) : el;
// Add balance text to the element
Vue.nextTick(function () {
return balanceText(target, {
watch: true... | [
"function",
"bind",
"(",
"el",
",",
"_ref",
")",
"{",
"var",
"modifiers",
"=",
"_ref",
".",
"modifiers",
";",
"var",
"target",
";",
"// Support children's modifier",
"target",
"=",
"modifiers",
".",
"children",
"?",
"Array",
".",
"from",
"(",
"el",
".",
... | Add balance text to the element | [
"Add",
"balance",
"text",
"to",
"the",
"element"
] | 86e00b5fbef3d38b7d180cd89b98b66757975010 | https://github.com/BKWLD/vue-balance-text/blob/86e00b5fbef3d38b7d180cd89b98b66757975010/index.js#L17-L35 | train |
BKWLD/vue-balance-text | index.js | componentUpdated | function componentUpdated(el, _ref2) {
var modifiers = _ref2.modifiers;
var target;
target = modifiers.children ? Array.from(el.children) : el;
return balanceText(target);
} | javascript | function componentUpdated(el, _ref2) {
var modifiers = _ref2.modifiers;
var target;
target = modifiers.children ? Array.from(el.children) : el;
return balanceText(target);
} | [
"function",
"componentUpdated",
"(",
"el",
",",
"_ref2",
")",
"{",
"var",
"modifiers",
"=",
"_ref2",
".",
"modifiers",
";",
"var",
"target",
";",
"target",
"=",
"modifiers",
".",
"children",
"?",
"Array",
".",
"from",
"(",
"el",
".",
"children",
")",
"... | Update when contents change | [
"Update",
"when",
"contents",
"change"
] | 86e00b5fbef3d38b7d180cd89b98b66757975010 | https://github.com/BKWLD/vue-balance-text/blob/86e00b5fbef3d38b7d180cd89b98b66757975010/index.js#L37-L43 | train |
JakubMrozek/eet | lib/validate.js | date | function date (value) {
if (Object.prototype.toString.call(value) !== '[object Date]' || isNaN(value)) {
throw new Error(`Value '${value}' is not a date object.`)
}
} | javascript | function date (value) {
if (Object.prototype.toString.call(value) !== '[object Date]' || isNaN(value)) {
throw new Error(`Value '${value}' is not a date object.`)
}
} | [
"function",
"date",
"(",
"value",
")",
"{",
"if",
"(",
"Object",
".",
"prototype",
".",
"toString",
".",
"call",
"(",
"value",
")",
"!==",
"'[object Date]'",
"||",
"isNaN",
"(",
"value",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"`",
"${",
"value"... | Validace data. | [
"Validace",
"data",
"."
] | 28a8f0b6743308c705eb0c17e985e0ed065b692e | https://github.com/JakubMrozek/eet/blob/28a8f0b6743308c705eb0c17e985e0ed065b692e/lib/validate.js#L67-L71 | train |
JakubMrozek/eet | lib/validate.js | httpResponse | function httpResponse (response) {
if (!response) {
throw new Error('Unable to parse response.')
}
const errorAttrs = response.Chyba && response.Chyba.attributes
if (errorAttrs) {
throw new Error(`${response.Chyba.$value} (${errorAttrs.kod})`)
}
const body = response.Potvrzeni && response.Potvrzeni.... | javascript | function httpResponse (response) {
if (!response) {
throw new Error('Unable to parse response.')
}
const errorAttrs = response.Chyba && response.Chyba.attributes
if (errorAttrs) {
throw new Error(`${response.Chyba.$value} (${errorAttrs.kod})`)
}
const body = response.Potvrzeni && response.Potvrzeni.... | [
"function",
"httpResponse",
"(",
"response",
")",
"{",
"if",
"(",
"!",
"response",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Unable to parse response.'",
")",
"}",
"const",
"errorAttrs",
"=",
"response",
".",
"Chyba",
"&&",
"response",
".",
"Chyba",
".",
"... | Zpracuje chybnou odpoved. | [
"Zpracuje",
"chybnou",
"odpoved",
"."
] | 28a8f0b6743308c705eb0c17e985e0ed065b692e | https://github.com/JakubMrozek/eet/blob/28a8f0b6743308c705eb0c17e985e0ed065b692e/lib/validate.js#L98-L111 | train |
grasshopper-cms/grasshopper-api-js | lib/routes/social/pinterest.js | _createSocialAccount | function _createSocialAccount(){
return BB
.bind(this)
.then(function() {
return grasshopper.auth('Pinterest', this.params);
})
.then(function(token) {
this.req.session.token = new Buffer(token).toString('base64');
this.req.session.save();
... | javascript | function _createSocialAccount(){
return BB
.bind(this)
.then(function() {
return grasshopper.auth('Pinterest', this.params);
})
.then(function(token) {
this.req.session.token = new Buffer(token).toString('base64');
this.req.session.save();
... | [
"function",
"_createSocialAccount",
"(",
")",
"{",
"return",
"BB",
".",
"bind",
"(",
"this",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"return",
"grasshopper",
".",
"auth",
"(",
"'Pinterest'",
",",
"this",
".",
"params",
")",
";",
"}",
")",
"... | Function that will create a user in our system. the `auth` function will auto-create a user if there is not already one in the system. | [
"Function",
"that",
"will",
"create",
"a",
"user",
"in",
"our",
"system",
".",
"the",
"auth",
"function",
"will",
"auto",
"-",
"create",
"a",
"user",
"if",
"there",
"is",
"not",
"already",
"one",
"in",
"the",
"system",
"."
] | 05a952b8b65e3a66c8a27f5d84699ee5cf02844d | https://github.com/grasshopper-cms/grasshopper-api-js/blob/05a952b8b65e3a66c8a27f5d84699ee5cf02844d/lib/routes/social/pinterest.js#L66-L76 | train |
grasshopper-cms/grasshopper-api-js | lib/routes/social/pinterest.js | _linkSocialAccount | function _linkSocialAccount(){
return BB.bind(this)
.then(_loadUserFromToken)
.then(_getUserSocialDetails)
.then(_linkIdentity)
.catch(function(){
return _createSocialAccount.call(this); // Could not link account. Create one instead.
});
} | javascript | function _linkSocialAccount(){
return BB.bind(this)
.then(_loadUserFromToken)
.then(_getUserSocialDetails)
.then(_linkIdentity)
.catch(function(){
return _createSocialAccount.call(this); // Could not link account. Create one instead.
});
} | [
"function",
"_linkSocialAccount",
"(",
")",
"{",
"return",
"BB",
".",
"bind",
"(",
"this",
")",
".",
"then",
"(",
"_loadUserFromToken",
")",
".",
"then",
"(",
"_getUserSocialDetails",
")",
".",
"then",
"(",
"_linkIdentity",
")",
".",
"catch",
"(",
"functio... | Function will link an existing account loading the current user from their token. We first load the user from token, then link identities. If there is an issue, we try to create the user. | [
"Function",
"will",
"link",
"an",
"existing",
"account",
"loading",
"the",
"current",
"user",
"from",
"their",
"token",
".",
"We",
"first",
"load",
"the",
"user",
"from",
"token",
"then",
"link",
"identities",
".",
"If",
"there",
"is",
"an",
"issue",
"we",... | 05a952b8b65e3a66c8a27f5d84699ee5cf02844d | https://github.com/grasshopper-cms/grasshopper-api-js/blob/05a952b8b65e3a66c8a27f5d84699ee5cf02844d/lib/routes/social/pinterest.js#L81-L90 | train |
grasshopper-cms/grasshopper-api-js | lib/routes/social/pinterest.js | _getUserSocialDetails | function _getUserSocialDetails(){
return BB
.bind(this)
.then(function() {
return pinterest
.query()
.get('me/?fields=id,first_name,last_name,url,username,image&access_token=' + this.params.access_token)
.request();
})
.then... | javascript | function _getUserSocialDetails(){
return BB
.bind(this)
.then(function() {
return pinterest
.query()
.get('me/?fields=id,first_name,last_name,url,username,image&access_token=' + this.params.access_token)
.request();
})
.then... | [
"function",
"_getUserSocialDetails",
"(",
")",
"{",
"return",
"BB",
".",
"bind",
"(",
"this",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"return",
"pinterest",
".",
"query",
"(",
")",
".",
"get",
"(",
"'me/?fields=id,first_name,last_name,url,username,im... | Pinterest doesn't return any user info back with login. So go get some basic info so we can link the account. | [
"Pinterest",
"doesn",
"t",
"return",
"any",
"user",
"info",
"back",
"with",
"login",
".",
"So",
"go",
"get",
"some",
"basic",
"info",
"so",
"we",
"can",
"link",
"the",
"account",
"."
] | 05a952b8b65e3a66c8a27f5d84699ee5cf02844d | https://github.com/grasshopper-cms/grasshopper-api-js/blob/05a952b8b65e3a66c8a27f5d84699ee5cf02844d/lib/routes/social/pinterest.js#L105-L117 | train |
grasshopper-cms/grasshopper-api-js | lib/routes/social/pinterest.js | _linkIdentity | function _linkIdentity() {
var identityOptions = {
id: this.socialUserInfo.id,
accessToken: this.params.access_token,
screen_name: this.socialUserInfo.username
};
return BB.resolve(grasshopper.request(this.token).users.linkIdentity(this.user._id.toString(), 'pinteres... | javascript | function _linkIdentity() {
var identityOptions = {
id: this.socialUserInfo.id,
accessToken: this.params.access_token,
screen_name: this.socialUserInfo.username
};
return BB.resolve(grasshopper.request(this.token).users.linkIdentity(this.user._id.toString(), 'pinteres... | [
"function",
"_linkIdentity",
"(",
")",
"{",
"var",
"identityOptions",
"=",
"{",
"id",
":",
"this",
".",
"socialUserInfo",
".",
"id",
",",
"accessToken",
":",
"this",
".",
"params",
".",
"access_token",
",",
"screen_name",
":",
"this",
".",
"socialUserInfo",
... | Utility function to link a user's pinterest info to the current user. | [
"Utility",
"function",
"to",
"link",
"a",
"user",
"s",
"pinterest",
"info",
"to",
"the",
"current",
"user",
"."
] | 05a952b8b65e3a66c8a27f5d84699ee5cf02844d | https://github.com/grasshopper-cms/grasshopper-api-js/blob/05a952b8b65e3a66c8a27f5d84699ee5cf02844d/lib/routes/social/pinterest.js#L120-L128 | train |
wmfs/tymly-core | lib/boot/refs/first-pass/index.js | firstPass | function firstPass (loadedComponents, messages) {
messages.heading('Reference resolution - first pass')
const components = loadedComponents.blueprintComponents
const tymlyRefs = loadedComponents.blueprintRefs
const resolutions = findFirstPassResolutions(tymlyRefs, components)
if (!resolutions) {
messag... | javascript | function firstPass (loadedComponents, messages) {
messages.heading('Reference resolution - first pass')
const components = loadedComponents.blueprintComponents
const tymlyRefs = loadedComponents.blueprintRefs
const resolutions = findFirstPassResolutions(tymlyRefs, components)
if (!resolutions) {
messag... | [
"function",
"firstPass",
"(",
"loadedComponents",
",",
"messages",
")",
"{",
"messages",
".",
"heading",
"(",
"'Reference resolution - first pass'",
")",
"const",
"components",
"=",
"loadedComponents",
".",
"blueprintComponents",
"const",
"tymlyRefs",
"=",
"loadedCompon... | First pass through the references. None of the services have yet been booted, but we can resolve static references | [
"First",
"pass",
"through",
"the",
"references",
".",
"None",
"of",
"the",
"services",
"have",
"yet",
"been",
"booted",
"but",
"we",
"can",
"resolve",
"static",
"references"
] | 7f05f7b8c2a1c09b03bb4a6ac34013ff4c9edfee | https://github.com/wmfs/tymly-core/blob/7f05f7b8c2a1c09b03bb4a6ac34013ff4c9edfee/lib/boot/refs/first-pass/index.js#L6-L20 | train |
benjamn/arson | index.js | getArrayOfHoles | function getArrayOfHoles(length) {
var holyLen = HOLY_ARRAY.length;
if (length > holyLen) {
HOLY_ARRAY.length = length;
for (var i = holyLen; i < length; ++i) {
HOLY_ARRAY[i] = ARRAY_HOLE_INDEX;
}
}
return HOLY_ARRAY.slice(0, length);
} | javascript | function getArrayOfHoles(length) {
var holyLen = HOLY_ARRAY.length;
if (length > holyLen) {
HOLY_ARRAY.length = length;
for (var i = holyLen; i < length; ++i) {
HOLY_ARRAY[i] = ARRAY_HOLE_INDEX;
}
}
return HOLY_ARRAY.slice(0, length);
} | [
"function",
"getArrayOfHoles",
"(",
"length",
")",
"{",
"var",
"holyLen",
"=",
"HOLY_ARRAY",
".",
"length",
";",
"if",
"(",
"length",
">",
"holyLen",
")",
"{",
"HOLY_ARRAY",
".",
"length",
"=",
"length",
";",
"for",
"(",
"var",
"i",
"=",
"holyLen",
";"... | Returns an array of the given length filled with ARRAY_HOLE_INDEX. | [
"Returns",
"an",
"array",
"of",
"the",
"given",
"length",
"filled",
"with",
"ARRAY_HOLE_INDEX",
"."
] | aeee18764c9901759762d2f011589caea9e768e1 | https://github.com/benjamn/arson/blob/aeee18764c9901759762d2f011589caea9e768e1/index.js#L39-L49 | train |
canjs/can-construct | can-construct.js | function (what, oldProps, propName, val) {
Object.defineProperty(what, propName, {value: val, configurable: true, enumerable: true, writable: true});
} | javascript | function (what, oldProps, propName, val) {
Object.defineProperty(what, propName, {value: val, configurable: true, enumerable: true, writable: true});
} | [
"function",
"(",
"what",
",",
"oldProps",
",",
"propName",
",",
"val",
")",
"{",
"Object",
".",
"defineProperty",
"(",
"what",
",",
"propName",
",",
"{",
"value",
":",
"val",
",",
"configurable",
":",
"true",
",",
"enumerable",
":",
"true",
",",
"writa... | used for overwriting a single property. this should be used for patching other objects the super plugin overwrites this | [
"used",
"for",
"overwriting",
"a",
"single",
"property",
".",
"this",
"should",
"be",
"used",
"for",
"patching",
"other",
"objects",
"the",
"super",
"plugin",
"overwrites",
"this"
] | 0c64cc2ccf917d705070d51416ac8cd1bda35259 | https://github.com/canjs/can-construct/blob/0c64cc2ccf917d705070d51416ac8cd1bda35259/can-construct.js#L334-L336 | train | |
canjs/can-construct | can-construct.js | init | function init() {
/* jshint validthis: true */
// All construction is actually done in the init method.
if (!initializing) {
//!steal-remove-start
if(process.env.NODE_ENV !== 'production') {
if(!this || (this.constructor !== Constructor) &&
// We are being called without `new` or we are exten... | javascript | function init() {
/* jshint validthis: true */
// All construction is actually done in the init method.
if (!initializing) {
//!steal-remove-start
if(process.env.NODE_ENV !== 'production') {
if(!this || (this.constructor !== Constructor) &&
// We are being called without `new` or we are exten... | [
"function",
"init",
"(",
")",
"{",
"/* jshint validthis: true */",
"// All construction is actually done in the init method.",
"if",
"(",
"!",
"initializing",
")",
"{",
"//!steal-remove-start",
"if",
"(",
"process",
".",
"env",
".",
"NODE_ENV",
"!==",
"'production'",
")... | !steal-remove-end The dummy class constructor. | [
"!steal",
"-",
"remove",
"-",
"end",
"The",
"dummy",
"class",
"constructor",
"."
] | 0c64cc2ccf917d705070d51416ac8cd1bda35259 | https://github.com/canjs/can-construct/blob/0c64cc2ccf917d705070d51416ac8cd1bda35259/can-construct.js#L642-L662 | train |
grasshopper-cms/grasshopper-core-nodejs | lib/event/filter.js | findMatch | function findMatch(filters, listener){
var handlers = [],
isMatch = true;
if( !_.isUndefined(listener.filters.nodes) && listener.filters.nodes.length > 0 ) {
isMatch = !_.isUndefined( _.find( listener.filters.nodes , function(node) {
return (node === filters.node... | javascript | function findMatch(filters, listener){
var handlers = [],
isMatch = true;
if( !_.isUndefined(listener.filters.nodes) && listener.filters.nodes.length > 0 ) {
isMatch = !_.isUndefined( _.find( listener.filters.nodes , function(node) {
return (node === filters.node... | [
"function",
"findMatch",
"(",
"filters",
",",
"listener",
")",
"{",
"var",
"handlers",
"=",
"[",
"]",
",",
"isMatch",
"=",
"true",
";",
"if",
"(",
"!",
"_",
".",
"isUndefined",
"(",
"listener",
".",
"filters",
".",
"nodes",
")",
"&&",
"listener",
"."... | Function will look at the filters that have been passed in to the module through an
emit call and compair them to the filters that are attached to all of the listeners.
If there are matches the function will return an array of event handlers that
match the criteria.
@param filters - Event filters that are passed in th... | [
"Function",
"will",
"look",
"at",
"the",
"filters",
"that",
"have",
"been",
"passed",
"in",
"to",
"the",
"module",
"through",
"an",
"emit",
"call",
"and",
"compair",
"them",
"to",
"the",
"filters",
"that",
"are",
"attached",
"to",
"all",
"of",
"the",
"li... | 8fabc3bfc5b18855ead443db0644608a277d0ea0 | https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/lib/event/filter.js#L17-L51 | train |
grasshopper-cms/grasshopper-core-nodejs | lib/event/filter.js | filterListeners | function filterListeners (listenerCollection) {
return function(filters) {
var handlers = [];
_.each(listenerCollection, function(listener){
handlers = handlers.concat( findMatch(filters, listener) );
});
return handlers;
};
} | javascript | function filterListeners (listenerCollection) {
return function(filters) {
var handlers = [];
_.each(listenerCollection, function(listener){
handlers = handlers.concat( findMatch(filters, listener) );
});
return handlers;
};
} | [
"function",
"filterListeners",
"(",
"listenerCollection",
")",
"{",
"return",
"function",
"(",
"filters",
")",
"{",
"var",
"handlers",
"=",
"[",
"]",
";",
"_",
".",
"each",
"(",
"listenerCollection",
",",
"function",
"(",
"listener",
")",
"{",
"handlers",
... | Function that accepts a collection of listeners and inspects each one to determine
if their handler should be called.
@param listenerCollection
@returns {Function} | [
"Function",
"that",
"accepts",
"a",
"collection",
"of",
"listeners",
"and",
"inspects",
"each",
"one",
"to",
"determine",
"if",
"their",
"handler",
"should",
"be",
"called",
"."
] | 8fabc3bfc5b18855ead443db0644608a277d0ea0 | https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/lib/event/filter.js#L60-L70 | train |
casetext/fireproof | lib/demux.js | Demux | function Demux(refs, limit) {
if (!(this instanceof Fireproof.Demux)) {
return new Fireproof.Demux(refs);
} else if (arguments.length > 1 && !Array.isArray(refs)) {
refs = Array.prototype.slice.call(arguments, 0);
}
this._limit = (limit !== undefined ? limit : true);
this._refs = refs;
this._posit... | javascript | function Demux(refs, limit) {
if (!(this instanceof Fireproof.Demux)) {
return new Fireproof.Demux(refs);
} else if (arguments.length > 1 && !Array.isArray(refs)) {
refs = Array.prototype.slice.call(arguments, 0);
}
this._limit = (limit !== undefined ? limit : true);
this._refs = refs;
this._posit... | [
"function",
"Demux",
"(",
"refs",
",",
"limit",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Fireproof",
".",
"Demux",
")",
")",
"{",
"return",
"new",
"Fireproof",
".",
"Demux",
"(",
"refs",
")",
";",
"}",
"else",
"if",
"(",
"arguments",
"... | A helper object for retrieving sorted Firebase objects from multiple
locations.
@constructor Fireproof.Demux
@static
@param {Array} refs a list of Fireproof object references to draw from.
@param {boolean} [limitToFirst] Whether to use "limitToFirst" to restrict the length
of queries to Firebase. True by default. Set t... | [
"A",
"helper",
"object",
"for",
"retrieving",
"sorted",
"Firebase",
"objects",
"from",
"multiple",
"locations",
"."
] | a568157310d965d2c115e5a3c9e8287fc8fe021b | https://github.com/casetext/fireproof/blob/a568157310d965d2c115e5a3c9e8287fc8fe021b/lib/demux.js#L12-L38 | train |
reddit/node-build | lib/uploadToSentry.js | createRelease | function createRelease(endpoint, version) {
return new Promise(function(resolve, reject) {
superagent
.post(endpoint)
.set(HEADERS)
.send({ version: version })
.end(function(err, res) {
if (!err) {
console.log('Sentry - Pushed release. Version: ' + version);
res... | javascript | function createRelease(endpoint, version) {
return new Promise(function(resolve, reject) {
superagent
.post(endpoint)
.set(HEADERS)
.send({ version: version })
.end(function(err, res) {
if (!err) {
console.log('Sentry - Pushed release. Version: ' + version);
res... | [
"function",
"createRelease",
"(",
"endpoint",
",",
"version",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"superagent",
".",
"post",
"(",
"endpoint",
")",
".",
"set",
"(",
"HEADERS",
")",
".",
"send",
... | Creates a Sentry release, a versioned collection of compiled js and their
sourcemaps.
@param {String} endpoint
The endpoint this release is being pushed to
@param {String} version
The version for this release | [
"Creates",
"a",
"Sentry",
"release",
"a",
"versioned",
"collection",
"of",
"compiled",
"js",
"and",
"their",
"sourcemaps",
"."
] | af30dc8c637631b177ae33a1984a44ffa839914b | https://github.com/reddit/node-build/blob/af30dc8c637631b177ae33a1984a44ffa839914b/lib/uploadToSentry.js#L20-L35 | train |
reddit/node-build | lib/uploadToSentry.js | uploadFile | function uploadFile(endpoint, releaseVersion, filePath) {
// sentry lets you use the tilde to indicate it just looks at relative locations
// instead of relying on the host/domain.
var IGNORE_DOMAIN = '~';
var staticBase = process.env.STATIC_BASE;
var IGNORE_PATH = staticBase ? url.parse(staticBase).path + '/... | javascript | function uploadFile(endpoint, releaseVersion, filePath) {
// sentry lets you use the tilde to indicate it just looks at relative locations
// instead of relying on the host/domain.
var IGNORE_DOMAIN = '~';
var staticBase = process.env.STATIC_BASE;
var IGNORE_PATH = staticBase ? url.parse(staticBase).path + '/... | [
"function",
"uploadFile",
"(",
"endpoint",
",",
"releaseVersion",
",",
"filePath",
")",
"{",
"// sentry lets you use the tilde to indicate it just looks at relative locations",
"// instead of relying on the host/domain.",
"var",
"IGNORE_DOMAIN",
"=",
"'~'",
";",
"var",
"staticBas... | Uploads a single file to a selected release.
@param {String} endpoint
The endpoint to push these files to
@param {String} releaseVersion
The release version for this file
@param {String} filePath
The absolute file path for the file we want to upload to the release | [
"Uploads",
"a",
"single",
"file",
"to",
"a",
"selected",
"release",
"."
] | af30dc8c637631b177ae33a1984a44ffa839914b | https://github.com/reddit/node-build/blob/af30dc8c637631b177ae33a1984a44ffa839914b/lib/uploadToSentry.js#L46-L78 | train |
reddit/node-build | lib/uploadToSentry.js | uploadToSentry | function uploadToSentry(projectSlug, orgSlug, releaseVersion, assets) {
var releaseEndpoint = makeUrl(projectSlug, orgSlug);
var uploadEndpoint = releaseEndpoint + releaseVersion + '/files/';
createRelease(releaseEndpoint, releaseVersion)
.then(function() {
return Promise.all(assets.map(uploadFile.bind... | javascript | function uploadToSentry(projectSlug, orgSlug, releaseVersion, assets) {
var releaseEndpoint = makeUrl(projectSlug, orgSlug);
var uploadEndpoint = releaseEndpoint + releaseVersion + '/files/';
createRelease(releaseEndpoint, releaseVersion)
.then(function() {
return Promise.all(assets.map(uploadFile.bind... | [
"function",
"uploadToSentry",
"(",
"projectSlug",
",",
"orgSlug",
",",
"releaseVersion",
",",
"assets",
")",
"{",
"var",
"releaseEndpoint",
"=",
"makeUrl",
"(",
"projectSlug",
",",
"orgSlug",
")",
";",
"var",
"uploadEndpoint",
"=",
"releaseEndpoint",
"+",
"relea... | Creates a Sentry release and pushes the relevant assets to that release.
@param {String} projectName
The Sentry project this release belongs to
@param {String} releaseVersion
The release version for the js assets
@param {Array} assets
An array of filepaths to the assets that will be uploaded | [
"Creates",
"a",
"Sentry",
"release",
"and",
"pushes",
"the",
"relevant",
"assets",
"to",
"that",
"release",
"."
] | af30dc8c637631b177ae33a1984a44ffa839914b | https://github.com/reddit/node-build/blob/af30dc8c637631b177ae33a1984a44ffa839914b/lib/uploadToSentry.js#L89-L103 | train |
gilt/swig | packages/swig-cli/index.js | tell | function tell(name, taskInfo) {
if (swig.tasks[name]) {
console.log(`Task '${name}' has been overridden by a local installation`.yellow);
}
swig.tasks[name] = _.extend({
description: '<unknown>',
flags: {},
}, taskInfo);
} | javascript | function tell(name, taskInfo) {
if (swig.tasks[name]) {
console.log(`Task '${name}' has been overridden by a local installation`.yellow);
}
swig.tasks[name] = _.extend({
description: '<unknown>',
flags: {},
}, taskInfo);
} | [
"function",
"tell",
"(",
"name",
",",
"taskInfo",
")",
"{",
"if",
"(",
"swig",
".",
"tasks",
"[",
"name",
"]",
")",
"{",
"console",
".",
"log",
"(",
"`",
"${",
"name",
"}",
"`",
".",
"yellow",
")",
";",
"}",
"swig",
".",
"tasks",
"[",
"name",
... | allows a task to tell swig about itself | [
"allows",
"a",
"task",
"to",
"tell",
"swig",
"about",
"itself"
] | 499e83d60dea7208640549056d99988b29177980 | https://github.com/gilt/swig/blob/499e83d60dea7208640549056d99988b29177980/packages/swig-cli/index.js#L170-L179 | train |
acss-io/gulp-atomizer | index.js | function (file, unused, cb) {
if (file.isNull()) {
// nothing to do
return cb(null, file)
} else if (file.isStream()) {
// file.contents is a Stream. We don't support streams
this.emit('error', new PluginError(PLUGIN_NAME, 'Streams not supported!'))
} else if (file.isBuffer()) {
... | javascript | function (file, unused, cb) {
if (file.isNull()) {
// nothing to do
return cb(null, file)
} else if (file.isStream()) {
// file.contents is a Stream. We don't support streams
this.emit('error', new PluginError(PLUGIN_NAME, 'Streams not supported!'))
} else if (file.isBuffer()) {
... | [
"function",
"(",
"file",
",",
"unused",
",",
"cb",
")",
"{",
"if",
"(",
"file",
".",
"isNull",
"(",
")",
")",
"{",
"// nothing to do",
"return",
"cb",
"(",
"null",
",",
"file",
")",
"}",
"else",
"if",
"(",
"file",
".",
"isStream",
"(",
")",
")",
... | create the file handler | [
"create",
"the",
"file",
"handler"
] | 8a0e4aca88ea4d8cb701b7323fa6164887f97503 | https://github.com/acss-io/gulp-atomizer/blob/8a0e4aca88ea4d8cb701b7323fa6164887f97503/index.js#L36-L67 | train | |
senecajs/seneca-mem-store | mem-store.js | do_save | function do_save(id, isnew) {
var mement = ent.data$(true, 'string')
if (undefined !== id) {
mement.id = id
}
mement.entity$ = ent.entity$
entmap[base] = entmap[base] || {}
entmap[base][name] = entmap[base][name] || {}
var prev = entmap[base][name][m... | javascript | function do_save(id, isnew) {
var mement = ent.data$(true, 'string')
if (undefined !== id) {
mement.id = id
}
mement.entity$ = ent.entity$
entmap[base] = entmap[base] || {}
entmap[base][name] = entmap[base][name] || {}
var prev = entmap[base][name][m... | [
"function",
"do_save",
"(",
"id",
",",
"isnew",
")",
"{",
"var",
"mement",
"=",
"ent",
".",
"data$",
"(",
"true",
",",
"'string'",
")",
"if",
"(",
"undefined",
"!==",
"id",
")",
"{",
"mement",
".",
"id",
"=",
"id",
"}",
"mement",
".",
"entity$",
... | The actual save logic for saving or creating and then saving the entity. | [
"The",
"actual",
"save",
"logic",
"for",
"saving",
"or",
"creating",
"and",
"then",
"saving",
"the",
"entity",
"."
] | 46a25e9fe75f85a31dc6c052f4807eaf4745fdbb | https://github.com/senecajs/seneca-mem-store/blob/46a25e9fe75f85a31dc6c052f4807eaf4745fdbb/mem-store.js#L82-L123 | train |
senecajs/seneca-mem-store | mem-store.js | create_new | function create_new() {
var id
// Check if we already have an id or if
// we need to generate a new one.
if (undefined !== ent.id$) {
// Take a copy of the existing id and
// delete it from the ent object. Do
// save will handle the id for us.
id ... | javascript | function create_new() {
var id
// Check if we already have an id or if
// we need to generate a new one.
if (undefined !== ent.id$) {
// Take a copy of the existing id and
// delete it from the ent object. Do
// save will handle the id for us.
id ... | [
"function",
"create_new",
"(",
")",
"{",
"var",
"id",
"// Check if we already have an id or if",
"// we need to generate a new one.",
"if",
"(",
"undefined",
"!==",
"ent",
".",
"id$",
")",
"{",
"// Take a copy of the existing id and",
"// delete it from the ent object. Do",
"... | We will still use do_save to save the entity but we need a place to handle new entites and id concerns. | [
"We",
"will",
"still",
"use",
"do_save",
"to",
"save",
"the",
"entity",
"but",
"we",
"need",
"a",
"place",
"to",
"handle",
"new",
"entites",
"and",
"id",
"concerns",
"."
] | 46a25e9fe75f85a31dc6c052f4807eaf4745fdbb | https://github.com/senecajs/seneca-mem-store/blob/46a25e9fe75f85a31dc6c052f4807eaf4745fdbb/mem-store.js#L127-L165 | train |
senecajs/seneca-mem-store | mem-store.js | listents | function listents(seneca, entmap, qent, q, done) {
var list = []
var canon = qent.canon$({ object: true })
var base = canon.base
var name = canon.name
var entset = entmap[base] ? entmap[base][name] : null
if (entset) {
if (_.isString(q)) {
var ent = entset[q]
if (ent) {
list.push(... | javascript | function listents(seneca, entmap, qent, q, done) {
var list = []
var canon = qent.canon$({ object: true })
var base = canon.base
var name = canon.name
var entset = entmap[base] ? entmap[base][name] : null
if (entset) {
if (_.isString(q)) {
var ent = entset[q]
if (ent) {
list.push(... | [
"function",
"listents",
"(",
"seneca",
",",
"entmap",
",",
"qent",
",",
"q",
",",
"done",
")",
"{",
"var",
"list",
"=",
"[",
"]",
"var",
"canon",
"=",
"qent",
".",
"canon$",
"(",
"{",
"object",
":",
"true",
"}",
")",
"var",
"base",
"=",
"canon",
... | Seneca supports a reasonable set of features in terms of listing. This function can handle sorting, skiping, limiting and general retrieval. | [
"Seneca",
"supports",
"a",
"reasonable",
"set",
"of",
"features",
"in",
"terms",
"of",
"listing",
".",
"This",
"function",
"can",
"handle",
"sorting",
"skiping",
"limiting",
"and",
"general",
"retrieval",
"."
] | 46a25e9fe75f85a31dc6c052f4807eaf4745fdbb | https://github.com/senecajs/seneca-mem-store/blob/46a25e9fe75f85a31dc6c052f4807eaf4745fdbb/mem-store.js#L329-L404 | train |
grasshopper-cms/grasshopper-core-nodejs | lib/middleware/content/validate.js | validateContentType | function validateContentType(cb) {
if (!_.isUndefined(kontx.args.meta) && !_.isUndefined(kontx.args.meta.type)) {
db.contentTypes.getById(kontx.args.meta.type.toString()).then(
function(contentType) {
cb(null, contentType);
},
funct... | javascript | function validateContentType(cb) {
if (!_.isUndefined(kontx.args.meta) && !_.isUndefined(kontx.args.meta.type)) {
db.contentTypes.getById(kontx.args.meta.type.toString()).then(
function(contentType) {
cb(null, contentType);
},
funct... | [
"function",
"validateContentType",
"(",
"cb",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isUndefined",
"(",
"kontx",
".",
"args",
".",
"meta",
")",
"&&",
"!",
"_",
".",
"isUndefined",
"(",
"kontx",
".",
"args",
".",
"meta",
".",
"type",
")",
")",
"{",
... | Function will test to see if the content type is in the system. | [
"Function",
"will",
"test",
"to",
"see",
"if",
"the",
"content",
"type",
"is",
"in",
"the",
"system",
"."
] | 8fabc3bfc5b18855ead443db0644608a277d0ea0 | https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/lib/middleware/content/validate.js#L27-L40 | train |
grasshopper-cms/grasshopper-core-nodejs | lib/middleware/content/validate.js | validateFields | function validateFields(contentType, cb) {
if (_.isArray(contentType.fields)) {
async.each(contentType.fields, validateField, function(err) {
cb(err);
});
} else {
cb();
}
} | javascript | function validateFields(contentType, cb) {
if (_.isArray(contentType.fields)) {
async.each(contentType.fields, validateField, function(err) {
cb(err);
});
} else {
cb();
}
} | [
"function",
"validateFields",
"(",
"contentType",
",",
"cb",
")",
"{",
"if",
"(",
"_",
".",
"isArray",
"(",
"contentType",
".",
"fields",
")",
")",
"{",
"async",
".",
"each",
"(",
"contentType",
".",
"fields",
",",
"validateField",
",",
"function",
"(",
... | Function will iterate all the fields in the content type and check the validation rules for each one. | [
"Function",
"will",
"iterate",
"all",
"the",
"fields",
"in",
"the",
"content",
"type",
"and",
"check",
"the",
"validation",
"rules",
"for",
"each",
"one",
"."
] | 8fabc3bfc5b18855ead443db0644608a277d0ea0 | https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/lib/middleware/content/validate.js#L43-L51 | train |
grasshopper-cms/grasshopper-core-nodejs | lib/middleware/content/validate.js | validateField | function validateField(field, cb) {
if (_.isArray(field.validation)) {
async.each(field.validation, performValidation(field), function(err) {
cb(err);
});
} else {
cb();
}
} | javascript | function validateField(field, cb) {
if (_.isArray(field.validation)) {
async.each(field.validation, performValidation(field), function(err) {
cb(err);
});
} else {
cb();
}
} | [
"function",
"validateField",
"(",
"field",
",",
"cb",
")",
"{",
"if",
"(",
"_",
".",
"isArray",
"(",
"field",
".",
"validation",
")",
")",
"{",
"async",
".",
"each",
"(",
"field",
".",
"validation",
",",
"performValidation",
"(",
"field",
")",
",",
"... | Function will iterate all of the validation rules for a specific field and perform the validation rule. | [
"Function",
"will",
"iterate",
"all",
"of",
"the",
"validation",
"rules",
"for",
"a",
"specific",
"field",
"and",
"perform",
"the",
"validation",
"rule",
"."
] | 8fabc3bfc5b18855ead443db0644608a277d0ea0 | https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/lib/middleware/content/validate.js#L54-L62 | train |
grasshopper-cms/grasshopper-core-nodejs | lib/middleware/content/validate.js | performValidation | function performValidation(field) {
return function(rule, cb) {
var valueToBeValidated = kontx.args.fields[field._id],
validate = validator.get(rule);
//Undefined values do not need to be validated unless the field is required
if (rule.type === 'required' || ... | javascript | function performValidation(field) {
return function(rule, cb) {
var valueToBeValidated = kontx.args.fields[field._id],
validate = validator.get(rule);
//Undefined values do not need to be validated unless the field is required
if (rule.type === 'required' || ... | [
"function",
"performValidation",
"(",
"field",
")",
"{",
"return",
"function",
"(",
"rule",
",",
"cb",
")",
"{",
"var",
"valueToBeValidated",
"=",
"kontx",
".",
"args",
".",
"fields",
"[",
"field",
".",
"_id",
"]",
",",
"validate",
"=",
"validator",
".",... | Function actually tests the field for a specific validation rule. | [
"Function",
"actually",
"tests",
"the",
"field",
"for",
"a",
"specific",
"validation",
"rule",
"."
] | 8fabc3bfc5b18855ead443db0644608a277d0ea0 | https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/lib/middleware/content/validate.js#L65-L105 | train |
grasshopper-cms/grasshopper-core-nodejs | lib/security/providers/facebook.js | _getPersistantFacebookToken | function _getPersistantFacebookToken(){
return facebook.query()
.get('/oauth/access_token?' +
'grant_type=fb_exchange_token&' +
'client_id=' + appId + '&' +
'client_secret=' + secret + '&' +
'fb_exchange_token=' + this.options.code)
... | javascript | function _getPersistantFacebookToken(){
return facebook.query()
.get('/oauth/access_token?' +
'grant_type=fb_exchange_token&' +
'client_id=' + appId + '&' +
'client_secret=' + secret + '&' +
'fb_exchange_token=' + this.options.code)
... | [
"function",
"_getPersistantFacebookToken",
"(",
")",
"{",
"return",
"facebook",
".",
"query",
"(",
")",
".",
"get",
"(",
"'/oauth/access_token?'",
"+",
"'grant_type=fb_exchange_token&'",
"+",
"'client_id='",
"+",
"appId",
"+",
"'&'",
"+",
"'client_secret='",
"+",
... | Function will accept the passed in authentication token from FB and exchange it for a permenant token. This token will be saved to the user's identities profile. | [
"Function",
"will",
"accept",
"the",
"passed",
"in",
"authentication",
"token",
"from",
"FB",
"and",
"exchange",
"it",
"for",
"a",
"permenant",
"token",
".",
"This",
"token",
"will",
"be",
"saved",
"to",
"the",
"user",
"s",
"identities",
"profile",
"."
] | 8fabc3bfc5b18855ead443db0644608a277d0ea0 | https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/lib/security/providers/facebook.js#L39-L55 | train |
grasshopper-cms/grasshopper-core-nodejs | lib/security/providers/facebook.js | _createNewFacebookUser | function _createNewFacebookUser() {
var avatar = '',
excludedFields = ['link', 'email', 'first_name', 'last_name','picture'],
newUser;
//Set Image
if(this.socialUserInfo.picture && this.socialUserInfo.picture.data && this.socialUserInfo.picture.data.url !== ''){
avatar = this.social... | javascript | function _createNewFacebookUser() {
var avatar = '',
excludedFields = ['link', 'email', 'first_name', 'last_name','picture'],
newUser;
//Set Image
if(this.socialUserInfo.picture && this.socialUserInfo.picture.data && this.socialUserInfo.picture.data.url !== ''){
avatar = this.social... | [
"function",
"_createNewFacebookUser",
"(",
")",
"{",
"var",
"avatar",
"=",
"''",
",",
"excludedFields",
"=",
"[",
"'link'",
",",
"'email'",
",",
"'first_name'",
",",
"'last_name'",
",",
"'picture'",
"]",
",",
"newUser",
";",
"//Set Image",
"if",
"(",
"this",... | Function that takes the facebook social data and attaches it to a user in grasshopper | [
"Function",
"that",
"takes",
"the",
"facebook",
"social",
"data",
"and",
"attaches",
"it",
"to",
"a",
"user",
"in",
"grasshopper"
] | 8fabc3bfc5b18855ead443db0644608a277d0ea0 | https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/lib/security/providers/facebook.js#L97-L133 | train |
grasshopper-cms/grasshopper-core-nodejs | lib/security/providers/facebook.js | _createNewToken | function _createNewToken() {
var token = uuid.v4(),
newTokenObj = {
_id: crypto.createHash(token, config.crypto.secret_passphrase),
uid: this.userInfo._id.toString(),
created: new Date().toISOString(),
type: 'facebook'
};
return db.tokens.insert(n... | javascript | function _createNewToken() {
var token = uuid.v4(),
newTokenObj = {
_id: crypto.createHash(token, config.crypto.secret_passphrase),
uid: this.userInfo._id.toString(),
created: new Date().toISOString(),
type: 'facebook'
};
return db.tokens.insert(n... | [
"function",
"_createNewToken",
"(",
")",
"{",
"var",
"token",
"=",
"uuid",
".",
"v4",
"(",
")",
",",
"newTokenObj",
"=",
"{",
"_id",
":",
"crypto",
".",
"createHash",
"(",
"token",
",",
"config",
".",
"crypto",
".",
"secret_passphrase",
")",
",",
"uid"... | Function will create a new access token in grasshopper and return it to the app | [
"Function",
"will",
"create",
"a",
"new",
"access",
"token",
"in",
"grasshopper",
"and",
"return",
"it",
"to",
"the",
"app"
] | 8fabc3bfc5b18855ead443db0644608a277d0ea0 | https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/lib/security/providers/facebook.js#L149-L159 | train |
aureooms/js-itertools | lib/reduce/some.js | some | function some(iterable, n) {
if (n <= 0) return true;
for (let item of iterable) {
if (item && --n === 0) return true;
}
return false;
} | javascript | function some(iterable, n) {
if (n <= 0) return true;
for (let item of iterable) {
if (item && --n === 0) return true;
}
return false;
} | [
"function",
"some",
"(",
"iterable",
",",
"n",
")",
"{",
"if",
"(",
"n",
"<=",
"0",
")",
"return",
"true",
";",
"for",
"(",
"let",
"item",
"of",
"iterable",
")",
"{",
"if",
"(",
"item",
"&&",
"--",
"n",
"===",
"0",
")",
"return",
"true",
";",
... | Returns true if at least some of the elements of the input iterable are
truthy.
@example
some( repeat( true ) , 100 ) ; // returns true
@example
some( repeat( false ) , 0 ) ; // returns true
@example
some( repeat( false ) , 10 ) ; // loops forever
@example
some( nrepeat( true , 10 ) , 11 ) ; // returns false
@para... | [
"Returns",
"true",
"if",
"at",
"least",
"some",
"of",
"the",
"elements",
"of",
"the",
"input",
"iterable",
"are",
"truthy",
"."
] | 72bafa5f3f957ceb37bdfa87a222364fe4974be3 | https://github.com/aureooms/js-itertools/blob/72bafa5f3f957ceb37bdfa87a222364fe4974be3/lib/reduce/some.js#L30-L40 | train |
grasshopper-cms/grasshopper-core-nodejs | lib/runners/users.js | roleOrSelf | function roleOrSelf (role) {
if (!_.isNumber(role)) {
role = roles[role.toUpperCase()];
}
return function validateRoleOrSelf (kontx, next) {
var userPrivLevel = roles[kontx.user.role.toUpperCase()],
passedInUserId = kontx.args[0],
err = cr... | javascript | function roleOrSelf (role) {
if (!_.isNumber(role)) {
role = roles[role.toUpperCase()];
}
return function validateRoleOrSelf (kontx, next) {
var userPrivLevel = roles[kontx.user.role.toUpperCase()],
passedInUserId = kontx.args[0],
err = cr... | [
"function",
"roleOrSelf",
"(",
"role",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isNumber",
"(",
"role",
")",
")",
"{",
"role",
"=",
"roles",
"[",
"role",
".",
"toUpperCase",
"(",
")",
"]",
";",
"}",
"return",
"function",
"validateRoleOrSelf",
"(",
"kontx... | Middleware the ensures that the user either has a good enough role or is trying to get information
about themselves.
@param role
@returns {Function} | [
"Middleware",
"the",
"ensures",
"that",
"the",
"user",
"either",
"has",
"a",
"good",
"enough",
"role",
"or",
"is",
"trying",
"to",
"get",
"information",
"about",
"themselves",
"."
] | 8fabc3bfc5b18855ead443db0644608a277d0ea0 | https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/lib/runners/users.js#L18-L41 | train |
grasshopper-cms/grasshopper-core-nodejs | lib/runners/users.js | setDefaultUser | function setDefaultUser (kontx, next) {
var a = _.clone(kontx.args);
if (a.length === 0) { //No args are sent in, set first to be user id
a[0] = kontx.user._id;
}
else if (_.has(a[0], 'include') || _.has(a[0], 'exclude')) { // If first arg is options then reassign
... | javascript | function setDefaultUser (kontx, next) {
var a = _.clone(kontx.args);
if (a.length === 0) { //No args are sent in, set first to be user id
a[0] = kontx.user._id;
}
else if (_.has(a[0], 'include') || _.has(a[0], 'exclude')) { // If first arg is options then reassign
... | [
"function",
"setDefaultUser",
"(",
"kontx",
",",
"next",
")",
"{",
"var",
"a",
"=",
"_",
".",
"clone",
"(",
"kontx",
".",
"args",
")",
";",
"if",
"(",
"a",
".",
"length",
"===",
"0",
")",
"{",
"//No args are sent in, set first to be user id",
"a",
"[",
... | Middleware that will set the function argument equal to the currently logged in user id if it is left
empty. This can be used for returning back the currently logged in user's information.
@param kontx
@param next | [
"Middleware",
"that",
"will",
"set",
"the",
"function",
"argument",
"equal",
"to",
"the",
"currently",
"logged",
"in",
"user",
"id",
"if",
"it",
"is",
"left",
"empty",
".",
"This",
"can",
"be",
"used",
"for",
"returning",
"back",
"the",
"currently",
"logge... | 8fabc3bfc5b18855ead443db0644608a277d0ea0 | https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/lib/runners/users.js#L49-L62 | train |
grasshopper-cms/grasshopper-core-nodejs | lib/db/mongodb/mixins/fields.js | function(options){
var cleanOptions = this.parseOptions(options),
excludes = _.clone(this.privateFields),
includeExludes = [];
// If any includes are passed in through the options clean up the
// default excluded fields. A type can have some excluded ... | javascript | function(options){
var cleanOptions = this.parseOptions(options),
excludes = _.clone(this.privateFields),
includeExludes = [];
// If any includes are passed in through the options clean up the
// default excluded fields. A type can have some excluded ... | [
"function",
"(",
"options",
")",
"{",
"var",
"cleanOptions",
"=",
"this",
".",
"parseOptions",
"(",
"options",
")",
",",
"excludes",
"=",
"_",
".",
"clone",
"(",
"this",
".",
"privateFields",
")",
",",
"includeExludes",
"=",
"[",
"]",
";",
"// If any inc... | Build string variable that can be sent to mongo query to include or exclude fields in the response. Your
implementation module should set 'privateFields' so that we can use the parameter here.
@param options Query options object
@returns {string} | [
"Build",
"string",
"variable",
"that",
"can",
"be",
"sent",
"to",
"mongo",
"query",
"to",
"include",
"or",
"exclude",
"fields",
"in",
"the",
"response",
".",
"Your",
"implementation",
"module",
"should",
"set",
"privateFields",
"so",
"that",
"we",
"can",
"us... | 8fabc3bfc5b18855ead443db0644608a277d0ea0 | https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/lib/db/mongodb/mixins/fields.js#L38-L69 | train | |
gilt/swig | packages/swig-minify/lib/regex-replacer.js | Position | function Position(file, line, column) {
this.file = file;
this.line = line || 1;
this.column = column || 0;
} | javascript | function Position(file, line, column) {
this.file = file;
this.line = line || 1;
this.column = column || 0;
} | [
"function",
"Position",
"(",
"file",
",",
"line",
",",
"column",
")",
"{",
"this",
".",
"file",
"=",
"file",
";",
"this",
".",
"line",
"=",
"line",
"||",
"1",
";",
"this",
".",
"column",
"=",
"column",
"||",
"0",
";",
"}"
] | Handle a position in a file | [
"Handle",
"a",
"position",
"in",
"a",
"file"
] | 499e83d60dea7208640549056d99988b29177980 | https://github.com/gilt/swig/blob/499e83d60dea7208640549056d99988b29177980/packages/swig-minify/lib/regex-replacer.js#L13-L17 | train |
gilt/swig | packages/swig-spec/lib/jasmine-nyan-reporter.js | function () {
function draw(color, n) {
n = Math.max(parseInt(n), 0);
write(' ');
write('\u001b[' + color + 'm' + n + '\u001b[0m');
write('\n');
}
draw(colors.green, this.passed);
draw(colors.fail, this.failed);
draw(colors.pending, this.pending + ' ');
... | javascript | function () {
function draw(color, n) {
n = Math.max(parseInt(n), 0);
write(' ');
write('\u001b[' + color + 'm' + n + '\u001b[0m');
write('\n');
}
draw(colors.green, this.passed);
draw(colors.fail, this.failed);
draw(colors.pending, this.pending + ' ');
... | [
"function",
"(",
")",
"{",
"function",
"draw",
"(",
"color",
",",
"n",
")",
"{",
"n",
"=",
"Math",
".",
"max",
"(",
"parseInt",
"(",
"n",
")",
",",
"0",
")",
";",
"write",
"(",
"' '",
")",
";",
"write",
"(",
"'\\u001b['",
"+",
"color",
"+",
"... | Draw the "scoreboard" showing the number
of passes, failures and pending tests.
@api private | [
"Draw",
"the",
"scoreboard",
"showing",
"the",
"number",
"of",
"passes",
"failures",
"and",
"pending",
"tests",
"."
] | 499e83d60dea7208640549056d99988b29177980 | https://github.com/gilt/swig/blob/499e83d60dea7208640549056d99988b29177980/packages/swig-spec/lib/jasmine-nyan-reporter.js#L261-L277 | train | |
gilt/swig | packages/swig-spec/lib/jasmine-nyan-reporter.js | function () {
var self = this;
this.trajectories.forEach(function(line, index) {
write('\u001b[' + self.scoreboardWidth + 'C');
write(line.join(''));
write('\n');
});
cursor.up(this.numberOfLines);
} | javascript | function () {
var self = this;
this.trajectories.forEach(function(line, index) {
write('\u001b[' + self.scoreboardWidth + 'C');
write(line.join(''));
write('\n');
});
cursor.up(this.numberOfLines);
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"this",
".",
"trajectories",
".",
"forEach",
"(",
"function",
"(",
"line",
",",
"index",
")",
"{",
"write",
"(",
"'\\u001b['",
"+",
"self",
".",
"scoreboardWidth",
"+",
"'C'",
")",
";",
"wri... | Draw the rainbow.
@api private | [
"Draw",
"the",
"rainbow",
"."
] | 499e83d60dea7208640549056d99988b29177980 | https://github.com/gilt/swig/blob/499e83d60dea7208640549056d99988b29177980/packages/swig-spec/lib/jasmine-nyan-reporter.js#L300-L310 | train | |
gilt/swig | packages/swig-spec/lib/jasmine-nyan-reporter.js | function () {
var self = this;
var startWidth = this.scoreboardWidth + this.trajectories[0].length;
var color = '\u001b[' + startWidth + 'C';
var padding = '';
write(color);
write('_,------,');
write('\n');
write(color);
padding = self.tick ? ' ' : ' ';
w... | javascript | function () {
var self = this;
var startWidth = this.scoreboardWidth + this.trajectories[0].length;
var color = '\u001b[' + startWidth + 'C';
var padding = '';
write(color);
write('_,------,');
write('\n');
write(color);
padding = self.tick ? ' ' : ' ';
w... | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"startWidth",
"=",
"this",
".",
"scoreboardWidth",
"+",
"this",
".",
"trajectories",
"[",
"0",
"]",
".",
"length",
";",
"var",
"color",
"=",
"'\\u001b['",
"+",
"startWidth",
"+",
"'C'",... | Draw the nyan cat
@api private | [
"Draw",
"the",
"nyan",
"cat"
] | 499e83d60dea7208640549056d99988b29177980 | https://github.com/gilt/swig/blob/499e83d60dea7208640549056d99988b29177980/packages/swig-spec/lib/jasmine-nyan-reporter.js#L317-L345 | train | |
aureooms/js-itertools | lib/reduce/_reduce.js | _reduce | function _reduce(accumulator, iterable, initializer) {
for (let item of iterable) {
initializer = accumulator(initializer, item);
}
return initializer;
} | javascript | function _reduce(accumulator, iterable, initializer) {
for (let item of iterable) {
initializer = accumulator(initializer, item);
}
return initializer;
} | [
"function",
"_reduce",
"(",
"accumulator",
",",
"iterable",
",",
"initializer",
")",
"{",
"for",
"(",
"let",
"item",
"of",
"iterable",
")",
"{",
"initializer",
"=",
"accumulator",
"(",
"initializer",
",",
"item",
")",
";",
"}",
"return",
"initializer",
";"... | Applies the accumulator function iteratively on the last return value of the
accumulator and the next value in the input iterable. The initial value is
the initializer parameter.
@example
_reduce( ( x , y ) => x + y , range( 10 ) , 0 ) ; // returns 45
@example
_reduce( ( x , y ) => x + y , range( 10 ) , 100 ) ; // re... | [
"Applies",
"the",
"accumulator",
"function",
"iteratively",
"on",
"the",
"last",
"return",
"value",
"of",
"the",
"accumulator",
"and",
"the",
"next",
"value",
"in",
"the",
"input",
"iterable",
".",
"The",
"initial",
"value",
"is",
"the",
"initializer",
"parame... | 72bafa5f3f957ceb37bdfa87a222364fe4974be3 | https://github.com/aureooms/js-itertools/blob/72bafa5f3f957ceb37bdfa87a222364fe4974be3/lib/reduce/_reduce.js#L23-L30 | train |
gilt/swig | packages/swig-install/lib/public-directory.js | compile | function compile() {
swig.log.info('', 'Compiling module list...');
const modulesPath = path.join(swig.temp, '/**/node_modules/@gilt-tech');
const modPaths = glob.sync(modulesPath);
let dirs;
swig.log.verbose(`[compile] searching: ${modulesPath}`);
swig.log.verbose(`[compile] found module dire... | javascript | function compile() {
swig.log.info('', 'Compiling module list...');
const modulesPath = path.join(swig.temp, '/**/node_modules/@gilt-tech');
const modPaths = glob.sync(modulesPath);
let dirs;
swig.log.verbose(`[compile] searching: ${modulesPath}`);
swig.log.verbose(`[compile] found module dire... | [
"function",
"compile",
"(",
")",
"{",
"swig",
".",
"log",
".",
"info",
"(",
"''",
",",
"'Compiling module list...'",
")",
";",
"const",
"modulesPath",
"=",
"path",
".",
"join",
"(",
"swig",
".",
"temp",
",",
"'/**/node_modules/@gilt-tech'",
")",
";",
"cons... | find and compile a list of all unique modules, and their paths | [
"find",
"and",
"compile",
"a",
"list",
"of",
"all",
"unique",
"modules",
"and",
"their",
"paths"
] | 499e83d60dea7208640549056d99988b29177980 | https://github.com/gilt/swig/blob/499e83d60dea7208640549056d99988b29177980/packages/swig-install/lib/public-directory.js#L54-L101 | train |
casetext/fireproof | lib/pager.js | Pager | function Pager(ref, initialCount) {
if (arguments.length < 1) {
throw new Error('Not enough arguments to Pager');
}
this._mainRef = ref.ref();
this._resetCurrentOperation();
this.hasNext = true;
this.hasPrevious = false;
var promise;
if (initialCount) {
promise = this.next(initialCount);
}... | javascript | function Pager(ref, initialCount) {
if (arguments.length < 1) {
throw new Error('Not enough arguments to Pager');
}
this._mainRef = ref.ref();
this._resetCurrentOperation();
this.hasNext = true;
this.hasPrevious = false;
var promise;
if (initialCount) {
promise = this.next(initialCount);
}... | [
"function",
"Pager",
"(",
"ref",
",",
"initialCount",
")",
"{",
"if",
"(",
"arguments",
".",
"length",
"<",
"1",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Not enough arguments to Pager'",
")",
";",
"}",
"this",
".",
"_mainRef",
"=",
"ref",
".",
"ref",
... | A helper object for paging over Firebase objects.
@constructor Fireproof.Pager
@static
@param {Fireproof} ref a Firebase ref whose children you wish to page over.
@param {Number} [initialCount] The number of objects in the first page.
@property {Boolean} hasPrevious True if there are more objects before the current pag... | [
"A",
"helper",
"object",
"for",
"paging",
"over",
"Firebase",
"objects",
"."
] | a568157310d965d2c115e5a3c9e8287fc8fe021b | https://github.com/casetext/fireproof/blob/a568157310d965d2c115e5a3c9e8287fc8fe021b/lib/pager.js#L11-L32 | train |
pex-gl/pex-gl | patch-gl.js | flipImageData | function flipImageData (data, width, height) {
const numComponents = data.length / (width * height)
for (let y = 0; y < height / 2; y++) {
for (let x = 0; x < width; x++) {
for (let c = 0; c < numComponents; c++) {
const i = (y * width + x) * numComponents + c
const flippedI = ((height - y... | javascript | function flipImageData (data, width, height) {
const numComponents = data.length / (width * height)
for (let y = 0; y < height / 2; y++) {
for (let x = 0; x < width; x++) {
for (let c = 0; c < numComponents; c++) {
const i = (y * width + x) * numComponents + c
const flippedI = ((height - y... | [
"function",
"flipImageData",
"(",
"data",
",",
"width",
",",
"height",
")",
"{",
"const",
"numComponents",
"=",
"data",
".",
"length",
"/",
"(",
"width",
"*",
"height",
")",
"for",
"(",
"let",
"y",
"=",
"0",
";",
"y",
"<",
"height",
"/",
"2",
";",
... | Flipping array buffer in place | [
"Flipping",
"array",
"buffer",
"in",
"place"
] | d611c6defd45676da98edb9242da9c30faeef18e | https://github.com/pex-gl/pex-gl/blob/d611c6defd45676da98edb9242da9c30faeef18e/patch-gl.js#L2-L15 | train |
stealjs/steal-npm | npm-load.js | deeplyExtendPkg | function deeplyExtendPkg(a, b) {
if(!a.resolutions) {
a.resolutions = {};
}
utils.extend(a.resolutions, b.resolutions || {});
if(!a.steal) {
a.steal = {};
}
if(!b.steal) {
b.steal = {};
}
utils.extend(a.steal, b.steal, true);
} | javascript | function deeplyExtendPkg(a, b) {
if(!a.resolutions) {
a.resolutions = {};
}
utils.extend(a.resolutions, b.resolutions || {});
if(!a.steal) {
a.steal = {};
}
if(!b.steal) {
b.steal = {};
}
utils.extend(a.steal, b.steal, true);
} | [
"function",
"deeplyExtendPkg",
"(",
"a",
",",
"b",
")",
"{",
"if",
"(",
"!",
"a",
".",
"resolutions",
")",
"{",
"a",
".",
"resolutions",
"=",
"{",
"}",
";",
"}",
"utils",
".",
"extend",
"(",
"a",
".",
"resolutions",
",",
"b",
".",
"resolutions",
... | Deeply extend the configuration that needs to be kept from a previous bundle that runs through the build process. This makes sure that if we load different configuration for different bundles, all of it is retained for use in production. | [
"Deeply",
"extend",
"the",
"configuration",
"that",
"needs",
"to",
"be",
"kept",
"from",
"a",
"previous",
"bundle",
"that",
"runs",
"through",
"the",
"build",
"process",
".",
"This",
"makes",
"sure",
"that",
"if",
"we",
"load",
"different",
"configuration",
... | 216463c552cabe7d9dad86d754da784b5dea3d78 | https://github.com/stealjs/steal-npm/blob/216463c552cabe7d9dad86d754da784b5dea3d78/npm-load.js#L255-L269 | train |
grasshopper-cms/grasshopper-core-nodejs | lib/middleware/nodes/getChildren.js | loadChild | function loadChild(node, cb){
db.nodes.getByParent(node._id.toString()).then(
function(data){
payload = payload.concat(data);
async.each(data, loadChild, cb);
}).done();
} | javascript | function loadChild(node, cb){
db.nodes.getByParent(node._id.toString()).then(
function(data){
payload = payload.concat(data);
async.each(data, loadChild, cb);
}).done();
} | [
"function",
"loadChild",
"(",
"node",
",",
"cb",
")",
"{",
"db",
".",
"nodes",
".",
"getByParent",
"(",
"node",
".",
"_id",
".",
"toString",
"(",
")",
")",
".",
"then",
"(",
"function",
"(",
"data",
")",
"{",
"payload",
"=",
"payload",
".",
"concat... | Recursive function to load children and save them into the payload | [
"Recursive",
"function",
"to",
"load",
"children",
"and",
"save",
"them",
"into",
"the",
"payload"
] | 8fabc3bfc5b18855ead443db0644608a277d0ea0 | https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/lib/middleware/nodes/getChildren.js#L21-L27 | train |
grasshopper-cms/grasshopper-core-nodejs | lib/middleware/nodes/getChildren.js | setNodes | function setNodes(data){
payload = data;
if(kontx.args.deep === true){
async.eachSeries(data, loadChild, sendNext);
}
else {
sendNext();
}
} | javascript | function setNodes(data){
payload = data;
if(kontx.args.deep === true){
async.eachSeries(data, loadChild, sendNext);
}
else {
sendNext();
}
} | [
"function",
"setNodes",
"(",
"data",
")",
"{",
"payload",
"=",
"data",
";",
"if",
"(",
"kontx",
".",
"args",
".",
"deep",
"===",
"true",
")",
"{",
"async",
".",
"eachSeries",
"(",
"data",
",",
"loadChild",
",",
"sendNext",
")",
";",
"}",
"else",
"{... | Initial callback that sets the payload and kicks off the recursive method if "deep" is set to true | [
"Initial",
"callback",
"that",
"sets",
"the",
"payload",
"and",
"kicks",
"off",
"the",
"recursive",
"method",
"if",
"deep",
"is",
"set",
"to",
"true"
] | 8fabc3bfc5b18855ead443db0644608a277d0ea0 | https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/lib/middleware/nodes/getChildren.js#L30-L39 | train |
reddit/node-build | lib/build.js | function() {
if (!builds.length) { return; } // this shouldn't happen
var build = builds.shift();
var buildCallback = function(stats) {
cb(build.buildName, stats);
if (builds.length) {
runNextBuild();
}
};
console.log(colors.cyan('[Starting build]'), build.buildName);
... | javascript | function() {
if (!builds.length) { return; } // this shouldn't happen
var build = builds.shift();
var buildCallback = function(stats) {
cb(build.buildName, stats);
if (builds.length) {
runNextBuild();
}
};
console.log(colors.cyan('[Starting build]'), build.buildName);
... | [
"function",
"(",
")",
"{",
"if",
"(",
"!",
"builds",
".",
"length",
")",
"{",
"return",
";",
"}",
"// this shouldn't happen",
"var",
"build",
"=",
"builds",
".",
"shift",
"(",
")",
";",
"var",
"buildCallback",
"=",
"function",
"(",
"stats",
")",
"{",
... | Run each build serially so the server can do things like read an app manifest file that's genrated during the client build step. | [
"Run",
"each",
"build",
"serially",
"so",
"the",
"server",
"can",
"do",
"things",
"like",
"read",
"an",
"app",
"manifest",
"file",
"that",
"s",
"genrated",
"during",
"the",
"client",
"build",
"step",
"."
] | af30dc8c637631b177ae33a1984a44ffa839914b | https://github.com/reddit/node-build/blob/af30dc8c637631b177ae33a1984a44ffa839914b/lib/build.js#L20-L32 | train | |
grasshopper-cms/grasshopper-core-nodejs | dev/server/public/admin/vendor/svg-edit-2.7/extensions/ext-overview_window.js | function(){
var portHeight=parseFloat($("#workarea").css("height"));
var portWidth=parseFloat($("#workarea").css("width"));
var portX=$("#workarea").scrollLeft();
var portY=$("#workarea").scrollTop();
var windowWidth=parseFloat($("#svgcanvas").css("width"));
var windowHeight=parseFloat($("#svgcanvas").css("... | javascript | function(){
var portHeight=parseFloat($("#workarea").css("height"));
var portWidth=parseFloat($("#workarea").css("width"));
var portX=$("#workarea").scrollLeft();
var portY=$("#workarea").scrollTop();
var windowWidth=parseFloat($("#svgcanvas").css("width"));
var windowHeight=parseFloat($("#svgcanvas").css("... | [
"function",
"(",
")",
"{",
"var",
"portHeight",
"=",
"parseFloat",
"(",
"$",
"(",
"\"#workarea\"",
")",
".",
"css",
"(",
"\"height\"",
")",
")",
";",
"var",
"portWidth",
"=",
"parseFloat",
"(",
"$",
"(",
"\"#workarea\"",
")",
".",
"css",
"(",
"\"width\... | define dynamic animation of the view box. | [
"define",
"dynamic",
"animation",
"of",
"the",
"view",
"box",
"."
] | 8fabc3bfc5b18855ead443db0644608a277d0ea0 | https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/dev/server/public/admin/vendor/svg-edit-2.7/extensions/ext-overview_window.js#L30-L49 | train | |
grasshopper-cms/grasshopper-core-nodejs | dev/server/public/admin/vendor/svg-edit-2.7/extensions/ext-overview_window.js | function(){
var viewWidth=$("#svgroot").attr("width");
var viewHeight=$("#svgroot").attr("height");
var viewX=640;
var viewY=480;
if(svgedit.browser.isIE())
{
//This has only been tested with Firefox 10 and IE 9 (without chrome frame).
//I am not sure if if is Firefox or IE that is being non compli... | javascript | function(){
var viewWidth=$("#svgroot").attr("width");
var viewHeight=$("#svgroot").attr("height");
var viewX=640;
var viewY=480;
if(svgedit.browser.isIE())
{
//This has only been tested with Firefox 10 and IE 9 (without chrome frame).
//I am not sure if if is Firefox or IE that is being non compli... | [
"function",
"(",
")",
"{",
"var",
"viewWidth",
"=",
"$",
"(",
"\"#svgroot\"",
")",
".",
"attr",
"(",
"\"width\"",
")",
";",
"var",
"viewHeight",
"=",
"$",
"(",
"\"#svgroot\"",
")",
".",
"attr",
"(",
"\"height\"",
")",
";",
"var",
"viewX",
"=",
"640",... | comphensate for changes in zoom and canvas size | [
"comphensate",
"for",
"changes",
"in",
"zoom",
"and",
"canvas",
"size"
] | 8fabc3bfc5b18855ead443db0644608a277d0ea0 | https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/dev/server/public/admin/vendor/svg-edit-2.7/extensions/ext-overview_window.js#L59-L82 | train | |
grasshopper-cms/grasshopper-core-nodejs | dev/server/public/admin/vendor/svg-edit-2.7/extensions/ext-markers.js | getLinked | function getLinked(elem, attr) {
var str = elem.getAttribute(attr);
if(!str) {return null;}
var m = str.match(/\(\#(.*)\)/);
if(!m || m.length !== 2) {
return null;
}
return S.getElem(m[1]);
} | javascript | function getLinked(elem, attr) {
var str = elem.getAttribute(attr);
if(!str) {return null;}
var m = str.match(/\(\#(.*)\)/);
if(!m || m.length !== 2) {
return null;
}
return S.getElem(m[1]);
} | [
"function",
"getLinked",
"(",
"elem",
",",
"attr",
")",
"{",
"var",
"str",
"=",
"elem",
".",
"getAttribute",
"(",
"attr",
")",
";",
"if",
"(",
"!",
"str",
")",
"{",
"return",
"null",
";",
"}",
"var",
"m",
"=",
"str",
".",
"match",
"(",
"/",
"\\... | elem = a graphic element will have an attribute like marker-start attr - marker-start, marker-mid, or marker-end returns the marker element that is linked to the graphic element | [
"elem",
"=",
"a",
"graphic",
"element",
"will",
"have",
"an",
"attribute",
"like",
"marker",
"-",
"start",
"attr",
"-",
"marker",
"-",
"start",
"marker",
"-",
"mid",
"or",
"marker",
"-",
"end",
"returns",
"the",
"marker",
"element",
"that",
"is",
"linked... | 8fabc3bfc5b18855ead443db0644608a277d0ea0 | https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/dev/server/public/admin/vendor/svg-edit-2.7/extensions/ext-markers.js#L113-L121 | train |
grasshopper-cms/grasshopper-core-nodejs | dev/server/public/admin/vendor/svg-edit-2.7/extensions/ext-markers.js | colorChanged | function colorChanged(elem) {
var color = elem.getAttribute('stroke');
$.each(mtypes, function(i, pos) {
var marker = getLinked(elem, 'marker-'+pos);
if (!marker) {return;}
if (!marker.attributes.se_type) {return;} // not created by this extension
var ch = marker.lastElementChild;
if (!ch) {return;}... | javascript | function colorChanged(elem) {
var color = elem.getAttribute('stroke');
$.each(mtypes, function(i, pos) {
var marker = getLinked(elem, 'marker-'+pos);
if (!marker) {return;}
if (!marker.attributes.se_type) {return;} // not created by this extension
var ch = marker.lastElementChild;
if (!ch) {return;}... | [
"function",
"colorChanged",
"(",
"elem",
")",
"{",
"var",
"color",
"=",
"elem",
".",
"getAttribute",
"(",
"'stroke'",
")",
";",
"$",
".",
"each",
"(",
"mtypes",
",",
"function",
"(",
"i",
",",
"pos",
")",
"{",
"var",
"marker",
"=",
"getLinked",
"(",
... | called when the main system modifies an object this routine changes the associated markers to be the same color | [
"called",
"when",
"the",
"main",
"system",
"modifies",
"an",
"object",
"this",
"routine",
"changes",
"the",
"associated",
"markers",
"to",
"be",
"the",
"same",
"color"
] | 8fabc3bfc5b18855ead443db0644608a277d0ea0 | https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/dev/server/public/admin/vendor/svg-edit-2.7/extensions/ext-markers.js#L329-L343 | train |
grasshopper-cms/grasshopper-core-nodejs | dev/server/public/admin/vendor/svg-edit-2.7/extensions/ext-markers.js | updateReferences | function updateReferences(el) {
$.each(mtypes, function (i, pos) {
var id = marker_prefix + pos + '_' + el.id;
var marker_name = 'marker-'+pos;
var marker = getLinked(el, marker_name);
if (!marker || !marker.attributes.se_type) {return;} // not created by this extension
var url = el.getAttribute(marker... | javascript | function updateReferences(el) {
$.each(mtypes, function (i, pos) {
var id = marker_prefix + pos + '_' + el.id;
var marker_name = 'marker-'+pos;
var marker = getLinked(el, marker_name);
if (!marker || !marker.attributes.se_type) {return;} // not created by this extension
var url = el.getAttribute(marker... | [
"function",
"updateReferences",
"(",
"el",
")",
"{",
"$",
".",
"each",
"(",
"mtypes",
",",
"function",
"(",
"i",
",",
"pos",
")",
"{",
"var",
"id",
"=",
"marker_prefix",
"+",
"pos",
"+",
"'_'",
"+",
"el",
".",
"id",
";",
"var",
"marker_name",
"=",
... | called when the main system creates or modifies an object primary purpose is create new markers for cloned objects | [
"called",
"when",
"the",
"main",
"system",
"creates",
"or",
"modifies",
"an",
"object",
"primary",
"purpose",
"is",
"create",
"new",
"markers",
"for",
"cloned",
"objects"
] | 8fabc3bfc5b18855ead443db0644608a277d0ea0 | https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/dev/server/public/admin/vendor/svg-edit-2.7/extensions/ext-markers.js#L347-L366 | train |
grasshopper-cms/grasshopper-core-nodejs | dev/server/public/admin/vendor/svg-edit-2.7/svgcanvas.js | function(elem) {
try {
// TODO: Fix issue with rotated groups. Currently they work
// fine in FF, but not in other browsers (same problem mentioned
// in Issue 339 comment #2).
var bb = svgedit.utilities.getBBox(elem);
var angle = svgedit.utilities.getRotationAngle(elem);
if ((angle && angle % 90... | javascript | function(elem) {
try {
// TODO: Fix issue with rotated groups. Currently they work
// fine in FF, but not in other browsers (same problem mentioned
// in Issue 339 comment #2).
var bb = svgedit.utilities.getBBox(elem);
var angle = svgedit.utilities.getRotationAngle(elem);
if ((angle && angle % 90... | [
"function",
"(",
"elem",
")",
"{",
"try",
"{",
"// TODO: Fix issue with rotated groups. Currently they work",
"// fine in FF, but not in other browsers (same problem mentioned",
"// in Issue 339 comment #2).",
"var",
"bb",
"=",
"svgedit",
".",
"utilities",
".",
"getBBox",
"(",
... | Make sure the expected BBox is returned if the element is a group | [
"Make",
"sure",
"the",
"expected",
"BBox",
"is",
"returned",
"if",
"the",
"element",
"is",
"a",
"group"
] | 8fabc3bfc5b18855ead443db0644608a277d0ea0 | https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/dev/server/public/admin/vendor/svg-edit-2.7/svgcanvas.js#L602-L679 | train | |
grasshopper-cms/grasshopper-core-nodejs | dev/server/public/admin/vendor/svg-edit-2.7/svgcanvas.js | function(m) {
console.log([m.a, m.b, m.c, m.d, m.e, m.f]);
} | javascript | function(m) {
console.log([m.a, m.b, m.c, m.d, m.e, m.f]);
} | [
"function",
"(",
"m",
")",
"{",
"console",
".",
"log",
"(",
"[",
"m",
".",
"a",
",",
"m",
".",
"b",
",",
"m",
".",
"c",
",",
"m",
".",
"d",
",",
"m",
".",
"e",
",",
"m",
".",
"f",
"]",
")",
";",
"}"
] | Debug tool to easily see the current matrix in the browser's console | [
"Debug",
"tool",
"to",
"easily",
"see",
"the",
"current",
"matrix",
"in",
"the",
"browser",
"s",
"console"
] | 8fabc3bfc5b18855ead443db0644608a277d0ea0 | https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/dev/server/public/admin/vendor/svg-edit-2.7/svgcanvas.js#L1022-L1024 | train | |
apostrophecms-legacy/apostrophe-pages | index.js | sanitizeSpontaneousAreas | function sanitizeSpontaneousAreas(req, data, page, callback) {
var toSanitize = [];
_.each(data, function(val, key) {
if (typeof(val) === 'object') {
if (val.type === 'area') {
if (_.has(page, key) && ((typeof(page[key]) !== 'object') || (page[key].type !== 'area'))) {
// Spo... | javascript | function sanitizeSpontaneousAreas(req, data, page, callback) {
var toSanitize = [];
_.each(data, function(val, key) {
if (typeof(val) === 'object') {
if (val.type === 'area') {
if (_.has(page, key) && ((typeof(page[key]) !== 'object') || (page[key].type !== 'area'))) {
// Spo... | [
"function",
"sanitizeSpontaneousAreas",
"(",
"req",
",",
"data",
",",
"page",
",",
"callback",
")",
"{",
"var",
"toSanitize",
"=",
"[",
"]",
";",
"_",
".",
"each",
"(",
"data",
",",
"function",
"(",
"val",
",",
"key",
")",
"{",
"if",
"(",
"typeof",
... | Both the new and edit page operations utilize this to deal with areas that arise spontaneously via page templates rather than being hardcoded in the schema. The rule is that if an otherwise unknown property is an object with a "type" sub-property set to "area", that is accepted and sanitized as an area. | [
"Both",
"the",
"new",
"and",
"edit",
"page",
"operations",
"utilize",
"this",
"to",
"deal",
"with",
"areas",
"that",
"arise",
"spontaneously",
"via",
"page",
"templates",
"rather",
"than",
"being",
"hardcoded",
"in",
"the",
"schema",
".",
"The",
"rule",
"is"... | 72eb4b1df351b1c253e9b1c2bd2fe3fff6eb71b3 | https://github.com/apostrophecms-legacy/apostrophe-pages/blob/72eb4b1df351b1c253e9b1c2bd2fe3fff6eb71b3/index.js#L1760-L1790 | train |
apostrophecms-legacy/apostrophe-pages | index.js | diffVersions | function diffVersions(callback) {
var prior = null;
_.each(versions, function(version) {
if (!prior) {
version.diff = [ { value: '[NEW]', added: true } ];
} else {
version.diff = apos.diffPages(prior, version);
}
prior = version;
})... | javascript | function diffVersions(callback) {
var prior = null;
_.each(versions, function(version) {
if (!prior) {
version.diff = [ { value: '[NEW]', added: true } ];
} else {
version.diff = apos.diffPages(prior, version);
}
prior = version;
})... | [
"function",
"diffVersions",
"(",
"callback",
")",
"{",
"var",
"prior",
"=",
"null",
";",
"_",
".",
"each",
"(",
"versions",
",",
"function",
"(",
"version",
")",
"{",
"if",
"(",
"!",
"prior",
")",
"{",
"version",
".",
"diff",
"=",
"[",
"{",
"value"... | We must diff on the fly because versions get pruned over time | [
"We",
"must",
"diff",
"on",
"the",
"fly",
"because",
"versions",
"get",
"pruned",
"over",
"time"
] | 72eb4b1df351b1c253e9b1c2bd2fe3fff6eb71b3 | https://github.com/apostrophecms-legacy/apostrophe-pages/blob/72eb4b1df351b1c253e9b1c2bd2fe3fff6eb71b3/index.js#L2226-L2238 | train |
grasshopper-cms/grasshopper-core-nodejs | lib/db/mongodb/nodes.js | getId | function getId(id){
if(_.isObject(id) && !_.isUndefined(id.id)){
if (objectIdRegex.test(id.id)) {
id = id.id;
}
else {
id = null;
}
}
return id;
} | javascript | function getId(id){
if(_.isObject(id) && !_.isUndefined(id.id)){
if (objectIdRegex.test(id.id)) {
id = id.id;
}
else {
id = null;
}
}
return id;
} | [
"function",
"getId",
"(",
"id",
")",
"{",
"if",
"(",
"_",
".",
"isObject",
"(",
"id",
")",
"&&",
"!",
"_",
".",
"isUndefined",
"(",
"id",
".",
"id",
")",
")",
"{",
"if",
"(",
"objectIdRegex",
".",
"test",
"(",
"id",
".",
"id",
")",
")",
"{",
... | Function will look at the id that has been passed to the module and
if it is a string send it back, if it is an object with an `id` property
then it will check to see if it is a valid mongo objectid format and then
send it back.
@param id
@returns {*} | [
"Function",
"will",
"look",
"at",
"the",
"id",
"that",
"has",
"been",
"passed",
"to",
"the",
"module",
"and",
"if",
"it",
"is",
"a",
"string",
"send",
"it",
"back",
"if",
"it",
"is",
"an",
"object",
"with",
"an",
"id",
"property",
"then",
"it",
"will... | 8fabc3bfc5b18855ead443db0644608a277d0ea0 | https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/lib/db/mongodb/nodes.js#L30-L40 | train |
grasshopper-cms/grasshopper-core-nodejs | dev/server/public/admin/vendor/svg-edit-2.7/extensions/ext-connector.js | init | function init() {
// Make sure all connectors have data set
$(svgcontent).find('*').each(function() {
var conn = this.getAttributeNS(se_ns, "connector");
if(conn) {
this.setAttribute('class', conn_sel.substr(1));
var conn_data = conn.split(' ');
var sbb = svgCanvas.getStrokedBBox([getElem(conn_da... | javascript | function init() {
// Make sure all connectors have data set
$(svgcontent).find('*').each(function() {
var conn = this.getAttributeNS(se_ns, "connector");
if(conn) {
this.setAttribute('class', conn_sel.substr(1));
var conn_data = conn.split(' ');
var sbb = svgCanvas.getStrokedBBox([getElem(conn_da... | [
"function",
"init",
"(",
")",
"{",
"// Make sure all connectors have data set",
"$",
"(",
"svgcontent",
")",
".",
"find",
"(",
"'*'",
")",
".",
"each",
"(",
"function",
"(",
")",
"{",
"var",
"conn",
"=",
"this",
".",
"getAttributeNS",
"(",
"se_ns",
",",
... | Do on reset | [
"Do",
"on",
"reset"
] | 8fabc3bfc5b18855ead443db0644608a277d0ea0 | https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/dev/server/public/admin/vendor/svg-edit-2.7/extensions/ext-connector.js#L274-L291 | train |
matmanjs/matman | packages/matman-crawler/asserts/nightmare-preload.js | error | function error(err) {
if (!(err instanceof Error)) return err
return {
code: err.code,
message: err.message,
details: err.detail,
stack: err.stack || ''
}
} | javascript | function error(err) {
if (!(err instanceof Error)) return err
return {
code: err.code,
message: err.message,
details: err.detail,
stack: err.stack || ''
}
} | [
"function",
"error",
"(",
"err",
")",
"{",
"if",
"(",
"!",
"(",
"err",
"instanceof",
"Error",
")",
")",
"return",
"err",
"return",
"{",
"code",
":",
"err",
".",
"code",
",",
"message",
":",
"err",
".",
"message",
",",
"details",
":",
"err",
".",
... | Make errors serializeable | [
"Make",
"errors",
"serializeable"
] | 2ffe0760aba4d8ccb45f056bb1aa1b8429e2c89a | https://github.com/matmanjs/matman/blob/2ffe0760aba4d8ccb45f056bb1aa1b8429e2c89a/packages/matman-crawler/asserts/nightmare-preload.js#L106-L114 | train |
stratumn/js-chainscript | src/proto/chainscript_pb.js | Segment | function Segment(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | javascript | function Segment(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | [
"function",
"Segment",
"(",
"properties",
")",
"{",
"if",
"(",
"properties",
")",
"for",
"(",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"properties",
")",
",",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
"length",
";",
"++",
"i",
")",
"if",
... | Properties of a Segment.
@memberof stratumn.chainscript
@interface ISegment
@property {stratumn.chainscript.ILink|null} [link] Segment link
@property {stratumn.chainscript.ISegmentMeta|null} [meta] Segment meta
Constructs a new Segment.
@memberof stratumn.chainscript
@classdesc Represents a Segment.
@implements ISegm... | [
"Properties",
"of",
"a",
"Segment",
"."
] | 1aba9933f18107d6d66c0b559cb07255e6398cdb | https://github.com/stratumn/js-chainscript/blob/1aba9933f18107d6d66c0b559cb07255e6398cdb/src/proto/chainscript_pb.js#L48-L53 | train |
stratumn/js-chainscript | src/proto/chainscript_pb.js | SegmentMeta | function SegmentMeta(properties) {
this.evidences = [];
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
... | javascript | function SegmentMeta(properties) {
this.evidences = [];
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
... | [
"function",
"SegmentMeta",
"(",
"properties",
")",
"{",
"this",
".",
"evidences",
"=",
"[",
"]",
";",
"if",
"(",
"properties",
")",
"for",
"(",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"properties",
")",
",",
"i",
"=",
"0",
";",
"i",
"<",
... | Properties of a SegmentMeta.
@memberof stratumn.chainscript
@interface ISegmentMeta
@property {Uint8Array|null} [linkHash] SegmentMeta linkHash
@property {Array.<stratumn.chainscript.IEvidence>|null} [evidences] SegmentMeta evidences
Constructs a new SegmentMeta.
@memberof stratumn.chainscript
@classdesc Represents a... | [
"Properties",
"of",
"a",
"SegmentMeta",
"."
] | 1aba9933f18107d6d66c0b559cb07255e6398cdb | https://github.com/stratumn/js-chainscript/blob/1aba9933f18107d6d66c0b559cb07255e6398cdb/src/proto/chainscript_pb.js#L268-L274 | train |
stratumn/js-chainscript | src/proto/chainscript_pb.js | Evidence | function Evidence(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | javascript | function Evidence(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | [
"function",
"Evidence",
"(",
"properties",
")",
"{",
"if",
"(",
"properties",
")",
"for",
"(",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"properties",
")",
",",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
"length",
";",
"++",
"i",
")",
"if",... | Properties of an Evidence.
@memberof stratumn.chainscript
@interface IEvidence
@property {string|null} [version] Evidence version
@property {string|null} [backend] Evidence backend
@property {string|null} [provider] Evidence provider
@property {Uint8Array|null} [proof] Evidence proof
Constructs a new Evidence.
@membe... | [
"Properties",
"of",
"an",
"Evidence",
"."
] | 1aba9933f18107d6d66c0b559cb07255e6398cdb | https://github.com/stratumn/js-chainscript/blob/1aba9933f18107d6d66c0b559cb07255e6398cdb/src/proto/chainscript_pb.js#L510-L515 | train |
stratumn/js-chainscript | src/proto/chainscript_pb.js | Link | function Link(properties) {
this.signatures = [];
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
... | javascript | function Link(properties) {
this.signatures = [];
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
... | [
"function",
"Link",
"(",
"properties",
")",
"{",
"this",
".",
"signatures",
"=",
"[",
"]",
";",
"if",
"(",
"properties",
")",
"for",
"(",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"properties",
")",
",",
"i",
"=",
"0",
";",
"i",
"<",
"keys"... | Properties of a Link.
@memberof stratumn.chainscript
@interface ILink
@property {string|null} [version] Link version
@property {Uint8Array|null} [data] Link data
@property {stratumn.chainscript.ILinkMeta|null} [meta] Link meta
@property {Array.<stratumn.chainscript.ISignature>|null} [signatures] Link signatures
Const... | [
"Properties",
"of",
"a",
"Link",
"."
] | 1aba9933f18107d6d66c0b559cb07255e6398cdb | https://github.com/stratumn/js-chainscript/blob/1aba9933f18107d6d66c0b559cb07255e6398cdb/src/proto/chainscript_pb.js#L773-L779 | train |
stratumn/js-chainscript | src/proto/chainscript_pb.js | Process | function Process(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | javascript | function Process(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | [
"function",
"Process",
"(",
"properties",
")",
"{",
"if",
"(",
"properties",
")",
"for",
"(",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"properties",
")",
",",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
"length",
";",
"++",
"i",
")",
"if",
... | Properties of a Process.
@memberof stratumn.chainscript
@interface IProcess
@property {string|null} [name] Process name
@property {string|null} [state] Process state
Constructs a new Process.
@memberof stratumn.chainscript
@classdesc Represents a Process.
@implements IProcess
@constructor
@param {stratumn.chainscript... | [
"Properties",
"of",
"a",
"Process",
"."
] | 1aba9933f18107d6d66c0b559cb07255e6398cdb | https://github.com/stratumn/js-chainscript/blob/1aba9933f18107d6d66c0b559cb07255e6398cdb/src/proto/chainscript_pb.js#L1061-L1066 | train |
stratumn/js-chainscript | src/proto/chainscript_pb.js | LinkMeta | function LinkMeta(properties) {
this.refs = [];
this.tags = [];
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = p... | javascript | function LinkMeta(properties) {
this.refs = [];
this.tags = [];
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = p... | [
"function",
"LinkMeta",
"(",
"properties",
")",
"{",
"this",
".",
"refs",
"=",
"[",
"]",
";",
"this",
".",
"tags",
"=",
"[",
"]",
";",
"if",
"(",
"properties",
")",
"for",
"(",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"properties",
")",
",... | Properties of a LinkMeta.
@memberof stratumn.chainscript
@interface ILinkMeta
@property {string|null} [clientId] LinkMeta clientId
@property {Uint8Array|null} [prevLinkHash] LinkMeta prevLinkHash
@property {number|null} [priority] LinkMeta priority
@property {Array.<stratumn.chainscript.ILinkReference>|null} [refs] Lin... | [
"Properties",
"of",
"a",
"LinkMeta",
"."
] | 1aba9933f18107d6d66c0b559cb07255e6398cdb | https://github.com/stratumn/js-chainscript/blob/1aba9933f18107d6d66c0b559cb07255e6398cdb/src/proto/chainscript_pb.js#L1280-L1287 | train |
stratumn/js-chainscript | src/proto/chainscript_pb.js | LinkReference | function LinkReference(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | javascript | function LinkReference(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | [
"function",
"LinkReference",
"(",
"properties",
")",
"{",
"if",
"(",
"properties",
")",
"for",
"(",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"properties",
")",
",",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
"length",
";",
"++",
"i",
")",
... | Properties of a LinkReference.
@memberof stratumn.chainscript
@interface ILinkReference
@property {Uint8Array|null} [linkHash] LinkReference linkHash
@property {string|null} [process] LinkReference process
Constructs a new LinkReference.
@memberof stratumn.chainscript
@classdesc Represents a LinkReference.
@implement... | [
"Properties",
"of",
"a",
"LinkReference",
"."
] | 1aba9933f18107d6d66c0b559cb07255e6398cdb | https://github.com/stratumn/js-chainscript/blob/1aba9933f18107d6d66c0b559cb07255e6398cdb/src/proto/chainscript_pb.js#L1741-L1746 | train |
stratumn/js-chainscript | src/proto/chainscript_pb.js | Signature | function Signature(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | javascript | function Signature(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | [
"function",
"Signature",
"(",
"properties",
")",
"{",
"if",
"(",
"properties",
")",
"for",
"(",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"properties",
")",
",",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
"length",
";",
"++",
"i",
")",
"if"... | Properties of a Signature.
@memberof stratumn.chainscript
@interface ISignature
@property {string|null} [version] Signature version
@property {string|null} [type] Signature type
@property {string|null} [payloadPath] Signature payloadPath
@property {Uint8Array|null} [publicKey] Signature publicKey
@property {Uint8Array|... | [
"Properties",
"of",
"a",
"Signature",
"."
] | 1aba9933f18107d6d66c0b559cb07255e6398cdb | https://github.com/stratumn/js-chainscript/blob/1aba9933f18107d6d66c0b559cb07255e6398cdb/src/proto/chainscript_pb.js#L1963-L1968 | train |
grasshopper-cms/grasshopper-core-nodejs | lib/middleware/assets/index.js | proxy | function proxy(func){
'use strict';
// Returns a middleware
return function (kontx, next){
func(kontx.args).then(
function(payload){
kontx.payload = payload;
next();
},
function(err){
next(err);
}
... | javascript | function proxy(func){
'use strict';
// Returns a middleware
return function (kontx, next){
func(kontx.args).then(
function(payload){
kontx.payload = payload;
next();
},
function(err){
next(err);
}
... | [
"function",
"proxy",
"(",
"func",
")",
"{",
"'use strict'",
";",
"// Returns a middleware",
"return",
"function",
"(",
"kontx",
",",
"next",
")",
"{",
"func",
"(",
"kontx",
".",
"args",
")",
".",
"then",
"(",
"function",
"(",
"payload",
")",
"{",
"kontx"... | Proxy function will take a assets function and wrap it with a middleware.
@param func
@returns {Function} | [
"Proxy",
"function",
"will",
"take",
"a",
"assets",
"function",
"and",
"wrap",
"it",
"with",
"a",
"middleware",
"."
] | 8fabc3bfc5b18855ead443db0644608a277d0ea0 | https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/lib/middleware/assets/index.js#L9-L24 | train |
grasshopper-cms/grasshopper-core-nodejs | docs/js/vendor/flipclock/flipclock.js | function(index, obj) {
var lang = this.lang;
var lindex = index.toLowerCase();
if(typeof obj == "object") {
lang = obj;
}
if(lang && lang[lindex]) {
return lang[lindex];
}
return index;
} | javascript | function(index, obj) {
var lang = this.lang;
var lindex = index.toLowerCase();
if(typeof obj == "object") {
lang = obj;
}
if(lang && lang[lindex]) {
return lang[lindex];
}
return index;
} | [
"function",
"(",
"index",
",",
"obj",
")",
"{",
"var",
"lang",
"=",
"this",
".",
"lang",
";",
"var",
"lindex",
"=",
"index",
".",
"toLowerCase",
"(",
")",
";",
"if",
"(",
"typeof",
"obj",
"==",
"\"object\"",
")",
"{",
"lang",
"=",
"obj",
";",
"}"... | Localize strings into various languages
@param string The index of the localized string
@param object Optionally pass a lang object | [
"Localize",
"strings",
"into",
"various",
"languages"
] | 8fabc3bfc5b18855ead443db0644608a277d0ea0 | https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/docs/js/vendor/flipclock/flipclock.js#L354-L367 | train | |
grasshopper-cms/grasshopper-core-nodejs | docs/js/vendor/flipclock/flipclock.js | function(callback) {
this.face.stop();
this.timer.stop(callback);
for(var x in this.lists) {
this.lists[x].stop();
}
} | javascript | function(callback) {
this.face.stop();
this.timer.stop(callback);
for(var x in this.lists) {
this.lists[x].stop();
}
} | [
"function",
"(",
"callback",
")",
"{",
"this",
".",
"face",
".",
"stop",
"(",
")",
";",
"this",
".",
"timer",
".",
"stop",
"(",
"callback",
")",
";",
"for",
"(",
"var",
"x",
"in",
"this",
".",
"lists",
")",
"{",
"this",
".",
"lists",
"[",
"x",
... | Stops the clock | [
"Stops",
"the",
"clock"
] | 8fabc3bfc5b18855ead443db0644608a277d0ea0 | https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/docs/js/vendor/flipclock/flipclock.js#L396-L403 | train | |
grasshopper-cms/grasshopper-core-nodejs | docs/js/vendor/flipclock/flipclock.js | function(label, css, excludeDots) {
if(typeof css == "boolean" || !css) {
excludeDots = css;
css = label;
}
var dots = [
'<span class="'+this.factory.classes.dot+' top"></span>',
'<span class="'+this.factory.classes.dot+' bottom"></span>'
].join('');
if(excludeDots) {
dots = ''; ... | javascript | function(label, css, excludeDots) {
if(typeof css == "boolean" || !css) {
excludeDots = css;
css = label;
}
var dots = [
'<span class="'+this.factory.classes.dot+' top"></span>',
'<span class="'+this.factory.classes.dot+' bottom"></span>'
].join('');
if(excludeDots) {
dots = ''; ... | [
"function",
"(",
"label",
",",
"css",
",",
"excludeDots",
")",
"{",
"if",
"(",
"typeof",
"css",
"==",
"\"boolean\"",
"||",
"!",
"css",
")",
"{",
"excludeDots",
"=",
"css",
";",
"css",
"=",
"label",
";",
"}",
"var",
"dots",
"=",
"[",
"'<span class=\"'... | Creates a jQuery object used for the digit divider
@param mixed The divider label text
@param mixed Set true to exclude the dots in the divider.
If not set, is false. | [
"Creates",
"a",
"jQuery",
"object",
"used",
"for",
"the",
"digit",
"divider"
] | 8fabc3bfc5b18855ead443db0644608a277d0ea0 | https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/docs/js/vendor/flipclock/flipclock.js#L514-L540 | train | |
grasshopper-cms/grasshopper-core-nodejs | docs/js/vendor/flipclock/flipclock.js | function(digit) {
var obj = this.createList(digit, {
classes: {
active: this.factory.classes.active,
before: this.factory.classes.before,
flip: this.factory.classes.flip
}
});
obj.$obj.insertBefore(this.factory.lists[0].$obj);
this.factory.lists.unshift(obj);
} | javascript | function(digit) {
var obj = this.createList(digit, {
classes: {
active: this.factory.classes.active,
before: this.factory.classes.before,
flip: this.factory.classes.flip
}
});
obj.$obj.insertBefore(this.factory.lists[0].$obj);
this.factory.lists.unshift(obj);
} | [
"function",
"(",
"digit",
")",
"{",
"var",
"obj",
"=",
"this",
".",
"createList",
"(",
"digit",
",",
"{",
"classes",
":",
"{",
"active",
":",
"this",
".",
"factory",
".",
"classes",
".",
"active",
",",
"before",
":",
"this",
".",
"factory",
".",
"c... | Sets the clock time | [
"Sets",
"the",
"clock",
"time"
] | 8fabc3bfc5b18855ead443db0644608a277d0ea0 | https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/docs/js/vendor/flipclock/flipclock.js#L580-L592 | train | |
grasshopper-cms/grasshopper-core-nodejs | docs/js/vendor/flipclock/flipclock.js | function() {
var t = this;
setTimeout(function() {
t.$obj.removeClass(t.factory.classes.play);
}, this.factory.timer.interval);
} | javascript | function() {
var t = this;
setTimeout(function() {
t.$obj.removeClass(t.factory.classes.play);
}, this.factory.timer.interval);
} | [
"function",
"(",
")",
"{",
"var",
"t",
"=",
"this",
";",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"t",
".",
"$obj",
".",
"removeClass",
"(",
"t",
".",
"factory",
".",
"classes",
".",
"play",
")",
";",
"}",
",",
"this",
".",
"factory",
".",
... | Removes the play class to the DOM object | [
"Removes",
"the",
"play",
"class",
"to",
"the",
"DOM",
"object"
] | 8fabc3bfc5b18855ead443db0644608a277d0ea0 | https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/docs/js/vendor/flipclock/flipclock.js#L781-L787 | train | |
grasshopper-cms/grasshopper-core-nodejs | lib/db/mongodb/schemas/contentType.js | validateFieldType | function validateFieldType(fieldsCollection){
var err;
// ensure fieldsCollection is an array.
if(!_.isArray(fieldsCollection)) {
err = new Error('content type fields collection must be an array of field objects.');
}
if(!err) {
_.each(fieldsCollection, ... | javascript | function validateFieldType(fieldsCollection){
var err;
// ensure fieldsCollection is an array.
if(!_.isArray(fieldsCollection)) {
err = new Error('content type fields collection must be an array of field objects.');
}
if(!err) {
_.each(fieldsCollection, ... | [
"function",
"validateFieldType",
"(",
"fieldsCollection",
")",
"{",
"var",
"err",
";",
"// ensure fieldsCollection is an array.",
"if",
"(",
"!",
"_",
".",
"isArray",
"(",
"fieldsCollection",
")",
")",
"{",
"err",
"=",
"new",
"Error",
"(",
"'content type fields co... | In order to be valid we are checking the following rules
1) Collection must be an instance of an array
2) Does the element in the Collection array have all of the necessary properties
3) Are there any duplicate ids
@param value
@returns {null} | [
"In",
"order",
"to",
"be",
"valid",
"we",
"are",
"checking",
"the",
"following",
"rules",
"1",
")",
"Collection",
"must",
"be",
"an",
"instance",
"of",
"an",
"array",
"2",
")",
"Does",
"the",
"element",
"in",
"the",
"Collection",
"array",
"have",
"all",
... | 8fabc3bfc5b18855ead443db0644608a277d0ea0 | https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/lib/db/mongodb/schemas/contentType.js#L70-L85 | train |
grasshopper-cms/grasshopper-core-nodejs | lib/security/providers/twitter.js | _setUserInfoFromSocialAccount | function _setUserInfoFromSocialAccount(){
return db.users.socialAuthentication('twitter', this.socialUserInfo.id_str)
.then(function(user){
this.userInfo = user;
}.bind(this))
.catch(function(err){ // If user isn't found surpress error. If found and still error th... | javascript | function _setUserInfoFromSocialAccount(){
return db.users.socialAuthentication('twitter', this.socialUserInfo.id_str)
.then(function(user){
this.userInfo = user;
}.bind(this))
.catch(function(err){ // If user isn't found surpress error. If found and still error th... | [
"function",
"_setUserInfoFromSocialAccount",
"(",
")",
"{",
"return",
"db",
".",
"users",
".",
"socialAuthentication",
"(",
"'twitter'",
",",
"this",
".",
"socialUserInfo",
".",
"id_str",
")",
".",
"then",
"(",
"function",
"(",
"user",
")",
"{",
"this",
".",... | Function will look up a user by their social id and then assign it to the userInfo object | [
"Function",
"will",
"look",
"up",
"a",
"user",
"by",
"their",
"social",
"id",
"and",
"then",
"assign",
"it",
"to",
"the",
"userInfo",
"object"
] | 8fabc3bfc5b18855ead443db0644608a277d0ea0 | https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/lib/security/providers/twitter.js#L48-L58 | train |
grasshopper-cms/grasshopper-core-nodejs | lib/grasshopper.js | function(token){
return {
users: require('./runners/users')(token),
tokens: require('./runners/tokens')(token),
content: require('./runners/content')(token),
contentTypes: require('./runners/contentTypes')(token),
nodes: require... | javascript | function(token){
return {
users: require('./runners/users')(token),
tokens: require('./runners/tokens')(token),
content: require('./runners/content')(token),
contentTypes: require('./runners/contentTypes')(token),
nodes: require... | [
"function",
"(",
"token",
")",
"{",
"return",
"{",
"users",
":",
"require",
"(",
"'./runners/users'",
")",
"(",
"token",
")",
",",
"tokens",
":",
"require",
"(",
"'./runners/tokens'",
")",
"(",
"token",
")",
",",
"content",
":",
"require",
"(",
"'./runne... | The grasshopper request function will return back an object that can execute calls to the system.
If you are making an authenticated call then you should send in your token. If you are making a
public call then don't pass in an argument.
@param token
@returns {{users: *, tokens: *, content: *, contentTypes: *, nodes: *... | [
"The",
"grasshopper",
"request",
"function",
"will",
"return",
"back",
"an",
"object",
"that",
"can",
"execute",
"calls",
"to",
"the",
"system",
".",
"If",
"you",
"are",
"making",
"an",
"authenticated",
"call",
"then",
"you",
"should",
"send",
"in",
"your",
... | 8fabc3bfc5b18855ead443db0644608a277d0ea0 | https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/lib/grasshopper.js#L57-L67 | train | |
EasyGraphQL/easygraphql-parser | lib/schemaParser.js | findType | function findType (node, typeInfo, nestedCall) {
typeInfo = typeInfo || { noNull: false, isArray: false, noNullArrayValues: false }
if (!node) {
return typeInfo
}
// Validate nested call, the parser will check first if the array can be null
// then it will check if the values inside can be null
if (!ne... | javascript | function findType (node, typeInfo, nestedCall) {
typeInfo = typeInfo || { noNull: false, isArray: false, noNullArrayValues: false }
if (!node) {
return typeInfo
}
// Validate nested call, the parser will check first if the array can be null
// then it will check if the values inside can be null
if (!ne... | [
"function",
"findType",
"(",
"node",
",",
"typeInfo",
",",
"nestedCall",
")",
"{",
"typeInfo",
"=",
"typeInfo",
"||",
"{",
"noNull",
":",
"false",
",",
"isArray",
":",
"false",
",",
"noNullArrayValues",
":",
"false",
"}",
"if",
"(",
"!",
"node",
")",
"... | Find the type of a field on the Schema
@param node - The graph schema
@param typeInfo - The object with the recursive values
@returns {{type: String, noNull: Boolean, isArray: Boolean}} | [
"Find",
"the",
"type",
"of",
"a",
"field",
"on",
"the",
"Schema"
] | 6425e9a68647a90602e0eda7728ae0929c4f8539 | https://github.com/EasyGraphQL/easygraphql-parser/blob/6425e9a68647a90602e0eda7728ae0929c4f8539/lib/schemaParser.js#L79-L105 | train |
EasyGraphQL/easygraphql-parser | lib/schemaParser.js | findArguments | function findArguments (node) {
if (!node) {
return []
}
return node.map(arg => {
const name = arg.name.value
const fieldType = findType(arg.type)
const isDeprecated = validateIfDeprecated(arg.directives)
return Object.assign({ name, isDeprecated }, fieldType)
})
} | javascript | function findArguments (node) {
if (!node) {
return []
}
return node.map(arg => {
const name = arg.name.value
const fieldType = findType(arg.type)
const isDeprecated = validateIfDeprecated(arg.directives)
return Object.assign({ name, isDeprecated }, fieldType)
})
} | [
"function",
"findArguments",
"(",
"node",
")",
"{",
"if",
"(",
"!",
"node",
")",
"{",
"return",
"[",
"]",
"}",
"return",
"node",
".",
"map",
"(",
"arg",
"=>",
"{",
"const",
"name",
"=",
"arg",
".",
"name",
".",
"value",
"const",
"fieldType",
"=",
... | Find the arguments that are used on the Schema
@param node - The graph schema
@returns {[{name: String, noNull: Boolean, isArray: Boolean, type: String}]} | [
"Find",
"the",
"arguments",
"that",
"are",
"used",
"on",
"the",
"Schema"
] | 6425e9a68647a90602e0eda7728ae0929c4f8539 | https://github.com/EasyGraphQL/easygraphql-parser/blob/6425e9a68647a90602e0eda7728ae0929c4f8539/lib/schemaParser.js#L112-L124 | train |
EasyGraphQL/easygraphql-parser | lib/schemaParser.js | validateIfDeprecated | function validateIfDeprecated (directives) {
if (!directives.length) {
return false
}
return directives.some(directive => directive.name.value === 'deprecated')
} | javascript | function validateIfDeprecated (directives) {
if (!directives.length) {
return false
}
return directives.some(directive => directive.name.value === 'deprecated')
} | [
"function",
"validateIfDeprecated",
"(",
"directives",
")",
"{",
"if",
"(",
"!",
"directives",
".",
"length",
")",
"{",
"return",
"false",
"}",
"return",
"directives",
".",
"some",
"(",
"directive",
"=>",
"directive",
".",
"name",
".",
"value",
"===",
"'de... | Check if a field is deprecated
@param directives - Receive the directives array
@returns {boolean} | [
"Check",
"if",
"a",
"field",
"is",
"deprecated"
] | 6425e9a68647a90602e0eda7728ae0929c4f8539 | https://github.com/EasyGraphQL/easygraphql-parser/blob/6425e9a68647a90602e0eda7728ae0929c4f8539/lib/schemaParser.js#L131-L137 | train |
aureooms/js-itertools | lib/reduce/min.js | min | function min(compare, iterable, dflt = undefined) {
let iterator = (0, _iter.iter)(iterable);
let first = iterator.next();
if (first.done) return dflt;
let smallest = first.value;
for (let candidate of iterator) {
if (compare(candidate, smallest) < 0) {
smallest = candidate;
}
}
retu... | javascript | function min(compare, iterable, dflt = undefined) {
let iterator = (0, _iter.iter)(iterable);
let first = iterator.next();
if (first.done) return dflt;
let smallest = first.value;
for (let candidate of iterator) {
if (compare(candidate, smallest) < 0) {
smallest = candidate;
}
}
retu... | [
"function",
"min",
"(",
"compare",
",",
"iterable",
",",
"dflt",
"=",
"undefined",
")",
"{",
"let",
"iterator",
"=",
"(",
"0",
",",
"_iter",
".",
"iter",
")",
"(",
"iterable",
")",
";",
"let",
"first",
"=",
"iterator",
".",
"next",
"(",
")",
";",
... | Returns the smallest element of the input iterable according
to some comparison function.
@example
min( ( a , b ) => a - b , range( 10 ) ) ; // returns 0
@example
min( ( a , b ) => a - b , range( 0 ) ) ; // returns undefined
@param {Function} compare - The comparison function to use. This function
must be 2-ary. It ... | [
"Returns",
"the",
"smallest",
"element",
"of",
"the",
"input",
"iterable",
"according",
"to",
"some",
"comparison",
"function",
"."
] | 72bafa5f3f957ceb37bdfa87a222364fe4974be3 | https://github.com/aureooms/js-itertools/blob/72bafa5f3f957ceb37bdfa87a222364fe4974be3/lib/reduce/min.js#L30-L49 | train |
syntax-tree/mdast-util-to-nlcst | index.js | toNLCST | function toNLCST(tree, file, Parser, options) {
var settings = options || {}
var parser
// Warn for invalid parameters.
if (!tree || !tree.type) {
throw new Error('mdast-util-to-nlcst expected node')
}
if (!file || !file.messages) {
throw new Error('mdast-util-to-nlcst expected file')
}
// Co... | javascript | function toNLCST(tree, file, Parser, options) {
var settings = options || {}
var parser
// Warn for invalid parameters.
if (!tree || !tree.type) {
throw new Error('mdast-util-to-nlcst expected node')
}
if (!file || !file.messages) {
throw new Error('mdast-util-to-nlcst expected file')
}
// Co... | [
"function",
"toNLCST",
"(",
"tree",
",",
"file",
",",
"Parser",
",",
"options",
")",
"{",
"var",
"settings",
"=",
"options",
"||",
"{",
"}",
"var",
"parser",
"// Warn for invalid parameters.",
"if",
"(",
"!",
"tree",
"||",
"!",
"tree",
".",
"type",
")",
... | Transform `tree` into `nlcst`. | [
"Transform",
"tree",
"into",
"nlcst",
"."
] | a827720d2e5d4f53aa44cc3a3231e4431b4ad4e0 | https://github.com/syntax-tree/mdast-util-to-nlcst/blob/a827720d2e5d4f53aa44cc3a3231e4431b4ad4e0/index.js#L17-L60 | train |
syntax-tree/mdast-util-to-nlcst | index.js | one | function one(config, node) {
var offset = config.location.toOffset
var parser = config.parser
var doc = config.doc
var type = node.type
var start = offset(position.start(node))
var end = offset(position.end(node))
if (config.ignore.indexOf(type) === -1) {
if (config.source.indexOf(type) !== -1) {
... | javascript | function one(config, node) {
var offset = config.location.toOffset
var parser = config.parser
var doc = config.doc
var type = node.type
var start = offset(position.start(node))
var end = offset(position.end(node))
if (config.ignore.indexOf(type) === -1) {
if (config.source.indexOf(type) !== -1) {
... | [
"function",
"one",
"(",
"config",
",",
"node",
")",
"{",
"var",
"offset",
"=",
"config",
".",
"location",
".",
"toOffset",
"var",
"parser",
"=",
"config",
".",
"parser",
"var",
"doc",
"=",
"config",
".",
"doc",
"var",
"type",
"=",
"node",
".",
"type"... | Convert `node` into NLCST. | [
"Convert",
"node",
"into",
"NLCST",
"."
] | a827720d2e5d4f53aa44cc3a3231e4431b4ad4e0 | https://github.com/syntax-tree/mdast-util-to-nlcst/blob/a827720d2e5d4f53aa44cc3a3231e4431b4ad4e0/index.js#L63-L98 | train |
syntax-tree/mdast-util-to-nlcst | index.js | patch | function patch(config, nodes, offset) {
var position = config.location.toPosition
var length = nodes.length
var index = -1
var start = offset
var children
var node
var end
while (++index < length) {
node = nodes[index]
children = node.children
if (children) {
patch(config, children, ... | javascript | function patch(config, nodes, offset) {
var position = config.location.toPosition
var length = nodes.length
var index = -1
var start = offset
var children
var node
var end
while (++index < length) {
node = nodes[index]
children = node.children
if (children) {
patch(config, children, ... | [
"function",
"patch",
"(",
"config",
",",
"nodes",
",",
"offset",
")",
"{",
"var",
"position",
"=",
"config",
".",
"location",
".",
"toPosition",
"var",
"length",
"=",
"nodes",
".",
"length",
"var",
"index",
"=",
"-",
"1",
"var",
"start",
"=",
"offset",... | Patch a position on each node in `nodes`. `offset` is the offset in `file` this run of content starts at. | [
"Patch",
"a",
"position",
"on",
"each",
"node",
"in",
"nodes",
".",
"offset",
"is",
"the",
"offset",
"in",
"file",
"this",
"run",
"of",
"content",
"starts",
"at",
"."
] | a827720d2e5d4f53aa44cc3a3231e4431b4ad4e0 | https://github.com/syntax-tree/mdast-util-to-nlcst/blob/a827720d2e5d4f53aa44cc3a3231e4431b4ad4e0/index.js#L147-L172 | train |
aureooms/js-itertools | lib/reduce/reduce.js | reduce | function reduce(accumulator, iterable, initializer = undefined) {
if (initializer === undefined) {
const iterator = (0, _iter.iter)(iterable);
const first = iterator.next();
if (first.done) {
return undefined;
}
return (0, _reduce2._reduce)(accumulator, iterator, first.value);
}
retu... | javascript | function reduce(accumulator, iterable, initializer = undefined) {
if (initializer === undefined) {
const iterator = (0, _iter.iter)(iterable);
const first = iterator.next();
if (first.done) {
return undefined;
}
return (0, _reduce2._reduce)(accumulator, iterator, first.value);
}
retu... | [
"function",
"reduce",
"(",
"accumulator",
",",
"iterable",
",",
"initializer",
"=",
"undefined",
")",
"{",
"if",
"(",
"initializer",
"===",
"undefined",
")",
"{",
"const",
"iterator",
"=",
"(",
"0",
",",
"_iter",
".",
"iter",
")",
"(",
"iterable",
")",
... | Applies the accumulator function iteratively on the last return value of the
accumulator and the next value in the input iterable. The initial value is
the initializer parameter. If no initial value is given, the first element
of the input iterable is used.
@example
_reduce( ( x , y ) => x + y , range( 10 ) , 0 ) ; //... | [
"Applies",
"the",
"accumulator",
"function",
"iteratively",
"on",
"the",
"last",
"return",
"value",
"of",
"the",
"accumulator",
"and",
"the",
"next",
"value",
"in",
"the",
"input",
"iterable",
".",
"The",
"initial",
"value",
"is",
"the",
"initializer",
"parame... | 72bafa5f3f957ceb37bdfa87a222364fe4974be3 | https://github.com/aureooms/js-itertools/blob/72bafa5f3f957ceb37bdfa87a222364fe4974be3/lib/reduce/reduce.js#L29-L43 | train |
stealjs/steal-npm | npm-extension.js | function(loader, name){
var pkg = utils.pkg.findByName(loader, name.split("/")[0]);
if(pkg) {
var parsed = utils.moduleName.parse(name, pkg.name);
parsed.version = pkg.version;
if(!parsed.modulePath) {
parsed.modulePath = utils.pkg.main(pkg);
}
return utils.moduleName.create(parsed);
}
return... | javascript | function(loader, name){
var pkg = utils.pkg.findByName(loader, name.split("/")[0]);
if(pkg) {
var parsed = utils.moduleName.parse(name, pkg.name);
parsed.version = pkg.version;
if(!parsed.modulePath) {
parsed.modulePath = utils.pkg.main(pkg);
}
return utils.moduleName.create(parsed);
}
return... | [
"function",
"(",
"loader",
",",
"name",
")",
"{",
"var",
"pkg",
"=",
"utils",
".",
"pkg",
".",
"findByName",
"(",
"loader",
",",
"name",
".",
"split",
"(",
"\"/\"",
")",
"[",
"0",
"]",
")",
";",
"if",
"(",
"pkg",
")",
"{",
"var",
"parsed",
"=",... | Given a moduleName convert it into a npm-style moduleName if it belongs to a package. | [
"Given",
"a",
"moduleName",
"convert",
"it",
"into",
"a",
"npm",
"-",
"style",
"moduleName",
"if",
"it",
"belongs",
"to",
"a",
"package",
"."
] | 216463c552cabe7d9dad86d754da784b5dea3d78 | https://github.com/stealjs/steal-npm/blob/216463c552cabe7d9dad86d754da784b5dea3d78/npm-extension.js#L329-L340 | train | |
apostrophecms-legacy/apostrophe-pages | public/js/editor.js | function(callback) {
var page = apos.data.aposPages.page;
var _id = page._id;
$.get('/apos-pages/info', { _id: _id }, function(data) {
var newPathname = data.slug.replace(/^\/\//, '/');
apos.redirect(newPathname);
}).error(function() {
// If th... | javascript | function(callback) {
var page = apos.data.aposPages.page;
var _id = page._id;
$.get('/apos-pages/info', { _id: _id }, function(data) {
var newPathname = data.slug.replace(/^\/\//, '/');
apos.redirect(newPathname);
}).error(function() {
// If th... | [
"function",
"(",
"callback",
")",
"{",
"var",
"page",
"=",
"apos",
".",
"data",
".",
"aposPages",
".",
"page",
";",
"var",
"_id",
"=",
"page",
".",
"_id",
";",
"$",
".",
"get",
"(",
"'/apos-pages/info'",
",",
"{",
"_id",
":",
"_id",
"}",
",",
"fu... | After a reorg the page URL may have changed, be prepared to navigate there or to the home page or just refresh to reflect possible new tabs | [
"After",
"a",
"reorg",
"the",
"page",
"URL",
"may",
"have",
"changed",
"be",
"prepared",
"to",
"navigate",
"there",
"or",
"to",
"the",
"home",
"page",
"or",
"just",
"refresh",
"to",
"reflect",
"possible",
"new",
"tabs"
] | 72eb4b1df351b1c253e9b1c2bd2fe3fff6eb71b3 | https://github.com/apostrophecms-legacy/apostrophe-pages/blob/72eb4b1df351b1c253e9b1c2bd2fe3fff6eb71b3/public/js/editor.js#L546-L556 | train | |
thinkjs/think-loader | loader/bootstrap.js | loadBootstrap | function loadBootstrap(appPath, modules, type = 'worker') {
let bootstrapPath = '';
if (modules.length) {
bootstrapPath = path.join(appPath, 'common/bootstrap');
} else {
bootstrapPath = path.join(appPath, 'bootstrap');
}
const filepath = path.join(bootstrapPath, `${type}.js`);
if (helper.isFile(fil... | javascript | function loadBootstrap(appPath, modules, type = 'worker') {
let bootstrapPath = '';
if (modules.length) {
bootstrapPath = path.join(appPath, 'common/bootstrap');
} else {
bootstrapPath = path.join(appPath, 'bootstrap');
}
const filepath = path.join(bootstrapPath, `${type}.js`);
if (helper.isFile(fil... | [
"function",
"loadBootstrap",
"(",
"appPath",
",",
"modules",
",",
"type",
"=",
"'worker'",
")",
"{",
"let",
"bootstrapPath",
"=",
"''",
";",
"if",
"(",
"modules",
".",
"length",
")",
"{",
"bootstrapPath",
"=",
"path",
".",
"join",
"(",
"appPath",
",",
... | load bootstrap files | [
"load",
"bootstrap",
"files"
] | 680ab3dfd38c3a926b6bd5a026b78a0095cd39f6 | https://github.com/thinkjs/think-loader/blob/680ab3dfd38c3a926b6bd5a026b78a0095cd39f6/loader/bootstrap.js#L8-L20 | 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.