effect
Version:
The missing standard library for TypeScript, for writing production-grade software.
54 lines (53 loc) • 2.97 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.linear = exports.isMetricBoundaries = exports.fromIterable = exports.exponential = exports.MetricBoundariesTypeId = void 0;
var Arr = _interopRequireWildcard(require("../../Array.js"));
var Chunk = _interopRequireWildcard(require("../../Chunk.js"));
var Equal = _interopRequireWildcard(require("../../Equal.js"));
var _Function = require("../../Function.js");
var Hash = _interopRequireWildcard(require("../../Hash.js"));
var _Pipeable = require("../../Pipeable.js");
var _Predicate = require("../../Predicate.js");
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
/** @internal */
const MetricBoundariesSymbolKey = "effect/MetricBoundaries";
/** @internal */
const MetricBoundariesTypeId = exports.MetricBoundariesTypeId = /*#__PURE__*/Symbol.for(MetricBoundariesSymbolKey);
/** @internal */
class MetricBoundariesImpl {
values;
[MetricBoundariesTypeId] = MetricBoundariesTypeId;
constructor(values) {
this.values = values;
this._hash = (0, _Function.pipe)(Hash.string(MetricBoundariesSymbolKey), Hash.combine(Hash.array(this.values)));
}
_hash;
[Hash.symbol]() {
return this._hash;
}
[Equal.symbol](u) {
return isMetricBoundaries(u) && Equal.equals(this.values, u.values);
}
pipe() {
return (0, _Pipeable.pipeArguments)(this, arguments);
}
}
/** @internal */
const isMetricBoundaries = u => (0, _Predicate.hasProperty)(u, MetricBoundariesTypeId);
/** @internal */
exports.isMetricBoundaries = isMetricBoundaries;
const fromIterable = iterable => {
const values = (0, _Function.pipe)(iterable, Arr.appendAll(Chunk.of(Number.POSITIVE_INFINITY)), Arr.dedupe);
return new MetricBoundariesImpl(values);
};
/** @internal */
exports.fromIterable = fromIterable;
const linear = options => (0, _Function.pipe)(Arr.makeBy(options.count - 1, i => options.start + i * options.width), Chunk.unsafeFromArray, fromIterable);
/** @internal */
exports.linear = linear;
const exponential = options => (0, _Function.pipe)(Arr.makeBy(options.count - 1, i => options.start * Math.pow(options.factor, i)), Chunk.unsafeFromArray, fromIterable);
exports.exponential = exponential;
//# sourceMappingURL=boundaries.js.map