_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q63300
normalize
test
function normalize (obj) { var result = obj; if (typeof obj !== "function") { if (typeof obj !== "undefined") { if (Object.prototype.toString.call(obj) !== "[object Object]") { result = (function (value) { return function () { return value; }; }(obj)); } else { result = (function (o)...
javascript
{ "resource": "" }
q63301
supplyMissingDefault
test
function supplyMissingDefault (options, name) { if (options[name]() === void 0) { options[name] = _.wrap(options[name], function(func, key) { var res = func(key); return res === void 0 ? defaults[name] : res; }); } }
javascript
{ "resource": "" }
q63302
prepOptions
test
function prepOptions (options, listener) { // Ensure defaults are represented common.ensure(options, defaults); // Normalize certain arguments if they are not functions. // The certain arguments are per-page options. // However, outputPath is a special case [ "selector", "timeout", "useJQuery", "verbos...
javascript
{ "resource": "" }
q63303
getOutputPath
test
function getOutputPath (options, page, parse) { var pagePart = urlm.parse(page), // if outputPath was normalized with an object, let the key passthru outputPath = options.outputPath(page, true); // check for bad output path if (!outputPath) { return false; } // if the outputPath is really st...
javascript
{ "resource": "" }
q63304
mapOutputFile
test
function mapOutputFile (options, page, parse) { if (!_.isFunction(options.outputPath)) { options.outputPath = normalize(options.outputPath); } var outputPath = getOutputPath(options, page, parse); var outputDir = options.outputDir; var fileName = "index.html"; if (options.sitemapOutputDir) { outpu...
javascript
{ "resource": "" }
q63305
test
function (options, generator, listener) { options = options || {}; prepOptions(options, listener); return generator(options); }
javascript
{ "resource": "" }
q63306
test
function (options, page) { var parse = {}; var outputFile = mapOutputFile(options, page, parse); if (outputFile) { options._inputEmitter.emit("input", { outputFile: outputFile, // make the url url: urlm.format({ protocol: options.protocol, auth...
javascript
{ "resource": "" }
q63307
pathExists
test
function pathExists (path, options) { options = options || { returnFile: false }; // Defaults to F_OK return nodeCall(fs.access, path) .then(function () { return options.returnFile ? path : true; }) .catch(function () { if (fs.existsSync(path)) { return options.returnFile ? ...
javascript
{ "resource": "" }
q63308
test
function () { // If the path we're given by phantomjs is to a .cmd, it is pointing to a global copy. // Using the cmd as the process to execute causes problems cleaning up the processes // so we walk from the cmd to the phantomjs.exe and use that instead. var phantomSource = require("phantomjs-prebuilt").path;...
javascript
{ "resource": "" }
q63309
worker
test
function worker (input, options, notifier, qcb) { var cp, customModule, snapshotScript = options.snapshotScript, phantomjsOptions = Array.isArray(input.phantomjsOptions) ? input.phantomjsOptions : [input.phantomjsOptions]; // If the outputFile has NOT already been seen by the notifier, process. ...
javascript
{ "resource": "" }
q63310
prepOptions
test
function prepOptions (options) { // ensure this module's defaults are represented in the options. common.ensure(options, defaults); // if array data source, ensure input type is "array". if (Array.isArray(options.source)) { options.input = "array"; } }
javascript
{ "resource": "" }
q63311
test
function (options, listener) { var inputGenerator, notifier, started, result, q, emitter, completion; options = options || {}; prepOptions(options); // create the inputGenerator, default to robots inputGenerator = inputFactory.create(options.input); // clean the snapshot output directory ...
javascript
{ "resource": "" }
q63312
createLockFactory
test
function createLockFactory () { // Create the per instance async lock. var lock = new AsyncLock(); // Make a random id var rid = crypto.randomBytes(16).toString("hex"); /** * Force a serial execution context. * * @param {Function} fn - The function to guard. * @param {Number} timeout - The max t...
javascript
{ "resource": "" }
q63313
Notifier
test
function Notifier () { // Create the serial execution context mechanism. this.csFactory = createLockFactory(); // The private files collection // Contains a file and timer: "filename": {timer: timerid} // Used for tracking work left to do. When empty, work is done. this.files = {}; // Contains files su...
javascript
{ "resource": "" }
q63314
start
test
function start (pollInterval, input, listener) { var result = ( pollInterval > 0 && typeof listener === "function" && (!!input) ); if (result) { if (this.isStarted()) { throw new Error("Notifier already started"); } this.callback = listener; this.interva...
javascript
{ "resource": "" }
q63315
add
test
function add (outputFile, timeout) { var failTimeout = timeout; var timer; if (!this.isStarted()) { throw new Error("MUST call `start` before `add`"); } if (!this._exists(outputFile)) { // make sure we evaluate after the child process failTimeout = parseInt(timeout, 10) + parseIn...
javascript
{ "resource": "" }
q63316
known
test
function known (outputFile) { var result = false; this.csFactory(function (done) { result = this._exists(outputFile) || this.filesDone.indexOf(outputFile) > -1; done(); }.bind(this), L_WAIT)(); return result; }
javascript
{ "resource": "" }
q63317
_remove
test
function _remove (outputFile, done) { if (this._exists(outputFile)) { if (done) { this.filesDone.push(outputFile); } else { this.filesNotDone.push(outputFile); } clearTimeout(this.files[outputFile].timer); delete this.files[outputFile]; } }
javascript
{ "resource": "" }
q63318
remove
test
function remove (outputFile, done) { this.csFactory(function (_done) { this._remove(outputFile, done); _done(); }.bind(this), L_WAIT)(); }
javascript
{ "resource": "" }
q63319
test
function (time) { fs.write(options.outputFile, filter(page.content), "w"); globals.exit(0, "snapshot for "+options.url+" finished in "+time+" ms\n written to "+options.outputFile); }
javascript
{ "resource": "" }
q63320
oneline
test
function oneline (line, options) { var key = "Allow: ", index = line.indexOf(key); if (index !== -1) { var page = line.substr(index + key.length).replace(/^\s+|\s+$/g, ""); return page.indexOf("*") === -1 && base.input(options, page); } return true; }
javascript
{ "resource": "" }
q63321
getRobotsUrl
test
function getRobotsUrl (options, callback) { request({ url: options.source, timeout: options.timeout() }, function (err, res, body) { var error = err || common.checkResponse(res, "text/plain"); if (error) { callback(common.prependMsgToErr(error, options.source, true)); } else { body....
javascript
{ "resource": "" }
q63322
getRobotsFile
test
function getRobotsFile (options, callback) { fs.readFile(options.source, function (err, data) { if (!err) { data.toString().split('\n').every(function (line) { // Process the line input, but break if base.input returns false. // For now, this can only happen if no outputDir is defined, ...
javascript
{ "resource": "" }
q63323
bubble
test
function bubble(values) { return values.map(d => { if (d.key && d.values) { if (d.values[0].key === "undefined") return d.values[0].values[0]; else d.values = bubble(d.values); } return d; }); }
javascript
{ "resource": "" }
q63324
exclude
test
function exclude(a, b, v) { const aStart = a.start({type: "bigInteger"}); const bStart = b.start({type: "bigInteger"}); const aEnd = a.end({type: "bigInteger"}); const bEnd = b.end({type: "bigInteger"}); const parts = []; // compareTo returns negative if left is less than right // aaa // bbb ...
javascript
{ "resource": "" }
q63325
getMsTimestamp
test
function getMsTimestamp(){ var ts = new Date().getTime(); if(lastMsTs >= ts){ lastMsTs++; } else{ lastMsTs = ts; } return lastMsTs; }
javascript
{ "resource": "" }
q63326
parseUrl
test
function parseUrl(url) { var serverOptions = { host: "localhost", port: 80 }; if(url.indexOf("https") === 0){ serverOptions.port = 443; } var host = url.split("://").pop(); serverOptions.host = host; var lastPos = host.indexOf("...
javascript
{ "resource": "" }
q63327
prepareParams
test
function prepareParams(params){ var str = []; for(var i in params){ str.push(i+"="+encodeURIComponent(params[i])); } return str.join("&"); }
javascript
{ "resource": "" }
q63328
stripTrailingSlash
test
function stripTrailingSlash(str) { if(str.substr(str.length - 1) === "/") { return str.substr(0, str.length - 1); } return str; }
javascript
{ "resource": "" }
q63329
getProperties
test
function getProperties(orig, props){ var ob = {}; var prop; for(var i = 0; i < props.length; i++){ prop = props[i]; if(typeof orig[prop] !== "undefined"){ ob[prop] = orig[prop]; } } return ob; }
javascript
{ "resource": "" }
q63330
add_cly_events
test
function add_cly_events(event){ if(!event.key){ log("Event must have key property"); return; } if(cluster.isMaster){ if(!event.count){ event.count = 1; } var props = ["key", "count", "sum", "dur", "segmentat...
javascript
{ "resource": "" }
q63331
prepareRequest
test
function prepareRequest(request) { request.app_key = Countly.app_key; request.device_id = Countly.device_id; request.sdk_name = SDK_NAME; request.sdk_version = SDK_VERSION; if(Countly.check_consent("location")){ if(Countly.country_code){ request.countr...
javascript
{ "resource": "" }
q63332
toRequestQueue
test
function toRequestQueue(request){ if(cluster.isMaster){ if(!Countly.app_key || !Countly.device_id){ log("app_key or device_id is missing"); return; } prepareRequest(request); if(requestQueue.length > queueSize){ ...
javascript
{ "resource": "" }
q63333
getMetrics
test
function getMetrics(){ var m = JSON.parse(JSON.stringify(metrics)); //getting app version m._app_version = m._app_version || Countly.app_version; m._os = m._os || os.type(); m._os_version = m._os_version || os.release(); platform = os.type(); ...
javascript
{ "resource": "" }
q63334
makeRequest
test
function makeRequest(url, path, params, callback) { try { log("Sending HTTP request"); var serverOptions = parseUrl(url); var data = prepareParams(params); var method = "GET"; var options = { host: serverOptions.host, po...
javascript
{ "resource": "" }
q63335
allSettled
test
function allSettled(promises) { "use strict"; const wrappedPromises = promises.map((curPromise) => curPromise.reflect()); return Promise.all(wrappedPromises); }
javascript
{ "resource": "" }
q63336
after
test
function after(parent, index) { var siblings = parent.children var sibling = siblings[++index] var other if (is('WhiteSpaceNode', sibling)) { sibling = siblings[++index] if (is('PunctuationNode', sibling) && punctuation.test(toString(sibling))) { sibling = siblings[++index] } if (is('Wo...
javascript
{ "resource": "" }
q63337
classify
test
function classify(value) { var type = null var normal value = value.replace(digits, toWords).split(split, 1)[0] normal = lower(value) if (requiresA(value)) { type = 'a' } if (requiresAn(value)) { type = type === 'a' ? 'a-or-an' : 'an' } if (!type && normal === value) { type = vowel.tes...
javascript
{ "resource": "" }
q63338
factory
test
function factory(list) { var expressions = [] var sensitive = [] var insensitive = [] construct() return test function construct() { var length = list.length var index = -1 var value var normal while (++index < length) { value = list[index] normal = value === lower(value)...
javascript
{ "resource": "" }
q63339
test
function(rcb) { return function() { if (frc || !db[cname]) { bindColCtls(db); } if (rcb) { rcb.apply(this, arguments); } } ...
javascript
{ "resource": "" }
q63340
test
function() { Object.defineProperty(this, "_impl", { value : new EJDBImpl(), configurable : false, enumerable : false, writable : false }); return this; }
javascript
{ "resource": "" }
q63341
dummyText
test
function dummyText ( opts ) { var corpus = opts.corpus || 'lorem', i = opts.start, isRandom = typeof(i) === 'undefined', mustReset = typeof(origin) === 'undefined', skip = opts.skip || 1, sentences = opts.sentences || 1, words = opts.words,...
javascript
{ "resource": "" }
q63342
Back
test
function Back(options) { if (!(this instanceof Back)) { return new Back(options); } this.settings = extend(options); this.reconnect = null; }
javascript
{ "resource": "" }
q63343
css
test
function css(files, output, options) { options = Object.assign({ banner: false }, options); return () => { var build = gulp.src(files) if (options.banner) build = build.pipe($.header(banner, {pkg})); build = build .pipe($.rename('d3.compose.css')) .pipe(gulp.dest(output)); ...
javascript
{ "resource": "" }
q63344
series
test
function series() { const tasks = Array.prototype.slice.call(arguments); var fn = cb => cb(); if (typeof tasks[tasks.length - 1] === 'function') fn = tasks.pop(); return (cb) => { const tasks_with_cb = tasks.concat([(err) => { if (err) return cb(err); fn(cb); }]); runSequence.appl...
javascript
{ "resource": "" }
q63345
simpleTypeFilter
test
function simpleTypeFilter(doc, oldDoc, candidateDocType) { if (oldDoc) { if (doc._deleted) { return oldDoc.type === candidateDocType; } else { return doc.type === oldDoc.type && oldDoc.type === candidateDocType; } } else { return doc.type === candidateDocType; } }
javascript
{ "resource": "" }
q63346
padRight
test
function padRight(value, desiredLength, padding) { while (value.length < desiredLength) { value += padding; } return value; }
javascript
{ "resource": "" }
q63347
resolveCollectionDefinition
test
function resolveCollectionDefinition(doc, oldDoc, collectionDefinition, itemPrefix) { if (utils.isValueNullOrUndefined(collectionDefinition)) { return [ ]; } else { if (typeof collectionDefinition === 'function') { var fnResults = collectionDefinition(doc, oldDoc); return resolveCol...
javascript
{ "resource": "" }
q63348
assignRolesToUsers
test
function assignRolesToUsers(doc, oldDoc, accessAssignmentDefinition) { var users = resolveCollectionDefinition(doc, oldDoc, accessAssignmentDefinition.users); var roles = resolveRoleCollectionDefinition(doc, oldDoc, accessAssignmentDefinition.roles); role(users, roles); return { type: 'role', ...
javascript
{ "resource": "" }
q63349
getAllDocChannels
test
function getAllDocChannels(docDefinition) { var docChannelMap = utils.resolveDocumentConstraint(docDefinition.channels); var allChannels = [ ]; if (docChannelMap) { appendToAuthorizationList(allChannels, docChannelMap.view); appendToAuthorizationList(allChannels, docChannelMap.write); app...
javascript
{ "resource": "" }
q63350
outputHelpIfNecessary
test
function outputHelpIfNecessary(cmd, options) { options = options || []; for (var i = 0; i < options.length; i++) { if (options[i] === '--help' || options[i] === '-h') { cmd.outputHelp(); process.exit(0); } } }
javascript
{ "resource": "" }
q63351
humanReadableArgName
test
function humanReadableArgName(arg) { var nameOutput = arg.name + (arg.variadic === true ? '...' : ''); return arg.required ? '<' + nameOutput + '>' : '[' + nameOutput + ']'; }
javascript
{ "resource": "" }
q63352
validateObjectProperties
test
function validateObjectProperties(propertyValidators, allowUnknownProperties, ignoreInternalProperties) { var currentItemEntry = itemStack[itemStack.length - 1]; var objectValue = currentItemEntry.itemValue; var oldObjectValue = currentItemEntry.oldItemValue; var supportedProperties = [...
javascript
{ "resource": "" }
q63353
buildItemPath
test
function buildItemPath(itemStack) { var nameComponents = [ ]; for (var i = 0; i < itemStack.length; i++) { var itemName = itemStack[i].itemName; if (!itemName) { // Skip null or empty names (e.g. the first element is typically the root of the document, which has no name) continue; ...
javascript
{ "resource": "" }
q63354
getBusinessId
test
function getBusinessId(doc, oldDoc) { var regex = /^biz\.([A-Za-z0-9_-]+)(?:\..+)?$/; var matchGroups = regex.exec(doc._id); if (matchGroups) { return matchGroups[1]; } else if (oldDoc && oldDoc.businessId) { // The document ID doesn't contain a business ID, so use the property from the old ...
javascript
{ "resource": "" }
q63355
toDefaultSyncChannels
test
function toDefaultSyncChannels(doc, oldDoc, basePrivilegeName) { var businessId = getBusinessId(doc, oldDoc); return function(doc, oldDoc) { return { view: [ toSyncChannel(businessId, 'VIEW_' + basePrivilegeName) ], add: [ toSyncChannel(businessId, 'ADD_' + basePrivilegeName) ], r...
javascript
{ "resource": "" }
q63356
isIso8601DateTimeString
test
function isIso8601DateTimeString(value) { var dateAndTimePieces = splitDateAndTime(value); var date = extractDateStructureFromDateAndTime(dateAndTimePieces); if (date) { var timeAndTimezone = extractTimeStructuresFromDateAndTime(dateAndTimePieces); var time = timeAndTimezone.time; var time...
javascript
{ "resource": "" }
q63357
normalizeIso8601Time
test
function normalizeIso8601Time(time, timezoneOffsetMinutes) { var msPerSecond = 1000; var msPerMinute = 60000; var msPerHour = 3600000; var effectiveTimezoneOffset = timezoneOffsetMinutes || 0; var rawTimeMs = (time.hour * msPerHour) + (time.minute * msPerMinute) + (time.second * msPerSecond) ...
javascript
{ "resource": "" }
q63358
compareTimes
test
function compareTimes(a, b) { if (typeof a !== 'string' || typeof b !== 'string') { return NaN; } return normalizeIso8601Time(parseIso8601Time(a)) - normalizeIso8601Time(parseIso8601Time(b)); }
javascript
{ "resource": "" }
q63359
compareDates
test
function compareDates(a, b) { var aPieces = extractDatePieces(a); var bPieces = extractDatePieces(b); if (aPieces === null || bPieces === null) { return NaN; } for (var pieceIndex = 0; pieceIndex < aPieces.length; pieceIndex++) { if (aPieces[pieceIndex] < bPieces[pieceIndex]) { ...
javascript
{ "resource": "" }
q63360
normalizeIso8601TimeZone
test
function normalizeIso8601TimeZone(value) { return value ? value.multiplicationFactor * ((value.hour * 60) + value.minute) : -(new Date().getTimezoneOffset()); }
javascript
{ "resource": "" }
q63361
start
test
async function start() { log.i('--Nexus/Start'); //build the setup promise array let startArray = []; for (let pid in Start) { startArray.push(new Promise((resolve, _reject) => { let com = {}; com.Cmd = Start[pid]; com.Passport = {}; com.Passport.To = pid; c...
javascript
{ "resource": "" }
q63362
exit
test
async function exit(code = 0) { log.i('--Nexus/Stop'); //build the Stop promise array let stopTasks = []; log.i('Nexus unloading node modules'); log.v(Object.keys(require.cache).join('\n')); for (let pid in Stop) { stopTasks.push(new Promise((resolve, _reject) => { let com = {}; ...
javascript
{ "resource": "" }
q63363
sendMessage
test
function sendMessage(com, fun = _ => _) { if (!('Passport' in com)) { log.w('Message has no Passport, ignored'); log.w(' ' + JSON.stringify(com)); fun('No Passport'); return; } if (!('To' in com.Passport) || !com.Passport.To) { log.w('Message has no destination entity, ignored');...
javascript
{ "resource": "" }
q63364
deleteEntity
test
function deleteEntity(pid, fun = (err, _pid) => { if (err) log.e(err); }) { cacheInterface.deleteEntity(pid, (err, removedPidArray) => { //remove ent from EntCache (in RAM) for (let i = 0; i < removedPidArray.length; i++) { let entPid = removedPidArray[i]; if (entPid in EntCache) { del...
javascript
{ "resource": "" }
q63365
saveEntity
test
async function saveEntity(par, fun = (err, _pid) => { if (err) log.e(err); }) { let saveEntity = (async (par) => { await new Promise((res, rej) => { cacheInterface.saveEntityPar(par, (err, pid) => { if (err){ log.e(err, 'saving ', pid); rej(err); } log.v(`Saved entit...
javascript
{ "resource": "" }
q63366
getFile
test
function getFile(module, filename, fun = _ => _) { let mod = ModCache[module]; if (filename in mod.files) { mod.file(filename).async('string').then((dat) => { fun(null, dat); }); return; } let err = `Error: File ${filename} does not exist in module ${module}`; log.e(err); fu...
javascript
{ "resource": "" }
q63367
getEntityContext
test
async function getEntityContext(pid, fun = _ => _) { EntCache[pid] = new Volatile({}); await EntCache[pid].lock((_entityContext) => { return new Promise((res, _rej) => { cacheInterface.getEntityPar(pid, (err, data) => { let par = JSON.parse(data.toString()); if (err) { log.e(`Er...
javascript
{ "resource": "" }
q63368
GetModule
test
function GetModule(ModName, fun = _ => _) { ModName = ModName.replace(/:\//g, '.'); if (ModName in ModCache) return fun(null, ModCache[ModName]); else cacheInterface.getModule(ModName, (err, moduleZip) => { if (err) return fun(err); ModCache[ModName] = moduleZip; return fun(null, ModCache[Mod...
javascript
{ "resource": "" }
q63369
processSources
test
function processSources(cfg) { if (typeof cfg['Sources'] === 'undefined') { log.e('You must defined a Sources object.\n'); rejectSetup('You must defined a Sources object.'); return; } let val, sources, subval; for (let key in cfg) { val = cfg[key]; if (key == 'Sources'...
javascript
{ "resource": "" }
q63370
generateModuleCatalog
test
function generateModuleCatalog() { // Create new cache and install high level // module subdirectories. Each of these also // has a link to the source of that module (Module.json). let keys = Object.keys(Config.Modules); for (let i = 0; i < keys.length; i++) { let key = keys[i]; if ...
javascript
{ "resource": "" }
q63371
logModule
test
function logModule(key, mod) { let folder = mod.Module.replace(/[/:]/g, '.'); if (!('Source' in mod)) { log.e(`No Source Declared in module: ${key}: ${mod.Module}`); rejectSetup(`No Source Declared in module: ${key}`); return; } let source = { Source: mod.Source, ...
javascript
{ "resource": "" }
q63372
buildApexInstances
test
async function buildApexInstances(processPidReferences) { if (processPidReferences) { // Assign pids to all instance in Config.Modules for (let instname in Config.Modules) { if (instname == 'Deferred') continue; Apex[instname] = genPid(); } log.v('Apex List', JSON.stri...
javascript
{ "resource": "" }
q63373
buildDir
test
async function buildDir(path) { let dirObj = {}; if (fs.existsSync(path)) { let files = fs.readdirSync(path); let itemPromises = []; for (let file of files) { itemPromises.push(new Promise(async (resolve) => { let curPath = path + '/' + file; if (fs.lstatSync(curPath)....
javascript
{ "resource": "" }
q63374
genPid
test
function genPid() { if (!Uuid) { // module.paths = [Path.join(Path.resolve(CacheDir), 'node_modules')]; Uuid = require('uuid/v4'); } let str = Uuid(); let pid = str.replace(/-/g, '').toUpperCase(); return pid; }
javascript
{ "resource": "" }
q63375
genesis
test
async function genesis(system) { log.i(' [Save Cache]'.padStart(80, '=')); log.i('Genesis Compile Start:'); let cacheState = null; if (fs.existsSync(CacheDir)) cacheState = 'exists'; cacheInterface = new CacheInterface({ path: CacheDir, log }); cleanCache(); log.i('Saving modules and upd...
javascript
{ "resource": "" }
q63376
cacheModules
test
async function cacheModules(ModCache) { let timer = log.time('cacheModules'); let ModulePromiseArray = []; for (let folder in ModCache) { ModulePromiseArray.push(new Promise(async (res) => { await cacheInterface.addModule(folder, ModCache[folder]); log.v(`Finished installing dependencies fo...
javascript
{ "resource": "" }
q63377
cacheApexes
test
async function cacheApexes(Apexes, ModuleDefinitions) { let ModulePromiseArray = []; for (let moduleId in Apexes) { ModulePromiseArray.push( await cacheInterface.createInstance(ModuleDefinitions[moduleId], Apexes[moduleId]) ); } await Promise.all(ModulePromiseArray); }
javascript
{ "resource": "" }
q63378
Stop
test
async function Stop() { log.i(`Genesis Compile Stop: ${new Date().toString()}`); log.i(' [Finished]'.padStart(80, '=')); for(const xgrl in BrokerCache) { const broker = BrokerCache[xgrl]; broker.cleanup(); } log.timeEnd(compileTimer); resolveMain(); }
javascript
{ "resource": "" }
q63379
getProtocolModule
test
function getProtocolModule(protocol) { return new Promise(function (resolve, reject) { let cacheFilepath = path.join(appdata, protocol); if (fs.existsSync(cacheFilepath)) { return resolve(JSON.parse(fs.readFileSync(cacheFilepath).toString())); } let options = { host: 'protocols.xgraphdev.com', port: ...
javascript
{ "resource": "" }
q63380
remDir
test
function remDir(path) { return (new Promise(async (resolve, _reject) => { if (fs.existsSync(path)) { let files = fs.readdirSync(path); let promiseArray = []; for (let fileIndex = 0; fileIndex < files.length; fileIndex++) { promiseArray.push(new Promise(async (resolve2, _reject2) => { ...
javascript
{ "resource": "" }
q63381
getMousePosition
test
function getMousePosition(e) { var mouseObj = void 0, originalEvent = e.originalEvent ? e.originalEvent : e; mouseObj = 'changedTouches' in originalEvent && originalEvent.changedTouches ? originalEvent.changedTouches[0] : originalEvent; // clientX, Y 쓰...
javascript
{ "resource": "" }
q63382
proxyRequest
test
function proxyRequest(req, res, rule) { var router, target, path; injectProxyHeaders(req, rule); // rewrite the base path of the requested URL path = req.url.replace(rule.regexp, rule.target.path); if (useGateway) { // for HTTP LAN proxies, rewrite the request URL from a relative URL to an ...
javascript
{ "resource": "" }
q63383
injectProxyHeaders
test
function injectProxyHeaders(req, rule){ // the HTTP host header is often needed by the target webserver config req.headers['host'] = rule.target.host + (rule.target.originalPort ? util.format(':%d', rule.target.originalPort) : ''); // document that this request was proxied req.headers['via'] = util.format('htt...
javascript
{ "resource": "" }
q63384
parseFile
test
function parseFile(filepath, config) { var contents; filepath = filepath || path.join(process.cwd(), '/json-proxy.json'); // if we were passed a config file, read and parse it if (fs.existsSync(filepath)) { try { var data = fs.readFileSync(filepath); contents = JSON.parse(data.toString()); ...
javascript
{ "resource": "" }
q63385
parseConfig
test
function parseConfig(contents, config) { contents.server = contents.server || {}; contents.proxy = contents.proxy || {}; if (contents.proxy.gateway && typeof(contents.proxy.gateway) === "string" && contents.proxy.gateway.length > 0) { contents.proxy.gateway = parseGateway(contents.proxy.gateway); } cont...
javascript
{ "resource": "" }
q63386
parseConfigMap
test
function parseConfigMap(map, callback) { var result = []; if (!(map instanceof Object)) { return map; } for(var property in map) { if (map.hasOwnProperty(property)) { result.push(callback(property, map[property])); } } return result; }
javascript
{ "resource": "" }
q63387
parseCommandLine
test
function parseCommandLine(argv, config) { if (argv) { // read the command line arguments if no config file was given parseCommandLineArgument(argv.port, function(item){ config.server.port = item; }); parseCommandLineArgument(argv.html5mode, function(item){ config.server.html5mode = item; ...
javascript
{ "resource": "" }
q63388
parseCommandLineArgument
test
function parseCommandLineArgument(arg, fn) { if (typeof(fn) !== 'function') return; if (Array.isArray(arg)) { arg.forEach(function(item) { fn.call(null, item); }); } else { if (arg !== null && arg !== undefined) { fn.call(null, arg); } } }
javascript
{ "resource": "" }
q63389
parseForwardRule
test
function parseForwardRule() { var token, rule; if (arguments[0] === undefined || arguments[0] === null) { return; } if (typeof(arguments[0]) === "object") { return arguments[0]; } try { token = tokenize.apply(null, arguments); rule = { regexp: new RegExp('^' + token.name, 'i'), targ...
javascript
{ "resource": "" }
q63390
withCode
test
function withCode(code, msg) { const err = new Error(msg); err.code = code; return err; }
javascript
{ "resource": "" }
q63391
updateWorkingState
test
function updateWorkingState(repoState, branch, newWorkingState) { let workingStates = repoState.getWorkingStates(); const key = branch.getFullName(); if (newWorkingState === null) { // Delete workingStates = workingStates.delete(key); } else { // Update the entry in the map ...
javascript
{ "resource": "" }
q63392
fetchBranches
test
function fetchBranches(repoState, driver) { const oldBranches = repoState.getBranches(); return driver.fetchBranches() .then((branches) => { return repoState.set('branches', branches); }) .then(function refreshWorkingStates(repoState) { // Remove outdated WorkingStates return...
javascript
{ "resource": "" }
q63393
initialize
test
function initialize(driver) { const repoState = RepositoryState.createEmpty(); return fetchBranches(repoState, driver) .then((repoState) => { const branches = repoState.getBranches(); const master = branches.find(function isMaster(branch) { return branch.getFullName() === 'master...
javascript
{ "resource": "" }
q63394
enforceArrayBuffer
test
function enforceArrayBuffer(b, encoding) { if (isArrayBuffer(b)) return b; else if (isBuffer(b)) return fromBuffer(b); else return fromString(b, encoding); }
javascript
{ "resource": "" }
q63395
enforceString
test
function enforceString(b, encoding) { if (is.string(b)) return b; if (isArrayBuffer(b)) b = toBuffer(b); return b.toString(encoding); }
javascript
{ "resource": "" }
q63396
equals
test
function equals(buf1, buf2) { if (buf1.byteLength != buf2.byteLength) return false; const dv1 = new Int8Array(buf1); const dv2 = new Int8Array(buf2); for (let i = 0 ; i != buf1.byteLength ; i++) { if (dv1[i] != dv2[i]) return false; } return true; }
javascript
{ "resource": "" }
q63397
getMergedFileSet
test
function getMergedFileSet(workingState) { return Immutable.Set.fromKeys( getMergedTreeEntries(workingState).filter( treeEntry => treeEntry.getType() === TreeEntry.TYPES.BLOB ) ); }
javascript
{ "resource": "" }
q63398
getMergedTreeEntries
test
function getMergedTreeEntries(workingState) { const removedOrModified = workingState.getChanges().groupBy((change, path) => { if (change.getType() === CHANGES.REMOVE) { return 'remove'; } else { // Must be UDPATE or CREATE return 'modified'; } }); ...
javascript
{ "resource": "" }
q63399
findSha
test
function findSha(workingState, filepath) { // Lookup potential changes const change = workingState.getChanges().get(filepath); // Else lookup tree const treeEntry = workingState.getTreeEntries().get(filepath); if (change) { if (change.getType() == CHANGES.REMOVE) { throw error.f...
javascript
{ "resource": "" }