12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- 'use strict';
- class InvalidFormatError extends Error {
- constructor(formatFn) {
- super(`Format functions must be synchronous taking a two arguments: (info, opts)
- Found: ${formatFn.toString().split('\n')[0]}\n`);
- Error.captureStackTrace(this, InvalidFormatError);
- }
- }
- module.exports = formatFn => {
- if (formatFn.length > 2) {
- throw new InvalidFormatError(formatFn);
- }
-
- function Format(options = {}) {
- this.options = options;
- }
- Format.prototype.transform = formatFn;
-
-
-
-
-
-
- function createFormatWrap(opts) {
- return new Format(opts);
- }
-
-
-
-
- createFormatWrap.Format = Format;
- return createFormatWrap;
- };
|