Skip to content

Commit

Permalink
s/.mts/.ts/g
Browse files Browse the repository at this point in the history
  • Loading branch information
ajvincent committed Sep 22, 2024
1 parent cc6950a commit 19eda82
Show file tree
Hide file tree
Showing 59 changed files with 73 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import type {
NumberStringType
} from "../fixtures/types/NumberStringType.mjs";
} from "../fixtures/types/NumberStringType.js";

import NumberStringClass from "../fixtures/NumberStringClass.mjs";
import NumberStringClass from "../fixtures/NumberStringClass.js";

type ClassMethodDecorator<
This extends object,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"spec_files": [
"./spec/**/*.mjs",
"./spec/**/*.mts",
"./spec/**/*.js",
"./spec/**/*.ts"
],
"stopSpecOnExpectationFailure": false
Expand Down
30 changes: 15 additions & 15 deletions packages/v2-es-membrane/_01_stage_utilities/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@ This directory is an infrastructure grab-bag: it provides common classes to sup

## Generic tools

- [DefaultMap](./source/DefaultMap.mts) extends `Map` and `WeakMap`, to provide a `getDefault()` method where the user can set a value for a key if there isn't an existing value.
- [PromiseTypes](./source/PromiseTypes.mts) is a set of utilities relating directly to basic promises.
- [DefaultMap](./source/DefaultMap.ts) extends `Map` and `WeakMap`, to provide a `getDefault()` method where the user can set a value for a key if there isn't an existing value.
- [PromiseTypes](./source/PromiseTypes.ts) is a set of utilities relating directly to basic promises.
- `TimeoutPromise` for promises rejecting after a delay. Useful with `Promise.race()` to ensure a task finishes in a certain length of time.
- `SingletonPromise` for wrapping a Promise-returning method so it only runs once.
- `PromiseAllParallel` and its sibling `PromiseAllSequence`, for mapping an array of objects into an array of promises, and then waiting for all the promises to resolve.
- `PromiseDictionary` for converting a dictionary of promises (`{ [key in keyof T]: Promise<T[key]> }`) into a promise of a dictionary (`Promise<T>`). See [the proposal-await-dictionary](https://github.com/tc39/proposal-await-dictionary) repository, which I originally started.
- [PropertyKeySorter](./source/PropertyKeySorter.mts) is a simple utility for sorting:
- [PropertyKeySorter](./source/PropertyKeySorter.ts) is a simple utility for sorting:
1. strings by JavaScript's default sort ordering,
2. symbols in the order the PropertyKeySorter sees them.
- [ReplaceableValueMap](./source/ReplaceableValueMap.mts) lets you define a value you want to subsitute for another, and a shared object for that replaced value to use. This is useful for decorators which want to have a _single_ replacement for an original value (i.e. the same class decorator run more than once won't subclass more than once).
- [WeakRefSet](./source/WeakRefSet.mts) is basically a `Set<WeakRef<T>>`: it stores weak references and allows you to retrieve them later.
- [SharedAssertSet](./source/SharedAssertSet.mts): assertion failures in one object, notifying other objects of the failure so all of them can shut down. Membranes have several proxy handlers which the user should never see, so an assertion failure in one proxy handler can terminate an entire membrane.
- [types/assert.d.mts](./source/types/assert.d.mts) defines common assertion interfaces and types.
- [RequiredInitializers](./source/RequiredInitializers.mts) is a very simple state machine for defining and resolving prerequisites, when you can't use constructors. [See mix-in decorators](../_02_mixin_decorators/README.md).
- [`maybeDefined.mts`](./source/maybeDefined.mts) provides some utilities for making sure we've filled in some fields. This may not have been my best idea... but it works.
- [types/Utility.d.mts](./source/types/Utility.d.mts) provides utility types, many of which I don't use but I thought I might need.
- [ReplaceableValueMap](./source/ReplaceableValueMap.ts) lets you define a value you want to subsitute for another, and a shared object for that replaced value to use. This is useful for decorators which want to have a _single_ replacement for an original value (i.e. the same class decorator run more than once won't subclass more than once).
- [WeakRefSet](./source/WeakRefSet.ts) is basically a `Set<WeakRef<T>>`: it stores weak references and allows you to retrieve them later.
- [SharedAssertSet](./source/SharedAssertSet.ts): assertion failures in one object, notifying other objects of the failure so all of them can shut down. Membranes have several proxy handlers which the user should never see, so an assertion failure in one proxy handler can terminate an entire membrane.
- [types/assert.d.ts](./source/types/assert.d.ts) defines common assertion interfaces and types.
- [RequiredInitializers](./source/RequiredInitializers.ts) is a very simple state machine for defining and resolving prerequisites, when you can't use constructors. [See mix-in decorators](../_02_mixin_decorators/README.md).
- [`maybeDefined.ts`](./source/maybeDefined.ts) provides some utilities for making sure we've filled in some fields. This may not have been my best idea... but it works.
- [types/Utility.d.ts](./source/types/Utility.d.ts) provides utility types, many of which I don't use but I thought I might need.

## Internal build tools

- [AsyncSpecModules](./source/AsyncSpecModules.mts) is for Jasmine test specifications to load modules dynamically. Think of this as wrapping [the import() function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import) in TypeScript.
- [getTS_SourceFile.mts](./source/getTS_SourceFile.mts) uses [ts-morph](https://ts-morph.com) to parse TypeScript source files.
- [SpyBase](./source/SpyBase.mts) provides a helper class for Jasmine spies.
- [StateMachine_DFA](./source/stateMachines/dfa-states.mts) is a very bare-bones state machine implementation.
- [holdsArgument](./source/gc/holdsArgument.mts) and [holdsReturn](./source/gc/holdsReturn.mts) are for Jasmine test specifications to use, testing whether a particular function holds a reference to an argument or its return value, respectively. They use two NodeJS-specific functions, `gc()` and `setImmediatePromise()`, for tests involving garbage collection.
- [AsyncSpecModules](./source/AsyncSpecModules.ts) is for Jasmine test specifications to load modules dynamically. Think of this as wrapping [the import() function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import) in TypeScript.
- [getTS_SourceFile.ts](./source/getTS_SourceFile.ts) uses [ts-morph](https://ts-morph.com) to parse TypeScript source files.
- [SpyBase](./source/SpyBase.ts) provides a helper class for Jasmine spies.
- [StateMachine_DFA](./source/stateMachines/dfa-states.ts) is a very bare-bones state machine implementation.
- [holdsArgument](./source/gc/holdsArgument.ts) and [holdsReturn](./source/gc/holdsReturn.ts) are for Jasmine test specifications to use, testing whether a particular function holds a reference to an argument or its return value, respectively. They use two NodeJS-specific functions, `gc()` and `setImmediatePromise()`, for tests involving garbage collection.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { doubleArray } from "./source/AsyncModule.mjs";
import { doubleArray } from "./source/AsyncModule.js";

export default async function() : Promise<void> {
console.log(await doubleArray.run());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {
getModuleDefaultClassWithArgs,
ModuleSourceDirectory,
} from "../../source/AsyncSpecModules.mjs";
} from "../../source/AsyncSpecModules.js";

import type {
DoubleArrayPromiseType,
} from "./DoubleArrayPromise.mjs";
} from "./DoubleArrayPromise.js";

const moduleSource: ModuleSourceDirectory = {
importMeta: import.meta,
Expand All @@ -16,7 +16,7 @@ const DoubleArrayPromise = await getModuleDefaultClassWithArgs<
[number],
DoubleArrayPromiseType
>(
moduleSource, "DoubleArrayPromise.mjs"
moduleSource, "DoubleArrayPromise.js"
);

const doubleArray = new DoubleArrayPromise(100);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
PromiseAllSequence,
SingletonPromise,
} from "../../source/PromiseTypes.mjs";
} from "../../source/PromiseTypes.js";

export type DoubleArrayPromiseType = {
run() : Promise<number[]>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import holdsReturn from "./holdsReturn.mjs";
import holdsReturn from "./holdsReturn.js";

/**
* Report if a callback function holds references to any values.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import tryGarbageCollection from "./tryGarbageCollection.mjs";
import tryGarbageCollection from "./tryGarbageCollection.js";
import PromiseFinalizer, {
type PromiseResolver
} from "./promiseFinalizer.mjs";
} from "./promiseFinalizer.js";

type MaybeHoldReturn = () => object;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
import {
ModuleSourceDirectory,
pathToModule,
} from "./AsyncSpecModules.mjs";
} from "./AsyncSpecModules.js";

const project = new Project({
"compilerOptions": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import type {
MethodsOnlyType
} from "./MethodsOnlyType.d.mts";
} from "./MethodsOnlyType.js";

export type ClassMethodDecoratorFunction<
This extends MethodsOnlyType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ import {
getModuleDefaultClass,
getModuleDefaultClassWithArgs,
getModulePart,
} from "../source/AsyncSpecModules.mjs";
} from "../source/AsyncSpecModules.js";

import NumberStringClass from "../fixtures/NumberStringClass.mjs";
import NumberStringClass from "../fixtures/NumberStringClass.js";
import type {
NumberStringType
} from "../fixtures/types/NumberStringType.mjs";
} from "../fixtures/types/NumberStringType.js";

import type {
DoubleArrayPromiseType,
} from "../examples/source/DoubleArrayPromise.mjs";
} from "../examples/source/DoubleArrayPromise.js";

const stageDir: ModuleSourceDirectory = {
importMeta: import.meta,
Expand All @@ -25,20 +25,20 @@ const stageDir: ModuleSourceDirectory = {
describe("AsyncSpecModules", () => {
it("pathToModule provides resolved paths", () => {
expect(
pathToModule(stageDir, "spec/AsyncSpecModules.mts")
pathToModule(stageDir, "spec/AsyncSpecModules.ts")
).toBe(fileURLToPath(import.meta.url));

expect(
pathToModule({
pathToDirectory: "#stage_utilities/spec",
isAbsolutePath: true
}, "AsyncSpecModules.mts")
}, "AsyncSpecModules.ts")
).toBe(fileURLToPath(import.meta.url));
});

it("getModuleDefaultClass retrieves an exported module", async () => {
await expectAsync(getModuleDefaultClass<NumberStringType>(
stageDir, "fixtures/NumberStringClass.mjs"
stageDir, "fixtures/NumberStringClass.js"
)).toBeResolvedTo(NumberStringClass);
});

Expand All @@ -48,7 +48,7 @@ describe("AsyncSpecModules", () => {
DoubleArrayPromiseType
>
(
stageDir, "examples/source/DoubleArrayPromise.mjs"
stageDir, "examples/source/DoubleArrayPromise.js"
);
const doubleArray = new DoubleArrayPromise(100);
expect((await doubleArray.run()).length).toBe(100);
Expand All @@ -59,7 +59,7 @@ describe("AsyncSpecModules", () => {
"pathToModule", typeof pathToModule
>
(
stageDir, "source/AsyncSpecModules.mjs", "pathToModule"
stageDir, "source/AsyncSpecModules.js", "pathToModule"
);

expect(pathToModuleAsPart).toBe(pathToModule);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PromiseDictionary } from "#stage_utilities/source/PromiseTypes.mjs";
import { PromiseDictionary } from "#stage_utilities/source/PromiseTypes.js";

it("PromiseDictionary resolves", async () => {
const THREE = Symbol("three");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
SingletonPromise
} from "../../source/PromiseTypes.mjs";
} from "../../source/PromiseTypes.js";

describe("PromiseTypes.SingletonPromise", () => {
it("resolves to the value we pass in", async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import PropertyKeySorter, { propertyKey } from "../source/PropertyKeySorter.mjs";
import PropertyKeySorter, { propertyKey } from "../source/PropertyKeySorter.js";

describe("Property key sorter", () => {
const str0 = "0", str1 = "1", sym0 = Symbol("0"), sym1 = Symbol("1");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ReplaceableValueMap from "#stage_utilities/source/ReplaceableValueMap.mjs";
import ReplaceableValueMap from "#stage_utilities/source/ReplaceableValueMap.js";

it("ReplaceableValueMap provides a matching replacement for each value it receives", () => {
class Foo {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import getRequiredInitializers, {
type RequiredState
} from "../source/RequiredInitializers.mjs";
} from "../source/RequiredInitializers.js";

it("RequiredInitializers provide a one-way path to ensuring flags are set, then cleared, then empty", () => {
function message(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type {
ClassMethodDecoratorFunction
} from "../../source/types/ClassMethodDecoratorFunction.mjs";
} from "../../source/types/ClassMethodDecoratorFunction.js";

import NumberStringClass from "#stage_utilities/fixtures/NumberStringClass.mjs";
import NumberStringClass from "#stage_utilities/fixtures/NumberStringClass.js";
import type {
NumberStringType
} from "#stage_utilities/fixtures/types/NumberStringType.mjs";
} from "#stage_utilities/fixtures/types/NumberStringType.js";

describe("ClassMethodDecoratorFunction is compatible with ECMAScript decorators", () => {
it("returning void", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import WeakStrongMap from "#stage_utilities/source/collections/WeakStrongMap.js";

describe("CodeGenerator(WeakStrongMap.mjs),", () => {
describe("CodeGenerator(WeakStrongMap.js),", () => {
let testMap: WeakStrongMap<object, unknown, unknown>, refMap = new Map;

const defaultValue1 = Symbol("default value one");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import OneToOneStrongMap from "#stage_utilities/source/collections/OneToOneStrongMap.js";
import holdsArgument from "#stage_utilities/source/gc/holdsArgument.mjs";
import holdsArgument from "#stage_utilities/source/gc/holdsArgument.js";

describe("CodeGenerator(OneToOneStrongMap.mjs) to hold values", () => {
describe("CodeGenerator(OneToOneStrongMap.js) to hold values", () => {
let map: OneToOneStrongMap<unknown, object>;
beforeEach(() => map = new OneToOneStrongMap);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import WeakRefSet from "#stage_utilities/source/collections/WeakRefSet.js";
import holdsReturn from "#stage_utilities/source/gc/holdsReturn.mjs";
import holdsReturn from "#stage_utilities/source/gc/holdsReturn.js";

it("WeakRefSet holds references to objects weakly", async () => {
const refSet: WeakRefSet<object> = new WeakRefSet;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import WeakStrongMap from "#stage_utilities/source/collections/WeakStrongMap.js";
import holdsArgument from "#stage_utilities/source/gc/holdsArgument.mjs";
import holdsArgument from "#stage_utilities/source/gc/holdsArgument.js";

describe("CodeGenerator(WeakStrongMap.mjs) holds references to objects", () => {
describe("CodeGenerator(WeakStrongMap.js) holds references to objects", () => {
let testMap: WeakStrongMap<object, unknown, unknown>, refMap = new Map;

const defaultValue1 = Symbol("default value one");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import holdsArgument from "#stage_utilities/source/gc/holdsArgument.mjs";
import holdsArgument from "#stage_utilities/source/gc/holdsArgument.js";

it("holdsArgument demonstrates functions holding an object strongly or weakly", async () => {
function voidObject(obj: object): void {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import holdsReturn from "#stage_utilities/source/gc/holdsReturn.mjs";
import holdsReturn from "#stage_utilities/source/gc/holdsReturn.js";

it("holdsReturn demonstrates functions returning objects held strongly or weakly", async () => {
function voidObject(): object {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import type { ModuleSourceDirectory } from "../source/AsyncSpecModules.mjs";
import getTS_SourceFile from "../source/getTS_SourceFile.mjs";
import type { ModuleSourceDirectory } from "../source/AsyncSpecModules.js";
import getTS_SourceFile from "../source/getTS_SourceFile.js";

it("getTS_SourceFile works", () => {
const startDir: ModuleSourceDirectory = {
importMeta: import.meta,
pathToDirectory: "../../source"
};

const sourceFile = getTS_SourceFile(startDir, "PromiseTypes.mts");
const sourceFile = getTS_SourceFile(startDir, "PromiseTypes.ts");
expect(
() => sourceFile.getFunctionOrThrow("PromiseAllParallel")
).not.toThrow();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import StateMachine_DFA from "../../source/stateMachines/dfa-states.mjs";
import StateMachine_DFA from "../../source/stateMachines/dfa-states.js";

describe("StateMachine_DFA", () => {
type State = "one" | "two" | "three";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"spec_files": [
"./spec/**/*.mts",
"./spec/**/*.ts"
],
"stopSpecOnExpectationFailure": false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import {

import {
createSourceFileFromStructure,
} from "#stage_utilities/source/getTS_SourceFile.mjs";
} from "#stage_utilities/source/getTS_SourceFile.js";

import {
stageDir
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {

import {
createSourceFileFromStructure,
} from "#stage_utilities/source/getTS_SourceFile.mjs";
} from "#stage_utilities/source/getTS_SourceFile.js";

import {
stageDir
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {

import {
createSourceFileFromStructure,
} from "#stage_utilities/source/getTS_SourceFile.mjs";
} from "#stage_utilities/source/getTS_SourceFile.js";

import {
stageDir
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {

import {
createSourceFileFromStructure,
} from "#stage_utilities/source/getTS_SourceFile.mjs";
} from "#stage_utilities/source/getTS_SourceFile.js";

import {
stageDir
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {

import getTS_SourceFile, {
addSeveralSourceFiles
} from "#stage_utilities/source/getTS_SourceFile.mjs";
} from "#stage_utilities/source/getTS_SourceFile.js";

import {
InterfaceDeclarationImpl,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import {

import {
monorepoDir
} from "#stage_utilities/source/AsyncSpecModules.mjs";
} from "#stage_utilities/source/AsyncSpecModules.js";

import {
addSeveralSourceFiles
} from "#stage_utilities/source/getTS_SourceFile.mjs";
} from "#stage_utilities/source/getTS_SourceFile.js";

import {
InterfaceDeclarationImpl,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {

import {
createSourceFileFromStructure,
} from "#stage_utilities/source/getTS_SourceFile.mjs";
} from "#stage_utilities/source/getTS_SourceFile.js";

import {
stageDir
Expand Down
Loading

0 comments on commit 19eda82

Please sign in to comment.