Skip to content

Commit 0d919c1

Browse files
committed
add the Integer library
1 parent 9ccde39 commit 0d919c1

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

packages/webchannel-wrapper/src/index.d.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,18 @@ export class Md5 {
143143
digest(): Array<number>;
144144
update(bytes: Array<number> | Uint8Array | string, opt_length?: number): void;
145145
}
146+
147+
// See https://google.github.io/closure-library/api/goog.math.Integer.html
148+
// Unit test are written in
149+
// packages/firestore/test/unit/core/webchannel_wrapper.test.ts
150+
export class Integer {
151+
constructor(bits: Array<number>, sign: number);
152+
add(other: Integer): Integer;
153+
multiply(other: Integer): Integer;
154+
modulo(other: Integer): Integer;
155+
compare(other: Integer): number;
156+
toNumber(): number;
157+
toString(opt_radix?: number): string;
158+
static fromNumber(value: number): Integer;
159+
static fromString(str: string, opt_radix?: number): Integer;
160+
}

packages/webchannel-wrapper/src/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,16 @@ goog.crypt.Md5.prototype['digest'] = goog.crypt.Md5.prototype.digest;
8383
goog.crypt.Md5.prototype['reset'] = goog.crypt.Md5.prototype.reset;
8484
goog.crypt.Md5.prototype['update'] = goog.crypt.Md5.prototype.update;
8585

86+
goog.require('goog.math.Integer');
87+
goog.math.Integer.prototype['add'] = goog.math.Integer.prototype.add;
88+
goog.math.Integer.prototype['multiply'] = goog.math.Integer.prototype.multiply;
89+
goog.math.Integer.prototype['modulo'] = goog.math.Integer.prototype.modulo;
90+
goog.math.Integer.prototype['compare'] = goog.math.Integer.prototype.compare;
91+
goog.math.Integer.prototype['toNumber'] = goog.math.Integer.prototype.toNumber;
92+
goog.math.Integer.prototype['toString'] = goog.math.Integer.prototype.toString;
93+
goog.math.Integer['fromNumber'] = goog.math.Integer.fromNumber;
94+
goog.math.Integer['fromString'] = goog.math.Integer.fromString;
95+
8696
module['exports']['createWebChannelTransport'] =
8797
goog.net.createWebChannelTransport;
8898
module['exports']['getStatEventTarget'] =
@@ -95,3 +105,4 @@ module['exports']['FetchXmlHttpFactory'] = goog.net.FetchXmlHttpFactory;
95105
module['exports']['WebChannel'] = goog.net.WebChannel;
96106
module['exports']['XhrIo'] = goog.net.XhrIo;
97107
module['exports']['Md5'] = goog.crypt.Md5;
108+
module['exports']['Integer'] = goog.math.Integer;

0 commit comments

Comments
 (0)