Skip to content

Commit 732b12e

Browse files
committed
remove onDemand accessors
1 parent 74fc9e3 commit 732b12e

5 files changed

Lines changed: 18 additions & 18 deletions

File tree

src/bson.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,32 +38,32 @@ export function parseToElementsToArray(bytes: Uint8Array, offset?: number): BSON
3838
return Array.isArray(res) ? res : [...res];
3939
}
4040

41-
export const getInt32LE = BSON.onDemand.NumberUtils.getInt32LE;
42-
export const getFloat64LE = BSON.onDemand.NumberUtils.getFloat64LE;
43-
export const getBigInt64LE = BSON.onDemand.NumberUtils.getBigInt64LE;
44-
export const toUTF8 = BSON.onDemand.ByteUtils.toUTF8;
41+
export const getInt32LE = BSON.NumberUtils.getInt32LE;
42+
export const getFloat64LE = BSON.NumberUtils.getFloat64LE;
43+
export const getBigInt64LE = BSON.NumberUtils.getBigInt64LE;
44+
export const toUTF8 = BSON.ByteUtils.toUTF8;
4545

4646
// BSON wrappers
4747

4848
// writeInt32LE, same order of arguments as Buffer.writeInt32LE
4949
export const writeInt32LE = (destination: Uint8Array, value: number, offset: number) =>
50-
BSON.onDemand.NumberUtils.setInt32LE(destination, offset, value);
50+
BSON.NumberUtils.setInt32LE(destination, offset, value);
5151

5252
// various wrappers that consume and return local buffer types
5353

5454
export const fromUTF8 = (text: string) =>
55-
ByteUtils.toLocalBufferType(BSON.onDemand.ByteUtils.fromUTF8(text));
55+
ByteUtils.toLocalBufferType(BSON.ByteUtils.fromUTF8(text));
5656
export const fromBase64 = (b64: string) =>
57-
ByteUtils.toLocalBufferType(BSON.onDemand.ByteUtils.fromBase64(b64));
57+
ByteUtils.toLocalBufferType(BSON.ByteUtils.fromBase64(b64));
5858
export const fromNumberArray = (array: number[]) =>
59-
ByteUtils.toLocalBufferType(BSON.onDemand.ByteUtils.fromNumberArray(array));
59+
ByteUtils.toLocalBufferType(BSON.ByteUtils.fromNumberArray(array));
6060
export const concatBuffers = (list: Uint8Array[]) => {
61-
return ByteUtils.toLocalBufferType(BSON.onDemand.ByteUtils.concat(list));
61+
return ByteUtils.toLocalBufferType(BSON.ByteUtils.concat(list));
6262
};
6363
export const allocateBuffer = (size: number) =>
64-
ByteUtils.toLocalBufferType(BSON.onDemand.ByteUtils.allocate(size));
64+
ByteUtils.toLocalBufferType(BSON.ByteUtils.allocate(size));
6565
export const allocateUnsafeBuffer = (size: number) =>
66-
ByteUtils.toLocalBufferType(BSON.onDemand.ByteUtils.allocateUnsafe(size));
66+
ByteUtils.toLocalBufferType(BSON.ByteUtils.allocateUnsafe(size));
6767

6868
// validates buffer inputs, used for read operations
6969
const validateBufferInputs = (buffer: Uint8Array, offset: number, length: number) => {

src/cmap/auth/aws4.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export type SignedHeaders = {
3131
const getHexSha256 = async (str: string): Promise<string> => {
3232
const data = stringToBuffer(str);
3333
const hashBuffer = await crypto.subtle.digest('SHA-256', data);
34-
const hashHex = BSON.onDemand.ByteUtils.toHex(new Uint8Array(hashBuffer));
34+
const hashHex = BSON.ByteUtils.toHex(new Uint8Array(hashBuffer));
3535
return hashHex;
3636
};
3737

@@ -81,8 +81,8 @@ const convertHeaderValue = (value: string | number) => {
8181
* @returns Uint8Array containing the UTF-8 encoded string.
8282
*/
8383
function stringToBuffer(str: string): Uint8Array {
84-
const data = new Uint8Array(BSON.onDemand.ByteUtils.utf8ByteLength(str));
85-
BSON.onDemand.ByteUtils.encodeUTF8Into(data, str, 0);
84+
const data = new Uint8Array(BSON.ByteUtils.utf8ByteLength(str));
85+
BSON.ByteUtils.encodeUTF8Into(data, str, 0);
8686
return data;
8787
}
8888

@@ -189,7 +189,7 @@ export async function aws4Sign(
189189

190190
// 5. Calculate the signature
191191
const signatureBuffer = await getHmacSha256(signingKey, stringToSign);
192-
const signature = BSON.onDemand.ByteUtils.toHex(signatureBuffer);
192+
const signature = BSON.ByteUtils.toHex(signatureBuffer);
193193

194194
// 6. Add the signature to the request
195195
// Calculate the Authorization header

src/cmap/commands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const QUERY_FAILURE = 2;
4040
const SHARD_CONFIG_STALE = 4;
4141
const AWAIT_CAPABLE = 8;
4242

43-
const encodeUTF8Into = BSON.onDemand.ByteUtils.encodeUTF8Into;
43+
const encodeUTF8Into = BSON.ByteUtils.encodeUTF8Into;
4444

4545
/** @internal */
4646
export type WriteProtocolMessageType = OpQueryRequest | OpMsgRequest;

src/cmap/connection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ function streamIdentifier(stream: Stream, options: ConnectionOptions): string {
176176
return HostAddress.fromHostPort(remoteAddress, remotePort).toString();
177177
}
178178

179-
return BSON.onDemand.ByteUtils.toHex(uuidV4());
179+
return BSON.ByteUtils.toHex(uuidV4());
180180
}
181181

182182
/** @internal */

src/cmap/handshake/client_metadata.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export async function makeClientMetadata(
114114
// Add app name first, it must be sent
115115
if (appName.length > 0) {
116116
const name =
117-
BSON.onDemand.ByteUtils.utf8ByteLength(appName) <= 128
117+
BSON.ByteUtils.utf8ByteLength(appName) <= 128
118118
? appName
119119
: toUTF8(fromUTF8(appName), 0, 128, false);
120120
metadataDocument.ifItFitsItSits('application', { name });

0 commit comments

Comments
 (0)