pax_global_header00006660000000000000000000000064131401304720014505gustar00rootroot0000000000000052 comment=ee617be915a410b5aef59e8f02a551299dd7424e append-buffer-1.0.2/000077500000000000000000000000001314013047200142235ustar00rootroot00000000000000append-buffer-1.0.2/.editorconfig000066400000000000000000000004051314013047200166770ustar00rootroot00000000000000root = true [*] indent_style = space end_of_line = lf charset = utf-8 indent_size = 2 trim_trailing_whitespace = true insert_final_newline = true [{**/{actual,fixtures,expected,templates}/**,*.md}] trim_trailing_whitespace = false insert_final_newline = falseappend-buffer-1.0.2/.eslintrc.json000066400000000000000000000071251314013047200170240ustar00rootroot00000000000000{ "ecmaFeatures": { "modules": true, "experimentalObjectRestSpread": true }, "env": { "browser": false, "es6": true, "node": true, "mocha": true }, "globals": { "document": false, "navigator": false, "window": false }, "rules": { "accessor-pairs": 2, "arrow-spacing": [2, { "before": true, "after": true }], "block-spacing": [2, "always"], "brace-style": [2, "1tbs", { "allowSingleLine": true }], "comma-dangle": [2, "never"], "comma-spacing": [2, { "before": false, "after": true }], "comma-style": [2, "last"], "constructor-super": 2, "curly": [2, "multi-line"], "dot-location": [2, "property"], "eol-last": 2, "eqeqeq": [2, "allow-null"], "generator-star-spacing": [2, { "before": true, "after": true }], "handle-callback-err": [2, "^(err|error)$" ], "indent": [2, 2, { "SwitchCase": 1 }], "key-spacing": [2, { "beforeColon": false, "afterColon": true }], "keyword-spacing": [2, { "before": true, "after": true }], "new-cap": [2, { "newIsCap": true, "capIsNew": false }], "new-parens": 2, "no-array-constructor": 2, "no-caller": 2, "no-class-assign": 2, "no-cond-assign": 2, "no-const-assign": 2, "no-control-regex": 2, "no-debugger": 2, "no-delete-var": 2, "no-dupe-args": 2, "no-dupe-class-members": 2, "no-dupe-keys": 2, "no-duplicate-case": 2, "no-empty-character-class": 2, "no-eval": 2, "no-ex-assign": 2, "no-extend-native": 2, "no-extra-bind": 2, "no-extra-boolean-cast": 2, "no-extra-parens": [2, "functions"], "no-fallthrough": 2, "no-floating-decimal": 2, "no-func-assign": 2, "no-implied-eval": 2, "no-inner-declarations": [2, "functions"], "no-invalid-regexp": 2, "no-irregular-whitespace": 2, "no-iterator": 2, "no-label-var": 2, "no-labels": 2, "no-lone-blocks": 2, "no-mixed-spaces-and-tabs": 2, "no-multi-spaces": 2, "no-multi-str": 2, "no-multiple-empty-lines": [2, { "max": 1 }], "no-native-reassign": 0, "no-negated-in-lhs": 2, "no-new": 2, "no-new-func": 2, "no-new-object": 2, "no-new-require": 2, "no-new-wrappers": 2, "no-obj-calls": 2, "no-octal": 2, "no-octal-escape": 2, "no-proto": 0, "no-redeclare": 2, "no-regex-spaces": 2, "no-return-assign": 2, "no-self-compare": 2, "no-sequences": 2, "no-shadow-restricted-names": 2, "no-spaced-func": 2, "no-sparse-arrays": 2, "no-this-before-super": 2, "no-throw-literal": 2, "no-trailing-spaces": 0, "no-undef": 2, "no-undef-init": 2, "no-unexpected-multiline": 2, "no-unneeded-ternary": [2, { "defaultAssignment": false }], "no-unreachable": 2, "no-unused-vars": [2, { "vars": "all", "args": "none" }], "no-useless-call": 0, "no-with": 2, "one-var": [0, { "initialized": "never" }], "operator-linebreak": [0, "after", { "overrides": { "?": "before", ":": "before" } }], "padded-blocks": [0, "never"], "quotes": [2, "single", "avoid-escape"], "radix": 2, "semi": [2, "always"], "semi-spacing": [2, { "before": false, "after": true }], "space-before-blocks": [2, "always"], "space-before-function-paren": [2, "never"], "space-in-parens": [2, "never"], "space-infix-ops": 2, "space-unary-ops": [2, { "words": true, "nonwords": false }], "spaced-comment": [0, "always", { "markers": ["global", "globals", "eslint", "eslint-disable", "*package", "!", ","] }], "use-isnan": 2, "valid-typeof": 2, "wrap-iife": [2, "any"], "yoda": [2, "never"] } } append-buffer-1.0.2/.gitattributes000066400000000000000000000000141314013047200171110ustar00rootroot00000000000000* text=auto append-buffer-1.0.2/.github/000077500000000000000000000000001314013047200155635ustar00rootroot00000000000000append-buffer-1.0.2/.github/contributing.md000066400000000000000000000112751314013047200206220ustar00rootroot00000000000000# Contributing to append-buffer First and foremost, thank you! We appreciate that you want to contribute to append-buffer, your time is valuable, and your contributions mean a lot to us. ## Important! By contributing to this project, you: * Agree that you have authored 100% of the content * Agree that you have the necessary rights to the content * Agree that you have received the necessary permissions from your employer to make the contributions (if applicable) * Agree that the content you contribute may be provided under the Project license(s) ## Getting started **What does "contributing" mean?** Creating an issue is the simplest form of contributing to a project. But there are many ways to contribute, including the following: - Updating or correcting documentation - Feature requests - Bug reports If you'd like to learn more about contributing in general, the [Guide to Idiomatic Contributing](https://github.com/jonschlinkert/idiomatic-contributing) has a lot of useful information. **Showing support for append-buffer** Please keep in mind that open source software is built by people like you, who spend their free time creating things the rest the community can use. Don't have time to contribute? No worries, here are some other ways to show your support for append-buffer: - star the [project](https://github.com/doowb/append-buffer) - tweet your support for append-buffer ## Issues ### Before creating an issue Please try to determine if the issue is caused by an underlying library, and if so, create the issue there. Sometimes this is difficult to know. We only ask that you attempt to give a reasonable attempt to find out. Oftentimes the readme will have advice about where to go to create issues. Try to follow these guidelines - **Avoid creating issues for implementation help**. It's much better for discoverability, SEO, and semantics - to keep the issue tracker focused on bugs and feature requests - to ask implementation-related questions on [stackoverflow.com][so] - **Investigate the issue**: - **Check the readme** - oftentimes you will find notes about creating issues, and where to go depending on the type of issue. - Create the issue in the appropriate repository. ### Creating an issue Please be as descriptive as possible when creating an issue. Give us the information we need to successfully answer your question or address your issue by answering the following in your issue: - **version**: please note the version of append-buffer are you using - **extensions, plugins, helpers, etc** (if applicable): please list any extensions you're using - **error messages**: please paste any error messages into the issue, or a [gist](https://gist.github.com/) ### Closing issues The original poster or the maintainer's of append-buffer may close an issue at any time. Typically, but not exclusively, issues are closed when: - The issue is resolved - The project's maintainers have determined the issue is out of scope - An issue is clearly a duplicate of another issue, in which case the duplicate issue will be linked. - A discussion has clearly run its course ## Next steps **Tips for creating idiomatic issues** Spending just a little extra time to review best practices and brush up on your contributing skills will, at minimum, make your issue easier to read, easier to resolve, and more likely to be found by others who have the same or similar issue in the future. At best, it will open up doors and potential career opportunities by helping you be at your best. The following resources were hand-picked to help you be the most effective contributor you can be: - The [Guide to Idiomatic Contributing](https://github.com/jonschlinkert/idiomatic-contributing) is a great place for newcomers to start, but there is also information for experienced contributors there. - Take some time to learn basic markdown. We can't stress this enough. Don't start pasting code into GitHub issues before you've taken a moment to review this [markdown cheatsheet](https://gist.github.com/jonschlinkert/5854601) - The GitHub guide to [basic markdown](https://help.github.com/articles/markdown-basics/) is another great markdown resource. - Learn about [GitHub Flavored Markdown](https://help.github.com/articles/github-flavored-markdown/). And if you want to really go above and beyond, read [mastering markdown](https://guides.github.com/features/mastering-markdown/). At the very least, please try to: - Use backticks to wrap code. This ensures that it retains its formatting and isn't modified when it's rendered by GitHub, and makes the code more readable to others - When applicable, use syntax highlighting by adding the correct language name after the first "code fence" [so]: http://stackoverflow.com/questions/tagged/append-buffer append-buffer-1.0.2/.gitignore000066400000000000000000000004401314013047200162110ustar00rootroot00000000000000# always ignore files *.DS_Store *.sublime-* # test related, or directories generated by tests test/actual actual coverage .nyc* # npm node_modules npm-debug.log # yarn yarn.lock yarn-error.log # misc _gh_pages _draft _drafts bower_components vendor temp tmp TODO.md package-lock.jsonappend-buffer-1.0.2/.travis.yml000066400000000000000000000002041314013047200163300ustar00rootroot00000000000000sudo: false os: - linux - osx language: node_js node_js: - node - '8' - '7' - '6' - '5' - '4' - '0.12' - '0.10' append-buffer-1.0.2/.verb.md000066400000000000000000000004611314013047200155620ustar00rootroot00000000000000## Usage ```js var appendBuffer = require('{%= name %}'); ``` ## API {%= apidocs('index.js') %} ## Attribution The code in this module was originally added in a [PR](https://github.com/jonschlinkert/file-normalize/pull/3) to [file-normalize][]. It has been split out to allow for standalone use cases.append-buffer-1.0.2/LICENSE000066400000000000000000000020721314013047200152310ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2017, Brian Woodward. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.append-buffer-1.0.2/README.md000066400000000000000000000063041314013047200155050ustar00rootroot00000000000000# append-buffer [![NPM version](https://img.shields.io/npm/v/append-buffer.svg?style=flat)](https://www.npmjs.com/package/append-buffer) [![NPM monthly downloads](https://img.shields.io/npm/dm/append-buffer.svg?style=flat)](https://npmjs.org/package/append-buffer) [![NPM total downloads](https://img.shields.io/npm/dt/append-buffer.svg?style=flat)](https://npmjs.org/package/append-buffer) [![Linux Build Status](https://img.shields.io/travis/doowb/append-buffer.svg?style=flat&label=Travis)](https://travis-ci.org/doowb/append-buffer) [![Windows Build Status](https://img.shields.io/appveyor/ci/doowb/append-buffer.svg?style=flat&label=AppVeyor)](https://ci.appveyor.com/project/doowb/append-buffer) > Append a buffer to another buffer ensuring to preserve line ending characters. ## Install Install with [npm](https://www.npmjs.com/): ```sh $ npm install --save append-buffer ``` Install with [yarn](https://yarnpkg.com): ```sh $ yarn add append-buffer ``` ## Usage ```js var appendBuffer = require('append-buffer'); ``` ## API ### [appendBuffer](index.js#L28) Append a buffer to another buffer ensuring to preserve line ending characters. **Params** * `buf` **{Buffer}**: Buffer that will be used to check for an existing line ending. The suffix is appended to this. * `suffix` **{Buffer}**: Buffer that will be appended to the buf. * `returns` **{Buffer}**: Final Buffer **Example** ```js console.log([appendBuffer(new Buffer('abc\r\n'), new Buffer('def')).toString()]); //=> [ 'abc\r\ndef\r\n' ] console.log([appendBuffer(new Buffer('abc\n'), new Buffer('def')).toString()]); //=> [ 'abc\ndef\n' ] // uses os.EOL when a line ending is not found console.log([appendBuffer(new Buffer('abc'), new Buffer('def')).toString()]); //=> [ 'abc\ndef' ] ``` ## Attribution 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. ## About ### Contributing Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new). Please read the [contributing guide](.github/contributing.md) for advice on opening issues, pull requests, and coding standards. ### Building docs _(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.)_ To generate the readme, run the following command: ```sh $ npm install -g verbose/verb#dev verb-generate-readme && verb ``` ### Running tests 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: ```sh $ npm install && npm test ``` ### Author **Brian Woodward** * [github/doowb](https://github.com/doowb) * [twitter/doowb](https://twitter.com/doowb) ### License Copyright © 2017, [Brian Woodward](https://doowb.com). Released under the [MIT License](LICENSE). *** _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on August 01, 2017._append-buffer-1.0.2/appveyor.yml000066400000000000000000000012111314013047200166060ustar00rootroot00000000000000# Test against this version of Node.js environment: matrix: # node.js - nodejs_version: "8.0" - nodejs_version: "7.0" - nodejs_version: "6.0" - nodejs_version: "5.0" - nodejs_version: "4.0" - nodejs_version: "0.12" - nodejs_version: "0.10" # Install scripts. (runs after repo cloning) install: # Get the latest stable version of Node.js or io.js - ps: Install-Product node $env:nodejs_version # install modules - npm install # Post-install test scripts. test_script: # Output useful info for debugging. - node --version - npm --version # run tests - npm test # Don't actually build. build: off append-buffer-1.0.2/index.js000066400000000000000000000023271314013047200156740ustar00rootroot00000000000000'use strict'; var os = require('os'); var equals = require('buffer-equal'); var cr = new Buffer('\r\n'); var nl = new Buffer('\n'); /** * Append a buffer to another buffer ensuring to preserve line ending characters. * * ```js * console.log([appendBuffer(new Buffer('abc\r\n'), new Buffer('def')).toString()]); * //=> [ 'abc\r\ndef\r\n' ] * * console.log([appendBuffer(new Buffer('abc\n'), new Buffer('def')).toString()]); * //=> [ 'abc\ndef\n' ] * * // uses os.EOL when a line ending is not found * console.log([appendBuffer(new Buffer('abc'), new Buffer('def')).toString()]); * //=> [ 'abc\ndef' ] * * ``` * @param {Buffer} `buf` Buffer that will be used to check for an existing line ending. The suffix is appended to this. * @param {Buffer} `suffix` Buffer that will be appended to the buf. * @return {Buffer} Final Buffer * @api public */ module.exports = function appendBuffer(buf, suffix) { if (!suffix || !suffix.length) { return buf; } var eol; if (equals(buf.slice(-2), cr)) { eol = cr; } else if (equals(buf.slice(-1), nl)) { eol = nl; } else { return Buffer.concat([buf, new Buffer(os.EOL), new Buffer(suffix)]); } return Buffer.concat([buf, new Buffer(suffix), eol]); }; append-buffer-1.0.2/package.json000066400000000000000000000017701314013047200165160ustar00rootroot00000000000000{ "name": "append-buffer", "description": "Append a buffer to another buffer ensuring to preserve line ending characters.", "version": "1.0.2", "homepage": "https://github.com/doowb/append-buffer", "author": "Brian Woodward (https://doowb.com)", "repository": "doowb/append-buffer", "bugs": { "url": "https://github.com/doowb/append-buffer/issues" }, "license": "MIT", "files": [ "index.js" ], "main": "index.js", "engines": { "node": ">=0.10.0" }, "scripts": { "test": "mocha" }, "keywords": [ "append", "append-buffer", "concat", "concat-buffer", "eol", "join", "join-buffer", "normalize", "buffer" ], "devDependencies": { "gulp-format-md": "^1.0.0", "mocha": "^3.5.0" }, "dependencies": { "buffer-equal": "^1.0.0" }, "verb": { "toc": false, "layout": "default", "tasks": [ "readme" ], "plugins": [ "gulp-format-md" ], "lint": { "reflinks": true } } } append-buffer-1.0.2/test.js000066400000000000000000000033761314013047200155510ustar00rootroot00000000000000'use strict'; var os = require('os'); require('mocha'); var assert = require('assert'); var appendBuffer = require('./'); describe('appendBuffer', function() { it('should append the buffer suffix to the buffer prefix with \\r\\n', function() { assert.deepEqual(appendBuffer(new Buffer('abc\r\n'), new Buffer('def')), new Buffer('abc\r\ndef\r\n')); }); it('should append the buffer suffix to the buffer prefix with \\n:', function() { assert.deepEqual(appendBuffer(new Buffer('abc\n'), new Buffer('def')), new Buffer('abc\ndef\n')); }); it('should append the buffer suffix to the buffer prefix without EOL', function() { assert.deepEqual(appendBuffer(new Buffer('abc'), new Buffer('def')), new Buffer('abc' + os.EOL + 'def')); }); it('should append the string suffix to the buffer prefix with \\r\\n', function() { assert.deepEqual(appendBuffer(new Buffer('abc\r\n'), 'def'), new Buffer('abc\r\ndef\r\n')); }); it('should append the string suffix to the buffer prefix with \\n:', function() { assert.deepEqual(appendBuffer(new Buffer('abc\n'), 'def'), new Buffer('abc\ndef\n')); }); it('should append the string suffix to the buffer prefix without EOL', function() { assert.deepEqual(appendBuffer(new Buffer('abc'), 'def'), new Buffer('abc' + os.EOL + 'def')); }); it('should not append EOL when suffix is empty', function() { assert.deepEqual(appendBuffer(new Buffer('abc'), new Buffer('')), new Buffer('abc')); }); it('should not append EOL when suffix is undefined', function() { assert.deepEqual(appendBuffer(new Buffer('abc')), new Buffer('abc')); }); it('should not append EOL when suffix is empty string', function() { assert.deepEqual(appendBuffer(new Buffer('abc'), ''), new Buffer('abc')); }); });