![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
truncate html by text length
using npm
.
npm install -S trunc-html
trunc(html, limit, options?)
Returns the result of truncating the provided html
. A plain-text version is provided as well.
var html = 'the force is <strong>with this one</strong>. some more rubbish';
trunc(html, { limit: 30 });
// <-
// { html: 'the force is <strong>with this one</strong>. …',
// text: 'the force is with this one. …' }
limit
Maximum amount of text characters allowed. When the limit
is reached, the algorithm will trace back to the last word separator and trim the rest into a …
glyph.
options.ignoreTags
If you'd like to supress certain HTML tags from being output you can provide an array of tags to be excluded, e.g ['img']
.
options.sanitizer
Options passed to insane
. Note that these options are overridden by the options provided by trunc-html
, so you can't use filter
and transformText
, which trunc-html
reserves for itself.
MIT
FAQs
truncate html by text length
The npm package trunc-html receives a total of 4,030 weekly downloads. As such, trunc-html popularity was classified as popular.
We found that trunc-html demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.