Major changes in Flow 0.281: - $FlowFixMe comments now require explicit error codes (e.g., $FlowFixMe[incompatible-type]) - Changed all bare $FlowFixMe to include appropriate error codes - Changed $FlowIgnore to $FlowFixMe where needed - Fixed stream types to have cancel() return Promise<void> instead of void - Added pseudoElement property to KeyframeEffect type - Added suppressions for Proxy handler variance issues - Fixed various type errors across the codebase
33 lines
717 B
JavaScript
33 lines
717 B
JavaScript
/**
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @flow
|
|
*/
|
|
|
|
import {TextDecoder} from 'util';
|
|
|
|
export type StringDecoder = TextDecoder;
|
|
|
|
export function createStringDecoder(): StringDecoder {
|
|
return new TextDecoder();
|
|
}
|
|
|
|
const decoderOptions: {stream?: boolean, ...} = {stream: true};
|
|
|
|
export function readPartialStringChunk(
|
|
decoder: StringDecoder,
|
|
buffer: Uint8Array,
|
|
): string {
|
|
return decoder.decode(buffer, decoderOptions);
|
|
}
|
|
|
|
export function readFinalStringChunk(
|
|
decoder: StringDecoder,
|
|
buffer: Uint8Array,
|
|
): string {
|
|
return decoder.decode(buffer);
|
|
}
|