|
1 | | -# append-buffer [](https://npmjs.org/package/append-buffer) [](https://travis-ci.org/doowb/append-buffer) |
| 1 | +# append-buffer [](https://www.npmjs.com/package/append-buffer) [](https://npmjs.org/package/append-buffer) [](https://npmjs.org/package/append-buffer) [](https://travis-ci.org/doowb/append-buffer) [](https://ci.appveyor.com/project/doowb/append-buffer) |
2 | 2 |
|
3 | 3 | > Append a buffer to another buffer ensuring to preserve line ending characters. |
4 | 4 |
|
5 | | -## Installation |
| 5 | +## Install |
| 6 | + |
| 7 | +Install with [npm](https://www.npmjs.com/): |
6 | 8 |
|
7 | 9 | ```sh |
8 | 10 | $ npm install --save append-buffer |
9 | 11 | ``` |
10 | 12 |
|
| 13 | +Install with [yarn](https://yarnpkg.com): |
| 14 | + |
| 15 | +```sh |
| 16 | +$ yarn add append-buffer |
| 17 | +``` |
| 18 | + |
11 | 19 | ## Usage |
12 | 20 |
|
13 | 21 | ```js |
14 | 22 | var appendBuffer = require('append-buffer'); |
15 | | -appendBuffer(); |
16 | 23 | ``` |
17 | 24 |
|
18 | | -## License |
| 25 | +## API |
| 26 | + |
| 27 | +### [appendBuffer](index.js#L28) |
| 28 | + |
| 29 | +Append a buffer to another buffer ensuring to preserve line ending characters. |
| 30 | + |
| 31 | +**Params** |
| 32 | + |
| 33 | +* `buf` **{Buffer}**: Buffer that will be used to check for an existing line ending. The suffix is appended to this. |
| 34 | +* `suffix` **{Buffer}**: Buffer that will be appended to the buf. |
| 35 | +* `returns` **{Buffer}**: Final Buffer |
| 36 | + |
| 37 | +**Example** |
| 38 | + |
| 39 | +```js |
| 40 | +console.log([appendBuffer(new Buffer('abc\r\n'), new Buffer('def')).toString()]); |
| 41 | +//=> [ 'abc\r\ndef\r\n' ] |
| 42 | + |
| 43 | +console.log([appendBuffer(new Buffer('abc\n'), new Buffer('def')).toString()]); |
| 44 | +//=> [ 'abc\ndef\n' ] |
| 45 | + |
| 46 | +// uses os.EOL when a line ending is not found |
| 47 | +console.log([appendBuffer(new Buffer('abc'), new Buffer('def')).toString()]); |
| 48 | +//=> [ 'abc\ndef' ] |
| 49 | +``` |
| 50 | + |
| 51 | +## Attribution |
| 52 | + |
| 53 | +The code in this module was originally added in a [PR](https://github.com/jonschlinkert/file-normalize/pull/3) to [file-normalize](https://github.com/jonschlinkert/file-normalize). It has been split out to allow for standalone use cases. |
| 54 | + |
| 55 | +## About |
| 56 | + |
| 57 | +### Contributing |
| 58 | + |
| 59 | +Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new). |
| 60 | + |
| 61 | +Please read the [contributing guide](.github/contributing.md) for advice on opening issues, pull requests, and coding standards. |
| 62 | + |
| 63 | +### Building docs |
| 64 | + |
| 65 | +_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_ |
| 66 | + |
| 67 | +To generate the readme, run the following command: |
| 68 | + |
| 69 | +```sh |
| 70 | +$ npm install -g verbose/verb#dev verb-generate-readme && verb |
| 71 | +``` |
| 72 | + |
| 73 | +### Running tests |
| 74 | + |
| 75 | +Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command: |
| 76 | + |
| 77 | +```sh |
| 78 | +$ npm install && npm test |
| 79 | +``` |
| 80 | + |
| 81 | +### Author |
| 82 | + |
| 83 | +**Brian Woodward** |
| 84 | + |
| 85 | +* [github/doowb](https://github.com/doowb) |
| 86 | +* [twitter/doowb](https://twitter.com/doowb) |
| 87 | + |
| 88 | +### License |
| 89 | + |
| 90 | +Copyright © 2017, [Brian Woodward](https://doowb.com). |
| 91 | +Released under the [MIT License](LICENSE). |
| 92 | + |
| 93 | +*** |
19 | 94 |
|
20 | | -MIT © [Brian Woodward](https://doowb.com) |
| 95 | +_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on August 01, 2017._ |
0 commit comments