content-entry
Version:
content entries for content containers (aka files)
31 lines (26 loc) • 691 B
JavaScript
import { ContentEntry } from "./content-entry.mjs";
/**
* Content entries where a Async iterator is the primary data representation.
*/
export class IteratorContentEntry extends ContentEntry {
/**
* @return {number|Promise<number>} size in bytes
*/
get size() {
return Array.fromAsync(this.getSource())
.then(array => array.join(""))
.then(string => string.length);
}
get isEmpty() {
return this.size.then(size => size === 0);
}
/**
* @return {string|Promise<string>}
*/
get string() {
return Array.fromAsync(this.getSource()).then(array => array.join(""));
}
get stream() {
return ReadableStream.from(this.getSource());
}
}