mirror of
https://github.com/tribufu/node-gamedig
synced 2026-06-01 09:42:41 +00:00
feat: export games and protocols besides GameDig (#411)
* feat: export games and protocols besides GameDig * fix: revert ProtocolResolver rename * fix: imports on the attempt tools * docs: update changelog to note exports
This commit is contained in:
parent
f472d8b0e4
commit
8192ed07e0
6 changed files with 34 additions and 28 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import * as Protocols from '../protocols/index.js'
|
||||
import * as protocols from '../protocols/index.js'
|
||||
|
||||
export const getProtocol = (protocolId) => {
|
||||
if (!(protocolId in Protocols)) { throw Error('Protocol definition file missing: ' + protocolId) }
|
||||
if (!(protocolId in protocols)) { throw Error('Protocol definition file missing: ' + protocolId) }
|
||||
|
||||
return new Protocols[protocolId]()
|
||||
return new protocols[protocolId]()
|
||||
}
|
||||
|
|
|
|||
23
lib/gamedig.js
Normal file
23
lib/gamedig.js
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import QueryRunner from './QueryRunner.js'
|
||||
|
||||
let singleton = null
|
||||
|
||||
export class GameDig {
|
||||
constructor (runnerOpts) {
|
||||
this.queryRunner = new QueryRunner(runnerOpts)
|
||||
}
|
||||
|
||||
async query (userOptions) {
|
||||
return await this.queryRunner.run(userOptions)
|
||||
}
|
||||
|
||||
static getInstance () {
|
||||
if (!singleton) { singleton = new GameDig() }
|
||||
|
||||
return singleton
|
||||
}
|
||||
|
||||
static async query (...args) {
|
||||
return await GameDig.getInstance().query(...args)
|
||||
}
|
||||
}
|
||||
26
lib/index.js
26
lib/index.js
|
|
@ -1,23 +1,5 @@
|
|||
import QueryRunner from './QueryRunner.js'
|
||||
import { GameDig } from './gamedig.js'
|
||||
import { games } from './games.js'
|
||||
import * as protocols from '../protocols/index.js'
|
||||
|
||||
let singleton = null
|
||||
|
||||
export default class Gamedig {
|
||||
constructor (runnerOpts) {
|
||||
this.queryRunner = new QueryRunner(runnerOpts)
|
||||
}
|
||||
|
||||
async query (userOptions) {
|
||||
return await this.queryRunner.run(userOptions)
|
||||
}
|
||||
|
||||
static getInstance () {
|
||||
if (!singleton) { singleton = new Gamedig() }
|
||||
|
||||
return singleton
|
||||
}
|
||||
|
||||
static async query (...args) {
|
||||
return await Gamedig.getInstance().query(...args)
|
||||
}
|
||||
}
|
||||
export { GameDig, games, protocols }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue