Options
All
  • Public
  • Public/Protected
  • All
Menu

Contains tools for encoding/decoding data in different circumstances.

Will automatically use native modules (via EncodeToolsNative) if they are installed.

Hierarchy

  • EncodeToolsAuto

Implements

Index

Constructors

constructor

  • example

    const enc = new EncodeToolsAuto({ hashAlgorithm: HashAlgorithm.xxhash3 }, { hashAlgorithm: HashAlgorithm.xxhash64 });

    Parameters

    • Optional nativeOptions: Partial<ConfiguredEncodingOptions>

      Options for the EncodeToolsNative constructor that will be used if the corresponding native module is available

    • Optional fallbackOptions: Partial<ConfiguredEncodingOptions>

      A set of fallback options to be used if the native module needed for the option in the first argument is missing

    Returns EncodeToolsAuto

Properties

Protected fallbackOptions

fallbackOptions: ConfiguredEncodingOptions

Protected native

Protected nativeOptions

options

Protected regular

regular: default

Accessors

availableNativeModules

convertableFormatMimeTypes

mimeTypesConvertableFormat

toPojoInstance

  • get toPojoInstance(): ToPojo<unknown, unknown>

Static WithDefaults

Methods

adjustImageBrightness

  • adjustImageBrightness(buffer: Buffer | ArrayBuffer, factor: number, format?: png): Promise<Buffer>
  • adjustImageBrightness(buffer: Buffer | ArrayBuffer, factor: number, format?: jpeg): Promise<Buffer>
  • adjustImageBrightness(buffer: BinaryInputOutput, factor: number, format?: ImageFormat): Promise<Buffer>
  • Adjust brightness of image

    Parameters

    • buffer: Buffer | ArrayBuffer

      Image

    • factor: number
    • Optional format: png

      Format to save result as

    Returns Promise<Buffer>

  • Adjust brightness of image

    Parameters

    • buffer: Buffer | ArrayBuffer

      Image

    • factor: number
    • Optional format: jpeg

      Format to save result as

    Returns Promise<Buffer>

  • Adjust brightness of image

    Parameters

    Returns Promise<Buffer>

compress

  • compress(data: Buffer | ArrayBuffer, format?: lzma, level?: number, ...args: any[]): Promise<Buffer>
  • compress(data: Buffer | ArrayBuffer, format?: zstd, level?: number, ...args: any[]): Promise<Buffer>
  • compress(data: BinaryInputOutput, format?: CompressionFormat, level?: number, ...args: any[]): Promise<Buffer>
  • Compresses arbitrary data using the provided format and any options

    Parameters

    • data: Buffer | ArrayBuffer

      Data to compress

    • Optional format: lzma

      Format to use

    • Optional level: number
    • Rest ...args: any[]

      Options

    Returns Promise<Buffer>

  • Compresses arbitrary data using the provided format and any options

    Parameters

    • data: Buffer | ArrayBuffer

      Data to compress

    • Optional format: zstd

      Format to use

    • Optional level: number
    • Rest ...args: any[]

      Options

    Returns Promise<Buffer>

  • Compresses arbitrary data using the provided format and any options

    Parameters

    Returns Promise<Buffer>

convertImage

  • convertImage(buffer: Buffer | ArrayBuffer, format?: png): Promise<Buffer>
  • convertImage(buffer: Buffer | ArrayBuffer, format?: jpeg): Promise<Buffer>
  • convertImage(data: BinaryInputOutput, format?: ImageFormat): Promise<Buffer>
  • Saves an image in the provided format, performing no operations on the image

    Parameters

    • buffer: Buffer | ArrayBuffer

      Image

    • Optional format: png

      Format to save result as

    Returns Promise<Buffer>

  • Saves an image in the provided format, performing no operations on the image

    Parameters

    • buffer: Buffer | ArrayBuffer

      Image

    • Optional format: jpeg

      Format to save result as

    Returns Promise<Buffer>

  • Saves an image in the provided format, performing no operations on the image

    Parameters

    Returns Promise<Buffer>

cropImage

  • Crops an image and returns a Buffer containing the result in the provided format

    Parameters

    • buffer: Buffer | ArrayBuffer

      Image

    • dims: CropDims

      Height/Width to resize to

    • Optional format: png

      Format to save result as

    Returns Promise<Buffer>

  • Crops an image and returns a Buffer containing the result in the provided format

    Parameters

    • buffer: Buffer | ArrayBuffer

      Image

    • dims: CropDims

      Height/Width to resize to

    • Optional format: jpeg

      Format to save result as

    Returns Promise<Buffer>

  • Crops an image and returns a Buffer containing the result in the provided format

    Parameters

    Returns Promise<Buffer>

decodeBuffer

  • decodeBuffer(buffer: ArrayBuffer, format?: arrayBuffer, ...args: any[]): Buffer
  • decodeBuffer(buffer: Buffer, format?: nodeBuffer, ...args: any[]): Buffer
  • decodeBuffer(input: string, format?: hex, ...args: any[]): Buffer
  • decodeBuffer(input: string, format?: base32, ...args: any[]): Buffer
  • decodeBuffer(input: string, format?: hashids, ...args: any[]): Buffer
  • decodeBuffer(input: string, format?: base64, ...args: any[]): Buffer
  • decodeBuffer(input: string, format?: base64url, ...args: any[]): Buffer
  • decodeBuffer(input: string, format?: ascii85, ...args: any[]): Buffer
  • decodeBuffer(input: string, format?: ascii85, ...args: any[]): Buffer
  • decodeBuffer(buffer: BinaryInputOutput, format?: BinaryEncoding, ...args: any[]): Buffer
  • Decodes binary data from the provided format returning either a node.js buffer.

    Parameters

    • buffer: ArrayBuffer
    • Optional format: arrayBuffer
    • Rest ...args: any[]

    Returns Buffer

  • Decodes binary data from the provided format returning either a node.js buffer.

    Parameters

    • buffer: Buffer
    • Optional format: nodeBuffer
    • Rest ...args: any[]

    Returns Buffer

  • Decodes binary data from the provided format returning either a node.js buffer.

    Parameters

    • input: string
    • Optional format: hex
    • Rest ...args: any[]

    Returns Buffer

  • Decodes binary data from the provided format returning either a node.js buffer.

    Parameters

    • input: string
    • Optional format: base32
    • Rest ...args: any[]

    Returns Buffer

  • Decodes binary data from the provided format returning either a node.js buffer.

    Parameters

    • input: string
    • Optional format: hashids
    • Rest ...args: any[]

    Returns Buffer

  • Decodes binary data from the provided format returning either a node.js buffer.

    Parameters

    • input: string
    • Optional format: base64
    • Rest ...args: any[]

    Returns Buffer

  • Decodes binary data from the provided format returning either a node.js buffer.

    Parameters

    • input: string
    • Optional format: base64url
    • Rest ...args: any[]

    Returns Buffer

  • Decodes binary data from the provided format returning either a node.js buffer.

    Parameters

    • input: string
    • Optional format: ascii85
    • Rest ...args: any[]

    Returns Buffer

  • Decodes binary data from the provided format returning either a node.js buffer.

    Parameters

    • input: string
    • Optional format: ascii85
    • Rest ...args: any[]

    Returns Buffer

  • Decodes binary data from the provided format returning either a node.js buffer.

    Parameters

    Returns Buffer

decodeObject

  • decodeObject<T>(buffer: Buffer, format?: nodeBuffer, ...args: any[]): T
  • decodeObject<T>(buffer: string, format?: base64, ...args: any[]): T
  • decodeObject<T>(buffer: string, format?: base64url, ...args: any[]): T
  • decodeObject<T>(buffer: string, format?: hex, ...args: any[]): T
  • decodeObject<T>(buffer: string, format?: base32, ...args: any[]): T
  • decodeObject<T>(buffer: string, format?: hashids, ...args: any[]): T
  • decodeObject<T>(buffer: ArrayBuffer, format?: arrayBuffer, ...args: any[]): T
  • decodeObject<T>(buffer: string, format?: ascii85, ...args: any[]): T
  • decodeObject<T>(buffer: string, format?: ascii85, ...args: any[]): T
  • decodeObject<T>(inputBuffer: BinaryInputOutput, format?: BinaryEncoding, ...args: any[]): T
  • Decodes binary data from the provided format returning either a node.js buffer.

    Type parameters

    • T

    Parameters

    • buffer: Buffer
    • Optional format: nodeBuffer
    • Rest ...args: any[]

    Returns T

  • Decodes binary data from the provided format returning either a node.js buffer.

    Type parameters

    • T

    Parameters

    • buffer: string
    • Optional format: base64
    • Rest ...args: any[]

    Returns T

  • Decodes binary data from the provided format returning either a node.js buffer.

    Type parameters

    • T

    Parameters

    • buffer: string
    • Optional format: base64url
    • Rest ...args: any[]

    Returns T

  • Decodes binary data from the provided format returning either a node.js buffer.

    Type parameters

    • T

    Parameters

    • buffer: string
    • Optional format: hex
    • Rest ...args: any[]

    Returns T

  • Decodes binary data from the provided format returning either a node.js buffer.

    Type parameters

    • T

    Parameters

    • buffer: string
    • Optional format: base32
    • Rest ...args: any[]

    Returns T

  • Decodes binary data from the provided format returning either a node.js buffer.

    Type parameters

    • T

    Parameters

    • buffer: string
    • Optional format: hashids
    • Rest ...args: any[]

    Returns T

  • Decodes binary data from the provided format returning either a node.js buffer.

    Type parameters

    • T

    Parameters

    • buffer: ArrayBuffer
    • Optional format: arrayBuffer
    • Rest ...args: any[]

    Returns T

  • Decodes binary data from the provided format returning either a node.js buffer.

    Type parameters

    • T

    Parameters

    • buffer: string
    • Optional format: ascii85
    • Rest ...args: any[]

    Returns T

  • Decodes binary data from the provided format returning either a node.js buffer.

    Type parameters

    • T

    Parameters

    • buffer: string
    • Optional format: ascii85
    • Rest ...args: any[]

    Returns T

  • Decodes binary data from the provided format returning either a node.js buffer.

    Type parameters

    • T

    Parameters

    Returns T

decompress

  • decompress(data: Buffer | ArrayBuffer, format: lzma, ...args: any[]): Promise<Buffer>
  • decompress(data: Buffer | ArrayBuffer, format: zstd, ...args: any[]): Promise<Buffer>
  • decompress(data: BinaryInputOutput, format: CompressionFormat, ...args: any[]): Promise<Buffer>
  • Decompresses arbitrary data using the provided format and any options

    Parameters

    • data: Buffer | ArrayBuffer

      Data to decompress

    • format: lzma

      Format to use

    • Rest ...args: any[]

    Returns Promise<Buffer>

  • Decompresses arbitrary data using the provided format and any options

    Parameters

    • data: Buffer | ArrayBuffer

      Data to decompress

    • format: zstd

      Format to use

    • Rest ...args: any[]

    Returns Promise<Buffer>

  • Decompresses arbitrary data using the provided format and any options

    Parameters

    Returns Promise<Buffer>

deserializeObject

  • deserializeObject<T>(data: string | Buffer | ArrayBuffer, serializationFormat?: json): T
  • deserializeObject<T>(data: string | Buffer | ArrayBuffer, serializationFormat?: json5): T
  • deserializeObject<T>(data: Buffer | ArrayBuffer, serializationFormat?: cbor): T
  • deserializeObject<T>(data: Buffer | ArrayBuffer, serializationFormat?: msgpack): T
  • deserializeObject<T>(data: Buffer | ArrayBuffer, serializationFormat?: bson): T
  • deserializeObject<T>(data: Buffer | ArrayBuffer, serializationFormat?: SerializationFormat): T
  • Deserializes an object serialized using one of the available algorithms, returning the result as an object

    Type parameters

    • T

    Parameters

    • data: string | Buffer | ArrayBuffer

      Data to deserialize

    • Optional serializationFormat: json

      Algorithm to deserialize with

    Returns T

  • Deserializes an object serialized using one of the available algorithms, returning the result as an object

    Type parameters

    • T

    Parameters

    • data: string | Buffer | ArrayBuffer

      Data to deserialize

    • Optional serializationFormat: json5

      Algorithm to deserialize with

    Returns T

  • Deserializes an object serialized using one of the available algorithms, returning the result as an object

    Type parameters

    • T

    Parameters

    • data: Buffer | ArrayBuffer

      Data to deserialize

    • Optional serializationFormat: cbor

      Algorithm to deserialize with

    Returns T

  • Deserializes an object serialized using one of the available algorithms, returning the result as an object

    Type parameters

    • T

    Parameters

    • data: Buffer | ArrayBuffer

      Data to deserialize

    • Optional serializationFormat: msgpack

      Algorithm to deserialize with

    Returns T

  • Deserializes an object serialized using one of the available algorithms, returning the result as an object

    Type parameters

    • T

    Parameters

    • data: Buffer | ArrayBuffer

      Data to deserialize

    • Optional serializationFormat: bson

      Algorithm to deserialize with

    Returns T

  • Deserializes an object serialized using one of the available algorithms, returning the result as an object

    Type parameters

    • T

    Parameters

    • data: Buffer | ArrayBuffer

      Data to deserialize

    • Optional serializationFormat: SerializationFormat

      Algorithm to deserialize with

    Returns T

encodeBuffer

  • encodeBuffer(inputBuffer: Buffer | ArrayBuffer, format?: nodeBuffer, ...args: any[]): Buffer
  • encodeBuffer(inputBuffer: Buffer | ArrayBuffer, format?: arrayBuffer, ...args: any[]): ArrayBuffer
  • encodeBuffer(inputBuffer: string | Buffer | ArrayBuffer, format?: hex, ...args: any[]): string
  • encodeBuffer(inputBuffer: string | Buffer | ArrayBuffer, format?: base64, ...args: any[]): string
  • encodeBuffer(inputBuffer: string | Buffer | ArrayBuffer, format?: base32, ...args: any[]): string
  • encodeBuffer(inputBuffer: string | Buffer | ArrayBuffer, format?: base64url, ...args: any[]): string
  • encodeBuffer(inputBuffer: string | Buffer | ArrayBuffer, format?: hashids, ...args: any[]): string
  • encodeBuffer(inputBuffer: string | Buffer | ArrayBuffer, format?: ascii85, ...args: any[]): string
  • encodeBuffer(inputBuffer: string | Buffer | ArrayBuffer, format?: ascii85, ...args: any[]): string
  • encodeBuffer(inputBuffer: BinaryInputOutput, format?: BinaryEncoding, ...args: any[]): BinaryInputOutput
  • Encodes binary data using the provided format returning either a node.js buffer, array buffer, or string

    Parameters

    • inputBuffer: Buffer | ArrayBuffer
    • Optional format: nodeBuffer
    • Rest ...args: any[]

    Returns Buffer

  • Encodes binary data using the provided format returning either a node.js buffer, array buffer, or string

    Parameters

    • inputBuffer: Buffer | ArrayBuffer
    • Optional format: arrayBuffer
    • Rest ...args: any[]

    Returns ArrayBuffer

  • Encodes binary data using the provided format returning either a node.js buffer, array buffer, or string

    Parameters

    • inputBuffer: string | Buffer | ArrayBuffer
    • Optional format: hex
    • Rest ...args: any[]

    Returns string

  • Encodes binary data using the provided format returning either a node.js buffer, array buffer, or string

    Parameters

    • inputBuffer: string | Buffer | ArrayBuffer
    • Optional format: base64
    • Rest ...args: any[]

    Returns string

  • Encodes binary data using the provided format returning either a node.js buffer, array buffer, or string

    Parameters

    • inputBuffer: string | Buffer | ArrayBuffer
    • Optional format: base32
    • Rest ...args: any[]

    Returns string

  • Encodes binary data using the provided format returning either a node.js buffer, array buffer, or string

    Parameters

    • inputBuffer: string | Buffer | ArrayBuffer
    • Optional format: base64url
    • Rest ...args: any[]

    Returns string

  • Encodes binary data using the provided format returning either a node.js buffer, array buffer, or string

    Parameters

    • inputBuffer: string | Buffer | ArrayBuffer
    • Optional format: hashids
    • Rest ...args: any[]

    Returns string

  • Encodes binary data using the provided format returning either a node.js buffer, array buffer, or string

    Parameters

    • inputBuffer: string | Buffer | ArrayBuffer
    • Optional format: ascii85
    • Rest ...args: any[]

    Returns string

  • Encodes binary data using the provided format returning either a node.js buffer, array buffer, or string

    Parameters

    • inputBuffer: string | Buffer | ArrayBuffer
    • Optional format: ascii85
    • Rest ...args: any[]

    Returns string

  • Encodes binary data using the provided format returning either a node.js buffer, array buffer, or string

    Parameters

    Returns BinaryInputOutput

encodeObject

  • encodeObject<T>(inputObject: T, format?: nodeBuffer, ...args: any[]): Buffer
  • encodeObject<T>(inputObject: T, format?: base64, ...args: any[]): string
  • encodeObject<T>(inputObject: T, format?: base64url, ...args: any[]): string
  • encodeObject<T>(inputObject: T, format?: hex, ...args: any[]): string
  • encodeObject<T>(inputObject: T, format?: base32, ...args: any[]): string
  • encodeObject<T>(inputObject: T, format?: hashids, ...args: any[]): string
  • encodeObject<T>(inputObject: T, format?: arrayBuffer, ...args: any[]): ArrayBuffer
  • encodeObject<T>(inputObject: T, format?: ascii85, ...args: any[]): string
  • encodeObject<T>(inputObject: T, format?: ascii85, ...args: any[]): string
  • encodeObject<T>(inputObject: T, format?: BinaryEncoding, ...args: any[]): BinaryInputOutput
  • Encodes binary data using the provided format returning either a node.js buffer, array buffer, or string

    Type parameters

    • T

    Parameters

    • inputObject: T
    • Optional format: nodeBuffer
    • Rest ...args: any[]

    Returns Buffer

  • Encodes binary data using the provided format returning either a node.js buffer, array buffer, or string

    Type parameters

    • T

    Parameters

    • inputObject: T
    • Optional format: base64
    • Rest ...args: any[]

    Returns string

  • Encodes binary data using the provided format returning either a node.js buffer, array buffer, or string

    Type parameters

    • T

    Parameters

    • inputObject: T
    • Optional format: base64url
    • Rest ...args: any[]

    Returns string

  • Encodes binary data using the provided format returning either a node.js buffer, array buffer, or string

    Type parameters

    • T

    Parameters

    • inputObject: T
    • Optional format: hex
    • Rest ...args: any[]

    Returns string

  • Encodes binary data using the provided format returning either a node.js buffer, array buffer, or string

    Type parameters

    • T

    Parameters

    • inputObject: T
    • Optional format: base32
    • Rest ...args: any[]

    Returns string

  • Encodes binary data using the provided format returning either a node.js buffer, array buffer, or string

    Type parameters

    • T

    Parameters

    • inputObject: T
    • Optional format: hashids
    • Rest ...args: any[]

    Returns string

  • Encodes binary data using the provided format returning either a node.js buffer, array buffer, or string

    Type parameters

    • T

    Parameters

    • inputObject: T
    • Optional format: arrayBuffer
    • Rest ...args: any[]

    Returns ArrayBuffer

  • Encodes binary data using the provided format returning either a node.js buffer, array buffer, or string

    Type parameters

    • T

    Parameters

    • inputObject: T
    • Optional format: ascii85
    • Rest ...args: any[]

    Returns string

  • Encodes binary data using the provided format returning either a node.js buffer, array buffer, or string

    Type parameters

    • T

    Parameters

    • inputObject: T
    • Optional format: ascii85
    • Rest ...args: any[]

    Returns string

  • Encodes binary data using the provided format returning either a node.js buffer, array buffer, or string

    Type parameters

    • T

    Parameters

    Returns BinaryInputOutput

hash

hashObject

  • hashObject(obj: any, algorithm?: HashAlgorithm, ...args: any[]): Promise<Buffer>

hashString

headerToConvertableFormat

headerToImageFormat

headerToSerializationFormat

resizeImage

  • resizeImage(buffer: Buffer | ArrayBuffer, dims: { height: number; width?: number } | { height?: number; width: number }, format?: png): Promise<Buffer>
  • resizeImage(buffer: Buffer | ArrayBuffer, dims: { height: number; width?: number } | { height?: number; width: number }, format?: jpeg): Promise<Buffer>
  • resizeImage(data: BinaryInputOutput, dims: { height: number; width?: number } | { height?: number; width: number }, format?: ImageFormat): Promise<Buffer>
  • Resizes an image and returns a Buffer containing the result in the provided format

    Parameters

    • buffer: Buffer | ArrayBuffer

      Image

    • dims: { height: number; width?: number } | { height?: number; width: number }

      Height/Width to resize to

    • Optional format: png

      Format to save result as

    Returns Promise<Buffer>

  • Resizes an image and returns a Buffer containing the result in the provided format

    Parameters

    • buffer: Buffer | ArrayBuffer

      Image

    • dims: { height: number; width?: number } | { height?: number; width: number }

      Height/Width to resize to

    • Optional format: jpeg

      Format to save result as

    Returns Promise<Buffer>

  • Resizes an image and returns a Buffer containing the result in the provided format

    Parameters

    • data: BinaryInputOutput

      Image

    • dims: { height: number; width?: number } | { height?: number; width: number }

      Height/Width to resize to

    • Optional format: ImageFormat

      Format to save result as

    Returns Promise<Buffer>

serializeObject

  • serializeObject<T>(obj: T, serializationFormat?: json, useToPojoBeforeSerializing?: boolean): string
  • serializeObject<T>(obj: T, serializationFormat?: json5, useToPojoBeforeSerializing?: boolean): string
  • serializeObject<T>(obj: T, serializationFormat?: cbor, useToPojoBeforeSerializing?: boolean): Buffer
  • serializeObject<T>(obj: T, serializationFormat?: msgpack, useToPojoBeforeSerializing?: boolean): Buffer
  • serializeObject<T>(obj: T, serializationFormat?: bson, useToPojoBeforeSerializing?: boolean): Buffer
  • serializeObject<T>(obj: T, serializationFormat?: SerializationFormat, useToPojoBeforeSerializing?: boolean): Buffer
  • Serializes an object using one of the available algorithms, returning the result as a Buffer or a string

    Type parameters

    • T

    Parameters

    • obj: T

      Object to serialize

    • Optional serializationFormat: json

      Algorithm to serialize with

    • Optional useToPojoBeforeSerializing: boolean

    Returns string

  • Serializes an object using one of the available algorithms, returning the result as a Buffer or a string

    Type parameters

    • T

    Parameters

    • obj: T

      Object to serialize

    • Optional serializationFormat: json5

      Algorithm to serialize with

    • Optional useToPojoBeforeSerializing: boolean

    Returns string

  • Serializes an object using one of the available algorithms, returning the result as a Buffer or a string

    Type parameters

    • T

    Parameters

    • obj: T

      Object to serialize

    • Optional serializationFormat: cbor

      Algorithm to serialize with

    • Optional useToPojoBeforeSerializing: boolean

    Returns Buffer

  • Serializes an object using one of the available algorithms, returning the result as a Buffer or a string

    Type parameters

    • T

    Parameters

    • obj: T

      Object to serialize

    • Optional serializationFormat: msgpack

      Algorithm to serialize with

    • Optional useToPojoBeforeSerializing: boolean

    Returns Buffer

  • Serializes an object using one of the available algorithms, returning the result as a Buffer or a string

    Type parameters

    • T

    Parameters

    • obj: T

      Object to serialize

    • Optional serializationFormat: bson

      Algorithm to serialize with

    • Optional useToPojoBeforeSerializing: boolean

    Returns Buffer

  • Serializes an object using one of the available algorithms, returning the result as a Buffer or a string

    Type parameters

    • T

    Parameters

    • obj: T

      Object to serialize

    • Optional serializationFormat: SerializationFormat

      Algorithm to serialize with

    • Optional useToPojoBeforeSerializing: boolean

    Returns Buffer

uniqueId

  • uniqueId(idFormat: uuidv4): Buffer
  • uniqueId(idFormat: uuidv1): Buffer
  • uniqueId(idFormat: uuidv4String): string
  • uniqueId(idFormat: uuidv1String): string
  • uniqueId(idFormat: objectId): Buffer
  • uniqueId(idFormat: nanoid, size?: number): string
  • uniqueId(idFormat: timestamp): number
  • uniqueId(idFormat?: IDFormat, ...args: any[]): string | number | Buffer
  • Generates a unique ID using one of the available algorithms, returning the result as a Buffer, string or number.

    Parameters

    • idFormat: uuidv4

      Algorithm to use to generate the unique id

    Returns Buffer

  • Generates a unique ID using one of the available algorithms, returning the result as a Buffer, string or number.

    Parameters

    • idFormat: uuidv1

      Algorithm to use to generate the unique id

    Returns Buffer

  • Generates a unique ID using one of the available algorithms, returning the result as a Buffer, string or number.

    Parameters

    • idFormat: uuidv4String

      Algorithm to use to generate the unique id

    Returns string

  • Generates a unique ID using one of the available algorithms, returning the result as a Buffer, string or number.

    Parameters

    • idFormat: uuidv1String

      Algorithm to use to generate the unique id

    Returns string

  • Generates a unique ID using one of the available algorithms, returning the result as a Buffer, string or number.

    Parameters

    • idFormat: objectId

      Algorithm to use to generate the unique id

    Returns Buffer

  • Generates a unique ID using one of the available algorithms, returning the result as a Buffer, string or number.

    Parameters

    • idFormat: nanoid

      Algorithm to use to generate the unique id

    • Optional size: number

    Returns string

  • Generates a unique ID using one of the available algorithms, returning the result as a Buffer, string or number.

    Parameters

    • idFormat: timestamp

      Algorithm to use to generate the unique id

    Returns number

  • Generates a unique ID using one of the available algorithms, returning the result as a Buffer, string or number.

    Parameters

    • Optional idFormat: IDFormat

      Algorithm to use to generate the unique id

    • Rest ...args: any[]

      Extra args to pass to the ID generation function

    Returns string | number | Buffer

Static create

Generated using TypeDoc