Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BigInt support #138

Merged
merged 1 commit into from May 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/build.js
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
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
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