UNPKG

compromise

Version:
49 lines (44 loc) 1.13 kB
'use strict'; const splitMethods = (Text) => { const methods = { /** turn result into two seperate results */ splitAfter: function(reg, verbose) { let list = []; this.list.forEach((ts) => { ts.splitAfter(reg, verbose).forEach((mts) => { list.push(mts); }); }); this.list = list; return this; }, /** turn result into two seperate results */ splitBefore: function(reg, verbose) { let list = []; this.list.forEach((ts) => { ts.splitBefore(reg, verbose).forEach((mts) => { list.push(mts); }); }); this.list = list; return this; }, /** turn result into two seperate results */ splitOn: function(reg, verbose) { let list = []; this.list.forEach((ts) => { ts.splitOn(reg, verbose).forEach((mts) => { list.push(mts); }); }); this.list = list; return this; }, } //hook them into result.proto Object.keys(methods).forEach((k) => { Text.prototype[k] = methods[k]; }); return Text; }; module.exports = splitMethods;