bl 2.1.1 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.jshintrc +2 -1
- package/bl.js +12 -12
- package/package.json +1 -1
package/.jshintrc
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
, "boss": true
|
|
23
23
|
, "debug": true
|
|
24
24
|
, "eqnull": true
|
|
25
|
-
, "esnext":
|
|
25
|
+
, "esnext": false
|
|
26
26
|
, "evil": true
|
|
27
27
|
, "expr": true
|
|
28
28
|
, "funcscope": false
|
|
@@ -56,4 +56,5 @@
|
|
|
56
56
|
, "nomen": false
|
|
57
57
|
, "onevar": false
|
|
58
58
|
, "passfail": false
|
|
59
|
+
, "esversion": 3
|
|
59
60
|
}
|
package/bl.js
CHANGED
|
@@ -50,9 +50,9 @@ BufferList.prototype._offset = function _offset (offset) {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
BufferList.prototype._reverseOffset = function (blOffset) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
for (
|
|
53
|
+
var bufferId = blOffset[0]
|
|
54
|
+
var offset = blOffset[1]
|
|
55
|
+
for (var i = 0; i < bufferId; i++) {
|
|
56
56
|
offset += this._bufs[i].length
|
|
57
57
|
}
|
|
58
58
|
return offset
|
|
@@ -121,7 +121,7 @@ BufferList.prototype.get = function get (index) {
|
|
|
121
121
|
if (index > this.length || index < 0) {
|
|
122
122
|
return undefined
|
|
123
123
|
}
|
|
124
|
-
|
|
124
|
+
var offset = this._offset(index)
|
|
125
125
|
return this._bufs[offset[0]][offset[1]]
|
|
126
126
|
}
|
|
127
127
|
|
|
@@ -297,23 +297,23 @@ BufferList.prototype.indexOf = function (search, offset, encoding) {
|
|
|
297
297
|
return offset > this.length ? this.length : offset
|
|
298
298
|
}
|
|
299
299
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
300
|
+
var blOffset = this._offset(offset)
|
|
301
|
+
var blIndex = blOffset[0] // index of which internal buffer we're working on
|
|
302
|
+
var buffOffset = blOffset[1] // offset of the internal buffer we're working on
|
|
303
303
|
|
|
304
304
|
// scan over each buffer
|
|
305
305
|
for (blIndex; blIndex < this._bufs.length; blIndex++) {
|
|
306
|
-
|
|
306
|
+
var buff = this._bufs[blIndex]
|
|
307
307
|
while(buffOffset < buff.length) {
|
|
308
|
-
|
|
308
|
+
var availableWindow = buff.length - buffOffset
|
|
309
309
|
if (availableWindow >= search.length) {
|
|
310
|
-
|
|
310
|
+
var nativeSearchResult = buff.indexOf(search, buffOffset)
|
|
311
311
|
if (nativeSearchResult !== -1) {
|
|
312
312
|
return this._reverseOffset([blIndex, nativeSearchResult])
|
|
313
313
|
}
|
|
314
314
|
buffOffset = buff.length - search.length + 1 // end of native search window
|
|
315
315
|
} else {
|
|
316
|
-
|
|
316
|
+
var revOffset = this._reverseOffset([blIndex, buffOffset])
|
|
317
317
|
if (this._match(revOffset, search)) {
|
|
318
318
|
return revOffset
|
|
319
319
|
}
|
|
@@ -329,7 +329,7 @@ BufferList.prototype._match = function(offset, search) {
|
|
|
329
329
|
if (this.length - offset < search.length) {
|
|
330
330
|
return false
|
|
331
331
|
}
|
|
332
|
-
for (
|
|
332
|
+
for (var searchOffset = 0; searchOffset < search.length ; searchOffset++) {
|
|
333
333
|
if(this.get(offset + searchOffset) !== search[searchOffset]){
|
|
334
334
|
return false
|
|
335
335
|
}
|