Permalink
May 4, 2020 18:50
Newer
100644
40 lines (31 sloc)
906 Bytes
Ignoring revisions in .git-blame-ignore-revs.
1
'use strict'
2
3
const constants = require('../constants')
4
const formatUtils = require('../formatUtils')
5
const lineBuilder = require('../lineBuilder')
6
7
const DEEP_EQUAL = constants.DEEP_EQUAL
8
const UNEQUAL = constants.UNEQUAL
9
10
function describe (value) {
11
return new BigIntValue(value)
12
}
13
exports.describe = describe
14
15
exports.deserialize = describe
16
17
const tag = Symbol('BigIntValue')
18
exports.tag = tag
19
20
class BigIntValue {
21
constructor (value) {
22
this.value = value
23
}
24
25
compare (expected) {
26
return expected.tag === tag && Object.is(this.value, expected.value)
27
? DEEP_EQUAL
28
: UNEQUAL
29
}
30
31
formatDeep (theme) {
32
return lineBuilder.single(formatUtils.wrap(theme.bigInt, `${this.value}n`))
33
}
34
35
serialize () {
36
return this.value
37
}
38
}
39
Object.defineProperty(BigIntValue.prototype, 'isPrimitive', { value: true })
40
Object.defineProperty(BigIntValue.prototype, 'tag', { value: tag })