Skip to content

Commit

Permalink
prettier --write '**/*.{md,js}'
Browse files Browse the repository at this point in the history
  • Loading branch information
papandreou committed Apr 4, 2020
1 parent 520ee14 commit 25542e0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 29 deletions.
27 changes: 13 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
node-optipng
============
# node-optipng

[![NPM version](https://badge.fury.io/js/optipng.svg)](http://badge.fury.io/js/optipng)
[![Build Status](https://travis-ci.org/papandreou/node-optipng.svg?branch=master)](https://travis-ci.org/papandreou/node-optipng)
Expand All @@ -20,7 +19,7 @@ the `optipng` binary:

```javascript
var OptiPng = require('optipng'),
myOptimizer = new OptiPng(['-o7']);
myOptimizer = new OptiPng(['-o7']);

sourceStream.pipe(myOptimizer).pipe(destinationStream);
```
Expand All @@ -29,27 +28,27 @@ OptiPng as a web service:

```javascript
var OptiPng = require('optipng'),
http = require('http');
http = require('http');

http.createServer(function (req, res) {
http
.createServer(function (req, res) {
if (req.headers['content-type'] === 'image/png') {
res.writeHead(200, {'Content-Type': 'image/png'});
req.pipe(new OptiPng(['-o7'])).pipe(res);
res.writeHead(200, { 'Content-Type': 'image/png' });
req.pipe(new OptiPng(['-o7'])).pipe(res);
} else {
res.writeHead(400);
res.end('Feed me a PNG!');
res.writeHead(400);
res.end('Feed me a PNG!');
}
}).listen(1337);
})
.listen(1337);
```

Installation
------------
## Installation

Make sure you have node.js and npm installed, then run:

npm install optipng

License
-------
## License

3-clause BSD license -- see the `LICENSE` file for details.
2 changes: 1 addition & 1 deletion lib/OptiPng.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class OptiPng extends Duplex {
}
}

OptiPng.getBinaryPath = memoizeAsync(cb => {
OptiPng.getBinaryPath = memoizeAsync((cb) => {
// trying environment path first
which('optipng', function onWhichDone(err, binary) {
if (err) {
Expand Down
28 changes: 14 additions & 14 deletions test/OptiPng.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ describe('OptiPng', () => {
'when piped through',
new OptiPng(['-o7']),
'to yield output satisfying',
expect.it(resultPngBuffer => {
expect.it((resultPngBuffer) => {
expect(resultPngBuffer.length, 'to be within', 0, 152);
})
));

it('should not emit data events while paused', done => {
it('should not emit data events while paused', (done) => {
const optiPng = new OptiPng(['-o7']);

function fail() {
Expand All @@ -37,7 +37,7 @@ describe('OptiPng', () => {
const chunks = [];

optiPng
.on('data', chunk => {
.on('data', (chunk) => {
chunks.push(chunk);
})
.on('end', () => {
Expand All @@ -50,14 +50,14 @@ describe('OptiPng', () => {
}, 1000);
});

it('should emit an error if an invalid image is processed', done => {
it('should emit an error if an invalid image is processed', (done) => {
const optiPng = new OptiPng();

optiPng
.on('error', () => {
done();
})
.on('data', chunk => {
.on('data', (chunk) => {
if (chunk !== null) {
done(new Error('OptiPng emitted data when an error was expected'));
}
Expand All @@ -66,18 +66,18 @@ describe('OptiPng', () => {
optiPng.end(Buffer.from('qwvopeqwovkqvwiejvq', 'utf-8'));
});

it('should end the output stream properly even if no data has been piped in', done => {
it('should end the output stream properly even if no data has been piped in', (done) => {
const optiPng = new OptiPng(['-o7']);

optiPng.on('error', e => {
optiPng.on('error', (e) => {
expect(e.message, 'to be', 'Closing stream before writing data.');
done();
});

optiPng.end();
});

it('should emit a single error if an invalid command line is specified', done => {
it('should emit a single error if an invalid command line is specified', (done) => {
const optiPng = new OptiPng(['-vqve']);

let seenError = false;
Expand All @@ -96,7 +96,7 @@ describe('OptiPng', () => {
setTimeout(done, 100);
}
})
.on('data', chunk => {
.on('data', (chunk) => {
if (chunk !== null) {
done(new Error('OptiPng emitted data when an error was expected'));
}
Expand All @@ -113,12 +113,12 @@ describe('OptiPng', () => {
optiPng
);
optiPng.destroy();
return expect.promise(run => {
return expect.promise((run) => {
setTimeout(
run(() => {
expect(optiPng, 'to satisfy', {
writeStream: expect.it('to be falsy'),
optiPngProcess: expect.it('to be falsy')
optiPngProcess: expect.it('to be falsy'),
});
}),
10
Expand All @@ -133,7 +133,7 @@ describe('OptiPng', () => {
optiPng
);

return expect.promise(run => {
return expect.promise((run) => {
setTimeout(
run(function waitForWriteStream() {
const writeStream = optiPng.writeStream;
Expand Down Expand Up @@ -171,7 +171,7 @@ describe('OptiPng', () => {

sinon.spy(fs, 'unlink');
return expect
.promise(run => {
.promise((run) => {
setTimeout(
run(function waitForOptiPngProcess() {
const optiPngProcess = optiPng.optiPngProcess;
Expand Down Expand Up @@ -211,7 +211,7 @@ describe('OptiPng', () => {

sinon.spy(fs, 'unlink');
return expect
.promise(run => {
.promise((run) => {
setTimeout(
run(function waitForReadStream() {
const readStream = optiPng.readStream;
Expand Down

0 comments on commit 25542e0

Please sign in to comment.