Options
All
  • Public
  • Public/Protected
  • All
Menu

General utilities

Index

Functions

Const Throw

  • Throw(e: string | Error): never
  • like 'throw', but a function rather than a statement.

    Parameters

    • e: string | Error

      The exception or string to be thrown.

    Returns never

Const asFiles

  • A type checker that verifies the argument is a file array, not a directory tree. Throws an error if given something else

    Parameters

    • Optional t: Tree | Files

      A tree or a file array

    Returns null | Files

    A file array or null if the argument was undefined

Const asTree

  • A type checker that verifies the argument is a tree, not a file array. Throws an error if given something else.

    Parameters

    • Optional t: Tree | Files

      A tree or a file array

    Returns null | Tree

    Tree or null if the argument was undefined.

Const deleteVersion

  • Delete a specific version from a Files array. This is an internal tool for implementing FILE handlers

    Parameters

    • files: Files

      The Files array

    • version: Version

      The version to delete. Either a version number or a label. The special label '*' deletes all versions.

    Returns void

    void

dsv

  • dsv(data: string, delimiter: "\t" | ",", __namedParameters?: DataOptions): object[]
  • Parameters

    • data: string

      The data to be parsed

    • delimiter: "\t" | ","

      The field delimiter, either "\t" or ",".

    • __namedParameters: DataOptions = ...

    Returns object[]

Const encodeString16

  • encodeString16(s: string): ArrayBuffer
  • Encode a string into an ArrayBuffer.

    Parameters

    • s: string

      The string to be encoded

    Returns ArrayBuffer

    An ArrayBuffer with the string data as UTF-16

entry

  • entry(name: string, data: any, metadata?: Partial<Metadata> | null, ...versionList: Version[]): Tree
  • entry(name: string, data: any, ...versionList: Version[]): Tree
  • Convenience method to construct an entry in a AFileSystem tree, without having to specifiy the name multiple times. Takes a name and a data item, optional metadata, and list of versions, and constructs the appropriate Files array for the tree.

    Simplest usage:

    F = new AFileSystem({
      myFile: file('myFile', (myData));
    });
    
    Advanced usage that supplies a creation date as metadata, and gives the file
    a version of 1 and a label of 'tested';
    ```javascript
    F = new AFileSystem({
      ...entry('myFile', (myData), {creationDate}, 1, 'tested');
    });
    

    @param name The name of the file @param data The data to store @param metadata The metadata to associate with both array and file @param versionList A list of versions to store the file under, or [1]. @returns

    Parameters

    • name: string
    • data: any
    • Optional metadata: Partial<Metadata> | null
    • Rest ...versionList: Version[]

    Returns Tree

  • Parameters

    • name: string
    • data: any
    • Rest ...versionList: Version[]

    Returns Tree

file

  • file(name: string, data: any, metadata?: Partial<Metadata> | null, ...versionList: Version[]): Files
  • file(name: string, data: any, ...versionList: Version[]): Files
  • Convenience method to construct an entry in a AFileSystem tree. Takes a name and a data item, optional metadata, and list of versions, and constructs the appropriate Files array for the tree.

    Simplest usage:

    F = new AFileSystem({
      myFile: file('myFile', (myData));
    });
    
    Advanced usage that supplies a creation date as metadata, and gives the file
    a version of 1 and a label of 'tested';
    ```javascript
    F = new AFileSystem({
      myFile: file('myFile', (myData), {creationDate}, 1, 'tested');
    });
    

    @param name The name of the file @param data The data to store @param metadata The metadata to associate with both array and file @param versionList A list of versions to store the file under, or [1]. @returns

    Parameters

    • name: string
    • data: any
    • Optional metadata: Partial<Metadata> | null
    • Rest ...versionList: Version[]

    Returns Files

  • Parameters

    • name: string
    • data: any
    • Rest ...versionList: Version[]

    Returns Files

Const fromArrayBuffer

  • fromArrayBuffer(ab: ArrayBuffer, __namedParameters?: DataOptions): string
  • Convert an ArrayBuffer to a string.

    Parameters

    • ab: ArrayBuffer

      An ArrayBuffer

    • __namedParameters: DataOptions = ...

    Returns string

    the string

Const getVersion

  • Add a file at a specific version or label in a Files array. This is an internal tool for implementing FILE handlers.

    Parameters

    • files: Files

      The Files array

    • version: Version

      The version to delete. Either a version number or a label

    Returns null | VFile

    void

Const isFileAttachment

Const isFiles

  • A type guard to distinguish directory trees and file arrays.

    Parameters

    • Optional t: Tree | Files

      The object, which should be a directory tree or a files array

    Returns t is Files

    true if the argument is a Files array

Const isTree

  • A type guard to distinguish directory trees and file arrays.

    Parameters

    • Optional t: Tree | Files

      The object, which should be a directory tree or a files array

    Returns t is Tree

    true if the argument is a Tree

Const meta

  • meta<T>(obj: T, metadata: Metadata): any
  • Associate a metadata object with the specified file (or array of file versions). This is normally used to annotate entries in the AFileSystem tree.

    Type parameters

    • T

    Parameters

    Returns any

Const setVersion

  • Add a file at a specific version or label in a Files array. This is an internal tool for implementing FILE handlers.

    Parameters

    Returns void

    void

Const toArrayBuffer

  • toArrayBuffer(s: string, __namedParameters?: DataOptions): ArrayBufferLike
  • Convert a string to an ArrayBuffer, in either UTF8 or UTF16 formats.

    Parameters

    Returns ArrayBufferLike

    an ArrayBuffer with the string's content in the requested format.

Const versions

Generated using TypeDoc