Skip to content

Commit

Permalink
Properly handle strings and numbers in array mode
Browse files Browse the repository at this point in the history
  • Loading branch information
kriszyp committed Jun 11, 2020
1 parent ce451c2 commit d53ffed
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/serialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,10 @@ function createSerializer(options) {
property = arrayProperty // restore current property
} else if (typeof array == 'object' && array[iteratorSymbol]) {
return writeAsIterable(array)
} else if (type === 'string') {
return writeInlineString(value)
} else if (type === 'number' && (value >>> 0 === value || (value > 0 && value < 0x400000000000 && value % 1 === 0))) {
return writeToken(NUMBER_CODE, value)
} else { // bail to default mode behavior
writeTypedValue(array)
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "dpack",
"author": "Kris Zyp",
"version": "0.6.21",
"version": "0.6.22",
"description": "Efficient, compact binary format for serializing data structures with extensible typing",
"license": "MIT",
"repository": {
Expand Down

0 comments on commit d53ffed

Please sign in to comment.