every-fn

1.0.6 • Public • Published

Every-Fn

Every

every is a function that iterates over an list of functions until one of the functions returns false. The output of each function is merged into the output of the previously called function and passed as input to the next function call.

An optional initial state object may be provided as a second argument.

If an asynchronous function is specified, every will await it's return before calling the next function.

For example: sample-controller.js

import { every } from "every-fn";
import {
  validateInput,
  sendValidationErrors,
  cleanUserInput,
  findCustomer,
  handleDbError,
  sendCustomerExistsError,
  sendLoginSuccessResponse
} from "./lib/customer-login.js";
 
export const loginCustomer = async (req, res) =>
  await every(
    [
      validateInput,
      sendValidationErrors,
      cleanUserInput,
      findCustomer,
      handleDbError,
      sendCustomerExistsError,
      sendLoginSuccessResponse
    ],
    { req, res }
  );

Readme

Keywords

Package Sidebar

Install

npm i every-fn

Weekly Downloads

8

Version

1.0.6

License

MIT

Unpacked Size

4.54 kB

Total Files

7

Last publish

Collaborators

  • opinephp