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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
blueapron/grunt-qunit-kimchi | qunit/phantom_screenshot.js | excludeElements | function excludeElements(exclude) {
return Array.isArray(exclude) ? exclude.forEach(function(selector) {
// Use querySelectorAll to hide all dom element with the specified selector
var selectorAll = document.querySelectorAll(selector);
if(selectorAll.length) {
// Interate throug... | javascript | function excludeElements(exclude) {
return Array.isArray(exclude) ? exclude.forEach(function(selector) {
// Use querySelectorAll to hide all dom element with the specified selector
var selectorAll = document.querySelectorAll(selector);
if(selectorAll.length) {
// Interate throug... | [
"function",
"excludeElements",
"(",
"exclude",
")",
"{",
"return",
"Array",
".",
"isArray",
"(",
"exclude",
")",
"?",
"exclude",
".",
"forEach",
"(",
"function",
"(",
"selector",
")",
"{",
"// Use querySelectorAll to hide all dom element with the specified selector",
... | Loop through the exlude array and
find the dom of the selector and hide it
@param {Array} exclude - each item in the array should contain selector string | [
"Loop",
"through",
"the",
"exlude",
"array",
"and",
"find",
"the",
"dom",
"of",
"the",
"selector",
"and",
"hide",
"it"
] | 594450211b0de3175501e39836cf63e7a12f6504 | https://github.com/blueapron/grunt-qunit-kimchi/blob/594450211b0de3175501e39836cf63e7a12f6504/qunit/phantom_screenshot.js#L83-L95 | train |
blueapron/grunt-qunit-kimchi | qunit/phantom_screenshot.js | screenshot | function screenshot(name, options) {
var options = options || {};
var newPath = path;
// options to override
if(options.selector) { selector = options.selector; }
if(options.path) { newPath = path + '/' + options.path; }
if(Array.isArray(options.exclude)) { exclude = exclude.concat... | javascript | function screenshot(name, options) {
var options = options || {};
var newPath = path;
// options to override
if(options.selector) { selector = options.selector; }
if(options.path) { newPath = path + '/' + options.path; }
if(Array.isArray(options.exclude)) { exclude = exclude.concat... | [
"function",
"screenshot",
"(",
"name",
",",
"options",
")",
"{",
"var",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"var",
"newPath",
"=",
"path",
";",
"// options to override",
"if",
"(",
"options",
".",
"selector",
")",
"{",
"selector",
"=",
"optio... | Helper function to take screenshot if in phantomjs environment
@param {String} name - Name of the image to be saved
@param {Object} options - selector[String], path[String], exclude[Array] | [
"Helper",
"function",
"to",
"take",
"screenshot",
"if",
"in",
"phantomjs",
"environment"
] | 594450211b0de3175501e39836cf63e7a12f6504 | https://github.com/blueapron/grunt-qunit-kimchi/blob/594450211b0de3175501e39836cf63e7a12f6504/qunit/phantom_screenshot.js#L131-L144 | train |
bjoerge/route-pattern | route-pattern.js | PathPattern | function PathPattern(options) {
// The route string are compiled to a regexp (if it isn't already)
this.regexp = options.regexp;
// The query parameters specified in the path part of the route
this.params = options.params;
// The original routestring (optional)
this.routeString = options.route... | javascript | function PathPattern(options) {
// The route string are compiled to a regexp (if it isn't already)
this.regexp = options.regexp;
// The query parameters specified in the path part of the route
this.params = options.params;
// The original routestring (optional)
this.routeString = options.route... | [
"function",
"PathPattern",
"(",
"options",
")",
"{",
"// The route string are compiled to a regexp (if it isn't already)",
"this",
".",
"regexp",
"=",
"options",
".",
"regexp",
";",
"// The query parameters specified in the path part of the route",
"this",
".",
"params",
"=",
... | The PathPattern constructor Takes a route string or regexp as parameter and provides a set of utility functions for matching against a location path | [
"The",
"PathPattern",
"constructor",
"Takes",
"a",
"route",
"string",
"or",
"regexp",
"as",
"parameter",
"and",
"provides",
"a",
"set",
"of",
"utility",
"functions",
"for",
"matching",
"against",
"a",
"location",
"path"
] | 460f59e3ecb1f9601f45c9cd93952df39c29d08a | https://github.com/bjoerge/route-pattern/blob/460f59e3ecb1f9601f45c9cd93952df39c29d08a/route-pattern.js#L164-L173 | train |
harishanchu/nodejs-config | lib/config/environmentDetector.js | detectWebEnvironment | function detectWebEnvironment(environments) {
// If the given environment is just a Closure, we will defer the environment check
// to the Closure the developer has provided, which allows them to totally swap
// the webs environment detection logic with their own custom Closure's code.
if (typeof enviro... | javascript | function detectWebEnvironment(environments) {
// If the given environment is just a Closure, we will defer the environment check
// to the Closure the developer has provided, which allows them to totally swap
// the webs environment detection logic with their own custom Closure's code.
if (typeof enviro... | [
"function",
"detectWebEnvironment",
"(",
"environments",
")",
"{",
"// If the given environment is just a Closure, we will defer the environment check",
"// to the Closure the developer has provided, which allows them to totally swap",
"// the webs environment detection logic with their own custom C... | Set the application environment for a web request.
@param {Object|function} environments
@return string | [
"Set",
"the",
"application",
"environment",
"for",
"a",
"web",
"request",
"."
] | 47c0d057913c6aaf361afb667b2141906d15c088 | https://github.com/harishanchu/nodejs-config/blob/47c0d057913c6aaf361afb667b2141906d15c088/lib/config/environmentDetector.js#L30-L54 | train |
pablolb/promise-circuitbreaker | doc/scripts/toc.js | function(ul) {
var prevLevel = {level: -1, index: -1, parent: -1, val: ''};
var levelParent = {0: -1};
tocList = ul.children("li");
tocList.each(function(i) {
var me = $(this).removeClass("toc-active");
var currentLevel = parseInt(me.attr('class').trim().slice(-1));
if (currentLevel > ... | javascript | function(ul) {
var prevLevel = {level: -1, index: -1, parent: -1, val: ''};
var levelParent = {0: -1};
tocList = ul.children("li");
tocList.each(function(i) {
var me = $(this).removeClass("toc-active");
var currentLevel = parseInt(me.attr('class').trim().slice(-1));
if (currentLevel > ... | [
"function",
"(",
"ul",
")",
"{",
"var",
"prevLevel",
"=",
"{",
"level",
":",
"-",
"1",
",",
"index",
":",
"-",
"1",
",",
"parent",
":",
"-",
"1",
",",
"val",
":",
"''",
"}",
";",
"var",
"levelParent",
"=",
"{",
"0",
":",
"-",
"1",
"}",
";",... | Create the tree | [
"Create",
"the",
"tree"
] | cfc27daf6f6477c680c8225ba806751f1838b12b | https://github.com/pablolb/promise-circuitbreaker/blob/cfc27daf6f6477c680c8225ba806751f1838b12b/doc/scripts/toc.js#L54-L77 | train | |
pablolb/promise-circuitbreaker | doc/scripts/toc.js | function(key) {
var me = treeObject[key];
if (me.parent > -1) {
$(tocList[me.parent]).show();
showParents(me.parent);
}
} | javascript | function(key) {
var me = treeObject[key];
if (me.parent > -1) {
$(tocList[me.parent]).show();
showParents(me.parent);
}
} | [
"function",
"(",
"key",
")",
"{",
"var",
"me",
"=",
"treeObject",
"[",
"key",
"]",
";",
"if",
"(",
"me",
".",
"parent",
">",
"-",
"1",
")",
"{",
"$",
"(",
"tocList",
"[",
"me",
".",
"parent",
"]",
")",
".",
"show",
"(",
")",
";",
"showParents... | Show the parents recursively | [
"Show",
"the",
"parents",
"recursively"
] | cfc27daf6f6477c680c8225ba806751f1838b12b | https://github.com/pablolb/promise-circuitbreaker/blob/cfc27daf6f6477c680c8225ba806751f1838b12b/doc/scripts/toc.js#L80-L86 | train | |
pablolb/promise-circuitbreaker | doc/scripts/toc.js | function(searchVal) {
searchVal = searchVal.trim().toLowerCase();
for (var key in treeObject) {
var me = treeObject[key];
if (me.val.indexOf(searchVal) !== -1 || searchVal.length == 0) {
$(tocList[key]).show();
if ($(tocList[me.parent]).is(":hidden")) {
showParents(key);
... | javascript | function(searchVal) {
searchVal = searchVal.trim().toLowerCase();
for (var key in treeObject) {
var me = treeObject[key];
if (me.val.indexOf(searchVal) !== -1 || searchVal.length == 0) {
$(tocList[key]).show();
if ($(tocList[me.parent]).is(":hidden")) {
showParents(key);
... | [
"function",
"(",
"searchVal",
")",
"{",
"searchVal",
"=",
"searchVal",
".",
"trim",
"(",
")",
".",
"toLowerCase",
"(",
")",
";",
"for",
"(",
"var",
"key",
"in",
"treeObject",
")",
"{",
"var",
"me",
"=",
"treeObject",
"[",
"key",
"]",
";",
"if",
"("... | Perform the search | [
"Perform",
"the",
"search"
] | cfc27daf6f6477c680c8225ba806751f1838b12b | https://github.com/pablolb/promise-circuitbreaker/blob/cfc27daf6f6477c680c8225ba806751f1838b12b/doc/scripts/toc.js#L89-L102 | train | |
reklatsmasters/pem-file | index.js | encode | function encode(source, label) {
if (!Buffer.isBuffer(source)) {
throw new TypeError('Argument `source` should be a Buffer.')
}
if (typeof label !== 'string') {
throw new TypeError('Argument `label` should be a string in upper case.')
}
const prefix = before + ' ' + label + endline
const suffix = ... | javascript | function encode(source, label) {
if (!Buffer.isBuffer(source)) {
throw new TypeError('Argument `source` should be a Buffer.')
}
if (typeof label !== 'string') {
throw new TypeError('Argument `label` should be a string in upper case.')
}
const prefix = before + ' ' + label + endline
const suffix = ... | [
"function",
"encode",
"(",
"source",
",",
"label",
")",
"{",
"if",
"(",
"!",
"Buffer",
".",
"isBuffer",
"(",
"source",
")",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'Argument `source` should be a Buffer.'",
")",
"}",
"if",
"(",
"typeof",
"label",
"!=="... | Convert data to PEM format.
@param {Buffer} source
@param {string} label
@returns {String} | [
"Convert",
"data",
"to",
"PEM",
"format",
"."
] | ac192c8edd4ad310400c34691ab2f04042b0bdec | https://github.com/reklatsmasters/pem-file/blob/ac192c8edd4ad310400c34691ab2f04042b0bdec/index.js#L26-L41 | train |
reklatsmasters/pem-file | index.js | decode | function decode(pem) {
if (Buffer.isBuffer(pem)) {
pem = pem.toString('ascii')
}
const lines = pem.trim().split('\n')
if (lines.length < 3) {
throw new Error('Invalid PEM data.')
}
const match = header.exec(lines[0])
if (match === null) {
throw new Error('Invalid label.')
}
const labe... | javascript | function decode(pem) {
if (Buffer.isBuffer(pem)) {
pem = pem.toString('ascii')
}
const lines = pem.trim().split('\n')
if (lines.length < 3) {
throw new Error('Invalid PEM data.')
}
const match = header.exec(lines[0])
if (match === null) {
throw new Error('Invalid label.')
}
const labe... | [
"function",
"decode",
"(",
"pem",
")",
"{",
"if",
"(",
"Buffer",
".",
"isBuffer",
"(",
"pem",
")",
")",
"{",
"pem",
"=",
"pem",
".",
"toString",
"(",
"'ascii'",
")",
"}",
"const",
"lines",
"=",
"pem",
".",
"trim",
"(",
")",
".",
"split",
"(",
"... | Convert PEM formatted data to raw buffer.
@param {Buffer|String} pem
@returns {Buffer} | [
"Convert",
"PEM",
"formatted",
"data",
"to",
"raw",
"buffer",
"."
] | ac192c8edd4ad310400c34691ab2f04042b0bdec | https://github.com/reklatsmasters/pem-file/blob/ac192c8edd4ad310400c34691ab2f04042b0bdec/index.js#L48-L82 | train |
harish2704/html-scrapper | lib/Browser.js | Browser | function Browser ( opts ){
opts = opts || {};
// Members
this.headers = _.defaults({}, headers, opts.headers );
this.proxy = opts.proxy;
this.jar = opts.jar || request.jar();
} | javascript | function Browser ( opts ){
opts = opts || {};
// Members
this.headers = _.defaults({}, headers, opts.headers );
this.proxy = opts.proxy;
this.jar = opts.jar || request.jar();
} | [
"function",
"Browser",
"(",
"opts",
")",
"{",
"opts",
"=",
"opts",
"||",
"{",
"}",
";",
"// Members",
"this",
".",
"headers",
"=",
"_",
".",
"defaults",
"(",
"{",
"}",
",",
"headers",
",",
"opts",
".",
"headers",
")",
";",
"this",
".",
"proxy",
"... | A simple class imitating a web-browser. It can be considered as a wrapper around famous 'request' module.
Current implementation is very limited .
Only get method is implemented. It can be done very easily.
@param {Object} opts - Option object.
@param {Object} opts.headers - [optional] additional headers used for all ... | [
"A",
"simple",
"class",
"imitating",
"a",
"web",
"-",
"browser",
".",
"It",
"can",
"be",
"considered",
"as",
"a",
"wrapper",
"around",
"famous",
"request",
"module",
".",
"Current",
"implementation",
"is",
"very",
"limited",
".",
"Only",
"get",
"method",
"... | 1515a295bb41d3bdecf8e497d2c0b678854d77a1 | https://github.com/harish2704/html-scrapper/blob/1515a295bb41d3bdecf8e497d2c0b678854d77a1/lib/Browser.js#L39-L45 | train |
vicanso/koa-log | lib/dev.js | dev | function dev() {
return function logger(ctx, next) {
// request
const start = new Date();
/* eslint no-console: 0 */
console.log(` ${chalk.gray('<--')} ${chalk.bold(ctx.method)} ${chalk.gray(ctx.originalUrl)}`);
// calculate the length of a streaming response
// by intercepting the stream w... | javascript | function dev() {
return function logger(ctx, next) {
// request
const start = new Date();
/* eslint no-console: 0 */
console.log(` ${chalk.gray('<--')} ${chalk.bold(ctx.method)} ${chalk.gray(ctx.originalUrl)}`);
// calculate the length of a streaming response
// by intercepting the stream w... | [
"function",
"dev",
"(",
")",
"{",
"return",
"function",
"logger",
"(",
"ctx",
",",
"next",
")",
"{",
"// request",
"const",
"start",
"=",
"new",
"Date",
"(",
")",
";",
"/* eslint no-console: 0 */",
"console",
".",
"log",
"(",
"`",
"${",
"chalk",
".",
"... | Development logger. | [
"Development",
"logger",
"."
] | 881c093ba4d4fc8cc01d05c274efeedd32db98fb | https://github.com/vicanso/koa-log/blob/881c093ba4d4fc8cc01d05c274efeedd32db98fb/lib/dev.js#L28-L65 | train |
vicanso/koa-log | lib/dev.js | time | function time(start) {
let delta = new Date() - start;
delta = delta < 10000 ? `${delta}ms` : `${Math.round(delta / 1000)}s`;
return humanize(delta);
} | javascript | function time(start) {
let delta = new Date() - start;
delta = delta < 10000 ? `${delta}ms` : `${Math.round(delta / 1000)}s`;
return humanize(delta);
} | [
"function",
"time",
"(",
"start",
")",
"{",
"let",
"delta",
"=",
"new",
"Date",
"(",
")",
"-",
"start",
";",
"delta",
"=",
"delta",
"<",
"10000",
"?",
"`",
"${",
"delta",
"}",
"`",
":",
"`",
"${",
"Math",
".",
"round",
"(",
"delta",
"/",
"1000"... | Show the response time in a human readable format.
In milliseconds if less than 10 seconds,
in seconds otherwise. | [
"Show",
"the",
"response",
"time",
"in",
"a",
"human",
"readable",
"format",
".",
"In",
"milliseconds",
"if",
"less",
"than",
"10",
"seconds",
"in",
"seconds",
"otherwise",
"."
] | 881c093ba4d4fc8cc01d05c274efeedd32db98fb | https://github.com/vicanso/koa-log/blob/881c093ba4d4fc8cc01d05c274efeedd32db98fb/lib/dev.js#L108-L112 | train |
simonepri/is-sea | index.js | isSea | function isSea(lat, lng) {
if (landLookup === null) {
const map = getMap();
landLookup = new GeoJsonLookup(map);
}
return landLookup.hasContainers({type: 'Point', coordinates: [lng, lat]});
} | javascript | function isSea(lat, lng) {
if (landLookup === null) {
const map = getMap();
landLookup = new GeoJsonLookup(map);
}
return landLookup.hasContainers({type: 'Point', coordinates: [lng, lat]});
} | [
"function",
"isSea",
"(",
"lat",
",",
"lng",
")",
"{",
"if",
"(",
"landLookup",
"===",
"null",
")",
"{",
"const",
"map",
"=",
"getMap",
"(",
")",
";",
"landLookup",
"=",
"new",
"GeoJsonLookup",
"(",
"map",
")",
";",
"}",
"return",
"landLookup",
".",
... | Returns wheather the given point is in the sea or not.
@public
@param {number} lat The latitude of the point.
@param {number} lng The longitude of the point.
@return {boolean} True if the point is in the sea, false otherwise. | [
"Returns",
"wheather",
"the",
"given",
"point",
"is",
"in",
"the",
"sea",
"or",
"not",
"."
] | e437c849942b4600599d3e16a592ca87bf7ee582 | https://github.com/simonepri/is-sea/blob/e437c849942b4600599d3e16a592ca87bf7ee582/index.js#L15-L22 | train |
Justineo/postcss-sort-style-rules | index.js | getRange | function getRange(node) {
if (isScope(node)) {
return node.nodes
.map(getRange)
.reduce(reduceRanges);
} else if (node.type === 'rule') {
return specificity.calculate(node.selector)
.map(result => {
return result.specificity.split(',').map(v =>... | javascript | function getRange(node) {
if (isScope(node)) {
return node.nodes
.map(getRange)
.reduce(reduceRanges);
} else if (node.type === 'rule') {
return specificity.calculate(node.selector)
.map(result => {
return result.specificity.split(',').map(v =>... | [
"function",
"getRange",
"(",
"node",
")",
"{",
"if",
"(",
"isScope",
"(",
"node",
")",
")",
"{",
"return",
"node",
".",
"nodes",
".",
"map",
"(",
"getRange",
")",
".",
"reduce",
"(",
"reduceRanges",
")",
";",
"}",
"else",
"if",
"(",
"node",
".",
... | Get specificity range of a style rule or a scope | [
"Get",
"specificity",
"range",
"of",
"a",
"style",
"rule",
"or",
"a",
"scope"
] | 11d28ee3595c9c37003f69d78657605234fe817e | https://github.com/Justineo/postcss-sort-style-rules/blob/11d28ee3595c9c37003f69d78657605234fe817e/index.js#L63-L76 | train |
discolabs/shopify.i18n.js | dist/shopify.i18n.js | init | function init(defaultLocale, defaultLocaleAssetUrl, defaultCurrency) {
// Store default/initial settings.
_defaultLocale = defaultLocale;
_defaultLocaleAssetUrl = defaultLocaleAssetUrl;
_defaultCurrency = defaultCurrency;
// Store default currency against the Currency object.
Currency.currentCu... | javascript | function init(defaultLocale, defaultLocaleAssetUrl, defaultCurrency) {
// Store default/initial settings.
_defaultLocale = defaultLocale;
_defaultLocaleAssetUrl = defaultLocaleAssetUrl;
_defaultCurrency = defaultCurrency;
// Store default currency against the Currency object.
Currency.currentCu... | [
"function",
"init",
"(",
"defaultLocale",
",",
"defaultLocaleAssetUrl",
",",
"defaultCurrency",
")",
"{",
"// Store default/initial settings.",
"_defaultLocale",
"=",
"defaultLocale",
";",
"_defaultLocaleAssetUrl",
"=",
"defaultLocaleAssetUrl",
";",
"_defaultCurrency",
"=",
... | Initialise the i18n module.
@param defaultLocale
@param defaultLocaleAssetUrl
@param defaultCurrency | [
"Initialise",
"the",
"i18n",
"module",
"."
] | aefa0999b9dece6e4fa74df29b50c0a543608049 | https://github.com/discolabs/shopify.i18n.js/blob/aefa0999b9dece6e4fa74df29b50c0a543608049/dist/shopify.i18n.js#L672-L697 | train |
discolabs/shopify.i18n.js | dist/shopify.i18n.js | translateElement | function translateElement(element, locale) {
var $element = $(element),
keyPath = $element.data('translate');
var translation = getTranslation(keyPath, locale);
if(translation) {
$(element).text(translation);
}
} | javascript | function translateElement(element, locale) {
var $element = $(element),
keyPath = $element.data('translate');
var translation = getTranslation(keyPath, locale);
if(translation) {
$(element).text(translation);
}
} | [
"function",
"translateElement",
"(",
"element",
",",
"locale",
")",
"{",
"var",
"$element",
"=",
"$",
"(",
"element",
")",
",",
"keyPath",
"=",
"$element",
".",
"data",
"(",
"'translate'",
")",
";",
"var",
"translation",
"=",
"getTranslation",
"(",
"keyPat... | Translate a specific element to the given locale.
@param element
@param locale | [
"Translate",
"a",
"specific",
"element",
"to",
"the",
"given",
"locale",
"."
] | aefa0999b9dece6e4fa74df29b50c0a543608049 | https://github.com/discolabs/shopify.i18n.js/blob/aefa0999b9dece6e4fa74df29b50c0a543608049/dist/shopify.i18n.js#L733-L741 | train |
discolabs/shopify.i18n.js | dist/shopify.i18n.js | translate | function translate(locale) {
// Check to see if we have the locale translation data available. If not, fetch it via Ajax.
if(_locales[locale] === undefined) {
$.getJSON(getLocaleAssetUrl(locale), function (localeData) {
// Store the returned locale data.
_locales[locale] = localeData;
... | javascript | function translate(locale) {
// Check to see if we have the locale translation data available. If not, fetch it via Ajax.
if(_locales[locale] === undefined) {
$.getJSON(getLocaleAssetUrl(locale), function (localeData) {
// Store the returned locale data.
_locales[locale] = localeData;
... | [
"function",
"translate",
"(",
"locale",
")",
"{",
"// Check to see if we have the locale translation data available. If not, fetch it via Ajax.",
"if",
"(",
"_locales",
"[",
"locale",
"]",
"===",
"undefined",
")",
"{",
"$",
".",
"getJSON",
"(",
"getLocaleAssetUrl",
"(",
... | Translate all elements on the page marked up with data-translate attributes to the given locale.
@param locale | [
"Translate",
"all",
"elements",
"on",
"the",
"page",
"marked",
"up",
"with",
"data",
"-",
"translate",
"attributes",
"to",
"the",
"given",
"locale",
"."
] | aefa0999b9dece6e4fa74df29b50c0a543608049 | https://github.com/discolabs/shopify.i18n.js/blob/aefa0999b9dece6e4fa74df29b50c0a543608049/dist/shopify.i18n.js#L748-L767 | train |
discolabs/shopify.i18n.js | dist/shopify.i18n.js | convert | function convert(currency) {
// Store the current currency.
var oldCurrency = Currency.currentCurrency;
// Call convertAll with all possible formats. Currency.currentCurrency will be set as a side effect.
Currency.convertAll(Currency.currentCurrency, currency, '[data-convert="money"]', 'money_format');... | javascript | function convert(currency) {
// Store the current currency.
var oldCurrency = Currency.currentCurrency;
// Call convertAll with all possible formats. Currency.currentCurrency will be set as a side effect.
Currency.convertAll(Currency.currentCurrency, currency, '[data-convert="money"]', 'money_format');... | [
"function",
"convert",
"(",
"currency",
")",
"{",
"// Store the current currency.",
"var",
"oldCurrency",
"=",
"Currency",
".",
"currentCurrency",
";",
"// Call convertAll with all possible formats. Currency.currentCurrency will be set as a side effect.",
"Currency",
".",
"convertA... | Convert all elements on the page marked up with data-convert attributes to the given currency.
@param currency | [
"Convert",
"all",
"elements",
"on",
"the",
"page",
"marked",
"up",
"with",
"data",
"-",
"convert",
"attributes",
"to",
"the",
"given",
"currency",
"."
] | aefa0999b9dece6e4fa74df29b50c0a543608049 | https://github.com/discolabs/shopify.i18n.js/blob/aefa0999b9dece6e4fa74df29b50c0a543608049/dist/shopify.i18n.js#L796-L812 | train |
alexmic/mongoose-fakery | lib/fakery.js | Factory | function Factory(name, model, attributes) {
this.name = name;
this.model = model;
this.attributes = attributes;
} | javascript | function Factory(name, model, attributes) {
this.name = name;
this.model = model;
this.attributes = attributes;
} | [
"function",
"Factory",
"(",
"name",
",",
"model",
",",
"attributes",
")",
"{",
"this",
".",
"name",
"=",
"name",
";",
"this",
".",
"model",
"=",
"model",
";",
"this",
".",
"attributes",
"=",
"attributes",
";",
"}"
] | Helper Factory class. Mainly acts as a 'mark' that this is a Factory. For
now this does not play an active role in anything. | [
"Helper",
"Factory",
"class",
".",
"Mainly",
"acts",
"as",
"a",
"mark",
"that",
"this",
"is",
"a",
"Factory",
".",
"For",
"now",
"this",
"does",
"not",
"play",
"an",
"active",
"role",
"in",
"anything",
"."
] | 98a7357e08d48c785c804dab350e77eb420d3d91 | https://github.com/alexmic/mongoose-fakery/blob/98a7357e08d48c785c804dab350e77eb420d3d91/lib/fakery.js#L14-L18 | train |
alexmic/mongoose-fakery | lib/fakery.js | function(name, model, attributes) {
if (name != null && model == null && attributes == null) return factories[name];
if (model == null) return;
if (attributes == null) attributes = {};
factories[name] = new Factory(name, model, attributes);
} | javascript | function(name, model, attributes) {
if (name != null && model == null && attributes == null) return factories[name];
if (model == null) return;
if (attributes == null) attributes = {};
factories[name] = new Factory(name, model, attributes);
} | [
"function",
"(",
"name",
",",
"model",
",",
"attributes",
")",
"{",
"if",
"(",
"name",
"!=",
"null",
"&&",
"model",
"==",
"null",
"&&",
"attributes",
"==",
"null",
")",
"return",
"factories",
"[",
"name",
"]",
";",
"if",
"(",
"model",
"==",
"null",
... | Adds a factory object in `factories`. If a factory with the given name
is already defined, it will get overriden. If only `name` is provided
then it acts as a getter for the named factory.
Params:
- name: the name of the factory, as a string
- model: the mongoose model class
- attributes: hash with model attributes
E... | [
"Adds",
"a",
"factory",
"object",
"in",
"factories",
".",
"If",
"a",
"factory",
"with",
"the",
"given",
"name",
"is",
"already",
"defined",
"it",
"will",
"get",
"overriden",
".",
"If",
"only",
"name",
"is",
"provided",
"then",
"it",
"acts",
"as",
"a",
... | 98a7357e08d48c785c804dab350e77eb420d3d91 | https://github.com/alexmic/mongoose-fakery/blob/98a7357e08d48c785c804dab350e77eb420d3d91/lib/fakery.js#L46-L51 | train | |
alexmic/mongoose-fakery | lib/fakery.js | function(attr, lazyContext) {
var resolved;
if (helpers.isArray(attr)) {
resolved = helpers.map(attr, function(item) {
return resolve(item, lazyContext);
});
} else if (helpers.isFunction(attr)) {
if (attr._lazy === true) {
if (lazyContext != null) resolved =... | javascript | function(attr, lazyContext) {
var resolved;
if (helpers.isArray(attr)) {
resolved = helpers.map(attr, function(item) {
return resolve(item, lazyContext);
});
} else if (helpers.isFunction(attr)) {
if (attr._lazy === true) {
if (lazyContext != null) resolved =... | [
"function",
"(",
"attr",
",",
"lazyContext",
")",
"{",
"var",
"resolved",
";",
"if",
"(",
"helpers",
".",
"isArray",
"(",
"attr",
")",
")",
"{",
"resolved",
"=",
"helpers",
".",
"map",
"(",
"attr",
",",
"function",
"(",
"item",
")",
"{",
"return",
... | Resolves an attribute to a value, depending on its type.
`lazyContext` is passed to this method during the second pass where
lazy attributes are supposed to get resolved.
This is a private method.
Params
- attr: the factory attribute to resolve
- lazyContext: the context for lazy attributes, which is a hash of all
r... | [
"Resolves",
"an",
"attribute",
"to",
"a",
"value",
"depending",
"on",
"its",
"type",
"."
] | 98a7357e08d48c785c804dab350e77eb420d3d91 | https://github.com/alexmic/mongoose-fakery/blob/98a7357e08d48c785c804dab350e77eb420d3d91/lib/fakery.js#L67-L90 | train | |
alexmic/mongoose-fakery | lib/fakery.js | function(name, overrides) {
var factory = factories[name], resolved;
if (overrides == null) overrides = {};
if (factory == null) return;
// resolve "eager" properties first and leave lazy ones for a second pass
var resolved = resolve(factory.attributes);
// pass already resolved attributes as co... | javascript | function(name, overrides) {
var factory = factories[name], resolved;
if (overrides == null) overrides = {};
if (factory == null) return;
// resolve "eager" properties first and leave lazy ones for a second pass
var resolved = resolve(factory.attributes);
// pass already resolved attributes as co... | [
"function",
"(",
"name",
",",
"overrides",
")",
"{",
"var",
"factory",
"=",
"factories",
"[",
"name",
"]",
",",
"resolved",
";",
"if",
"(",
"overrides",
"==",
"null",
")",
"overrides",
"=",
"{",
"}",
";",
"if",
"(",
"factory",
"==",
"null",
")",
"r... | Makes a model from the factory with the given `name`.
Params
- name: the name of the factory, as a string
- overrides: a hash of attributes to override factory attributes passed
in `fake()` call.
Examples:
>>> fakery.make('test', {name: 'test'});
// => {name: 'test', ...} | [
"Makes",
"a",
"model",
"from",
"the",
"factory",
"with",
"the",
"given",
"name",
"."
] | 98a7357e08d48c785c804dab350e77eb420d3d91 | https://github.com/alexmic/mongoose-fakery/blob/98a7357e08d48c785c804dab350e77eb420d3d91/lib/fakery.js#L104-L117 | train | |
alexmic/mongoose-fakery | lib/fakery.js | function(name, arg1, arg2) {
var overrides, done, model;
if (helpers.isObject(arg1)) {
overrides = arg1;
done = arg2;
}
if (helpers.isFunction(arg1)) {
overrides = {};
done = arg1;
}
model = make(name, overrides);
if (model != null) model.save(done);
retur... | javascript | function(name, arg1, arg2) {
var overrides, done, model;
if (helpers.isObject(arg1)) {
overrides = arg1;
done = arg2;
}
if (helpers.isFunction(arg1)) {
overrides = {};
done = arg1;
}
model = make(name, overrides);
if (model != null) model.save(done);
retur... | [
"function",
"(",
"name",
",",
"arg1",
",",
"arg2",
")",
"{",
"var",
"overrides",
",",
"done",
",",
"model",
";",
"if",
"(",
"helpers",
".",
"isObject",
"(",
"arg1",
")",
")",
"{",
"overrides",
"=",
"arg1",
";",
"done",
"=",
"arg2",
";",
"}",
"if"... | Makes a model and persists it in the database.
Params
- name: the name of the factory, as a string
- arg1: either a mongoose callback or an override hash
- arg2: if arg1 is an override hash, then arg2 is the mongoose callback
Examples:
>>> fakery.makeAndSave('test', function(err, test) {
console.log(test);
})
// => T... | [
"Makes",
"a",
"model",
"and",
"persists",
"it",
"in",
"the",
"database",
"."
] | 98a7357e08d48c785c804dab350e77eb420d3d91 | https://github.com/alexmic/mongoose-fakery/blob/98a7357e08d48c785c804dab350e77eb420d3d91/lib/fakery.js#L133-L146 | train | |
alexmic/mongoose-fakery | lib/fakery.js | function(name, fn) {
if (name == null || fn == null) return;
generatorStore[name] = function() {
var args = [].slice.call(arguments);
return function() {
return fn.apply(fn, args);
};
};
} | javascript | function(name, fn) {
if (name == null || fn == null) return;
generatorStore[name] = function() {
var args = [].slice.call(arguments);
return function() {
return fn.apply(fn, args);
};
};
} | [
"function",
"(",
"name",
",",
"fn",
")",
"{",
"if",
"(",
"name",
"==",
"null",
"||",
"fn",
"==",
"null",
")",
"return",
";",
"generatorStore",
"[",
"name",
"]",
"=",
"function",
"(",
")",
"{",
"var",
"args",
"=",
"[",
"]",
".",
"slice",
".",
"c... | Creates and stores a new generator function from a data provider. A data
provider is basically a function that returns some data. Generators wrap
data providers and pass any parameters they receive.
Params:
- name: the name of the generator, as a string
- fn: the provider function
Examples:
>>> fakery.generator('now'... | [
"Creates",
"and",
"stores",
"a",
"new",
"generator",
"function",
"from",
"a",
"data",
"provider",
".",
"A",
"data",
"provider",
"is",
"basically",
"a",
"function",
"that",
"returns",
"some",
"data",
".",
"Generators",
"wrap",
"data",
"providers",
"and",
"pas... | 98a7357e08d48c785c804dab350e77eb420d3d91 | https://github.com/alexmic/mongoose-fakery/blob/98a7357e08d48c785c804dab350e77eb420d3d91/lib/fakery.js#L163-L171 | train | |
azu/babel-plugin-jsdoc-to-assert | src/index.js | maybeSkip | function maybeSkip(path) {
if(path.__jsdoc_to_assert_checked__) {
return true;
}
const {node} = path;
if (node.leadingComments != null && node.leadingComments.length > 0) {
return false;
}
return true;
} | javascript | function maybeSkip(path) {
if(path.__jsdoc_to_assert_checked__) {
return true;
}
const {node} = path;
if (node.leadingComments != null && node.leadingComments.length > 0) {
return false;
}
return true;
} | [
"function",
"maybeSkip",
"(",
"path",
")",
"{",
"if",
"(",
"path",
".",
"__jsdoc_to_assert_checked__",
")",
"{",
"return",
"true",
";",
"}",
"const",
"{",
"node",
"}",
"=",
"path",
";",
"if",
"(",
"node",
".",
"leadingComments",
"!=",
"null",
"&&",
"no... | if the `path` have not comments, return true
@param {Object} path
@returns {boolean} | [
"if",
"the",
"path",
"have",
"not",
"comments",
"return",
"true"
] | 1b001e993a6086ec01305fc310283ddf3273c92b | https://github.com/azu/babel-plugin-jsdoc-to-assert/blob/1b001e993a6086ec01305fc310283ddf3273c92b/src/index.js#L23-L32 | train |
emmetio/html-transform | lib/addons/bem.js | getBlockName | function getBlockName(node, lookup, prefix) {
let depth = prefix.length > 1 ? prefix.length : 0;
// NB don’t walk up to root node, stay at first root child in case of
// too deep prefix
while (node.parent && node.parent.parent && depth--) {
node = node.parent;
}
return lookup.get(node) || '';
} | javascript | function getBlockName(node, lookup, prefix) {
let depth = prefix.length > 1 ? prefix.length : 0;
// NB don’t walk up to root node, stay at first root child in case of
// too deep prefix
while (node.parent && node.parent.parent && depth--) {
node = node.parent;
}
return lookup.get(node) || '';
} | [
"function",
"getBlockName",
"(",
"node",
",",
"lookup",
",",
"prefix",
")",
"{",
"let",
"depth",
"=",
"prefix",
".",
"length",
">",
"1",
"?",
"prefix",
".",
"length",
":",
"0",
";",
"// NB don’t walk up to root node, stay at first root child in case of",
"// too d... | Returns block name for given `node` by `prefix`, which tells the depth of
of parent node lookup
@param {Node} node
@param {Map} lookup
@param {String} prefix
@return {String} | [
"Returns",
"block",
"name",
"for",
"given",
"node",
"by",
"prefix",
"which",
"tells",
"the",
"depth",
"of",
"of",
"parent",
"node",
"lookup"
] | 61774dba583f811f910f7b031743289b87cab98f | https://github.com/emmetio/html-transform/blob/61774dba583f811f910f7b031743289b87cab98f/lib/addons/bem.js#L132-L142 | train |
julianburr/sketchtool-cli | index.js | pluginFolder | function pluginFolder () {
const path = sketchtoolExec('show plugins');
invariant(path, 'Plugin folder not found!');
invariant(fs.existsSync(path), `Plugin folder does not exist at ${path}!`);
return path;
} | javascript | function pluginFolder () {
const path = sketchtoolExec('show plugins');
invariant(path, 'Plugin folder not found!');
invariant(fs.existsSync(path), `Plugin folder does not exist at ${path}!`);
return path;
} | [
"function",
"pluginFolder",
"(",
")",
"{",
"const",
"path",
"=",
"sketchtoolExec",
"(",
"'show plugins'",
")",
";",
"invariant",
"(",
"path",
",",
"'Plugin folder not found!'",
")",
";",
"invariant",
"(",
"fs",
".",
"existsSync",
"(",
"path",
")",
",",
"`",
... | Receive plugin folder path from current Sketch installation
@return {string} | [
"Receive",
"plugin",
"folder",
"path",
"from",
"current",
"Sketch",
"installation"
] | 9609acf4ef234507eef32151f93e892243437124 | https://github.com/julianburr/sketchtool-cli/blob/9609acf4ef234507eef32151f93e892243437124/index.js#L71-L76 | train |
julianburr/sketchtool-cli | index.js | runPluginWithIdentifier | function runPluginWithIdentifier (pluginName, identifier, options = {}) {
const pluginFolderPath = options.dir || pluginFolder();
// Append `.sketchplugin` if not passed in with the plugin name
if (!pluginName.endsWith('.sketchplugin')) {
pluginName += '.sketchplugin';
}
const pluginPath = `${pluginFolde... | javascript | function runPluginWithIdentifier (pluginName, identifier, options = {}) {
const pluginFolderPath = options.dir || pluginFolder();
// Append `.sketchplugin` if not passed in with the plugin name
if (!pluginName.endsWith('.sketchplugin')) {
pluginName += '.sketchplugin';
}
const pluginPath = `${pluginFolde... | [
"function",
"runPluginWithIdentifier",
"(",
"pluginName",
",",
"identifier",
",",
"options",
"=",
"{",
"}",
")",
"{",
"const",
"pluginFolderPath",
"=",
"options",
".",
"dir",
"||",
"pluginFolder",
"(",
")",
";",
"// Append `.sketchplugin` if not passed in with the plu... | Run given plugin command of given plugin name
@param {string} pluginName
@param {string} identifier
@param {Object} options | [
"Run",
"given",
"plugin",
"command",
"of",
"given",
"plugin",
"name"
] | 9609acf4ef234507eef32151f93e892243437124 | https://github.com/julianburr/sketchtool-cli/blob/9609acf4ef234507eef32151f93e892243437124/index.js#L84-L107 | train |
julianburr/sketchtool-cli | index.js | list | function list (type, filePath) {
invariant(
ALLOWED_LIST_TYPES.includes(type),
`Type '${type}' is not supported by sketchtool`
);
return JSON.parse(sketchtoolExec(`list ${type} ${escape(filePath)}`));
} | javascript | function list (type, filePath) {
invariant(
ALLOWED_LIST_TYPES.includes(type),
`Type '${type}' is not supported by sketchtool`
);
return JSON.parse(sketchtoolExec(`list ${type} ${escape(filePath)}`));
} | [
"function",
"list",
"(",
"type",
",",
"filePath",
")",
"{",
"invariant",
"(",
"ALLOWED_LIST_TYPES",
".",
"includes",
"(",
"type",
")",
",",
"`",
"${",
"type",
"}",
"`",
")",
";",
"return",
"JSON",
".",
"parse",
"(",
"sketchtoolExec",
"(",
"`",
"${",
... | List specific element type from given file
@param {string} type
@param {string} filePath
@return {Object} | [
"List",
"specific",
"element",
"type",
"from",
"given",
"file"
] | 9609acf4ef234507eef32151f93e892243437124 | https://github.com/julianburr/sketchtool-cli/blob/9609acf4ef234507eef32151f93e892243437124/index.js#L124-L130 | train |
amida-tech/withings-lib | lib/withings.js | function (options) {
this._oauth = new OAuth.OAuth(
endpoints.requestToken,
endpoints.accessToken,
options.consumerKey,
options.consumerSecret,
'1.0',
options.callbackUrl,
'HMAC-SHA1'
);
// Store authenticated access if it exists
if (options.acce... | javascript | function (options) {
this._oauth = new OAuth.OAuth(
endpoints.requestToken,
endpoints.accessToken,
options.consumerKey,
options.consumerSecret,
'1.0',
options.callbackUrl,
'HMAC-SHA1'
);
// Store authenticated access if it exists
if (options.acce... | [
"function",
"(",
"options",
")",
"{",
"this",
".",
"_oauth",
"=",
"new",
"OAuth",
".",
"OAuth",
"(",
"endpoints",
".",
"requestToken",
",",
"endpoints",
".",
"accessToken",
",",
"options",
".",
"consumerKey",
",",
"options",
".",
"consumerSecret",
",",
"'1... | OAuth API Client | [
"OAuth",
"API",
"Client"
] | e82ad901f1642f276dcfcceb3ac93edd9027cd2f | https://github.com/amida-tech/withings-lib/blob/e82ad901f1642f276dcfcceb3ac93edd9027cd2f/lib/withings.js#L35-L58 | train | |
pablolb/promise-circuitbreaker | lib/observer.js | CBObserver | function CBObserver() {
var EVENT = 'interval',
watched = [],
listeners = [],
intervals = {},
self = this;
/**
* Watch a circuit breaker
*
* @param {CircuitBreaker} cb - The circuit breaker on which we'll listen the 'interval' event.
*/
this.watc... | javascript | function CBObserver() {
var EVENT = 'interval',
watched = [],
listeners = [],
intervals = {},
self = this;
/**
* Watch a circuit breaker
*
* @param {CircuitBreaker} cb - The circuit breaker on which we'll listen the 'interval' event.
*/
this.watc... | [
"function",
"CBObserver",
"(",
")",
"{",
"var",
"EVENT",
"=",
"'interval'",
",",
"watched",
"=",
"[",
"]",
",",
"listeners",
"=",
"[",
"]",
",",
"intervals",
"=",
"{",
"}",
",",
"self",
"=",
"this",
";",
"/**\n * Watch a circuit breaker\n *\n * @... | An observer that watches one or more circuit breakers. It will
group their 'interval' event by name, and emit a single 'batch'
event with their combined data.
@fires CBObserver#batch
@constructor | [
"An",
"observer",
"that",
"watches",
"one",
"or",
"more",
"circuit",
"breakers",
".",
"It",
"will",
"group",
"their",
"interval",
"event",
"by",
"name",
"and",
"emit",
"a",
"single",
"batch",
"event",
"with",
"their",
"combined",
"data",
"."
] | cfc27daf6f6477c680c8225ba806751f1838b12b | https://github.com/pablolb/promise-circuitbreaker/blob/cfc27daf6f6477c680c8225ba806751f1838b12b/lib/observer.js#L14-L92 | train |
emmetio/html-transform | lib/numbering.js | findRepeater | function findRepeater(node) {
while (node) {
if (node.repeat) {
return node.repeat;
}
node = node.parent;
}
} | javascript | function findRepeater(node) {
while (node) {
if (node.repeat) {
return node.repeat;
}
node = node.parent;
}
} | [
"function",
"findRepeater",
"(",
"node",
")",
"{",
"while",
"(",
"node",
")",
"{",
"if",
"(",
"node",
".",
"repeat",
")",
"{",
"return",
"node",
".",
"repeat",
";",
"}",
"node",
"=",
"node",
".",
"parent",
";",
"}",
"}"
] | Returns repeater object for given node
@param {Node} node
@return {Object} | [
"Returns",
"repeater",
"object",
"for",
"given",
"node"
] | 61774dba583f811f910f7b031743289b87cab98f | https://github.com/emmetio/html-transform/blob/61774dba583f811f910f7b031743289b87cab98f/lib/numbering.js#L50-L58 | train |
emmetio/html-transform | lib/numbering.js | replaceNumbering | function replaceNumbering(str, value, count) {
// replace numbering in strings only: skip explicit wrappers that could
// contain unescaped numbering tokens
if (typeof str === 'string') {
const ranges = getNumberingRanges(str);
return replaceNumberingRanges(str, ranges, value, count);
}
... | javascript | function replaceNumbering(str, value, count) {
// replace numbering in strings only: skip explicit wrappers that could
// contain unescaped numbering tokens
if (typeof str === 'string') {
const ranges = getNumberingRanges(str);
return replaceNumberingRanges(str, ranges, value, count);
}
... | [
"function",
"replaceNumbering",
"(",
"str",
",",
"value",
",",
"count",
")",
"{",
"// replace numbering in strings only: skip explicit wrappers that could",
"// contain unescaped numbering tokens",
"if",
"(",
"typeof",
"str",
"===",
"'string'",
")",
"{",
"const",
"ranges",
... | Replaces numbering in given string
@param {String} str
@param {Number} value
@return {String} | [
"Replaces",
"numbering",
"in",
"given",
"string"
] | 61774dba583f811f910f7b031743289b87cab98f | https://github.com/emmetio/html-transform/blob/61774dba583f811f910f7b031743289b87cab98f/lib/numbering.js#L66-L75 | train |
emmetio/html-transform | lib/numbering.js | unescapeString | function unescapeString(str) {
let i = 0, result = '';
const len = str.length;
while (i < len) {
const ch = str[i++];
result += (ch === '\\') ? (str[i++] || '') : ch;
}
return result;
} | javascript | function unescapeString(str) {
let i = 0, result = '';
const len = str.length;
while (i < len) {
const ch = str[i++];
result += (ch === '\\') ? (str[i++] || '') : ch;
}
return result;
} | [
"function",
"unescapeString",
"(",
"str",
")",
"{",
"let",
"i",
"=",
"0",
",",
"result",
"=",
"''",
";",
"const",
"len",
"=",
"str",
".",
"length",
";",
"while",
"(",
"i",
"<",
"len",
")",
"{",
"const",
"ch",
"=",
"str",
"[",
"i",
"++",
"]",
... | Unescapes characters, screened with `\`, in given string
@param {String} str
@return {String} | [
"Unescapes",
"characters",
"screened",
"with",
"\\",
"in",
"given",
"string"
] | 61774dba583f811f910f7b031743289b87cab98f | https://github.com/emmetio/html-transform/blob/61774dba583f811f910f7b031743289b87cab98f/lib/numbering.js#L125-L135 | train |
emmetio/html-transform | lib/repeater-content.js | insertContentIntoPlaceholder | function insertContentIntoPlaceholder(node, content) {
const state = {replaced: false};
node.value = replacePlaceholder(node.value, content, state);
node.attributes.forEach(attr => {
if (attr.value) {
node.setAttribute(attr.name, replacePlaceholder(attr.value, content, state));
}
});
return state.replaced... | javascript | function insertContentIntoPlaceholder(node, content) {
const state = {replaced: false};
node.value = replacePlaceholder(node.value, content, state);
node.attributes.forEach(attr => {
if (attr.value) {
node.setAttribute(attr.name, replacePlaceholder(attr.value, content, state));
}
});
return state.replaced... | [
"function",
"insertContentIntoPlaceholder",
"(",
"node",
",",
"content",
")",
"{",
"const",
"state",
"=",
"{",
"replaced",
":",
"false",
"}",
";",
"node",
".",
"value",
"=",
"replacePlaceholder",
"(",
"node",
".",
"value",
",",
"content",
",",
"state",
")"... | Inserts given `content` into placeholders for given `node`. Placeholders
might be available in attribute values and node content
@param {Node} node
@param {String} content
@return {Boolean} Returns `true` if placeholders were found and replaced in node | [
"Inserts",
"given",
"content",
"into",
"placeholders",
"for",
"given",
"node",
".",
"Placeholders",
"might",
"be",
"available",
"in",
"attribute",
"values",
"and",
"node",
"content"
] | 61774dba583f811f910f7b031743289b87cab98f | https://github.com/emmetio/html-transform/blob/61774dba583f811f910f7b031743289b87cab98f/lib/repeater-content.js#L118-L129 | train |
emmetio/html-transform | lib/repeater-content.js | replacePlaceholder | function replacePlaceholder(str, value, _state) {
if (typeof str === 'string') {
const ranges = findUnescapedTokens(str, placeholder);
if (ranges.length) {
if (_state) {
_state.replaced = true;
}
str = replaceRanges(str, ranges, value);
}
}
return str;
} | javascript | function replacePlaceholder(str, value, _state) {
if (typeof str === 'string') {
const ranges = findUnescapedTokens(str, placeholder);
if (ranges.length) {
if (_state) {
_state.replaced = true;
}
str = replaceRanges(str, ranges, value);
}
}
return str;
} | [
"function",
"replacePlaceholder",
"(",
"str",
",",
"value",
",",
"_state",
")",
"{",
"if",
"(",
"typeof",
"str",
"===",
"'string'",
")",
"{",
"const",
"ranges",
"=",
"findUnescapedTokens",
"(",
"str",
",",
"placeholder",
")",
";",
"if",
"(",
"ranges",
".... | Replaces all placeholder occurances in given `str` with `value`
@param {String} str
@param {String} value
@param {Object} [_state] If provided, set `replaced` property of given
object to `true` if placeholder was found and replaced
@return {String} | [
"Replaces",
"all",
"placeholder",
"occurances",
"in",
"given",
"str",
"with",
"value"
] | 61774dba583f811f910f7b031743289b87cab98f | https://github.com/emmetio/html-transform/blob/61774dba583f811f910f7b031743289b87cab98f/lib/repeater-content.js#L139-L152 | train |
emmetio/html-transform | lib/repeater-content.js | setNodeContent | function setNodeContent(node, content) {
// find caret position and replace it with content, if possible
if (node.value) {
const ranges = findUnescapedTokens(node.value, caret);
if (ranges.length) {
node.value = replaceRanges(node.value, ranges, content);
return;
}
}
if ((node.name && node.name.toLower... | javascript | function setNodeContent(node, content) {
// find caret position and replace it with content, if possible
if (node.value) {
const ranges = findUnescapedTokens(node.value, caret);
if (ranges.length) {
node.value = replaceRanges(node.value, ranges, content);
return;
}
}
if ((node.name && node.name.toLower... | [
"function",
"setNodeContent",
"(",
"node",
",",
"content",
")",
"{",
"// find caret position and replace it with content, if possible",
"if",
"(",
"node",
".",
"value",
")",
"{",
"const",
"ranges",
"=",
"findUnescapedTokens",
"(",
"node",
".",
"value",
",",
"caret",... | Updates content of given node
@param {Node} node
@param {String} content | [
"Updates",
"content",
"of",
"given",
"node"
] | 61774dba583f811f910f7b031743289b87cab98f | https://github.com/emmetio/html-transform/blob/61774dba583f811f910f7b031743289b87cab98f/lib/repeater-content.js#L172-L192 | train |
mikcsabee/npm-submodule-webpack-plugin | src/plugin.js | NpmSubmodulePlugin | function NpmSubmodulePlugin(options) {
// initialize instance variables
this.commands = options.commands ? options.commands : [];
this.autoInstall = options.autoInstall ? options.autoInstall : false;
this.logger = options.logger ? options.logger : console.log;
this.path = 'node_modules' + path.sep + options.m... | javascript | function NpmSubmodulePlugin(options) {
// initialize instance variables
this.commands = options.commands ? options.commands : [];
this.autoInstall = options.autoInstall ? options.autoInstall : false;
this.logger = options.logger ? options.logger : console.log;
this.path = 'node_modules' + path.sep + options.m... | [
"function",
"NpmSubmodulePlugin",
"(",
"options",
")",
"{",
"// initialize instance variables",
"this",
".",
"commands",
"=",
"options",
".",
"commands",
"?",
"options",
".",
"commands",
":",
"[",
"]",
";",
"this",
".",
"autoInstall",
"=",
"options",
".",
"aut... | Logger to caputer the command output.
@callback Logger
@param {string} message - message to log.
The mandatory named JavaScript function which represents a Webpack plugin.
@example
new NpmSubmodulePlugin({
module: 'isObject',
autoInstall: false,
commands: [
'install',
'install --save react'
],
logger: console.log
});... | [
"Logger",
"to",
"caputer",
"the",
"command",
"output",
"."
] | 1eee09d129b480e3aa1fcf5f786cee9a13464181 | https://github.com/mikcsabee/npm-submodule-webpack-plugin/blob/1eee09d129b480e3aa1fcf5f786cee9a13464181/src/plugin.js#L56-L66 | train |
simonguo/hbook | lib/utils/git.js | parseGitUrl | function parseGitUrl(giturl) {
var ref, uri, fileParts, filepath;
if (!checkGitUrl(giturl)) return null;
giturl = giturl.slice(GIT_PREFIX.length);
uri = new URI(giturl);
ref = uri.fragment() || 'master';
uri.fragment(null);
// Extract file inside the repo (after the .git)
fileParts =u... | javascript | function parseGitUrl(giturl) {
var ref, uri, fileParts, filepath;
if (!checkGitUrl(giturl)) return null;
giturl = giturl.slice(GIT_PREFIX.length);
uri = new URI(giturl);
ref = uri.fragment() || 'master';
uri.fragment(null);
// Extract file inside the repo (after the .git)
fileParts =u... | [
"function",
"parseGitUrl",
"(",
"giturl",
")",
"{",
"var",
"ref",
",",
"uri",
",",
"fileParts",
",",
"filepath",
";",
"if",
"(",
"!",
"checkGitUrl",
"(",
"giturl",
")",
")",
"return",
"null",
";",
"giturl",
"=",
"giturl",
".",
"slice",
"(",
"GIT_PREFIX... | Parse and extract infos | [
"Parse",
"and",
"extract",
"infos"
] | 5ea071130cc418fccd97a3e7e9a285c1d756b80b | https://github.com/simonguo/hbook/blob/5ea071130cc418fccd97a3e7e9a285c1d756b80b/lib/utils/git.js#L26-L49 | train |
simonguo/hbook | lib/utils/git.js | cloneGitRepo | function cloneGitRepo(host, ref) {
var isBranch = false;
ref = ref || 'master';
if (!validateSha(ref)) isBranch = true;
return Q()
// Create temporary folder to store git repos
.then(function() {
if (GIT_TMP) return;
return fs.tmp.dir()
.then(function(_tmp) {
... | javascript | function cloneGitRepo(host, ref) {
var isBranch = false;
ref = ref || 'master';
if (!validateSha(ref)) isBranch = true;
return Q()
// Create temporary folder to store git repos
.then(function() {
if (GIT_TMP) return;
return fs.tmp.dir()
.then(function(_tmp) {
... | [
"function",
"cloneGitRepo",
"(",
"host",
",",
"ref",
")",
"{",
"var",
"isBranch",
"=",
"false",
";",
"ref",
"=",
"ref",
"||",
"'master'",
";",
"if",
"(",
"!",
"validateSha",
"(",
"ref",
")",
")",
"isBranch",
"=",
"true",
";",
"return",
"Q",
"(",
")... | Clone a git repo from a specific ref | [
"Clone",
"a",
"git",
"repo",
"from",
"a",
"specific",
"ref"
] | 5ea071130cc418fccd97a3e7e9a285c1d756b80b | https://github.com/simonguo/hbook/blob/5ea071130cc418fccd97a3e7e9a285c1d756b80b/lib/utils/git.js#L52-L89 | train |
simonguo/hbook | lib/utils/git.js | resolveFileFromGit | function resolveFileFromGit(giturl) {
if (_.isString(giturl)) giturl = parseGitUrl(giturl);
if (!giturl) return Q(null);
// Clone or get from cache
return cloneGitRepo(giturl.host, giturl.ref)
.then(function(repo) {
// Resolve relative path
return path.resolve(repo, giturl.filepath... | javascript | function resolveFileFromGit(giturl) {
if (_.isString(giturl)) giturl = parseGitUrl(giturl);
if (!giturl) return Q(null);
// Clone or get from cache
return cloneGitRepo(giturl.host, giturl.ref)
.then(function(repo) {
// Resolve relative path
return path.resolve(repo, giturl.filepath... | [
"function",
"resolveFileFromGit",
"(",
"giturl",
")",
"{",
"if",
"(",
"_",
".",
"isString",
"(",
"giturl",
")",
")",
"giturl",
"=",
"parseGitUrl",
"(",
"giturl",
")",
";",
"if",
"(",
"!",
"giturl",
")",
"return",
"Q",
"(",
"null",
")",
";",
"// Clone... | Get file from a git repo | [
"Get",
"file",
"from",
"a",
"git",
"repo"
] | 5ea071130cc418fccd97a3e7e9a285c1d756b80b | https://github.com/simonguo/hbook/blob/5ea071130cc418fccd97a3e7e9a285c1d756b80b/lib/utils/git.js#L92-L103 | train |
simonguo/hbook | lib/utils/git.js | resolveGitRoot | function resolveGitRoot(filepath) {
var relativeToGit, repoId;
// No git repo cloned, or file is not in a git repository
if (!GIT_TMP || !pathUtil.isInRoot(GIT_TMP, filepath)) return null;
// Extract first directory (is the repo id)
relativeToGit = path.relative(GIT_TMP, filepath);
repoId = _.... | javascript | function resolveGitRoot(filepath) {
var relativeToGit, repoId;
// No git repo cloned, or file is not in a git repository
if (!GIT_TMP || !pathUtil.isInRoot(GIT_TMP, filepath)) return null;
// Extract first directory (is the repo id)
relativeToGit = path.relative(GIT_TMP, filepath);
repoId = _.... | [
"function",
"resolveGitRoot",
"(",
"filepath",
")",
"{",
"var",
"relativeToGit",
",",
"repoId",
";",
"// No git repo cloned, or file is not in a git repository",
"if",
"(",
"!",
"GIT_TMP",
"||",
"!",
"pathUtil",
".",
"isInRoot",
"(",
"GIT_TMP",
",",
"filepath",
")",... | Return root of git repo from a filepath | [
"Return",
"root",
"of",
"git",
"repo",
"from",
"a",
"filepath"
] | 5ea071130cc418fccd97a3e7e9a285c1d756b80b | https://github.com/simonguo/hbook/blob/5ea071130cc418fccd97a3e7e9a285c1d756b80b/lib/utils/git.js#L106-L119 | train |
KirinJS/Kirin | javascript/lib/extensions/Networking.js | function(config) {
var hasParams = (typeof config.params === 'object');
var hasFiles = _.isArray(config.attachments);
if('GET' === config.method) {
if(hasParams) {
config.url = addParams(config.url, config.params);
}
if (hasFiles) {
throw new Error("Canno... | javascript | function(config) {
var hasParams = (typeof config.params === 'object');
var hasFiles = _.isArray(config.attachments);
if('GET' === config.method) {
if(hasParams) {
config.url = addParams(config.url, config.params);
}
if (hasFiles) {
throw new Error("Canno... | [
"function",
"(",
"config",
")",
"{",
"var",
"hasParams",
"=",
"(",
"typeof",
"config",
".",
"params",
"===",
"'object'",
")",
";",
"var",
"hasFiles",
"=",
"_",
".",
"isArray",
"(",
"config",
".",
"attachments",
")",
";",
"if",
"(",
"'GET'",
"===",
"c... | If the method is GET, the config.url string will have any parameters in the config.params added to it appropriately.
If the method is POST and there is no config.postData, the config.params object will be changed to a string. The form of this string will be "param1key=param1value¶m2key=param2value". Each key and v... | [
"If",
"the",
"method",
"is",
"GET",
"the",
"config",
".",
"url",
"string",
"will",
"have",
"any",
"parameters",
"in",
"the",
"config",
".",
"params",
"added",
"to",
"it",
"appropriately",
"."
] | d40e86ca89c40b5d3e0c129c24ff3b77ed3d28e1 | https://github.com/KirinJS/Kirin/blob/d40e86ca89c40b5d3e0c129c24ff3b77ed3d28e1/javascript/lib/extensions/Networking.js#L124-L170 | train | |
simonguo/hbook | lib/utils/progress.js | calculProgress | function calculProgress(navigation, current) {
var n = _.size(navigation);
var percent = 0, prevPercent = 0, currentChapter = null;
var done = true;
var chapters = _.chain(navigation)
// Transform as array
.map(function(nav, path) {
nav.path = path;
return nav;
})
// S... | javascript | function calculProgress(navigation, current) {
var n = _.size(navigation);
var percent = 0, prevPercent = 0, currentChapter = null;
var done = true;
var chapters = _.chain(navigation)
// Transform as array
.map(function(nav, path) {
nav.path = path;
return nav;
})
// S... | [
"function",
"calculProgress",
"(",
"navigation",
",",
"current",
")",
"{",
"var",
"n",
"=",
"_",
".",
"size",
"(",
"navigation",
")",
";",
"var",
"percent",
"=",
"0",
",",
"prevPercent",
"=",
"0",
",",
"currentChapter",
"=",
"null",
";",
"var",
"done",... | Returns from a navigation and a current file, a snapshot of current detailed state | [
"Returns",
"from",
"a",
"navigation",
"and",
"a",
"current",
"file",
"a",
"snapshot",
"of",
"current",
"detailed",
"state"
] | 5ea071130cc418fccd97a3e7e9a285c1d756b80b | https://github.com/simonguo/hbook/blob/5ea071130cc418fccd97a3e7e9a285c1d756b80b/lib/utils/progress.js#L4-L53 | train |
anvaka/amator | index.js | animate | function animate(source, target, options) {
var start = Object.create(null)
var diff = Object.create(null)
options = options || {}
// We let clients specify their own easing function
var easing = (typeof options.easing === 'function') ? options.easing : animations[options.easing]
// if nothing is specified... | javascript | function animate(source, target, options) {
var start = Object.create(null)
var diff = Object.create(null)
options = options || {}
// We let clients specify their own easing function
var easing = (typeof options.easing === 'function') ? options.easing : animations[options.easing]
// if nothing is specified... | [
"function",
"animate",
"(",
"source",
",",
"target",
",",
"options",
")",
"{",
"var",
"start",
"=",
"Object",
".",
"create",
"(",
"null",
")",
"var",
"diff",
"=",
"Object",
".",
"create",
"(",
"null",
")",
"options",
"=",
"options",
"||",
"{",
"}",
... | Creates a new instance of animator. Animator uses
interpolation function to change `source` object into
`target` object.
Note: this method mutates `source` object properties.
@param {Object} source
@param {Object} target
@param {Object} options - animation configuration
@param {Function} options.step - called on each... | [
"Creates",
"a",
"new",
"instance",
"of",
"animator",
".",
"Animator",
"uses",
"interpolation",
"function",
"to",
"change",
"source",
"object",
"into",
"target",
"object",
"."
] | 9147cdb2e9dbfcb35c564184150c2dfbd36fe4ee | https://github.com/anvaka/amator/blob/9147cdb2e9dbfcb35c564184150c2dfbd36fe4ee/index.js#L34-L94 | train |
bhoriuchi/vsphere-connect | archive/v1/client/method.js | getFields | function getFields(def, obj) {
var a = {};
// if not an object, return the value
if (!_.isObject(obj)) {
return obj;
}
// check for type override
var defType = _.get(obj, 'attributes.xsi:type') || _.get(obj, 'attributes.type');
defType = defType ? defType.replace(/^vim25\:/i, '') : null;
/... | javascript | function getFields(def, obj) {
var a = {};
// if not an object, return the value
if (!_.isObject(obj)) {
return obj;
}
// check for type override
var defType = _.get(obj, 'attributes.xsi:type') || _.get(obj, 'attributes.type');
defType = defType ? defType.replace(/^vim25\:/i, '') : null;
/... | [
"function",
"getFields",
"(",
"def",
",",
"obj",
")",
"{",
"var",
"a",
"=",
"{",
"}",
";",
"// if not an object, return the value",
"if",
"(",
"!",
"_",
".",
"isObject",
"(",
"obj",
")",
")",
"{",
"return",
"obj",
";",
"}",
"// check for type override",
... | recursive function to get the fields in the correct order based on the wsdl definitions | [
"recursive",
"function",
"to",
"get",
"the",
"fields",
"in",
"the",
"correct",
"order",
"based",
"on",
"the",
"wsdl",
"definitions"
] | 2203b678847a57e3cb982f1a23277d44444f6de4 | https://github.com/bhoriuchi/vsphere-connect/blob/2203b678847a57e3cb982f1a23277d44444f6de4/archive/v1/client/method.js#L19-L60 | train |
bhoriuchi/vsphere-connect | archive/v1/client/method.js | sortArgs | function sortArgs(method, args) {
// get the method definition
var def = _.get(_client.types, method.replace(/\_Task$/i, '') + 'RequestType');
// if found create the definition by calling its function
if (def) {
return getFields(def(), args);
}
return args;
} | javascript | function sortArgs(method, args) {
// get the method definition
var def = _.get(_client.types, method.replace(/\_Task$/i, '') + 'RequestType');
// if found create the definition by calling its function
if (def) {
return getFields(def(), args);
}
return args;
} | [
"function",
"sortArgs",
"(",
"method",
",",
"args",
")",
"{",
"// get the method definition",
"var",
"def",
"=",
"_",
".",
"get",
"(",
"_client",
".",
"types",
",",
"method",
".",
"replace",
"(",
"/",
"\\_Task$",
"/",
"i",
",",
"''",
")",
"+",
"'Reques... | function to correctly order the arguments this is done because arguments in an incorrect order will cause the soap method to fail | [
"function",
"to",
"correctly",
"order",
"the",
"arguments",
"this",
"is",
"done",
"because",
"arguments",
"in",
"an",
"incorrect",
"order",
"will",
"cause",
"the",
"soap",
"method",
"to",
"fail"
] | 2203b678847a57e3cb982f1a23277d44444f6de4 | https://github.com/bhoriuchi/vsphere-connect/blob/2203b678847a57e3cb982f1a23277d44444f6de4/archive/v1/client/method.js#L66-L76 | train |
bhoriuchi/vsphere-connect | archive/v1/client/method.js | function(resolve, reject) {
var fn = _client.client.VimService.VimPort[name];
fn(args, function(err, result, raw, soapHeader) {
if (err) {
// emit an error and handle the error
_client.emit('method.error', err);
_client.errorHandler(err, name, args, resolve, reject);
}
else {
... | javascript | function(resolve, reject) {
var fn = _client.client.VimService.VimPort[name];
fn(args, function(err, result, raw, soapHeader) {
if (err) {
// emit an error and handle the error
_client.emit('method.error', err);
_client.errorHandler(err, name, args, resolve, reject);
}
else {
... | [
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"var",
"fn",
"=",
"_client",
".",
"client",
".",
"VimService",
".",
"VimPort",
"[",
"name",
"]",
";",
"fn",
"(",
"args",
",",
"function",
"(",
"err",
",",
"result",
",",
"raw",
",",
"soapHeader",
... | executes the function | [
"executes",
"the",
"function"
] | 2203b678847a57e3cb982f1a23277d44444f6de4 | https://github.com/bhoriuchi/vsphere-connect/blob/2203b678847a57e3cb982f1a23277d44444f6de4/archive/v1/client/method.js#L86-L103 | train | |
bhoriuchi/vsphere-connect | archive/v1/client/emitUpdates.js | getUpdates | function getUpdates() {
return _client.method('WaitForUpdatesEx', {
_this: _client._updatesCollector,
version: _client._updatesVersion,
options: {
maxWaitSeconds: 0
}
})
.then(function(set) {
if (set) {
// update the version
_client._updatesVersion = set.version;
// get only t... | javascript | function getUpdates() {
return _client.method('WaitForUpdatesEx', {
_this: _client._updatesCollector,
version: _client._updatesVersion,
options: {
maxWaitSeconds: 0
}
})
.then(function(set) {
if (set) {
// update the version
_client._updatesVersion = set.version;
// get only t... | [
"function",
"getUpdates",
"(",
")",
"{",
"return",
"_client",
".",
"method",
"(",
"'WaitForUpdatesEx'",
",",
"{",
"_this",
":",
"_client",
".",
"_updatesCollector",
",",
"version",
":",
"_client",
".",
"_updatesVersion",
",",
"options",
":",
"{",
"maxWaitSecon... | function to get updates | [
"function",
"to",
"get",
"updates"
] | 2203b678847a57e3cb982f1a23277d44444f6de4 | https://github.com/bhoriuchi/vsphere-connect/blob/2203b678847a57e3cb982f1a23277d44444f6de4/archive/v1/client/emitUpdates.js#L28-L77 | train |
serg-io/backbone-dynamodb | backbone-dynamodb.js | wrapComplete | function wrapComplete(instance, options) {
var complete = options.complete;
options.complete = function(response) {
if ( _.isFunction( complete ) ) {
complete.call( this, instance, response, options );
}
};
} | javascript | function wrapComplete(instance, options) {
var complete = options.complete;
options.complete = function(response) {
if ( _.isFunction( complete ) ) {
complete.call( this, instance, response, options );
}
};
} | [
"function",
"wrapComplete",
"(",
"instance",
",",
"options",
")",
"{",
"var",
"complete",
"=",
"options",
".",
"complete",
";",
"options",
".",
"complete",
"=",
"function",
"(",
"response",
")",
"{",
"if",
"(",
"_",
".",
"isFunction",
"(",
"complete",
")... | Wraps the complete callback function inside another function to ensure it is executed with the right arguments.
@param {Backbone.DynamoDB.Model} instance
@param {Object} options | [
"Wraps",
"the",
"complete",
"callback",
"function",
"inside",
"another",
"function",
"to",
"ensure",
"it",
"is",
"executed",
"with",
"the",
"right",
"arguments",
"."
] | a501865f8513d27f6577289d7cf4a20324075146 | https://github.com/serg-io/backbone-dynamodb/blob/a501865f8513d27f6577289d7cf4a20324075146/backbone-dynamodb.js#L48-L56 | train |
serg-io/backbone-dynamodb | backbone-dynamodb.js | putItem | function putItem(model, options) {
options || ( options = {} );
if ( options.serializeDates !== false ) {
// If serializeDates is NOT `false`, use `true` by default.
options.serializeDates = true;
}
var newKey, // If the model `isNew`, a new key is generated.
request,
hashName, // Name of the hash attribut... | javascript | function putItem(model, options) {
options || ( options = {} );
if ( options.serializeDates !== false ) {
// If serializeDates is NOT `false`, use `true` by default.
options.serializeDates = true;
}
var newKey, // If the model `isNew`, a new key is generated.
request,
hashName, // Name of the hash attribut... | [
"function",
"putItem",
"(",
"model",
",",
"options",
")",
"{",
"options",
"||",
"(",
"options",
"=",
"{",
"}",
")",
";",
"if",
"(",
"options",
".",
"serializeDates",
"!==",
"false",
")",
"{",
"// If serializeDates is NOT `false`, use `true` by default.",
"option... | Sends a request to store a Backbone.DynamoDB.Model in a DynamoDB table using a PutItem request.
@param {Backbone.DynamoDB.Model} model The model to store in DynamoDB.
@param {Object} options The options object. | [
"Sends",
"a",
"request",
"to",
"store",
"a",
"Backbone",
".",
"DynamoDB",
".",
"Model",
"in",
"a",
"DynamoDB",
"table",
"using",
"a",
"PutItem",
"request",
"."
] | a501865f8513d27f6577289d7cf4a20324075146 | https://github.com/serg-io/backbone-dynamodb/blob/a501865f8513d27f6577289d7cf4a20324075146/backbone-dynamodb.js#L64-L169 | train |
serg-io/backbone-dynamodb | backbone-dynamodb.js | deleteItem | function deleteItem(model, options) {
var request,
deferred = new _.Deferred(),
params = {
Key: key.call( model ),
TableName: model._tableName()
};
options || ( options = {} );
wrapComplete( model, options );
_.extend( params, options.dynamodb );
if ( options.serializeDates !== false ) {
// If the ... | javascript | function deleteItem(model, options) {
var request,
deferred = new _.Deferred(),
params = {
Key: key.call( model ),
TableName: model._tableName()
};
options || ( options = {} );
wrapComplete( model, options );
_.extend( params, options.dynamodb );
if ( options.serializeDates !== false ) {
// If the ... | [
"function",
"deleteItem",
"(",
"model",
",",
"options",
")",
"{",
"var",
"request",
",",
"deferred",
"=",
"new",
"_",
".",
"Deferred",
"(",
")",
",",
"params",
"=",
"{",
"Key",
":",
"key",
".",
"call",
"(",
"model",
")",
",",
"TableName",
":",
"mod... | Deletes a Backbone.DynamoDB.Model from a DynamoDB table using a DeleteItem request.
@param {Backbone.DynamoDB.Model} model The model to delete from DynamoDB.
@param {Object} options The options object. | [
"Deletes",
"a",
"Backbone",
".",
"DynamoDB",
".",
"Model",
"from",
"a",
"DynamoDB",
"table",
"using",
"a",
"DeleteItem",
"request",
"."
] | a501865f8513d27f6577289d7cf4a20324075146 | https://github.com/serg-io/backbone-dynamodb/blob/a501865f8513d27f6577289d7cf4a20324075146/backbone-dynamodb.js#L177-L210 | train |
serg-io/backbone-dynamodb | backbone-dynamodb.js | fetchCollection | function fetchCollection(collection, options) {
options || ( options = {} );
var request,
deferred = new _.Deferred(),
// Determine the type of request: Query or Scan. Default is Scan.
fetchType = options.query ? 'query' : 'scan',
params = { TableName: collection._tableName() };
wrapComplete( collection, o... | javascript | function fetchCollection(collection, options) {
options || ( options = {} );
var request,
deferred = new _.Deferred(),
// Determine the type of request: Query or Scan. Default is Scan.
fetchType = options.query ? 'query' : 'scan',
params = { TableName: collection._tableName() };
wrapComplete( collection, o... | [
"function",
"fetchCollection",
"(",
"collection",
",",
"options",
")",
"{",
"options",
"||",
"(",
"options",
"=",
"{",
"}",
")",
";",
"var",
"request",
",",
"deferred",
"=",
"new",
"_",
".",
"Deferred",
"(",
")",
",",
"// Determine the type of request: Query... | Retrieves a collection of Backbone.DynamoDB.Models from a DynamoDB table using a Query or Scan request.
@param {Backbone.DynamoDB.Collection} collection The collection instance.
@param {Object} options The options object. | [
"Retrieves",
"a",
"collection",
"of",
"Backbone",
".",
"DynamoDB",
".",
"Models",
"from",
"a",
"DynamoDB",
"table",
"using",
"a",
"Query",
"or",
"Scan",
"request",
"."
] | a501865f8513d27f6577289d7cf4a20324075146 | https://github.com/serg-io/backbone-dynamodb/blob/a501865f8513d27f6577289d7cf4a20324075146/backbone-dynamodb.js#L271-L311 | train |
serg-io/backbone-dynamodb | backbone-dynamodb.js | serializeAllDates | function serializeAllDates(model, json) {
_.each(json, function (value, name) {
if ( _.isDate( value ) ) {
json[ name ] = model.serializeDate( name, value );
} else if ( !isScalar( value ) && !isBackboneInstance( value ) && isRecursive( value ) ) {
serializeAllDates( model, value );
}
});
return json;
} | javascript | function serializeAllDates(model, json) {
_.each(json, function (value, name) {
if ( _.isDate( value ) ) {
json[ name ] = model.serializeDate( name, value );
} else if ( !isScalar( value ) && !isBackboneInstance( value ) && isRecursive( value ) ) {
serializeAllDates( model, value );
}
});
return json;
} | [
"function",
"serializeAllDates",
"(",
"model",
",",
"json",
")",
"{",
"_",
".",
"each",
"(",
"json",
",",
"function",
"(",
"value",
",",
"name",
")",
"{",
"if",
"(",
"_",
".",
"isDate",
"(",
"value",
")",
")",
"{",
"json",
"[",
"name",
"]",
"=",
... | Recursively serializes all `Date` values in an object.
@param {Backbone.DynamoDB.Model} model
@param {Object} json | [
"Recursively",
"serializes",
"all",
"Date",
"values",
"in",
"an",
"object",
"."
] | a501865f8513d27f6577289d7cf4a20324075146 | https://github.com/serg-io/backbone-dynamodb/blob/a501865f8513d27f6577289d7cf4a20324075146/backbone-dynamodb.js#L365-L375 | train |
serg-io/backbone-dynamodb | backbone-dynamodb.js | deserializeAllDates | function deserializeAllDates(model, json) {
_.each(json, function (value, name) {
if ( !_.isDate( value ) && !isBackboneInstance( value ) ) {
if ( _.isString( value ) && model.isSerializedDate( name, value ) ) {
json[ name ] = model.deserializeDate( name, value );
} else if ( !isScalar( value ) && isRecurs... | javascript | function deserializeAllDates(model, json) {
_.each(json, function (value, name) {
if ( !_.isDate( value ) && !isBackboneInstance( value ) ) {
if ( _.isString( value ) && model.isSerializedDate( name, value ) ) {
json[ name ] = model.deserializeDate( name, value );
} else if ( !isScalar( value ) && isRecurs... | [
"function",
"deserializeAllDates",
"(",
"model",
",",
"json",
")",
"{",
"_",
".",
"each",
"(",
"json",
",",
"function",
"(",
"value",
",",
"name",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isDate",
"(",
"value",
")",
"&&",
"!",
"isBackboneInstance",
"(",
... | Recursively deserializes all date values in an object.
@param {Backbone.DynamoDB.Model} model
@param {Object} json | [
"Recursively",
"deserializes",
"all",
"date",
"values",
"in",
"an",
"object",
"."
] | a501865f8513d27f6577289d7cf4a20324075146 | https://github.com/serg-io/backbone-dynamodb/blob/a501865f8513d27f6577289d7cf4a20324075146/backbone-dynamodb.js#L383-L395 | train |
serg-io/backbone-dynamodb | backbone-dynamodb.js | _tableName | function _tableName() {
if ( this.tableName ) {
return _.result( this, 'tableName' );
}
var urlAttributeName = this instanceof Backbone.DynamoDB.Model ? 'urlRoot' : 'url',
table = _.result( this, urlAttributeName ).replace( /^\//, '' );
return table.charAt( 0 ).toUpperCase() + table.substr( 1 );
} | javascript | function _tableName() {
if ( this.tableName ) {
return _.result( this, 'tableName' );
}
var urlAttributeName = this instanceof Backbone.DynamoDB.Model ? 'urlRoot' : 'url',
table = _.result( this, urlAttributeName ).replace( /^\//, '' );
return table.charAt( 0 ).toUpperCase() + table.substr( 1 );
} | [
"function",
"_tableName",
"(",
")",
"{",
"if",
"(",
"this",
".",
"tableName",
")",
"{",
"return",
"_",
".",
"result",
"(",
"this",
",",
"'tableName'",
")",
";",
"}",
"var",
"urlAttributeName",
"=",
"this",
"instanceof",
"Backbone",
".",
"DynamoDB",
".",
... | Determines the name of the table for the Model or Collection instance.
It returns the instance's `tableName` property, if it has one. Otherwise,
it determines the name using the `urlRoot` property, if it's a Model, or the
`url` property if it's a Collection. | [
"Determines",
"the",
"name",
"of",
"the",
"table",
"for",
"the",
"Model",
"or",
"Collection",
"instance",
".",
"It",
"returns",
"the",
"instance",
"s",
"tableName",
"property",
"if",
"it",
"has",
"one",
".",
"Otherwise",
"it",
"determines",
"the",
"name",
... | a501865f8513d27f6577289d7cf4a20324075146 | https://github.com/serg-io/backbone-dynamodb/blob/a501865f8513d27f6577289d7cf4a20324075146/backbone-dynamodb.js#L403-L412 | train |
serg-io/backbone-dynamodb | backbone-dynamodb.js | function() {
var hashKey = _.result( this, 'hashAttribute' ) || _.result( this, 'idAttribute' ),
rangeKey = _.result( this, 'rangeAttribute' ),
hashValue = this.get( hashKey ),
rangeValue = rangeKey ? this.get( rangeKey ) : null;
return hashValue == null || ( rangeKey && rangeValue == null );
} | javascript | function() {
var hashKey = _.result( this, 'hashAttribute' ) || _.result( this, 'idAttribute' ),
rangeKey = _.result( this, 'rangeAttribute' ),
hashValue = this.get( hashKey ),
rangeValue = rangeKey ? this.get( rangeKey ) : null;
return hashValue == null || ( rangeKey && rangeValue == null );
} | [
"function",
"(",
")",
"{",
"var",
"hashKey",
"=",
"_",
".",
"result",
"(",
"this",
",",
"'hashAttribute'",
")",
"||",
"_",
".",
"result",
"(",
"this",
",",
"'idAttribute'",
")",
",",
"rangeKey",
"=",
"_",
".",
"result",
"(",
"this",
",",
"'rangeAttri... | Determines if the model is new. | [
"Determines",
"if",
"the",
"model",
"is",
"new",
"."
] | a501865f8513d27f6577289d7cf4a20324075146 | https://github.com/serg-io/backbone-dynamodb/blob/a501865f8513d27f6577289d7cf4a20324075146/backbone-dynamodb.js#L491-L498 | train | |
serg-io/backbone-dynamodb | backbone-dynamodb.js | function (dynamoDbParams, options) {
var _options = { query: dynamoDbParams };
_.extend( _options, options );
return this.fetch( _options );
} | javascript | function (dynamoDbParams, options) {
var _options = { query: dynamoDbParams };
_.extend( _options, options );
return this.fetch( _options );
} | [
"function",
"(",
"dynamoDbParams",
",",
"options",
")",
"{",
"var",
"_options",
"=",
"{",
"query",
":",
"dynamoDbParams",
"}",
";",
"_",
".",
"extend",
"(",
"_options",
",",
"options",
")",
";",
"return",
"this",
".",
"fetch",
"(",
"_options",
")",
";"... | Sends a "Query" request to DynamoDB to "fetch" a collection.
@param {Object} dynamoDbParams DynamoDB [query](http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB.html#query-property) parameters.
@param {Object} options Additional `fetch` options. | [
"Sends",
"a",
"Query",
"request",
"to",
"DynamoDB",
"to",
"fetch",
"a",
"collection",
"."
] | a501865f8513d27f6577289d7cf4a20324075146 | https://github.com/serg-io/backbone-dynamodb/blob/a501865f8513d27f6577289d7cf4a20324075146/backbone-dynamodb.js#L642-L646 | train | |
serg-io/backbone-dynamodb | backbone-dynamodb.js | function (dynamoDbParams, options) {
var _options = { scan: dynamoDbParams };
_.extend( _options, options );
return this.fetch( _options );
} | javascript | function (dynamoDbParams, options) {
var _options = { scan: dynamoDbParams };
_.extend( _options, options );
return this.fetch( _options );
} | [
"function",
"(",
"dynamoDbParams",
",",
"options",
")",
"{",
"var",
"_options",
"=",
"{",
"scan",
":",
"dynamoDbParams",
"}",
";",
"_",
".",
"extend",
"(",
"_options",
",",
"options",
")",
";",
"return",
"this",
".",
"fetch",
"(",
"_options",
")",
";",... | Sends a "Scan" request to DynamoDB to "fetch" a collection.
@param {Object} dynamoDbParams DynamoDB [scan](http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB.html#scan-property) parameters.
@param {Object} options Additional `fetch` options. | [
"Sends",
"a",
"Scan",
"request",
"to",
"DynamoDB",
"to",
"fetch",
"a",
"collection",
"."
] | a501865f8513d27f6577289d7cf4a20324075146 | https://github.com/serg-io/backbone-dynamodb/blob/a501865f8513d27f6577289d7cf4a20324075146/backbone-dynamodb.js#L653-L657 | train | |
KirinJS/Kirin | javascript/lib/core/kirin-webview.js | function (jsName, methodName) {
return function () {
var args = slice.call(arguments, 0);
var i = 0, max, arg, util, id, exportable;
for (max=args.length; i<max; i++) {
arg = args[i];
if (arg.kirin_bridgeUtils) {
util = arg.kirin_bridgeUtils;
... | javascript | function (jsName, methodName) {
return function () {
var args = slice.call(arguments, 0);
var i = 0, max, arg, util, id, exportable;
for (max=args.length; i<max; i++) {
arg = args[i];
if (arg.kirin_bridgeUtils) {
util = arg.kirin_bridgeUtils;
... | [
"function",
"(",
"jsName",
",",
"methodName",
")",
"{",
"return",
"function",
"(",
")",
"{",
"var",
"args",
"=",
"slice",
".",
"call",
"(",
"arguments",
",",
"0",
")",
";",
"var",
"i",
"=",
"0",
",",
"max",
",",
"arg",
",",
"util",
",",
"id",
"... | This is the function call that every call out to native goes through. | [
"This",
"is",
"the",
"function",
"call",
"that",
"every",
"call",
"out",
"to",
"native",
"goes",
"through",
"."
] | d40e86ca89c40b5d3e0c129c24ff3b77ed3d28e1 | https://github.com/KirinJS/Kirin/blob/d40e86ca89c40b5d3e0c129c24ff3b77ed3d28e1/javascript/lib/core/kirin-webview.js#L84-L113 | train | |
KirinJS/Kirin | javascript/lib/core/kirin-webview.js | handleError | function handleError(during, e) {
/*
* {
"message": "Can't find variable: cardObject",
"line": 505,
"sourceId": 250182872,
"sourceURL": "file:///Users/james/Library/Application%20Support/iPhone%20Simulator/4.3.2/Applications/ADE774FF-B033-46A2-9CBA-DD362196E1F... | javascript | function handleError(during, e) {
/*
* {
"message": "Can't find variable: cardObject",
"line": 505,
"sourceId": 250182872,
"sourceURL": "file:///Users/james/Library/Application%20Support/iPhone%20Simulator/4.3.2/Applications/ADE774FF-B033-46A2-9CBA-DD362196E1F... | [
"function",
"handleError",
"(",
"during",
",",
"e",
")",
"{",
"/*\n * {\n \"message\": \"Can't find variable: cardObject\",\n \"line\": 505,\n \"sourceId\": 250182872,\n \"sourceURL\": \"file:///Users/james/Library/Application%20Support/iPhone%20Sim... | This is a generic error handler.
It does its best to report a stack trace, or an error or *something*.
Unfortunately, some devices are better suported than others.
e.g. Android >2.0, iOS 4.3 and iOS 6.0 are pretty good at providing errors (e.g. file location, stack trace etc)
iOS5 was shockingly bad.
@param during - ... | [
"This",
"is",
"a",
"generic",
"error",
"handler",
"."
] | d40e86ca89c40b5d3e0c129c24ff3b77ed3d28e1 | https://github.com/KirinJS/Kirin/blob/d40e86ca89c40b5d3e0c129c24ff3b77ed3d28e1/javascript/lib/core/kirin-webview.js#L140-L170 | train |
KirinJS/Kirin | javascript/lib/core/kirin-webview.js | resolveModule | function resolveModule(moduleName) {
if (loadedObjects[moduleName]) {
return loadedObjects[moduleName];
}
var aModule, anObject, MyModule;
if (gwtClasses) {
aModule = gwtClasses[moduleName];
}
if (!aModule) {
try {
aModule = myRequire(moduleName);
} ca... | javascript | function resolveModule(moduleName) {
if (loadedObjects[moduleName]) {
return loadedObjects[moduleName];
}
var aModule, anObject, MyModule;
if (gwtClasses) {
aModule = gwtClasses[moduleName];
}
if (!aModule) {
try {
aModule = myRequire(moduleName);
} ca... | [
"function",
"resolveModule",
"(",
"moduleName",
")",
"{",
"if",
"(",
"loadedObjects",
"[",
"moduleName",
"]",
")",
"{",
"return",
"loadedObjects",
"[",
"moduleName",
"]",
";",
"}",
"var",
"aModule",
",",
"anObject",
",",
"MyModule",
";",
"if",
"(",
"gwtCla... | Finds the named module.
It tries quite hard to do this, looking at where gwtClasses may be stashed, and the browserify.require mechanism.
If the resulting object is a function, then it is assumed that the function is a constructor, and an object is newed.
Once we have an object to return, we keep it around as a cach... | [
"Finds",
"the",
"named",
"module",
"."
] | d40e86ca89c40b5d3e0c129c24ff3b77ed3d28e1 | https://github.com/KirinJS/Kirin/blob/d40e86ca89c40b5d3e0c129c24ff3b77ed3d28e1/javascript/lib/core/kirin-webview.js#L185-L216 | train |
bhoriuchi/vsphere-connect | archive/v1/specUtil.js | traversalSpec | function traversalSpec(args) {
return {
attributes: {
'xsi:type': 'TraversalSpec'
},
type: args.listSpec.type,
path: args.listSpec.path,
skip: false
};
} | javascript | function traversalSpec(args) {
return {
attributes: {
'xsi:type': 'TraversalSpec'
},
type: args.listSpec.type,
path: args.listSpec.path,
skip: false
};
} | [
"function",
"traversalSpec",
"(",
"args",
")",
"{",
"return",
"{",
"attributes",
":",
"{",
"'xsi:type'",
":",
"'TraversalSpec'",
"}",
",",
"type",
":",
"args",
".",
"listSpec",
".",
"type",
",",
"path",
":",
"args",
".",
"listSpec",
".",
"path",
",",
"... | new traversal spec | [
"new",
"traversal",
"spec"
] | 2203b678847a57e3cb982f1a23277d44444f6de4 | https://github.com/bhoriuchi/vsphere-connect/blob/2203b678847a57e3cb982f1a23277d44444f6de4/archive/v1/specUtil.js#L16-L25 | train |
bhoriuchi/vsphere-connect | archive/v1/specUtil.js | objectSpec | function objectSpec(args) {
var set = [];
if (!args.id) {
// create a base object
var spec = { attributes: { 'xsi:type': 'ObjectSpec' } };
// check for containerview
if (args.listSpec.type === 'ContainerView' && args.containerView) {
spec.obj = args.containerView;
}
else {
... | javascript | function objectSpec(args) {
var set = [];
if (!args.id) {
// create a base object
var spec = { attributes: { 'xsi:type': 'ObjectSpec' } };
// check for containerview
if (args.listSpec.type === 'ContainerView' && args.containerView) {
spec.obj = args.containerView;
}
else {
... | [
"function",
"objectSpec",
"(",
"args",
")",
"{",
"var",
"set",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"args",
".",
"id",
")",
"{",
"// create a base object",
"var",
"spec",
"=",
"{",
"attributes",
":",
"{",
"'xsi:type'",
":",
"'ObjectSpec'",
"}",
"}",
"... | new object spec | [
"new",
"object",
"spec"
] | 2203b678847a57e3cb982f1a23277d44444f6de4 | https://github.com/bhoriuchi/vsphere-connect/blob/2203b678847a57e3cb982f1a23277d44444f6de4/archive/v1/specUtil.js#L35-L76 | train |
bhoriuchi/vsphere-connect | archive/v1/specUtil.js | propertySpec | function propertySpec(args) {
// create a basic specification
var spec = {
attributes: {
'xsi:type': 'PropertySpec'
},
type: args.type
};
// if an array of properties was passed, validate the properties
if (Array.isArray(args.properties) && args.properties.length > 0) {
var validPaths = ... | javascript | function propertySpec(args) {
// create a basic specification
var spec = {
attributes: {
'xsi:type': 'PropertySpec'
},
type: args.type
};
// if an array of properties was passed, validate the properties
if (Array.isArray(args.properties) && args.properties.length > 0) {
var validPaths = ... | [
"function",
"propertySpec",
"(",
"args",
")",
"{",
"// create a basic specification",
"var",
"spec",
"=",
"{",
"attributes",
":",
"{",
"'xsi:type'",
":",
"'PropertySpec'",
"}",
",",
"type",
":",
"args",
".",
"type",
"}",
";",
"// if an array of properties was pass... | new property spec | [
"new",
"property",
"spec"
] | 2203b678847a57e3cb982f1a23277d44444f6de4 | https://github.com/bhoriuchi/vsphere-connect/blob/2203b678847a57e3cb982f1a23277d44444f6de4/archive/v1/specUtil.js#L79-L105 | train |
slorber/backspace-disabler | index.js | isInActiveContentEditable | function isInActiveContentEditable(node) {
while (node) {
if ( node.getAttribute &&
node.getAttribute("contenteditable") &&
node.getAttribute("contenteditable").toUpperCase() === "TRUE" ) {
return true
}
node = node.parentNod... | javascript | function isInActiveContentEditable(node) {
while (node) {
if ( node.getAttribute &&
node.getAttribute("contenteditable") &&
node.getAttribute("contenteditable").toUpperCase() === "TRUE" ) {
return true
}
node = node.parentNod... | [
"function",
"isInActiveContentEditable",
"(",
"node",
")",
"{",
"while",
"(",
"node",
")",
"{",
"if",
"(",
"node",
".",
"getAttribute",
"&&",
"node",
".",
"getAttribute",
"(",
"\"contenteditable\"",
")",
"&&",
"node",
".",
"getAttribute",
"(",
"\"contenteditab... | Returns true if the node is or is inside an active contenteditable | [
"Returns",
"true",
"if",
"the",
"node",
"is",
"or",
"is",
"inside",
"an",
"active",
"contenteditable"
] | d57c4c6642a090aa03459b25db5e9d06c755e292 | https://github.com/slorber/backspace-disabler/blob/d57c4c6642a090aa03459b25db5e9d06c755e292/index.js#L53-L65 | train |
slorber/backspace-disabler | index.js | connectedToTheDom | function connectedToTheDom(node) {
// IE does not have contains method on document element, only body
var container = node.ownerDocument.contains ? node.ownerDocument : node.ownerDocument.body;
return container.contains(node);
} | javascript | function connectedToTheDom(node) {
// IE does not have contains method on document element, only body
var container = node.ownerDocument.contains ? node.ownerDocument : node.ownerDocument.body;
return container.contains(node);
} | [
"function",
"connectedToTheDom",
"(",
"node",
")",
"{",
"// IE does not have contains method on document element, only body ",
"var",
"container",
"=",
"node",
".",
"ownerDocument",
".",
"contains",
"?",
"node",
".",
"ownerDocument",
":",
"node",
".",
"ownerDocument",
... | returns true if the element is contained within a document | [
"returns",
"true",
"if",
"the",
"element",
"is",
"contained",
"within",
"a",
"document"
] | d57c4c6642a090aa03459b25db5e9d06c755e292 | https://github.com/slorber/backspace-disabler/blob/d57c4c6642a090aa03459b25db5e9d06c755e292/index.js#L68-L72 | train |
andrewimm/js-struct | lib/sign.js | sign | function sign(value, pow) {
const msb = 1 << pow;
if ((value & msb) === 0) {
return value;
}
let neg = -1 * (value & msb);
neg += (value & (msb - 1));
return neg;
} | javascript | function sign(value, pow) {
const msb = 1 << pow;
if ((value & msb) === 0) {
return value;
}
let neg = -1 * (value & msb);
neg += (value & (msb - 1));
return neg;
} | [
"function",
"sign",
"(",
"value",
",",
"pow",
")",
"{",
"const",
"msb",
"=",
"1",
"<<",
"pow",
";",
"if",
"(",
"(",
"value",
"&",
"msb",
")",
"===",
"0",
")",
"{",
"return",
"value",
";",
"}",
"let",
"neg",
"=",
"-",
"1",
"*",
"(",
"value",
... | Convert a two's-complement negative to its JS numeric value | [
"Convert",
"a",
"two",
"s",
"-",
"complement",
"negative",
"to",
"its",
"JS",
"numeric",
"value"
] | 730cb45660e36910a65dc515a880a26aca18d4b6 | https://github.com/andrewimm/js-struct/blob/730cb45660e36910a65dc515a880a26aca18d4b6/lib/sign.js#L6-L14 | train |
simonguo/hbook | lib/utils/page.js | renderDom | function renderDom($, dom, options) {
if (!dom && $._root && $._root.children) {
dom = $._root.children;
}
options = options|| dom.options || $._options;
return domSerializer(dom, options);
} | javascript | function renderDom($, dom, options) {
if (!dom && $._root && $._root.children) {
dom = $._root.children;
}
options = options|| dom.options || $._options;
return domSerializer(dom, options);
} | [
"function",
"renderDom",
"(",
"$",
",",
"dom",
",",
"options",
")",
"{",
"if",
"(",
"!",
"dom",
"&&",
"$",
".",
"_root",
"&&",
"$",
".",
"_root",
".",
"children",
")",
"{",
"dom",
"=",
"$",
".",
"_root",
".",
"children",
";",
"}",
"options",
"=... | Render a cheerio dom as html | [
"Render",
"a",
"cheerio",
"dom",
"as",
"html"
] | 5ea071130cc418fccd97a3e7e9a285c1d756b80b | https://github.com/simonguo/hbook/blob/5ea071130cc418fccd97a3e7e9a285c1d756b80b/lib/utils/page.js#L22-L29 | train |
simonguo/hbook | lib/utils/page.js | convertImages | function convertImages(images, options) {
if (!options.convertImages) return Q();
var downloaded = [];
options.book.log.debug.ln('convert ', images.length, 'images to png');
return batch.execEach(images, {
max: 100,
fn: function(image) {
var imgin = path.resolve(options.boo... | javascript | function convertImages(images, options) {
if (!options.convertImages) return Q();
var downloaded = [];
options.book.log.debug.ln('convert ', images.length, 'images to png');
return batch.execEach(images, {
max: 100,
fn: function(image) {
var imgin = path.resolve(options.boo... | [
"function",
"convertImages",
"(",
"images",
",",
"options",
")",
"{",
"if",
"(",
"!",
"options",
".",
"convertImages",
")",
"return",
"Q",
"(",
")",
";",
"var",
"downloaded",
"=",
"[",
"]",
";",
"options",
".",
"book",
".",
"log",
".",
"debug",
".",
... | Convert svg images to png | [
"Convert",
"svg",
"images",
"to",
"png"
] | 5ea071130cc418fccd97a3e7e9a285c1d756b80b | https://github.com/simonguo/hbook/blob/5ea071130cc418fccd97a3e7e9a285c1d756b80b/lib/utils/page.js#L298-L343 | train |
simonguo/hbook | lib/utils/page.js | normalizePage | function normalizePage(sections, options) {
options = _.defaults(options || {}, {
// Current book
book: null,
// Do we need to convert svg?
convertImages: false,
// Current file path
input: '.',
// Navigation to use to transform path
navigation: {},... | javascript | function normalizePage(sections, options) {
options = _.defaults(options || {}, {
// Current book
book: null,
// Do we need to convert svg?
convertImages: false,
// Current file path
input: '.',
// Navigation to use to transform path
navigation: {},... | [
"function",
"normalizePage",
"(",
"sections",
",",
"options",
")",
"{",
"options",
"=",
"_",
".",
"defaults",
"(",
"options",
"||",
"{",
"}",
",",
"{",
"// Current book",
"book",
":",
"null",
",",
"// Do we need to convert svg?",
"convertImages",
":",
"false",... | Adapt page content to be relative to a base folder | [
"Adapt",
"page",
"content",
"to",
"be",
"relative",
"to",
"a",
"base",
"folder"
] | 5ea071130cc418fccd97a3e7e9a285c1d756b80b | https://github.com/simonguo/hbook/blob/5ea071130cc418fccd97a3e7e9a285c1d756b80b/lib/utils/page.js#L346-L389 | train |
simonguo/hbook | lib/utils/batch.js | execEach | function execEach(items, options) {
if (_.size(items) === 0) return Q();
var concurrents = 0, d = Q.defer(), pending = [];
options = _.defaults(options || {}, {
max: 100,
fn: function() {}
});
function startItem(item, i) {
if (concurrents >= options.max) {
pend... | javascript | function execEach(items, options) {
if (_.size(items) === 0) return Q();
var concurrents = 0, d = Q.defer(), pending = [];
options = _.defaults(options || {}, {
max: 100,
fn: function() {}
});
function startItem(item, i) {
if (concurrents >= options.max) {
pend... | [
"function",
"execEach",
"(",
"items",
",",
"options",
")",
"{",
"if",
"(",
"_",
".",
"size",
"(",
"items",
")",
"===",
"0",
")",
"return",
"Q",
"(",
")",
";",
"var",
"concurrents",
"=",
"0",
",",
"d",
"=",
"Q",
".",
"defer",
"(",
")",
",",
"p... | Execute a method for all element | [
"Execute",
"a",
"method",
"for",
"all",
"element"
] | 5ea071130cc418fccd97a3e7e9a285c1d756b80b | https://github.com/simonguo/hbook/blob/5ea071130cc418fccd97a3e7e9a285c1d756b80b/lib/utils/batch.js#L5-L47 | train |
simonguo/hbook | lib/template.js | function(filepath, source) {
var parser = parsers.get(path.extname(filepath));
var type = parser? parser.name : null;
return that.applyShortcuts(type, source);
} | javascript | function(filepath, source) {
var parser = parsers.get(path.extname(filepath));
var type = parser? parser.name : null;
return that.applyShortcuts(type, source);
} | [
"function",
"(",
"filepath",
",",
"source",
")",
"{",
"var",
"parser",
"=",
"parsers",
".",
"get",
"(",
"path",
".",
"extname",
"(",
"filepath",
")",
")",
";",
"var",
"type",
"=",
"parser",
"?",
"parser",
".",
"name",
":",
"null",
";",
"return",
"t... | Replace shortcuts in imported files | [
"Replace",
"shortcuts",
"in",
"imported",
"files"
] | 5ea071130cc418fccd97a3e7e9a285c1d756b80b | https://github.com/simonguo/hbook/blob/5ea071130cc418fccd97a3e7e9a285c1d756b80b/lib/template.js#L29-L34 | train | |
simonguo/hbook | theme/javascript/toolbar.js | createDropdownMenu | function createDropdownMenu(dropdown) {
var $menu = $('<div>', {
'class': 'dropdown-menu',
'html': '<div class="dropdown-caret"><span class="caret-outer"></span><span class="caret-inner"></span></div>'
});
if (_.isString(dropdown)) {
$menu.append(dropdown);
} else {
var ... | javascript | function createDropdownMenu(dropdown) {
var $menu = $('<div>', {
'class': 'dropdown-menu',
'html': '<div class="dropdown-caret"><span class="caret-outer"></span><span class="caret-inner"></span></div>'
});
if (_.isString(dropdown)) {
$menu.append(dropdown);
} else {
var ... | [
"function",
"createDropdownMenu",
"(",
"dropdown",
")",
"{",
"var",
"$menu",
"=",
"$",
"(",
"'<div>'",
",",
"{",
"'class'",
":",
"'dropdown-menu'",
",",
"'html'",
":",
"'<div class=\"dropdown-caret\"><span class=\"caret-outer\"></span><span class=\"caret-inner\"></span></div>... | Create a dropdown menu | [
"Create",
"a",
"dropdown",
"menu"
] | 5ea071130cc418fccd97a3e7e9a285c1d756b80b | https://github.com/simonguo/hbook/blob/5ea071130cc418fccd97a3e7e9a285c1d756b80b/theme/javascript/toolbar.js#L28-L74 | train |
simonguo/hbook | theme/javascript/toolbar.js | createButton | function createButton(opts) {
opts = _.defaults(opts || {}, {
// Aria label for the button
label: '',
// Icon to show
icon: '',
// Inner text
text: '',
// Right or left position
position: 'left',
// Other class name to add to the button
... | javascript | function createButton(opts) {
opts = _.defaults(opts || {}, {
// Aria label for the button
label: '',
// Icon to show
icon: '',
// Inner text
text: '',
// Right or left position
position: 'left',
// Other class name to add to the button
... | [
"function",
"createButton",
"(",
"opts",
")",
"{",
"opts",
"=",
"_",
".",
"defaults",
"(",
"opts",
"||",
"{",
"}",
",",
"{",
"// Aria label for the button",
"label",
":",
"''",
",",
"// Icon to show",
"icon",
":",
"''",
",",
"// Inner text",
"text",
":",
... | Create a new button in the toolbar | [
"Create",
"a",
"new",
"button",
"in",
"the",
"toolbar"
] | 5ea071130cc418fccd97a3e7e9a285c1d756b80b | https://github.com/simonguo/hbook/blob/5ea071130cc418fccd97a3e7e9a285c1d756b80b/theme/javascript/toolbar.js#L77-L106 | train |
simonguo/hbook | theme/javascript/toolbar.js | updateButton | function updateButton(opts) {
var $result;
var $toolbar = $('.book-header');
var $title = $toolbar.find('h1');
// Build class name
var positionClass = 'pull-'+opts.position;
// Create button
var $btn = $('<a>', {
'class': 'btn',
'text': opts.text? ' ' + opts.text : '',
... | javascript | function updateButton(opts) {
var $result;
var $toolbar = $('.book-header');
var $title = $toolbar.find('h1');
// Build class name
var positionClass = 'pull-'+opts.position;
// Create button
var $btn = $('<a>', {
'class': 'btn',
'text': opts.text? ' ' + opts.text : '',
... | [
"function",
"updateButton",
"(",
"opts",
")",
"{",
"var",
"$result",
";",
"var",
"$toolbar",
"=",
"$",
"(",
"'.book-header'",
")",
";",
"var",
"$title",
"=",
"$toolbar",
".",
"find",
"(",
"'h1'",
")",
";",
"// Build class name",
"var",
"positionClass",
"="... | Update a button | [
"Update",
"a",
"button"
] | 5ea071130cc418fccd97a3e7e9a285c1d756b80b | https://github.com/simonguo/hbook/blob/5ea071130cc418fccd97a3e7e9a285c1d756b80b/theme/javascript/toolbar.js#L109-L166 | train |
mmoulton/capture | phantomjs/capture.js | argsToObject | function argsToObject(args) {
var options = {};
options.address = args.shift();
options.output = args.shift();
// Pair two arguments, while transforming the key to camelCase
for (i = 0; i < args.length; i = i + 2) {
options[toCamelCase(args[i].substr(2))] = args[i + 1];
}
return options;
} | javascript | function argsToObject(args) {
var options = {};
options.address = args.shift();
options.output = args.shift();
// Pair two arguments, while transforming the key to camelCase
for (i = 0; i < args.length; i = i + 2) {
options[toCamelCase(args[i].substr(2))] = args[i + 1];
}
return options;
} | [
"function",
"argsToObject",
"(",
"args",
")",
"{",
"var",
"options",
"=",
"{",
"}",
";",
"options",
".",
"address",
"=",
"args",
".",
"shift",
"(",
")",
";",
"options",
".",
"output",
"=",
"args",
".",
"shift",
"(",
")",
";",
"// Pair two arguments, wh... | Transform an array to an object literal
@param {Array} args Array with seperate arguments
@return {Object} | [
"Transform",
"an",
"array",
"to",
"an",
"object",
"literal"
] | 794a0542603c4ff1f908d5d00c1bd3cda5c490ec | https://github.com/mmoulton/capture/blob/794a0542603c4ff1f908d5d00c1bd3cda5c490ec/phantomjs/capture.js#L116-L127 | train |
bhoriuchi/vsphere-connect | archive/v1/client/findParentType.js | getParent | function getParent(type, id, parentType, root) {
return _client.retrieve({
type: type,
id: id,
properties: ['parent']
})
.then(function(obj) {
if (obj.length > 0) {
obj = _.first(obj);
type = _.get(obj, 'parent.type');
id = _.get(obj, 'parent.id');
// if there is no pa... | javascript | function getParent(type, id, parentType, root) {
return _client.retrieve({
type: type,
id: id,
properties: ['parent']
})
.then(function(obj) {
if (obj.length > 0) {
obj = _.first(obj);
type = _.get(obj, 'parent.type');
id = _.get(obj, 'parent.id');
// if there is no pa... | [
"function",
"getParent",
"(",
"type",
",",
"id",
",",
"parentType",
",",
"root",
")",
"{",
"return",
"_client",
".",
"retrieve",
"(",
"{",
"type",
":",
"type",
",",
"id",
":",
"id",
",",
"properties",
":",
"[",
"'parent'",
"]",
"}",
")",
".",
"then... | recursively looks for a parent type | [
"recursively",
"looks",
"for",
"a",
"parent",
"type"
] | 2203b678847a57e3cb982f1a23277d44444f6de4 | https://github.com/bhoriuchi/vsphere-connect/blob/2203b678847a57e3cb982f1a23277d44444f6de4/archive/v1/client/findParentType.js#L20-L76 | train |
simonguo/hbook | lib/configuration.js | isDefaultPlugin | function isDefaultPlugin(name, version) {
if (!_.contains(DEFAULT_PLUGINS, name)) return false;
try {
var pluginPkg = require('gitbook-plugin-'+name+'/package.json');
return semver.satisfies(pluginPkg.version, version || '*');
} catch(e) {
return false;
}
} | javascript | function isDefaultPlugin(name, version) {
if (!_.contains(DEFAULT_PLUGINS, name)) return false;
try {
var pluginPkg = require('gitbook-plugin-'+name+'/package.json');
return semver.satisfies(pluginPkg.version, version || '*');
} catch(e) {
return false;
}
} | [
"function",
"isDefaultPlugin",
"(",
"name",
",",
"version",
")",
"{",
"if",
"(",
"!",
"_",
".",
"contains",
"(",
"DEFAULT_PLUGINS",
",",
"name",
")",
")",
"return",
"false",
";",
"try",
"{",
"var",
"pluginPkg",
"=",
"require",
"(",
"'gitbook-plugin-'",
"... | Check if a plugin is a default plugin Plugin should be in the list And version from book.json specified for this plugin should be satisfied | [
"Check",
"if",
"a",
"plugin",
"is",
"a",
"default",
"plugin",
"Plugin",
"should",
"be",
"in",
"the",
"list",
"And",
"version",
"from",
"book",
".",
"json",
"specified",
"for",
"this",
"plugin",
"should",
"be",
"satisfied"
] | 5ea071130cc418fccd97a3e7e9a285c1d756b80b | https://github.com/simonguo/hbook/blob/5ea071130cc418fccd97a3e7e9a285c1d756b80b/lib/configuration.js#L18-L27 | train |
simonguo/hbook | lib/configuration.js | normalizePluginsList | function normalizePluginsList(plugins, addDefaults) {
// Normalize list to an array
plugins = _.isString(plugins) ? plugins.split(',') : (plugins || []);
// Remove empty parts
plugins = _.compact(plugins);
// Divide as {name, version} to handle format like 'myplugin@1.0.0'
plugins = _.map(plug... | javascript | function normalizePluginsList(plugins, addDefaults) {
// Normalize list to an array
plugins = _.isString(plugins) ? plugins.split(',') : (plugins || []);
// Remove empty parts
plugins = _.compact(plugins);
// Divide as {name, version} to handle format like 'myplugin@1.0.0'
plugins = _.map(plug... | [
"function",
"normalizePluginsList",
"(",
"plugins",
",",
"addDefaults",
")",
"{",
"// Normalize list to an array",
"plugins",
"=",
"_",
".",
"isString",
"(",
"plugins",
")",
"?",
"plugins",
".",
"split",
"(",
"','",
")",
":",
"(",
"plugins",
"||",
"[",
"]",
... | Normalize a list of plugins to use | [
"Normalize",
"a",
"list",
"of",
"plugins",
"to",
"use"
] | 5ea071130cc418fccd97a3e7e9a285c1d756b80b | https://github.com/simonguo/hbook/blob/5ea071130cc418fccd97a3e7e9a285c1d756b80b/lib/configuration.js#L30-L84 | train |
cnlon/fuck-env | utils.js | getFiles | function getFiles () {
const FUCK_ENV = process.env.FUCK_ENV
|| process.env.npm_package_config_FUCK_ENV
|| FUCK_ENV_DEFAULT
return FUCK_ENV.split(',').map(file => path.resolve(root, file))
} | javascript | function getFiles () {
const FUCK_ENV = process.env.FUCK_ENV
|| process.env.npm_package_config_FUCK_ENV
|| FUCK_ENV_DEFAULT
return FUCK_ENV.split(',').map(file => path.resolve(root, file))
} | [
"function",
"getFiles",
"(",
")",
"{",
"const",
"FUCK_ENV",
"=",
"process",
".",
"env",
".",
"FUCK_ENV",
"||",
"process",
".",
"env",
".",
"npm_package_config_FUCK_ENV",
"||",
"FUCK_ENV_DEFAULT",
"return",
"FUCK_ENV",
".",
"split",
"(",
"','",
")",
".",
"map... | Get files from environment variables | [
"Get",
"files",
"from",
"environment",
"variables"
] | ddbd6d9ff34a35adf26e807e7fd4db99c52acafd | https://github.com/cnlon/fuck-env/blob/ddbd6d9ff34a35adf26e807e7fd4db99c52acafd/utils.js#L18-L23 | train |
bhoriuchi/vsphere-connect | archive/v1/format.js | formatValue | function formatValue(value) {
var out;
var type = util.sType(value);
// if there is a type, check all sub items for types
if (_.has(value, 'attributes.type') && _.has(value, '$value') && _.keys(value).length === 2) {
out = util.moRef(value);
}
else if (type) {
if (util.isArray(value)) {
out ... | javascript | function formatValue(value) {
var out;
var type = util.sType(value);
// if there is a type, check all sub items for types
if (_.has(value, 'attributes.type') && _.has(value, '$value') && _.keys(value).length === 2) {
out = util.moRef(value);
}
else if (type) {
if (util.isArray(value)) {
out ... | [
"function",
"formatValue",
"(",
"value",
")",
"{",
"var",
"out",
";",
"var",
"type",
"=",
"util",
".",
"sType",
"(",
"value",
")",
";",
"// if there is a type, check all sub items for types",
"if",
"(",
"_",
".",
"has",
"(",
"value",
",",
"'attributes.type'",
... | recursive formatting function | [
"recursive",
"formatting",
"function"
] | 2203b678847a57e3cb982f1a23277d44444f6de4 | https://github.com/bhoriuchi/vsphere-connect/blob/2203b678847a57e3cb982f1a23277d44444f6de4/archive/v1/format.js#L45-L119 | train |
bhoriuchi/vsphere-connect | archive/v1/format.js | formatProp | function formatProp(obj) {
var out = {};
var props = _.get(obj, 'propSet');
var moRef = _.has(obj, 'obj') ? util.moRef(obj.obj) : util.moRef(obj);
out.id = moRef.id;
out.type = moRef.type;
// loop through the propSet
if (Array.isArray(props)) {
_.forEach(props, function(prop) {... | javascript | function formatProp(obj) {
var out = {};
var props = _.get(obj, 'propSet');
var moRef = _.has(obj, 'obj') ? util.moRef(obj.obj) : util.moRef(obj);
out.id = moRef.id;
out.type = moRef.type;
// loop through the propSet
if (Array.isArray(props)) {
_.forEach(props, function(prop) {... | [
"function",
"formatProp",
"(",
"obj",
")",
"{",
"var",
"out",
"=",
"{",
"}",
";",
"var",
"props",
"=",
"_",
".",
"get",
"(",
"obj",
",",
"'propSet'",
")",
";",
"var",
"moRef",
"=",
"_",
".",
"has",
"(",
"obj",
",",
"'obj'",
")",
"?",
"util",
... | format each object | [
"format",
"each",
"object"
] | 2203b678847a57e3cb982f1a23277d44444f6de4 | https://github.com/bhoriuchi/vsphere-connect/blob/2203b678847a57e3cb982f1a23277d44444f6de4/archive/v1/format.js#L123-L142 | train |
bhoriuchi/vsphere-connect | archive/v1/format.js | expandFields | function expandFields(obj) {
var out = {};
_.forEach(obj, function(val, key) {
if (_.includes(key, '.')) {
_.set(out, key, val);
}
else {
out[key] = val;
}
});
return out;
} | javascript | function expandFields(obj) {
var out = {};
_.forEach(obj, function(val, key) {
if (_.includes(key, '.')) {
_.set(out, key, val);
}
else {
out[key] = val;
}
});
return out;
} | [
"function",
"expandFields",
"(",
"obj",
")",
"{",
"var",
"out",
"=",
"{",
"}",
";",
"_",
".",
"forEach",
"(",
"obj",
",",
"function",
"(",
"val",
",",
"key",
")",
"{",
"if",
"(",
"_",
".",
"includes",
"(",
"key",
",",
"'.'",
")",
")",
"{",
"_... | since filters with dot notation return field names with dots, expand those fields and remove the dot named field | [
"since",
"filters",
"with",
"dot",
"notation",
"return",
"field",
"names",
"with",
"dots",
"expand",
"those",
"fields",
"and",
"remove",
"the",
"dot",
"named",
"field"
] | 2203b678847a57e3cb982f1a23277d44444f6de4 | https://github.com/bhoriuchi/vsphere-connect/blob/2203b678847a57e3cb982f1a23277d44444f6de4/archive/v1/format.js#L146-L159 | train |
bhoriuchi/vsphere-connect | archive/v1/format.js | format | function format(response) {
var newObj = [];
var objects = _.get(response, 'objects') || response;
if (objects) {
// check if objects is an array
if (Array.isArray(objects)) {
_.forEach(objects, function(obj) {
newObj.push(expandFields(formatProp(obj)));
});
}
else {
newObj = exp... | javascript | function format(response) {
var newObj = [];
var objects = _.get(response, 'objects') || response;
if (objects) {
// check if objects is an array
if (Array.isArray(objects)) {
_.forEach(objects, function(obj) {
newObj.push(expandFields(formatProp(obj)));
});
}
else {
newObj = exp... | [
"function",
"format",
"(",
"response",
")",
"{",
"var",
"newObj",
"=",
"[",
"]",
";",
"var",
"objects",
"=",
"_",
".",
"get",
"(",
"response",
",",
"'objects'",
")",
"||",
"response",
";",
"if",
"(",
"objects",
")",
"{",
"// check if objects is an array"... | main formatting function | [
"main",
"formatting",
"function"
] | 2203b678847a57e3cb982f1a23277d44444f6de4 | https://github.com/bhoriuchi/vsphere-connect/blob/2203b678847a57e3cb982f1a23277d44444f6de4/archive/v1/format.js#L163-L184 | train |
simonguo/hbook | theme/javascript/sidebar.js | filterSummary | function filterSummary(paths) {
var $summary = $('.book-summary');
$summary.find('li').each(function() {
var path = $(this).data('path');
var st = paths == null || _.contains(paths, path);
$(this).toggle(st);
if (st) $(this).parents('li').show();
});
} | javascript | function filterSummary(paths) {
var $summary = $('.book-summary');
$summary.find('li').each(function() {
var path = $(this).data('path');
var st = paths == null || _.contains(paths, path);
$(this).toggle(st);
if (st) $(this).parents('li').show();
});
} | [
"function",
"filterSummary",
"(",
"paths",
")",
"{",
"var",
"$summary",
"=",
"$",
"(",
"'.book-summary'",
")",
";",
"$summary",
".",
"find",
"(",
"'li'",
")",
".",
"each",
"(",
"function",
"(",
")",
"{",
"var",
"path",
"=",
"$",
"(",
"this",
")",
"... | Filter summary with a list of path | [
"Filter",
"summary",
"with",
"a",
"list",
"of",
"path"
] | 5ea071130cc418fccd97a3e7e9a285c1d756b80b | https://github.com/simonguo/hbook/blob/5ea071130cc418fccd97a3e7e9a285c1d756b80b/theme/javascript/sidebar.js#L39-L49 | train |
bhoriuchi/vsphere-connect | src/soap/client/wsdl/methods/process-docs.js | setOperations | function setOperations(operations, portType) {
_.forEach(portType.childNodes, node => {
if (node.localName === 'operation') {
operations[node.getAttribute('name')] = node;
}
});
} | javascript | function setOperations(operations, portType) {
_.forEach(portType.childNodes, node => {
if (node.localName === 'operation') {
operations[node.getAttribute('name')] = node;
}
});
} | [
"function",
"setOperations",
"(",
"operations",
",",
"portType",
")",
"{",
"_",
".",
"forEach",
"(",
"portType",
".",
"childNodes",
",",
"node",
"=>",
"{",
"if",
"(",
"node",
".",
"localName",
"===",
"'operation'",
")",
"{",
"operations",
"[",
"node",
".... | set operations via interface or portType | [
"set",
"operations",
"via",
"interface",
"or",
"portType"
] | 2203b678847a57e3cb982f1a23277d44444f6de4 | https://github.com/bhoriuchi/vsphere-connect/blob/2203b678847a57e3cb982f1a23277d44444f6de4/src/soap/client/wsdl/methods/process-docs.js#L6-L12 | train |
simonguo/hbook | lib/utils/fs.js | getUniqueFilename | function getUniqueFilename(base, filename) {
if (!filename) {
filename = base;
base = '/';
}
filename = path.resolve(base, filename);
var ext = path.extname(filename);
filename = path.join(path.dirname(filename), path.basename(filename, ext));
var _filename = filename+ext;
... | javascript | function getUniqueFilename(base, filename) {
if (!filename) {
filename = base;
base = '/';
}
filename = path.resolve(base, filename);
var ext = path.extname(filename);
filename = path.join(path.dirname(filename), path.basename(filename, ext));
var _filename = filename+ext;
... | [
"function",
"getUniqueFilename",
"(",
"base",
",",
"filename",
")",
"{",
"if",
"(",
"!",
"filename",
")",
"{",
"filename",
"=",
"base",
";",
"base",
"=",
"'/'",
";",
"}",
"filename",
"=",
"path",
".",
"resolve",
"(",
"base",
",",
"filename",
")",
";"... | Find a filename available | [
"Find",
"a",
"filename",
"available"
] | 5ea071130cc418fccd97a3e7e9a285c1d756b80b | https://github.com/simonguo/hbook/blob/5ea071130cc418fccd97a3e7e9a285c1d756b80b/lib/utils/fs.js#L78-L97 | train |
simonguo/hbook | lib/utils/fs.js | listFiles | function listFiles(root, options) {
options = _.defaults(options || {}, {
ignoreFiles: [],
ignoreRules: []
});
var d = Q.defer();
// Our list of files
var files = [];
var ig = Ignore({
path: root,
ignoreFiles: options.ignoreFiles
});
// Add extra rules... | javascript | function listFiles(root, options) {
options = _.defaults(options || {}, {
ignoreFiles: [],
ignoreRules: []
});
var d = Q.defer();
// Our list of files
var files = [];
var ig = Ignore({
path: root,
ignoreFiles: options.ignoreFiles
});
// Add extra rules... | [
"function",
"listFiles",
"(",
"root",
",",
"options",
")",
"{",
"options",
"=",
"_",
".",
"defaults",
"(",
"options",
"||",
"{",
"}",
",",
"{",
"ignoreFiles",
":",
"[",
"]",
",",
"ignoreRules",
":",
"[",
"]",
"}",
")",
";",
"var",
"d",
"=",
"Q",
... | List files in a directory | [
"List",
"files",
"in",
"a",
"directory"
] | 5ea071130cc418fccd97a3e7e9a285c1d756b80b | https://github.com/simonguo/hbook/blob/5ea071130cc418fccd97a3e7e9a285c1d756b80b/lib/utils/fs.js#L101-L142 | train |
simonguo/hbook | lib/utils/fs.js | cleanFolder | function cleanFolder(root) {
if (!fs.existsSync(root)) return fsUtils.mkdirp(root);
return listFiles(root, {
ignoreFiles: [],
ignoreRules: [
// Skip Git and SVN stuff
'.git/',
'.svn/'
]
})
.then(function(files) {
var d = Q.defer();
... | javascript | function cleanFolder(root) {
if (!fs.existsSync(root)) return fsUtils.mkdirp(root);
return listFiles(root, {
ignoreFiles: [],
ignoreRules: [
// Skip Git and SVN stuff
'.git/',
'.svn/'
]
})
.then(function(files) {
var d = Q.defer();
... | [
"function",
"cleanFolder",
"(",
"root",
")",
"{",
"if",
"(",
"!",
"fs",
".",
"existsSync",
"(",
"root",
")",
")",
"return",
"fsUtils",
".",
"mkdirp",
"(",
"root",
")",
";",
"return",
"listFiles",
"(",
"root",
",",
"{",
"ignoreFiles",
":",
"[",
"]",
... | Clean a folder without removing .git and .svn Creates it if non existant | [
"Clean",
"a",
"folder",
"without",
"removing",
".",
"git",
"and",
".",
"svn",
"Creates",
"it",
"if",
"non",
"existant"
] | 5ea071130cc418fccd97a3e7e9a285c1d756b80b | https://github.com/simonguo/hbook/blob/5ea071130cc418fccd97a3e7e9a285c1d756b80b/lib/utils/fs.js#L146-L180 | train |
stremlenye/immutable-http | src/validate.js | validateMethod | function validateMethod (method) {
if (!method) {
return option.some('HTTP method is not specified')
}
if (typeof method !== 'string') {
return option.some('HTTP method should be type of string')
}
if (supportedMethods.indexOf(method.toUpperCase()) < 0) {
return option.some(`Http method ${method} ... | javascript | function validateMethod (method) {
if (!method) {
return option.some('HTTP method is not specified')
}
if (typeof method !== 'string') {
return option.some('HTTP method should be type of string')
}
if (supportedMethods.indexOf(method.toUpperCase()) < 0) {
return option.some(`Http method ${method} ... | [
"function",
"validateMethod",
"(",
"method",
")",
"{",
"if",
"(",
"!",
"method",
")",
"{",
"return",
"option",
".",
"some",
"(",
"'HTTP method is not specified'",
")",
"}",
"if",
"(",
"typeof",
"method",
"!==",
"'string'",
")",
"{",
"return",
"option",
"."... | Validate HTTP method
@param {String} method – HTTP method
@return {String} error | [
"Validate",
"HTTP",
"method"
] | 4d46a66cc11cd02d96be63a3283bbfe7df1272c3 | https://github.com/stremlenye/immutable-http/blob/4d46a66cc11cd02d96be63a3283bbfe7df1272c3/src/validate.js#L11-L22 | train |
stremlenye/immutable-http | src/validate.js | validateUrl | function validateUrl (url) {
if (!url) {
return option.some('Url is not specified')
}
if (typeof url !== 'string') {
return option.some('Url should be type of string')
}
return option.none
} | javascript | function validateUrl (url) {
if (!url) {
return option.some('Url is not specified')
}
if (typeof url !== 'string') {
return option.some('Url should be type of string')
}
return option.none
} | [
"function",
"validateUrl",
"(",
"url",
")",
"{",
"if",
"(",
"!",
"url",
")",
"{",
"return",
"option",
".",
"some",
"(",
"'Url is not specified'",
")",
"}",
"if",
"(",
"typeof",
"url",
"!==",
"'string'",
")",
"{",
"return",
"option",
".",
"some",
"(",
... | Basicly validate url
@param {String} url – URL
@return {String} error | [
"Basicly",
"validate",
"url"
] | 4d46a66cc11cd02d96be63a3283bbfe7df1272c3 | https://github.com/stremlenye/immutable-http/blob/4d46a66cc11cd02d96be63a3283bbfe7df1272c3/src/validate.js#L29-L37 | train |
stremlenye/immutable-http | src/validate.js | validateHeader | function validateHeader (key, value) {
if (typeof key !== 'string' || typeof value !== 'string')
return option.some(`Parts of header ${key}:${value} must be strings`)
return option.none
} | javascript | function validateHeader (key, value) {
if (typeof key !== 'string' || typeof value !== 'string')
return option.some(`Parts of header ${key}:${value} must be strings`)
return option.none
} | [
"function",
"validateHeader",
"(",
"key",
",",
"value",
")",
"{",
"if",
"(",
"typeof",
"key",
"!==",
"'string'",
"||",
"typeof",
"value",
"!==",
"'string'",
")",
"return",
"option",
".",
"some",
"(",
"`",
"${",
"key",
"}",
"${",
"value",
"}",
"`",
")... | Validate header to all parts be strings
@param {String} key – Header key
@param {String} value – Header value
@return {String} error | [
"Validate",
"header",
"to",
"all",
"parts",
"be",
"strings"
] | 4d46a66cc11cd02d96be63a3283bbfe7df1272c3 | https://github.com/stremlenye/immutable-http/blob/4d46a66cc11cd02d96be63a3283bbfe7df1272c3/src/validate.js#L45-L49 | train |
stremlenye/immutable-http | src/validate.js | validateResponseType | function validateResponseType (type) {
if (validTypes.indexOf(type) < 0)
return option.some(`Response content type ${type} is not supported`)
return option.none
} | javascript | function validateResponseType (type) {
if (validTypes.indexOf(type) < 0)
return option.some(`Response content type ${type} is not supported`)
return option.none
} | [
"function",
"validateResponseType",
"(",
"type",
")",
"{",
"if",
"(",
"validTypes",
".",
"indexOf",
"(",
"type",
")",
"<",
"0",
")",
"return",
"option",
".",
"some",
"(",
"`",
"${",
"type",
"}",
"`",
")",
"return",
"option",
".",
"none",
"}"
] | Validates response type
@param {string} type - response type
@return {String} error | [
"Validates",
"response",
"type"
] | 4d46a66cc11cd02d96be63a3283bbfe7df1272c3 | https://github.com/stremlenye/immutable-http/blob/4d46a66cc11cd02d96be63a3283bbfe7df1272c3/src/validate.js#L68-L72 | train |
bhoriuchi/vsphere-connect | archive/v1/client/retrieve.js | getResults | function getResults(result, objects) {
// if there are no results, resolve an empty array
if (!result) {
return new Promise(function(resolve, reject) {
resolve([]);
});
}
// if the result object is undefined or not an array, make it one
result.objects = result.objects || [];
result.objects =... | javascript | function getResults(result, objects) {
// if there are no results, resolve an empty array
if (!result) {
return new Promise(function(resolve, reject) {
resolve([]);
});
}
// if the result object is undefined or not an array, make it one
result.objects = result.objects || [];
result.objects =... | [
"function",
"getResults",
"(",
"result",
",",
"objects",
")",
"{",
"// if there are no results, resolve an empty array",
"if",
"(",
"!",
"result",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"resolve",
"(",
"... | continues to get all properties until finished | [
"continues",
"to",
"get",
"all",
"properties",
"until",
"finished"
] | 2203b678847a57e3cb982f1a23277d44444f6de4 | https://github.com/bhoriuchi/vsphere-connect/blob/2203b678847a57e3cb982f1a23277d44444f6de4/archive/v1/client/retrieve.js#L25-L56 | train |
steamerjs/steamer-react-component | src/spin.js | ins | function ins(parent /* child1, child2, ... */) {
for (let i = 1, n = arguments.length; i < n; i++) {
parent.appendChild(arguments[i]);
}
return parent;
} | javascript | function ins(parent /* child1, child2, ... */) {
for (let i = 1, n = arguments.length; i < n; i++) {
parent.appendChild(arguments[i]);
}
return parent;
} | [
"function",
"ins",
"(",
"parent",
"/* child1, child2, ... */",
")",
"{",
"for",
"(",
"let",
"i",
"=",
"1",
",",
"n",
"=",
"arguments",
".",
"length",
";",
"i",
"<",
"n",
";",
"i",
"++",
")",
"{",
"parent",
".",
"appendChild",
"(",
"arguments",
"[",
... | Appends children and returns the parent. | [
"Appends",
"children",
"and",
"returns",
"the",
"parent",
"."
] | 84cbf6a125d8d5693f037f8544c79e2b1c2bdca6 | https://github.com/steamerjs/steamer-react-component/blob/84cbf6a125d8d5693f037f8544c79e2b1c2bdca6/src/spin.js#L54-L60 | train |
steamerjs/steamer-react-component | src/spin.js | function() {
let el = this.el;
if (el) {
clearTimeout(this.timeout);
if (el.parentNode) el.parentNode.removeChild(el);
this.el = null;
}
return this;
} | javascript | function() {
let el = this.el;
if (el) {
clearTimeout(this.timeout);
if (el.parentNode) el.parentNode.removeChild(el);
this.el = null;
}
return this;
} | [
"function",
"(",
")",
"{",
"let",
"el",
"=",
"this",
".",
"el",
";",
"if",
"(",
"el",
")",
"{",
"clearTimeout",
"(",
"this",
".",
"timeout",
")",
";",
"if",
"(",
"el",
".",
"parentNode",
")",
"el",
".",
"parentNode",
".",
"removeChild",
"(",
"el"... | Stops and removes the Spinner. | [
"Stops",
"and",
"removes",
"the",
"Spinner",
"."
] | 84cbf6a125d8d5693f037f8544c79e2b1c2bdca6 | https://github.com/steamerjs/steamer-react-component/blob/84cbf6a125d8d5693f037f8544c79e2b1c2bdca6/src/spin.js#L226-L235 | train | |
bhoriuchi/vsphere-connect | archive/v1/util.js | moRef | function moRef(type, id) {
if (type && id) {
return {
attributes: {
type: type
},
"$value": id
};
}
else if (typeof(type) === 'object') {
return {
id: _.get(type, '$value'),
type: _.get(type, 'attributes.type') || _.get(type, 'attributes.xsi:type')
};
}
return null;
} | javascript | function moRef(type, id) {
if (type && id) {
return {
attributes: {
type: type
},
"$value": id
};
}
else if (typeof(type) === 'object') {
return {
id: _.get(type, '$value'),
type: _.get(type, 'attributes.type') || _.get(type, 'attributes.xsi:type')
};
}
return null;
} | [
"function",
"moRef",
"(",
"type",
",",
"id",
")",
"{",
"if",
"(",
"type",
"&&",
"id",
")",
"{",
"return",
"{",
"attributes",
":",
"{",
"type",
":",
"type",
"}",
",",
"\"$value\"",
":",
"id",
"}",
";",
"}",
"else",
"if",
"(",
"typeof",
"(",
"typ... | compose or decompose a moRef | [
"compose",
"or",
"decompose",
"a",
"moRef"
] | 2203b678847a57e3cb982f1a23277d44444f6de4 | https://github.com/bhoriuchi/vsphere-connect/blob/2203b678847a57e3cb982f1a23277d44444f6de4/archive/v1/util.js#L14-L31 | train |
bhoriuchi/vsphere-connect | archive/v1/util.js | isArray | function isArray(obj) {
var type = sType(obj);
return (Array.isArray(obj) || (typeof(type) === 'string' && type.substring(0, 5) === 'Array'));
} | javascript | function isArray(obj) {
var type = sType(obj);
return (Array.isArray(obj) || (typeof(type) === 'string' && type.substring(0, 5) === 'Array'));
} | [
"function",
"isArray",
"(",
"obj",
")",
"{",
"var",
"type",
"=",
"sType",
"(",
"obj",
")",
";",
"return",
"(",
"Array",
".",
"isArray",
"(",
"obj",
")",
"||",
"(",
"typeof",
"(",
"type",
")",
"===",
"'string'",
"&&",
"type",
".",
"substring",
"(",
... | determine if type is an array | [
"determine",
"if",
"type",
"is",
"an",
"array"
] | 2203b678847a57e3cb982f1a23277d44444f6de4 | https://github.com/bhoriuchi/vsphere-connect/blob/2203b678847a57e3cb982f1a23277d44444f6de4/archive/v1/util.js#L39-L42 | train |
bhoriuchi/vsphere-connect | archive/v1/util.js | isBoolean | function isBoolean(obj) {
var type = sType(obj);
return (_.has(obj, '$value') && (type === 'xsd:boolean' || type === 'boolean'));
} | javascript | function isBoolean(obj) {
var type = sType(obj);
return (_.has(obj, '$value') && (type === 'xsd:boolean' || type === 'boolean'));
} | [
"function",
"isBoolean",
"(",
"obj",
")",
"{",
"var",
"type",
"=",
"sType",
"(",
"obj",
")",
";",
"return",
"(",
"_",
".",
"has",
"(",
"obj",
",",
"'$value'",
")",
"&&",
"(",
"type",
"===",
"'xsd:boolean'",
"||",
"type",
"===",
"'boolean'",
")",
")... | check for boolean | [
"check",
"for",
"boolean"
] | 2203b678847a57e3cb982f1a23277d44444f6de4 | https://github.com/bhoriuchi/vsphere-connect/blob/2203b678847a57e3cb982f1a23277d44444f6de4/archive/v1/util.js#L45-L48 | 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.