for-ease
Version:
a simple library for itrating over anything
33 lines (32 loc) • 1.49 kB
JavaScript
;
const returnsOfCounterClass_1 = require("./returnsOfCounterClass");
const tillFactory_class_1 = require("./tillFactory/tillFactory.class");
const returnFactory_class_1 = require("./returnFactory/returnFactory.class");
const doFactory_class_1 = require("./doFactory/doFactory.class");
let For;
const doFactory = new doFactory_class_1.DoFactory();
const returnFactory = new returnFactory_class_1.ReturnFactory();
const tillFactory = new tillFactory_class_1.TillFactory();
const returnsOfCounterFactory = new returnsOfCounterClass_1.ReturnsOfCounter();
For = (mixed) => {
let maybeCopyOfMixed = [];
if (For.__copy && Array.isArray(mixed))
maybeCopyOfMixed = mixed.slice();
else
maybeCopyOfMixed = mixed;
const counter = doFactory.setMixedObj(maybeCopyOfMixed).getCounter();
const returns = returnFactory.setMixedObj(maybeCopyOfMixed).getReturn();
const tills = tillFactory.setMixedObj(maybeCopyOfMixed).getTills();
const returnMethods = returnsOfCounterFactory.setMixedObj(maybeCopyOfMixed).getReturns();
const combinedFactories = Object.assign({}, counter, returns, tills, returnMethods);
return combinedFactories;
};
For.__copy = true; // by default all the given arrays will be copied and used
// if you diable copying the returnSorted method will copy either way
For.disableCopy = () => {
For.__copy = false;
};
For.enableCopy = () => {
For.__copy = true;
};
module.exports = For;