Skip to content

Commit

Permalink
Refactor internals to reduce bundle size
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Oct 29, 2021
1 parent 1cdda59 commit 98076ae
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
8 changes: 3 additions & 5 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {isHexadecimal} from 'is-hexadecimal'
import {isAlphanumerical} from 'is-alphanumerical'
import {decodeEntity} from './decode-entity.js'

const own = {}.hasOwnProperty
const fromCharCode = String.fromCharCode

// Warning messages.
Expand Down Expand Up @@ -156,11 +155,10 @@ export function parseEntities(value, options = {}) {
// Check if we can match a legacy named reference.
// If so, we cache that as the last viable named reference.
// This ensures we do not need to walk backwards later.
if (type === 'named' && own.call(characterEntitiesLegacy, characters)) {
if (type === 'named' && characterEntitiesLegacy.includes(characters)) {
characterReferenceCharacters = characters
// @ts-expect-error: to do, make `characterEntitiesLegacy` a normal
// object.
characterReference = characterEntitiesLegacy[characters]
// @ts-expect-error: always able to decode.
characterReference = decodeEntity(characters)
}
}

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
"index.d.ts"
],
"dependencies": {
"@types/unist": "^2.0.6",
"@types/unist": "^2.0.0",
"character-entities": "^2.0.0",
"character-entities-legacy": "^2.0.0",
"character-entities-legacy": "^3.0.0",
"character-reference-invalid": "^2.0.0",
"is-alphanumerical": "^2.0.0",
"is-decimal": "^2.0.0",
Expand Down

0 comments on commit 98076ae

Please sign in to comment.