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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
theisensanders-wf/responsive-sketchpad | responsive-sketchpad.js | startLine | function startLine (e) {
e.preventDefault();
strokes = that.strokes;
sketching = true;
that.undos = [];
var cursor = getCursorRelativeToCanvas(e);
strokes.push({
points: [cursor],
color: opts.line.color,
... | javascript | function startLine (e) {
e.preventDefault();
strokes = that.strokes;
sketching = true;
that.undos = [];
var cursor = getCursorRelativeToCanvas(e);
strokes.push({
points: [cursor],
color: opts.line.color,
... | [
"function",
"startLine",
"(",
"e",
")",
"{",
"e",
".",
"preventDefault",
"(",
")",
";",
"strokes",
"=",
"that",
".",
"strokes",
";",
"sketching",
"=",
"true",
";",
"that",
".",
"undos",
"=",
"[",
"]",
";",
"var",
"cursor",
"=",
"getCursorRelativeToCanv... | On mouse down, create a new stroke with a start location | [
"On",
"mouse",
"down",
"create",
"a",
"new",
"stroke",
"with",
"a",
"start",
"location"
] | aedc4d2aa710cc75e48e0df49aeff9b49e51ad5f | https://github.com/theisensanders-wf/responsive-sketchpad/blob/aedc4d2aa710cc75e48e0df49aeff9b49e51ad5f/responsive-sketchpad.js#L187-L203 | train |
umidbekkarimov/babel-plugin-direct-import | src/resolver.js | resolveFilename | function resolveFilename(fileName, cwd = process.cwd()) {
try {
const parent = new Module();
// eslint-disable-next-line no-underscore-dangle
parent.paths = Module._nodeModulePaths(cwd);
// eslint-disable-next-line no-underscore-dangle
return Module._resolveFilename(fileName, parent);
} catch ... | javascript | function resolveFilename(fileName, cwd = process.cwd()) {
try {
const parent = new Module();
// eslint-disable-next-line no-underscore-dangle
parent.paths = Module._nodeModulePaths(cwd);
// eslint-disable-next-line no-underscore-dangle
return Module._resolveFilename(fileName, parent);
} catch ... | [
"function",
"resolveFilename",
"(",
"fileName",
",",
"cwd",
"=",
"process",
".",
"cwd",
"(",
")",
")",
"{",
"try",
"{",
"const",
"parent",
"=",
"new",
"Module",
"(",
")",
";",
"// eslint-disable-next-line no-underscore-dangle",
"parent",
".",
"paths",
"=",
"... | Resolve module file.
@param {String} fileName
@param {String} cwd
@returns {String|null} | [
"Resolve",
"module",
"file",
"."
] | d98ac4ed5c48f572856cc2963e62dcaaf3c305bd | https://github.com/umidbekkarimov/babel-plugin-direct-import/blob/d98ac4ed5c48f572856cc2963e62dcaaf3c305bd/src/resolver.js#L13-L31 | train |
alexilyaev/stylelint-find-rules | src/lib/cli.js | handleError | function handleError(err) {
let errMsg = err;
if (err instanceof Object) {
errMsg = err.message || err.error || JSON.stringify(err);
}
printColumns(chalk.red('Error: ' + errMsg));
printColumns(
chalk.white(
"If you can't settle this, please open an issue at:" + EOL + chalk.cyan(pkg.bugs.url)
... | javascript | function handleError(err) {
let errMsg = err;
if (err instanceof Object) {
errMsg = err.message || err.error || JSON.stringify(err);
}
printColumns(chalk.red('Error: ' + errMsg));
printColumns(
chalk.white(
"If you can't settle this, please open an issue at:" + EOL + chalk.cyan(pkg.bugs.url)
... | [
"function",
"handleError",
"(",
"err",
")",
"{",
"let",
"errMsg",
"=",
"err",
";",
"if",
"(",
"err",
"instanceof",
"Object",
")",
"{",
"errMsg",
"=",
"err",
".",
"message",
"||",
"err",
".",
"error",
"||",
"JSON",
".",
"stringify",
"(",
"err",
")",
... | Handle promise rejections and errors | [
"Handle",
"promise",
"rejections",
"and",
"errors"
] | 5c23235686c56ef463fc61bf6f912e64b23acb94 | https://github.com/alexilyaev/stylelint-find-rules/blob/5c23235686c56ef463fc61bf6f912e64b23acb94/src/lib/cli.js#L83-L97 | train |
alexilyaev/stylelint-find-rules | src/lib/cli.js | printColumns | function printColumns(heading, data) {
const columns = columnify(data, {});
const spacer = EOL + EOL;
process.stdout.write(heading);
process.stdout.write(spacer);
if (columns) {
process.stdout.write(columns);
process.stdout.write(spacer);
}
} | javascript | function printColumns(heading, data) {
const columns = columnify(data, {});
const spacer = EOL + EOL;
process.stdout.write(heading);
process.stdout.write(spacer);
if (columns) {
process.stdout.write(columns);
process.stdout.write(spacer);
}
} | [
"function",
"printColumns",
"(",
"heading",
",",
"data",
")",
"{",
"const",
"columns",
"=",
"columnify",
"(",
"data",
",",
"{",
"}",
")",
";",
"const",
"spacer",
"=",
"EOL",
"+",
"EOL",
";",
"process",
".",
"stdout",
".",
"write",
"(",
"heading",
")"... | Print to stdout
@param {string} heading
@param {Array?} data | [
"Print",
"to",
"stdout"
] | 5c23235686c56ef463fc61bf6f912e64b23acb94 | https://github.com/alexilyaev/stylelint-find-rules/blob/5c23235686c56ef463fc61bf6f912e64b23acb94/src/lib/cli.js#L105-L116 | train |
alexilyaev/stylelint-find-rules | src/lib/cli.js | getUserRules | function getUserRules(cosmiconfig) {
const userConfig = cosmiconfig.config;
const configPath = cosmiconfig.filepath;
return (
Promise.resolve()
// Handle `extends`
.then(() => {
// If `extends` is defined, use stylelint's extends resolver
if (!_.isEmpty(userConfig.extends)) {
... | javascript | function getUserRules(cosmiconfig) {
const userConfig = cosmiconfig.config;
const configPath = cosmiconfig.filepath;
return (
Promise.resolve()
// Handle `extends`
.then(() => {
// If `extends` is defined, use stylelint's extends resolver
if (!_.isEmpty(userConfig.extends)) {
... | [
"function",
"getUserRules",
"(",
"cosmiconfig",
")",
"{",
"const",
"userConfig",
"=",
"cosmiconfig",
".",
"config",
";",
"const",
"configPath",
"=",
"cosmiconfig",
".",
"filepath",
";",
"return",
"(",
"Promise",
".",
"resolve",
"(",
")",
"// Handle `extends`",
... | Get user rules
Gather rules from `extends` as well | [
"Get",
"user",
"rules",
"Gather",
"rules",
"from",
"extends",
"as",
"well"
] | 5c23235686c56ef463fc61bf6f912e64b23acb94 | https://github.com/alexilyaev/stylelint-find-rules/blob/5c23235686c56ef463fc61bf6f912e64b23acb94/src/lib/cli.js#L149-L174 | train |
alexilyaev/stylelint-find-rules | src/lib/cli.js | findDeprecatedStylelintRules | function findDeprecatedStylelintRules() {
if (!argv.deprecated && !argv.unused) {
return Promise.resolve();
}
const isDeprecatedPromises = _.map(rules.stylelintAll, isDDeprecated);
return Promise.all(isDeprecatedPromises).then(rulesIsDeprecated => {
rules.stylelintDeprecated = _.filter(
rules.st... | javascript | function findDeprecatedStylelintRules() {
if (!argv.deprecated && !argv.unused) {
return Promise.resolve();
}
const isDeprecatedPromises = _.map(rules.stylelintAll, isDDeprecated);
return Promise.all(isDeprecatedPromises).then(rulesIsDeprecated => {
rules.stylelintDeprecated = _.filter(
rules.st... | [
"function",
"findDeprecatedStylelintRules",
"(",
")",
"{",
"if",
"(",
"!",
"argv",
".",
"deprecated",
"&&",
"!",
"argv",
".",
"unused",
")",
"{",
"return",
"Promise",
".",
"resolve",
"(",
")",
";",
"}",
"const",
"isDeprecatedPromises",
"=",
"_",
".",
"ma... | Find all deprecated rules from the list of stylelint rules
@returns {Promise} | [
"Find",
"all",
"deprecated",
"rules",
"from",
"the",
"list",
"of",
"stylelint",
"rules"
] | 5c23235686c56ef463fc61bf6f912e64b23acb94 | https://github.com/alexilyaev/stylelint-find-rules/blob/5c23235686c56ef463fc61bf6f912e64b23acb94/src/lib/cli.js#L181-L205 | train |
alexilyaev/stylelint-find-rules | src/lib/cli.js | printUserCurrent | function printUserCurrent() {
if (!argv.current) {
return;
}
const heading = chalk.blue.underline('CURRENT: Currently configured user rules:');
const rulesToPrint = _.map(rules.userRulesNames, rule => {
return {
rule,
url: chalk.cyan(`https://stylelint.io/user-guide/rules/${rule}/`)
};
... | javascript | function printUserCurrent() {
if (!argv.current) {
return;
}
const heading = chalk.blue.underline('CURRENT: Currently configured user rules:');
const rulesToPrint = _.map(rules.userRulesNames, rule => {
return {
rule,
url: chalk.cyan(`https://stylelint.io/user-guide/rules/${rule}/`)
};
... | [
"function",
"printUserCurrent",
"(",
")",
"{",
"if",
"(",
"!",
"argv",
".",
"current",
")",
"{",
"return",
";",
"}",
"const",
"heading",
"=",
"chalk",
".",
"blue",
".",
"underline",
"(",
"'CURRENT: Currently configured user rules:'",
")",
";",
"const",
"rule... | Print currently configured rules | [
"Print",
"currently",
"configured",
"rules"
] | 5c23235686c56ef463fc61bf6f912e64b23acb94 | https://github.com/alexilyaev/stylelint-find-rules/blob/5c23235686c56ef463fc61bf6f912e64b23acb94/src/lib/cli.js#L217-L231 | train |
alexilyaev/stylelint-find-rules | src/lib/cli.js | printAllAvailable | function printAllAvailable() {
if (!argv.available) {
return;
}
const heading = chalk.blue.underline('AVAILABLE: All available stylelint rules:');
const rulesToPrint = _.map(rules.stylelintAll, rule => {
return {
rule,
url: chalk.cyan(`https://stylelint.io/user-guide/rules/${rule}/`)
};... | javascript | function printAllAvailable() {
if (!argv.available) {
return;
}
const heading = chalk.blue.underline('AVAILABLE: All available stylelint rules:');
const rulesToPrint = _.map(rules.stylelintAll, rule => {
return {
rule,
url: chalk.cyan(`https://stylelint.io/user-guide/rules/${rule}/`)
};... | [
"function",
"printAllAvailable",
"(",
")",
"{",
"if",
"(",
"!",
"argv",
".",
"available",
")",
"{",
"return",
";",
"}",
"const",
"heading",
"=",
"chalk",
".",
"blue",
".",
"underline",
"(",
"'AVAILABLE: All available stylelint rules:'",
")",
";",
"const",
"r... | Print all available stylelint rules | [
"Print",
"all",
"available",
"stylelint",
"rules"
] | 5c23235686c56ef463fc61bf6f912e64b23acb94 | https://github.com/alexilyaev/stylelint-find-rules/blob/5c23235686c56ef463fc61bf6f912e64b23acb94/src/lib/cli.js#L236-L250 | train |
alexilyaev/stylelint-find-rules | src/lib/cli.js | printConfiguredUnavailable | function printConfiguredUnavailable() {
if (!argv.invalid) {
return;
}
const configuredUnavailable = _.difference(rules.userRulesNames, rules.stylelintAll);
if (!configuredUnavailable.length) {
return;
}
const heading = chalk.red.underline('INVALID: Configured rules that are no longer available:'... | javascript | function printConfiguredUnavailable() {
if (!argv.invalid) {
return;
}
const configuredUnavailable = _.difference(rules.userRulesNames, rules.stylelintAll);
if (!configuredUnavailable.length) {
return;
}
const heading = chalk.red.underline('INVALID: Configured rules that are no longer available:'... | [
"function",
"printConfiguredUnavailable",
"(",
")",
"{",
"if",
"(",
"!",
"argv",
".",
"invalid",
")",
"{",
"return",
";",
"}",
"const",
"configuredUnavailable",
"=",
"_",
".",
"difference",
"(",
"rules",
".",
"userRulesNames",
",",
"rules",
".",
"stylelintAl... | Print configured rules that are no longer available | [
"Print",
"configured",
"rules",
"that",
"are",
"no",
"longer",
"available"
] | 5c23235686c56ef463fc61bf6f912e64b23acb94 | https://github.com/alexilyaev/stylelint-find-rules/blob/5c23235686c56ef463fc61bf6f912e64b23acb94/src/lib/cli.js#L255-L274 | train |
alexilyaev/stylelint-find-rules | src/lib/cli.js | printUserDeprecated | function printUserDeprecated() {
if (!argv.deprecated) {
return;
}
const userDeprecated = _.intersection(rules.stylelintDeprecated, rules.userRulesNames);
if (!userDeprecated.length) {
return;
}
const heading = chalk.red.underline('DEPRECATED: Configured rules that are deprecated:');
const rule... | javascript | function printUserDeprecated() {
if (!argv.deprecated) {
return;
}
const userDeprecated = _.intersection(rules.stylelintDeprecated, rules.userRulesNames);
if (!userDeprecated.length) {
return;
}
const heading = chalk.red.underline('DEPRECATED: Configured rules that are deprecated:');
const rule... | [
"function",
"printUserDeprecated",
"(",
")",
"{",
"if",
"(",
"!",
"argv",
".",
"deprecated",
")",
"{",
"return",
";",
"}",
"const",
"userDeprecated",
"=",
"_",
".",
"intersection",
"(",
"rules",
".",
"stylelintDeprecated",
",",
"rules",
".",
"userRulesNames"... | Print user configured rules that are deprecated | [
"Print",
"user",
"configured",
"rules",
"that",
"are",
"deprecated"
] | 5c23235686c56ef463fc61bf6f912e64b23acb94 | https://github.com/alexilyaev/stylelint-find-rules/blob/5c23235686c56ef463fc61bf6f912e64b23acb94/src/lib/cli.js#L279-L299 | train |
alexilyaev/stylelint-find-rules | src/lib/cli.js | printUserUnused | function printUserUnused() {
if (!argv.unused) {
return;
}
const userUnconfigured = _.difference(rules.stylelintNoDeprecated, rules.userRulesNames);
let heading;
if (!userUnconfigured.length) {
heading = chalk.green('All rules are up-to-date!');
printColumns(heading);
return;
}
const r... | javascript | function printUserUnused() {
if (!argv.unused) {
return;
}
const userUnconfigured = _.difference(rules.stylelintNoDeprecated, rules.userRulesNames);
let heading;
if (!userUnconfigured.length) {
heading = chalk.green('All rules are up-to-date!');
printColumns(heading);
return;
}
const r... | [
"function",
"printUserUnused",
"(",
")",
"{",
"if",
"(",
"!",
"argv",
".",
"unused",
")",
"{",
"return",
";",
"}",
"const",
"userUnconfigured",
"=",
"_",
".",
"difference",
"(",
"rules",
".",
"stylelintNoDeprecated",
",",
"rules",
".",
"userRulesNames",
")... | Print available stylelint rules that the user hasn't configured yet | [
"Print",
"available",
"stylelint",
"rules",
"that",
"the",
"user",
"hasn",
"t",
"configured",
"yet"
] | 5c23235686c56ef463fc61bf6f912e64b23acb94 | https://github.com/alexilyaev/stylelint-find-rules/blob/5c23235686c56ef463fc61bf6f912e64b23acb94/src/lib/cli.js#L304-L329 | train |
alexilyaev/stylelint-find-rules | src/lib/cli.js | printTimingAndExit | function printTimingAndExit(startTime) {
const execTime = time() - startTime;
printColumns(chalk.green(`Finished in: ${execTime.toFixed()}ms`));
process.exit(0);
} | javascript | function printTimingAndExit(startTime) {
const execTime = time() - startTime;
printColumns(chalk.green(`Finished in: ${execTime.toFixed()}ms`));
process.exit(0);
} | [
"function",
"printTimingAndExit",
"(",
"startTime",
")",
"{",
"const",
"execTime",
"=",
"time",
"(",
")",
"-",
"startTime",
";",
"printColumns",
"(",
"chalk",
".",
"green",
"(",
"`",
"${",
"execTime",
".",
"toFixed",
"(",
")",
"}",
"`",
")",
")",
";",
... | Print how long it took the tool to execute | [
"Print",
"how",
"long",
"it",
"took",
"the",
"tool",
"to",
"execute"
] | 5c23235686c56ef463fc61bf6f912e64b23acb94 | https://github.com/alexilyaev/stylelint-find-rules/blob/5c23235686c56ef463fc61bf6f912e64b23acb94/src/lib/cli.js#L334-L339 | train |
swissquote/crafty | packages/crafty/src/configuration.js | resolveModule | function resolveModule(module) {
debug("resolveModule", module);
const presetName = module;
if (path.isAbsolute(presetName)) {
return [getPresetName(module), module];
}
try {
// Try the naive way
return [presetName, require.resolve(module)];
} catch (e) {
// Try a more advanced way
re... | javascript | function resolveModule(module) {
debug("resolveModule", module);
const presetName = module;
if (path.isAbsolute(presetName)) {
return [getPresetName(module), module];
}
try {
// Try the naive way
return [presetName, require.resolve(module)];
} catch (e) {
// Try a more advanced way
re... | [
"function",
"resolveModule",
"(",
"module",
")",
"{",
"debug",
"(",
"\"resolveModule\"",
",",
"module",
")",
";",
"const",
"presetName",
"=",
"module",
";",
"if",
"(",
"path",
".",
"isAbsolute",
"(",
"presetName",
")",
")",
"{",
"return",
"[",
"getPresetNa... | A module can be a a full path or just a module name
From that we'll try to find the name of the preset and the file that contains it.
@param {String} module | [
"A",
"module",
"can",
"be",
"a",
"a",
"full",
"path",
"or",
"just",
"a",
"module",
"name",
"From",
"that",
"we",
"ll",
"try",
"to",
"find",
"the",
"name",
"of",
"the",
"preset",
"and",
"the",
"file",
"that",
"contains",
"it",
"."
] | ff88203810516a5ff73a0705d20afc6857bfd445 | https://github.com/swissquote/crafty/blob/ff88203810516a5ff73a0705d20afc6857bfd445/packages/crafty/src/configuration.js#L21-L37 | train |
swissquote/crafty | packages/crafty/src/configuration.js | getPresetName | function getPresetName(file) {
const packageJson = findUp.sync("package.json", { cwd: path.dirname(file) });
if (packageJson) {
return require(packageJson).name || file;
}
return file;
} | javascript | function getPresetName(file) {
const packageJson = findUp.sync("package.json", { cwd: path.dirname(file) });
if (packageJson) {
return require(packageJson).name || file;
}
return file;
} | [
"function",
"getPresetName",
"(",
"file",
")",
"{",
"const",
"packageJson",
"=",
"findUp",
".",
"sync",
"(",
"\"package.json\"",
",",
"{",
"cwd",
":",
"path",
".",
"dirname",
"(",
"file",
")",
"}",
")",
";",
"if",
"(",
"packageJson",
")",
"{",
"return"... | Get the package's name or the filename if nothing is found
@param {*} file | [
"Get",
"the",
"package",
"s",
"name",
"or",
"the",
"filename",
"if",
"nothing",
"is",
"found"
] | ff88203810516a5ff73a0705d20afc6857bfd445 | https://github.com/swissquote/crafty/blob/ff88203810516a5ff73a0705d20afc6857bfd445/packages/crafty/src/configuration.js#L58-L66 | train |
swissquote/crafty | packages/crafty/src/configuration.js | getOverrides | function getOverrides() {
const configPath = path.join(process.cwd(), "crafty.config.js");
if (fs.existsSync(configPath)) {
return require(configPath);
}
console.log(`No crafty.config.js found in '${process.cwd()}', proceeding...`);
return {};
} | javascript | function getOverrides() {
const configPath = path.join(process.cwd(), "crafty.config.js");
if (fs.existsSync(configPath)) {
return require(configPath);
}
console.log(`No crafty.config.js found in '${process.cwd()}', proceeding...`);
return {};
} | [
"function",
"getOverrides",
"(",
")",
"{",
"const",
"configPath",
"=",
"path",
".",
"join",
"(",
"process",
".",
"cwd",
"(",
")",
",",
"\"crafty.config.js\"",
")",
";",
"if",
"(",
"fs",
".",
"existsSync",
"(",
"configPath",
")",
")",
"{",
"return",
"re... | Get the user's configuration
@return {*} A configuration object | [
"Get",
"the",
"user",
"s",
"configuration"
] | ff88203810516a5ff73a0705d20afc6857bfd445 | https://github.com/swissquote/crafty/blob/ff88203810516a5ff73a0705d20afc6857bfd445/packages/crafty/src/configuration.js#L221-L230 | train |
swissquote/crafty | packages/crafty-runner-webpack/src/webpack_output.js | sortFiles | function sortFiles(files) {
const modules = [];
const assets = [];
let isAssets = false;
for (var i in files) {
const row = files[i];
if (row[0] == "size" && row[2] == "asset") {
isAssets = true;
}
if (row[0] == "size" || row[0] == "") {
continue;
}
if (isAssets) {
... | javascript | function sortFiles(files) {
const modules = [];
const assets = [];
let isAssets = false;
for (var i in files) {
const row = files[i];
if (row[0] == "size" && row[2] == "asset") {
isAssets = true;
}
if (row[0] == "size" || row[0] == "") {
continue;
}
if (isAssets) {
... | [
"function",
"sortFiles",
"(",
"files",
")",
"{",
"const",
"modules",
"=",
"[",
"]",
";",
"const",
"assets",
"=",
"[",
"]",
";",
"let",
"isAssets",
"=",
"false",
";",
"for",
"(",
"var",
"i",
"in",
"files",
")",
"{",
"const",
"row",
"=",
"files",
"... | Sort the files order.
The main reason is that test snapshots need the order to stay the same.
For some reason this isn't the case sometimes.
@param {*} files | [
"Sort",
"the",
"files",
"order",
".",
"The",
"main",
"reason",
"is",
"that",
"test",
"snapshots",
"need",
"the",
"order",
"to",
"stay",
"the",
"same",
".",
"For",
"some",
"reason",
"this",
"isn",
"t",
"the",
"case",
"sometimes",
"."
] | ff88203810516a5ff73a0705d20afc6857bfd445 | https://github.com/swissquote/crafty/blob/ff88203810516a5ff73a0705d20afc6857bfd445/packages/crafty-runner-webpack/src/webpack_output.js#L14-L75 | train |
rafrex/react-interactive | src/inputTracker.js | updateMouse | function updateMouse(e) {
input.mouse.clientX = e.clientX;
input.mouse.clientY = e.clientY;
input.mouse.buttons = e.buttons;
if (e.type === 'mouseleave') input.mouse.mouseOnDocument = false;
else input.mouse.mouseOnDocument = true;
} | javascript | function updateMouse(e) {
input.mouse.clientX = e.clientX;
input.mouse.clientY = e.clientY;
input.mouse.buttons = e.buttons;
if (e.type === 'mouseleave') input.mouse.mouseOnDocument = false;
else input.mouse.mouseOnDocument = true;
} | [
"function",
"updateMouse",
"(",
"e",
")",
"{",
"input",
".",
"mouse",
".",
"clientX",
"=",
"e",
".",
"clientX",
";",
"input",
".",
"mouse",
".",
"clientY",
"=",
"e",
".",
"clientY",
";",
"input",
".",
"mouse",
".",
"buttons",
"=",
"e",
".",
"button... | update mouse input tracking | [
"update",
"mouse",
"input",
"tracking"
] | 65b802b7915d1241c24cbba8770e6b066182c243 | https://github.com/rafrex/react-interactive/blob/65b802b7915d1241c24cbba8770e6b066182c243/src/inputTracker.js#L50-L56 | train |
rafrex/react-interactive | src/inputTracker.js | updateHybridMouse | function updateHybridMouse(e) {
if (input.touch.recentTouch || input.touch.touchOnScreen) return;
updateMouse(e);
} | javascript | function updateHybridMouse(e) {
if (input.touch.recentTouch || input.touch.touchOnScreen) return;
updateMouse(e);
} | [
"function",
"updateHybridMouse",
"(",
"e",
")",
"{",
"if",
"(",
"input",
".",
"touch",
".",
"recentTouch",
"||",
"input",
".",
"touch",
".",
"touchOnScreen",
")",
"return",
";",
"updateMouse",
"(",
"e",
")",
";",
"}"
] | only update mouse if the mouse event is not from a touch event | [
"only",
"update",
"mouse",
"if",
"the",
"mouse",
"event",
"is",
"not",
"from",
"a",
"touch",
"event"
] | 65b802b7915d1241c24cbba8770e6b066182c243 | https://github.com/rafrex/react-interactive/blob/65b802b7915d1241c24cbba8770e6b066182c243/src/inputTracker.js#L59-L62 | train |
rafrex/react-interactive | src/notifier.js | handleNotifyNext | function handleNotifyNext(e) {
if (notifyOfNextSubs[e.type].length === 0) return;
e.persist = blankFunction;
const reNotifyOfNext = [];
const reNotifyOfNextIDs = {};
notifyOfNextSubs[e.type].forEach(sub => {
if (sub.callback(e) === 'reNotifyOfNext') {
reNotifyOfNextIDs[sub.id] = reNotifyOfNext.push(... | javascript | function handleNotifyNext(e) {
if (notifyOfNextSubs[e.type].length === 0) return;
e.persist = blankFunction;
const reNotifyOfNext = [];
const reNotifyOfNextIDs = {};
notifyOfNextSubs[e.type].forEach(sub => {
if (sub.callback(e) === 'reNotifyOfNext') {
reNotifyOfNextIDs[sub.id] = reNotifyOfNext.push(... | [
"function",
"handleNotifyNext",
"(",
"e",
")",
"{",
"if",
"(",
"notifyOfNextSubs",
"[",
"e",
".",
"type",
"]",
".",
"length",
"===",
"0",
")",
"return",
";",
"e",
".",
"persist",
"=",
"blankFunction",
";",
"const",
"reNotifyOfNext",
"=",
"[",
"]",
";",... | notify next when event comes, if the callback returns 'reNotifyOfNext', then re-subscribe using the same id | [
"notify",
"next",
"when",
"event",
"comes",
"if",
"the",
"callback",
"returns",
"reNotifyOfNext",
"then",
"re",
"-",
"subscribe",
"using",
"the",
"same",
"id"
] | 65b802b7915d1241c24cbba8770e6b066182c243 | https://github.com/rafrex/react-interactive/blob/65b802b7915d1241c24cbba8770e6b066182c243/src/notifier.js#L74-L86 | train |
rafrex/react-interactive | src/notifier.js | setupEvent | function setupEvent(element, eType, handler, capture) {
notifyOfNextSubs[eType] = [];
subsIDs[eType] = {};
element.addEventListener(
eType,
handler,
passiveEventSupport
? {
capture,
// don't set click listener as passive because syntheticClick may call preventDefault
... | javascript | function setupEvent(element, eType, handler, capture) {
notifyOfNextSubs[eType] = [];
subsIDs[eType] = {};
element.addEventListener(
eType,
handler,
passiveEventSupport
? {
capture,
// don't set click listener as passive because syntheticClick may call preventDefault
... | [
"function",
"setupEvent",
"(",
"element",
",",
"eType",
",",
"handler",
",",
"capture",
")",
"{",
"notifyOfNextSubs",
"[",
"eType",
"]",
"=",
"[",
"]",
";",
"subsIDs",
"[",
"eType",
"]",
"=",
"{",
"}",
";",
"element",
".",
"addEventListener",
"(",
"eTy... | setup event listeners and notification system for events | [
"setup",
"event",
"listeners",
"and",
"notification",
"system",
"for",
"events"
] | 65b802b7915d1241c24cbba8770e6b066182c243 | https://github.com/rafrex/react-interactive/blob/65b802b7915d1241c24cbba8770e6b066182c243/src/notifier.js#L94-L108 | train |
tkalfigo/dotenvenc | index.js | exists | function exists(fileOrDir) {
let stats;
try {
stats = statSync(fileOrDir);
return stats.isFile() || stats.isDirectory();
} catch (err) {
return false;
}
} | javascript | function exists(fileOrDir) {
let stats;
try {
stats = statSync(fileOrDir);
return stats.isFile() || stats.isDirectory();
} catch (err) {
return false;
}
} | [
"function",
"exists",
"(",
"fileOrDir",
")",
"{",
"let",
"stats",
";",
"try",
"{",
"stats",
"=",
"statSync",
"(",
"fileOrDir",
")",
";",
"return",
"stats",
".",
"isFile",
"(",
")",
"||",
"stats",
".",
"isDirectory",
"(",
")",
";",
"}",
"catch",
"(",
... | Checks if a file or directory exists
@param {String} fileOrDir name of file or directory
@returns {Boolean} if @fileOrDir exists and is readable file or directory | [
"Checks",
"if",
"a",
"file",
"or",
"directory",
"exists"
] | 1ebb0de439fa274b049029d79e02e1587be0f021 | https://github.com/tkalfigo/dotenvenc/blob/1ebb0de439fa274b049029d79e02e1587be0f021/index.js#L17-L25 | train |
tkalfigo/dotenvenc | index.js | findFileLocation | function findFileLocation(file) {
let location = './';
while (true) {
if (exists(location + file)) {
break;
} else if (exists(location + 'package.json') || location === '/') {
// Assumption is that reaching the app root folder or the system '/' marks the end of the search
throw new Error(`... | javascript | function findFileLocation(file) {
let location = './';
while (true) {
if (exists(location + file)) {
break;
} else if (exists(location + 'package.json') || location === '/') {
// Assumption is that reaching the app root folder or the system '/' marks the end of the search
throw new Error(`... | [
"function",
"findFileLocation",
"(",
"file",
")",
"{",
"let",
"location",
"=",
"'./'",
";",
"while",
"(",
"true",
")",
"{",
"if",
"(",
"exists",
"(",
"location",
"+",
"file",
")",
")",
"{",
"break",
";",
"}",
"else",
"if",
"(",
"exists",
"(",
"loca... | Goes up folder hierarchy looking for encrypted file; search stops when either root folder or folder with 'package.json' is reached
@param {String} file the file to look for
@returns {String} the full pathname of passed @file or throws error if not found | [
"Goes",
"up",
"folder",
"hierarchy",
"looking",
"for",
"encrypted",
"file",
";",
"search",
"stops",
"when",
"either",
"root",
"folder",
"or",
"folder",
"with",
"package",
".",
"json",
"is",
"reached"
] | 1ebb0de439fa274b049029d79e02e1587be0f021 | https://github.com/tkalfigo/dotenvenc/blob/1ebb0de439fa274b049029d79e02e1587be0f021/index.js#L32-L45 | train |
mathiasvr/audio-oscilloscope | examples/custom.js | drawLoop | function drawLoop () {
ctx.clearRect(0, 0, canvas.width, canvas.height)
var centerX = canvas.width / 2
var centerY = canvas.height / 2
// draw circle
ctx.beginPath()
ctx.arc(centerX, centerY, 100, 0, 2 * Math.PI, false)
ctx.fillStyle = 'yellow'
ctx.fill()
// draw three oscilloscopes in different po... | javascript | function drawLoop () {
ctx.clearRect(0, 0, canvas.width, canvas.height)
var centerX = canvas.width / 2
var centerY = canvas.height / 2
// draw circle
ctx.beginPath()
ctx.arc(centerX, centerY, 100, 0, 2 * Math.PI, false)
ctx.fillStyle = 'yellow'
ctx.fill()
// draw three oscilloscopes in different po... | [
"function",
"drawLoop",
"(",
")",
"{",
"ctx",
".",
"clearRect",
"(",
"0",
",",
"0",
",",
"canvas",
".",
"width",
",",
"canvas",
".",
"height",
")",
"var",
"centerX",
"=",
"canvas",
".",
"width",
"/",
"2",
"var",
"centerY",
"=",
"canvas",
".",
"heig... | custom animation loop | [
"custom",
"animation",
"loop"
] | c93a6d3237dc2c13d4e5415e55136f9223b7dfc4 | https://github.com/mathiasvr/audio-oscilloscope/blob/c93a6d3237dc2c13d4e5415e55136f9223b7dfc4/examples/custom.js#L30-L53 | train |
chinedufn/collada-dae-parser | demo/animated-model/animate/animation-target.js | ToggleAnimation | function ToggleAnimation (AppState) {
var state = AppState.get()
if (
state.currentAnimation[0] === animationDictionary.bend[0] &&
state.currentAnimation[1] === animationDictionary.bend[1]
) {
state.currentAnimation = animationDictionary.jump
} else {
state.currentAnimation = animationDictionary... | javascript | function ToggleAnimation (AppState) {
var state = AppState.get()
if (
state.currentAnimation[0] === animationDictionary.bend[0] &&
state.currentAnimation[1] === animationDictionary.bend[1]
) {
state.currentAnimation = animationDictionary.jump
} else {
state.currentAnimation = animationDictionary... | [
"function",
"ToggleAnimation",
"(",
"AppState",
")",
"{",
"var",
"state",
"=",
"AppState",
".",
"get",
"(",
")",
"if",
"(",
"state",
".",
"currentAnimation",
"[",
"0",
"]",
"===",
"animationDictionary",
".",
"bend",
"[",
"0",
"]",
"&&",
"state",
".",
"... | We have two animations This switches from one animation to the other | [
"We",
"have",
"two",
"animations",
"This",
"switches",
"from",
"one",
"animation",
"to",
"the",
"other"
] | b7f0c69bfc0b96e82a2c5b548d8b8fa73109b35e | https://github.com/chinedufn/collada-dae-parser/blob/b7f0c69bfc0b96e82a2c5b548d8b8fa73109b35e/demo/animated-model/animate/animation-target.js#L19-L31 | train |
chinedufn/collada-dae-parser | src/parse-collada.js | compactXML | function compactXML (res, xml) {
var txt = Object.keys(xml.attributes).length === 0 && xml.children.length === 0
var r = {}
if (!res[xml.name]) res[xml.name] = []
if (txt) {
r = xml.content || ''
} else {
r.$ = xml.attributes
r._ = xml.content || ''
xml.children.forEach(function (ch) {
c... | javascript | function compactXML (res, xml) {
var txt = Object.keys(xml.attributes).length === 0 && xml.children.length === 0
var r = {}
if (!res[xml.name]) res[xml.name] = []
if (txt) {
r = xml.content || ''
} else {
r.$ = xml.attributes
r._ = xml.content || ''
xml.children.forEach(function (ch) {
c... | [
"function",
"compactXML",
"(",
"res",
",",
"xml",
")",
"{",
"var",
"txt",
"=",
"Object",
".",
"keys",
"(",
"xml",
".",
"attributes",
")",
".",
"length",
"===",
"0",
"&&",
"xml",
".",
"children",
".",
"length",
"===",
"0",
"var",
"r",
"=",
"{",
"}... | We used to use a different XML parsing library. This recursively transforms
the data that we get from our new XML parser to match the old one. This is a
stopgap measure until we get around to changing the keys that we look while we parse to
the keys that the new parser expects | [
"We",
"used",
"to",
"use",
"a",
"different",
"XML",
"parsing",
"library",
".",
"This",
"recursively",
"transforms",
"the",
"data",
"that",
"we",
"get",
"from",
"our",
"new",
"XML",
"parser",
"to",
"match",
"the",
"old",
"one",
".",
"This",
"is",
"a",
"... | b7f0c69bfc0b96e82a2c5b548d8b8fa73109b35e | https://github.com/chinedufn/collada-dae-parser/blob/b7f0c69bfc0b96e82a2c5b548d8b8fa73109b35e/src/parse-collada.js#L88-L103 | train |
chinedufn/collada-dae-parser | src/library_visual_scenes/parse-visual-scenes.js | parseJoints | function parseJoints (node, parentJointName, accumulator) {
accumulator = accumulator || {}
node.forEach(function (joint) {
accumulator[joint.$.sid] = accumulator[joint.$.sid] || {}
// The bind pose of the matrix. We don't make use of this right now, but you would
// use it to render a model in bind pos... | javascript | function parseJoints (node, parentJointName, accumulator) {
accumulator = accumulator || {}
node.forEach(function (joint) {
accumulator[joint.$.sid] = accumulator[joint.$.sid] || {}
// The bind pose of the matrix. We don't make use of this right now, but you would
// use it to render a model in bind pos... | [
"function",
"parseJoints",
"(",
"node",
",",
"parentJointName",
",",
"accumulator",
")",
"{",
"accumulator",
"=",
"accumulator",
"||",
"{",
"}",
"node",
".",
"forEach",
"(",
"function",
"(",
"joint",
")",
"{",
"accumulator",
"[",
"joint",
".",
"$",
".",
... | Recursively parse child joints | [
"Recursively",
"parse",
"child",
"joints"
] | b7f0c69bfc0b96e82a2c5b548d8b8fa73109b35e | https://github.com/chinedufn/collada-dae-parser/blob/b7f0c69bfc0b96e82a2c5b548d8b8fa73109b35e/src/library_visual_scenes/parse-visual-scenes.js#L34-L49 | train |
WebReflection/workway | node/index.js | createSandbox | function createSandbox(filename, socket) {
var self = new EventEmitter;
var listeners = new WeakMap;
self.addEventListener = function (type, listener) {
if (!listeners.has(listener)) {
var facade = function (event) {
if (!event.canceled) listener.apply(this, arguments);
};
listeners.... | javascript | function createSandbox(filename, socket) {
var self = new EventEmitter;
var listeners = new WeakMap;
self.addEventListener = function (type, listener) {
if (!listeners.has(listener)) {
var facade = function (event) {
if (!event.canceled) listener.apply(this, arguments);
};
listeners.... | [
"function",
"createSandbox",
"(",
"filename",
",",
"socket",
")",
"{",
"var",
"self",
"=",
"new",
"EventEmitter",
";",
"var",
"listeners",
"=",
"new",
"WeakMap",
";",
"self",
".",
"addEventListener",
"=",
"function",
"(",
"type",
",",
"listener",
")",
"{",... | return a new Worker sandbox | [
"return",
"a",
"new",
"Worker",
"sandbox"
] | 0f1c33b5e95b714b54d72f97cba1bfbac03a62cc | https://github.com/WebReflection/workway/blob/0f1c33b5e95b714b54d72f97cba1bfbac03a62cc/node/index.js#L38-L79 | train |
WebReflection/workway | node/index.js | error | function error(socket, err) {
socket.emit(SECRET + ':error', {
message: err.message,
stack: cleanedStack(err.stack)
});
} | javascript | function error(socket, err) {
socket.emit(SECRET + ':error', {
message: err.message,
stack: cleanedStack(err.stack)
});
} | [
"function",
"error",
"(",
"socket",
",",
"err",
")",
"{",
"socket",
".",
"emit",
"(",
"SECRET",
"+",
"':error'",
",",
"{",
"message",
":",
"err",
".",
"message",
",",
"stack",
":",
"cleanedStack",
"(",
"err",
".",
"stack",
")",
"}",
")",
";",
"}"
] | notify the socket there was an error | [
"notify",
"the",
"socket",
"there",
"was",
"an",
"error"
] | 0f1c33b5e95b714b54d72f97cba1bfbac03a62cc | https://github.com/WebReflection/workway/blob/0f1c33b5e95b714b54d72f97cba1bfbac03a62cc/node/index.js#L86-L91 | train |
nowa-webpack/nowa | src/index.js | findPluginPath | function findPluginPath(command) {
if (command && /^\w+$/.test(command)) {
try {
return resolve.sync('nowa-' + command, {
paths: moduleDirs
});
} catch (e) {
console.log('');
console.log(' ' + chalk.green.bold(command) + ' command is not installed.');
console.log(' You ... | javascript | function findPluginPath(command) {
if (command && /^\w+$/.test(command)) {
try {
return resolve.sync('nowa-' + command, {
paths: moduleDirs
});
} catch (e) {
console.log('');
console.log(' ' + chalk.green.bold(command) + ' command is not installed.');
console.log(' You ... | [
"function",
"findPluginPath",
"(",
"command",
")",
"{",
"if",
"(",
"command",
"&&",
"/",
"^\\w+$",
"/",
".",
"test",
"(",
"command",
")",
")",
"{",
"try",
"{",
"return",
"resolve",
".",
"sync",
"(",
"'nowa-'",
"+",
"command",
",",
"{",
"paths",
":",
... | locate the plugin by command | [
"locate",
"the",
"plugin",
"by",
"command"
] | 8da38f00b925f892da385205384835474cf82c86 | https://github.com/nowa-webpack/nowa/blob/8da38f00b925f892da385205384835474cf82c86/src/index.js#L137-L150 | train |
nowa-webpack/nowa | src/index.js | loadDefaultOpts | function loadDefaultOpts(startDir, configFile) {
try {
return require(path.join(startDir, configFile)).options || {};
} catch (e) {
var dir = path.dirname(startDir);
if (dir === startDir) {
return {};
}
return loadDefaultOpts(dir, configFile);
}
} | javascript | function loadDefaultOpts(startDir, configFile) {
try {
return require(path.join(startDir, configFile)).options || {};
} catch (e) {
var dir = path.dirname(startDir);
if (dir === startDir) {
return {};
}
return loadDefaultOpts(dir, configFile);
}
} | [
"function",
"loadDefaultOpts",
"(",
"startDir",
",",
"configFile",
")",
"{",
"try",
"{",
"return",
"require",
"(",
"path",
".",
"join",
"(",
"startDir",
",",
"configFile",
")",
")",
".",
"options",
"||",
"{",
"}",
";",
"}",
"catch",
"(",
"e",
")",
"{... | load default options | [
"load",
"default",
"options"
] | 8da38f00b925f892da385205384835474cf82c86 | https://github.com/nowa-webpack/nowa/blob/8da38f00b925f892da385205384835474cf82c86/src/index.js#L153-L163 | train |
jsdoc2md/jsdoc-api | index.js | explainSync | function explainSync (options) {
options = new JsdocOptions(options)
const ExplainSync = require('./lib/explain-sync')
const command = new ExplainSync(options, exports.cache)
return command.execute()
} | javascript | function explainSync (options) {
options = new JsdocOptions(options)
const ExplainSync = require('./lib/explain-sync')
const command = new ExplainSync(options, exports.cache)
return command.execute()
} | [
"function",
"explainSync",
"(",
"options",
")",
"{",
"options",
"=",
"new",
"JsdocOptions",
"(",
"options",
")",
"const",
"ExplainSync",
"=",
"require",
"(",
"'./lib/explain-sync'",
")",
"const",
"command",
"=",
"new",
"ExplainSync",
"(",
"options",
",",
"expo... | Returns jsdoc explain output.
@param [options] {module:jsdoc-api~JsdocOptions}
@returns {object[]}
@static
@prerequisite Requires node v0.12 or above | [
"Returns",
"jsdoc",
"explain",
"output",
"."
] | 2cd5096c8b7db5d825e296204c30ca795ff0e0b2 | https://github.com/jsdoc2md/jsdoc-api/blob/2cd5096c8b7db5d825e296204c30ca795ff0e0b2/index.js#L27-L32 | train |
jsdoc2md/jsdoc-api | index.js | explain | function explain (options) {
options = new JsdocOptions(options)
const Explain = require('./lib/explain')
const command = new Explain(options, exports.cache)
return command.execute()
} | javascript | function explain (options) {
options = new JsdocOptions(options)
const Explain = require('./lib/explain')
const command = new Explain(options, exports.cache)
return command.execute()
} | [
"function",
"explain",
"(",
"options",
")",
"{",
"options",
"=",
"new",
"JsdocOptions",
"(",
"options",
")",
"const",
"Explain",
"=",
"require",
"(",
"'./lib/explain'",
")",
"const",
"command",
"=",
"new",
"Explain",
"(",
"options",
",",
"exports",
".",
"c... | Returns a promise for the jsdoc explain output.
@param [options] {module:jsdoc-api~JsdocOptions}
@fulfil {object[]} - jsdoc explain output
@returns {Promise}
@static | [
"Returns",
"a",
"promise",
"for",
"the",
"jsdoc",
"explain",
"output",
"."
] | 2cd5096c8b7db5d825e296204c30ca795ff0e0b2 | https://github.com/jsdoc2md/jsdoc-api/blob/2cd5096c8b7db5d825e296204c30ca795ff0e0b2/index.js#L42-L47 | train |
jsdoc2md/jsdoc-api | index.js | renderSync | function renderSync (options) {
options = new JsdocOptions(options)
const RenderSync = require('./lib/render-sync')
const command = new RenderSync(options)
return command.execute()
} | javascript | function renderSync (options) {
options = new JsdocOptions(options)
const RenderSync = require('./lib/render-sync')
const command = new RenderSync(options)
return command.execute()
} | [
"function",
"renderSync",
"(",
"options",
")",
"{",
"options",
"=",
"new",
"JsdocOptions",
"(",
"options",
")",
"const",
"RenderSync",
"=",
"require",
"(",
"'./lib/render-sync'",
")",
"const",
"command",
"=",
"new",
"RenderSync",
"(",
"options",
")",
"return",... | Render jsdoc documentation.
@param [options] {module:jsdoc-api~JsdocOptions}
@prerequisite Requires node v0.12 or above
@static
@example
jsdoc.renderSync({ files: 'lib/*', destination: 'api-docs' }) | [
"Render",
"jsdoc",
"documentation",
"."
] | 2cd5096c8b7db5d825e296204c30ca795ff0e0b2 | https://github.com/jsdoc2md/jsdoc-api/blob/2cd5096c8b7db5d825e296204c30ca795ff0e0b2/index.js#L58-L63 | train |
felixhagspiel/jsOnlyLightbox | js/lightbox.js | addEvent | function addEvent(el, e, callback, capture) {
if (el.addEventListener) {
el.addEventListener(e, callback, capture || false);
}
else
if (el.attachEvent) {
el.attachEvent('on' + e, callback);
}
} | javascript | function addEvent(el, e, callback, capture) {
if (el.addEventListener) {
el.addEventListener(e, callback, capture || false);
}
else
if (el.attachEvent) {
el.attachEvent('on' + e, callback);
}
} | [
"function",
"addEvent",
"(",
"el",
",",
"e",
",",
"callback",
",",
"capture",
")",
"{",
"if",
"(",
"el",
".",
"addEventListener",
")",
"{",
"el",
".",
"addEventListener",
"(",
"e",
",",
"callback",
",",
"capture",
"||",
"false",
")",
";",
"}",
"else"... | Adds eventlisteners cross browser
@param {Object} el The element which gets the listener
@param {String} e The event type
@param {Function} callback The action to execute on event
@param {Boolean} capture The capture mode | [
"Adds",
"eventlisteners",
"cross",
"browser"
] | 894dad069c6b8f7b3dac26829dfebbd80efc84fc | https://github.com/felixhagspiel/jsOnlyLightbox/blob/894dad069c6b8f7b3dac26829dfebbd80efc84fc/js/lightbox.js#L92-L100 | train |
felixhagspiel/jsOnlyLightbox | js/lightbox.js | hasClass | function hasClass(el, className) {
if (!el || !className) {
return;
}
return (new RegExp('(^|\\s)' + className + '(\\s|$)').test(el.className));
} | javascript | function hasClass(el, className) {
if (!el || !className) {
return;
}
return (new RegExp('(^|\\s)' + className + '(\\s|$)').test(el.className));
} | [
"function",
"hasClass",
"(",
"el",
",",
"className",
")",
"{",
"if",
"(",
"!",
"el",
"||",
"!",
"className",
")",
"{",
"return",
";",
"}",
"return",
"(",
"new",
"RegExp",
"(",
"'(^|\\\\s)'",
"+",
"className",
"+",
"'(\\\\s|$)'",
")",
".",
"test",
"("... | Checks if element has a specific class
@param {Object} el [description]
@param {String} className [description]
@return {Boolean} [description] | [
"Checks",
"if",
"element",
"has",
"a",
"specific",
"class"
] | 894dad069c6b8f7b3dac26829dfebbd80efc84fc | https://github.com/felixhagspiel/jsOnlyLightbox/blob/894dad069c6b8f7b3dac26829dfebbd80efc84fc/js/lightbox.js#L108-L113 | train |
felixhagspiel/jsOnlyLightbox | js/lightbox.js | removeClass | function removeClass(el, className) {
if (!el || !className) {
return;
}
el.className = el.className.replace(new RegExp('(?:^|\\s)' + className + '(?!\\S)'), '');
return el;
} | javascript | function removeClass(el, className) {
if (!el || !className) {
return;
}
el.className = el.className.replace(new RegExp('(?:^|\\s)' + className + '(?!\\S)'), '');
return el;
} | [
"function",
"removeClass",
"(",
"el",
",",
"className",
")",
"{",
"if",
"(",
"!",
"el",
"||",
"!",
"className",
")",
"{",
"return",
";",
"}",
"el",
".",
"className",
"=",
"el",
".",
"className",
".",
"replace",
"(",
"new",
"RegExp",
"(",
"'(?:^|\\\\s... | Removes class from element
@param {Object} el
@param {String} className
@return {Object} | [
"Removes",
"class",
"from",
"element"
] | 894dad069c6b8f7b3dac26829dfebbd80efc84fc | https://github.com/felixhagspiel/jsOnlyLightbox/blob/894dad069c6b8f7b3dac26829dfebbd80efc84fc/js/lightbox.js#L121-L127 | train |
felixhagspiel/jsOnlyLightbox | js/lightbox.js | getAttr | function getAttr(obj, attr) {
if (!obj || !isset(obj)) {
return false;
}
var ret;
if (obj.getAttribute) {
ret = obj.getAttribute(attr);
}
else
if (obj.getAttributeNode) {
ret = obj.getAttributeNode(attr).value;
}
if (isset(ret) && ret !== '') {
return re... | javascript | function getAttr(obj, attr) {
if (!obj || !isset(obj)) {
return false;
}
var ret;
if (obj.getAttribute) {
ret = obj.getAttribute(attr);
}
else
if (obj.getAttributeNode) {
ret = obj.getAttributeNode(attr).value;
}
if (isset(ret) && ret !== '') {
return re... | [
"function",
"getAttr",
"(",
"obj",
",",
"attr",
")",
"{",
"if",
"(",
"!",
"obj",
"||",
"!",
"isset",
"(",
"obj",
")",
")",
"{",
"return",
"false",
";",
"}",
"var",
"ret",
";",
"if",
"(",
"obj",
".",
"getAttribute",
")",
"{",
"ret",
"=",
"obj",
... | Get attribute value cross-browser. Returns the attribute as string if found,
otherwise returns false
@param {Object} obj
@param {String} attr
@return {boolean || string} | [
"Get",
"attribute",
"value",
"cross",
"-",
"browser",
".",
"Returns",
"the",
"attribute",
"as",
"string",
"if",
"found",
"otherwise",
"returns",
"false"
] | 894dad069c6b8f7b3dac26829dfebbd80efc84fc | https://github.com/felixhagspiel/jsOnlyLightbox/blob/894dad069c6b8f7b3dac26829dfebbd80efc84fc/js/lightbox.js#L162-L178 | train |
felixhagspiel/jsOnlyLightbox | js/lightbox.js | clckHlpr | function clckHlpr(i) {
addEvent(i, 'click', function (e) {
stopPropagation(e);
preventDefault(e);
currGroup = getAttr(i, _const_dataattr + '-group') || false;
currThumbnail = i;
openBox(i, false, false, false);
}, false);
} | javascript | function clckHlpr(i) {
addEvent(i, 'click', function (e) {
stopPropagation(e);
preventDefault(e);
currGroup = getAttr(i, _const_dataattr + '-group') || false;
currThumbnail = i;
openBox(i, false, false, false);
}, false);
} | [
"function",
"clckHlpr",
"(",
"i",
")",
"{",
"addEvent",
"(",
"i",
",",
"'click'",
",",
"function",
"(",
"e",
")",
"{",
"stopPropagation",
"(",
"e",
")",
";",
"preventDefault",
"(",
"e",
")",
";",
"currGroup",
"=",
"getAttr",
"(",
"i",
",",
"_const_da... | Adds clickhandlers to thumbnails
@param {Object} i | [
"Adds",
"clickhandlers",
"to",
"thumbnails"
] | 894dad069c6b8f7b3dac26829dfebbd80efc84fc | https://github.com/felixhagspiel/jsOnlyLightbox/blob/894dad069c6b8f7b3dac26829dfebbd80efc84fc/js/lightbox.js#L206-L214 | train |
felixhagspiel/jsOnlyLightbox | js/lightbox.js | getByGroup | function getByGroup(group) {
var arr = [];
for (var i = 0; i < CTX.thumbnails.length; i++) {
if (getAttr(CTX.thumbnails[i], _const_dataattr + '-group') === group) {
arr.push(CTX.thumbnails[i]);
}
}
return arr;
} | javascript | function getByGroup(group) {
var arr = [];
for (var i = 0; i < CTX.thumbnails.length; i++) {
if (getAttr(CTX.thumbnails[i], _const_dataattr + '-group') === group) {
arr.push(CTX.thumbnails[i]);
}
}
return arr;
} | [
"function",
"getByGroup",
"(",
"group",
")",
"{",
"var",
"arr",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"CTX",
".",
"thumbnails",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"getAttr",
"(",
"CTX",
".",
"th... | Get thumbnails by group
@param {String} group
@return {Object} Array containing the thumbnails | [
"Get",
"thumbnails",
"by",
"group"
] | 894dad069c6b8f7b3dac26829dfebbd80efc84fc | https://github.com/felixhagspiel/jsOnlyLightbox/blob/894dad069c6b8f7b3dac26829dfebbd80efc84fc/js/lightbox.js#L248-L256 | train |
felixhagspiel/jsOnlyLightbox | js/lightbox.js | getPos | function getPos(thumbnail, group) {
var arr = getByGroup(group);
for (var i = 0; i < arr.length; i++) {
// compare elements
if (getAttr(thumbnail, 'src') === getAttr(arr[i], 'src') &&
getAttr(thumbnail, _const_dataattr + '-index') === getAttr(arr[i], _const_dataattr + '-index') &&
ge... | javascript | function getPos(thumbnail, group) {
var arr = getByGroup(group);
for (var i = 0; i < arr.length; i++) {
// compare elements
if (getAttr(thumbnail, 'src') === getAttr(arr[i], 'src') &&
getAttr(thumbnail, _const_dataattr + '-index') === getAttr(arr[i], _const_dataattr + '-index') &&
ge... | [
"function",
"getPos",
"(",
"thumbnail",
",",
"group",
")",
"{",
"var",
"arr",
"=",
"getByGroup",
"(",
"group",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"arr",
".",
"length",
";",
"i",
"++",
")",
"{",
"// compare elements",
"if",
... | Get the position of thumbnail in group-array
@param {Object} thumbnail
@param {String} group
@return {number} | [
"Get",
"the",
"position",
"of",
"thumbnail",
"in",
"group",
"-",
"array"
] | 894dad069c6b8f7b3dac26829dfebbd80efc84fc | https://github.com/felixhagspiel/jsOnlyLightbox/blob/894dad069c6b8f7b3dac26829dfebbd80efc84fc/js/lightbox.js#L264-L275 | train |
felixhagspiel/jsOnlyLightbox | js/lightbox.js | preload | function preload() {
if (!currGroup) {
return;
}
var prev = new Image();
var next = new Image();
var pos = getPos(currThumbnail, currGroup);
if (pos === (currImages.length - 1)) {
// last image in group, preload first image and the one before
prev.src = getAttr(currImages[currI... | javascript | function preload() {
if (!currGroup) {
return;
}
var prev = new Image();
var next = new Image();
var pos = getPos(currThumbnail, currGroup);
if (pos === (currImages.length - 1)) {
// last image in group, preload first image and the one before
prev.src = getAttr(currImages[currI... | [
"function",
"preload",
"(",
")",
"{",
"if",
"(",
"!",
"currGroup",
")",
"{",
"return",
";",
"}",
"var",
"prev",
"=",
"new",
"Image",
"(",
")",
";",
"var",
"next",
"=",
"new",
"Image",
"(",
")",
";",
"var",
"pos",
"=",
"getPos",
"(",
"currThumbnai... | Preloads next and prev images | [
"Preloads",
"next",
"and",
"prev",
"images"
] | 894dad069c6b8f7b3dac26829dfebbd80efc84fc | https://github.com/felixhagspiel/jsOnlyLightbox/blob/894dad069c6b8f7b3dac26829dfebbd80efc84fc/js/lightbox.js#L280-L303 | train |
felixhagspiel/jsOnlyLightbox | js/lightbox.js | startAnimation | function startAnimation() {
if (isIE8) {
return;
}
// stop any already running animations
stopAnimation();
var fnc = function () {
addClass(CTX.box, _const_class_prefix + '-loading');
if (!isIE9 && typeof CTX.opt.loadingAnimation === 'number') {
var index = 0;
anima... | javascript | function startAnimation() {
if (isIE8) {
return;
}
// stop any already running animations
stopAnimation();
var fnc = function () {
addClass(CTX.box, _const_class_prefix + '-loading');
if (!isIE9 && typeof CTX.opt.loadingAnimation === 'number') {
var index = 0;
anima... | [
"function",
"startAnimation",
"(",
")",
"{",
"if",
"(",
"isIE8",
")",
"{",
"return",
";",
"}",
"// stop any already running animations",
"stopAnimation",
"(",
")",
";",
"var",
"fnc",
"=",
"function",
"(",
")",
"{",
"addClass",
"(",
"CTX",
".",
"box",
",",
... | Starts the loading animation | [
"Starts",
"the",
"loading",
"animation"
] | 894dad069c6b8f7b3dac26829dfebbd80efc84fc | https://github.com/felixhagspiel/jsOnlyLightbox/blob/894dad069c6b8f7b3dac26829dfebbd80efc84fc/js/lightbox.js#L308-L329 | train |
felixhagspiel/jsOnlyLightbox | js/lightbox.js | stopAnimation | function stopAnimation() {
if (isIE8) {
return;
}
// hide animation-element
removeClass(CTX.box, _const_class_prefix + '-loading');
// stop animation
if (!isIE9 && typeof CTX.opt.loadingAnimation !== 'string' && CTX.opt.loadingAnimation) {
clearInterval(animationInt);
// do not... | javascript | function stopAnimation() {
if (isIE8) {
return;
}
// hide animation-element
removeClass(CTX.box, _const_class_prefix + '-loading');
// stop animation
if (!isIE9 && typeof CTX.opt.loadingAnimation !== 'string' && CTX.opt.loadingAnimation) {
clearInterval(animationInt);
// do not... | [
"function",
"stopAnimation",
"(",
")",
"{",
"if",
"(",
"isIE8",
")",
"{",
"return",
";",
"}",
"// hide animation-element",
"removeClass",
"(",
"CTX",
".",
"box",
",",
"_const_class_prefix",
"+",
"'-loading'",
")",
";",
"// stop animation",
"if",
"(",
"!",
"i... | Stops the animation | [
"Stops",
"the",
"animation"
] | 894dad069c6b8f7b3dac26829dfebbd80efc84fc | https://github.com/felixhagspiel/jsOnlyLightbox/blob/894dad069c6b8f7b3dac26829dfebbd80efc84fc/js/lightbox.js#L334-L348 | train |
felixhagspiel/jsOnlyLightbox | js/lightbox.js | initControls | function initControls() {
if (!nextBtn) {
// create & append next-btn
nextBtn = document.createElement('span');
addClass(nextBtn, _const_class_prefix + '-next');
// add custom images
if (CTX.opt.nextImg) {
var nextBtnImg = document.createElement('img');
nextBtnIm... | javascript | function initControls() {
if (!nextBtn) {
// create & append next-btn
nextBtn = document.createElement('span');
addClass(nextBtn, _const_class_prefix + '-next');
// add custom images
if (CTX.opt.nextImg) {
var nextBtnImg = document.createElement('img');
nextBtnIm... | [
"function",
"initControls",
"(",
")",
"{",
"if",
"(",
"!",
"nextBtn",
")",
"{",
"// create & append next-btn",
"nextBtn",
"=",
"document",
".",
"createElement",
"(",
"'span'",
")",
";",
"addClass",
"(",
"nextBtn",
",",
"_const_class_prefix",
"+",
"'-next'",
")... | Initializes the control arrows | [
"Initializes",
"the",
"control",
"arrows"
] | 894dad069c6b8f7b3dac26829dfebbd80efc84fc | https://github.com/felixhagspiel/jsOnlyLightbox/blob/894dad069c6b8f7b3dac26829dfebbd80efc84fc/js/lightbox.js#L353-L396 | train |
felixhagspiel/jsOnlyLightbox | js/lightbox.js | repositionControls | function repositionControls() {
if (CTX.opt.responsive && nextBtn && prevBtn) {
var btnTop = (getHeight() / 2) - (nextBtn.offsetHeight / 2);
nextBtn.style.top = btnTop + 'px';
prevBtn.style.top = btnTop + 'px';
}
} | javascript | function repositionControls() {
if (CTX.opt.responsive && nextBtn && prevBtn) {
var btnTop = (getHeight() / 2) - (nextBtn.offsetHeight / 2);
nextBtn.style.top = btnTop + 'px';
prevBtn.style.top = btnTop + 'px';
}
} | [
"function",
"repositionControls",
"(",
")",
"{",
"if",
"(",
"CTX",
".",
"opt",
".",
"responsive",
"&&",
"nextBtn",
"&&",
"prevBtn",
")",
"{",
"var",
"btnTop",
"=",
"(",
"getHeight",
"(",
")",
"/",
"2",
")",
"-",
"(",
"nextBtn",
".",
"offsetHeight",
"... | Moves controls to correct position | [
"Moves",
"controls",
"to",
"correct",
"position"
] | 894dad069c6b8f7b3dac26829dfebbd80efc84fc | https://github.com/felixhagspiel/jsOnlyLightbox/blob/894dad069c6b8f7b3dac26829dfebbd80efc84fc/js/lightbox.js#L401-L407 | train |
VFK/gulp-html-replace | lib/common.js | resolveSrcString | function resolveSrcString(srcProperty) {
if (Array.isArray(srcProperty)) {
// handle multiple tag replacement
return Promise.all(srcProperty.map(function (item) {
return resolveSrcString(item);
}));
} else if (isStream(srcProperty)) {
return new Promise(function (reso... | javascript | function resolveSrcString(srcProperty) {
if (Array.isArray(srcProperty)) {
// handle multiple tag replacement
return Promise.all(srcProperty.map(function (item) {
return resolveSrcString(item);
}));
} else if (isStream(srcProperty)) {
return new Promise(function (reso... | [
"function",
"resolveSrcString",
"(",
"srcProperty",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"srcProperty",
")",
")",
"{",
"// handle multiple tag replacement",
"return",
"Promise",
".",
"all",
"(",
"srcProperty",
".",
"map",
"(",
"function",
"(",
"i... | Takes the src property of the task configuration and deeply "resolves" any vinyl file stream in it by turning
it into a string.
This function doesn't change the "arborescence" of the given value: all the forms with strings accepted
work with vinyl file streams.
@returns {Promise} | [
"Takes",
"the",
"src",
"property",
"of",
"the",
"task",
"configuration",
"and",
"deeply",
"resolves",
"any",
"vinyl",
"file",
"stream",
"in",
"it",
"by",
"turning",
"it",
"into",
"a",
"string",
"."
] | 4b99045040b3fbf79a2702a64276ec78a2e2b771 | https://github.com/VFK/gulp-html-replace/blob/4b99045040b3fbf79a2702a64276ec78a2e2b771/lib/common.js#L19-L44 | train |
datavis-tech/json-templates | index.js | type | function type(value) {
let valueType = typeof value;
if (Array.isArray(value)) {
valueType = 'array';
} else if (value instanceof Date) {
valueType = 'date';
} else if (value === null) {
valueType = 'null';
}
return valueType;
} | javascript | function type(value) {
let valueType = typeof value;
if (Array.isArray(value)) {
valueType = 'array';
} else if (value instanceof Date) {
valueType = 'date';
} else if (value === null) {
valueType = 'null';
}
return valueType;
} | [
"function",
"type",
"(",
"value",
")",
"{",
"let",
"valueType",
"=",
"typeof",
"value",
";",
"if",
"(",
"Array",
".",
"isArray",
"(",
"value",
")",
")",
"{",
"valueType",
"=",
"'array'",
";",
"}",
"else",
"if",
"(",
"value",
"instanceof",
"Date",
")"... | An enhanced version of `typeof` that handles arrays and dates as well. | [
"An",
"enhanced",
"version",
"of",
"typeof",
"that",
"handles",
"arrays",
"and",
"dates",
"as",
"well",
"."
] | d9cd78e71bdc8f189dba70ebdfc89093388ce05a | https://github.com/datavis-tech/json-templates/blob/d9cd78e71bdc8f189dba70ebdfc89093388ce05a/index.js#L10-L21 | train |
datavis-tech/json-templates | index.js | Template | function Template(fn, parameters) {
// Paul Brewer Dec 2017 add deduplication call, use only key property to eliminate
Object.assign(fn, {
parameters: dedupe(parameters, item => item.key)
});
return fn;
} | javascript | function Template(fn, parameters) {
// Paul Brewer Dec 2017 add deduplication call, use only key property to eliminate
Object.assign(fn, {
parameters: dedupe(parameters, item => item.key)
});
return fn;
} | [
"function",
"Template",
"(",
"fn",
",",
"parameters",
")",
"{",
"// Paul Brewer Dec 2017 add deduplication call, use only key property to eliminate",
"Object",
".",
"assign",
"(",
"fn",
",",
"{",
"parameters",
":",
"dedupe",
"(",
"parameters",
",",
"item",
"=>",
"item... | Constructs a template function with deduped `parameters` property. | [
"Constructs",
"a",
"template",
"function",
"with",
"deduped",
"parameters",
"property",
"."
] | d9cd78e71bdc8f189dba70ebdfc89093388ce05a | https://github.com/datavis-tech/json-templates/blob/d9cd78e71bdc8f189dba70ebdfc89093388ce05a/index.js#L44-L51 | train |
datavis-tech/json-templates | index.js | parseObject | function parseObject(object) {
const children = Object.keys(object).map(key => ({
keyTemplate: parseString(key),
valueTemplate: parse(object[key])
}));
const templateParameters = children.reduce(
(parameters, child) =>
parameters.concat(child.valueTemplate.parameters, child.keyTemplate.parameter... | javascript | function parseObject(object) {
const children = Object.keys(object).map(key => ({
keyTemplate: parseString(key),
valueTemplate: parse(object[key])
}));
const templateParameters = children.reduce(
(parameters, child) =>
parameters.concat(child.valueTemplate.parameters, child.keyTemplate.parameter... | [
"function",
"parseObject",
"(",
"object",
")",
"{",
"const",
"children",
"=",
"Object",
".",
"keys",
"(",
"object",
")",
".",
"map",
"(",
"key",
"=>",
"(",
"{",
"keyTemplate",
":",
"parseString",
"(",
"key",
")",
",",
"valueTemplate",
":",
"parse",
"("... | Parses non-leaf-nodes in the template object that are objects. | [
"Parses",
"non",
"-",
"leaf",
"-",
"nodes",
"in",
"the",
"template",
"object",
"that",
"are",
"objects",
"."
] | d9cd78e71bdc8f189dba70ebdfc89093388ce05a | https://github.com/datavis-tech/json-templates/blob/d9cd78e71bdc8f189dba70ebdfc89093388ce05a/index.js#L117-L135 | train |
datavis-tech/json-templates | index.js | parseArray | function parseArray(array) {
const templates = array.map(parse);
const templateParameters = templates.reduce(
(parameters, template) => parameters.concat(template.parameters),
[]
);
const templateFn = context => templates.map(template => template(context));
return Template(templateFn, templateParamet... | javascript | function parseArray(array) {
const templates = array.map(parse);
const templateParameters = templates.reduce(
(parameters, template) => parameters.concat(template.parameters),
[]
);
const templateFn = context => templates.map(template => template(context));
return Template(templateFn, templateParamet... | [
"function",
"parseArray",
"(",
"array",
")",
"{",
"const",
"templates",
"=",
"array",
".",
"map",
"(",
"parse",
")",
";",
"const",
"templateParameters",
"=",
"templates",
".",
"reduce",
"(",
"(",
"parameters",
",",
"template",
")",
"=>",
"parameters",
".",... | Parses non-leaf-nodes in the template object that are arrays. | [
"Parses",
"non",
"-",
"leaf",
"-",
"nodes",
"in",
"the",
"template",
"object",
"that",
"are",
"arrays",
"."
] | d9cd78e71bdc8f189dba70ebdfc89093388ce05a | https://github.com/datavis-tech/json-templates/blob/d9cd78e71bdc8f189dba70ebdfc89093388ce05a/index.js#L138-L147 | train |
mkloubert/node-simple-socket | helpers.js | asBuffer | function asBuffer(data, encoding) {
let result = data;
if (!isNullOrUndefined(result)) {
if ('object' !== typeof result) {
// handle as string
encoding = normalizeString(encoding);
if (!encoding) {
encoding = 'utf8';
}
... | javascript | function asBuffer(data, encoding) {
let result = data;
if (!isNullOrUndefined(result)) {
if ('object' !== typeof result) {
// handle as string
encoding = normalizeString(encoding);
if (!encoding) {
encoding = 'utf8';
}
... | [
"function",
"asBuffer",
"(",
"data",
",",
"encoding",
")",
"{",
"let",
"result",
"=",
"data",
";",
"if",
"(",
"!",
"isNullOrUndefined",
"(",
"result",
")",
")",
"{",
"if",
"(",
"'object'",
"!==",
"typeof",
"result",
")",
"{",
"// handle as string\r",
"en... | Returns data as buffer.
@param {any} data The input data.
@param {string} [encoding] The custom encoding to use if 'data' is NOT a buffer.
@return {Buffer} The output data. | [
"Returns",
"data",
"as",
"buffer",
"."
] | a673f1987cd6d16f76c218c0a6a98723c42a12ce | https://github.com/mkloubert/node-simple-socket/blob/a673f1987cd6d16f76c218c0a6a98723c42a12ce/helpers.js#L11-L24 | train |
mkloubert/node-simple-socket | helpers.js | createSimplePromiseCompletedAction | function createSimplePromiseCompletedAction(resolve, reject) {
return (err, result) => {
if (err) {
if (reject) {
reject(err);
}
}
else {
if (resolve) {
resolve(result);
}
}
};
} | javascript | function createSimplePromiseCompletedAction(resolve, reject) {
return (err, result) => {
if (err) {
if (reject) {
reject(err);
}
}
else {
if (resolve) {
resolve(result);
}
}
};
} | [
"function",
"createSimplePromiseCompletedAction",
"(",
"resolve",
",",
"reject",
")",
"{",
"return",
"(",
"err",
",",
"result",
")",
"=>",
"{",
"if",
"(",
"err",
")",
"{",
"if",
"(",
"reject",
")",
"{",
"reject",
"(",
"err",
")",
";",
"}",
"}",
"else... | Creates a simple 'completed' callback for a promise.
@param {Function} resolve The 'succeeded' callback.
@param {Function} reject The 'error' callback.
@return {SimpleCompletedAction<TResult>} The created action. | [
"Creates",
"a",
"simple",
"completed",
"callback",
"for",
"a",
"promise",
"."
] | a673f1987cd6d16f76c218c0a6a98723c42a12ce | https://github.com/mkloubert/node-simple-socket/blob/a673f1987cd6d16f76c218c0a6a98723c42a12ce/helpers.js#L34-L47 | train |
mkloubert/node-simple-socket | helpers.js | normalizeString | function normalizeString(val, normalizer) {
if (!normalizer) {
normalizer = (str) => str.toLowerCase().trim();
}
return normalizer(toStringSafe(val));
} | javascript | function normalizeString(val, normalizer) {
if (!normalizer) {
normalizer = (str) => str.toLowerCase().trim();
}
return normalizer(toStringSafe(val));
} | [
"function",
"normalizeString",
"(",
"val",
",",
"normalizer",
")",
"{",
"if",
"(",
"!",
"normalizer",
")",
"{",
"normalizer",
"=",
"(",
"str",
")",
"=>",
"str",
".",
"toLowerCase",
"(",
")",
".",
"trim",
"(",
")",
";",
"}",
"return",
"normalizer",
"(... | Normalizes a value as string so that is comparable.
@param {any} val The value to convert.
@param {(str: string) => string} [normalizer] The custom normalizer.
@return {string} The normalized value. | [
"Normalizes",
"a",
"value",
"as",
"string",
"so",
"that",
"is",
"comparable",
"."
] | a673f1987cd6d16f76c218c0a6a98723c42a12ce | https://github.com/mkloubert/node-simple-socket/blob/a673f1987cd6d16f76c218c0a6a98723c42a12ce/helpers.js#L81-L86 | train |
mkloubert/node-simple-socket | helpers.js | readSocket | function readSocket(socket, numberOfBytes) {
return new Promise((resolve, reject) => {
let completed = createSimplePromiseCompletedAction(resolve, reject);
try {
let buff = socket.read(numberOfBytes);
if (null === buff) {
socket.once('readable', function... | javascript | function readSocket(socket, numberOfBytes) {
return new Promise((resolve, reject) => {
let completed = createSimplePromiseCompletedAction(resolve, reject);
try {
let buff = socket.read(numberOfBytes);
if (null === buff) {
socket.once('readable', function... | [
"function",
"readSocket",
"(",
"socket",
",",
"numberOfBytes",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"let",
"completed",
"=",
"createSimplePromiseCompletedAction",
"(",
"resolve",
",",
"reject",
")",
";",
"... | Reads a number of bytes from a socket.
@param {net.Socket} socket The socket.
@param {Number} [numberOfBytes] The amount of bytes to read.
@return {Promise<Buffer>} The promise. | [
"Reads",
"a",
"number",
"of",
"bytes",
"from",
"a",
"socket",
"."
] | a673f1987cd6d16f76c218c0a6a98723c42a12ce | https://github.com/mkloubert/node-simple-socket/blob/a673f1987cd6d16f76c218c0a6a98723c42a12ce/helpers.js#L96-L118 | train |
mkloubert/node-simple-socket | index.js | listen | function listen(port, cb) {
return new Promise((resolve, reject) => {
let completed = ssocket_helpers.createSimplePromiseCompletedAction(resolve, reject);
try {
let serverToClient;
let server = Net.createServer((connectionWithClient) => {
try {
... | javascript | function listen(port, cb) {
return new Promise((resolve, reject) => {
let completed = ssocket_helpers.createSimplePromiseCompletedAction(resolve, reject);
try {
let serverToClient;
let server = Net.createServer((connectionWithClient) => {
try {
... | [
"function",
"listen",
"(",
"port",
",",
"cb",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"let",
"completed",
"=",
"ssocket_helpers",
".",
"createSimplePromiseCompletedAction",
"(",
"resolve",
",",
"reject",
")",... | Starts listening on a port.
@param {number} port The TCP port to listen on.
@param {ListenCallback} cb The listener callback.
@return {Promise<Net.Server>} The promise. | [
"Starts",
"listening",
"on",
"a",
"port",
"."
] | a673f1987cd6d16f76c218c0a6a98723c42a12ce | https://github.com/mkloubert/node-simple-socket/blob/a673f1987cd6d16f76c218c0a6a98723c42a12ce/index.js#L1253-L1286 | train |
octet-stream/node-yaml | lib/node-yaml.js | read | async function read(filename, options = undefined) {
const {encoding, flag, ...opts} = normalizeOptions(options)
if (!isNumber(filename)) {
filename = await normalizePath(base, filename)
opts.filename = filename
}
const content = await fs.readFile(filename, {encoding, flag})
return yaml.load(conte... | javascript | async function read(filename, options = undefined) {
const {encoding, flag, ...opts} = normalizeOptions(options)
if (!isNumber(filename)) {
filename = await normalizePath(base, filename)
opts.filename = filename
}
const content = await fs.readFile(filename, {encoding, flag})
return yaml.load(conte... | [
"async",
"function",
"read",
"(",
"filename",
",",
"options",
"=",
"undefined",
")",
"{",
"const",
"{",
"encoding",
",",
"flag",
",",
"...",
"opts",
"}",
"=",
"normalizeOptions",
"(",
"options",
")",
"if",
"(",
"!",
"isNumber",
"(",
"filename",
")",
")... | Read and parse YAML file from given path
@param {string | number} filename
@param {string | object} [options = undefined]
@param {string}
@return {Promise<object>}
@api public | [
"Read",
"and",
"parse",
"YAML",
"file",
"from",
"given",
"path"
] | cdbc81185b3769c20f9e9cabdec6d5ff7cb7a289 | https://github.com/octet-stream/node-yaml/blob/cdbc81185b3769c20f9e9cabdec6d5ff7cb7a289/lib/node-yaml.js#L61-L73 | train |
octet-stream/node-yaml | lib/node-yaml.js | write | async function write(filename, object, options = undefined) {
const {encoding, flag, ...opts} = normalizeOptions(options)
if (!isNumber(filename)) {
filename = toAbsolute(base, filename)
opts.filename = filename
}
await fs.writeFile(filename, yaml.dump(object, opts), {encoding, flag})
} | javascript | async function write(filename, object, options = undefined) {
const {encoding, flag, ...opts} = normalizeOptions(options)
if (!isNumber(filename)) {
filename = toAbsolute(base, filename)
opts.filename = filename
}
await fs.writeFile(filename, yaml.dump(object, opts), {encoding, flag})
} | [
"async",
"function",
"write",
"(",
"filename",
",",
"object",
",",
"options",
"=",
"undefined",
")",
"{",
"const",
"{",
"encoding",
",",
"flag",
",",
"...",
"opts",
"}",
"=",
"normalizeOptions",
"(",
"options",
")",
"if",
"(",
"!",
"isNumber",
"(",
"fi... | Write given YAML content to disk
@param {string | number} filename
@param {object} object
@param {options} [options = undefined]
@return {void}
@api public | [
"Write",
"given",
"YAML",
"content",
"to",
"disk"
] | cdbc81185b3769c20f9e9cabdec6d5ff7cb7a289 | https://github.com/octet-stream/node-yaml/blob/cdbc81185b3769c20f9e9cabdec6d5ff7cb7a289/lib/node-yaml.js#L110-L120 | train |
ebi-uniprot/ProtVista | gulpfile.js | exposeBundles | function exposeBundles(b){
b.add("./" + packageConfig.main, {expose: packageConfig.name });
if(packageConfig.sniper !== undefined && packageConfig.sniper.exposed !== undefined){
for(var i=0; i<packageConfig.sniper.exposed.length; i++){
b.require(packageConfig.sniper.exposed[i]);
}
... | javascript | function exposeBundles(b){
b.add("./" + packageConfig.main, {expose: packageConfig.name });
if(packageConfig.sniper !== undefined && packageConfig.sniper.exposed !== undefined){
for(var i=0; i<packageConfig.sniper.exposed.length; i++){
b.require(packageConfig.sniper.exposed[i]);
}
... | [
"function",
"exposeBundles",
"(",
"b",
")",
"{",
"b",
".",
"add",
"(",
"\"./\"",
"+",
"packageConfig",
".",
"main",
",",
"{",
"expose",
":",
"packageConfig",
".",
"name",
"}",
")",
";",
"if",
"(",
"packageConfig",
".",
"sniper",
"!==",
"undefined",
"&&... | exposes the main package + checks the config whether it should expose other packages | [
"exposes",
"the",
"main",
"package",
"+",
"checks",
"the",
"config",
"whether",
"it",
"should",
"expose",
"other",
"packages"
] | ea5172f18c5cc448db71111184ef3919daf67ce1 | https://github.com/ebi-uniprot/ProtVista/blob/ea5172f18c5cc448db71111184ef3919daf67ce1/gulpfile.js#L178-L185 | train |
hex7c0/mkdir-recursive | index.js | mkdirSync | function mkdirSync(root, mode) {
if (typeof root !== 'string') {
throw new Error('missing root');
}
var chunks = root.split(path.sep); // split in chunks
var chunk;
if (path.isAbsolute(root) === true) { // build from absolute path
chunk = chunks.shift(); // remove "/" or C:/
if (!chunk) { // add... | javascript | function mkdirSync(root, mode) {
if (typeof root !== 'string') {
throw new Error('missing root');
}
var chunks = root.split(path.sep); // split in chunks
var chunk;
if (path.isAbsolute(root) === true) { // build from absolute path
chunk = chunks.shift(); // remove "/" or C:/
if (!chunk) { // add... | [
"function",
"mkdirSync",
"(",
"root",
",",
"mode",
")",
"{",
"if",
"(",
"typeof",
"root",
"!==",
"'string'",
")",
"{",
"throw",
"new",
"Error",
"(",
"'missing root'",
")",
";",
"}",
"var",
"chunks",
"=",
"root",
".",
"split",
"(",
"path",
".",
"sep",... | makeSync main. Check README.md
@exports mkdirSync
@function mkdirSync
@param {String} root - pathname
@param {Number} mode - directories mode, see Node documentation
@return [{Object}] | [
"makeSync",
"main",
".",
"Check",
"README",
".",
"md"
] | 25c6a044688043f8be8ff5d2432c22e25b393432 | https://github.com/hex7c0/mkdir-recursive/blob/25c6a044688043f8be8ff5d2432c22e25b393432/index.js#L65-L83 | train |
hex7c0/mkdir-recursive | index.js | rmdir | function rmdir(root, callback) {
if (typeof root !== 'string') {
throw new Error('missing root');
} else if (typeof callback !== 'function') {
throw new Error('missing callback');
}
var chunks = root.split(path.sep); // split in chunks
var chunk = path.resolve(root); // build absolute path
// remo... | javascript | function rmdir(root, callback) {
if (typeof root !== 'string') {
throw new Error('missing root');
} else if (typeof callback !== 'function') {
throw new Error('missing callback');
}
var chunks = root.split(path.sep); // split in chunks
var chunk = path.resolve(root); // build absolute path
// remo... | [
"function",
"rmdir",
"(",
"root",
",",
"callback",
")",
"{",
"if",
"(",
"typeof",
"root",
"!==",
"'string'",
")",
"{",
"throw",
"new",
"Error",
"(",
"'missing root'",
")",
";",
"}",
"else",
"if",
"(",
"typeof",
"callback",
"!==",
"'function'",
")",
"{"... | remove main. Check README.md
@exports rmdir
@function rmdir
@param {String} root - pathname
@param {Function} callback - next callback | [
"remove",
"main",
".",
"Check",
"README",
".",
"md"
] | 25c6a044688043f8be8ff5d2432c22e25b393432 | https://github.com/hex7c0/mkdir-recursive/blob/25c6a044688043f8be8ff5d2432c22e25b393432/index.js#L94-L113 | train |
hex7c0/mkdir-recursive | index.js | rmdirSync | function rmdirSync(root) {
if (typeof root !== 'string') {
throw new Error('missing root');
}
var chunks = root.split(path.sep); // split in chunks
var chunk = path.resolve(root); // build absolute path
// remove "/" from head and tail
if (chunks[0] === '') {
chunks.shift();
}
if (chunks[chunk... | javascript | function rmdirSync(root) {
if (typeof root !== 'string') {
throw new Error('missing root');
}
var chunks = root.split(path.sep); // split in chunks
var chunk = path.resolve(root); // build absolute path
// remove "/" from head and tail
if (chunks[0] === '') {
chunks.shift();
}
if (chunks[chunk... | [
"function",
"rmdirSync",
"(",
"root",
")",
"{",
"if",
"(",
"typeof",
"root",
"!==",
"'string'",
")",
"{",
"throw",
"new",
"Error",
"(",
"'missing root'",
")",
";",
"}",
"var",
"chunks",
"=",
"root",
".",
"split",
"(",
"path",
".",
"sep",
")",
";",
... | removeSync main. Check README.md
@exports rmdirSync
@function rmdirSync
@param {String} root - pathname
@return [{Object}] | [
"removeSync",
"main",
".",
"Check",
"README",
".",
"md"
] | 25c6a044688043f8be8ff5d2432c22e25b393432 | https://github.com/hex7c0/mkdir-recursive/blob/25c6a044688043f8be8ff5d2432c22e25b393432/index.js#L124-L141 | train |
hex7c0/mkdir-recursive | index.js | mkdirSyncRecursive | function mkdirSyncRecursive(root, chunks, mode) {
var chunk = chunks.shift();
if (!chunk) {
return;
}
var root = path.join(root, chunk);
if (fs.existsSync(root) === true) { // already done
return mkdirSyncRecursive(root, chunks, mode);
}
var err = fs.mkdirSync(root, mode);
return err ? err : m... | javascript | function mkdirSyncRecursive(root, chunks, mode) {
var chunk = chunks.shift();
if (!chunk) {
return;
}
var root = path.join(root, chunk);
if (fs.existsSync(root) === true) { // already done
return mkdirSyncRecursive(root, chunks, mode);
}
var err = fs.mkdirSync(root, mode);
return err ? err : m... | [
"function",
"mkdirSyncRecursive",
"(",
"root",
",",
"chunks",
",",
"mode",
")",
"{",
"var",
"chunk",
"=",
"chunks",
".",
"shift",
"(",
")",
";",
"if",
"(",
"!",
"chunk",
")",
"{",
"return",
";",
"}",
"var",
"root",
"=",
"path",
".",
"join",
"(",
... | make directory recursively. Sync version
@function mkdirSyncRecursive
@param {String} root - absolute root where append chunks
@param {Array} chunks - directories chunks
@param {Number} mode - directories mode, see Node documentation
@return [{Object}] | [
"make",
"directory",
"recursively",
".",
"Sync",
"version"
] | 25c6a044688043f8be8ff5d2432c22e25b393432 | https://github.com/hex7c0/mkdir-recursive/blob/25c6a044688043f8be8ff5d2432c22e25b393432/index.js#L187-L200 | train |
hex7c0/mkdir-recursive | index.js | rmdirRecursive | function rmdirRecursive(root, chunks, callback) {
var chunk = chunks.pop();
if (!chunk) {
return callback(null);
}
var pathname = path.join(root, '..'); // backtrack
return fs.exists(root, function(exists) {
if (exists === false) { // already done
return rmdirRecursive(root, chunks, callback)... | javascript | function rmdirRecursive(root, chunks, callback) {
var chunk = chunks.pop();
if (!chunk) {
return callback(null);
}
var pathname = path.join(root, '..'); // backtrack
return fs.exists(root, function(exists) {
if (exists === false) { // already done
return rmdirRecursive(root, chunks, callback)... | [
"function",
"rmdirRecursive",
"(",
"root",
",",
"chunks",
",",
"callback",
")",
"{",
"var",
"chunk",
"=",
"chunks",
".",
"pop",
"(",
")",
";",
"if",
"(",
"!",
"chunk",
")",
"{",
"return",
"callback",
"(",
"null",
")",
";",
"}",
"var",
"pathname",
"... | remove directory recursively
@function rmdirRecursive
@param {String} root - absolute root where take chunks
@param {Array} chunks - directories chunks
@param {Function} callback - next callback | [
"remove",
"directory",
"recursively"
] | 25c6a044688043f8be8ff5d2432c22e25b393432 | https://github.com/hex7c0/mkdir-recursive/blob/25c6a044688043f8be8ff5d2432c22e25b393432/index.js#L210-L231 | train |
hex7c0/mkdir-recursive | index.js | rmdirSyncRecursive | function rmdirSyncRecursive(root, chunks) {
var chunk = chunks.pop();
if (!chunk) {
return;
}
var pathname = path.join(root, '..'); // backtrack
if (fs.existsSync(root) === false) { // already done
return rmdirSyncRecursive(root, chunks);
}
var err = fs.rmdirSync(root);
return err ? err : rmdi... | javascript | function rmdirSyncRecursive(root, chunks) {
var chunk = chunks.pop();
if (!chunk) {
return;
}
var pathname = path.join(root, '..'); // backtrack
if (fs.existsSync(root) === false) { // already done
return rmdirSyncRecursive(root, chunks);
}
var err = fs.rmdirSync(root);
return err ? err : rmdi... | [
"function",
"rmdirSyncRecursive",
"(",
"root",
",",
"chunks",
")",
"{",
"var",
"chunk",
"=",
"chunks",
".",
"pop",
"(",
")",
";",
"if",
"(",
"!",
"chunk",
")",
"{",
"return",
";",
"}",
"var",
"pathname",
"=",
"path",
".",
"join",
"(",
"root",
",",
... | remove directory recursively. Sync version
@function rmdirRecursive
@param {String} root - absolute root where take chunks
@param {Array} chunks - directories chunks
@return [{Object}] | [
"remove",
"directory",
"recursively",
".",
"Sync",
"version"
] | 25c6a044688043f8be8ff5d2432c22e25b393432 | https://github.com/hex7c0/mkdir-recursive/blob/25c6a044688043f8be8ff5d2432c22e25b393432/index.js#L241-L254 | train |
doowb/group-array | examples/geojson.js | interval | function interval(prop) {
// create a function that will use the intervals to check the group by property
return function(intervals) {
// create custom labels to use for the resulting object keys
var labels = intervals.reduce(function(acc, val, i) {
var min = val;
var max = (intervals[i + 1] &... | javascript | function interval(prop) {
// create a function that will use the intervals to check the group by property
return function(intervals) {
// create custom labels to use for the resulting object keys
var labels = intervals.reduce(function(acc, val, i) {
var min = val;
var max = (intervals[i + 1] &... | [
"function",
"interval",
"(",
"prop",
")",
"{",
"// create a function that will use the intervals to check the group by property",
"return",
"function",
"(",
"intervals",
")",
"{",
"// create custom labels to use for the resulting object keys",
"var",
"labels",
"=",
"intervals",
"... | create a function that will use the property provided to group on | [
"create",
"a",
"function",
"that",
"will",
"use",
"the",
"property",
"provided",
"to",
"group",
"on"
] | 69c01ca548146e7a5c12eb2ad7c0310161854cb9 | https://github.com/doowb/group-array/blob/69c01ca548146e7a5c12eb2ad7c0310161854cb9/examples/geojson.js#L10-L40 | train |
ulivz/vue-foldable | docs/.vuepress/config.js | inferSiderbars | function inferSiderbars () {
// You will need to update this config when directory was added or removed.
const sidebars = [
// { title: 'JavaScript', dirname: 'javascript' },
// { title: 'CSS', dirname: 'css' },
]
return sidebars.map(({ title, dirname }) => {
const dirpath = path.resolve(__dirname, ... | javascript | function inferSiderbars () {
// You will need to update this config when directory was added or removed.
const sidebars = [
// { title: 'JavaScript', dirname: 'javascript' },
// { title: 'CSS', dirname: 'css' },
]
return sidebars.map(({ title, dirname }) => {
const dirpath = path.resolve(__dirname, ... | [
"function",
"inferSiderbars",
"(",
")",
"{",
"// You will need to update this config when directory was added or removed.",
"const",
"sidebars",
"=",
"[",
"// { title: 'JavaScript', dirname: 'javascript' },",
"// { title: 'CSS', dirname: 'css' },",
"]",
"return",
"sidebars",
".",
"ma... | If you want to create a docs that automatically lists all files in all subdirectories,
This method will help you complete this task.
If you do not prefer this preset, just remove it and configure it according to the
docs: https://vuepress.vuejs.org/default-theme-config/#sidebar
@returns {Array} | [
"If",
"you",
"want",
"to",
"create",
"a",
"docs",
"that",
"automatically",
"lists",
"all",
"files",
"in",
"all",
"subdirectories",
"This",
"method",
"will",
"help",
"you",
"complete",
"this",
"task",
"."
] | 1c91ad97fb2f48941c6554d18a6997615c2164bb | https://github.com/ulivz/vue-foldable/blob/1c91ad97fb2f48941c6554d18a6997615c2164bb/docs/.vuepress/config.js#L53-L70 | train |
ulivz/vue-foldable | scripts/build.js | getBuildingConfigs | function getBuildingConfigs (target) {
return target.map(({ dirname, name, version, entry, outDir, styleFilename }) => {
return formats.map(format => {
return {
inputOptions: getInputOptions({ entry, outDir, styleFilename }),
outputOptions: getOutputOptions({ outDir, name, version, format })... | javascript | function getBuildingConfigs (target) {
return target.map(({ dirname, name, version, entry, outDir, styleFilename }) => {
return formats.map(format => {
return {
inputOptions: getInputOptions({ entry, outDir, styleFilename }),
outputOptions: getOutputOptions({ outDir, name, version, format })... | [
"function",
"getBuildingConfigs",
"(",
"target",
")",
"{",
"return",
"target",
".",
"map",
"(",
"(",
"{",
"dirname",
",",
"name",
",",
"version",
",",
"entry",
",",
"outDir",
",",
"styleFilename",
"}",
")",
"=>",
"{",
"return",
"formats",
".",
"map",
"... | Get rollup building configurations
@param target | [
"Get",
"rollup",
"building",
"configurations"
] | 1c91ad97fb2f48941c6554d18a6997615c2164bb | https://github.com/ulivz/vue-foldable/blob/1c91ad97fb2f48941c6554d18a6997615c2164bb/scripts/build.js#L67-L76 | train |
nodeca/unhomoglyph | update.js | save | function save(str) {
let result = {};
console.log('Writing data...');
str.split(/\r?\n/g)
.filter(line => line.length && line[0] !== '#')
.forEach(line => {
if (line.split(';').length < 2) return;
let [ src, dst ] = line.split(';').slice(0, 2).map(s => s.trim());
src = String.fromCod... | javascript | function save(str) {
let result = {};
console.log('Writing data...');
str.split(/\r?\n/g)
.filter(line => line.length && line[0] !== '#')
.forEach(line => {
if (line.split(';').length < 2) return;
let [ src, dst ] = line.split(';').slice(0, 2).map(s => s.trim());
src = String.fromCod... | [
"function",
"save",
"(",
"str",
")",
"{",
"let",
"result",
"=",
"{",
"}",
";",
"console",
".",
"log",
"(",
"'Writing data...'",
")",
";",
"str",
".",
"split",
"(",
"/",
"\\r?\\n",
"/",
"g",
")",
".",
"filter",
"(",
"line",
"=>",
"line",
".",
"len... | Parse & save mappings | [
"Parse",
"&",
"save",
"mappings"
] | fed5576b38863d75cdc16414c2fa61d9f9f28442 | https://github.com/nodeca/unhomoglyph/blob/fed5576b38863d75cdc16414c2fa61d9f9f28442/update.js#L19-L43 | train |
grantcarthew/node-rethinkdb-job-queue | src/queue-change.js | restartProcessing | function restartProcessing (q) {
logger('restartProcessing')
setTimeout(function randomRestart () {
queueProcess.restart(q)
}, Math.floor(Math.random() * 1000))
} | javascript | function restartProcessing (q) {
logger('restartProcessing')
setTimeout(function randomRestart () {
queueProcess.restart(q)
}, Math.floor(Math.random() * 1000))
} | [
"function",
"restartProcessing",
"(",
"q",
")",
"{",
"logger",
"(",
"'restartProcessing'",
")",
"setTimeout",
"(",
"function",
"randomRestart",
"(",
")",
"{",
"queueProcess",
".",
"restart",
"(",
"q",
")",
"}",
",",
"Math",
".",
"floor",
"(",
"Math",
".",
... | Following is the list of supported change feed events; paused - Global event resumed - Global event reviewed - Global event added active progress completed cancelled failed terminated removed log | [
"Following",
"is",
"the",
"list",
"of",
"supported",
"change",
"feed",
"events",
";",
"paused",
"-",
"Global",
"event",
"resumed",
"-",
"Global",
"event",
"reviewed",
"-",
"Global",
"event",
"added",
"active",
"progress",
"completed",
"cancelled",
"failed",
"t... | ae3111cdd7596c552e05d60a32daadd4088af63f | https://github.com/grantcarthew/node-rethinkdb-job-queue/blob/ae3111cdd7596c552e05d60a32daadd4088af63f/src/queue-change.js#L22-L27 | train |
mudchina/webtelnet | webtelnet-proxy.js | unicodeStringToTypedArray | function unicodeStringToTypedArray(s) {
var escstr = encodeURIComponent(s);
var binstr = escstr.replace(/%([0-9A-F]{2})/g, function(match, p1) {
return String.fromCharCode('0x' + p1);
});
var ua = new Uint8Array(binstr.length);
Array.prototype.forEach.call(binstr, function (ch, i) {
... | javascript | function unicodeStringToTypedArray(s) {
var escstr = encodeURIComponent(s);
var binstr = escstr.replace(/%([0-9A-F]{2})/g, function(match, p1) {
return String.fromCharCode('0x' + p1);
});
var ua = new Uint8Array(binstr.length);
Array.prototype.forEach.call(binstr, function (ch, i) {
... | [
"function",
"unicodeStringToTypedArray",
"(",
"s",
")",
"{",
"var",
"escstr",
"=",
"encodeURIComponent",
"(",
"s",
")",
";",
"var",
"binstr",
"=",
"escstr",
".",
"replace",
"(",
"/",
"%([0-9A-F]{2})",
"/",
"g",
",",
"function",
"(",
"match",
",",
"p1",
"... | string to uint array | [
"string",
"to",
"uint",
"array"
] | 47b47d15040f1dd100099fa7b98e186723a1dbae | https://github.com/mudchina/webtelnet/blob/47b47d15040f1dd100099fa7b98e186723a1dbae/webtelnet-proxy.js#L10-L20 | train |
mudchina/webtelnet | webtelnet-proxy.js | typedArrayToUnicodeString | function typedArrayToUnicodeString(ua) {
var binstr = Array.prototype.map.call(ua, function (ch) {
return String.fromCharCode(ch);
}).join('');
var escstr = binstr.replace(/(.)/g, function (m, p) {
var code = p.charCodeAt(p).toString(16).toUpperCase();
if (code.length < 2) {
... | javascript | function typedArrayToUnicodeString(ua) {
var binstr = Array.prototype.map.call(ua, function (ch) {
return String.fromCharCode(ch);
}).join('');
var escstr = binstr.replace(/(.)/g, function (m, p) {
var code = p.charCodeAt(p).toString(16).toUpperCase();
if (code.length < 2) {
... | [
"function",
"typedArrayToUnicodeString",
"(",
"ua",
")",
"{",
"var",
"binstr",
"=",
"Array",
".",
"prototype",
".",
"map",
".",
"call",
"(",
"ua",
",",
"function",
"(",
"ch",
")",
"{",
"return",
"String",
".",
"fromCharCode",
"(",
"ch",
")",
";",
"}",
... | uint array to string | [
"uint",
"array",
"to",
"string"
] | 47b47d15040f1dd100099fa7b98e186723a1dbae | https://github.com/mudchina/webtelnet/blob/47b47d15040f1dd100099fa7b98e186723a1dbae/webtelnet-proxy.js#L23-L35 | train |
sam3d/vue-svg | index.js | setup | function setup(config, options) {
const rule = config.module.rule("svg"); // Find the svg rule
/*
* Let's use the file loader option defaults for the svg loader again. Otherwise
* we'll have to set our own and it's no longer consistent with the changing
* vue-cli.
*/
const fileLoaderOptions = rule.us... | javascript | function setup(config, options) {
const rule = config.module.rule("svg"); // Find the svg rule
/*
* Let's use the file loader option defaults for the svg loader again. Otherwise
* we'll have to set our own and it's no longer consistent with the changing
* vue-cli.
*/
const fileLoaderOptions = rule.us... | [
"function",
"setup",
"(",
"config",
",",
"options",
")",
"{",
"const",
"rule",
"=",
"config",
".",
"module",
".",
"rule",
"(",
"\"svg\"",
")",
";",
"// Find the svg rule",
"/*\n * Let's use the file loader option defaults for the svg loader again. Otherwise\n * we'll ha... | Perform the main setup of the svg rule parsing and rewriting. This uses the
chainWebpack API modify the required rules.
@param {ChainWebpack} config An instance of ChainWebpack
@param {Object} options The svg options from the vue.config.js | [
"Perform",
"the",
"main",
"setup",
"of",
"the",
"svg",
"rule",
"parsing",
"and",
"rewriting",
".",
"This",
"uses",
"the",
"chainWebpack",
"API",
"modify",
"the",
"required",
"rules",
"."
] | 6d83be536df4ef247ab94d57615b22c0b4e78aaf | https://github.com/sam3d/vue-svg/blob/6d83be536df4ef247ab94d57615b22c0b4e78aaf/index.js#L31-L77 | train |
sam3d/vue-svg | index.js | parseResourceQuery | function parseResourceQuery(options) {
const query = {};
for (option in options) {
if (!options[option].resourceQuery) continue; // Skip if no query
query[option] = options[option].resourceQuery; // Get the query
delete options[option].resourceQuery; // Delete the field (to prevent passing it as a load... | javascript | function parseResourceQuery(options) {
const query = {};
for (option in options) {
if (!options[option].resourceQuery) continue; // Skip if no query
query[option] = options[option].resourceQuery; // Get the query
delete options[option].resourceQuery; // Delete the field (to prevent passing it as a load... | [
"function",
"parseResourceQuery",
"(",
"options",
")",
"{",
"const",
"query",
"=",
"{",
"}",
";",
"for",
"(",
"option",
"in",
"options",
")",
"{",
"if",
"(",
"!",
"options",
"[",
"option",
"]",
".",
"resourceQuery",
")",
"continue",
";",
"// Skip if no q... | Processes the options object passed to the app by extracting the resource query
options and returning them so that they can be used later.
@param {object} options The plugin options object
@return {object} An object containing the resource queries and their relevant config names | [
"Processes",
"the",
"options",
"object",
"passed",
"to",
"the",
"app",
"by",
"extracting",
"the",
"resource",
"query",
"options",
"and",
"returning",
"them",
"so",
"that",
"they",
"can",
"be",
"used",
"later",
"."
] | 6d83be536df4ef247ab94d57615b22c0b4e78aaf | https://github.com/sam3d/vue-svg/blob/6d83be536df4ef247ab94d57615b22c0b4e78aaf/index.js#L100-L110 | train |
mz121star/NJBlog | public/lib/jquery.sly.js | slideTo | function slideTo(newPos, immediate) {
// Align items
if (itemNav && dragging.released) {
var tempRel = getRelatives(newPos),
isDetached = newPos > pos.start && newPos < pos.end;
if (centeredNav) {
if (isDetached) {
... | javascript | function slideTo(newPos, immediate) {
// Align items
if (itemNav && dragging.released) {
var tempRel = getRelatives(newPos),
isDetached = newPos > pos.start && newPos < pos.end;
if (centeredNav) {
if (isDetached) {
... | [
"function",
"slideTo",
"(",
"newPos",
",",
"immediate",
")",
"{",
"// Align items\r",
"if",
"(",
"itemNav",
"&&",
"dragging",
".",
"released",
")",
"{",
"var",
"tempRel",
"=",
"getRelatives",
"(",
"newPos",
")",
",",
"isDetached",
"=",
"newPos",
">",
"pos"... | Animate to a position.
@param {Int} newPos New position.
@param {Bool} immediate Reposition immediately without an animation.
@return {Void} | [
"Animate",
"to",
"a",
"position",
"."
] | 08be4473daa854e3e8942340998a6c282f3f8c44 | https://github.com/mz121star/NJBlog/blob/08be4473daa854e3e8942340998a6c282f3f8c44/public/lib/jquery.sly.js#L291-L346 | train |
mz121star/NJBlog | public/lib/jquery.sly.js | render | function render() {
// If first render call, wait for next animationFrame
if (!renderID) {
renderID = rAF(render);
if (dragging.released) {
trigger('moveStart');
}
return;
}
// ... | javascript | function render() {
// If first render call, wait for next animationFrame
if (!renderID) {
renderID = rAF(render);
if (dragging.released) {
trigger('moveStart');
}
return;
}
// ... | [
"function",
"render",
"(",
")",
"{",
"// If first render call, wait for next animationFrame\r",
"if",
"(",
"!",
"renderID",
")",
"{",
"renderID",
"=",
"rAF",
"(",
"render",
")",
";",
"if",
"(",
"dragging",
".",
"released",
")",
"{",
"trigger",
"(",
"'moveStart... | Render animation frame.
@return {Void} | [
"Render",
"animation",
"frame",
"."
] | 08be4473daa854e3e8942340998a6c282f3f8c44 | https://github.com/mz121star/NJBlog/blob/08be4473daa854e3e8942340998a6c282f3f8c44/public/lib/jquery.sly.js#L353-L404 | train |
mz121star/NJBlog | public/lib/jquery.sly.js | syncScrollbar | function syncScrollbar() {
if ($handle) {
hPos.cur = pos.start === pos.end ? 0 : (((!dragging.released && dragging.source === 'handle') ? pos.dest : pos.cur) - pos.start) / (pos.end - pos.start) * hPos.end;
hPos.cur = within(Math.round(hPos.cur), hPos.start, hPos.end);
... | javascript | function syncScrollbar() {
if ($handle) {
hPos.cur = pos.start === pos.end ? 0 : (((!dragging.released && dragging.source === 'handle') ? pos.dest : pos.cur) - pos.start) / (pos.end - pos.start) * hPos.end;
hPos.cur = within(Math.round(hPos.cur), hPos.start, hPos.end);
... | [
"function",
"syncScrollbar",
"(",
")",
"{",
"if",
"(",
"$handle",
")",
"{",
"hPos",
".",
"cur",
"=",
"pos",
".",
"start",
"===",
"pos",
".",
"end",
"?",
"0",
":",
"(",
"(",
"(",
"!",
"dragging",
".",
"released",
"&&",
"dragging",
".",
"source",
"... | Synchronizes scrollbar with the SLIDEE.
@return {Void} | [
"Synchronizes",
"scrollbar",
"with",
"the",
"SLIDEE",
"."
] | 08be4473daa854e3e8942340998a6c282f3f8c44 | https://github.com/mz121star/NJBlog/blob/08be4473daa854e3e8942340998a6c282f3f8c44/public/lib/jquery.sly.js#L411-L424 | train |
mz121star/NJBlog | public/lib/jquery.sly.js | syncPagesbar | function syncPagesbar() {
if ($pages[0] && last.page !== rel.activePage) {
last.page = rel.activePage;
$pages.removeClass(o.activeClass).eq(rel.activePage).addClass(o.activeClass);
}
} | javascript | function syncPagesbar() {
if ($pages[0] && last.page !== rel.activePage) {
last.page = rel.activePage;
$pages.removeClass(o.activeClass).eq(rel.activePage).addClass(o.activeClass);
}
} | [
"function",
"syncPagesbar",
"(",
")",
"{",
"if",
"(",
"$pages",
"[",
"0",
"]",
"&&",
"last",
".",
"page",
"!==",
"rel",
".",
"activePage",
")",
"{",
"last",
".",
"page",
"=",
"rel",
".",
"activePage",
";",
"$pages",
".",
"removeClass",
"(",
"o",
".... | Synchronizes pagesbar with SLIDEE.
@return {Void} | [
"Synchronizes",
"pagesbar",
"with",
"SLIDEE",
"."
] | 08be4473daa854e3e8942340998a6c282f3f8c44 | https://github.com/mz121star/NJBlog/blob/08be4473daa854e3e8942340998a6c282f3f8c44/public/lib/jquery.sly.js#L431-L436 | train |
mz121star/NJBlog | public/lib/jquery.sly.js | to | function to(location, item, immediate) {
// Optional arguments logic
if (typeof item === 'boolean') {
immediate = item;
item = undefined;
}
if (item === undefined) {
slideTo(pos[location]);
} else {
... | javascript | function to(location, item, immediate) {
// Optional arguments logic
if (typeof item === 'boolean') {
immediate = item;
item = undefined;
}
if (item === undefined) {
slideTo(pos[location]);
} else {
... | [
"function",
"to",
"(",
"location",
",",
"item",
",",
"immediate",
")",
"{",
"// Optional arguments logic\r",
"if",
"(",
"typeof",
"item",
"===",
"'boolean'",
")",
"{",
"immediate",
"=",
"item",
";",
"item",
"=",
"undefined",
";",
"}",
"if",
"(",
"item",
... | Core method for handling `toLocation` methods.
@param {String} location
@param {Mixed} item
@param {Bool} immediate
@return {Void} | [
"Core",
"method",
"for",
"handling",
"toLocation",
"methods",
"."
] | 08be4473daa854e3e8942340998a6c282f3f8c44 | https://github.com/mz121star/NJBlog/blob/08be4473daa854e3e8942340998a6c282f3f8c44/public/lib/jquery.sly.js#L550-L571 | train |
mz121star/NJBlog | public/lib/jquery.sly.js | getIndex | function getIndex(item) {
return isNumber(item) ? within(item, 0, items.length - 1) : item === undefined ? -1 : $items.index(item);
} | javascript | function getIndex(item) {
return isNumber(item) ? within(item, 0, items.length - 1) : item === undefined ? -1 : $items.index(item);
} | [
"function",
"getIndex",
"(",
"item",
")",
"{",
"return",
"isNumber",
"(",
"item",
")",
"?",
"within",
"(",
"item",
",",
"0",
",",
"items",
".",
"length",
"-",
"1",
")",
":",
"item",
"===",
"undefined",
"?",
"-",
"1",
":",
"$items",
".",
"index",
... | Get the index of an item in SLIDEE.
@param {Mixed} item Item DOM element, or index starting at 0.
@return {Int} | [
"Get",
"the",
"index",
"of",
"an",
"item",
"in",
"SLIDEE",
"."
] | 08be4473daa854e3e8942340998a6c282f3f8c44 | https://github.com/mz121star/NJBlog/blob/08be4473daa854e3e8942340998a6c282f3f8c44/public/lib/jquery.sly.js#L616-L618 | train |
mz121star/NJBlog | public/lib/jquery.sly.js | getRelatives | function getRelatives(slideePos) {
slideePos = within(isNumber(slideePos) ? slideePos : pos.dest, pos.start, pos.end);
var relatives = {},
centerOffset = forceCenteredNav ? 0 : frameSize / 2;
// Determine active page
if (!parallax) {
... | javascript | function getRelatives(slideePos) {
slideePos = within(isNumber(slideePos) ? slideePos : pos.dest, pos.start, pos.end);
var relatives = {},
centerOffset = forceCenteredNav ? 0 : frameSize / 2;
// Determine active page
if (!parallax) {
... | [
"function",
"getRelatives",
"(",
"slideePos",
")",
"{",
"slideePos",
"=",
"within",
"(",
"isNumber",
"(",
"slideePos",
")",
"?",
"slideePos",
":",
"pos",
".",
"dest",
",",
"pos",
".",
"start",
",",
"pos",
".",
"end",
")",
";",
"var",
"relatives",
"=",
... | Return relative positions of items based on their visibility within FRAME.
@param {Int} slideePos Position of SLIDEE.
@return {Void} | [
"Return",
"relative",
"positions",
"of",
"items",
"based",
"on",
"their",
"visibility",
"within",
"FRAME",
"."
] | 08be4473daa854e3e8942340998a6c282f3f8c44 | https://github.com/mz121star/NJBlog/blob/08be4473daa854e3e8942340998a6c282f3f8c44/public/lib/jquery.sly.js#L696-L753 | train |
mz121star/NJBlog | public/lib/jquery.sly.js | updateNavButtonsState | function updateNavButtonsState() {
// Item navigation
if (itemNav) {
var isFirst = rel.activeItem === 0,
isLast = rel.activeItem >= items.length - 1,
itemsButtonState = isFirst ? 'first' : isLast ? 'last' : 'middle';
... | javascript | function updateNavButtonsState() {
// Item navigation
if (itemNav) {
var isFirst = rel.activeItem === 0,
isLast = rel.activeItem >= items.length - 1,
itemsButtonState = isFirst ? 'first' : isLast ? 'last' : 'middle';
... | [
"function",
"updateNavButtonsState",
"(",
")",
"{",
"// Item navigation\r",
"if",
"(",
"itemNav",
")",
"{",
"var",
"isFirst",
"=",
"rel",
".",
"activeItem",
"===",
"0",
",",
"isLast",
"=",
"rel",
".",
"activeItem",
">=",
"items",
".",
"length",
"-",
"1",
... | Disable navigation buttons when needed.
Adds disabledClass, and when the button is <button> or <input>, activates :disabled state.
@return {Void} | [
"Disable",
"navigation",
"buttons",
"when",
"needed",
"."
] | 08be4473daa854e3e8942340998a6c282f3f8c44 | https://github.com/mz121star/NJBlog/blob/08be4473daa854e3e8942340998a6c282f3f8c44/public/lib/jquery.sly.js#L773-L818 | train |
mz121star/NJBlog | public/lib/jquery.sly.js | handleToSlidee | function handleToSlidee(handlePos) {
return Math.round(within(handlePos, hPos.start, hPos.end) / hPos.end * (pos.end - pos.start)) + pos.start;
} | javascript | function handleToSlidee(handlePos) {
return Math.round(within(handlePos, hPos.start, hPos.end) / hPos.end * (pos.end - pos.start)) + pos.start;
} | [
"function",
"handleToSlidee",
"(",
"handlePos",
")",
"{",
"return",
"Math",
".",
"round",
"(",
"within",
"(",
"handlePos",
",",
"hPos",
".",
"start",
",",
"hPos",
".",
"end",
")",
"/",
"hPos",
".",
"end",
"*",
"(",
"pos",
".",
"end",
"-",
"pos",
".... | Calculate SLIDEE representation of handle position.
@param {Int} handlePos
@return {Int} | [
"Calculate",
"SLIDEE",
"representation",
"of",
"handle",
"position",
"."
] | 08be4473daa854e3e8942340998a6c282f3f8c44 | https://github.com/mz121star/NJBlog/blob/08be4473daa854e3e8942340998a6c282f3f8c44/public/lib/jquery.sly.js#L900-L902 | train |
mz121star/NJBlog | public/lib/jquery.sly.js | dragInit | function dragInit(event) {
var isTouch = event.type === 'touchstart',
source = event.data.source,
isSlidee = source === 'slidee';
// Ignore other than left mouse button
if (isTouch || event.which <= 1) {
stopDefault(event);
... | javascript | function dragInit(event) {
var isTouch = event.type === 'touchstart',
source = event.data.source,
isSlidee = source === 'slidee';
// Ignore other than left mouse button
if (isTouch || event.which <= 1) {
stopDefault(event);
... | [
"function",
"dragInit",
"(",
"event",
")",
"{",
"var",
"isTouch",
"=",
"event",
".",
"type",
"===",
"'touchstart'",
",",
"source",
"=",
"event",
".",
"data",
".",
"source",
",",
"isSlidee",
"=",
"source",
"===",
"'slidee'",
";",
"// Ignore other than left mo... | Dragging initiator.
@param {Event} event
@return {Void} | [
"Dragging",
"initiator",
"."
] | 08be4473daa854e3e8942340998a6c282f3f8c44 | https://github.com/mz121star/NJBlog/blob/08be4473daa854e3e8942340998a6c282f3f8c44/public/lib/jquery.sly.js#L911-L940 | train |
mz121star/NJBlog | public/lib/jquery.sly.js | dragHandler | function dragHandler(event) {
dragging.released = event.type === 'mouseup' || event.type === 'touchend';
dragging.path = within(
(dragging.touch ? event.originalEvent[dragging.released ? 'changedTouches' : 'touches'][0] : event)[o.horizontal ? 'pageX' : 'pageY'] - dragging... | javascript | function dragHandler(event) {
dragging.released = event.type === 'mouseup' || event.type === 'touchend';
dragging.path = within(
(dragging.touch ? event.originalEvent[dragging.released ? 'changedTouches' : 'touches'][0] : event)[o.horizontal ? 'pageX' : 'pageY'] - dragging... | [
"function",
"dragHandler",
"(",
"event",
")",
"{",
"dragging",
".",
"released",
"=",
"event",
".",
"type",
"===",
"'mouseup'",
"||",
"event",
".",
"type",
"===",
"'touchend'",
";",
"dragging",
".",
"path",
"=",
"within",
"(",
"(",
"dragging",
".",
"touch... | Handler for dragging scrollbar handle or SLIDEE.
@param {Event} event
@return {Void} | [
"Handler",
"for",
"dragging",
"scrollbar",
"handle",
"or",
"SLIDEE",
"."
] | 08be4473daa854e3e8942340998a6c282f3f8c44 | https://github.com/mz121star/NJBlog/blob/08be4473daa854e3e8942340998a6c282f3f8c44/public/lib/jquery.sly.js#L949-L1001 | train |
mz121star/NJBlog | public/lib/jquery.sly.js | trigger | function trigger(name, arg1, arg2, arg3, arg4) {
// Common arguments for events
switch (name) {
case 'active':
arg2 = arg1;
arg1 = $items;
break;
case 'activePage':
arg2 = ar... | javascript | function trigger(name, arg1, arg2, arg3, arg4) {
// Common arguments for events
switch (name) {
case 'active':
arg2 = arg1;
arg1 = $items;
break;
case 'activePage':
arg2 = ar... | [
"function",
"trigger",
"(",
"name",
",",
"arg1",
",",
"arg2",
",",
"arg3",
",",
"arg4",
")",
"{",
"// Common arguments for events\r",
"switch",
"(",
"name",
")",
"{",
"case",
"'active'",
":",
"arg2",
"=",
"arg1",
";",
"arg1",
"=",
"$items",
";",
"break",... | Trigger callbacks for event.
@param {String} name Event name.
@param {Mixed} argX Arguments passed to callback.
@return {Void} | [
"Trigger",
"callbacks",
"for",
"event",
"."
] | 08be4473daa854e3e8942340998a6c282f3f8c44 | https://github.com/mz121star/NJBlog/blob/08be4473daa854e3e8942340998a6c282f3f8c44/public/lib/jquery.sly.js#L1087-L1116 | train |
mz121star/NJBlog | public/lib/jquery.sly.js | stopDefault | function stopDefault(event, noBubbles) {
event = event || w.event;
if (event.preventDefault) {
event.preventDefault();
} else {
event.returnValue = false;
}
if (noBubbles) {
if (event.stopPropagation) {
event.stopPr... | javascript | function stopDefault(event, noBubbles) {
event = event || w.event;
if (event.preventDefault) {
event.preventDefault();
} else {
event.returnValue = false;
}
if (noBubbles) {
if (event.stopPropagation) {
event.stopPr... | [
"function",
"stopDefault",
"(",
"event",
",",
"noBubbles",
")",
"{",
"event",
"=",
"event",
"||",
"w",
".",
"event",
";",
"if",
"(",
"event",
".",
"preventDefault",
")",
"{",
"event",
".",
"preventDefault",
"(",
")",
";",
"}",
"else",
"{",
"event",
"... | Crossbrowser reliable way to stop default event action.
@param {Event} event Event object.
@param {Bool} noBubbles Cancel event bubbling.
@return {Void} | [
"Crossbrowser",
"reliable",
"way",
"to",
"stop",
"default",
"event",
"action",
"."
] | 08be4473daa854e3e8942340998a6c282f3f8c44 | https://github.com/mz121star/NJBlog/blob/08be4473daa854e3e8942340998a6c282f3f8c44/public/lib/jquery.sly.js#L1349-L1365 | train |
HaoyCn/iconfont-plugin-webpack | index.js | shouldReplace | function shouldReplace(svg, cssPath, newCssContent) {
try {
fs.accessSync(svg.path, fs.constants ? fs.constants.R_OK : fs.R_OK);
fs.accessSync(cssPath, fs.constants ? fs.constants.R_OK : fs.R_OK);
} catch(e) {
return true;
}
const oldSvg = fs.readFileSync(svg.path).toString();
const newSvg = svg.conten... | javascript | function shouldReplace(svg, cssPath, newCssContent) {
try {
fs.accessSync(svg.path, fs.constants ? fs.constants.R_OK : fs.R_OK);
fs.accessSync(cssPath, fs.constants ? fs.constants.R_OK : fs.R_OK);
} catch(e) {
return true;
}
const oldSvg = fs.readFileSync(svg.path).toString();
const newSvg = svg.conten... | [
"function",
"shouldReplace",
"(",
"svg",
",",
"cssPath",
",",
"newCssContent",
")",
"{",
"try",
"{",
"fs",
".",
"accessSync",
"(",
"svg",
".",
"path",
",",
"fs",
".",
"constants",
"?",
"fs",
".",
"constants",
".",
"R_OK",
":",
"fs",
".",
"R_OK",
")",... | checks if a recompilation is necessary | [
"checks",
"if",
"a",
"recompilation",
"is",
"necessary"
] | 8252e04898c4d53fbba1cb7dcb3293a90fbe32b2 | https://github.com/HaoyCn/iconfont-plugin-webpack/blob/8252e04898c4d53fbba1cb7dcb3293a90fbe32b2/index.js#L11-L28 | train |
mz121star/NJBlog | libs/mocha/should.js | function(expr, msg, negatedMsg, expected, showDiff){
var msg = this.negate ? negatedMsg : msg
, ok = this.negate ? !expr : expr
, obj = this.obj;
if (ok) return;
var err = new AssertionError({
message: msg.call(this)
, actual: obj
... | javascript | function(expr, msg, negatedMsg, expected, showDiff){
var msg = this.negate ? negatedMsg : msg
, ok = this.negate ? !expr : expr
, obj = this.obj;
if (ok) return;
var err = new AssertionError({
message: msg.call(this)
, actual: obj
... | [
"function",
"(",
"expr",
",",
"msg",
",",
"negatedMsg",
",",
"expected",
",",
"showDiff",
")",
"{",
"var",
"msg",
"=",
"this",
".",
"negate",
"?",
"negatedMsg",
":",
"msg",
",",
"ok",
"=",
"this",
".",
"negate",
"?",
"!",
"expr",
":",
"expr",
",",
... | Assert _expr_ with the given _msg_ and _negatedMsg_.
@param {Boolean} expr
@param {String} msg
@param {String} negatedMsg
@param {Object} expected
@api private | [
"Assert",
"_expr_",
"with",
"the",
"given",
"_msg_",
"and",
"_negatedMsg_",
"."
] | 08be4473daa854e3e8942340998a6c282f3f8c44 | https://github.com/mz121star/NJBlog/blob/08be4473daa854e3e8942340998a6c282f3f8c44/libs/mocha/should.js#L113-L131 | train | |
mz121star/NJBlog | libs/mocha/should.js | function(val, desc){
this.assert(
eql(val, this.obj)
, function(){ return 'expected ' + this.inspect + ' to equal ' + i(val) + (desc ? " | " + desc : "") }
, function(){ return 'expected ' + this.inspect + ' to not equal ' + i(val) + (desc ? " | " + desc : "") }
... | javascript | function(val, desc){
this.assert(
eql(val, this.obj)
, function(){ return 'expected ' + this.inspect + ' to equal ' + i(val) + (desc ? " | " + desc : "") }
, function(){ return 'expected ' + this.inspect + ' to not equal ' + i(val) + (desc ? " | " + desc : "") }
... | [
"function",
"(",
"val",
",",
"desc",
")",
"{",
"this",
".",
"assert",
"(",
"eql",
"(",
"val",
",",
"this",
".",
"obj",
")",
",",
"function",
"(",
")",
"{",
"return",
"'expected '",
"+",
"this",
".",
"inspect",
"+",
"' to equal '",
"+",
"i",
"(",
... | Assert equal.
@param {Mixed} val
@param {String} description
@api public | [
"Assert",
"equal",
"."
] | 08be4473daa854e3e8942340998a6c282f3f8c44 | https://github.com/mz121star/NJBlog/blob/08be4473daa854e3e8942340998a6c282f3f8c44/libs/mocha/should.js#L284-L292 | train | |
mz121star/NJBlog | libs/mocha/should.js | function(val, desc){
this.assert(
val.valueOf() === this.obj
, function(){ return 'expected ' + this.inspect + ' to equal ' + i(val) + (desc ? " | " + desc : "") }
, function(){ return 'expected ' + this.inspect + ' to not equal ' + i(val) + (desc ? " | " + desc : "") }
... | javascript | function(val, desc){
this.assert(
val.valueOf() === this.obj
, function(){ return 'expected ' + this.inspect + ' to equal ' + i(val) + (desc ? " | " + desc : "") }
, function(){ return 'expected ' + this.inspect + ' to not equal ' + i(val) + (desc ? " | " + desc : "") }
... | [
"function",
"(",
"val",
",",
"desc",
")",
"{",
"this",
".",
"assert",
"(",
"val",
".",
"valueOf",
"(",
")",
"===",
"this",
".",
"obj",
",",
"function",
"(",
")",
"{",
"return",
"'expected '",
"+",
"this",
".",
"inspect",
"+",
"' to equal '",
"+",
"... | Assert strict equal.
@param {Mixed} val
@param {String} description
@api public | [
"Assert",
"strict",
"equal",
"."
] | 08be4473daa854e3e8942340998a6c282f3f8c44 | https://github.com/mz121star/NJBlog/blob/08be4473daa854e3e8942340998a6c282f3f8c44/libs/mocha/should.js#L302-L309 | train | |
mz121star/NJBlog | libs/mocha/should.js | function(type, desc){
this.assert(
type == typeof this.obj
, function(){ return 'expected ' + this.inspect + ' to be a ' + type + (desc ? " | " + desc : "") }
, function(){ return 'expected ' + this.inspect + ' not to be a ' + type + (desc ? " | " + desc : "") })
... | javascript | function(type, desc){
this.assert(
type == typeof this.obj
, function(){ return 'expected ' + this.inspect + ' to be a ' + type + (desc ? " | " + desc : "") }
, function(){ return 'expected ' + this.inspect + ' not to be a ' + type + (desc ? " | " + desc : "") })
... | [
"function",
"(",
"type",
",",
"desc",
")",
"{",
"this",
".",
"assert",
"(",
"type",
"==",
"typeof",
"this",
".",
"obj",
",",
"function",
"(",
")",
"{",
"return",
"'expected '",
"+",
"this",
".",
"inspect",
"+",
"' to be a '",
"+",
"type",
"+",
"(",
... | Assert typeof.
@param {Mixed} type
@param {String} description
@api public | [
"Assert",
"typeof",
"."
] | 08be4473daa854e3e8942340998a6c282f3f8c44 | https://github.com/mz121star/NJBlog/blob/08be4473daa854e3e8942340998a6c282f3f8c44/libs/mocha/should.js#L350-L356 | train | |
mz121star/NJBlog | libs/mocha/should.js | function(constructor, desc){
var name = constructor.name;
this.assert(
this.obj instanceof constructor
, function(){ return 'expected ' + this.inspect + ' to be an instance of ' + name + (desc ? " | " + desc : "") }
, function(){ return 'expected ' + this.inspect... | javascript | function(constructor, desc){
var name = constructor.name;
this.assert(
this.obj instanceof constructor
, function(){ return 'expected ' + this.inspect + ' to be an instance of ' + name + (desc ? " | " + desc : "") }
, function(){ return 'expected ' + this.inspect... | [
"function",
"(",
"constructor",
",",
"desc",
")",
"{",
"var",
"name",
"=",
"constructor",
".",
"name",
";",
"this",
".",
"assert",
"(",
"this",
".",
"obj",
"instanceof",
"constructor",
",",
"function",
"(",
")",
"{",
"return",
"'expected '",
"+",
"this",... | Assert instanceof.
@param {Function} constructor
@param {String} description
@api public | [
"Assert",
"instanceof",
"."
] | 08be4473daa854e3e8942340998a6c282f3f8c44 | https://github.com/mz121star/NJBlog/blob/08be4473daa854e3e8942340998a6c282f3f8c44/libs/mocha/should.js#L366-L373 | train | |
mz121star/NJBlog | libs/mocha/should.js | function(n, desc){
this.assert(
this.obj > n
, function(){ return 'expected ' + this.inspect + ' to be above ' + n + (desc ? " | " + desc : "") }
, function(){ return 'expected ' + this.inspect + ' to be below ' + n + (desc ? " | " + desc : "") });
return this;
... | javascript | function(n, desc){
this.assert(
this.obj > n
, function(){ return 'expected ' + this.inspect + ' to be above ' + n + (desc ? " | " + desc : "") }
, function(){ return 'expected ' + this.inspect + ' to be below ' + n + (desc ? " | " + desc : "") });
return this;
... | [
"function",
"(",
"n",
",",
"desc",
")",
"{",
"this",
".",
"assert",
"(",
"this",
".",
"obj",
">",
"n",
",",
"function",
"(",
")",
"{",
"return",
"'expected '",
"+",
"this",
".",
"inspect",
"+",
"' to be above '",
"+",
"n",
"+",
"(",
"desc",
"?",
... | Assert numeric value above _n_.
@param {Number} n
@param {String} description
@api public | [
"Assert",
"numeric",
"value",
"above",
"_n_",
"."
] | 08be4473daa854e3e8942340998a6c282f3f8c44 | https://github.com/mz121star/NJBlog/blob/08be4473daa854e3e8942340998a6c282f3f8c44/libs/mocha/should.js#L383-L389 | train | |
mz121star/NJBlog | libs/mocha/should.js | function(regexp, desc){
this.assert(
regexp.exec(this.obj)
, function(){ return 'expected ' + this.inspect + ' to match ' + regexp + (desc ? " | " + desc : "") }
, function(){ return 'expected ' + this.inspect + ' not to match ' + regexp + (desc ? " | " + desc : "") });
... | javascript | function(regexp, desc){
this.assert(
regexp.exec(this.obj)
, function(){ return 'expected ' + this.inspect + ' to match ' + regexp + (desc ? " | " + desc : "") }
, function(){ return 'expected ' + this.inspect + ' not to match ' + regexp + (desc ? " | " + desc : "") });
... | [
"function",
"(",
"regexp",
",",
"desc",
")",
"{",
"this",
".",
"assert",
"(",
"regexp",
".",
"exec",
"(",
"this",
".",
"obj",
")",
",",
"function",
"(",
")",
"{",
"return",
"'expected '",
"+",
"this",
".",
"inspect",
"+",
"' to match '",
"+",
"regexp... | Assert string value matches _regexp_.
@param {RegExp} regexp
@param {String} description
@api public | [
"Assert",
"string",
"value",
"matches",
"_regexp_",
"."
] | 08be4473daa854e3e8942340998a6c282f3f8c44 | https://github.com/mz121star/NJBlog/blob/08be4473daa854e3e8942340998a6c282f3f8c44/libs/mocha/should.js#L415-L421 | train | |
mz121star/NJBlog | libs/mocha/should.js | function(n, desc){
this.obj.should.have.property('length');
var len = this.obj.length;
this.assert(
n == len
, function(){ return 'expected ' + this.inspect + ' to have a length of ' + n + ' but got ' + len + (desc ? " | " + desc : "") }
, function(){ re... | javascript | function(n, desc){
this.obj.should.have.property('length');
var len = this.obj.length;
this.assert(
n == len
, function(){ return 'expected ' + this.inspect + ' to have a length of ' + n + ' but got ' + len + (desc ? " | " + desc : "") }
, function(){ re... | [
"function",
"(",
"n",
",",
"desc",
")",
"{",
"this",
".",
"obj",
".",
"should",
".",
"have",
".",
"property",
"(",
"'length'",
")",
";",
"var",
"len",
"=",
"this",
".",
"obj",
".",
"length",
";",
"this",
".",
"assert",
"(",
"n",
"==",
"len",
",... | Assert property "length" exists and has value of _n_.
@param {Number} n
@param {String} description
@api public | [
"Assert",
"property",
"length",
"exists",
"and",
"has",
"value",
"of",
"_n_",
"."
] | 08be4473daa854e3e8942340998a6c282f3f8c44 | https://github.com/mz121star/NJBlog/blob/08be4473daa854e3e8942340998a6c282f3f8c44/libs/mocha/should.js#L431-L439 | train | |
mz121star/NJBlog | libs/mocha/should.js | function(name, val, desc){
if (this.negate && undefined !== val) {
if (undefined === this.obj[name]) {
throw new Error(this.inspect + ' has no property ' + i(name) + (desc ? " | " + desc : ""));
}
} else {
this.assert(
undefined ... | javascript | function(name, val, desc){
if (this.negate && undefined !== val) {
if (undefined === this.obj[name]) {
throw new Error(this.inspect + ' has no property ' + i(name) + (desc ? " | " + desc : ""));
}
} else {
this.assert(
undefined ... | [
"function",
"(",
"name",
",",
"val",
",",
"desc",
")",
"{",
"if",
"(",
"this",
".",
"negate",
"&&",
"undefined",
"!==",
"val",
")",
"{",
"if",
"(",
"undefined",
"===",
"this",
".",
"obj",
"[",
"name",
"]",
")",
"{",
"throw",
"new",
"Error",
"(",
... | Assert property _name_ exists, with optional _val_.
@param {String} name
@param {Mixed} [val]
@param {String} description
@api public | [
"Assert",
"property",
"_name_",
"exists",
"with",
"optional",
"_val_",
"."
] | 08be4473daa854e3e8942340998a6c282f3f8c44 | https://github.com/mz121star/NJBlog/blob/08be4473daa854e3e8942340998a6c282f3f8c44/libs/mocha/should.js#L450-L472 | train | |
mz121star/NJBlog | libs/mocha/should.js | function(name, desc){
this.assert(
this.obj.hasOwnProperty(name)
, function(){ return 'expected ' + this.inspect + ' to have own property ' + i(name) + (desc ? " | " + desc : "") }
, function(){ return 'expected ' + this.inspect + ' to not have own property ' + i(name) + ... | javascript | function(name, desc){
this.assert(
this.obj.hasOwnProperty(name)
, function(){ return 'expected ' + this.inspect + ' to have own property ' + i(name) + (desc ? " | " + desc : "") }
, function(){ return 'expected ' + this.inspect + ' to not have own property ' + i(name) + ... | [
"function",
"(",
"name",
",",
"desc",
")",
"{",
"this",
".",
"assert",
"(",
"this",
".",
"obj",
".",
"hasOwnProperty",
"(",
"name",
")",
",",
"function",
"(",
")",
"{",
"return",
"'expected '",
"+",
"this",
".",
"inspect",
"+",
"' to have own property '"... | Assert own property _name_ exists.
@param {String} name
@param {String} description
@api public | [
"Assert",
"own",
"property",
"_name_",
"exists",
"."
] | 08be4473daa854e3e8942340998a6c282f3f8c44 | https://github.com/mz121star/NJBlog/blob/08be4473daa854e3e8942340998a6c282f3f8c44/libs/mocha/should.js#L482-L489 | train | |
mz121star/NJBlog | libs/mocha/should.js | function(obj, desc){
this.assert(
this.obj.some(function(item) { return eql(obj, item); })
, function(){ return 'expected ' + this.inspect + ' to include an object equal to ' + i(obj) + (desc ? " | " + desc : "") }
, function(){ return 'expected ' + this.inspect + ' to no... | javascript | function(obj, desc){
this.assert(
this.obj.some(function(item) { return eql(obj, item); })
, function(){ return 'expected ' + this.inspect + ' to include an object equal to ' + i(obj) + (desc ? " | " + desc : "") }
, function(){ return 'expected ' + this.inspect + ' to no... | [
"function",
"(",
"obj",
",",
"desc",
")",
"{",
"this",
".",
"assert",
"(",
"this",
".",
"obj",
".",
"some",
"(",
"function",
"(",
"item",
")",
"{",
"return",
"eql",
"(",
"obj",
",",
"item",
")",
";",
"}",
")",
",",
"function",
"(",
")",
"{",
... | Assert that an object equal to `obj` is present.
@param {Array} obj
@param {String} description
@api public | [
"Assert",
"that",
"an",
"object",
"equal",
"to",
"obj",
"is",
"present",
"."
] | 08be4473daa854e3e8942340998a6c282f3f8c44 | https://github.com/mz121star/NJBlog/blob/08be4473daa854e3e8942340998a6c282f3f8c44/libs/mocha/should.js#L524-L530 | train | |
mz121star/NJBlog | libs/mocha/should.js | function(obj){
console.warn('should.contain() is deprecated, use should.include()');
this.obj.should.be.an.instanceof(Array);
this.assert(
~this.obj.indexOf(obj)
, function(){ return 'expected ' + this.inspect + ' to contain ' + i(obj) }
, function(){ re... | javascript | function(obj){
console.warn('should.contain() is deprecated, use should.include()');
this.obj.should.be.an.instanceof(Array);
this.assert(
~this.obj.indexOf(obj)
, function(){ return 'expected ' + this.inspect + ' to contain ' + i(obj) }
, function(){ re... | [
"function",
"(",
"obj",
")",
"{",
"console",
".",
"warn",
"(",
"'should.contain() is deprecated, use should.include()'",
")",
";",
"this",
".",
"obj",
".",
"should",
".",
"be",
".",
"an",
".",
"instanceof",
"(",
"Array",
")",
";",
"this",
".",
"assert",
"(... | Assert that the array contains _obj_.
@param {Mixed} obj
@api public | [
"Assert",
"that",
"the",
"array",
"contains",
"_obj_",
"."
] | 08be4473daa854e3e8942340998a6c282f3f8c44 | https://github.com/mz121star/NJBlog/blob/08be4473daa854e3e8942340998a6c282f3f8c44/libs/mocha/should.js#L539-L547 | train | |
mz121star/NJBlog | libs/mocha/should.js | function(field, val){
this.obj.should
.have.property('headers').and
.have.property(field.toLowerCase(), val);
return this;
} | javascript | function(field, val){
this.obj.should
.have.property('headers').and
.have.property(field.toLowerCase(), val);
return this;
} | [
"function",
"(",
"field",
",",
"val",
")",
"{",
"this",
".",
"obj",
".",
"should",
".",
"have",
".",
"property",
"(",
"'headers'",
")",
".",
"and",
".",
"have",
".",
"property",
"(",
"field",
".",
"toLowerCase",
"(",
")",
",",
"val",
")",
";",
"r... | Assert that header `field` has the given `val`.
@param {String} field
@param {String} val
@return {Assertion} for chaining
@api public | [
"Assert",
"that",
"header",
"field",
"has",
"the",
"given",
"val",
"."
] | 08be4473daa854e3e8942340998a6c282f3f8c44 | https://github.com/mz121star/NJBlog/blob/08be4473daa854e3e8942340998a6c282f3f8c44/libs/mocha/should.js#L609-L614 | 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.