/
githubmr
/
facebook-react-native
Обзор
Документация
Войти
/
githubmr
/
facebook-react-native
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
main
packages/react-native/src/private/webapis/xhr/events/ProgressEvent.js
52 строки
1 KB
Rubén Norte
Type event options as interface instead of objects (#49204)
11 фев 2025, 20:14
11 фев 2025, 20:14
3a8837d
Код
Авторство
О чём код?
/** * 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 strict * @format */ /** * This module implements the `ProgressEvent` interface from `XMLHttpRequest`. * See https://xhr.spec.whatwg.org/#interface-progressevent. */ // flowlint unsafe-getters-setters:off import type {EventInit} from '../../dom/events/Event'; import Event from '../../dom/events/Event'; export interface ProgressEventInit extends EventInit { +lengthComputable: boolean; +loaded: number; +total: number; } export default class ProgressEvent extends Event { _lengthComputable: boolean; _loaded: number; _total: number; constructor(type: string, options?: ?ProgressEventInit) { super(type, options); this._lengthComputable = Boolean(options?.lengthComputable); this._loaded = Number(options?.loaded) || 0; this._total = Number(options?.total) || 0; } get lengthComputable(): boolean { return this._lengthComputable; } get loaded(): number { return this._loaded; } get total(): number { return this._total; } }