Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
decode-named-character-reference
Advanced tools
The decode-named-character-reference npm package is used to decode named character references (also known as HTML entities) into their corresponding characters. This is particularly useful when dealing with HTML or XML content where special characters are encoded as named entities.
Decode Named Character Reference
This feature allows you to decode a named character reference into its corresponding character. In this example, the named character reference '&' is decoded to '&'.
const decode = require('decode-named-character-reference');
const decodedString = decode('&');
console.log(decodedString); // Output: &
Decode Multiple Named Character References
This feature allows you to decode multiple named character references within a string. In this example, both '&' and '<' are decoded to '&' and '<' respectively.
const decode = require('decode-named-character-reference');
const decodedString = decode('Hello & welcome to the world of <coding>!');
console.log(decodedString); // Output: Hello & welcome to the world of <coding>!
The 'he' package (short for HTML entities) is a robust HTML entity encoder/decoder. It supports both named and numeric character references and can handle both encoding and decoding. Compared to decode-named-character-reference, 'he' offers more comprehensive functionality including encoding capabilities.
The 'entities' package provides fast and robust encoding and decoding of XML and HTML entities. It supports both named and numeric character references. Similar to 'he', it offers both encoding and decoding functionalities, making it more versatile than decode-named-character-reference.
The 'html-entities' package is another library for encoding and decoding HTML entities. It supports named, numeric, and hexadecimal character references. This package is similar to 'he' and 'entities' in terms of functionality, providing both encoding and decoding capabilities.
Decode named character references.
A workaround for webpack.
Never use this.
Use parse-entities
.
It uses this.
This package is ESM only. In Node.js (version 12.20+, 14.14+, or 16.0+), install with npm:
npm install decode-named-character-reference
In Deno with esm.sh
:
import {decodeNamedCharacterReference} from 'https://esm.sh/decode-named-character-reference@1'
In browsers with esm.sh
:
<script type="module">
import {decodeNamedCharacterReference} from 'https://esm.sh/decode-named-character-reference@1?bundle'
</script>
import {decodeNamedCharacterReference} from 'decode-named-character-reference'
decodeNamedCharacterReference('amp') //=> '&'
This package exports the following identifier: decodeNamedCharacterReference
.
There is no default export.
decodeNamedCharacterReference(value)
Again, use parse-entities
.
This package is fully typed with TypeScript.
This package is at least compatible with all maintained versions of Node.js. As of now, that is Node.js 12.20+, 14.14+, and 16.0+. It also works in Deno and modern browsers.
This package is safe.
parse-entities
— parse (decode) HTML character referencesYes please! See How to Contribute to Open Source.
FAQs
Decode named character references
The npm package decode-named-character-reference receives a total of 3,438,743 weekly downloads. As such, decode-named-character-reference popularity was classified as popular.
We found that decode-named-character-reference 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.