giantdb
Version:
Large object database in native JavaScript, with encryption support
37 lines (36 loc) • 1.03 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.MiddlewareTransformable = void 0;
/**
* Represents a triple (stream, metadata, metadataChanged) that can be updated
* with middleware results.
*/
class MiddlewareTransformable {
stream;
metadata;
metadataChanged;
constructor(stream, metadata) {
this.stream = stream;
this.metadata = metadata;
this.metadataChanged = false;
}
/**
* Update this object with the results from a middleware.
*
* If the results contain a reference to metadata, the metadataChanged
* attribute will be set to true.
*
* @param result The results.
*/
update(result) {
if (result == null) {
return;
}
this.stream = result.stream ?? this.stream;
if (result.metadata != null) {
this.metadata = result.metadata;
this.metadataChanged = true;
}
}
}
exports.MiddlewareTransformable = MiddlewareTransformable;