Skip to content

Commit

Permalink
add method to reset sequences
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanstitt committed Mar 16, 2021
1 parent 943f039 commit 4dc5862
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/factory.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IDENTIFIER as sequence } from './sequences'
import { IDENTIFIER as sequence, Sequences } from './sequences'
import { Reference, ReferenceOptions } from './reference'
import { getFactory } from './factories'
import { propertyFactory } from './property-factory'
Expand All @@ -10,6 +10,10 @@ const Factory: FactoryI = {

sequence,

resetSequences(): void {
Sequences.clear()
},

reference(name: string, options: ReferenceOptions = {}): Reference {
return new Reference(name, options)
},
Expand Down
4 changes: 4 additions & 0 deletions src/sequences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ export const IDENTIFIER = Symbol('sequence')

export const Sequences = {

clear() {
SEQUENCES.clear()
},

get map(): Map<string, Record<string, number>> {
return SEQUENCES
},
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { IDENTIFIER } from './sequences'
export interface Factory {
defaults?: Record<string, any>,
sequence: typeof IDENTIFIER,
resetSequences(): void,
reference(name: string, options?: ReferenceOptions): Reference,
define(name: string): any,
create(name: string, values?: Record<string, any>): Record<string, any>,
Expand Down

0 comments on commit 4dc5862

Please sign in to comment.