Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

trim-leading-lines

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

trim-leading-lines - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

19

index.js
'use strict';
var isWhitespace = require('is-whitespace');
module.exports = function(str) {

@@ -7,8 +9,17 @@ if (typeof str !== 'string') {

}
if (!str) return str;
var lines = str.split('\n');
var idx = 0;
while (/^\s+$/.test(lines[idx]) || !lines[idx]) {
idx++;
if (lines.length === 1) {
return str;
}
return lines.slice(idx).join('\n');
var start = 0;
for (var i = 0; i < lines.length; i++) {
var line = lines[i];
if (isWhitespace(line) || line === '') {
continue;
}
start = i;
break;
}
return lines.slice(start).join('\n');
};
{
"name": "trim-leading-lines",
"description": "Trim leading lines from a string when they are 100% whitespace or empty.",
"version": "0.1.0",
"version": "0.1.1",
"homepage": "https://github.com/jonschlinkert/trim-leading-lines",

@@ -46,3 +46,6 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)",

]
},
"dependencies": {
"is-whitespace": "^0.3.0"
}
}

@@ -23,2 +23,10 @@ 'use strict';

it('should return empty strings', function() {
assert.equal(trimLeadingLines(''), '');
});
it('should return original string if no newlines', function() {
assert.equal(trimLeadingLines('foo'), 'foo');
});
it('should trim leading whitespace lines', function() {

@@ -25,0 +33,0 @@ var fixture = [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc