pax_global_header00006660000000000000000000000064126305475320014521gustar00rootroot0000000000000052 comment=365dfe6c19b4e607a0cc2cf7dad0b0620f238333 strip-eof-1.0.0/000077500000000000000000000000001263054753200134275ustar00rootroot00000000000000strip-eof-1.0.0/.editorconfig000066400000000000000000000003471263054753200161100ustar00rootroot00000000000000root = true [*] indent_style = tab end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [{package.json,*.yml}] indent_style = space indent_size = 2 [*.md] trim_trailing_whitespace = false strip-eof-1.0.0/.gitattributes000066400000000000000000000000141263054753200163150ustar00rootroot00000000000000* text=auto strip-eof-1.0.0/.gitignore000066400000000000000000000000151263054753200154130ustar00rootroot00000000000000node_modules strip-eof-1.0.0/.travis.yml000066400000000000000000000000761263054753200155430ustar00rootroot00000000000000language: node_js node_js: - 'stable' - '0.12' - '0.10' strip-eof-1.0.0/index.js000066400000000000000000000004731263054753200151000ustar00rootroot00000000000000'use strict'; module.exports = function (x) { var lf = typeof x === 'string' ? '\n' : '\n'.charCodeAt(); var cr = typeof x === 'string' ? '\r' : '\r'.charCodeAt(); if (x[x.length - 1] === lf) { x = x.slice(0, x.length - 1); } if (x[x.length - 1] === cr) { x = x.slice(0, x.length - 1); } return x; }; strip-eof-1.0.0/license000066400000000000000000000021371263054753200147770ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) Sindre Sorhus (sindresorhus.com) 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. strip-eof-1.0.0/package.json000066400000000000000000000012341263054753200157150ustar00rootroot00000000000000{ "name": "strip-eof", "version": "1.0.0", "description": "Strip the End-Of-File (EOF) character from a string/buffer", "license": "MIT", "repository": "sindresorhus/strip-eof", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", "url": "sindresorhus.com" }, "engines": { "node": ">=0.10.0" }, "scripts": { "test": "xo && ava" }, "files": [ "index.js" ], "keywords": [ "strip", "trim", "remove", "delete", "eof", "end", "file", "newline", "linebreak", "character", "string", "buffer" ], "devDependencies": { "ava": "*", "xo": "*" } } strip-eof-1.0.0/readme.md000066400000000000000000000010301263054753200152000ustar00rootroot00000000000000# strip-eof [![Build Status](https://travis-ci.org/sindresorhus/strip-eof.svg?branch=master)](https://travis-ci.org/sindresorhus/strip-eof) > Strip the [End-Of-File](https://en.wikipedia.org/wiki/End-of-file) (EOF) character from a string/buffer ## Install ``` $ npm install --save strip-eof ``` ## Usage ```js const stripEof = require('strip-eof'); stripEof('foo\nbar\n\n'); //=> 'foo\nbar\n' stripEof(new Buffer('foo\nbar\n\n')).toString(); //=> 'foo\nbar\n' ``` ## License MIT © [Sindre Sorhus](http://sindresorhus.com) strip-eof-1.0.0/test.js000066400000000000000000000011451263054753200147450ustar00rootroot00000000000000import test from 'ava'; import fn from './'; test('string', t => { t.is(fn('foo\n'), 'foo'); t.is(fn('foo\nbar\n'), 'foo\nbar'); t.is(fn('foo\n\n\n'), 'foo\n\n'); t.is(fn('foo\r\n'), 'foo'); t.is(fn('foo\r'), 'foo'); t.is(fn('foo\n\r\n'), 'foo\n'); }); test('buffer', t => { t.is(fn(new Buffer('foo\n')).toString(), 'foo'); t.is(fn(new Buffer('foo\nbar\n')).toString(), 'foo\nbar'); t.is(fn(new Buffer('foo\n\n\n').toString()), 'foo\n\n'); t.is(fn(new Buffer('foo\r\n')).toString(), 'foo'); t.is(fn(new Buffer('foo\r')).toString(), 'foo'); t.is(fn(new Buffer('foo\n\r\n')).toString(), 'foo\n'); });