Node-Red configuration
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

es.number.to-precision.js 815B

12345678910111213141516171819202122232425
  1. 'use strict';
  2. var $ = require('../internals/export');
  3. var uncurryThis = require('../internals/function-uncurry-this');
  4. var fails = require('../internals/fails');
  5. var thisNumberValue = require('../internals/this-number-value');
  6. var nativeToPrecision = uncurryThis(1.0.toPrecision);
  7. var FORCED = fails(function () {
  8. // IE7-
  9. return nativeToPrecision(1, undefined) !== '1';
  10. }) || !fails(function () {
  11. // V8 ~ Android 4.3-
  12. nativeToPrecision({});
  13. });
  14. // `Number.prototype.toPrecision` method
  15. // https://tc39.es/ecma262/#sec-number.prototype.toprecision
  16. $({ target: 'Number', proto: true, forced: FORCED }, {
  17. toPrecision: function toPrecision(precision) {
  18. return precision === undefined
  19. ? nativeToPrecision(thisNumberValue(this))
  20. : nativeToPrecision(thisNumberValue(this), precision);
  21. }
  22. });