for-ease
Version:
a simple library for itrating over anything
31 lines (30 loc) • 994 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const returnsOfCounterClass_1 = require("./../returnsOfCounterClass");
class FunctionClass {
constructor(_func) {
this._func = _func;
}
getCounter() {
// if(this.func === undefined) throw new Error('First set a function for this process')
return {
do: (cb) => {
let result;
let changesOnArray = [];
let i = 0;
const func = this._func;
while (result = func()) {
let ret = cb && cb(result);
if (ret)
changesOnArray[i++] = ret;
}
return (new returnsOfCounterClass_1.ReturnsOfCounter(changesOnArray)).getReturns();
}
};
}
setMixedObj(mixed) {
this._func = mixed;
return this;
}
}
exports.FunctionClass = FunctionClass;