Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7e23ae8

Browse files
authored
Fix serialization issue for 0n. (#156)
Fix#125Fix#154
1 parent343abd9 commit7e23ae8

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

‎index.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ module.exports = function serialize(obj, options) {
8383
deleteFunctions(value);
8484
}
8585

86-
if(!value&&value!==undefined){
86+
if(!value&&value!==undefined&&value!==BigInt(0)){
8787
returnvalue;
8888
}
8989

‎test/unit/serialize.js‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,12 @@ describe('serialize( obj )', function () {
441441
expect(serialize({t:[b]})).to.be.a('string').equal('{"t":[BigInt("9999")]}');
442442
});
443443

444+
it('should serialize 0n',function(){
445+
varb=BigInt(0);
446+
expect(serialize(b)).to.equal('BigInt("0")');
447+
expect(serialize({t:[b]})).to.be.a('string').equal('{"t":[BigInt("0")]}');
448+
});
449+
444450
it('should deserialize BigInt',function(){
445451
vard=eval(serialize(BigInt(9999)));
446452
expect(d).to.be.a('BigInt');

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp