@atomist/automation-client
Version:
Atomist API for software low-level client
29 lines • 1.41 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Exclude matches that are within a match of the given microgrammar
* @param {Grammar<any>} mg
* @return {MatchTesterMaker}
*/
function notWithin(mg) {
return (file) => __awaiter(this, void 0, void 0, function* () {
const content = yield file.getContent();
const matches = mg.findMatches(content);
return n => !matches.some(m => {
const mEndoffset = m.$offset + m.$matched.length;
const nEndoffset = n.$offset + n.$value.length;
return m.$offset <= n.$offset && mEndoffset >= nEndoffset;
});
});
}
exports.notWithin = notWithin;
//# sourceMappingURL=matchTesters.js.map