@effect-ts/system
Version:
Effect-TS is a zero dependency set of libraries to write highly productive, purely functional TypeScript at scale.
58 lines (44 loc) • 2.86 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.StreamTypeId = exports.Stream = exports.DEFAULT_CHUNK_SIZE = void 0;
exports.isStream = isStream;
require("../../../Operator/index.js");
var T = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("../../../Effect/index.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; }
var _a; // ets_tracing: off
const StreamTypeId = /*#__PURE__*/Symbol();
/**
* A `Stream<R, E, A>` is a description of a program that, when evaluated,
* may emit 0 or more values of type `A`, may fail with errors of type `E`
* and uses an environment of type `R`.
* One way to think of `Stream` is as a `Effect` program that could emit multiple values.
*
* `Stream` is a purely functional *pull* based stream. Pull based streams offer
* inherent laziness and backpressure, relieving users of the need to manage buffers
* between operators. As an optimization, `Stream` does not emit single values, but
* rather an array of values. This allows the cost of effect evaluation to be
* amortized.
*
* `Stream` forms a monad on its `A` type parameter, and has error management
* facilities for its `E` type parameter, modeled similarly to `Effect` (with some
* adjustments for the multiple-valued nature of `Stream`). These aspects allow
* for rich and expressive composition of streams.
*/
exports.StreamTypeId = StreamTypeId;
class Stream {
constructor(channel) {
this.channel = channel;
this[_a] = StreamTypeId;
}
}
exports.Stream = Stream;
_a = StreamTypeId, T._R, T._E, T._A;
function isStream(u) {
return typeof u === "object" && u != null && StreamTypeId in u;
}
const DEFAULT_CHUNK_SIZE = 4096;
exports.DEFAULT_CHUNK_SIZE = DEFAULT_CHUNK_SIZE;
//# sourceMappingURL=core.js.map