@cere-ddc-sdk/ddc / 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
• get
isPart(): boolean
Checks if the piece is part of a multipart upload.
boolean
• get
size(): number
The size of the piece.
number
▸ from(piece
): Piece
Creates a new Piece
from an existing one.
Name | Type | Description |
---|---|---|
piece |
Piece |
The existing Piece to create a new one from. |
A new Piece
with the same content and metadata as the existing one.
▸ isPiece(object
): object is Piece
Checks if an object is an instance of Piece
.
Name | Type | Description |
---|---|---|
object |
unknown |
The object to check. |
object is Piece
true
if the object is an instance of Piece
or has the same properties as a Piece
, false
otherwise.
▸ isStaticPiece(object
): object is Piece
Checks if an object is an instance of Piece
with static content.
Name | Type | Description |
---|---|---|
object |
unknown |
The object to check. |
object is Piece
true
if the object is an instance of Piece
and its content is a Uint8Array
, false
otherwise.
• Readonly
body: ContentStream
The content of the piece as a stream.
• Readonly
meta: StaticPieceMeta
The metadata for the piece.
• Optional
offset: number
The offset of the piece in a multipart upload.