_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q400
train
function(filedata, callback) { var lines; lines = filedata.toString().split(/(?:\r\n|\r|\n)/gm); if (module.exports.verify(lines)) { return callback(undefined, lines); } return callback('INVALID_SRT_FORMAT'); }
javascript
{ "resource": "" }
q401
train
function(data) { var json = {}, index = 0, id, text, startTimeMicro, durationMicro, invalidText = /^\s+$/, endTimeMicro, time, lastNonEmptyLine; function getLastNonEmptyLine(linesArray) { ...
javascript
{ "resource": "" }
q402
train
function(timestamp) { if (!timestamp) { return; } //TODO check this //var secondsPerStamp = 1.001, var timesplit = timestamp.replace(',', ':').split(':'); return (parseInt(timesplit[0], 10) * 3600 + parseInt(timesplit[1], 10) * 60 + par...
javascript
{ "resource": "" }
q403
train
function(text) { return macros.cleanMacros(text.replace(/\n/g, '{break}').replace(/<i>/g, '{italic}').replace(/<\/i>/g, '{end-italic}')); }
javascript
{ "resource": "" }
q404
finishBasicPromise
train
function finishBasicPromise (resolve, reject) { return (err, res) => { if (err) { return reject(err); } else { return resolve(res); } }; }
javascript
{ "resource": "" }
q405
initRoutes
train
function initRoutes (ravelInstance, koaRouter) { const proto = Object.getPrototypeOf(this); // handle class-level @mapping decorators const classMeta = Metadata.getClassMeta(proto, '@mapping', Object.create(null)); for (const r of Object.keys(classMeta)) { buildRoute(ravelInstance, this, koaRouter, r, class...
javascript
{ "resource": "" }
q406
getClasses
train
function getClasses(element) { const className = element.className; const classes = {}; if (className !== null && className.length > 0) { className.split(' ').forEach((className) => { if (className.trim().length) { classes[className.trim()] = true; } }...
javascript
{ "resource": "" }
q407
getStyle
train
function getStyle(element) { const style = element.style; const styles = {}; for (let i = 0; i < style.length; i++) { const name = style.item(i); const transformedName = transformName(name); styles[transformedName] = style.getPropertyValue(name); } return styles; }
javascript
{ "resource": "" }
q408
train
function (value) { const IllegalValue = this.$err.IllegalValue; if (typeof value !== 'string') { return value; } const result = value.replace(ENVVAR_PATTERN, function () { const varname = arguments[1]; if (process.env[varname] === undefined) { throw new IllegalValue(`Environmen...
javascript
{ "resource": "" }
q409
normalize
train
function normalize(obj, caseType = 'camel') { let ret = obj; const method = methods[caseType]; if (Array.isArray(obj)) { ret = []; let i = 0; while (i < obj.length) { ret.push(normalize(obj[i], caseType)); ++i; } } else if (isPlainObject(obj)) { ret = {}; // eslint-disable-...
javascript
{ "resource": "" }
q410
connectHandlers
train
function connectHandlers (decorator, event) { const handlers = Metadata.getClassMeta(Object.getPrototypeOf(self), decorator, Object.create(null)); for (const f of Object.keys(handlers)) { ravelInstance.once(event, (...args) => { ravelInstance.$log.trace(`${name}: Invoking ${decorator} ${f}`); ...
javascript
{ "resource": "" }
q411
translateX
train
function translateX(progress) { var to = (this.options.to !== undefined) ? this.options.to : 0; var from = (this.options.from !== undefined) ? this.options.from : 0; var offset = (to - from) * progress + from; this.transforms.position[0] = offset; }
javascript
{ "resource": "" }
q412
scale
train
function scale(progress) { var to = (this.options.to !== undefined) ? this.options.to : 1; var from = (this.options.from !== undefined) ? this.options.from : this.transforms.scale[0]; var scale = (to - from) * progress + from; this.transforms.scale[0] = scale; this.transforms.scale[1] = scale; }
javascript
{ "resource": "" }
q413
fade
train
function fade(progress) { var to = (this.options.to !== undefined) ? this.options.to : 0; var from = (this.options.from !== undefined) ? this.options.from : 1; var opacity = (to - from) * progress + from; this.element.style.opacity = opacity; }
javascript
{ "resource": "" }
q414
blur
train
function blur(progress) { var to = (this.options.to !== undefined) ? this.options.to : 0; var from = (this.options.from !== undefined) ? this.options.from : 0; var amount = (to - from) * progress + from; this.element.style.filter = 'blur(' + amount + 'px)'; }
javascript
{ "resource": "" }
q415
parallax
train
function parallax(progress) { var range = this.options.range || 0; var offset = progress * range; // TODO add provision for speed as well this.transforms.position[1] = offset; // just vertical for now }
javascript
{ "resource": "" }
q416
toggle
train
function toggle(progress) { var opts = this.options; var element = this.element; var times = Object.keys(opts); times.forEach(function(time) { var css = opts[time]; if (progress > time) { element.classList.add(css); } else { element.classList.remove(css); } }); }
javascript
{ "resource": "" }
q417
Diagram
train
function Diagram(index, options, question) { this.index = index; this.options = options; this.question = question; this.element = createElement(h('li.list-group-item', { style: { width: '100%', height: '500px' } })); this.viewer; if (options.xml) { // Load XML this.xml...
javascript
{ "resource": "" }
q418
createClient
train
function createClient (ravelInstance, restrict = true) { const localRedis = ravelInstance.get('redis port') === undefined || ravelInstance.get('redis host') === undefined; ravelInstance.on('post init', () => { ravelInstance.$log.info(localRedis ? 'Using in-memory key-value store. Please do not scale this ...
javascript
{ "resource": "" }
q419
BpmnQuestionnaire
train
function BpmnQuestionnaire(options) { // Check if options was provided if (!options) { throw new Error('No options provided'); } if (has(options, 'questionnaireJson')) { this.questionnaireJson = options.questionnaireJson; } else { // Report error throw new Error('No questionnaire specified'...
javascript
{ "resource": "" }
q420
train
function (index, options, questionnaire) { this.index = index; this.options = options; this.questionnaire = questionnaire; if (options.diagram) { this.diagram = new Diagram(index, options.diagram, this); } // Initial state is immutable this.initState = Immutable({ ...
javascript
{ "resource": "" }
q421
parseString
train
function parseString(xml, cb) { return fastxml2js.parseString(xml, function(err, data) { //So that it's asynchronous process.nextTick(function() { cb(err, data); }); }); }
javascript
{ "resource": "" }
q422
_callIfFn
train
function _callIfFn(thing, context, properties) { return _.isFunction(thing) ? thing(context, properties) : thing; }
javascript
{ "resource": "" }
q423
servicesRunning
train
function servicesRunning() { var composeArgs = ['ps']; // If we're tailing just the main service's logs, then we only check that service if (service === '<%= dockerCompose.options.mainService %>') { composeArgs.push(grunt.config.get('dockerCompose.options.mainService')); } // get the stdout of dock...
javascript
{ "resource": "" }
q424
_define
train
function _define(/* <exports>, name, dependencies, factory */) { var // extract arguments argv = arguments, argc = argv.length, // extract arguments from function call - (exports?, name?, modules?, factory) exports = argv[argc ...
javascript
{ "resource": "" }
q425
matches
train
function matches(node, selector) { var parent, matches, i; if (node.matches) { return node.matches(selector); } else { parent = node.parentElement; matches = parent ? parent.querySelectorAll(selector) : []; i = 0; while (matches[i] && matches[i] !== node) { i++; } return !!match...
javascript
{ "resource": "" }
q426
closest
train
function closest(node, parentSelector) { var cursor = node; if (!parentSelector || typeof parentSelector !== 'string') { throw new Error('Please specify a selector to match against!'); } while (cursor && !matches(cursor, parentSelector)) { cursor = cursor.parentNode; } if (!cursor) { return n...
javascript
{ "resource": "" }
q427
wrapElements
train
function wrapElements(els, wrapper) { var wrapperEl = document.createElement(wrapper); // make sure elements are in an array if (els instanceof HTMLElement) { els = [els]; } else { els = Array.prototype.slice.call(els); } _each(els, function (el) { // put it into the wrapper, remove it from it...
javascript
{ "resource": "" }
q428
unwrapElements
train
function unwrapElements(parent, wrapper) { var el = wrapper.childNodes[0]; // ok, so this looks weird, right? // turns out, appending nodes to another node will remove them // from the live NodeList, so we can keep iterating over the // first item in that list and grab all of them. Nice! while (el) { p...
javascript
{ "resource": "" }
q429
createRemoveNodeHandler
train
function createRemoveNodeHandler(el, fn) { return function (mutations, observer) { mutations.forEach(function (mutation) { if (_includes(mutation.removedNodes, el)) { fn(); observer.disconnect(); } }); }; }
javascript
{ "resource": "" }
q430
getPos
train
function getPos(el) { var rect = el.getBoundingClientRect(), scrollY = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop; return { top: rect.top + scrollY, bottom: rect.top + rect.height + scrollY, height: rect.height }; }
javascript
{ "resource": "" }
q431
train
function(tokenService, domainPrefix) { var tokenUrl = tokenService.replace(/\{DOMAIN_PREFIX\}/, domainPrefix); log.debug('token Url: '+ tokenUrl); return tokenUrl; }
javascript
{ "resource": "" }
q432
AdapterFactory
train
function AdapterFactory(injector) { if (!injector.adapters) { return; } var me = this; this.adapterMap = {}; _.each(injector.adapterMap, function (adapterName, adapterType) { var adapter = injector.adapters[adapterName]; if (adapter) { me.adapterMap[adapterType + 'adapter'] ...
javascript
{ "resource": "" }
q433
getCamelCase
train
function getCamelCase(filePath) { if (!filePath) { return ''; } // clip off everything by after the last slash and the .js filePath = filePath.substring(filePath.lastIndexOf(delim) + 1); if (filePath.substring(filePath.length - 3) === '.js') { filePath = filePath.substring(0, fileP...
javascript
{ "resource": "" }
q434
getPascalCase
train
function getPascalCase(filePath) { var camelCase = getCamelCase(filePath); return camelCase.substring(0, 1).toUpperCase() + camelCase.substring(1); }
javascript
{ "resource": "" }
q435
getModulePath
train
function getModulePath(filePath, fileName) { if (isJavaScript(fileName)) { fileName = fileName.substring(0, fileName.length - 3); } return filePath + '/' + fileName; }
javascript
{ "resource": "" }
q436
parseIfJson
train
function parseIfJson(val) { if (_.isString(val)) { val = val.trim(); if (val.substring(0, 1) === '{' && val.substring(val.length - 1) === '}') { try { val = JSON.parse(val); } catch (ex) { /* eslint no-console:0 */ c...
javascript
{ "resource": "" }
q437
chainPromises
train
function chainPromises(calls, val) { if (!calls || !calls.length) { return Q.when(val); } return calls.reduce(Q.when, Q.when(val)); }
javascript
{ "resource": "" }
q438
checksum
train
function checksum(str) { crcTbl = crcTbl || makeCRCTable(); /* jslint bitwise: true */ var crc = 0 ^ (-1); for (var i = 0; i < str.length; i++) { crc = (crc >>> 8) ^ crcTbl[(crc ^ str.charCodeAt(i)) & 0xFF]; } return (crc ^ (-1)) >>> 0; }
javascript
{ "resource": "" }
q439
DependencyInjector
train
function DependencyInjector(opts) { var rootDefault = p.join(__dirname, '../../..'); this.rootDir = opts.rootDir || rootDefault; // project base dir (default is a guess) this.require = opts.require || require; // we need require from the project this.container = opts....
javascript
{ "resource": "" }
q440
loadFactories
train
function loadFactories(opts) { this.flapjackFactory = new FlapjackFactory(this); return [ new InternalObjFactory(this), new AdapterFactory(this), new ServiceFactory(this), new ModelFactory(this), new UipartFactory(this), this.flapj...
javascript
{ "resource": "" }
q441
loadMappings
train
function loadMappings(rootDir, paths) { var mappings = {}, i, j, fullPath, fileNames, fileName, path, name, val; if (!paths) { return mappings; } for (i = 0; i < paths.length; i++) { path = paths[i]; fullPath = rootDir + '/' + path; // i...
javascript
{ "resource": "" }
q442
exists
train
function exists(modulePath, options) { if (this.aliases[modulePath]) { modulePath = this.aliases[modulePath]; } var len = this.factories.length - 1; // -1 because we don't want the default factory for (var i = 0; this.factories && i < len; i++) { if (this.factor...
javascript
{ "resource": "" }
q443
loadModule
train
function loadModule(modulePath, moduleStack, options) { var newModule, i; options = options || {}; // if modulePath is null return null if (!modulePath) { return null; } // if actual flapjack sent in as the module path then switch things around so modulePath...
javascript
{ "resource": "" }
q444
injectFlapjack
train
function injectFlapjack(flapjack, moduleStack, options) { options = options || {}; // if server is false, then return null var moduleInfo = annotations.getModuleInfo(flapjack); if (moduleInfo && moduleInfo.server === false && !options.test) { return null; } ...
javascript
{ "resource": "" }
q445
loadModulePlugins
train
function loadModulePlugins(modulePlugins) { var serverModules = {}; var me = this; // add modules from each plugin to the serverModules map _.each(modulePlugins, function (modulePlugin) { _.extend(serverModules, me.loadModules(modulePlugin.rootDir, modulePlugin.serverModuleD...
javascript
{ "resource": "" }
q446
loadModules
train
function loadModules(rootDir, paths) { var serverModules = {}; var me = this; // return empty object if no rootDir or paths if (!rootDir || !paths) { return serverModules; } // loop through paths and load all modules in those directories _.each(paths, function (relative...
javascript
{ "resource": "" }
q447
traverseFilters
train
function traverseFilters(config, levels, levelIdx) { var lastIdx = levels.length - 1; var val, filters; if (!config || levelIdx > lastIdx) { return null; } val = config[levels[levelIdx]]; if (levelIdx === lastIdx) { if (val) { return val; } else { ...
javascript
{ "resource": "" }
q448
getFilters
train
function getFilters(resourceName, adapterName, operation) { var filterConfig = injector.loadModule('filterConfig'); var filters = { before: [], after: [] }; if (!filterConfig) { return filters; } var levels = [resourceName, adapterName, operation, 'before']; filters.before = (traverseFilters(filte...
javascript
{ "resource": "" }
q449
processApiCall
train
function processApiCall(resource, operation, requestParams) { var service = injector.loadModule(utensils.getCamelCase(resource.name + '.service')); var adapterName = resource.adapters.api; // remove the keys that start with onBehalfOf _.each(requestParams, function (val, key) { if (key.indexOf(...
javascript
{ "resource": "" }
q450
loadInlineCss
train
function loadInlineCss(rootDir, apps) { _.each(apps, function (app, appName) { _.each(app.routes, function (route) { var filePath = rootDir + '/app/' + appName + '/inline/' + route.name + '.css'; if (route.inline && fs.existsSync(filePath)) { inlineCssCache[appName + ...
javascript
{ "resource": "" }
q451
convertUrlSegmentToRegex
train
function convertUrlSegmentToRegex(segment) { // if it has this format "{stuff}" - then it's regex-y var beginIdx = segment.indexOf('{'); var endIdx = segment.indexOf('}'); if (beginIdx < 0) { return segment; } // if capturing regex and trim trailing "}" // this could be a named re...
javascript
{ "resource": "" }
q452
getTokenValuesFromUrl
train
function getTokenValuesFromUrl(pattern, url) { var tokenValues = {}, urlSegments = url.split('/'); pattern.split('/').forEach(function (segment, idx) { // this has this form {stuff}, so let's dig var beginIdx = segment.indexOf('{'); var endIdx = segment.indexOf('}'); va...
javascript
{ "resource": "" }
q453
getRouteInfo
train
function getRouteInfo(appName, urlRequest, query, lang, user, referrer) { var activeUser = user ? { _id: user._id, name: user.username, role: user.role, user: user } : {}; // if route info already in cache, return it var cacheKey = appName + '||' + lang + '||' + urlRequ...
javascript
{ "resource": "" }
q454
setDefaults
train
function setDefaults(model, defaults) { if (!defaults) { return; } _.each(defaults, function (value, key) { if (model[key] === undefined) { model[key] = value; } }); }
javascript
{ "resource": "" }
q455
getInitialModel
train
function getInitialModel(routeInfo, page) { var initModelDeps = { appName: routeInfo.appName, tokens: routeInfo.tokens, routeInfo: routeInfo, defaults: page.defaults, activeUser: routeInfo.activeUser || {}, currentScope: {} }; // if no model, just r...
javascript
{ "resource": "" }
q456
processWebRequest
train
function processWebRequest(routeInfo, callbacks) { var appName = routeInfo.appName; var serverOnly = !!routeInfo.query.server; var page = injector.loadModule('app/' + appName + '/pages/' + routeInfo.name + '.page'); // get the callbacks var serverPreprocessing = callbacks.serverPreprocessing || fun...
javascript
{ "resource": "" }
q457
generateTransformer
train
function generateTransformer(name, transformerFns, templateDir, pluginOptions) { var Transformer = function () {}; var transformer = new Transformer(); // add function mixins to the transformer _.extend(transformer, transformerFns, baseTransformer, annotationHelper, utensils, pluginOptions); // a...
javascript
{ "resource": "" }
q458
getTransformer
train
function getTransformer(name, clientPlugin, pluginOptions) { // if in cache, just return it if (cache[name]) { return cache[name]; } var transformers = clientPlugin.transformers; var templateDir = clientPlugin.templateDir; // if no transformer, throw error if (!transformers[name]) { throw new...
javascript
{ "resource": "" }
q459
init
train
function init(opts) { opts = opts || {}; // include pancakes instance into options that we pass to plugins opts.pluginOptions = opts.pluginOptions || {}; opts.pluginOptions.pancakes = exports; injector = new DependencyInjector(opts); var ClientPlugin = opts.clientPlugin; var ServerPlugin =...
javascript
{ "resource": "" }
q460
initContainer
train
function initContainer(opts) { var apps, appDir; container = opts.container; // if batch, preload that dir container === 'batch' ? opts.preload.push('batch') : opts.preload.push('middleware'); if (container === 'webserver') { appDir = path.join(opts.rootDir, '/app'); ...
javascript
{ "resource": "" }
q461
requireModule
train
function requireModule(filePath, refreshFlag) { if (refreshFlag) { delete injector.require.cache[filePath]; } return injector.require(filePath); }
javascript
{ "resource": "" }
q462
getService
train
function getService(name) { if (name.indexOf('.') >= 0) { name = utils.getCamelCase(name); } if (!name.match(/^.*Service$/)) { name += 'Service'; } return cook(name); }
javascript
{ "resource": "" }
q463
transform
train
function transform(flapjack, pluginOptions, runtimeOptions) { var name = runtimeOptions.transformer; var transformer = transformerFactory.getTransformer(name, clientPlugin, pluginOptions); var options = _.extend({}, pluginOptions, runtimeOptions); return transformer.transform(flapjack, options); }
javascript
{ "resource": "" }
q464
train
function(e) { var tooltip = this.$(".ui-tooltip-top"); var val = this.input.val(); tooltip.fadeOut(); if (this.tooltipTimeout) clearTimeout(this.tooltipTimeout); if (val == '' || val == this.input.attr('placeholder')) return; var show = function(){ tooltip.show().fadeIn(); }; t...
javascript
{ "resource": "" }
q465
getUiPart
train
function getUiPart(modulePath, options) { var rootDir = this.injector.rootDir; var tplDir = (options && options.tplDir) || 'dist' + delim + 'tpls'; var pathParts = modulePath.split(delim); var appName = pathParts[1]; var len = modulePath.length; var filePath, fullModulePa...
javascript
{ "resource": "" }
q466
ServiceFactory
train
function ServiceFactory(injector) { this.cache = {}; this.injector = injector || {}; // if we are in debug mode, then add the debug handler var pattern = this.injector.debugPattern || '*.*.*.*.*'; var handler = this.injector.debugHandler || debugHandler; if (this.injector.debug) { event...
javascript
{ "resource": "" }
q467
isCandidate
train
function isCandidate(modulePath) { modulePath = modulePath || ''; var len = modulePath.length; return modulePath.indexOf('/') < 0 && len > 7 && modulePath.substring(modulePath.length - 7) === 'Service'; }
javascript
{ "resource": "" }
q468
getServiceInfo
train
function getServiceInfo(serviceName, adapterMap) { var serviceInfo = { serviceName: serviceName }; var serviceParts = utils.splitCamelCase(serviceName); // turn oneTwoThree into ['one', 'two', 'three'] var nbrParts = serviceParts.length; // first check to see if the second to last part...
javascript
{ "resource": "" }
q469
getResource
train
function getResource(serviceInfo, moduleStack) { var resourceName = serviceInfo.resourceName; var resourcePath = '/resources/' + resourceName + '/' + resourceName + '.resource'; return this.loadIfExists(resourcePath, moduleStack, 'Could not find resource file'); }
javascript
{ "resource": "" }
q470
getAdapter
train
function getAdapter(serviceInfo, resource, moduleStack) { var adapterName = serviceInfo.adapterName; // if adapter name is 'service' and there is a default, switch to the default if (adapterName === 'service' && resource.adapters[this.injector.container]) { adapterName = serviceInfo...
javascript
{ "resource": "" }
q471
loadIfExists
train
function loadIfExists(path, moduleStack, errMsg) { var servicesDir = this.injector.servicesDir; var servicesFullPath = this.injector.rootDir + '/' + servicesDir; // if the file doesn't exist, either throw an error (if msg passed in), else just return null if (!fs.existsSync(p.join(servi...
javascript
{ "resource": "" }
q472
putItAllTogether
train
function putItAllTogether(serviceInfo, resource, adapter) { var me = this; var debug = this.injector.debug; // loop through the methods _.each(resource.methods[serviceInfo.adapterName], function (method) { if (!adapter[method]) { return; } ...
javascript
{ "resource": "" }
q473
emitEvent
train
function emitEvent(payload, eventNameBase, debugParams) { // create a copy of the payload so that nothing modifies the original object try { payload = JSON.parse(JSON.stringify(payload)); } catch (err) { /* eslint no-console:0 */ console.log('issue pa...
javascript
{ "resource": "" }
q474
validateRequestParams
train
function validateRequestParams(req, resource, method, adapter) { req = req || {}; var params = resource.params || {}; var methodParams = _.extend({}, params[method], params[adapter + '.' + method] ); var requiredParams = methodParams.required || []; var eitherorParams = methodPa...
javascript
{ "resource": "" }
q475
logWrap
train
function logWrap(level) { return function log() { let context, message, args, trace, err; if (arguments[0] instanceof Error) { // log.<level>(err, ...) context = API.getContext(); args = Array.prototype.slice.call(arguments, 1); if (!args.length) { // log.<leve...
javascript
{ "resource": "" }
q476
setLevel
train
function setLevel(level) { opts.level = level; let logLevelIndex = levels.indexOf(opts.level.toUpperCase()); levels.forEach((logLevel) => { let fn; if (logLevelIndex <= levels.indexOf(logLevel)) { fn = logWrap(logLevel); } else { fn = noop; } API[logLevel.toLow...
javascript
{ "resource": "" }
q477
merge
train
function merge(obj1, obj2) { var res = {}, attrname; for (attrname in obj1) { res[attrname] = obj1[attrname]; } for (attrname in obj2) { res[attrname] = obj2[attrname]; } return res; }
javascript
{ "resource": "" }
q478
loadUIPart
train
function loadUIPart(appName, filePath) { var idx = filePath.indexOf(delim + appName + delim); var modulePath = filePath.substring(idx - 3); return this.pancakes.cook(modulePath); }
javascript
{ "resource": "" }
q479
setTemplate
train
function setTemplate(transformDir, templateName, clientType) { clientType = clientType ? (clientType + '.') : ''; if (templateCache[templateName]) { this.template = templateCache[templateName]; } else { var fileName = transformDir + '/' + clientType + templateName + '.template'; ...
javascript
{ "resource": "" }
q480
getParamInfo
train
function getParamInfo(params, aliases) { var paramInfo = { converted: [], list: [], ngrefs: [] }; _.each(params, function (param) { var mappedVal = aliases[param] || param; if (mappedVal === 'angular') { paramInfo.ngrefs.push(param); } else { paramInfo.li...
javascript
{ "resource": "" }
q481
getFilteredParamInfo
train
function getFilteredParamInfo(flapjack, options) { if (!flapjack) { return {}; } var aliases = this.getClientAliases(flapjack, options); var params = this.getParameters(flapjack) || []; params = params.filter(function (param) { return ['$scope', 'defaults', 'initialModel'].indexOf(param) < 0; ...
javascript
{ "resource": "" }
q482
getModuleBody
train
function getModuleBody(flapjack) { if (!flapjack) { return ''; } var str = flapjack.toString(); var openingCurly = str.indexOf('{'); var closingCurly = str.lastIndexOf('}'); // if can't find the opening or closing curly, just return the entire string if (openingCurly < 0 || closingCurly < 0) {...
javascript
{ "resource": "" }
q483
updateInfo
train
function updateInfo(info, override, source, sourceId) { if (source) { if (source.minzoom !== undefined) { // eslint-disable-next-line no-param-reassign info.minzoom = source.minzoom; } if (source.maxzoom !== undefined) { // eslint-disable-next-line no-param-reassign info.maxzoom = ...
javascript
{ "resource": "" }
q484
qcertEval
train
function qcertEval(inputConfig) { console.log("qcertEval chosen"); var handler = function(result) { console.log("Compiler returned"); console.log(result); postMessage(result.eval); console.log("reply message posted"); // Each spawned worker is designed to be used once close(); } qcertWhiskDispatch(inpu...
javascript
{ "resource": "" }
q485
getAnnotationInfo
train
function getAnnotationInfo(name, fn, isArray) { if (!fn) { return null; } var str = fn.toString(); var rgx = new RegExp('(?:@' + name + '\\()(.*)(?:\\))'); var matches = rgx.exec(str); if (!matches || matches.length < 2) { return null; } var annotation = matches[1]; if (isAr...
javascript
{ "resource": "" }
q486
getAliases
train
function getAliases(name, flapjack) { var moduleInfo = getModuleInfo(flapjack) || {}; var aliases = moduleInfo[name] || {}; return aliases === true ? {} : aliases; }
javascript
{ "resource": "" }
q487
getServerAliases
train
function getServerAliases(flapjack, options) { options = options || {}; var aliases = getAliases('server', flapjack); var serverAliases = options && options.serverAliases; return _.extend({}, aliases, serverAliases); }
javascript
{ "resource": "" }
q488
getClientAliases
train
function getClientAliases(flapjack, options) { options = options || {}; var aliases = getAliases('client', flapjack); return _.extend({}, aliases, options.clientAliases); }
javascript
{ "resource": "" }
q489
getParameters
train
function getParameters(flapjack) { if (!_.isFunction(flapjack)) { throw new Error('Flapjack not a function ' + JSON.stringify(flapjack)); } var str = flapjack.toString(); var pattern = /(?:\()([^\)]*)(?:\))/; var matches = pattern.exec(str); if (matches === null || matches.length < 2)...
javascript
{ "resource": "" }
q490
getResourceNames
train
function getResourceNames() { var resourceNames = {}; var resourcesDir = this.injector.rootDir + '/' + this.injector.servicesDir + '/resources'; if (!fs.existsSync(path.normalize(resourcesDir))) { return resourceNames; } var names = fs.readdirSync(path.normalize(res...
javascript
{ "resource": "" }
q491
getModel
train
function getModel(service, mixins) { // model constructor takes in data and saves it along with the model mixins var Model = function (data) { _.extend(this, data, mixins); }; if (service.save) { Model.prototype.save = function () { if (this._id)...
javascript
{ "resource": "" }
q492
create
train
function create(modulePath, moduleStack) { // first check the cache to see if we already loaded it if (this.cache[modulePath]) { return this.cache[modulePath]; } // try to get the resource for this module var resource; if (this.resources[modulePath]) { ...
javascript
{ "resource": "" }
q493
InternalObjectFactory
train
function InternalObjectFactory(injector) { this.injector = injector; this.internalObjects = { resources: true, reactors: true, adapters: true, appConfigs: true, eventBus: eventBus, chainPromises: utils.chainPromises }; }
javascript
{ "resource": "" }
q494
loadResources
train
function loadResources() { var resources = {}; var resourcesDir = path.join(this.injector.rootDir, this.injector.servicesDir + '/resources'); if (!fs.existsSync(resourcesDir)) { return resources; } var me = this; var resourceNames = fs.readdirSync(resources...
javascript
{ "resource": "" }
q495
loadAdapters
train
function loadAdapters() { var adapters = {}; var adaptersDir = path.join(this.injector.rootDir, this.injector.servicesDir + '/adapters'); if (!fs.existsSync(adaptersDir)) { return this.injector.adapters || {}; } var me = this; var adapterNames = fs.readdirSy...
javascript
{ "resource": "" }
q496
loadReactors
train
function loadReactors() { var reactors = {}; var reactorsDir = path.join(this.injector.rootDir, this.injector.servicesDir + '/reactors'); if (!fs.existsSync(reactorsDir)) { return reactors; } var me = this; var reactorNames = fs.readdirSync(reactorsDir); ...
javascript
{ "resource": "" }
q497
loadAppConfigs
train
function loadAppConfigs() { var appConfigs = {}; var appDir = path.join(this.injector.rootDir, '/app'); if (!fs.existsSync(appDir)) { return appConfigs; } var me = this; var appNames = fs.readdirSync(appDir); _.each(appNames, function (appName) { ...
javascript
{ "resource": "" }
q498
create
train
function create(objectName) { // for resources we need to load them the first time they are referenced if (objectName === 'resources' && this.internalObjects[objectName] === true) { this.internalObjects[objectName] = this.loadResources(); } // for reactors we need to load t...
javascript
{ "resource": "" }
q499
formatDevTrace
train
function formatDevTrace(level, context, message, args, err) { var str, mainMessage = util.format.apply(global, [message].concat(args)), printStack = API.stacktracesWith.indexOf(level) > -1, errCommomMessage = err && (err.name + ': ' + err.message), isErrorLoggingWithoutMessage = mainMessage ==...
javascript
{ "resource": "" }