Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
9d81f4fd
Commit
9d81f4fd
authored
Apr 12, 2016
by
Felix Lange
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2448 from fjl/jsre-bignum
jsre: print BigNumber objects with custom constructor as number
parents
f460b021
4e85be07
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
5 deletions
+13
-5
pretty.go
jsre/pretty.go
+13
-5
No files found.
jsre/pretty.go
View file @
9d81f4fd
...
@@ -227,12 +227,20 @@ func iterOwnKeys(vm *otto.Otto, obj *otto.Object, f func(string)) {
...
@@ -227,12 +227,20 @@ func iterOwnKeys(vm *otto.Otto, obj *otto.Object, f func(string)) {
}
}
func
(
ctx
ppctx
)
isBigNumber
(
v
*
otto
.
Object
)
bool
{
func
(
ctx
ppctx
)
isBigNumber
(
v
*
otto
.
Object
)
bool
{
BigNumber
,
err
:=
ctx
.
vm
.
Run
(
"BigNumber.prototype"
)
// Handle numbers with custom constructor.
if
err
!=
nil
{
if
v
,
_
:=
v
.
Get
(
"constructor"
);
v
.
Object
()
!=
nil
{
panic
(
err
)
if
strings
.
HasPrefix
(
toString
(
v
.
Object
()),
"function BigNumber"
)
{
return
true
}
}
cp
:=
constructorPrototype
(
v
)
}
return
cp
!=
nil
&&
cp
.
Value
()
==
BigNumber
// Handle default constructor.
BigNumber
,
_
:=
ctx
.
vm
.
Object
(
"BigNumber.prototype"
)
if
BigNumber
==
nil
{
return
false
}
bv
,
_
:=
BigNumber
.
Call
(
"isPrototypeOf"
,
v
)
b
,
_
:=
bv
.
ToBoolean
()
return
b
}
}
func
toString
(
obj
*
otto
.
Object
)
string
{
func
toString
(
obj
*
otto
.
Object
)
string
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment