File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed
Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -1819,9 +1819,8 @@ class JSBI extends Array {
18191819 if ( obj . constructor === JSBI ) return obj ;
18201820 if ( typeof Symbol !== 'undefined' &&
18211821 typeof Symbol . toPrimitive === 'symbol' ) {
1822- const exoticToPrim = obj [ Symbol . toPrimitive ] ;
1823- if ( exoticToPrim ) {
1824- const primitive = exoticToPrim ( hint ) ;
1822+ if ( obj [ Symbol . toPrimitive ] ) {
1823+ const primitive = obj [ Symbol . toPrimitive ] ( hint ) ;
18251824 if ( typeof primitive !== 'object' ) return primitive ;
18261825 throw new TypeError ( 'Cannot convert object to primitive value' ) ;
18271826 }
Original file line number Diff line number Diff line change @@ -131,6 +131,16 @@ const TESTS = [
131131 }
132132} ) ( ) ;
133133
134+ // https://github.com/GoogleChromeLabs/jsbi/issues/101
135+ ( function ( ) {
136+ const o = {
137+ num : 123 ,
138+ [ Symbol . toPrimitive ] : function ( ) { return this . num ; }
139+ } ;
140+ const result = JSBI . BigInt ( o ) ;
141+ assertTrue ( JSBI . equal ( result , JSBI . BigInt ( 123 ) ) ) ;
142+ } ) ( ) ;
143+
134144function parse ( string ) {
135145 if ( string . charCodeAt ( 0 ) === 0x2D ) { // '-'
136146 return JSBI . unaryMinus ( JSBI . BigInt ( string . slice ( 1 ) ) ) ;
You can’t perform that action at this time.
0 commit comments