Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

micromark-util-decode-numeric-character-reference

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

micromark-util-decode-numeric-character-reference - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

7

dev/index.d.ts

@@ -5,3 +5,3 @@ /**

*
* Sort of like `String.fromCharCode(Number.parseInt(value, base))`, but makes
* Sort of like `String.fromCodePoint(Number.parseInt(value, base))`, but makes
* non-characters and control characters safe.

@@ -16,5 +16,2 @@ *

*/
export function decodeNumericCharacterReference(
value: string,
base: number
): string
export function decodeNumericCharacterReference(value: string, base: number): string;

@@ -7,3 +7,3 @@ import {codes, values} from 'micromark-util-symbol'

*
* Sort of like `String.fromCharCode(Number.parseInt(value, base))`, but makes
* Sort of like `String.fromCodePoint(Number.parseInt(value, base))`, but makes
* non-characters and control characters safe.

@@ -42,3 +42,3 @@ *

return String.fromCharCode(code)
return String.fromCodePoint(code)
}

@@ -5,3 +5,3 @@ /**

*
* Sort of like `String.fromCharCode(Number.parseInt(value, base))`, but makes
* Sort of like `String.fromCodePoint(Number.parseInt(value, base))`, but makes
* non-characters and control characters safe.

@@ -16,5 +16,2 @@ *

*/
export function decodeNumericCharacterReference(
value: string,
base: number
): string
export function decodeNumericCharacterReference(value: string, base: number): string;

@@ -5,3 +5,3 @@ /**

*
* Sort of like `String.fromCharCode(Number.parseInt(value, base))`, but makes
* Sort of like `String.fromCodePoint(Number.parseInt(value, base))`, but makes
* non-characters and control characters safe.

@@ -17,22 +17,18 @@ *

export function decodeNumericCharacterReference(value, base) {
const code = Number.parseInt(value, base)
const code = Number.parseInt(value, base);
if (
// C0 except for HT, LF, FF, CR, space.
code < 9 ||
code === 11 ||
(code > 13 && code < 32) ||
// Control character (DEL) of C0, and C1 controls.
(code > 126 && code < 160) ||
// Lone high surrogates and low surrogates.
(code > 55_295 && code < 57_344) ||
// Noncharacters.
(code > 64_975 && code < 65_008) /* eslint-disable no-bitwise */ ||
(code & 65_535) === 65_535 ||
(code & 65_535) === 65_534 /* eslint-enable no-bitwise */ ||
// Out of range
code > 1_114_111
) {
return '\uFFFD'
// C0 except for HT, LF, FF, CR, space.
code < 9 || code === 11 || code > 13 && code < 32 ||
// Control character (DEL) of C0, and C1 controls.
code > 126 && code < 160 ||
// Lone high surrogates and low surrogates.
code > 55_295 && code < 57_344 ||
// Noncharacters.
code > 64_975 && code < 65_008 || /* eslint-disable no-bitwise */
(code & 65_535) === 65_535 || (code & 65_535) === 65_534 || /* eslint-enable no-bitwise */
// Out of range
code > 1_114_111) {
return "\uFFFD";
}
return String.fromCharCode(code)
}
return String.fromCodePoint(code);
}
{
"name": "micromark-util-decode-numeric-character-reference",
"version": "2.0.0",
"version": "2.0.1",
"description": "micromark utility to decode numeric character references",

@@ -49,3 +49,11 @@ "license": "MIT",

},
"xo": false
"xo": {
"envs": [
"shared-node-browser"
],
"prettier": true,
"rules": {
"unicorn/prefer-code-point": "off"
}
}
}

@@ -81,3 +81,3 @@ # micromark-util-decode-numeric-character-reference

Sort of like `String.fromCharCode(Number.parseInt(value, base))`, but makes
Sort of like `String.fromCodePoint(Number.parseInt(value, base))`, but makes
non-characters and control characters safe.

@@ -84,0 +84,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc