Skip to content

Commit

Permalink
refactor(xsnap): Remove redundant defer.js (#9745)
Browse files Browse the repository at this point in the history
This removes some stale code from before embracing makePromiseKit()
  • Loading branch information
mergify[bot] committed Jul 20, 2024
2 parents 5d70529 + 6973036 commit 8d1be18
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 45 deletions.
31 changes: 0 additions & 31 deletions packages/xsnap/src/defer.js

This file was deleted.

12 changes: 4 additions & 8 deletions packages/xsnap/src/xsnap.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,14 @@ import { makeNodeReader, makeNodeWriter } from '@endo/stream-node';
import { makePromiseKit, racePromises } from '@endo/promise-kit';
import { forever } from '@agoric/internal';
import { ErrorCode, ErrorSignal, ErrorMessage, METER_TYPE } from '../api.js';
import { defer } from './defer.js';

/** @import {PromiseKit} from '@endo/promise-kit' */

/**
* @typedef {typeof import('child_process').spawn} Spawn
* @import {Writable} from 'stream'
*/

/**
* @template T
* @typedef {import('./defer.js').Deferred<T>} Deferred
*/

// This will need adjustment, but seems to be fine for a start.
export const DEFAULT_CRANK_METERING_LIMIT = 1e8;

Expand Down Expand Up @@ -185,8 +181,8 @@ export async function xsnap(options) {
import.meta.url,
).pathname;

/** @type {Deferred<void>} */
const vatExit = defer();
/** @type {PromiseKit<void>} */
const vatExit = makePromiseKit();

assert(!/^-/.test(name), `name '${name}' cannot start with hyphen`);

Expand Down
12 changes: 6 additions & 6 deletions packages/xsnap/src/xsrepl.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@

import '@endo/init';

/**
* @template T
* @typedef {import('./defer.js').Deferred<T>} Deferred
*/
import * as childProcess from 'child_process';
import fs from 'fs';
import { tmpName } from 'tmp';
import * as os from 'os';
import * as readline from 'readline';
import { makePromiseKit } from '@endo/promise-kit';
import { xsnap } from './xsnap.js';
import { defer } from './defer.js';

/** @import {PromiseKit} from '@endo/promise-kit' */

const decoder = new TextDecoder();

Expand Down Expand Up @@ -65,7 +63,9 @@ async function main() {
* @returns {Promise<string>}
*/
function ask(prompt) {
const { promise, resolve } = /** @type {Deferred<string>} */ (defer());
const { promise, resolve } = /** @type {PromiseKit<string>} */ (
makePromiseKit()
);
rl.question(prompt, resolve);
return promise;
}
Expand Down

0 comments on commit 8d1be18

Please sign in to comment.