Security News
NVD Backlog Tops 20,000 CVEs Awaiting Analysis as NIST Prepares System Updates
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
collapse-whitespace
Advanced tools
collapse-whitespace
is a module for removing unnecessary whitespace from a DOM tree.
Use npm
:
$ npm install collapse-whitespace
Then, if you’re using browserify
or something similar:
var collapse = require('collapse-whitespace')
Otherwise, just include the minified file, whitespace.min.js
, somewhere on your page:
<script src="./node_modules/collapse-whitespace/whitespace.min.js"></script>
var collapse = require('collapse-whitespace')
var div = document.createElement('div')
div.innerHTML = ' <p>Foo bar</p> <p>Words</p> '
collapse(div)
console.log(div.innerHTML)
// '<p>Foo bar</p><p>Words</p>'
For more examples of what collapse-whitespace
does, check out the test page.
collapse-whitespace
exposes a single function; if you’re including this module as a global, it will be called collapse
.
Removes all extraneous whitespace from the given node. By default, collapse-whitespace
relies on a theoretical list of block elements to determine which elements are block and which ones are inline. This list may be unsuitable for your needs; the optional parameter isBlock
can be used to tweak this behaviour. isBlock
should be a function that accepts a DOM node and returns a Boolean.
Note that collapse-whitespace
also does not take into account the parent(s) of the given node
<pre>
<span class="test">
Lots of whitespace around this text.
</span>
</pre>
<script>
collapse(document.querySelector('.test'))
</script>
<!-- Results in: -->
<pre>
<span class="test">Lots of whitespace around this text.</span>
</pre>
MIT
FAQs
Remove unnecessary whitespace from an element.
The npm package collapse-whitespace receives a total of 14,335 weekly downloads. As such, collapse-whitespace popularity was classified as popular.
We found that collapse-whitespace demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.