Options
All
  • Public
  • Public/Protected
  • All
Menu

SlpFolderStream is responsible for monitoring a folder, and detecting when a new SLP file is created and is written to. This creates essentially a fake live-stream by reading the SLP file as it's still being written to.

Typically when you detect changes to a file that is still being written to, you want to include a timeout where if the file isn't changed within that timeout, you consider it "done" and stop checking it. However, since players can pause Slippi games for an indefinite amount of time, we don't want to timeout since the file might still continue to be written to. So to achieve this, we use the package tailstream where we have to manually call done() when we no longer anticipate the file to change.

Hierarchy

Implements

  • WritableStream

Index

Constructors

constructor

  • new SlpFolderStream(options?: Partial<SlpFileWriterOptions>, opts?: WritableOptions): SlpFolderStream

Properties

destroyed

destroyed: boolean

gameEnd$

gameEnd$: Observable<GameEndType> = fromEvent<GameEndType>(this.parser, SlpParserEvent.END).pipe(share())

gameStart$

gameStart$: Observable<GameStartType> = fromEvent<GameStartType>(this.parser, SlpParserEvent.SETTINGS).pipe(share())

messageSize$

messageSize$: Observable<Map<Command, number>> = this.messageSizeSource.asObservable()

Protected parser

parser: SlpParser = new SlpParser({ strict: true })

playerFrame$

playerFrame$: Observable<FrameEntryType> = fromEvent<FrameEntryType>(this.parser, SlpParserEvent.FINALIZED_FRAME).pipe(share())

writable

writable: boolean

writableEnded

writableEnded: boolean

writableFinished

writableFinished: boolean

writableHighWaterMark

writableHighWaterMark: number

writableLength

writableLength: number

writableObjectMode

writableObjectMode: boolean

Static defaultMaxListeners

defaultMaxListeners: number

Methods

_destroy

  • _destroy(error: Error | null, callback: (error?: Error | null) => void): void
  • Parameters

    • error: Error | null
    • callback: (error?: Error | null) => void
        • (error?: Error | null): void
        • Parameters

          • Optional error: Error | null

          Returns void

    Returns void

_final

  • _final(callback: (error?: Error | null) => void): void
  • Parameters

    • callback: (error?: Error | null) => void
        • (error?: Error | null): void
        • Parameters

          • Optional error: Error | null

          Returns void

    Returns void

_write

  • _write(newData: Buffer, encoding: string, callback: (error?: Error | null, data?: any) => void): void
  • Parameters

    • newData: Buffer
    • encoding: string
    • callback: (error?: Error | null, data?: any) => void
        • (error?: Error | null, data?: any): void
        • Parameters

          • Optional error: Error | null
          • Optional data: any

          Returns void

    Returns void

Optional _writev

  • _writev(chunks: Array<{ chunk: any; encoding: string }>, callback: (error?: Error | null) => void): void
  • Parameters

    • chunks: Array<{ chunk: any; encoding: string }>
    • callback: (error?: Error | null) => void
        • (error?: Error | null): void
        • Parameters

          • Optional error: Error | null

          Returns void

    Returns void

addListener

  • addListener(event: "close", listener: () => void): this
  • addListener(event: "drain", listener: () => void): this
  • addListener(event: "error", listener: (err: Error) => void): this
  • addListener(event: "finish", listener: () => void): this
  • addListener(event: "pipe", listener: (src: Readable) => void): this
  • addListener(event: "unpipe", listener: (src: Readable) => void): this
  • addListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Event emitter The defined events on documents including:

    1. close
    2. drain
    3. error
    4. finish
    5. pipe
    6. unpipe

    Parameters

    • event: "close"
    • listener: () => void
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "drain"
    • listener: () => void
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "error"
    • listener: (err: Error) => void
        • (err: Error): void
        • Parameters

          • err: Error

          Returns void

    Returns this

  • Parameters

    • event: "finish"
    • listener: () => void
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "pipe"
    • listener: (src: Readable) => void
        • (src: Readable): void
        • Parameters

          • src: Readable

          Returns void

    Returns this

  • Parameters

    • event: "unpipe"
    • listener: (src: Readable) => void
        • (src: Readable): void
        • Parameters

          • src: Readable

          Returns void

    Returns this

  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

cork

  • cork(): void
  • Returns void

destroy

  • destroy(error?: Error): void
  • Parameters

    • Optional error: Error

    Returns void

emit

  • emit(event: "close"): boolean
  • emit(event: "drain"): boolean
  • emit(event: "error", err: Error): boolean
  • emit(event: "finish"): boolean
  • emit(event: "pipe", src: Readable): boolean
  • emit(event: "unpipe", src: Readable): boolean
  • emit(event: string | symbol, ...args: any[]): boolean
  • Parameters

    • event: "close"

    Returns boolean

  • Parameters

    • event: "drain"

    Returns boolean

  • Parameters

    • event: "error"
    • err: Error

    Returns boolean

  • Parameters

    • event: "finish"

    Returns boolean

  • Parameters

    • event: "pipe"
    • src: Readable

    Returns boolean

  • Parameters

    • event: "unpipe"
    • src: Readable

    Returns boolean

  • Parameters

    • event: string | symbol
    • Rest ...args: any[]

    Returns boolean

end

  • end(cb?: () => void): void
  • end(chunk: any, cb?: () => void): void
  • end(chunk: any, encoding: string, cb?: () => void): void
  • Parameters

    • Optional cb: () => void
        • (): void
        • Returns void

    Returns void

  • Parameters

    • chunk: any
    • Optional cb: () => void
        • (): void
        • Returns void

    Returns void

  • Parameters

    • chunk: any
    • encoding: string
    • Optional cb: () => void
        • (): void
        • Returns void

    Returns void

endCurrentFile

  • endCurrentFile(): void
  • Ends the current file being written to.

    memberof

    SlpFileWriter

    Returns void

eventNames

  • eventNames(): Array<string | symbol>
  • Returns Array<string | symbol>

getCurrentFilename

  • getCurrentFilename(): string | null
  • Return the name of the SLP file currently being written or null if no file is being written to currently.

    memberof

    SlpFileWriter

    Returns string | null

getMaxListeners

  • getMaxListeners(): number

latestFile

  • latestFile(): string | null

listenerCount

  • listenerCount(type: string | symbol): number
  • Parameters

    • type: string | symbol

    Returns number

listeners

  • listeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

off

  • off(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

on

  • on(event: "close", listener: () => void): this
  • on(event: "drain", listener: () => void): this
  • on(event: "error", listener: (err: Error) => void): this
  • on(event: "finish", listener: () => void): this
  • on(event: "pipe", listener: (src: Readable) => void): this
  • on(event: "unpipe", listener: (src: Readable) => void): this
  • on(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: "close"
    • listener: () => void
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "drain"
    • listener: () => void
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "error"
    • listener: (err: Error) => void
        • (err: Error): void
        • Parameters

          • err: Error

          Returns void

    Returns this

  • Parameters

    • event: "finish"
    • listener: () => void
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "pipe"
    • listener: (src: Readable) => void
        • (src: Readable): void
        • Parameters

          • src: Readable

          Returns void

    Returns this

  • Parameters

    • event: "unpipe"
    • listener: (src: Readable) => void
        • (src: Readable): void
        • Parameters

          • src: Readable

          Returns void

    Returns this

  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

once

  • once(event: "close", listener: () => void): this
  • once(event: "drain", listener: () => void): this
  • once(event: "error", listener: (err: Error) => void): this
  • once(event: "finish", listener: () => void): this
  • once(event: "pipe", listener: (src: Readable) => void): this
  • once(event: "unpipe", listener: (src: Readable) => void): this
  • once(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: "close"
    • listener: () => void
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "drain"
    • listener: () => void
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "error"
    • listener: (err: Error) => void
        • (err: Error): void
        • Parameters

          • err: Error

          Returns void

    Returns this

  • Parameters

    • event: "finish"
    • listener: () => void
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "pipe"
    • listener: (src: Readable) => void
        • (src: Readable): void
        • Parameters

          • src: Readable

          Returns void

    Returns this

  • Parameters

    • event: "unpipe"
    • listener: (src: Readable) => void
        • (src: Readable): void
        • Parameters

          • src: Readable

          Returns void

    Returns this

  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

pipe

  • pipe<T>(destination: T, options?: { end?: boolean }): T
  • Type parameters

    • T: WritableStream

    Parameters

    • destination: T
    • Optional options: { end?: boolean }
      • Optional end?: boolean

    Returns T

prependListener

  • prependListener(event: "close", listener: () => void): this
  • prependListener(event: "drain", listener: () => void): this
  • prependListener(event: "error", listener: (err: Error) => void): this
  • prependListener(event: "finish", listener: () => void): this
  • prependListener(event: "pipe", listener: (src: Readable) => void): this
  • prependListener(event: "unpipe", listener: (src: Readable) => void): this
  • prependListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: "close"
    • listener: () => void
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "drain"
    • listener: () => void
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "error"
    • listener: (err: Error) => void
        • (err: Error): void
        • Parameters

          • err: Error

          Returns void

    Returns this

  • Parameters

    • event: "finish"
    • listener: () => void
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "pipe"
    • listener: (src: Readable) => void
        • (src: Readable): void
        • Parameters

          • src: Readable

          Returns void

    Returns this

  • Parameters

    • event: "unpipe"
    • listener: (src: Readable) => void
        • (src: Readable): void
        • Parameters

          • src: Readable

          Returns void

    Returns this

  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prependOnceListener

  • prependOnceListener(event: "close", listener: () => void): this
  • prependOnceListener(event: "drain", listener: () => void): this
  • prependOnceListener(event: "error", listener: (err: Error) => void): this
  • prependOnceListener(event: "finish", listener: () => void): this
  • prependOnceListener(event: "pipe", listener: (src: Readable) => void): this
  • prependOnceListener(event: "unpipe", listener: (src: Readable) => void): this
  • prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: "close"
    • listener: () => void
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "drain"
    • listener: () => void
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "error"
    • listener: (err: Error) => void
        • (err: Error): void
        • Parameters

          • err: Error

          Returns void

    Returns this

  • Parameters

    • event: "finish"
    • listener: () => void
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "pipe"
    • listener: (src: Readable) => void
        • (src: Readable): void
        • Parameters

          • src: Readable

          Returns void

    Returns this

  • Parameters

    • event: "unpipe"
    • listener: (src: Readable) => void
        • (src: Readable): void
        • Parameters

          • src: Readable

          Returns void

    Returns this

  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

rawListeners

  • rawListeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

removeAllListeners

  • removeAllListeners(event?: string | symbol): this
  • Parameters

    • Optional event: string | symbol

    Returns this

removeListener

  • removeListener(event: "close", listener: () => void): this
  • removeListener(event: "drain", listener: () => void): this
  • removeListener(event: "error", listener: (err: Error) => void): this
  • removeListener(event: "finish", listener: () => void): this
  • removeListener(event: "pipe", listener: (src: Readable) => void): this
  • removeListener(event: "unpipe", listener: (src: Readable) => void): this
  • removeListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: "close"
    • listener: () => void
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "drain"
    • listener: () => void
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "error"
    • listener: (err: Error) => void
        • (err: Error): void
        • Parameters

          • err: Error

          Returns void

    Returns this

  • Parameters

    • event: "finish"
    • listener: () => void
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "pipe"
    • listener: (src: Readable) => void
        • (src: Readable): void
        • Parameters

          • src: Readable

          Returns void

    Returns this

  • Parameters

    • event: "unpipe"
    • listener: (src: Readable) => void
        • (src: Readable): void
        • Parameters

          • src: Readable

          Returns void

    Returns this

  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

restart

  • restart(): void

setDefaultEncoding

  • setDefaultEncoding(encoding: string): this

setMaxListeners

  • setMaxListeners(n: number): this

start

  • start(slpFolder: string, includeSubfolders?: boolean): void
  • Starts watching a particular folder for slp files. It treats all new .slp files as though it's a live Slippi stream.

    memberof

    SlpFolderStream

    Parameters

    • slpFolder: string
    • Optional includeSubfolders: boolean

    Returns void

stop

  • stop(): void

uncork

  • uncork(): void
  • Returns void

updateSettings

  • updateSettings(settings: Partial<SlpFileWriterOptions>): void
  • Updates the settings to be the desired ones passed in.

    memberof

    SlpFileWriter

    Parameters

    • settings: Partial<SlpFileWriterOptions>

    Returns void

write

  • write(chunk: any, cb?: (error: Error | null | undefined) => void): boolean
  • write(chunk: any, encoding: string, cb?: (error: Error | null | undefined) => void): boolean
  • Parameters

    • chunk: any
    • Optional cb: (error: Error | null | undefined) => void
        • (error: Error | null | undefined): void
        • Parameters

          • error: Error | null | undefined

          Returns void

    Returns boolean

  • Parameters

    • chunk: any
    • encoding: string
    • Optional cb: (error: Error | null | undefined) => void
        • (error: Error | null | undefined): void
        • Parameters

          • error: Error | null | undefined

          Returns void

    Returns boolean

Static listenerCount

  • listenerCount(emitter: EventEmitter, event: string | symbol): number
  • deprecated

    since v4.0.0

    Parameters

    • emitter: EventEmitter
    • event: string | symbol

    Returns number

Generated using TypeDoc