_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q34200
getServer
train
function getServer(inPath, { react, port, contentBase, configureApplication }) { const server = new _webpackDevServer2.default((0, _webpack2.default)(_extends({}, getConfig(react), { devtool: 'eval-source-map', entry: [`webpack-dev-server/client?http://0.0.0.0:${port}`, 'webpack/hot/only-dev-server', 'babel-polyfill', inPath], output: { path: contentBase, filename: 'script.js', publicPath: '/' }, plugins: serverPlugins })), { contentBase: false, publicPath: '/', hot: true }); server.use((0, _serveStatic2.default)(contentBase)); configureApplication(server.app); return server; }
javascript
{ "resource": "" }
q34201
NixInlineJS
train
function NixInlineJS(args) { /* Compose the NixInlineJS function's parameters */ var params = {}; if(typeof args.code == "function") { params.codeIsFunction = true; params.code = args.code.toString(); } else { params.codeIsFunction = false; params.code = args.code; } if(args.requires === undefined) params.requires = []; else params.requires = args.requires; if(args.modules === undefined) params.modules = []; else params.modules = args.modules; /* Construct function invocation object to the nijsInlineProxy */ NixFunInvocation.call(this, { funExpr: new nijs.NixExpression("nijsInlineProxy"), paramExpr: params }); }
javascript
{ "resource": "" }
q34202
getPayload
train
function getPayload(req, res, next) { req.hasCallback = false; req.payload = req.body.payload || []; // Determines if the request is asynchronous or not req.payload.forEach(function(arg, i) { if (arg === '__clientCallback__') { req.hasCallback = true; req.clientCallbackIndex = i; } }); debug('Got payload' + (req.hasCallback ? ' with callback' : '') + ': ' + JSON.stringify(req.payload, null, 3)); next(); }
javascript
{ "resource": "" }
q34203
callEntityMethod
train
function callEntityMethod(req, res, next) { var payload = req.payload; var method = req.serversideMethod; if (req.hasCallback) { debug('Transforming callback function'); payload[req.clientCallbackIndex] = function(err) { if (err) { return next(err); } var values = Array.prototype.slice.call(arguments).slice(1); debug('Callback function called. Values are:', values); res.entityResponse = values; next(); }; } debug('Calling ' + req.path + ' with arguments:', payload); var context = { req: req, xhr: true, setCookie: res.cookie.bind(res), clearCookie: res.clearCookie.bind(res) }; var ret; // Calls the requested serverside method. // Applies the payload, and provides a context for validation purposes. // Caches errors in the method's scope, and sends it to the next error handler. try { ret = method.apply(context, payload); } catch(err) { return next(err); } if (util.isPromise(ret)) { ret.then(function(resolved) { res.entityResponse = [resolved]; next(); }) .catch(function(err) { next(err); }); } // If the request is not expecting the response from the entity, // send a generic 'Ok' response. else if (!req.hasCallback) { res.entityResponse = [ret]; debug('Not asynchronous. Returning value: ', res.entityResponse); next(); } }
javascript
{ "resource": "" }
q34204
serve
train
function serve(req, res) { var responseIsArray = Array.isArray(res.entityResponse); util.invariant(responseIsArray, 'Response values are required.'); res.json({ values: res.entityResponse }); }
javascript
{ "resource": "" }
q34205
nextPreHook
train
function nextPreHook() { /** * read the arguments from previous "hook" response */ const args = Array.prototype.slice.apply(arguments); /** * Check if the arguments contains an "__override" property * that would override the arguments sent originally to the * target method */ if (is.object(args[0]) && {}.hasOwnProperty.call(args[0], '__override')) { passedArgs = arrify(args[0].__override); } /** * Reference to current pre hook */ let currentHook; if (currentPre + 1 < totalPres) { currentPre += 1; currentHook = pres[currentPre]; const hookMethod = currentHook.displayName || currentHook.name; /** * If there is a __scopeHook function on the object * we call it to get the scope wanted for the hook */ scope = getScope(self, name, passedArgs, hookMethod, 'pre'); /** * Execute the hook and recursively call the next one */ return currentHook.apply(scope, passedArgs).then(nextPreHook, handleError); } /** * We are done with "pre" hooks */ return done.apply(scope, passedArgs); }
javascript
{ "resource": "" }
q34206
nextPostHook
train
function nextPostHook(res) { response = checkResponse(res, response); if (currentPost + 1 < totalPost && self.__hooksEnabled !== false) { currentPost += 1; // Reference to current post hook const currPost = posts[currentPost]; const hookMethod = currPost.displayName || currPost.name; scope = getScope(self, name, res, hookMethod, 'post'); // Recursively call all the "post" hooks return currPost.call(scope, response).then(nextPostHook, postHookErrorHandler); } /** * All "post" hook process done. * If the response has an "__override" property it will be our response */ if (is.object(response) && {}.hasOwnProperty.call(response, '__override')) { response = response.__override; } return resolveFn(response); }
javascript
{ "resource": "" }
q34207
postHookErrorHandler
train
function postHookErrorHandler(err) { /** * Helper to add an error to an Object "errors" Symbol */ const addError = (obj) => { obj[ERR_KEY] = obj[ERR_KEY] || []; obj[ERR_KEY].push(err); return obj; }; /** * For response type that are *not* objects (string, integers, functions...) * we convert the response to an object with a "result" property and set it as "override" */ if (typeof response !== 'object') { response = { __override: { result: response, }, }; } if ({}.hasOwnProperty.call(response, '__override')) { response.__override = addError(response.__override); } else { response = addError(response); } return nextPostHook(response); }
javascript
{ "resource": "" }
q34208
renderInlines
train
function renderInlines(val, indent) { const indentStr = Array(indent + 1).join(' '); return '\n' + map(orderBy(val, first), (pair) => [ `${indentStr}${pair[0]} { ${exports.renderDefinition(pair[1], indent + 2)} ${indentStr}}`, ].join('\n') ).join('\n\n'); }
javascript
{ "resource": "" }
q34209
renderDefinitionRhs
train
function renderDefinitionRhs(val, indent) { indent = indent || 0; const indentStr = Array(indent + 1).join(' '); if (isUndefined(val)) { throw new Error('Undefined value in definition RHS.'); } if (isBoolean(val)) { return val.toString(); } if (isInteger(val)) { return val; } if (isString(val)) { return JSON.stringify(val); } if (isArray(val)) { return ['[', map(val, (elem) => `${indentStr} ${JSON.stringify(elem)}`).join(',\n'), `${indentStr}]`].join('\n'); } if (isObject(val)) { const rhsLines = exports.renderDefinition(val, indent + 2); const rhsStr = rhsLines; return `{ ${rhsStr} ${indentStr}}`; } }
javascript
{ "resource": "" }
q34210
makePrefixMapReducer
train
function makePrefixMapReducer() { for (var _len2 = arguments.length, reducers = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { reducers[_key2] = arguments[_key2]; } if (reducers.some(function (r) { return !_lodash2.default.isFunction(r); })) { throw new Error('all arguments must be a function'); } var initAction = { type: '@@redux/INIT' }; var initialState = reducers.reduce(function (a, r) { return Object.assign(a, r(undefined, initAction)); }, {}); function prefixOf(r, i) { // TODO warning about foreign reducers var p = _lodash2.default.isFunction(r.getPrefix) ? r.getPrefix() : '@@FOREIGN' + i; if (p && p.charAt(p.length - 1) === '/') { return p.substr(0, p.length - 1); } return p; } var reducerMap = reducers.reduce(function (a, r, i) { return _extends({}, a, _defineProperty({}, prefixOf(r, i), r)); }, {}); var reducer = function reducer() { var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState; var action = arguments[1]; var i = action.type.indexOf('/'); var prefix = i >= 0 ? action.type.substring(0, i) : ''; if (prefix) { var fn = reducerMap[prefix]; return fn(state, action); } // TODO try to dispatch foreign reducers return state; }; reducer.getInitialState = function getInitialState() { return _extends({}, initialState); }; return reducer; }
javascript
{ "resource": "" }
q34211
NixIf
train
function NixIf(args) { this.ifExpr = args.ifExpr; this.thenExpr = args.thenExpr; this.elseExpr = args.elseExpr; }
javascript
{ "resource": "" }
q34212
train
function (id, version, done, headers, config) { if (!_.isNumber(parseInt(id, 10))) { return done(new Error('id must be specified.')); } if (!_.isEmpty(version) && !_.isNumber(parseInt(version, 10))) { return done(new Error('version must be a number.')); } this._request(['files', id, 'versions', version], 'DELETE', done, null, null, null, headers, null, config); }
javascript
{ "resource": "" }
q34213
DoubleDottedItem
train
function DoubleDottedItem(parameters) { // An identifier is constructed from rule, dots, from and to this.id = "DoubleDottedItem(" + parameters.rule.lhs + "->" + parameters.rule.rhs + ", " + parameters.left_dot + ", " + parameters.right_dot + ", " + parameters.from + ", " + parameters.to +")"; logger.debug("Enter DoubleDottedItem: " + this.id); this.name = parameters.rule.lhs; this.children = []; this.data = {}; this.data.rule = parameters.rule; this.data.left_dot = parameters.left_dot; this.data.right_dot = parameters.right_dot; this.data.from = parameters.from; this.data.to = parameters.to; this.data.fs = parameters.fs; logger.debug("Exit DoubleDottedItem: created item: " + this.id); }
javascript
{ "resource": "" }
q34214
EarleyItem
train
function EarleyItem(parameters) { // A unique identifier is constructed from rule, dot and from this.id = "Earley(" + parameters.rule.lhs + "->" + parameters.rule.rhs + ", " + parameters.dot + ", " + parameters.from + ", " + parameters.to +")"; logger.debug("EarleyItem: " + this.id); this.name = parameters.rule.lhs; this.children = []; this.data = {}; this.data.rule = parameters.rule; this.data.dot = parameters.dot; this.data.from = parameters.from; this.data.to = parameters.to; if (global.config.UNIFICATION) { this.data.fs = parameters.fs; } }
javascript
{ "resource": "" }
q34215
_applyAnyStylesheet
train
function _applyAnyStylesheet(node) { if (!doc.createStyleSheet) { return; } if (_getHTMLNodeName(node) === 'style') { // IE var ss = doc.createStyleSheet(); // Create a stylesheet to actually do something useful ss.cssText = node.cssText; // We continue to add the style tag, however } }
javascript
{ "resource": "" }
q34216
_appendNode
train
function _appendNode(parent, child) { var parentName = _getHTMLNodeName(parent); var childName = _getHTMLNodeName(child); if (doc.createStyleSheet) { if (parentName === 'script') { parent.text = child.nodeValue; return; } if (parentName === 'style') { parent.cssText = child.nodeValue; // This will not apply it--just make it available within the DOM cotents return; } } if (parentName === 'template') { parent.content.appendChild(child); return; } try { parent.appendChild(child); // IE9 is now ok with this } catch (e) { if (parentName === 'select' && childName === 'option') { try { // Since this is now DOM Level 4 standard behavior (and what IE7+ can handle), we try it first parent.add(child); } catch (err) { // DOM Level 2 did require a second argument, so we try it too just in case the user is using an older version of Firefox, etc. parent.add(child, null); // IE7 has a problem with this, but IE8+ is ok } return; } throw e; } }
javascript
{ "resource": "" }
q34217
_addEvent
train
function _addEvent(el, type, handler, capturing) { el.addEventListener(type, handler, !!capturing); }
javascript
{ "resource": "" }
q34218
_createSafeReference
train
function _createSafeReference(type, prefix, arg) { // For security reasons related to innerHTML, we ensure this string only contains potential entity characters if (!arg.match(/^\w+$/)) { throw new TypeError('Bad ' + type); } var elContainer = doc.createElement('div'); // Todo: No workaround for XML? elContainer.innerHTML = '&' + prefix + arg + ';'; return doc.createTextNode(elContainer.innerHTML); }
javascript
{ "resource": "" }
q34219
glue
train
function glue(jmlArray, glu) { return _toConsumableArray(jmlArray).reduce(function (arr, item) { arr.push(item, glu); return arr; }, []).slice(0, -1); }
javascript
{ "resource": "" }
q34220
inputRecord
train
function inputRecord (type, record) { const clone = {}; const recordTypes = this.recordTypes; const primaryKey = this.keys.primary; const isArrayKey = this.keys.isArray; const generateId = this.options.generateId; const fields = recordTypes[type]; // ID business. const id = record[primaryKey]; clone[idKey] = id ? id : generateId(type); for (const field in record) { if (field === primaryKey) continue; clone[field] = record[field]; } for (const field of Object.getOwnPropertyNames(fields)) if (!(field in record)) clone[field] = fields[field][isArrayKey] ? [] : null; return clone; }
javascript
{ "resource": "" }
q34221
parseHTML
train
function parseHTML(html) { const dom = (0, _cheerio.load)(html), { children } = dom.root().toArray()[0]; return { dom, children }; }
javascript
{ "resource": "" }
q34222
toJSXKey
train
function toJSXKey(key) { return (0, _replace2.default)(/^-ms-/.test(key) ? key.substr(1) : key, /-(.)/g, (match, chr) => (0, _toUpper2.default)(chr)); }
javascript
{ "resource": "" }
q34223
transformStyle
train
function transformStyle(object) { if ((0, _has2.default)(object, 'style')) { object.style = (0, _transform2.default)((0, _split2.default)(object.style, ';'), (result, style) => { const firstColon = style.indexOf(':'), key = (0, _trim2.default)(style.substr(0, firstColon)); if (key) { result[toJSXKey((0, _toLower2.default)(key))] = (0, _trim2.default)(style.substr(firstColon + 1)); } }, {}); } }
javascript
{ "resource": "" }
q34224
rename
train
function rename(object, fromKey, toKey) { if ((0, _has2.default)(object, fromKey)) { object[toKey] = object[fromKey]; delete object[fromKey]; } }
javascript
{ "resource": "" }
q34225
transformElement
train
function transformElement({ name: type, attribs: props, children: childElements }) { transformStyle(props); rename(props, 'for', 'htmlFor'); rename(props, 'class', 'className'); if ('input' === type) { rename(props, 'checked', 'defaultChecked'); rename(props, 'value', 'defaultValue'); } let children = transformElements(childElements); if ('textarea' === type && children.length) { props.defaultValue = children[0]; children = []; } return { type, props, children }; }
javascript
{ "resource": "" }
q34226
flatten
train
function flatten(...args) { return (0, _transform2.default)((0, _flattenDeep2.default)(args), (accumulator, value) => { if (!value) { return; } const lastIndex = accumulator.length - 1; if ((0, _isString2.default)(value) && (0, _isString2.default)(accumulator[lastIndex])) { accumulator[lastIndex] += value; } else { accumulator.push(value); } }, []); }
javascript
{ "resource": "" }
q34227
arrayToJSX
train
function arrayToJSX(arr = []) { return (0, _map2.default)(arr, (el, key) => { if ((0, _isString2.default)(el)) { return el; } const { type, props, children } = el; return (0, _react.createElement)(type, _extends({}, props, { key }), ...arrayToJSX(children)); }); }
javascript
{ "resource": "" }
q34228
train
function (mine, their, strategy) { this._doMerge(mine, their, function(key){ if (typeof their[key] === 'object') { if (their[key] instanceof Array) { mine[key] = [].concat(mine[key], their[key]); } else { mine[key] = this[strategy](mine[key], their[key]); } } else if (mine[key] === undefined ) { mine[key] = their[key]; } }); return mine; }
javascript
{ "resource": "" }
q34229
train
function(line, curr_pos) { var ret = tokenizer.getBarLine(line, curr_pos); if (ret.len === 0) return [0,""]; if (ret.warn) { warn(ret.warn, line, curr_pos); return [ret.len,""]; } // Now see if this is a repeated ending // A repeated ending is all of the characters 1,2,3,4,5,6,7,8,9,0,-, and comma // It can also optionally start with '[', which is ignored. // Also, it can have white space before the '['. for (var ws = 0; ws < line.length; ws++) if (line.charAt(curr_pos + ret.len + ws) !== ' ') break; var orig_bar_len = ret.len; if (line.charAt(curr_pos+ret.len+ws) === '[') { ret.len += ws + 1; } // It can also be a quoted string. It is unclear whether that construct requires '[', but it seems like it would. otherwise it would be confused with a regular chord. if (line.charAt(curr_pos+ret.len) === '"' && line.charAt(curr_pos+ret.len-1) === '[') { var ending = tokenizer.getBrackettedSubstring(line, curr_pos+ret.len, 5); return [ret.len+ending[0], ret.token, ending[1]]; } var retRep = tokenizer.getTokenOf(line.substring(curr_pos+ret.len), "1234567890-,"); if (retRep.len === 0 || retRep.token[0] === '-') return [orig_bar_len, ret.token]; return [ret.len+retRep.len, ret.token, retRep.token]; }
javascript
{ "resource": "" }
q34230
train
function(all, backslash, comment){ var spaces = " "; var padding = comment ? spaces.substring(0, comment.length) : ""; return backslash + " \x12" + padding; }
javascript
{ "resource": "" }
q34231
train
function (attachment) { // Define custom metadata properties for the file before saving var customFileMetadata = {}; var parentItemId = model.getParentItemId(); if (parentItemId && parentItemId != '') customFileMetadata[scope.attachmentFilterFieldName + "Id"] = String(parentItemId); // Upload the file using the SharePoint item service return spFormFactory.uploadFileToDocLib(attachment.File.ArrayBuffer, scope.attachmentDocLibName, scope.attachmentDocFolderName, attachment.File.Name, attachment.File.Title, customFileMetadata); }
javascript
{ "resource": "" }
q34232
Queue
train
function Queue(name, opts) { // allow call as function if (!(this instanceof Queue)) return new Queue(name, opts); if (!name) { throw new Error('queue name is required'); } opts = opts || {}; // basic this.name = name; this.port = opts.port || 6379; this.host = opts.host || '127.0.0.1'; // queue config this.config = { blockTimeout: opts.blockTimeout || 60 , maxRetry: opts.maxRetry || 3 }; // redis options this.opts = opts; // main redis client this.client = Redis.createClient(this.port, this.host, this.opts); // client for blocking command only this.bclient = Redis.createClient(this.port, this.host, this.opts); // queue name this.prefix = 'dq:' + this.name; this.workQueue = this.prefix + ':work'; this.runQueue = this.prefix + ':run'; this.failQueue = this.prefix + ':fail'; // status code this.status_timeout = 1; // queue status this.shutdown = false; this.running = false; }
javascript
{ "resource": "" }
q34233
pton4
train
function pton4(addr, dest, index = 0) { if (typeof addr !== 'string') { throw new TypeError('Argument 1 should be a string.') } if (arguments.length >= 3) { if (typeof index !== 'number') { throw new TypeError('Argument 3 should be a Number.') } } const isbuffer = Buffer.isBuffer(dest) if (isbuffer) { if (index + IPV4_OCTETS > dest.length) { throw new Error('Too small target buffer.') } } const buf = isbuffer ? dest : Buffer.allocUnsafe(IPV4_OCTETS) let octets = 0 let sawDigit = false let number = 0 for (let i = 0; i < addr.length; ++i) { const char = code(addr[i]) if (isDigit(char)) { number = (number * 10) + (char - CHAR0) if (sawDigit && number === 0) { einval() } if (number > 0xFF) { einval() } if (!sawDigit) { if (++octets > IPV4_OCTETS) { einval() } sawDigit = true } } else if (char === CHARPOINT && sawDigit) { if (octets === IPV4_OCTETS) { einval() } buf[index++] = number number = 0 sawDigit = false } else { einval() } } if (octets < IPV4_OCTETS) { einval() } if (sawDigit) { buf[index] = number } return buf }
javascript
{ "resource": "" }
q34234
BufferGeometry
train
function BufferGeometry() { Object.defineProperty( this, 'id', { value: bufferGeometryId += 2 } ); this.uuid = _Math.generateUUID(); this.name = ''; this.type = 'BufferGeometry'; this.index = null; this.attributes = {}; this.morphAttributes = {}; this.groups = []; this.boundingBox = null; this.boundingSphere = null; this.drawRange = { start: 0, count: Infinity }; this.userData = {}; }
javascript
{ "resource": "" }
q34235
getSingularSetter
train
function getSingularSetter( type ) { switch ( type ) { case 0x1406: return setValue1f; // FLOAT case 0x8b50: return setValue2fv; // _VEC2 case 0x8b51: return setValue3fv; // _VEC3 case 0x8b52: return setValue4fv; // _VEC4 case 0x8b5a: return setValue2fm; // _MAT2 case 0x8b5b: return setValue3fm; // _MAT3 case 0x8b5c: return setValue4fm; // _MAT4 case 0x8b5e: case 0x8d66: return setValueT1; // SAMPLER_2D, SAMPLER_EXTERNAL_OES case 0x8B5F: return setValueT3D1; // SAMPLER_3D case 0x8b60: return setValueT6; // SAMPLER_CUBE case 0x1404: case 0x8b56: return setValue1i; // INT, BOOL case 0x8b53: case 0x8b57: return setValue2iv; // _VEC2 case 0x8b54: case 0x8b58: return setValue3iv; // _VEC3 case 0x8b55: case 0x8b59: return setValue4iv; // _VEC4 } }
javascript
{ "resource": "" }
q34236
setValue1fv
train
function setValue1fv( gl, v ) { var cache = this.cache; if ( arraysEqual( cache, v ) ) return; gl.uniform1fv( this.addr, v ); copyArray( cache, v ); }
javascript
{ "resource": "" }
q34237
CubicInterpolant
train
function CubicInterpolant( parameterPositions, sampleValues, sampleSize, resultBuffer ) { Interpolant.call( this, parameterPositions, sampleValues, sampleSize, resultBuffer ); this._weightPrev = - 0; this._offsetPrev = - 0; this._weightNext = - 0; this._offsetNext = - 0; }
javascript
{ "resource": "" }
q34238
train
function () { var valid = true; var valueSize = this.getValueSize(); if ( valueSize - Math.floor( valueSize ) !== 0 ) { console.error( 'THREE.KeyframeTrack: Invalid value size in track.', this ); valid = false; } var times = this.times, values = this.values, nKeys = times.length; if ( nKeys === 0 ) { console.error( 'THREE.KeyframeTrack: Track is empty.', this ); valid = false; } var prevTime = null; for ( var i = 0; i !== nKeys; i ++ ) { var currTime = times[ i ]; if ( typeof currTime === 'number' && isNaN( currTime ) ) { console.error( 'THREE.KeyframeTrack: Time is not a valid number.', this, i, currTime ); valid = false; break; } if ( prevTime !== null && prevTime > currTime ) { console.error( 'THREE.KeyframeTrack: Out of order keys.', this, i, currTime, prevTime ); valid = false; break; } prevTime = currTime; } if ( values !== undefined ) { if ( AnimationUtils.isTypedArray( values ) ) { for ( var i = 0, n = values.length; i !== n; ++ i ) { var value = values[ i ]; if ( isNaN( value ) ) { console.error( 'THREE.KeyframeTrack: Value is not a valid number.', this, i, value ); valid = false; break; } } } } return valid; }
javascript
{ "resource": "" }
q34239
QuaternionLinearInterpolant
train
function QuaternionLinearInterpolant( parameterPositions, sampleValues, sampleSize, resultBuffer ) { Interpolant.call( this, parameterPositions, sampleValues, sampleSize, resultBuffer ); }
javascript
{ "resource": "" }
q34240
train
function ( animation, bones ) { if ( ! animation ) { console.error( 'THREE.AnimationClip: No animation in JSONLoader data.' ); return null; } var addNonemptyTrack = function ( trackType, trackName, animationKeys, propertyName, destTracks ) { // only return track if there are actually keys. if ( animationKeys.length !== 0 ) { var times = []; var values = []; AnimationUtils.flattenJSON( animationKeys, times, values, propertyName ); // empty keys are filtered out, so check again if ( times.length !== 0 ) { destTracks.push( new trackType( trackName, times, values ) ); } } }; var tracks = []; var clipName = animation.name || 'default'; // automatic length determination in AnimationClip. var duration = animation.length || - 1; var fps = animation.fps || 30; var hierarchyTracks = animation.hierarchy || []; for ( var h = 0; h < hierarchyTracks.length; h ++ ) { var animationKeys = hierarchyTracks[ h ].keys; // skip empty tracks if ( ! animationKeys || animationKeys.length === 0 ) continue; // process morph targets if ( animationKeys[ 0 ].morphTargets ) { // figure out all morph targets used in this track var morphTargetNames = {}; for ( var k = 0; k < animationKeys.length; k ++ ) { if ( animationKeys[ k ].morphTargets ) { for ( var m = 0; m < animationKeys[ k ].morphTargets.length; m ++ ) { morphTargetNames[ animationKeys[ k ].morphTargets[ m ] ] = - 1; } } } // create a track for each morph target with all zero // morphTargetInfluences except for the keys in which // the morphTarget is named. for ( var morphTargetName in morphTargetNames ) { var times = []; var values = []; for ( var m = 0; m !== animationKeys[ k ].morphTargets.length; ++ m ) { var animationKey = animationKeys[ k ]; times.push( animationKey.time ); values.push( ( animationKey.morphTarget === morphTargetName ) ? 1 : 0 ); } tracks.push( new NumberKeyframeTrack( '.morphTargetInfluence[' + morphTargetName + ']', times, values ) ); } duration = morphTargetNames.length * ( fps || 1.0 ); } else { // ...assume skeletal animation var boneName = '.bones[' + bones[ h ].name + ']'; addNonemptyTrack( VectorKeyframeTrack, boneName + '.position', animationKeys, 'pos', tracks ); addNonemptyTrack( QuaternionKeyframeTrack, boneName + '.quaternion', animationKeys, 'rot', tracks ); addNonemptyTrack( VectorKeyframeTrack, boneName + '.scale', animationKeys, 'scl', tracks ); } } if ( tracks.length === 0 ) { return null; } var clip = new AnimationClip( clipName, duration, tracks ); return clip; }
javascript
{ "resource": "" }
q34241
train
function ( clip, optionalRoot ) { var root = optionalRoot || this._root, rootUuid = root.uuid, clipObject = typeof clip === 'string' ? AnimationClip.findByName( root, clip ) : clip, clipUuid = clipObject ? clipObject.uuid : clip, actionsForClip = this._actionsByClip[ clipUuid ]; if ( actionsForClip !== undefined ) { return actionsForClip.actionByRoot[ rootUuid ] || null; } return null; }
javascript
{ "resource": "" }
q34242
train
function ( deltaTime ) { deltaTime *= this.timeScale; var actions = this._actions, nActions = this._nActiveActions, time = this.time += deltaTime, timeDirection = Math.sign( deltaTime ), accuIndex = this._accuIndex ^= 1; // run active actions for ( var i = 0; i !== nActions; ++ i ) { var action = actions[ i ]; action._update( time, deltaTime, timeDirection, accuIndex ); } // update scene graph var bindings = this._bindings, nBindings = this._nActiveBindings; for ( var i = 0; i !== nBindings; ++ i ) { bindings[ i ].apply( accuIndex ); } return this; }
javascript
{ "resource": "" }
q34243
checkConfig
train
function checkConfig(config) { let requiredProps = ['algorithm', 'format']; const errMsg = `Configuration isn't an object with the required properties: ${requiredProps.join(', ')}`; if ((!config) || (typeof config !== 'object')) { throw new Error(errMsg); } requiredProps.forEach(p => { if (!config[p]) { throw new Error(errMsg); } }); }
javascript
{ "resource": "" }
q34244
train
function(arg) { return /^f/.test(typeof arg) ? /c/.test(document.readyState) ? arg() : u._defInit.push(arg) : new Init(arg); }
javascript
{ "resource": "" }
q34245
train
function(event, selector, handler, fn) { if (/^f/.test(typeof selector)) { handler = selector; fn = handler; } else if (/^s/.test(typeof selector)) { fn = handler; handler = function(e) { var element; if (u(e.target).is(selector)) { element = e.target; } else if (u(e.target).parents(selector).length) { element = u(e.target).parents(selector)[0]; } if (element) { fn.apply(element, [e]); } }; } return this.each(function(index, el) { var events = event.split(' '); u.each(events, function(i, event){ u._events.add(el, event, fn, handler); el.addEventListener(event, function temp(e) { el.removeEventListener(event, temp); u._events.remove(el, event, fn); handler.call(this,e); }); }); }); }
javascript
{ "resource": "" }
q34246
train
function(event, selector, handler, fn) { if (/^f/.test(typeof selector)) { handler = selector; } fn = handler; return this.each(function(index, el) { var events = event.split(' '); u.each(events, function(i, event, origEvent){ origEvent = u._events.remove(el, event, fn); handler = origEvent.length ? origEvent[0].handler : handler; el.removeEventListener(event, handler); }); }); }
javascript
{ "resource": "" }
q34247
train
function(e, data, evt) { if (/^f/.test(typeof CustomEvent)) { evt = new CustomEvent(e, { detail: data, bubbles: true, cancelable: false }); } else { evt = document.createEvent('CustomEvent'); evt.initCustomEvent(e, true, false, data); } return this.each(function(index, el) { el.dispatchEvent ? el.dispatchEvent(evt) : el.fireEvent('on' + e, evt); }); }
javascript
{ "resource": "" }
q34248
train
function(val) { return val === undefined ? (this.length ? (this[0].scrollTop !== undefined ? this[0].scrollTop : (this[0].scrollY || this[0].pageYOffset)) : 0) : this.each(function(index, el) { el.scrollTop === undefined || el.scrollTo !== undefined ? el.scrollTo(0, val) : el.scrollTop = val; }); }
javascript
{ "resource": "" }
q34249
train
function(to, duration, callback) { return this.each(function(index, el) { var _el = u(el), start = _el.scrollTop(), change = to - start, currentTime = 0, increment = 20; duration = duration || 1500; function easing(t, b, c, d) { t /= d/2; if (t < 1) { return c/2 * Math.pow( 2, 10 * (t - 1) ) + b; } t--; return c/2 * ( -Math.pow( 2, -10 * t) + 2 ) + b; } function animateScroll() { currentTime += increment; var val = easing(currentTime, start, change, duration); _el.scrollTop(val); if (currentTime < duration) { requestAnimationFrame(animateScroll); } else { callback && callback.apply(window); } } animateScroll(); }); }
javascript
{ "resource": "" }
q34250
train
function(duration, callback) { return this.each(function(index, el) { u(el).scrollTo(0, duration, callback); }); }
javascript
{ "resource": "" }
q34251
train
function(val) { return val === undefined ? (this.length ? this[0].clientWidth || this[0].innerWidth : 0) : this.each(function(index, el) { el.style.width = val + 'px'; }); }
javascript
{ "resource": "" }
q34252
train
function(margin) { if (!this.length) { return 0; } return margin ? this[0].offsetWidth + parseInt(getComputedStyle(this[0]).marginLeft) + parseInt(getComputedStyle(this[0]).marginRight) : this[0].offsetWidth; }
javascript
{ "resource": "" }
q34253
train
function(val) { return val === undefined ? (this.length ? this[0].clientHeight || this[0].innerHeight : 0) : this.each(function(index, el) { el.style.height = val + 'px'; }); }
javascript
{ "resource": "" }
q34254
train
function(margin) { if (!this.length) { return 0; } return margin ? this[0].offsetHeight + parseInt(getComputedStyle(this[0]).marginTop) + parseInt(getComputedStyle(this[0]).marginBottom) : this[0].offsetHeight; }
javascript
{ "resource": "" }
q34255
train
function(attr, val) { return val === undefined ? (this.length ? this[0].getAttribute(attr) : null) : this.each(function(index, el) { el.setAttribute(attr, val); }); }
javascript
{ "resource": "" }
q34256
train
function(prop, val) { return val === undefined ? (this.length ? this[0][prop] : null) : this.each(function(index, el) { el[prop] = val; }); }
javascript
{ "resource": "" }
q34257
train
function(attr, val, el, index, obj, attrCamel) { if (attr === undefined) { if (!this.length) { return {}; } el = this[0]; obj = u.extend({}, el.dataset || {}); if ((index = el[u._id]) === undefined) { el[u._id] = index = u._data.push(obj) - 1; return obj; } else { return u._data[index] = u.extend({}, obj, u._data[index]); } } else { attrCamel = u.toCamel(u.toDash(attr)); if (val === undefined) { if (!this.length) { return null; } el = this[0]; if ((index = el[u._id]) === undefined) { obj = {}; obj[attrCamel] = el.dataset ? el.dataset[attrCamel] : el.getAttribute('data-' + attr); el[u._id] = index = u._data.push(obj) - 1; return obj[attrCamel]; } else { return !!u._data[index][attrCamel] ? u._data[index][attrCamel] : (u._data[index][attrCamel] = el.dataset ? el.dataset[attrCamel] : el.getAttribute('data-' + attr)); } } else { return this.each(function(index, el) { if ((index = el[u._id]) === undefined) { obj = {}; obj[attrCamel] = val; el[u._id] = index = u._data.push(obj) - 1; } else { u._data[index][attrCamel] = val; } }); } } }
javascript
{ "resource": "" }
q34258
train
function(attr, index, attrCamel) { return this.each(function(i, el) { if (attr !== undefined) { attrCamel = u.toCamel(u.toDash(attr)); if ((index = el[u._id]) !== undefined) { el.dataset ? delete el.dataset[attrCamel] : el.removeAttribute('data-' + attr); delete u._data[index][attrCamel]; } } }); }
javascript
{ "resource": "" }
q34259
train
function(props, val) { if (/^o/.test(typeof props)) { for(var prop in props) { var prefixed = u.prfx(prop); if (props.hasOwnProperty(prop)) { this.each(function(index, el) { el.style[prefixed] = props[prop]; }); } } return this; } else { return val === undefined ? (this.length ? getComputedStyle(this[0])[props] : null) : this.each(function(index, el) { var prefixed = u.prfx(props); el.style[prefixed] = val; }); } }
javascript
{ "resource": "" }
q34260
train
function(child) { return this.length ? (/^o/.test(typeof child) ? this[0] !== child[0] && this[0].contains(child[0]) : this[0].querySelector(child) !== null) : false; }
javascript
{ "resource": "" }
q34261
train
function(filter) { return u(array.filter.call(this, function(el, index) { return /^f/.test(typeof filter) ? filter(index, el) : u(el).is(filter); })); }
javascript
{ "resource": "" }
q34262
train
function(sel) { if (!this.length) { return false; } var m = (this[0].matches || this[0].matchesSelector || this[0].msMatchesSelector || this[0].mozMatchesSelector || this[0].webkitMatchesSelector || this[0].oMatchesSelector || function(s) { return [].indexOf.call(document.querySelectorAll(s), this) !== -1; }); return m.call(this[0], sel); }
javascript
{ "resource": "" }
q34263
train
function(el) { if (!el) { return this[0] ? this.first().prevAll().length : -1; } if (''+el === el) { return u.toArray(u(el)).indexOf(this[0]); } el = el.ujs ? el[0] : el; return u.toArray(this).indexOf(el); }
javascript
{ "resource": "" }
q34264
train
function(sel) { if (!this.length) { return this; } var matched = [], el = this[0]; while (el = el.previousElementSibling) { sel ? (u(el).is(sel) && matched.push(el)) : matched.push(el); } return u(matched); }
javascript
{ "resource": "" }
q34265
train
function(sel) { if (!this.length) { return this; } var matched = [], el = this[0]; while (el = el.nextElementSibling) { sel ? (u(el).is(sel) && matched.push(el)) : matched.push(el); } return u(matched); }
javascript
{ "resource": "" }
q34266
train
function(sel) { if (!this.length) { return this; } var el = this[0]; return u(array.filter.call(el.parentNode.children, function(child) { return sel ? child !== el && u(child).is(sel) : child !== el; })); }
javascript
{ "resource": "" }
q34267
train
function(sel) { if (!this.length) { return this; } var parents = [], finished = false, currentElement = this[0]; while (!finished) { currentElement = currentElement.parentNode; if (currentElement) { if (sel === undefined) { parents.push(currentElement); } else if (u(currentElement).is(sel)) { parents.push(currentElement); } } else { finished = true; } } return u(parents); }
javascript
{ "resource": "" }
q34268
train
function(val) { return val === undefined ? (this.length ? this[0].textContent : null) : this.each(function(index, el) { el.textContent = val; }); }
javascript
{ "resource": "" }
q34269
train
function(val) { return val === undefined ? (this.length ? this[0].innerHTML : null) : this.each(function(index, el) { el.innerHTML = val; }); }
javascript
{ "resource": "" }
q34270
train
function(val) { return val === undefined ? (this.length ? this[0].outerHTML : null) : this.each(function(index, el) { el.outerHTML = val; }); }
javascript
{ "resource": "" }
q34271
train
function(val) { return val === undefined ? (this.length ? this[0].value : null) : this.each(function(index, el) { el.value = val; }); }
javascript
{ "resource": "" }
q34272
train
function() { var args = u.toArray(arguments); args.unshift(u.fn); return u.extend.apply(this, args); }
javascript
{ "resource": "" }
q34273
train
function(params) { This.lines[This.lineNum].staff[This.staffNum].voices[This.voiceNum] = []; if (This.isFirstLine(This.lineNum)) { if (params.name) {if (!This.lines[This.lineNum].staff[This.staffNum].title) This.lines[This.lineNum].staff[This.staffNum].title = [];This.lines[This.lineNum].staff[This.staffNum].title[This.voiceNum] = params.name;} } else { if (params.subname) {if (!This.lines[This.lineNum].staff[This.staffNum].title) This.lines[This.lineNum].staff[This.staffNum].title = [];This.lines[This.lineNum].staff[This.staffNum].title[This.voiceNum] = params.subname;} } if (params.style) This.appendElement('style', null, null, {head: params.style}); if (params.stem) This.appendElement('stem', null, null, {direction: params.stem}); else if (This.voiceNum > 0) { if (This.lines[This.lineNum].staff[This.staffNum].voices[0]!== undefined) { var found = false; for (var i = 0; i < This.lines[This.lineNum].staff[This.staffNum].voices[0].length; i++) { if (This.lines[This.lineNum].staff[This.staffNum].voices[0].el_type === 'stem') found = true; } if (!found) { var stem = { el_type: 'stem', direction: 'up' }; This.lines[This.lineNum].staff[This.staffNum].voices[0].splice(0,0,stem); } } This.appendElement('stem', null, null, {direction: 'down'}); } if (params.scale) This.appendElement('scale', null, null, { size: params.scale} ); }
javascript
{ "resource": "" }
q34274
featureIsUnifiable
train
function featureIsUnifiable(feature) { logger.debug('TypedFeatureStructure.unifiable: checking feature: ' + feature + fs2.features[feature]); if (fs1.features[feature]) { // If feature of fs2 is a back pointer we want it to overrule feature // of the fs1. if (newStackb.indexOf(fs2.features[feature].id) > -1) { fs1.addAuxFeature(feature, fs2.features[feature], signature); } // One of the features should be not a back pointer because // otherwise we are checking for unification multiple times if ((newStacka.indexOf(fs1.features[feature].id) === -1) || (newStackb.indexOf(fs2.features[feature].id) === -1)) { var unifiable = fs1.features[feature].unifiable(fs2.features[feature], signature, newStacka, newStackb); logger.debug('TypedFeatureStructure.unifiable: checking feature: ' + feature + ' with result: ' + unifiable); return (unifiable); } else { return (true); } } else { fs1.addAuxFeature(feature, fs2.features[feature], signature); return (true); } }
javascript
{ "resource": "" }
q34275
prettyPrint0
train
function prettyPrint0(fs, indent) { logger.debug('prettyPrint0: ' + fs); var result = ''; if (fs) { if (Object.keys(fs.incoming).length > 1) { if (fs.printed) { // Return the label return (fs.getLabel()); } else { // Print the label result += fs.getLabel() + space; indent += fs.getLabel().length + 1; // and continue to print the substructure } } // mark the current node as printed fs.printed = true; if (!Object.keys(fs.features).length) { logger.debug('prettyPrint0() ' + fs.type.name); result += (debug ? fs.getLabel() : ''); if (fs.type === signature.typeLattice.string) { // Print the lexical string result += '\"' + fs.lexicalString + '\"'; } else { if (fs.type === signature.typeLattice.list) { // Distinguish ordinary references from list of references if (fs.listOfCrossRefs) { // Print the list of cross references result += '<'; fs.listOfCrossRefs.forEach(function (ref) { if (ref.printed) { result += ref.getLabel() + ', '; } else { // Print the referred fs result += prettyPrint0(ref, indent + 1) + ',\n'; } }); // Remove the last comma plus space, if necessary if (fs.listOfCrossRefs.length) { result = result.substr(0, result.length - 2); } result += '>'; } else { // Print the type result += fs.type.prettyPrint(); } } else { if (fs.type === signature.typeLattice.concatlist) { // Print concatenation of lists of cross referenced nodes if (fs.listOfCrossRefs) { result += '<'; var nrPrinted = 0; fs.listOfCrossRefs.forEach(function (ref) { if (ref.printed) { result += ref.getLabel() + ' + '; } else { result += prettyPrint0(ref, indent + 1) + ' +\n'; } nrPrinted++; }); // Remove the last comma plus space, if one or more elements // were printed if (nrPrinted) { result = result.substr(0, result.length - 3); } result += '>'; } else { // Print the type result += fs.type.prettyPrint(); } } else { // Print the type result += fs.type.prettyPrint(); } } } } else { // Print the substructure result += '[' + (debug ? fs.getLabel() : ''); Object.keys(fs.features).forEach(function (feature, index) { if (index === 0) { // first print the type of the substructure logger.debug('prettyPrint0(): ' + fs.type.name); result += fs.type.prettyPrint() + '\n'; // + ' (incoming: ' +' + //' Object.keys(fs.incoming).length + ')' + '\n'; result += space.repeat(indent + 1); result += feature + ':' + space; result += prettyPrint0(fs.features[feature], indent + feature.length + 3) + '\n'; } else { result += space.repeat(indent + 1) + feature + ':' + space; result += prettyPrint0(fs.features[feature], indent + feature.length + 3) + '\n'; } }); result += space.repeat(indent) + ']'; } } else { result += 'WARNING: empty fs\n'; } return (result); }
javascript
{ "resource": "" }
q34276
livereload
train
function livereload() { if (!reloadFn) { const lr = (0, _tinyLr2.default)(); lr.listen(LIVERELOAD_PORT); reloadFn = (file = '*') => { lr.changed({ body: { files: [file] } }); }; } return reloadFn; }
javascript
{ "resource": "" }
q34277
train
function(fullUrl, body, key, signature) { var data = fullUrl + sortPostParameters(body); var expected = getHash(data, key); return expected === signature; }
javascript
{ "resource": "" }
q34278
train
function(body) { body = Object(body); var sortedKeys = Object.keys(body).sort(); return sortedKeys.reduce(function(signature, key) { return signature + key + body[key]; }, ''); }
javascript
{ "resource": "" }
q34279
train
function(req, res, next) { var signature = req.headers[MANDRILL_SIGNATURE_HEADER]; var fullUrl = options.domain + req.url; var isValid = validator(fullUrl, req.body, signature); var respondWith = responder(res); if (!signature) { respondWith(401, NOT_AUTHORIZED); }else if (req.body && req.body.mandrill_events === '[]' && isValid('test-webhook')) { respondWith(200, OK); }else if (!isValid(options.webhookAuthKey)) { respondWith(403, FORBIDDEN); } else { next(); } }
javascript
{ "resource": "" }
q34280
Column
train
function Column({ size, ...props }) { const staticStyles = { display: 'flex', flexDirection: 'column', } const dynamicStyles = { flex: `0 0 ${size / 12 * 100}`, } return createStyledElement('div', props)(staticStyles, dynamicStyles) }
javascript
{ "resource": "" }
q34281
Slack
train
function Slack(options) { var suppliedOptions = options ? options : {}; if (!suppliedOptions.webhook || typeof suppliedOptions.webhook !== 'string') { throw new Error('Invalid webhook parameter'); } this.name = 'slack'; this.webhook = suppliedOptions.webhook; this.customFormatter = suppliedOptions.customFormatter || defaultFormatter; delete suppliedOptions.customFormatter; delete suppliedOptions.webhook; this.options = extend({ channel: '#general', username: 'winston-slacker', iconUrl: false, iconEmoji: false, level: 'info', silent: false, raw: false, name: 'slacker', handleExceptions: false, }, suppliedOptions); }
javascript
{ "resource": "" }
q34282
send
train
function send(message, callback) { const suppliedCallback = callback || function () {}; if (!message) { return suppliedCallback(new Error('No message')); } const requestParams = { url: this.webhook, body: extend(this.options, { text: message }), json: true }; return request.post(requestParams, function (err, res, body) { if (err || body !== 'ok') { return suppliedCallback(err || new Error(body)); } return suppliedCallback(null, body); }); }
javascript
{ "resource": "" }
q34283
tokenize_sentence
train
function tokenize_sentence(sentence) { var tokenized = tokenizer.tokenize(sentence); logger.info("tokenize_sentence: " + tokenized); return(tokenized); }
javascript
{ "resource": "" }
q34284
stem_sentence
train
function stem_sentence(sentence) { for (var i = 0; i < sentence.length; i++) { sentence[i] = natural.PorterStemmer.stem(sentence[i]); } logger.info("stem_sentence: " + sentence); return(sentence); }
javascript
{ "resource": "" }
q34285
Type
train
function Type(name, super_types, fs) { this.super_types = []; this.name = name; if (super_types) { this.super_types = super_types; } this.fs = fs; }
javascript
{ "resource": "" }
q34286
NixFunction
train
function NixFunction(args) { if(args.argSpec === null) { throw "Cannot derivate function argument specification from a null reference"; } else if(typeof args.argSpec == "string" || typeof args.argSpec == "object") { this.argSpec = args.argSpec; this.body = args.body; } else { throw "Cannot derive function argument specification from an object of type: "+args.argSpec; } }
javascript
{ "resource": "" }
q34287
train
function(req, res, next) { var requestTokenUrl = 'https://api.twitter.com/oauth/request_token'; var accessTokenUrl = 'https://api.twitter.com/oauth/access_token'; var authenticateUrl = 'https://api.twitter.com/oauth/authenticate'; // Step 2. Redirect to the authorization screen. if (!req.query.oauth_token || !req.query.oauth_verifier) { var requestTokenOauth = { consumer_key: config.TWITTER_KEY, consumer_secret: config.TWITTER_SECRET, callback: config.TWITTER_CALLBACK }; request.post({ url: requestTokenUrl, oauth: requestTokenOauth }, function(err, response, body) { var oauthToken = qs.parse(body); var params = qs.stringify({ oauth_token: oauthToken.oauth_token }); res.redirect(authenticateUrl + '?' + params); }); return; } // Step 3. Exchange oauth token and oauth verifier for access token. var accessTokenOauth = { consumer_key: config.TWITTER_KEY, consumer_secret: config.TWITTER_SECRET, token: req.query.oauth_token, verifier: req.query.oauth_verifier }; request.post({ url: accessTokenUrl, oauth: accessTokenOauth }, function(err, response, profile) { if (err) { res.status(500).send(err); return; } req.profile = qs.parse(profile); next(); }); }
javascript
{ "resource": "" }
q34288
train
function (req, res, next) { var prifile = req.profile; var filter = { or: [{ twitter: profile.user_id }, { email: profile.email }] }; User.find({ where: filter }, function(err, users) { var user = users[0]; if (user) { if (!user.twitter) { user.twitter = profile.user_id; user.displayName = user.displayName || profile.name; user.save(function() { req.user = user; next(); }); return; } req.user = user; next(); return; } User.create({ displayName: profile.name, yahoo: profile.user_id, email: profile.email, password: profile.user_id }, function (err, user) { req.user = user; next(); }); }); }
javascript
{ "resource": "" }
q34289
train
function (req, res, next) { var profileUrl = 'https://api.foursquare.com/v2/users/self'; var params = { v: '20140806', oauth_token: req.accessToken }; request.get({ url: profileUrl, qs: params, json: true }, function(err, response, profile) { if (err) { res.status(500).send(err); return; } req.profile = profile.response.user; next(); }); }
javascript
{ "resource": "" }
q34290
getAugmentedOptionsObject
train
function getAugmentedOptionsObject (initialObject) { // jshint validthis:true const thisIsLateralus = isLateralus(this); const augmentedOptions = _.extend(initialObject || {}, { lateralus: thisIsLateralus ? this : this.lateralus }); if (!thisIsLateralus) { augmentedOptions.component = this.component || this; } return augmentedOptions; }
javascript
{ "resource": "" }
q34291
formatLine
train
function formatLine(message, file, line, column) { const { yellow, cyan, magenta } = consoleStyles; return ['"', yellow(message), '" in ', cyan((0, _path.relative)('', file)), ' on ', magenta(line), ':', magenta(column)]; }
javascript
{ "resource": "" }
q34292
formatErrorMarker
train
function formatErrorMarker(message = 'Error') { const { bold, bgRed, white } = consoleStyles; return bgRed(bold(white(message))); }
javascript
{ "resource": "" }
q34293
log
train
function log(...messages) { const { message, styles } = new Message({ ansi: ['', ''], css: '' }).addMessages(messages); console.log(message, ...styles); }
javascript
{ "resource": "" }
q34294
logPostCSSWarnings
train
function logPostCSSWarnings(warnings) { (0, _forEach2.default)(warnings, ({ text, plugin, node: { source: { input: { file } } }, line, column }) => { log(formatErrorMarker('Warning'), ': ', ...formatLine(`${text}(${plugin})`, file, line, column)); }); log('PostCSS warnings: ', warnings.length); }
javascript
{ "resource": "" }
q34295
logSASSError
train
function logSASSError({ message, file, line, column }) { log(formatErrorMarker('SASS error'), ': ', ...formatLine(message, file, line, column)); }
javascript
{ "resource": "" }
q34296
logLintingErrors
train
function logLintingErrors(errors, prefix = null) { (0, _forEach2.default)(errors, ({ message, rule, file, line, column }) => { log(formatErrorMarker(), ': ', ...formatLine(`${message}${rule ? ` (${rule})` : ''}`, file, line, column)); }); log(prefix ? `${prefix} l` : 'L', 'inting errors: ', errors.length); }
javascript
{ "resource": "" }
q34297
ProductionRule
train
function ProductionRule(lhs, rhs, head) { this.lhs = lhs; this.rhs = rhs; this.head = head; // feature structure of the constraints specified with the rule this.fs = null; }
javascript
{ "resource": "" }
q34298
parseMethodsFromRust
train
function parseMethodsFromRust (source) { // Matching the custom `rpc` attribute with it's doc comment const attributePattern = /((?:\s*\/\/\/.*$)*)\s*#\[rpc\(([^)]+)\)]/gm; const commentPattern = /\s*\/\/\/\s*/g; const separatorPattern = /\s*,\s*/g; const assignPattern = /([\S]+)\s*=\s*"([^"]*)"/; const ignorePattern = /@(ignore|deprecated|unimplemented|alias)\b/i; const methods = []; source.toString().replace(attributePattern, (match, comment, props) => { comment = comment.replace(commentPattern, '\n').trim(); // Skip deprecated methods if (ignorePattern.test(comment)) { return match; } props.split(separatorPattern).forEach((prop) => { const [, key, value] = prop.split(assignPattern) || []; if (key === 'name' && value != null) { methods.push(value); } }); return match; }); return methods; }
javascript
{ "resource": "" }
q34299
getMethodsFromRustTraits
train
function getMethodsFromRustTraits () { const traitsDir = path.join(__dirname, '../../.parity/rpc/src/v1/traits'); return fs .readdirSync(traitsDir) .filter((name) => name !== 'mod.rs' && /\.rs$/.test(name)) .map((name) => fs.readFileSync(path.join(traitsDir, name))) .map(parseMethodsFromRust) .reduce((a, b) => a.concat(b)); }
javascript
{ "resource": "" }