From 043f7dd6ec5abd786b2b4b012b82091a39e93a87 Mon Sep 17 00:00:00 2001 From: Rod Machen Date: Wed, 28 Oct 2015 11:46:41 -0500 Subject: [PATCH] buffer: Add Buffer#includes() --- lib/buffer.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/buffer.js b/lib/buffer.js index 3668494334a666..59e8598a41891a 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -428,6 +428,14 @@ Buffer.prototype.indexOf = function indexOf(val, byteOffset) { throw new TypeError('val must be string, number or Buffer'); }; +Buffer.prototype.includes = function includes(val) { + if (this.indexOf(val) === -1) + return false; + else + return true; + + throw new TypeError('val must be number'); +}; Buffer.prototype.fill = function fill(val, start, end) { start = start >> 0;