|
17 | 17 | * under the License. |
18 | 18 | */ |
19 | 19 |
|
20 | | -const Fury = require("@furyjs/fury"); |
21 | | -const utils = require("../test/util"); |
22 | | -const hps = require('@furyjs/hps'); |
23 | | -const fury = new Fury.default({ hps, refTracking: false, useSliceString: true }); |
24 | | -const Benchmark = require("benchmark"); |
25 | | -const protobuf = require("protobufjs"); |
26 | | -const path = require('path'); |
27 | | -const Type = Fury.Type; |
28 | | -const assert = require('assert'); |
29 | | -const { spawn } = require("child_process"); |
| 20 | +import utils from '../test/util.js'; |
| 21 | +import Fury from "@furyjs/fury"; |
| 22 | +import Hps from '@furyjs/hps'; |
| 23 | +import Benchmark from 'benchmark'; |
| 24 | +import protobuf from 'protobufjs'; |
| 25 | +import path, { dirname } from 'path'; |
| 26 | +import assert from 'assert'; |
| 27 | +import { fileURLToPath } from 'url'; |
| 28 | +import { spawn } from 'child_process'; |
30 | 29 |
|
| 30 | +const fury = new Fury({ hps: Hps, refTracking: false, useSliceString: true }); |
| 31 | +const currentModulePath = fileURLToPath(import.meta.url); |
| 32 | +const currentModuleDir = dirname(currentModulePath); |
31 | 33 |
|
32 | 34 | const sample = { |
33 | 35 | id: 123456, |
@@ -116,7 +118,7 @@ const sampleJson = JSON.stringify(sample); |
116 | 118 |
|
117 | 119 | function loadProto() { |
118 | 120 | return new Promise((resolve) => { |
119 | | - protobuf.load(path.join(__dirname, 'sample.proto'), function (err, root) { |
| 121 | + protobuf.load(path.join(currentModuleDir, 'sample.proto'), function (err, root) { |
120 | 122 | if (err) throw err; |
121 | 123 | const AwesomeMessage = root.lookupType("SomeMessage"); |
122 | 124 | resolve({ |
@@ -208,7 +210,7 @@ async function start() { |
208 | 210 | `python3`, |
209 | 211 | ['draw.py', result.json.serialize, result.json.deserialize, result.protobuf.serialize, result.protobuf.deserialize, result.fury.serialize, result.fury.deserialize], |
210 | 212 | { |
211 | | - cwd: __dirname, |
| 213 | + cwd: currentModuleDir, |
212 | 214 | } |
213 | 215 | ) |
214 | 216 | } |
|
0 commit comments