1. /**
    
  2.  * Copyright (c) Meta Platforms, Inc. and affiliates.
    
  3.  *
    
  4.  * This source code is licensed under the MIT license found in the
    
  5.  * LICENSE file in the root directory of this source tree.
    
  6.  *
    
  7.  * @flow
    
  8.  */
    
  9. 
    
  10. export type StringDecoder = TextDecoder;
    
  11. 
    
  12. export function createStringDecoder(): StringDecoder {
    
  13.   return new TextDecoder();
    
  14. }
    
  15. 
    
  16. const decoderOptions = {stream: true};
    
  17. 
    
  18. export function readPartialStringChunk(
    
  19.   decoder: StringDecoder,
    
  20.   buffer: Uint8Array,
    
  21. ): string {
    
  22.   return decoder.decode(buffer, decoderOptions);
    
  23. }
    
  24. 
    
  25. export function readFinalStringChunk(
    
  26.   decoder: StringDecoder,
    
  27.   buffer: Uint8Array,
    
  28. ): string {
    
  29.   return decoder.decode(buffer);
    
  30. }