Skip to content

Commit

Permalink
Merge pull request #62 from jhaenchen/DontUseES2015Const
Browse files Browse the repository at this point in the history
Dont use const or let, enforce in linter
  • Loading branch information
mcollina committed Oct 12, 2018
2 parents 6702c3a + ccb664b commit 91cbaf9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
3 changes: 2 additions & 1 deletion .jshintrc
Expand Up @@ -22,7 +22,7 @@
, "boss": true
, "debug": true
, "eqnull": true
, "esnext": true
, "esnext": false
, "evil": true
, "expr": true
, "funcscope": false
Expand Down Expand Up @@ -56,4 +56,5 @@
, "nomen": false
, "onevar": false
, "passfail": false
, "esversion": 3
}
24 changes: 12 additions & 12 deletions bl.js
Expand Up @@ -50,9 +50,9 @@ BufferList.prototype._offset = function _offset (offset) {
}

BufferList.prototype._reverseOffset = function (blOffset) {
const bufferId = blOffset[0]
let offset = blOffset[1]
for (let i = 0; i < bufferId; i++) {
var bufferId = blOffset[0]
var offset = blOffset[1]
for (var i = 0; i < bufferId; i++) {
offset += this._bufs[i].length
}
return offset
Expand Down Expand Up @@ -121,7 +121,7 @@ BufferList.prototype.get = function get (index) {
if (index > this.length || index < 0) {
return undefined
}
const offset = this._offset(index)
var offset = this._offset(index)
return this._bufs[offset[0]][offset[1]]
}

Expand Down Expand Up @@ -297,23 +297,23 @@ BufferList.prototype.indexOf = function (search, offset, encoding) {
return offset > this.length ? this.length : offset
}

const blOffset = this._offset(offset)
let blIndex = blOffset[0] // index of which internal buffer we're working on
let buffOffset = blOffset[1] // offset of the internal buffer we're working on
var blOffset = this._offset(offset)
var blIndex = blOffset[0] // index of which internal buffer we're working on
var buffOffset = blOffset[1] // offset of the internal buffer we're working on

// scan over each buffer
for (blIndex; blIndex < this._bufs.length; blIndex++) {
const buff = this._bufs[blIndex]
var buff = this._bufs[blIndex]
while(buffOffset < buff.length) {
const availableWindow = buff.length - buffOffset
var availableWindow = buff.length - buffOffset
if (availableWindow >= search.length) {
const nativeSearchResult = buff.indexOf(search, buffOffset)
var nativeSearchResult = buff.indexOf(search, buffOffset)
if (nativeSearchResult !== -1) {
return this._reverseOffset([blIndex, nativeSearchResult])
}
buffOffset = buff.length - search.length + 1 // end of native search window
} else {
const revOffset = this._reverseOffset([blIndex, buffOffset])
var revOffset = this._reverseOffset([blIndex, buffOffset])
if (this._match(revOffset, search)) {
return revOffset
}
Expand All @@ -329,7 +329,7 @@ BufferList.prototype._match = function(offset, search) {
if (this.length - offset < search.length) {
return false
}
for (let searchOffset = 0; searchOffset < search.length ; searchOffset++) {
for (var searchOffset = 0; searchOffset < search.length ; searchOffset++) {
if(this.get(offset + searchOffset) !== search[searchOffset]){
return false
}
Expand Down

0 comments on commit 91cbaf9

Please sign in to comment.