Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extract symbols #208

Merged
merged 2 commits into from
Jun 25, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ const {
AVV_ERR_ROOT_PLG_BOOTED,
AVV_ERR_READY_TIMEOUT
} = require('./lib/errors')
const {
kAvvio,
kThenifyDoNotWrap
} = require('./lib/symbols')
const TimeTree = require('./time-tree')
const Plugin = require('./plugin')
const debug = require('debug')('avvio')
const kAvvio = Symbol('kAvvio')
const kThenifyDoNotWrap = Symbol('kThenifyDoNotWrap')

function wrap (server, opts, instance) {
const expose = opts.expose || {}
Expand Down
24 changes: 24 additions & 0 deletions lib/symbols.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
'use strict'

// Internal Symbols
const kAvvio = Symbol('avvio.Boot')
const kThenifyDoNotWrap = Symbol('avvio.ThenifyDoNotWrap')
const kUntrackNode = Symbol('avvio.TimeTree.untrackNode')
const kTrackNode = Symbol('avvio.TimeTree.trackNode')
const kGetParent = Symbol('avvio.TimeTree.getParent')
const kGetNode = Symbol('avvio.TimeTree.getNode')
const kAddNode = Symbol('avvio.TimeTree.addNode')

// Public Symbols
const kPluginMeta = Symbol.for('plugin-meta')

module.exports = {
kAvvio,
kThenifyDoNotWrap,
kUntrackNode,
kTrackNode,
kGetParent,
kGetNode,
kAddNode,
kPluginMeta
}
4 changes: 1 addition & 3 deletions plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ const EE = require('events').EventEmitter
const inherits = require('util').inherits
const debug = require('debug')('avvio')
const { AVV_ERR_READY_TIMEOUT } = require('./lib/errors')

// this symbol is assigned by fastify-plugin
const kPluginMeta = Symbol.for('plugin-meta')
const { kPluginMeta } = require('./lib/symbols')

function getName (func, optsOrFunc) {
// use explicit function metadata if set
Expand Down
13 changes: 7 additions & 6 deletions time-tree.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
'use strict'

const archy = require('archy')

const kUntrackNode = Symbol('avvio.TimeTree.untrackNode')
const kTrackNode = Symbol('avvio.TimeTree.trackNode')
const kGetParent = Symbol('avvio.TimeTree.getParent')
const kGetNode = Symbol('avvio.TimeTree.getNode')
const kAddNode = Symbol('avvio.TimeTree.addNode')
const {
kUntrackNode,
kTrackNode,
kGetParent,
kGetNode,
kAddNode
} = require('./lib/symbols')

class TimeTree {
constructor () {
Expand Down