1'use strict'; 2 3require('../common'); 4const assert = require('assert'); 5 6const b = Buffer.from('abcdf'); 7const c = Buffer.from('abcdf'); 8const d = Buffer.from('abcde'); 9const e = Buffer.from('abcdef'); 10 11assert.ok(b.equals(c)); 12assert.ok(!c.equals(d)); 13assert.ok(!d.equals(e)); 14assert.ok(d.equals(d)); 15assert.ok(d.equals(new Uint8Array([0x61, 0x62, 0x63, 0x64, 0x65]))); 16 17assert.throws( 18 () => Buffer.alloc(1).equals('abc'), 19 { 20 code: 'ERR_INVALID_ARG_TYPE', 21 name: 'TypeError', 22 message: 'The "otherBuffer" argument must be an instance of ' + 23 "Buffer or Uint8Array. Received type string ('abc')" 24 } 25); 26