string.js 555 B

12345678910111213141516171819202122232425262728
  1. 'use strict';
  2. const Container = require('./container');
  3. const Node = require('./node');
  4. class StringNode extends Node {
  5. constructor (opts) {
  6. super(opts);
  7. this.type = 'string';
  8. }
  9. toString () {
  10. let quote = this.quoted ? this.raws.quote : '';
  11. return [
  12. this.raws.before,
  13. quote,
  14. // we can't use String() here because it'll try using itself
  15. // as the constructor
  16. this.value + '',
  17. quote,
  18. this.raws.after
  19. ].join('');
  20. }
  21. }
  22. Container.registerWalker(StringNode);
  23. module.exports = StringNode;