Skip to content

Commit

Permalink
fixed number determination. Now uses BigNumber to determine NnN
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffWScott committed Sep 15, 2020
1 parent a9b8713 commit bbbe043
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dist/lamden.js
Original file line number Diff line number Diff line change
Expand Up @@ -5305,7 +5305,7 @@ function Encoder (type, value) {

const isNumber = (val) => {
if (isArray(val)) return false
return !isNaN(parseFloat(val))
return !isNaN(encodeBigNumber(val).toNumber())
};

const isInteger = (val) => {
Expand Down
2 changes: 1 addition & 1 deletion src/js/encoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function Encoder (type, value) {

const isNumber = (val) => {
if (isArray(val)) return false
return !isNaN(parseFloat(val))
return !isNaN(encodeBigNumber(val).toNumber())
}

const isInteger = (val) => {
Expand Down
2 changes: 1 addition & 1 deletion test/encoder-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ describe('Test Type Encoder', () => {
expect( JSON.stringify(Encoder('dict', {})) ).to.be( JSON.stringify({}) )
})
it('encodes a dict from a string', () => {
expect( JSON.stringify(Encoder('dict', '{}')) ).to.be( JSON.stringify({}) )
expect( JSON.stringify(Encoder('dict', '{"vk":"833f3f66de0da4599ca60ae7854256f37404f543cf7a97c328d38aff9d3f8ac7"}')) ).to.be( JSON.stringify({vk:"833f3f66de0da4599ca60ae7854256f37404f543cf7a97c328d38aff9d3f8ac7"}) )
})
it('encodes datetime and float inside a dict from a string', () => {
expect( JSON.stringify(Encoder('dict', {'datetime':new Date(dateString), 'float': 1.1})) ).to.be( '{"datetime":[2020,6,28,19,16,35,59],"float":{"__fixed__":"1.1"}}' )
Expand Down

0 comments on commit bbbe043

Please sign in to comment.