Skip to content

Commit 55b1cb9

Browse files
committedMar 11, 2025
Change to require Node.js 16
1 parent fd07510 commit 55b1cb9

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed
 

‎lib/core.js

+6-9
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@ import {h} from 'hastscript'
5555
import {parseEntities} from 'parse-entities'
5656
import {Prism} from './prism-core.js'
5757

58-
// To do: next major, use `Object.hasOwn`.
59-
const own = {}.hasOwnProperty
60-
6158
// Inherit.
6259
function Refractor() {}
6360

@@ -111,7 +108,7 @@ function highlight(value, language) {
111108
throw new TypeError('Expected `string` for `name`, got `' + name + '`')
112109
}
113110

114-
if (own.call(refractor.languages, name)) {
111+
if (Object.hasOwn(refractor.languages, name)) {
115112
grammar = refractor.languages[name]
116113
} else {
117114
throw new Error('Unknown language: `' + name + '` is not registered')
@@ -140,7 +137,7 @@ function register(syntax) {
140137
}
141138

142139
// Do not duplicate registrations.
143-
if (!own.call(refractor.languages, syntax.displayName)) {
140+
if (!Object.hasOwn(refractor.languages, syntax.displayName)) {
144141
syntax(refractor)
145142
}
146143
}
@@ -172,7 +169,7 @@ function alias(language, alias) {
172169
let key
173170

174171
for (key in map) {
175-
if (own.call(map, key)) {
172+
if (Object.hasOwn(map, key)) {
176173
const value = map[key]
177174
const list = typeof value === 'string' ? [value] : value
178175
let index = -1
@@ -199,7 +196,7 @@ function registered(aliasOrLanguage) {
199196
)
200197
}
201198

202-
return own.call(refractor.languages, aliasOrLanguage)
199+
return Object.hasOwn(refractor.languages, aliasOrLanguage)
203200
}
204201

205202
/**
@@ -217,7 +214,7 @@ function listLanguages() {
217214

218215
for (language in languages) {
219216
if (
220-
own.call(languages, language) &&
217+
Object.hasOwn(languages, language) &&
221218
typeof languages[language] === 'object'
222219
) {
223220
list.push(language)
@@ -310,7 +307,7 @@ function attributes(record) {
310307
let key
311308

312309
for (key in record) {
313-
if (own.call(record, key)) {
310+
if (Object.hasOwn(record, key)) {
314311
record[key] = parseEntities(record[key])
315312
}
316313
}

‎readme.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ You can play with refractor on the
9090
## Install
9191

9292
This package is [ESM only][github-gist-esm].
93-
In Node.js (version 14+),
93+
In Node.js (version 16+),
9494
install with [npm][npmjs-install]:
9595

9696
```sh
@@ -727,7 +727,7 @@ to get Prism Dark from [`esm.sh`][esmsh]:
727727

728728
This package is at least compatible with all maintained versions of Node.js.
729729
As of now,
730-
that is Node.js 14+.
730+
that is Node.js 16+.
731731
It also works in Deno and modern browsers.
732732

733733
Only the custom built syntaxes in `refractor/lang/*.js` will work with

‎tsconfig.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@
66
"declaration": true,
77
"emitDeclarationOnly": true,
88
"exactOptionalPropertyTypes": true,
9-
"lib": ["dom", "es2020"],
9+
"lib": ["dom", "es2022"],
1010
"module": "node16",
11-
"skipLibCheck": true,
1211
"strict": true,
13-
"target": "es2020"
12+
"target": "es2022"
1413
},
1514
"exclude": ["coverage/", "lang/", "node_modules/"],
1615
"include": ["**/*.js"]

0 commit comments

Comments
 (0)
Please sign in to comment.