Skip to content

Commit

Permalink
chore: fix linting though needs a new aegir
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain committed Nov 21, 2018
1 parent 1b2cf61 commit c0c48bd
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 18 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
"url": "https://github.com/ipfs-shipyard/js-hamt-sharding/issues"
},
"engines": {
"node": ">=8.0.0",
"npm": ">=3.0.0"
"node": ">=10.0.0",
"npm": ">=6.0.0"
},
"homepage": "https://github.com/ipfs-shipyard/js-hamt-sharding#readme",
"devDependencies": {
Expand Down
11 changes: 5 additions & 6 deletions src/bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ const defaultOptions = {
bits: 8
}

// TODO: make HAMT a generic NPM package

class Bucket {
constructor (options, parent, posAtParent) {
this._options = Object.assign({}, defaultOptions, options)
Expand Down Expand Up @@ -75,7 +73,7 @@ class Bucket {
async * eachLeafSeries () {
const children = this._children.compactArray()

for(const child of children) {
for (const child of children) {
if (child instanceof Bucket) {
for await (const c2 of child.eachLeafSeries()) {
yield c2
Expand Down Expand Up @@ -132,7 +130,7 @@ class Bucket {
const child = this._children.get(index)

if (child instanceof Bucket) {
return await child._findPlace(hashValue)
return child._findPlace(hashValue)
}

return {
Expand All @@ -156,7 +154,7 @@ class Bucket {
const newPlace = await bucket._findPlace(child.hash)
newPlace.bucket._putAt(newPlace, child.key, child.value)

return await bucket._findNewBucketAndPos(place.hash)
return bucket._findNewBucketAndPos(place.hash)
}

// no conflict, we found the place
Expand Down Expand Up @@ -191,6 +189,7 @@ class Bucket {
if (this._popCount === 1) {
// remove myself from parent, replacing me with my only child
const onlyChild = this._children.find(exists)

if (!(onlyChild instanceof Bucket)) {
const hash = onlyChild.hash
hash.untake(this._options.bits)
Expand Down Expand Up @@ -226,7 +225,7 @@ function reduceNodes (nodes) {
async function asyncTransformBucket (bucket, asyncMap, asyncReduce) {
const output = []

for(const child of bucket._children.compactArray()) {
for (const child of bucket._children.compactArray()) {
if (child instanceof Bucket) {
await asyncTransformBucket(child, asyncMap, asyncReduce)
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/consumable-hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ class InfiniteHash {
async take (bits) {
let pendingBits = bits

while(this._availableBits < pendingBits) {
while (this._availableBits < pendingBits) {
await this._produceMoreBits()
}

let result = 0

while(pendingBits > 0) {
while (pendingBits > 0) {
const hash = this._buffers[this._currentBufferIndex]
const available = Math.min(hash.availableBits(), pendingBits)
const took = hash.take(available)
Expand Down
8 changes: 4 additions & 4 deletions test/hamt-consumable-hash.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const crypto = require('crypto')
const ConsumableHash = require('../src/consumable-hash')

describe('HAMT: consumable hash', () => {
let hash, h
let hash

beforeEach(() => {
hash = ConsumableHash(hashFn)
Expand Down Expand Up @@ -41,7 +41,7 @@ describe('HAMT: consumable hash', () => {
let iter = 100
const h = hash('some value')

while(iter > 0) {
while (iter > 0) {
const result = await h.take(10)

expect(result).to.be.below(1024)
Expand All @@ -63,14 +63,14 @@ describe('HAMT: consumable hash', () => {
const values = []
const h = hash('some value')

while(iter > 0) {
while (iter > 0) {
values.push(await h.take(10))
iter--
}

h.untake(10 * 100)

while(iter > 0) {
while (iter > 0) {
const result = h.take(10)

values.push(result)
Expand Down
8 changes: 4 additions & 4 deletions test/hamt.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ describe('HAMT', () => {
expect(bucket.leafCount()).to.eql(0)

// insert enough keys to cause multiple buckets to be created
const keys = await insertKeys(400, bucket)
await insertKeys(400, bucket)

expect(bucket.leafCount()).to.eql(22622)
})
Expand All @@ -118,7 +118,7 @@ describe('HAMT', () => {
expect(bucket.leafCount()).to.eql(0)

// insert enough keys to cause multiple buckets to be created
const keys = await insertKeys(400, bucket)
await insertKeys(400, bucket)

expect(bucket.childrenCount()).to.eql(256)
})
Expand All @@ -134,9 +134,9 @@ describe('HAMT', () => {
let childCount = 0

// insert enough keys to cause multiple buckets to be created
const keys = await insertKeys(expectedCount, bucket)
await insertKeys(expectedCount, bucket)

for await (const child of bucket.eachLeafSeries()) {
for await (const child of bucket.eachLeafSeries()) { // eslint-disable-line no-unused-vars
childCount++
}

Expand Down

0 comments on commit c0c48bd

Please sign in to comment.