From d8d8647b2066b4bba6fa71a8527a81289535fd7e Mon Sep 17 00:00:00 2001 From: Francis Gulotta Date: Thu, 4 Oct 2018 21:58:32 -0400 Subject: [PATCH] Add indexof docs --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 5f2b341..f1c4d77 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,9 @@ console.log(bl.slice(3, 6).toString('ascii')) // 'def' console.log(bl.slice(3, 8).toString('ascii')) // 'defgh' console.log(bl.slice(5, 10).toString('ascii')) // 'fghij' +console.log(bl.indexOf('def')) // 3 +console.log(bl.indexOf('asdf')) // -1 + // or just use toString! console.log(bl.toString()) // 'abcdefghij\u0003\u0004' console.log(bl.toString('ascii', 3, 8)) // 'defgh' @@ -86,6 +89,7 @@ bl.pipe(fs.createWriteStream('gibberish.txt')) * bl.length * bl.append(buffer) * bl.get(index) + * bl.indexOf(value[, byteOffset][, encoding]) * bl.slice([ start[, end ] ]) * bl.shallowSlice([ start[, end ] ]) * bl.copy(dest, [ destStart, [ srcStart [, srcEnd ] ] ]) @@ -129,6 +133,12 @@ Get the length of the list in bytes. This is the sum of the lengths of all of th ### bl.get(index) `get()` will return the byte at the specified index. +-------------------------------------------------------- + +### bl.indexOf(value[, byteOffset][, encoding]) +`get()` will return the byte at the specified index. +`indexOf()` method returns the first index at which a given element can be found in the BufferList, or -1 if it is not present. + -------------------------------------------------------- ### bl.slice([ start, [ end ] ])