Skip to content

Commit

Permalink
refactor: write as constant
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Jun 15, 2023
1 parent 482f945 commit 6665cd9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 4 additions & 3 deletions packages/runtime/src/cli/repl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ import { join } from 'path'

import { EdgeRuntime } from '../edge-runtime'

const [NODE_MAJOR] = process.versions.node.split('.').map((v) => Number(v))

const format = createFormat()

const writer: createRepl.REPLWriter = (output) => {
return typeof output === 'function' ? output.toString() : format(output)
}

const repl = createRepl.start({ prompt: 'ƒ => ', writer })
repl.setupHistory(join(homedir(), '.edge_runtime_repl_history'), () => {})
repl.setupHistory(join(homedir(), '.edge_runtime_repl_history'), () => { })

Object.getOwnPropertyNames(repl.context).forEach(
(mod) => delete repl.context[mod]
Expand All @@ -33,8 +35,7 @@ Object.defineProperty(repl.context, 'EdgeRuntime', {
value: runtime.context.EdgeRuntime,
})

const nodeMajorVersion = parseInt(process.versions.node.split('.')[0])
if (nodeMajorVersion < 16) {
if (NODE_MAJOR < 16) {
repl.context.util = {
inspect: (...args: any[]) => {
const stack = new Error().stack ?? ''
Expand Down
5 changes: 3 additions & 2 deletions packages/vm/tests/integration/crypto.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { EdgeVM } from '../../src'
import { createHash } from 'crypto'

const [NODE_MAJOR] = process.versions.node.split('.').map((v) => Number(v))

test('crypto.subtle.digest returns an ArrayBuffer', async () => {
const vm = new EdgeVM()

Expand Down Expand Up @@ -59,8 +61,7 @@ test('crypto.generateKey works with a Uint8Array from the VM', async () => {
await vm.evaluate(`(${fn})()`)
})

const nodeMajorVersion = parseInt(process.versions.node.split('.')[0])
if (nodeMajorVersion >= 16) {
if (NODE_MAJOR >= 16) {
test('Ed25519', async () => {
const vm = new EdgeVM()

Expand Down

0 comments on commit 6665cd9

Please sign in to comment.