esbuild-gas-plugin
Version:
esbuild plugin for Google Apps Script.
37 lines (36 loc) • 1 kB
JavaScript
;
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
// This module is browser compatible.
Object.defineProperty(exports, "__esModule", { value: true });
exports.LimitedReader = void 0;
class LimitedReader {
constructor(reader, limit) {
Object.defineProperty(this, "reader", {
enumerable: true,
configurable: true,
writable: true,
value: reader
});
Object.defineProperty(this, "limit", {
enumerable: true,
configurable: true,
writable: true,
value: limit
});
}
async read(p) {
if (this.limit <= 0) {
return null;
}
if (p.length > this.limit) {
p = p.subarray(0, this.limit);
}
const n = await this.reader.read(p);
if (n == null) {
return null;
}
this.limit -= n;
return n;
}
}
exports.LimitedReader = LimitedReader;