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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
Jam3/touches | index.js | getTargetTouch | function getTargetTouch (touches, target) {
return Array.prototype.slice.call(touches).filter(function (t) {
return t.target === target
})[0] || touches[0]
} | javascript | function getTargetTouch (touches, target) {
return Array.prototype.slice.call(touches).filter(function (t) {
return t.target === target
})[0] || touches[0]
} | [
"function",
"getTargetTouch",
"(",
"touches",
",",
"target",
")",
"{",
"return",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"touches",
")",
".",
"filter",
"(",
"function",
"(",
"t",
")",
"{",
"return",
"t",
".",
"target",
"===",
"target... | since we are adding events to a parent we can't rely on targetTouches | [
"since",
"we",
"are",
"adding",
"events",
"to",
"a",
"parent",
"we",
"can",
"t",
"rely",
"on",
"targetTouches"
] | c0efd9c43c26c31d54bf8cdb9ee7ce9b22c95eae | https://github.com/Jam3/touches/blob/c0efd9c43c26c31d54bf8cdb9ee7ce9b22c95eae/index.js#L107-L111 | train |
patik/within-viewport | demo/inc/demo.js | function () {
// Scroll or window resize
$(window).on('resize scrollstop', _updateBoxes);
// User entry
$('input[type="number"]').on('keyup change click', events.onBoundaryChange); // 'click' is for spinners on input[number] control
// Boundary toggle
... | javascript | function () {
// Scroll or window resize
$(window).on('resize scrollstop', _updateBoxes);
// User entry
$('input[type="number"]').on('keyup change click', events.onBoundaryChange); // 'click' is for spinners on input[number] control
// Boundary toggle
... | [
"function",
"(",
")",
"{",
"// Scroll or window resize",
"$",
"(",
"window",
")",
".",
"on",
"(",
"'resize scrollstop'",
",",
"_updateBoxes",
")",
";",
"// User entry",
"$",
"(",
"'input[type=\"number\"]'",
")",
".",
"on",
"(",
"'keyup change click'",
",",
"even... | Setup event listeners | [
"Setup",
"event",
"listeners"
] | a0dde75426e8f0e0b31efb296308ea2a4f458d1e | https://github.com/patik/within-viewport/blob/a0dde75426e8f0e0b31efb296308ea2a4f458d1e/demo/inc/demo.js#L57-L76 | train | |
patik/within-viewport | demo/inc/demo.js | function (evt) {
var target = evt.target;
var val = parseInt(target.value, 10);
var id = target.id;
// Positive value was entered (negative values are allowed, but the boundaries would be off screen)
if (val > 0) {
if ($showBoundsCheck.is(':ch... | javascript | function (evt) {
var target = evt.target;
var val = parseInt(target.value, 10);
var id = target.id;
// Positive value was entered (negative values are allowed, but the boundaries would be off screen)
if (val > 0) {
if ($showBoundsCheck.is(':ch... | [
"function",
"(",
"evt",
")",
"{",
"var",
"target",
"=",
"evt",
".",
"target",
";",
"var",
"val",
"=",
"parseInt",
"(",
"target",
".",
"value",
",",
"10",
")",
";",
"var",
"id",
"=",
"target",
".",
"id",
";",
"// Positive value was entered (negative value... | When a boundary value changes | [
"When",
"a",
"boundary",
"value",
"changes"
] | a0dde75426e8f0e0b31efb296308ea2a4f458d1e | https://github.com/patik/within-viewport/blob/a0dde75426e8f0e0b31efb296308ea2a4f458d1e/demo/inc/demo.js#L79-L103 | train | |
patik/within-viewport | demo/inc/demo.js | function (evt) {
// Ignore input fields
if ($(evt.target).is('input')) {
return true;
}
if (evt.shiftKey && 37 <= evt.keyCode && evt.keyCode <= 40) {
var key = 'key' + evt.keyCode;
var scrollVals = {
... | javascript | function (evt) {
// Ignore input fields
if ($(evt.target).is('input')) {
return true;
}
if (evt.shiftKey && 37 <= evt.keyCode && evt.keyCode <= 40) {
var key = 'key' + evt.keyCode;
var scrollVals = {
... | [
"function",
"(",
"evt",
")",
"{",
"// Ignore input fields",
"if",
"(",
"$",
"(",
"evt",
".",
"target",
")",
".",
"is",
"(",
"'input'",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"evt",
".",
"shiftKey",
"&&",
"37",
"<=",
"evt",
".",
"ke... | When shift + arrow key is pressed, nudge the page by 1px | [
"When",
"shift",
"+",
"arrow",
"key",
"is",
"pressed",
"nudge",
"the",
"page",
"by",
"1px"
] | a0dde75426e8f0e0b31efb296308ea2a4f458d1e | https://github.com/patik/within-viewport/blob/a0dde75426e8f0e0b31efb296308ea2a4f458d1e/demo/inc/demo.js#L119-L137 | train | |
patik/within-viewport | demo/inc/demo.js | _drawBound | function _drawBound (side, dist) {
dist += 'px';
switch (side) {
case 'top':
$('.boundary-top').css({
top: dist,
height: dist,
marginTop: '-' + dist
});
break;
case 'right... | javascript | function _drawBound (side, dist) {
dist += 'px';
switch (side) {
case 'top':
$('.boundary-top').css({
top: dist,
height: dist,
marginTop: '-' + dist
});
break;
case 'right... | [
"function",
"_drawBound",
"(",
"side",
",",
"dist",
")",
"{",
"dist",
"+=",
"'px'",
";",
"switch",
"(",
"side",
")",
"{",
"case",
"'top'",
":",
"$",
"(",
"'.boundary-top'",
")",
".",
"css",
"(",
"{",
"top",
":",
"dist",
",",
"height",
":",
"dist",
... | Overlay a boundary line on the viewport when one is set by the user | [
"Overlay",
"a",
"boundary",
"line",
"on",
"the",
"viewport",
"when",
"one",
"is",
"set",
"by",
"the",
"user"
] | a0dde75426e8f0e0b31efb296308ea2a4f458d1e | https://github.com/patik/within-viewport/blob/a0dde75426e8f0e0b31efb296308ea2a4f458d1e/demo/inc/demo.js#L177-L215 | train |
nodejitsu/jitsu | lib/jitsu/commands/apps.js | viewCloud | function viewCloud(app) {
if (!app.config || !app.config.cloud) {
jitsu.log.error('Error: The app ' + app.name.magenta + ' don\'t have any cloud config.');
jitsu.log.error('You need deploy your app before get any cloud config.');
return callback(new Error());
}
jitsu.log.info('Viewing clou... | javascript | function viewCloud(app) {
if (!app.config || !app.config.cloud) {
jitsu.log.error('Error: The app ' + app.name.magenta + ' don\'t have any cloud config.');
jitsu.log.error('You need deploy your app before get any cloud config.');
return callback(new Error());
}
jitsu.log.info('Viewing clou... | [
"function",
"viewCloud",
"(",
"app",
")",
"{",
"if",
"(",
"!",
"app",
".",
"config",
"||",
"!",
"app",
".",
"config",
".",
"cloud",
")",
"{",
"jitsu",
".",
"log",
".",
"error",
"(",
"'Error: The app '",
"+",
"app",
".",
"name",
".",
"magenta",
"+",... | Print the cloud information for the app and respond. | [
"Print",
"the",
"cloud",
"information",
"for",
"the",
"app",
"and",
"respond",
"."
] | b4a40605cb5b888ff13fc0b0f1cfa252ad0dd917 | https://github.com/nodejitsu/jitsu/blob/b4a40605cb5b888ff13fc0b0f1cfa252ad0dd917/lib/jitsu/commands/apps.js#L937-L946 | train |
nodejitsu/jitsu | lib/jitsu/commands/apps.js | setCloud | function setCloud(app) {
drones = drones || app.maxDrones;
ram = ram || (app.config.cloud ? app.config.cloud[0].ram : 256);
var cloud = {
datacenter: datacenter,
provider: provider,
drones: drones,
ram: ram
};
if (app.state === 'started') {
jitsu.log.info('App current... | javascript | function setCloud(app) {
drones = drones || app.maxDrones;
ram = ram || (app.config.cloud ? app.config.cloud[0].ram : 256);
var cloud = {
datacenter: datacenter,
provider: provider,
drones: drones,
ram: ram
};
if (app.state === 'started') {
jitsu.log.info('App current... | [
"function",
"setCloud",
"(",
"app",
")",
"{",
"drones",
"=",
"drones",
"||",
"app",
".",
"maxDrones",
";",
"ram",
"=",
"ram",
"||",
"(",
"app",
".",
"config",
".",
"cloud",
"?",
"app",
".",
"config",
".",
"cloud",
"[",
"0",
"]",
".",
"ram",
":",
... | 1. Print what cloud app is deployed in now. 2. Print new cloud app will be deployed to. 3. Start the app in the specified cloud. | [
"1",
".",
"Print",
"what",
"cloud",
"app",
"is",
"deployed",
"in",
"now",
".",
"2",
".",
"Print",
"new",
"cloud",
"app",
"will",
"be",
"deployed",
"to",
".",
"3",
".",
"Start",
"the",
"app",
"in",
"the",
"specified",
"cloud",
"."
] | b4a40605cb5b888ff13fc0b0f1cfa252ad0dd917 | https://github.com/nodejitsu/jitsu/blob/b4a40605cb5b888ff13fc0b0f1cfa252ad0dd917/lib/jitsu/commands/apps.js#L953-L999 | train |
nodejitsu/jitsu | lib/jitsu/commands/apps.js | viewApp | function viewApp() {
jitsu.log.info('Fetching app ' + name.magenta);
jitsu.apps.view(name, function (err, app) {
if (err) {
jitsu.log.error('App ' + name.magenta + ' doesn\'t exist on Nodejitsu yet!');
jitsu.log.help('Try running ' + 'jitsu deploy'.magenta);
return callback({});
... | javascript | function viewApp() {
jitsu.log.info('Fetching app ' + name.magenta);
jitsu.apps.view(name, function (err, app) {
if (err) {
jitsu.log.error('App ' + name.magenta + ' doesn\'t exist on Nodejitsu yet!');
jitsu.log.help('Try running ' + 'jitsu deploy'.magenta);
return callback({});
... | [
"function",
"viewApp",
"(",
")",
"{",
"jitsu",
".",
"log",
".",
"info",
"(",
"'Fetching app '",
"+",
"name",
".",
"magenta",
")",
";",
"jitsu",
".",
"apps",
".",
"view",
"(",
"name",
",",
"function",
"(",
"err",
",",
"app",
")",
"{",
"if",
"(",
"... | Retreive the app and call `setCloud` or `viewCloud` depending on what arguments have been passed. | [
"Retreive",
"the",
"app",
"and",
"call",
"setCloud",
"or",
"viewCloud",
"depending",
"on",
"what",
"arguments",
"have",
"been",
"passed",
"."
] | b4a40605cb5b888ff13fc0b0f1cfa252ad0dd917 | https://github.com/nodejitsu/jitsu/blob/b4a40605cb5b888ff13fc0b0f1cfa252ad0dd917/lib/jitsu/commands/apps.js#L1005-L1018 | train |
nodejitsu/jitsu | lib/jitsu/commands/apps.js | readApp | function readApp(next) {
jitsu.package.read(process.cwd(), function (err, pkg) {
if (err) {
callback(err);
}
name = pkg.name;
next();
});
} | javascript | function readApp(next) {
jitsu.package.read(process.cwd(), function (err, pkg) {
if (err) {
callback(err);
}
name = pkg.name;
next();
});
} | [
"function",
"readApp",
"(",
"next",
")",
"{",
"jitsu",
".",
"package",
".",
"read",
"(",
"process",
".",
"cwd",
"(",
")",
",",
"function",
"(",
"err",
",",
"pkg",
")",
"{",
"if",
"(",
"err",
")",
"{",
"callback",
"(",
"err",
")",
";",
"}",
"nam... | Read the app from the current directory. | [
"Read",
"the",
"app",
"from",
"the",
"current",
"directory",
"."
] | b4a40605cb5b888ff13fc0b0f1cfa252ad0dd917 | https://github.com/nodejitsu/jitsu/blob/b4a40605cb5b888ff13fc0b0f1cfa252ad0dd917/lib/jitsu/commands/apps.js#L1023-L1032 | train |
nodejitsu/jitsu | lib/jitsu/commands/users.js | setupUserNoUsername | function setupUserNoUsername(callback) {
//
// Attempt to get the password three times.
//
var tries = 0;
function offerReset (username) {
jitsu.prompt.get(['reset'], function (err, res) {
if (err) {
return callback(err);
}
if (/^y[es]+/i.test(res['request pa... | javascript | function setupUserNoUsername(callback) {
//
// Attempt to get the password three times.
//
var tries = 0;
function offerReset (username) {
jitsu.prompt.get(['reset'], function (err, res) {
if (err) {
return callback(err);
}
if (/^y[es]+/i.test(res['request pa... | [
"function",
"setupUserNoUsername",
"(",
"callback",
")",
"{",
"//",
"// Attempt to get the password three times.",
"//",
"var",
"tries",
"=",
"0",
";",
"function",
"offerReset",
"(",
"username",
")",
"{",
"jitsu",
".",
"prompt",
".",
"get",
"(",
"[",
"'reset'",
... | This is like setupUserNoWarn except that it only asks for your password. | [
"This",
"is",
"like",
"setupUserNoWarn",
"except",
"that",
"it",
"only",
"asks",
"for",
"your",
"password",
"."
] | b4a40605cb5b888ff13fc0b0f1cfa252ad0dd917 | https://github.com/nodejitsu/jitsu/blob/b4a40605cb5b888ff13fc0b0f1cfa252ad0dd917/lib/jitsu/commands/users.js#L33-L91 | train |
nodejitsu/jitsu | lib/jitsu/commands/databases.js | createDatabase | function createDatabase(database, callback) {
database.type = databases.alias(database.type);
//
// Make sure that the user is passing in a valid database type
//
if (databases.available.indexOf(database.type) === -1) {
jitsu.log.warn('Invalid database type ' + database.type.red);
data... | javascript | function createDatabase(database, callback) {
database.type = databases.alias(database.type);
//
// Make sure that the user is passing in a valid database type
//
if (databases.available.indexOf(database.type) === -1) {
jitsu.log.warn('Invalid database type ' + database.type.red);
data... | [
"function",
"createDatabase",
"(",
"database",
",",
"callback",
")",
"{",
"database",
".",
"type",
"=",
"databases",
".",
"alias",
"(",
"database",
".",
"type",
")",
";",
"//",
"// Make sure that the user is passing in a valid database type",
"//",
"if",
"(",
"dat... | Helper function to execute the database creation. | [
"Helper",
"function",
"to",
"execute",
"the",
"database",
"creation",
"."
] | b4a40605cb5b888ff13fc0b0f1cfa252ad0dd917 | https://github.com/nodejitsu/jitsu/blob/b4a40605cb5b888ff13fc0b0f1cfa252ad0dd917/lib/jitsu/commands/databases.js#L78-L115 | train |
nodejitsu/jitsu | lib/jitsu/package.js | isValid | function isValid(desc) {
if (desc.validator) {
if (desc.validator instanceof RegExp) {
return !desc.validator.test(value);
}
return !desc.validator(value);
}
return false;
} | javascript | function isValid(desc) {
if (desc.validator) {
if (desc.validator instanceof RegExp) {
return !desc.validator.test(value);
}
return !desc.validator(value);
}
return false;
} | [
"function",
"isValid",
"(",
"desc",
")",
"{",
"if",
"(",
"desc",
".",
"validator",
")",
"{",
"if",
"(",
"desc",
".",
"validator",
"instanceof",
"RegExp",
")",
"{",
"return",
"!",
"desc",
".",
"validator",
".",
"test",
"(",
"value",
")",
";",
"}",
"... | handle invalid values | [
"handle",
"invalid",
"values"
] | b4a40605cb5b888ff13fc0b0f1cfa252ad0dd917 | https://github.com/nodejitsu/jitsu/blob/b4a40605cb5b888ff13fc0b0f1cfa252ad0dd917/lib/jitsu/package.js#L179-L188 | train |
ciaranj/connect-auth | spec/lib/jspec.growl.js | function(cmd) {
var lines = [], line
with (JavaImporter(java.lang, java.io)) {
var proccess = Runtime.getRuntime().exec(Array.prototype.slice.call(arguments))
var stream = new DataInputStream(proccess.getInputStream())
while (line = stream.readLine())
lines.push(line + '')
... | javascript | function(cmd) {
var lines = [], line
with (JavaImporter(java.lang, java.io)) {
var proccess = Runtime.getRuntime().exec(Array.prototype.slice.call(arguments))
var stream = new DataInputStream(proccess.getInputStream())
while (line = stream.readLine())
lines.push(line + '')
... | [
"function",
"(",
"cmd",
")",
"{",
"var",
"lines",
"=",
"[",
"]",
",",
"line",
"with",
"(",
"JavaImporter",
"(",
"java",
".",
"lang",
",",
"java",
".",
"io",
")",
")",
"{",
"var",
"proccess",
"=",
"Runtime",
".",
"getRuntime",
"(",
")",
".",
"exec... | Execute the given _cmd_, returning an array of lines from stdout.
Examples:
Growl.exec('growlnotify', '-m', msg)
@param {string ...} cmd
@return {array}
@api public | [
"Execute",
"the",
"given",
"_cmd_",
"returning",
"an",
"array",
"of",
"lines",
"from",
"stdout",
"."
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.growl.js#L24-L34 | train | |
ciaranj/connect-auth | spec/lib/jspec.growl.js | function(path) {
return path.lastIndexOf('.') != -1 ?
path.slice(path.lastIndexOf('.') + 1, path.length) :
null
} | javascript | function(path) {
return path.lastIndexOf('.') != -1 ?
path.slice(path.lastIndexOf('.') + 1, path.length) :
null
} | [
"function",
"(",
"path",
")",
"{",
"return",
"path",
".",
"lastIndexOf",
"(",
"'.'",
")",
"!=",
"-",
"1",
"?",
"path",
".",
"slice",
"(",
"path",
".",
"lastIndexOf",
"(",
"'.'",
")",
"+",
"1",
",",
"path",
".",
"length",
")",
":",
"null",
"}"
] | Return the extension of the given _path_ or null.
@param {string} path
@return {string}
@api private | [
"Return",
"the",
"extension",
"of",
"the",
"given",
"_path_",
"or",
"null",
"."
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.growl.js#L44-L48 | train | |
ciaranj/connect-auth | spec/lib/jspec.growl.js | function(msg, options) {
options = options || {}
var args = ['growlnotify', '-m', msg]
if (!this.binVersion()) throw new Error('growlnotify executable is required')
if (image = options.image) {
var flag, ext = this.extname(image)
flag = flag || ext == 'icns' && 'iconpath'
... | javascript | function(msg, options) {
options = options || {}
var args = ['growlnotify', '-m', msg]
if (!this.binVersion()) throw new Error('growlnotify executable is required')
if (image = options.image) {
var flag, ext = this.extname(image)
flag = flag || ext == 'icns' && 'iconpath'
... | [
"function",
"(",
"msg",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
"var",
"args",
"=",
"[",
"'growlnotify'",
",",
"'-m'",
",",
"msg",
"]",
"if",
"(",
"!",
"this",
".",
"binVersion",
"(",
")",
")",
"throw",
"new",
"Error",
... | Send growl notification _msg_ with _options_.
Options:
- title Notification title
- sticky Make the notification stick (defaults to false)
- name Application name (defaults to growlnotify)
- image
- path to an icon sets --iconpath
- path to an image sets --image
- capitalized word sets --appIcon
- filename uses... | [
"Send",
"growl",
"notification",
"_msg_",
"with",
"_options_",
"."
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.growl.js#L86-L103 | train | |
ciaranj/connect-auth | spec/lib/jspec.shell.js | function() {
for (var name in this.commands)
if (this.commands.hasOwnProperty(name))
this.commands[name][1].length ?
this.main[name] = this.commands[name][1] :
this.main.__defineGetter__(name, this.commands[name][1])
} | javascript | function() {
for (var name in this.commands)
if (this.commands.hasOwnProperty(name))
this.commands[name][1].length ?
this.main[name] = this.commands[name][1] :
this.main.__defineGetter__(name, this.commands[name][1])
} | [
"function",
"(",
")",
"{",
"for",
"(",
"var",
"name",
"in",
"this",
".",
"commands",
")",
"if",
"(",
"this",
".",
"commands",
".",
"hasOwnProperty",
"(",
"name",
")",
")",
"this",
".",
"commands",
"[",
"name",
"]",
"[",
"1",
"]",
".",
"length",
"... | Start the interactive shell.
@api public | [
"Start",
"the",
"interactive",
"shell",
"."
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.shell.js#L28-L34 | train | |
ciaranj/connect-auth | examples/mac/app.js | createServer | function createServer () {
// Create server
var server = express.createServer();
// Configure Server
server.configure(function () {
// Built-in
server.use(express.methodOverride()); // Allow method override using _method form parameter
server.use(e... | javascript | function createServer () {
// Create server
var server = express.createServer();
// Configure Server
server.configure(function () {
// Built-in
server.use(express.methodOverride()); // Allow method override using _method form parameter
server.use(e... | [
"function",
"createServer",
"(",
")",
"{",
"// Create server",
"var",
"server",
"=",
"express",
".",
"createServer",
"(",
")",
";",
"// Configure Server",
"server",
".",
"configure",
"(",
"function",
"(",
")",
"{",
"// Built-in",
"server",
".",
"use",
"(",
"... | Create and configure server instance | [
"Create",
"and",
"configure",
"server",
"instance"
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/examples/mac/app.js#L9-L48 | train |
ciaranj/connect-auth | examples/mac/app.js | logConsole | function logConsole() {
return function (req, res, next) {
console.log('Received request: ' + req.method + ' ' + req.originalUrl);
next();
};
} | javascript | function logConsole() {
return function (req, res, next) {
console.log('Received request: ' + req.method + ' ' + req.originalUrl);
next();
};
} | [
"function",
"logConsole",
"(",
")",
"{",
"return",
"function",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"console",
".",
"log",
"(",
"'Received request: '",
"+",
"req",
".",
"method",
"+",
"' '",
"+",
"req",
".",
"originalUrl",
")",
";",
"next",
... | Log requests to console | [
"Log",
"requests",
"to",
"console"
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/examples/mac/app.js#L69-L77 | train |
ciaranj/connect-auth | lib/auth.strategies/http/mac.js | signRequest | function signRequest(method, URI, host, port, token, secret, hashMethod, timestamp, nonce, bodyHash) {
// Parse request URI
var uri = URL.parse(URI, true);
if (uri.pathname == null) {
// Error: Bad request URI
return "";
}
// Construct normalized request string
var normaliz... | javascript | function signRequest(method, URI, host, port, token, secret, hashMethod, timestamp, nonce, bodyHash) {
// Parse request URI
var uri = URL.parse(URI, true);
if (uri.pathname == null) {
// Error: Bad request URI
return "";
}
// Construct normalized request string
var normaliz... | [
"function",
"signRequest",
"(",
"method",
",",
"URI",
",",
"host",
",",
"port",
",",
"token",
",",
"secret",
",",
"hashMethod",
",",
"timestamp",
",",
"nonce",
",",
"bodyHash",
")",
"{",
"// Parse request URI",
"var",
"uri",
"=",
"URL",
".",
"parse",
"("... | Calculate the request signature | [
"Calculate",
"the",
"request",
"signature"
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/lib/auth.strategies/http/mac.js#L252-L310 | train |
ciaranj/connect-auth | lib/auth.strategies/http/mac.js | percentEscape | function percentEscape(value) {
// Percent-escape per specification
var escapedString = '';
for (var i = 0; i < value.length; i++) {
var char = value.charCodeAt(i);
if ((char >= 48 && char <= 57) || // 09
(char >= 65 && char <= 90) || // AZ
(char >= 9... | javascript | function percentEscape(value) {
// Percent-escape per specification
var escapedString = '';
for (var i = 0; i < value.length; i++) {
var char = value.charCodeAt(i);
if ((char >= 48 && char <= 57) || // 09
(char >= 65 && char <= 90) || // AZ
(char >= 9... | [
"function",
"percentEscape",
"(",
"value",
")",
"{",
"// Percent-escape per specification",
"var",
"escapedString",
"=",
"''",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"value",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"char",
"=",
"... | Percent encode values per custom specification | [
"Percent",
"encode",
"values",
"per",
"custom",
"specification"
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/lib/auth.strategies/http/mac.js#L315-L342 | train |
ciaranj/connect-auth | lib/auth.strategies/oauth/_oauthservices.js | function(requestParameters, next) {
if(self.providerProvidesValidateNotReplayClient) {
self.provider.validateNotReplayClient(requestParameters.oauth_consumer_key, requestParameters.oauth_token, requestParameters.oauth_timestamp, requestParameters.oauth_nonce, function(err, result) {
if(err) {
... | javascript | function(requestParameters, next) {
if(self.providerProvidesValidateNotReplayClient) {
self.provider.validateNotReplayClient(requestParameters.oauth_consumer_key, requestParameters.oauth_token, requestParameters.oauth_timestamp, requestParameters.oauth_nonce, function(err, result) {
if(err) {
... | [
"function",
"(",
"requestParameters",
",",
"next",
")",
"{",
"if",
"(",
"self",
".",
"providerProvidesValidateNotReplayClient",
")",
"{",
"self",
".",
"provider",
".",
"validateNotReplayClient",
"(",
"requestParameters",
".",
"oauth_consumer_key",
",",
"requestParamet... | Given all the requestParameters and the next step function, error out if the a replay is detected | [
"Given",
"all",
"the",
"requestParameters",
"and",
"the",
"next",
"step",
"function",
"error",
"out",
"if",
"the",
"a",
"replay",
"is",
"detected"
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/lib/auth.strategies/oauth/_oauthservices.js#L227-L245 | train | |
kartograph/kartograph.js | dist/kartograph.js | kdtree | function kdtree() {
var kdtree = {},
axes = ["x", "y"],
root,
points = [];
kdtree.axes = function(x) {
if (!arguments.length) return axes;
axes = x;
return kdtree;
};
kdtree.points = function(x) {
if (!arguments.length) return points;
points = x;
root = null;
retu... | javascript | function kdtree() {
var kdtree = {},
axes = ["x", "y"],
root,
points = [];
kdtree.axes = function(x) {
if (!arguments.length) return axes;
axes = x;
return kdtree;
};
kdtree.points = function(x) {
if (!arguments.length) return points;
points = x;
root = null;
retu... | [
"function",
"kdtree",
"(",
")",
"{",
"var",
"kdtree",
"=",
"{",
"}",
",",
"axes",
"=",
"[",
"\"x\"",
",",
"\"y\"",
"]",
",",
"root",
",",
"points",
"=",
"[",
"]",
";",
"kdtree",
".",
"axes",
"=",
"function",
"(",
"x",
")",
"{",
"if",
"(",
"!"... | kd-tree | [
"kd",
"-",
"tree"
] | d3d3f2e1d022cd8c40236d94659ca54fe6aa52c1 | https://github.com/kartograph/kartograph.js/blob/d3d3f2e1d022cd8c40236d94659ca54fe6aa52c1/dist/kartograph.js#L5238-L5305 | train |
ciaranj/connect-auth | spec/lib/jspec.js | function(path) {
if (JSpec.cache[path]) return JSpec.cache[path]
return JSpec.cache[path] =
JSpec.tryLoading(JSpec.options.fixturePath + '/' + path) ||
JSpec.tryLoading(JSpec.options.fixturePath + '/' + path + '.html')
} | javascript | function(path) {
if (JSpec.cache[path]) return JSpec.cache[path]
return JSpec.cache[path] =
JSpec.tryLoading(JSpec.options.fixturePath + '/' + path) ||
JSpec.tryLoading(JSpec.options.fixturePath + '/' + path + '.html')
} | [
"function",
"(",
"path",
")",
"{",
"if",
"(",
"JSpec",
".",
"cache",
"[",
"path",
"]",
")",
"return",
"JSpec",
".",
"cache",
"[",
"path",
"]",
"return",
"JSpec",
".",
"cache",
"[",
"path",
"]",
"=",
"JSpec",
".",
"tryLoading",
"(",
"JSpec",
".",
... | Load fixture at _path_.
Fixtures are resolved as:
- <path>
- <path>.html
@param {string} path
@return {string}
@api public | [
"Load",
"fixture",
"at",
"_path_",
"."
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L66-L71 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function(results, options) {
var uri = options.uri || 'http://' + window.location.host + '/results'
JSpec.post(uri, {
stats: JSpec.stats,
options: options,
results: map(results.allSuites, function(suite) {
if (suite.hasSpecs())
return {
... | javascript | function(results, options) {
var uri = options.uri || 'http://' + window.location.host + '/results'
JSpec.post(uri, {
stats: JSpec.stats,
options: options,
results: map(results.allSuites, function(suite) {
if (suite.hasSpecs())
return {
... | [
"function",
"(",
"results",
",",
"options",
")",
"{",
"var",
"uri",
"=",
"options",
".",
"uri",
"||",
"'http://'",
"+",
"window",
".",
"location",
".",
"host",
"+",
"'/results'",
"JSpec",
".",
"post",
"(",
"uri",
",",
"{",
"stats",
":",
"JSpec",
".",... | Report to server.
Options:
- uri specific uri to report to.
- verbose weither or not to output messages
- failuresOnly output failure messages only
@api public | [
"Report",
"to",
"server",
"."
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L89-L116 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function(results, options) {
var id = option('reportToId') || 'jspec'
var report = document.getElementById(id)
var failuresOnly = option('failuresOnly')
var classes = results.stats.failures ? 'has-failures' : ''
if (!report) throw 'JSpec requires the element #' + id + ' to output... | javascript | function(results, options) {
var id = option('reportToId') || 'jspec'
var report = document.getElementById(id)
var failuresOnly = option('failuresOnly')
var classes = results.stats.failures ? 'has-failures' : ''
if (!report) throw 'JSpec requires the element #' + id + ' to output... | [
"function",
"(",
"results",
",",
"options",
")",
"{",
"var",
"id",
"=",
"option",
"(",
"'reportToId'",
")",
"||",
"'jspec'",
"var",
"report",
"=",
"document",
".",
"getElementById",
"(",
"id",
")",
"var",
"failuresOnly",
"=",
"option",
"(",
"'failuresOnly'... | Default reporter, outputting to the DOM.
Options:
- reportToId id of element to output reports to, defaults to 'jspec'
- failuresOnly displays only suites with failing specs
@api public | [
"Default",
"reporter",
"outputting",
"to",
"the",
"DOM",
"."
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L128-L164 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function(results, options) {
failuresOnly = option('failuresOnly')
print(color("\n Passes: ", 'bold') + color(results.stats.passes, 'green') +
color(" Failures: ", 'bold') + color(results.stats.failures, 'red') +
color(" Duration: ", 'bold') + color(results.duration, 'gr... | javascript | function(results, options) {
failuresOnly = option('failuresOnly')
print(color("\n Passes: ", 'bold') + color(results.stats.passes, 'green') +
color(" Failures: ", 'bold') + color(results.stats.failures, 'red') +
color(" Duration: ", 'bold') + color(results.duration, 'gr... | [
"function",
"(",
"results",
",",
"options",
")",
"{",
"failuresOnly",
"=",
"option",
"(",
"'failuresOnly'",
")",
"print",
"(",
"color",
"(",
"\"\\n Passes: \"",
",",
"'bold'",
")",
"+",
"color",
"(",
"results",
".",
"stats",
".",
"passes",
",",
"'green'",
... | Terminal reporter.
@api public | [
"Terminal",
"reporter",
"."
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L172-L203 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function(results, options) {
console.log('')
console.log('Passes: ' + results.stats.passes + ' Failures: ' + results.stats.failures)
each(results.allSuites, function(suite) {
if (suite.ran) {
console.group(suite.description)
each(suite.specs, function(spec){
... | javascript | function(results, options) {
console.log('')
console.log('Passes: ' + results.stats.passes + ' Failures: ' + results.stats.failures)
each(results.allSuites, function(suite) {
if (suite.ran) {
console.group(suite.description)
each(suite.specs, function(spec){
... | [
"function",
"(",
"results",
",",
"options",
")",
"{",
"console",
".",
"log",
"(",
"''",
")",
"console",
".",
"log",
"(",
"'Passes: '",
"+",
"results",
".",
"stats",
".",
"passes",
"+",
"' Failures: '",
"+",
"results",
".",
"stats",
".",
"failures",
")"... | Console reporter.
@api public | [
"Console",
"reporter",
"."
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L211-L229 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function() {
return any(this.calls, function(call){
return self.expectedResult.an_instance_of ?
call.result.constructor == self.expectedResult.an_instance_of:
equal(self.expectedResult, call.result)
})
} | javascript | function() {
return any(this.calls, function(call){
return self.expectedResult.an_instance_of ?
call.result.constructor == self.expectedResult.an_instance_of:
equal(self.expectedResult, call.result)
})
} | [
"function",
"(",
")",
"{",
"return",
"any",
"(",
"this",
".",
"calls",
",",
"function",
"(",
"call",
")",
"{",
"return",
"self",
".",
"expectedResult",
".",
"an_instance_of",
"?",
"call",
".",
"result",
".",
"constructor",
"==",
"self",
".",
"expectedRes... | Check if any calls have passing results | [
"Check",
"if",
"any",
"calls",
"have",
"passing",
"results"
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L317-L323 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function() {
return any(this.calls, function(call){
return any(self.expectedArgs, function(i, arg){
return arg.an_instance_of ?
call.args[i].constructor == arg.an_instance_of:
equal(arg, call.args[i])
... | javascript | function() {
return any(this.calls, function(call){
return any(self.expectedArgs, function(i, arg){
return arg.an_instance_of ?
call.args[i].constructor == arg.an_instance_of:
equal(arg, call.args[i])
... | [
"function",
"(",
")",
"{",
"return",
"any",
"(",
"this",
".",
"calls",
",",
"function",
"(",
"call",
")",
"{",
"return",
"any",
"(",
"self",
".",
"expectedArgs",
",",
"function",
"(",
"i",
",",
"arg",
")",
"{",
"return",
"arg",
".",
"an_instance_of",... | Check if any arguments pass | [
"Check",
"if",
"any",
"arguments",
"pass"
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L353-L362 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function(description, body) {
var self = this
extend(this, {
body: body,
description: description,
suites: [],
specs: [],
ran: false,
hooks: { 'before' : [], 'after' : [], 'before_each' : [], 'after_each' : [] },
// Add a spec to the suite
... | javascript | function(description, body) {
var self = this
extend(this, {
body: body,
description: description,
suites: [],
specs: [],
ran: false,
hooks: { 'before' : [], 'after' : [], 'before_each' : [], 'after_each' : [] },
// Add a spec to the suite
... | [
"function",
"(",
"description",
",",
"body",
")",
"{",
"var",
"self",
"=",
"this",
"extend",
"(",
"this",
",",
"{",
"body",
":",
"body",
",",
"description",
":",
"description",
",",
"suites",
":",
"[",
"]",
",",
"specs",
":",
"[",
"]",
",",
"ran",
... | Specification Suite block object.
@param {string} description
@param {function} body
@api private | [
"Specification",
"Suite",
"block",
"object",
"."
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L421-L486 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function(description, body) {
var spec = new JSpec.Spec(description, body)
this.specs.push(spec)
JSpec.stats.specs++ // TODO: abstract
spec.suite = this
} | javascript | function(description, body) {
var spec = new JSpec.Spec(description, body)
this.specs.push(spec)
JSpec.stats.specs++ // TODO: abstract
spec.suite = this
} | [
"function",
"(",
"description",
",",
"body",
")",
"{",
"var",
"spec",
"=",
"new",
"JSpec",
".",
"Spec",
"(",
"description",
",",
"body",
")",
"this",
".",
"specs",
".",
"push",
"(",
"spec",
")",
"JSpec",
".",
"stats",
".",
"specs",
"++",
"// TODO: ab... | Add a spec to the suite | [
"Add",
"a",
"spec",
"to",
"the",
"suite"
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L433-L438 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function(description, body) {
var suite = new JSpec.Suite(description, body)
JSpec.allSuites.push(suite)
suite.name = suite.description
suite.description = this.description + ' ' + suite.description
this.suites.push(suite)
suite.suite = this
} | javascript | function(description, body) {
var suite = new JSpec.Suite(description, body)
JSpec.allSuites.push(suite)
suite.name = suite.description
suite.description = this.description + ' ' + suite.description
this.suites.push(suite)
suite.suite = this
} | [
"function",
"(",
"description",
",",
"body",
")",
"{",
"var",
"suite",
"=",
"new",
"JSpec",
".",
"Suite",
"(",
"description",
",",
"body",
")",
"JSpec",
".",
"allSuites",
".",
"push",
"(",
"suite",
")",
"suite",
".",
"name",
"=",
"suite",
".",
"descr... | Add a nested suite | [
"Add",
"a",
"nested",
"suite"
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L448-L455 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function(hook) {
if (this.suite) this.suite.hook(hook)
each(this.hooks[hook], function(body) {
JSpec.evalBody(body, "Error in hook '" + hook + "', suite '" + self.description + "': ")
})
} | javascript | function(hook) {
if (this.suite) this.suite.hook(hook)
each(this.hooks[hook], function(body) {
JSpec.evalBody(body, "Error in hook '" + hook + "', suite '" + self.description + "': ")
})
} | [
"function",
"(",
"hook",
")",
"{",
"if",
"(",
"this",
".",
"suite",
")",
"this",
".",
"suite",
".",
"hook",
"(",
"hook",
")",
"each",
"(",
"this",
".",
"hooks",
"[",
"hook",
"]",
",",
"function",
"(",
"body",
")",
"{",
"JSpec",
".",
"evalBody",
... | Invoke a hook in context to this suite | [
"Invoke",
"a",
"hook",
"in",
"context",
"to",
"this",
"suite"
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L459-L464 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function(description, body) {
extend(this, {
body: body,
description: description,
assertions: [],
// Add passing assertion
pass : function(message) {
this.assertions.push({ passed: true, message: message })
if (JSpec.assert) ++JSpec.st... | javascript | function(description, body) {
extend(this, {
body: body,
description: description,
assertions: [],
// Add passing assertion
pass : function(message) {
this.assertions.push({ passed: true, message: message })
if (JSpec.assert) ++JSpec.st... | [
"function",
"(",
"description",
",",
"body",
")",
"{",
"extend",
"(",
"this",
",",
"{",
"body",
":",
"body",
",",
"description",
":",
"description",
",",
"assertions",
":",
"[",
"]",
",",
"// Add passing assertion",
"pass",
":",
"function",
"(",
"message",... | Specification block object.
@param {string} description
@param {function} body
@api private | [
"Specification",
"block",
"object",
"."
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L496-L560 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function(message) {
this.assertions.push({ passed: true, message: message })
if (JSpec.assert) ++JSpec.stats.passes
} | javascript | function(message) {
this.assertions.push({ passed: true, message: message })
if (JSpec.assert) ++JSpec.stats.passes
} | [
"function",
"(",
"message",
")",
"{",
"this",
".",
"assertions",
".",
"push",
"(",
"{",
"passed",
":",
"true",
",",
"message",
":",
"message",
"}",
")",
"if",
"(",
"JSpec",
".",
"assert",
")",
"++",
"JSpec",
".",
"stats",
".",
"passes",
"}"
] | Add passing assertion | [
"Add",
"passing",
"assertion"
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L504-L507 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function(message) {
this.assertions.push({ passed: false, message: message })
if (JSpec.assert) ++JSpec.stats.failures
} | javascript | function(message) {
this.assertions.push({ passed: false, message: message })
if (JSpec.assert) ++JSpec.stats.failures
} | [
"function",
"(",
"message",
")",
"{",
"this",
".",
"assertions",
".",
"push",
"(",
"{",
"passed",
":",
"false",
",",
"message",
":",
"message",
"}",
")",
"if",
"(",
"JSpec",
".",
"assert",
")",
"++",
"JSpec",
".",
"stats",
".",
"failures",
"}"
] | Add failing assertion | [
"Add",
"failing",
"assertion"
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L511-L514 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function() {
each(this.assertions, function(assertion){
if (assertion.defer) assertion.run().report(), hook('afterAssertion', assertion)
})
} | javascript | function() {
each(this.assertions, function(assertion){
if (assertion.defer) assertion.run().report(), hook('afterAssertion', assertion)
})
} | [
"function",
"(",
")",
"{",
"each",
"(",
"this",
".",
"assertions",
",",
"function",
"(",
"assertion",
")",
"{",
"if",
"(",
"assertion",
".",
"defer",
")",
"assertion",
".",
"run",
"(",
")",
".",
"report",
"(",
")",
",",
"hook",
"(",
"'afterAssertion'... | Run deferred assertions | [
"Run",
"deferred",
"assertions"
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L518-L522 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function(object) {
var self = this
if (object == undefined || object == null) return 'null'
if (object === true) return 'true'
if (object === false) return 'false'
switch (typeof object) {
case 'number': return object
case 'string': return this.escapable.test(... | javascript | function(object) {
var self = this
if (object == undefined || object == null) return 'null'
if (object === true) return 'true'
if (object === false) return 'false'
switch (typeof object) {
case 'number': return object
case 'string': return this.escapable.test(... | [
"function",
"(",
"object",
")",
"{",
"var",
"self",
"=",
"this",
"if",
"(",
"object",
"==",
"undefined",
"||",
"object",
"==",
"null",
")",
"return",
"'null'",
"if",
"(",
"object",
"===",
"true",
")",
"return",
"'true'",
"if",
"(",
"object",
"===",
"... | JSON encode _object_.
@param {mixed} object
@return {string}
@api private | [
"JSON",
"encode",
"_object_",
"."
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L596-L620 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function(object) {
var module = object.constructor == JSpec.Module ? object : new JSpec.Module(object)
this.modules.push(module)
if ('init' in module) module.init()
if ('utilities' in module) extend(this.defaultContext, module.utilities)
if ('matchers' in module) this.addMatchers(module.ma... | javascript | function(object) {
var module = object.constructor == JSpec.Module ? object : new JSpec.Module(object)
this.modules.push(module)
if ('init' in module) module.init()
if ('utilities' in module) extend(this.defaultContext, module.utilities)
if ('matchers' in module) this.addMatchers(module.ma... | [
"function",
"(",
"object",
")",
"{",
"var",
"module",
"=",
"object",
".",
"constructor",
"==",
"JSpec",
".",
"Module",
"?",
"object",
":",
"new",
"JSpec",
".",
"Module",
"(",
"object",
")",
"this",
".",
"modules",
".",
"push",
"(",
"module",
")",
"if... | Include _object_ which may be a hash or Module instance.
@param {hash, Module} object
@return {JSpec}
@api public | [
"Include",
"_object_",
"which",
"may",
"be",
"a",
"hash",
"or",
"Module",
"instance",
"."
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L684-L697 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function(name, args) {
args = toArray(arguments, 1)
return inject(JSpec.modules, [], function(results, module){
if (typeof module[name] == 'function')
results.push(JSpec.evalHook(module, name, args))
})
} | javascript | function(name, args) {
args = toArray(arguments, 1)
return inject(JSpec.modules, [], function(results, module){
if (typeof module[name] == 'function')
results.push(JSpec.evalHook(module, name, args))
})
} | [
"function",
"(",
"name",
",",
"args",
")",
"{",
"args",
"=",
"toArray",
"(",
"arguments",
",",
"1",
")",
"return",
"inject",
"(",
"JSpec",
".",
"modules",
",",
"[",
"]",
",",
"function",
"(",
"results",
",",
"module",
")",
"{",
"if",
"(",
"typeof",... | Add a module hook _name_, which is immediately
called per module with the _args_ given. An array of
hook return values is returned.
@param {name} string
@param {...} args
@return {array}
@api private | [
"Add",
"a",
"module",
"hook",
"_name_",
"which",
"is",
"immediately",
"called",
"per",
"module",
"with",
"the",
"_args_",
"given",
".",
"An",
"array",
"of",
"hook",
"return",
"values",
"is",
"returned",
"."
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L710-L716 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function(module, name, args) {
hook('evaluatingHookBody', module, name)
try { return module[name].apply(module, args) }
catch(e) { error('Error in hook ' + module.name + '.' + name + ': ', e) }
} | javascript | function(module, name, args) {
hook('evaluatingHookBody', module, name)
try { return module[name].apply(module, args) }
catch(e) { error('Error in hook ' + module.name + '.' + name + ': ', e) }
} | [
"function",
"(",
"module",
",",
"name",
",",
"args",
")",
"{",
"hook",
"(",
"'evaluatingHookBody'",
",",
"module",
",",
"name",
")",
"try",
"{",
"return",
"module",
"[",
"name",
"]",
".",
"apply",
"(",
"module",
",",
"args",
")",
"}",
"catch",
"(",
... | Eval _module_ hook _name_ with _args_. Evaluates in context
to the module itself, JSpec, and JSpec.context.
@param {Module} module
@param {string} name
@param {array} args
@return {mixed}
@api private | [
"Eval",
"_module_",
"hook",
"_name_",
"with",
"_args_",
".",
"Evaluates",
"in",
"context",
"to",
"the",
"module",
"itself",
"JSpec",
"and",
"JSpec",
".",
"context",
"."
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L729-L733 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function(description) {
return find(this.allSuites, function(suite){
return suite.name == description || suite.description == description
})
} | javascript | function(description) {
return find(this.allSuites, function(suite){
return suite.name == description || suite.description == description
})
} | [
"function",
"(",
"description",
")",
"{",
"return",
"find",
"(",
"this",
".",
"allSuites",
",",
"function",
"(",
"suite",
")",
"{",
"return",
"suite",
".",
"name",
"==",
"description",
"||",
"suite",
".",
"description",
"==",
"description",
"}",
")",
"}"... | Find a suite by its description or name.
@param {string} description
@return {Suite}
@api private | [
"Find",
"a",
"suite",
"by",
"its",
"description",
"or",
"name",
"."
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L762-L766 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function(fromSuite, toSuite) {
each(fromSuite.specs, function(spec){
spec.assertions = []
toSuite.specs.push(spec)
})
} | javascript | function(fromSuite, toSuite) {
each(fromSuite.specs, function(spec){
spec.assertions = []
toSuite.specs.push(spec)
})
} | [
"function",
"(",
"fromSuite",
",",
"toSuite",
")",
"{",
"each",
"(",
"fromSuite",
".",
"specs",
",",
"function",
"(",
"spec",
")",
"{",
"spec",
".",
"assertions",
"=",
"[",
"]",
"toSuite",
".",
"specs",
".",
"push",
"(",
"spec",
")",
"}",
")",
"}"
... | Copy specs from one suite to another.
@param {Suite} fromSuite
@param {Suite} toSuite
@api public | [
"Copy",
"specs",
"from",
"one",
"suite",
"to",
"another",
"."
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L789-L794 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function(string, color) {
return "\u001B[" + {
bold : 1,
black : 30,
red : 31,
green : 32,
yellow : 33,
blue : 34,
magenta : 35,
cyan : 36,
white : 37
}[color] + 'm' + string + "\u001B[0m"
} | javascript | function(string, color) {
return "\u001B[" + {
bold : 1,
black : 30,
red : 31,
green : 32,
yellow : 33,
blue : 34,
magenta : 35,
cyan : 36,
white : 37
}[color] + 'm' + string + "\u001B[0m"
} | [
"function",
"(",
"string",
",",
"color",
")",
"{",
"return",
"\"\\u001B[\"",
"+",
"{",
"bold",
":",
"1",
",",
"black",
":",
"30",
",",
"red",
":",
"31",
",",
"green",
":",
"32",
",",
"yellow",
":",
"33",
",",
"blue",
":",
"34",
",",
"magenta",
... | Return ANSI-escaped colored string.
@param {string} string
@param {string} color
@return {string}
@api public | [
"Return",
"ANSI",
"-",
"escaped",
"colored",
"string",
"."
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L818-L830 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function(actual, expected, negate, name) {
return 'expected ' + puts(actual) + ' to ' +
(negate ? 'not ' : '') +
name.replace(/_/g, ' ') +
' ' + (expected.length > 1 ?
puts.apply(this, expected.slice(1)) :
'')
... | javascript | function(actual, expected, negate, name) {
return 'expected ' + puts(actual) + ' to ' +
(negate ? 'not ' : '') +
name.replace(/_/g, ' ') +
' ' + (expected.length > 1 ?
puts.apply(this, expected.slice(1)) :
'')
... | [
"function",
"(",
"actual",
",",
"expected",
",",
"negate",
",",
"name",
")",
"{",
"return",
"'expected '",
"+",
"puts",
"(",
"actual",
")",
"+",
"' to '",
"+",
"(",
"negate",
"?",
"'not '",
":",
"''",
")",
"+",
"name",
".",
"replace",
"(",
"/",
"_"... | Default matcher message callback.
@api private | [
"Default",
"matcher",
"message",
"callback",
"."
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L838-L845 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function(body) {
switch (body.constructor) {
case String:
if (captures = body.match(/^alias (\w+)/)) return JSpec.matchers[last(captures)]
if (body.length < 4) body = 'actual ' + body + ' expected'
return { match: function(actual, expected) { return eval(body) }}
... | javascript | function(body) {
switch (body.constructor) {
case String:
if (captures = body.match(/^alias (\w+)/)) return JSpec.matchers[last(captures)]
if (body.length < 4) body = 'actual ' + body + ' expected'
return { match: function(actual, expected) { return eval(body) }}
... | [
"function",
"(",
"body",
")",
"{",
"switch",
"(",
"body",
".",
"constructor",
")",
"{",
"case",
"String",
":",
"if",
"(",
"captures",
"=",
"body",
".",
"match",
"(",
"/",
"^alias (\\w+)",
"/",
")",
")",
"return",
"JSpec",
".",
"matchers",
"[",
"last"... | Normalize a matcher body
This process allows the following conversions until
the matcher is in its final normalized hash state.
- '==' becomes 'actual == expected'
- 'actual == expected' becomes 'return actual == expected'
- function(actual, expected) { return actual == expected } becomes
{ match : function(actual, e... | [
"Normalize",
"a",
"matcher",
"body"
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L880-L893 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function(key) {
return (value = query(key)) !== null ? value :
JSpec.options[key] || null
} | javascript | function(key) {
return (value = query(key)) !== null ? value :
JSpec.options[key] || null
} | [
"function",
"(",
"key",
")",
"{",
"return",
"(",
"value",
"=",
"query",
"(",
"key",
")",
")",
"!==",
"null",
"?",
"value",
":",
"JSpec",
".",
"options",
"[",
"key",
"]",
"||",
"null",
"}"
] | Get option value. This method first checks if
the option key has been set via the query string,
otherwise returning the options hash value.
@param {string} key
@return {mixed}
@api public | [
"Get",
"option",
"value",
".",
"This",
"method",
"first",
"checks",
"if",
"the",
"option",
"key",
"has",
"been",
"set",
"via",
"the",
"query",
"string",
"otherwise",
"returning",
"the",
"options",
"hash",
"value",
"."
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L905-L908 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function(a, b) {
if (typeof a != typeof b) return
if (a === b) return true
if (a instanceof RegExp)
return a.toString() === b.toString()
if (a instanceof Date)
return Number(a) === Number(b)
if (typeof a != 'object') return
if (a.length !== undefined)
... | javascript | function(a, b) {
if (typeof a != typeof b) return
if (a === b) return true
if (a instanceof RegExp)
return a.toString() === b.toString()
if (a instanceof Date)
return Number(a) === Number(b)
if (typeof a != 'object') return
if (a.length !== undefined)
... | [
"function",
"(",
"a",
",",
"b",
")",
"{",
"if",
"(",
"typeof",
"a",
"!=",
"typeof",
"b",
")",
"return",
"if",
"(",
"a",
"===",
"b",
")",
"return",
"true",
"if",
"(",
"a",
"instanceof",
"RegExp",
")",
"return",
"a",
".",
"toString",
"(",
")",
"=... | Check if object _a_, is equal to object _b_.
@param {object} a
@param {object} b
@return {bool}
@api private | [
"Check",
"if",
"object",
"_a_",
"is",
"equal",
"to",
"object",
"_b_",
"."
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L919-L937 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function(html) {
return html.toString()
.replace(/&/gmi, '&')
.replace(/"/gmi, '"')
.replace(/>/gmi, '>')
.replace(/</gmi, '<')
} | javascript | function(html) {
return html.toString()
.replace(/&/gmi, '&')
.replace(/"/gmi, '"')
.replace(/>/gmi, '>')
.replace(/</gmi, '<')
} | [
"function",
"(",
"html",
")",
"{",
"return",
"html",
".",
"toString",
"(",
")",
".",
"replace",
"(",
"/",
"&",
"/",
"gmi",
",",
"'&'",
")",
".",
"replace",
"(",
"/",
"\"",
"/",
"gmi",
",",
"'"'",
")",
".",
"replace",
"(",
"/",
">",
"/"... | Escape HTML.
@param {string} html
@return {string}
@api public | [
"Escape",
"HTML",
"."
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L1003-L1009 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function(actual, matcher, expected) {
var assertion = new JSpec.Assertion(JSpec.matchers[matcher], actual, toArray(arguments, 2))
return assertion.run().result
} | javascript | function(actual, matcher, expected) {
var assertion = new JSpec.Assertion(JSpec.matchers[matcher], actual, toArray(arguments, 2))
return assertion.run().result
} | [
"function",
"(",
"actual",
",",
"matcher",
",",
"expected",
")",
"{",
"var",
"assertion",
"=",
"new",
"JSpec",
".",
"Assertion",
"(",
"JSpec",
".",
"matchers",
"[",
"matcher",
"]",
",",
"actual",
",",
"toArray",
"(",
"arguments",
",",
"2",
")",
")",
... | Perform an assertion without reporting.
This method is primarily used for internal
matchers in order retain DRYness. May be invoked
like below:
does('foo', 'eql', 'foo')
does([1,2], 'include', 1, 2)
External hooks are not run for internal assertions
performed by does().
@param {mixed} actual
@param {string} match... | [
"Perform",
"an",
"assertion",
"without",
"reporting",
"."
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L1031-L1034 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function(actual) {
function assert(matcher, args, negate) {
var expected = toArray(args, 1)
matcher.negate = negate
assertion = new JSpec.Assertion(matcher, actual, expected, negate)
hook('beforeAssertion', assertion)
if (matcher.defer) assertion.run()
else JSpec.... | javascript | function(actual) {
function assert(matcher, args, negate) {
var expected = toArray(args, 1)
matcher.negate = negate
assertion = new JSpec.Assertion(matcher, actual, expected, negate)
hook('beforeAssertion', assertion)
if (matcher.defer) assertion.run()
else JSpec.... | [
"function",
"(",
"actual",
")",
"{",
"function",
"assert",
"(",
"matcher",
",",
"args",
",",
"negate",
")",
"{",
"var",
"expected",
"=",
"toArray",
"(",
"args",
",",
"1",
")",
"matcher",
".",
"negate",
"=",
"negate",
"assertion",
"=",
"new",
"JSpec",
... | Perform an assertion.
expect(true).to('be', true)
expect('foo').not_to('include', 'bar')
expect([1, [2]]).to('include', 1, [2])
@param {mixed} actual
@return {hash}
@api public | [
"Perform",
"an",
"assertion",
"."
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L1048-L1073 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function(callback, a, b) {
return callback.length == 1 ? callback(b) : callback(a, b)
} | javascript | function(callback, a, b) {
return callback.length == 1 ? callback(b) : callback(a, b)
} | [
"function",
"(",
"callback",
",",
"a",
",",
"b",
")",
"{",
"return",
"callback",
".",
"length",
"==",
"1",
"?",
"callback",
"(",
"b",
")",
":",
"callback",
"(",
"a",
",",
"b",
")",
"}"
] | Call an iterator callback with arguments a, or b
depending on the arity of the callback.
@param {function} callback
@param {mixed} a
@param {mixed} b
@return {mixed}
@api private | [
"Call",
"an",
"iterator",
"callback",
"with",
"arguments",
"a",
"or",
"b",
"depending",
"on",
"the",
"arity",
"of",
"the",
"callback",
"."
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L1101-L1103 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function(object, callback) {
if (object.constructor == Array)
for (var i = 0, len = object.length; i < len; ++i)
callIterator(callback, i, object[i])
else
for (var key in object)
if (object.hasOwnProperty(key))
callIterator(callback, key, object[key])
... | javascript | function(object, callback) {
if (object.constructor == Array)
for (var i = 0, len = object.length; i < len; ++i)
callIterator(callback, i, object[i])
else
for (var key in object)
if (object.hasOwnProperty(key))
callIterator(callback, key, object[key])
... | [
"function",
"(",
"object",
",",
"callback",
")",
"{",
"if",
"(",
"object",
".",
"constructor",
"==",
"Array",
")",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"object",
".",
"length",
";",
"i",
"<",
"len",
";",
"++",
"i",
")",
"callIterato... | Iterate an object, invoking the given callback.
@param {hash, array} object
@param {function} callback
@return {JSpec}
@api public | [
"Iterate",
"an",
"object",
"invoking",
"the",
"given",
"callback",
"."
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L1128-L1136 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function(object, memo, callback) {
each(object, function(key, value){
memo = (callback.length == 2 ?
callback(memo, value):
callback(memo, key, value)) ||
memo
})
return memo
} | javascript | function(object, memo, callback) {
each(object, function(key, value){
memo = (callback.length == 2 ?
callback(memo, value):
callback(memo, key, value)) ||
memo
})
return memo
} | [
"function",
"(",
"object",
",",
"memo",
",",
"callback",
")",
"{",
"each",
"(",
"object",
",",
"function",
"(",
"key",
",",
"value",
")",
"{",
"memo",
"=",
"(",
"callback",
".",
"length",
"==",
"2",
"?",
"callback",
"(",
"memo",
",",
"value",
")",
... | Iterate with memo.
@param {hash, array} object
@param {object} memo
@param {function} callback
@return {object}
@api public | [
"Iterate",
"with",
"memo",
"."
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L1148-L1156 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function(object, method) {
if (method) {
if (object['__prototype__' + method])
delete object[method]
else
object[method] = object['__original__' + method]
delete object['__prototype__' + method]
delete object['__original____' + method]
}
els... | javascript | function(object, method) {
if (method) {
if (object['__prototype__' + method])
delete object[method]
else
object[method] = object['__original__' + method]
delete object['__prototype__' + method]
delete object['__original____' + method]
}
els... | [
"function",
"(",
"object",
",",
"method",
")",
"{",
"if",
"(",
"method",
")",
"{",
"if",
"(",
"object",
"[",
"'__prototype__'",
"+",
"method",
"]",
")",
"delete",
"object",
"[",
"method",
"]",
"else",
"object",
"[",
"method",
"]",
"=",
"object",
"[",... | Destub _object_'s _method_. When no _method_ is passed
all stubbed methods are destubbed. When no arguments
are passed every object found in JSpec.stubbed will be
destubbed.
@param {mixed} object
@param {string} method
@api public | [
"Destub",
"_object_",
"s",
"_method_",
".",
"When",
"no",
"_method_",
"is",
"passed",
"all",
"stubbed",
"methods",
"are",
"destubbed",
".",
"When",
"no",
"arguments",
"are",
"passed",
"every",
"object",
"found",
"in",
"JSpec",
".",
"stubbed",
"will",
"be",
... | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L1169-L1186 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function(object, method) {
hook('stubbing', object, method)
JSpec.stubbed.push(object)
var type = object.hasOwnProperty(method) ? '__original__' : '__prototype__'
object[type + method] = object[method]
object[method] = function(){}
return {
and_return : function(value)... | javascript | function(object, method) {
hook('stubbing', object, method)
JSpec.stubbed.push(object)
var type = object.hasOwnProperty(method) ? '__original__' : '__prototype__'
object[type + method] = object[method]
object[method] = function(){}
return {
and_return : function(value)... | [
"function",
"(",
"object",
",",
"method",
")",
"{",
"hook",
"(",
"'stubbing'",
",",
"object",
",",
"method",
")",
"JSpec",
".",
"stubbed",
".",
"push",
"(",
"object",
")",
"var",
"type",
"=",
"object",
".",
"hasOwnProperty",
"(",
"method",
")",
"?",
... | Stub _object_'s _method_.
stub(foo, 'toString').and_return('bar')
@param {mixed} object
@param {string} method
@return {hash}
@api public | [
"Stub",
"_object_",
"s",
"_method_",
"."
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L1199-L1211 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function(object, callback) {
return inject(object, [], function(memo, key, value){
memo.push(callIterator(callback, key, value))
})
} | javascript | function(object, callback) {
return inject(object, [], function(memo, key, value){
memo.push(callIterator(callback, key, value))
})
} | [
"function",
"(",
"object",
",",
"callback",
")",
"{",
"return",
"inject",
"(",
"object",
",",
"[",
"]",
",",
"function",
"(",
"memo",
",",
"key",
",",
"value",
")",
"{",
"memo",
".",
"push",
"(",
"callIterator",
"(",
"callback",
",",
"key",
",",
"v... | Map callback return values.
@param {hash, array} object
@param {function} callback
@return {array}
@api public | [
"Map",
"callback",
"return",
"values",
"."
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L1222-L1226 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function(object, callback) {
return inject(object, null, function(state, key, value){
if (state == undefined)
return callIterator(callback, key, value) ? value : state
})
} | javascript | function(object, callback) {
return inject(object, null, function(state, key, value){
if (state == undefined)
return callIterator(callback, key, value) ? value : state
})
} | [
"function",
"(",
"object",
",",
"callback",
")",
"{",
"return",
"inject",
"(",
"object",
",",
"null",
",",
"function",
"(",
"state",
",",
"key",
",",
"value",
")",
"{",
"if",
"(",
"state",
"==",
"undefined",
")",
"return",
"callIterator",
"(",
"callbac... | Returns the first matching expression or null.
@param {hash, array} object
@param {function} callback
@return {mixed}
@api public | [
"Returns",
"the",
"first",
"matching",
"expression",
"or",
"null",
"."
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L1237-L1242 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function(object, callback) {
return inject(object, [], function(selected, key, value){
if (callIterator(callback, key, value))
selected.push(value)
})
} | javascript | function(object, callback) {
return inject(object, [], function(selected, key, value){
if (callIterator(callback, key, value))
selected.push(value)
})
} | [
"function",
"(",
"object",
",",
"callback",
")",
"{",
"return",
"inject",
"(",
"object",
",",
"[",
"]",
",",
"function",
"(",
"selected",
",",
"key",
",",
"value",
")",
"{",
"if",
"(",
"callIterator",
"(",
"callback",
",",
"key",
",",
"value",
")",
... | Returns an array of values collected when the callback
given evaluates to true.
@param {hash, array} object
@return {function} callback
@return {array}
@api public | [
"Returns",
"an",
"array",
"of",
"values",
"collected",
"when",
"the",
"callback",
"given",
"evaluates",
"to",
"true",
"."
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L1254-L1259 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function(name, body) {
hook('addingMatcher', name, body)
if (name.indexOf(' ') != -1) {
var matchers = name.split(/\s+/)
var prefix = matchers.shift()
each(matchers, function(name) {
JSpec.addMatcher(prefix + '_' + name, body(name))
})
}
this.matchers[na... | javascript | function(name, body) {
hook('addingMatcher', name, body)
if (name.indexOf(' ') != -1) {
var matchers = name.split(/\s+/)
var prefix = matchers.shift()
each(matchers, function(name) {
JSpec.addMatcher(prefix + '_' + name, body(name))
})
}
this.matchers[na... | [
"function",
"(",
"name",
",",
"body",
")",
"{",
"hook",
"(",
"'addingMatcher'",
",",
"name",
",",
"body",
")",
"if",
"(",
"name",
".",
"indexOf",
"(",
"' '",
")",
"!=",
"-",
"1",
")",
"{",
"var",
"matchers",
"=",
"name",
".",
"split",
"(",
"/",
... | Define a matcher.
@param {string} name
@param {hash, function, string} body
@api public | [
"Define",
"a",
"matcher",
"."
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L1282-L1293 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function(description, body) {
var suite = new JSpec.Suite(description, body)
hook('addingSuite', suite)
this.allSuites.push(suite)
this.suites.push(suite)
} | javascript | function(description, body) {
var suite = new JSpec.Suite(description, body)
hook('addingSuite', suite)
this.allSuites.push(suite)
this.suites.push(suite)
} | [
"function",
"(",
"description",
",",
"body",
")",
"{",
"var",
"suite",
"=",
"new",
"JSpec",
".",
"Suite",
"(",
"description",
",",
"body",
")",
"hook",
"(",
"'addingSuite'",
",",
"suite",
")",
"this",
".",
"allSuites",
".",
"push",
"(",
"suite",
")",
... | Add a root suite to JSpec.
@param {string} description
@param {body} function
@api public | [
"Add",
"a",
"root",
"suite",
"to",
"JSpec",
"."
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L1303-L1308 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function(body, errorMessage) {
var dsl = this.DSL || this.DSLs.snake
var matchers = this.matchers
var context = this.context || this.defaultContext
var contents = this.contentsOf(body)
hook('evaluatingBody', dsl, matchers, context, contents)
try { with (dsl){ with (context) { with (m... | javascript | function(body, errorMessage) {
var dsl = this.DSL || this.DSLs.snake
var matchers = this.matchers
var context = this.context || this.defaultContext
var contents = this.contentsOf(body)
hook('evaluatingBody', dsl, matchers, context, contents)
try { with (dsl){ with (context) { with (m... | [
"function",
"(",
"body",
",",
"errorMessage",
")",
"{",
"var",
"dsl",
"=",
"this",
".",
"DSL",
"||",
"this",
".",
"DSLs",
".",
"snake",
"var",
"matchers",
"=",
"this",
".",
"matchers",
"var",
"context",
"=",
"this",
".",
"context",
"||",
"this",
".",... | Evaluate a JSpec capture body.
@param {function} body
@param {string} errorMessage (optional)
@return {Type}
@api private | [
"Evaluate",
"a",
"JSpec",
"capture",
"body",
"."
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L1331-L1339 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function(input) {
if (typeof input != 'string') return
input = hookImmutable('preprocessing', input)
return input.
replace(/\t/g, ' ').
replace(/\r\n|\n|\r/g, '\n').
split('__END__')[0].
replace(/([\w\.]+)\.(stub|destub)\((.*?)\)$/gm, '$2($1, $3)').
replace(/de... | javascript | function(input) {
if (typeof input != 'string') return
input = hookImmutable('preprocessing', input)
return input.
replace(/\t/g, ' ').
replace(/\r\n|\n|\r/g, '\n').
split('__END__')[0].
replace(/([\w\.]+)\.(stub|destub)\((.*?)\)$/gm, '$2($1, $3)').
replace(/de... | [
"function",
"(",
"input",
")",
"{",
"if",
"(",
"typeof",
"input",
"!=",
"'string'",
")",
"return",
"input",
"=",
"hookImmutable",
"(",
"'preprocessing'",
",",
"input",
")",
"return",
"input",
".",
"replace",
"(",
"/",
"\\t",
"/",
"g",
",",
"' '",
")",... | Pre-process a string of JSpec.
@param {string} input
@return {string}
@api private | [
"Pre",
"-",
"process",
"a",
"string",
"of",
"JSpec",
"."
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L1349-L1367 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function(start, end) {
var current = parseInt(start), end = parseInt(end), values = [current]
if (end > current) while (++current <= end) values.push(current)
else while (--current >= end) values.push(current)
return '[' + values + ']'
} | javascript | function(start, end) {
var current = parseInt(start), end = parseInt(end), values = [current]
if (end > current) while (++current <= end) values.push(current)
else while (--current >= end) values.push(current)
return '[' + values + ']'
} | [
"function",
"(",
"start",
",",
"end",
")",
"{",
"var",
"current",
"=",
"parseInt",
"(",
"start",
")",
",",
"end",
"=",
"parseInt",
"(",
"end",
")",
",",
"values",
"=",
"[",
"current",
"]",
"if",
"(",
"end",
">",
"current",
")",
"while",
"(",
"++"... | Create a range string which can be evaluated to a native array.
@param {int} start
@param {int} end
@return {string}
@api public | [
"Create",
"a",
"range",
"string",
"which",
"can",
"be",
"evaluated",
"to",
"a",
"native",
"array",
"."
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L1378-L1383 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function() {
this.duration = Number(new Date) - this.start
hook('reporting', JSpec.options)
new (JSpec.options.reporter || JSpec.reporters.DOM)(JSpec, JSpec.options)
} | javascript | function() {
this.duration = Number(new Date) - this.start
hook('reporting', JSpec.options)
new (JSpec.options.reporter || JSpec.reporters.DOM)(JSpec, JSpec.options)
} | [
"function",
"(",
")",
"{",
"this",
".",
"duration",
"=",
"Number",
"(",
"new",
"Date",
")",
"-",
"this",
".",
"start",
"hook",
"(",
"'reporting'",
",",
"JSpec",
".",
"options",
")",
"new",
"(",
"JSpec",
".",
"options",
".",
"reporter",
"||",
"JSpec",... | Report on the results.
@api public | [
"Report",
"on",
"the",
"results",
"."
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L1391-L1395 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function(options) {
if (any(hook('running'), haveStopped)) return this
if (options) extend(this.options, options)
this.start = Number(new Date)
each(this.suites, function(suite) { JSpec.runSuite(suite) })
return this
} | javascript | function(options) {
if (any(hook('running'), haveStopped)) return this
if (options) extend(this.options, options)
this.start = Number(new Date)
each(this.suites, function(suite) { JSpec.runSuite(suite) })
return this
} | [
"function",
"(",
"options",
")",
"{",
"if",
"(",
"any",
"(",
"hook",
"(",
"'running'",
")",
",",
"haveStopped",
")",
")",
"return",
"this",
"if",
"(",
"options",
")",
"extend",
"(",
"this",
".",
"options",
",",
"options",
")",
"this",
".",
"start",
... | Run the spec suites. Options are merged
with JSpec options when present.
@param {hash} options
@return {JSpec}
@api public | [
"Run",
"the",
"spec",
"suites",
".",
"Options",
"are",
"merged",
"with",
"JSpec",
"options",
"when",
"present",
"."
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L1406-L1412 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function(suite) {
this.currentSuite = suite
this.evalBody(suite.body)
suite.ran = true
hook('beforeSuite', suite), suite.hook('before')
each(suite.specs, function(spec) {
hook('beforeSpec', spec)
suite.hook('before_each')
JSpec.runSpec(spec)
hook('afterSpec'... | javascript | function(suite) {
this.currentSuite = suite
this.evalBody(suite.body)
suite.ran = true
hook('beforeSuite', suite), suite.hook('before')
each(suite.specs, function(spec) {
hook('beforeSpec', spec)
suite.hook('before_each')
JSpec.runSpec(spec)
hook('afterSpec'... | [
"function",
"(",
"suite",
")",
"{",
"this",
".",
"currentSuite",
"=",
"suite",
"this",
".",
"evalBody",
"(",
"suite",
".",
"body",
")",
"suite",
".",
"ran",
"=",
"true",
"hook",
"(",
"'beforeSuite'",
",",
"suite",
")",
",",
"suite",
".",
"hook",
"(",... | Run a suite.
@param {Suite} suite
@api public | [
"Run",
"a",
"suite",
"."
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L1421-L1440 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function(spec) {
this.currentSpec = spec
try { this.evalBody(spec.body) }
catch (e) { fail(e) }
spec.runDeferredAssertions()
destub()
this.stats.specsFinished++
this.stats.assertions += spec.assertions.length
} | javascript | function(spec) {
this.currentSpec = spec
try { this.evalBody(spec.body) }
catch (e) { fail(e) }
spec.runDeferredAssertions()
destub()
this.stats.specsFinished++
this.stats.assertions += spec.assertions.length
} | [
"function",
"(",
"spec",
")",
"{",
"this",
".",
"currentSpec",
"=",
"spec",
"try",
"{",
"this",
".",
"evalBody",
"(",
"spec",
".",
"body",
")",
"}",
"catch",
"(",
"e",
")",
"{",
"fail",
"(",
"e",
")",
"}",
"spec",
".",
"runDeferredAssertions",
"(",... | Run a spec.
@param {Spec} spec
@api public | [
"Run",
"a",
"spec",
"."
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L1471-L1479 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function(dependency, message) {
hook('requiring', dependency, message)
try { eval(dependency) }
catch (e) { throw 'JSpec depends on ' + dependency + ' ' + message }
return this
} | javascript | function(dependency, message) {
hook('requiring', dependency, message)
try { eval(dependency) }
catch (e) { throw 'JSpec depends on ' + dependency + ' ' + message }
return this
} | [
"function",
"(",
"dependency",
",",
"message",
")",
"{",
"hook",
"(",
"'requiring'",
",",
"dependency",
",",
"message",
")",
"try",
"{",
"eval",
"(",
"dependency",
")",
"}",
"catch",
"(",
"e",
")",
"{",
"throw",
"'JSpec depends on '",
"+",
"dependency",
... | Require a dependency, with optional message.
@param {string} dependency
@param {string} message (optional)
@return {JSpec}
@api public | [
"Require",
"a",
"dependency",
"with",
"optional",
"message",
"."
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L1490-L1495 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function(key, queryString) {
var queryString = (queryString || (main.location ? main.location.search : null) || '').substring(1)
return inject(queryString.split('&'), null, function(value, pair){
parts = pair.split('=')
return parts[0] == key ? parts[1].replace(/%20|\+/gmi, ' ') : value
... | javascript | function(key, queryString) {
var queryString = (queryString || (main.location ? main.location.search : null) || '').substring(1)
return inject(queryString.split('&'), null, function(value, pair){
parts = pair.split('=')
return parts[0] == key ? parts[1].replace(/%20|\+/gmi, ' ') : value
... | [
"function",
"(",
"key",
",",
"queryString",
")",
"{",
"var",
"queryString",
"=",
"(",
"queryString",
"||",
"(",
"main",
".",
"location",
"?",
"main",
".",
"location",
".",
"search",
":",
"null",
")",
"||",
"''",
")",
".",
"substring",
"(",
"1",
")",
... | Query against the current query strings keys
or the queryString specified.
@param {string} key
@param {string} queryString
@return {string, null}
@api private | [
"Query",
"against",
"the",
"current",
"query",
"strings",
"keys",
"or",
"the",
"queryString",
"specified",
"."
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L1507-L1513 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function(message, e) {
if ('stack' in e)
require('util').puts(e.stack + '\n')
throw (message ? message : '') + e.toString() +
(e.line ? ' near line ' + e.line : '')
} | javascript | function(message, e) {
if ('stack' in e)
require('util').puts(e.stack + '\n')
throw (message ? message : '') + e.toString() +
(e.line ? ' near line ' + e.line : '')
} | [
"function",
"(",
"message",
",",
"e",
")",
"{",
"if",
"(",
"'stack'",
"in",
"e",
")",
"require",
"(",
"'util'",
")",
".",
"puts",
"(",
"e",
".",
"stack",
"+",
"'\\n'",
")",
"throw",
"(",
"message",
"?",
"message",
":",
"''",
")",
"+",
"e",
".",... | Throw a JSpec related error.
@param {string} message
@param {Exception} e
@api public | [
"Throw",
"a",
"JSpec",
"related",
"error",
"."
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L1523-L1528 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function(uri, data) {
if (any(hook('posting', uri, data), haveStopped)) return
var request = this.xhr()
request.open('POST', uri, false)
request.setRequestHeader('Content-Type', 'application/json')
request.send(JSpec.JSON.encode(data))
} | javascript | function(uri, data) {
if (any(hook('posting', uri, data), haveStopped)) return
var request = this.xhr()
request.open('POST', uri, false)
request.setRequestHeader('Content-Type', 'application/json')
request.send(JSpec.JSON.encode(data))
} | [
"function",
"(",
"uri",
",",
"data",
")",
"{",
"if",
"(",
"any",
"(",
"hook",
"(",
"'posting'",
",",
"uri",
",",
"data",
")",
",",
"haveStopped",
")",
")",
"return",
"var",
"request",
"=",
"this",
".",
"xhr",
"(",
")",
"request",
".",
"open",
"("... | Ad-hoc POST request for JSpec server usage.
@param {string} uri
@param {string} data
@api private | [
"Ad",
"-",
"hoc",
"POST",
"request",
"for",
"JSpec",
"server",
"usage",
"."
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L1538-L1544 | train | |
ciaranj/connect-auth | spec/lib/jspec.js | function(file, callback) {
if (any(hook('loading', file), haveStopped)) return
if ('readFile' in main)
return readFile(file)
else if (this.hasXhr()) {
var request = this.xhr()
request.open('GET', file, false)
request.send(null)
if (request.readyState == 4 &&
... | javascript | function(file, callback) {
if (any(hook('loading', file), haveStopped)) return
if ('readFile' in main)
return readFile(file)
else if (this.hasXhr()) {
var request = this.xhr()
request.open('GET', file, false)
request.send(null)
if (request.readyState == 4 &&
... | [
"function",
"(",
"file",
",",
"callback",
")",
"{",
"if",
"(",
"any",
"(",
"hook",
"(",
"'loading'",
",",
"file",
")",
",",
"haveStopped",
")",
")",
"return",
"if",
"(",
"'readFile'",
"in",
"main",
")",
"return",
"readFile",
"(",
"file",
")",
"else",... | Load a _file_'s contents.
@param {string} file
@param {function} callback
@return {string}
@api public | [
"Load",
"a",
"_file_",
"s",
"contents",
"."
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.js#L1611-L1626 | train | |
ciaranj/connect-auth | spec/lib/jspec.xhr.js | function(method, url, async, user, password) {
this.user = user
this.password = password
this.url = url
this.readyState = 1
this.method = method.toUpperCase()
if (async != undefined) this.async = async
if (this.async) this.onreadystatechange()
} | javascript | function(method, url, async, user, password) {
this.user = user
this.password = password
this.url = url
this.readyState = 1
this.method = method.toUpperCase()
if (async != undefined) this.async = async
if (this.async) this.onreadystatechange()
} | [
"function",
"(",
"method",
",",
"url",
",",
"async",
",",
"user",
",",
"password",
")",
"{",
"this",
".",
"user",
"=",
"user",
"this",
".",
"password",
"=",
"password",
"this",
".",
"url",
"=",
"url",
"this",
".",
"readyState",
"=",
"1",
"this",
".... | Open mock request. | [
"Open",
"mock",
"request",
"."
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.xhr.js#L57-L65 | train | |
ciaranj/connect-auth | spec/lib/jspec.xhr.js | function(data) {
var self = this
this.data = data
this.readyState = 4
if (this.method == 'HEAD') this.responseText = null
this.responseHeaders['content-length'] = (this.responseText || '').length
if(this.async) this.onreadystatechange()
lastRequest = function(){
return ... | javascript | function(data) {
var self = this
this.data = data
this.readyState = 4
if (this.method == 'HEAD') this.responseText = null
this.responseHeaders['content-length'] = (this.responseText || '').length
if(this.async) this.onreadystatechange()
lastRequest = function(){
return ... | [
"function",
"(",
"data",
")",
"{",
"var",
"self",
"=",
"this",
"this",
".",
"data",
"=",
"data",
"this",
".",
"readyState",
"=",
"4",
"if",
"(",
"this",
".",
"method",
"==",
"'HEAD'",
")",
"this",
".",
"responseText",
"=",
"null",
"this",
".",
"res... | Send request _data_. | [
"Send",
"request",
"_data_",
"."
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.xhr.js#L71-L81 | train | |
ciaranj/connect-auth | spec/lib/jspec.xhr.js | mockRequest | function mockRequest() {
return { and_return : function(body, type, status, headers) {
XMLHttpRequest = MockXMLHttpRequest
ActiveXObject = false
status = status || 200
headers = headers || {}
headers['content-type'] = type
JSpec.extend(XMLHttpRequest.prototype, {
response... | javascript | function mockRequest() {
return { and_return : function(body, type, status, headers) {
XMLHttpRequest = MockXMLHttpRequest
ActiveXObject = false
status = status || 200
headers = headers || {}
headers['content-type'] = type
JSpec.extend(XMLHttpRequest.prototype, {
response... | [
"function",
"mockRequest",
"(",
")",
"{",
"return",
"{",
"and_return",
":",
"function",
"(",
"body",
",",
"type",
",",
"status",
",",
"headers",
")",
"{",
"XMLHttpRequest",
"=",
"MockXMLHttpRequest",
"ActiveXObject",
"=",
"false",
"status",
"=",
"status",
"|... | Mock XMLHttpRequest requests.
mockRequest().and_return('some data', 'text/plain', 200, { 'X-SomeHeader' : 'somevalue' })
@return {hash}
@api public | [
"Mock",
"XMLHttpRequest",
"requests",
"."
] | 9b7c06461f58309136bace9c1abe9709dfb763f6 | https://github.com/ciaranj/connect-auth/blob/9b7c06461f58309136bace9c1abe9709dfb763f6/spec/lib/jspec.xhr.js#L139-L153 | train |
documentcloud/underscore-contrib | dist/underscore-contrib.js | function() {
return _.reduce(arguments, function(acc, elem) {
if (_.isArguments(elem)) {
return concat.call(acc, slice.call(elem));
}
else {
return concat.call(acc, elem);
}
}, []);
} | javascript | function() {
return _.reduce(arguments, function(acc, elem) {
if (_.isArguments(elem)) {
return concat.call(acc, slice.call(elem));
}
else {
return concat.call(acc, elem);
}
}, []);
} | [
"function",
"(",
")",
"{",
"return",
"_",
".",
"reduce",
"(",
"arguments",
",",
"function",
"(",
"acc",
",",
"elem",
")",
"{",
"if",
"(",
"_",
".",
"isArguments",
"(",
"elem",
")",
")",
"{",
"return",
"concat",
".",
"call",
"(",
"acc",
",",
"slic... | Concatenates one or more arrays given as arguments. If given objects and scalars as arguments `cat` will plop them down in place in the result array. If given an `arguments` object, `cat` will treat it like an array and concatenate it likewise. | [
"Concatenates",
"one",
"or",
"more",
"arrays",
"given",
"as",
"arguments",
".",
"If",
"given",
"objects",
"and",
"scalars",
"as",
"arguments",
"cat",
"will",
"plop",
"them",
"down",
"in",
"place",
"in",
"the",
"result",
"array",
".",
"If",
"given",
"an",
... | 1492ffbe04a62a838da89df6ebdf77d0ed0b9844 | https://github.com/documentcloud/underscore-contrib/blob/1492ffbe04a62a838da89df6ebdf77d0ed0b9844/dist/underscore-contrib.js#L37-L46 | train | |
documentcloud/underscore-contrib | dist/underscore-contrib.js | function(array, n, pad) {
var p = function(array) {
if (array == null) return [];
var part = _.take(array, n);
if (n === _.size(part)) {
return _.cons(part, p(_.drop(array, n)));
}
else {
return pad ? [_.take(_.cat(part, pad), n)] : [];
}
... | javascript | function(array, n, pad) {
var p = function(array) {
if (array == null) return [];
var part = _.take(array, n);
if (n === _.size(part)) {
return _.cons(part, p(_.drop(array, n)));
}
else {
return pad ? [_.take(_.cat(part, pad), n)] : [];
}
... | [
"function",
"(",
"array",
",",
"n",
",",
"pad",
")",
"{",
"var",
"p",
"=",
"function",
"(",
"array",
")",
"{",
"if",
"(",
"array",
"==",
"null",
")",
"return",
"[",
"]",
";",
"var",
"part",
"=",
"_",
".",
"take",
"(",
"array",
",",
"n",
")",
... | Takes an array and chunks it some number of times into sub-arrays of size n. Allows and optional padding array as the third argument to fill in the tail chunk when n is not sufficient to build chunks of the same size. | [
"Takes",
"an",
"array",
"and",
"chunks",
"it",
"some",
"number",
"of",
"times",
"into",
"sub",
"-",
"arrays",
"of",
"size",
"n",
".",
"Allows",
"and",
"optional",
"padding",
"array",
"as",
"the",
"third",
"argument",
"to",
"fill",
"in",
"the",
"tail",
... | 1492ffbe04a62a838da89df6ebdf77d0ed0b9844 | https://github.com/documentcloud/underscore-contrib/blob/1492ffbe04a62a838da89df6ebdf77d0ed0b9844/dist/underscore-contrib.js#L57-L72 | train | |
documentcloud/underscore-contrib | dist/underscore-contrib.js | function(array, n, step) {
step = (step != null) ? step : n;
var p = function(array, n, step) {
if (_.isEmpty(array)) return [];
return _.cons(_.take(array, n),
p(_.drop(array, step), n, step));
};
return p(array, n, step);
} | javascript | function(array, n, step) {
step = (step != null) ? step : n;
var p = function(array, n, step) {
if (_.isEmpty(array)) return [];
return _.cons(_.take(array, n),
p(_.drop(array, step), n, step));
};
return p(array, n, step);
} | [
"function",
"(",
"array",
",",
"n",
",",
"step",
")",
"{",
"step",
"=",
"(",
"step",
"!=",
"null",
")",
"?",
"step",
":",
"n",
";",
"var",
"p",
"=",
"function",
"(",
"array",
",",
"n",
",",
"step",
")",
"{",
"if",
"(",
"_",
".",
"isEmpty",
... | Takes an array and chunks it some number of times into sub-arrays of size n. If the array given cannot fill the size needs of the final chunk then a smaller chunk is used for the last. | [
"Takes",
"an",
"array",
"and",
"chunks",
"it",
"some",
"number",
"of",
"times",
"into",
"sub",
"-",
"arrays",
"of",
"size",
"n",
".",
"If",
"the",
"array",
"given",
"cannot",
"fill",
"the",
"size",
"needs",
"of",
"the",
"final",
"chunk",
"then",
"a",
... | 1492ffbe04a62a838da89df6ebdf77d0ed0b9844 | https://github.com/documentcloud/underscore-contrib/blob/1492ffbe04a62a838da89df6ebdf77d0ed0b9844/dist/underscore-contrib.js#L78-L89 | train | |
documentcloud/underscore-contrib | dist/underscore-contrib.js | function(array, fun) {
return _.cat.apply(null, _.map(array, fun));
} | javascript | function(array, fun) {
return _.cat.apply(null, _.map(array, fun));
} | [
"function",
"(",
"array",
",",
"fun",
")",
"{",
"return",
"_",
".",
"cat",
".",
"apply",
"(",
"null",
",",
"_",
".",
"map",
"(",
"array",
",",
"fun",
")",
")",
";",
"}"
] | Maps a function over an array and concatenates all of the results. | [
"Maps",
"a",
"function",
"over",
"an",
"array",
"and",
"concatenates",
"all",
"of",
"the",
"results",
"."
] | 1492ffbe04a62a838da89df6ebdf77d0ed0b9844 | https://github.com/documentcloud/underscore-contrib/blob/1492ffbe04a62a838da89df6ebdf77d0ed0b9844/dist/underscore-contrib.js#L92-L94 | train | |
documentcloud/underscore-contrib | dist/underscore-contrib.js | function(array, inter) {
if (!_.isArray(array)) throw new TypeError;
var sz = _.size(array);
if (sz === 0) return array;
if (sz === 1) return array;
return slice.call(_.mapcat(array, function(elem) {
return _.cons(elem, [inter]);
}), 0, -1);
} | javascript | function(array, inter) {
if (!_.isArray(array)) throw new TypeError;
var sz = _.size(array);
if (sz === 0) return array;
if (sz === 1) return array;
return slice.call(_.mapcat(array, function(elem) {
return _.cons(elem, [inter]);
}), 0, -1);
} | [
"function",
"(",
"array",
",",
"inter",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isArray",
"(",
"array",
")",
")",
"throw",
"new",
"TypeError",
";",
"var",
"sz",
"=",
"_",
".",
"size",
"(",
"array",
")",
";",
"if",
"(",
"sz",
"===",
"0",
")",
"re... | Returns an array with some item between each element of a given array. | [
"Returns",
"an",
"array",
"with",
"some",
"item",
"between",
"each",
"element",
"of",
"a",
"given",
"array",
"."
] | 1492ffbe04a62a838da89df6ebdf77d0ed0b9844 | https://github.com/documentcloud/underscore-contrib/blob/1492ffbe04a62a838da89df6ebdf77d0ed0b9844/dist/underscore-contrib.js#L98-L107 | train | |
documentcloud/underscore-contrib | dist/underscore-contrib.js | function(/* args */) {
if (!_.some(arguments)) return [];
if (arguments.length == 1) return arguments[0];
return _.filter(_.flatten(_.zip.apply(null, arguments), true), function(elem) {
return elem != null;
});
} | javascript | function(/* args */) {
if (!_.some(arguments)) return [];
if (arguments.length == 1) return arguments[0];
return _.filter(_.flatten(_.zip.apply(null, arguments), true), function(elem) {
return elem != null;
});
} | [
"function",
"(",
"/* args */",
")",
"{",
"if",
"(",
"!",
"_",
".",
"some",
"(",
"arguments",
")",
")",
"return",
"[",
"]",
";",
"if",
"(",
"arguments",
".",
"length",
"==",
"1",
")",
"return",
"arguments",
"[",
"0",
"]",
";",
"return",
"_",
".",
... | Weaves two or more arrays together | [
"Weaves",
"two",
"or",
"more",
"arrays",
"together"
] | 1492ffbe04a62a838da89df6ebdf77d0ed0b9844 | https://github.com/documentcloud/underscore-contrib/blob/1492ffbe04a62a838da89df6ebdf77d0ed0b9844/dist/underscore-contrib.js#L110-L117 | train | |
documentcloud/underscore-contrib | dist/underscore-contrib.js | function(array, index) {
return [_.take(array, index), _.drop(array, index)];
} | javascript | function(array, index) {
return [_.take(array, index), _.drop(array, index)];
} | [
"function",
"(",
"array",
",",
"index",
")",
"{",
"return",
"[",
"_",
".",
"take",
"(",
"array",
",",
"index",
")",
",",
"_",
".",
"drop",
"(",
"array",
",",
"index",
")",
"]",
";",
"}"
] | Returns an array with two internal arrays built from taking an original array and spliting it at an index. | [
"Returns",
"an",
"array",
"with",
"two",
"internal",
"arrays",
"built",
"from",
"taking",
"an",
"original",
"array",
"and",
"spliting",
"it",
"at",
"an",
"index",
"."
] | 1492ffbe04a62a838da89df6ebdf77d0ed0b9844 | https://github.com/documentcloud/underscore-contrib/blob/1492ffbe04a62a838da89df6ebdf77d0ed0b9844/dist/underscore-contrib.js#L134-L136 | train | |
documentcloud/underscore-contrib | dist/underscore-contrib.js | function(array, n) {
var ret = [];
var sz = _.size(array);
if (n <= 0) return [];
if (n === 1) return array;
for(var index = 0; index < sz; index += n) {
ret.push(array[index]);
}
return ret;
} | javascript | function(array, n) {
var ret = [];
var sz = _.size(array);
if (n <= 0) return [];
if (n === 1) return array;
for(var index = 0; index < sz; index += n) {
ret.push(array[index]);
}
return ret;
} | [
"function",
"(",
"array",
",",
"n",
")",
"{",
"var",
"ret",
"=",
"[",
"]",
";",
"var",
"sz",
"=",
"_",
".",
"size",
"(",
"array",
")",
";",
"if",
"(",
"n",
"<=",
"0",
")",
"return",
"[",
"]",
";",
"if",
"(",
"n",
"===",
"1",
")",
"return"... | Takes every nth item from an array, returning an array of the results. | [
"Takes",
"every",
"nth",
"item",
"from",
"an",
"array",
"returning",
"an",
"array",
"of",
"the",
"results",
"."
] | 1492ffbe04a62a838da89df6ebdf77d0ed0b9844 | https://github.com/documentcloud/underscore-contrib/blob/1492ffbe04a62a838da89df6ebdf77d0ed0b9844/dist/underscore-contrib.js#L154-L166 | train | |
documentcloud/underscore-contrib | dist/underscore-contrib.js | function(array, fun, init) {
var ret = [];
var acc = init;
_.each(array, function(v,k) {
acc = fun(acc, array[k]);
ret.push(acc);
});
return ret;
} | javascript | function(array, fun, init) {
var ret = [];
var acc = init;
_.each(array, function(v,k) {
acc = fun(acc, array[k]);
ret.push(acc);
});
return ret;
} | [
"function",
"(",
"array",
",",
"fun",
",",
"init",
")",
"{",
"var",
"ret",
"=",
"[",
"]",
";",
"var",
"acc",
"=",
"init",
";",
"_",
".",
"each",
"(",
"array",
",",
"function",
"(",
"v",
",",
"k",
")",
"{",
"acc",
"=",
"fun",
"(",
"acc",
","... | Returns an array of each intermediate stage of a call to a `reduce`-like function. | [
"Returns",
"an",
"array",
"of",
"each",
"intermediate",
"stage",
"of",
"a",
"call",
"to",
"a",
"reduce",
"-",
"like",
"function",
"."
] | 1492ffbe04a62a838da89df6ebdf77d0ed0b9844 | https://github.com/documentcloud/underscore-contrib/blob/1492ffbe04a62a838da89df6ebdf77d0ed0b9844/dist/underscore-contrib.js#L170-L180 | train | |
documentcloud/underscore-contrib | dist/underscore-contrib.js | function(array, pred) {
return _.filter(_.map(_.range(_.size(array)), function(i) {
return pred(i, array[i]);
}),
existy);
} | javascript | function(array, pred) {
return _.filter(_.map(_.range(_.size(array)), function(i) {
return pred(i, array[i]);
}),
existy);
} | [
"function",
"(",
"array",
",",
"pred",
")",
"{",
"return",
"_",
".",
"filter",
"(",
"_",
".",
"map",
"(",
"_",
".",
"range",
"(",
"_",
".",
"size",
"(",
"array",
")",
")",
",",
"function",
"(",
"i",
")",
"{",
"return",
"pred",
"(",
"i",
",",
... | Runs its given function on the index of the elements rather than the elements themselves, keeping all of the truthy values in the end. | [
"Runs",
"its",
"given",
"function",
"on",
"the",
"index",
"of",
"the",
"elements",
"rather",
"than",
"the",
"elements",
"themselves",
"keeping",
"all",
"of",
"the",
"truthy",
"values",
"in",
"the",
"end",
"."
] | 1492ffbe04a62a838da89df6ebdf77d0ed0b9844 | https://github.com/documentcloud/underscore-contrib/blob/1492ffbe04a62a838da89df6ebdf77d0ed0b9844/dist/underscore-contrib.js#L184-L189 | train | |
documentcloud/underscore-contrib | dist/underscore-contrib.js | function(array, pred) {
if (!isSeq(array)) throw new TypeError;
var sz = _.size(array);
for (var index = 0; index < sz; index++) {
if(!truthy(pred(array[index]))) {
break;
}
}
return _.take(array, index);
} | javascript | function(array, pred) {
if (!isSeq(array)) throw new TypeError;
var sz = _.size(array);
for (var index = 0; index < sz; index++) {
if(!truthy(pred(array[index]))) {
break;
}
}
return _.take(array, index);
} | [
"function",
"(",
"array",
",",
"pred",
")",
"{",
"if",
"(",
"!",
"isSeq",
"(",
"array",
")",
")",
"throw",
"new",
"TypeError",
";",
"var",
"sz",
"=",
"_",
".",
"size",
"(",
"array",
")",
";",
"for",
"(",
"var",
"index",
"=",
"0",
";",
"index",
... | Takes all items in an array while a given predicate returns truthy. | [
"Takes",
"all",
"items",
"in",
"an",
"array",
"while",
"a",
"given",
"predicate",
"returns",
"truthy",
"."
] | 1492ffbe04a62a838da89df6ebdf77d0ed0b9844 | https://github.com/documentcloud/underscore-contrib/blob/1492ffbe04a62a838da89df6ebdf77d0ed0b9844/dist/underscore-contrib.js#L255-L267 | train | |
documentcloud/underscore-contrib | dist/underscore-contrib.js | function(array, pred) {
return [_.takeWhile(array, pred), _.dropWhile(array, pred)];
} | javascript | function(array, pred) {
return [_.takeWhile(array, pred), _.dropWhile(array, pred)];
} | [
"function",
"(",
"array",
",",
"pred",
")",
"{",
"return",
"[",
"_",
".",
"takeWhile",
"(",
"array",
",",
"pred",
")",
",",
"_",
".",
"dropWhile",
"(",
"array",
",",
"pred",
")",
"]",
";",
"}"
] | Returns an array with two internal arrays built from taking an original array and spliting it at the index where a given function goes falsey. | [
"Returns",
"an",
"array",
"with",
"two",
"internal",
"arrays",
"built",
"from",
"taking",
"an",
"original",
"array",
"and",
"spliting",
"it",
"at",
"the",
"index",
"where",
"a",
"given",
"function",
"goes",
"falsey",
"."
] | 1492ffbe04a62a838da89df6ebdf77d0ed0b9844 | https://github.com/documentcloud/underscore-contrib/blob/1492ffbe04a62a838da89df6ebdf77d0ed0b9844/dist/underscore-contrib.js#L286-L288 | train | |
documentcloud/underscore-contrib | dist/underscore-contrib.js | function(array, fun){
if (_.isEmpty(array) || !existy(array)) return [];
var fst = _.first(array);
var fstVal = fun(fst);
var run = concat.call([fst], _.takeWhile(_.rest(array), function(e) {
return _.isEqual(fstVal, fun(e));
}));
return concat.call([run], _.... | javascript | function(array, fun){
if (_.isEmpty(array) || !existy(array)) return [];
var fst = _.first(array);
var fstVal = fun(fst);
var run = concat.call([fst], _.takeWhile(_.rest(array), function(e) {
return _.isEqual(fstVal, fun(e));
}));
return concat.call([run], _.... | [
"function",
"(",
"array",
",",
"fun",
")",
"{",
"if",
"(",
"_",
".",
"isEmpty",
"(",
"array",
")",
"||",
"!",
"existy",
"(",
"array",
")",
")",
"return",
"[",
"]",
";",
"var",
"fst",
"=",
"_",
".",
"first",
"(",
"array",
")",
";",
"var",
"fst... | Takes an array and partitions it as the given predicate changes truth sense. | [
"Takes",
"an",
"array",
"and",
"partitions",
"it",
"as",
"the",
"given",
"predicate",
"changes",
"truth",
"sense",
"."
] | 1492ffbe04a62a838da89df6ebdf77d0ed0b9844 | https://github.com/documentcloud/underscore-contrib/blob/1492ffbe04a62a838da89df6ebdf77d0ed0b9844/dist/underscore-contrib.js#L292-L302 | train | |
documentcloud/underscore-contrib | dist/underscore-contrib.js | function(array, fun) {
return _.reduce(array, function(x, y) {
return fun(x, y) ? x : y;
});
} | javascript | function(array, fun) {
return _.reduce(array, function(x, y) {
return fun(x, y) ? x : y;
});
} | [
"function",
"(",
"array",
",",
"fun",
")",
"{",
"return",
"_",
".",
"reduce",
"(",
"array",
",",
"function",
"(",
"x",
",",
"y",
")",
"{",
"return",
"fun",
"(",
"x",
",",
"y",
")",
"?",
"x",
":",
"y",
";",
"}",
")",
";",
"}"
] | Returns the 'best' value in an array based on the result of a given function. | [
"Returns",
"the",
"best",
"value",
"in",
"an",
"array",
"based",
"on",
"the",
"result",
"of",
"a",
"given",
"function",
"."
] | 1492ffbe04a62a838da89df6ebdf77d0ed0b9844 | https://github.com/documentcloud/underscore-contrib/blob/1492ffbe04a62a838da89df6ebdf77d0ed0b9844/dist/underscore-contrib.js#L306-L310 | train | |
documentcloud/underscore-contrib | dist/underscore-contrib.js | function(array, fun) {
if (!isSeq(array)) throw new TypeError("expected an array as the first argument");
return _.filter(_.map(array, function(e) {
return fun(e);
}), existy);
} | javascript | function(array, fun) {
if (!isSeq(array)) throw new TypeError("expected an array as the first argument");
return _.filter(_.map(array, function(e) {
return fun(e);
}), existy);
} | [
"function",
"(",
"array",
",",
"fun",
")",
"{",
"if",
"(",
"!",
"isSeq",
"(",
"array",
")",
")",
"throw",
"new",
"TypeError",
"(",
"\"expected an array as the first argument\"",
")",
";",
"return",
"_",
".",
"filter",
"(",
"_",
".",
"map",
"(",
"array",
... | Returns an array of existy results of a function over an source array. | [
"Returns",
"an",
"array",
"of",
"existy",
"results",
"of",
"a",
"function",
"over",
"an",
"source",
"array",
"."
] | 1492ffbe04a62a838da89df6ebdf77d0ed0b9844 | https://github.com/documentcloud/underscore-contrib/blob/1492ffbe04a62a838da89df6ebdf77d0ed0b9844/dist/underscore-contrib.js#L313-L319 | train | |
documentcloud/underscore-contrib | dist/underscore-contrib.js | function(obj, visitor, context) {
var result;
this.preorder(obj, function(value, key, parent) {
if (visitor.call(context, value, key, parent)) {
result = value;
return stopWalk;
}
}, context);
return result;
} | javascript | function(obj, visitor, context) {
var result;
this.preorder(obj, function(value, key, parent) {
if (visitor.call(context, value, key, parent)) {
result = value;
return stopWalk;
}
}, context);
return result;
} | [
"function",
"(",
"obj",
",",
"visitor",
",",
"context",
")",
"{",
"var",
"result",
";",
"this",
".",
"preorder",
"(",
"obj",
",",
"function",
"(",
"value",
",",
"key",
",",
"parent",
")",
"{",
"if",
"(",
"visitor",
".",
"call",
"(",
"context",
",",... | Performs a preorder traversal of `obj` and returns the first value which passes a truth test. | [
"Performs",
"a",
"preorder",
"traversal",
"of",
"obj",
"and",
"returns",
"the",
"first",
"value",
"which",
"passes",
"a",
"truth",
"test",
"."
] | 1492ffbe04a62a838da89df6ebdf77d0ed0b9844 | https://github.com/documentcloud/underscore-contrib/blob/1492ffbe04a62a838da89df6ebdf77d0ed0b9844/dist/underscore-contrib.js#L408-L417 | train | |
documentcloud/underscore-contrib | dist/underscore-contrib.js | function(obj, strategy, visitor, context) {
return this.filter(obj, strategy, function(value, key, parent) {
return !visitor.call(context, value, key, parent);
});
} | javascript | function(obj, strategy, visitor, context) {
return this.filter(obj, strategy, function(value, key, parent) {
return !visitor.call(context, value, key, parent);
});
} | [
"function",
"(",
"obj",
",",
"strategy",
",",
"visitor",
",",
"context",
")",
"{",
"return",
"this",
".",
"filter",
"(",
"obj",
",",
"strategy",
",",
"function",
"(",
"value",
",",
"key",
",",
"parent",
")",
"{",
"return",
"!",
"visitor",
".",
"call"... | Recursively traverses `obj` and returns all the elements for which a truth test fails. | [
"Recursively",
"traverses",
"obj",
"and",
"returns",
"all",
"the",
"elements",
"for",
"which",
"a",
"truth",
"test",
"fails",
"."
] | 1492ffbe04a62a838da89df6ebdf77d0ed0b9844 | https://github.com/documentcloud/underscore-contrib/blob/1492ffbe04a62a838da89df6ebdf77d0ed0b9844/dist/underscore-contrib.js#L433-L437 | train | |
documentcloud/underscore-contrib | dist/underscore-contrib.js | function(obj, visitor, context, traversalStrategy) {
traversalStrategy = traversalStrategy || this._traversalStrategy;
walkImpl(obj, traversalStrategy, null, visitor, context);
} | javascript | function(obj, visitor, context, traversalStrategy) {
traversalStrategy = traversalStrategy || this._traversalStrategy;
walkImpl(obj, traversalStrategy, null, visitor, context);
} | [
"function",
"(",
"obj",
",",
"visitor",
",",
"context",
",",
"traversalStrategy",
")",
"{",
"traversalStrategy",
"=",
"traversalStrategy",
"||",
"this",
".",
"_traversalStrategy",
";",
"walkImpl",
"(",
"obj",
",",
"traversalStrategy",
",",
"null",
",",
"visitor"... | Recursively traverses `obj` in a depth-first fashion, invoking the `visitor` function for each object only after traversing its children. `traversalStrategy` is intended for internal callers, and is not part of the public API. | [
"Recursively",
"traverses",
"obj",
"in",
"a",
"depth",
"-",
"first",
"fashion",
"invoking",
"the",
"visitor",
"function",
"for",
"each",
"object",
"only",
"after",
"traversing",
"its",
"children",
".",
"traversalStrategy",
"is",
"intended",
"for",
"internal",
"c... | 1492ffbe04a62a838da89df6ebdf77d0ed0b9844 | https://github.com/documentcloud/underscore-contrib/blob/1492ffbe04a62a838da89df6ebdf77d0ed0b9844/dist/underscore-contrib.js#L468-L471 | train | |
documentcloud/underscore-contrib | dist/underscore-contrib.js | function(obj, visitor, leafMemo, context) {
var reducer = function(value, key, parent, subResults) {
return visitor(subResults || leafMemo, value, key, parent);
};
return walkImpl(obj, this._traversalStrategy, null, reducer, context, true);
} | javascript | function(obj, visitor, leafMemo, context) {
var reducer = function(value, key, parent, subResults) {
return visitor(subResults || leafMemo, value, key, parent);
};
return walkImpl(obj, this._traversalStrategy, null, reducer, context, true);
} | [
"function",
"(",
"obj",
",",
"visitor",
",",
"leafMemo",
",",
"context",
")",
"{",
"var",
"reducer",
"=",
"function",
"(",
"value",
",",
"key",
",",
"parent",
",",
"subResults",
")",
"{",
"return",
"visitor",
"(",
"subResults",
"||",
"leafMemo",
",",
"... | Builds up a single value by doing a post-order traversal of `obj` and calling the `visitor` function on each object in the tree. For leaf objects, the `memo` argument to `visitor` is the value of the `leafMemo` argument to `reduce`. For non-leaf objects, `memo` is a collection of the results of calling `reduce` on the ... | [
"Builds",
"up",
"a",
"single",
"value",
"by",
"doing",
"a",
"post",
"-",
"order",
"traversal",
"of",
"obj",
"and",
"calling",
"the",
"visitor",
"function",
"on",
"each",
"object",
"in",
"the",
"tree",
".",
"For",
"leaf",
"objects",
"the",
"memo",
"argume... | 1492ffbe04a62a838da89df6ebdf77d0ed0b9844 | https://github.com/documentcloud/underscore-contrib/blob/1492ffbe04a62a838da89df6ebdf77d0ed0b9844/dist/underscore-contrib.js#L487-L492 | train | |
documentcloud/underscore-contrib | dist/underscore-contrib.js | function(fun) {
var fixArgs = _.rest(arguments);
var f = function() {
var args = fixArgs.slice();
var arg = 0;
for ( var i = 0; i < (args.length || arg < arguments.length); i++ ) {
if ( args[i] === _ ) {
args[i] = arguments[arg++];
}
}
... | javascript | function(fun) {
var fixArgs = _.rest(arguments);
var f = function() {
var args = fixArgs.slice();
var arg = 0;
for ( var i = 0; i < (args.length || arg < arguments.length); i++ ) {
if ( args[i] === _ ) {
args[i] = arguments[arg++];
}
}
... | [
"function",
"(",
"fun",
")",
"{",
"var",
"fixArgs",
"=",
"_",
".",
"rest",
"(",
"arguments",
")",
";",
"var",
"f",
"=",
"function",
"(",
")",
"{",
"var",
"args",
"=",
"fixArgs",
".",
"slice",
"(",
")",
";",
"var",
"arg",
"=",
"0",
";",
"for",
... | Fixes the arguments to a function based on the parameter template defined by the presence of values and the `_` placeholder. | [
"Fixes",
"the",
"arguments",
"to",
"a",
"function",
"based",
"on",
"the",
"parameter",
"template",
"defined",
"by",
"the",
"presence",
"of",
"values",
"and",
"the",
"_",
"placeholder",
"."
] | 1492ffbe04a62a838da89df6ebdf77d0ed0b9844 | https://github.com/documentcloud/underscore-contrib/blob/1492ffbe04a62a838da89df6ebdf77d0ed0b9844/dist/underscore-contrib.js#L602-L621 | train | |
documentcloud/underscore-contrib | dist/underscore-contrib.js | baseMapArgs | function baseMapArgs (fun, mapFun) {
return _.arity(fun.length, function () {
return fun.apply(this, __map.call(arguments, mapFun));
});
} | javascript | function baseMapArgs (fun, mapFun) {
return _.arity(fun.length, function () {
return fun.apply(this, __map.call(arguments, mapFun));
});
} | [
"function",
"baseMapArgs",
"(",
"fun",
",",
"mapFun",
")",
"{",
"return",
"_",
".",
"arity",
"(",
"fun",
".",
"length",
",",
"function",
"(",
")",
"{",
"return",
"fun",
".",
"apply",
"(",
"this",
",",
"__map",
".",
"call",
"(",
"arguments",
",",
"m... | Takes a target function and a mapping function. Returns a function that applies the mapper to its arguments before evaluating the body. | [
"Takes",
"a",
"target",
"function",
"and",
"a",
"mapping",
"function",
".",
"Returns",
"a",
"function",
"that",
"applies",
"the",
"mapper",
"to",
"its",
"arguments",
"before",
"evaluating",
"the",
"body",
"."
] | 1492ffbe04a62a838da89df6ebdf77d0ed0b9844 | https://github.com/documentcloud/underscore-contrib/blob/1492ffbe04a62a838da89df6ebdf77d0ed0b9844/dist/underscore-contrib.js#L757-L761 | train |
documentcloud/underscore-contrib | dist/underscore-contrib.js | function(/*, funs */){
var funs = (_.isArray(arguments[0])) ? arguments[0] : arguments;
return function(seed) {
return _.reduce(funs,
function(l,r) { return r(l); },
seed);
};
} | javascript | function(/*, funs */){
var funs = (_.isArray(arguments[0])) ? arguments[0] : arguments;
return function(seed) {
return _.reduce(funs,
function(l,r) { return r(l); },
seed);
};
} | [
"function",
"(",
"/*, funs */",
")",
"{",
"var",
"funs",
"=",
"(",
"_",
".",
"isArray",
"(",
"arguments",
"[",
"0",
"]",
")",
")",
"?",
"arguments",
"[",
"0",
"]",
":",
"arguments",
";",
"return",
"function",
"(",
"seed",
")",
"{",
"return",
"_",
... | Takes some number of functions, either as an array or variadically and returns a function that takes some value as its first argument and runs it through a pipeline of the original functions given. | [
"Takes",
"some",
"number",
"of",
"functions",
"either",
"as",
"an",
"array",
"or",
"variadically",
"and",
"returns",
"a",
"function",
"that",
"takes",
"some",
"value",
"as",
"its",
"first",
"argument",
"and",
"runs",
"it",
"through",
"a",
"pipeline",
"of",
... | 1492ffbe04a62a838da89df6ebdf77d0ed0b9844 | https://github.com/documentcloud/underscore-contrib/blob/1492ffbe04a62a838da89df6ebdf77d0ed0b9844/dist/underscore-contrib.js#L773-L781 | train | |
documentcloud/underscore-contrib | dist/underscore-contrib.js | function(/* preds */) {
var preds = arguments;
return function(array) {
return _.every(array, function(e) {
return _.every(preds, function(p) {
return p(e);
});
});
};
} | javascript | function(/* preds */) {
var preds = arguments;
return function(array) {
return _.every(array, function(e) {
return _.every(preds, function(p) {
return p(e);
});
});
};
} | [
"function",
"(",
"/* preds */",
")",
"{",
"var",
"preds",
"=",
"arguments",
";",
"return",
"function",
"(",
"array",
")",
"{",
"return",
"_",
".",
"every",
"(",
"array",
",",
"function",
"(",
"e",
")",
"{",
"return",
"_",
".",
"every",
"(",
"preds",
... | Composes a bunch of predicates into a single predicate that checks all elements of an array for conformance to all of the original predicates. | [
"Composes",
"a",
"bunch",
"of",
"predicates",
"into",
"a",
"single",
"predicate",
"that",
"checks",
"all",
"elements",
"of",
"an",
"array",
"for",
"conformance",
"to",
"all",
"of",
"the",
"original",
"predicates",
"."
] | 1492ffbe04a62a838da89df6ebdf77d0ed0b9844 | https://github.com/documentcloud/underscore-contrib/blob/1492ffbe04a62a838da89df6ebdf77d0ed0b9844/dist/underscore-contrib.js#L786-L796 | train | |
documentcloud/underscore-contrib | dist/underscore-contrib.js | function(/* preds */) {
var preds = arguments;
return function(array) {
return _.some(array, function(e) {
return _.some(preds, function(p) {
return p(e);
});
});
};
} | javascript | function(/* preds */) {
var preds = arguments;
return function(array) {
return _.some(array, function(e) {
return _.some(preds, function(p) {
return p(e);
});
});
};
} | [
"function",
"(",
"/* preds */",
")",
"{",
"var",
"preds",
"=",
"arguments",
";",
"return",
"function",
"(",
"array",
")",
"{",
"return",
"_",
".",
"some",
"(",
"array",
",",
"function",
"(",
"e",
")",
"{",
"return",
"_",
".",
"some",
"(",
"preds",
... | Composes a bunch of predicates into a single predicate that checks all elements of an array for conformance to any of the original predicates. | [
"Composes",
"a",
"bunch",
"of",
"predicates",
"into",
"a",
"single",
"predicate",
"that",
"checks",
"all",
"elements",
"of",
"an",
"array",
"for",
"conformance",
"to",
"any",
"of",
"the",
"original",
"predicates",
"."
] | 1492ffbe04a62a838da89df6ebdf77d0ed0b9844 | https://github.com/documentcloud/underscore-contrib/blob/1492ffbe04a62a838da89df6ebdf77d0ed0b9844/dist/underscore-contrib.js#L801-L811 | 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.