Skip to content

Commit

Permalink
fix: use strings instead of symbols as keys
Browse files Browse the repository at this point in the history
  • Loading branch information
brillout committed Oct 22, 2022
1 parent 3f50fbf commit bdbd31e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion telefunc/node/server/Abort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export { Abort }
export { isAbort }

import { assert, assertUsage, objectAssign } from '../utils'
const stamp = Symbol('isAbort')
const stamp = '__telefunc_isAbort'

function isAbort(thing: unknown): thing is ReturnType<typeof Abort> {
assert(thing !== Abort) // Catched earlier in `executeTelefunction()`
Expand Down
16 changes: 8 additions & 8 deletions telefunc/node/server/shield.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ export { shieldToHumandReadable }

import { isPlainObject, unique, isCallable, assert, assertUsage } from '../utils'

const shielKey = Symbol('shielKey')
const isVerifierKey = Symbol('isVerifierKey')
const isVerifierTupleKey = Symbol('isVerifierTupleKey')
const shieldKey = '__telefunc_shield'
const isVerifierKey = '__telefunc_isVerifier'
const isVerifierTupleKey = '__telefunc_isVerifierTuple'

type ShieldOptions = { __autoGenerated ?: boolean }
type ShieldOptions = { __autoGenerated?: boolean }

const shield: {
<
Expand Down Expand Up @@ -71,12 +71,12 @@ function isTelefunction(thing: unknown): thing is Telefunction {
}

function installShield(telefunction: Function, telefunctionShield: any, generated: boolean) {
const installedShield = (telefunction as any as Record<any, unknown>)[shielKey as any]
const installedShield = (telefunction as any as Record<any, unknown>)[shieldKey as any]
if (installedShield && generated) {
// another shield is already installed, so not installing generated shield
return;
return
}
;(telefunction as any as Record<any, unknown>)[shielKey as any] = telefunctionShield
;(telefunction as any as Record<any, unknown>)[shieldKey as any] = telefunctionShield
}

function shieldIsMissing(telefunction: Telefunction): boolean {
Expand All @@ -92,7 +92,7 @@ function shieldApply(telefunction: Telefunction, args: unknown[]): true | string

type TelefunctionShield = unknown[] | Verifier
function getTelefunctionShield(telefunction: Telefunction): TelefunctionShield | null {
return (telefunction as any)[shielKey] || null
return (telefunction as any)[shieldKey] || null
}

function shieldToHumandReadable(telefunctionShield: TelefunctionShield): string {
Expand Down

0 comments on commit bdbd31e

Please sign in to comment.