Skip to content

Commit

Permalink
Merge pull request #138 from dnicolson/add-bigint-support
Browse files Browse the repository at this point in the history
Add BigInt support
  • Loading branch information
mreinstein authored May 30, 2023
2 parents 89a74fc + 80d65bc commit 7271d59
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ function walk_obj(next, next_child) {
tag_type = (next % 1 === 0) ? 'integer' : 'real';
next_child.ele(tag_type).txt(next.toString());

} else if ('BigInt' == name) {
next_child.ele('integer').txt(next);

} else if ('Date' == name) {
next_child.ele('date').txt(ISODateString(new Date(next)));

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@
"test": "make test"
},
"engines": {
"node": ">=6"
"node": ">=10.4.0"
}
}
11 changes: 11 additions & 0 deletions test/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ describe('plist', function () {
*/}));
});

it('should create a plist XML real from a BigInt', function () {
var xml = build(BigInt('0x1fffffffffffff'));
assert.strictEqual(xml, multiline(function () {/*
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<integer>9007199254740991</integer>
</plist>
*/}));
});

it('should create a plist XML date from a Date', function () {
var xml = build(new Date('2010-02-08T21:41:23Z'));
assert.strictEqual(xml, multiline(function () {/*
Expand Down

0 comments on commit 7271d59

Please sign in to comment.