Skip to content

Migrating from 1.x

  • mini-fp 2. @ngwes/mini-fp 2.x (^2.0.0) is the required peer dependency. See its changelog for its own changes (prelude right / left, lazy Try).
  • Pipeline returns an EitherAsync, not a native Promise. await Pipeline(...) still gives an Either, and .then still works. .catch, .finally and instanceof Promise do not: await the result (in a try if a hook may throw), or chain match / map instead.
  • Steps and hooks may return an Either, a promise of one, or an EitherAsync (the new StepResult type). Existing async steps and hooks keep working; they no longer need to be async.
  • onLeft is optional. Without it, a step’s left stops the pipeline unchanged. A 1.x onLeft: async (err) => Either.left(err) can be removed.
  • A hook returning right continues with the next step, for every hook, onException included. In 1.x, onException returning right ended the pipeline with that context. To stop, return left.
  • onConflictingKeys receives (keys, ctx, next): next is the context the step returned, so the hook can accept it with right(next). The keys are typed keyof Ctx & string.
  • A hook’s context is not conflict-checked. In 1.x, the context returned by a recovering onLeft went through the conflict check, so onConflictingKeys ran when it overwrote a value. In 2.0 no hook’s output is checked: the hook has the last word. If your onLeft relied on that check, compare the keys in onLeft itself.
  • The initial context is copied before it is frozen. 1.x froze the object you passed in. Contexts must be plain objects: a class instance loses its prototype in the copy.
  • Dropped keys count as conflicts. A step that returns a context without a key that held a value now triggers onConflictingKeys.
  • loadSteps and loadStepsFromDir return EitherAsync<ReadonlyArray<LoadError>, ReadonlyArray<Step>> instead of throwing. Replace try { await loadSteps(...) } with match or mapLeft on the result (see Load errors).
  • A module without a usable steps or default export is an invalid-export error, instead of being skipped silently. So is an array export holding something that is not a function.
  • The default loadStepsFromDir pattern skips .d.ts, .test.* and .spec.* files.
  • The loaders’ type parameter is named E, like the pipeline’s (it was L). This only matters if you referred to it by name.