Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dont use const or let, enforce in linter #62

Merged
merged 2 commits into from Oct 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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