monorepo-shared-assets
Version:
Shared assets used by various packages from nodemonorepo
29 lines • 1.04 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const assert_1 = tslib_1.__importDefault(require("assert"));
function* urge(iterable, partLength, handleRemain = urge.DEFAULT_REMAINING_HANDLER) {
assert_1.default(partLength > 0, `${partLength} > 0`);
assert_1.default.strictEqual(partLength % 1, 0, `${partLength} is an integer`);
let count = partLength;
let tray = Array();
for (const x of iterable) {
--count;
tray.push(x);
if (!count) {
yield tray;
count = partLength;
tray = [];
}
}
yield* handleRemain(tray);
}
exports.urge = urge;
(function (urge) {
urge.OMIT_EMPTY_REMAINING_PART = (x) => x.length ? [x] : [];
urge.KEEP_REMAINING_PART = (x) => [x];
urge.OMIT_REMAINING_PART = () => [];
urge.DEFAULT_REMAINING_HANDLER = urge.OMIT_EMPTY_REMAINING_PART;
})(urge = exports.urge || (exports.urge = {}));
exports.default = urge;
//# sourceMappingURL=index.js.map
;