Skip to content

Commit

Permalink
remove bops, close #4
Browse files Browse the repository at this point in the history
  • Loading branch information
mourner committed Mar 15, 2016
1 parent d1d8d0b commit 92c6216
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
9 changes: 4 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
var bops = require('bops')
var through = require('through2')
var os = require('os')

module.exports = BinarySplit

function BinarySplit (matcher) {
if (!(this instanceof BinarySplit)) return new BinarySplit(matcher)
matcher = bops.from(matcher || os.EOL)
matcher = Buffer(matcher || os.EOL)
var buffered
var bufcount = 0
return through(write, end)
Expand All @@ -16,19 +15,19 @@ function BinarySplit (matcher) {
var offset = 0
var lastMatch = 0
if (buffered) {
buf = bops.join([buffered, buf])
buf = Buffer.concat([buffered, buf])
offset = buffered.length
buffered = undefined
}

while (true) {
var idx = firstMatch(buf, offset)
if (idx !== -1 && idx < buf.length) {
this.push(bops.subarray(buf, lastMatch, idx))
this.push(buf.slice(lastMatch, idx))
offset = idx + matcher.length
lastMatch = offset
} else {
buffered = bops.subarray(buf, lastMatch)
buffered = buf.slice(lastMatch)
break
}
}
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"url": "https://github.com/maxogden/binary-split/issues"
},
"dependencies": {
"bops": "0.1.1",
"through2": "^2.0.0"
},
"devDependencies": {
Expand Down

0 comments on commit 92c6216

Please sign in to comment.