Skip to content

Commit

Permalink
chore: address feedback
Browse files Browse the repository at this point in the history
fixup! fix(marshal): remove ambient types, but still use JSDoc
  • Loading branch information
mhofman committed Feb 2, 2022
1 parent 409cd6c commit c5f2ef7
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 21 deletions.
8 changes: 2 additions & 6 deletions packages/marshal/src/helpers/copyArray.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

/// <reference types="ses"/>

import {
assertChecker,
checkNormalProperty,
conditionChecker,
} from './passStyle-helpers.js';
import { assertChecker, checkNormalProperty } from './passStyle-helpers.js';

const { details: X } = assert;
const { getPrototypeOf } = Object;
Expand All @@ -20,7 +16,7 @@ const { isArray, prototype: arrayPrototype } = Array;
export const CopyArrayHelper = harden({
styleName: 'copyArray',

canBeValid: (candidate, check = conditionChecker) =>
canBeValid: (candidate, check = v => v) =>
check(isArray(candidate), X`Array expected: ${candidate}`),

assertValid: (candidate, passStyleOfRecur) => {
Expand Down
3 changes: 1 addition & 2 deletions packages/marshal/src/helpers/copyRecord.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
assertChecker,
canBeMethod,
checkNormalProperty,
conditionChecker,
} from './passStyle-helpers.js';

const { details: X } = assert;
Expand All @@ -24,7 +23,7 @@ const {
export const CopyRecordHelper = harden({
styleName: 'copyRecord',

canBeValid: (candidate, check = conditionChecker) => {
canBeValid: (candidate, check = v => v) => {
const proto = getPrototypeOf(candidate);
if (proto !== objectPrototype && proto !== null) {
return check(false, X`Unexpected prototype for: ${candidate}`);
Expand Down
4 changes: 2 additions & 2 deletions packages/marshal/src/helpers/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/// <reference types="ses"/>

import { assertChecker, conditionChecker } from './passStyle-helpers.js';
import { assertChecker } from './passStyle-helpers.js';

/** @typedef {import('./internal-types.js').PassStyleHelper} PassStyleHelper */

Expand Down Expand Up @@ -46,7 +46,7 @@ harden(getErrorConstructor);
export const ErrorHelper = harden({
styleName: 'error',

canBeValid: (candidate, check = conditionChecker) => {
canBeValid: (candidate, check = v => v) => {
// TODO: Need a better test than instanceof
if (!(candidate instanceof Error)) {
return check(false, X`Error expected: ${candidate}`);
Expand Down
4 changes: 0 additions & 4 deletions packages/marshal/src/helpers/passStyle-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ const {
const { apply } = Reflect;
const { isArray } = Array;

/** @type {Checker} */
export const conditionChecker = (cond, _details = undefined) => cond;
harden(conditionChecker);

export const hasOwnPropertyOf = (obj, prop) =>
apply(objectHasOwnProperty, obj, [prop]);
harden(hasOwnPropertyOf);
Expand Down
9 changes: 4 additions & 5 deletions packages/marshal/src/helpers/remotable.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import {
assertChecker,
conditionChecker,
canBeMethod,
hasOwnPropertyOf,
PASS_STYLE,
Expand Down Expand Up @@ -45,7 +44,7 @@ export const ALLOW_IMPLICIT_REMOTABLES =
* @param {InterfaceSpec} iface
* @param {Checker=} check
*/
const checkIface = (iface, check = conditionChecker) => {
const checkIface = (iface, check = v => v) => {
return (
// TODO other possible ifaces, once we have third party veracity
check(
Expand All @@ -72,7 +71,7 @@ harden(assertIface);
* @param {Checker} [check]
* @returns {boolean}
*/
const checkRemotableProtoOf = (original, check = conditionChecker) => {
const checkRemotableProtoOf = (original, check = v => v) => {
/**
* TODO: It would be nice to typedef this shape, but we can't declare a type
* with PASS_STYLE from JSDoc.
Expand Down Expand Up @@ -144,7 +143,7 @@ const checkRemotableProtoOf = (original, check = conditionChecker) => {
* @param {Checker} [check]
* @returns {boolean}
*/
const checkRemotable = (val, check = conditionChecker) => {
const checkRemotable = (val, check = v => v) => {
const not = (cond, details) => !check(cond, details);
if (not(isFrozen(val), X`cannot serialize non-frozen objects like ${val}`)) {
return false;
Expand Down Expand Up @@ -189,7 +188,7 @@ harden(getInterfaceOf);
export const RemotableHelper = harden({
styleName: 'remotable',

canBeValid: (candidate, check = conditionChecker) => {
canBeValid: (candidate, check = v => v) => {
if (
!(
check(
Expand Down
3 changes: 1 addition & 2 deletions packages/marshal/src/helpers/tagged.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
checkTagRecord,
PASS_STYLE,
checkNormalProperty,
conditionChecker,
} from './passStyle-helpers.js';

const { details: X } = assert;
Expand All @@ -21,7 +20,7 @@ const { getPrototypeOf, prototype: objectPrototype } = Object;
export const TaggedHelper = harden({
styleName: 'tagged',

canBeValid: (candidate, check = conditionChecker) =>
canBeValid: (candidate, check = v => v) =>
checkTagRecord(candidate, 'tagged', check),

assertValid: (candidate, passStyleOfRecur) => {
Expand Down

0 comments on commit c5f2ef7

Please sign in to comment.