_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q40500
train
function (req, res, next) { if (periodic.app.controller.extension.reactadmin) { let reactadmin = periodic.app.controller.extension.reactadmin; // console.log({ reactadmin }); // console.log('ensureAuthenticated req.session', req.session); // console.log('ensureAuthenticated req.user', req.user); next();...
javascript
{ "resource": "" }
q40501
train
function (req, res, next) { // console.log('req.body', req.body); // console.log('req.params', req.params); var user_token = req.params.token || req.body.token; //req.controllerData.token; waterfall([ function (cb) { cb(null, req, res, next); }, invalidateUserToken, resetPassword, saveUs...
javascript
{ "resource": "" }
q40502
createSub
train
function createSub(value, computed) { if (isArray(value)) { return new List(value, computed); } else if (isObject(value)) { if (isImmutable(value)) { return value; } else if (value.constructor === Object) { return new Struct(value, comp...
javascript
{ "resource": "" }
q40503
Abstract
train
function Abstract(value, data, computed) { this.value = value; this.data = data && each(data, function (item) { return createSub(item); }); this.computedProps = computed; }
javascript
{ "resource": "" }
q40504
train
function(name, schema, callback){ var self = this; this.db.serialize(function() { self.db.run("CREATE TABLE IF NOT EXISTS\"" + name + "\" " + schema, callback); }); }
javascript
{ "resource": "" }
q40505
train
function () { this.el = element(by.tagName('todo')); this.available = function() { return this.el.element(by.binding('$ctrl.todos.length')).getText(); }; this.uncompleted = function() { return this.el.element(by.binding('$ctrl.uncompleted()')).getText(); }; this.todos = function(...
javascript
{ "resource": "" }
q40506
train
function (id) { var self = this; self._unpublishedBuffer.remove(id); // To keep the contract "buffer is never empty in STEADY phase unless the // everything matching fits into published" true, we poll everything as soon // as we see the buffer becoming empty. if (! self._unpublishedBuffer.size()...
javascript
{ "resource": "" }
q40507
train
function (doc) { var self = this; var id = doc._id; if (self._published.has(id)) throw Error("tried to add something already published " + id); if (self._limit && self._unpublishedBuffer.has(id)) throw Error("tried to add something already existed in buffer " + id); var limit = self._li...
javascript
{ "resource": "" }
q40508
train
function (id) { var self = this; if (! self._published.has(id) && ! self._limit) throw Error("tried to remove something matching but not cached " + id); if (self._published.has(id)) { self._removePublished(id); } else if (self._unpublishedBuffer.has(id)) { self._removeBuffered(id); ...
javascript
{ "resource": "" }
q40509
train
function () { var self = this; if (self._stopped) return; self._stopped = true; _.each(self._stopHandles, function (handle) { handle.stop(); }); // Note: we *don't* use multiplexer.onFlush here because this stop // callback is actually invoked by the multiplexer itself when it h...
javascript
{ "resource": "" }
q40510
addBinaries
train
function addBinaries(binaries) { var SLICE = Array.prototype.slice; //iterate backwards to mimic normal resolution order for (var i = binaries.length-1; i >= 0; i--) { var parts = binaries[i].split('/'); (function() {var name = parts[parts.length-1]; exports[name] = function() { //grab the last argument, w...
javascript
{ "resource": "" }
q40511
train
function() { var extended = {}, deep = false, i = 0, length = arguments.length; if (Object.prototype.toString.call(arguments[0]) === '[object Boolean]'){ deep = arguments[0]; i++; } var merge = function(obj) { for (var prop in obj) { if (O...
javascript
{ "resource": "" }
q40512
createApp
train
async function createApp(middlewareConfig) { const app = new Koa() const middleware = await setupMiddleware(middlewareConfig, app) if (app.env == 'production') { app.proxy = true } return { app, middleware, } }
javascript
{ "resource": "" }
q40513
train
function (defaults, attr, custom) { var resolvedPath; if (defaults === undefined || defaults[attr] === undefined) { throw new Error('Missing Parameter', 'Expect a given defaults object'); } if (attr === undefined) { throw new Error('Missing Parameter', 'Expect a...
javascript
{ "resource": "" }
q40514
train
function (content, type) { var results = {}; if (content === undefined) { return results; } _.forEach(content, function (element, key) { if (element === undefined || element.type === undefined || element.type !== type) { return; } ...
javascript
{ "resource": "" }
q40515
train
function (content, type) { var results = []; if (content === undefined) { return results; } _.forEach(content, function (element) { if (element === undefined || element.type === undefined || element.type !== type) { return; } ...
javascript
{ "resource": "" }
q40516
train
function (file, parent, type) { var fileDetails = path.parse(file), filePath = (type === 'static') ? path.join(fileDetails.dir, fileDetails.name + fileDetails.ext) : path.join(fileDetails.dir, fileDetails.name); return { name: filePath, ...
javascript
{ "resource": "" }
q40517
Accumulator
train
function Accumulator(name, deps, fragment, resultsFn, options) { if (!(this instanceof Accumulator)) { return new Accumulator(name, deps, fragment, resultsFn, options); } Task.apply(this, Array.prototype.slice.call(arguments)); this.fragment = fragment; if (!_.isFunction(resultsFn)) { throw new Err...
javascript
{ "resource": "" }
q40518
constructor
train
function constructor(options, error, name) { Pagelet.prototype.constructor.call(this, options); if (name) this.name = name; this.data = error instanceof Error ? error : {}; }
javascript
{ "resource": "" }
q40519
get
train
function get(render) { render(null, { env: this.env, message: this.data.message, stack: this.env !== 'production' ? this.data.stack : '' }); }
javascript
{ "resource": "" }
q40520
pushTask
train
function pushTask(client, task) { /*jshint validthis: true */ if (!this.tasks[client]) { this.tasks[client] = []; } this.tasks[client].push(task); }
javascript
{ "resource": "" }
q40521
Cache
train
function Cache(opts) { //debug.log('new Cache'); opts = opts || {}; debug.assert(opts).is('object'); /** {boolean} True if this cache is using cursors */ this._has_cursors = opts.cursors ? true : false; // All cursors in a VariableStore if(this._has_cursors) { this._cursors = new VariableStore(); this._pa...
javascript
{ "resource": "" }
q40522
train
function(plugin_dir, src, project_dir, dest, link) { var target_path = common.resolveTargetPath(project_dir, dest); if (fs.existsSync(target_path)) throw new Error('"' + target_path + '" already exists!'); common.copyFile(plugin_dir, src, project_dir, dest, !!link); }
javascript
{ "resource": "" }
q40523
Peer
train
function Peer(internalPeer){ Emitter.Target.call(this,emitter); this[rooms] = {}; this[pids] = {}; this[ip] = internalPeer; plugins.give('peer',this); }
javascript
{ "resource": "" }
q40524
Info
train
function Info(state) { this.state = state; this.conf = state.conf; this.stats = state.stats; this.name = pkg.name; this.version = pkg.version; }
javascript
{ "resource": "" }
q40525
getServer
train
function getServer() { var o = {} , uptime = process.uptime() o.version = this.version; o.os = process.platform; o.arch = process.arch; o.process_id = process.pid; o.tcp_port = this.state.addr && this.state.addr.port ? this.state.addr.port : NA; o.uptime_in_seconds = uptime; o.uptime_in_days =...
javascript
{ "resource": "" }
q40526
getMemory
train
function getMemory(rusage) { var o = {}, mem = process.memoryUsage(); o.used_memory = mem.heapUsed; o.used_memory_human = bytes.humanize(mem.heapUsed, 2, true); o.used_memory_rss = mem.rss; o.used_memory_peak = rusage.maxrss; o.used_memory_peak_human = bytes.humanize(rusage.maxrss, 2, true); return o; }
javascript
{ "resource": "" }
q40527
getStats
train
function getStats() { var o = {}; o.total_connections_received = this.stats.connections; o.total_commands_processed = this.stats.commands; o.total_net_input_bytes = this.stats.ibytes; o.total_net_output_bytes = this.stats.obytes; o.rejected_connections = this.stats.rejected; o.expired_keys = this.stats....
javascript
{ "resource": "" }
q40528
getCpu
train
function getCpu(rusage) { var o = {}; //console.dir(rusage); o.used_cpu_sys = rusage.stime.toFixed(2); o.used_cpu_user = rusage.utime.toFixed(2); return o; }
javascript
{ "resource": "" }
q40529
getKeyspace
train
function getKeyspace() { var o = {} , i , db , size; for(i in this.state.store.databases) { db = this.state.store.databases[i]; size = db.dbsize(); if(size) { o['db' + i] = util.format('keys=%s,expires=%s', size, db.expiring); } } return o; }
javascript
{ "resource": "" }
q40530
getObject
train
function getObject(section) { var o = {} , i , k , name , method , sections = section ? [section] : keys , rusage = proc.usage(); for(i = 0;i < sections.length;i++) { k = sections[i]; name = k.charAt(0).toUpperCase() + k.substr(1); method = 'get' + name o[k] = { header...
javascript
{ "resource": "" }
q40531
execute
train
function execute(req, res) { var t = systime(); res.send(null, [t.s, t.m]); }
javascript
{ "resource": "" }
q40532
train
function (filePath) { if (0 === filePath.indexOf(process.cwd())) { filePath = path.relative(process.cwd(), filePath); } if (0 !== filePath.indexOf("./") && 0 !== filePath.indexOf("/")) { filePath = "./" + filePath; } return filePath; ...
javascript
{ "resource": "" }
q40533
train
function(body, error, code, errorTraceId, errorUserTitle, errorUserMessage) { _$jscmd("utils.js", "line", 104); //TODO: support errorTraceId //TODO: errorUserTitle and errorUserMessage should be change from strings to ints (==code) to support localization var response = {...
javascript
{ "resource": "" }
q40534
ErrorNotFound
train
function ErrorNotFound (message, data) { Error.call(this); // Add Information this.name = 'ErrorNotFound'; this.type = 'client'; this.status = 404; if (message) { this.message = message; } if (data) { this.data = {}; if (data.method) { this.data.method = data.method; } if (dat...
javascript
{ "resource": "" }
q40535
hasChild
train
function hasChild(child, element) { assert(child !== undefined, 'Child is undefined'); assertType(element, Node, true, 'Parameter \'element\', if specified, must be a Node'); if (typeof child === 'string') { return !noval(getChild(element, child, true)); } else { if (!element || element === window ||...
javascript
{ "resource": "" }
q40536
lint
train
function lint(p) { return () => { gulp.src(p).pipe(g.eslint()) .pipe(g.eslint.format()) .pipe(g.eslint.failOnError()); }; }
javascript
{ "resource": "" }
q40537
train
function(data, done) { if(!this._key) { done('no key found for metadata'); return; } var key = data[this._key]; var self = this; this._getCollection(function(err) { if(err) { done(err); } var kobj = {}; kobj[self._key.getName()] = k...
javascript
{ "resource": "" }
q40538
train
function(key, done) { if(!this._key) { done('no key found for metadata'); return; } var self = this; this._getCollection(function(err) { if(err) { done(err); } var kobj = {}; kobj[self._key.getName()] = key; self._collection.find(...
javascript
{ "resource": "" }
q40539
addRepository
train
function addRepository(name, rep, directory, gitOptions, options) { var userConfig = options || {}; REPOSITORIES.push(_.extend({ name: name, options: _.extend({ repository: rep, directory: directory || name }, gitOptions || {}) ...
javascript
{ "resource": "" }
q40540
checkCRLF
train
function checkCRLF() { /*function check if the current character is NEWLINE or RETURN if RETURN it checks if the next is NEWLINE (CRLF) afterwards it sets the charIndex after the NEWLINE, RETURN OR CRLF and currentCharacter to the character at index charIndex*/ //check if current character at charIndex ...
javascript
{ "resource": "" }
q40541
validate
train
function validate(cmd, args, info) { AbstractCommand.prototype.validate.apply(this, arguments); var source = '' + args[0] , destination = '' + args[1]; if(!info.db.getKey(args[0], info)) { throw NoSuchKey; }else if(source === destination) { throw SourceDestination; } args[0] = source; args[1...
javascript
{ "resource": "" }
q40542
getIntersectRect
train
function getIntersectRect() { let n = arguments.length; if (!assert(n > 0, 'This method requires at least 1 argument specified.')) return null; let rect = {}; let currRect, nextRect; for (let i = 0; i < n; i++) { if (!currRect) currRect = getRect(arguments[i]); if (!assert(currRect, 'Invalid compu...
javascript
{ "resource": "" }
q40543
executeInitiateBatchTask
train
function executeInitiateBatchTask(batch, cancellable, context) { /** * Defines the initiate batch task (and its sub-tasks) to be used to track the state of the initiating phase. * @returns {InitiateBatchTaskDef} a new initiate batch task definition (with its sub-task definitions) */ function defineInitiate...
javascript
{ "resource": "" }
q40544
executeProcessBatchTask
train
function executeProcessBatchTask(batch, cancellable, context) { /** * Defines the process batch task (and its sub-tasks) to be used to track the state of the processing phase. * @returns {ProcessBatchTaskDef} a new process batch task definition (with its sub-task definitions) */ function defineProcessBatch...
javascript
{ "resource": "" }
q40545
createProcessBatchTask
train
function createProcessBatchTask(batch, context) { // Define a new process task definition for the batch & updates the batch with it batch.taskDefs.processTaskDef = defineProcessBatchTask(); const task = context.taskFactory.createTask(batch.taskDefs.processTaskDef, processTaskOpts); // Cache it on the ...
javascript
{ "resource": "" }
q40546
executeFinaliseBatchTask
train
function executeFinaliseBatchTask(batch, processOutcomes, cancellable, context) { /** * Defines the finalise batch task (and its sub-tasks) to be used to track the state of the finalising phase. * @returns {FinaliseBatchTaskDef} a new finalise batch task definition (with its sub-task definitions) */ functi...
javascript
{ "resource": "" }
q40547
createFinaliseBatchTask
train
function createFinaliseBatchTask(batch, context) { // Define a new finalise task definition for the batch & updates the batch with it batch.taskDefs.finaliseTaskDef = defineFinaliseBatchTask(); const task = context.taskFactory.createTask(batch.taskDefs.finaliseTaskDef, finaliseTaskOpts); // Cache it o...
javascript
{ "resource": "" }
q40548
preProcessBatch
train
function preProcessBatch(batch, context) { const task = this; // const initiatingTask = task.parent; // Look up the actual function to be used to do the load of the previous tracked state (if any) of the current batch const preProcessBatchFn = Settings.getPreProcessBatchFunction(context); if (!preProcessBat...
javascript
{ "resource": "" }
q40549
executeAllProcessAllTasks
train
function executeAllProcessAllTasks(batch, cancellable, context) { const messages = batch.messages; const m = messages.length; const ms = toCountString(m, 'message'); const t = batch.taskDefs.processAllTaskDefs.length; const ts = toCountString(t, 'process all task'); if (m <= 0) { if (context.debugEnab...
javascript
{ "resource": "" }
q40550
calculateTimeoutMs
train
function calculateTimeoutMs(timeoutAtPercentageOfRemainingTime, context) { const remainingTimeInMillis = context.awsContext.getRemainingTimeInMillis(); return Math.round(remainingTimeInMillis * timeoutAtPercentageOfRemainingTime); }
javascript
{ "resource": "" }
q40551
createCompletedPromise
train
function createCompletedPromise(task, completingPromise, batch, timeoutCancellable, context) { const mustResolve = false; return completingPromise.then( outcomes => { // The completing promise has completed // 1. Try to cancel the timeout with which the completing promise was racing const tim...
javascript
{ "resource": "" }
q40552
preFinaliseBatch
train
function preFinaliseBatch(batch, context) { const task = this; // Look up the actual function to be used to do the pre-finalise batch logic (if any) const preFinaliseBatchFn = Settings.getPreFinaliseBatchFunction(context); if (!preFinaliseBatchFn) { if (context.traceEnabled) context.trace(`Skipping pre-fi...
javascript
{ "resource": "" }
q40553
postFinaliseBatch
train
function postFinaliseBatch(batch, context) { const task = this; // const finalisingTask = task.parent; // Look up the actual function to be used to do the post-finalise batch logic (if any) const postFinaliseBatchFn = Settings.getPostFinaliseBatchFunction(context); if (!postFinaliseBatchFn) { if (contex...
javascript
{ "resource": "" }
q40554
logFinalResults
train
function logFinalResults(batch, finalError, context) { const summary = batch ? batch.summarizeFinalResults(finalError) : undefined; context.info(`Summarized final batch results: ${JSON.stringify(summary)}`); }
javascript
{ "resource": "" }
q40555
fromEpoch
train
function fromEpoch(val, def) { if (!is_1.isValue(val) || !is_1.isNumber(val)) return to_1.toDefault(null, def); return new Date(val); }
javascript
{ "resource": "" }
q40556
listEvents
train
function listEvents(req, res, next){ var logger = log.logger; var EventModel = models.getModels().Event; var listReq = RequestTranslator.parseListEventsRequest(req); if(! listReq.uid || ! listReq.env || ! listReq.domain){ return next({"error":"invalid params missing uid env or domain","code":400}); } Ev...
javascript
{ "resource": "" }
q40557
train
function(arn, attributes) { var params = { PlatformApplicationArn: arn, Attributes: attributes }; return this.svc.setPlatformApplicationAttributes(params); }
javascript
{ "resource": "" }
q40558
train
function(arn, token) { var params = { PlatformApplicationArn: arn, NextToken: token }; return this.svc.listEndpointsByPlatformApplication(params); }
javascript
{ "resource": "" }
q40559
train
function(arn, token, data, attributes) { var params = { PlatformApplicationArn: arn, Token: token, CustomUserData: data, Attributes: attributes }; return this.svc.createPlatformEndpoint(params); }
javascript
{ "resource": "" }
q40560
train
function(arn, attributes) { var params = { EndpointArn: arn, Attributes: attributes }; return this.svc.setEndpointAttributes(params); }
javascript
{ "resource": "" }
q40561
train
function(topicArn, endpointArn) { var params = { TopicArn: topicArn, Protocol: 'application', Endpoint: endpointArn }; return this.svc.subscribe(params); }
javascript
{ "resource": "" }
q40562
messageBuilder
train
function messageBuilder(msg, args) { var message = msg, supported = [], badge = 0, builders = {}; //** currently only APNS is supported builders[platforms.APNS] = builders[platforms.APNSSandbox] = function() { return { aps: { //** adds the custom...
javascript
{ "resource": "" }
q40563
getBorders
train
function getBorders(ranges) { var borders = []; ranges.forEach(function(range) { var leftBorder = { value: range.from, type: 'from' }; var rightBorder = { value: range.to, type: 'to' }; borders.push(leftBorder, rightBorder); }); return borders; }
javascript
{ "resource": "" }
q40564
isEqualRange
train
function isEqualRange(range1, range2) { return range1.from === range2.from && range1.to === range2.to; }
javascript
{ "resource": "" }
q40565
generateLevelMap
train
function generateLevelMap () { LEVELS.forEach(level => { const levelIndex = LEVELS.indexOf(level) levelMap[level] = {} LEVELS.forEach(type => { const typeIndex = LEVELS.indexOf(type) if (typeIndex <= levelIndex) { levelMap[level][type] = true } }) }) }
javascript
{ "resource": "" }
q40566
checkLevel
train
function checkLevel (type) { const logLevel = (global.JUDEnvironment && global.JUDEnvironment.logLevel) || 'log' return levelMap[logLevel] && levelMap[logLevel][type] }
javascript
{ "resource": "" }
q40567
format
train
function format (args) { return args.map((v) => { const type = Object.prototype.toString.call(v) if (type.toLowerCase() === '[object object]') { v = JSON.stringify(v) } else { v = String(v) } return v }) }
javascript
{ "resource": "" }
q40568
train
function (url, requestItemsCb) { // use the bearer auth token request.get(url, { 'auth': { 'bearer': exports.authorizedToken } }, (error, response, body) => { if (error) console.error(error) if (response.statusCode && response.statusCode === 200) {...
javascript
{ "resource": "" }
q40569
train
function() { var _2x2x = this; var guard_file = 0; var guard_2x = 0; grunt.file.recurse(this.imgsrcdir, function(file) { guard_file += 1; var srcextname = path.extname(file), ...
javascript
{ "resource": "" }
q40570
train
function(){ var args= slice.call(arguments), block= args.pop(); return blam.compile(block, ctx).apply(tagset, args); }
javascript
{ "resource": "" }
q40571
deepCopy
train
function deepCopy(destination, source) { Object.keys(source).forEach(function (property) { if (destination[property] && isObject(destination[property])) { deepCopy(destination[property], source[property]); } else { destination[property] = source[property]; } }); }
javascript
{ "resource": "" }
q40572
runExtensions
train
function runExtensions(settings) { var extensions = settings.extensions, channels = settings.channels, connection = settings.connection, userPackage = settings.userPackage, server = settings.server; // For every extension the user listed... extensions.forEach(function (extension) { ...
javascript
{ "resource": "" }
q40573
cleanIdentity
train
function cleanIdentity(identity) { var userPackage = {}; Object.keys(identity).forEach(function (key) { if (key.indexOf('BRIGHTSOCKET:') !== 0) { userPackage[key] = identity[key]; } }); return userPackage; }
javascript
{ "resource": "" }
q40574
PoolAPI
train
function PoolAPI(server) { _classCallCheck(this, PoolAPI); this.pool = (0, _socketpool2.default)(server); this.server = server; this.channels = {}; }
javascript
{ "resource": "" }
q40575
get
train
function get(address, contentType, redirs = 0, tries = 0) { return new Promise((fulfill, reject) => { const { host, path } = url.parse(address); const options = { headers: { 'User-Agent': 'peerio-updater/1.0' }, timeout: REQUEST_TIMEOUT, host, path ...
javascript
{ "resource": "" }
q40576
streamToText
train
function streamToText(stream) { return new Promise((fulfill, reject) => { let chunks = []; let length = 0; stream.setEncoding('utf8'); stream.on('data', chunk => { length += chunk.length; if (length > MAX_TEXT_LENGTH) { reject(new Error('Respon...
javascript
{ "resource": "" }
q40577
fetchText
train
function fetchText(address, contentType) { return get(address, contentType) .then(streamToText) .catch(err => { console.error(`Fetch error: ${err.message}`); throw err; // re-throw }); }
javascript
{ "resource": "" }
q40578
fetchFile
train
function fetchFile(address, filepath) { return get(address) .then(res => new Promise((fulfill, reject) => { const file = fs.createWriteStream(filepath); res.on('error', err => { // reading error file.close(); fs.unlink(filepath, err => ...
javascript
{ "resource": "" }
q40579
getVisitorsBySet
train
function getVisitorsBySet(sets) { var visitorsToInclude = sets.reduce(function(visitors, set) { if (!transformSets.hasOwnProperty(set)) { throw new Error('Unknown visitor set: ' + set); } transformSets[set].forEach(function(visitor) { visitors[visitor] = true; }); return visitors; },...
javascript
{ "resource": "" }
q40580
train
function(user_opts) { // Set options this.options = _.defaults(user_opts, this.options) // Set title // this.options.title = chalk.bold(this.options.title) // Without this, we would only get streams once enter is pressed process.stdin.setRawMode(true) // Resume stdin in the parent process...
javascript
{ "resource": "" }
q40581
train
function(message, options, callback) { // If no callback given create one if( ! callback) callback = function() {} // If a previous terminal has been opened then close it if(terminal) terminal.close() terminal = t_menu(this.options.menu) // Reset the terminal, clearing all contents if(thi...
javascript
{ "resource": "" }
q40582
train
function(err, exit) { // Close the terminal if(terminal) terminal.close() // If there was an error throw it before exit if(err) throw err // process.stdin.resume() prevents node from exiting. // process.exit() overrides in more cases than stdin.pause() or stdin.end() // it also means we do...
javascript
{ "resource": "" }
q40583
put
train
function put(item) { if (monitor) monitor("put", item); if (readQueue.length) { if (monitor) monitor("take", item); readQueue.shift()(null, item); } else { dataQueue.push(item); } return dataQueue.length <= bufferSize; }
javascript
{ "resource": "" }
q40584
dlnorm
train
function dlnorm(meanlog, sdlog, logp) { logp = logp === true; if (utils.hasNaN(meanlog, sdlog) || sdlog < 0) { return function() { return NaN; }; } return function(x) { var z; if (utils.hasNaN(x)) { return NaN; } if (sdlog === 0) { return Math.l...
javascript
{ "resource": "" }
q40585
rlnorm
train
function rlnorm(meanlog, sdlog) { var rnorm; rnorm = normal.rnorm(meanlog, sdlog); return function() { return Math.exp(rnorm()); }; }
javascript
{ "resource": "" }
q40586
ptlog
train
function ptlog(df, lowerTail) { return function(x) { var val; if (utils.hasNaN(x, df) || df <= 0) { return NaN; } val = df > x * x ? bratio(0.5, df / 2, x * x / (df + x * x), false, true) : bratio(df / 2, 0.5, 1 / (1 + x / df * x), true, true); if ...
javascript
{ "resource": "" }
q40587
Verbalize
train
function Verbalize(options) { if (!(this instanceof Verbalize)) { return new Verbalize(options); } Logger.call(this); this.options = options || {}; this.define('cache', {}); use(this); this.initDefaults(); this.initPlugins(); }
javascript
{ "resource": "" }
q40588
log
train
function log(err, stdout, stderr, cb) { //And handle errors (if any) if (err) { grunt.log.errorlns(err); } else if (stderr) { grunt.log.errorlns(stderr); } else { //Otherwise load a lodash...
javascript
{ "resource": "" }
q40589
generateIndex
train
function generateIndex(base, files) { var document = base.copy(); var head = document.find().only().elem('head').toValue(); // set title head.find() .only().elem('title').toValue() .setContent('Mocha Tests - all'); // bind testcases Object.keys(files).forEach(function (relative) { head.app...
javascript
{ "resource": "" }
q40590
train
function(o, callback) { var self = this; // Model::insert > Get ID > Create Model this.insert(o, function(err, id) { if (err) { callback.call(self, err, null); } else { self.get(id, function(err, model) { if (err) { callback.call(self, err, null); ...
javascript
{ "resource": "" }
q40591
cropHorizontally
train
function cropHorizontally( img ) { var zoom = this.height / img.height; var x = 0; if( this.cropping == 'body' ) { x = 0.5 * (this.width - img.width * zoom); } else if( this.cropping == 'tail' ) { x = this.width - img.width * zoom; } draw.call( this, img, x, 0, zoom ); }
javascript
{ "resource": "" }
q40592
cropVertically
train
function cropVertically( img ) { var zoom = this.width / img.width; var y = 0; if( this.cropping == 'body' ) { y = 0.5 * (this.height - img.height * zoom); } else if( this.cropping == 'tail' ) { y = this.height - img.height * zoom; } draw.call( this, img, 0, y, zoom ); }
javascript
{ "resource": "" }
q40593
train
function(socket, reqId, moduleId, msg) { doSend(socket, 'monitor', protocol.composeRequest(reqId, moduleId, msg)); }
javascript
{ "resource": "" }
q40594
createLoading
train
function createLoading(opts = {}) { const namespace = opts.namespace || NAMESPACE; const { only = [], except = [] } = opts; if (only.length > 0 && except.length > 0) { throw Error('It is ambiguous to configurate `only` and `except` items at the same time.'); } const initialState = { global: fa...
javascript
{ "resource": "" }
q40595
addEvent
train
function addEvent(o,e,f){ if (o.addEventListener){ o.addEventListener(e,f,false); return true; } else if (o.attachEvent){ return o.attachEvent("on"+e,f); } else { return false; } }
javascript
{ "resource": "" }
q40596
setDefault
train
function setDefault(name,val) { if (typeof(window[name])=="undefined" || window[name]==null) { window[name]=val; } }
javascript
{ "resource": "" }
q40597
expandTree
train
function expandTree(treeId) { var ul = document.getElementById(treeId); if (ul == null) { return false; } expandCollapseList(ul,nodeOpenClass); }
javascript
{ "resource": "" }
q40598
collapseTree
train
function collapseTree(treeId) { var ul = document.getElementById(treeId); if (ul == null) { return false; } expandCollapseList(ul,nodeClosedClass); }
javascript
{ "resource": "" }
q40599
expandToItem
train
function expandToItem(treeId,itemId) { var ul = document.getElementById(treeId); if (ul == null) { return false; } var ret = expandCollapseList(ul,nodeOpenClass,itemId); if (ret) { var o = document.getElementById(itemId); if (o.scrollIntoView) { o.scrollIntoView(false); } } }
javascript
{ "resource": "" }