@@ -593,6 +593,46 @@ for (var key of buf.keys()) {
593
593
// 5
594
594
```
595
595
596
+ ### buf.lastIndexOf(value[ , byteOffset] [ , encoding ] )
597
+
598
+ * ` value ` {String|Buffer|Number}
599
+ * ` byteOffset ` {Number} Default: ` buf.length `
600
+ * ` encoding ` {String} Default: ` 'utf8' `
601
+ * Return: {Number}
602
+
603
+ Identical to [ ` Buffer#indexOf() ` ] [ ] , but searches the Buffer from back to front
604
+ instead of front to back. Returns the starting index position of ` value ` in
605
+ Buffer or ` -1 ` if the Buffer does not contain ` value ` . The ` value ` can be a
606
+ String, Buffer or Number. Strings are by default interpreted as UTF8. If
607
+ ` byteOffset ` is provided, will return the last match that begins at or before
608
+ ` byteOffset ` .
609
+
610
+ ``` js
611
+ const buf = new Buffer (' this buffer is a buffer' );
612
+
613
+ buf .lastIndexOf (' this' );
614
+ // returns 0
615
+ buf .lastIndexOf (' buffer' );
616
+ // returns 17
617
+ buf .lastIndexOf (new Buffer (' buffer' ));
618
+ // returns 17
619
+ buf .lastIndexOf (97 ); // ascii for 'a'
620
+ // returns 15
621
+ buf .lastIndexOf (new Buffer (' yolo' ));
622
+ // returns -1
623
+ buf .lastIndexOf (' buffer' , 5 )
624
+ // returns 5
625
+ buf .lastIndexOf (' buffer' , 4 )
626
+ // returns -1
627
+
628
+ const utf16Buffer = new Buffer (' \u039a\u0391\u03a3\u03a3\u0395 ' , ' ucs2' );
629
+
630
+ utf16Buffer .lastIndexOf (' \u03a3 ' , null , ' ucs2' );
631
+ // returns 6
632
+ utf16Buffer .lastIndexOf (' \u03a3 ' , - 5 , ' ucs2' );
633
+ // returns 4
634
+ ```
635
+
596
636
### buf.length
597
637
598
638
* {Number}
0 commit comments