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.

52 lines
1.1 KiB

4 years ago
  1. var helpers = require('./helpers');
  2. function store(serializeContext, token) {
  3. serializeContext.output.push(typeof token == 'string' ? token : token[1]);
  4. }
  5. function context() {
  6. var newContext = {
  7. output: [],
  8. store: store
  9. };
  10. return newContext;
  11. }
  12. function all(tokens) {
  13. var oneTimeContext = context();
  14. helpers.all(oneTimeContext, tokens);
  15. return oneTimeContext.output.join('');
  16. }
  17. function body(tokens) {
  18. var oneTimeContext = context();
  19. helpers.body(oneTimeContext, tokens);
  20. return oneTimeContext.output.join('');
  21. }
  22. function property(tokens, position) {
  23. var oneTimeContext = context();
  24. helpers.property(oneTimeContext, tokens, position, true);
  25. return oneTimeContext.output.join('');
  26. }
  27. function rules(tokens) {
  28. var oneTimeContext = context();
  29. helpers.rules(oneTimeContext, tokens);
  30. return oneTimeContext.output.join('');
  31. }
  32. function value(tokens) {
  33. var oneTimeContext = context();
  34. helpers.value(oneTimeContext, tokens);
  35. return oneTimeContext.output.join('');
  36. }
  37. module.exports = {
  38. all: all,
  39. body: body,
  40. property: property,
  41. rules: rules,
  42. value: value
  43. };