Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
@types/he provides TypeScript type definitions for the 'he' library, which is used for encoding and decoding HTML entities.
Encode HTML entities
This feature allows you to encode special characters in a string into their corresponding HTML entities. For example, the ampersand '&' is encoded as '&'.
const he = require('he');
const encoded = he.encode('Hello & World');
console.log(encoded); // Output: 'Hello & World'
Decode HTML entities
This feature allows you to decode HTML entities back into their original characters. For example, '&' is decoded back to '&'.
const he = require('he');
const decoded = he.decode('Hello & World');
console.log(decoded); // Output: 'Hello & World'
Encode HTML entities with custom options
This feature allows you to encode HTML entities with custom options, such as using named references for entities.
const he = require('he');
const encoded = he.encode('Hello & World', { 'useNamedReferences': true });
console.log(encoded); // Output: 'Hello & World'
Decode HTML entities with custom options
This feature allows you to decode HTML entities with custom options, such as treating the input as an attribute value.
const he = require('he');
const decoded = he.decode('Hello & World', { 'isAttributeValue': true });
console.log(decoded); // Output: 'Hello & World'
The 'entities' package provides similar functionality for encoding and decoding HTML entities. It supports both XML and HTML entities and offers a more comprehensive set of features for handling different types of entities.
The 'html-entities' package is another alternative for encoding and decoding HTML entities. It provides a simple API and supports both named and numeric entities. It is known for its performance and ease of use.
The 'escape-html' package focuses on escaping HTML entities to prevent XSS attacks. It provides a lightweight and efficient way to escape special characters in HTML strings.
npm install --save @types/he
This package contains type definitions for he v0.5.0 (https://github.com/mathiasbynens/he).
Files were exported from https://www.github.com/DefinitelyTyped/DefinitelyTyped/tree/types-2.0/he
Additional Details
These definitions were written by Simon Edwards https://github.com/sedwards2009.
FAQs
TypeScript definitions for he
The npm package @types/he receives a total of 319,645 weekly downloads. As such, @types/he popularity was classified as popular.
We found that @types/he demonstrated a healthy version release cadence and project activity because the last version was released less than 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
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.