refactor(web): use fs/promises
This commit is contained in:
parent
0cd4aa2075
commit
ac37e60559
2 changed files with 5 additions and 10 deletions
|
|
@ -1163,16 +1163,11 @@ class Language {
|
|||
if (input instanceof Uint8Array) {
|
||||
bytes = Promise.resolve(input);
|
||||
} else {
|
||||
const url = input;
|
||||
if (
|
||||
typeof process !== 'undefined' &&
|
||||
process.versions &&
|
||||
process.versions.node
|
||||
) {
|
||||
const fs = require('fs');
|
||||
bytes = Promise.resolve(fs.readFileSync(url));
|
||||
if (globalThis.process?.versions?.node) {
|
||||
const fs = require('fs/promises');
|
||||
bytes = fs.readFile(input);
|
||||
} else {
|
||||
bytes = fetch(url)
|
||||
bytes = fetch(input)
|
||||
.then((response) => response.arrayBuffer()
|
||||
.then((buffer) => {
|
||||
if (response.ok) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
const Parser = require(`..`);
|
||||
const Parser = require('..');
|
||||
|
||||
function languageURL(name) {
|
||||
return require.resolve(`../../../target/release/tree-sitter-${name}.wasm`);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue