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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
tunnckoCore/acorn-extract-comments | index.js | acornExtractComments | function acornExtractComments (input, opts) {
if (typeof input !== 'string') {
throw new TypeError('acorn-extract-comments expect `input` to be a string')
}
if (!input.length) return []
opts = extend({
ast: false,
line: false,
block: false,
preserve: false,
locations: false,
ecmaVer... | javascript | function acornExtractComments (input, opts) {
if (typeof input !== 'string') {
throw new TypeError('acorn-extract-comments expect `input` to be a string')
}
if (!input.length) return []
opts = extend({
ast: false,
line: false,
block: false,
preserve: false,
locations: false,
ecmaVer... | [
"function",
"acornExtractComments",
"(",
"input",
",",
"opts",
")",
"{",
"if",
"(",
"typeof",
"input",
"!==",
"'string'",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'acorn-extract-comments expect `input` to be a string'",
")",
"}",
"if",
"(",
"!",
"input",
"."... | > Core logic to extract comments
@param {String} `<input>` string from which to get comments
@param {Object} `[opts]` optional options, passed to `acorn`
@return {Array} can have `.ast` property if `opts.ast: true`
@api private | [
">",
"Core",
"logic",
"to",
"extract",
"comments"
] | bcf965d8c85c1a0618348dbdb9f00b3af2591850 | https://github.com/tunnckoCore/acorn-extract-comments/blob/bcf965d8c85c1a0618348dbdb9f00b3af2591850/index.js#L111-L150 | train |
Cloudstek/alfred-hugo | examples/file-cache.js | processComments | function processComments(file) {
let data = JSON.parse(file);
return data.map(x => ({
title: x.name,
subtitle: x.email,
arg: x.id,
valid: true
}));
} | javascript | function processComments(file) {
let data = JSON.parse(file);
return data.map(x => ({
title: x.name,
subtitle: x.email,
arg: x.id,
valid: true
}));
} | [
"function",
"processComments",
"(",
"file",
")",
"{",
"let",
"data",
"=",
"JSON",
".",
"parse",
"(",
"file",
")",
";",
"return",
"data",
".",
"map",
"(",
"x",
"=>",
"(",
"{",
"title",
":",
"x",
".",
"name",
",",
"subtitle",
":",
"x",
".",
"email"... | My fancy processing function that takes longer than I'd like to complete
@param {string} file Input file
@return {Object} | [
"My",
"fancy",
"processing",
"function",
"that",
"takes",
"longer",
"than",
"I",
"d",
"like",
"to",
"complete"
] | e7b0da032be0ca9fd272f02247b843b8f15db0ff | https://github.com/Cloudstek/alfred-hugo/blob/e7b0da032be0ca9fd272f02247b843b8f15db0ff/examples/file-cache.js#L35-L44 | train |
mobify/pinny | dist/pinny.js | function(divisor) {
var coverage;
var percent = this.options.coverage.match(/(\d*)%$/);
if (percent) {
coverage = 100 - parseInt(percent[1]);
if (divisor) {
coverage = coverage / divisor;
}
}
... | javascript | function(divisor) {
var coverage;
var percent = this.options.coverage.match(/(\d*)%$/);
if (percent) {
coverage = 100 - parseInt(percent[1]);
if (divisor) {
coverage = coverage / divisor;
}
}
... | [
"function",
"(",
"divisor",
")",
"{",
"var",
"coverage",
";",
"var",
"percent",
"=",
"this",
".",
"options",
".",
"coverage",
".",
"match",
"(",
"/",
"(\\d*)%$",
"/",
")",
";",
"if",
"(",
"percent",
")",
"{",
"coverage",
"=",
"100",
"-",
"parseInt",
... | Takes the coverage option and turns it into a effect value | [
"Takes",
"the",
"coverage",
"option",
"and",
"turns",
"it",
"into",
"a",
"effect",
"value"
] | ffa8e340eb50e6ff27126c75f54d6ff3edfa5d82 | https://github.com/mobify/pinny/blob/ffa8e340eb50e6ff27126c75f54d6ff3edfa5d82/dist/pinny.js#L373-L386 | train | |
mobify/pinny | dist/pinny.js | function() {
// If lockup is already locked don't try to disable inputs again
if (this.$pinny.lockup('isLocked')) {
return;
}
var $focusableElements = $(FOCUSABLE_ELEMENTS).not(function() {
return $(this).isChildOf('.' + classes.PINNY);
... | javascript | function() {
// If lockup is already locked don't try to disable inputs again
if (this.$pinny.lockup('isLocked')) {
return;
}
var $focusableElements = $(FOCUSABLE_ELEMENTS).not(function() {
return $(this).isChildOf('.' + classes.PINNY);
... | [
"function",
"(",
")",
"{",
"// If lockup is already locked don't try to disable inputs again",
"if",
"(",
"this",
".",
"$pinny",
".",
"lockup",
"(",
"'isLocked'",
")",
")",
"{",
"return",
";",
"}",
"var",
"$focusableElements",
"=",
"$",
"(",
"FOCUSABLE_ELEMENTS",
... | Traps any tabbing within the visible Pinny window
by disabling tabbing into all inputs outside of
pinny using a negative tabindex. | [
"Traps",
"any",
"tabbing",
"within",
"the",
"visible",
"Pinny",
"window",
"by",
"disabling",
"tabbing",
"into",
"all",
"inputs",
"outside",
"of",
"pinny",
"using",
"a",
"negative",
"tabindex",
"."
] | ffa8e340eb50e6ff27126c75f54d6ff3edfa5d82 | https://github.com/mobify/pinny/blob/ffa8e340eb50e6ff27126c75f54d6ff3edfa5d82/dist/pinny.js#L432-L450 | train | |
mobify/pinny | dist/pinny.js | function() {
// At this point, this pinny has been closed and lockup has unlocked.
// If there are any other pinny's open we don't want to re-enable the
// inputs as they still require them to be disabled.
if (this._activePinnies()) {
return;
}... | javascript | function() {
// At this point, this pinny has been closed and lockup has unlocked.
// If there are any other pinny's open we don't want to re-enable the
// inputs as they still require them to be disabled.
if (this._activePinnies()) {
return;
}... | [
"function",
"(",
")",
"{",
"// At this point, this pinny has been closed and lockup has unlocked.",
"// If there are any other pinny's open we don't want to re-enable the",
"// inputs as they still require them to be disabled.",
"if",
"(",
"this",
".",
"_activePinnies",
"(",
")",
")",
... | Re-enables tabbing in inputs not inside Pinny's content | [
"Re",
"-",
"enables",
"tabbing",
"in",
"inputs",
"not",
"inside",
"Pinny",
"s",
"content"
] | ffa8e340eb50e6ff27126c75f54d6ff3edfa5d82 | https://github.com/mobify/pinny/blob/ffa8e340eb50e6ff27126c75f54d6ff3edfa5d82/dist/pinny.js#L455-L475 | train | |
darren-lester/nihongo | src/parsers.js | basicParser | function basicParser(condition, str) {
let result = [];
for (let i = 0; i < str.length; ++i) {
if (condition(str[i])) {
result.push(str[i]);
}
}
return result;
} | javascript | function basicParser(condition, str) {
let result = [];
for (let i = 0; i < str.length; ++i) {
if (condition(str[i])) {
result.push(str[i]);
}
}
return result;
} | [
"function",
"basicParser",
"(",
"condition",
",",
"str",
")",
"{",
"let",
"result",
"=",
"[",
"]",
";",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"str",
".",
"length",
";",
"++",
"i",
")",
"{",
"if",
"(",
"condition",
"(",
"str",
"[",
... | returns an array of all characters in a string that fulfill a condition | [
"returns",
"an",
"array",
"of",
"all",
"characters",
"in",
"a",
"string",
"that",
"fulfill",
"a",
"condition"
] | 2ca0fbfac7aa41c8b5d8476fc6da0ab1f0ea27e7 | https://github.com/darren-lester/nihongo/blob/2ca0fbfac7aa41c8b5d8476fc6da0ab1f0ea27e7/src/parsers.js#L10-L20 | train |
darren-lester/nihongo | src/parsers.js | accumulativeParser | function accumulativeParser(condition, str) {
let accumulations = [];
let accumulator = "";
for (let i = 0; i < str.length; ++i) {
let ch = str[i];
if (condition(ch)) {
accumulator += ch;
} else if (accumulator !== "") {
accumulations.push(accumulator);
... | javascript | function accumulativeParser(condition, str) {
let accumulations = [];
let accumulator = "";
for (let i = 0; i < str.length; ++i) {
let ch = str[i];
if (condition(ch)) {
accumulator += ch;
} else if (accumulator !== "") {
accumulations.push(accumulator);
... | [
"function",
"accumulativeParser",
"(",
"condition",
",",
"str",
")",
"{",
"let",
"accumulations",
"=",
"[",
"]",
";",
"let",
"accumulator",
"=",
"\"\"",
";",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"str",
".",
"length",
";",
"++",
"i",
")"... | returns an array of all sequences of characters in a string that fulfill a condition | [
"returns",
"an",
"array",
"of",
"all",
"sequences",
"of",
"characters",
"in",
"a",
"string",
"that",
"fulfill",
"a",
"condition"
] | 2ca0fbfac7aa41c8b5d8476fc6da0ab1f0ea27e7 | https://github.com/darren-lester/nihongo/blob/2ca0fbfac7aa41c8b5d8476fc6da0ab1f0ea27e7/src/parsers.js#L24-L40 | train |
mahirshah/css-property-parser | src/initialValueMap.js | computeInitialValue | function computeInitialValue(propertyName) {
if (properties[propertyName] === undefined) return; // unknown property
if (initialValueMap[propertyName]) return; // value is cached.
let initialValue = properties[propertyName].initial;
if (Array.isArray(initialValue)) {
// it's a shorthand
initialValue.for... | javascript | function computeInitialValue(propertyName) {
if (properties[propertyName] === undefined) return; // unknown property
if (initialValueMap[propertyName]) return; // value is cached.
let initialValue = properties[propertyName].initial;
if (Array.isArray(initialValue)) {
// it's a shorthand
initialValue.for... | [
"function",
"computeInitialValue",
"(",
"propertyName",
")",
"{",
"if",
"(",
"properties",
"[",
"propertyName",
"]",
"===",
"undefined",
")",
"return",
";",
"// unknown property",
"if",
"(",
"initialValueMap",
"[",
"propertyName",
"]",
")",
"return",
";",
"// va... | Warms up the cache for a single property.
@private
@param {string} propertyName - the property name to warm up.
@returns {void} this function runs for its side effects only. | [
"Warms",
"up",
"the",
"cache",
"for",
"a",
"single",
"property",
"."
] | 012889d04e6b99f76352c9b6437c513e2ce54267 | https://github.com/mahirshah/css-property-parser/blob/012889d04e6b99f76352c9b6437c513e2ce54267/src/initialValueMap.js#L115-L146 | train |
mahirshah/css-property-parser | src/initialValueMap.js | initialValues | function initialValues(property, recursivelyResolve = false, includeShorthands = false) {
computeInitialValue(property);
if (recursivelyResolve) {
const initials = includeShorthands ? initialValueRecursiveMap[property] : initialValueConcreteMap[property];
if (!initials) {
// It's an unknown property, ... | javascript | function initialValues(property, recursivelyResolve = false, includeShorthands = false) {
computeInitialValue(property);
if (recursivelyResolve) {
const initials = includeShorthands ? initialValueRecursiveMap[property] : initialValueConcreteMap[property];
if (!initials) {
// It's an unknown property, ... | [
"function",
"initialValues",
"(",
"property",
",",
"recursivelyResolve",
"=",
"false",
",",
"includeShorthands",
"=",
"false",
")",
"{",
"computeInitialValue",
"(",
"property",
")",
";",
"if",
"(",
"recursivelyResolve",
")",
"{",
"const",
"initials",
"=",
"inclu... | Get the initial values for a property.
@param {string} property - the property name
@param {boolean} recursivelyResolve - when given a shorthand property,
causes the result to include long hand values.
@param {boolean} includeShorthands - when resolving recursively, causes the
the result to include the specified shorth... | [
"Get",
"the",
"initial",
"values",
"for",
"a",
"property",
"."
] | 012889d04e6b99f76352c9b6437c513e2ce54267 | https://github.com/mahirshah/css-property-parser/blob/012889d04e6b99f76352c9b6437c513e2ce54267/src/initialValueMap.js#L181-L194 | train |
sweetcaptcha/sweetCaptcha-sdk-js | example.js | validateCaptcha | function validateCaptcha(captchaKey, captchaValue, callback) {
// callback = function(err, isValid) {...}
sweetcaptcha.api('check', {sckey: captchaKey, scvalue: captchaValue}, function(err, response){
if (err) return callback(err);
if (response === 'true') {
// valid captcha
return callback(nu... | javascript | function validateCaptcha(captchaKey, captchaValue, callback) {
// callback = function(err, isValid) {...}
sweetcaptcha.api('check', {sckey: captchaKey, scvalue: captchaValue}, function(err, response){
if (err) return callback(err);
if (response === 'true') {
// valid captcha
return callback(nu... | [
"function",
"validateCaptcha",
"(",
"captchaKey",
",",
"captchaValue",
",",
"callback",
")",
"{",
"// callback = function(err, isValid) {...}",
"sweetcaptcha",
".",
"api",
"(",
"'check'",
",",
"{",
"sckey",
":",
"captchaKey",
",",
"scvalue",
":",
"captchaValue",
"}"... | Validate using sckey and scvalue, hidden inputs from previous HTML | [
"Validate",
"using",
"sckey",
"and",
"scvalue",
"hidden",
"inputs",
"from",
"previous",
"HTML"
] | f58dd1b1bec69cfaefe6b6033b67eaee68b9cfce | https://github.com/sweetcaptcha/sweetCaptcha-sdk-js/blob/f58dd1b1bec69cfaefe6b6033b67eaee68b9cfce/example.js#L14-L30 | train |
tkellen/requirejs-library-skeleton | vendor/r.js | function (depMap, parent) {
var mod = registry[depMap.id];
if (mod) {
getModule(depMap).enable();
}
} | javascript | function (depMap, parent) {
var mod = registry[depMap.id];
if (mod) {
getModule(depMap).enable();
}
} | [
"function",
"(",
"depMap",
",",
"parent",
")",
"{",
"var",
"mod",
"=",
"registry",
"[",
"depMap",
".",
"id",
"]",
";",
"if",
"(",
"mod",
")",
"{",
"getModule",
"(",
"depMap",
")",
".",
"enable",
"(",
")",
";",
"}",
"}"
] | Called to enable a module if it is still in the registry
awaiting enablement. parent module is passed in for context,
used by the optimizer. | [
"Called",
"to",
"enable",
"a",
"module",
"if",
"it",
"is",
"still",
"in",
"the",
"registry",
"awaiting",
"enablement",
".",
"parent",
"module",
"is",
"passed",
"in",
"for",
"context",
"used",
"by",
"the",
"optimizer",
"."
] | c4ff186c588ba9418af71afb64cf7d000aa36bfb | https://github.com/tkellen/requirejs-library-skeleton/blob/c4ff186c588ba9418af71afb64cf7d000aa36bfb/vendor/r.js#L1549-L1554 | train | |
tkellen/requirejs-library-skeleton | vendor/r.js | skipComment | function skipComment() {
var ch, blockComment, lineComment;
blockComment = false;
lineComment = false;
while (index < length) {
ch = source[index];
if (lineComment) {
ch = nextChar();
if (isLineTerminator(ch)) {
... | javascript | function skipComment() {
var ch, blockComment, lineComment;
blockComment = false;
lineComment = false;
while (index < length) {
ch = source[index];
if (lineComment) {
ch = nextChar();
if (isLineTerminator(ch)) {
... | [
"function",
"skipComment",
"(",
")",
"{",
"var",
"ch",
",",
"blockComment",
",",
"lineComment",
";",
"blockComment",
"=",
"false",
";",
"lineComment",
"=",
"false",
";",
"while",
"(",
"index",
"<",
"length",
")",
"{",
"ch",
"=",
"source",
"[",
"index",
... | 7.4 Comments | [
"7",
".",
"4",
"Comments"
] | c4ff186c588ba9418af71afb64cf7d000aa36bfb | https://github.com/tkellen/requirejs-library-skeleton/blob/c4ff186c588ba9418af71afb64cf7d000aa36bfb/vendor/r.js#L3616-L3686 | train |
tkellen/requirejs-library-skeleton | vendor/r.js | addComment | function addComment(start, end, type, value) {
assert(typeof start === 'number', 'Comment must have valid position');
// Because the way the actual token is scanned, often the comments
// (if any) are skipped twice during the lexical analysis.
// Thus, we need to skip adding a comment i... | javascript | function addComment(start, end, type, value) {
assert(typeof start === 'number', 'Comment must have valid position');
// Because the way the actual token is scanned, often the comments
// (if any) are skipped twice during the lexical analysis.
// Thus, we need to skip adding a comment i... | [
"function",
"addComment",
"(",
"start",
",",
"end",
",",
"type",
",",
"value",
")",
"{",
"assert",
"(",
"typeof",
"start",
"===",
"'number'",
",",
"'Comment must have valid position'",
")",
";",
"// Because the way the actual token is scanned, often the comments",
"// (... | The following functions are needed only when the option to preserve the comments is active. | [
"The",
"following",
"functions",
"are",
"needed",
"only",
"when",
"the",
"option",
"to",
"preserve",
"the",
"comments",
"is",
"active",
"."
] | c4ff186c588ba9418af71afb64cf7d000aa36bfb | https://github.com/tkellen/requirejs-library-skeleton/blob/c4ff186c588ba9418af71afb64cf7d000aa36bfb/vendor/r.js#L6323-L6341 | train |
mahirshah/css-property-parser | src/isInitialValue.js | isInitialValue | function isInitialValue(property, value) {
const expanded = expandShorthandProperty(property, value, true, true);
return Object.entries(expanded).every(([prop, val]) => {
// eslint-disable-next-line no-param-reassign
val = val.toLowerCase();
if (isShorthandProperty(prop)) return true;
if (val === 'i... | javascript | function isInitialValue(property, value) {
const expanded = expandShorthandProperty(property, value, true, true);
return Object.entries(expanded).every(([prop, val]) => {
// eslint-disable-next-line no-param-reassign
val = val.toLowerCase();
if (isShorthandProperty(prop)) return true;
if (val === 'i... | [
"function",
"isInitialValue",
"(",
"property",
",",
"value",
")",
"{",
"const",
"expanded",
"=",
"expandShorthandProperty",
"(",
"property",
",",
"value",
",",
"true",
",",
"true",
")",
";",
"return",
"Object",
".",
"entries",
"(",
"expanded",
")",
".",
"e... | Because of the `initial` keyword and shorthand expansion,
there are many possible values that are equivalently identical
with the initial value of a css property. This function
returns true for all possible values that have the effect of
setting a property to its initial value.
@param {string} property the property to... | [
"Because",
"of",
"the",
"initial",
"keyword",
"and",
"shorthand",
"expansion",
"there",
"are",
"many",
"possible",
"values",
"that",
"are",
"equivalently",
"identical",
"with",
"the",
"initial",
"value",
"of",
"a",
"css",
"property",
".",
"This",
"function",
"... | 012889d04e6b99f76352c9b6437c513e2ce54267 | https://github.com/mahirshah/css-property-parser/blob/012889d04e6b99f76352c9b6437c513e2ce54267/src/isInitialValue.js#L16-L32 | train |
Smile-SA/grunt-build-html | tasks/buildHtml-retrieve-remote.js | function (fragmentKey, cachePath, skipCache, callback) {
if (skipCache) {
debug(' cache is disabled so...');
callback(false);
} else {
fs.exists(cachePath + '/' + fragmentKey, callback);
}
} | javascript | function (fragmentKey, cachePath, skipCache, callback) {
if (skipCache) {
debug(' cache is disabled so...');
callback(false);
} else {
fs.exists(cachePath + '/' + fragmentKey, callback);
}
} | [
"function",
"(",
"fragmentKey",
",",
"cachePath",
",",
"skipCache",
",",
"callback",
")",
"{",
"if",
"(",
"skipCache",
")",
"{",
"debug",
"(",
"' cache is disabled so...'",
")",
";",
"callback",
"(",
"false",
")",
";",
"}",
"else",
"{",
"fs",
".",
"exis... | Know if content is already in file system
@param fragmentKey Remote content key
@param cachePath Temp FS cache directory
@param skipCache If false, attempt to retrieve remote content from files
@param callback Method to call when data is retrieved | [
"Know",
"if",
"content",
"is",
"already",
"in",
"file",
"system"
] | 6fe1644ff6d08e0eada9482ae9dcdb0d4169ea2e | https://github.com/Smile-SA/grunt-build-html/blob/6fe1644ff6d08e0eada9482ae9dcdb0d4169ea2e/tasks/buildHtml-retrieve-remote.js#L26-L33 | train | |
Smile-SA/grunt-build-html | tasks/buildHtml-retrieve-remote.js | function (data, fragmentKey, cachePath, callback) {
debug(' write content in file system');
var basePath = path.dirname(fragmentKey);
if (basePath){
mkdirp.sync(cachePath + '/' + basePath);
}
fs.writeFile(cachePath + '/' + fragmentKey, data, function (err) {
if (err) {
... | javascript | function (data, fragmentKey, cachePath, callback) {
debug(' write content in file system');
var basePath = path.dirname(fragmentKey);
if (basePath){
mkdirp.sync(cachePath + '/' + basePath);
}
fs.writeFile(cachePath + '/' + fragmentKey, data, function (err) {
if (err) {
... | [
"function",
"(",
"data",
",",
"fragmentKey",
",",
"cachePath",
",",
"callback",
")",
"{",
"debug",
"(",
"' write content in file system'",
")",
";",
"var",
"basePath",
"=",
"path",
".",
"dirname",
"(",
"fragmentKey",
")",
";",
"if",
"(",
"basePath",
")",
... | Dump remote content in file system
@param data Remote content data
@param fragmentKey Remote content key
@param cachePath Temp FS cache directory
@param callback Method to call when file is written | [
"Dump",
"remote",
"content",
"in",
"file",
"system"
] | 6fe1644ff6d08e0eada9482ae9dcdb0d4169ea2e | https://github.com/Smile-SA/grunt-build-html/blob/6fe1644ff6d08e0eada9482ae9dcdb0d4169ea2e/tasks/buildHtml-retrieve-remote.js#L58-L71 | train | |
MiguelCastillo/bit-loader | src/plugin/plugin.js | runHandler | function runHandler(plugin, handler, cancel) {
return function runHandlerDelegate(data) {
if (!data) {
return Promise.resolve();
}
return Promise
.resolve(handler.handler(data, plugin, cancel))
.then(function(result) {
return data.configure(result);
});
};
} | javascript | function runHandler(plugin, handler, cancel) {
return function runHandlerDelegate(data) {
if (!data) {
return Promise.resolve();
}
return Promise
.resolve(handler.handler(data, plugin, cancel))
.then(function(result) {
return data.configure(result);
});
};
} | [
"function",
"runHandler",
"(",
"plugin",
",",
"handler",
",",
"cancel",
")",
"{",
"return",
"function",
"runHandlerDelegate",
"(",
"data",
")",
"{",
"if",
"(",
"!",
"data",
")",
"{",
"return",
"Promise",
".",
"resolve",
"(",
")",
";",
"}",
"return",
"P... | Method that return a function that executes a plugin handler. | [
"Method",
"that",
"return",
"a",
"function",
"that",
"executes",
"a",
"plugin",
"handler",
"."
] | da9d18952d87014fdb09e7a8320a24cbf1c2b436 | https://github.com/MiguelCastillo/bit-loader/blob/da9d18952d87014fdb09e7a8320a24cbf1c2b436/src/plugin/plugin.js#L111-L123 | train |
feedhenry/fh-mbaas-client | lib/app/appforms/forms.js | submitFormData | function submitFormData(params, cb) {
var resourcePath = config.addURIParams("/appforms/forms/:id/submitFormData", params);
var method = "POST";
var data = params.submission;
params.resourcePath = resourcePath;
params.method = method;
params.data = data;
mbaasRequest.app(params, cb);
} | javascript | function submitFormData(params, cb) {
var resourcePath = config.addURIParams("/appforms/forms/:id/submitFormData", params);
var method = "POST";
var data = params.submission;
params.resourcePath = resourcePath;
params.method = method;
params.data = data;
mbaasRequest.app(params, cb);
} | [
"function",
"submitFormData",
"(",
"params",
",",
"cb",
")",
"{",
"var",
"resourcePath",
"=",
"config",
".",
"addURIParams",
"(",
"\"/appforms/forms/:id/submitFormData\"",
",",
"params",
")",
";",
"var",
"method",
"=",
"\"POST\"",
";",
"var",
"data",
"=",
"par... | Making A Submisison Against A Form | [
"Making",
"A",
"Submisison",
"Against",
"A",
"Form"
] | 2d5a9cbb32e1b2464d71ffa18513358fea388859 | https://github.com/feedhenry/fh-mbaas-client/blob/2d5a9cbb32e1b2464d71ffa18513358fea388859/lib/app/appforms/forms.js#L39-L49 | train |
feedhenry/fh-mbaas-client | lib/app/appforms/forms.js | search | function search(params, cb) {
var resourcePath = config.addURIParams("/appforms/forms/search", params);
var method = "POST";
var data = params.searchParams;
params.resourcePath = resourcePath;
params.method = method;
params.data = data;
mbaasRequest.app(params, cb);
} | javascript | function search(params, cb) {
var resourcePath = config.addURIParams("/appforms/forms/search", params);
var method = "POST";
var data = params.searchParams;
params.resourcePath = resourcePath;
params.method = method;
params.data = data;
mbaasRequest.app(params, cb);
} | [
"function",
"search",
"(",
"params",
",",
"cb",
")",
"{",
"var",
"resourcePath",
"=",
"config",
".",
"addURIParams",
"(",
"\"/appforms/forms/search\"",
",",
"params",
")",
";",
"var",
"method",
"=",
"\"POST\"",
";",
"var",
"data",
"=",
"params",
".",
"sear... | Search For Forms Based On Ids. This will return fully populated forms
@param params
@param cb | [
"Search",
"For",
"Forms",
"Based",
"On",
"Ids",
".",
"This",
"will",
"return",
"fully",
"populated",
"forms"
] | 2d5a9cbb32e1b2464d71ffa18513358fea388859 | https://github.com/feedhenry/fh-mbaas-client/blob/2d5a9cbb32e1b2464d71ffa18513358fea388859/lib/app/appforms/forms.js#L57-L67 | train |
tmorin/ceb | dist/systemjs/helper/functions.js | partial | function partial(fn) {
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
return function () {
return fn.apply(this, args.concat(toArray(arguments)));
};
} | javascript | function partial(fn) {
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
return function () {
return fn.apply(this, args.concat(toArray(arguments)));
};
} | [
"function",
"partial",
"(",
"fn",
")",
"{",
"for",
"(",
"var",
"_len",
"=",
"arguments",
".",
"length",
",",
"args",
"=",
"Array",
"(",
"_len",
">",
"1",
"?",
"_len",
"-",
"1",
":",
"0",
")",
",",
"_key",
"=",
"1",
";",
"_key",
"<",
"_len",
"... | Partially apply a function by filling in any number of its arguments, without changing its dynamic this value.
@param {!Function} fn the function to partially apply arguments to
@param {...} args the arguments to be partially applied
@returns {Function} the new partially applied function | [
"Partially",
"apply",
"a",
"function",
"by",
"filling",
"in",
"any",
"number",
"of",
"its",
"arguments",
"without",
"changing",
"its",
"dynamic",
"this",
"value",
"."
] | 7cc0904b482aa99e5123302c5de4401f7a80af02 | https://github.com/tmorin/ceb/blob/7cc0904b482aa99e5123302c5de4401f7a80af02/dist/systemjs/helper/functions.js#L15-L23 | train |
harrisiirak/bunyan-redis | index.js | RedisTransport | function RedisTransport (opts) {
this._container = opts.container || 'logs';
this._length = opts.length || undefined;
this._client = opts.client || redis.createClient(opts.port, opts.host);
// Authorize cleint
if (opts.hasOwnProperty('password')) {
this._client.auth(opts.password);
}
// Set database... | javascript | function RedisTransport (opts) {
this._container = opts.container || 'logs';
this._length = opts.length || undefined;
this._client = opts.client || redis.createClient(opts.port, opts.host);
// Authorize cleint
if (opts.hasOwnProperty('password')) {
this._client.auth(opts.password);
}
// Set database... | [
"function",
"RedisTransport",
"(",
"opts",
")",
"{",
"this",
".",
"_container",
"=",
"opts",
".",
"container",
"||",
"'logs'",
";",
"this",
".",
"_length",
"=",
"opts",
".",
"length",
"||",
"undefined",
";",
"this",
".",
"_client",
"=",
"opts",
".",
"c... | Create a new RedisTransport instance
@param {Object} opts Transport options object
@param {String} opts.container Redis key
@param {Number} opts.length List max length
@param {Object} opts.client Redis client instance
@param {String} opts.host Redis host
@param {Number} opts.port Redis port
@param {Number} opts.db Red... | [
"Create",
"a",
"new",
"RedisTransport",
"instance"
] | d5035e5f2cdee44f20372c15ea181d70aa129fd1 | https://github.com/harrisiirak/bunyan-redis/blob/d5035e5f2cdee44f20372c15ea181d70aa129fd1/index.js#L22-L36 | train |
harrisiirak/bunyan-redis | index.js | findListLength | function findListLength (args, next) {
client.llen(self._container, function listLengthFound (err, length) {
if (err) {
return next(err);
}
args.length = length;
return next(null, length);
});
} | javascript | function findListLength (args, next) {
client.llen(self._container, function listLengthFound (err, length) {
if (err) {
return next(err);
}
args.length = length;
return next(null, length);
});
} | [
"function",
"findListLength",
"(",
"args",
",",
"next",
")",
"{",
"client",
".",
"llen",
"(",
"self",
".",
"_container",
",",
"function",
"listLengthFound",
"(",
"err",
",",
"length",
")",
"{",
"if",
"(",
"err",
")",
"{",
"return",
"next",
"(",
"err",
... | Find list length | [
"Find",
"list",
"length"
] | d5035e5f2cdee44f20372c15ea181d70aa129fd1 | https://github.com/harrisiirak/bunyan-redis/blob/d5035e5f2cdee44f20372c15ea181d70aa129fd1/index.js#L55-L64 | train |
harrisiirak/bunyan-redis | index.js | trimList | function trimList (args, next) {
if (self._length === undefined || args.length <= self._length) {
return next();
}
client.ltrim(self._container, 0, self._length, function dataStored (err) {
if (err) {
return next(err);
}
return next();
... | javascript | function trimList (args, next) {
if (self._length === undefined || args.length <= self._length) {
return next();
}
client.ltrim(self._container, 0, self._length, function dataStored (err) {
if (err) {
return next(err);
}
return next();
... | [
"function",
"trimList",
"(",
"args",
",",
"next",
")",
"{",
"if",
"(",
"self",
".",
"_length",
"===",
"undefined",
"||",
"args",
".",
"length",
"<=",
"self",
".",
"_length",
")",
"{",
"return",
"next",
"(",
")",
";",
"}",
"client",
".",
"ltrim",
"(... | Trim data list | [
"Trim",
"data",
"list"
] | d5035e5f2cdee44f20372c15ea181d70aa129fd1 | https://github.com/harrisiirak/bunyan-redis/blob/d5035e5f2cdee44f20372c15ea181d70aa129fd1/index.js#L79-L91 | train |
theboyWhoCriedWoolf/transition-manager | src/core/fsm.js | _transitionTo | function _transitionTo( nextState, action, data )
{
_cancelled = false;
_transitionCompleted = false;
if( isCancelled() ) { return false; }
if( _currentState ) {
let previousState = _currentState;
if(_options.history){ _history.push(previousState.name); }
}
_currentState = nextState;
if(... | javascript | function _transitionTo( nextState, action, data )
{
_cancelled = false;
_transitionCompleted = false;
if( isCancelled() ) { return false; }
if( _currentState ) {
let previousState = _currentState;
if(_options.history){ _history.push(previousState.name); }
}
_currentState = nextState;
if(... | [
"function",
"_transitionTo",
"(",
"nextState",
",",
"action",
",",
"data",
")",
"{",
"_cancelled",
"=",
"false",
";",
"_transitionCompleted",
"=",
"false",
";",
"if",
"(",
"isCancelled",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"_curre... | transition to the next state
@param {object} nextState new state object
@param {string} action actionID
@param {object} data data sent with the action
@param {string} actionIdentifier state and action combined to make a unique string | [
"transition",
"to",
"the",
"next",
"state"
] | a20fda0bb07c0098bf709ea03770b1ee2a855655 | https://github.com/theboyWhoCriedWoolf/transition-manager/blob/a20fda0bb07c0098bf709ea03770b1ee2a855655/src/core/fsm.js#L52-L73 | train |
theboyWhoCriedWoolf/transition-manager | src/core/fsm.js | _processActionQueue | function _processActionQueue()
{
if( _actionQueue.length > 0 ) {
var stateEvent = _actionQueue.shift();
if(!_currentState.getTarget(stateEvent.action)) {
_processActionQueue();
}
else {
} FSM.action( stateEvent.action, stateEvent.data );
return false;
}
FSM.log('State transition Com... | javascript | function _processActionQueue()
{
if( _actionQueue.length > 0 ) {
var stateEvent = _actionQueue.shift();
if(!_currentState.getTarget(stateEvent.action)) {
_processActionQueue();
}
else {
} FSM.action( stateEvent.action, stateEvent.data );
return false;
}
FSM.log('State transition Com... | [
"function",
"_processActionQueue",
"(",
")",
"{",
"if",
"(",
"_actionQueue",
".",
"length",
">",
"0",
")",
"{",
"var",
"stateEvent",
"=",
"_actionQueue",
".",
"shift",
"(",
")",
";",
"if",
"(",
"!",
"_currentState",
".",
"getTarget",
"(",
"stateEvent",
"... | If states have queued up
loop through and action all states in the queue until
none remain | [
"If",
"states",
"have",
"queued",
"up",
"loop",
"through",
"and",
"action",
"all",
"states",
"in",
"the",
"queue",
"until",
"none",
"remain"
] | a20fda0bb07c0098bf709ea03770b1ee2a855655 | https://github.com/theboyWhoCriedWoolf/transition-manager/blob/a20fda0bb07c0098bf709ea03770b1ee2a855655/src/core/fsm.js#L80-L96 | train |
theboyWhoCriedWoolf/transition-manager | src/core/fsm.js | function( action, target, actionIdnentifier ) {
if( this._transitions[ action ] ) { return false; }
this._transitions[ action ] = { target : target, _id : actionIdnentifier };
} | javascript | function( action, target, actionIdnentifier ) {
if( this._transitions[ action ] ) { return false; }
this._transitions[ action ] = { target : target, _id : actionIdnentifier };
} | [
"function",
"(",
"action",
",",
"target",
",",
"actionIdnentifier",
")",
"{",
"if",
"(",
"this",
".",
"_transitions",
"[",
"action",
"]",
")",
"{",
"return",
"false",
";",
"}",
"this",
".",
"_transitions",
"[",
"action",
"]",
"=",
"{",
"target",
":",
... | add the available trasitions for each state
@param {string} action e.g.'GOTOHOME'
@param {string} target e.g. 'HOME' | [
"add",
"the",
"available",
"trasitions",
"for",
"each",
"state"
] | a20fda0bb07c0098bf709ea03770b1ee2a855655 | https://github.com/theboyWhoCriedWoolf/transition-manager/blob/a20fda0bb07c0098bf709ea03770b1ee2a855655/src/core/fsm.js#L268-L271 | train | |
codemix/modeling | lib/factory.js | function (Class, descriptors, staticDescriptors) {
var castAll = Casting.forDescriptors(descriptors);
function cast (value) {
if (!(value instanceof this)) {
return new this(castAll(value));
}
else {
return castAll(value);
}
}
cast.isAutoGenerated = true;
retu... | javascript | function (Class, descriptors, staticDescriptors) {
var castAll = Casting.forDescriptors(descriptors);
function cast (value) {
if (!(value instanceof this)) {
return new this(castAll(value));
}
else {
return castAll(value);
}
}
cast.isAutoGenerated = true;
retu... | [
"function",
"(",
"Class",
",",
"descriptors",
",",
"staticDescriptors",
")",
"{",
"var",
"castAll",
"=",
"Casting",
".",
"forDescriptors",
"(",
"descriptors",
")",
";",
"function",
"cast",
"(",
"value",
")",
"{",
"if",
"(",
"!",
"(",
"value",
"instanceof",... | Create a function which can cast objects to this class.
@param {Function} Class The class.
@param {Object} descriptors The property descriptors.
@param {Object} staticDescriptors The static property descriptors.
@return {Function} The generated function. | [
"Create",
"a",
"function",
"which",
"can",
"cast",
"objects",
"to",
"this",
"class",
"."
] | 7c95e2bae2e5ea12565a567a55535fe4d63c513c | https://github.com/codemix/modeling/blob/7c95e2bae2e5ea12565a567a55535fe4d63c513c/lib/factory.js#L75-L88 | train | |
codemix/modeling | lib/factory.js | function (Class, descriptors, staticDescriptors) {
var validate = Validating.forDescriptors(descriptors);
validate.isAutoGenerated = true;
return validate;
} | javascript | function (Class, descriptors, staticDescriptors) {
var validate = Validating.forDescriptors(descriptors);
validate.isAutoGenerated = true;
return validate;
} | [
"function",
"(",
"Class",
",",
"descriptors",
",",
"staticDescriptors",
")",
"{",
"var",
"validate",
"=",
"Validating",
".",
"forDescriptors",
"(",
"descriptors",
")",
";",
"validate",
".",
"isAutoGenerated",
"=",
"true",
";",
"return",
"validate",
";",
"}"
] | Create a function which can validate instances of the class.
@param {Function} Class The class.
@param {Object} descriptors The property descriptors.
@param {Object} staticDescriptors The static property descriptors.
@return {Function} The generated function. | [
"Create",
"a",
"function",
"which",
"can",
"validate",
"instances",
"of",
"the",
"class",
"."
] | 7c95e2bae2e5ea12565a567a55535fe4d63c513c | https://github.com/codemix/modeling/blob/7c95e2bae2e5ea12565a567a55535fe4d63c513c/lib/factory.js#L98-L102 | train | |
codemix/modeling | lib/factory.js | function (Class, descriptors, staticDescriptors) {
var casters = {},
validators = {},
body = '"use strict";\n\
var valid = true,\n\
errors = {},\n\
result;\n\
if (values === undefined) {\n\
values = subject || ... | javascript | function (Class, descriptors, staticDescriptors) {
var casters = {},
validators = {},
body = '"use strict";\n\
var valid = true,\n\
errors = {},\n\
result;\n\
if (values === undefined) {\n\
values = subject || ... | [
"function",
"(",
"Class",
",",
"descriptors",
",",
"staticDescriptors",
")",
"{",
"var",
"casters",
"=",
"{",
"}",
",",
"validators",
"=",
"{",
"}",
",",
"body",
"=",
"'\"use strict\";\\n\\\n var valid = true,\\n\\\n errors = {},\\n\\\n ... | Create a function which can accept user input for the model.
@param {Function} Class The class.
@param {Object} descriptors The property descriptors.
@param {Object} staticDescriptors The static property descriptors.
@return {Function} The generated function. | [
"Create",
"a",
"function",
"which",
"can",
"accept",
"user",
"input",
"for",
"the",
"model",
"."
] | 7c95e2bae2e5ea12565a567a55535fe4d63c513c | https://github.com/codemix/modeling/blob/7c95e2bae2e5ea12565a567a55535fe4d63c513c/lib/factory.js#L112-L180 | train | |
codemix/modeling | lib/factory.js | function (Class, descriptors) {
var body = '"use strict";\n';
var casters = {};
each(descriptors, function (descriptor, name) {
if (descriptor.writable || typeof descriptor.set === 'function') {
var accessor = createAccessor(name);
if (descriptor.cast || descriptor.type) {
ca... | javascript | function (Class, descriptors) {
var body = '"use strict";\n';
var casters = {};
each(descriptors, function (descriptor, name) {
if (descriptor.writable || typeof descriptor.set === 'function') {
var accessor = createAccessor(name);
if (descriptor.cast || descriptor.type) {
ca... | [
"function",
"(",
"Class",
",",
"descriptors",
")",
"{",
"var",
"body",
"=",
"'\"use strict\";\\n'",
";",
"var",
"casters",
"=",
"{",
"}",
";",
"each",
"(",
"descriptors",
",",
"function",
"(",
"descriptor",
",",
"name",
")",
"{",
"if",
"(",
"descriptor",... | Create a `configure` function for a class.
@param {Function} Class The class.
@param {Object} descriptors The property descriptors.
@return {Function} The configure function. | [
"Create",
"a",
"configure",
"function",
"for",
"a",
"class",
"."
] | 7c95e2bae2e5ea12565a567a55535fe4d63c513c | https://github.com/codemix/modeling/blob/7c95e2bae2e5ea12565a567a55535fe4d63c513c/lib/factory.js#L189-L214 | train | |
codemix/modeling | lib/factory.js | function (Class, descriptors) {
ClassFactory.prototype.updateDynamicFunctions.call(this, Class, descriptors);
if (!Class.cast || Class.cast.isAutoGenerated) {
Class.cast = this.createStaticCast(Class, descriptors);
}
if (!Class.validate || Class.validate.isAutoGenerated) {
Class.validate = t... | javascript | function (Class, descriptors) {
ClassFactory.prototype.updateDynamicFunctions.call(this, Class, descriptors);
if (!Class.cast || Class.cast.isAutoGenerated) {
Class.cast = this.createStaticCast(Class, descriptors);
}
if (!Class.validate || Class.validate.isAutoGenerated) {
Class.validate = t... | [
"function",
"(",
"Class",
",",
"descriptors",
")",
"{",
"ClassFactory",
".",
"prototype",
".",
"updateDynamicFunctions",
".",
"call",
"(",
"this",
",",
"Class",
",",
"descriptors",
")",
";",
"if",
"(",
"!",
"Class",
".",
"cast",
"||",
"Class",
".",
"cast... | Update the dynamic auto-generated functions for a class.
@param {Function} Class The class.
@param {Object} descriptors The property descriptors.
@param {Object} staticDescriptors The static property descriptors. | [
"Update",
"the",
"dynamic",
"auto",
"-",
"generated",
"functions",
"for",
"a",
"class",
"."
] | 7c95e2bae2e5ea12565a567a55535fe4d63c513c | https://github.com/codemix/modeling/blob/7c95e2bae2e5ea12565a567a55535fe4d63c513c/lib/factory.js#L270-L284 | train | |
codemix/modeling | lib/factory.js | tryCatch1 | function tryCatch1 (fn, arg1) {
var errorObject = {};
try {
errorObject.value = fn(arg1);
}
catch (e) {
errorObject.error = e;
}
return errorObject;
} | javascript | function tryCatch1 (fn, arg1) {
var errorObject = {};
try {
errorObject.value = fn(arg1);
}
catch (e) {
errorObject.error = e;
}
return errorObject;
} | [
"function",
"tryCatch1",
"(",
"fn",
",",
"arg1",
")",
"{",
"var",
"errorObject",
"=",
"{",
"}",
";",
"try",
"{",
"errorObject",
".",
"value",
"=",
"fn",
"(",
"arg1",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"errorObject",
".",
"error",
"=",
"e... | try..catch causes deoptimisation in V8 and most other JS engines. Using a specialist function minimises the impact. | [
"try",
"..",
"catch",
"causes",
"deoptimisation",
"in",
"V8",
"and",
"most",
"other",
"JS",
"engines",
".",
"Using",
"a",
"specialist",
"function",
"minimises",
"the",
"impact",
"."
] | 7c95e2bae2e5ea12565a567a55535fe4d63c513c | https://github.com/codemix/modeling/blob/7c95e2bae2e5ea12565a567a55535fe4d63c513c/lib/factory.js#L290-L299 | train |
janschaefer/GivenJS | given-core/lib/model/model.js | SuiteModel | function SuiteModel (name) {
this.className = 'js.' + name
this.scenarios = []
this.tagMap = {}
this.tagMap.JS = new TagModel('JS')
log('Creating new model ' + this.className)
} | javascript | function SuiteModel (name) {
this.className = 'js.' + name
this.scenarios = []
this.tagMap = {}
this.tagMap.JS = new TagModel('JS')
log('Creating new model ' + this.className)
} | [
"function",
"SuiteModel",
"(",
"name",
")",
"{",
"this",
".",
"className",
"=",
"'js.'",
"+",
"name",
"this",
".",
"scenarios",
"=",
"[",
"]",
"this",
".",
"tagMap",
"=",
"{",
"}",
"this",
".",
"tagMap",
".",
"JS",
"=",
"new",
"TagModel",
"(",
"'JS... | A SuiteModel represents a collection of ScenarioModels
@param name
@see ScenarioModel
@constructor | [
"A",
"SuiteModel",
"represents",
"a",
"collection",
"of",
"ScenarioModels"
] | 743c2773c00ad0822c65d2b7a5f337d3ee582538 | https://github.com/janschaefer/GivenJS/blob/743c2773c00ad0822c65d2b7a5f337d3ee582538/given-core/lib/model/model.js#L162-L169 | train |
mchalapuk/hyper-text-slider | lib/core/slider.js | Slider | function Slider(elem) {
check(elem, 'elem').is.anInstanceOf(Element)();
var priv = {};
priv.elem = elem;
priv.transitions = [];
priv.phaser = phaser(elem);
priv.slides = [];
priv.upgrader = upgrader(elem);
priv.listeners = {};
priv.tempClasses = [];
priv.fromIndex = 1;
priv.toIndex = 0;
priv.st... | javascript | function Slider(elem) {
check(elem, 'elem').is.anInstanceOf(Element)();
var priv = {};
priv.elem = elem;
priv.transitions = [];
priv.phaser = phaser(elem);
priv.slides = [];
priv.upgrader = upgrader(elem);
priv.listeners = {};
priv.tempClasses = [];
priv.fromIndex = 1;
priv.toIndex = 0;
priv.st... | [
"function",
"Slider",
"(",
"elem",
")",
"{",
"check",
"(",
"elem",
",",
"'elem'",
")",
".",
"is",
".",
"anInstanceOf",
"(",
"Element",
")",
"(",
")",
";",
"var",
"priv",
"=",
"{",
"}",
";",
"priv",
".",
"elem",
"=",
"elem",
";",
"priv",
".",
"t... | public
Constructs the slider.
@param {Element} elem DOM element for the slider
@fqn Slider.prototype.constructor | [
"public",
"Constructs",
"the",
"slider",
"."
] | 2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4 | https://github.com/mchalapuk/hyper-text-slider/blob/2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4/lib/core/slider.js#L69-L139 | train |
mchalapuk/hyper-text-slider | lib/core/slider.js | start | function start(priv, callback) {
check(priv.started, 'slider.started').is.False();
check(callback, 'callback').is.aFunction.or.Undefined();
priv.startCallback = callback || noop;
window.addEventListener('keydown', partial(keyBasedMove, priv), false);
priv.elem.addEventListener('click', partial(clickBasedMov... | javascript | function start(priv, callback) {
check(priv.started, 'slider.started').is.False();
check(callback, 'callback').is.aFunction.or.Undefined();
priv.startCallback = callback || noop;
window.addEventListener('keydown', partial(keyBasedMove, priv), false);
priv.elem.addEventListener('click', partial(clickBasedMov... | [
"function",
"start",
"(",
"priv",
",",
"callback",
")",
"{",
"check",
"(",
"priv",
".",
"started",
",",
"'slider.started'",
")",
".",
"is",
".",
"False",
"(",
")",
";",
"check",
"(",
"callback",
",",
"'callback'",
")",
".",
"is",
".",
"aFunction",
".... | Upgrades DOM elements and shows the first slide.
Starting procedure involves manipuilating DOM and waiting for changes to be visible on the
screen, therefore slider will not be started immediately after returning from this call.
After all slides are upgraded and visible on the screen, given **callback** will be called... | [
"Upgrades",
"DOM",
"elements",
"and",
"shows",
"the",
"first",
"slide",
"."
] | 2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4 | https://github.com/mchalapuk/hyper-text-slider/blob/2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4/lib/core/slider.js#L162-L177 | train |
mchalapuk/hyper-text-slider | lib/core/slider.js | moveToPrevious | function moveToPrevious(priv) {
moveTo(priv, (priv.toIndex - 1 + priv.slides.length) % priv.slides.length);
} | javascript | function moveToPrevious(priv) {
moveTo(priv, (priv.toIndex - 1 + priv.slides.length) % priv.slides.length);
} | [
"function",
"moveToPrevious",
"(",
"priv",
")",
"{",
"moveTo",
"(",
"priv",
",",
"(",
"priv",
".",
"toIndex",
"-",
"1",
"+",
"priv",
".",
"slides",
".",
"length",
")",
"%",
"priv",
".",
"slides",
".",
"length",
")",
";",
"}"
] | Moves slider previous slide.
@precondition ${link Slider.prototype.start} was called on this slider
@fqn Slider.prototype.moveToPrevious | [
"Moves",
"slider",
"previous",
"slide",
"."
] | 2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4 | https://github.com/mchalapuk/hyper-text-slider/blob/2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4/lib/core/slider.js#L198-L200 | train |
mchalapuk/hyper-text-slider | lib/core/slider.js | moveTo | function moveTo(priv, index) {
check(priv.started, 'slider.started').is.True();
check(index, 'index').is.inRange(0, priv.slides.length)();
var toIndex = index <= priv.slides.length? index % priv.slides.length: index;
if (priv.toIndex === toIndex) {
return;
}
removeTempClasses(priv);
removeMarkers(pr... | javascript | function moveTo(priv, index) {
check(priv.started, 'slider.started').is.True();
check(index, 'index').is.inRange(0, priv.slides.length)();
var toIndex = index <= priv.slides.length? index % priv.slides.length: index;
if (priv.toIndex === toIndex) {
return;
}
removeTempClasses(priv);
removeMarkers(pr... | [
"function",
"moveTo",
"(",
"priv",
",",
"index",
")",
"{",
"check",
"(",
"priv",
".",
"started",
",",
"'slider.started'",
")",
".",
"is",
".",
"True",
"(",
")",
";",
"check",
"(",
"index",
",",
"'index'",
")",
".",
"is",
".",
"inRange",
"(",
"0",
... | Moves slider slide of given index.
@param {Number} index index of the slide that slider will be moved to
@precondition ${link Slider.prototype.start} was called on this slider
@fqn Slider.prototype.moveTo | [
"Moves",
"slider",
"slide",
"of",
"given",
"index",
"."
] | 2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4 | https://github.com/mchalapuk/hyper-text-slider/blob/2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4/lib/core/slider.js#L210-L230 | train |
mchalapuk/hyper-text-slider | lib/core/slider.js | on | function on(priv, eventName, listener) {
check(eventName, 'eventName').is.aString.and.oneOf(EVENT_NAMES)();
check(listener, 'listener').is.aFunction();
getListeners(priv, eventName).push(listener);
} | javascript | function on(priv, eventName, listener) {
check(eventName, 'eventName').is.aString.and.oneOf(EVENT_NAMES)();
check(listener, 'listener').is.aFunction();
getListeners(priv, eventName).push(listener);
} | [
"function",
"on",
"(",
"priv",
",",
"eventName",
",",
"listener",
")",
"{",
"check",
"(",
"eventName",
",",
"'eventName'",
")",
".",
"is",
".",
"aString",
".",
"and",
".",
"oneOf",
"(",
"EVENT_NAMES",
")",
"(",
")",
";",
"check",
"(",
"listener",
","... | Registers a listener on given eventName.
@param {String} eventName name of event
@param {Function} listener a function
@postcondition given listener will be notified about current slide changes
@fqn Slider.prototype.on | [
"Registers",
"a",
"listener",
"on",
"given",
"eventName",
"."
] | 2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4 | https://github.com/mchalapuk/hyper-text-slider/blob/2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4/lib/core/slider.js#L240-L245 | train |
mchalapuk/hyper-text-slider | lib/core/slider.js | removeListener | function removeListener(priv, eventName, listener) {
check(eventName, 'eventName').is.aString.and.oneOf(EVENT_NAMES)();
var listeners = getListeners(priv, eventName);
check(listener, 'listener').is.aFunction.and.is.oneOf(listeners, 'registered listeners')();
listeners.splice(listeners.indexOf(listener), 1);
} | javascript | function removeListener(priv, eventName, listener) {
check(eventName, 'eventName').is.aString.and.oneOf(EVENT_NAMES)();
var listeners = getListeners(priv, eventName);
check(listener, 'listener').is.aFunction.and.is.oneOf(listeners, 'registered listeners')();
listeners.splice(listeners.indexOf(listener), 1);
} | [
"function",
"removeListener",
"(",
"priv",
",",
"eventName",
",",
"listener",
")",
"{",
"check",
"(",
"eventName",
",",
"'eventName'",
")",
".",
"is",
".",
"aString",
".",
"and",
".",
"oneOf",
"(",
"EVENT_NAMES",
")",
"(",
")",
";",
"var",
"listeners",
... | Unregisters a listener from given eventName.
@param {String} eventName name of event
@param {Function} listener a function
@precondition given listener was previously passed to ${link Slider.prototype.on}
@postcondition given listener will no longer be notified about current slide changes
@fqn Slider.prototype.removeL... | [
"Unregisters",
"a",
"listener",
"from",
"given",
"eventName",
"."
] | 2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4 | https://github.com/mchalapuk/hyper-text-slider/blob/2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4/lib/core/slider.js#L256-L262 | train |
mchalapuk/hyper-text-slider | lib/core/slider.js | acceptSlide | function acceptSlide(priv, slideElement) {
slideElement.classList.add(Flag.UPGRADED);
insertSlide(priv, slideElement);
priv.phaser.addPhaseTrigger(slideElement.querySelector('.'+ Layout.CONTENT));
if (priv.slides.length === 1) {
priv.startCallback.call(null, priv.pub);
// moving this to next tick is r... | javascript | function acceptSlide(priv, slideElement) {
slideElement.classList.add(Flag.UPGRADED);
insertSlide(priv, slideElement);
priv.phaser.addPhaseTrigger(slideElement.querySelector('.'+ Layout.CONTENT));
if (priv.slides.length === 1) {
priv.startCallback.call(null, priv.pub);
// moving this to next tick is r... | [
"function",
"acceptSlide",
"(",
"priv",
",",
"slideElement",
")",
"{",
"slideElement",
".",
"classList",
".",
"add",
"(",
"Flag",
".",
"UPGRADED",
")",
";",
"insertSlide",
"(",
"priv",
",",
"slideElement",
")",
";",
"priv",
".",
"phaser",
".",
"addPhaseTri... | private initialization functions | [
"private",
"initialization",
"functions"
] | 2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4 | https://github.com/mchalapuk/hyper-text-slider/blob/2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4/lib/core/slider.js#L268-L279 | train |
cfpb/AtomicComponent | src/utilities/on-ready/index.js | onReady | function onReady( fn ) {
// Ensure we passed a function as the argument
if ( typeof fn !== 'function' ) {
return [];
}
// If the ready state is already complete, run the passed function,
// otherwise add it to our saved array.
if ( document.readyState === 'complete' ) {
fn();
} else {
_readyF... | javascript | function onReady( fn ) {
// Ensure we passed a function as the argument
if ( typeof fn !== 'function' ) {
return [];
}
// If the ready state is already complete, run the passed function,
// otherwise add it to our saved array.
if ( document.readyState === 'complete' ) {
fn();
} else {
_readyF... | [
"function",
"onReady",
"(",
"fn",
")",
"{",
"// Ensure we passed a function as the argument",
"if",
"(",
"typeof",
"fn",
"!==",
"'function'",
")",
"{",
"return",
"[",
"]",
";",
"}",
"// If the ready state is already complete, run the passed function,",
"// otherwise add it ... | Checks if the document is ready, if it is, trigger the passed function,
if not, push the function to an array to be triggered after the page
is loaded.
@param {Function} fn -
Function to run only after the DOM has completely loaded.
@returns {Array} List of functions to run after the DOM has loaded. | [
"Checks",
"if",
"the",
"document",
"is",
"ready",
"if",
"it",
"is",
"trigger",
"the",
"passed",
"function",
"if",
"not",
"push",
"the",
"function",
"to",
"an",
"array",
"to",
"be",
"triggered",
"after",
"the",
"page",
"is",
"loaded",
"."
] | f45d7ded6687672c8b701c9910ddfe90c7ede742 | https://github.com/cfpb/AtomicComponent/blob/f45d7ded6687672c8b701c9910ddfe90c7ede742/src/utilities/on-ready/index.js#L20-L45 | train |
humantech/Hey | lib/hey.js | Hey | function Hey(options) {
// force the use of new
if (this.constructor !== Hey) {
throw "Hey must be instantiated with \"new\"!";
}
// we need some options, don't we?
if (!options || !options.path) {
throw "Option object must be set with a valid path to watch.";
}
// start EventEmitter
EventEmitt... | javascript | function Hey(options) {
// force the use of new
if (this.constructor !== Hey) {
throw "Hey must be instantiated with \"new\"!";
}
// we need some options, don't we?
if (!options || !options.path) {
throw "Option object must be set with a valid path to watch.";
}
// start EventEmitter
EventEmitt... | [
"function",
"Hey",
"(",
"options",
")",
"{",
"// force the use of new",
"if",
"(",
"this",
".",
"constructor",
"!==",
"Hey",
")",
"{",
"throw",
"\"Hey must be instantiated with \\\"new\\\"!\"",
";",
"}",
"// we need some options, don't we?",
"if",
"(",
"!",
"options",... | class for watching a path with custom events and options | [
"class",
"for",
"watching",
"a",
"path",
"with",
"custom",
"events",
"and",
"options"
] | 801972fc036d199f78a031e7a7444c8215e2b1e0 | https://github.com/humantech/Hey/blob/801972fc036d199f78a031e7a7444c8215e2b1e0/lib/hey.js#L14-L75 | train |
throneteki/throneteki-deck-helper | lib/formatDeckAsFullCards.js | formatDeckAsFullCards | function formatDeckAsFullCards(deck, data) {
var newDeck = {
_id: deck._id,
name: deck.name,
username: deck.username,
lastUpdated: deck.lastUpdated,
faction: Object.assign({}, deck.faction)
};
if (data.factions) {
newDeck.faction = data.factions[deck.faction.... | javascript | function formatDeckAsFullCards(deck, data) {
var newDeck = {
_id: deck._id,
name: deck.name,
username: deck.username,
lastUpdated: deck.lastUpdated,
faction: Object.assign({}, deck.faction)
};
if (data.factions) {
newDeck.faction = data.factions[deck.faction.... | [
"function",
"formatDeckAsFullCards",
"(",
"deck",
",",
"data",
")",
"{",
"var",
"newDeck",
"=",
"{",
"_id",
":",
"deck",
".",
"_id",
",",
"name",
":",
"deck",
".",
"name",
",",
"username",
":",
"deck",
".",
"username",
",",
"lastUpdated",
":",
"deck",
... | Creates a clone of the existing deck with full card data filled in instead of
just card codes.
@param {object} deck
@param {object} data
@param {object} data.cards - an index of card code to full card object
@param {object} data.factions - an index of faction code to full faction object | [
"Creates",
"a",
"clone",
"of",
"the",
"existing",
"deck",
"with",
"full",
"card",
"data",
"filled",
"in",
"instead",
"of",
"just",
"card",
"codes",
"."
] | 700280f5747b99d626c8ea6033064bd01f93da60 | https://github.com/throneteki/throneteki-deck-helper/blob/700280f5747b99d626c8ea6033064bd01f93da60/lib/formatDeckAsFullCards.js#L12-L37 | train |
binduwavell/generator-alfresco-common | lib/dependency-versions.js | function (rawLine) {
// Maven on the Travis-CI Ubunty Trusty container makes the version line bold.
// Let's just say I'm pretty salty at this point. So we strip ANSI codes.
var line = stripAnsi(rawLine);
debug('Checking cmd output: ' + line);
var match = line.match(re);
if (match !== null) {
... | javascript | function (rawLine) {
// Maven on the Travis-CI Ubunty Trusty container makes the version line bold.
// Let's just say I'm pretty salty at this point. So we strip ANSI codes.
var line = stripAnsi(rawLine);
debug('Checking cmd output: ' + line);
var match = line.match(re);
if (match !== null) {
... | [
"function",
"(",
"rawLine",
")",
"{",
"// Maven on the Travis-CI Ubunty Trusty container makes the version line bold.",
"// Let's just say I'm pretty salty at this point. So we strip ANSI codes.",
"var",
"line",
"=",
"stripAnsi",
"(",
"rawLine",
")",
";",
"debug",
"(",
"'Checking c... | if line matches regex return line | [
"if",
"line",
"matches",
"regex",
"return",
"line"
] | d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4 | https://github.com/binduwavell/generator-alfresco-common/blob/d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4/lib/dependency-versions.js#L73-L82 | train | |
vid/SenseBase | services/watch.js | processWatches | function processWatches(items) {
// queue up matches
// { "member" : { "uri" : [ "match", "match" ] } }
var toSend = {};
GLOBAL.svc.indexer.retrieveWatches({}, function(err, res) {
if (res.hits) {
var watches = _.pluck(res.hits.hits, '_source');
// for each hit
items.forEach(function(item)... | javascript | function processWatches(items) {
// queue up matches
// { "member" : { "uri" : [ "match", "match" ] } }
var toSend = {};
GLOBAL.svc.indexer.retrieveWatches({}, function(err, res) {
if (res.hits) {
var watches = _.pluck(res.hits.hits, '_source');
// for each hit
items.forEach(function(item)... | [
"function",
"processWatches",
"(",
"items",
")",
"{",
"// queue up matches",
"// { \"member\" : { \"uri\" : [ \"match\", \"match\" ] } }",
"var",
"toSend",
"=",
"{",
"}",
";",
"GLOBAL",
".",
"svc",
".",
"indexer",
".",
"retrieveWatches",
"(",
"{",
"}",
",",
"functio... | process any watches in the last time period | [
"process",
"any",
"watches",
"in",
"the",
"last",
"time",
"period"
] | d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/services/watch.js#L21-L42 | train |
typoerr/quex | dist/index.js | createStore | function createStore(initialState, option) {
let $state = initialState;
let $listener = [];
const $enhancer = option && option.enhancer;
const $updater = (() => {
const f1 = option && option.updater;
const f2 = (s1, s2) => Object.assign({}, s1, s2);
return f1 || f2;
})();
... | javascript | function createStore(initialState, option) {
let $state = initialState;
let $listener = [];
const $enhancer = option && option.enhancer;
const $updater = (() => {
const f1 = option && option.updater;
const f2 = (s1, s2) => Object.assign({}, s1, s2);
return f1 || f2;
})();
... | [
"function",
"createStore",
"(",
"initialState",
",",
"option",
")",
"{",
"let",
"$state",
"=",
"initialState",
";",
"let",
"$listener",
"=",
"[",
"]",
";",
"const",
"$enhancer",
"=",
"option",
"&&",
"option",
".",
"enhancer",
";",
"const",
"$updater",
"=",... | create quex store
@export
@template S
@param {S} initialState
@param {{
updater?: Updater<S>;
enhancer?: Enhancer<S>
}} [option]
@returns {Quex<S>} | [
"create",
"quex",
"store"
] | 5d7652b1642d356db68177fa6bd76d79accfbd4e | https://github.com/typoerr/quex/blob/5d7652b1642d356db68177fa6bd76d79accfbd4e/dist/index.js#L15-L146 | train |
typoerr/quex | dist/index.js | next | function next(i, p, task) {
let iResult = task ? { value: task, done: false } : i.next();
try {
if (iResult.done) {
publish($state);
return;
}
const result = iResult.value($state, p);
/* Promise(Like) */
if (resu... | javascript | function next(i, p, task) {
let iResult = task ? { value: task, done: false } : i.next();
try {
if (iResult.done) {
publish($state);
return;
}
const result = iResult.value($state, p);
/* Promise(Like) */
if (resu... | [
"function",
"next",
"(",
"i",
",",
"p",
",",
"task",
")",
"{",
"let",
"iResult",
"=",
"task",
"?",
"{",
"value",
":",
"task",
",",
"done",
":",
"false",
"}",
":",
"i",
".",
"next",
"(",
")",
";",
"try",
"{",
"if",
"(",
"iResult",
".",
"done",... | Execute one task from iterator then
mutation state and publishing
@private
@param {Iterator<Function>} i
@param {*} p
@param {Function} [task]
@returns {void} | [
"Execute",
"one",
"task",
"from",
"iterator",
"then",
"mutation",
"state",
"and",
"publishing"
] | 5d7652b1642d356db68177fa6bd76d79accfbd4e | https://github.com/typoerr/quex/blob/5d7652b1642d356db68177fa6bd76d79accfbd4e/dist/index.js#L114-L145 | train |
socialally/air | lib/air/ui/dialog.js | dialog | function dialog(opts, cb) {
var $ = dialog.air
, el = opts.el.clone(true)
, container = opts.container || $('body')
, evt = opts.evt || 'click'
, res = {accepted: false, el: el};
opts.accept = opts.accept || '[href="#ok"]';
opts.reject = opts.reject || '[href="#cancel"]';
// pass function to r... | javascript | function dialog(opts, cb) {
var $ = dialog.air
, el = opts.el.clone(true)
, container = opts.container || $('body')
, evt = opts.evt || 'click'
, res = {accepted: false, el: el};
opts.accept = opts.accept || '[href="#ok"]';
opts.reject = opts.reject || '[href="#cancel"]';
// pass function to r... | [
"function",
"dialog",
"(",
"opts",
",",
"cb",
")",
"{",
"var",
"$",
"=",
"dialog",
".",
"air",
",",
"el",
"=",
"opts",
".",
"el",
".",
"clone",
"(",
"true",
")",
",",
"container",
"=",
"opts",
".",
"container",
"||",
"$",
"(",
"'body'",
")",
",... | Show a modal dialog.
The passed element (`el`) is cloned and appended to the `container`.
@param opts {Object} Dialog options.
@param cb {Function} A callback function for accept or reject.
@options:
- el: The dialog element (root of the markup below).
- container: Parent element to append the dialog to.
- modal: W... | [
"Show",
"a",
"modal",
"dialog",
"."
] | a3d94de58aaa4930a425fbcc7266764bf6ca8ca6 | https://github.com/socialally/air/blob/a3d94de58aaa4930a425fbcc7266764bf6ca8ca6/lib/air/ui/dialog.js#L60-L107 | train |
jonschlinkert/delims | index.js | Delimiters | function Delimiters (delims, options) {
this.options = options || {};
this.delims = delims || [];
this.defaults = merge({}, {
beginning: '^', // '^' Matches beginning of input.
matter: '([\\s\\S]+?)', // The "content" between the delims
body: '([\\s\\S]+|\\s?)', // The "content" after the... | javascript | function Delimiters (delims, options) {
this.options = options || {};
this.delims = delims || [];
this.defaults = merge({}, {
beginning: '^', // '^' Matches beginning of input.
matter: '([\\s\\S]+?)', // The "content" between the delims
body: '([\\s\\S]+|\\s?)', // The "content" after the... | [
"function",
"Delimiters",
"(",
"delims",
",",
"options",
")",
"{",
"this",
".",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"this",
".",
"delims",
"=",
"delims",
"||",
"[",
"]",
";",
"this",
".",
"defaults",
"=",
"merge",
"(",
"{",
"}",
",",
... | Generate regular expressions for template delimiters.
@param {Array} `delims`
@param {Object} `options` | [
"Generate",
"regular",
"expressions",
"for",
"template",
"delimiters",
"."
] | 137f643e83632317045f8d68c3b32abd1ccb45d3 | https://github.com/jonschlinkert/delims/blob/137f643e83632317045f8d68c3b32abd1ccb45d3/index.js#L22-L33 | train |
AsceticBoy/chilli-toolkit | lib/ipromise/core.js | safelyToExecutor | function safelyToExecutor(self, executor) {
let done = false;
try {
executor(
function(result) {
if (done) return;
done = true;
doResolve.call(self, result);
}, // doResolve
function(error) {
if (done) return;
done = true;
doReject.call(self, err... | javascript | function safelyToExecutor(self, executor) {
let done = false;
try {
executor(
function(result) {
if (done) return;
done = true;
doResolve.call(self, result);
}, // doResolve
function(error) {
if (done) return;
done = true;
doReject.call(self, err... | [
"function",
"safelyToExecutor",
"(",
"self",
",",
"executor",
")",
"{",
"let",
"done",
"=",
"false",
";",
"try",
"{",
"executor",
"(",
"function",
"(",
"result",
")",
"{",
"if",
"(",
"done",
")",
"return",
";",
"done",
"=",
"true",
";",
"doResolve",
... | onResolved or onRejected only one called once
@param { object } self current IPromise
@param { function } executor this's user operater | [
"onResolved",
"or",
"onRejected",
"only",
"one",
"called",
"once"
] | a4f5f03ce55187a8c91b847e84d767357f347839 | https://github.com/AsceticBoy/chilli-toolkit/blob/a4f5f03ce55187a8c91b847e84d767357f347839/lib/ipromise/core.js#L40-L60 | train |
AsceticBoy/chilli-toolkit | lib/ipromise/core.js | doResolve | function doResolve(result) {
let self = this;
if (result === self) {
// Promise Standard 2.3.1
return doReject.call(
self,
new TypeError("Can not resolve 'Promise' itself")
);
}
// Promise Standard 2.3.3.2
try {
// Promise Standard 2.3.2 and 2.3.3 can be merge
// if result is a... | javascript | function doResolve(result) {
let self = this;
if (result === self) {
// Promise Standard 2.3.1
return doReject.call(
self,
new TypeError("Can not resolve 'Promise' itself")
);
}
// Promise Standard 2.3.3.2
try {
// Promise Standard 2.3.2 and 2.3.3 can be merge
// if result is a... | [
"function",
"doResolve",
"(",
"result",
")",
"{",
"let",
"self",
"=",
"this",
";",
"if",
"(",
"result",
"===",
"self",
")",
"{",
"// Promise Standard 2.3.1",
"return",
"doReject",
".",
"call",
"(",
"self",
",",
"new",
"TypeError",
"(",
"\"Can not resolve 'Pr... | Safely exec executor then doResolve or doReject
The most important function call | [
"Safely",
"exec",
"executor",
"then",
"doResolve",
"or",
"doReject",
"The",
"most",
"important",
"function",
"call"
] | a4f5f03ce55187a8c91b847e84d767357f347839 | https://github.com/AsceticBoy/chilli-toolkit/blob/a4f5f03ce55187a8c91b847e84d767357f347839/lib/ipromise/core.js#L88-L124 | train |
synder/xpress | demo/body-parser/lib/types/text.js | text | function text (options) {
var opts = options || {}
var defaultCharset = opts.defaultCharset || 'utf-8'
var inflate = opts.inflate !== false
var limit = typeof opts.limit !== 'number'
? bytes.parse(opts.limit || '100kb')
: opts.limit
var type = opts.type || 'text/plain'
var verify = opts.verify || f... | javascript | function text (options) {
var opts = options || {}
var defaultCharset = opts.defaultCharset || 'utf-8'
var inflate = opts.inflate !== false
var limit = typeof opts.limit !== 'number'
? bytes.parse(opts.limit || '100kb')
: opts.limit
var type = opts.type || 'text/plain'
var verify = opts.verify || f... | [
"function",
"text",
"(",
"options",
")",
"{",
"var",
"opts",
"=",
"options",
"||",
"{",
"}",
"var",
"defaultCharset",
"=",
"opts",
".",
"defaultCharset",
"||",
"'utf-8'",
"var",
"inflate",
"=",
"opts",
".",
"inflate",
"!==",
"false",
"var",
"limit",
"=",... | Create a middleware to parse text bodies.
@param {object} [options]
@return {function}
@api public | [
"Create",
"a",
"middleware",
"to",
"parse",
"text",
"bodies",
"."
] | 4b1e89208b6f34cd78ce90b8a858592115b6ccb5 | https://github.com/synder/xpress/blob/4b1e89208b6f34cd78ce90b8a858592115b6ccb5/demo/body-parser/lib/types/text.js#L33-L93 | train |
synder/xpress | demo/body-parser/lib/types/text.js | getCharset | function getCharset (req) {
try {
return contentType.parse(req).parameters.charset.toLowerCase()
} catch (e) {
return undefined
}
} | javascript | function getCharset (req) {
try {
return contentType.parse(req).parameters.charset.toLowerCase()
} catch (e) {
return undefined
}
} | [
"function",
"getCharset",
"(",
"req",
")",
"{",
"try",
"{",
"return",
"contentType",
".",
"parse",
"(",
"req",
")",
".",
"parameters",
".",
"charset",
".",
"toLowerCase",
"(",
")",
"}",
"catch",
"(",
"e",
")",
"{",
"return",
"undefined",
"}",
"}"
] | Get the charset of a request.
@param {object} req
@api private | [
"Get",
"the",
"charset",
"of",
"a",
"request",
"."
] | 4b1e89208b6f34cd78ce90b8a858592115b6ccb5 | https://github.com/synder/xpress/blob/4b1e89208b6f34cd78ce90b8a858592115b6ccb5/demo/body-parser/lib/types/text.js#L102-L108 | train |
hardog/fare | lib/fare.js | Fire | function Fire(opts) {
opts = opts || {};
opts.host = opts.host || '0.0.0.0';
opts.port = opts.port || 9998;
var self = this;
Socket.call(self);
self.n = 0;
self.buf_size = opts.buf_size || 100;
self.stream = opts.stream || 'off';
self.log_queue = [];
self.connect(opts.port, opts.host, function(){
... | javascript | function Fire(opts) {
opts = opts || {};
opts.host = opts.host || '0.0.0.0';
opts.port = opts.port || 9998;
var self = this;
Socket.call(self);
self.n = 0;
self.buf_size = opts.buf_size || 100;
self.stream = opts.stream || 'off';
self.log_queue = [];
self.connect(opts.port, opts.host, function(){
... | [
"function",
"Fire",
"(",
"opts",
")",
"{",
"opts",
"=",
"opts",
"||",
"{",
"}",
";",
"opts",
".",
"host",
"=",
"opts",
".",
"host",
"||",
"'0.0.0.0'",
";",
"opts",
".",
"port",
"=",
"opts",
".",
"port",
"||",
"9998",
";",
"var",
"self",
"=",
"t... | Initialize a new `RepSocket`.
@api private | [
"Initialize",
"a",
"new",
"RepSocket",
"."
] | 83e29214b8331601f270fe80e21a969a5ba3f047 | https://github.com/hardog/fare/blob/83e29214b8331601f270fe80e21a969a5ba3f047/lib/fare.js#L22-L38 | train |
hagino3000/Struct.js | struct.js | function(name) {
if (name in props) {
// Check property descriptor
var desc = this.getOwnPropertyDescriptor(name);
if (props[name].nullable === false) {
throw name + ' is not allowd null or undefined';
}
return delete obj[name];
} else {
throw name... | javascript | function(name) {
if (name in props) {
// Check property descriptor
var desc = this.getOwnPropertyDescriptor(name);
if (props[name].nullable === false) {
throw name + ' is not allowd null or undefined';
}
return delete obj[name];
} else {
throw name... | [
"function",
"(",
"name",
")",
"{",
"if",
"(",
"name",
"in",
"props",
")",
"{",
"// Check property descriptor",
"var",
"desc",
"=",
"this",
".",
"getOwnPropertyDescriptor",
"(",
"name",
")",
";",
"if",
"(",
"props",
"[",
"name",
"]",
".",
"nullable",
"===... | Delete specified property.
Check property name if defined in advance. | [
"Delete",
"specified",
"property",
".",
"Check",
"property",
"name",
"if",
"defined",
"in",
"advance",
"."
] | 8c5876f58e8b1e721e9e0e3d9ff06ba02e1dd9e5 | https://github.com/hagino3000/Struct.js/blob/8c5876f58e8b1e721e9e0e3d9ff06ba02e1dd9e5/struct.js#L173-L186 | train | |
hagino3000/Struct.js | struct.js | function(receiver, name, val) {
if (name in props) {
// Check property descriptor
var desc = this.getOwnPropertyDescriptor(name);
if (desc && !desc.writable) {
throw name + ' is not writable property';
}
if (props[name].nullable === false && isNullOrUndefined(va... | javascript | function(receiver, name, val) {
if (name in props) {
// Check property descriptor
var desc = this.getOwnPropertyDescriptor(name);
if (desc && !desc.writable) {
throw name + ' is not writable property';
}
if (props[name].nullable === false && isNullOrUndefined(va... | [
"function",
"(",
"receiver",
",",
"name",
",",
"val",
")",
"{",
"if",
"(",
"name",
"in",
"props",
")",
"{",
"// Check property descriptor",
"var",
"desc",
"=",
"this",
".",
"getOwnPropertyDescriptor",
"(",
"name",
")",
";",
"if",
"(",
"desc",
"&&",
"!",
... | Set value.
Check property name if defined and type is matched in advance. | [
"Set",
"value",
".",
"Check",
"property",
"name",
"if",
"defined",
"and",
"type",
"is",
"matched",
"in",
"advance",
"."
] | 8c5876f58e8b1e721e9e0e3d9ff06ba02e1dd9e5 | https://github.com/hagino3000/Struct.js/blob/8c5876f58e8b1e721e9e0e3d9ff06ba02e1dd9e5/struct.js#L223-L253 | train | |
hagino3000/Struct.js | struct.js | createFake | function createFake(name, obj) {
obj = obj || {};
// Only add property for type check.
Object.defineProperty(obj, STRUCT_NAME_KEY, {
value: name,
wriatble: false,
enumerable: false
});
return obj;
} | javascript | function createFake(name, obj) {
obj = obj || {};
// Only add property for type check.
Object.defineProperty(obj, STRUCT_NAME_KEY, {
value: name,
wriatble: false,
enumerable: false
});
return obj;
} | [
"function",
"createFake",
"(",
"name",
",",
"obj",
")",
"{",
"obj",
"=",
"obj",
"||",
"{",
"}",
";",
"// Only add property for type check.",
"Object",
".",
"defineProperty",
"(",
"obj",
",",
"STRUCT_NAME_KEY",
",",
"{",
"value",
":",
"name",
",",
"wriatble",... | For no-check mode.
@param {String} name Struct name.
@param {Object} obj Base object (option).
@return {Object} Fake struct object. | [
"For",
"no",
"-",
"check",
"mode",
"."
] | 8c5876f58e8b1e721e9e0e3d9ff06ba02e1dd9e5 | https://github.com/hagino3000/Struct.js/blob/8c5876f58e8b1e721e9e0e3d9ff06ba02e1dd9e5/struct.js#L430-L440 | train |
vadr-vr/VR-Analytics-JSCore | js/userData.js | getUserDictionary | function getUserDictionary(){
const userDict = {};
if (!userId){
userDict['userId'] = deviceData.getDeviceId();
} else {
userDict['userId'] = userId;
}
for (let key in extraInfo){
userDict[key] = extraInfo[key];
}
return userDict;
} | javascript | function getUserDictionary(){
const userDict = {};
if (!userId){
userDict['userId'] = deviceData.getDeviceId();
} else {
userDict['userId'] = userId;
}
for (let key in extraInfo){
userDict[key] = extraInfo[key];
}
return userDict;
} | [
"function",
"getUserDictionary",
"(",
")",
"{",
"const",
"userDict",
"=",
"{",
"}",
";",
"if",
"(",
"!",
"userId",
")",
"{",
"userDict",
"[",
"'userId'",
"]",
"=",
"deviceData",
".",
"getDeviceId",
"(",
")",
";",
"}",
"else",
"{",
"userDict",
"[",
"'... | Used to get all the user details in a dictionary format
@memberof User
@returns {dictionary} dictionary | [
"Used",
"to",
"get",
"all",
"the",
"user",
"details",
"in",
"a",
"dictionary",
"format"
] | 7e4a493c824c2c1716360dcb6a3bfecfede5df3b | https://github.com/vadr-vr/VR-Analytics-JSCore/blob/7e4a493c824c2c1716360dcb6a3bfecfede5df3b/js/userData.js#L87-L109 | train |
librpc/web | dist/web-rpc.js | peekTransferables | function peekTransferables (data, result) {
if ( result === void 0 ) result = [];
if (isTransferable(data)) {
result.push(data);
} else if (isObject(data)) {
for (var i in data) {
peekTransferables(data[i], result);
}
}
return result
} | javascript | function peekTransferables (data, result) {
if ( result === void 0 ) result = [];
if (isTransferable(data)) {
result.push(data);
} else if (isObject(data)) {
for (var i in data) {
peekTransferables(data[i], result);
}
}
return result
} | [
"function",
"peekTransferables",
"(",
"data",
",",
"result",
")",
"{",
"if",
"(",
"result",
"===",
"void",
"0",
")",
"result",
"=",
"[",
"]",
";",
"if",
"(",
"isTransferable",
"(",
"data",
")",
")",
"{",
"result",
".",
"push",
"(",
"data",
")",
";"... | Recursively peek transferables from passed data
@param {*} data Data source
@param {Array} [result=[]] Dist array
@return {ArrayBuffer[]} List of transferables objects | [
"Recursively",
"peek",
"transferables",
"from",
"passed",
"data"
] | 9103512ad0574373ced19d361ae487e8ac8386ca | https://github.com/librpc/web/blob/9103512ad0574373ced19d361ae487e8ac8386ca/dist/web-rpc.js#L103-L114 | train |
chapmanu/hb | lib/services/facebook/stream.js | function(service, credentials, accounts, keywords) {
Stream.call(this, service, credentials, accounts, keywords);
// Initialize FBGraph
fbgraph.setAccessToken(credentials.access_token);
// Set api endpoint URL for subscriber
this.api_endpoint = 'https://graph.facebook.com/'+ credentials.app_id +'/subscr... | javascript | function(service, credentials, accounts, keywords) {
Stream.call(this, service, credentials, accounts, keywords);
// Initialize FBGraph
fbgraph.setAccessToken(credentials.access_token);
// Set api endpoint URL for subscriber
this.api_endpoint = 'https://graph.facebook.com/'+ credentials.app_id +'/subscr... | [
"function",
"(",
"service",
",",
"credentials",
",",
"accounts",
",",
"keywords",
")",
"{",
"Stream",
".",
"call",
"(",
"this",
",",
"service",
",",
"credentials",
",",
"accounts",
",",
"keywords",
")",
";",
"// Initialize FBGraph",
"fbgraph",
".",
"setAcces... | Manages the streaming connection to Facebook
@constructor
@extends Stream | [
"Manages",
"the",
"streaming",
"connection",
"to",
"Facebook"
] | 5edd8de89c7c5fdffc3df0c627513889220f7d51 | https://github.com/chapmanu/hb/blob/5edd8de89c7c5fdffc3df0c627513889220f7d51/lib/services/facebook/stream.js#L15-L35 | train | |
briancsparks/serverassist | lib/sa-modules/load-http-server.js | function(key, value) {
const key2 = key.toLowerCase().replace(/[^a-z0-9]/ig, '');
res.serverassist.headers[key] = value;
res.serverassist.headers2[key2] = value;
} | javascript | function(key, value) {
const key2 = key.toLowerCase().replace(/[^a-z0-9]/ig, '');
res.serverassist.headers[key] = value;
res.serverassist.headers2[key2] = value;
} | [
"function",
"(",
"key",
",",
"value",
")",
"{",
"const",
"key2",
"=",
"key",
".",
"toLowerCase",
"(",
")",
".",
"replace",
"(",
"/",
"[^a-z0-9]",
"/",
"ig",
",",
"''",
")",
";",
"res",
".",
"serverassist",
".",
"headers",
"[",
"key",
"]",
"=",
"v... | Remember headers that get set on the response. headers2 is a table that can be looked-up much easier | [
"Remember",
"headers",
"that",
"get",
"set",
"on",
"the",
"response",
".",
"headers2",
"is",
"a",
"table",
"that",
"can",
"be",
"looked",
"-",
"up",
"much",
"easier"
] | f966832aae287f502cce53a71f5129b962ada8a3 | https://github.com/briancsparks/serverassist/blob/f966832aae287f502cce53a71f5129b962ada8a3/lib/sa-modules/load-http-server.js#L149-L153 | train | |
linyngfly/omelo-scheduler | lib/schedule.js | setTimer | function setTimer(job){
clearTimeout(timer);
timer = setTimeout(excuteJob, job.excuteTime()-Date.now());
} | javascript | function setTimer(job){
clearTimeout(timer);
timer = setTimeout(excuteJob, job.excuteTime()-Date.now());
} | [
"function",
"setTimer",
"(",
"job",
")",
"{",
"clearTimeout",
"(",
"timer",
")",
";",
"timer",
"=",
"setTimeout",
"(",
"excuteJob",
",",
"job",
".",
"excuteTime",
"(",
")",
"-",
"Date",
".",
"now",
"(",
")",
")",
";",
"}"
] | Clear last timeout and schedule the next job, it will automaticly run the job that
need to run now
@param job The job need to schedule
@return void | [
"Clear",
"last",
"timeout",
"and",
"schedule",
"the",
"next",
"job",
"it",
"will",
"automaticly",
"run",
"the",
"job",
"that",
"need",
"to",
"run",
"now"
] | aa7775eb2b8b31160669c8fedccd84e2108797eb | https://github.com/linyngfly/omelo-scheduler/blob/aa7775eb2b8b31160669c8fedccd84e2108797eb/lib/schedule.js#L68-L72 | train |
linyngfly/omelo-scheduler | lib/schedule.js | excuteJob | function excuteJob(){
let job = peekNextJob();
let nextJob;
while(!!job && (job.excuteTime()-Date.now())<accuracy){
job.run();
queue.pop();
let nextTime = job.nextTime();
if(nextTime === null){
delete map[job.id];
}else{
queue.offer({id:job.id, time: nextTime});
}
job = ... | javascript | function excuteJob(){
let job = peekNextJob();
let nextJob;
while(!!job && (job.excuteTime()-Date.now())<accuracy){
job.run();
queue.pop();
let nextTime = job.nextTime();
if(nextTime === null){
delete map[job.id];
}else{
queue.offer({id:job.id, time: nextTime});
}
job = ... | [
"function",
"excuteJob",
"(",
")",
"{",
"let",
"job",
"=",
"peekNextJob",
"(",
")",
";",
"let",
"nextJob",
";",
"while",
"(",
"!",
"!",
"job",
"&&",
"(",
"job",
".",
"excuteTime",
"(",
")",
"-",
"Date",
".",
"now",
"(",
")",
")",
"<",
"accuracy",... | The function used to ran the schedule job, and setTimeout for next running job | [
"The",
"function",
"used",
"to",
"ran",
"the",
"schedule",
"job",
"and",
"setTimeout",
"for",
"next",
"running",
"job"
] | aa7775eb2b8b31160669c8fedccd84e2108797eb | https://github.com/linyngfly/omelo-scheduler/blob/aa7775eb2b8b31160669c8fedccd84e2108797eb/lib/schedule.js#L77-L101 | train |
linyngfly/omelo-scheduler | lib/schedule.js | peekNextJob | function peekNextJob(){
if(queue.size() <= 0)
return null;
let job = null;
do{
job = map[queue.peek().id];
if(!job) queue.pop();
}while(!job && queue.size() > 0);
return (!!job)?job:null;
} | javascript | function peekNextJob(){
if(queue.size() <= 0)
return null;
let job = null;
do{
job = map[queue.peek().id];
if(!job) queue.pop();
}while(!job && queue.size() > 0);
return (!!job)?job:null;
} | [
"function",
"peekNextJob",
"(",
")",
"{",
"if",
"(",
"queue",
".",
"size",
"(",
")",
"<=",
"0",
")",
"return",
"null",
";",
"let",
"job",
"=",
"null",
";",
"do",
"{",
"job",
"=",
"map",
"[",
"queue",
".",
"peek",
"(",
")",
".",
"id",
"]",
";"... | Return, but not remove the next valid job
@return Next valid job | [
"Return",
"but",
"not",
"remove",
"the",
"next",
"valid",
"job"
] | aa7775eb2b8b31160669c8fedccd84e2108797eb | https://github.com/linyngfly/omelo-scheduler/blob/aa7775eb2b8b31160669c8fedccd84e2108797eb/lib/schedule.js#L107-L119 | train |
linyngfly/omelo-scheduler | lib/schedule.js | getNextJob | function getNextJob(){
let job = null;
while(!job && queue.size() > 0){
let id = queue.pop().id;
job = map[id];
}
return (!!job)?job:null;
} | javascript | function getNextJob(){
let job = null;
while(!job && queue.size() > 0){
let id = queue.pop().id;
job = map[id];
}
return (!!job)?job:null;
} | [
"function",
"getNextJob",
"(",
")",
"{",
"let",
"job",
"=",
"null",
";",
"while",
"(",
"!",
"job",
"&&",
"queue",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"let",
"id",
"=",
"queue",
".",
"pop",
"(",
")",
".",
"id",
";",
"job",
"=",
"map",
... | Return and remove the next valid job
@return Next valid job | [
"Return",
"and",
"remove",
"the",
"next",
"valid",
"job"
] | aa7775eb2b8b31160669c8fedccd84e2108797eb | https://github.com/linyngfly/omelo-scheduler/blob/aa7775eb2b8b31160669c8fedccd84e2108797eb/lib/schedule.js#L125-L134 | train |
Whitebolt/require-extra | src/workspaces.js | _createProxy | function _createProxy(ids, workspaces) {
const _workspaces = makeArray(ids).map(id=>{
if (!workspaces.has(id)) workspaces.set(id, {});
return workspaces.get(id);
});
return new Proxy(global, {
get: function(target, property, receiver) {
if (property === 'global') return global;
for (let n... | javascript | function _createProxy(ids, workspaces) {
const _workspaces = makeArray(ids).map(id=>{
if (!workspaces.has(id)) workspaces.set(id, {});
return workspaces.get(id);
});
return new Proxy(global, {
get: function(target, property, receiver) {
if (property === 'global') return global;
for (let n... | [
"function",
"_createProxy",
"(",
"ids",
",",
"workspaces",
")",
"{",
"const",
"_workspaces",
"=",
"makeArray",
"(",
"ids",
")",
".",
"map",
"(",
"id",
"=>",
"{",
"if",
"(",
"!",
"workspaces",
".",
"has",
"(",
"id",
")",
")",
"workspaces",
".",
"set",... | Create a Proxy for use a sandbox global.
@private
@param {Array.<Symbol>} ids The workspaces to apply to the proxy, in order of use.
@param {Workspaces} workspaces The workspaces store.
@returns {Proxy} The created proxy. | [
"Create",
"a",
"Proxy",
"for",
"use",
"a",
"sandbox",
"global",
"."
] | 2a8f737aab67305c9fda3ee56aa7953e97cee859 | https://github.com/Whitebolt/require-extra/blob/2a8f737aab67305c9fda3ee56aa7953e97cee859/src/workspaces.js#L17-L41 | train |
Whitebolt/require-extra | src/workspaces.js | createLookup | function createLookup(ids) {
for (let value of lookup) {
if (ids.length === value.length) {
let match = true;
value.forEach(subItem=>{
if (ids[n] !== subItem) match = false;
});
if (match) return value;
}
}
return ids;
} | javascript | function createLookup(ids) {
for (let value of lookup) {
if (ids.length === value.length) {
let match = true;
value.forEach(subItem=>{
if (ids[n] !== subItem) match = false;
});
if (match) return value;
}
}
return ids;
} | [
"function",
"createLookup",
"(",
"ids",
")",
"{",
"for",
"(",
"let",
"value",
"of",
"lookup",
")",
"{",
"if",
"(",
"ids",
".",
"length",
"===",
"value",
".",
"length",
")",
"{",
"let",
"match",
"=",
"true",
";",
"value",
".",
"forEach",
"(",
"subIt... | Create a unique lookup for the given workspaces array.
@param {Array.<Symbol>] ids Workspaces id.
@returns {Array.<Symbol>} The lookup value, always the same array for same Symbol collection. | [
"Create",
"a",
"unique",
"lookup",
"for",
"the",
"given",
"workspaces",
"array",
"."
] | 2a8f737aab67305c9fda3ee56aa7953e97cee859 | https://github.com/Whitebolt/require-extra/blob/2a8f737aab67305c9fda3ee56aa7953e97cee859/src/workspaces.js#L49-L60 | train |
acornejo/downshow | src/downshow.js | bfsOrder | function bfsOrder(root) {
var inqueue = [root], outqueue = [];
root._bfs_parent = null;
while (inqueue.length > 0) {
var elem = inqueue.shift();
outqueue.push(elem);
var children = elem.childNodes;
var liParent = null;
for (var i=0 ; i<children.length; i++) {
if (childr... | javascript | function bfsOrder(root) {
var inqueue = [root], outqueue = [];
root._bfs_parent = null;
while (inqueue.length > 0) {
var elem = inqueue.shift();
outqueue.push(elem);
var children = elem.childNodes;
var liParent = null;
for (var i=0 ; i<children.length; i++) {
if (childr... | [
"function",
"bfsOrder",
"(",
"root",
")",
"{",
"var",
"inqueue",
"=",
"[",
"root",
"]",
",",
"outqueue",
"=",
"[",
"]",
";",
"root",
".",
"_bfs_parent",
"=",
"null",
";",
"while",
"(",
"inqueue",
".",
"length",
">",
"0",
")",
"{",
"var",
"elem",
... | Returns every element in root in their bfs traversal order.
In the process it transforms any nested lists to conform to the w3c
standard, see: http://www.w3.org/wiki/HTML_lists#Nesting_lists | [
"Returns",
"every",
"element",
"in",
"root",
"in",
"their",
"bfs",
"traversal",
"order",
"."
] | 67cd83e7e9068666e4edb1c0b9ba171e0e1c1ad1 | https://github.com/acornejo/downshow/blob/67cd83e7e9068666e4edb1c0b9ba171e0e1c1ad1/src/downshow.js#L39-L63 | train |
acornejo/downshow | src/downshow.js | prefixBlock | function prefixBlock(prefix, block, skipEmpty) {
var lines = block.split('\n');
for (var i =0; i<lines.length; i++) {
// Do not prefix empty lines
if (lines[i].length === 0 && skipEmpty === true)
continue;
else
lines[i] = prefix + lines[i];
}
return lines.join('\n');
... | javascript | function prefixBlock(prefix, block, skipEmpty) {
var lines = block.split('\n');
for (var i =0; i<lines.length; i++) {
// Do not prefix empty lines
if (lines[i].length === 0 && skipEmpty === true)
continue;
else
lines[i] = prefix + lines[i];
}
return lines.join('\n');
... | [
"function",
"prefixBlock",
"(",
"prefix",
",",
"block",
",",
"skipEmpty",
")",
"{",
"var",
"lines",
"=",
"block",
".",
"split",
"(",
"'\\n'",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"lines",
".",
"length",
";",
"i",
"++",
")",
... | Add prefix to the beginning of every line in block. | [
"Add",
"prefix",
"to",
"the",
"beginning",
"of",
"every",
"line",
"in",
"block",
"."
] | 67cd83e7e9068666e4edb1c0b9ba171e0e1c1ad1 | https://github.com/acornejo/downshow/blob/67cd83e7e9068666e4edb1c0b9ba171e0e1c1ad1/src/downshow.js#L82-L92 | train |
acornejo/downshow | src/downshow.js | setContent | function setContent(node, content, prefix, suffix) {
if (content.length > 0) {
if (prefix && suffix)
node._bfs_text = prefix + content + suffix;
else
node._bfs_text = content;
} else
node._bfs_text = '';
} | javascript | function setContent(node, content, prefix, suffix) {
if (content.length > 0) {
if (prefix && suffix)
node._bfs_text = prefix + content + suffix;
else
node._bfs_text = content;
} else
node._bfs_text = '';
} | [
"function",
"setContent",
"(",
"node",
",",
"content",
",",
"prefix",
",",
"suffix",
")",
"{",
"if",
"(",
"content",
".",
"length",
">",
"0",
")",
"{",
"if",
"(",
"prefix",
"&&",
"suffix",
")",
"node",
".",
"_bfs_text",
"=",
"prefix",
"+",
"content",... | Set the node's content. | [
"Set",
"the",
"node",
"s",
"content",
"."
] | 67cd83e7e9068666e4edb1c0b9ba171e0e1c1ad1 | https://github.com/acornejo/downshow/blob/67cd83e7e9068666e4edb1c0b9ba171e0e1c1ad1/src/downshow.js#L97-L105 | train |
acornejo/downshow | src/downshow.js | getContent | function getContent(node) {
var text = '', atom;
for (var i = 0; i<node.childNodes.length; i++) {
if (node.childNodes[i].nodeType === 1) {
atom = node.childNodes[i]._bfs_text;
} else if (node.childNodes[i].nodeType === 3) {
atom = node.childNodes[i].data;
} else
continu... | javascript | function getContent(node) {
var text = '', atom;
for (var i = 0; i<node.childNodes.length; i++) {
if (node.childNodes[i].nodeType === 1) {
atom = node.childNodes[i]._bfs_text;
} else if (node.childNodes[i].nodeType === 3) {
atom = node.childNodes[i].data;
} else
continu... | [
"function",
"getContent",
"(",
"node",
")",
"{",
"var",
"text",
"=",
"''",
",",
"atom",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"node",
".",
"childNodes",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"node",
".",
"childNode... | Get a node's content. | [
"Get",
"a",
"node",
"s",
"content",
"."
] | 67cd83e7e9068666e4edb1c0b9ba171e0e1c1ad1 | https://github.com/acornejo/downshow/blob/67cd83e7e9068666e4edb1c0b9ba171e0e1c1ad1/src/downshow.js#L110-L126 | train |
acornejo/downshow | src/downshow.js | processNode | function processNode(node) {
if (node.tagName === 'P' || node.tagName === 'DIV' || node.tagName === 'UL' || node.tagName === 'OL' || node.tagName === 'PRE')
setContent(node, getContent(node), '\n\n', '\n\n');
else if (node.tagName === 'BR')
setContent(node, '\n\n');
else if (node.tagName === 'HR... | javascript | function processNode(node) {
if (node.tagName === 'P' || node.tagName === 'DIV' || node.tagName === 'UL' || node.tagName === 'OL' || node.tagName === 'PRE')
setContent(node, getContent(node), '\n\n', '\n\n');
else if (node.tagName === 'BR')
setContent(node, '\n\n');
else if (node.tagName === 'HR... | [
"function",
"processNode",
"(",
"node",
")",
"{",
"if",
"(",
"node",
".",
"tagName",
"===",
"'P'",
"||",
"node",
".",
"tagName",
"===",
"'DIV'",
"||",
"node",
".",
"tagName",
"===",
"'UL'",
"||",
"node",
".",
"tagName",
"===",
"'OL'",
"||",
"node",
"... | Process a node in the DOM tree. | [
"Process",
"a",
"node",
"in",
"the",
"DOM",
"tree",
"."
] | 67cd83e7e9068666e4edb1c0b9ba171e0e1c1ad1 | https://github.com/acornejo/downshow/blob/67cd83e7e9068666e4edb1c0b9ba171e0e1c1ad1/src/downshow.js#L131-L188 | train |
nodejitsu/contour | pagelets/nodejitsu/login/base.js | initialize | function initialize() {
var hash = window.location.hash.match(/^\#?\/([^\/]+)?\/?$/)
, self = this;
//
// The login form is in the DOM by default so it can leverage
// browser password saving features.
//
this.content = $('section.modal').get('innerHTML');
if (hash && hash[1] === 'lo... | javascript | function initialize() {
var hash = window.location.hash.match(/^\#?\/([^\/]+)?\/?$/)
, self = this;
//
// The login form is in the DOM by default so it can leverage
// browser password saving features.
//
this.content = $('section.modal').get('innerHTML');
if (hash && hash[1] === 'lo... | [
"function",
"initialize",
"(",
")",
"{",
"var",
"hash",
"=",
"window",
".",
"location",
".",
"hash",
".",
"match",
"(",
"/",
"^\\#?\\/([^\\/]+)?\\/?$",
"/",
")",
",",
"self",
"=",
"this",
";",
"//",
"// The login form is in the DOM by default so it can leverage",
... | Initialize called by the constructor on load.
@api private | [
"Initialize",
"called",
"by",
"the",
"constructor",
"on",
"load",
"."
] | 0828e9bd25ef1eeb97ea231c447118d9867021b6 | https://github.com/nodejitsu/contour/blob/0828e9bd25ef1eeb97ea231c447118d9867021b6/pagelets/nodejitsu/login/base.js#L33-L48 | train |
nodejitsu/contour | pagelets/nodejitsu/login/base.js | modal | function modal(e) {
e.preventDefault();
// Remove the old listeners so we don't trigger the regular validation
Cortex.app('modal').off('done');
var self = this;
self.redirect = $(e.element).get('data-redirect');
if (!this.restore) this.restore = Cortex.app('modal').on('close', function () {
... | javascript | function modal(e) {
e.preventDefault();
// Remove the old listeners so we don't trigger the regular validation
Cortex.app('modal').off('done');
var self = this;
self.redirect = $(e.element).get('data-redirect');
if (!this.restore) this.restore = Cortex.app('modal').on('close', function () {
... | [
"function",
"modal",
"(",
"e",
")",
"{",
"e",
".",
"preventDefault",
"(",
")",
";",
"// Remove the old listeners so we don't trigger the regular validation",
"Cortex",
".",
"app",
"(",
"'modal'",
")",
".",
"off",
"(",
"'done'",
")",
";",
"var",
"self",
"=",
"t... | Open the Login modal
@param {Event} e
@api private | [
"Open",
"the",
"Login",
"modal"
] | 0828e9bd25ef1eeb97ea231c447118d9867021b6 | https://github.com/nodejitsu/contour/blob/0828e9bd25ef1eeb97ea231c447118d9867021b6/pagelets/nodejitsu/login/base.js#L56-L75 | train |
nodejitsu/contour | pagelets/nodejitsu/login/base.js | forgotten | function forgotten() {
var self = this
, username = $('.modal input[name="username"]')
, button = $('.modal button[type="submit"]');
// Add an disabled state to the button as we are processing it
button.addClass('disabled loading')
.set('disabled', 'disabled')
.set('innerHTML', 'Sub... | javascript | function forgotten() {
var self = this
, username = $('.modal input[name="username"]')
, button = $('.modal button[type="submit"]');
// Add an disabled state to the button as we are processing it
button.addClass('disabled loading')
.set('disabled', 'disabled')
.set('innerHTML', 'Sub... | [
"function",
"forgotten",
"(",
")",
"{",
"var",
"self",
"=",
"this",
",",
"username",
"=",
"$",
"(",
"'.modal input[name=\"username\"]'",
")",
",",
"button",
"=",
"$",
"(",
"'.modal button[type=\"submit\"]'",
")",
";",
"// Add an disabled state to the button as we are ... | The user requested a password forget.
@api public | [
"The",
"user",
"requested",
"a",
"password",
"forget",
"."
] | 0828e9bd25ef1eeb97ea231c447118d9867021b6 | https://github.com/nodejitsu/contour/blob/0828e9bd25ef1eeb97ea231c447118d9867021b6/pagelets/nodejitsu/login/base.js#L96-L129 | train |
nodejitsu/contour | pagelets/nodejitsu/login/base.js | validate | function validate(closed) {
if (closed) return;
var username = $('.modal input[name="username"]')
, password = $('.modal input[name="password"]')
, button = $('.modal button[type="submit"]')
, self = this;
// Add an disabled state to the button as we are processing it
button.addClass... | javascript | function validate(closed) {
if (closed) return;
var username = $('.modal input[name="username"]')
, password = $('.modal input[name="password"]')
, button = $('.modal button[type="submit"]')
, self = this;
// Add an disabled state to the button as we are processing it
button.addClass... | [
"function",
"validate",
"(",
"closed",
")",
"{",
"if",
"(",
"closed",
")",
"return",
";",
"var",
"username",
"=",
"$",
"(",
"'.modal input[name=\"username\"]'",
")",
",",
"password",
"=",
"$",
"(",
"'.modal input[name=\"password\"]'",
")",
",",
"button",
"=",
... | Validate the login credentials.
@param {Boolean} closed the user closed modal
@api private | [
"Validate",
"the",
"login",
"credentials",
"."
] | 0828e9bd25ef1eeb97ea231c447118d9867021b6 | https://github.com/nodejitsu/contour/blob/0828e9bd25ef1eeb97ea231c447118d9867021b6/pagelets/nodejitsu/login/base.js#L137-L177 | train |
nodejitsu/contour | pagelets/nodejitsu/login/base.js | render | function render(name, data) {
var template;
if (name !== 'login') {
template = this.template(name, data || {});
template.where('name').is('username').use('username').as('value');
template.where('name').is('password').use('password').as('value');
if (data && data.error) {
templ... | javascript | function render(name, data) {
var template;
if (name !== 'login') {
template = this.template(name, data || {});
template.where('name').is('username').use('username').as('value');
template.where('name').is('password').use('password').as('value');
if (data && data.error) {
templ... | [
"function",
"render",
"(",
"name",
",",
"data",
")",
"{",
"var",
"template",
";",
"if",
"(",
"name",
"!==",
"'login'",
")",
"{",
"template",
"=",
"this",
".",
"template",
"(",
"name",
",",
"data",
"||",
"{",
"}",
")",
";",
"template",
".",
"where",... | Render a new Modal window where the user can log his stuff
@param {Object} data
@api public | [
"Render",
"a",
"new",
"Modal",
"window",
"where",
"the",
"user",
"can",
"log",
"his",
"stuff"
] | 0828e9bd25ef1eeb97ea231c447118d9867021b6 | https://github.com/nodejitsu/contour/blob/0828e9bd25ef1eeb97ea231c447118d9867021b6/pagelets/nodejitsu/login/base.js#L201-L252 | train |
odogono/elsinore-js | src/query/pluck.js | commandPluck | function commandPluck(context, componentIDs, attributes, options) {
// resolve the components to ids
let result;
let entitySet;
// if( true ){ log.debug('pluck> ' + stringify(_.rest(arguments))); }
attributes = context.valueOf(attributes, true);
attributes = Array.isArray(attributes) ? attribu... | javascript | function commandPluck(context, componentIDs, attributes, options) {
// resolve the components to ids
let result;
let entitySet;
// if( true ){ log.debug('pluck> ' + stringify(_.rest(arguments))); }
attributes = context.valueOf(attributes, true);
attributes = Array.isArray(attributes) ? attribu... | [
"function",
"commandPluck",
"(",
"context",
",",
"componentIDs",
",",
"attributes",
",",
"options",
")",
"{",
"// resolve the components to ids",
"let",
"result",
";",
"let",
"entitySet",
";",
"// if( true ){ log.debug('pluck> ' + stringify(_.rest(arguments))); }",
"attribute... | Returns the attribute values of specified components in the specified
entitySet | [
"Returns",
"the",
"attribute",
"values",
"of",
"specified",
"components",
"in",
"the",
"specified",
"entitySet"
] | 1ecce67ad0022646419a740def029b1ba92dd558 | https://github.com/odogono/elsinore-js/blob/1ecce67ad0022646419a740def029b1ba92dd558/src/query/pluck.js#L48-L79 | train |
vanetix/waterline-errors | lib/index.js | expose | function expose(anchor, name, message) {
Object.defineProperty(errors[anchor], name, {
enumerable: true,
get: function() {
var err = new Error();
err.name = capitalize(anchor) + 'Error';
err.message = message;
Error.captureStackTrace(err, arguments.callee);
return err;
}
}... | javascript | function expose(anchor, name, message) {
Object.defineProperty(errors[anchor], name, {
enumerable: true,
get: function() {
var err = new Error();
err.name = capitalize(anchor) + 'Error';
err.message = message;
Error.captureStackTrace(err, arguments.callee);
return err;
}
}... | [
"function",
"expose",
"(",
"anchor",
",",
"name",
",",
"message",
")",
"{",
"Object",
".",
"defineProperty",
"(",
"errors",
"[",
"anchor",
"]",
",",
"name",
",",
"{",
"enumerable",
":",
"true",
",",
"get",
":",
"function",
"(",
")",
"{",
"var",
"err"... | Helper function for exposing errors,
also edits the stack trace to remove itself.
@param {Object} anchor
@param {String} name
@param {String} message | [
"Helper",
"function",
"for",
"exposing",
"errors",
"also",
"edits",
"the",
"stack",
"trace",
"to",
"remove",
"itself",
"."
] | 274319a0418dc42e0f0b182e3d1085bb20469c04 | https://github.com/vanetix/waterline-errors/blob/274319a0418dc42e0f0b182e3d1085bb20469c04/lib/index.js#L36-L48 | train |
jaredhanson/antenna | lib/router.js | Router | function Router() {
var self = this;
this.arr = [];
this.caseSensitive = true;
this.strict = false;
this.middleware = function router(msg, next) {
self._dispatch(msg, next);
};
} | javascript | function Router() {
var self = this;
this.arr = [];
this.caseSensitive = true;
this.strict = false;
this.middleware = function router(msg, next) {
self._dispatch(msg, next);
};
} | [
"function",
"Router",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"this",
".",
"arr",
"=",
"[",
"]",
";",
"this",
".",
"caseSensitive",
"=",
"true",
";",
"this",
".",
"strict",
"=",
"false",
";",
"this",
".",
"middleware",
"=",
"function",
"rou... | `Router` constructor.
@api protected | [
"Router",
"constructor",
"."
] | fecfa8320a29d0f1cf22df0230f3b65a12316087 | https://github.com/jaredhanson/antenna/blob/fecfa8320a29d0f1cf22df0230f3b65a12316087/lib/router.js#L14-L23 | train |
hufeng/babel-plugin-transform-rn-react-dom | lib/index.js | function(path, state) {
if (t.isStringLiteral(path.node.source, { value: 'react-dom' })) {
path.node.source = t.StringLiteral('react-native');
}
} | javascript | function(path, state) {
if (t.isStringLiteral(path.node.source, { value: 'react-dom' })) {
path.node.source = t.StringLiteral('react-native');
}
} | [
"function",
"(",
"path",
",",
"state",
")",
"{",
"if",
"(",
"t",
".",
"isStringLiteral",
"(",
"path",
".",
"node",
".",
"source",
",",
"{",
"value",
":",
"'react-dom'",
"}",
")",
")",
"{",
"path",
".",
"node",
".",
"source",
"=",
"t",
".",
"Strin... | import ReactDOM from 'react-dom' => import ReactDOm from 'react-native' | [
"import",
"ReactDOM",
"from",
"react",
"-",
"dom",
"=",
">",
"import",
"ReactDOm",
"from",
"react",
"-",
"native"
] | 1024b5cb7b7fd7b458202223787de0300b7eb64f | https://github.com/hufeng/babel-plugin-transform-rn-react-dom/blob/1024b5cb7b7fd7b458202223787de0300b7eb64f/lib/index.js#L21-L25 | train | |
vid/SenseBase | lib/apis/bing.js | checkApiKey | function checkApiKey(key) {
if (!GLOBAL.config.apis || !GLOBAL.config.apis[key]) {
GLOBAL.error('no GLOBAL.config.apis.bing');
return false;
}
return true;
} | javascript | function checkApiKey(key) {
if (!GLOBAL.config.apis || !GLOBAL.config.apis[key]) {
GLOBAL.error('no GLOBAL.config.apis.bing');
return false;
}
return true;
} | [
"function",
"checkApiKey",
"(",
"key",
")",
"{",
"if",
"(",
"!",
"GLOBAL",
".",
"config",
".",
"apis",
"||",
"!",
"GLOBAL",
".",
"config",
".",
"apis",
"[",
"key",
"]",
")",
"{",
"GLOBAL",
".",
"error",
"(",
"'no GLOBAL.config.apis.bing'",
")",
";",
... | Check if an API key exists, return false if not | [
"Check",
"if",
"an",
"API",
"key",
"exists",
"return",
"false",
"if",
"not"
] | d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/lib/apis/bing.js#L101-L107 | train |
bosonic-labs/b-datepicker | dist/b-datepicker.js | function(date, preventOnSelect)
{
if (!date) {
this._d = null;
return this.draw();
}
if (typeof date === 'string') {
date = new Date(Date.parse(date));
}
if (!isDate(date)) {
return;
... | javascript | function(date, preventOnSelect)
{
if (!date) {
this._d = null;
return this.draw();
}
if (typeof date === 'string') {
date = new Date(Date.parse(date));
}
if (!isDate(date)) {
return;
... | [
"function",
"(",
"date",
",",
"preventOnSelect",
")",
"{",
"if",
"(",
"!",
"date",
")",
"{",
"this",
".",
"_d",
"=",
"null",
";",
"return",
"this",
".",
"draw",
"(",
")",
";",
"}",
"if",
"(",
"typeof",
"date",
"===",
"'string'",
")",
"{",
"date",... | set the current selection | [
"set",
"the",
"current",
"selection"
] | a15b4cafc04c36a69fca72c5924ed77d0114fc5d | https://github.com/bosonic-labs/b-datepicker/blob/a15b4cafc04c36a69fca72c5924ed77d0114fc5d/dist/b-datepicker.js#L615-L648 | train | |
bosonic-labs/b-datepicker | dist/b-datepicker.js | function(date)
{
if (!isDate(date)) {
return;
}
this._y = date.getFullYear();
this._m = date.getMonth();
this.draw();
} | javascript | function(date)
{
if (!isDate(date)) {
return;
}
this._y = date.getFullYear();
this._m = date.getMonth();
this.draw();
} | [
"function",
"(",
"date",
")",
"{",
"if",
"(",
"!",
"isDate",
"(",
"date",
")",
")",
"{",
"return",
";",
"}",
"this",
".",
"_y",
"=",
"date",
".",
"getFullYear",
"(",
")",
";",
"this",
".",
"_m",
"=",
"date",
".",
"getMonth",
"(",
")",
";",
"t... | change view to a specific date | [
"change",
"view",
"to",
"a",
"specific",
"date"
] | a15b4cafc04c36a69fca72c5924ed77d0114fc5d | https://github.com/bosonic-labs/b-datepicker/blob/a15b4cafc04c36a69fca72c5924ed77d0114fc5d/dist/b-datepicker.js#L653-L661 | train | |
bosonic-labs/b-datepicker | dist/b-datepicker.js | function(force)
{
if (!this._v && !force) {
return;
}
var opts = this._o,
minYear = opts.minYear,
maxYear = opts.maxYear,
minMonth = opts.minMonth,
maxMonth = opts.maxMonth;
if (this.... | javascript | function(force)
{
if (!this._v && !force) {
return;
}
var opts = this._o,
minYear = opts.minYear,
maxYear = opts.maxYear,
minMonth = opts.minMonth,
maxMonth = opts.maxMonth;
if (this.... | [
"function",
"(",
"force",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_v",
"&&",
"!",
"force",
")",
"{",
"return",
";",
"}",
"var",
"opts",
"=",
"this",
".",
"_o",
",",
"minYear",
"=",
"opts",
".",
"minYear",
",",
"maxYear",
"=",
"opts",
".",
"maxY... | refresh the HTML | [
"refresh",
"the",
"HTML"
] | a15b4cafc04c36a69fca72c5924ed77d0114fc5d | https://github.com/bosonic-labs/b-datepicker/blob/a15b4cafc04c36a69fca72c5924ed77d0114fc5d/dist/b-datepicker.js#L727-L768 | train | |
bosonic-labs/b-datepicker | dist/b-datepicker.js | function(year, month)
{
var opts = this._o,
now = new Date(),
days = getDaysInMonth(year, month),
before = new Date(year, month, 1).getDay(),
data = [],
row = [];
setToStartOfDay(now);
... | javascript | function(year, month)
{
var opts = this._o,
now = new Date(),
days = getDaysInMonth(year, month),
before = new Date(year, month, 1).getDay(),
data = [],
row = [];
setToStartOfDay(now);
... | [
"function",
"(",
"year",
",",
"month",
")",
"{",
"var",
"opts",
"=",
"this",
".",
"_o",
",",
"now",
"=",
"new",
"Date",
"(",
")",
",",
"days",
"=",
"getDaysInMonth",
"(",
"year",
",",
"month",
")",
",",
"before",
"=",
"new",
"Date",
"(",
"year",
... | render HTML for a particular month | [
"render",
"HTML",
"for",
"a",
"particular",
"month"
] | a15b4cafc04c36a69fca72c5924ed77d0114fc5d | https://github.com/bosonic-labs/b-datepicker/blob/a15b4cafc04c36a69fca72c5924ed77d0114fc5d/dist/b-datepicker.js#L819-L857 | train | |
odogono/elsinore-js | src/query/alias.js | commandAlias | function commandAlias(context, name) {
let value;
context.alias = context.alias || {};
value = context.last;
name = context.valueOf(name, true);
value = context.valueOf(value, true);
if (context.debug) {
log.debug('cmd alias ' + stringify(name) + ' ' + stringify(value));
}
con... | javascript | function commandAlias(context, name) {
let value;
context.alias = context.alias || {};
value = context.last;
name = context.valueOf(name, true);
value = context.valueOf(value, true);
if (context.debug) {
log.debug('cmd alias ' + stringify(name) + ' ' + stringify(value));
}
con... | [
"function",
"commandAlias",
"(",
"context",
",",
"name",
")",
"{",
"let",
"value",
";",
"context",
".",
"alias",
"=",
"context",
".",
"alias",
"||",
"{",
"}",
";",
"value",
"=",
"context",
".",
"last",
";",
"name",
"=",
"context",
".",
"valueOf",
"("... | Stores or retrieves a value with the given name in the context | [
"Stores",
"or",
"retrieves",
"a",
"value",
"with",
"the",
"given",
"name",
"in",
"the",
"context"
] | 1ecce67ad0022646419a740def029b1ba92dd558 | https://github.com/odogono/elsinore-js/blob/1ecce67ad0022646419a740def029b1ba92dd558/src/query/alias.js#L29-L44 | train |
Knape/triggerhappy | lib/spray.js | caller | function caller(instances, index, options) {
// at the moment we are only calling the first event,
// but lets start prepare the api for managin an array of events
return instances(options).then(function (_ref) {
var event = _ref.event,
eventName = _ref.eventName;
var shouldExit = typeof options.... | javascript | function caller(instances, index, options) {
// at the moment we are only calling the first event,
// but lets start prepare the api for managin an array of events
return instances(options).then(function (_ref) {
var event = _ref.event,
eventName = _ref.eventName;
var shouldExit = typeof options.... | [
"function",
"caller",
"(",
"instances",
",",
"index",
",",
"options",
")",
"{",
"// at the moment we are only calling the first event,",
"// but lets start prepare the api for managin an array of events",
"return",
"instances",
"(",
"options",
")",
".",
"then",
"(",
"function... | Recursive function to be called as many times as we defined the steps count
@param {Array} instances
@param {Integer} index
@param {Object} options | [
"Recursive",
"function",
"to",
"be",
"called",
"as",
"many",
"times",
"as",
"we",
"defined",
"the",
"steps",
"count"
] | 7d470faab8f74004d3b4ba2d27d8006e9203b7f3 | https://github.com/Knape/triggerhappy/blob/7d470faab8f74004d3b4ba2d27d8006e9203b7f3/lib/spray.js#L42-L57 | train |
edappy/seneca-context | plugins/setContext.js | setContextPlugin | function setContextPlugin(options) {
var seneca = this;
var plugin = 'set-context';
options = seneca.util.deepextend({
createContext: createContext,
contextHeader: 'x-request-id'
}, options);
seneca.act({
role: 'web',
plugin: plugin,
use: processRequest.bind(null, options)
});
retur... | javascript | function setContextPlugin(options) {
var seneca = this;
var plugin = 'set-context';
options = seneca.util.deepextend({
createContext: createContext,
contextHeader: 'x-request-id'
}, options);
seneca.act({
role: 'web',
plugin: plugin,
use: processRequest.bind(null, options)
});
retur... | [
"function",
"setContextPlugin",
"(",
"options",
")",
"{",
"var",
"seneca",
"=",
"this",
";",
"var",
"plugin",
"=",
"'set-context'",
";",
"options",
"=",
"seneca",
".",
"util",
".",
"deepextend",
"(",
"{",
"createContext",
":",
"createContext",
",",
"contextH... | A seneca plugin, which automatically sets the context for all HTTP requests.
@param {{
// A function which creates a context based on the HTTP request and response.
// It is used by the `setContextPlugin`.
// The `defaultContext` is `{requestId: req.headers[options.contextHeader]}`.
// Default is noop.
createContext: ... | [
"A",
"seneca",
"plugin",
"which",
"automatically",
"sets",
"the",
"context",
"for",
"all",
"HTTP",
"requests",
"."
] | 1e0c8d36c5be4b661b062754c01f064de47873c4 | https://github.com/edappy/seneca-context/blob/1e0c8d36c5be4b661b062754c01f064de47873c4/plugins/setContext.js#L23-L39 | train |
edappy/seneca-context | plugins/setContext.js | processRequest | function processRequest(options, req, res, next) {
debug('processing HTTP request');
var seneca = req.seneca;
options.createContext(req, res, createDefaultContext(options, req), function (error, context) {
if (error) {
next(error);
} else {
setContext(seneca, context);
next();
}
... | javascript | function processRequest(options, req, res, next) {
debug('processing HTTP request');
var seneca = req.seneca;
options.createContext(req, res, createDefaultContext(options, req), function (error, context) {
if (error) {
next(error);
} else {
setContext(seneca, context);
next();
}
... | [
"function",
"processRequest",
"(",
"options",
",",
"req",
",",
"res",
",",
"next",
")",
"{",
"debug",
"(",
"'processing HTTP request'",
")",
";",
"var",
"seneca",
"=",
"req",
".",
"seneca",
";",
"options",
".",
"createContext",
"(",
"req",
",",
"res",
",... | Derives a context from an HTTP request and
ensures that it is available to all seneca actions in this transaction. | [
"Derives",
"a",
"context",
"from",
"an",
"HTTP",
"request",
"and",
"ensures",
"that",
"it",
"is",
"available",
"to",
"all",
"seneca",
"actions",
"in",
"this",
"transaction",
"."
] | 1e0c8d36c5be4b661b062754c01f064de47873c4 | https://github.com/edappy/seneca-context/blob/1e0c8d36c5be4b661b062754c01f064de47873c4/plugins/setContext.js#L45-L58 | train |
edappy/seneca-context | plugins/setContext.js | createContext | function createContext(req, res, context, done) {
debug('default createContext - does nothing', context);
process.nextTick(done.bind(null, null, context));
} | javascript | function createContext(req, res, context, done) {
debug('default createContext - does nothing', context);
process.nextTick(done.bind(null, null, context));
} | [
"function",
"createContext",
"(",
"req",
",",
"res",
",",
"context",
",",
"done",
")",
"{",
"debug",
"(",
"'default createContext - does nothing'",
",",
"context",
")",
";",
"process",
".",
"nextTick",
"(",
"done",
".",
"bind",
"(",
"null",
",",
"null",
",... | Default implementation of createContext, which responds with the default context. | [
"Default",
"implementation",
"of",
"createContext",
"which",
"responds",
"with",
"the",
"default",
"context",
"."
] | 1e0c8d36c5be4b661b062754c01f064de47873c4 | https://github.com/edappy/seneca-context/blob/1e0c8d36c5be4b661b062754c01f064de47873c4/plugins/setContext.js#L75-L78 | train |
octet-stream/object-deep-from-entries | objectDeepFromEntries.js | objectDeepFromEntries | function objectDeepFromEntries(entries) {
if (!isArray(entries)) {
throw new TypeError(
`Expected an array of entries. Received ${getTag(entries)}`
)
}
let res = {}
let isCollection = false
if (hasNumKey(entries)) {
res = []
isCollection = true
}
for (const entry of entries) {
... | javascript | function objectDeepFromEntries(entries) {
if (!isArray(entries)) {
throw new TypeError(
`Expected an array of entries. Received ${getTag(entries)}`
)
}
let res = {}
let isCollection = false
if (hasNumKey(entries)) {
res = []
isCollection = true
}
for (const entry of entries) {
... | [
"function",
"objectDeepFromEntries",
"(",
"entries",
")",
"{",
"if",
"(",
"!",
"isArray",
"(",
"entries",
")",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"`",
"${",
"getTag",
"(",
"entries",
")",
"}",
"`",
")",
"}",
"let",
"res",
"=",
"{",
"}",
"l... | Create an object from given entries
@param {array} entries
@return {object}
@api public
@example
const entries = [
[
["name"], "John Doe"
],
[
["age"], 25
],
[
["gender"], "Male"
]
]
objectDeepFromEntries(entries)
// -> {name: "John Doe", age: 25, gender: "Male"} | [
"Create",
"an",
"object",
"from",
"given",
"entries"
] | ea0c889c659150aeee6855f03ce7fbfba04ad99a | https://github.com/octet-stream/object-deep-from-entries/blob/ea0c889c659150aeee6855f03ce7fbfba04ad99a/objectDeepFromEntries.js#L87-L124 | train |
socialally/air | lib/air/dimension.js | outerWidth | function outerWidth(margin) {
var s, style;
if(!this.length) {
return null;
}
s = this.dom[0].getClientRects()[0].width;
if(!margin) {
style = window.getComputedStyle(this.dom[0], null);
s -= parseInt(style.getPropertyValue('margin-top'));
s -= parseInt(style.getPropertyValue('margin-bottom'))... | javascript | function outerWidth(margin) {
var s, style;
if(!this.length) {
return null;
}
s = this.dom[0].getClientRects()[0].width;
if(!margin) {
style = window.getComputedStyle(this.dom[0], null);
s -= parseInt(style.getPropertyValue('margin-top'));
s -= parseInt(style.getPropertyValue('margin-bottom'))... | [
"function",
"outerWidth",
"(",
"margin",
")",
"{",
"var",
"s",
",",
"style",
";",
"if",
"(",
"!",
"this",
".",
"length",
")",
"{",
"return",
"null",
";",
"}",
"s",
"=",
"this",
".",
"dom",
"[",
"0",
"]",
".",
"getClientRects",
"(",
")",
"[",
"0... | Get the current computed width for the first element in the set of
matched elements, including padding, border, and optionally margin.
Returns a number (without "px") representation of the value or null
if called on an empty set of elements. | [
"Get",
"the",
"current",
"computed",
"width",
"for",
"the",
"first",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
"including",
"padding",
"border",
"and",
"optionally",
"margin",
"."
] | a3d94de58aaa4930a425fbcc7266764bf6ca8ca6 | https://github.com/socialally/air/blob/a3d94de58aaa4930a425fbcc7266764bf6ca8ca6/lib/air/dimension.js#L34-L46 | train |
socialally/air | lib/air/dimension.js | outerHeight | function outerHeight(margin) {
var s, style;
if(!this.length) {
return null;
}
s = this.dom[0].getClientRects()[0].height;
if(!margin) {
style = window.getComputedStyle(this.dom[0], null);
s -= parseInt(style.getPropertyValue('margin-top'));
s -= parseInt(style.getPropertyValue('margin-bottom'... | javascript | function outerHeight(margin) {
var s, style;
if(!this.length) {
return null;
}
s = this.dom[0].getClientRects()[0].height;
if(!margin) {
style = window.getComputedStyle(this.dom[0], null);
s -= parseInt(style.getPropertyValue('margin-top'));
s -= parseInt(style.getPropertyValue('margin-bottom'... | [
"function",
"outerHeight",
"(",
"margin",
")",
"{",
"var",
"s",
",",
"style",
";",
"if",
"(",
"!",
"this",
".",
"length",
")",
"{",
"return",
"null",
";",
"}",
"s",
"=",
"this",
".",
"dom",
"[",
"0",
"]",
".",
"getClientRects",
"(",
")",
"[",
"... | Get the current computed height for the first element in the set of
matched elements, including padding, border, and optionally margin.
Returns a number (without "px") representation of the value or null
if called on an empty set of elements. | [
"Get",
"the",
"current",
"computed",
"height",
"for",
"the",
"first",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
"including",
"padding",
"border",
"and",
"optionally",
"margin",
"."
] | a3d94de58aaa4930a425fbcc7266764bf6ca8ca6 | https://github.com/socialally/air/blob/a3d94de58aaa4930a425fbcc7266764bf6ca8ca6/lib/air/dimension.js#L55-L67 | train |
Sobesednik/wrote | src/read-dir-structure.js | readDirStructure | async function readDirStructure(dirPath) {
if (!dirPath) {
throw new Error('Please specify a path to the directory')
}
const lstat = await makePromise(fs.lstat, dirPath)
if (!lstat.isDirectory()) {
const err = new Error('Path is not a directory')
err.code = 'ENOTDIR'
thro... | javascript | async function readDirStructure(dirPath) {
if (!dirPath) {
throw new Error('Please specify a path to the directory')
}
const lstat = await makePromise(fs.lstat, dirPath)
if (!lstat.isDirectory()) {
const err = new Error('Path is not a directory')
err.code = 'ENOTDIR'
thro... | [
"async",
"function",
"readDirStructure",
"(",
"dirPath",
")",
"{",
"if",
"(",
"!",
"dirPath",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Please specify a path to the directory'",
")",
"}",
"const",
"lstat",
"=",
"await",
"makePromise",
"(",
"fs",
".",
"lstat",
... | Read a directory, and return its structure as an object
@param {string} dirPath Path to the directory
@returns {Promise.<DirectoryStructure>} An object reflecting directory structure | [
"Read",
"a",
"directory",
"and",
"return",
"its",
"structure",
"as",
"an",
"object"
] | 24992ad3bba4e5959dfb617b6c1f22d9a1306ab9 | https://github.com/Sobesednik/wrote/blob/24992ad3bba4e5959dfb617b6c1f22d9a1306ab9/src/read-dir-structure.js#L50-L88 | train |
eps1lon/poe-i18n | scripts/generateDatLocaleData.js | fromEntries | function fromEntries(keys, values) {
return keys.reduce((obj, key, i) => {
obj[key] = values[i];
return obj;
}, {})
} | javascript | function fromEntries(keys, values) {
return keys.reduce((obj, key, i) => {
obj[key] = values[i];
return obj;
}, {})
} | [
"function",
"fromEntries",
"(",
"keys",
",",
"values",
")",
"{",
"return",
"keys",
".",
"reduce",
"(",
"(",
"obj",
",",
"key",
",",
"i",
")",
"=>",
"{",
"obj",
"[",
"key",
"]",
"=",
"values",
"[",
"i",
"]",
";",
"return",
"obj",
";",
"}",
",",
... | reverse of Object.entries | [
"reverse",
"of",
"Object",
".",
"entries"
] | fa92cc4a2be7f321f07a5dba28135db03dc0bc38 | https://github.com/eps1lon/poe-i18n/blob/fa92cc4a2be7f321f07a5dba28135db03dc0bc38/scripts/generateDatLocaleData.js#L160-L165 | train |
gkarthiks/isEmptyObj | index.js | isEmptyObj | function isEmptyObj(object) {
if(object === undefined)
return true;
var objToSend = JSON.parse(JSON.stringify(object));
var result = nestedEmptyCheck(objToSend);
if(JSON.stringify(result).indexOf('false') > -1)
return false;
return true;
} | javascript | function isEmptyObj(object) {
if(object === undefined)
return true;
var objToSend = JSON.parse(JSON.stringify(object));
var result = nestedEmptyCheck(objToSend);
if(JSON.stringify(result).indexOf('false') > -1)
return false;
return true;
} | [
"function",
"isEmptyObj",
"(",
"object",
")",
"{",
"if",
"(",
"object",
"===",
"undefined",
")",
"return",
"true",
";",
"var",
"objToSend",
"=",
"JSON",
".",
"parse",
"(",
"JSON",
".",
"stringify",
"(",
"object",
")",
")",
";",
"var",
"result",
"=",
... | before calling the nested validation method,
makes a copy of the original object and calls with the copy of the object.
@param object
@returns {boolean} | [
"before",
"calling",
"the",
"nested",
"validation",
"method",
"makes",
"a",
"copy",
"of",
"the",
"original",
"object",
"and",
"calls",
"with",
"the",
"copy",
"of",
"the",
"object",
"."
] | b83ea082db800731b9d7e0ad57e975f864994b07 | https://github.com/gkarthiks/isEmptyObj/blob/b83ea082db800731b9d7e0ad57e975f864994b07/index.js#L60-L69 | train |
onecommons/base | lib/jsonrpc.js | function(result) {
if (done) {
if (session.httpRequest && session.httpRequest.log) {
session.httpRequest.log.error("jsonrpc promise resolved after response sent:", req.method, "params:", req.params);
}
return;
... | javascript | function(result) {
if (done) {
if (session.httpRequest && session.httpRequest.log) {
session.httpRequest.log.error("jsonrpc promise resolved after response sent:", req.method, "params:", req.params);
}
return;
... | [
"function",
"(",
"result",
")",
"{",
"if",
"(",
"done",
")",
"{",
"if",
"(",
"session",
".",
"httpRequest",
"&&",
"session",
".",
"httpRequest",
".",
"log",
")",
"{",
"session",
".",
"httpRequest",
".",
"log",
".",
"error",
"(",
"\"jsonrpc promise resolv... | it's a promise | [
"it",
"s",
"a",
"promise"
] | 4f35d9f714d0367b0622a3504802363404290246 | https://github.com/onecommons/base/blob/4f35d9f714d0367b0622a3504802363404290246/lib/jsonrpc.js#L117-L125 | train | |
jaredhanson/antenna | lib/index.js | create | function create() {
function app(msg) { app.handle(msg); }
utils.merge(app, proto);
app.init();
for (var i = 0; i < arguments.length; ++i) {
app.use(arguments[i]);
}
return app;
} | javascript | function create() {
function app(msg) { app.handle(msg); }
utils.merge(app, proto);
app.init();
for (var i = 0; i < arguments.length; ++i) {
app.use(arguments[i]);
}
return app;
} | [
"function",
"create",
"(",
")",
"{",
"function",
"app",
"(",
"msg",
")",
"{",
"app",
".",
"handle",
"(",
"msg",
")",
";",
"}",
"utils",
".",
"merge",
"(",
"app",
",",
"proto",
")",
";",
"app",
".",
"init",
"(",
")",
";",
"for",
"(",
"var",
"i... | Create application.
@return {Function}
@api public | [
"Create",
"application",
"."
] | fecfa8320a29d0f1cf22df0230f3b65a12316087 | https://github.com/jaredhanson/antenna/blob/fecfa8320a29d0f1cf22df0230f3b65a12316087/lib/index.js#L14-L22 | train |
onecommons/base | lib/namedroutes.js | update | function update(app, target, source) {
for (var prop in source) {
if (!source.hasOwnProperty(prop)) continue;
var def = expandDefinition(app, prop, source[prop]);
if (prop in target) {
if (!def) {
delete target[prop];
} else if (def.route) {
... | javascript | function update(app, target, source) {
for (var prop in source) {
if (!source.hasOwnProperty(prop)) continue;
var def = expandDefinition(app, prop, source[prop]);
if (prop in target) {
if (!def) {
delete target[prop];
} else if (def.route) {
... | [
"function",
"update",
"(",
"app",
",",
"target",
",",
"source",
")",
"{",
"for",
"(",
"var",
"prop",
"in",
"source",
")",
"{",
"if",
"(",
"!",
"source",
".",
"hasOwnProperty",
"(",
"prop",
")",
")",
"continue",
";",
"var",
"def",
"=",
"expandDefiniti... | expand source and target then merge, if source and target are both have route recurse XXX if one or the the have route replace target with source otherwise merge source keys into target, if source key has falsy value, remove the key if handle is being added assume its the current app unless app is specified? | [
"expand",
"source",
"and",
"target",
"then",
"merge",
"if",
"source",
"and",
"target",
"are",
"both",
"have",
"route",
"recurse",
"XXX",
"if",
"one",
"or",
"the",
"the",
"have",
"route",
"replace",
"target",
"with",
"source",
"otherwise",
"merge",
"source",
... | 4f35d9f714d0367b0622a3504802363404290246 | https://github.com/onecommons/base/blob/4f35d9f714d0367b0622a3504802363404290246/lib/namedroutes.js#L10-L32 | 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.