You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
607 B

2 years ago
  1. var parse = require("./parse");
  2. var walk = require("./walk");
  3. var stringify = require("./stringify");
  4. function ValueParser(value) {
  5. if (this instanceof ValueParser) {
  6. this.nodes = parse(value);
  7. return this;
  8. }
  9. return new ValueParser(value);
  10. }
  11. ValueParser.prototype.toString = function() {
  12. return Array.isArray(this.nodes) ? stringify(this.nodes) : "";
  13. };
  14. ValueParser.prototype.walk = function(cb, bubble) {
  15. walk(this.nodes, cb, bubble);
  16. return this;
  17. };
  18. ValueParser.unit = require("./unit");
  19. ValueParser.walk = walk;
  20. ValueParser.stringify = stringify;
  21. module.exports = ValueParser;