tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

value-bigint-tojson.js (626B)


      1 // Copyright (C) 2017 Robin Templeton. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 description: BigInt toJSON method
      6 esid: sec-serializejsonproperty
      7 info: |
      8  Runtime Semantics: SerializeJSONProperty ( key, holder )
      9 
     10  2. If Type(value) is Object or BigInt, then
     11    a. Let toJSON be ? GetGetV(value, "toJSON").
     12    b. If IsCallable(toJSON) is true, then
     13      i. Set value to ? Call(toJSON, value, « key »).
     14 features: [BigInt]
     15 ---*/
     16 
     17 BigInt.prototype.toJSON = function () { return this.toString(); };
     18 assert.sameValue(JSON.stringify(0n), '"0"');
     19 
     20 reportCompare(0, 0);