number.js 444 B

12345678910111213141516171819202122232425
  1. 'use strict';
  2. const Container = require('./container');
  3. const Node = require('./node');
  4. class NumberNode extends Node {
  5. constructor (opts) {
  6. super(opts);
  7. this.type = 'number';
  8. this.unit = Object(opts).unit || '';
  9. }
  10. toString () {
  11. return [
  12. this.raws.before,
  13. String(this.value),
  14. this.unit,
  15. this.raws.after
  16. ].join('');
  17. }
  18. };
  19. Container.registerWalker(NumberNode);
  20. module.exports = NumberNode;