mirror of
https://github.com/yume-chan/ya-webadb.git
synced 2025-10-04 18:29:23 +02:00
refactor(struct): replace bluebird with native Promise
This commit is contained in:
parent
1ee03486a6
commit
7d5445aeae
8 changed files with 1357 additions and 1336 deletions
|
@ -2,7 +2,7 @@
|
|||
|
||||
import type { StructAsyncDeserializeStream, StructDeserializeStream, StructFieldDefinition, StructFieldValue, StructOptions } from './basic/index.js';
|
||||
import { StructDefaultOptions, StructValue } from './basic/index.js';
|
||||
import { Syncbird } from "./syncbird.js";
|
||||
import { SyncPromise } from "./sync-promise.js";
|
||||
import { BigIntFieldDefinition, BigIntFieldType, BufferFieldSubType, FixedLengthBufferLikeFieldDefinition, NumberFieldDefinition, NumberFieldType, StringBufferFieldSubType, Uint8ArrayBufferFieldSubType, VariableLengthBufferLikeFieldDefinition, type FixedLengthBufferLikeFieldOptions, type LengthField, type VariableLengthBufferLikeFieldOptions } from './types/index.js';
|
||||
import type { Evaluate, Identity, Overwrite, ValueOrPromise } from "./utils.js";
|
||||
|
||||
|
@ -545,13 +545,15 @@ export class Struct<
|
|||
const value = new StructValue();
|
||||
Object.defineProperties(value.value, this._extra);
|
||||
|
||||
return Syncbird
|
||||
return SyncPromise
|
||||
.each(this._fields, ([name, definition]) => {
|
||||
return Syncbird.resolve(
|
||||
definition.deserialize(this.options, stream as any, value)
|
||||
).then(fieldValue => {
|
||||
value.set(name, fieldValue);
|
||||
});
|
||||
return SyncPromise
|
||||
.try(() => {
|
||||
return definition.deserialize(this.options, stream as any, value);
|
||||
})
|
||||
.then(fieldValue => {
|
||||
value.set(name, fieldValue);
|
||||
});
|
||||
})
|
||||
.then(() => {
|
||||
const object = value.value;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue