Dimension.cjs 642 B

123456789101112131415161718192021222324252627282930
  1. 'use strict';
  2. const types = require('../../tokenizer/types.cjs');
  3. const name = 'Dimension';
  4. const structure = {
  5. value: String,
  6. unit: String
  7. };
  8. function parse() {
  9. const start = this.tokenStart;
  10. const value = this.consumeNumber(types.Dimension);
  11. return {
  12. type: 'Dimension',
  13. loc: this.getLocation(start, this.tokenStart),
  14. value,
  15. unit: this.substring(start + value.length, this.tokenStart)
  16. };
  17. }
  18. function generate(node) {
  19. this.token(types.Dimension, node.value + node.unit);
  20. }
  21. exports.generate = generate;
  22. exports.name = name;
  23. exports.parse = parse;
  24. exports.structure = structure;