UNPKG

@fastly/esi

Version:

ESI implementation for JavaScript, using the modern fetch and streaming APIs.

22 lines (21 loc) 573 B
/* * Copyright Fastly, Inc. * Licensed under the MIT license. See LICENSE file for details. */ export default class StreamerState { bufferedString; postponedString = undefined; constructor(initialValue) { this.bufferedString = initialValue ?? ''; } applyPostponedXmlString() { if (this.postponedString != null) { this.bufferedString += this.postponedString; this.postponedString = undefined; } } append(str) { this.applyPostponedXmlString(); this.bufferedString += str; } }