Skip to content

Commit

Permalink
fix: buffer instanceof usage (#9235)
Browse files Browse the repository at this point in the history
Closes #5782
  • Loading branch information
ludamad authored Oct 14, 2024
1 parent 155b40b commit 8e66ef9
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion yarn-project/foundation/src/fields/fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ abstract class BaseField {
}

protected constructor(value: number | bigint | boolean | BaseField | Buffer) {
if (value instanceof Buffer) {
if (Buffer.isBuffer(value)) {
if (value.length > BaseField.SIZE_IN_BYTES) {
throw new Error(`Value length ${value.length} exceeds ${BaseField.SIZE_IN_BYTES}`);
}
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/foundation/src/json-rpc/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export function convertToJsonObj(cc: ClassConverter, obj: any): any {
}

// Is this a Node buffer?
if (obj instanceof Buffer) {
if (Buffer.isBuffer(obj)) {
return { type: 'Buffer', data: obj.toString('base64') };
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ function writeBigInt128BE(this: Buffer, value: bigint): void {
*/
export function deserialize(cursor: BufferCursor | Buffer, operands: OperandType[]): (number | bigint)[] {
const argValues = [];
if (cursor instanceof Buffer) {
if (Buffer.isBuffer(cursor)) {
cursor = new BufferCursor(cursor);
}

Expand Down

0 comments on commit 8e66ef9

Please sign in to comment.