UNPKG

jaywalk

Version:
29 lines 1.02 kB
"use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Promise = require('any-promise'); var rule_1 = require('./rule'); var Mutate = (function (_super) { __extends(Mutate, _super); function Mutate(options) { _super.call(this, options); this.type = 'Test'; this.name = options.name; this.mutate = options.mutate; this._tests.push(toMutateTest(this.mutate)); } return Mutate; }(rule_1.Rule)); exports.Mutate = Mutate; function toMutateTest(mutate) { return function (value, path, context, next) { return new Promise(function (resolve) { return resolve(mutate(value)); }) .then(function (mutation) { return next(mutation).then(function () { return value; }); }); }; } //# sourceMappingURL=mutate.js.map