MCPcopy
hub / github.com/ThatGuySam/doesitarm / readFile

Method readFile

helpers/scanner/file-api.ts:315–336  ·  view source on GitHub ↗
( file: NodeFile, format: ReadFormat, encoding?: BufferEncoding )

Source from the content-addressed store, hash-verified

313 }
314
315 private readFile ( file: NodeFile, format: ReadFormat, encoding?: BufferEncoding ) {
316 this.file = file
317 this.format = format
318 this.encoding = encoding
319
320 if ( !this.file || !this.file.name || !( this.file.path || this.file.stream || this.file.buffer ) ) {
321 throw new Error( `cannot read as File: ${ JSON.stringify( this.file ).slice( 0, 1000 ) }` )
322 }
323
324 if ( this.readyState !== this.EMPTY ) {
325 console.log( 'already loading, request to change format ignored' )
326 return
327 }
328
329 process.nextTick( () => {
330 this.readyState = this.LOADING
331 this.dispatchEvent( 'loadstart' )
332 this.createFileStream()
333 this.mapStreamToEmitter()
334 this.registerUserEvents()
335 } )
336 }
337}

Callers 11

readAsArrayBufferMethod · 0.95
readAsBinaryStringMethod · 0.95
readAsDataURLMethod · 0.95
readAsTextMethod · 0.95
build-app-list.jsFile · 0.80
loadGamesSnapshotFunction · 0.80
getNetlifyConfigFunction · 0.80
handlers.jsFile · 0.80
index.test.jsFile · 0.80

Calls 4

dispatchEventMethod · 0.95
createFileStreamMethod · 0.95
mapStreamToEmitterMethod · 0.95
registerUserEventsMethod · 0.95

Tested by

no test coverage detected