PHP 8.2.30
Preview: combine.js Size: 1.76 KB
/home/byroehnu/easepay.easetack.com/node_modules/logform/combine.js

'use strict';

const format = require('./format');

/*
 * function cascade(formats)
 * Returns a function that invokes the `._format` function in-order
 * for the specified set of `formats`. In this manner we say that Formats
 * are "pipe-like", but not a pure pumpify implementation. Since there is no back
 * pressure we can remove all of the "readable" plumbing in Node streams.
 */
function cascade(formats) {
  if (!formats.every(isValidFormat)) {
    return;
  }

  return info => {
    let obj = info;
    for (let i = 0; i < formats.length; i++) {
      obj = formats[i].transform(obj, formats[i].options);
      if (!obj) {
        return false;
      }
    }

    return obj;
  };
}

/*
 * function isValidFormat(format)
 * If the format does not define a `transform` function throw an error
 * with more detailed usage.
 */
function isValidFormat(fmt) {
  if (typeof fmt.transform !== 'function') {
    throw new Error([
      'No transform function found on format. Did you create a format instance?',
      'const myFormat = format(formatFn);',
      'const instance = myFormat();'
    ].join('\n'));
  }

  return true;
}

/*
 * function combine (info)
 * Returns a new instance of the combine Format which combines the specified
 * formats into a new format. This is similar to a pipe-chain in transform streams.
 * We choose to combine the prototypes this way because there is no back pressure in
 * an in-memory transform chain.
 */
module.exports = (...formats) => {
  const combinedFormat = format(cascade(formats));
  const instance = combinedFormat();
  instance.Format = combinedFormat.Format;
  return instance;
};

//
// Export the cascade method for use in cli and other
// combined formats that should not be assumed to be
// singletons.
//
module.exports.cascade = cascade;

Directory Contents

Dirs: 2 × Files: 31

Name Size Perms Modified Actions
dist DIR
- drwxr-xr-x 2026-03-14 01:49:19
Edit Download
- drwxr-xr-x 2026-03-14 01:49:19
Edit Download
39 B lrw-r--r-- 2026-02-21 00:53:16
Edit Download
105 B lrw-r--r-- 2026-02-21 00:53:18
Edit Download
25 B lrw-r--r-- 2026-02-21 00:53:20
Edit Download
127 B lr--r--r-- 2026-03-14 01:49:19
Edit Download
367 B lrw-r--r-- 2026-02-21 00:53:22
Edit Download
1.72 KB lrw-r--r-- 2026-02-21 00:53:24
Edit Download
10.48 KB lrw-r--r-- 2026-02-21 00:54:00
Edit Download
1.19 KB lrw-r--r-- 2026-02-21 00:53:28
Edit Download
2.97 KB lrw-r--r-- 2026-02-21 00:53:32
Edit Download
1.76 KB lrw-r--r-- 2026-02-21 00:53:34
Edit Download
1.19 KB lrw-r--r-- 2026-02-21 00:53:36
Edit Download
1.14 KB lrw-r--r-- 2026-02-21 00:53:38
Edit Download
6.04 KB lrw-r--r-- 2026-02-21 00:54:00
Edit Download
1.83 KB lrw-r--r-- 2026-02-21 00:53:38
Edit Download
983 B lrw-r--r-- 2026-02-21 00:53:40
Edit Download
469 B lrw-r--r-- 2026-02-21 00:53:42
Edit Download
251 B lrw-r--r-- 2026-02-21 00:53:44
Edit Download
1.07 KB lrw-r--r-- 2026-02-21 00:53:22
Edit Download
759 B lrw-r--r-- 2026-02-21 00:53:46
Edit Download
1.30 KB lrw-r--r-- 2026-02-21 00:53:48
Edit Download
430 B lrw-r--r-- 2026-02-21 00:53:50
Edit Download
1.44 KB lrw-r--r-- 2026-02-21 00:53:58
Edit Download
2.81 KB lrw-r--r-- 2026-02-21 00:53:50
Edit Download
899 B lrw-r--r-- 2026-02-21 00:53:52
Edit Download
515 B lrw-r--r-- 2026-02-21 00:53:54
Edit Download
17.66 KB lrw-r--r-- 2026-02-21 00:54:00
Edit Download
979 B lrw-r--r-- 2026-02-21 00:53:56
Edit Download
4.17 KB lrw-r--r-- 2026-02-21 00:53:58
Edit Download
757 B lrw-r--r-- 2026-02-21 00:53:58
Edit Download
384 B lrw-r--r-- 2026-02-21 00:53:58
Edit Download
705 B lrw-r--r-- 2026-02-21 00:53:58
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).