1 | 'use strict'
|
2 |
|
3 | const la = require('lazy-ass')
|
4 | const is = require('check-more-types')
|
5 |
|
6 | function snapshotIndex ({counters, specName}) {
|
7 | la(is.object(counters), 'expected counters', counters)
|
8 | la(is.unemptyString(specName), 'expected specName', specName)
|
9 | if (!(specName in counters)) {
|
10 | counters[specName] = 1
|
11 | } else {
|
12 | counters[specName] += 1
|
13 | }
|
14 | return counters[specName]
|
15 | }
|
16 |
|
17 |
|
18 |
|
19 | function strip (o) {
|
20 | la(!is.fn(o), 'cannot clean up functions!', o.name)
|
21 | return JSON.parse(JSON.stringify(o))
|
22 | }
|
23 |
|
24 | module.exports = {
|
25 | snapshotIndex,
|
26 | strip
|
27 | }
|