Dimension.js 540 B

1234567891011121314151617181920212223
  1. import { Dimension } from '../../tokenizer/index.js';
  2. export const name = 'Dimension';
  3. export const structure = {
  4. value: String,
  5. unit: String
  6. };
  7. export function parse() {
  8. const start = this.tokenStart;
  9. const value = this.consumeNumber(Dimension);
  10. return {
  11. type: 'Dimension',
  12. loc: this.getLocation(start, this.tokenStart),
  13. value,
  14. unit: this.substring(start + value.length, this.tokenStart)
  15. };
  16. }
  17. export function generate(node) {
  18. this.token(Dimension, node.value + node.unit);
  19. }