3 var makeCheck = require('./makeCheck');
4 var isEmpty = require('./is').isEmpty;
10 exports.remove = remove;
11 function remove(target) {
13 target.next.prev = target.prev;
14 } else if (target.root) {
15 target.root.endToken = target.prev;
19 target.prev.next = target.next;
20 } else if (target.root) {
21 target.root.startToken = target.next;
26 exports.removeInBetween = removeInBetween;
27 function removeInBetween(startToken, endToken, check) {
28 check = makeCheck(check);
29 var last = endToken && endToken.next;
30 while (startToken && startToken !== last) {
31 if (check(startToken)) {
34 startToken = startToken.next;
39 exports.removeAdjacent = removeAdjacent;
40 function removeAdjacent(token, check) {
41 removeAdjacentBefore(token, check);
42 removeAdjacentAfter(token, check);
46 exports.removeAdjacentBefore = removeAdjacentBefore;
47 function removeAdjacentBefore(token, check) {
48 check = makeCheck(check);
49 var prev = token.prev;
50 while (prev && check(prev)) {
57 exports.removeAdjacentAfter = removeAdjacentAfter;
58 function removeAdjacentAfter(token, check) {
59 check = makeCheck(check);
60 var next = token.next;
61 while (next && check(next)) {
68 exports.removeEmptyAdjacentBefore = removeEmptyAdjacentBefore;
69 function removeEmptyAdjacentBefore(startToken) {
70 removeAdjacentBefore(startToken, isEmpty);
74 exports.removeEmptyAdjacentAfter = removeEmptyAdjacentAfter;
75 function removeEmptyAdjacentAfter(startToken) {
76 removeAdjacentAfter(startToken, isEmpty);
80 exports.removeEmptyInBetween = removeEmptyInBetween;
81 function removeEmptyInBetween(startToken, endToken) {
82 removeInBetween(startToken, endToken, isEmpty);