Skip to content

Commit

Permalink
prettier --write '**/*.js'
Browse files Browse the repository at this point in the history
  • Loading branch information
papandreou committed Apr 2, 2020
1 parent 448af85 commit 7e3f757
Show file tree
Hide file tree
Showing 5 changed files with 311 additions and 313 deletions.
2 changes: 1 addition & 1 deletion lib/errors.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const createError = require('createerror');

module.exports = {
OutputDimensionsExceeded: createError({ name: 'OutputDimensionsExceeded' })
OutputDimensionsExceeded: createError({ name: 'OutputDimensionsExceeded' }),
};
4 changes: 2 additions & 2 deletions lib/prepareImproQueryString.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ const isSupportedEngine = {
jpegtran: true,
optipng: true,
svgfilter: true,
inkscape: true
inkscape: true,
};

const resizeOptions = {
ignoreAspectRatio: true,
withoutEnlargement: true
withoutEnlargement: true,
};

const queryStringEngineAndArgsRegex = new RegExp(
Expand Down
26 changes: 13 additions & 13 deletions lib/processImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const hijackResponse = require('hijackresponse');
const prepareImproQueryString = require('./prepareImproQueryString');

const isImageByExtension = {};
Object.keys(mime._extensions).forEach(contentType => {
Object.keys(mime._extensions).forEach((contentType) => {
if (/^image\//.test(contentType)) {
const extension = mime._extensions[contentType];
isImageByExtension[extension] = true;
Expand All @@ -34,19 +34,19 @@ function reverseIteratorFor(arr) {
let index = arr.length;

return {
next: function() {
next: function () {
index -= 1;

const isEnded = index < 0;

return {
done: isEnded,
value: !isEnded ? arr[index] : undefined
value: !isEnded ? arr[index] : undefined,
};
},
[Symbol.iterator]() {
return this;
}
},
};
}

Expand All @@ -70,7 +70,7 @@ function toUsedNames(usedEngines) {
return orderedUsedNames;
}

module.exports = options => {
module.exports = (options) => {
options = options || {};

const engines = pickProperties(
Expand Down Expand Up @@ -105,10 +105,10 @@ module.exports = options => {
if (ifNoneMatch) {
const validIfNoneMatchTokens = ifNoneMatch
.split(' ')
.filter(etag => /-processimage["-]/.test(etag));
.filter((etag) => /-processimage["-]/.test(etag));
if (validIfNoneMatchTokens.length > 0) {
req.headers['if-none-match'] = validIfNoneMatchTokens
.map(token => token.replace(/-processimage(["-])/, '$1'))
.map((token) => token.replace(/-processimage(["-])/, '$1'))
.join(' ');
} else {
delete req.headers['if-none-match'];
Expand Down Expand Up @@ -215,7 +215,7 @@ module.exports = options => {
}
}

res.once('error', err => {
res.once('error', (err) => {
// trigger teardown of all pipeline streams
pipeline.emit(err);
// respond with an error
Expand Down Expand Up @@ -243,7 +243,7 @@ module.exports = options => {
sharpCache: options.sharpCache,
svgAssetPath: options.root
? Path.resolve(options.root, req.url.substr(1))
: null
: null,
},
filterInfosAndTargetFormat.operations
);
Expand Down Expand Up @@ -282,7 +282,7 @@ module.exports = options => {
res.end();
}
})
.on('readable', function() {
.on('readable', function () {
if (!hasEnded) {
let data;
while ((data = this.read())) {
Expand Down Expand Up @@ -313,7 +313,7 @@ module.exports = options => {
filesize:
contentLengthHeaderValue &&
parseInt(contentLengthHeaderValue, 10),
etag: oldETag
etag: oldETag,
};

filterInfosAndTargetFormat = makeFilterInfosAndTargetFormat();
Expand All @@ -323,7 +323,7 @@ module.exports = options => {
}

if (options.secondGuessSourceContentType) {
const endOrCloseOrErrorBeforeFirstDataChunkListener = err => {
const endOrCloseOrErrorBeforeFirstDataChunkListener = (err) => {
if (err) {
next(500);
} else {
Expand All @@ -332,7 +332,7 @@ module.exports = options => {
};
res.once('error', endOrCloseOrErrorBeforeFirstDataChunkListener);
res.once('end', endOrCloseOrErrorBeforeFirstDataChunkListener);
res.once('data', firstChunk => {
res.once('data', (firstChunk) => {
res.removeListener(
'end',
endOrCloseOrErrorBeforeFirstDataChunkListener
Expand Down
38 changes: 19 additions & 19 deletions test/browsersync-compat.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ const serverPort = '9999';
expect.use(require('unexpected-http')).use(require('unexpected-image'));

describe('browser-sync compatibility', () => {
before(done => {
before((done) => {
bs.init(
{
port: serverPort,
server: root,
open: false,
logLevel: 'silent',
middleware: [processImage({ root })]
middleware: [processImage({ root })],
},
done
);
Expand All @@ -32,9 +32,9 @@ describe('browser-sync compatibility', () => {
'to yield response',
{
headers: {
'Content-Type': 'text/plain; charset=UTF-8'
'Content-Type': 'text/plain; charset=UTF-8',
},
body: 'foo\n'
body: 'foo\n',
}
));

Expand All @@ -44,9 +44,9 @@ describe('browser-sync compatibility', () => {
'to yield response',
{
headers: {
'Content-Type': 'image/png'
'Content-Type': 'image/png',
},
body: expect.it('to have length', 3711)
body: expect.it('to have length', 3711),
}
));

Expand All @@ -56,9 +56,9 @@ describe('browser-sync compatibility', () => {
'to yield response',
{
headers: {
'Content-Type': 'image/png'
'Content-Type': 'image/png',
},
body: expect.it('to have length', 3711)
body: expect.it('to have length', 3711),
}
));

Expand All @@ -69,24 +69,24 @@ describe('browser-sync compatibility', () => {
{
statusCode: 200,
headers: {
'Content-Type': 'image/png'
'Content-Type': 'image/png',
},
body: expect.it('to have length', 3711)
body: expect.it('to have length', 3711),
}
).then(context => {
).then((context) => {
const etag = context.httpResponse.headers.get('ETag');
return expect(
{
url: `GET http://localhost:${serverPort}/ancillaryChunks.png?foo=bar`,
headers: {
'If-None-Match': etag
}
'If-None-Match': etag,
},
},
'to yield response',
{
statusCode: 304,
headers: expect.it('to be empty'),
body: expect.it('to be', '')
body: expect.it('to be', ''),
}
);
}));
Expand All @@ -98,19 +98,19 @@ describe('browser-sync compatibility', () => {
{
statusCode: 200,
headers: {
'Content-Type': 'image/png'
'Content-Type': 'image/png',
},
body: expect
.it('to have metadata satisfying', {
format: 'PNG',
size: {
width: 400,
height: 20
}
height: 20,
},
})
.and(body => {
.and((body) => {
expect(body.length, 'to be within', 1, 3711);
})
}),
}
));
});
Loading

0 comments on commit 7e3f757

Please sign in to comment.