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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
react-components/react-loading-status-mixin | index.js | function() {
var self = this;
var children = self._children;
var prev = self.state.childrenLoadingStatus;
var isLoading = false;
for (var k in children) {
if (children[k]) {
isLoading = true;
break;
}
}
if (prev === isLoading) return;
self.setState({children... | javascript | function() {
var self = this;
var children = self._children;
var prev = self.state.childrenLoadingStatus;
var isLoading = false;
for (var k in children) {
if (children[k]) {
isLoading = true;
break;
}
}
if (prev === isLoading) return;
self.setState({children... | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"children",
"=",
"self",
".",
"_children",
";",
"var",
"prev",
"=",
"self",
".",
"state",
".",
"childrenLoadingStatus",
";",
"var",
"isLoading",
"=",
"false",
";",
"for",
"(",
"var",
... | Helper methods for updaing the child status
@api private | [
"Helper",
"methods",
"for",
"updaing",
"the",
"child",
"status"
] | 9138bd678508c4669aed69cf109bc1e7b6e61f3a | https://github.com/react-components/react-loading-status-mixin/blob/9138bd678508c4669aed69cf109bc1e7b6e61f3a/index.js#L96-L111 | train | |
react-components/react-loading-status-mixin | index.js | function(isLoaded) {
var self = this;
var isLoading = !isLoaded;
var state = self.state;
var prev = state.loadingStatus;
isLoading = isLoading || false;
state.loadingStatus = isLoading;
self._notifyParentLoadingStatus(prev, !self.isLoaded());
} | javascript | function(isLoaded) {
var self = this;
var isLoading = !isLoaded;
var state = self.state;
var prev = state.loadingStatus;
isLoading = isLoading || false;
state.loadingStatus = isLoading;
self._notifyParentLoadingStatus(prev, !self.isLoaded());
} | [
"function",
"(",
"isLoaded",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"isLoading",
"=",
"!",
"isLoaded",
";",
"var",
"state",
"=",
"self",
".",
"state",
";",
"var",
"prev",
"=",
"state",
".",
"loadingStatus",
";",
"isLoading",
"=",
"isLoading"... | child
Set the loaded status for the component
@param {Boolean} isLoaded
@api public | [
"child",
"Set",
"the",
"loaded",
"status",
"for",
"the",
"component"
] | 9138bd678508c4669aed69cf109bc1e7b6e61f3a | https://github.com/react-components/react-loading-status-mixin/blob/9138bd678508c4669aed69cf109bc1e7b6e61f3a/index.js#L131-L141 | train | |
react-components/react-loading-status-mixin | index.js | createScheduleStatusUpdate | function createScheduleStatusUpdate() {
var isChanging = false;
var shouldUpdate = false;
function update(self, fn) {
raf(function() {
if (self.isMounted()) fn();
isChanging = false;
if (shouldUpdate) update(self, fn);
shouldUpdate = false;
});
}
return function _scheduleStat... | javascript | function createScheduleStatusUpdate() {
var isChanging = false;
var shouldUpdate = false;
function update(self, fn) {
raf(function() {
if (self.isMounted()) fn();
isChanging = false;
if (shouldUpdate) update(self, fn);
shouldUpdate = false;
});
}
return function _scheduleStat... | [
"function",
"createScheduleStatusUpdate",
"(",
")",
"{",
"var",
"isChanging",
"=",
"false",
";",
"var",
"shouldUpdate",
"=",
"false",
";",
"function",
"update",
"(",
"self",
",",
"fn",
")",
"{",
"raf",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"self",
... | Create a schedule status update function that is debounced | [
"Create",
"a",
"schedule",
"status",
"update",
"function",
"that",
"is",
"debounced"
] | 9138bd678508c4669aed69cf109bc1e7b6e61f3a | https://github.com/react-components/react-loading-status-mixin/blob/9138bd678508c4669aed69cf109bc1e7b6e61f3a/index.js#L170-L189 | train |
shellzie/grunt-boot-server-async | tasks/boot_server_async.js | function(chunk){
if(printOutput){
if (chunk.indexOf(options.matchString) !== -1) {
child_process.stdout.removeListener('data', detachIfStarted);
printOutput = false;
done();
}
}
} | javascript | function(chunk){
if(printOutput){
if (chunk.indexOf(options.matchString) !== -1) {
child_process.stdout.removeListener('data', detachIfStarted);
printOutput = false;
done();
}
}
} | [
"function",
"(",
"chunk",
")",
"{",
"if",
"(",
"printOutput",
")",
"{",
"if",
"(",
"chunk",
".",
"indexOf",
"(",
"options",
".",
"matchString",
")",
"!==",
"-",
"1",
")",
"{",
"child_process",
".",
"stdout",
".",
"removeListener",
"(",
"'data'",
",",
... | detach the listener, which listens for changes in stdout, once matchString is output to terminal. otherwise, process will hang. | [
"detach",
"the",
"listener",
"which",
"listens",
"for",
"changes",
"in",
"stdout",
"once",
"matchString",
"is",
"output",
"to",
"terminal",
".",
"otherwise",
"process",
"will",
"hang",
"."
] | a992c7ccb0f837ee1a4e471fd66764b9cb22f132 | https://github.com/shellzie/grunt-boot-server-async/blob/a992c7ccb0f837ee1a4e471fd66764b9cb22f132/tasks/boot_server_async.js#L70-L78 | train | |
andrewscwei/requiem | src/dom/getClassIndex.js | getClassIndex | function getClassIndex(element, className) {
assertType(element, Node, false, 'Invalid element specified');
assertType(className, 'string', false, `Invalid class name: ${className}`);
let classList = element.className.split(' ');
return classList.indexOf(className);
} | javascript | function getClassIndex(element, className) {
assertType(element, Node, false, 'Invalid element specified');
assertType(className, 'string', false, `Invalid class name: ${className}`);
let classList = element.className.split(' ');
return classList.indexOf(className);
} | [
"function",
"getClassIndex",
"(",
"element",
",",
"className",
")",
"{",
"assertType",
"(",
"element",
",",
"Node",
",",
"false",
",",
"'Invalid element specified'",
")",
";",
"assertType",
"(",
"className",
",",
"'string'",
",",
"false",
",",
"`",
"${",
"cl... | Gets the index of a specified class in a DOM element,
@param {Node} element - Target element.
@param {string} className - Target class name.
@return {number} Index of given class name. -1 if not found.
@alias module:requiem~dom.getClassIndex | [
"Gets",
"the",
"index",
"of",
"a",
"specified",
"class",
"in",
"a",
"DOM",
"element"
] | c4182bfffc9841c6de5718f689ad3c2060511777 | https://github.com/andrewscwei/requiem/blob/c4182bfffc9841c6de5718f689ad3c2060511777/src/dom/getClassIndex.js#L17-L22 | train |
vkiding/jud-vue-render | src/render/browser/render/register.js | registerModuleEventListener | function registerModuleEventListener (name, module, meta) {
if (name !== 'globalEvent') {
module['addEventListener'] = function (evt, callbackId, options) {
return addEventListener.call(this, name, evt, callbackId, options)
}
module['removeAllEventListeners'] = function (evt) {
return removeAl... | javascript | function registerModuleEventListener (name, module, meta) {
if (name !== 'globalEvent') {
module['addEventListener'] = function (evt, callbackId, options) {
return addEventListener.call(this, name, evt, callbackId, options)
}
module['removeAllEventListeners'] = function (evt) {
return removeAl... | [
"function",
"registerModuleEventListener",
"(",
"name",
",",
"module",
",",
"meta",
")",
"{",
"if",
"(",
"name",
"!==",
"'globalEvent'",
")",
"{",
"module",
"[",
"'addEventListener'",
"]",
"=",
"function",
"(",
"evt",
",",
"callbackId",
",",
"options",
")",
... | register module event listener for every api module except 'globalEvent'. | [
"register",
"module",
"event",
"listener",
"for",
"every",
"api",
"module",
"except",
"globalEvent",
"."
] | 07d8ab08d0ef86cf2819e5f2bf1f4b06381f4d47 | https://github.com/vkiding/jud-vue-render/blob/07d8ab08d0ef86cf2819e5f2bf1f4b06381f4d47/src/render/browser/render/register.js#L10-L26 | train |
pzlr/build-core | lib/validators.js | declaration | function declaration(obj) {
const
{error, value} = joi.validate(obj, declarationSchema);
if (error) {
throw new TypeError(`Invalid declaration object: ${error.message}`);
}
return value;
} | javascript | function declaration(obj) {
const
{error, value} = joi.validate(obj, declarationSchema);
if (error) {
throw new TypeError(`Invalid declaration object: ${error.message}`);
}
return value;
} | [
"function",
"declaration",
"(",
"obj",
")",
"{",
"const",
"{",
"error",
",",
"value",
"}",
"=",
"joi",
".",
"validate",
"(",
"obj",
",",
"declarationSchema",
")",
";",
"if",
"(",
"error",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"`",
"${",
"error"... | Validates the specified package declaration
@template {T}
@param {T} obj
@returns {T} | [
"Validates",
"the",
"specified",
"package",
"declaration"
] | 11e20eda500682b9fa62c7804c66be1714df0df4 | https://github.com/pzlr/build-core/blob/11e20eda500682b9fa62c7804c66be1714df0df4/lib/validators.js#L70-L79 | train |
redisjs/jsr-server | lib/command/server/client.js | getname | function getname(req, res) {
res.send(null, req.conn.client.name);
} | javascript | function getname(req, res) {
res.send(null, req.conn.client.name);
} | [
"function",
"getname",
"(",
"req",
",",
"res",
")",
"{",
"res",
".",
"send",
"(",
"null",
",",
"req",
".",
"conn",
".",
"client",
".",
"name",
")",
";",
"}"
] | Respond to the GETNAME subcommand. | [
"Respond",
"to",
"the",
"GETNAME",
"subcommand",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/server/client.js#L22-L24 | train |
redisjs/jsr-server | lib/command/server/client.js | setname | function setname(req, res) {
req.conn.client.name = req.args[0];
res.send(null, Constants.OK);
} | javascript | function setname(req, res) {
req.conn.client.name = req.args[0];
res.send(null, Constants.OK);
} | [
"function",
"setname",
"(",
"req",
",",
"res",
")",
"{",
"req",
".",
"conn",
".",
"client",
".",
"name",
"=",
"req",
".",
"args",
"[",
"0",
"]",
";",
"res",
".",
"send",
"(",
"null",
",",
"Constants",
".",
"OK",
")",
";",
"}"
] | Respond to the SETNAME subcommand. | [
"Respond",
"to",
"the",
"SETNAME",
"subcommand",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/server/client.js#L29-L32 | train |
redisjs/jsr-server | lib/command/server/client.js | list | function list(req, res) {
var s = '';
this.state.connections.forEach(function(conn) {
s += conn.toString();
})
res.send(null, s);
} | javascript | function list(req, res) {
var s = '';
this.state.connections.forEach(function(conn) {
s += conn.toString();
})
res.send(null, s);
} | [
"function",
"list",
"(",
"req",
",",
"res",
")",
"{",
"var",
"s",
"=",
"''",
";",
"this",
".",
"state",
".",
"connections",
".",
"forEach",
"(",
"function",
"(",
"conn",
")",
"{",
"s",
"+=",
"conn",
".",
"toString",
"(",
")",
";",
"}",
")",
"re... | Respond to the LIST subcommand. | [
"Respond",
"to",
"the",
"LIST",
"subcommand",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/server/client.js#L37-L43 | train |
redisjs/jsr-server | lib/command/server/client.js | pause | function pause(req, res) {
res.send(null, Constants.OK);
this.state.pause(req.args[0]);
} | javascript | function pause(req, res) {
res.send(null, Constants.OK);
this.state.pause(req.args[0]);
} | [
"function",
"pause",
"(",
"req",
",",
"res",
")",
"{",
"res",
".",
"send",
"(",
"null",
",",
"Constants",
".",
"OK",
")",
";",
"this",
".",
"state",
".",
"pause",
"(",
"req",
".",
"args",
"[",
"0",
"]",
")",
";",
"}"
] | Respond to the PAUSE subcommand. | [
"Respond",
"to",
"the",
"PAUSE",
"subcommand",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/server/client.js#L48-L51 | train |
redisjs/jsr-server | lib/command/server/client.js | kill | function kill(req, res) {
// TODO: implement filters
var conn;
// single ip:port
if(req.args.length === 1) {
conn = req.args[0];
// shouldn't get here, however there is a possible
// race condition whereby the target connection quits
// between validate and execute
if(!conn) return res.send... | javascript | function kill(req, res) {
// TODO: implement filters
var conn;
// single ip:port
if(req.args.length === 1) {
conn = req.args[0];
// shouldn't get here, however there is a possible
// race condition whereby the target connection quits
// between validate and execute
if(!conn) return res.send... | [
"function",
"kill",
"(",
"req",
",",
"res",
")",
"{",
"// TODO: implement filters",
"var",
"conn",
";",
"// single ip:port",
"if",
"(",
"req",
".",
"args",
".",
"length",
"===",
"1",
")",
"{",
"conn",
"=",
"req",
".",
"args",
"[",
"0",
"]",
";",
"// ... | Respond to the KILL subcommand. | [
"Respond",
"to",
"the",
"KILL",
"subcommand",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/server/client.js#L56-L81 | train |
redisjs/jsr-server | lib/command/server/client.js | validate | function validate(cmd, args, info) {
AbstractCommand.prototype.validate.apply(this, arguments);
var sub = info.command.sub
, cmd = ('' + sub.cmd)
, args = sub.args
, timeout
, conn;
if(cmd === Constants.SUBCOMMAND.client.pause.name) {
timeout = parseInt('' + args[0]);
// redis returns: 't... | javascript | function validate(cmd, args, info) {
AbstractCommand.prototype.validate.apply(this, arguments);
var sub = info.command.sub
, cmd = ('' + sub.cmd)
, args = sub.args
, timeout
, conn;
if(cmd === Constants.SUBCOMMAND.client.pause.name) {
timeout = parseInt('' + args[0]);
// redis returns: 't... | [
"function",
"validate",
"(",
"cmd",
",",
"args",
",",
"info",
")",
"{",
"AbstractCommand",
".",
"prototype",
".",
"validate",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"var",
"sub",
"=",
"info",
".",
"command",
".",
"sub",
",",
"cmd",
"=... | Validate the CLIENT subcommands. | [
"Validate",
"the",
"CLIENT",
"subcommands",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/server/client.js#L86-L118 | train |
solid-live/solidbot | lib/bots/inbox.js | checkInbox | function checkInbox(uri, cert) {
console.log('checking inbox for:', uri, cert)
shell.ls([null, null, uri, cert], function(err, ret) {
if (err) {
console.error(err)
} else {
console.log(ret)
}
})
} | javascript | function checkInbox(uri, cert) {
console.log('checking inbox for:', uri, cert)
shell.ls([null, null, uri, cert], function(err, ret) {
if (err) {
console.error(err)
} else {
console.log(ret)
}
})
} | [
"function",
"checkInbox",
"(",
"uri",
",",
"cert",
")",
"{",
"console",
".",
"log",
"(",
"'checking inbox for:'",
",",
"uri",
",",
"cert",
")",
"shell",
".",
"ls",
"(",
"[",
"null",
",",
"null",
",",
"uri",
",",
"cert",
"]",
",",
"function",
"(",
"... | check a given inbox
@param {string} uri The inbox to check.
@param {string} cert Certificate location. | [
"check",
"a",
"given",
"inbox"
] | c91bfef38ab01f7f88fb6bf1b1bc4875aea0ceda | https://github.com/solid-live/solidbot/blob/c91bfef38ab01f7f88fb6bf1b1bc4875aea0ceda/lib/bots/inbox.js#L59-L69 | train |
kryo2k/connect-mongoose | index.js | MongooseStore | function MongooseStore(session, mongooseModel) {
var
self = this;
if(!session || !session.Store) {
throw 'express-session was not passed in constructor.';
}
if(!mongooseModel || !mongooseModel.findById) {
throw 'Mongoose Model was not passed in constructor.';
}
var Store = session.Store;
/**... | javascript | function MongooseStore(session, mongooseModel) {
var
self = this;
if(!session || !session.Store) {
throw 'express-session was not passed in constructor.';
}
if(!mongooseModel || !mongooseModel.findById) {
throw 'Mongoose Model was not passed in constructor.';
}
var Store = session.Store;
/**... | [
"function",
"MongooseStore",
"(",
"session",
",",
"mongooseModel",
")",
"{",
"var",
"self",
"=",
"this",
";",
"if",
"(",
"!",
"session",
"||",
"!",
"session",
".",
"Store",
")",
"{",
"throw",
"'express-session was not passed in constructor.'",
";",
"}",
"if",
... | MongooseStore bootstrap constructor
@param {Express} Session Instance of express-session
@param {Model} mongooseModel Model to use for sessions
@return {Function} | [
"MongooseStore",
"bootstrap",
"constructor"
] | 74672a6bac57abe765dea423256407c4dacb8225 | https://github.com/kryo2k/connect-mongoose/blob/74672a6bac57abe765dea423256407c4dacb8225/index.js#L36-L150 | train |
AckerApple/ack-host | modules/web.js | web | function web(){
this.router = routers
this.data = {}
this.data.portStruct = this.data.portStruct || {}
this.data.routers = {}
this.data.isClearRequires = this.data.isClearRequires || this.isProductionMode
this.data.consoleAll = this.data.consoleAll
this.data.consoleNonProductionErrors = true
return th... | javascript | function web(){
this.router = routers
this.data = {}
this.data.portStruct = this.data.portStruct || {}
this.data.routers = {}
this.data.isClearRequires = this.data.isClearRequires || this.isProductionMode
this.data.consoleAll = this.data.consoleAll
this.data.consoleNonProductionErrors = true
return th... | [
"function",
"web",
"(",
")",
"{",
"this",
".",
"router",
"=",
"routers",
"this",
".",
"data",
"=",
"{",
"}",
"this",
".",
"data",
".",
"portStruct",
"=",
"this",
".",
"data",
".",
"portStruct",
"||",
"{",
"}",
"this",
".",
"data",
".",
"routers",
... | request object CLASS
@scope: isClearRequires, consoleAll | [
"request",
"object",
"CLASS"
] | b8ff0563e236499a2b9add5bf1d3849b9137a520 | https://github.com/AckerApple/ack-host/blob/b8ff0563e236499a2b9add5bf1d3849b9137a520/modules/web.js#L19-L30 | train |
jonschlinkert/test-helpers | index.js | helpers | function helpers (options) {
extend(helpers, Options.prototype);
var opts = extend({}, options);
helpers.option('dir', opts.dir || 'test');
helpers.option('fixtures', helpers.options.dir + '/fixtures');
helpers.option('actual', helpers.options.dir + '/actual');
helpers.config(opts);
return helpers;
} | javascript | function helpers (options) {
extend(helpers, Options.prototype);
var opts = extend({}, options);
helpers.option('dir', opts.dir || 'test');
helpers.option('fixtures', helpers.options.dir + '/fixtures');
helpers.option('actual', helpers.options.dir + '/actual');
helpers.config(opts);
return helpers;
} | [
"function",
"helpers",
"(",
"options",
")",
"{",
"extend",
"(",
"helpers",
",",
"Options",
".",
"prototype",
")",
";",
"var",
"opts",
"=",
"extend",
"(",
"{",
"}",
",",
"options",
")",
";",
"helpers",
".",
"option",
"(",
"'dir'",
",",
"opts",
".",
... | Initialize `helpers` with default `options`.
```js
var helpers = require('test-helpers')
helpers({dir: 'test'})
```
@method `helpers`
@param {Object} `options` Default options to use.
@api public | [
"Initialize",
"helpers",
"with",
"default",
"options",
"."
] | d13879220299ca7c1bb00d64ff51b5c4e87d4020 | https://github.com/jonschlinkert/test-helpers/blob/d13879220299ca7c1bb00d64ff51b5c4e87d4020/index.js#L31-L40 | train |
nachos/nachos-config | lib/index.js | NachosConfig | function NachosConfig() {
var defaults = {
packages: nachosHome('packages'),
server: 'http://nachosjs.herokuapp.com',
defaults: {
shell: 'shell',
exts: {}
},
startup: []
};
debug('creating new settings file with these defaults: %j', defaults);
SettingsFile.call(this, 'nachos', ... | javascript | function NachosConfig() {
var defaults = {
packages: nachosHome('packages'),
server: 'http://nachosjs.herokuapp.com',
defaults: {
shell: 'shell',
exts: {}
},
startup: []
};
debug('creating new settings file with these defaults: %j', defaults);
SettingsFile.call(this, 'nachos', ... | [
"function",
"NachosConfig",
"(",
")",
"{",
"var",
"defaults",
"=",
"{",
"packages",
":",
"nachosHome",
"(",
"'packages'",
")",
",",
"server",
":",
"'http://nachosjs.herokuapp.com'",
",",
"defaults",
":",
"{",
"shell",
":",
"'shell'",
",",
"exts",
":",
"{",
... | Creating a settings file with nachos defaults
@constructor | [
"Creating",
"a",
"settings",
"file",
"with",
"nachos",
"defaults"
] | 310d6b2b0157e611d8a88bf55cc2a473966d8b8e | https://github.com/nachos/nachos-config/blob/310d6b2b0157e611d8a88bf55cc2a473966d8b8e/lib/index.js#L14-L30 | train |
MakerCollider/node-red-contrib-smartnode-hook | html/scripts/highchart/modules/funnel.src.js | function () {
var data = this.data,
labelDistance = this.options.dataLabels.distance,
leftSide,
sign,
point,
i = data.length,
x,
y;
// In the original pie label anticollision logic, the slots are distributed
// from one labelDistance above to one labelDistance below the pie. In funnels
/... | javascript | function () {
var data = this.data,
labelDistance = this.options.dataLabels.distance,
leftSide,
sign,
point,
i = data.length,
x,
y;
// In the original pie label anticollision logic, the slots are distributed
// from one labelDistance above to one labelDistance below the pie. In funnels
/... | [
"function",
"(",
")",
"{",
"var",
"data",
"=",
"this",
".",
"data",
",",
"labelDistance",
"=",
"this",
".",
"options",
".",
"dataLabels",
".",
"distance",
",",
"leftSide",
",",
"sign",
",",
"point",
",",
"i",
"=",
"data",
".",
"length",
",",
"x",
"... | Extend the pie data label method | [
"Extend",
"the",
"pie",
"data",
"label",
"method"
] | 245c267e832968bad880ca009929043e82c7bc25 | https://github.com/MakerCollider/node-red-contrib-smartnode-hook/blob/245c267e832968bad880ca009929043e82c7bc25/html/scripts/highchart/modules/funnel.src.js#L256-L293 | train | |
gethuman/jyt | lib/jyt.plugins.js | addPluginsToScope | function addPluginsToScope(scope) {
var name;
for (name in plugins) {
if (plugins.hasOwnProperty(name)) {
scope[name] = plugins[name];
}
}
} | javascript | function addPluginsToScope(scope) {
var name;
for (name in plugins) {
if (plugins.hasOwnProperty(name)) {
scope[name] = plugins[name];
}
}
} | [
"function",
"addPluginsToScope",
"(",
"scope",
")",
"{",
"var",
"name",
";",
"for",
"(",
"name",
"in",
"plugins",
")",
"{",
"if",
"(",
"plugins",
".",
"hasOwnProperty",
"(",
"name",
")",
")",
"{",
"scope",
"[",
"name",
"]",
"=",
"plugins",
"[",
"name... | Add all existing plugins to the input scope
@param scope | [
"Add",
"all",
"existing",
"plugins",
"to",
"the",
"input",
"scope"
] | 716be37e09217b4be917e179389f752212a428b3 | https://github.com/gethuman/jyt/blob/716be37e09217b4be917e179389f752212a428b3/lib/jyt.plugins.js#L16-L23 | train |
gethuman/jyt | lib/jyt.plugins.js | registerPlugin | function registerPlugin(name, obj) {
if (name && name.length && obj) {
plugins[name] = obj;
}
} | javascript | function registerPlugin(name, obj) {
if (name && name.length && obj) {
plugins[name] = obj;
}
} | [
"function",
"registerPlugin",
"(",
"name",
",",
"obj",
")",
"{",
"if",
"(",
"name",
"&&",
"name",
".",
"length",
"&&",
"obj",
")",
"{",
"plugins",
"[",
"name",
"]",
"=",
"obj",
";",
"}",
"}"
] | Register a new plugin
@param name
@param obj | [
"Register",
"a",
"new",
"plugin"
] | 716be37e09217b4be917e179389f752212a428b3 | https://github.com/gethuman/jyt/blob/716be37e09217b4be917e179389f752212a428b3/lib/jyt.plugins.js#L30-L34 | train |
gethuman/jyt | lib/jyt.plugins.js | init | function init() {
// ex. jif(true, div('blah'))
registerPlugin('jif', function jif(condition, elem) {
if (utils.isArray(elem)) {
elem = runtime.naked(elem, null);
}
return condition ? elem : null;
});
// ex. jeach({}, function (item) {})
registerPlugin('jeach',... | javascript | function init() {
// ex. jif(true, div('blah'))
registerPlugin('jif', function jif(condition, elem) {
if (utils.isArray(elem)) {
elem = runtime.naked(elem, null);
}
return condition ? elem : null;
});
// ex. jeach({}, function (item) {})
registerPlugin('jeach',... | [
"function",
"init",
"(",
")",
"{",
"// ex. jif(true, div('blah'))",
"registerPlugin",
"(",
"'jif'",
",",
"function",
"jif",
"(",
"condition",
",",
"elem",
")",
"{",
"if",
"(",
"utils",
".",
"isArray",
"(",
"elem",
")",
")",
"{",
"elem",
"=",
"runtime",
"... | Register common plugins | [
"Register",
"common",
"plugins"
] | 716be37e09217b4be917e179389f752212a428b3 | https://github.com/gethuman/jyt/blob/716be37e09217b4be917e179389f752212a428b3/lib/jyt.plugins.js#L39-L61 | train |
sendanor/nor-nopg | src/InternalCursor.js | InternalCursor | function InternalCursor(parent, key) {
debug.assert(parent).is('object');
debug.assert(key).is('defined');
this.cursors = [{'parent':parent, 'key':key}];
} | javascript | function InternalCursor(parent, key) {
debug.assert(parent).is('object');
debug.assert(key).is('defined');
this.cursors = [{'parent':parent, 'key':key}];
} | [
"function",
"InternalCursor",
"(",
"parent",
",",
"key",
")",
"{",
"debug",
".",
"assert",
"(",
"parent",
")",
".",
"is",
"(",
"'object'",
")",
";",
"debug",
".",
"assert",
"(",
"key",
")",
".",
"is",
"(",
"'defined'",
")",
";",
"this",
".",
"curso... | Internal cursor object | [
"Internal",
"cursor",
"object"
] | 0d99b86c1a1996b5828b56de8de23700df8bbc0c | https://github.com/sendanor/nor-nopg/blob/0d99b86c1a1996b5828b56de8de23700df8bbc0c/src/InternalCursor.js#L8-L12 | train |
defeo/was_framework | lib/db.js | connect_cb | function connect_cb(err, db) {
if (err) {
next(err);
} else {
if (db && db instanceof sqlite) { // Sqlite only
app.db = db;
// Use the query escaping facilities of mysql
app.db.escape = SqliteString.escape;
app.db.escapeId = SqliteString.escapeId;
app.db.format = SqliteString.format;
// Wrap... | javascript | function connect_cb(err, db) {
if (err) {
next(err);
} else {
if (db && db instanceof sqlite) { // Sqlite only
app.db = db;
// Use the query escaping facilities of mysql
app.db.escape = SqliteString.escape;
app.db.escapeId = SqliteString.escapeId;
app.db.format = SqliteString.format;
// Wrap... | [
"function",
"connect_cb",
"(",
"err",
",",
"db",
")",
"{",
"if",
"(",
"err",
")",
"{",
"next",
"(",
"err",
")",
";",
"}",
"else",
"{",
"if",
"(",
"db",
"&&",
"db",
"instanceof",
"sqlite",
")",
"{",
"// Sqlite only",
"app",
".",
"db",
"=",
"db",
... | This function is executed after the connection to the database has been established | [
"This",
"function",
"is",
"executed",
"after",
"the",
"connection",
"to",
"the",
"database",
"has",
"been",
"established"
] | ab52bbbf5943e9062fe6ea82f1fea637a11d727a | https://github.com/defeo/was_framework/blob/ab52bbbf5943e9062fe6ea82f1fea637a11d727a/lib/db.js#L28-L70 | train |
xiamidaxia/xiami | meteor/accounts-password/password_server.js | function (user) {
if (user.id)
return {_id: user.id};
else if (user.username)
return {username: user.username};
else if (user.email)
return {"emails.address": user.email};
throw new Error("shouldn't happen (validation missed something)");
} | javascript | function (user) {
if (user.id)
return {_id: user.id};
else if (user.username)
return {username: user.username};
else if (user.email)
return {"emails.address": user.email};
throw new Error("shouldn't happen (validation missed something)");
} | [
"function",
"(",
"user",
")",
"{",
"if",
"(",
"user",
".",
"id",
")",
"return",
"{",
"_id",
":",
"user",
".",
"id",
"}",
";",
"else",
"if",
"(",
"user",
".",
"username",
")",
"return",
"{",
"username",
":",
"user",
".",
"username",
"}",
";",
"e... | Users can specify various keys to identify themselves with. @param user {Object} with one of `id`, `username`, or `email`. @returns A selector to pass to mongo to get the user record. | [
"Users",
"can",
"specify",
"various",
"keys",
"to",
"identify",
"themselves",
"with",
"."
] | 6fcee92c493c12bf8fd67c7068e67fa6a72a306b | https://github.com/xiamidaxia/xiami/blob/6fcee92c493c12bf8fd67c7068e67fa6a72a306b/meteor/accounts-password/password_server.js#L18-L26 | train | |
xiamidaxia/xiami | meteor/accounts-password/password_server.js | function (options) {
// Unknown keys allowed, because a onCreateUserHook can take arbitrary
// options.
check(options, Match.ObjectIncluding({
username: Match.Optional(String),
email: Match.Optional(String),
password: Match.Optional(String),
srp: Match.Optional(SRP.matchVerifier)
}));
var use... | javascript | function (options) {
// Unknown keys allowed, because a onCreateUserHook can take arbitrary
// options.
check(options, Match.ObjectIncluding({
username: Match.Optional(String),
email: Match.Optional(String),
password: Match.Optional(String),
srp: Match.Optional(SRP.matchVerifier)
}));
var use... | [
"function",
"(",
"options",
")",
"{",
"// Unknown keys allowed, because a onCreateUserHook can take arbitrary",
"// options.",
"check",
"(",
"options",
",",
"Match",
".",
"ObjectIncluding",
"(",
"{",
"username",
":",
"Match",
".",
"Optional",
"(",
"String",
")",
",",
... | Shared createUser function called from the createUser method, both if originates in client or server code. Calls user provided hooks, does the actual user insertion. returns the user id | [
"Shared",
"createUser",
"function",
"called",
"from",
"the",
"createUser",
"method",
"both",
"if",
"originates",
"in",
"client",
"or",
"server",
"code",
".",
"Calls",
"user",
"provided",
"hooks",
"does",
"the",
"actual",
"user",
"insertion",
".",
"returns",
"t... | 6fcee92c493c12bf8fd67c7068e67fa6a72a306b | https://github.com/xiamidaxia/xiami/blob/6fcee92c493c12bf8fd67c7068e67fa6a72a306b/meteor/accounts-password/password_server.js#L534-L567 | train | |
Coffeekraken/s-validator-component | dist/js/SValidatorComponent.js | setMessages | function setMessages() {
var messages = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
__messages = _extends({}, __messages, messages);
} | javascript | function setMessages() {
var messages = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
__messages = _extends({}, __messages, messages);
} | [
"function",
"setMessages",
"(",
")",
"{",
"var",
"messages",
"=",
"arguments",
".",
"length",
">",
"0",
"&&",
"arguments",
"[",
"0",
"]",
"!==",
"undefined",
"?",
"arguments",
"[",
"0",
"]",
":",
"{",
"}",
";",
"__messages",
"=",
"_extends",
"(",
"{"... | Set the messages
@param {Object} messages An object of messages to override | [
"Set",
"the",
"messages"
] | 84519fc1bb013ccd0a4683dbcf88f2c3e08a5f9c | https://github.com/Coffeekraken/s-validator-component/blob/84519fc1bb013ccd0a4683dbcf88f2c3e08a5f9c/dist/js/SValidatorComponent.js#L779-L783 | train |
artdecocode/which-stream | build/index.js | whichStream | async function whichStream(config) {
const {
source,
destination,
} = config
let { readable, writable } = config
if (!(source || readable))
throw new Error('Please give either a source or readable.')
if (!(destination || writable))
throw new Error('Please give either a destination or writable... | javascript | async function whichStream(config) {
const {
source,
destination,
} = config
let { readable, writable } = config
if (!(source || readable))
throw new Error('Please give either a source or readable.')
if (!(destination || writable))
throw new Error('Please give either a destination or writable... | [
"async",
"function",
"whichStream",
"(",
"config",
")",
"{",
"const",
"{",
"source",
",",
"destination",
",",
"}",
"=",
"config",
"let",
"{",
"readable",
",",
"writable",
"}",
"=",
"config",
"if",
"(",
"!",
"(",
"source",
"||",
"readable",
")",
")",
... | Handles the flow of streams, and awaits for them to complete. The input can be specified either as a string with the `source` property, or as as stream with the `readable`. The output can also be given either as a string with the `destination`, or as a stream with the `writable`. If destination is passed as the `-`, th... | [
"Handles",
"the",
"flow",
"of",
"streams",
"and",
"awaits",
"for",
"them",
"to",
"complete",
".",
"The",
"input",
"can",
"be",
"specified",
"either",
"as",
"a",
"string",
"with",
"the",
"source",
"property",
"or",
"as",
"as",
"stream",
"with",
"the",
"re... | f019bbc83af3e272f4985f23a22c6dd1f2f2a54f | https://github.com/artdecocode/which-stream/blob/f019bbc83af3e272f4985f23a22c6dd1f2f2a54f/build/index.js#L16-L41 | train |
131/phar-stream | index.js | search | function search(stream, needle) {
var ss = new streamsearch(needle),
push = ss.push.bind(ss);
ss.maxMatches = 1;
var defered = defer();
stream.on("data", push);
stream.once("finish", function(){
defered.reject("No stub found in stream")
});
var pos = 0;
ss.on("info", function(isMatch, dat... | javascript | function search(stream, needle) {
var ss = new streamsearch(needle),
push = ss.push.bind(ss);
ss.maxMatches = 1;
var defered = defer();
stream.on("data", push);
stream.once("finish", function(){
defered.reject("No stub found in stream")
});
var pos = 0;
ss.on("info", function(isMatch, dat... | [
"function",
"search",
"(",
"stream",
",",
"needle",
")",
"{",
"var",
"ss",
"=",
"new",
"streamsearch",
"(",
"needle",
")",
",",
"push",
"=",
"ss",
".",
"push",
".",
"bind",
"(",
"ss",
")",
";",
"ss",
".",
"maxMatches",
"=",
"1",
";",
"var",
"defe... | search for a stub in a stream, return a promise | [
"search",
"for",
"a",
"stub",
"in",
"a",
"stream",
"return",
"a",
"promise"
] | 0a63b5d0adf3d04315bbd15d60d0cf24cfee68c2 | https://github.com/131/phar-stream/blob/0a63b5d0adf3d04315bbd15d60d0cf24cfee68c2/index.js#L20-L46 | train |
marinvvasilev/appcelerator-githubauth | index.js | Plugin | function Plugin(server) {
this.server = server;
this.config = server.config;
//Check if we have the right config
this.checkConfiguration();
this.settings = this.config.githubAuth;
//Init if not present
if (typeof this.server.passport === "undefined")
this.initGithubAuth();
else
... | javascript | function Plugin(server) {
this.server = server;
this.config = server.config;
//Check if we have the right config
this.checkConfiguration();
this.settings = this.config.githubAuth;
//Init if not present
if (typeof this.server.passport === "undefined")
this.initGithubAuth();
else
... | [
"function",
"Plugin",
"(",
"server",
")",
"{",
"this",
".",
"server",
"=",
"server",
";",
"this",
".",
"config",
"=",
"server",
".",
"config",
";",
"//Check if we have the right config",
"this",
".",
"checkConfiguration",
"(",
")",
";",
"this",
".",
"setting... | Plugin initialization logic
@param Object server
@param Object testConfig - optional - configuration settings for testing purposes | [
"Plugin",
"initialization",
"logic"
] | 07bb77a1bc5720dc584b57b3de782cfc6fd5a06e | https://github.com/marinvvasilev/appcelerator-githubauth/blob/07bb77a1bc5720dc584b57b3de782cfc6fd5a06e/index.js#L9-L20 | train |
nfroidure/common-services | src/lock.js | take | async function take(key) {
const previousLocks = LOCKS_MAP.get(key) || [];
let locksLength = previousLocks.length;
log('debug', `Taking the lock on ${key} (queue length was ${locksLength})`);
let release;
const newLock = {
releasePromise: new Promise(async (resolve, reject) => {
rel... | javascript | async function take(key) {
const previousLocks = LOCKS_MAP.get(key) || [];
let locksLength = previousLocks.length;
log('debug', `Taking the lock on ${key} (queue length was ${locksLength})`);
let release;
const newLock = {
releasePromise: new Promise(async (resolve, reject) => {
rel... | [
"async",
"function",
"take",
"(",
"key",
")",
"{",
"const",
"previousLocks",
"=",
"LOCKS_MAP",
".",
"get",
"(",
"key",
")",
"||",
"[",
"]",
";",
"let",
"locksLength",
"=",
"previousLocks",
".",
"length",
";",
"log",
"(",
"'debug'",
",",
"`",
"${",
"k... | Take the lock on the given resource key
@param {String} key
A unique key for the locked resource
@return {Promise}
A promise to be resolved when the lock
is gained or rejected if the lock release
timeout is reached. | [
"Take",
"the",
"lock",
"on",
"the",
"given",
"resource",
"key"
] | 09df32597fe798777abec0ef1f3a994e91046085 | https://github.com/nfroidure/common-services/blob/09df32597fe798777abec0ef1f3a994e91046085/src/lock.js#L86-L115 | train |
nfroidure/common-services | src/lock.js | release | async function release(key) {
const previousLocks = LOCKS_MAP.get(key) || [];
const locksLength = previousLocks.length;
log(
'debug',
`Releasing the lock on ${key} (queue length was ${locksLength})`,
);
previousLocks.pop().release();
} | javascript | async function release(key) {
const previousLocks = LOCKS_MAP.get(key) || [];
const locksLength = previousLocks.length;
log(
'debug',
`Releasing the lock on ${key} (queue length was ${locksLength})`,
);
previousLocks.pop().release();
} | [
"async",
"function",
"release",
"(",
"key",
")",
"{",
"const",
"previousLocks",
"=",
"LOCKS_MAP",
".",
"get",
"(",
"key",
")",
"||",
"[",
"]",
";",
"const",
"locksLength",
"=",
"previousLocks",
".",
"length",
";",
"log",
"(",
"'debug'",
",",
"`",
"${",... | Release the lock on the given resource key
@param {String} key A unique key for the resource to release
@return {void} | [
"Release",
"the",
"lock",
"on",
"the",
"given",
"resource",
"key"
] | 09df32597fe798777abec0ef1f3a994e91046085 | https://github.com/nfroidure/common-services/blob/09df32597fe798777abec0ef1f3a994e91046085/src/lock.js#L122-L131 | train |
nearform/docker-container | lib/registry.js | service | function service(root, cb) {
var registryPath = config.registryPath || path.join(root, 'registry');
fs.mkdir(registryPath, function(err) {
if (err && err.code !== 'EEXIST') {
logger.error(err);
return cb(err);
}
// swallow errors, it may exists
var server = registry({
... | javascript | function service(root, cb) {
var registryPath = config.registryPath || path.join(root, 'registry');
fs.mkdir(registryPath, function(err) {
if (err && err.code !== 'EEXIST') {
logger.error(err);
return cb(err);
}
// swallow errors, it may exists
var server = registry({
... | [
"function",
"service",
"(",
"root",
",",
"cb",
")",
"{",
"var",
"registryPath",
"=",
"config",
".",
"registryPath",
"||",
"path",
".",
"join",
"(",
"root",
",",
"'registry'",
")",
";",
"fs",
".",
"mkdir",
"(",
"registryPath",
",",
"function",
"(",
"err... | Starts the registry | [
"Starts",
"the",
"registry"
] | 724ff6a9d8d3c116f9a6b8239594c4b5cd5e8e17 | https://github.com/nearform/docker-container/blob/724ff6a9d8d3c116f9a6b8239594c4b5cd5e8e17/lib/registry.js#L95-L129 | train |
happen-zhang/cakes | lib/cakes.js | Class | function Class(prop, superClass) {
var ClassType = function() {
function F(args) {
for (var name in ClassType.__prop) {
var val = ClassType.__prop[name];
this[name] = isObject(val) ? extend({}, val) : val;
}
if ... | javascript | function Class(prop, superClass) {
var ClassType = function() {
function F(args) {
for (var name in ClassType.__prop) {
var val = ClassType.__prop[name];
this[name] = isObject(val) ? extend({}, val) : val;
}
if ... | [
"function",
"Class",
"(",
"prop",
",",
"superClass",
")",
"{",
"var",
"ClassType",
"=",
"function",
"(",
")",
"{",
"function",
"F",
"(",
"args",
")",
"{",
"for",
"(",
"var",
"name",
"in",
"ClassType",
".",
"__prop",
")",
"{",
"var",
"val",
"=",
"Cl... | Create a class construct function.
@param {Function} prop Custom properties of class
@param {Function} superClass Super class
@return {Function} New class construct function | [
"Create",
"a",
"class",
"construct",
"function",
"."
] | a88a1d8d99b9ba6ec858d982c58c541d9483104f | https://github.com/happen-zhang/cakes/blob/a88a1d8d99b9ba6ec858d982c58c541d9483104f/lib/cakes.js#L38-L128 | train |
sleeplessinc/jsond | index.js | accept | function accept(req, res, cb) {
var u = url.parse(req.url, true),
path = u.pathname
if(/^\/api\/?$/.test(path)) {
messageInit({cb:(cb || nop), req:req, res:res, path:path, query:u.query, u:u})
return;
}
if(req.method == "OPTIONS") {
res.writeHead(200, {
"Access-Control-Allow-Origin": "*", // to support... | javascript | function accept(req, res, cb) {
var u = url.parse(req.url, true),
path = u.pathname
if(/^\/api\/?$/.test(path)) {
messageInit({cb:(cb || nop), req:req, res:res, path:path, query:u.query, u:u})
return;
}
if(req.method == "OPTIONS") {
res.writeHead(200, {
"Access-Control-Allow-Origin": "*", // to support... | [
"function",
"accept",
"(",
"req",
",",
"res",
",",
"cb",
")",
"{",
"var",
"u",
"=",
"url",
".",
"parse",
"(",
"req",
".",
"url",
",",
"true",
")",
",",
"path",
"=",
"u",
".",
"pathname",
"if",
"(",
"/",
"^\\/api\\/?$",
"/",
".",
"test",
"(",
... | Every request starts here | [
"Every",
"request",
"starts",
"here"
] | 0f65a925d604edd5be74dc75aba19a3c1448307b | https://github.com/sleeplessinc/jsond/blob/0f65a925d604edd5be74dc75aba19a3c1448307b/index.js#L143-L162 | train |
xiamidaxia/xiami | meteor/binary-heap/max-heap.js | function (data) {
var self = this;
self._heap = _.map(data, function (o) {
return { id: o.id, value: o.value };
});
_.each(data, function (o, i) {
self._heapIdx.set(o.id, i);
});
if (! data.length)
return;
// start from the first non-leaf - the parent of the last leaf
... | javascript | function (data) {
var self = this;
self._heap = _.map(data, function (o) {
return { id: o.id, value: o.value };
});
_.each(data, function (o, i) {
self._heapIdx.set(o.id, i);
});
if (! data.length)
return;
// start from the first non-leaf - the parent of the last leaf
... | [
"function",
"(",
"data",
")",
"{",
"var",
"self",
"=",
"this",
";",
"self",
".",
"_heap",
"=",
"_",
".",
"map",
"(",
"data",
",",
"function",
"(",
"o",
")",
"{",
"return",
"{",
"id",
":",
"o",
".",
"id",
",",
"value",
":",
"o",
".",
"value",
... | Builds a new heap in-place in linear time based on passed data | [
"Builds",
"a",
"new",
"heap",
"in",
"-",
"place",
"in",
"linear",
"time",
"based",
"on",
"passed",
"data"
] | 6fcee92c493c12bf8fd67c7068e67fa6a72a306b | https://github.com/xiamidaxia/xiami/blob/6fcee92c493c12bf8fd67c7068e67fa6a72a306b/meteor/binary-heap/max-heap.js#L44-L61 | train | |
xiamidaxia/xiami | meteor/binary-heap/max-heap.js | function (iterator) {
var self = this;
_.each(self._heap, function (obj) {
return iterator(obj.value, obj.id);
});
} | javascript | function (iterator) {
var self = this;
_.each(self._heap, function (obj) {
return iterator(obj.value, obj.id);
});
} | [
"function",
"(",
"iterator",
")",
"{",
"var",
"self",
"=",
"this",
";",
"_",
".",
"each",
"(",
"self",
".",
"_heap",
",",
"function",
"(",
"obj",
")",
"{",
"return",
"iterator",
"(",
"obj",
".",
"value",
",",
"obj",
".",
"id",
")",
";",
"}",
")... | iterate over values in no particular order | [
"iterate",
"over",
"values",
"in",
"no",
"particular",
"order"
] | 6fcee92c493c12bf8fd67c7068e67fa6a72a306b | https://github.com/xiamidaxia/xiami/blob/6fcee92c493c12bf8fd67c7068e67fa6a72a306b/meteor/binary-heap/max-heap.js#L187-L192 | train | |
feedhenry/fh-mbaas-middleware | lib/alerts/alerts.js | matchAndIssueAlertEmails | function matchAndIssueAlertEmails(eventDetails, alerts){
underscore.each(alerts, function(alert) {
if (shouldTriggerAlert(eventDetails, alert)){
issueAlertEmail(eventDetails, alert);
}
});
} | javascript | function matchAndIssueAlertEmails(eventDetails, alerts){
underscore.each(alerts, function(alert) {
if (shouldTriggerAlert(eventDetails, alert)){
issueAlertEmail(eventDetails, alert);
}
});
} | [
"function",
"matchAndIssueAlertEmails",
"(",
"eventDetails",
",",
"alerts",
")",
"{",
"underscore",
".",
"each",
"(",
"alerts",
",",
"function",
"(",
"alert",
")",
"{",
"if",
"(",
"shouldTriggerAlert",
"(",
"eventDetails",
",",
"alert",
")",
")",
"{",
"issue... | Iterate user defined alerts to incoming event message and send emails when appropriate
@param alerts | [
"Iterate",
"user",
"defined",
"alerts",
"to",
"incoming",
"event",
"message",
"and",
"send",
"emails",
"when",
"appropriate"
] | f906e98efbb4b0963bf5137b34b5e0589ba24e69 | https://github.com/feedhenry/fh-mbaas-middleware/blob/f906e98efbb4b0963bf5137b34b5e0589ba24e69/lib/alerts/alerts.js#L13-L19 | train |
feedhenry/fh-mbaas-middleware | lib/alerts/alerts.js | shouldTriggerAlert | function shouldTriggerAlert(eventDetails, alert){
if (alert.alertEnabled){
// Event Message Criteria
var msgEventName = eventDetails.eventType;
var msgEventCategory = eventDetails.eventClass;
var msgEventSeverity = eventDetails.eventLevel;
// Saved Alert Criteria
var alertEventNames = ale... | javascript | function shouldTriggerAlert(eventDetails, alert){
if (alert.alertEnabled){
// Event Message Criteria
var msgEventName = eventDetails.eventType;
var msgEventCategory = eventDetails.eventClass;
var msgEventSeverity = eventDetails.eventLevel;
// Saved Alert Criteria
var alertEventNames = ale... | [
"function",
"shouldTriggerAlert",
"(",
"eventDetails",
",",
"alert",
")",
"{",
"if",
"(",
"alert",
".",
"alertEnabled",
")",
"{",
"// Event Message Criteria",
"var",
"msgEventName",
"=",
"eventDetails",
".",
"eventType",
";",
"var",
"msgEventCategory",
"=",
"event... | Test the Alert and see if we should send an email or not
@param alert | [
"Test",
"the",
"Alert",
"and",
"see",
"if",
"we",
"should",
"send",
"an",
"email",
"or",
"not"
] | f906e98efbb4b0963bf5137b34b5e0589ba24e69 | https://github.com/feedhenry/fh-mbaas-middleware/blob/f906e98efbb4b0963bf5137b34b5e0589ba24e69/lib/alerts/alerts.js#L25-L55 | train |
feedhenry/fh-mbaas-middleware | lib/alerts/alerts.js | handler | function handler (eventDetails){
var Alert = models.getModels().Alert;
logger.logger.trace(loggerPrefix +'Processing Alerts for Event: ', eventDetails);
Alert.queryAlerts(eventDetails.uid, eventDetails.env, eventDetails.domain, function(err, alerts){
if(err) {
logger.logger.warn({ error:err }, loggerPr... | javascript | function handler (eventDetails){
var Alert = models.getModels().Alert;
logger.logger.trace(loggerPrefix +'Processing Alerts for Event: ', eventDetails);
Alert.queryAlerts(eventDetails.uid, eventDetails.env, eventDetails.domain, function(err, alerts){
if(err) {
logger.logger.warn({ error:err }, loggerPr... | [
"function",
"handler",
"(",
"eventDetails",
")",
"{",
"var",
"Alert",
"=",
"models",
".",
"getModels",
"(",
")",
".",
"Alert",
";",
"logger",
".",
"logger",
".",
"trace",
"(",
"loggerPrefix",
"+",
"'Processing Alerts for Event: '",
",",
"eventDetails",
")",
... | Handle an EVENT. We will take the EVENT details,
match the Alerts in Mongo that have been setup and
if a match is found, then send the email from the MBaaS
@param msg
@param headers
@param info
@param cb | [
"Handle",
"an",
"EVENT",
".",
"We",
"will",
"take",
"the",
"EVENT",
"details",
"match",
"the",
"Alerts",
"in",
"Mongo",
"that",
"have",
"been",
"setup",
"and",
"if",
"a",
"match",
"is",
"found",
"then",
"send",
"the",
"email",
"from",
"the",
"MBaaS"
] | f906e98efbb4b0963bf5137b34b5e0589ba24e69 | https://github.com/feedhenry/fh-mbaas-middleware/blob/f906e98efbb4b0963bf5137b34b5e0589ba24e69/lib/alerts/alerts.js#L103-L119 | train |
noblesamurai/noblerecord | src/migration.js | columnToSQL | function columnToSQL(col) {
var sql = "`" + col.name + "` ";
sql += nrutil.typeToSQL(col.type);
if (col['additional']) {
sql += ' ' + col['additional'];
}
if (!col['allow_null']) {
sql += " NOT NULL";
}
if (col['default_value'] !== undefined) {
var def = col['default_value']
sql += " DEFAULT " + nru... | javascript | function columnToSQL(col) {
var sql = "`" + col.name + "` ";
sql += nrutil.typeToSQL(col.type);
if (col['additional']) {
sql += ' ' + col['additional'];
}
if (!col['allow_null']) {
sql += " NOT NULL";
}
if (col['default_value'] !== undefined) {
var def = col['default_value']
sql += " DEFAULT " + nru... | [
"function",
"columnToSQL",
"(",
"col",
")",
"{",
"var",
"sql",
"=",
"\"`\"",
"+",
"col",
".",
"name",
"+",
"\"` \"",
";",
"sql",
"+=",
"nrutil",
".",
"typeToSQL",
"(",
"col",
".",
"type",
")",
";",
"if",
"(",
"col",
"[",
"'additional'",
"]",
")",
... | Generates the SQL fragment defining a given column. | [
"Generates",
"the",
"SQL",
"fragment",
"defining",
"a",
"given",
"column",
"."
] | fc7d3aac186598c4c7023f5448979d4162ab5e38 | https://github.com/noblesamurai/noblerecord/blob/fc7d3aac186598c4c7023f5448979d4162ab5e38/src/migration.js#L26-L50 | train |
noblesamurai/noblerecord | src/migration.js | function(name, newname) {
var act = new NobleMachine(function() {
act.toNext(db.query("SHOW COLUMNS FROM `" + tablename + "`;"));
});
act.next(function(result) {
var sql = "ALTER TABLE `" + tablename + "` CHANGE `" + name + "` `" + newname + "`";
result.forEach(function(coldatum) {
if... | javascript | function(name, newname) {
var act = new NobleMachine(function() {
act.toNext(db.query("SHOW COLUMNS FROM `" + tablename + "`;"));
});
act.next(function(result) {
var sql = "ALTER TABLE `" + tablename + "` CHANGE `" + name + "` `" + newname + "`";
result.forEach(function(coldatum) {
if... | [
"function",
"(",
"name",
",",
"newname",
")",
"{",
"var",
"act",
"=",
"new",
"NobleMachine",
"(",
"function",
"(",
")",
"{",
"act",
".",
"toNext",
"(",
"db",
".",
"query",
"(",
"\"SHOW COLUMNS FROM `\"",
"+",
"tablename",
"+",
"\"`;\"",
")",
")",
";",
... | There doesn't seem to be a proper RENAME COLUMN statement in MySQL. As such, it is necessary to use CHANGE after extracting the current column definition. | [
"There",
"doesn",
"t",
"seem",
"to",
"be",
"a",
"proper",
"RENAME",
"COLUMN",
"statement",
"in",
"MySQL",
".",
"As",
"such",
"it",
"is",
"necessary",
"to",
"use",
"CHANGE",
"after",
"extracting",
"the",
"current",
"column",
"definition",
"."
] | fc7d3aac186598c4c7023f5448979d4162ab5e38 | https://github.com/noblesamurai/noblerecord/blob/fc7d3aac186598c4c7023f5448979d4162ab5e38/src/migration.js#L109-L142 | train | |
noblesamurai/noblerecord | src/migration.js | function() {
var me = {};
var db = common.config.database;
me.act = new NobleMachine();
return _.extend(me, {
create_table: function(name, definer) {
var t = new TableDefinition(name, 'create', definer);
me.act.next(t.act);
},
change_table: function(name, definer) {
var t = new TableDefinition(nam... | javascript | function() {
var me = {};
var db = common.config.database;
me.act = new NobleMachine();
return _.extend(me, {
create_table: function(name, definer) {
var t = new TableDefinition(name, 'create', definer);
me.act.next(t.act);
},
change_table: function(name, definer) {
var t = new TableDefinition(nam... | [
"function",
"(",
")",
"{",
"var",
"me",
"=",
"{",
"}",
";",
"var",
"db",
"=",
"common",
".",
"config",
".",
"database",
";",
"me",
".",
"act",
"=",
"new",
"NobleMachine",
"(",
")",
";",
"return",
"_",
".",
"extend",
"(",
"me",
",",
"{",
"create... | Database definition class. Conglomerates TableDefinitions and SQL actions corresponding to friendly definition calls. | [
"Database",
"definition",
"class",
".",
"Conglomerates",
"TableDefinitions",
"and",
"SQL",
"actions",
"corresponding",
"to",
"friendly",
"definition",
"calls",
"."
] | fc7d3aac186598c4c7023f5448979d4162ab5e38 | https://github.com/noblesamurai/noblerecord/blob/fc7d3aac186598c4c7023f5448979d4162ab5e38/src/migration.js#L175-L200 | train | |
jonschlinkert/verbalize | examples/index.js | helpPlugin | function helpPlugin() {
return function(app) {
// style to turn `[ ]` strings into
// colored strings with backticks
app.style('codify', function(msg) {
var re = /\[([^\]]*\[?[^\]]*\]?[^[]*)\]/g;
return msg.replace(re, function(str, code) {
return this.red('`' + code + '`');
}.b... | javascript | function helpPlugin() {
return function(app) {
// style to turn `[ ]` strings into
// colored strings with backticks
app.style('codify', function(msg) {
var re = /\[([^\]]*\[?[^\]]*\]?[^[]*)\]/g;
return msg.replace(re, function(str, code) {
return this.red('`' + code + '`');
}.b... | [
"function",
"helpPlugin",
"(",
")",
"{",
"return",
"function",
"(",
"app",
")",
"{",
"// style to turn `[ ]` strings into",
"// colored strings with backticks",
"app",
".",
"style",
"(",
"'codify'",
",",
"function",
"(",
"msg",
")",
"{",
"var",
"re",
"=",
"/",
... | This plugin adds styles and emitters to make it
easier to log out help text | [
"This",
"plugin",
"adds",
"styles",
"and",
"emitters",
"to",
"make",
"it",
"easier",
"to",
"log",
"out",
"help",
"text"
] | 3d590602fde6a13682d0eebc180c731ea386b64f | https://github.com/jonschlinkert/verbalize/blob/3d590602fde6a13682d0eebc180c731ea386b64f/examples/index.js#L20-L98 | train |
tolokoban/ToloFrameWork | lib/util.js | removeDoubles | function removeDoubles( arrInput ) {
const
arrOutput = [],
map = {};
arrInput.forEach( function forEachItem( itm ) {
if ( itm in map ) return;
map[ itm ] = 1;
arrOutput.push( itm );
} );
return arrOutput;
} | javascript | function removeDoubles( arrInput ) {
const
arrOutput = [],
map = {};
arrInput.forEach( function forEachItem( itm ) {
if ( itm in map ) return;
map[ itm ] = 1;
arrOutput.push( itm );
} );
return arrOutput;
} | [
"function",
"removeDoubles",
"(",
"arrInput",
")",
"{",
"const",
"arrOutput",
"=",
"[",
"]",
",",
"map",
"=",
"{",
"}",
";",
"arrInput",
".",
"forEach",
"(",
"function",
"forEachItem",
"(",
"itm",
")",
"{",
"if",
"(",
"itm",
"in",
"map",
")",
"return... | Return a copy of an array after removing all doubles.
@param {array} arrInput array of any comparable object.
@returns {array} A copy of the input array without doubles. | [
"Return",
"a",
"copy",
"of",
"an",
"array",
"after",
"removing",
"all",
"doubles",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/lib/util.js#L307-L317 | train |
tolokoban/ToloFrameWork | lib/util.js | cleanDir | function cleanDir( path, _preserveGit ) {
const
preserveGit = typeof _preserveGit !== 'undefined' ? _preserveGit : false,
fullPath = Path.resolve( path );
// If the pah does not exist, everything is fine!
if ( !FS.existsSync( fullPath ) ) return;
if ( preserveGit ) {
/*
* We m... | javascript | function cleanDir( path, _preserveGit ) {
const
preserveGit = typeof _preserveGit !== 'undefined' ? _preserveGit : false,
fullPath = Path.resolve( path );
// If the pah does not exist, everything is fine!
if ( !FS.existsSync( fullPath ) ) return;
if ( preserveGit ) {
/*
* We m... | [
"function",
"cleanDir",
"(",
"path",
",",
"_preserveGit",
")",
"{",
"const",
"preserveGit",
"=",
"typeof",
"_preserveGit",
"!==",
"'undefined'",
"?",
"_preserveGit",
":",
"false",
",",
"fullPath",
"=",
"Path",
".",
"resolve",
"(",
"path",
")",
";",
"// If th... | Remove all files and directories found in `path`, but not `path` itself.
@param {string} path - The folder we want to clean the content.
@param {boolean} _preserveGit [false] - If `true`, the folder ".git" is not deleted.
@returns {undefined} | [
"Remove",
"all",
"files",
"and",
"directories",
"found",
"in",
"path",
"but",
"not",
"path",
"itself",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/lib/util.js#L325-L353 | train |
tolokoban/ToloFrameWork | lib/util.js | isNewerThan | function isNewerThan( inputs, target ) {
if ( !FS.existsSync( target ) ) return true;
const files = Array.isArray( inputs ) ? inputs : [ inputs ],
statTarget = FS.statSync( target ),
targetTime = statTarget.mtime;
for ( const file of files ) {
if ( !FS.existsSync( file ) ) cont... | javascript | function isNewerThan( inputs, target ) {
if ( !FS.existsSync( target ) ) return true;
const files = Array.isArray( inputs ) ? inputs : [ inputs ],
statTarget = FS.statSync( target ),
targetTime = statTarget.mtime;
for ( const file of files ) {
if ( !FS.existsSync( file ) ) cont... | [
"function",
"isNewerThan",
"(",
"inputs",
",",
"target",
")",
"{",
"if",
"(",
"!",
"FS",
".",
"existsSync",
"(",
"target",
")",
")",
"return",
"true",
";",
"const",
"files",
"=",
"Array",
".",
"isArray",
"(",
"inputs",
")",
"?",
"inputs",
":",
"[",
... | Check if at least one file is newer than the target one.
@param {array} inputs - Array of files (with full path) to compare to `target`.
@param {string} target - Full path of the reference file.
@returns {Boolean} `true` if `target` does not exist, or if at leat one input is newer than `target`. | [
"Check",
"if",
"at",
"least",
"one",
"file",
"is",
"newer",
"than",
"the",
"target",
"one",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/lib/util.js#L467-L483 | train |
keleko34/KObservableData | KObservableData/KObservableData.js | addData | function addData(a)
{
if(isObject(a.event.value) || isArray(a.event.value))
{
if(!isObservable(a.event.value))
{
a.preventDefault();
var local = a.event.local,
str = local.__kbscopeString+(loc... | javascript | function addData(a)
{
if(isObject(a.event.value) || isArray(a.event.value))
{
if(!isObservable(a.event.value))
{
a.preventDefault();
var local = a.event.local,
str = local.__kbscopeString+(loc... | [
"function",
"addData",
"(",
"a",
")",
"{",
"if",
"(",
"isObject",
"(",
"a",
".",
"event",
".",
"value",
")",
"||",
"isArray",
"(",
"a",
".",
"event",
".",
"value",
")",
")",
"{",
"if",
"(",
"!",
"isObservable",
"(",
"a",
".",
"event",
".",
"val... | these take care of recursion for us | [
"these",
"take",
"care",
"of",
"recursion",
"for",
"us"
] | 22a3637cba73be7533a76141803644472443b606 | https://github.com/keleko34/KObservableData/blob/22a3637cba73be7533a76141803644472443b606/KObservableData/KObservableData.js#L269-L295 | train |
perfectapi/ami-generator | www/build/tools/csslint-rhino.js | SyntaxUnit | function SyntaxUnit(text, line, col){
/**
* The column of text on which the unit resides.
* @type int
* @property col
*/
this.col = col;
/**
* The line of text on which the unit resides.
* @type int
* @property line
*/
this.line = line;
/**
* The text... | javascript | function SyntaxUnit(text, line, col){
/**
* The column of text on which the unit resides.
* @type int
* @property col
*/
this.col = col;
/**
* The line of text on which the unit resides.
* @type int
* @property line
*/
this.line = line;
/**
* The text... | [
"function",
"SyntaxUnit",
"(",
"text",
",",
"line",
",",
"col",
")",
"{",
"/**\n * The column of text on which the unit resides.\n * @type int\n * @property col\n */",
"this",
".",
"col",
"=",
"col",
";",
"/**\n * The line of text on which the unit resides.\n ... | Base type to represent a single syntactic unit.
@class SyntaxUnit
@namespace parserlib.util
@constructor
@param {String} text The text of the unit.
@param {int} line The line of text on which the unit resides.
@param {int} col The column of text on which the unit resides. | [
"Base",
"type",
"to",
"represent",
"a",
"single",
"syntactic",
"unit",
"."
] | 7913f300cccc79c59a2feac42225bbb26c042766 | https://github.com/perfectapi/ami-generator/blob/7913f300cccc79c59a2feac42225bbb26c042766/www/build/tools/csslint-rhino.js#L452-L476 | train |
perfectapi/ami-generator | www/build/tools/csslint-rhino.js | function(type, listener){
if (this._handlers[type] instanceof Array){
var handlers = this._handlers[type];
for (var i=0, len=handlers.length; i < len; i++){
if (handlers[i] === listener){
handlers.splice(i, 1);
break;
... | javascript | function(type, listener){
if (this._handlers[type] instanceof Array){
var handlers = this._handlers[type];
for (var i=0, len=handlers.length; i < len; i++){
if (handlers[i] === listener){
handlers.splice(i, 1);
break;
... | [
"function",
"(",
"type",
",",
"listener",
")",
"{",
"if",
"(",
"this",
".",
"_handlers",
"[",
"type",
"]",
"instanceof",
"Array",
")",
"{",
"var",
"handlers",
"=",
"this",
".",
"_handlers",
"[",
"type",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
... | Removes a listener for a given event type.
@param {String} type The type of event to remove a listener from.
@param {Function} listener The function to remove from the event.
@return {void}
@method detach | [
"Removes",
"a",
"listener",
"for",
"a",
"given",
"event",
"type",
"."
] | 7913f300cccc79c59a2feac42225bbb26c042766 | https://github.com/perfectapi/ami-generator/blob/7913f300cccc79c59a2feac42225bbb26c042766/www/build/tools/csslint-rhino.js#L4912-L4922 | train | |
perfectapi/ami-generator | www/build/tools/csslint-rhino.js | function(receiver, supplier){
for (var prop in supplier){
if (supplier.hasOwnProperty(prop)){
receiver[prop] = supplier[prop];
}
}
return receiver;
} | javascript | function(receiver, supplier){
for (var prop in supplier){
if (supplier.hasOwnProperty(prop)){
receiver[prop] = supplier[prop];
}
}
return receiver;
} | [
"function",
"(",
"receiver",
",",
"supplier",
")",
"{",
"for",
"(",
"var",
"prop",
"in",
"supplier",
")",
"{",
"if",
"(",
"supplier",
".",
"hasOwnProperty",
"(",
"prop",
")",
")",
"{",
"receiver",
"[",
"prop",
"]",
"=",
"supplier",
"[",
"prop",
"]",
... | Mixes the own properties from the supplier onto the
receiver.
@param {Object} receiver The object to receive the properties.
@param {Object} supplier The object to supply the properties.
@return {Object} The receiver that was passed in.
@method mix
@static | [
"Mixes",
"the",
"own",
"properties",
"from",
"the",
"supplier",
"onto",
"the",
"receiver",
"."
] | 7913f300cccc79c59a2feac42225bbb26c042766 | https://github.com/perfectapi/ami-generator/blob/7913f300cccc79c59a2feac42225bbb26c042766/www/build/tools/csslint-rhino.js#L4956-L4965 | train | |
perfectapi/ami-generator | www/build/tools/csslint-rhino.js | function (expected, actual, message) {
YUITest.Assert._increment();
if (expected !== actual) {
throw new YUITest.ComparisonFailure(YUITest.Assert._formatMessage(message, "Values should be the same."), expected, actual);
}
} | javascript | function (expected, actual, message) {
YUITest.Assert._increment();
if (expected !== actual) {
throw new YUITest.ComparisonFailure(YUITest.Assert._formatMessage(message, "Values should be the same."), expected, actual);
}
} | [
"function",
"(",
"expected",
",",
"actual",
",",
"message",
")",
"{",
"YUITest",
".",
"Assert",
".",
"_increment",
"(",
")",
";",
"if",
"(",
"expected",
"!==",
"actual",
")",
"{",
"throw",
"new",
"YUITest",
".",
"ComparisonFailure",
"(",
"YUITest",
".",
... | Asserts that a value is the same as another. This uses the triple equals sign
so no type cohersion may occur.
@param {Object} expected The expected value.
@param {Object} actual The actual value to test.
@param {String} message (Optional) The message to display if the assertion fails.
@method areSame
@static | [
"Asserts",
"that",
"a",
"value",
"is",
"the",
"same",
"as",
"another",
".",
"This",
"uses",
"the",
"triple",
"equals",
"sign",
"so",
"no",
"type",
"cohersion",
"may",
"occur",
"."
] | 7913f300cccc79c59a2feac42225bbb26c042766 | https://github.com/perfectapi/ami-generator/blob/7913f300cccc79c59a2feac42225bbb26c042766/www/build/tools/csslint-rhino.js#L5429-L5434 | train | |
perfectapi/ami-generator | www/build/tools/csslint-rhino.js | function (actual, message) {
YUITest.Assert._increment();
if (true !== actual) {
throw new YUITest.ComparisonFailure(YUITest.Assert._formatMessage(message, "Value should be true."), true, actual);
}
} | javascript | function (actual, message) {
YUITest.Assert._increment();
if (true !== actual) {
throw new YUITest.ComparisonFailure(YUITest.Assert._formatMessage(message, "Value should be true."), true, actual);
}
} | [
"function",
"(",
"actual",
",",
"message",
")",
"{",
"YUITest",
".",
"Assert",
".",
"_increment",
"(",
")",
";",
"if",
"(",
"true",
"!==",
"actual",
")",
"{",
"throw",
"new",
"YUITest",
".",
"ComparisonFailure",
"(",
"YUITest",
".",
"Assert",
".",
"_fo... | Asserts that a value is true. This uses the triple equals sign
so no type cohersion may occur.
@param {Object} actual The actual value to test.
@param {String} message (Optional) The message to display if the assertion fails.
@method isTrue
@static | [
"Asserts",
"that",
"a",
"value",
"is",
"true",
".",
"This",
"uses",
"the",
"triple",
"equals",
"sign",
"so",
"no",
"type",
"cohersion",
"may",
"occur",
"."
] | 7913f300cccc79c59a2feac42225bbb26c042766 | https://github.com/perfectapi/ami-generator/blob/7913f300cccc79c59a2feac42225bbb26c042766/www/build/tools/csslint-rhino.js#L5463-L5469 | train | |
perfectapi/ami-generator | www/build/tools/csslint-rhino.js | function (actual, message) {
YUITest.Assert._increment();
if (actual !== null) {
throw new YUITest.ComparisonFailure(YUITest.Assert._formatMessage(message, "Value should be null."), null, actual);
}
} | javascript | function (actual, message) {
YUITest.Assert._increment();
if (actual !== null) {
throw new YUITest.ComparisonFailure(YUITest.Assert._formatMessage(message, "Value should be null."), null, actual);
}
} | [
"function",
"(",
"actual",
",",
"message",
")",
"{",
"YUITest",
".",
"Assert",
".",
"_increment",
"(",
")",
";",
"if",
"(",
"actual",
"!==",
"null",
")",
"{",
"throw",
"new",
"YUITest",
".",
"ComparisonFailure",
"(",
"YUITest",
".",
"Assert",
".",
"_fo... | Asserts that a value is null. This uses the triple equals sign
so no type cohersion may occur.
@param {Object} actual The actual value to test.
@param {String} message (Optional) The message to display if the assertion fails.
@method isNull
@static | [
"Asserts",
"that",
"a",
"value",
"is",
"null",
".",
"This",
"uses",
"the",
"triple",
"equals",
"sign",
"so",
"no",
"type",
"cohersion",
"may",
"occur",
"."
] | 7913f300cccc79c59a2feac42225bbb26c042766 | https://github.com/perfectapi/ami-generator/blob/7913f300cccc79c59a2feac42225bbb26c042766/www/build/tools/csslint-rhino.js#L5541-L5546 | train | |
perfectapi/ami-generator | www/build/tools/csslint-rhino.js | function (actual, message) {
YUITest.Assert._increment();
if (typeof actual != "undefined") {
throw new YUITest.ComparisonFailure(YUITest.Assert._formatMessage(message, "Value should be undefined."), undefined, actual);
}
} | javascript | function (actual, message) {
YUITest.Assert._increment();
if (typeof actual != "undefined") {
throw new YUITest.ComparisonFailure(YUITest.Assert._formatMessage(message, "Value should be undefined."), undefined, actual);
}
} | [
"function",
"(",
"actual",
",",
"message",
")",
"{",
"YUITest",
".",
"Assert",
".",
"_increment",
"(",
")",
";",
"if",
"(",
"typeof",
"actual",
"!=",
"\"undefined\"",
")",
"{",
"throw",
"new",
"YUITest",
".",
"ComparisonFailure",
"(",
"YUITest",
".",
"As... | Asserts that a value is undefined. This uses the triple equals sign
so no type cohersion may occur.
@param {Object} actual The actual value to test.
@param {String} message (Optional) The message to display if the assertion fails.
@method isUndefined
@static | [
"Asserts",
"that",
"a",
"value",
"is",
"undefined",
".",
"This",
"uses",
"the",
"triple",
"equals",
"sign",
"so",
"no",
"type",
"cohersion",
"may",
"occur",
"."
] | 7913f300cccc79c59a2feac42225bbb26c042766 | https://github.com/perfectapi/ami-generator/blob/7913f300cccc79c59a2feac42225bbb26c042766/www/build/tools/csslint-rhino.js#L5556-L5561 | train | |
perfectapi/ami-generator | www/build/tools/csslint-rhino.js | function (actual, message) {
YUITest.Assert._increment();
if (typeof actual != "boolean"){
throw new YUITest.UnexpectedValue(YUITest.Assert._formatMessage(message, "Value should be a Boolean."), actual);
}
} | javascript | function (actual, message) {
YUITest.Assert._increment();
if (typeof actual != "boolean"){
throw new YUITest.UnexpectedValue(YUITest.Assert._formatMessage(message, "Value should be a Boolean."), actual);
}
} | [
"function",
"(",
"actual",
",",
"message",
")",
"{",
"YUITest",
".",
"Assert",
".",
"_increment",
"(",
")",
";",
"if",
"(",
"typeof",
"actual",
"!=",
"\"boolean\"",
")",
"{",
"throw",
"new",
"YUITest",
".",
"UnexpectedValue",
"(",
"YUITest",
".",
"Assert... | Asserts that a value is a Boolean.
@param {Object} actual The value to test.
@param {String} message (Optional) The message to display if the assertion fails.
@method isBoolean
@static | [
"Asserts",
"that",
"a",
"value",
"is",
"a",
"Boolean",
"."
] | 7913f300cccc79c59a2feac42225bbb26c042766 | https://github.com/perfectapi/ami-generator/blob/7913f300cccc79c59a2feac42225bbb26c042766/www/build/tools/csslint-rhino.js#L5594-L5599 | train | |
perfectapi/ami-generator | www/build/tools/csslint-rhino.js | function (expectedType, actualValue, message){
YUITest.Assert._increment();
if (typeof actualValue != expectedType){
throw new YUITest.ComparisonFailure(YUITest.Assert._formatMessage(message, "Value should be of type " + expectedType + "."), expectedType, typeof actualValue);
}
} | javascript | function (expectedType, actualValue, message){
YUITest.Assert._increment();
if (typeof actualValue != expectedType){
throw new YUITest.ComparisonFailure(YUITest.Assert._formatMessage(message, "Value should be of type " + expectedType + "."), expectedType, typeof actualValue);
}
} | [
"function",
"(",
"expectedType",
",",
"actualValue",
",",
"message",
")",
"{",
"YUITest",
".",
"Assert",
".",
"_increment",
"(",
")",
";",
"if",
"(",
"typeof",
"actualValue",
"!=",
"expectedType",
")",
"{",
"throw",
"new",
"YUITest",
".",
"ComparisonFailure"... | Asserts that a value is of a particular type.
@param {String} expectedType The expected type of the variable.
@param {Object} actualValue The actual value to test.
@param {String} message (Optional) The message to display if the assertion fails.
@method isTypeOf
@static | [
"Asserts",
"that",
"a",
"value",
"is",
"of",
"a",
"particular",
"type",
"."
] | 7913f300cccc79c59a2feac42225bbb26c042766 | https://github.com/perfectapi/ami-generator/blob/7913f300cccc79c59a2feac42225bbb26c042766/www/build/tools/csslint-rhino.js#L5682-L5687 | train | |
perfectapi/ami-generator | www/build/tools/csslint-rhino.js | function (needle, haystack,
message) {
YUITest.Assert._increment();
if (this._indexOf(haystack, needle) == -1){
YUITest.Assert.fail(YUITest.Assert._formatMessage(message, "Value " + needle + " (" + (typeof needle) + ") not found in array [" + haystack + "]."));
... | javascript | function (needle, haystack,
message) {
YUITest.Assert._increment();
if (this._indexOf(haystack, needle) == -1){
YUITest.Assert.fail(YUITest.Assert._formatMessage(message, "Value " + needle + " (" + (typeof needle) + ") not found in array [" + haystack + "]."));
... | [
"function",
"(",
"needle",
",",
"haystack",
",",
"message",
")",
"{",
"YUITest",
".",
"Assert",
".",
"_increment",
"(",
")",
";",
"if",
"(",
"this",
".",
"_indexOf",
"(",
"haystack",
",",
"needle",
")",
"==",
"-",
"1",
")",
"{",
"YUITest",
".",
"As... | Asserts that a value is present in an array. This uses the triple equals
sign so no type cohersion may occur.
@param {Object} needle The value that is expected in the array.
@param {Array} haystack An array of values.
@param {String} message (Optional) The message to display if the assertion fails.
@method contains
@st... | [
"Asserts",
"that",
"a",
"value",
"is",
"present",
"in",
"an",
"array",
".",
"This",
"uses",
"the",
"triple",
"equals",
"sign",
"so",
"no",
"type",
"cohersion",
"may",
"occur",
"."
] | 7913f300cccc79c59a2feac42225bbb26c042766 | https://github.com/perfectapi/ami-generator/blob/7913f300cccc79c59a2feac42225bbb26c042766/www/build/tools/csslint-rhino.js#L5824-L5832 | train | |
perfectapi/ami-generator | www/build/tools/csslint-rhino.js | function (needles, haystack,
message) {
YUITest.Assert._increment();
for (var i=0; i < needles.length; i++){
if (this._indexOf(haystack, needles[i]) > -1){
YUITest.Assert.fail(YUITest.Assert._formatMessage(message, "Value found in array [" + hayst... | javascript | function (needles, haystack,
message) {
YUITest.Assert._increment();
for (var i=0; i < needles.length; i++){
if (this._indexOf(haystack, needles[i]) > -1){
YUITest.Assert.fail(YUITest.Assert._formatMessage(message, "Value found in array [" + hayst... | [
"function",
"(",
"needles",
",",
"haystack",
",",
"message",
")",
"{",
"YUITest",
".",
"Assert",
".",
"_increment",
"(",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"needles",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"... | Asserts that a set of values are not present in an array. This uses the triple equals
sign so no type cohersion may occur. For this assertion to pass, all values must
not be found.
@param {Object[]} needles An array of values that are not expected in the array.
@param {Array} haystack An array of values to check.
@para... | [
"Asserts",
"that",
"a",
"set",
"of",
"values",
"are",
"not",
"present",
"in",
"an",
"array",
".",
"This",
"uses",
"the",
"triple",
"equals",
"sign",
"so",
"no",
"type",
"cohersion",
"may",
"occur",
".",
"For",
"this",
"assertion",
"to",
"pass",
"all",
... | 7913f300cccc79c59a2feac42225bbb26c042766 | https://github.com/perfectapi/ami-generator/blob/7913f300cccc79c59a2feac42225bbb26c042766/www/build/tools/csslint-rhino.js#L5909-L5920 | train | |
perfectapi/ami-generator | www/build/tools/csslint-rhino.js | function (matcher, haystack,
message) {
YUITest.Assert._increment();
//check for valid matcher
if (typeof matcher != "function"){
throw new TypeError("ArrayAssert.doesNotContainMatch(): First argument must be a function.");
}
if (this._so... | javascript | function (matcher, haystack,
message) {
YUITest.Assert._increment();
//check for valid matcher
if (typeof matcher != "function"){
throw new TypeError("ArrayAssert.doesNotContainMatch(): First argument must be a function.");
}
if (this._so... | [
"function",
"(",
"matcher",
",",
"haystack",
",",
"message",
")",
"{",
"YUITest",
".",
"Assert",
".",
"_increment",
"(",
")",
";",
"//check for valid matcher",
"if",
"(",
"typeof",
"matcher",
"!=",
"\"function\"",
")",
"{",
"throw",
"new",
"TypeError",
"(",
... | Asserts that no values matching a condition are present in an array. This uses
a function to determine a match.
@param {Function} matcher A function that returns true if the item matches or false if not.
@param {Array} haystack An array of values.
@param {String} message (Optional) The message to display if the asserti... | [
"Asserts",
"that",
"no",
"values",
"matching",
"a",
"condition",
"are",
"present",
"in",
"an",
"array",
".",
"This",
"uses",
"a",
"function",
"to",
"determine",
"a",
"match",
"."
] | 7913f300cccc79c59a2feac42225bbb26c042766 | https://github.com/perfectapi/ami-generator/blob/7913f300cccc79c59a2feac42225bbb26c042766/www/build/tools/csslint-rhino.js#L5931-L5944 | train | |
perfectapi/ami-generator | www/build/tools/csslint-rhino.js | function (expected, actual,
message) {
YUITest.Assert._increment();
//first check array length
if (expected.length != actual.length){
YUITest.Assert.fail(YUITest.Assert._formatMessage(message, "Array should have a length of " + expected.length + " but has... | javascript | function (expected, actual,
message) {
YUITest.Assert._increment();
//first check array length
if (expected.length != actual.length){
YUITest.Assert.fail(YUITest.Assert._formatMessage(message, "Array should have a length of " + expected.length + " but has... | [
"function",
"(",
"expected",
",",
"actual",
",",
"message",
")",
"{",
"YUITest",
".",
"Assert",
".",
"_increment",
"(",
")",
";",
"//first check array length",
"if",
"(",
"expected",
".",
"length",
"!=",
"actual",
".",
"length",
")",
"{",
"YUITest",
".",
... | Asserts that the values in an array are equal, and in the same position,
as values in another array. This uses the double equals sign
so type cohersion may occur. Note that the array objects themselves
need not be the same for this test to pass.
@param {Array} expected An array of the expected values.
@param {Array} ac... | [
"Asserts",
"that",
"the",
"values",
"in",
"an",
"array",
"are",
"equal",
"and",
"in",
"the",
"same",
"position",
"as",
"values",
"in",
"another",
"array",
".",
"This",
"uses",
"the",
"double",
"equals",
"sign",
"so",
"type",
"cohersion",
"may",
"occur",
... | 7913f300cccc79c59a2feac42225bbb26c042766 | https://github.com/perfectapi/ami-generator/blob/7913f300cccc79c59a2feac42225bbb26c042766/www/build/tools/csslint-rhino.js#L5985-L6001 | train | |
perfectapi/ami-generator | www/build/tools/csslint-rhino.js | function (actual, message) {
YUITest.Assert._increment();
if (actual.length > 0){
YUITest.Assert.fail(YUITest.Assert._formatMessage(message, "Array should be empty."));
}
} | javascript | function (actual, message) {
YUITest.Assert._increment();
if (actual.length > 0){
YUITest.Assert.fail(YUITest.Assert._formatMessage(message, "Array should be empty."));
}
} | [
"function",
"(",
"actual",
",",
"message",
")",
"{",
"YUITest",
".",
"Assert",
".",
"_increment",
"(",
")",
";",
"if",
"(",
"actual",
".",
"length",
">",
"0",
")",
"{",
"YUITest",
".",
"Assert",
".",
"fail",
"(",
"YUITest",
".",
"Assert",
".",
"_fo... | Asserts that an array is empty.
@param {Array} actual The array to test.
@param {String} message (Optional) The message to display if the assertion fails.
@method isEmpty
@static | [
"Asserts",
"that",
"an",
"array",
"is",
"empty",
"."
] | 7913f300cccc79c59a2feac42225bbb26c042766 | https://github.com/perfectapi/ami-generator/blob/7913f300cccc79c59a2feac42225bbb26c042766/www/build/tools/csslint-rhino.js#L6047-L6052 | train | |
perfectapi/ami-generator | www/build/tools/csslint-rhino.js | function (needle, haystack, index, message) {
//try to find the value in the array
for (var i=haystack.length; i >= 0; i--){
if (haystack[i] === needle){
if (index != i){
YUITest.Assert.fail(YUITest.Assert._formatMessage(message, "Value exists at index " ... | javascript | function (needle, haystack, index, message) {
//try to find the value in the array
for (var i=haystack.length; i >= 0; i--){
if (haystack[i] === needle){
if (index != i){
YUITest.Assert.fail(YUITest.Assert._formatMessage(message, "Value exists at index " ... | [
"function",
"(",
"needle",
",",
"haystack",
",",
"index",
",",
"message",
")",
"{",
"//try to find the value in the array",
"for",
"(",
"var",
"i",
"=",
"haystack",
".",
"length",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"if",
"(",
"haystack",
"[... | Asserts that the given value is contained in an array at the specified index,
starting from the back of the array.
This uses the triple equals sign so no type cohersion will occur.
@param {Object} needle The value to look for.
@param {Array} haystack The array to search in.
@param {int} index The index at which the val... | [
"Asserts",
"that",
"the",
"given",
"value",
"is",
"contained",
"in",
"an",
"array",
"at",
"the",
"specified",
"index",
"starting",
"from",
"the",
"back",
"of",
"the",
"array",
".",
"This",
"uses",
"the",
"triple",
"equals",
"sign",
"so",
"no",
"type",
"c... | 7913f300cccc79c59a2feac42225bbb26c042766 | https://github.com/perfectapi/ami-generator/blob/7913f300cccc79c59a2feac42225bbb26c042766/www/build/tools/csslint-rhino.js#L6108-L6122 | train | |
perfectapi/ami-generator | www/build/tools/csslint-rhino.js | function(expected, actual, message) {
YUITest.Assert._increment();
for (var name in expected){
if (expected.hasOwnProperty(name)){
if (expected[name] != actual[name]){
throw new YUITest.ComparisonFailure(YUITest.Assert._formatMessage(message, "Values shou... | javascript | function(expected, actual, message) {
YUITest.Assert._increment();
for (var name in expected){
if (expected.hasOwnProperty(name)){
if (expected[name] != actual[name]){
throw new YUITest.ComparisonFailure(YUITest.Assert._formatMessage(message, "Values shou... | [
"function",
"(",
"expected",
",",
"actual",
",",
"message",
")",
"{",
"YUITest",
".",
"Assert",
".",
"_increment",
"(",
")",
";",
"for",
"(",
"var",
"name",
"in",
"expected",
")",
"{",
"if",
"(",
"expected",
".",
"hasOwnProperty",
"(",
"name",
")",
"... | Asserts that an object has all of the same properties
and property values as the other.
@param {Object} expected The object with all expected properties and values.
@param {Object} actual The object to inspect.
@param {String} message (Optional) The message to display if the assertion fails.
@method areEqual
@static
@d... | [
"Asserts",
"that",
"an",
"object",
"has",
"all",
"of",
"the",
"same",
"properties",
"and",
"property",
"values",
"as",
"the",
"other",
"."
] | 7913f300cccc79c59a2feac42225bbb26c042766 | https://github.com/perfectapi/ami-generator/blob/7913f300cccc79c59a2feac42225bbb26c042766/www/build/tools/csslint-rhino.js#L6146-L6156 | train | |
perfectapi/ami-generator | www/build/tools/csslint-rhino.js | function (object, message) {
YUITest.Assert._increment();
var count = 0,
name;
for (name in object){
if (object.hasOwnProperty(name)){
count++;
}
}
if (count !== 0){
YUITest.Assert.fail(YUITest.Assert._formatMessage... | javascript | function (object, message) {
YUITest.Assert._increment();
var count = 0,
name;
for (name in object){
if (object.hasOwnProperty(name)){
count++;
}
}
if (count !== 0){
YUITest.Assert.fail(YUITest.Assert._formatMessage... | [
"function",
"(",
"object",
",",
"message",
")",
"{",
"YUITest",
".",
"Assert",
".",
"_increment",
"(",
")",
";",
"var",
"count",
"=",
"0",
",",
"name",
";",
"for",
"(",
"name",
"in",
"object",
")",
"{",
"if",
"(",
"object",
".",
"hasOwnProperty",
"... | Asserts that an object owns no properties.
@param {Object} object The object to check.
@param {String} message (Optional) The message to display if the assertion fails.
@method ownsNoKeys
@static | [
"Asserts",
"that",
"an",
"object",
"owns",
"no",
"properties",
"."
] | 7913f300cccc79c59a2feac42225bbb26c042766 | https://github.com/perfectapi/ami-generator/blob/7913f300cccc79c59a2feac42225bbb26c042766/www/build/tools/csslint-rhino.js#L6255-L6269 | train | |
perfectapi/ami-generator | www/build/tools/csslint-rhino.js | function (propertyName, object, message) {
YUITest.Assert._increment();
if (!(propertyName in object)){
YUITest.Assert.fail(YUITest.Assert._formatMessage(message, "Property '" + propertyName + "' not found on object."));
}
} | javascript | function (propertyName, object, message) {
YUITest.Assert._increment();
if (!(propertyName in object)){
YUITest.Assert.fail(YUITest.Assert._formatMessage(message, "Property '" + propertyName + "' not found on object."));
}
} | [
"function",
"(",
"propertyName",
",",
"object",
",",
"message",
")",
"{",
"YUITest",
".",
"Assert",
".",
"_increment",
"(",
")",
";",
"if",
"(",
"!",
"(",
"propertyName",
"in",
"object",
")",
")",
"{",
"YUITest",
".",
"Assert",
".",
"fail",
"(",
"YUI... | Asserts that an object has a property with the given name.
@param {String} propertyName The name of the property to test.
@param {Object} object The object to search.
@param {String} message (Optional) The message to display if the assertion fails.
@method ownsOrInheritsKey
@static | [
"Asserts",
"that",
"an",
"object",
"has",
"a",
"property",
"with",
"the",
"given",
"name",
"."
] | 7913f300cccc79c59a2feac42225bbb26c042766 | https://github.com/perfectapi/ami-generator/blob/7913f300cccc79c59a2feac42225bbb26c042766/www/build/tools/csslint-rhino.js#L6279-L6284 | train | |
perfectapi/ami-generator | www/build/tools/csslint-rhino.js | function (properties, object, message) {
YUITest.Assert._increment();
for (var i=0; i < properties.length; i++){
if (!(properties[i] in object)){
YUITest.Assert.fail(YUITest.Assert._formatMessage(message, "Property '" + properties[i] + "' not found on object."));
... | javascript | function (properties, object, message) {
YUITest.Assert._increment();
for (var i=0; i < properties.length; i++){
if (!(properties[i] in object)){
YUITest.Assert.fail(YUITest.Assert._formatMessage(message, "Property '" + properties[i] + "' not found on object."));
... | [
"function",
"(",
"properties",
",",
"object",
",",
"message",
")",
"{",
"YUITest",
".",
"Assert",
".",
"_increment",
"(",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"properties",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",... | Asserts that an object has all properties of a reference object.
@param {Array} properties An array of property names that should be on the object.
@param {Object} object The object to search.
@param {String} message (Optional) The message to display if the assertion fails.
@method ownsOrInheritsKeys
@static | [
"Asserts",
"that",
"an",
"object",
"has",
"all",
"properties",
"of",
"a",
"reference",
"object",
"."
] | 7913f300cccc79c59a2feac42225bbb26c042766 | https://github.com/perfectapi/ami-generator/blob/7913f300cccc79c59a2feac42225bbb26c042766/www/build/tools/csslint-rhino.js#L6294-L6301 | train | |
perfectapi/ami-generator | www/build/tools/csslint-rhino.js | function (expected, actual, message){
YUITest.Assert._increment();
if (expected instanceof Date && actual instanceof Date){
var msg = "";
//check years first
if (expected.getFullYear() != actual.getFullYear()){
msg = "Years should be equal.";
... | javascript | function (expected, actual, message){
YUITest.Assert._increment();
if (expected instanceof Date && actual instanceof Date){
var msg = "";
//check years first
if (expected.getFullYear() != actual.getFullYear()){
msg = "Years should be equal.";
... | [
"function",
"(",
"expected",
",",
"actual",
",",
"message",
")",
"{",
"YUITest",
".",
"Assert",
".",
"_increment",
"(",
")",
";",
"if",
"(",
"expected",
"instanceof",
"Date",
"&&",
"actual",
"instanceof",
"Date",
")",
"{",
"var",
"msg",
"=",
"\"\"",
";... | Asserts that a date's month, day, and year are equal to another date's.
@param {Date} expected The expected date.
@param {Date} actual The actual date to test.
@param {String} message (Optional) The message to display if the assertion fails.
@method datesAreEqual
@static | [
"Asserts",
"that",
"a",
"date",
"s",
"month",
"day",
"and",
"year",
"are",
"equal",
"to",
"another",
"date",
"s",
"."
] | 7913f300cccc79c59a2feac42225bbb26c042766 | https://github.com/perfectapi/ami-generator/blob/7913f300cccc79c59a2feac42225bbb26c042766/www/build/tools/csslint-rhino.js#L6324-L6350 | train | |
perfectapi/ami-generator | www/build/tools/csslint-rhino.js | function (expected, actual, message){
YUITest.Assert._increment();
if (expected instanceof Date && actual instanceof Date){
var msg = "";
//check hours first
if (expected.getHours() != actual.getHours()){
msg = "Hours should be equal.";
}
... | javascript | function (expected, actual, message){
YUITest.Assert._increment();
if (expected instanceof Date && actual instanceof Date){
var msg = "";
//check hours first
if (expected.getHours() != actual.getHours()){
msg = "Hours should be equal.";
}
... | [
"function",
"(",
"expected",
",",
"actual",
",",
"message",
")",
"{",
"YUITest",
".",
"Assert",
".",
"_increment",
"(",
")",
";",
"if",
"(",
"expected",
"instanceof",
"Date",
"&&",
"actual",
"instanceof",
"Date",
")",
"{",
"var",
"msg",
"=",
"\"\"",
";... | Asserts that a date's hour, minutes, and seconds are equal to another date's.
@param {Date} expected The expected date.
@param {Date} actual The actual date to test.
@param {String} message (Optional) The message to display if the assertion fails.
@method timesAreEqual
@static | [
"Asserts",
"that",
"a",
"date",
"s",
"hour",
"minutes",
"and",
"seconds",
"are",
"equal",
"to",
"another",
"date",
"s",
"."
] | 7913f300cccc79c59a2feac42225bbb26c042766 | https://github.com/perfectapi/ami-generator/blob/7913f300cccc79c59a2feac42225bbb26c042766/www/build/tools/csslint-rhino.js#L6360-L6386 | train | |
perfectapi/ami-generator | www/build/tools/csslint-rhino.js | function (segment, delay){
var actualDelay = (typeof segment == "number" ? segment : delay);
actualDelay = (typeof actualDelay == "number" ? actualDelay : 10000);
if (typeof segment == "function"){
throw new YUITest.Wait(segment, actualDelay);
} else {
throw new YUITe... | javascript | function (segment, delay){
var actualDelay = (typeof segment == "number" ? segment : delay);
actualDelay = (typeof actualDelay == "number" ? actualDelay : 10000);
if (typeof segment == "function"){
throw new YUITest.Wait(segment, actualDelay);
} else {
throw new YUITe... | [
"function",
"(",
"segment",
",",
"delay",
")",
"{",
"var",
"actualDelay",
"=",
"(",
"typeof",
"segment",
"==",
"\"number\"",
"?",
"segment",
":",
"delay",
")",
";",
"actualDelay",
"=",
"(",
"typeof",
"actualDelay",
"==",
"\"number\"",
"?",
"actualDelay",
"... | Causes the test case to wait a specified amount of time and then
continue executing the given code.
@param {Function} segment (Optional) The function to run after the delay.
If omitted, the TestRunner will wait until resume() is called.
@param {int} delay (Optional) The number of milliseconds to wait before running
the... | [
"Causes",
"the",
"test",
"case",
"to",
"wait",
"a",
"specified",
"amount",
"of",
"time",
"and",
"then",
"continue",
"executing",
"the",
"given",
"code",
"."
] | 7913f300cccc79c59a2feac42225bbb26c042766 | https://github.com/perfectapi/ami-generator/blob/7913f300cccc79c59a2feac42225bbb26c042766/www/build/tools/csslint-rhino.js#L6754-L6766 | train | |
perfectapi/ami-generator | www/build/tools/csslint-rhino.js | function (testObject) {
if (testObject instanceof YUITest.TestSuite || testObject instanceof YUITest.TestCase) {
this.items.push(testObject);
}
return this;
} | javascript | function (testObject) {
if (testObject instanceof YUITest.TestSuite || testObject instanceof YUITest.TestCase) {
this.items.push(testObject);
}
return this;
} | [
"function",
"(",
"testObject",
")",
"{",
"if",
"(",
"testObject",
"instanceof",
"YUITest",
".",
"TestSuite",
"||",
"testObject",
"instanceof",
"YUITest",
".",
"TestCase",
")",
"{",
"this",
".",
"items",
".",
"push",
"(",
"testObject",
")",
";",
"}",
"retur... | Adds a test suite or test case to the test suite.
@param {YUITest.TestSuite||YUITest.TestCase} testObject The test suite or test case to add.
@return {Void}
@method add | [
"Adds",
"a",
"test",
"suite",
"or",
"test",
"case",
"to",
"the",
"test",
"suite",
"."
] | 7913f300cccc79c59a2feac42225bbb26c042766 | https://github.com/perfectapi/ami-generator/blob/7913f300cccc79c59a2feac42225bbb26c042766/www/build/tools/csslint-rhino.js#L6890-L6895 | train | |
perfectapi/ami-generator | www/build/tools/csslint-rhino.js | function(results) {
function serializeToXML(results){
var xml = "<" + results.type + " name=\"" + xmlEscape(results.name) + "\"";
if (typeof(results.duration)=="number"){
xml += " duration=\"" + results.duration + "\"";
}
... | javascript | function(results) {
function serializeToXML(results){
var xml = "<" + results.type + " name=\"" + xmlEscape(results.name) + "\"";
if (typeof(results.duration)=="number"){
xml += " duration=\"" + results.duration + "\"";
}
... | [
"function",
"(",
"results",
")",
"{",
"function",
"serializeToXML",
"(",
"results",
")",
"{",
"var",
"xml",
"=",
"\"<\"",
"+",
"results",
".",
"type",
"+",
"\" name=\\\"\"",
"+",
"xmlEscape",
"(",
"results",
".",
"name",
")",
"+",
"\"\\\"\"",
";",
"if",
... | Returns test results formatted as an XML string.
@param {Object} result The results object created by TestRunner.
@return {String} An XML-formatted string of results.
@method XML
@static | [
"Returns",
"test",
"results",
"formatted",
"as",
"an",
"XML",
"string",
"."
] | 7913f300cccc79c59a2feac42225bbb26c042766 | https://github.com/perfectapi/ami-generator/blob/7913f300cccc79c59a2feac42225bbb26c042766/www/build/tools/csslint-rhino.js#L6968-L6997 | train | |
perfectapi/ami-generator | www/build/tools/csslint-rhino.js | function() {
if (this._form){
this._form.parentNode.removeChild(this._form);
this._form = null;
}
if (this._iframe){
this._iframe.parentNode.removeChild(this._iframe);
this._iframe = null;
}
this.... | javascript | function() {
if (this._form){
this._form.parentNode.removeChild(this._form);
this._form = null;
}
if (this._iframe){
this._iframe.parentNode.removeChild(this._iframe);
this._iframe = null;
}
this.... | [
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"_form",
")",
"{",
"this",
".",
"_form",
".",
"parentNode",
".",
"removeChild",
"(",
"this",
".",
"_form",
")",
";",
"this",
".",
"_form",
"=",
"null",
";",
"}",
"if",
"(",
"this",
".",
"_iframe"... | Cleans up the memory associated with the TestReporter, removing DOM elements
that were created.
@return {Void}
@method destroy | [
"Cleans",
"up",
"the",
"memory",
"associated",
"with",
"the",
"TestReporter",
"removing",
"DOM",
"elements",
"that",
"were",
"created",
"."
] | 7913f300cccc79c59a2feac42225bbb26c042766 | https://github.com/perfectapi/ami-generator/blob/7913f300cccc79c59a2feac42225bbb26c042766/www/build/tools/csslint-rhino.js#L7959-L7969 | train | |
perfectapi/ami-generator | www/build/tools/csslint-rhino.js | function(results){
//if the form hasn't been created yet, create it
if (!this._form){
this._form = document.createElement("form");
this._form.method = "post";
this._form.style.visibility = "hidden";
this._form.style.position = "abs... | javascript | function(results){
//if the form hasn't been created yet, create it
if (!this._form){
this._form = document.createElement("form");
this._form.method = "post";
this._form.style.visibility = "hidden";
this._form.style.position = "abs... | [
"function",
"(",
"results",
")",
"{",
"//if the form hasn't been created yet, create it",
"if",
"(",
"!",
"this",
".",
"_form",
")",
"{",
"this",
".",
"_form",
"=",
"document",
".",
"createElement",
"(",
"\"form\"",
")",
";",
"this",
".",
"_form",
".",
"meth... | Sends the report to the server.
@param {Object} results The results object created by TestRunner.
@return {Void}
@method report | [
"Sends",
"the",
"report",
"to",
"the",
"server",
"."
] | 7913f300cccc79c59a2feac42225bbb26c042766 | https://github.com/perfectapi/ami-generator/blob/7913f300cccc79c59a2feac42225bbb26c042766/www/build/tools/csslint-rhino.js#L7977-L8039 | train | |
perfectapi/ami-generator | www/build/tools/csslint-rhino.js | function (page, results){
var r = this._results;
r.passed += results.passed;
r.failed += results.failed;
r.ignored += results.ignored;
r.total += results.total;
r.duration += results.duration;
if (results.failed){
r.failedPages.push(page);
}... | javascript | function (page, results){
var r = this._results;
r.passed += results.passed;
r.failed += results.failed;
r.ignored += results.ignored;
r.total += results.total;
r.duration += results.duration;
if (results.failed){
r.failedPages.push(page);
}... | [
"function",
"(",
"page",
",",
"results",
")",
"{",
"var",
"r",
"=",
"this",
".",
"_results",
";",
"r",
".",
"passed",
"+=",
"results",
".",
"passed",
";",
"r",
".",
"failed",
"+=",
"results",
".",
"failed",
";",
"r",
".",
"ignored",
"+=",
"results"... | Processes the results of a test page run, outputting log messages
for failed tests.
@return {Void}
@method _processResults
@private
@static | [
"Processes",
"the",
"results",
"of",
"a",
"test",
"page",
"run",
"outputting",
"log",
"messages",
"for",
"failed",
"tests",
"."
] | 7913f300cccc79c59a2feac42225bbb26c042766 | https://github.com/perfectapi/ami-generator/blob/7913f300cccc79c59a2feac42225bbb26c042766/www/build/tools/csslint-rhino.js#L8183-L8203 | train | |
perfectapi/ami-generator | www/build/tools/csslint-rhino.js | function () /*:Void*/ {
//set the current page
this._curPage = this._pages.shift();
this.fire(this.TEST_PAGE_BEGIN_EVENT, this._curPage);
//load the frame - destroy history in case there are other iframes that
//need testing
this._frame.location.replace(this._curPage);... | javascript | function () /*:Void*/ {
//set the current page
this._curPage = this._pages.shift();
this.fire(this.TEST_PAGE_BEGIN_EVENT, this._curPage);
//load the frame - destroy history in case there are other iframes that
//need testing
this._frame.location.replace(this._curPage);... | [
"function",
"(",
")",
"/*:Void*/",
"{",
"//set the current page",
"this",
".",
"_curPage",
"=",
"this",
".",
"_pages",
".",
"shift",
"(",
")",
";",
"this",
".",
"fire",
"(",
"this",
".",
"TEST_PAGE_BEGIN_EVENT",
",",
"this",
".",
"_curPage",
")",
";",
"/... | Loads the next test page into the iframe.
@return {Void}
@method _run
@static
@private | [
"Loads",
"the",
"next",
"test",
"page",
"into",
"the",
"iframe",
"."
] | 7913f300cccc79c59a2feac42225bbb26c042766 | https://github.com/perfectapi/ami-generator/blob/7913f300cccc79c59a2feac42225bbb26c042766/www/build/tools/csslint-rhino.js#L8212-L8223 | train | |
perfectapi/ami-generator | www/build/tools/csslint-rhino.js | function () /*:Void*/ {
if (!this._initialized) {
/**
* Fires when loading a test page
* @event testpagebegin
* @param curPage {string} the page being loaded
* @static
*/
/**
* Fires when a test page is comp... | javascript | function () /*:Void*/ {
if (!this._initialized) {
/**
* Fires when loading a test page
* @event testpagebegin
* @param curPage {string} the page being loaded
* @static
*/
/**
* Fires when a test page is comp... | [
"function",
"(",
")",
"/*:Void*/",
"{",
"if",
"(",
"!",
"this",
".",
"_initialized",
")",
"{",
"/**\n * Fires when loading a test page\n * @event testpagebegin\n * @param curPage {string} the page being loaded\n * @static\n */",
... | Begins the process of running the tests.
@return {Void}
@method start
@static | [
"Begins",
"the",
"process",
"of",
"running",
"the",
"tests",
"."
] | 7913f300cccc79c59a2feac42225bbb26c042766 | https://github.com/perfectapi/ami-generator/blob/7913f300cccc79c59a2feac42225bbb26c042766/www/build/tools/csslint-rhino.js#L8270-L8351 | train | |
perfectapi/ami-generator | www/build/tools/csslint-rhino.js | function (parentNode, testSuite) {
//add the test suite
var node = parentNode.appendChild(testSuite);
//iterate over the items in the master suite
for (var i=0; i < testSuite.items.length; i++){
if (testSuite.items[i] instanceof YUITe... | javascript | function (parentNode, testSuite) {
//add the test suite
var node = parentNode.appendChild(testSuite);
//iterate over the items in the master suite
for (var i=0; i < testSuite.items.length; i++){
if (testSuite.items[i] instanceof YUITe... | [
"function",
"(",
"parentNode",
",",
"testSuite",
")",
"{",
"//add the test suite",
"var",
"node",
"=",
"parentNode",
".",
"appendChild",
"(",
"testSuite",
")",
";",
"//iterate over the items in the master suite",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
... | Adds a test suite to the test tree as a child of the specified node.
@param {TestNode} parentNode The node to add the test suite to as a child.
@param {YUITest.TestSuite} testSuite The test suite to add.
@return {Void}
@static
@private
@method _addTestSuiteToTestTree | [
"Adds",
"a",
"test",
"suite",
"to",
"the",
"test",
"tree",
"as",
"a",
"child",
"of",
"the",
"specified",
"node",
"."
] | 7913f300cccc79c59a2feac42225bbb26c042766 | https://github.com/perfectapi/ami-generator/blob/7913f300cccc79c59a2feac42225bbb26c042766/www/build/tools/csslint-rhino.js#L8699-L8712 | train | |
perfectapi/ami-generator | www/build/tools/csslint-rhino.js | function () {
this._root = new TestNode(this.masterSuite);
//this._cur = this._root;
//iterate over the items in the master suite
for (var i=0; i < this.masterSuite.items.length; i++){
if (this.masterSuite.items[i] instanceof YUITest.... | javascript | function () {
this._root = new TestNode(this.masterSuite);
//this._cur = this._root;
//iterate over the items in the master suite
for (var i=0; i < this.masterSuite.items.length; i++){
if (this.masterSuite.items[i] instanceof YUITest.... | [
"function",
"(",
")",
"{",
"this",
".",
"_root",
"=",
"new",
"TestNode",
"(",
"this",
".",
"masterSuite",
")",
";",
"//this._cur = this._root;",
"//iterate over the items in the master suite",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"ma... | Builds the test tree based on items in the master suite. The tree is a hierarchical
representation of the test suites, test cases, and test functions. The resulting tree
is stored in _root and the pointer _cur is set to the root initially.
@return {Void}
@static
@private
@method _buildTestTree | [
"Builds",
"the",
"test",
"tree",
"based",
"on",
"items",
"in",
"the",
"master",
"suite",
".",
"The",
"tree",
"is",
"a",
"hierarchical",
"representation",
"of",
"the",
"test",
"suites",
"test",
"cases",
"and",
"test",
"functions",
".",
"The",
"resulting",
"... | 7913f300cccc79c59a2feac42225bbb26c042766 | https://github.com/perfectapi/ami-generator/blob/7913f300cccc79c59a2feac42225bbb26c042766/www/build/tools/csslint-rhino.js#L8723-L8737 | train | |
perfectapi/ami-generator | www/build/tools/csslint-rhino.js | function () {
//flag to indicate if the TestRunner should wait before continuing
var shouldWait = false;
//get the next test node
var node = this._next();
if (node !== null) {
//set flag to say the testrunner is runn... | javascript | function () {
//flag to indicate if the TestRunner should wait before continuing
var shouldWait = false;
//get the next test node
var node = this._next();
if (node !== null) {
//set flag to say the testrunner is runn... | [
"function",
"(",
")",
"{",
"//flag to indicate if the TestRunner should wait before continuing",
"var",
"shouldWait",
"=",
"false",
";",
"//get the next test node",
"var",
"node",
"=",
"this",
".",
"_next",
"(",
")",
";",
"if",
"(",
"node",
"!==",
"null",
")",
"{"... | Runs a test case or test suite, returning the results.
@param {YUITest.TestCase|YUITest.TestSuite} testObject The test case or test suite to run.
@return {Object} Results of the execution with properties passed, failed, and total.
@private
@method _run
@static | [
"Runs",
"a",
"test",
"case",
"or",
"test",
"suite",
"returning",
"the",
"results",
"."
] | 7913f300cccc79c59a2feac42225bbb26c042766 | https://github.com/perfectapi/ami-generator/blob/7913f300cccc79c59a2feac42225bbb26c042766/www/build/tools/csslint-rhino.js#L8862-L8920 | train | |
perfectapi/ami-generator | www/build/tools/csslint-rhino.js | function (node) {
//get relevant information
var testName = node.testObject,
testCase = node.parent.testObject,
test = testCase[testName],
//get the "should" test cases
shouldIgnore = testName.indexOf("igno... | javascript | function (node) {
//get relevant information
var testName = node.testObject,
testCase = node.parent.testObject,
test = testCase[testName],
//get the "should" test cases
shouldIgnore = testName.indexOf("igno... | [
"function",
"(",
"node",
")",
"{",
"//get relevant information",
"var",
"testName",
"=",
"node",
".",
"testObject",
",",
"testCase",
"=",
"node",
".",
"parent",
".",
"testObject",
",",
"test",
"=",
"testCase",
"[",
"testName",
"]",
",",
"//get the \"should\" t... | Runs a single test based on the data provided in the node.
@param {TestNode} node The TestNode representing the test to run.
@return {Void}
@static
@private
@name _runTest | [
"Runs",
"a",
"single",
"test",
"based",
"on",
"the",
"data",
"provided",
"in",
"the",
"node",
"."
] | 7913f300cccc79c59a2feac42225bbb26c042766 | https://github.com/perfectapi/ami-generator/blob/7913f300cccc79c59a2feac42225bbb26c042766/www/build/tools/csslint-rhino.js#L9122-L9171 | train | |
perfectapi/ami-generator | www/build/tools/csslint-rhino.js | function (options) {
options = options || {};
//pointer to runner to avoid scope issues
var runner = YUITest.TestRunner,
oldMode = options.oldMode;
//if there's only one suite on the masterSuite, move it up
if (!old... | javascript | function (options) {
options = options || {};
//pointer to runner to avoid scope issues
var runner = YUITest.TestRunner,
oldMode = options.oldMode;
//if there's only one suite on the masterSuite, move it up
if (!old... | [
"function",
"(",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"//pointer to runner to avoid scope issues",
"var",
"runner",
"=",
"YUITest",
".",
"TestRunner",
",",
"oldMode",
"=",
"options",
".",
"oldMode",
";",
"//if there's only one suite... | Runs the test suite.
@param {Object|Boolean} options (Optional) Options for the runner:
<code>oldMode</code> indicates the TestRunner should work in the YUI <= 2.8 way
of internally managing test suites. <code>groups</code> is an array
of test groups indicating which tests to run.
@return {Void}
@method run
@static | [
"Runs",
"the",
"test",
"suite",
"."
] | 7913f300cccc79c59a2feac42225bbb26c042766 | https://github.com/perfectapi/ami-generator/blob/7913f300cccc79c59a2feac42225bbb26c042766/www/build/tools/csslint-rhino.js#L9335-L9362 | train | |
perfectapi/ami-generator | www/build/tools/csslint-rhino.js | function(filename, options) {
var input = readFile(filename),
result = CSSLint.verify(input, gatherRules(options)),
formatId = options.format || "text",
messages = result.messages || [],
exitCode = 0;
if (!input) {
print("csslint: Could not read file data in " + filename... | javascript | function(filename, options) {
var input = readFile(filename),
result = CSSLint.verify(input, gatherRules(options)),
formatId = options.format || "text",
messages = result.messages || [],
exitCode = 0;
if (!input) {
print("csslint: Could not read file data in " + filename... | [
"function",
"(",
"filename",
",",
"options",
")",
"{",
"var",
"input",
"=",
"readFile",
"(",
"filename",
")",
",",
"result",
"=",
"CSSLint",
".",
"verify",
"(",
"input",
",",
"gatherRules",
"(",
"options",
")",
")",
",",
"formatId",
"=",
"options",
"."... | process a list of files, return 1 if one or more error occurred | [
"process",
"a",
"list",
"of",
"files",
"return",
"1",
"if",
"one",
"or",
"more",
"error",
"occurred"
] | 7913f300cccc79c59a2feac42225bbb26c042766 | https://github.com/perfectapi/ami-generator/blob/7913f300cccc79c59a2feac42225bbb26c042766/www/build/tools/csslint-rhino.js#L11008-L11027 | train | |
yiwn/compact | lib/compact.js | compact | function compact(source) {
if (!source) return null;
if (isArray(source))
return compactArray(source);
if (typeof source == 'object')
return compactObject(source);
return source;
} | javascript | function compact(source) {
if (!source) return null;
if (isArray(source))
return compactArray(source);
if (typeof source == 'object')
return compactObject(source);
return source;
} | [
"function",
"compact",
"(",
"source",
")",
"{",
"if",
"(",
"!",
"source",
")",
"return",
"null",
";",
"if",
"(",
"isArray",
"(",
"source",
")",
")",
"return",
"compactArray",
"(",
"source",
")",
";",
"if",
"(",
"typeof",
"source",
"==",
"'object'",
"... | Strip `null` and `undefined` values.
@param {Object|Array} source
@return {Object|Array}
@api public | [
"Strip",
"null",
"and",
"undefined",
"values",
"."
] | a30105810a94bfb06d5d4d55020a540c85901809 | https://github.com/yiwn/compact/blob/a30105810a94bfb06d5d4d55020a540c85901809/lib/compact.js#L23-L33 | train |
yiwn/compact | lib/compact.js | compactArray | function compactArray(source) {
return source.reduce(function(result, value){
if (value != void 0)
result.push(value);
return result;
}, []);
} | javascript | function compactArray(source) {
return source.reduce(function(result, value){
if (value != void 0)
result.push(value);
return result;
}, []);
} | [
"function",
"compactArray",
"(",
"source",
")",
"{",
"return",
"source",
".",
"reduce",
"(",
"function",
"(",
"result",
",",
"value",
")",
"{",
"if",
"(",
"value",
"!=",
"void",
"0",
")",
"result",
".",
"push",
"(",
"value",
")",
";",
"return",
"resu... | Remove `null` and `undefined` from array;
@param {Array} source
@return {Array}
@api private | [
"Remove",
"null",
"and",
"undefined",
"from",
"array",
";"
] | a30105810a94bfb06d5d4d55020a540c85901809 | https://github.com/yiwn/compact/blob/a30105810a94bfb06d5d4d55020a540c85901809/lib/compact.js#L43-L49 | train |
yiwn/compact | lib/compact.js | compactObject | function compactObject(source) {
var result = {}, key;
for (key in source) {
var value = source[key];
if (value != void 0)
result[key] = value;
}
return result;
} | javascript | function compactObject(source) {
var result = {}, key;
for (key in source) {
var value = source[key];
if (value != void 0)
result[key] = value;
}
return result;
} | [
"function",
"compactObject",
"(",
"source",
")",
"{",
"var",
"result",
"=",
"{",
"}",
",",
"key",
";",
"for",
"(",
"key",
"in",
"source",
")",
"{",
"var",
"value",
"=",
"source",
"[",
"key",
"]",
";",
"if",
"(",
"value",
"!=",
"void",
"0",
")",
... | Remove `null` and `undefined` from object;
@param {Object} source
@return {Object}
@api private | [
"Remove",
"null",
"and",
"undefined",
"from",
"object",
";"
] | a30105810a94bfb06d5d4d55020a540c85901809 | https://github.com/yiwn/compact/blob/a30105810a94bfb06d5d4d55020a540c85901809/lib/compact.js#L60-L70 | train |
XadillaX/algorithmjs | lib/algorithm/qsort.js | qsort | function qsort(array, l, r, func) {
if(l < r) {
var i = l, j = r;
var x = array[l];
while(i < j) {
while(i < j && func(x, array[j])) j--;
array[i] = array[j];
while(i < j && func(array[i], x)) i++;
array[j] = array[i];
}
array[... | javascript | function qsort(array, l, r, func) {
if(l < r) {
var i = l, j = r;
var x = array[l];
while(i < j) {
while(i < j && func(x, array[j])) j--;
array[i] = array[j];
while(i < j && func(array[i], x)) i++;
array[j] = array[i];
}
array[... | [
"function",
"qsort",
"(",
"array",
",",
"l",
",",
"r",
",",
"func",
")",
"{",
"if",
"(",
"l",
"<",
"r",
")",
"{",
"var",
"i",
"=",
"l",
",",
"j",
"=",
"r",
";",
"var",
"x",
"=",
"array",
"[",
"l",
"]",
";",
"while",
"(",
"i",
"<",
"j",
... | qsort main function
@param array
@param l
@param r
@param func
@return | [
"qsort",
"main",
"function"
] | b291834446fdead3c5303f7759b496110b57d42c | https://github.com/XadillaX/algorithmjs/blob/b291834446fdead3c5303f7759b496110b57d42c/lib/algorithm/qsort.js#L22-L38 | train |
noderaider/redux-addons | lib/context.js | validateLibOpts | function validateLibOpts(libOptsRaw) {
_chai.assert.ok(libOptsRaw, 'libOpts definition is required');
var libName = libOptsRaw.libName;
var validateContext = libOptsRaw.validateContext;
var configureAppContext = libOptsRaw.configureAppContext;
var configureInitialState = libOptsRaw.configureInitialState;
(... | javascript | function validateLibOpts(libOptsRaw) {
_chai.assert.ok(libOptsRaw, 'libOpts definition is required');
var libName = libOptsRaw.libName;
var validateContext = libOptsRaw.validateContext;
var configureAppContext = libOptsRaw.configureAppContext;
var configureInitialState = libOptsRaw.configureInitialState;
(... | [
"function",
"validateLibOpts",
"(",
"libOptsRaw",
")",
"{",
"_chai",
".",
"assert",
".",
"ok",
"(",
"libOptsRaw",
",",
"'libOpts definition is required'",
")",
";",
"var",
"libName",
"=",
"libOptsRaw",
".",
"libName",
";",
"var",
"validateContext",
"=",
"libOpts... | Validates library creators options | [
"Validates",
"library",
"creators",
"options"
] | 7b11262b5a89039e7d96e47b8391840e72510fe1 | https://github.com/noderaider/redux-addons/blob/7b11262b5a89039e7d96e47b8391840e72510fe1/lib/context.js#L62-L80 | train |
noderaider/redux-addons | lib/context.js | validateAppOpts | function validateAppOpts(appOptsRaw) {
_chai.assert.ok(appOptsRaw, 'appOpts are required');
var appName = appOptsRaw.appName;
(0, _chai.assert)(typeof appName === 'string', 'appName opt must be a string');
(0, _chai.assert)(appName.length > 0, 'appName opt must not be empty');
} | javascript | function validateAppOpts(appOptsRaw) {
_chai.assert.ok(appOptsRaw, 'appOpts are required');
var appName = appOptsRaw.appName;
(0, _chai.assert)(typeof appName === 'string', 'appName opt must be a string');
(0, _chai.assert)(appName.length > 0, 'appName opt must not be empty');
} | [
"function",
"validateAppOpts",
"(",
"appOptsRaw",
")",
"{",
"_chai",
".",
"assert",
".",
"ok",
"(",
"appOptsRaw",
",",
"'appOpts are required'",
")",
";",
"var",
"appName",
"=",
"appOptsRaw",
".",
"appName",
";",
"(",
"0",
",",
"_chai",
".",
"assert",
")",... | Validates library consumers options | [
"Validates",
"library",
"consumers",
"options"
] | 7b11262b5a89039e7d96e47b8391840e72510fe1 | https://github.com/noderaider/redux-addons/blob/7b11262b5a89039e7d96e47b8391840e72510fe1/lib/context.js#L83-L90 | train |
konfirm/node-submerge | lib/submerge.js | monitorArray | function monitorArray(a, emit) {
['copyWithin', 'fill', 'pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift']
.forEach(function(key) {
var original = a[key];
a[key] = function() {
var result = original.apply(a, arguments);
emit();
return result;
};
});
return a;
} | javascript | function monitorArray(a, emit) {
['copyWithin', 'fill', 'pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift']
.forEach(function(key) {
var original = a[key];
a[key] = function() {
var result = original.apply(a, arguments);
emit();
return result;
};
});
return a;
} | [
"function",
"monitorArray",
"(",
"a",
",",
"emit",
")",
"{",
"[",
"'copyWithin'",
",",
"'fill'",
",",
"'pop'",
",",
"'push'",
",",
"'reverse'",
",",
"'shift'",
",",
"'sort'",
",",
"'splice'",
",",
"'unshift'",
"]",
".",
"forEach",
"(",
"function",
"(",
... | Wrap all modifying array methods, so change-emisions can be triggered
@name monitorArray
@access internal
@param Array a
@param function emitter
@return Array a | [
"Wrap",
"all",
"modifying",
"array",
"methods",
"so",
"change",
"-",
"emisions",
"can",
"be",
"triggered"
] | 5c471a1c8f794eb3827ca216e739263b512ff16c | https://github.com/konfirm/node-submerge/blob/5c471a1c8f794eb3827ca216e739263b512ff16c/lib/submerge.js#L45-L60 | train |
konfirm/node-submerge | lib/submerge.js | inherit | function inherit(options, destination, source, key) {
var define, override, path;
if (key in destination) {
if (isObject(destination[key]) && isObject(source[key])) {
// live up to the name and merge the sub objects
Object.keys(source[key]).forEach(function(k) {
inherit(options, destination[key], ... | javascript | function inherit(options, destination, source, key) {
var define, override, path;
if (key in destination) {
if (isObject(destination[key]) && isObject(source[key])) {
// live up to the name and merge the sub objects
Object.keys(source[key]).forEach(function(k) {
inherit(options, destination[key], ... | [
"function",
"inherit",
"(",
"options",
",",
"destination",
",",
"source",
",",
"key",
")",
"{",
"var",
"define",
",",
"override",
",",
"path",
";",
"if",
"(",
"key",
"in",
"destination",
")",
"{",
"if",
"(",
"isObject",
"(",
"destination",
"[",
"key",
... | Inherit the value at key of one object from a single other object
@name inherit
@access internal
@param object options {live:bool, locked:bool}
@param object destination
@param object source
@param string key
@return void | [
"Inherit",
"the",
"value",
"at",
"key",
"of",
"one",
"object",
"from",
"a",
"single",
"other",
"object"
] | 5c471a1c8f794eb3827ca216e739263b512ff16c | https://github.com/konfirm/node-submerge/blob/5c471a1c8f794eb3827ca216e739263b512ff16c/lib/submerge.js#L72-L128 | train |
jokeyrhyme/promised-requirejs.js | index.js | promisedRequire | function promisedRequire (name, retries=0) {
if (Array.isArray(name)) {
return Promise.all(name.map((n) => {
return promisedRequire(n);
}));
}
return new Promise(function (resolve, reject) {
global.requirejs([name], (result) => {
resolve(result);
}, (err) => {
var failedId = err... | javascript | function promisedRequire (name, retries=0) {
if (Array.isArray(name)) {
return Promise.all(name.map((n) => {
return promisedRequire(n);
}));
}
return new Promise(function (resolve, reject) {
global.requirejs([name], (result) => {
resolve(result);
}, (err) => {
var failedId = err... | [
"function",
"promisedRequire",
"(",
"name",
",",
"retries",
"=",
"0",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"name",
")",
")",
"{",
"return",
"Promise",
".",
"all",
"(",
"name",
".",
"map",
"(",
"(",
"n",
")",
"=>",
"{",
"return",
"pr... | this module
- @param {(String|String[])} name - module(s) that you wish to load
- @param {Number} [retries=0] - number of extra attempts in case of error | [
"this",
"module",
"-"
] | 2a250ad5306ce555fa76299803b367b1247427a8 | https://github.com/jokeyrhyme/promised-requirejs.js/blob/2a250ad5306ce555fa76299803b367b1247427a8/index.js#L9-L37 | train |
Tennu/tennu-factoids | factoids.js | function (key) {
const value = db.get(key);
if (!value) {
db.set(key, {
frozen: true
});
return;
}
db.set(key, {
intent: value.intent,
message: value.message,
... | javascript | function (key) {
const value = db.get(key);
if (!value) {
db.set(key, {
frozen: true
});
return;
}
db.set(key, {
intent: value.intent,
message: value.message,
... | [
"function",
"(",
"key",
")",
"{",
"const",
"value",
"=",
"db",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"!",
"value",
")",
"{",
"db",
".",
"set",
"(",
"key",
",",
"{",
"frozen",
":",
"true",
"}",
")",
";",
"return",
";",
"}",
"db",
".",... | String -> Boolean | [
"String",
"-",
">",
"Boolean"
] | 1b806563c35e3f75109a6dcb561168972cf990fe | https://github.com/Tennu/tennu-factoids/blob/1b806563c35e3f75109a6dcb561168972cf990fe/factoids.js#L280-L299 | train | |
Nazariglez/perenquen | lib/pixi/src/core/utils/pluginTarget.js | pluginTarget | function pluginTarget(obj)
{
obj.__plugins = {};
/**
* Adds a plugin to an object
*
* @param pluginName {string} The events that should be listed.
* @param ctor {Object} ?? @alvin
*/
obj.registerPlugin = function (pluginName, ctor)
{
obj.__plugins[pluginName] = ctor;
... | javascript | function pluginTarget(obj)
{
obj.__plugins = {};
/**
* Adds a plugin to an object
*
* @param pluginName {string} The events that should be listed.
* @param ctor {Object} ?? @alvin
*/
obj.registerPlugin = function (pluginName, ctor)
{
obj.__plugins[pluginName] = ctor;
... | [
"function",
"pluginTarget",
"(",
"obj",
")",
"{",
"obj",
".",
"__plugins",
"=",
"{",
"}",
";",
"/**\n * Adds a plugin to an object\n *\n * @param pluginName {string} The events that should be listed.\n * @param ctor {Object} ?? @alvin\n */",
"obj",
".",
"registerP... | Mixins functionality to make an object have "plugins".
@mixin
@memberof PIXI.utils
@param obj {object} The object to mix into.
@example
function MyObject() {}
pluginTarget.mixin(MyObject); | [
"Mixins",
"functionality",
"to",
"make",
"an",
"object",
"have",
"plugins",
"."
] | e023964d05afeefebdcac4e2044819fdfa3899ae | https://github.com/Nazariglez/perenquen/blob/e023964d05afeefebdcac4e2044819fdfa3899ae/lib/pixi/src/core/utils/pluginTarget.js#L12-L55 | train |
jamespdlynn/microjs | examples/game/lib/view.js | function(){
canvas = document.getElementById("canvas");
canvas.width = Zone.prototype.WIDTH;
canvas.height = Zone.prototype.HEIGHT;
frameCount = 0;
if (GameView.isRunning()){
run();
}
//Add a listener on our global ... | javascript | function(){
canvas = document.getElementById("canvas");
canvas.width = Zone.prototype.WIDTH;
canvas.height = Zone.prototype.HEIGHT;
frameCount = 0;
if (GameView.isRunning()){
run();
}
//Add a listener on our global ... | [
"function",
"(",
")",
"{",
"canvas",
"=",
"document",
".",
"getElementById",
"(",
"\"canvas\"",
")",
";",
"canvas",
".",
"width",
"=",
"Zone",
".",
"prototype",
".",
"WIDTH",
";",
"canvas",
".",
"height",
"=",
"Zone",
".",
"prototype",
".",
"HEIGHT",
"... | Set up Game View | [
"Set",
"up",
"Game",
"View"
] | 780a4074de84bcd74e3ae50d0ed64144b4474166 | https://github.com/jamespdlynn/microjs/blob/780a4074de84bcd74e3ae50d0ed64144b4474166/examples/game/lib/view.js#L19-L35 | train | |
jamespdlynn/microjs | examples/game/lib/view.js | angleDiff | function angleDiff(angle1, angle2){
var deltaAngle = angle1-angle2;
while (deltaAngle < -Math.PI) deltaAngle += (2*Math.PI);
while (deltaAngle > Math.PI) deltaAngle -= (2*Math.PI);
return Math.abs(deltaAngle);
} | javascript | function angleDiff(angle1, angle2){
var deltaAngle = angle1-angle2;
while (deltaAngle < -Math.PI) deltaAngle += (2*Math.PI);
while (deltaAngle > Math.PI) deltaAngle -= (2*Math.PI);
return Math.abs(deltaAngle);
} | [
"function",
"angleDiff",
"(",
"angle1",
",",
"angle2",
")",
"{",
"var",
"deltaAngle",
"=",
"angle1",
"-",
"angle2",
";",
"while",
"(",
"deltaAngle",
"<",
"-",
"Math",
".",
"PI",
")",
"deltaAngle",
"+=",
"(",
"2",
"*",
"Math",
".",
"PI",
")",
";",
"... | Calculates the delta between two angles | [
"Calculates",
"the",
"delta",
"between",
"two",
"angles"
] | 780a4074de84bcd74e3ae50d0ed64144b4474166 | https://github.com/jamespdlynn/microjs/blob/780a4074de84bcd74e3ae50d0ed64144b4474166/examples/game/lib/view.js#L175-L180 | train |
alexpods/ClazzJS | src/components/meta/Property/Constratins.js | function(object, constraints, property) {
var that = this;
object.__addSetter(property, this.SETTER_NAME, this.SETTER_WEIGHT, function(value, fields) {
return that.apply(value, constraints, property, fields, this);
});
} | javascript | function(object, constraints, property) {
var that = this;
object.__addSetter(property, this.SETTER_NAME, this.SETTER_WEIGHT, function(value, fields) {
return that.apply(value, constraints, property, fields, this);
});
} | [
"function",
"(",
"object",
",",
"constraints",
",",
"property",
")",
"{",
"var",
"that",
"=",
"this",
";",
"object",
".",
"__addSetter",
"(",
"property",
",",
"this",
".",
"SETTER_NAME",
",",
"this",
".",
"SETTER_WEIGHT",
",",
"function",
"(",
"value",
"... | Add constraints setter to object
@param {object} object Object to which constraints will be applied
@param {object} constraints Hash of constraints
@param {string} property Property name
@this {metaProcessor} | [
"Add",
"constraints",
"setter",
"to",
"object"
] | 2f94496019669813c8246d48fcceb12a3e68a870 | https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Property/Constratins.js#L19-L25 | train | |
alexpods/ClazzJS | src/components/meta/Property/Constratins.js | function(value, constraints, property, fields, object) {
_.each(constraints, function(constraint, name) {
if (!constraint.call(object, value, fields, property)) {
throw new Error('Constraint "' + name + '" was failed!');
}
});
return value;
} | javascript | function(value, constraints, property, fields, object) {
_.each(constraints, function(constraint, name) {
if (!constraint.call(object, value, fields, property)) {
throw new Error('Constraint "' + name + '" was failed!');
}
});
return value;
} | [
"function",
"(",
"value",
",",
"constraints",
",",
"property",
",",
"fields",
",",
"object",
")",
"{",
"_",
".",
"each",
"(",
"constraints",
",",
"function",
"(",
"constraint",
",",
"name",
")",
"{",
"if",
"(",
"!",
"constraint",
".",
"call",
"(",
"o... | Applies property constraints to object
@param {*} value Property value
@param {object} constraints Hash of property constraints
@param {string} property Property name
@param {array} fields Property fields
@param {object} object Object
@returns {*} value Processed property value
@throws ... | [
"Applies",
"property",
"constraints",
"to",
"object"
] | 2f94496019669813c8246d48fcceb12a3e68a870 | https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Property/Constratins.js#L42-L51 | train | |
vader-httpclient/vader | build/node/restClient/utils.js | normalizeUrl | function normalizeUrl(url) {
if (!IS_ABSOLUTE.test(url)) {
return (0, _normalizeUrl2['default'])(url).replace('http://', '');
} else {
return (0, _normalizeUrl2['default'])(url);
}
} | javascript | function normalizeUrl(url) {
if (!IS_ABSOLUTE.test(url)) {
return (0, _normalizeUrl2['default'])(url).replace('http://', '');
} else {
return (0, _normalizeUrl2['default'])(url);
}
} | [
"function",
"normalizeUrl",
"(",
"url",
")",
"{",
"if",
"(",
"!",
"IS_ABSOLUTE",
".",
"test",
"(",
"url",
")",
")",
"{",
"return",
"(",
"0",
",",
"_normalizeUrl2",
"[",
"'default'",
"]",
")",
"(",
"url",
")",
".",
"replace",
"(",
"'http://'",
",",
... | Normalize an url.
@param {String} url
@return {String} | [
"Normalize",
"an",
"url",
"."
] | 4c0f5a51faae5ea143a4ce9157ef557b148be55a | https://github.com/vader-httpclient/vader/blob/4c0f5a51faae5ea143a4ce9157ef557b148be55a/build/node/restClient/utils.js#L37-L43 | train |
Psychopoulet/node-promfs | lib/extends/_isFile.js | _isFile | function _isFile (file, callback) {
if ("undefined" === typeof file) {
throw new ReferenceError("missing \"file\" argument");
}
else if ("string" !== typeof file) {
throw new TypeError("\"file\" argument is not a string");
}
else if ("" === file.trim()) {
throw new Error("\"file\" argum... | javascript | function _isFile (file, callback) {
if ("undefined" === typeof file) {
throw new ReferenceError("missing \"file\" argument");
}
else if ("string" !== typeof file) {
throw new TypeError("\"file\" argument is not a string");
}
else if ("" === file.trim()) {
throw new Error("\"file\" argum... | [
"function",
"_isFile",
"(",
"file",
",",
"callback",
")",
"{",
"if",
"(",
"\"undefined\"",
"===",
"typeof",
"file",
")",
"{",
"throw",
"new",
"ReferenceError",
"(",
"\"missing \\\"file\\\" argument\"",
")",
";",
"}",
"else",
"if",
"(",
"\"string\"",
"!==",
"... | methods
Async isFile
@param {string} file : file to check
@param {function} callback : operation's result
@returns {void} | [
"methods",
"Async",
"isFile"
] | 016e272fc58c6ef6eae5ea551a0e8873f0ac20cc | https://github.com/Psychopoulet/node-promfs/blob/016e272fc58c6ef6eae5ea551a0e8873f0ac20cc/lib/extends/_isFile.js#L18-L43 | 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.