Update protobufjs.d.ts

This PR includes the [ProtoBuf.Long](https://github.com/dcodeIO/ProtoBuf.js/blob/master/src/ProtoBuf.js#L19) property.  I based the definition on the existing long.d.ts.  I didn't use it directly because I didn't want to create a dependency and because the long.d.ts would have to be changed to do this in the first place.

@panuhorsmalahti - does this look okay to you?
This commit is contained in:
John Reilly 2015-08-05 13:27:04 +01:00
parent 147cc7a8b3
commit 4ded082c5d

View File

@ -11,6 +11,7 @@ declare module ProtoBuf {
var Builder: Builder;
var ByteBuffer: Buffer;
var Long: LongStatic;
var DotProto: DotProto;
var Reflect: Reflect;
@ -33,6 +34,69 @@ declare module ProtoBuf {
export function newBuilder(options?: {[key: string]: any}): ProtoBuilder;
export interface LongStatic {
new(low?: number, high?: number, unsigned?:boolean): Long;
MAX_UNSIGNED_VALUE: Long;
MAX_VALUE: Long;
MIN_VALUE: Long;
NEG_ONE: Long;
ONE: Long;
UONE: Long;
UZERO: Long;
ZERO: Long;
fromBits(lowBits: number, highBits: number, unsigned?: boolean): Long;
fromInt(value: number, unsigned?: boolean): Long;
fromNumber(value: number, unsigned?: boolean): Long;
fromString(str: string, unsigned?: boolean | number, radix?: number): Long;
fromValue(val: Long | number | string): Long;
isLong(obj: any): boolean;
}
// Based on https://github.com/dcodeIO/Long.js and https://github.com/borisyankov/DefinitelyTyped/blob/master/long/long.d.ts
export interface Long {
high: number;
low: number;
unsigned :boolean;
add(other: Long | number | string): Long;
and(other: Long | number | string): Long;
compare(other: Long | number | string): number;
div(divisor: Long | number | string): Long;
equals(other: Long | number | string): boolean;
getHighBits(): number;
getHighBitsUnsigned(): number;
getLowBits(): number;
getLowBitsUnsigned(): number;
getNumBitsAbs(): number;
greaterThan(other: Long | number | string): boolean;
greaterThanOrEqual(other: Long | number | string): boolean;
isEven(): boolean;
isNegative(): boolean;
isOdd(): boolean;
isPositive(): boolean;
isZero(): boolean;
lessThan(other: Long | number | string): boolean;
lessThanOrEqual(other: Long | number | string): boolean;
modulo(divisor: Long | number | string): Long;
multiply(multiplier: Long | number | string): Long;
negate(): Long;
not(): Long;
notEquals(other: Long | number | string): boolean;
or(other: Long | number | string): Long;
shiftLeft(numBits: number | Long): Long;
shiftRight(numBits: number | Long): Long;
shiftRightUnsigned(numBits: number | Long): Long;
subtract(other: Long | number | string): Long;
toInt(): number;
toNumber(): number;
toSigned(): Long;
toString(radix?: number): string;
toUnsigned(): Long;
xor(other: Long | number | string): Long;
}
// ==========
// protobufjs/src/ProtoBuf/Builder.js