fix(List): toString is different from toJSON
This commit is contained in:
@ -120,13 +120,17 @@ export class SequenceContainer {
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
return this.toString()
|
||||
let res = []
|
||||
for (const value of this) {
|
||||
res.push(JSON.stringify(value))
|
||||
}
|
||||
return '[ ' + res.join(', ') + ' ]'
|
||||
}
|
||||
|
||||
toString() {
|
||||
let res = []
|
||||
for (const value of this) {
|
||||
res.push(JSON.stringify(value))
|
||||
res.push(value.toString())
|
||||
}
|
||||
return '[ ' + res.join(', ') + ' ]'
|
||||
}
|
||||
|
||||
@ -134,4 +134,5 @@ test('pushBack, pushFront, popBack, popFront, back, front', () => {
|
||||
|
||||
test('toJSON, toString', () => {
|
||||
expect(List.from([1, 2]).toJSON()).toEqual('[ 1, 2 ]')
|
||||
expect(List.from([0n]).toString()).toEqual('[ 0 ]')
|
||||
})
|
||||
Reference in New Issue
Block a user