This is a
playground to test code. It runs a full
Node.js environment and already has all of
npm’s 400,000 packages pre-installed, including
trim-newlines with all
npm packages installed. Try it out:
This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.
Trim newlines from the start and/or end of a string
$ npm install trim-newlines
const trimNewlines = require('trim-newlines'); trimNewlines('\n🦄\r\n'); //=> '🦄' trimNewlines.start('\n🦄\r\n'); //=> '🦄\r\n' trimNewlines.end('\n🦄\r\n'); //=> '\n🦄'
Trim from the start and end of a string.
Trim from the start of a string.
Trim from the end of a string.
String#trim()but removes only whitespace on the left
String#trim()but removes only whitespace on the right.
MIT © Sindre Sorhus