Skip to content

v1.0.0

Choose a tag to compare

@mauro-d mauro-d released this 11 Aug 19:57
· 2 commits to main since this release

The estimator is an object you create and keep: every counting function takes it
first, so one count can be saved, resumed, read at any point, and carried across
several sources.

Breaking

  • Requires Node 20 or newer.
  • estimateDistinct(estimator, source, options). epsilon, delta,
    expectedSize, seed and random belong to new CVM() alone; the options of
    the counting functions cover only how values reach it.
  • Sources are split by kind: estimateDistinctSync for an iterable you already
    hold, estimateDistinct for an async iterable or a Readable. Each refuses
    the other's sources and names the one to call, and the synchronous one takes no
    signal.
  • keyFn's parameter follows the element type of the source, so over an Order[]
    a wrong field is a compile error where it used to be any. TypeScript only:
    the runtime is unchanged.
  • DistinctEstimateStream is replaced by createEstimatorSink(estimator, options).
    The count is read from the estimator, so the sink has no result().
  • expectedSize is required and must be at least 1. A snapshot written by 0.4
    without it carries 0 and no longer restores.

Fixed

  • An abort lands while the source is waiting, not only between values.
  • A signal already aborted before the call rejects with ABORT_ERR on a
    Readable source too, instead of Node 24's ERR_STREAM_UNABLE_TO_PIPE.
  • createRandom throws with CVM_INVALID_OPTION on a bad seed, the one error
    that carried no code.

The hand-written types are now typechecked as a consumer compiles them, in CI and
before publishing.