Skip to content

Commit

Permalink
fix(core): Use Symbol.for to instantiate shared symbols (#3087)
Browse files Browse the repository at this point in the history
  • Loading branch information
daffl committed Mar 8, 2023
1 parent a5eb1d5 commit 7f3fc21
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/adapter-commons/src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from './declarations'
import { filterQuery } from './query'

export const VALIDATED = Symbol('@feathersjs/adapter/sanitized')
export const VALIDATED = Symbol.for('@feathersjs/adapter/sanitized')

const alwaysMulti: { [key: string]: boolean } = {
find: true,
Expand Down
2 changes: 1 addition & 1 deletion packages/commons/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export function isPromise(result: any) {
}

export function createSymbol(name: string) {
return typeof Symbol !== 'undefined' ? Symbol(name) : name
return typeof Symbol !== 'undefined' ? Symbol.for(name) : name
}

export * from './debug'
2 changes: 1 addition & 1 deletion packages/knex/src/error-handler.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { errors } from '@feathersjs/errors'

export const ERROR = Symbol('@feathersjs/knex/error')
export const ERROR = Symbol.for('@feathersjs/knex/error')

export function errorHandler(error: any) {
const { message } = error
Expand Down
2 changes: 1 addition & 1 deletion packages/schema/src/hooks/resolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export const resolveResult = <H extends HookContext>(...resolvers: Resolver<any,
}
}

export const DISPATCH = Symbol('@feathersjs/schema/dispatch')
export const DISPATCH = Symbol.for('@feathersjs/schema/dispatch')

export const getDispatchValue = (value: any): any => {
if (typeof value === 'object' && value !== null) {
Expand Down
2 changes: 1 addition & 1 deletion packages/schema/src/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export type VirtualResolver<T, V, C> = (
status: ResolverStatus<T, C>
) => Promise<V | undefined>

export const IS_VIRTUAL = Symbol('@feathersjs/schema/virtual')
export const IS_VIRTUAL = Symbol.for('@feathersjs/schema/virtual')

/**
* Create a resolver for a virtual property. A virtual property is a property that
Expand Down
6 changes: 3 additions & 3 deletions packages/transport-commons/src/channels/mixins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { Channel } from './channel/base'
import { CombinedChannel } from './channel/combined'

const debug = createDebug('@feathersjs/transport-commons/channels/mixins')
const PUBLISHERS = Symbol('@feathersjs/transport-commons/publishers')
const CHANNELS = Symbol('@feathersjs/transport-commons/channels')
const ALL_EVENTS = Symbol('@feathersjs/transport-commons/all-events')
const PUBLISHERS = Symbol.for('@feathersjs/transport-commons/publishers')
const CHANNELS = Symbol.for('@feathersjs/transport-commons/channels')
const ALL_EVENTS = Symbol.for('@feathersjs/transport-commons/all-events')

export const keys = {
PUBLISHERS: PUBLISHERS as typeof PUBLISHERS,
Expand Down

0 comments on commit 7f3fc21

Please sign in to comment.