Skip to content

Commit 109ff93

Browse files
committed
standard: --fix for standard@11
1 parent 3817b7a commit 109ff93

File tree

10 files changed

+112
-112
lines changed

10 files changed

+112
-112
lines changed

get.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ function getData (byDigest, cache, key, opts) {
2020
opts = opts || {}
2121
const memoized = (
2222
byDigest
23-
? memo.get.byDigest(cache, key, opts)
24-
: memo.get(cache, key, opts)
23+
? memo.get.byDigest(cache, key, opts)
24+
: memo.get(cache, key, opts)
2525
)
2626
if (memoized && opts.memoize !== false) {
2727
return BB.resolve(byDigest ? memoized : {
@@ -180,11 +180,11 @@ function copy (byDigest, cache, key, dest, opts) {
180180
} else {
181181
return getData(byDigest, cache, key, opts).then(res => {
182182
return fs.writeFileAsync(dest, byDigest ? res : res.data)
183-
.then(() => byDigest ? key : {
184-
metadata: res.metadata,
185-
size: res.size,
186-
integrity: res.integrity
187-
})
183+
.then(() => byDigest ? key : {
184+
metadata: res.metadata,
185+
size: res.size,
186+
integrity: res.integrity
187+
})
188188
})
189189
}
190190
}

lib/content/read.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,17 @@ module.exports.hasContent = hasContent
6868
function hasContent (cache, integrity) {
6969
if (!integrity) { return BB.resolve(false) }
7070
return pickContentSri(cache, integrity)
71-
.catch({code: 'ENOENT'}, () => false)
72-
.catch({code: 'EPERM'}, err => {
73-
if (process.platform !== 'win32') {
74-
throw err
75-
} else {
76-
return false
77-
}
78-
}).then(content => {
79-
if (!content.sri) return false
80-
return ({ sri: content.sri, size: content.stat.size })
81-
})
71+
.catch({code: 'ENOENT'}, () => false)
72+
.catch({code: 'EPERM'}, err => {
73+
if (process.platform !== 'win32') {
74+
throw err
75+
} else {
76+
return false
77+
}
78+
}).then(content => {
79+
if (!content.sri) return false
80+
return ({ sri: content.sri, size: content.stat.size })
81+
})
8282
}
8383

8484
module.exports._pickContentSri = pickContentSri
@@ -95,16 +95,16 @@ function pickContentSri (cache, integrity) {
9595
return BB.any(sri[sri.pickAlgorithm()].map(meta => {
9696
return pickContentSri(cache, meta)
9797
}))
98-
.catch(err => {
99-
if ([].some.call(err, e => e.code === 'ENOENT')) {
100-
throw Object.assign(
101-
new Error('No matching content found for ' + sri.toString()),
102-
{code: 'ENOENT'}
103-
)
104-
} else {
105-
throw err[0]
106-
}
107-
})
98+
.catch(err => {
99+
if ([].some.call(err, e => e.code === 'ENOENT')) {
100+
throw Object.assign(
101+
new Error('No matching content found for ' + sri.toString()),
102+
{code: 'ENOENT'}
103+
)
104+
} else {
105+
throw err[0]
106+
}
107+
})
108108
}
109109
}
110110

lib/entry-index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,9 @@ function hashEntry (str) {
197197

198198
function hash (str, digest) {
199199
return crypto
200-
.createHash(digest)
201-
.update(str)
202-
.digest('hex')
200+
.createHash(digest)
201+
.update(str)
202+
.digest('hex')
203203
}
204204

205205
function formatEntry (cache, entry) {
@@ -217,8 +217,8 @@ function formatEntry (cache, entry) {
217217

218218
function readdirOrEmpty (dir) {
219219
return readdirAsync(dir)
220-
.catch({code: 'ENOENT'}, () => [])
221-
.catch({code: 'ENOTDIR'}, () => [])
220+
.catch({code: 'ENOENT'}, () => [])
221+
.catch({code: 'ENOTDIR'}, () => [])
222222
}
223223

224224
function nop () {

test/benchmarks/content.read.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,17 @@ module.exports = (suite, CACHE) => {
7474
fn (deferred) {
7575
if (read.copy) {
7676
read.copy(CACHE, INTEGRITY, path.join(CACHE, 'data'))
77-
.then(
78-
() => deferred.resolve(),
79-
err => deferred.reject(err)
80-
)
77+
.then(
78+
() => deferred.resolve(),
79+
err => deferred.reject(err)
80+
)
8181
} else {
8282
read(CACHE, INTEGRITY)
83-
.then(data => fs.writeFileAsync(path.join(CACHE, 'data'), data))
84-
.then(
85-
() => deferred.resolve(),
86-
err => deferred.reject(err)
87-
)
83+
.then(data => fs.writeFileAsync(path.join(CACHE, 'data'), data))
84+
.then(
85+
() => deferred.resolve(),
86+
err => deferred.reject(err)
87+
)
8888
}
8989
}
9090
})
@@ -100,17 +100,17 @@ module.exports = (suite, CACHE) => {
100100
fn (deferred) {
101101
if (read.copy) {
102102
read.copy(CACHE, BIGINTEGRITY, path.join(CACHE, 'bigdata'))
103-
.then(
104-
() => deferred.resolve(),
105-
err => deferred.reject(err)
106-
)
103+
.then(
104+
() => deferred.resolve(),
105+
err => deferred.reject(err)
106+
)
107107
} else {
108108
read(CACHE, BIGINTEGRITY)
109-
.then(data => fs.writeFileAsync(path.join(CACHE, 'bigdata'), data))
110-
.then(
111-
() => deferred.resolve(),
112-
err => deferred.reject(err)
113-
)
109+
.then(data => fs.writeFileAsync(path.join(CACHE, 'bigdata'), data))
110+
.then(
111+
() => deferred.resolve(),
112+
err => deferred.reject(err)
113+
)
114114
}
115115
}
116116
})

test/benchmarks/get.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,10 @@ module.exports = (suite, CACHE) => {
108108
},
109109
fn (deferred) {
110110
get.copy.byDigest(CACHE, INTEGRITY, path.join(CACHE, 'data'))
111-
.then(
112-
() => deferred.resolve(),
113-
err => deferred.reject(err)
114-
)
111+
.then(
112+
() => deferred.resolve(),
113+
err => deferred.reject(err)
114+
)
115115
}
116116
})
117117

@@ -125,10 +125,10 @@ module.exports = (suite, CACHE) => {
125125
},
126126
fn (deferred) {
127127
get.copy.byDigest(CACHE, BIGINTEGRITY, path.join(CACHE, 'data'))
128-
.then(
129-
() => deferred.resolve(),
130-
err => deferred.reject(err)
131-
)
128+
.then(
129+
() => deferred.resolve(),
130+
err => deferred.reject(err)
131+
)
132132
}
133133
})
134134
}

test/benchmarks/index.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ const WARN_RANGE = 5
1313
const suite = new Benchmark.Suite({
1414
onStart () {
1515
let previousPath = process.env.COMPARETO
16-
? path.resolve(process.env.COMPARETO)
17-
: PREVIOUS
16+
? path.resolve(process.env.COMPARETO)
17+
: PREVIOUS
1818
try {
1919
this.previous = require(previousPath)
2020
} catch (e) {}
@@ -29,14 +29,14 @@ const suite = new Benchmark.Suite({
2929
const prev = this.previous && this.previous[bench.name]
3030
const pctDelta = prev && (((bench.stats.mean - prev.stats.mean) / prev.stats.mean) * 100)
3131
let colorDiff = !prev
32-
? ''
33-
: `${pctDelta > 0 ? '+' : ''}${pctDelta.toFixed(2)}% `
32+
? ''
33+
: `${pctDelta > 0 ? '+' : ''}${pctDelta.toFixed(2)}% `
3434
colorDiff = ` (${
3535
pctDelta >= (WARN_RANGE + bench.stats.rme)
36-
? chalk.red(colorDiff)
37-
: pctDelta <= -(WARN_RANGE + bench.stats.rme)
38-
? chalk.green(colorDiff)
39-
: colorDiff
36+
? chalk.red(colorDiff)
37+
: pctDelta <= -(WARN_RANGE + bench.stats.rme)
38+
? chalk.green(colorDiff)
39+
: colorDiff
4040
}±${bench.stats.rme.toFixed(2)}%)`
4141
console.log(` ${bench.name}`)
4242
console.log('------------------------------------------------')

test/content.read.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -142,18 +142,18 @@ test('hasContent: returns { sri, size } when a cache file exists', function (t)
142142
fixture.create(CACHE)
143143
return BB.join(
144144
read.hasContent(CACHE, 'sha1-deadbeef')
145-
.then(content => {
146-
t.ok(content.sri, 'returned sri for this content')
147-
t.equal(content.size, 0, 'returned the right size for this content')
148-
}),
145+
.then(content => {
146+
t.ok(content.sri, 'returned sri for this content')
147+
t.equal(content.size, 0, 'returned the right size for this content')
148+
}),
149149
read.hasContent(CACHE, 'sha1-not-there')
150-
.then(content => {
151-
t.equal(content, false, 'returned false for missing content')
152-
}),
150+
.then(content => {
151+
t.equal(content, false, 'returned false for missing content')
152+
}),
153153
read.hasContent(CACHE, 'sha1-not-here sha1-also-not-here')
154-
.then(content => {
155-
t.equal(content, false, 'multi-content hash failures work ok')
156-
})
154+
.then(content => {
155+
t.equal(content, false, 'multi-content hash failures work ok')
156+
})
157157
)
158158
})
159159

test/content.write.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ test('does not overwrite content if already on disk', t => {
143143

144144
test('errors if input stream errors', t => {
145145
const stream = fromString('foobarbaz')
146-
.on('end', () => stream.emit('error', new Error('bleh')))
146+
.on('end', () => stream.emit('error', new Error('bleh')))
147147
let integrity
148148
const putter = write.stream(CACHE).on('integrity', int => {
149149
integrity = int

test/get.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -114,25 +114,25 @@ test('get.copy', t => {
114114
}))
115115
fixture.create(CACHE)
116116
return index.insert(CACHE, KEY, INTEGRITY, opts())
117-
.then(() => get.copy(CACHE, KEY, DEST))
118-
.then(res => {
119-
t.deepEqual(res, {
120-
metadata: METADATA,
121-
integrity: INTEGRITY,
122-
size: SIZE
123-
}, 'copy operation returns basic metadata')
124-
return fs.readFileAsync(DEST)
125-
})
126-
.then(data => {
127-
t.deepEqual(data, CONTENT, 'data copied by key matches')
128-
return rimraf(DEST)
129-
})
130-
.then(() => get.copy.byDigest(CACHE, INTEGRITY, DEST))
131-
.then(() => fs.readFileAsync(DEST))
132-
.then(data => {
133-
t.deepEqual(data, CONTENT, 'data copied by digest matches')
134-
return rimraf(DEST)
135-
})
117+
.then(() => get.copy(CACHE, KEY, DEST))
118+
.then(res => {
119+
t.deepEqual(res, {
120+
metadata: METADATA,
121+
integrity: INTEGRITY,
122+
size: SIZE
123+
}, 'copy operation returns basic metadata')
124+
return fs.readFileAsync(DEST)
125+
})
126+
.then(data => {
127+
t.deepEqual(data, CONTENT, 'data copied by key matches')
128+
return rimraf(DEST)
129+
})
130+
.then(() => get.copy.byDigest(CACHE, INTEGRITY, DEST))
131+
.then(() => fs.readFileAsync(DEST))
132+
.then(data => {
133+
t.deepEqual(data, CONTENT, 'data copied by digest matches')
134+
return rimraf(DEST)
135+
})
136136
})
137137

138138
test('ENOENT if not found', t => {

test/ls.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -149,21 +149,21 @@ test('correctly ignores deleted entries', t => {
149149
CACHE, contents.whatwhere.integrity)
150150
fixture.create(CACHE)
151151
return index.delete(CACHE, 'whatnot')
152-
.then(() => ls(CACHE))
153-
.then(listing => t.deepEqual(listing, {
154-
whatever: contents.whatever,
155-
whatwhere: contents.whatwhere
156-
}, 'index contents correct'))
157-
.then(() => {
158-
const listing = []
159-
const stream = ls.stream(CACHE)
160-
stream.on('data', entry => {
161-
listing[entry.key] = entry
162-
})
163-
return finished(stream)
164-
.then(() => t.deepEqual(listing, {
152+
.then(() => ls(CACHE))
153+
.then(listing => t.deepEqual(listing, {
165154
whatever: contents.whatever,
166155
whatwhere: contents.whatwhere
167-
}, 'ls is streamable'))
168-
})
156+
}, 'index contents correct'))
157+
.then(() => {
158+
const listing = []
159+
const stream = ls.stream(CACHE)
160+
stream.on('data', entry => {
161+
listing[entry.key] = entry
162+
})
163+
return finished(stream)
164+
.then(() => t.deepEqual(listing, {
165+
whatever: contents.whatever,
166+
whatwhere: contents.whatwhere
167+
}, 'ls is streamable'))
168+
})
169169
})

0 commit comments

Comments
 (0)