Skip to content

Latest commit

 

History

History
122 lines (66 loc) · 1.92 KB

File metadata and controls

122 lines (66 loc) · 1.92 KB

@cere-ddc-sdk/ddc / Piece

Class: Piece

The Piece class represents a piece of content.

Example

const content = new Uint8Array([1, 2, 3]);
const piece = new Piece(content, { size: 3 });

console.log(Piece.isPiece(piece)); // true

Accessors

isPart

get isPart(): boolean

Checks if the piece is part of a multipart upload.

Returns

boolean


size

get size(): number

The size of the piece.

Returns

number

Methods

from

from(piece): Piece

Creates a new Piece from an existing one.

Parameters

Name Type Description
piece Piece The existing Piece to create a new one from.

Returns

Piece

A new Piece with the same content and metadata as the existing one.


isPiece

isPiece(object): object is Piece

Checks if an object is an instance of Piece.

Parameters

Name Type Description
object unknown The object to check.

Returns

object is Piece

true if the object is an instance of Piece or has the same properties as a Piece, false otherwise.


isStaticPiece

isStaticPiece(object): object is Piece

Checks if an object is an instance of Piece with static content.

Parameters

Name Type Description
object unknown The object to check.

Returns

object is Piece

true if the object is an instance of Piece and its content is a Uint8Array, false otherwise.

Properties

body

Readonly body: ContentStream

The content of the piece as a stream.


meta

Readonly meta: StaticPieceMeta

The metadata for the piece.


offset

Optional offset: number

The offset of the piece in a multipart upload.