Options
All
  • Public
  • Public/Protected
  • All
Menu

Package core

@smcloudstore/core

This package is an internal one used by SMCloudStore. Most users will not need to use the @smcloudstore/core package directly.

SMCloudStore is a lightweight Node.js module that offers a simple API to interact with the object storage services of multiple cloud providers. Please refer to the main package smcloudstore to learn more and for documentation.

Index

Type aliases

ListResults

ListResults: Array<ListItemObject | ListItemPrefix>

The listObjects method returns an array with a mix of objects of type ListItemObject and ListItemPrefix

Functions

IsReadableStream

  • IsReadableStream(val: any): boolean
  • Returns a boolean indicating whether a value is a Readable Stream

    Parameters

    • val: any

      Value to test

    Returns boolean

    Boolean indicating whether val is a Readable Stream

IsStream

  • IsStream(val: any): boolean
  • Returns a boolean indicating whether a value is a Stream

    Parameters

    • val: any

      Value to test

    Returns boolean

    Boolean indicating whether val is a Stream

ReadChunkFromStream

  • ReadChunkFromStream(stream: Readable, size: number, peek?: boolean): Promise<Buffer>
  • Reads a certain amount of bytes from the beginning of a Stream, returning a Buffer. The amount of data read might be smaller if the stream ends before it could return the amount of data requested.

    If the peek argument is true, the data is put back into the beginning of the stream, so it can be consumed by another function

    Note that this function will pause the stream, so you might need to call the resume method on it to make it flow again.

    If passing a stream that has already ended, the function could enter into an infinite loop and return a Promise that never resolves. It's your responsibility to ensure that streams passed to this function still have data to return.

    async

    Parameters

    • stream: Readable

      Readable Stream to read data from

    • size: number

      Amount of data to read

    • Optional peek: boolean

      If true, after reading the data it is added back to the beginning of the stream

    Returns Promise<Buffer>

    Promise that resolves to a Buffer with a length of at most size

StreamToBuffer

  • StreamToBuffer(stream: Stream): Promise<Buffer>
  • Returns a Buffer with data read from the stream.

    async

    Parameters

    • stream: Stream

      Stream to read data from

    Returns Promise<Buffer>

    Promise that resolves to a Buffer containing the data from the stream

StreamToString

  • StreamToString(stream: Stream, encoding?: string): Promise<string>
  • Returns a string with data read from the stream.

    async

    Parameters

    • stream: Stream

      Stream to read data from

    • Optional encoding: string

      String encoding to use; defaults to utf8

    Returns Promise<string>

    Promise that resolves to a string containing the data from the stream

WaitPromise

  • WaitPromise(delay: number): Promise<void>
  • Returns a Promise that resolves after a certain amlount of time (in ms)

    async

    Parameters

    • delay: number

      ms to wait

    Returns Promise<void>

    Promise that resolves after the delay

Generated using TypeDoc