New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bun-repl

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bun-repl - npm Package Compare versions

Comparing version 2.0.1 to 2.0.2

4

package.json
{
"type": "module",
"name": "bun-repl",
"version": "2.0.1",
"version": "2.0.2",
"description": "Experimental REPL for Bun",

@@ -33,3 +33,3 @@ "main": "src/module/repl.ts",

"bun-devtools": "^0.0.2",
"bun-types": "^0.8.1",
"bun-types": "^1.0.1",
"eslint": "^8.44.0",

@@ -36,0 +36,0 @@ "eslint-plugin-unicorn": "^48.0.1",

@@ -50,3 +50,4 @@ #!/usr/bin/env bun

BUN_REPL_HISTORY_SIZE The maximum number of lines to store in the history. (Default: 1000)
BUN_REPL_PROMPT A string to override the default REPL prompt with. (Default: "> ")`);
BUN_REPL_PROMPT A string to override the default REPL prompt with. (Default: "> ")
BUN_REPL_PORT The port for the REPL's local server to use. (Default: random free port)`);
}

@@ -128,2 +128,3 @@ import { type JSC } from 'bun-devtools';

development: true,
port: process.env.BUN_REPL_PORT ?? 0,
// @ts-expect-error stub

@@ -133,2 +134,3 @@ fetch() {},

super(`ws://${server.hostname}:${server.port}/bun:inspect`);
debuglog(`[ws/open] repl server listening on ${$.blueBright}ws://${server.hostname}:${server.port}/bun:inspect`);
this.onmessage = (event) => {

@@ -291,3 +293,3 @@ try {

async eval(code: string, topLevelAwaited = false, extraOut?: { errored?: boolean, noPrintError?: boolean }): Promise<string> {
debuglog(`transpiled code: ${code}`);
debuglog(`transpiled code: ${code.trimEnd()}`);
const { result, wasThrown } = await this.rawEval(code);

@@ -354,2 +356,3 @@ let remoteObj: EvalRemoteObject = result;

else {
debuglog('Trying to load history from fallback location at home directory.');
const homedir = os.homedir();

@@ -362,6 +365,13 @@ return await tryLoadHistory(homedir) ?? { path: join(homedir, '.bun_repl_history'), lines: [] };

try {
debuglog(`Trying to load REPL history from ${path}`);
const file = Bun.file(path);
if (!await file.exists()) await Bun.write(path, '');
if (!await file.exists()) {
debuglog(`History file not found, creating new one at ${path}`);
await Bun.write(path, '');
}
debuglog(`Loading history file from ${path}`);
return { path, lines: (await file.text()).split('\n') };
} catch {
} catch (err) {
debuglog(`Failed to load history file from ${path}\nError will be printed below:`);
if (IS_DEBUG) console.error(err);
return null;

@@ -396,4 +406,6 @@ }

await repl.ready;
debuglog('REPL server initialized.');
// TODO: How to make Bun transpiler not dead-code-eliminate lone constants like "5"?
const transpiler = new SWCTranspiler();
debuglog('Transpiler initialized.');
/*new Bun.Transpiler({

@@ -441,2 +453,3 @@ target: 'bun',

}
debuglog(`REPL history data loaded: (${history.lines.length} lines) ${history.path}`);
const rl = readline.createInterface({

@@ -457,2 +470,3 @@ input: process.stdin,

});
debuglog('readline interface created.');
console.log(`Welcome to Bun v${Bun.version}\nType ".help" for more information.`);

@@ -469,3 +483,2 @@ //* Only primordials should be used beyond this point!

});
rl.prompt();
rl.on('line', async line => {

@@ -531,2 +544,4 @@ line = StringTrim(line);

});
debuglog('readline interface event handlers registered.');
rl.prompt();
} catch (err) {

@@ -533,0 +548,0 @@ console.error('Internal REPL Error:');

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc