UNPKG

647 BJavaScriptView Raw
1'use strict'
2
3const la = require('lazy-ass')
4const is = require('check-more-types')
5
6function 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// make sure values in the object are "safe" to be serialized
18// and compared from loaded value
19function strip (o) {
20 la(!is.fn(o), 'cannot clean up functions!', o.name)
21 return JSON.parse(JSON.stringify(o))
22}
23
24module.exports = {
25 snapshotIndex,
26 strip
27}