_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q6700
handle
train
function handle(nativeEvent) { var event = SyntheticKeyboardEvent.getPooled({}, 'hotkey', nativeEvent); try { dispatchEvent(event, handlers); } finally { if (!event.isPersistent()) { event.constructor.release(event); } } }
javascript
{ "resource": "" }
q6701
dispatchEvent
train
function dispatchEvent(event, handlers) { for (var i = (handlers.length - 1); i >= 0; i--) { if (event.isPropagationStopped()) { break; } var returnValue = handlers[i](event); if (returnValue === false) { event.stopPropagation(); event.preventDefau...
javascript
{ "resource": "" }
q6702
train
function(nodes) { if (nodes.length == 0) return nodes; var results = [], n; for (var i = 0, l = nodes.length; i < l; i++) if (!(n = nodes[i])._counted) { n._counted = true; results.push(Element.extend(n)); } return Selector.handlers.unmark(results); }
javascript
{ "resource": "" }
q6703
addNextNodesToASTObject
train
function addNextNodesToASTObject(ASTObject) { const ASTObjectsForDepths = [ASTObject]; function addNextNodes(ASTObject, depth) { const depthPlus1 = depth + 1; ASTObjectsForDepths[depthPlus1] = ASTObject; if (ASTObject.left) addNextNodes(ASTObject.left, depthPlus1); if (ASTObject.right) a...
javascript
{ "resource": "" }
q6704
Counter
train
function Counter() { this.total = 0; this.executed = 0; this.passed = 0; this.error = 0; this.failed = 0; this.timeout = 0; this.aborted = 0; this.inconclusive = 0; this.passedButRunAborted = 0; this.notRunnable = 0; this.notExecuted = 0; this.disconnected = 0; this.warning = 0; this.complet...
javascript
{ "resource": "" }
q6705
Times
train
function Times(params) { this.creation = params.creation; this.queuing = params.queuing; this.start = params.start; this.finish = params.finish; }
javascript
{ "resource": "" }
q6706
Deployment
train
function Deployment(params) { this.runDeploymentRoot = params.runDeploymentRoot this.userDeploymentRoot = params.userDeploymentRoot this.deploySatelliteAssemblies = params.deploySatelliteAssemblies this.ignoredDependentAssemblies = params.ignoredDependentAssemblies this.enabled = params.enabled }
javascript
{ "resource": "" }
q6707
assembleMiddleware
train
function assembleMiddleware (middlewareStackClasses, context) { var middlewares = []; middlewareStackClasses.forEach (function (MiddlewareClass) { middlewares.push (new MiddlewareClass (context)); }); return middlewares; }
javascript
{ "resource": "" }
q6708
traceModule
train
function traceModule (moduleName, context, processHook) { var module = context.modules[moduleName]; if (!module) fatal ('Module <cyan>%</cyan> was not found.', moduleName); // Ignore the module if it's external. if (module.external) return; // Include required submodules first. con...
javascript
{ "resource": "" }
q6709
safeCall
train
function safeCall (fn, args, callback) { args = Array.prototype.slice.call(arguments, 1); callback = args.pop(); var callbackCalled; try { args.push(safeCallback); fn.apply(null, args); } catch (err) { if (callbackCalled) { throw err; } else { safeCallback(err); } } ...
javascript
{ "resource": "" }
q6710
readReferencedFiles
train
function readReferencedFiles (schema, callback) { var filesBeingRead = [], filesToRead = []; var file, i; // Check the state of all files in the schema for (i = 0; i < schema.files.length; i++) { file = schema.files[i]; if (file[__internal].state < STATE_READING) { filesToRead.push(file); } ...
javascript
{ "resource": "" }
q6711
finished
train
function finished (schema, callback) { schema.plugins.finished(); delete schema.config.sync; callback(null, schema); }
javascript
{ "resource": "" }
q6712
parseMetaEvent
train
function parseMetaEvent(delay, cursor) { var type, specs = {}, length, value, rates; rates = [24, 25, 30, 30]; type = cursor.readUInt8(); length = parseVarInt(cursor); switch (type) { case MetaEvent.TYPE.SEQUENCE_NUMBER: specs.number = cursor.readUInt16LE(); break; case Met...
javascript
{ "resource": "" }
q6713
parseSysexEvent
train
function parseSysexEvent(delay, type, cursor) { var data, length = parseVarInt(cursor); data = cursor.slice(length).buffer; return new SysexEvent(type, data, delay); }
javascript
{ "resource": "" }
q6714
parseChannelEvent
train
function parseChannelEvent(delay, type, channel, cursor) { var specs = {}; switch (type) { case ChannelEvent.TYPE.NOTE_OFF: specs.note = cursor.readUInt8(); specs.velocity = cursor.readUInt8(); break; case ChannelEvent.TYPE.NOTE_ON: specs.note = cursor.readUInt8(); ...
javascript
{ "resource": "" }
q6715
parseEvent
train
function parseEvent(cursor, runningStatus) { var delay, status, result; delay = parseVarInt(cursor); status = cursor.readUInt8(); // if the most significant bit is not set, // we use the last status if ((status & 0x80) === 0) { if (!runningStatus) { throw new error.MIDIPars...
javascript
{ "resource": "" }
q6716
encodeSysexEvent
train
function encodeSysexEvent(event) { var cursor, length; length = encodeVarInt(event.data.length); cursor = new BufferCursor(new buffer.Buffer( 1 + length.length + event.data.length )); cursor.writeUInt8(0xF0 | event.type); cursor.copy(length); cursor.copy(event.data); return cu...
javascript
{ "resource": "" }
q6717
encodeChannelEvent
train
function encodeChannelEvent(event) { var cursor, eventData, value; switch (event.type) { case ChannelEvent.TYPE.NOTE_OFF: eventData = new BufferCursor(new buffer.Buffer(2)); eventData.writeUInt8(event.note); eventData.writeUInt8(event.velocity); break; case ChannelEvent...
javascript
{ "resource": "" }
q6718
encodeEvent
train
function encodeEvent(event, runningStatus) { var delay, eventData, cursor; delay = encodeVarInt(event.delay); if (event instanceof MetaEvent) { eventData = encodeMetaEvent(event); } else if (event instanceof SysexEvent) { eventData = encodeSysexEvent(event); } else if (event instan...
javascript
{ "resource": "" }
q6719
OverrideDependenciesMiddleware
train
function OverrideDependenciesMiddleware (context) { /* jshint unused: vars */ var options = context.options.overrideDependencies , enabled = options.dependencies && options.dependencies.length; //-----------------------------------------------------------------------------------------------------------------...
javascript
{ "resource": "" }
q6720
Header
train
function Header(fileType, trackCount, ticksPerBeat) { this._fileType = fileType || Header.FILE_TYPE.SYNC_TRACKS; this._trackCount = trackCount || 0; this._ticksPerBeat = ticksPerBeat || 120; }
javascript
{ "resource": "" }
q6721
BuildAssetsMiddleware
train
function BuildAssetsMiddleware (context) { var grunt = context.grunt , options = context.options.assets; /** * Records which files have been already exported. * Prevents duplicate asset exports. * It's a map of absolute file names to boolean `true`. * @type {Object.<string,boolean>} */ var exp...
javascript
{ "resource": "" }
q6722
MakeDebugBuildMiddleware
train
function MakeDebugBuildMiddleware (context) { var options = context.options.debugBuild; /** @type {string[]} */ var traceOutput = []; //-------------------------------------------------------------------------------------------------------------------- // EVENTS //------------------------------------------...
javascript
{ "resource": "" }
q6723
Parser
train
function Parser( options ) { if( !(this instanceof Parser) ) return new Parser( options ) Stream.Transform.call( this, options ) this._readableState.objectMode = true this._buffer = '' }
javascript
{ "resource": "" }
q6724
readFileAsync
train
function readFileAsync (args) { var file = args.file; var config = args.config; var next = args.next; var url = parseUrl(file.url); var transport; switch (url.protocol) { case 'http:': transport = followRedirects.http; break; case 'https:': transport = follow...
javascript
{ "resource": "" }
q6725
parseUrl
train
function parseUrl (url) { if (typeof URL === 'function') { // Use the new WHATWG URL API return new URL(url); } else { // Use the legacy url API var parsed = legacyURL.parse(url); // Replace nulls with default values, for compatibility with the WHATWG URL API parsed.pathname = parsed.path...
javascript
{ "resource": "" }
q6726
decompressResponse
train
function decompressResponse (res) { var encoding = lowercase(res.headers['content-encoding']); var isCompressed = ['gzip', 'compress', 'deflate'].indexOf(encoding) >= 0; if (isCompressed) { // The response is compressed, so add decompression middleware to the stream res.pipe(zlib.createUnzip()); // ...
javascript
{ "resource": "" }
q6727
fromHeaderOrQuerystring
train
function fromHeaderOrQuerystring(req) { if (req.headers.authorization && req.headers.authorization.split(' ')[0] === 'Bearer') { return req.headers.authorization.split(' ')[1]; } else if (req.query && req.query.token) { return req.query.token; } return false; }
javascript
{ "resource": "" }
q6728
train
function (a, b) { if (a) { if (Array.isArray(b)) { for (var i = 0; i < b.length; i++) { if (b[i]) { a[i] = extend(a[i], b[i]); } } return a; } else if (typeof b === 'object') { Object.getOwnPropertyNames(b).forEach(function (key) { a[key] = extend(a[ke...
javascript
{ "resource": "" }
q6729
allora
train
function allora (parent, prop) { return new Proxy(prop ? parent[prop] : parent, { get: (target, property) => { // no function no need for promises in return if (isOnCallback(property)) { // detect properties like // window.onload.then(() => console.log('loaded')) return new Pro...
javascript
{ "resource": "" }
q6730
renderToContext
train
function renderToContext (geoJson, projection) { var shapePath = new THREE.ShapePath(); var mapRenderContext = new ThreeJSRenderContext(shapePath); var mapPath = geoPath(projection, mapRenderContext); mapPath(geoJson); return mapRenderContext; }
javascript
{ "resource": "" }
q6731
train
function(callback){ var self = this; // if we have no pages just fire callback if(self.pageCollection.length === 0){ callback(self); } // this is called once a page is fully parsed whenPageIsFetched = function(){ self.completed ++; if(self.completed === self.pageCollection.le...
javascript
{ "resource": "" }
q6732
train
function (){ var out = {} if(this.profiles.length !== 0){ out.profiles = this.profiles } if(this.noProfilesFound.length !== 0){ out.noProfilesFound = this.noProfilesFound; } if(utils.hasProperties(this.combinedProfile)){ out.combinedProfile = this.combinedProfile } ...
javascript
{ "resource": "" }
q6733
commonUserName
train
function commonUserName(objs, logger){ logger.info('finding common username'); var i = objs.length, x = 0 usernames = [], highest = 0, out =''; while (x < i) { appendName(objs[x].userName); x++; } var i = usernames.length; while (i--) { if(usernames[i].count > high...
javascript
{ "resource": "" }
q6734
appendUrl
train
function appendUrl(url, urls) { var i = urls.length found = false; while (i--) { if (utils.compareUrl(urls[i], url)) found = true; } if (found === false && utils.isUrl(url)) urls.push(url); }
javascript
{ "resource": "" }
q6735
rateAddress
train
function rateAddress(addr){ var rating = 0; if(addr != undefined){ if (addr['extended-address']) rating++; if (addr['street-address']) rating++; if (addr.locality) rating++; if (addr.region) rating++; if (addr['postal-code']) rating++; if (addr['country-...
javascript
{ "resource": "" }
q6736
checkFamily
train
function checkFamily(program, family) { var familyIndex = gm.families.indexOf(family.toLowerCase()); if (familyIndex === -1 || program < (familyIndex * 8) || program >= ((familyIndex + 1) * 8)) { return false; } return true; }
javascript
{ "resource": "" }
q6737
format
train
function format(arg) { if (typeof arg === 'number') { return '0x' + arg.toString(16).toUpperCase(); } if (typeof arg === 'string') { return '"' + arg + '"'; } return arg.toString(); }
javascript
{ "resource": "" }
q6738
MIDIParserError
train
function MIDIParserError(actual, expected, byte) { Error.call(this); Error.captureStackTrace(this, this.constructor); this.name = this.constructor.name; this.actual = actual; this.expected = expected; actual = format(actual); expected = format(expected); this.message = 'Invalid MIDI f...
javascript
{ "resource": "" }
q6739
MIDIEncoderError
train
function MIDIEncoderError(actual, expected) { Error.call(this); Error.captureStackTrace(this, this.constructor); this.name = this.constructor.name; this.actual = actual; this.expected = expected; actual = format(actual); expected = format(expected); this.message = 'MIDI encoding error...
javascript
{ "resource": "" }
q6740
MIDIInvalidEventError
train
function MIDIInvalidEventError(message) { Error.call(this); Error.captureStackTrace(this, this.constructor); this.name = this.constructor.name; this.message = message; }
javascript
{ "resource": "" }
q6741
MIDIInvalidArgument
train
function MIDIInvalidArgument(message) { Error.call(this); Error.captureStackTrace(this, this.constructor); this.name = this.constructor.name; this.message = message; }
javascript
{ "resource": "" }
q6742
MIDINotMIDIError
train
function MIDINotMIDIError() { Error.call(this); Error.captureStackTrace(this, this.constructor); this.name = this.constructor.name; this.message = 'Not a valid MIDI file'; }
javascript
{ "resource": "" }
q6743
MIDINotSupportedError
train
function MIDINotSupportedError(message) { Error.call(this); Error.captureStackTrace(this, this.constructor); this.name = this.constructor.name; this.message = message; }
javascript
{ "resource": "" }
q6744
postMessage
train
function postMessage(message, target, force) { var consumer; var parsed; if (!this.disposed) { try { if (message) { if (this.ready || force) { // Post the message cons...
javascript
{ "resource": "" }
q6745
_hookupMessageChannel
train
function _hookupMessageChannel(onmessage) { return function() { this.channel = new MessageChannel(); this.receiver = this.channel.port1; this.dispatcher = this.channel.port2; this.receiver.onmessage = onmessage; this.neutered = ...
javascript
{ "resource": "" }
q6746
_isHandshake
train
function _isHandshake(event) { return (event && event.data && "string" === typeof event.data && (0 === event.data.indexOf(TOKEN_PREFIX) || (HANSHAKE_PREFIX + this.token) === event.data)); }
javascript
{ "resource": "" }
q6747
_wrapReadyCallback
train
function _wrapReadyCallback(onready, target) { return function(err) { if (target && "function" === typeof target.callback) { target.callback.call(target.context, err, this.target); } if (onready) { if ("function" === typ...
javascript
{ "resource": "" }
q6748
_waitForBody
train
function _waitForBody(options) { options = options || {}; var onready = options.onready; var doc = options.doc || root.document; var delay = options.delay; function _ready() { if (doc.body) { onready(); } ...
javascript
{ "resource": "" }
q6749
_createIFrame
train
function _createIFrame(options, container) { var frame = document.createElement("IFRAME"); var name = PostMessageUtilities.createUniqueSequence(IFRAME_PREFIX + PostMessageUtilities.SEQUENCE_FORMAT); var delay = options.delayLoad; var defaultAttributes = { ...
javascript
{ "resource": "" }
q6750
_addLoadHandler
train
function _addLoadHandler(frame) { var load = function() { this.loading = false; if (this.handshakeAttempts === this.handshakeAttemptsOrig) { // Probably a first try for handshake or a reload of the iframe, // Either way, we'll need to ...
javascript
{ "resource": "" }
q6751
_setIFrameLocation
train
function _setIFrameLocation(frame, src, bust){ src += (0 < src.indexOf("?") ? "&" : "?"); if (bust) { src += "bust="; src += (new Date()).getTime() + "&"; } src += ((this.hostParam ? "hostParam=" + this.hostParam + "&" + this.hostParam + ...
javascript
{ "resource": "" }
q6752
Input
train
function Input(native) { EventEmitter.call(this); this.native = native; this.id = native.id; this.manufacturer = native.manufacturer; this.name = native.name; this.version = native.version; native.onmidimessage = function (event) { var data, type, object; data = new Buffer...
javascript
{ "resource": "" }
q6753
fetch
train
function fetch(identity, options, callback){ var completed = 0 combinedProfile = {}; // this is called once a page is fully parsed function whenFetched(err, data){ completed ++; // combines the api and microformats data into one profile if(data){ if(data.fn) {combi...
javascript
{ "resource": "" }
q6754
whenFetched
train
function whenFetched(err, data){ completed ++; // combines the api and microformats data into one profile if(data){ if(data.fn) {combinedProfile.fn = data.fn}; if(data.n) {combinedProfile.n = data.n}; if(data.nickname) {combinedProfile.nickname = data.nickname}; ...
javascript
{ "resource": "" }
q6755
appendUrls
train
function appendUrls(url, arr){ var i = arr.length, found = false; while (i--) { if(arr[i] === url){ found = true; break; } } if(!found) arr.push(url); }
javascript
{ "resource": "" }
q6756
getUFData
train
function getUFData(userName, identity, options, callback) { var url = 'http://lanyrd.com/people/' + userName, cache = options.cache, page = new Page(url, identity, null, options); page.fetchUrl(function(){ if(page.profile.hCards.length > 0){ page.profile.hCards[0].source = 'microformat'; ...
javascript
{ "resource": "" }
q6757
getAPIData
train
function getAPIData(userName, options, callback){ if(process.env.LANYRD_API_URL) { var url = process.env.LANYRD_API_URL + 'people/' + userName, cache = options.cache, startedRequest = new Date(), requestObj = { uri: url, headers: options.httpHeaders }; // if url is in the...
javascript
{ "resource": "" }
q6758
record
train
function record(options) { return new Promise((res, rej) => { var micInstance = mic({ rate: "16000", channels: "1", debug: true, exitOnSilence: 3, }); var micInputStream = micInstance.getAudioStream(); // Encode the file as Opus in an Ogg container, to send to server. var...
javascript
{ "resource": "" }
q6759
JsonSchemaLib
train
function JsonSchemaLib (config, plugins) { if (plugins === undefined && Array.isArray(config)) { plugins = config; config = undefined; } /** * The configuration for this instance of {@link JsonSchemaLib}. * * @type {Config} */ this.config = new Config(config); /** * The plugins that h...
javascript
{ "resource": "" }
q6760
_config
train
function _config(args) { var opts = {}; if(args.removeExtraneous){ opts.removeExtraneous = true; } if (args.bitbucketAuthUser || args.bitbucketAuthPass) { opts.bitbucket = { authUser: args.bitbucketAuthUser, authPass: args.bitbucketAuthPass }; } else if (args.githubUser || args.gith...
javascript
{ "resource": "" }
q6761
Event
train
function Event(props, defaults, delay) { var name; this.delay = delay || 0; props = props || {}; for (name in defaults) { if (defaults.hasOwnProperty(name)) { if (props.hasOwnProperty(name)) { this[name] = props[name]; } else { this[name]...
javascript
{ "resource": "" }
q6762
MetaEvent
train
function MetaEvent(type, props, delay) { var defaults = {}; switch (type) { case MetaEvent.TYPE.SEQUENCE_NUMBER: defaults.number = 0; break; case MetaEvent.TYPE.TEXT: case MetaEvent.TYPE.COPYRIGHT_NOTICE: case MetaEvent.TYPE.SEQUENCE_NAME: case MetaEvent.TYPE.INSTRUMENT_NAME...
javascript
{ "resource": "" }
q6763
SysexEvent
train
function SysexEvent(type, data, delay) { this.type = type; this.data = data; Event.call(this, {}, {}, delay); }
javascript
{ "resource": "" }
q6764
ChannelEvent
train
function ChannelEvent(type, props, channel, delay) { var defaults = {}; switch (type) { case ChannelEvent.TYPE.NOTE_OFF: defaults.note = 0; defaults.velocity = 127; break; case ChannelEvent.TYPE.NOTE_ON: defaults.note = 0; defaults.velocity = 127; break; ...
javascript
{ "resource": "" }
q6765
Jumio
train
function Jumio(config) { var _this = this; // setup configuration with defaults this.config = __assign({ version: "1.0.0", identityApiBaseUrl: exports.identityRegionApiUrlMap[config.region], documentApiBaseUrl: exports.documentRegionApiUrlMap[config.region], callbackWhitelist: exports.regionCall...
javascript
{ "resource": "" }
q6766
isTypedArray
train
function isTypedArray (obj) { if (typeof obj === 'object') { for (var i = 0; i < supportedDataTypes.length; i++) { if (obj instanceof supportedDataTypes[i]) { return true; } } } }
javascript
{ "resource": "" }
q6767
getSupportedDataTypes
train
function getSupportedDataTypes () { var types = []; // NOTE: More frequently-used types come first, to improve lookup speed if (typeof Uint8Array === 'function') { types.push(Uint8Array); } if (typeof Uint16Array === 'function') { types.push(Uint16Array); } if (typeof ArrayBuffer === 'function') ...
javascript
{ "resource": "" }
q6768
Bitbucket
train
function Bitbucket(user, pass) { this.user = user; this.client = bitbucket.createClient({ username: user, password: pass }); }
javascript
{ "resource": "" }
q6769
parseChunk
train
function parseChunk(expected, cursor) { var type, length; type = cursor.toString('ascii', 4); length = cursor.readUInt32BE(); if (type !== expected) { throw new error.MIDIParserError( type, expected, cursor.tell() ); } return cursor.slice(le...
javascript
{ "resource": "" }
q6770
unbind
train
function unbind(unbindObj) { if ("*" !== defaultAppName) { unbindObj.appName = unbindObj.appName || defaultAppName; } return evUtil.unbind({ unbindObj: unbindObj, attrName: attrName, loggerName: appName, ...
javascript
{ "resource": "" }
q6771
hasFired
train
function hasFired(app, evName) { if ("undefined" === typeof evName) { evName = app; app = defaultAppName; } return evUtil.hasFired(fired, app, evName); }
javascript
{ "resource": "" }
q6772
_storeEventData
train
function _storeEventData(triggerData) { evUtil.storeEventData({ triggerData: triggerData, eventBufferLimit: eventBufferLimit, attrName: attrName, fired: fired, index: indexer }); }
javascript
{ "resource": "" }
q6773
singleSource
train
function singleSource(graph, source) { if (!isGraph(graph)) throw new Error('graphology-shortest-path: invalid graphology instance.'); if (arguments.length < 2) throw new Error('graphology-shortest-path: invalid number of arguments. Expecting at least 2.'); if (!graph.hasNode(source)) throw new Erro...
javascript
{ "resource": "" }
q6774
resolveUrl
train
function resolveUrl (from, to) { if (typeof URL === 'function') { // Use the new WHATWG URL API return new URL(to, from).href; } else { // Use the legacy url API return legacyURL.resolve(from, to); } }
javascript
{ "resource": "" }
q6775
abstractDijkstraMultisource
train
function abstractDijkstraMultisource( graph, sources, weightAttribute, cutoff, target, paths ) { if (!isGraph(graph)) throw new Error('graphology-shortest-path/dijkstra: invalid graphology instance.'); if (target && !graph.hasNode(target)) throw new Error('graphology-shortest-path/dijkstra: th...
javascript
{ "resource": "" }
q6776
singleSourceDijkstra
train
function singleSourceDijkstra(graph, source, weightAttribute) { var paths = {}; abstractDijkstraMultisource( graph, [source], weightAttribute, 0, null, paths ); return paths; }
javascript
{ "resource": "" }
q6777
PluginHelper
train
function PluginHelper (plugins, schema) { validatePlugins(plugins); plugins = plugins || []; // Clone the array of plugins, and sort by priority var pluginHelper = plugins.slice().sort(sortByPriority); /** * Internal stuff. Use at your own risk! * * @private */ pluginHelper[__internal] = { ...
javascript
{ "resource": "" }
q6778
encodeChunk
train
function encodeChunk(type, data) { var cursor = new BufferCursor(new buffer.Buffer( buffer.Buffer.byteLength(type) + 4 + data.length )); cursor.write(type); cursor.writeUInt32BE(data.length); cursor.copy(data); return cursor.buffer; }
javascript
{ "resource": "" }
q6779
train
function( value ) { var lines = TLE.trim( value + '' ).split( /\r?\n/g ) var line, checksum // Line 0 if (lines.length === 3) { this.name = TLE.trim( lines.shift() ) } // Line 1 line = lines.shift() checksum = TLE.check( line ) if( checksum != line.substring( 68, 69 ) ) { ...
javascript
{ "resource": "" }
q6780
callSyncPlugin
train
function callSyncPlugin (pluginHelper, methodName, args) { var plugins = pluginHelper.filter(filterByMethod(methodName)); args.schema = pluginHelper[__internal].schema; args.config = args.schema.config; return callNextPlugin(plugins, methodName, args); }
javascript
{ "resource": "" }
q6781
load
train
function load(dirPath) { findFiles(dirPath, function(filePath){ collection.push( require(filePath) ); }) function findFiles(dirPath, callback){ fs.readdir(dirPath, function(err, files) { files.forEach(function(file){ fs.stat(dirPath + '/' + file, function(err, s...
javascript
{ "resource": "" }
q6782
add
train
function add(interface){ var i = arr.collection, found = false; while (i--) { if(interface.name === collection[i].name){ found = true; } } if(!found){ collection.push( interface ) }; }
javascript
{ "resource": "" }
q6783
parseTrack
train
function parseTrack(cursor) { var chunk, events = [], result, runningStatus = null; chunk = parseChunk('MTrk', cursor); while (!chunk.eof()) { result = parseEvent(chunk, runningStatus); runningStatus = result.runningStatus; events.push(result.event); } return new ...
javascript
{ "resource": "" }
q6784
train
function(request, options){ if(typeof options == "undefined") options = {}; // define options if not yet defined options.relative_path_root = relative_path_root; // overwrite user defined rel path root - TODO - make this a private property return require_function(request,...
javascript
{ "resource": "" }
q6785
stripBOM
train
function stripBOM (str) { var bom = str.charCodeAt(0); // Check for the UTF-16 byte order mark (0xFEFF or 0xFFFE) if (bom === 0xFEFF || bom === 0xFFFE) { return str.slice(1); } return str; }
javascript
{ "resource": "" }
q6786
parseFile
train
function parseFile (args) { var file = args.file; var next = args.next; try { // Optimistically try to parse the file as JSON. return JSON.parse(file.data); } catch (error) { if (isJsonFile(file)) { // This is a JSON file, but its contents are invalid throw error; ...
javascript
{ "resource": "" }
q6787
isJsonFile
train
function isJsonFile (file) { return file.data && // The file has data (typeof file.data === 'string') && // and it's a string ( mimeTypePattern.test(file.mimeType) || // and it has a JSON MIME type extensionPattern.test(file.url) // or at lea...
javascript
{ "resource": "" }
q6788
ExportRequiredTemplatesMiddleware
train
function ExportRequiredTemplatesMiddleware (context) { var options = context.options.requiredTemplates; var path = require ('path'); /** * Paths of the required templates. * @type {string[]} */ var paths = []; //---------------------------------------------------------------------------------------...
javascript
{ "resource": "" }
q6789
findFile
train
function findFile (schema, url) { if (schema.files.length === 0) { return null; } if (url instanceof File) { // Short-circuit behavior for File obejcts return findByURL(schema.files, url.url); } // Try to find an exact URL match var file = findByURL(schema.files, url); if (!file) { // R...
javascript
{ "resource": "" }
q6790
findByURL
train
function findByURL (files, url) { for (var i = 0; i < files.length; i++) { var file = files[i]; if (file.url === url) { return file; } } }
javascript
{ "resource": "" }
q6791
train
function (num) { for (var ext = '', i = 0; i < 4; i++) { ext = String.fromCharCode(num & 0xFF) + ext num >>= 8 } return ext }
javascript
{ "resource": "" }
q6792
train
function (str) { while (str.length < 4) str += ' ' for (var num = 0, i = 0; i < 4; i++) { num = (num << 8) + str.charCodeAt(i) } return num }
javascript
{ "resource": "" }
q6793
DRS
train
function DRS (file) { if (!(this instanceof DRS)) return new DRS(file) this.tables = [] this.isSWGB = null if (typeof file === 'undefined') { file = {} } if (typeof file === 'string') { if (typeof FsSource !== 'function') { throw new Error('Cannot instantiate with a string filename in the br...
javascript
{ "resource": "" }
q6794
ExportSourceCodePathsMiddleware
train
function ExportSourceCodePathsMiddleware (context) { var options = context.options.sourcePaths; /** * Paths of all the required files (excluding standalone scripts) in the correct loading order. * @type {string[]} */ var tracedPaths = []; //-------------------------------------------------------------...
javascript
{ "resource": "" }
q6795
Driver
train
function Driver(native) { var outputs = [], inputs = [], length, i; EventEmitter.call(this); this.native = native; length = native.outputs.size; for (i = 0; i < length; i += 1) { outputs[i] = new Output(native.outputs.get(i)); } length = native.inputs.size; for (i = 0; i < l...
javascript
{ "resource": "" }
q6796
Context
train
function Context (grunt, task, defaultOptions) { this.grunt = grunt; this.options = extend ({}, defaultOptions, task.options ()); switch (this.options.buildMode) { case 'release': this.options.debugBuild.enabled = false; this.options.releaseBuild.enabled = true; break; case 'debug': ...
javascript
{ "resource": "" }
q6797
train
function (eventName, handler) { if (!this._events[eventName]) this._events[eventName] = []; this._events[eventName].push (handler); }
javascript
{ "resource": "" }
q6798
train
function (eventName, args) { var e = this._events[eventName]; if (e) { args = args || []; e.forEach (function (handler) { handler.apply (this, args); }); } }
javascript
{ "resource": "" }
q6799
train
function () { /** @type {Object.<string, ModuleDef>} */ var modules = {}; ((typeof this.options.externalModules === 'string' ? [this.options.externalModules] : this.options.externalModules ) || []). concat (this.options.builtinModules). forEach (function (moduleName) { //...
javascript
{ "resource": "" }