_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q38800 | train | 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 | {
"resource": ""
} | |
q38801 | train | 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 | {
"resource": ""
} | |
q38802 | createScheduleStatusUpdate | train | 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 | {
"resource": ""
} |
q38803 | train | function(chunk){
if(printOutput){
if (chunk.indexOf(options.matchString) !== -1) {
child_process.stdout.removeListener('data', detachIfStarted);
printOutput = false;
done();
}
}
} | javascript | {
"resource": ""
} | |
q38804 | getClassIndex | train | 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 | {
"resource": ""
} |
q38805 | registerModuleEventListener | train | 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 | {
"resource": ""
} |
q38806 | declaration | train | function declaration(obj) {
const
{error, value} = joi.validate(obj, declarationSchema);
if (error) {
throw new TypeError(`Invalid declaration object: ${error.message}`);
}
return value;
} | javascript | {
"resource": ""
} |
q38807 | getname | train | function getname(req, res) {
res.send(null, req.conn.client.name);
} | javascript | {
"resource": ""
} |
q38808 | setname | train | function setname(req, res) {
req.conn.client.name = req.args[0];
res.send(null, Constants.OK);
} | javascript | {
"resource": ""
} |
q38809 | list | train | function list(req, res) {
var s = '';
this.state.connections.forEach(function(conn) {
s += conn.toString();
})
res.send(null, s);
} | javascript | {
"resource": ""
} |
q38810 | pause | train | function pause(req, res) {
res.send(null, Constants.OK);
this.state.pause(req.args[0]);
} | javascript | {
"resource": ""
} |
q38811 | kill | train | 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 | {
"resource": ""
} |
q38812 | validate | train | 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 | {
"resource": ""
} |
q38813 | checkInbox | train | 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 | {
"resource": ""
} |
q38814 | MongooseStore | train | 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 | {
"resource": ""
} |
q38815 | web | train | 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 | {
"resource": ""
} |
q38816 | helpers | train | 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 | {
"resource": ""
} |
q38817 | NachosConfig | train | 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 | {
"resource": ""
} |
q38818 | train | 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 | {
"resource": ""
} | |
q38819 | addPluginsToScope | train | function addPluginsToScope(scope) {
var name;
for (name in plugins) {
if (plugins.hasOwnProperty(name)) {
scope[name] = plugins[name];
}
}
} | javascript | {
"resource": ""
} |
q38820 | registerPlugin | train | function registerPlugin(name, obj) {
if (name && name.length && obj) {
plugins[name] = obj;
}
} | javascript | {
"resource": ""
} |
q38821 | init | train | 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 | {
"resource": ""
} |
q38822 | InternalCursor | train | function InternalCursor(parent, key) {
debug.assert(parent).is('object');
debug.assert(key).is('defined');
this.cursors = [{'parent':parent, 'key':key}];
} | javascript | {
"resource": ""
} |
q38823 | connect_cb | train | 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 | {
"resource": ""
} |
q38824 | train | 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 | {
"resource": ""
} | |
q38825 | train | 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 | {
"resource": ""
} | |
q38826 | setMessages | train | function setMessages() {
var messages = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
__messages = _extends({}, __messages, messages);
} | javascript | {
"resource": ""
} |
q38827 | whichStream | train | 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 | {
"resource": ""
} |
q38828 | search | train | 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 | {
"resource": ""
} |
q38829 | Plugin | train | 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 | {
"resource": ""
} |
q38830 | take | train | 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 | {
"resource": ""
} |
q38831 | release | train | 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 | {
"resource": ""
} |
q38832 | service | train | 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 | {
"resource": ""
} |
q38833 | Class | train | 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 | {
"resource": ""
} |
q38834 | accept | train | 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 | {
"resource": ""
} |
q38835 | train | 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 | {
"resource": ""
} | |
q38836 | train | function (iterator) {
var self = this;
_.each(self._heap, function (obj) {
return iterator(obj.value, obj.id);
});
} | javascript | {
"resource": ""
} | |
q38837 | matchAndIssueAlertEmails | train | function matchAndIssueAlertEmails(eventDetails, alerts){
underscore.each(alerts, function(alert) {
if (shouldTriggerAlert(eventDetails, alert)){
issueAlertEmail(eventDetails, alert);
}
});
} | javascript | {
"resource": ""
} |
q38838 | shouldTriggerAlert | train | 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 | {
"resource": ""
} |
q38839 | handler | train | 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 | {
"resource": ""
} |
q38840 | columnToSQL | train | 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 | {
"resource": ""
} |
q38841 | train | 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 | {
"resource": ""
} | |
q38842 | train | 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 | {
"resource": ""
} | |
q38843 | helpPlugin | train | 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 | {
"resource": ""
} |
q38844 | removeDoubles | train | 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 | {
"resource": ""
} |
q38845 | cleanDir | train | 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 | {
"resource": ""
} |
q38846 | isNewerThan | train | 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 | {
"resource": ""
} |
q38847 | addData | train | 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 | {
"resource": ""
} |
q38848 | SyntaxUnit | train | 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 | {
"resource": ""
} |
q38849 | train | 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 | {
"resource": ""
} | |
q38850 | train | function(receiver, supplier){
for (var prop in supplier){
if (supplier.hasOwnProperty(prop)){
receiver[prop] = supplier[prop];
}
}
return receiver;
} | javascript | {
"resource": ""
} | |
q38851 | train | 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 | {
"resource": ""
} | |
q38852 | train | function (actual, message) {
YUITest.Assert._increment();
if (true !== actual) {
throw new YUITest.ComparisonFailure(YUITest.Assert._formatMessage(message, "Value should be true."), true, actual);
}
} | javascript | {
"resource": ""
} | |
q38853 | train | function (actual, message) {
YUITest.Assert._increment();
if (actual !== null) {
throw new YUITest.ComparisonFailure(YUITest.Assert._formatMessage(message, "Value should be null."), null, actual);
}
} | javascript | {
"resource": ""
} | |
q38854 | train | 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 | {
"resource": ""
} | |
q38855 | train | 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 | {
"resource": ""
} | |
q38856 | train | 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 | {
"resource": ""
} | |
q38857 | train | 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 | {
"resource": ""
} | |
q38858 | train | 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 | {
"resource": ""
} | |
q38859 | train | 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 | {
"resource": ""
} | |
q38860 | train | 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 | {
"resource": ""
} | |
q38861 | train | function (actual, message) {
YUITest.Assert._increment();
if (actual.length > 0){
YUITest.Assert.fail(YUITest.Assert._formatMessage(message, "Array should be empty."));
}
} | javascript | {
"resource": ""
} | |
q38862 | train | 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 | {
"resource": ""
} | |
q38863 | train | 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 | {
"resource": ""
} | |
q38864 | train | 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 | {
"resource": ""
} | |
q38865 | train | 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 | {
"resource": ""
} | |
q38866 | train | 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 | {
"resource": ""
} | |
q38867 | train | 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 | {
"resource": ""
} | |
q38868 | train | 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 | {
"resource": ""
} | |
q38869 | train | 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 | {
"resource": ""
} | |
q38870 | train | function (testObject) {
if (testObject instanceof YUITest.TestSuite || testObject instanceof YUITest.TestCase) {
this.items.push(testObject);
}
return this;
} | javascript | {
"resource": ""
} | |
q38871 | train | function(results) {
function serializeToXML(results){
var xml = "<" + results.type + " name=\"" + xmlEscape(results.name) + "\"";
if (typeof(results.duration)=="number"){
xml += " duration=\"" + results.duration + "\"";
}
... | javascript | {
"resource": ""
} | |
q38872 | train | 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 | {
"resource": ""
} | |
q38873 | train | 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 | {
"resource": ""
} | |
q38874 | train | 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 | {
"resource": ""
} | |
q38875 | train | 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 | {
"resource": ""
} | |
q38876 | train | 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 | {
"resource": ""
} | |
q38877 | train | 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 | {
"resource": ""
} | |
q38878 | train | 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 | {
"resource": ""
} | |
q38879 | train | 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 | {
"resource": ""
} | |
q38880 | train | 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 | {
"resource": ""
} | |
q38881 | train | 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 | {
"resource": ""
} | |
q38882 | train | 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 | {
"resource": ""
} | |
q38883 | compact | train | function compact(source) {
if (!source) return null;
if (isArray(source))
return compactArray(source);
if (typeof source == 'object')
return compactObject(source);
return source;
} | javascript | {
"resource": ""
} |
q38884 | compactArray | train | function compactArray(source) {
return source.reduce(function(result, value){
if (value != void 0)
result.push(value);
return result;
}, []);
} | javascript | {
"resource": ""
} |
q38885 | compactObject | train | function compactObject(source) {
var result = {}, key;
for (key in source) {
var value = source[key];
if (value != void 0)
result[key] = value;
}
return result;
} | javascript | {
"resource": ""
} |
q38886 | qsort | train | 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 | {
"resource": ""
} |
q38887 | validateLibOpts | train | 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 | {
"resource": ""
} |
q38888 | validateAppOpts | train | 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 | {
"resource": ""
} |
q38889 | monitorArray | train | 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 | {
"resource": ""
} |
q38890 | inherit | train | 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 | {
"resource": ""
} |
q38891 | promisedRequire | train | 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 | {
"resource": ""
} |
q38892 | train | 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 | {
"resource": ""
} | |
q38893 | pluginTarget | train | 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 | {
"resource": ""
} |
q38894 | train | 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 | {
"resource": ""
} | |
q38895 | angleDiff | train | 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 | {
"resource": ""
} |
q38896 | train | 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 | {
"resource": ""
} | |
q38897 | train | 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 | {
"resource": ""
} | |
q38898 | normalizeUrl | train | function normalizeUrl(url) {
if (!IS_ABSOLUTE.test(url)) {
return (0, _normalizeUrl2['default'])(url).replace('http://', '');
} else {
return (0, _normalizeUrl2['default'])(url);
}
} | javascript | {
"resource": ""
} |
q38899 | _isFile | train | 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 | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.