Skip to content

Commit

Permalink
Removes class. Amends default export
Browse files Browse the repository at this point in the history
  • Loading branch information
modernpoacherlimited committed May 31, 2023
1 parent 0d39433 commit d79756b
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 88 deletions.
94 changes: 10 additions & 84 deletions src/pantograph/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,68 +8,24 @@ import {
Signals
} from 'shinkansen-signals'

const log = debug('shinkansen-pantograph/pantograph')

const ALPHA = {
ERROR: 'ALPHA_ERROR',
ROUTE: 'ALPHA_ROUTE',
MOUNT: 'ALPHA_MOUNT',
FETCH: 'ALPHA_FETCH',
STORE: 'ALPHA_STORE',
QUERY: 'ALPHA_QUERY',
CHANGE: 'ALPHA_CHANGE',
SUBMIT: 'ALPHA_SUBMIT'
}

const OMEGA = {
ERROR: 'OMEGA_ERROR',
ROUTE: 'OMEGA_ROUTE',
MOUNT: 'OMEGA_MOUNT',
FETCH: 'OMEGA_FETCH',
STORE: 'OMEGA_STORE',
QUERY: 'OMEGA_QUERY',
CHANGE: 'OMEGA_CHANGE',
SUBMIT: 'OMEGA_SUBMIT'
}

const EMBARK = {
ERROR: 'EMBARK_ERROR',
ROUTE: 'EMBARK_ROUTE',
MOUNT: 'EMBARK_MOUNT',
FETCH: 'EMBARK_FETCH',
STORE: 'EMBARK_STORE',
CHANGE: 'EMBARK_CHANGE',
SUBMIT: 'EMBARK_SUBMIT'
}
import pantograph, {
ALPHA,
OMEGA,
EMBARK,
DEBARK,
CONFIRM
} from './pantograph.mjs'

const DEBARK = {
ERROR: 'DEBARK_ERROR',
ROUTE: 'DEBARK_ROUTE',
MOUNT: 'DEBARK_MOUNT',
FETCH: 'DEBARK_FETCH',
STORE: 'DEBARK_STORE',
CHANGE: 'DEBARK_CHANGE',
SUBMIT: 'DEBARK_SUBMIT'
}
const log = debug('shinkansen-pantograph/pantograph')

const CONFIRM = {
ERROR: 'CONFIRM_ERROR',
ROUTE: 'CONFIRM_ROUTE',
MOUNT: 'CONFIRM_MOUNT',
FETCH: 'CONFIRM_FETCH',
STORE: 'CONFIRM_STORE',
CHANGE: 'CONFIRM_CHANGE',
SUBMIT: 'CONFIRM_SUBMIT'
}
log('`shinkansen` is awake')

const ACTION = {}

const STATE = {}

const ROUTE = {}

log('`shinkansen` is awake')

export function getRedirectToAlpha ({ alpha, route }) {
log('getRedirectToAlpha')

Expand Down Expand Up @@ -197,34 +153,4 @@ export function graphite ({ action: { type } = ACTION, state = STATE, route = RO
}
}

/**
* Getters without setters ensure that these fields are read-only
*/
class Pantograph {
static get ALPHA () {
return ALPHA
}

static get OMEGA () {
return OMEGA
}

static get EMBARK () {
return EMBARK
}

static get DEBARK () {
return DEBARK
}

static get CONFIRM () {
return CONFIRM
}

static graphite = graphite
}

/**
* As does `freeze`
*/
export default Object.freeze(Pantograph)
export default Object.freeze(pantograph)
65 changes: 65 additions & 0 deletions src/pantograph/pantograph.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import debug from 'debug'

const log = debug('shinkansen-pantograph/pantograph')

log('`shinkansen` is awake')

export const ALPHA = {
ERROR: 'ALPHA_ERROR',
ROUTE: 'ALPHA_ROUTE',
MOUNT: 'ALPHA_MOUNT',
FETCH: 'ALPHA_FETCH',
STORE: 'ALPHA_STORE',
QUERY: 'ALPHA_QUERY',
CHANGE: 'ALPHA_CHANGE',
SUBMIT: 'ALPHA_SUBMIT'
}

export const OMEGA = {
ERROR: 'OMEGA_ERROR',
ROUTE: 'OMEGA_ROUTE',
MOUNT: 'OMEGA_MOUNT',
FETCH: 'OMEGA_FETCH',
STORE: 'OMEGA_STORE',
QUERY: 'OMEGA_QUERY',
CHANGE: 'OMEGA_CHANGE',
SUBMIT: 'OMEGA_SUBMIT'
}

export const EMBARK = {
ERROR: 'EMBARK_ERROR',
ROUTE: 'EMBARK_ROUTE',
MOUNT: 'EMBARK_MOUNT',
FETCH: 'EMBARK_FETCH',
STORE: 'EMBARK_STORE',
CHANGE: 'EMBARK_CHANGE',
SUBMIT: 'EMBARK_SUBMIT'
}

export const DEBARK = {
ERROR: 'DEBARK_ERROR',
ROUTE: 'DEBARK_ROUTE',
MOUNT: 'DEBARK_MOUNT',
FETCH: 'DEBARK_FETCH',
STORE: 'DEBARK_STORE',
CHANGE: 'DEBARK_CHANGE',
SUBMIT: 'DEBARK_SUBMIT'
}

export const CONFIRM = {
ERROR: 'CONFIRM_ERROR',
ROUTE: 'CONFIRM_ROUTE',
MOUNT: 'CONFIRM_MOUNT',
FETCH: 'CONFIRM_FETCH',
STORE: 'CONFIRM_STORE',
CHANGE: 'CONFIRM_CHANGE',
SUBMIT: 'CONFIRM_SUBMIT'
}

export default {
ALPHA,
OMEGA,
EMBARK,
DEBARK,
CONFIRM
}
8 changes: 4 additions & 4 deletions test/pantograph/index.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ import Pantograph, {
chai.use(sinonChai)

describe('shinkansen-pantograph/pantograph', () => {
it('is a function', () => {
it('is an object', () => {
return expect(Pantograph)
.to.be.a('function')
.to.be.an('object')
})

describe('`Pantograph.ALPHA`', () => {
Expand Down Expand Up @@ -512,9 +512,9 @@ describe('shinkansen-pantograph/pantograph', () => {
})
})

describe('`Pantograph.graphite`', () => {
describe('`graphite`', () => {
it('is a function', () => {
return expect(Pantograph.graphite)
return expect(graphite)
.to.be.a('function')
})
})
Expand Down

0 comments on commit d79756b

Please sign in to comment.