diff options
author | Trevor Norris <trev.norris@gmail.com> | 2016-01-21 13:51:09 -0700 |
---|---|---|
committer | Trevor Norris <trev.norris@gmail.com> | 2016-01-22 11:32:16 -0700 |
commit | 7240ad44413a096f6611afbcf356acedd8867fa7 (patch) | |
tree | ab419de07d911fe5aacbb998887fcd9dc6900e8f /test | |
parent | 6712a1faa5c3242805bd775cf0f21c45b569b890 (diff) | |
download | node-new-7240ad44413a096f6611afbcf356acedd8867fa7.tar.gz |
buffer: allow encoding param to collapse
Currently the signature is indexOf(val[, byteOffset[, encoding]])
Instead allow indexOf(val[, byteOffset][, encoding])
so that byteOffset does not need to be passed.
PR-URL: https://github.com/nodejs/node/pull/4803
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-buffer-indexof.js | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/test/parallel/test-buffer-indexof.js b/test/parallel/test-buffer-indexof.js index aac5b18f71..83776be80a 100644 --- a/test/parallel/test-buffer-indexof.js +++ b/test/parallel/test-buffer-indexof.js @@ -111,6 +111,11 @@ assert.equal( .indexOf(Buffer('d', 'binary'), 0, 'binary'), 3); +// test optional offset with passed encoding +assert.equal(new Buffer('aaaa0').indexOf('30', 'hex'), 4); +assert.equal(new Buffer('aaaa00a').indexOf('3030', 'hex'), 4); + + // test usc2 encoding var twoByteString = new Buffer('\u039a\u0391\u03a3\u03a3\u0395', 'ucs2'); |