(subvalue)
| 31590 | // Remove `subvalue` from `value`. `subvalue` must be at the start of |
| 31591 | // `value`. |
| 31592 | function eat(subvalue) { |
| 31593 | var indent = getOffset(); |
| 31594 | var pos = position(); |
| 31595 | var current = now(); |
| 31596 | |
| 31597 | validateEat(subvalue); |
| 31598 | |
| 31599 | apply.reset = reset; |
| 31600 | reset.test = test; |
| 31601 | apply.test = test; |
| 31602 | |
| 31603 | value = value.slice(subvalue.length); |
| 31604 | |
| 31605 | updatePosition(subvalue); |
| 31606 | |
| 31607 | indent = indent(); |
| 31608 | |
| 31609 | return apply |
| 31610 | |
| 31611 | // Add the given arguments, add `position` to the returned node, and |
| 31612 | // return the node. |
| 31613 | function apply(node, parent) { |
| 31614 | return pos(add(pos(node), parent), indent) |
| 31615 | } |
| 31616 | |
| 31617 | // Functions just like apply, but resets the content: the line and |
| 31618 | // column are reversed, and the eaten value is re-added. This is |
| 31619 | // useful for nodes with a single type of content, such as lists and |
| 31620 | // tables. See `apply` above for what parameters are expected. |
| 31621 | function reset() { |
| 31622 | var node = apply.apply(null, arguments); |
| 31623 | |
| 31624 | line = current.line; |
| 31625 | column = current.column; |
| 31626 | value = subvalue + value; |
| 31627 | |
| 31628 | return node |
| 31629 | } |
| 31630 | |
| 31631 | // Test the position, after eating, and reverse to a not-eaten state. |
| 31632 | function test() { |
| 31633 | var result = pos({}); |
| 31634 | |
| 31635 | line = current.line; |
| 31636 | column = current.column; |
| 31637 | value = subvalue + value; |
| 31638 | |
| 31639 | return result.position |
| 31640 | } |
| 31641 | } |
| 31642 | } |
| 31643 | } |
| 31644 |
no test coverage detected