_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
27
233k
language
stringclasses
1 value
meta_information
dict
q5200
removeListeners
train
function removeListeners() { $element.unbind(START_EV, touchStart); $element.unbind(CANCEL_EV, touchCancel); $element.unbind(MOVE_EV, touchMove); $element.unbind(END_EV, touchEnd); //we only have leave events on desktop, we manually calculate
javascript
{ "resource": "" }
q5201
getNextPhase
train
function getNextPhase(currentPhase) { var nextPhase = currentPhase; // Ensure we have valid swipe (under time and over distance and check if we are out of bound...) var validTime = validateSwipeTime(); var validDistance = validateSwipeDistance(); var didCancel = didSwipeBackToCancel(); //If we have exceeded our time, then cancel if(!validTime || didCancel) { nextPhase = PHASE_CANCEL; } //Else if we are moving, and have reached distance then end
javascript
{ "resource": "" }
q5202
validateSwipeDistance
train
function validateSwipeDistance() { var valid = true; //If we made it past the min swipe distance..
javascript
{ "resource": "" }
q5203
didSwipeBackToCancel
train
function didSwipeBackToCancel() { var cancelled = false; if(options.cancelThreshold !== null && direction !==null) { cancelled =
javascript
{ "resource": "" }
q5204
validateDefaultEvent
train
function validateDefaultEvent(jqEvent, direction) { //If we have no pinches, then do this //If we have a pinch, and we we have 2 fingers or more down, then dont allow page scroll. //If the option is set, allways allow the event to bubble up (let user handle wiredness) if( options.preventDefaultEvents === false) { return; } if (options.allowPageScroll === NONE) { jqEvent.preventDefault(); } else { var auto = options.allowPageScroll === AUTO; switch (direction) { case LEFT: if ((options.swipeLeft && auto) || (!auto && options.allowPageScroll != HORIZONTAL)) { jqEvent.preventDefault(); } break; case RIGHT: if ((options.swipeRight &&
javascript
{ "resource": "" }
q5205
validatePinch
train
function validatePinch() { var hasCorrectFingerCount = validateFingers(); var hasEndPoint = validateEndPoint(); var hasCorrectDistance = validatePinchDistance();
javascript
{ "resource": "" }
q5206
validateSwipe
train
function validateSwipe() { //Check validity of swipe var hasValidTime = validateSwipeTime(); var hasValidDistance = validateSwipeDistance(); var hasCorrectFingerCount = validateFingers(); var hasEndPoint = validateEndPoint(); var didCancel = didSwipeBackToCancel(); // if the user swiped more than the minimum length, perform the appropriate action
javascript
{ "resource": "" }
q5207
hasSwipes
train
function hasSwipes() { //Enure we dont return 0 or null for false values return !!(options.swipe || options.swipeStatus ||
javascript
{ "resource": "" }
q5208
validateDoubleTap
train
function validateDoubleTap() { if(doubleTapStartTime==null){ return false; } var now = getTimeStamp();
javascript
{ "resource": "" }
q5209
inMultiFingerRelease
train
function inMultiFingerRelease() { var withinThreshold = false; if(previousTouchEndTime) { var diff = getTimeStamp() - previousTouchEndTime
javascript
{ "resource": "" }
q5210
setTouchInProgress
train
function setTouchInProgress(val) { //Add or remove event listeners depending on touch status if(val===true) { $element.bind(MOVE_EV, touchMove); $element.bind(END_EV, touchEnd); //we only have leave events on desktop, we manually calcuate leave on touch as its not supported in webkit if(LEAVE_EV) { $element.bind(LEAVE_EV, touchLeave); } } else { $element.unbind(MOVE_EV, touchMove, false); $element.unbind(END_EV, touchEnd, false);
javascript
{ "resource": "" }
q5211
updateFingerData
train
function updateFingerData(evt) { var id = evt.identifier!==undefined ? evt.identifier : 0; var f = getFingerData( id );
javascript
{ "resource": "" }
q5212
getFingerData
train
function getFingerData( id ) { for(var i=0; i<fingerData.length;
javascript
{ "resource": "" }
q5213
createAllFingerData
train
function createAllFingerData() { var fingerData=[]; for (var i=0; i<=5; i++) { fingerData.push({ start:{ x: 0, y: 0 },
javascript
{ "resource": "" }
q5214
setMaxDistance
train
function setMaxDistance(direction, distance) { distance = Math.max(distance, getMaxDistance(direction) );
javascript
{ "resource": "" }
q5215
createMaximumsData
train
function createMaximumsData() { var maxData={}; maxData[LEFT]=createMaximumVO(LEFT); maxData[RIGHT]=createMaximumVO(RIGHT);
javascript
{ "resource": "" }
q5216
calculateAngle
train
function calculateAngle(startPoint, endPoint) { var x = startPoint.x - endPoint.x; var y = endPoint.y - startPoint.y; var r = Math.atan2(y, x); //radians var angle = Math.round(r * 180 / Math.PI); //degrees
javascript
{ "resource": "" }
q5217
calculateDirection
train
function calculateDirection(startPoint, endPoint ) { var angle = calculateAngle(startPoint, endPoint); if ((angle <= 45) && (angle >= 0)) { return LEFT;
javascript
{ "resource": "" }
q5218
getbounds
train
function getbounds( el ) { el = $(el); var offset = el.offset(); var bounds = { left:offset.left, right:offset.left+el.outerWidth(),
javascript
{ "resource": "" }
q5219
isInBounds
train
function isInBounds(point, bounds) { return (point.x > bounds.left && point.x < bounds.right
javascript
{ "resource": "" }
q5220
delayEvent
train
function delayEvent( type, instance, container ) { return function( event ) { container._trigger( type,
javascript
{ "resource": "" }
q5221
train
function (f, s, o) { // pattern for standard and localized AM/PM markers var getPatternAmpm = function (amNames, pmNames) { var markers = []; if (amNames) { $.merge(markers, amNames); } if (pmNames) { $.merge(markers, pmNames); } markers = $.map(markers, function (val) { return val.replace(/[.*+?|()\[\]{}\\]/g, '\\$&'); }); return '(' + markers.join('|') + ')?'; }; // figure out position of time elements.. cause js cant do named captures var getFormatPositions = function (timeFormat) { var finds = timeFormat.toLowerCase().match(/(h{1,2}|m{1,2}|s{1,2}|l{1}|c{1}|t{1,2}|z|'.*?')/g), orders = { h: -1, m: -1, s: -1, l: -1, c: -1, t: -1, z: -1 }; if (finds) { for (var i = 0; i < finds.length; i++) { if (orders[finds[i].toString().charAt(0)] === -1) { orders[finds[i].toString().charAt(0)] = i + 1; } } } return orders; }; var regstr = '^' + f.toString() .replace(/([hH]{1,2}|mm?|ss?|[tT]{1,2}|[zZ]|[lc]|'.*?')/g, function (match) { var ml = match.length; switch (match.charAt(0).toLowerCase()) { case 'h': return ml === 1 ? '(\\d?\\d)' : '(\\d{' + ml + '})'; case 'm': return ml === 1 ? '(\\d?\\d)' : '(\\d{' + ml + '})'; case 's': return ml === 1 ? '(\\d?\\d)' : '(\\d{' + ml + '})'; case 'l': return '(\\d?\\d?\\d)'; case 'c': return '(\\d?\\d?\\d)'; case 'z': return '(z|[-+]\\d\\d:?\\d\\d|\\S+)?'; case 't': return getPatternAmpm(o.amNames, o.pmNames); default: // literal escaped in quotes return '(' + match.replace(/\'/g, "").replace(/(\.|\$|\^|\\|\/|\(|\)|\[|\]|\?|\+|\*)/g, function (m) { return "\\" + m; }) + ')?'; } }) .replace(/\s/g, '\\s?') + o.timeSuffix + '$', order = getFormatPositions(f), ampm = '', treg; treg = s.match(new RegExp(regstr, 'i')); var resTime = { hour: 0, minute: 0, second: 0, millisec: 0, microsec: 0 }; if (treg) { if (order.t !== -1) { if (treg[order.t] === undefined || treg[order.t].length === 0) { ampm = ''; resTime.ampm = '';
javascript
{ "resource": "" }
q5222
train
function (timeFormat) { var finds = timeFormat.toLowerCase().match(/(h{1,2}|m{1,2}|s{1,2}|l{1}|c{1}|t{1,2}|z|'.*?')/g), orders = { h: -1, m: -1, s: -1, l: -1,
javascript
{ "resource": "" }
q5223
train
function (f, s, o) { try { var d = new Date('2012-01-01 ' + s); if (isNaN(d.getTime())) { d = new Date('2012-01-01T' + s); if (isNaN(d.getTime())) { d = new Date('01/01/2012 ' + s); if (isNaN(d.getTime())) { throw "Unable to parse time with native Date: " + s;
javascript
{ "resource": "" }
q5224
train
function(container, item) { var borderTop = parseFloat(container.css('borderTopWidth')) || 0, paddingTop = parseFloat(container.css('paddingTop')) || 0, offset = item.offset().top - container.offset().top - borderTop - paddingTop, scroll = container.scrollTop(), elementHeight = container.height(), itemHeight = item.outerHeight(true); if(offset < 0) {
javascript
{ "resource": "" }
q5225
train
function(jQuery) { var matched, browser; jQuery.uaMatch = function( ua ) { ua = ua.toLowerCase(); var match = /(opr)[\/]([\w.]+)/.exec( ua ) || /(chrome)[ \/]([\w.]+)/.exec( ua ) || /(version)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec( ua ) || /(webkit)[ \/]([\w.]+)/.exec( ua ) || /(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) || /(msie) ([\w.]+)/.exec( ua ) || ua.indexOf("trident") >= 0 && /(rv)(?::| )([\w.]+)/.exec( ua ) || ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) || []; var platform_match = /(ipad)/.exec( ua ) || /(iphone)/.exec( ua ) || /(android)/.exec( ua ) || /(windows phone)/.exec( ua ) || /(win)/.exec( ua ) || /(mac)/.exec( ua ) || /(linux)/.exec( ua ) || /(cros)/i.exec( ua ) || []; return { browser: match[ 3 ] || match[ 1 ] || "", version: match[ 2 ] || "0", platform: platform_match[ 0 ] || "" }; }; matched = jQuery.uaMatch( window.navigator.userAgent ); browser = {}; if ( matched.browser ) { browser[ matched.browser ] = true; browser.version = matched.version; browser.versionNumber = parseInt(matched.version); } if ( matched.platform ) { browser[ matched.platform ] = true; } // These are all considered mobile platforms, meaning they run a mobile browser if ( browser.android || browser.ipad || browser.iphone || browser[ "windows phone" ] ) { browser.mobile = true; } // These are all considered desktop platforms, meaning they run a desktop browser if ( browser.cros || browser.mac || browser.linux || browser.win ) {
javascript
{ "resource": "" }
q5226
train
function(index, silent) { var panel = this.panels.eq(index); if(!silent) { this._trigger('change', null, {'index': index}); }
javascript
{ "resource": "" }
q5227
train
function(index) { var panel = this.panels.eq(index), header = panel.prev(); header.attr('aria-expanded', false).children('.fa').removeClass('fa-caret-down').addClass('fa-caret-right');
javascript
{ "resource": "" }
q5228
train
function(pos) { var l = pos.left < 0 ? 0 : pos.left, t = pos.top < 0 ? 0 : pos.top; $(this).css({ left: l,
javascript
{ "resource": "" }
q5229
apiSpecs
train
function apiSpecs(options) { options = Options.applyDefaultSpecOptions(options) if (options.headers) { request.defaults.headers.common = Object.assign({}, request.defaults.headers.common, options.headers)
javascript
{ "resource": "" }
q5230
Config
train
function Config(pathToConfigFileIn, region) { have(arguments, {pathToConfigFile: 'str', region: 'opt str' }); debug('pathToConfigFileIn: '+pathToConfigFileIn); // if the path has '##' and process.env.NODE_ENV is a non-empty string, // replace '##' with the contents of process.env.NODE_ENV var pathToConfigFile = pathToConfigFileIn; var idx = pathToConfigFileIn.indexOf('##'); if (idx > -1 && is.nonEmptyStr(process.env.NODE_ENV)) { pathToConfigFile = pathToConfigFileIn.substr(0, idx) + process.env.NODE_ENV + pathToConfigFileIn.substr(idx+2); } // complimentary to have arg checking if (!is.nonEmptyStr(pathToConfigFile)) throw new Error('Bad path to config file: '+pathToConfigFile); if (!fs.existsSync(pathToConfigFile)) throw new Error('Config file is missing: '+pathToConfigFile); if (is.defined(region)) assert.ok(is.nonEmptyStr(region)); // english is the default if (is.undefined(region)) region = 'en'; debug('## sub: pathToConfigFileIn: '+pathToConfigFileIn); this.pathToDefaults = path.join(path.dirname(pathToConfigFileIn),
javascript
{ "resource": "" }
q5231
transformFile
train
function transformFile(contents) { var $ = cheerio.load(contents.toString()); var result = []; $(options.selector).each(function() {
javascript
{ "resource": "" }
q5232
train
function ( text ) { var lines = text.split( "\n" ); var info = {}; var delimiter_pattern = /\s+/; var materialsInfo = {}; for ( var i = 0; i < lines.length; i ++ ) { var line = lines[ i ]; line = line.trim(); if ( line.length === 0 || line.charAt( 0 ) === '#' ) { // Blank line or comment ignore continue; } var pos = line.indexOf( ' ' ); var key = ( pos >= 0 ) ? line.substring( 0, pos ) : line; key = key.toLowerCase(); var value = ( pos >= 0 ) ? line.substring( pos + 1 ) : ""; value = value.trim(); if ( key === "newmtl" ) { // New material info = { name: value }; materialsInfo[ value ] = info; } else if ( info ) {
javascript
{ "resource": "" }
q5233
train
function(target, styleName) { var styleVal = this.getComputedStyle(styleName); if (!!styleVal) {
javascript
{ "resource": "" }
q5234
train
function (coverage /*, testName */) { var store = this.store; Object.keys(coverage).forEach(function (key) { var fileCoverage = coverage[key];
javascript
{ "resource": "" }
q5235
getCircumCircle
train
function getCircumCircle(p1, p2, p3) { var x1 = p1[0]; var y1 = p1[1]; var x2 = p2[0]; var y2 = p2[1]; var x3 = p3[0]; var y3 = p3[1]; //center of circle var D = 2 * (x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2)); var Ux = ((x1 * x1
javascript
{ "resource": "" }
q5236
_argArray
train
function _argArray(argObj, prefix, suffix) { var args = Array.prototype.slice.call(argObj);
javascript
{ "resource": "" }
q5237
drawPass
train
function drawPass (bindings, passIndex, passCount, outputFBO) { var { debugFBO, gl, canvas, shader, quad, resolution, scale, offset } = bindings var { uniforms } = shader var { width, height } = canvas debugFBO.bind() shader.bind() // update shader var resizeResolutionX = width / passCount * (1 - MARGIN * 2) var resizeResolutionY = height / passCount * (1 - MARGIN * 2) resolution[0] = width resolution[1] = height scale[0] = width / resizeResolutionX scale[1] = height / resizeResolutionY var scissorOffsetX = width * passIndex / passCount + width / passCount * MARGIN var scissorOffsetY = (height / 2) - (resizeResolutionY / 2) offset[0] = scissorOffsetX / width offset[1] = scissorOffsetY / height uniforms.uOffset = offset uniforms.uResolution = resolution uniforms.uScale = scale uniforms.uInput = outputFBO.color[0].bind(0) // set scissor gl.enable(gl.SCISSOR_TEST) gl.scissor( // coordinate of
javascript
{ "resource": "" }
q5238
normalizeTranslateArguments
train
function normalizeTranslateArguments( args ) { var original = args[ 0 ], options = {}, i; // warn about older deprecated syntax if ( typeof original !== 'string' || args.length > 3 || ( args.length > 2 && typeof args[ 1 ] === 'object' && typeof args[ 2 ] === 'object' ) ) { warn( 'Deprecated Invocation: `translate()` accepts ( string, [string], [object] ). These arguments passed:', simpleArguments( args ), '. See https://github.com/Automattic/i18n-calypso#translate-method' ); } if ( args.length === 2 && typeof original === 'string' && typeof args[ 1 ] === 'string' ) { warn( 'Invalid Invocation: `translate()` requires an options object for plural translations, but passed:', simpleArguments( args ) ); } // options could be in position 0, 1, or 2 // sending options as the first object is deprecated and will raise a warning for ( i = 0; i < args.length; i++ ) { if ( typeof args[ i ] === 'object' ) { options = args[ i ]; }
javascript
{ "resource": "" }
q5239
loadDeps
train
function loadDeps(file, resource) { file.requires.forEach(function(id) { resource.add(id); });
javascript
{ "resource": "" }
q5240
train
function(param) { return function(el) { var text = el.innerText || el.textContent || el.value
javascript
{ "resource": "" }
q5241
train
function (graph, head, where) { var routes = []; Graph.Visitor.Stacked(graph, head, function (node, stack, weight) {
javascript
{ "resource": "" }
q5242
train
function (offset) { for (var i = beatmap.timingPoints.length - 1; i >= 0; i--) { if (beatmap.timingPoints[i].offset <= offset) { return
javascript
{ "resource": "" }
q5243
train
function (str) { if (!str) return {}; var additions = {}; var adds = str.split(':'); if (adds[0] && adds[0] !== '0') { var sample; switch (adds[0]) { case '1': sample = 'normal'; break; case '2': sample = 'soft'; break; case '3': sample = 'drum'; break; } additions.sample = sample; } if (adds[1] &&
javascript
{ "resource": "" }
q5244
train
function (line) { members = line.split(','); var timingPoint = { offset: parseInt(members[0]), beatLength: parseFloat(members[1]), velocity: 1, timingSignature: parseInt(members[2]), sampleSetId: parseInt(members[3]), customSampleIndex: parseInt(members[4]), sampleVolume: parseInt(members[5]), timingChange: (members[6] == 1), kiaiTimeActive: (members[7] == 1) }; if (!isNaN(timingPoint.beatLength) && timingPoint.beatLength !== 0) { if (timingPoint.beatLength > 0) { // If positive, beatLength is the length of a beat in milliseconds var bpm = Math.round(60000 / timingPoint.beatLength);
javascript
{ "resource": "" }
q5245
train
function (line) { /** * Background line : 0,0,"bg.jpg" * TODO: confirm that the second member is always zero * * Breaktimes lines : 2,1000,2000 * second integer is start offset * third integer is end offset */ members = line.split(','); if (members[0] == '0' && members[1] == '0' && members[2]) { var bgName = members[2].trim(); if (bgName.charAt(0) == '"' && bgName.charAt(bgName.length - 1) == '"') {
javascript
{ "resource": "" }
q5246
train
function () { var firstObject = beatmap.hitObjects[0]; var lastObject = beatmap.hitObjects[beatmap.hitObjects.length - 1]; var totalBreakTime = 0; beatmap.breakTimes.forEach(function (breakTime) { totalBreakTime += (breakTime.endTime - breakTime.startTime); }); if (firstObject && lastObject) { beatmap.totalTime = Math.floor(lastObject.startTime / 1000);
javascript
{ "resource": "" }
q5247
train
function () { if (beatmap.timingPoints.length === 0) { return; } var maxCombo = 0; var sliderMultiplier = parseFloat(beatmap.SliderMultiplier); var sliderTickRate = parseInt(beatmap.SliderTickRate, 10); var timingPoints = beatmap.timingPoints; var currentTiming = timingPoints[0]; var nextOffset = timingPoints[1] ? timingPoints[1].offset : Infinity; var i = 1; beatmap.hitObjects.forEach(function (hitObject) { if (hitObject.startTime >= nextOffset) { currentTiming = timingPoints[i++]; nextOffset = timingPoints[i] ? timingPoints[i].offset : Infinity; } var osupxPerBeat = sliderMultiplier * 100 * currentTiming.velocity; var tickLength = osupxPerBeat / sliderTickRate; switch
javascript
{ "resource": "" }
q5248
train
function () { if (beatmap.Tags) { beatmap.tagsArray = beatmap.Tags.split(' '); } eventsLines.forEach(parseEvent); beatmap.breakTimes.sort(function (a, b) { return (a.startTime > b.startTime ? 1 : -1); }); timingLines.forEach(parseTimingPoint); beatmap.timingPoints.sort(function (a, b) { return (a.offset > b.offset ? 1 : -1); }); var timingPoints = beatmap.timingPoints; for (var i = 1, l = timingPoints.length; i < l; i++) {
javascript
{ "resource": "" }
q5249
train
function(no_in) { handle_regexp(); var start = S.token; if (start.type == "name" && start.value == "yield") { if (is_in_generator()) { next(); return _yield_expression(); } else if (S.input.has_directive("use strict")) { token_error(S.token, "Unexpected yield identifier inside strict mode"); } } var left = maybe_conditional(no_in); var val = S.token.value; if (is("operator") && ASSIGNMENT(val)) { if (is_assignable(left) || (left = to_destructuring(left)) instanceof AST_Destructuring) {
javascript
{ "resource": "" }
q5250
is_true
train
function is_true(node) { return node instanceof AST_True || in_bool && node instanceof AST_Constant && node.getValue() || (node instanceof AST_UnaryPrefix
javascript
{ "resource": "" }
q5251
is_false
train
function is_false(node) { return node instanceof AST_False || in_bool && node instanceof AST_Constant && !node.getValue() || (node instanceof AST_UnaryPrefix
javascript
{ "resource": "" }
q5252
train
function (tag) { if (voidElements.indexOf(tag.name) < 0) { reporter.warn( tag.pos,
javascript
{ "resource": "" }
q5253
concatenateBinaryExpression
train
function concatenateBinaryExpression( ASTNode ) { var result; if ( ASTNode.operator !== '+' ) { return false; } result = ( 'StringLiteral' === ASTNode.left.type ) ? ASTNode.left.value : concatenateBinaryExpression( ASTNode.left ); result
javascript
{ "resource": "" }
q5254
language
train
function language(node) { var className = node.properties.className || [] var length = className.length var index = -1 var value while (++index < length) { value = className[index] if (value === 'no-highlight' || value === 'nohighlight') { return false } if (value.slice(0, 5) ===
javascript
{ "resource": "" }
q5255
getChildRsql
train
function getChildRsql (perhapsWrap, constraint) { const rsql = getRsqlFromConstraint(constraint) if (constraint.operands && constraint.operands.length === 1) { // Skip this node, render the only child node return getChildRsql(perhapsWrap, constraint.operands[0]) }
javascript
{ "resource": "" }
q5256
build
train
function build (config) { return new Promise((resolve, reject) => { const compiler = webpack(Object.assign(config, { output: { filename: 'file' }, plugins: [ new webpack.DefinePlugin({ 'process.env.NODE_ENV': '"production"', 'process.browser': true }) ] }), (err, stats) => { if (err || stats.hasErrors()) reject(err || new Error(stats.toString('errors-only')))
javascript
{ "resource": "" }
q5257
loadPaths
train
function loadPaths (pkg) { const name = pkg.name const file = pkg.path return resolveFile(tmp, path.join(name, file)).then(entry => ({ entry:
javascript
{ "resource": "" }
q5258
resolveFile
train
function resolveFile (dir, file) { return new Promise((resolve, reject) => {
javascript
{ "resource": "" }
q5259
formatNumber
train
function formatNumber(number) { number = String(number).split('.'); return
javascript
{ "resource": "" }
q5260
formatResult
train
function formatResult(event, times) { var hz = event.hz * times; var stats = event.stats; var size = stats.sample.length; var pm = '\xb1'; var result = " (array length " + times + ")"; result += ' x ' + chalk.cyan(formatNumber(hz.toFixed(hz <
javascript
{ "resource": "" }
q5261
createAttribute
train
function createAttribute(name, value, isAttribute) { if (properties.hasOwnProperty(name)) { if (shouldSkip(name, value)) return ''; name = (attributeNames[name] || name).toLowerCase(); var attrType = properties[name]; // for BOOLEAN `value` only has to be truthy // for OVERLOADED_BOOLEAN `value` has to be === true if ((attrType === types.BOOLEAN) || (attrType === types.OVERLOADED_BOOLEAN && value === true)) {
javascript
{ "resource": "" }
q5262
shouldSkip
train
function shouldSkip(name, value) { var attrType = properties[name]; return value ==
javascript
{ "resource": "" }
q5263
round
train
function round() { i++ var shasum = Crypto.createHash('sha512') shasum.update(out, 'utf8') out = shasum.digest('hex')
javascript
{ "resource": "" }
q5264
checkemail
train
function checkemail(next) { if (user.email) { userent.load$({ email: user.email }, function(err, userfound) { if (err) return done(err, { ok: false, user: user }) if (userfound) return done(null, {
javascript
{ "resource": "" }
q5265
checknick
train
function checknick(next) { if (args.nick) { userent.list$({ nick: args.nick }, function(err, users) { if (err) return done(err, { ok: false, user: user }) for (var i = 0; i < users.length; i++) { var each = users[i] if (each.id !== user.id) { return done(null, {
javascript
{ "resource": "" }
q5266
cmd_clean
train
function cmd_clean(args, done) { var user = args.user.data$() delete user.pass delete user.salt
javascript
{ "resource": "" }
q5267
train
function (namespace) { var nsparts = namespace.split("."); var parent = module.scope.MeadCo; // we want to be able to include or exclude the root namespace so we strip // it if it's in the namespace if (nsparts[0] === "MeadCo") { nsparts = nsparts.slice(1); } // loop through the parts and create a nested namespace if necessary for (var
javascript
{ "resource": "" }
q5268
train
function (serverUrl, apiLocation) { // check if given partial ... var p = serverUrl.indexOf("/api"); if (p === -1) { if (serverUrl.lastIndexOf("/") !== (serverUrl.length - 1)) { serverUrl += "/"; } serverUrl += "api/" + apiLocation;
javascript
{ "resource": "" }
q5269
showPrinterSettings
train
function showPrinterSettings() { fillAndSetBinsList(); var $dlg = $('#dlg-printersettings');
javascript
{ "resource": "" }
q5270
fillPrintersList
train
function fillPrintersList() { var printer = MeadCo.ScriptX.Printing; var $printers = $('#fld-printerselect'); $('#fld-printerselect > option').remove(); var name; for (var i = 0; (name = printer.EnumPrinters(i)).length > 0 ; i++) { $printers.append("<option>" + name);
javascript
{ "resource": "" }
q5271
concatMiddlewareNames
train
function concatMiddlewareNames(routes) { var output = []; // Concat each route's middleware names for (var i = 0; i < routes.length; i++) { output =
javascript
{ "resource": "" }
q5272
getMiddlewareNames
train
function getMiddlewareNames(route) { var middleware = getRouteMiddleware(route); // If the middleware is an array, just return it if ( middleware instanceof Array )
javascript
{ "resource": "" }
q5273
nextMiddleware
train
function nextMiddleware() { // Get the next middleware var next = _mappings[middleware.names[middleware.index++]]; // If there is middleware, then
javascript
{ "resource": "" }
q5274
nextRequest
train
function nextRequest() { // If there are no more middleware, // then resolve the middleware resolution if ( middleware.index == middleware.names.length ) {
javascript
{ "resource": "" }
q5275
redirectTo
train
function redirectTo(route, params, options) { middleware.resolution.reject({ type: "redirectTo", route:
javascript
{ "resource": "" }
q5276
train
function (mergeSelector) { if (this.tag !== mergeSelector.tag) { throw "different element selected (tag)"; } if (this.index !== null) { if (this.index !== mergeSelector.index) { // use indexn only for two elements if (this.indexn === null) { var indexn = Math.min(mergeSelector.index, this.index); if (indexn > 1) { this.indexn = Math.min(mergeSelector.index, this.index); } } else { this.indexn = -1; } this.index = null; } } if(this.isDirectChild === true) { this.isDirectChild = mergeSelector.isDirectChild; } if (this.id !== null) {
javascript
{ "resource": "" }
q5277
train
function(element1, element2) { while (true) { if(element1.tagName !== element2.tagName) { return false; } if(element1 === element2) { return true; } // stop at body tag if (element1 === undefined || element1.tagName === 'body' || element1.tagName === 'BODY') { return false; }
javascript
{ "resource": "" }
q5278
train
function(elements) { // first elment is in the first group // @TODO maybe i dont need this? var groups = [[elements[0]]]; for(var i = 1; i < elements.length; i++) { var elementNew = elements[i]; var addedToGroup = false; for(var j = 0; j < groups.length; j++) { var group = groups[j]; var elementGroup = group[0]; if(this.checkSimilarElements(elementNew, elementGroup)) {
javascript
{ "resource": "" }
q5279
primitive
train
function primitive (data) { var type; switch (data) { case null: case undefined: case false: case true: return true; } type = typeof data;
javascript
{ "resource": "" }
q5280
between
train
function between (data, x, y) { if (x < y) { return greater(data, x) && data < y;
javascript
{ "resource": "" }
q5281
inRange
train
function inRange (data, x, y) { if (x < y) { return greaterOrEqual(data, x) && data <= y;
javascript
{ "resource": "" }
q5282
instance
train
function instance (data, prototype) { try { return instanceStrict(data, prototype) || data.constructor.name === prototype.name ||
javascript
{ "resource": "" }
q5283
like
train
function like (data, archetype) { var name; for (name in archetype) { if (archetype.hasOwnProperty(name)) { if (data.hasOwnProperty(name) === false || typeof data[name] !== typeof archetype[name]) { return false; }
javascript
{ "resource": "" }
q5284
iterable
train
function iterable (data) { if (! haveSymbols) { // Fall back to `arrayLike` predicate in
javascript
{ "resource": "" }
q5285
includes
train
function includes (data, value) { var iterator, iteration, keys, length, i; if (! assigned(data)) { return false; } if (haveSymbols && data[Symbol.iterator] && isFunction(data.values)) { iterator = data.values(); do { iteration = iterator.next(); if (iteration.value === value) { return true; } } while (! iteration.done); return false;
javascript
{ "resource": "" }
q5286
apply
train
function apply (data, predicates) { assert.array(data); if (isFunction(predicates)) { return data.map(function (value) { return predicates(value); }); }
javascript
{ "resource": "" }
q5287
map
train
function map (data, predicates) { assert.object(data); if (isFunction(predicates)) { return mapSimple(data, predicates); }
javascript
{ "resource": "" }
q5288
all
train
function all (data) { if (array(data)) { return testArray(data, false); }
javascript
{ "resource": "" }
q5289
any
train
function any (data) { if (array(data)) { return testArray(data, true); }
javascript
{ "resource": "" }
q5290
notModifier
train
function notModifier (predicate) { var modifiedPredicate = function () { return notImpl(predicate.apply(null, arguments)); };
javascript
{ "resource": "" }
q5291
ofModifier
train
function ofModifier (target, type, predicate) { var modifiedPredicate = function () { var collection, args; collection = arguments[0]; if (target === 'maybe' && not.assigned(collection)) { return true; } if (!type(collection)) { return false; } collection = coerceCollection(type, collection); args = slice.call(arguments, 1); try { collection.forEach(function (item) { if ( (target !== 'maybe' || assigned(item)) &&
javascript
{ "resource": "" }
q5292
createBodystructure
train
function createBodystructure(tree, options) { options = options || {}; var walker = function(node) { switch((node.parsedHeader['content-type'] || {}).type) { case 'multipart': return processMultipartNode(node, options); case 'text': return processTextNode(node, options); case 'message': if (!options.attachmentRFC822) {
javascript
{ "resource": "" }
q5293
getBasicFields
train
function getBasicFields(node, options) { var bodyType = node.parsedHeader['content-type'] && node.parsedHeader['content-type'].type || null, bodySubtype = node.parsedHeader['content-type'] && node.parsedHeader['content-type'].subtype || null, contentTransfer = node.parsedHeader['content-transfer-encoding'] || '7bit'; return [ // body type options.upperCaseKeys ? bodyType && bodyType.toUpperCase() || null : bodyType, // body subtype options.upperCaseKeys ? bodySubtype && bodySubtype.toUpperCase() || null : bodySubtype, // body parameter parenthesized list node.parsedHeader['content-type'] && node.parsedHeader['content-type'].hasParams && flatten(Object.keys(node.parsedHeader['content-type'].params).map(function(key) { return [
javascript
{ "resource": "" }
q5294
getExtensionFields
train
function getExtensionFields(node, options) { options = options || {}; var languageString = node.parsedHeader['content-language'] && node.parsedHeader['content-language'].replace(/[ ,]+/g, ',').replace(/^,+|,+$/g, ''), language = languageString && languageString.split(',') || null, data; // if `contentLanguageString` is true, then use a string instead of single element array if (language && language.length == 1 && options.contentLanguageString) { language = language[0]; } data = [ // body MD5 node.parsedHeader['content-md5'] || null, // body disposition node.parsedHeader['content-disposition'] && [ options.upperCaseKeys ? node.parsedHeader['content-disposition'].value.toUpperCase() : node.parsedHeader['content-disposition'].value, node.parsedHeader['content-disposition'].params && node.parsedHeader['content-disposition'].hasParams && flatten(Object.keys(node.parsedHeader['content-disposition'].params).map(function(key) { return [ options.upperCaseKeys ? key.toUpperCase() : key, node.parsedHeader['content-disposition'].params[key]];
javascript
{ "resource": "" }
q5295
processAttachmentNode
train
function processAttachmentNode(node, options) { options = options || {}; var data = [].concat(getBasicFields(node, options)); if (!options.body) { data
javascript
{ "resource": "" }
q5296
train
function (key, config) { var props = key.split(','); this._cfg = { key: key, properties: props, name: config.name || camelize(props.join('_')), toGoogle: config.toGoogle || null, fromGoogle: config.fromGoogle || null, read: config.read || null, write: config.write ||
javascript
{ "resource": "" }
q5297
train
function(callback) { // If it's a webhook, delegate off if(method.type === 'webhook') { return RunUtil.runWebhook(grunt, options, method, callback); } //
javascript
{ "resource": "" }
q5298
train
function(r, callback) { result = r || {}; RunUtil.displayScriptData(grunt, result); RunUtil.displayScriptOutput(grunt, outputs, result); try { RunUtil.checkRunScriptResult(result, method); } catch(e) {
javascript
{ "resource": "" }
q5299
train
function(userScript, callback) { // If it's a run script, do some inputs script = userScript; if((userScript === 'run' || userScript === 'output') && (method.fields.input || method.scripts.input)) {
javascript
{ "resource": "" }