From 1ddc51a5049b9f0dd43a3f27e8a744ad8b3c808d Mon Sep 17 00:00:00 2001 From: "Mark S. Miller" Date: Sun, 14 Jan 2024 16:59:51 -0800 Subject: [PATCH] refactor(exo): "live" qualifier no longer needed --- packages/exo/src/exo-makers.js | 26 +++++++------- ...js => test-is-instance-heap-class-kits.js} | 34 +++++++++---------- 2 files changed, 30 insertions(+), 30 deletions(-) rename packages/exo/test/{test-live-instance-heap-class-kits.js => test-is-instance-heap-class-kits.js} (70%) diff --git a/packages/exo/src/exo-makers.js b/packages/exo/src/exo-makers.js index 837de20e32..54b1904376 100644 --- a/packages/exo/src/exo-makers.js +++ b/packages/exo/src/exo-makers.js @@ -88,7 +88,7 @@ export const initEmpty = () => emptyRecord; */ /** - * The power to amplify a live facet instance of the associated exo class kit + * The power to amplify a facet instance of the associated exo class kit * into the record of all facets of this facet instance's cohort. * * @template {any} [F=any] @@ -98,13 +98,13 @@ export const initEmpty = () => emptyRecord; */ /** - * The power to test if a value is a live instance of the - * associated exo class, or a live facet instance of the + * The power to test if a value is an instance of the + * associated exo class, or a facet instance of the * associated exo class kit. In the later case, if a `facetName` is provided, * then it tests only whether the argument is a facet instance of that * facet of the associated exo class kit. * - * @callback IsLiveInstance + * @callback IsInstance * @param {any} exo * @param {string} [facetName] * @returns {boolean} @@ -142,14 +142,14 @@ export const initEmpty = () => emptyRecord; * definition of the exo class kit with an `Amplify` function. If called * during the definition of a normal exo or exo class, it will throw, since * only exo kits can be amplified. - * An `Amplify` function is a function that takes a live facet instance of + * An `Amplify` function is a function that takes a facet instance of * this class kit as an argument, in which case it will return the facets * record, giving access to all the facet instances of the same cohort. * - * @property {ReceivePower} [receiveInstanceTester] + * @property {ReceivePower} [receiveInstanceTester] * If a `receiveInstanceTester` function is provided, it will be called * during the definition of the exo class or exo class kit with an - * `IsLiveInstance` function. The first argument of `IsLiveInstance` + * `IsInstance` function. The first argument of `IsInstance` * is the value to be tested. When it may be a facet instance of an * exo class kit, the optional second argument, if provided, is * a `facetName`. In that case, the function tests only if the first @@ -229,15 +229,15 @@ export const defineExoClass = ( }; if (receiveInstanceTester) { - const isLiveInstance = (exo, facetName = undefined) => { + const isInstance = (exo, facetName = undefined) => { facetName === undefined || Fail`facetName can only be used with an exo class kit: ${q( tag, )} has no facet ${q(facetName)}`; return contextMap.has(exo); }; - harden(isLiveInstance); - receiveInstanceTester(isLiveInstance); + harden(isInstance); + receiveInstanceTester(isInstance); } return harden(makeInstance); @@ -324,7 +324,7 @@ export const defineExoClassKit = ( } if (receiveInstanceTester) { - const isLiveInstance = (exoFacet, facetName = undefined) => { + const isInstance = (exoFacet, facetName = undefined) => { if (facetName === undefined) { return values(contextMapKit).some(contextMap => contextMap.has(exoFacet), @@ -336,8 +336,8 @@ export const defineExoClassKit = ( Fail`exo class kit ${q(tag)} has no facet named ${q(facetName)}`; return contextMap.has(exoFacet); }; - harden(isLiveInstance); - receiveInstanceTester(isLiveInstance); + harden(isInstance); + receiveInstanceTester(isInstance); } return harden(makeInstanceKit); diff --git a/packages/exo/test/test-live-instance-heap-class-kits.js b/packages/exo/test/test-is-instance-heap-class-kits.js similarity index 70% rename from packages/exo/test/test-live-instance-heap-class-kits.js rename to packages/exo/test/test-is-instance-heap-class-kits.js index 0ec0db3b80..2274ac43c4 100644 --- a/packages/exo/test/test-live-instance-heap-class-kits.js +++ b/packages/exo/test/test-is-instance-heap-class-kits.js @@ -15,8 +15,8 @@ const DownCounterI = M.interface('DownCounter', { decr: M.call().optional(M.gte(0)).returns(M.number()), }); -test('test isLiveInstance defineExoClass', t => { - let isLiveInstance; +test('test isInstance defineExoClass', t => { + let isInstance; const makeUpCounter = defineExoClass( 'UpCounter', UpCounterI, @@ -31,27 +31,27 @@ test('test isLiveInstance defineExoClass', t => { }, { receiveInstanceTester(i) { - isLiveInstance = i; + isInstance = i; }, }, ); - t.is(isLiveInstance(harden({})), false); - t.throws(() => isLiveInstance(harden({}), 'up'), { + t.is(isInstance(harden({})), false); + t.throws(() => isInstance(harden({}), 'up'), { message: 'facetName can only be used with an exo class kit: "UpCounter" has no facet "up"', }); const upCounter = makeUpCounter(3); - t.is(isLiveInstance(upCounter), true); - t.throws(() => isLiveInstance(upCounter, 'up'), { + t.is(isInstance(upCounter), true); + t.throws(() => isInstance(upCounter, 'up'), { message: 'facetName can only be used with an exo class kit: "UpCounter" has no facet "up"', }); }); -test('test isLiveInstance defineExoClassKit', t => { - let isLiveInstance; +test('test isInstance defineExoClassKit', t => { + let isInstance; const makeCounterKit = defineExoClassKit( 'Counter', { up: UpCounterI, down: DownCounterI }, @@ -75,23 +75,23 @@ test('test isLiveInstance defineExoClassKit', t => { }, { receiveInstanceTester(i) { - isLiveInstance = i; + isInstance = i; }, }, ); - t.is(isLiveInstance(harden({})), false); - t.is(isLiveInstance(harden({}), 'up'), false); - t.throws(() => isLiveInstance(harden({}), 'foo'), { + t.is(isInstance(harden({})), false); + t.is(isInstance(harden({}), 'up'), false); + t.throws(() => isInstance(harden({}), 'foo'), { message: 'exo class kit "Counter" has no facet named "foo"', }); const { up: upCounter } = makeCounterKit(3); - t.is(isLiveInstance(upCounter), true); - t.is(isLiveInstance(upCounter, 'up'), true); - t.is(isLiveInstance(upCounter, 'down'), false); - t.throws(() => isLiveInstance(upCounter, 'foo'), { + t.is(isInstance(upCounter), true); + t.is(isInstance(upCounter, 'up'), true); + t.is(isInstance(upCounter, 'down'), false); + t.throws(() => isInstance(upCounter, 'foo'), { message: 'exo class kit "Counter" has no facet named "foo"', }); });