_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q44400
removeClosingReturnPoints
train
function removeClosingReturnPoints(contours) { return _.map(contours, function (contour) { var length = contour.length; if (length > 1 && contour[0].x === contour[length - 1].x && contour[0].y === contour[length - 1].y) { contour.splice(length - 1); } return contour; }); }
javascript
{ "resource": "" }
q44401
compactFlags
train
function compactFlags(flags) { var result = []; var prevFlag = -1; var firstRepeat = false; _.forEach(flags, function (flag) { if (prevFlag === flag) { if (firstRepeat) { result[result.length - 1] += 8; //current flag repeats previous one, need to set 3rd bit of previous flag and set 1 to the...
javascript
{ "resource": "" }
q44402
glyphDataSize
train
function glyphDataSize(glyph) { // Ignore glyphs without outlines. These will get a length of zero in the “loca” table if (!glyph.contours.length) { return 0; } var result = 12; //glyph fixed properties result += glyph.contours.length * 2; //add contours _.forEach(glyph.ttf_x, function (x) { //ad...
javascript
{ "resource": "" }
q44403
ucs2encode
train
function ucs2encode(array) { return _.map(array, function (value) { var output = ''; if (value > 0xFFFF) { value -= 0x10000; output += String.fromCharCode(value >>> 10 & 0x3FF | 0xD800); value = 0xDC00 | value & 0x3FF; } output += String.fromCharCode(value); return output; })....
javascript
{ "resource": "" }
q44404
toSfntCoutours
train
function toSfntCoutours(svgPath) { var resContours = []; var resContour = []; svgPath.iterate(function (segment, index, x, y) { //start new contour if (index === 0 || segment[0] === 'M') { resContour = []; resContours.push(resContour); } var name = segment[0]; if (name === 'Q')...
javascript
{ "resource": "" }
q44405
createFeatureList
train
function createFeatureList() { var header = (0 + 2 // FeatureCount + 4 // FeatureTag[0] + 2 // Feature Offset[0] ); var length = (0 + header + 2 // FeatureParams[0] + 2 // LookupCount[0] + 2 // Lookup[0] LookupListIndex[0] ); var buffer = new ByteBuffer(length); // FeatureCoun...
javascript
{ "resource": "" }
q44406
createLookupList
train
function createLookupList(font) { var ligatures = font.ligatures; var groupedLigatures = {}; // Group ligatures by first code point _.forEach(ligatures, function (ligature) { var first = ligature.unicode[0]; if (!_.has(groupedLigatures, first)) { groupedLigatures[first] = []; } groupedL...
javascript
{ "resource": "" }
q44407
getMaxPoints
train
function getMaxPoints(font) { return _.max(_.map(font.glyphs, function (glyph) { return _.reduce(glyph.ttfContours, function (sum, ctr) { return sum + ctr.length; }, 0); })); }
javascript
{ "resource": "" }
q44408
selectScenario
train
function selectScenario(data, scenario) { return _execute('PUT', '/mocks', { identifier: _getIdentifier(data), scenario: scenario || null }, 'Could not select scenario [' + scenario + ']'); }
javascript
{ "resource": "" }
q44409
echoRequest
train
function echoRequest(data, echo) { return _execute('PUT', '/mocks', { identifier: _getIdentifier(data), echo: echo || false }, 'Could not echo the request'); }
javascript
{ "resource": "" }
q44410
_execute
train
function _execute(httpMethod, urlSuffix, options, errorMessage) { const opts = { headers: { 'Content-Type': 'application/json', 'ngapimockid': ngapimockid } }; if (options !== undefined) { opts.json = options; } ...
javascript
{ "resource": "" }
q44411
_getIdentifier
train
function _getIdentifier(data) { let identifier; if (typeof data === 'string') { // name of the mock identifier = data; } else if (data.name) { // the data containing the name of the mock identifier = data.name; } else { identifier = data.expression + '...
javascript
{ "resource": "" }
q44412
fetchMocks
train
function fetchMocks() { mockService.get({}, function (response) { vm.mocks = response.mocks.map(function(mock){ Object.keys(mock.responses).forEach(function(response) { mock.responses[response].name = response; }); ...
javascript
{ "resource": "" }
q44413
refreshMocks
train
function refreshMocks() { mockService.get({}, function (response) { angular.merge(vm.mocks, response.mocks); vm.selections = response.selections; }); }
javascript
{ "resource": "" }
q44414
echoMock
train
function echoMock(mock, echo) { mockService.update({'identifier': mock.identifier, 'echo': echo}, function () { vm.echos[mock.identifier] = echo; }); }
javascript
{ "resource": "" }
q44415
delayMock
train
function delayMock(mock, delay) { mockService.update({'identifier': mock.identifier, 'delay': delay}, function () { vm.delays[mock.identifier] = delay; }); }
javascript
{ "resource": "" }
q44416
toggleRecording
train
function toggleRecording() { mockService.toggleRecord({}, function (response) { vm.record = response.record; if (vm.record) { interval = $interval(refreshMocks, 5000); } else { $interval.cancel(interval); ...
javascript
{ "resource": "" }
q44417
selectMock
train
function selectMock(mock, selection) { mockService.update({'identifier': mock.identifier, 'scenario': selection || 'passThrough'}, function () { vm.selections[mock.identifier] = selection; }); }
javascript
{ "resource": "" }
q44418
addVariable
train
function addVariable() { variableService.addOrUpdate(vm.variable, function () { vm.variables[vm.variable.key] = vm.variable.value; vm.variable = { key: undefined, value: undefined }; }); }
javascript
{ "resource": "" }
q44419
updateVariable
train
function updateVariable(key, value) { variableService.addOrUpdate({key: key, value: value}, function () { vm.variables[key] = value; vm.variable = { key: undefined, value: undefined }; }); }
javascript
{ "resource": "" }
q44420
searchFilter
train
function searchFilter(mock) { if (!vm.searchUrl || !mock.expression) { return true; } return vm.searchUrl.match(mock.expression); }
javascript
{ "resource": "" }
q44421
discover
train
function discover(target) { var both = false; if (!target) { target = 'googlecast'; both = true; } return new Promise( function(resolve, reject) { var updateCounter=0; var discovered = []; try { if (getNetworkIp) { var browser = mdns.createBrowser(mdns.tcp(target)); var exception; browser....
javascript
{ "resource": "" }
q44422
train
function (success, error, nativeMethodName, args) { var fail; // args checking _checkCallbacks(success, error); // By convention a failure callback should always receive an instance // of a JavaScript Error object. fail = function(err) { // provide default message if no details passed t...
javascript
{ "resource": "" }
q44423
filterMatrix
train
function filterMatrix(matrix, filter) { const filtered = []; if (matrix.length === 0) { return matrix; } for (let row = 0; row < matrix.length; row++) { if (matrix.length !== 0) { for (let column = 0; column < matrix[0].length; column++) { const cell = matrix[row][column]; if (cell...
javascript
{ "resource": "" }
q44424
start
train
function start() { exec(function (a) { var tempListeners = listeners.slice(0); accel = new Acceleration(a.x, a.y, a.z, a.timestamp); for (var i = 0, l = tempListeners.length; i < l; i++) { tempListeners[i].win(accel); } }, function (e) { var tempListeners = li...
javascript
{ "resource": "" }
q44425
touchStart
train
function touchStart(e) { $this = $(e.currentTarget); $this.data('callee1', touchStart); originalCoord.x = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageX : e.pageX; originalCoord.y = (e.originalEvent.targetTouches) ? e.originalEven...
javascript
{ "resource": "" }
q44426
train
function(packet) { packet.status = packet.readInt(8); packet.oskType = packet.readInt(12); // TODO: for some reason, the way we decode it // gives an extra 16 bytes of garbage here. We // should really figure out why that's happening // ... and fix it if (packe...
javascript
{ "resource": "" }
q44427
train
function(packet) { packet._index = 8; packet.preEditIndex = packet.readInt(); packet.preEditLength = packet.readInt(); // TODO: see above about how how we're skipping // 16 bytes here for some reason and how hacky // this is if (packet.buf.length > 36) { ...
javascript
{ "resource": "" }
q44428
train
function(packet) { packet.commandId = packet.readInt(); packet.command = packet.commandId === 0 ? 'return' : 'close'; this.emit('osk_command', packet); }
javascript
{ "resource": "" }
q44429
Packet
train
function Packet(length) { this._index = 0; if (length instanceof Buffer) { this.buf = length; } else { this.buf = Buffer.alloc(length, 0); this.writeInt32LE(length); } }
javascript
{ "resource": "" }
q44430
findClosestPoint
train
function findClosestPoint (sources, target) { const distances = []; let minDistance; sources.forEach(function (source, index) { const d = distance(source, target); distances.push(d); if (index === 0) { minDistance = d; } else { minDistance = Math.min(d, minDistance); } }); ...
javascript
{ "resource": "" }
q44431
rectToPoints
train
function rectToPoints (rect) { const rectPoints = { topLeft: { x: rect.left, y: rect.top }, bottomRight: { x: rect.left + rect.width, y: rect.top + rect.height } }; return rectPoints; }
javascript
{ "resource": "" }
q44432
doesIntersect
train
function doesIntersect (rect1, rect2) { let intersectLeftRight; let intersectTopBottom; const rect1Points = rectToPoints(rect1); const rect2Points = rectToPoints(rect2); if (rect1.width >= 0) { if (rect2.width >= 0) { intersectLeftRight = !((rect1Points.bottomRight.x <= rect2Points.topLeft.x) || (...
javascript
{ "resource": "" }
q44433
getIntersectionRect
train
function getIntersectionRect (rect1, rect2) { const intersectRect = { topLeft: {}, bottomRight: {} }; if (!doesIntersect(rect1, rect2)) { return; } const rect1Points = rectToPoints(rect1); const rect2Points = rectToPoints(rect2); if (rect1.width >= 0) { if (rect2.width >= 0) { int...
javascript
{ "resource": "" }
q44434
clamp
train
function clamp (x, a, b) { return (x < a) ? a : ((x > b) ? b : x); }
javascript
{ "resource": "" }
q44435
intersectLine
train
function intersectLine (lineSegment1, lineSegment2) { const intersectionPoint = {}; let x1 = lineSegment1.start.x, y1 = lineSegment1.start.y, x2 = lineSegment1.end.x, y2 = lineSegment1.end.y, x3 = lineSegment2.start.x, y3 = lineSegment2.start.y, x4 = lineSegment2.end.x, y4 = lineSegment...
javascript
{ "resource": "" }
q44436
train
function (bytes) { var s = ''; for (var i = 0, l = bytes.length; i < l; i++) { s += String.fromCharCode(bytes[i]); } return s; }
javascript
{ "resource": "" }
q44437
calcCFFSubroutineBias
train
function calcCFFSubroutineBias(subrs) { var bias; if (subrs.length < 1240) { bias = 107; } else if (subrs.length < 33900) { bias = 1131; } else { bias = 32768; } return bias; ...
javascript
{ "resource": "" }
q44438
getRawTag
train
function getRawTag(value) { var isOwn = hasOwnProperty$1.call(value, symToStringTag$1), tag = value[symToStringTag$1]; try { value[symToStringTag$1] = undefined; var unmasked = true; } catch (e) {} var result = nativeObjectToString.call(value); if (unmasked) { if (isOwn) { value[symT...
javascript
{ "resource": "" }
q44439
default_deduplicator
train
function default_deduplicator(objectA, objectB) { // default deduplication handler: // if object versions differ, use highest available version if ((objectA.version || objectB.version) && (objectA.version !== objectB.version)) { return (+objectA.version || 0) > (+objectB.version || 0) ? objectA ...
javascript
{ "resource": "" }
q44440
has_interesting_tags
train
function has_interesting_tags(t, ignore_tags) { if (typeof ignore_tags !== "object") ignore_tags={}; if (typeof options.uninterestingTags === "function") return !options.uninterestingTags(t, ignore_tags); for (var k in t) if (!(options.uninterestingTags[k]===true) && ...
javascript
{ "resource": "" }
q44441
build_meta_information
train
function build_meta_information(object) { var res = { "timestamp": object.timestamp, "version": object.version, "changeset": object.changeset, "user": object.user, "uid": object.uid }; for (var k in res) if (res[k] === undefined) delete res[k];...
javascript
{ "resource": "" }
q44442
join
train
function join(ways) { var _first = function(arr) {return arr[0]}; var _last = function(arr) {return arr[arr.length-1]}; var _fitTogether = function(n1, n2) { return n1 !== undefined && n2 !== undefined && n1.id === n2.id; } // stolen from iD/relation.js var joined = [], current, first, last, i, how, wh...
javascript
{ "resource": "" }
q44443
train
function () { var deferred = Q.defer(); var parser = new xml2js.Parser(); fs.readFile(settings.CONFIG_FILE, function (err, data) { if (err) { deferred.reject(err); } parser.parseString(data, function (err, result) { if (err) { deferred.reject(err); } var projectName = r...
javascript
{ "resource": "" }
q44444
train
function (platform, splash) { var deferred = Q.defer(); var srcPath = settings.SPLASH_FILE; var platformPath = srcPath.replace(/\.png$/, '-' + platform.name + '.png'); if (fs.existsSync(platformPath)) { srcPath = platformPath; } var dstPath = platform.splashPath + splash.name; var dst = path.dirname(d...
javascript
{ "resource": "" }
q44445
train
function (platform) { var deferred = Q.defer(); display.header('Generating splash screen for ' + platform.name); var all = []; var splashes = platform.splash; splashes.forEach(function (splash) { all.push(generateSplash(platform, splash)); }); Q.all(all).then(function () { deferred.resolve(); })...
javascript
{ "resource": "" }
q44446
train
function (platforms) { var deferred = Q.defer(); var sequence = Q(); var all = []; _(platforms).where({ isAdded : true }).forEach(function (platform) { sequence = sequence.then(function () { return generateSplashForPlatform(platform); }); all.push(sequence); }); Q.all(all).then(function ()...
javascript
{ "resource": "" }
q44447
train
function () { var deferred = Q.defer(); getPlatforms().then(function (platforms) { var activePlatforms = _(platforms).where({ isAdded : true }); if (activePlatforms.length > 0) { display.success('platforms found: ' + _(activePlatforms).pluck('name').join(', ')); deferred.resolve(); } else { ...
javascript
{ "resource": "" }
q44448
train
function () { var deferred = Q.defer(); fs.exists(settings.SPLASH_FILE, function (exists) { if (exists) { display.success(settings.SPLASH_FILE + ' exists'); deferred.resolve(); } else { display.error(settings.SPLASH_FILE + ' does not exist'); deferred.reject(); } }); return d...
javascript
{ "resource": "" }
q44449
syncMaps
train
function syncMaps () { var maps; var argLen = arguments.length; if (argLen === 1) { maps = arguments[0]; } else { maps = []; for (var i = 0; i < argLen; i++) { maps.push(arguments[i]); } } // Create all the movement functions, because if they're created every time // they wouldn't b...
javascript
{ "resource": "" }
q44450
writeFile
train
function writeFile(path,content) { return when.promise(function(resolve,reject) { var stream = fs.createWriteStream(path); stream.on('open',function(fd) { stream.end(content,'utf8',function() { fs.fsync(fd,resolve); }); }); stream.on('error',fu...
javascript
{ "resource": "" }
q44451
train
function( result, message ) { message = message || ( result ? "okay" : "failed, expected argument to be truthy, was: " + QUnit.dump.parse( result ) ); if ( !!result ) { this.push( true, result, true, message ); } else { this.test.pushFailur...
javascript
{ "resource": "" }
q44452
handler
train
function handler(e) { if (!vNode.context) return // some components may have related popup item, on which we shall prevent the click outside event handler. var elements = e.path || (e.composedPath && e.composedPath()) elements && elements.length > 0 && elements.unshift(e.target) if...
javascript
{ "resource": "" }
q44453
wrapClass
train
function wrapClass(Controller) { let proto = Controller.prototype; const ret = {}; // tracing the prototype chain while (proto !== Object.prototype) { const keys = Object.getOwnPropertyNames(proto); for (const key of keys) { // getOwnPropertyNames will return constructor // that should be ig...
javascript
{ "resource": "" }
q44454
wrapObject
train
function wrapObject(obj, path, prefix) { const keys = Object.keys(obj); const ret = {}; for (const key of keys) { if (is.function(obj[key])) { const names = utility.getParamNames(obj[key]); if (names[0] === 'next') { throw new Error(`controller \`${prefix || ''}${key}\` should not use next...
javascript
{ "resource": "" }
q44455
getGasPrice
train
function getGasPrice(toWei) { return axios.get("https://ethgasstation.info/json/ethgasAPI.json").then(response => { //ethgasstation returns 10x the actual average for some odd reason let actualAverage = response.data.average / 10 winston.debug(`gas price actualAverage: ${actualAverage}`) //We want to...
javascript
{ "resource": "" }
q44456
cssnext
train
function cssnext (tagName, css) { // A small hack: it passes :scope as :root to PostCSS. // This make it easy to use css variables inside tags. css = css.replace(/:scope/g, ':root') css = postcss([postcssCssnext]).process(css).css css = css.replace(/:root/g, ':scope') return css }
javascript
{ "resource": "" }
q44457
makeLocalizeFunction
train
function makeLocalizeFunction(localization, nested) { return function localizeFunction(key) { return nested ? byString(localization, key) : localization[key]; }; }
javascript
{ "resource": "" }
q44458
byString
train
function byString(localization, nestedKey) { // remove a leading dot and split by dot const keys = nestedKey.replace(/^\./, '').split('.'); // loop through the keys to find the nested value for (let i = 0, length = keys.length; i < length; ++i) { const key = keys[i]; if (!(key in localization)) { retu...
javascript
{ "resource": "" }
q44459
Delegator
train
function Delegator(proto, target) { if (!(this instanceof Delegator)) return new Delegator(proto, target); this.proto = proto; this.target = target; this.methods = []; this.getters = []; this.setters = []; this.fluents = []; }
javascript
{ "resource": "" }
q44460
issued
train
function issued(err, val) { if (err) { return self.error(err); } res.cookie(self._key, val, self._opts); return self.success(user, info); }
javascript
{ "resource": "" }
q44461
gotData
train
function gotData() { var currentString = serial.readLine(); // read the incoming data trim(currentString); // trim off trailing whitespace if (!currentString) return; // if the incoming string is empty, do no more console.log(currentString); if (!isNaN(currentString)) { // mak...
javascript
{ "resource": "" }
q44462
setup
train
function setup() { createCanvas(windowWidth, windowHeight); // Instantiate our SerialPort object serial = new p5.SerialPort(); // Get a list the ports available // You should have a callback defined to see the results serial.list(); // Assuming our Arduino is connected, let's open the connection to it ...
javascript
{ "resource": "" }
q44463
gotData
train
function gotData() { var currentString = serial.readLine(); // read the incoming string trim(currentString); // remove any trailing whitespace if (!currentString) return; // if the string is empty, do no more console.log(currentString); // println the string latestD...
javascript
{ "resource": "" }
q44464
train
function (f) { var filename = path.basename(f); var extension = path.extname(f), allowedExtensions = lessWatchCompilerUtilsModule.config.allowedExtensions || defaultAllowedExtensions; if (filename.substr(0, 1) == '_' || filename.substr(0, 1) == '.' || filename == '' || ...
javascript
{ "resource": "" }
q44465
train
function (list) { var items = []; var i = 0; var listLength = list.length; for (; i < listLength; i++) { items.push(list[i]); } return items; }
javascript
{ "resource": "" }
q44466
train
function (stylesheet) { var sheetMedia = stylesheet.media && stylesheet.media.mediaText; var sheetHost; // if this sheet is cross-origin and option is set skip it if (objectFit.disableCrossDomain == 'true') { sheetHost = getCSSHost(stylesheet.href); if ((sheetHost !== window.location.host)) { return...
javascript
{ "resource": "" }
q44467
train
function (selector) { var score = [0, 0, 0]; var parts = selector.split(' '); var part; var match; //TODO: clean the ':not' part since the last ELEMENT_RE will pick it up while (part = parts.shift(), typeof part === 'string') { // find all pseudo-elements match = _find(part, PSEUDO_ELEMENTS_RE); s...
javascript
{ "resource": "" }
q44468
train
function (a, b) { return getSpecificityScore(element, b.selectorText) - getSpecificityScore(element, a.selectorText); }
javascript
{ "resource": "" }
q44469
tms2zxy
train
function tms2zxy(zxys) { return zxys.split(',').map(function(tms) { var zxy = tms.split('/').map(function(v) { return parseInt(v, 10); }); zxy[2] = (1 << zxy[0]) - 1 - zxy[2]; return zxy.join('/'); }); }
javascript
{ "resource": "" }
q44470
train
function(properties) { if (this instanceof User) { for (var property in (properties || {})) { if (Array.prototype.hasOwnProperty.call(properties, property)) { this[property] = properties[property]; } } } else { return(new User(properties)); } }
javascript
{ "resource": "" }
q44471
train
function(url, baseDN, username, password, defaults) { if (this instanceof ActiveDirectory) { this.opts = {}; if (typeof(url) === 'string') { this.opts.url = url; this.baseDN = baseDN; this.opts.bindDN = username; this.opts.bindCredentials = password; if (typeof((defaults || {})....
javascript
{ "resource": "" }
q44472
truncateLogOutput
train
function truncateLogOutput(output, maxLength) { if (typeof(maxLength) === 'undefined') maxLength = maxOutputLength; if (! output) return(output); if (typeof(output) !== 'string') output = output.toString(); var length = output.length; if ((! length) || (length < (maxLength + 3))) return(output); var prefi...
javascript
{ "resource": "" }
q44473
isDistinguishedName
train
function isDistinguishedName(value) { log.trace('isDistinguishedName(%s)', value); if ((! value) || (value.length === 0)) return(false); re.isDistinguishedName.lastIndex = 0; // Reset the regular expression return(re.isDistinguishedName.test(value)); }
javascript
{ "resource": "" }
q44474
getUserQueryFilter
train
function getUserQueryFilter(username) { log.trace('getUserQueryFilter(%s)', username); var self = this; if (! username) return('(objectCategory=User)'); if (isDistinguishedName.call(self, username)) { return('(&(objectCategory=User)(distinguishedName='+parseDistinguishedName(username)+'))'); } return(...
javascript
{ "resource": "" }
q44475
getGroupQueryFilter
train
function getGroupQueryFilter(groupName) { log.trace('getGroupQueryFilter(%s)', groupName); var self = this; if (! groupName) return('(objectCategory=Group)'); if (isDistinguishedName.call(self, groupName)) { return('(&(objectCategory=Group)(distinguishedName='+parseDistinguishedName(groupName)+'))'); } ...
javascript
{ "resource": "" }
q44476
isGroupResult
train
function isGroupResult(item) { log.trace('isGroupResult(%j)', item); if (! item) return(false); if (item.groupType) return(true); if (item.objectCategory) { re.isGroupResult.lastIndex = 0; // Reset the regular expression return(re.isGroupResult.test(item.objectCategory)); } if ((item.objectClass) &...
javascript
{ "resource": "" }
q44477
isUserResult
train
function isUserResult(item) { log.trace('isUserResult(%j)', item); if (! item) return(false); if (item.userPrincipalName) return(true); if (item.objectCategory) { re.isUserResult.lastIndex = 0; // Reset the regular expression return(re.isUserResult.test(item.objectCategory)); } if ((item.objectClas...
javascript
{ "resource": "" }
q44478
createClient
train
function createClient(url, opts) { // Attempt to get Url from this instance. url = url || this.url || (this.opts || {}).url || (opts || {}).url; if (! url) { throw 'No url specified for ActiveDirectory client.'; } log.trace('createClient(%s)', url); var opts = getLdapClientOpts(_.defaults({}, { url: ur...
javascript
{ "resource": "" }
q44479
isAllowedReferral
train
function isAllowedReferral(referral) { log.trace('isAllowedReferral(%j)', referral); if (! defaultReferrals.enabled) return(false); if (! referral) return(false); return(! _.any(defaultReferrals.exclude, function(exclusion) { var re = new RegExp(exclusion, "i"); return(re.test(referral)); })); }
javascript
{ "resource": "" }
q44480
removeReferral
train
function removeReferral(client) { if (! client) return; client.unbind(); var indexOf = pendingReferrals.indexOf(client); if (indexOf >= 0) { pendingReferrals.splice(indexOf, 1); } }
javascript
{ "resource": "" }
q44481
onSearchEntry
train
function onSearchEntry(entry) { log.trace('onSearchEntry(%j)', entry); var result = entry.object; delete result.controls; // Remove the controls array returned as part of the SearchEntry // Some attributes can have range attributes (paging). Execute the query // again to get additional items. p...
javascript
{ "resource": "" }
q44482
onReferralError
train
function onReferralError(err) { log.error(err, '[%s] An error occurred chasing the LDAP referral on %s (%j)', (err || {}).errno, referralBaseDn, opts); removeReferral(referralClient); }
javascript
{ "resource": "" }
q44483
onSearchEnd
train
function onSearchEnd(result) { if ((! pendingRangeRetrievals) && (pendingReferrals.length <= 0)) { client.unbind(); log.info('Active directory search (%s) for "%s" returned %d entries.', baseDN, truncateLogOutput(opts.filter), (results || []).length); if (callback) ca...
javascript
{ "resource": "" }
q44484
parseRangeAttributes
train
function parseRangeAttributes(result, opts, callback) { log.trace('parseRangeAttributes(%j,%j)', result, opts); var self = this; // Check to see if any of the result attributes have range= attributes. // If not, return immediately. if (! RangeRetrievalSpecifierAttribute.prototype.hasRangeAttributes(result)) ...
javascript
{ "resource": "" }
q44485
pickAttributes
train
function pickAttributes(result, attributes) { if (shouldIncludeAllAttributes(attributes)) { attributes = function() { return(true); }; } return(_.pick(result, attributes)); }
javascript
{ "resource": "" }
q44486
chunk
train
function chunk(arr, chunkSize) { var result = []; for (var index = 0, length = arr.length; index < length; index += chunkSize) { result.push(arr.slice(index,index + chunkSize)); } return(result); }
javascript
{ "resource": "" }
q44487
includeGroupMembershipFor
train
function includeGroupMembershipFor(opts, name) { if (typeof(opts) === 'string') { name = opts; opts = this.opts; } var lowerCaseName = (name || '').toLowerCase(); return(_.any(((opts || this.opts || {}).includeMembership || []), function(i) { i = i.toLowerCase(); return((i === 'all') || (i === ...
javascript
{ "resource": "" }
q44488
onClientError
train
function onClientError(err) { // Ignore ECONNRESET errors if ((err || {}).errno !== 'ECONNRESET') { log.error('An unhandled error occured when searching for the root DSE at "%s". Error: %j', url, err); if (hasEvents.call(self, 'error')) self.emit('error', err) } }
javascript
{ "resource": "" }
q44489
parseRangeRetrievalSpecifierAttribute
train
function parseRangeRetrievalSpecifierAttribute(attribute) { var re = new RegExp(pattern, 'i'); var match = re.exec(attribute); return({ attributeName: match[1], low: parseInt(match[2]), high: parseInt(match[3]) || null }); }
javascript
{ "resource": "" }
q44490
train
function(attribute) { if (this instanceof RangeRetrievalSpecifierAttribute) { if (! attribute) throw new Error('No attribute provided to create a range retrieval specifier.'); if (typeof(attribute) === 'string') { attribute = parseRangeRetrievalSpecifierAttribute(attribute); } for(var property ...
javascript
{ "resource": "" }
q44491
train
function(items, config) { config = config || {}; config.searchableFields = config.searchableFields || []; this.items = items; // creating index this.idx = lunr(function () { // currently schema hardcoded this.field('name', { boost: 10 }); var self = this; _.forEach(config.searchableFields, f...
javascript
{ "resource": "" }
q44492
train
function(input) { input = input || {}; /** * merge configuration aggregation with user input */ input.aggregations = helpers.mergeAggregations(configuration.aggregations, input); return service.search(items, input, configuration, fulltext); }
javascript
{ "resource": "" }
q44493
serve
train
function serve (options = { contentBase: '' }) { if (Array.isArray(options) || typeof options === 'string') { options = { contentBase: options } } options.contentBase = Array.isArray(options.contentBase) ? options.contentBase : [options.contentBase] options.host = options.host || 'localhost' options.port ...
javascript
{ "resource": "" }
q44494
Hotkey
train
function Hotkey (combo, description, callback, action, allowIn, persistent) { // TODO: Check that the values are sane because we could // be trying to instantiate a new Hotkey with outside dev's // supplied values this.combo = combo instanceof Array ? combo : [combo]; this.descr...
javascript
{ "resource": "" }
q44495
_add
train
function _add (combo, description, callback, action, allowIn, persistent) { // used to save original callback for "allowIn" wrapping: var _callback; // these elements are prevented by the default Mousetrap.stopCallback(): var preventIn = ['INPUT', 'SELECT', 'TEXTAREA']; // Det...
javascript
{ "resource": "" }
q44496
_del
train
function _del (hotkey) { var combo = (hotkey instanceof Hotkey) ? hotkey.combo : hotkey; Mousetrap.unbind(combo); if (angular.isArray(combo)) { var retStatus = true; var i = combo.length; while (i--) { retStatus = _del(combo[i]) && retStatus; ...
javascript
{ "resource": "" }
q44497
_get
train
function _get (combo) { if (!combo) { return scope.hotkeys; } var hotkey; for (var i = 0; i < scope.hotkeys.length; i++) { hotkey = scope.hotkeys[i]; if (hotkey.combo.indexOf(combo) > -1) { return hotkey; } } return...
javascript
{ "resource": "" }
q44498
bindTo
train
function bindTo (scope) { // Only initialize once to allow multiple calls for same scope. if (!(scope.$id in boundScopes)) { // Add the scope to the list of bound scopes boundScopes[scope.$id] = []; scope.$on('$destroy', function () { var i = boundScopes[scope...
javascript
{ "resource": "" }
q44499
create
train
function create(method, options = {}) { options = Object.assign(exports.defaults, options); exports.results.set(method, new lru_cache_1.default(options)); return exports.results.get(method); }
javascript
{ "resource": "" }