详解nodeJS之二进制buffer对象(6)

var buf = Buffer.from('this is a buffer'); // 输出: true console.log(buf.includes('this')); // 输出: true console.log(buf.includes('is')); // 输出: true console.log(buf.includes(Buffer.from('a buffer'))); // 输出: true // (97 是 'a' 的十进制 ASCII 值) console.log(buf.includes(97)); // 输出: false console.log(buf.includes(Buffer.from('a buffer example'))); // 输出: true console.log(buf.includes(Buffer.from('a buffer example').slice(0, 8))); // 输出: false console.log(buf.includes('this', 4));

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wyxxjd.html