_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q32200
acornExtractComments
train
function acornExtractComments (input, opts) { if (typeof input !== 'string') { throw new TypeError('acorn-extract-comments expect `input` to be a string') } if (!input.length) return [] opts = extend({ ast: false, line: false, block: false, preserve: false, locations: false, ecmaVer...
javascript
{ "resource": "" }
q32201
processComments
train
function processComments(file) { let data = JSON.parse(file); return data.map(x => ({ title: x.name, subtitle: x.email, arg: x.id, valid: true })); }
javascript
{ "resource": "" }
q32202
train
function(divisor) { var coverage; var percent = this.options.coverage.match(/(\d*)%$/); if (percent) { coverage = 100 - parseInt(percent[1]); if (divisor) { coverage = coverage / divisor; } } ...
javascript
{ "resource": "" }
q32203
train
function() { // If lockup is already locked don't try to disable inputs again if (this.$pinny.lockup('isLocked')) { return; } var $focusableElements = $(FOCUSABLE_ELEMENTS).not(function() { return $(this).isChildOf('.' + classes.PINNY); ...
javascript
{ "resource": "" }
q32204
train
function() { // At this point, this pinny has been closed and lockup has unlocked. // If there are any other pinny's open we don't want to re-enable the // inputs as they still require them to be disabled. if (this._activePinnies()) { return; }...
javascript
{ "resource": "" }
q32205
basicParser
train
function basicParser(condition, str) { let result = []; for (let i = 0; i < str.length; ++i) { if (condition(str[i])) { result.push(str[i]); } } return result; }
javascript
{ "resource": "" }
q32206
accumulativeParser
train
function accumulativeParser(condition, str) { let accumulations = []; let accumulator = ""; for (let i = 0; i < str.length; ++i) { let ch = str[i]; if (condition(ch)) { accumulator += ch; } else if (accumulator !== "") { accumulations.push(accumulator); ...
javascript
{ "resource": "" }
q32207
computeInitialValue
train
function computeInitialValue(propertyName) { if (properties[propertyName] === undefined) return; // unknown property if (initialValueMap[propertyName]) return; // value is cached. let initialValue = properties[propertyName].initial; if (Array.isArray(initialValue)) { // it's a shorthand initialValue.for...
javascript
{ "resource": "" }
q32208
initialValues
train
function initialValues(property, recursivelyResolve = false, includeShorthands = false) { computeInitialValue(property); if (recursivelyResolve) { const initials = includeShorthands ? initialValueRecursiveMap[property] : initialValueConcreteMap[property]; if (!initials) { // It's an unknown property, ...
javascript
{ "resource": "" }
q32209
validateCaptcha
train
function validateCaptcha(captchaKey, captchaValue, callback) { // callback = function(err, isValid) {...} sweetcaptcha.api('check', {sckey: captchaKey, scvalue: captchaValue}, function(err, response){ if (err) return callback(err); if (response === 'true') { // valid captcha return callback(nu...
javascript
{ "resource": "" }
q32210
train
function (depMap, parent) { var mod = registry[depMap.id]; if (mod) { getModule(depMap).enable(); } }
javascript
{ "resource": "" }
q32211
skipComment
train
function skipComment() { var ch, blockComment, lineComment; blockComment = false; lineComment = false; while (index < length) { ch = source[index]; if (lineComment) { ch = nextChar(); if (isLineTerminator(ch)) { ...
javascript
{ "resource": "" }
q32212
addComment
train
function addComment(start, end, type, value) { assert(typeof start === 'number', 'Comment must have valid position'); // Because the way the actual token is scanned, often the comments // (if any) are skipped twice during the lexical analysis. // Thus, we need to skip adding a comment i...
javascript
{ "resource": "" }
q32213
isInitialValue
train
function isInitialValue(property, value) { const expanded = expandShorthandProperty(property, value, true, true); return Object.entries(expanded).every(([prop, val]) => { // eslint-disable-next-line no-param-reassign val = val.toLowerCase(); if (isShorthandProperty(prop)) return true; if (val === 'i...
javascript
{ "resource": "" }
q32214
train
function (fragmentKey, cachePath, skipCache, callback) { if (skipCache) { debug(' cache is disabled so...'); callback(false); } else { fs.exists(cachePath + '/' + fragmentKey, callback); } }
javascript
{ "resource": "" }
q32215
train
function (data, fragmentKey, cachePath, callback) { debug(' write content in file system'); var basePath = path.dirname(fragmentKey); if (basePath){ mkdirp.sync(cachePath + '/' + basePath); } fs.writeFile(cachePath + '/' + fragmentKey, data, function (err) { if (err) { ...
javascript
{ "resource": "" }
q32216
runHandler
train
function runHandler(plugin, handler, cancel) { return function runHandlerDelegate(data) { if (!data) { return Promise.resolve(); } return Promise .resolve(handler.handler(data, plugin, cancel)) .then(function(result) { return data.configure(result); }); }; }
javascript
{ "resource": "" }
q32217
submitFormData
train
function submitFormData(params, cb) { var resourcePath = config.addURIParams("/appforms/forms/:id/submitFormData", params); var method = "POST"; var data = params.submission; params.resourcePath = resourcePath; params.method = method; params.data = data; mbaasRequest.app(params, cb); }
javascript
{ "resource": "" }
q32218
search
train
function search(params, cb) { var resourcePath = config.addURIParams("/appforms/forms/search", params); var method = "POST"; var data = params.searchParams; params.resourcePath = resourcePath; params.method = method; params.data = data; mbaasRequest.app(params, cb); }
javascript
{ "resource": "" }
q32219
partial
train
function partial(fn) { for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { args[_key - 1] = arguments[_key]; } return function () { return fn.apply(this, args.concat(toArray(arguments))); }; }
javascript
{ "resource": "" }
q32220
RedisTransport
train
function RedisTransport (opts) { this._container = opts.container || 'logs'; this._length = opts.length || undefined; this._client = opts.client || redis.createClient(opts.port, opts.host); // Authorize cleint if (opts.hasOwnProperty('password')) { this._client.auth(opts.password); } // Set database...
javascript
{ "resource": "" }
q32221
findListLength
train
function findListLength (args, next) { client.llen(self._container, function listLengthFound (err, length) { if (err) { return next(err); } args.length = length; return next(null, length); }); }
javascript
{ "resource": "" }
q32222
trimList
train
function trimList (args, next) { if (self._length === undefined || args.length <= self._length) { return next(); } client.ltrim(self._container, 0, self._length, function dataStored (err) { if (err) { return next(err); } return next(); ...
javascript
{ "resource": "" }
q32223
_transitionTo
train
function _transitionTo( nextState, action, data ) { _cancelled = false; _transitionCompleted = false; if( isCancelled() ) { return false; } if( _currentState ) { let previousState = _currentState; if(_options.history){ _history.push(previousState.name); } } _currentState = nextState; if(...
javascript
{ "resource": "" }
q32224
_processActionQueue
train
function _processActionQueue() { if( _actionQueue.length > 0 ) { var stateEvent = _actionQueue.shift(); if(!_currentState.getTarget(stateEvent.action)) { _processActionQueue(); } else { } FSM.action( stateEvent.action, stateEvent.data ); return false; } FSM.log('State transition Com...
javascript
{ "resource": "" }
q32225
train
function( action, target, actionIdnentifier ) { if( this._transitions[ action ] ) { return false; } this._transitions[ action ] = { target : target, _id : actionIdnentifier }; }
javascript
{ "resource": "" }
q32226
train
function (Class, descriptors, staticDescriptors) { var castAll = Casting.forDescriptors(descriptors); function cast (value) { if (!(value instanceof this)) { return new this(castAll(value)); } else { return castAll(value); } } cast.isAutoGenerated = true; retu...
javascript
{ "resource": "" }
q32227
train
function (Class, descriptors, staticDescriptors) { var validate = Validating.forDescriptors(descriptors); validate.isAutoGenerated = true; return validate; }
javascript
{ "resource": "" }
q32228
train
function (Class, descriptors, staticDescriptors) { var casters = {}, validators = {}, body = '"use strict";\n\ var valid = true,\n\ errors = {},\n\ result;\n\ if (values === undefined) {\n\ values = subject || ...
javascript
{ "resource": "" }
q32229
train
function (Class, descriptors) { var body = '"use strict";\n'; var casters = {}; each(descriptors, function (descriptor, name) { if (descriptor.writable || typeof descriptor.set === 'function') { var accessor = createAccessor(name); if (descriptor.cast || descriptor.type) { ca...
javascript
{ "resource": "" }
q32230
train
function (Class, descriptors) { ClassFactory.prototype.updateDynamicFunctions.call(this, Class, descriptors); if (!Class.cast || Class.cast.isAutoGenerated) { Class.cast = this.createStaticCast(Class, descriptors); } if (!Class.validate || Class.validate.isAutoGenerated) { Class.validate = t...
javascript
{ "resource": "" }
q32231
tryCatch1
train
function tryCatch1 (fn, arg1) { var errorObject = {}; try { errorObject.value = fn(arg1); } catch (e) { errorObject.error = e; } return errorObject; }
javascript
{ "resource": "" }
q32232
SuiteModel
train
function SuiteModel (name) { this.className = 'js.' + name this.scenarios = [] this.tagMap = {} this.tagMap.JS = new TagModel('JS') log('Creating new model ' + this.className) }
javascript
{ "resource": "" }
q32233
Slider
train
function Slider(elem) { check(elem, 'elem').is.anInstanceOf(Element)(); var priv = {}; priv.elem = elem; priv.transitions = []; priv.phaser = phaser(elem); priv.slides = []; priv.upgrader = upgrader(elem); priv.listeners = {}; priv.tempClasses = []; priv.fromIndex = 1; priv.toIndex = 0; priv.st...
javascript
{ "resource": "" }
q32234
start
train
function start(priv, callback) { check(priv.started, 'slider.started').is.False(); check(callback, 'callback').is.aFunction.or.Undefined(); priv.startCallback = callback || noop; window.addEventListener('keydown', partial(keyBasedMove, priv), false); priv.elem.addEventListener('click', partial(clickBasedMov...
javascript
{ "resource": "" }
q32235
moveToPrevious
train
function moveToPrevious(priv) { moveTo(priv, (priv.toIndex - 1 + priv.slides.length) % priv.slides.length); }
javascript
{ "resource": "" }
q32236
moveTo
train
function moveTo(priv, index) { check(priv.started, 'slider.started').is.True(); check(index, 'index').is.inRange(0, priv.slides.length)(); var toIndex = index <= priv.slides.length? index % priv.slides.length: index; if (priv.toIndex === toIndex) { return; } removeTempClasses(priv); removeMarkers(pr...
javascript
{ "resource": "" }
q32237
on
train
function on(priv, eventName, listener) { check(eventName, 'eventName').is.aString.and.oneOf(EVENT_NAMES)(); check(listener, 'listener').is.aFunction(); getListeners(priv, eventName).push(listener); }
javascript
{ "resource": "" }
q32238
removeListener
train
function removeListener(priv, eventName, listener) { check(eventName, 'eventName').is.aString.and.oneOf(EVENT_NAMES)(); var listeners = getListeners(priv, eventName); check(listener, 'listener').is.aFunction.and.is.oneOf(listeners, 'registered listeners')(); listeners.splice(listeners.indexOf(listener), 1); }
javascript
{ "resource": "" }
q32239
acceptSlide
train
function acceptSlide(priv, slideElement) { slideElement.classList.add(Flag.UPGRADED); insertSlide(priv, slideElement); priv.phaser.addPhaseTrigger(slideElement.querySelector('.'+ Layout.CONTENT)); if (priv.slides.length === 1) { priv.startCallback.call(null, priv.pub); // moving this to next tick is r...
javascript
{ "resource": "" }
q32240
onReady
train
function onReady( fn ) { // Ensure we passed a function as the argument if ( typeof fn !== 'function' ) { return []; } // If the ready state is already complete, run the passed function, // otherwise add it to our saved array. if ( document.readyState === 'complete' ) { fn(); } else { _readyF...
javascript
{ "resource": "" }
q32241
Hey
train
function Hey(options) { // force the use of new if (this.constructor !== Hey) { throw "Hey must be instantiated with \"new\"!"; } // we need some options, don't we? if (!options || !options.path) { throw "Option object must be set with a valid path to watch."; } // start EventEmitter EventEmitt...
javascript
{ "resource": "" }
q32242
formatDeckAsFullCards
train
function formatDeckAsFullCards(deck, data) { var newDeck = { _id: deck._id, name: deck.name, username: deck.username, lastUpdated: deck.lastUpdated, faction: Object.assign({}, deck.faction) }; if (data.factions) { newDeck.faction = data.factions[deck.faction....
javascript
{ "resource": "" }
q32243
train
function (rawLine) { // Maven on the Travis-CI Ubunty Trusty container makes the version line bold. // Let's just say I'm pretty salty at this point. So we strip ANSI codes. var line = stripAnsi(rawLine); debug('Checking cmd output: ' + line); var match = line.match(re); if (match !== null) { ...
javascript
{ "resource": "" }
q32244
processWatches
train
function processWatches(items) { // queue up matches // { "member" : { "uri" : [ "match", "match" ] } } var toSend = {}; GLOBAL.svc.indexer.retrieveWatches({}, function(err, res) { if (res.hits) { var watches = _.pluck(res.hits.hits, '_source'); // for each hit items.forEach(function(item)...
javascript
{ "resource": "" }
q32245
createStore
train
function createStore(initialState, option) { let $state = initialState; let $listener = []; const $enhancer = option && option.enhancer; const $updater = (() => { const f1 = option && option.updater; const f2 = (s1, s2) => Object.assign({}, s1, s2); return f1 || f2; })(); ...
javascript
{ "resource": "" }
q32246
next
train
function next(i, p, task) { let iResult = task ? { value: task, done: false } : i.next(); try { if (iResult.done) { publish($state); return; } const result = iResult.value($state, p); /* Promise(Like) */ if (resu...
javascript
{ "resource": "" }
q32247
dialog
train
function dialog(opts, cb) { var $ = dialog.air , el = opts.el.clone(true) , container = opts.container || $('body') , evt = opts.evt || 'click' , res = {accepted: false, el: el}; opts.accept = opts.accept || '[href="#ok"]'; opts.reject = opts.reject || '[href="#cancel"]'; // pass function to r...
javascript
{ "resource": "" }
q32248
Delimiters
train
function Delimiters (delims, options) { this.options = options || {}; this.delims = delims || []; this.defaults = merge({}, { beginning: '^', // '^' Matches beginning of input. matter: '([\\s\\S]+?)', // The "content" between the delims body: '([\\s\\S]+|\\s?)', // The "content" after the...
javascript
{ "resource": "" }
q32249
safelyToExecutor
train
function safelyToExecutor(self, executor) { let done = false; try { executor( function(result) { if (done) return; done = true; doResolve.call(self, result); }, // doResolve function(error) { if (done) return; done = true; doReject.call(self, err...
javascript
{ "resource": "" }
q32250
doResolve
train
function doResolve(result) { let self = this; if (result === self) { // Promise Standard 2.3.1 return doReject.call( self, new TypeError("Can not resolve 'Promise' itself") ); } // Promise Standard 2.3.3.2 try { // Promise Standard 2.3.2 and 2.3.3 can be merge // if result is a...
javascript
{ "resource": "" }
q32251
text
train
function text (options) { var opts = options || {} var defaultCharset = opts.defaultCharset || 'utf-8' var inflate = opts.inflate !== false var limit = typeof opts.limit !== 'number' ? bytes.parse(opts.limit || '100kb') : opts.limit var type = opts.type || 'text/plain' var verify = opts.verify || f...
javascript
{ "resource": "" }
q32252
getCharset
train
function getCharset (req) { try { return contentType.parse(req).parameters.charset.toLowerCase() } catch (e) { return undefined } }
javascript
{ "resource": "" }
q32253
Fire
train
function Fire(opts) { opts = opts || {}; opts.host = opts.host || '0.0.0.0'; opts.port = opts.port || 9998; var self = this; Socket.call(self); self.n = 0; self.buf_size = opts.buf_size || 100; self.stream = opts.stream || 'off'; self.log_queue = []; self.connect(opts.port, opts.host, function(){ ...
javascript
{ "resource": "" }
q32254
train
function(name) { if (name in props) { // Check property descriptor var desc = this.getOwnPropertyDescriptor(name); if (props[name].nullable === false) { throw name + ' is not allowd null or undefined'; } return delete obj[name]; } else { throw name...
javascript
{ "resource": "" }
q32255
train
function(receiver, name, val) { if (name in props) { // Check property descriptor var desc = this.getOwnPropertyDescriptor(name); if (desc && !desc.writable) { throw name + ' is not writable property'; } if (props[name].nullable === false && isNullOrUndefined(va...
javascript
{ "resource": "" }
q32256
createFake
train
function createFake(name, obj) { obj = obj || {}; // Only add property for type check. Object.defineProperty(obj, STRUCT_NAME_KEY, { value: name, wriatble: false, enumerable: false }); return obj; }
javascript
{ "resource": "" }
q32257
getUserDictionary
train
function getUserDictionary(){ const userDict = {}; if (!userId){ userDict['userId'] = deviceData.getDeviceId(); } else { userDict['userId'] = userId; } for (let key in extraInfo){ userDict[key] = extraInfo[key]; } return userDict; }
javascript
{ "resource": "" }
q32258
peekTransferables
train
function peekTransferables (data, result) { if ( result === void 0 ) result = []; if (isTransferable(data)) { result.push(data); } else if (isObject(data)) { for (var i in data) { peekTransferables(data[i], result); } } return result }
javascript
{ "resource": "" }
q32259
train
function(service, credentials, accounts, keywords) { Stream.call(this, service, credentials, accounts, keywords); // Initialize FBGraph fbgraph.setAccessToken(credentials.access_token); // Set api endpoint URL for subscriber this.api_endpoint = 'https://graph.facebook.com/'+ credentials.app_id +'/subscr...
javascript
{ "resource": "" }
q32260
train
function(key, value) { const key2 = key.toLowerCase().replace(/[^a-z0-9]/ig, ''); res.serverassist.headers[key] = value; res.serverassist.headers2[key2] = value; }
javascript
{ "resource": "" }
q32261
setTimer
train
function setTimer(job){ clearTimeout(timer); timer = setTimeout(excuteJob, job.excuteTime()-Date.now()); }
javascript
{ "resource": "" }
q32262
excuteJob
train
function excuteJob(){ let job = peekNextJob(); let nextJob; while(!!job && (job.excuteTime()-Date.now())<accuracy){ job.run(); queue.pop(); let nextTime = job.nextTime(); if(nextTime === null){ delete map[job.id]; }else{ queue.offer({id:job.id, time: nextTime}); } job = ...
javascript
{ "resource": "" }
q32263
peekNextJob
train
function peekNextJob(){ if(queue.size() <= 0) return null; let job = null; do{ job = map[queue.peek().id]; if(!job) queue.pop(); }while(!job && queue.size() > 0); return (!!job)?job:null; }
javascript
{ "resource": "" }
q32264
getNextJob
train
function getNextJob(){ let job = null; while(!job && queue.size() > 0){ let id = queue.pop().id; job = map[id]; } return (!!job)?job:null; }
javascript
{ "resource": "" }
q32265
_createProxy
train
function _createProxy(ids, workspaces) { const _workspaces = makeArray(ids).map(id=>{ if (!workspaces.has(id)) workspaces.set(id, {}); return workspaces.get(id); }); return new Proxy(global, { get: function(target, property, receiver) { if (property === 'global') return global; for (let n...
javascript
{ "resource": "" }
q32266
createLookup
train
function createLookup(ids) { for (let value of lookup) { if (ids.length === value.length) { let match = true; value.forEach(subItem=>{ if (ids[n] !== subItem) match = false; }); if (match) return value; } } return ids; }
javascript
{ "resource": "" }
q32267
bfsOrder
train
function bfsOrder(root) { var inqueue = [root], outqueue = []; root._bfs_parent = null; while (inqueue.length > 0) { var elem = inqueue.shift(); outqueue.push(elem); var children = elem.childNodes; var liParent = null; for (var i=0 ; i<children.length; i++) { if (childr...
javascript
{ "resource": "" }
q32268
prefixBlock
train
function prefixBlock(prefix, block, skipEmpty) { var lines = block.split('\n'); for (var i =0; i<lines.length; i++) { // Do not prefix empty lines if (lines[i].length === 0 && skipEmpty === true) continue; else lines[i] = prefix + lines[i]; } return lines.join('\n'); ...
javascript
{ "resource": "" }
q32269
setContent
train
function setContent(node, content, prefix, suffix) { if (content.length > 0) { if (prefix && suffix) node._bfs_text = prefix + content + suffix; else node._bfs_text = content; } else node._bfs_text = ''; }
javascript
{ "resource": "" }
q32270
getContent
train
function getContent(node) { var text = '', atom; for (var i = 0; i<node.childNodes.length; i++) { if (node.childNodes[i].nodeType === 1) { atom = node.childNodes[i]._bfs_text; } else if (node.childNodes[i].nodeType === 3) { atom = node.childNodes[i].data; } else continu...
javascript
{ "resource": "" }
q32271
processNode
train
function processNode(node) { if (node.tagName === 'P' || node.tagName === 'DIV' || node.tagName === 'UL' || node.tagName === 'OL' || node.tagName === 'PRE') setContent(node, getContent(node), '\n\n', '\n\n'); else if (node.tagName === 'BR') setContent(node, '\n\n'); else if (node.tagName === 'HR...
javascript
{ "resource": "" }
q32272
initialize
train
function initialize() { var hash = window.location.hash.match(/^\#?\/([^\/]+)?\/?$/) , self = this; // // The login form is in the DOM by default so it can leverage // browser password saving features. // this.content = $('section.modal').get('innerHTML'); if (hash && hash[1] === 'lo...
javascript
{ "resource": "" }
q32273
modal
train
function modal(e) { e.preventDefault(); // Remove the old listeners so we don't trigger the regular validation Cortex.app('modal').off('done'); var self = this; self.redirect = $(e.element).get('data-redirect'); if (!this.restore) this.restore = Cortex.app('modal').on('close', function () { ...
javascript
{ "resource": "" }
q32274
forgotten
train
function forgotten() { var self = this , username = $('.modal input[name="username"]') , button = $('.modal button[type="submit"]'); // Add an disabled state to the button as we are processing it button.addClass('disabled loading') .set('disabled', 'disabled') .set('innerHTML', 'Sub...
javascript
{ "resource": "" }
q32275
validate
train
function validate(closed) { if (closed) return; var username = $('.modal input[name="username"]') , password = $('.modal input[name="password"]') , button = $('.modal button[type="submit"]') , self = this; // Add an disabled state to the button as we are processing it button.addClass...
javascript
{ "resource": "" }
q32276
render
train
function render(name, data) { var template; if (name !== 'login') { template = this.template(name, data || {}); template.where('name').is('username').use('username').as('value'); template.where('name').is('password').use('password').as('value'); if (data && data.error) { templ...
javascript
{ "resource": "" }
q32277
commandPluck
train
function commandPluck(context, componentIDs, attributes, options) { // resolve the components to ids let result; let entitySet; // if( true ){ log.debug('pluck> ' + stringify(_.rest(arguments))); } attributes = context.valueOf(attributes, true); attributes = Array.isArray(attributes) ? attribu...
javascript
{ "resource": "" }
q32278
expose
train
function expose(anchor, name, message) { Object.defineProperty(errors[anchor], name, { enumerable: true, get: function() { var err = new Error(); err.name = capitalize(anchor) + 'Error'; err.message = message; Error.captureStackTrace(err, arguments.callee); return err; } }...
javascript
{ "resource": "" }
q32279
Router
train
function Router() { var self = this; this.arr = []; this.caseSensitive = true; this.strict = false; this.middleware = function router(msg, next) { self._dispatch(msg, next); }; }
javascript
{ "resource": "" }
q32280
train
function(path, state) { if (t.isStringLiteral(path.node.source, { value: 'react-dom' })) { path.node.source = t.StringLiteral('react-native'); } }
javascript
{ "resource": "" }
q32281
checkApiKey
train
function checkApiKey(key) { if (!GLOBAL.config.apis || !GLOBAL.config.apis[key]) { GLOBAL.error('no GLOBAL.config.apis.bing'); return false; } return true; }
javascript
{ "resource": "" }
q32282
train
function(date, preventOnSelect) { if (!date) { this._d = null; return this.draw(); } if (typeof date === 'string') { date = new Date(Date.parse(date)); } if (!isDate(date)) { return; ...
javascript
{ "resource": "" }
q32283
train
function(date) { if (!isDate(date)) { return; } this._y = date.getFullYear(); this._m = date.getMonth(); this.draw(); }
javascript
{ "resource": "" }
q32284
train
function(force) { if (!this._v && !force) { return; } var opts = this._o, minYear = opts.minYear, maxYear = opts.maxYear, minMonth = opts.minMonth, maxMonth = opts.maxMonth; if (this....
javascript
{ "resource": "" }
q32285
train
function(year, month) { var opts = this._o, now = new Date(), days = getDaysInMonth(year, month), before = new Date(year, month, 1).getDay(), data = [], row = []; setToStartOfDay(now); ...
javascript
{ "resource": "" }
q32286
commandAlias
train
function commandAlias(context, name) { let value; context.alias = context.alias || {}; value = context.last; name = context.valueOf(name, true); value = context.valueOf(value, true); if (context.debug) { log.debug('cmd alias ' + stringify(name) + ' ' + stringify(value)); } con...
javascript
{ "resource": "" }
q32287
caller
train
function caller(instances, index, options) { // at the moment we are only calling the first event, // but lets start prepare the api for managin an array of events return instances(options).then(function (_ref) { var event = _ref.event, eventName = _ref.eventName; var shouldExit = typeof options....
javascript
{ "resource": "" }
q32288
setContextPlugin
train
function setContextPlugin(options) { var seneca = this; var plugin = 'set-context'; options = seneca.util.deepextend({ createContext: createContext, contextHeader: 'x-request-id' }, options); seneca.act({ role: 'web', plugin: plugin, use: processRequest.bind(null, options) }); retur...
javascript
{ "resource": "" }
q32289
processRequest
train
function processRequest(options, req, res, next) { debug('processing HTTP request'); var seneca = req.seneca; options.createContext(req, res, createDefaultContext(options, req), function (error, context) { if (error) { next(error); } else { setContext(seneca, context); next(); } ...
javascript
{ "resource": "" }
q32290
createContext
train
function createContext(req, res, context, done) { debug('default createContext - does nothing', context); process.nextTick(done.bind(null, null, context)); }
javascript
{ "resource": "" }
q32291
objectDeepFromEntries
train
function objectDeepFromEntries(entries) { if (!isArray(entries)) { throw new TypeError( `Expected an array of entries. Received ${getTag(entries)}` ) } let res = {} let isCollection = false if (hasNumKey(entries)) { res = [] isCollection = true } for (const entry of entries) { ...
javascript
{ "resource": "" }
q32292
outerWidth
train
function outerWidth(margin) { var s, style; if(!this.length) { return null; } s = this.dom[0].getClientRects()[0].width; if(!margin) { style = window.getComputedStyle(this.dom[0], null); s -= parseInt(style.getPropertyValue('margin-top')); s -= parseInt(style.getPropertyValue('margin-bottom'))...
javascript
{ "resource": "" }
q32293
outerHeight
train
function outerHeight(margin) { var s, style; if(!this.length) { return null; } s = this.dom[0].getClientRects()[0].height; if(!margin) { style = window.getComputedStyle(this.dom[0], null); s -= parseInt(style.getPropertyValue('margin-top')); s -= parseInt(style.getPropertyValue('margin-bottom'...
javascript
{ "resource": "" }
q32294
readDirStructure
train
async function readDirStructure(dirPath) { if (!dirPath) { throw new Error('Please specify a path to the directory') } const lstat = await makePromise(fs.lstat, dirPath) if (!lstat.isDirectory()) { const err = new Error('Path is not a directory') err.code = 'ENOTDIR' thro...
javascript
{ "resource": "" }
q32295
fromEntries
train
function fromEntries(keys, values) { return keys.reduce((obj, key, i) => { obj[key] = values[i]; return obj; }, {}) }
javascript
{ "resource": "" }
q32296
isEmptyObj
train
function isEmptyObj(object) { if(object === undefined) return true; var objToSend = JSON.parse(JSON.stringify(object)); var result = nestedEmptyCheck(objToSend); if(JSON.stringify(result).indexOf('false') > -1) return false; return true; }
javascript
{ "resource": "" }
q32297
train
function(result) { if (done) { if (session.httpRequest && session.httpRequest.log) { session.httpRequest.log.error("jsonrpc promise resolved after response sent:", req.method, "params:", req.params); } return; ...
javascript
{ "resource": "" }
q32298
create
train
function create() { function app(msg) { app.handle(msg); } utils.merge(app, proto); app.init(); for (var i = 0; i < arguments.length; ++i) { app.use(arguments[i]); } return app; }
javascript
{ "resource": "" }
q32299
update
train
function update(app, target, source) { for (var prop in source) { if (!source.hasOwnProperty(prop)) continue; var def = expandDefinition(app, prop, source[prop]); if (prop in target) { if (!def) { delete target[prop]; } else if (def.route) { ...
javascript
{ "resource": "" }