🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

strip-whitespace

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

strip-whitespace

Strip whitespace in strings from javascript assets

1.0.7
latest
Source
npm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Strip-Whitespace - a javascript string minifier

node Travis AppVeyor Known Vulnerabilities David Greenkeeper badge Coveralls Codacy grade

Strip-Whitespace will remove extraneous spaces from strings. It's perfect for working with rendering templates (ex. mustache, handlebars) or es6 javascript templates. It works with anything where you might create very long strings.

Before strip-whitespace:
function() {
  if (condition) {
    const longString = '  String   with    some    extra   spaces  ';
  }
}
After strip-whitespace:
function() {
  if (condition) {
    const longString = ' String with some extra spaces ';
  }
}
Command-line usage
$ strip-whitespace --input <input-file> --output <output-file>
Javascript usage
var StripWhitespace = require('strip-whitespace');

// options are optional and can be omitted
var stripWhitespace = new StripWhitespace(options);
var result = stripWhitespace.strip(code);

// do things with the code
code = result.code;
Options

All options are optional

{
  shouldStripWhitespace: function(fatString) {
    // following code will answer the question: should this string be stripped of whitespace?
    if (fatString.startsWith('DO NOT MODIFY THIS STRING')) {
      return false;
    }

    return true;
  }
}

Keywords

whitespace

FAQs

Package last updated on 06 Jan 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts