protobufjs 8.1.6-experimental → 8.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +219 -565
- package/dist/light/protobuf.js +1986 -1483
- package/dist/light/protobuf.js.map +1 -1
- package/dist/light/protobuf.min.js +3 -3
- package/dist/light/protobuf.min.js.map +1 -1
- package/dist/minimal/protobuf.js +1122 -861
- package/dist/minimal/protobuf.js.map +1 -1
- package/dist/minimal/protobuf.min.js +3 -3
- package/dist/minimal/protobuf.min.js.map +1 -1
- package/dist/protobuf.js +2089 -1513
- package/dist/protobuf.js.map +1 -1
- package/dist/protobuf.min.js +3 -3
- package/dist/protobuf.min.js.map +1 -1
- package/ext/README.md +81 -0
- package/ext/descriptor/README.md +3 -70
- package/ext/descriptor/index.d.ts +1 -191
- package/ext/descriptor/index.js +1 -1161
- package/ext/descriptor.d.ts +309 -0
- package/ext/descriptor.js +1236 -0
- package/ext/textformat.d.ts +30 -0
- package/ext/textformat.js +1249 -0
- package/google/protobuf/compiler/plugin.json +126 -0
- package/google/protobuf/compiler/plugin.proto +47 -0
- package/google/protobuf/descriptor.json +2 -2
- package/google/protobuf/descriptor.proto +2 -1
- package/index.d.ts +590 -476
- package/package.json +23 -38
- package/src/converter.js +60 -24
- package/src/decoder.js +122 -49
- package/src/encoder.js +10 -2
- package/src/enum.js +4 -1
- package/src/field.js +10 -7
- package/src/mapfield.js +1 -0
- package/src/message.js +7 -6
- package/src/method.js +4 -3
- package/src/namespace.js +23 -12
- package/src/object.js +24 -19
- package/src/oneof.js +2 -0
- package/src/parse.js +114 -46
- package/src/reader.js +145 -30
- package/src/reader_buffer.js +24 -3
- package/src/root.js +7 -4
- package/src/service.js +12 -6
- package/src/tokenize.js +6 -1
- package/src/type.js +48 -25
- package/src/types.js +1 -1
- package/src/util/aspromise.d.ts +13 -0
- package/src/util/aspromise.js +52 -0
- package/src/util/base64.d.ts +32 -0
- package/src/util/base64.js +146 -0
- package/src/util/codegen.d.ts +31 -0
- package/src/util/codegen.js +113 -0
- package/src/util/eventemitter.d.ts +45 -0
- package/src/util/eventemitter.js +84 -0
- package/src/util/fetch.d.ts +56 -0
- package/src/util/fetch.js +112 -0
- package/src/util/float.d.ts +83 -0
- package/src/util/float.js +335 -0
- package/src/util/fs.js +11 -0
- package/src/util/inquire.d.ts +10 -0
- package/src/util/inquire.js +38 -0
- package/src/util/minimal.js +67 -12
- package/src/util/path.d.ts +22 -0
- package/src/util/path.js +72 -0
- package/src/util/patterns.js +8 -0
- package/src/util/pool.d.ts +32 -0
- package/src/util/pool.js +48 -0
- package/src/util/utf8.d.ts +24 -0
- package/src/util/utf8.js +104 -0
- package/src/util.js +30 -13
- package/src/verifier.js +7 -4
- package/src/wrappers.js +4 -3
- package/src/writer.js +27 -4
- package/src/writer_buffer.js +12 -0
- package/tsconfig.json +2 -2
- package/ext/descriptor/test.js +0 -54
package/index.d.ts
CHANGED
|
@@ -261,6 +261,16 @@ export class Field extends FieldBase {
|
|
|
261
261
|
*/
|
|
262
262
|
constructor(name: string, id: number, type: string, rule?: (string|{ [k: string]: any }), extend?: (string|{ [k: string]: any }), options?: { [k: string]: any });
|
|
263
263
|
|
|
264
|
+
/**
|
|
265
|
+
* Field decorator (TypeScript).
|
|
266
|
+
* @param fieldId Field id
|
|
267
|
+
* @param fieldType Field type
|
|
268
|
+
* @param [fieldRule="optional"] Field rule
|
|
269
|
+
* @returns Decorator function
|
|
270
|
+
* @deprecated Legacy TypeScript decorator support. Will be removed in a future release.
|
|
271
|
+
*/
|
|
272
|
+
public static d<T extends Message<T>>(fieldId: number, fieldType: (Constructor<T>|string), fieldRule?: ("optional"|"required"|"repeated")): FieldDecorator;
|
|
273
|
+
|
|
264
274
|
/**
|
|
265
275
|
* Constructs a field from a field descriptor.
|
|
266
276
|
* @param name Field name
|
|
@@ -295,17 +305,9 @@ export class Field extends FieldBase {
|
|
|
295
305
|
* @param [fieldRule="optional"] Field rule
|
|
296
306
|
* @param [defaultValue] Default value
|
|
297
307
|
* @returns Decorator function
|
|
308
|
+
* @deprecated Legacy TypeScript decorator support. Will be removed in a future release.
|
|
298
309
|
*/
|
|
299
310
|
public static d<T extends number | number[] | Long | Long[] | string | string[] | boolean | boolean[] | Uint8Array | Uint8Array[] | Buffer | Buffer[]>(fieldId: number, fieldType: ("double"|"float"|"int32"|"uint32"|"sint32"|"fixed32"|"sfixed32"|"int64"|"uint64"|"sint64"|"fixed64"|"sfixed64"|"string"|"bool"|"bytes"|object), fieldRule?: ("optional"|"required"|"repeated"), defaultValue?: T): FieldDecorator;
|
|
300
|
-
|
|
301
|
-
/**
|
|
302
|
-
* Field decorator (TypeScript).
|
|
303
|
-
* @param fieldId Field id
|
|
304
|
-
* @param fieldType Field type
|
|
305
|
-
* @param [fieldRule="optional"] Field rule
|
|
306
|
-
* @returns Decorator function
|
|
307
|
-
*/
|
|
308
|
-
public static d<T extends Message<T>>(fieldId: number, fieldType: (Constructor<T>|string), fieldRule?: ("optional"|"required"|"repeated")): FieldDecorator;
|
|
309
311
|
}
|
|
310
312
|
|
|
311
313
|
/** Base class of all reflected message fields. This is not an actual class but here for the sake of having consistent type definitions. */
|
|
@@ -418,6 +420,7 @@ export interface IExtensionField extends IField {
|
|
|
418
420
|
* Decorator function as returned by {@link Field.d} and {@link MapField.d} (TypeScript).
|
|
419
421
|
* @param prototype Target prototype
|
|
420
422
|
* @param fieldName Field name
|
|
423
|
+
* @deprecated Legacy TypeScript decorator support. Will be removed in a future release.
|
|
421
424
|
*/
|
|
422
425
|
type FieldDecorator = (prototype: object, fieldName: string) => void;
|
|
423
426
|
|
|
@@ -512,6 +515,7 @@ export class MapField extends FieldBase {
|
|
|
512
515
|
* @param fieldKeyType Field key type
|
|
513
516
|
* @param fieldValueType Field value type
|
|
514
517
|
* @returns Decorator function
|
|
518
|
+
* @deprecated Legacy TypeScript decorator support. Will be removed in a future release.
|
|
515
519
|
*/
|
|
516
520
|
public static d<T extends { [key: string]: number | Long | string | boolean | Uint8Array | Buffer | number[] | Message<{}> }>(fieldId: number, fieldKeyType: ("int32"|"uint32"|"sint32"|"fixed32"|"sfixed32"|"int64"|"uint64"|"sint64"|"fixed64"|"sfixed64"|"bool"|"string"), fieldValueType: ("double"|"float"|"int32"|"uint32"|"sint32"|"fixed32"|"sfixed32"|"int64"|"uint64"|"sint64"|"fixed64"|"sfixed64"|"bool"|"string"|"bytes"|object|Constructor<{}>)): FieldDecorator;
|
|
517
521
|
}
|
|
@@ -539,6 +543,9 @@ export class Message<T extends object = object> {
|
|
|
539
543
|
*/
|
|
540
544
|
constructor(properties?: Properties<T>);
|
|
541
545
|
|
|
546
|
+
/** Unknown fields preserved while decoding */
|
|
547
|
+
public $unknowns?: Uint8Array[];
|
|
548
|
+
|
|
542
549
|
/** Reference to the reflected type. */
|
|
543
550
|
public static readonly $type: Type;
|
|
544
551
|
|
|
@@ -624,9 +631,9 @@ export class Method extends ReflectionObject {
|
|
|
624
631
|
* @param [responseStream] Whether the response is streamed
|
|
625
632
|
* @param [options] Declared options
|
|
626
633
|
* @param [comment] The comment for this method
|
|
627
|
-
* @param [parsedOptions] Declared options, properly parsed into
|
|
634
|
+
* @param [parsedOptions] Declared options, properly parsed into objects
|
|
628
635
|
*/
|
|
629
|
-
constructor(name: string, type: (string|undefined), requestType: string, responseType: string, requestStream?: (boolean|{ [k: string]: any }), responseStream?: (boolean|{ [k: string]: any }), options?: { [k: string]: any }, comment?: string, parsedOptions?: { [k: string]: any });
|
|
636
|
+
constructor(name: string, type: (string|undefined), requestType: string, responseType: string, requestStream?: (boolean|{ [k: string]: any }), responseStream?: (boolean|{ [k: string]: any }), options?: { [k: string]: any }, comment?: string, parsedOptions?: { [k: string]: any }[]);
|
|
630
637
|
|
|
631
638
|
/** Method type. */
|
|
632
639
|
public type: string;
|
|
@@ -652,8 +659,8 @@ export class Method extends ReflectionObject {
|
|
|
652
659
|
/** Comment for this method */
|
|
653
660
|
public comment: (string|null);
|
|
654
661
|
|
|
655
|
-
/** Options properly parsed into
|
|
656
|
-
public parsedOptions: any;
|
|
662
|
+
/** Options properly parsed into objects */
|
|
663
|
+
public parsedOptions?: { [k: string]: any }[];
|
|
657
664
|
|
|
658
665
|
/**
|
|
659
666
|
* Constructs a method from a method descriptor.
|
|
@@ -696,8 +703,8 @@ export interface IMethod {
|
|
|
696
703
|
/** Method comments */
|
|
697
704
|
comment: string;
|
|
698
705
|
|
|
699
|
-
/** Method options properly parsed into
|
|
700
|
-
parsedOptions?: { [k: string]: any };
|
|
706
|
+
/** Method options properly parsed into objects */
|
|
707
|
+
parsedOptions?: { [k: string]: any }[];
|
|
701
708
|
}
|
|
702
709
|
|
|
703
710
|
/** Reflected namespace. */
|
|
@@ -714,10 +721,11 @@ export class Namespace extends NamespaceBase {
|
|
|
714
721
|
* Constructs a namespace from JSON.
|
|
715
722
|
* @param name Namespace name
|
|
716
723
|
* @param json JSON object
|
|
724
|
+
* @param [depth] Current nesting depth, defaults to `0`
|
|
717
725
|
* @returns Created namespace
|
|
718
726
|
* @throws {TypeError} If arguments are invalid
|
|
719
727
|
*/
|
|
720
|
-
public static fromJSON(name: string, json: { [k: string]: any }): Namespace;
|
|
728
|
+
public static fromJSON(name: string, json: { [k: string]: any }, depth?: number): Namespace;
|
|
721
729
|
|
|
722
730
|
/**
|
|
723
731
|
* Converts an array of reflection objects to JSON.
|
|
@@ -769,9 +777,10 @@ export abstract class NamespaceBase extends ReflectionObject {
|
|
|
769
777
|
/**
|
|
770
778
|
* Adds nested objects to this namespace from nested object descriptors.
|
|
771
779
|
* @param nestedJson Any nested object descriptors
|
|
780
|
+
* @param [depth] Current nesting depth, defaults to `0`
|
|
772
781
|
* @returns `this`
|
|
773
782
|
*/
|
|
774
|
-
public addJSON(nestedJson: { [k: string]: AnyNestedObject }): Namespace;
|
|
783
|
+
public addJSON(nestedJson: { [k: string]: AnyNestedObject }, depth?: number): Namespace;
|
|
775
784
|
|
|
776
785
|
/**
|
|
777
786
|
* Gets the nested object of the specified name.
|
|
@@ -898,7 +907,7 @@ export abstract class ReflectionObject {
|
|
|
898
907
|
public options?: { [k: string]: any };
|
|
899
908
|
|
|
900
909
|
/** Parsed Options. */
|
|
901
|
-
public parsedOptions?: { [k: string]: any[]
|
|
910
|
+
public parsedOptions?: { [k: string]: any }[];
|
|
902
911
|
|
|
903
912
|
/** Unique name within its namespace. */
|
|
904
913
|
public name: string;
|
|
@@ -1074,6 +1083,7 @@ export class OneOf extends ReflectionObject {
|
|
|
1074
1083
|
* OneOf decorator (TypeScript).
|
|
1075
1084
|
* @param fieldNames Field names
|
|
1076
1085
|
* @returns Decorator function
|
|
1086
|
+
* @deprecated Legacy TypeScript decorator support. Will be removed in a future release.
|
|
1077
1087
|
*/
|
|
1078
1088
|
public static d<T extends string>(...fieldNames: string[]): OneOfDecorator;
|
|
1079
1089
|
}
|
|
@@ -1092,6 +1102,7 @@ export interface IOneOf {
|
|
|
1092
1102
|
* Decorator function as returned by {@link OneOf.d} (TypeScript).
|
|
1093
1103
|
* @param prototype Target prototype
|
|
1094
1104
|
* @param oneofName OneOf name
|
|
1105
|
+
* @deprecated Legacy TypeScript decorator support. Will be removed in a future release.
|
|
1095
1106
|
*/
|
|
1096
1107
|
type OneOfDecorator = (prototype: object, oneofName: string) => void;
|
|
1097
1108
|
|
|
@@ -1174,12 +1185,26 @@ export class Reader {
|
|
|
1174
1185
|
*/
|
|
1175
1186
|
public static create(buffer: (Uint8Array|Buffer)): (Reader|BufferReader);
|
|
1176
1187
|
|
|
1188
|
+
/**
|
|
1189
|
+
* Returns raw bytes from the backing buffer without advancing the reader.
|
|
1190
|
+
* @param start Start offset
|
|
1191
|
+
* @param end End offset
|
|
1192
|
+
* @returns Raw bytes
|
|
1193
|
+
*/
|
|
1194
|
+
public raw(start: number, end: number): Uint8Array;
|
|
1195
|
+
|
|
1177
1196
|
/**
|
|
1178
1197
|
* Reads a varint as an unsigned 32 bit value.
|
|
1179
1198
|
* @returns Value read
|
|
1180
1199
|
*/
|
|
1181
1200
|
public uint32(): number;
|
|
1182
1201
|
|
|
1202
|
+
/**
|
|
1203
|
+
* Reads a field tag.
|
|
1204
|
+
* @returns Tag read
|
|
1205
|
+
*/
|
|
1206
|
+
public tag(): number;
|
|
1207
|
+
|
|
1183
1208
|
/**
|
|
1184
1209
|
* Reads a varint as a signed 32 bit value.
|
|
1185
1210
|
* @returns Value read
|
|
@@ -1271,12 +1296,17 @@ export class Reader {
|
|
|
1271
1296
|
*/
|
|
1272
1297
|
public skip(length?: number): Reader;
|
|
1273
1298
|
|
|
1299
|
+
/** Recursion limit. */
|
|
1300
|
+
public static recursionLimit: number;
|
|
1301
|
+
|
|
1274
1302
|
/**
|
|
1275
1303
|
* Skips the next element of the specified wire type.
|
|
1276
1304
|
* @param wireType Wire type received
|
|
1305
|
+
* @param [depth] Depth of recursion to control nested calls; 0 if omitted
|
|
1306
|
+
* @param [fieldNumber] Field number for validating group end tags
|
|
1277
1307
|
* @returns `this`
|
|
1278
1308
|
*/
|
|
1279
|
-
public skipType(wireType: number): Reader;
|
|
1309
|
+
public skipType(wireType: number, depth?: number, fieldNumber?: number): Reader;
|
|
1280
1310
|
}
|
|
1281
1311
|
|
|
1282
1312
|
/** Wire format reader using node buffers. */
|
|
@@ -1288,6 +1318,14 @@ export class BufferReader extends Reader {
|
|
|
1288
1318
|
*/
|
|
1289
1319
|
constructor(buffer: Buffer);
|
|
1290
1320
|
|
|
1321
|
+
/**
|
|
1322
|
+
* Returns raw bytes from the backing buffer without advancing the reader.
|
|
1323
|
+
* @param start Start offset
|
|
1324
|
+
* @param end End offset
|
|
1325
|
+
* @returns Raw bytes
|
|
1326
|
+
*/
|
|
1327
|
+
public raw(start: number, end: number): Buffer;
|
|
1328
|
+
|
|
1291
1329
|
/**
|
|
1292
1330
|
* Reads a sequence of bytes preceeded by its length as a varint.
|
|
1293
1331
|
* @returns Value read
|
|
@@ -1314,9 +1352,10 @@ export class Root extends NamespaceBase {
|
|
|
1314
1352
|
* Loads a namespace descriptor into a root namespace.
|
|
1315
1353
|
* @param json Namespace descriptor
|
|
1316
1354
|
* @param [root] Root namespace, defaults to create a new one if omitted
|
|
1355
|
+
* @param [depth] Current nesting depth, defaults to `0`
|
|
1317
1356
|
* @returns Root namespace
|
|
1318
1357
|
*/
|
|
1319
|
-
public static fromJSON(json: INamespace, root?: Root): Root;
|
|
1358
|
+
public static fromJSON(json: INamespace, root?: Root, depth?: number): Root;
|
|
1320
1359
|
|
|
1321
1360
|
/**
|
|
1322
1361
|
* Resolves the path of an imported file, relative to the importing origin.
|
|
@@ -1467,10 +1506,11 @@ export class Service extends NamespaceBase {
|
|
|
1467
1506
|
* Constructs a service from a service descriptor.
|
|
1468
1507
|
* @param name Service name
|
|
1469
1508
|
* @param json Service descriptor
|
|
1509
|
+
* @param [depth] Current nesting depth, defaults to `0`
|
|
1470
1510
|
* @returns Created service
|
|
1471
1511
|
* @throws {TypeError} If arguments are invalid
|
|
1472
1512
|
*/
|
|
1473
|
-
public static fromJSON(name: string, json: IService): Service;
|
|
1513
|
+
public static fromJSON(name: string, json: IService, depth?: number): Service;
|
|
1474
1514
|
|
|
1475
1515
|
/**
|
|
1476
1516
|
* Converts this service to a service descriptor.
|
|
@@ -1621,9 +1661,10 @@ export class Type extends NamespaceBase {
|
|
|
1621
1661
|
* Creates a message type from a message type descriptor.
|
|
1622
1662
|
* @param name Message name
|
|
1623
1663
|
* @param json Message type descriptor
|
|
1664
|
+
* @param [depth] Current nesting depth, defaults to `0`
|
|
1624
1665
|
* @returns Created message type
|
|
1625
1666
|
*/
|
|
1626
|
-
public static fromJSON(name: string, json: IType): Type;
|
|
1667
|
+
public static fromJSON(name: string, json: IType, depth?: number): Type;
|
|
1627
1668
|
|
|
1628
1669
|
/**
|
|
1629
1670
|
* Converts this message type to a message type descriptor.
|
|
@@ -1734,10 +1775,18 @@ export class Type extends NamespaceBase {
|
|
|
1734
1775
|
*/
|
|
1735
1776
|
public toObject(message: Message<{}>, options?: IConversionOptions): { [k: string]: any };
|
|
1736
1777
|
|
|
1778
|
+
/**
|
|
1779
|
+
* Gets the type url for this type.
|
|
1780
|
+
* @param [prefix] Custom type url prefix, defaults to `"type.googleapis.com"`
|
|
1781
|
+
* @returns The type url
|
|
1782
|
+
*/
|
|
1783
|
+
public getTypeUrl(prefix?: string): string;
|
|
1784
|
+
|
|
1737
1785
|
/**
|
|
1738
1786
|
* Type decorator (TypeScript).
|
|
1739
1787
|
* @param [typeName] Type name, defaults to the constructor's name
|
|
1740
1788
|
* @returns Decorator function
|
|
1789
|
+
* @deprecated Legacy TypeScript decorator support. Will be removed in a future release.
|
|
1741
1790
|
*/
|
|
1742
1791
|
public static d<T extends Message<T>>(typeName?: string): TypeDecorator<T>;
|
|
1743
1792
|
}
|
|
@@ -1804,6 +1853,7 @@ export interface IConversionOptions {
|
|
|
1804
1853
|
/**
|
|
1805
1854
|
* Decorator function as returned by {@link Type.d} (TypeScript).
|
|
1806
1855
|
* @param target Target constructor
|
|
1856
|
+
* @deprecated Legacy TypeScript decorator support. Will be removed in a future release.
|
|
1807
1857
|
*/
|
|
1808
1858
|
type TypeDecorator<T extends Message<T>> = (target: Constructor<T>) => void;
|
|
1809
1859
|
|
|
@@ -1900,6 +1950,45 @@ export interface Constructor<T> extends Function {
|
|
|
1900
1950
|
/** Properties type. */
|
|
1901
1951
|
type Properties<T> = { [P in keyof T]?: T[P] };
|
|
1902
1952
|
|
|
1953
|
+
/**
|
|
1954
|
+
* Callback as used by {@link util.asPromise}.
|
|
1955
|
+
* @param error Error, if any
|
|
1956
|
+
* @param params Additional arguments
|
|
1957
|
+
*/
|
|
1958
|
+
type asPromiseCallback = (error: (Error|null), ...params: any[]) => void;
|
|
1959
|
+
|
|
1960
|
+
/**
|
|
1961
|
+
* Appends code to the function's body or finishes generation.
|
|
1962
|
+
* @param [formatStringOrScope] Format string or, to finish the function, an object of additional scope variables, if any
|
|
1963
|
+
* @param [formatParams] Format parameters
|
|
1964
|
+
* @returns Itself or the generated function if finished
|
|
1965
|
+
* @throws {Error} If format parameter counts do not match
|
|
1966
|
+
*/
|
|
1967
|
+
type Codegen = (formatStringOrScope?: (string|{ [k: string]: any }), ...formatParams: any[]) => (Codegen|Function);
|
|
1968
|
+
|
|
1969
|
+
/**
|
|
1970
|
+
* Event listener as used by {@link util.EventEmitter}.
|
|
1971
|
+
* @param args Arguments
|
|
1972
|
+
*/
|
|
1973
|
+
type EventEmitterListener = (...args: any[]) => void;
|
|
1974
|
+
|
|
1975
|
+
/**
|
|
1976
|
+
* Node-style callback as used by {@link util.fetch}.
|
|
1977
|
+
* @param error Error, if any, otherwise `null`
|
|
1978
|
+
* @param [contents] File contents, if there hasn't been an error
|
|
1979
|
+
*/
|
|
1980
|
+
type FetchCallback = (error: Error, contents?: string) => void;
|
|
1981
|
+
|
|
1982
|
+
/** Options as used by {@link util.fetch}. */
|
|
1983
|
+
export interface IFetchOptions {
|
|
1984
|
+
|
|
1985
|
+
/** Whether expecting a binary response */
|
|
1986
|
+
binary?: boolean;
|
|
1987
|
+
|
|
1988
|
+
/** If `true`, forces the use of XMLHttpRequest */
|
|
1989
|
+
xhr?: boolean;
|
|
1990
|
+
}
|
|
1991
|
+
|
|
1903
1992
|
/**
|
|
1904
1993
|
* Any compatible Buffer instance.
|
|
1905
1994
|
* This is a minimal stand-alone definition of a Buffer instance. The actual type is that exported by node's typings.
|
|
@@ -1935,526 +2024,487 @@ type OneOfGetter = () => (string|undefined);
|
|
|
1935
2024
|
*/
|
|
1936
2025
|
type OneOfSetter = (value: (string|undefined)) => void;
|
|
1937
2026
|
|
|
1938
|
-
/**
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
/**
|
|
1945
|
-
* Constructs new long bits.
|
|
1946
|
-
* @param lo Low 32 bits, unsigned
|
|
1947
|
-
* @param hi High 32 bits, unsigned
|
|
1948
|
-
*/
|
|
1949
|
-
constructor(lo: number, hi: number);
|
|
2027
|
+
/**
|
|
2028
|
+
* An allocator as used by {@link util.pool}.
|
|
2029
|
+
* @param size Buffer size
|
|
2030
|
+
* @returns Buffer
|
|
2031
|
+
*/
|
|
2032
|
+
type PoolAllocator = (size: number) => Uint8Array;
|
|
1950
2033
|
|
|
1951
|
-
|
|
1952
|
-
|
|
2034
|
+
/**
|
|
2035
|
+
* A slicer as used by {@link util.pool}.
|
|
2036
|
+
* @param start Start offset
|
|
2037
|
+
* @param end End offset
|
|
2038
|
+
* @returns Buffer slice
|
|
2039
|
+
*/
|
|
2040
|
+
type PoolSlicer = (this: Uint8Array, start: number, end: number) => Uint8Array;
|
|
1953
2041
|
|
|
1954
|
-
|
|
1955
|
-
|
|
2042
|
+
/** Various utility functions. */
|
|
2043
|
+
export namespace util {
|
|
1956
2044
|
|
|
1957
|
-
|
|
1958
|
-
|
|
2045
|
+
/**
|
|
2046
|
+
* Returns a promise from a node-style callback function.
|
|
2047
|
+
* @param fn Function to call
|
|
2048
|
+
* @param ctx Function context
|
|
2049
|
+
* @param params Function arguments
|
|
2050
|
+
* @returns Promisified function
|
|
2051
|
+
*/
|
|
2052
|
+
function asPromise(fn: asPromiseCallback, ctx: any, ...params: any[]): Promise<any>;
|
|
1959
2053
|
|
|
1960
|
-
|
|
1961
|
-
|
|
2054
|
+
/** A minimal base64 implementation for number arrays. */
|
|
2055
|
+
namespace base64 {
|
|
1962
2056
|
|
|
1963
2057
|
/**
|
|
1964
|
-
*
|
|
1965
|
-
* @param
|
|
1966
|
-
* @returns
|
|
2058
|
+
* Calculates the byte length of a base64 encoded string.
|
|
2059
|
+
* @param string Base64 encoded string
|
|
2060
|
+
* @returns Byte length
|
|
1967
2061
|
*/
|
|
1968
|
-
|
|
2062
|
+
function length(string: string): number;
|
|
1969
2063
|
|
|
1970
2064
|
/**
|
|
1971
|
-
*
|
|
1972
|
-
* @param
|
|
1973
|
-
* @
|
|
2065
|
+
* Encodes a buffer to a base64 encoded string.
|
|
2066
|
+
* @param buffer Source buffer
|
|
2067
|
+
* @param start Source start
|
|
2068
|
+
* @param end Source end
|
|
2069
|
+
* @returns Base64 encoded string
|
|
1974
2070
|
*/
|
|
1975
|
-
|
|
2071
|
+
function encode(buffer: Uint8Array, start: number, end: number): string;
|
|
1976
2072
|
|
|
1977
2073
|
/**
|
|
1978
|
-
*
|
|
1979
|
-
* @param
|
|
1980
|
-
* @
|
|
2074
|
+
* Decodes a base64 encoded string to a buffer.
|
|
2075
|
+
* @param string Source string
|
|
2076
|
+
* @param buffer Destination buffer
|
|
2077
|
+
* @param offset Destination offset
|
|
2078
|
+
* @returns Number of bytes written
|
|
2079
|
+
* @throws {Error} If encoding is invalid
|
|
1981
2080
|
*/
|
|
1982
|
-
|
|
2081
|
+
function decode(string: string, buffer: Uint8Array, offset: number): number;
|
|
1983
2082
|
|
|
1984
2083
|
/**
|
|
1985
|
-
*
|
|
1986
|
-
* @param
|
|
1987
|
-
* @returns
|
|
2084
|
+
* Tests if the specified string appears to be base64 encoded.
|
|
2085
|
+
* @param string String to test
|
|
2086
|
+
* @returns `true` if probably base64 encoded, otherwise false
|
|
1988
2087
|
*/
|
|
1989
|
-
|
|
2088
|
+
function test(string: string): boolean;
|
|
2089
|
+
}
|
|
1990
2090
|
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
2091
|
+
/**
|
|
2092
|
+
* Begins generating a function.
|
|
2093
|
+
* @param functionParams Function parameter names
|
|
2094
|
+
* @param [functionName] Function name if not anonymous
|
|
2095
|
+
* @returns Appender that appends code to the function's body
|
|
2096
|
+
*/
|
|
2097
|
+
function codegen(functionParams: string[], functionName?: string): Codegen;
|
|
1997
2098
|
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2099
|
+
namespace codegen {
|
|
2100
|
+
|
|
2101
|
+
/** When set to `true`, codegen will log generated code to console. Useful for debugging. */
|
|
2102
|
+
let verbose: boolean;
|
|
2103
|
+
}
|
|
2104
|
+
|
|
2105
|
+
/**
|
|
2106
|
+
* Begins generating a function.
|
|
2107
|
+
* @param [functionName] Function name if not anonymous
|
|
2108
|
+
* @returns Appender that appends code to the function's body
|
|
2109
|
+
*/
|
|
2110
|
+
function codegen(functionName?: string): Codegen;
|
|
2111
|
+
|
|
2112
|
+
/** A minimal event emitter. */
|
|
2113
|
+
class EventEmitter {
|
|
2114
|
+
|
|
2115
|
+
/** Constructs a new event emitter instance. */
|
|
2116
|
+
constructor();
|
|
2003
2117
|
|
|
2004
2118
|
/**
|
|
2005
|
-
*
|
|
2119
|
+
* Registers an event listener.
|
|
2120
|
+
* @param evt Event name
|
|
2121
|
+
* @param fn Listener
|
|
2122
|
+
* @param [ctx] Listener context
|
|
2006
2123
|
* @returns `this`
|
|
2007
2124
|
*/
|
|
2008
|
-
public
|
|
2125
|
+
public on(evt: string, fn: EventEmitterListener, ctx?: any): this;
|
|
2009
2126
|
|
|
2010
2127
|
/**
|
|
2011
|
-
*
|
|
2128
|
+
* Removes an event listener or any matching listeners if arguments are omitted.
|
|
2129
|
+
* @param [evt] Event name. Removes all listeners if omitted.
|
|
2130
|
+
* @param [fn] Listener to remove. Removes all listeners of `evt` if omitted.
|
|
2012
2131
|
* @returns `this`
|
|
2013
2132
|
*/
|
|
2014
|
-
public
|
|
2133
|
+
public off(evt?: string, fn?: EventEmitterListener): this;
|
|
2015
2134
|
|
|
2016
2135
|
/**
|
|
2017
|
-
*
|
|
2018
|
-
* @
|
|
2136
|
+
* Emits an event by calling its listeners with the specified arguments.
|
|
2137
|
+
* @param evt Event name
|
|
2138
|
+
* @param args Arguments
|
|
2139
|
+
* @returns `this`
|
|
2019
2140
|
*/
|
|
2020
|
-
public
|
|
2141
|
+
public emit(evt: string, ...args: any[]): this;
|
|
2021
2142
|
}
|
|
2022
2143
|
|
|
2023
|
-
/** Whether running within node or not. */
|
|
2024
|
-
let isNode: boolean;
|
|
2025
|
-
|
|
2026
|
-
/** Global object reference. */
|
|
2027
|
-
let global: object;
|
|
2028
|
-
|
|
2029
|
-
/** An immuable empty array. */
|
|
2030
|
-
const emptyArray: any[];
|
|
2031
|
-
|
|
2032
|
-
/** An immutable empty object. */
|
|
2033
|
-
const emptyObject: object;
|
|
2034
|
-
|
|
2035
2144
|
/**
|
|
2036
|
-
*
|
|
2037
|
-
* @param
|
|
2038
|
-
* @
|
|
2145
|
+
* Fetches the contents of a file.
|
|
2146
|
+
* @param filename File path or url
|
|
2147
|
+
* @param options Fetch options
|
|
2148
|
+
* @param callback Callback function
|
|
2039
2149
|
*/
|
|
2040
|
-
function
|
|
2150
|
+
function fetch(filename: string, options: IFetchOptions, callback: FetchCallback): void;
|
|
2041
2151
|
|
|
2042
2152
|
/**
|
|
2043
|
-
*
|
|
2044
|
-
* @param
|
|
2045
|
-
* @
|
|
2153
|
+
* Fetches the contents of a file.
|
|
2154
|
+
* @param path File path or url
|
|
2155
|
+
* @param callback Callback function
|
|
2046
2156
|
*/
|
|
2047
|
-
function
|
|
2157
|
+
function fetch(path: string, callback: FetchCallback): void;
|
|
2048
2158
|
|
|
2049
2159
|
/**
|
|
2050
|
-
*
|
|
2051
|
-
* @param
|
|
2052
|
-
* @
|
|
2160
|
+
* Fetches the contents of a file.
|
|
2161
|
+
* @param path File path or url
|
|
2162
|
+
* @param [options] Fetch options
|
|
2163
|
+
* @returns Promise
|
|
2053
2164
|
*/
|
|
2054
|
-
function
|
|
2165
|
+
function fetch(path: string, options?: IFetchOptions): Promise<(string|Uint8Array)>;
|
|
2055
2166
|
|
|
2056
|
-
/**
|
|
2057
|
-
|
|
2058
|
-
* This is an alias of {@link util.isSet}.
|
|
2059
|
-
* @param obj Plain object or message instance
|
|
2060
|
-
* @param prop Property name
|
|
2061
|
-
* @returns `true` if considered to be present, otherwise `false`
|
|
2062
|
-
*/
|
|
2063
|
-
function isset(obj: object, prop: string): boolean;
|
|
2167
|
+
/** Reads / writes floats / doubles from / to buffers. */
|
|
2168
|
+
namespace float {
|
|
2064
2169
|
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2170
|
+
/**
|
|
2171
|
+
* Writes a 32 bit float to a buffer using little endian byte order.
|
|
2172
|
+
* @param val Value to write
|
|
2173
|
+
* @param buf Target buffer
|
|
2174
|
+
* @param pos Target buffer offset
|
|
2175
|
+
*/
|
|
2176
|
+
function writeFloatLE(val: number, buf: Uint8Array, pos: number): void;
|
|
2072
2177
|
|
|
2073
|
-
|
|
2074
|
-
|
|
2178
|
+
/**
|
|
2179
|
+
* Writes a 32 bit float to a buffer using big endian byte order.
|
|
2180
|
+
* @param val Value to write
|
|
2181
|
+
* @param buf Target buffer
|
|
2182
|
+
* @param pos Target buffer offset
|
|
2183
|
+
*/
|
|
2184
|
+
function writeFloatBE(val: number, buf: Uint8Array, pos: number): void;
|
|
2075
2185
|
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2186
|
+
/**
|
|
2187
|
+
* Reads a 32 bit float from a buffer using little endian byte order.
|
|
2188
|
+
* @param buf Source buffer
|
|
2189
|
+
* @param pos Source buffer offset
|
|
2190
|
+
* @returns Value read
|
|
2191
|
+
*/
|
|
2192
|
+
function readFloatLE(buf: Uint8Array, pos: number): number;
|
|
2082
2193
|
|
|
2083
|
-
|
|
2084
|
-
|
|
2194
|
+
/**
|
|
2195
|
+
* Reads a 32 bit float from a buffer using big endian byte order.
|
|
2196
|
+
* @param buf Source buffer
|
|
2197
|
+
* @param pos Source buffer offset
|
|
2198
|
+
* @returns Value read
|
|
2199
|
+
*/
|
|
2200
|
+
function readFloatBE(buf: Uint8Array, pos: number): number;
|
|
2085
2201
|
|
|
2086
|
-
|
|
2087
|
-
|
|
2202
|
+
/**
|
|
2203
|
+
* Writes a 64 bit double to a buffer using little endian byte order.
|
|
2204
|
+
* @param val Value to write
|
|
2205
|
+
* @param buf Target buffer
|
|
2206
|
+
* @param pos Target buffer offset
|
|
2207
|
+
*/
|
|
2208
|
+
function writeDoubleLE(val: number, buf: Uint8Array, pos: number): void;
|
|
2088
2209
|
|
|
2089
|
-
|
|
2090
|
-
|
|
2210
|
+
/**
|
|
2211
|
+
* Writes a 64 bit double to a buffer using big endian byte order.
|
|
2212
|
+
* @param val Value to write
|
|
2213
|
+
* @param buf Target buffer
|
|
2214
|
+
* @param pos Target buffer offset
|
|
2215
|
+
*/
|
|
2216
|
+
function writeDoubleBE(val: number, buf: Uint8Array, pos: number): void;
|
|
2091
2217
|
|
|
2092
|
-
|
|
2093
|
-
|
|
2218
|
+
/**
|
|
2219
|
+
* Reads a 64 bit double from a buffer using little endian byte order.
|
|
2220
|
+
* @param buf Source buffer
|
|
2221
|
+
* @param pos Source buffer offset
|
|
2222
|
+
* @returns Value read
|
|
2223
|
+
*/
|
|
2224
|
+
function readDoubleLE(buf: Uint8Array, pos: number): number;
|
|
2094
2225
|
|
|
2095
|
-
|
|
2096
|
-
|
|
2226
|
+
/**
|
|
2227
|
+
* Reads a 64 bit double from a buffer using big endian byte order.
|
|
2228
|
+
* @param buf Source buffer
|
|
2229
|
+
* @param pos Source buffer offset
|
|
2230
|
+
* @returns Value read
|
|
2231
|
+
*/
|
|
2232
|
+
function readDoubleBE(buf: Uint8Array, pos: number): number;
|
|
2233
|
+
}
|
|
2097
2234
|
|
|
2098
2235
|
/**
|
|
2099
|
-
*
|
|
2100
|
-
* @param
|
|
2101
|
-
* @returns
|
|
2236
|
+
* Requires a module only if available.
|
|
2237
|
+
* @param moduleName Module to require
|
|
2238
|
+
* @returns Required module if available and not empty, otherwise `null`
|
|
2239
|
+
* @deprecated Legacy optional require helper. Will be removed in a future release.
|
|
2102
2240
|
*/
|
|
2103
|
-
function
|
|
2241
|
+
function inquire(moduleName: string): object;
|
|
2104
2242
|
|
|
2105
|
-
/**
|
|
2106
|
-
|
|
2107
|
-
* @param hash Hash
|
|
2108
|
-
* @param [unsigned=false] Whether unsigned or not
|
|
2109
|
-
* @returns Original value
|
|
2110
|
-
*/
|
|
2111
|
-
function longFromHash(hash: string, unsigned?: boolean): (Long|number);
|
|
2243
|
+
/** Helper class for working with the low and high bits of a 64 bit value. */
|
|
2244
|
+
class LongBits {
|
|
2112
2245
|
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
*/
|
|
2120
|
-
function merge(dst: { [k: string]: any }, src: { [k: string]: any }, ifNotSet?: boolean): { [k: string]: any };
|
|
2246
|
+
/**
|
|
2247
|
+
* Constructs new long bits.
|
|
2248
|
+
* @param lo Low 32 bits, unsigned
|
|
2249
|
+
* @param hi High 32 bits, unsigned
|
|
2250
|
+
*/
|
|
2251
|
+
constructor(lo: number, hi: number);
|
|
2121
2252
|
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
* @param str String to convert
|
|
2125
|
-
* @returns Converted string
|
|
2126
|
-
*/
|
|
2127
|
-
function lcFirst(str: string): string;
|
|
2253
|
+
/** Low bits. */
|
|
2254
|
+
public lo: number;
|
|
2128
2255
|
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
* @param name Error name
|
|
2132
|
-
* @returns Custom error constructor
|
|
2133
|
-
*/
|
|
2134
|
-
function newError(name: string): Constructor<Error>;
|
|
2256
|
+
/** High bits. */
|
|
2257
|
+
public hi: number;
|
|
2135
2258
|
|
|
2136
|
-
|
|
2137
|
-
|
|
2259
|
+
/** Zero bits. */
|
|
2260
|
+
public static zero: util.LongBits;
|
|
2261
|
+
|
|
2262
|
+
/** Zero hash. */
|
|
2263
|
+
public static zeroHash: string;
|
|
2138
2264
|
|
|
2139
2265
|
/**
|
|
2140
|
-
* Constructs
|
|
2141
|
-
* @param
|
|
2142
|
-
* @
|
|
2266
|
+
* Constructs new long bits from the specified number.
|
|
2267
|
+
* @param value Value
|
|
2268
|
+
* @returns Instance
|
|
2143
2269
|
*/
|
|
2144
|
-
|
|
2270
|
+
public static fromNumber(value: number): util.LongBits;
|
|
2145
2271
|
|
|
2146
|
-
/**
|
|
2147
|
-
|
|
2148
|
-
|
|
2272
|
+
/**
|
|
2273
|
+
* Constructs new long bits from a number, long or string.
|
|
2274
|
+
* @param value Value
|
|
2275
|
+
* @returns Instance
|
|
2276
|
+
*/
|
|
2277
|
+
public static from(value: (Long|number|string)): util.LongBits;
|
|
2149
2278
|
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2279
|
+
/**
|
|
2280
|
+
* Converts this long bits to a possibly unsafe JavaScript number.
|
|
2281
|
+
* @param [unsigned=false] Whether unsigned or not
|
|
2282
|
+
* @returns Possibly unsafe number
|
|
2283
|
+
*/
|
|
2284
|
+
public toNumber(unsigned?: boolean): number;
|
|
2156
2285
|
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2286
|
+
/**
|
|
2287
|
+
* Converts this long bits to a long.
|
|
2288
|
+
* @param [unsigned=false] Whether unsigned or not
|
|
2289
|
+
* @returns Long
|
|
2290
|
+
*/
|
|
2291
|
+
public toLong(unsigned?: boolean): Long;
|
|
2163
2292
|
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
* - Enums become string keys
|
|
2171
|
-
* - Bytes become base64 encoded strings
|
|
2172
|
-
* - (Sub-)Messages become plain objects
|
|
2173
|
-
* - Maps become plain objects with all string keys
|
|
2174
|
-
* - Repeated fields become arrays
|
|
2175
|
-
* - NaN and Infinity for float and double fields become strings
|
|
2176
|
-
*
|
|
2177
|
-
* @see https://developers.google.com/protocol-buffers/docs/proto3?hl=en#json
|
|
2178
|
-
*/
|
|
2179
|
-
let toJSONOptions: IConversionOptions;
|
|
2293
|
+
/**
|
|
2294
|
+
* Constructs new long bits from the specified 8 characters long hash.
|
|
2295
|
+
* @param hash Hash
|
|
2296
|
+
* @returns Bits
|
|
2297
|
+
*/
|
|
2298
|
+
public static fromHash(hash: string): util.LongBits;
|
|
2180
2299
|
|
|
2181
|
-
|
|
2182
|
-
|
|
2300
|
+
/**
|
|
2301
|
+
* Converts this long bits to a 8 characters long hash.
|
|
2302
|
+
* @returns Hash
|
|
2303
|
+
*/
|
|
2304
|
+
public toHash(): string;
|
|
2183
2305
|
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
function toArray(object: { [k: string]: any }): any[];
|
|
2306
|
+
/**
|
|
2307
|
+
* Zig-zag encodes this long bits.
|
|
2308
|
+
* @returns `this`
|
|
2309
|
+
*/
|
|
2310
|
+
public zzEncode(): util.LongBits;
|
|
2190
2311
|
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
function toObject(array: any[]): { [k: string]: any };
|
|
2312
|
+
/**
|
|
2313
|
+
* Zig-zag decodes this long bits.
|
|
2314
|
+
* @returns `this`
|
|
2315
|
+
*/
|
|
2316
|
+
public zzDecode(): util.LongBits;
|
|
2197
2317
|
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2318
|
+
/**
|
|
2319
|
+
* Calculates the length of this longbits when encoded as a varint.
|
|
2320
|
+
* @returns Length
|
|
2321
|
+
*/
|
|
2322
|
+
public length(): number;
|
|
2323
|
+
}
|
|
2204
2324
|
|
|
2205
|
-
/**
|
|
2206
|
-
|
|
2207
|
-
* @param prop Property name
|
|
2208
|
-
* @returns Safe accessor
|
|
2209
|
-
*/
|
|
2210
|
-
function safeProp(prop: string): string;
|
|
2325
|
+
/** Whether running within node or not. */
|
|
2326
|
+
let isNode: boolean;
|
|
2211
2327
|
|
|
2212
|
-
/**
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2328
|
+
/** Global object reference. */
|
|
2329
|
+
let global: object;
|
|
2330
|
+
|
|
2331
|
+
/** An immuable empty array. */
|
|
2332
|
+
const emptyArray: any[];
|
|
2333
|
+
|
|
2334
|
+
/** An immutable empty object. */
|
|
2335
|
+
const emptyObject: object;
|
|
2218
2336
|
|
|
2219
2337
|
/**
|
|
2220
|
-
*
|
|
2221
|
-
* @param
|
|
2222
|
-
* @returns
|
|
2338
|
+
* Tests if the specified value is an integer.
|
|
2339
|
+
* @param value Value to test
|
|
2340
|
+
* @returns `true` if the value is an integer
|
|
2223
2341
|
*/
|
|
2224
|
-
function
|
|
2342
|
+
function isInteger(value: any): boolean;
|
|
2225
2343
|
|
|
2226
2344
|
/**
|
|
2227
|
-
*
|
|
2228
|
-
* @param
|
|
2229
|
-
* @
|
|
2230
|
-
* @returns Comparison value
|
|
2345
|
+
* Tests if the specified value is a string.
|
|
2346
|
+
* @param value Value to test
|
|
2347
|
+
* @returns `true` if the value is a string
|
|
2231
2348
|
*/
|
|
2232
|
-
function
|
|
2349
|
+
function isString(value: any): boolean;
|
|
2233
2350
|
|
|
2234
2351
|
/**
|
|
2235
|
-
*
|
|
2236
|
-
* @param
|
|
2237
|
-
* @
|
|
2238
|
-
* @returns Reflected type
|
|
2352
|
+
* Tests if the specified value is a non-null object.
|
|
2353
|
+
* @param value Value to test
|
|
2354
|
+
* @returns `true` if the value is a non-null object
|
|
2239
2355
|
*/
|
|
2240
|
-
function
|
|
2356
|
+
function isObject(value: any): boolean;
|
|
2241
2357
|
|
|
2242
2358
|
/**
|
|
2243
|
-
*
|
|
2244
|
-
*
|
|
2245
|
-
* @
|
|
2359
|
+
* Checks if a property on a message is considered to be present.
|
|
2360
|
+
* This is an alias of {@link util.isSet}.
|
|
2361
|
+
* @param obj Plain object or message instance
|
|
2362
|
+
* @param prop Property name
|
|
2363
|
+
* @returns `true` if considered to be present, otherwise `false`
|
|
2246
2364
|
*/
|
|
2247
|
-
function
|
|
2365
|
+
function isset(obj: object, prop: string): boolean;
|
|
2248
2366
|
|
|
2249
2367
|
/**
|
|
2250
|
-
*
|
|
2251
|
-
* @param
|
|
2252
|
-
* @param
|
|
2253
|
-
* @
|
|
2254
|
-
* @param [ifNotSet] Sets the option only if it isn't currently set
|
|
2255
|
-
* @returns Destination object
|
|
2368
|
+
* Checks if a property on a message is considered to be present.
|
|
2369
|
+
* @param obj Plain object or message instance
|
|
2370
|
+
* @param prop Property name
|
|
2371
|
+
* @returns `true` if considered to be present, otherwise `false`
|
|
2256
2372
|
*/
|
|
2257
|
-
function
|
|
2373
|
+
function isSet(obj: object, prop: string): boolean;
|
|
2258
2374
|
|
|
2259
|
-
/**
|
|
2260
|
-
let
|
|
2375
|
+
/** Node's Buffer class if available. */
|
|
2376
|
+
let Buffer: Constructor<Buffer>;
|
|
2261
2377
|
|
|
2262
2378
|
/**
|
|
2263
|
-
*
|
|
2264
|
-
* @param
|
|
2265
|
-
* @
|
|
2266
|
-
* @param params Function arguments
|
|
2267
|
-
* @returns Promisified function
|
|
2379
|
+
* Creates a new buffer of whatever type supported by the environment.
|
|
2380
|
+
* @param [sizeOrArray=0] Buffer size or number array
|
|
2381
|
+
* @returns Buffer
|
|
2268
2382
|
*/
|
|
2269
|
-
function
|
|
2383
|
+
function newBuffer(sizeOrArray?: (number|number[])): (Uint8Array|Buffer);
|
|
2270
2384
|
|
|
2271
|
-
/**
|
|
2272
|
-
|
|
2385
|
+
/** Array implementation used in the browser. `Uint8Array` if supported, otherwise `Array`. */
|
|
2386
|
+
let Array: Constructor<Uint8Array>;
|
|
2273
2387
|
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
* @param string Base64 encoded string
|
|
2277
|
-
* @returns Byte length
|
|
2278
|
-
*/
|
|
2279
|
-
function length(string: string): number;
|
|
2388
|
+
/** Long.js's Long class if available. */
|
|
2389
|
+
let Long: Constructor<Long>;
|
|
2280
2390
|
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
* @param buffer Source buffer
|
|
2284
|
-
* @param start Source start
|
|
2285
|
-
* @param end Source end
|
|
2286
|
-
* @returns Base64 encoded string
|
|
2287
|
-
*/
|
|
2288
|
-
function encode(buffer: Uint8Array, start: number, end: number): string;
|
|
2391
|
+
/** Regular expression used to verify 2 bit (`bool`) map keys. */
|
|
2392
|
+
const key2Re: RegExp;
|
|
2289
2393
|
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
* @param string Source string
|
|
2293
|
-
* @param buffer Destination buffer
|
|
2294
|
-
* @param offset Destination offset
|
|
2295
|
-
* @returns Number of bytes written
|
|
2296
|
-
* @throws {Error} If encoding is invalid
|
|
2297
|
-
*/
|
|
2298
|
-
function decode(string: string, buffer: Uint8Array, offset: number): number;
|
|
2394
|
+
/** Regular expression used to verify 32 bit (`int32` etc.) map keys. */
|
|
2395
|
+
const key32Re: RegExp;
|
|
2299
2396
|
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
* @param string String to test
|
|
2303
|
-
* @returns `true` if probably base64 encoded, otherwise false
|
|
2304
|
-
*/
|
|
2305
|
-
function test(string: string): boolean;
|
|
2306
|
-
}
|
|
2397
|
+
/** Regular expression used to verify 64 bit (`int64` etc.) map keys. */
|
|
2398
|
+
const key64Re: RegExp;
|
|
2307
2399
|
|
|
2308
2400
|
/**
|
|
2309
|
-
*
|
|
2310
|
-
* @param
|
|
2311
|
-
* @
|
|
2312
|
-
* @returns Appender that appends code to the function's body
|
|
2401
|
+
* Converts a number or long to an 8 characters long hash string.
|
|
2402
|
+
* @param value Value to convert
|
|
2403
|
+
* @returns Hash
|
|
2313
2404
|
*/
|
|
2314
|
-
function
|
|
2315
|
-
|
|
2316
|
-
namespace codegen {
|
|
2317
|
-
|
|
2318
|
-
/** When set to `true`, codegen will log generated code to console. Useful for debugging. */
|
|
2319
|
-
let verbose: boolean;
|
|
2320
|
-
}
|
|
2405
|
+
function longToHash(value: (Long|number)): string;
|
|
2321
2406
|
|
|
2322
2407
|
/**
|
|
2323
|
-
*
|
|
2324
|
-
* @param
|
|
2325
|
-
* @
|
|
2408
|
+
* Converts an 8 characters long hash string to a long or number.
|
|
2409
|
+
* @param hash Hash
|
|
2410
|
+
* @param [unsigned=false] Whether unsigned or not
|
|
2411
|
+
* @returns Original value
|
|
2326
2412
|
*/
|
|
2327
|
-
function
|
|
2328
|
-
|
|
2329
|
-
/** A minimal event emitter. */
|
|
2330
|
-
class EventEmitter {
|
|
2331
|
-
|
|
2332
|
-
/** Constructs a new event emitter instance. */
|
|
2333
|
-
constructor();
|
|
2334
|
-
|
|
2335
|
-
/**
|
|
2336
|
-
* Registers an event listener.
|
|
2337
|
-
* @param evt Event name
|
|
2338
|
-
* @param fn Listener
|
|
2339
|
-
* @param [ctx] Listener context
|
|
2340
|
-
* @returns `this`
|
|
2341
|
-
*/
|
|
2342
|
-
public on(evt: string, fn: EventEmitterListener, ctx?: any): this;
|
|
2343
|
-
|
|
2344
|
-
/**
|
|
2345
|
-
* Removes an event listener or any matching listeners if arguments are omitted.
|
|
2346
|
-
* @param [evt] Event name. Removes all listeners if omitted.
|
|
2347
|
-
* @param [fn] Listener to remove. Removes all listeners of `evt` if omitted.
|
|
2348
|
-
* @returns `this`
|
|
2349
|
-
*/
|
|
2350
|
-
public off(evt?: string, fn?: EventEmitterListener): this;
|
|
2351
|
-
|
|
2352
|
-
/**
|
|
2353
|
-
* Emits an event by calling its listeners with the specified arguments.
|
|
2354
|
-
* @param evt Event name
|
|
2355
|
-
* @param args Arguments
|
|
2356
|
-
* @returns `this`
|
|
2357
|
-
*/
|
|
2358
|
-
public emit(evt: string, ...args: any[]): this;
|
|
2359
|
-
}
|
|
2413
|
+
function longFromHash(hash: string, unsigned?: boolean): (Long|number);
|
|
2360
2414
|
|
|
2361
|
-
/**
|
|
2362
|
-
|
|
2415
|
+
/**
|
|
2416
|
+
* Converts a 64 bit key to a long or number if it is an 8 characters long hash string.
|
|
2417
|
+
* @param key Map key
|
|
2418
|
+
* @param [unsigned=false] Whether unsigned or not
|
|
2419
|
+
* @returns Original value
|
|
2420
|
+
*/
|
|
2421
|
+
function longFromKey(key: string, unsigned?: boolean): (Long|number|string);
|
|
2363
2422
|
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
function writeFloatLE(val: number, buf: Uint8Array, pos: number): void;
|
|
2423
|
+
/**
|
|
2424
|
+
* Converts a boolean key to a boolean value.
|
|
2425
|
+
* @param key Map key
|
|
2426
|
+
* @returns Boolean value
|
|
2427
|
+
*/
|
|
2428
|
+
function boolFromKey(key: string): boolean;
|
|
2371
2429
|
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2430
|
+
/**
|
|
2431
|
+
* Merges the properties of the source object into the destination object.
|
|
2432
|
+
* @param dst Destination object
|
|
2433
|
+
* @param src Source object
|
|
2434
|
+
* @param [ifNotSet=false] Merges only if the key is not already set
|
|
2435
|
+
* @returns Destination object
|
|
2436
|
+
*/
|
|
2437
|
+
function merge(dst: { [k: string]: any }, src: { [k: string]: any }, ifNotSet?: boolean): { [k: string]: any };
|
|
2379
2438
|
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
* @param buf Source buffer
|
|
2383
|
-
* @param pos Source buffer offset
|
|
2384
|
-
* @returns Value read
|
|
2385
|
-
*/
|
|
2386
|
-
function readFloatLE(buf: Uint8Array, pos: number): number;
|
|
2439
|
+
/** Recursion limit. */
|
|
2440
|
+
let recursionLimit: number;
|
|
2387
2441
|
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2442
|
+
/**
|
|
2443
|
+
* Makes a property safe for assignment as an own property.
|
|
2444
|
+
* @param obj Object
|
|
2445
|
+
* @param key Property key
|
|
2446
|
+
* @param [enumerable=true] Whether the property should be enumerable
|
|
2447
|
+
*/
|
|
2448
|
+
function makeProp(obj: { [k: string]: any }, key: string, enumerable?: boolean): void;
|
|
2395
2449
|
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
function writeDoubleLE(val: number, buf: Uint8Array, pos: number): void;
|
|
2450
|
+
/**
|
|
2451
|
+
* Converts the first character of a string to lower case.
|
|
2452
|
+
* @param str String to convert
|
|
2453
|
+
* @returns Converted string
|
|
2454
|
+
*/
|
|
2455
|
+
function lcFirst(str: string): string;
|
|
2403
2456
|
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
function writeDoubleBE(val: number, buf: Uint8Array, pos: number): void;
|
|
2457
|
+
/**
|
|
2458
|
+
* Creates a custom error constructor.
|
|
2459
|
+
* @param name Error name
|
|
2460
|
+
* @returns Custom error constructor
|
|
2461
|
+
*/
|
|
2462
|
+
function newError(name: string): Constructor<Error>;
|
|
2411
2463
|
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
* @param buf Source buffer
|
|
2415
|
-
* @param pos Source buffer offset
|
|
2416
|
-
* @returns Value read
|
|
2417
|
-
*/
|
|
2418
|
-
function readDoubleLE(buf: Uint8Array, pos: number): number;
|
|
2464
|
+
/** Error subclass indicating a protocol specifc error. */
|
|
2465
|
+
class ProtocolError<T extends Message<T>> extends Error {
|
|
2419
2466
|
|
|
2420
2467
|
/**
|
|
2421
|
-
*
|
|
2422
|
-
* @param
|
|
2423
|
-
* @param
|
|
2424
|
-
* @returns Value read
|
|
2468
|
+
* Constructs a new protocol error.
|
|
2469
|
+
* @param message Error message
|
|
2470
|
+
* @param [properties] Additional properties
|
|
2425
2471
|
*/
|
|
2426
|
-
|
|
2427
|
-
}
|
|
2472
|
+
constructor(message: string, properties?: { [k: string]: any });
|
|
2428
2473
|
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
* @param options Fetch options
|
|
2433
|
-
* @param callback Callback function
|
|
2434
|
-
*/
|
|
2435
|
-
function fetch(filename: string, options: IFetchOptions, callback: FetchCallback): void;
|
|
2474
|
+
/** So far decoded message instance. */
|
|
2475
|
+
public instance: Message<T>;
|
|
2476
|
+
}
|
|
2436
2477
|
|
|
2437
2478
|
/**
|
|
2438
|
-
*
|
|
2439
|
-
* @param
|
|
2440
|
-
* @
|
|
2479
|
+
* Builds a getter for a oneof's present field name.
|
|
2480
|
+
* @param fieldNames Field names
|
|
2481
|
+
* @returns Unbound getter
|
|
2441
2482
|
*/
|
|
2442
|
-
function
|
|
2483
|
+
function oneOfGetter(fieldNames: string[]): OneOfGetter;
|
|
2443
2484
|
|
|
2444
2485
|
/**
|
|
2445
|
-
*
|
|
2446
|
-
* @param
|
|
2447
|
-
* @
|
|
2448
|
-
* @returns Promise
|
|
2486
|
+
* Builds a setter for a oneof's present field name.
|
|
2487
|
+
* @param fieldNames Field names
|
|
2488
|
+
* @returns Unbound setter
|
|
2449
2489
|
*/
|
|
2450
|
-
function
|
|
2490
|
+
function oneOfSetter(fieldNames: string[]): OneOfSetter;
|
|
2451
2491
|
|
|
2452
2492
|
/**
|
|
2453
|
-
*
|
|
2454
|
-
*
|
|
2455
|
-
*
|
|
2493
|
+
* Default conversion options used for {@link Message#toJSON} implementations.
|
|
2494
|
+
*
|
|
2495
|
+
* These options are close to proto3's JSON mapping with the exception that internal types like Any are handled just like messages. More precisely:
|
|
2496
|
+
*
|
|
2497
|
+
* - Longs become strings
|
|
2498
|
+
* - Enums become string keys
|
|
2499
|
+
* - Bytes become base64 encoded strings
|
|
2500
|
+
* - (Sub-)Messages become plain objects
|
|
2501
|
+
* - Maps become plain objects with all string keys
|
|
2502
|
+
* - Repeated fields become arrays
|
|
2503
|
+
* - NaN and Infinity for float and double fields become strings
|
|
2504
|
+
*
|
|
2505
|
+
* @see https://developers.google.com/protocol-buffers/docs/proto3?hl=en#json
|
|
2456
2506
|
*/
|
|
2457
|
-
|
|
2507
|
+
let toJSONOptions: IConversionOptions;
|
|
2458
2508
|
|
|
2459
2509
|
/** A minimal path module to resolve Unix, Windows and URL paths alike. */
|
|
2460
2510
|
namespace path {
|
|
@@ -2520,6 +2570,100 @@ export namespace util {
|
|
|
2520
2570
|
*/
|
|
2521
2571
|
function write(string: string, buffer: Uint8Array, offset: number): number;
|
|
2522
2572
|
}
|
|
2573
|
+
|
|
2574
|
+
/** Node's fs module if available. */
|
|
2575
|
+
let fs: { [k: string]: any };
|
|
2576
|
+
|
|
2577
|
+
/**
|
|
2578
|
+
* Checks a recursion depth.
|
|
2579
|
+
* @param depth Depth of recursion
|
|
2580
|
+
* @returns Depth of recursion
|
|
2581
|
+
* @throws {Error} If depth exceeds util.recursionLimit
|
|
2582
|
+
*/
|
|
2583
|
+
function checkDepth(depth: (number|undefined)): number;
|
|
2584
|
+
|
|
2585
|
+
/**
|
|
2586
|
+
* Converts an object's values to an array.
|
|
2587
|
+
* @param object Object to convert
|
|
2588
|
+
* @returns Converted array
|
|
2589
|
+
*/
|
|
2590
|
+
function toArray(object: { [k: string]: any }): any[];
|
|
2591
|
+
|
|
2592
|
+
/**
|
|
2593
|
+
* Converts an array of keys immediately followed by their respective value to an object, omitting undefined values.
|
|
2594
|
+
* @param array Array to convert
|
|
2595
|
+
* @returns Converted object
|
|
2596
|
+
*/
|
|
2597
|
+
function toObject(array: any[]): { [k: string]: any };
|
|
2598
|
+
|
|
2599
|
+
/**
|
|
2600
|
+
* Tests whether the specified name is a reserved word in JS.
|
|
2601
|
+
* @param name Name to test
|
|
2602
|
+
* @returns `true` if reserved, otherwise `false`
|
|
2603
|
+
*/
|
|
2604
|
+
function isReserved(name: string): boolean;
|
|
2605
|
+
|
|
2606
|
+
/**
|
|
2607
|
+
* Returns a safe property accessor for the specified property name.
|
|
2608
|
+
* @param prop Property name
|
|
2609
|
+
* @returns Safe accessor
|
|
2610
|
+
*/
|
|
2611
|
+
function safeProp(prop: string): string;
|
|
2612
|
+
|
|
2613
|
+
/**
|
|
2614
|
+
* Converts the first character of a string to upper case.
|
|
2615
|
+
* @param str String to convert
|
|
2616
|
+
* @returns Converted string
|
|
2617
|
+
*/
|
|
2618
|
+
function ucFirst(str: string): string;
|
|
2619
|
+
|
|
2620
|
+
/**
|
|
2621
|
+
* Converts a string to camel case.
|
|
2622
|
+
* @param str String to convert
|
|
2623
|
+
* @returns Converted string
|
|
2624
|
+
*/
|
|
2625
|
+
function camelCase(str: string): string;
|
|
2626
|
+
|
|
2627
|
+
/**
|
|
2628
|
+
* Compares reflected fields by id.
|
|
2629
|
+
* @param a First field
|
|
2630
|
+
* @param b Second field
|
|
2631
|
+
* @returns Comparison value
|
|
2632
|
+
*/
|
|
2633
|
+
function compareFieldsById(a: Field, b: Field): number;
|
|
2634
|
+
|
|
2635
|
+
/**
|
|
2636
|
+
* Decorator helper for types (TypeScript).
|
|
2637
|
+
* @param ctor Constructor function
|
|
2638
|
+
* @param [typeName] Type name, defaults to the constructor's name
|
|
2639
|
+
* @returns Reflected type
|
|
2640
|
+
* @deprecated Legacy TypeScript decorator support. Will be removed in a future release.
|
|
2641
|
+
*/
|
|
2642
|
+
function decorateType<T extends Message<T>>(ctor: Constructor<T>, typeName?: string): Type;
|
|
2643
|
+
|
|
2644
|
+
/**
|
|
2645
|
+
* Decorator helper for enums (TypeScript).
|
|
2646
|
+
* @param object Enum object
|
|
2647
|
+
* @returns Reflected enum
|
|
2648
|
+
* @deprecated Legacy TypeScript decorator support. Will be removed in a future release.
|
|
2649
|
+
*/
|
|
2650
|
+
function decorateEnum(object: object): Enum;
|
|
2651
|
+
|
|
2652
|
+
/**
|
|
2653
|
+
* Sets the value of a property by property path. If a value already exists, it is turned to an array
|
|
2654
|
+
* @param dst Destination object
|
|
2655
|
+
* @param path dot '.' delimited path of the property to set
|
|
2656
|
+
* @param value the value to set
|
|
2657
|
+
* @param [ifNotSet] Sets the option only if it isn't currently set
|
|
2658
|
+
* @returns Destination object
|
|
2659
|
+
*/
|
|
2660
|
+
function setProperty(dst: { [k: string]: any }, path: string, value: object, ifNotSet?: (boolean|undefined)): { [k: string]: any };
|
|
2661
|
+
|
|
2662
|
+
/**
|
|
2663
|
+
* Decorator root (TypeScript).
|
|
2664
|
+
* @deprecated Legacy TypeScript decorator support. Will be removed in a future release.
|
|
2665
|
+
*/
|
|
2666
|
+
let decorateRoot: Root;
|
|
2523
2667
|
}
|
|
2524
2668
|
|
|
2525
2669
|
/**
|
|
@@ -2691,6 +2835,13 @@ export class Writer {
|
|
|
2691
2835
|
*/
|
|
2692
2836
|
public bytes(value: (Uint8Array|string)): Writer;
|
|
2693
2837
|
|
|
2838
|
+
/**
|
|
2839
|
+
* Writes raw bytes without a tag or length prefix.
|
|
2840
|
+
* @param value Raw bytes
|
|
2841
|
+
* @returns `this`
|
|
2842
|
+
*/
|
|
2843
|
+
public raw(value: Uint8Array): Writer;
|
|
2844
|
+
|
|
2694
2845
|
/**
|
|
2695
2846
|
* Writes a string.
|
|
2696
2847
|
* @param value Value to write
|
|
@@ -2722,6 +2873,16 @@ export class Writer {
|
|
|
2722
2873
|
* @returns Finished buffer
|
|
2723
2874
|
*/
|
|
2724
2875
|
public finish(): Uint8Array;
|
|
2876
|
+
|
|
2877
|
+
/**
|
|
2878
|
+
* Finishes the write operation, writing into the provided buffer.
|
|
2879
|
+
* The caller must ensure that `buf` has enough space starting at `offset`
|
|
2880
|
+
* to hold {@link Writer#len} bytes.
|
|
2881
|
+
* @param buf Target buffer
|
|
2882
|
+
* @param [offset=0] Offset to start writing at
|
|
2883
|
+
* @returns The provided buffer
|
|
2884
|
+
*/
|
|
2885
|
+
public finishInto<T extends Uint8Array>(buf: T, offset?: number): T;
|
|
2725
2886
|
}
|
|
2726
2887
|
|
|
2727
2888
|
/** Wire format writer using node buffers. */
|
|
@@ -2737,63 +2898,16 @@ export class BufferWriter extends Writer {
|
|
|
2737
2898
|
*/
|
|
2738
2899
|
public static alloc(size: number): Buffer;
|
|
2739
2900
|
|
|
2901
|
+
/**
|
|
2902
|
+
* Writes raw bytes without a tag or length prefix.
|
|
2903
|
+
* @param value Raw bytes
|
|
2904
|
+
* @returns `this`
|
|
2905
|
+
*/
|
|
2906
|
+
public raw(value: Uint8Array): BufferWriter;
|
|
2907
|
+
|
|
2740
2908
|
/**
|
|
2741
2909
|
* Finishes the write operation.
|
|
2742
2910
|
* @returns Finished buffer
|
|
2743
2911
|
*/
|
|
2744
2912
|
public finish(): Buffer;
|
|
2745
2913
|
}
|
|
2746
|
-
|
|
2747
|
-
/**
|
|
2748
|
-
* Callback as used by {@link util.asPromise}.
|
|
2749
|
-
* @param error Error, if any
|
|
2750
|
-
* @param params Additional arguments
|
|
2751
|
-
*/
|
|
2752
|
-
type asPromiseCallback = (error: (Error|null), ...params: any[]) => void;
|
|
2753
|
-
|
|
2754
|
-
/**
|
|
2755
|
-
* Appends code to the function's body or finishes generation.
|
|
2756
|
-
* @param [formatStringOrScope] Format string or, to finish the function, an object of additional scope variables, if any
|
|
2757
|
-
* @param [formatParams] Format parameters
|
|
2758
|
-
* @returns Itself or the generated function if finished
|
|
2759
|
-
* @throws {Error} If format parameter counts do not match
|
|
2760
|
-
*/
|
|
2761
|
-
type Codegen = (formatStringOrScope?: (string|{ [k: string]: any }), ...formatParams: any[]) => (Codegen|Function);
|
|
2762
|
-
|
|
2763
|
-
/**
|
|
2764
|
-
* Event listener as used by {@link util.EventEmitter}.
|
|
2765
|
-
* @param args Arguments
|
|
2766
|
-
*/
|
|
2767
|
-
type EventEmitterListener = (...args: any[]) => void;
|
|
2768
|
-
|
|
2769
|
-
/**
|
|
2770
|
-
* Node-style callback as used by {@link util.fetch}.
|
|
2771
|
-
* @param error Error, if any, otherwise `null`
|
|
2772
|
-
* @param [contents] File contents, if there hasn't been an error
|
|
2773
|
-
*/
|
|
2774
|
-
type FetchCallback = (error: Error, contents?: string) => void;
|
|
2775
|
-
|
|
2776
|
-
/** Options as used by {@link util.fetch}. */
|
|
2777
|
-
export interface IFetchOptions {
|
|
2778
|
-
|
|
2779
|
-
/** Whether expecting a binary response */
|
|
2780
|
-
binary?: boolean;
|
|
2781
|
-
|
|
2782
|
-
/** If `true`, forces the use of XMLHttpRequest */
|
|
2783
|
-
xhr?: boolean;
|
|
2784
|
-
}
|
|
2785
|
-
|
|
2786
|
-
/**
|
|
2787
|
-
* An allocator as used by {@link util.pool}.
|
|
2788
|
-
* @param size Buffer size
|
|
2789
|
-
* @returns Buffer
|
|
2790
|
-
*/
|
|
2791
|
-
type PoolAllocator = (size: number) => Uint8Array;
|
|
2792
|
-
|
|
2793
|
-
/**
|
|
2794
|
-
* A slicer as used by {@link util.pool}.
|
|
2795
|
-
* @param start Start offset
|
|
2796
|
-
* @param end End offset
|
|
2797
|
-
* @returns Buffer slice
|
|
2798
|
-
*/
|
|
2799
|
-
type PoolSlicer = (this: Uint8Array, start: number, end: number) => Uint8Array;
|