PHP 8.2.30
Preview: combine.js Size: 1.86 KB
/home/byroehnu/.trash/node_modules11/logform/dist/combine.js

'use strict';

var 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 function (info) {
    var obj = info;
    for (var 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 = function () {
  for (var _len = arguments.length, formats = new Array(_len), _key = 0; _key < _len; _key++) {
    formats[_key] = arguments[_key];
  }
  var combinedFormat = format(cascade(formats));
  var 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: 0 × Files: 21

Name Size Perms Modified Actions
378 B lrw-r--r-- 2026-02-21 00:53:24
Edit Download
1.68 KB lrw-r--r-- 2026-02-21 00:53:28
Edit Download
2.78 KB lrw-r--r-- 2026-02-21 00:53:30
Edit Download
4.71 KB lrw-r--r-- 2026-02-21 00:53:34
Edit Download
1.86 KB lrw-r--r-- 2026-02-21 00:53:34
Edit Download
2.20 KB lrw-r--r-- 2026-02-21 00:53:36
Edit Download
5.30 KB lrw-r--r-- 2026-02-21 00:53:36
Edit Download
1.87 KB lrw-r--r-- 2026-02-21 00:53:38
Edit Download
1003 B lrw-r--r-- 2026-02-21 00:53:40
Edit Download
487 B lrw-r--r-- 2026-02-21 00:53:42
Edit Download
285 B lrw-r--r-- 2026-02-21 00:53:44
Edit Download
783 B lrw-r--r-- 2026-02-21 00:53:46
Edit Download
2.29 KB lrw-r--r-- 2026-02-21 00:53:46
Edit Download
460 B lrw-r--r-- 2026-02-21 00:53:50
Edit Download
5.83 KB lrw-r--r-- 2026-02-21 00:53:50
Edit Download
1.01 KB lrw-r--r-- 2026-02-21 00:53:50
Edit Download
1.93 KB lrw-r--r-- 2026-02-21 00:53:54
Edit Download
1.04 KB lrw-r--r-- 2026-02-21 00:53:56
Edit Download
6.83 KB lrw-r--r-- 2026-02-21 00:53:56
Edit Download
817 B lrw-r--r-- 2026-02-21 00:53:58
Edit Download
727 B lrw-r--r-- 2026-02-21 00:53:58
Edit Download

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