pax_global_header00006660000000000000000000000064126024546650014524gustar00rootroot0000000000000052 comment=f651a2d4cbf382c2936e6e53edee9316602e4ce7 trim-newlines-1.0.0/000077500000000000000000000000001260245466500143175ustar00rootroot00000000000000trim-newlines-1.0.0/.editorconfig000066400000000000000000000003471260245466500170000ustar00rootroot00000000000000root = 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 trim-newlines-1.0.0/.gitattributes000066400000000000000000000000141260245466500172050ustar00rootroot00000000000000* text=auto trim-newlines-1.0.0/.gitignore000066400000000000000000000000151260245466500163030ustar00rootroot00000000000000node_modules trim-newlines-1.0.0/.travis.yml000066400000000000000000000000761260245466500164330ustar00rootroot00000000000000language: node_js node_js: - 'stable' - '0.12' - '0.10' trim-newlines-1.0.0/index.js000066400000000000000000000003301260245466500157600ustar00rootroot00000000000000'use strict'; var fn = module.exports = function (x) { return fn.end(fn.start(x)); }; fn.start = function (x) { return x.replace(/^[\r\n]+/, ''); }; fn.end = function (x) { return x.replace(/[\r\n]+$/, ''); }; trim-newlines-1.0.0/license000066400000000000000000000021371260245466500156670ustar00rootroot00000000000000The 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. trim-newlines-1.0.0/package.json000066400000000000000000000012761260245466500166130ustar00rootroot00000000000000{ "name": "trim-newlines", "version": "1.0.0", "description": "Trim newlines from the start and/or end of a string", "license": "MIT", "repository": "sindresorhus/trim-newlines", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", "url": "sindresorhus.com" }, "engines": { "node": ">=0.10.0" }, "scripts": { "test": "xo && ava" }, "files": [ "index.js" ], "keywords": [ "trim", "newline", "newlines", "linebreak", "lf", "crlf", "left", "right", "start", "end", "string", "str", "remove", "delete", "strip" ], "devDependencies": { "ava": "*", "xo": "*" } } trim-newlines-1.0.0/readme.md000066400000000000000000000016711260245466500161030ustar00rootroot00000000000000# trim-newlines [![Build Status](https://travis-ci.org/sindresorhus/trim-newlines.svg?branch=master)](https://travis-ci.org/sindresorhus/trim-newlines) > Trim [newlines](https://en.wikipedia.org/wiki/Newline) from the start and/or end of a string ## Install ``` $ npm install --save trim-newlines ``` ## Usage ```js var trimNewlines = require('trim-newlines'); trimNewlines('\nunicorn\r\n'); //=> 'unicorn' ``` ## API ### trimNewlines(input) Trim from the start and end of a string. ### trimNewlines.start(input) Trim from the start of a string. ### trimNewlines.end(input) Trim from the end of a string. ## Related - [trim-left](https://github.com/sindresorhus/trim-left) - Similar to `String#trim()` but removes only whitespace on the left - [trim-right](https://github.com/sindresorhus/trim-right) - Similar to `String#trim()` but removes only whitespace on the right. ## License MIT © [Sindre Sorhus](http://sindresorhus.com) trim-newlines-1.0.0/test.js000066400000000000000000000011561260245466500156370ustar00rootroot00000000000000import test from 'ava'; import fn from './'; test('main', t => { t.is(fn('\nx\n'), 'x'); t.is(fn('\n\n\nx\n\n\n'), 'x'); t.is(fn('\r\nx\r\n'), 'x'); t.is(fn('\n\r\n\nx\n\r\n\n'), 'x'); t.end(); }); test('start', t => { t.is(fn.start('\nx'), 'x'); t.is(fn.start('\r\nx'), 'x'); t.is(fn.start('\n\n\n\nx'), 'x'); t.is(fn.start('\n\n\r\n\nx'), 'x'); t.is(fn.start('x\n\n\r\n\n'), 'x\n\n\r\n\n'); t.end(); }); test('end', t => { t.is(fn.end('x\n'), 'x'); t.is(fn.end('x\r\n'), 'x'); t.is(fn.end('x\n\n\n\n'), 'x'); t.is(fn.end('x\n\n\r\n\n'), 'x'); t.is(fn.end('\n\n\r\n\nx'), '\n\n\r\n\nx'); t.end(); });