@effect-ts/system
Version:
Effect-TS is a zero dependency set of libraries to write highly productive, purely functional TypeScript at scale.
56 lines (45 loc) • 2.97 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.groupByKey = groupByKey;
exports.groupByKey_ = groupByKey_;
var Tp = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("../../../../Collections/Immutable/Tuple/index.js"));
var T = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("../../../../Effect/index.js"));
var GroupBy = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("./groupBy.js"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
// ets_tracing: off
/**
* Partition a stream using a function and process each stream individually.
* This returns a data structure that can be used
* to further filter down which groups shall be processed.
*
* After calling apply on the GroupBy object, the remaining groups will be processed
* in parallel and the resulting streams merged in a nondeterministic fashion.
*
* Up to `buffer` elements may be buffered in any group stream before the producer
* is backpressured. Take care to consume from all streams in order
* to prevent deadlocks.
*/
function groupByKey_(self, f, buffer = 16) {
return GroupBy.groupBy_(self, a => T.succeed(Tp.tuple(f(a), a)), buffer);
}
/**
* Partition a stream using a function and process each stream individually.
* This returns a data structure that can be used
* to further filter down which groups shall be processed.
*
* After calling apply on the GroupBy object, the remaining groups will be processed
* in parallel and the resulting streams merged in a nondeterministic fashion.
*
* Up to `buffer` elements may be buffered in any group stream before the producer
* is backpressured. Take care to consume from all streams in order
* to prevent deadlocks.
*
* @ets_data_first groupByKey_
*/
function groupByKey(f, buffer = 16) {
return self => groupByKey_(self, f, buffer);
}
//# sourceMappingURL=groupByKey.js.map