number.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. "use strict";
  6. // Make this available to both AMD and CJS environments
  7. define(function (require, exports, module) {
  8. // Dependencies
  9. const React = require("devtools/client/shared/vendor/react");
  10. // Shortcuts
  11. const { span } = React.DOM;
  12. /**
  13. * Renders a number
  14. */
  15. const Number = React.createClass({
  16. displayName: "Number",
  17. stringify: function (object) {
  18. let isNegativeZero = Object.is(object, -0) ||
  19. (object.type && object.type == "-0");
  20. return (isNegativeZero ? "-0" : String(object));
  21. },
  22. render: function () {
  23. let value = this.props.object;
  24. return (
  25. span({className: "objectBox objectBox-number"},
  26. this.stringify(value)
  27. )
  28. );
  29. }
  30. });
  31. function supportsObject(object, type) {
  32. return ["boolean", "number", "-0"].includes(type);
  33. }
  34. // Exports from this module
  35. exports.Number = {
  36. rep: Number,
  37. supportsObject: supportsObject
  38. };
  39. });