buf.includes(value[, byteOffset][, encoding])
Operates similar to Array#includes()
. The value
can be a String, Buffer or Number. Strings are interpreted as UTF8 unless overridden with the encoding
argument. Buffers will use the entire Buffer (to compare a partial Buffer use buf.slice()
). Numbers can range from 0 to 255.
The byteOffset
indicates the index in buf
where searching begins.
const buf = Buffer.from('this is a buffer'); buf.includes('this'); // returns true buf.includes('is'); // returns true buf.includes(Buffer.from('a buffer')); // returns true buf.includes(97); // ascii for 'a' // returns true buf.includes(Buffer.from('a buffer example')); // returns false buf.includes(Buffer.from('a buffer example').slice(0,8)); // returns true buf.includes('this', 4); // returns false
Please login to continue.