tailwind-widgets 5.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. package/LICENSE +24 -0
  2. package/README.md +113 -0
  3. package/bin.js +6 -0
  4. package/bingo-logger.js +211 -0
  5. package/browser.js +358 -0
  6. package/docs/api.md +1352 -0
  7. package/docs/asynchronous.md +102 -0
  8. package/docs/benchmarks.md +58 -0
  9. package/docs/browser.md +199 -0
  10. package/docs/bundling.md +34 -0
  11. package/docs/child-loggers.md +95 -0
  12. package/docs/ecosystem.md +74 -0
  13. package/docs/help.md +305 -0
  14. package/docs/lts.md +62 -0
  15. package/docs/pretty.md +101 -0
  16. package/docs/redaction.md +135 -0
  17. package/docs/transports.md +792 -0
  18. package/docs/web.md +257 -0
  19. package/file.js +12 -0
  20. package/lib/caller.js +30 -0
  21. package/lib/deprecations.js +10 -0
  22. package/lib/levels.js +193 -0
  23. package/lib/meta.js +5 -0
  24. package/lib/multistream.js +156 -0
  25. package/lib/parse.js +14 -0
  26. package/lib/proto.js +216 -0
  27. package/lib/redaction.js +118 -0
  28. package/lib/symbols.js +70 -0
  29. package/lib/time.js +11 -0
  30. package/lib/tools.js +563 -0
  31. package/lib/transport-stream.js +47 -0
  32. package/lib/transport.js +157 -0
  33. package/lib/worker-pipeline.js +40 -0
  34. package/lib/worker.js +54 -0
  35. package/package.json +131 -0
  36. package/test/basic.test.js +719 -0
  37. package/test/broken-pipe.test.js +42 -0
  38. package/test/browser-levels.test.js +218 -0
  39. package/test/browser-serializers.test.js +354 -0
  40. package/test/browser-timestamp.test.js +88 -0
  41. package/test/browser-transmit.test.js +349 -0
  42. package/test/browser.test.js +547 -0
  43. package/test/complex-objects.test.js +34 -0
  44. package/test/crlf.test.js +32 -0
  45. package/test/custom-levels.test.js +294 -0
  46. package/test/error.test.js +374 -0
  47. package/test/escaping.test.js +91 -0
  48. package/test/esm/esm.mjs +12 -0
  49. package/test/esm/index.test.js +34 -0
  50. package/test/esm/named-exports.mjs +28 -0
  51. package/test/exit.test.js +85 -0
  52. package/test/final.test.js +237 -0
  53. package/test/fixtures/broken-pipe/basic.js +9 -0
  54. package/test/fixtures/broken-pipe/destination.js +10 -0
  55. package/test/fixtures/broken-pipe/syncfalse.js +12 -0
  56. package/test/fixtures/console-transport.js +13 -0
  57. package/test/fixtures/default-exit.js +8 -0
  58. package/test/fixtures/destination-exit.js +8 -0
  59. package/test/fixtures/eval/index.js +29 -0
  60. package/test/fixtures/eval/node_modules/14-files.js +3 -0
  61. package/test/fixtures/eval/node_modules/2-files.js +3 -0
  62. package/test/fixtures/eval/node_modules/file1.js +5 -0
  63. package/test/fixtures/eval/node_modules/file10.js +5 -0
  64. package/test/fixtures/eval/node_modules/file11.js +5 -0
  65. package/test/fixtures/eval/node_modules/file12.js +5 -0
  66. package/test/fixtures/eval/node_modules/file13.js +5 -0
  67. package/test/fixtures/eval/node_modules/file14.js +11 -0
  68. package/test/fixtures/eval/node_modules/file15.js +10 -0
  69. package/test/fixtures/eval/node_modules/file2.js +5 -0
  70. package/test/fixtures/eval/node_modules/file3.js +5 -0
  71. package/test/fixtures/eval/node_modules/file4.js +5 -0
  72. package/test/fixtures/eval/node_modules/file5.js +5 -0
  73. package/test/fixtures/eval/node_modules/file6.js +5 -0
  74. package/test/fixtures/eval/node_modules/file7.js +5 -0
  75. package/test/fixtures/eval/node_modules/file8.js +5 -0
  76. package/test/fixtures/eval/node_modules/file9.js +5 -0
  77. package/test/fixtures/eval/node_modules/test.list +3 -0
  78. package/test/fixtures/pretty/basic.js +6 -0
  79. package/test/fixtures/pretty/child-with-serializer.js +17 -0
  80. package/test/fixtures/pretty/child-with-updated-chindings.js +8 -0
  81. package/test/fixtures/pretty/child.js +8 -0
  82. package/test/fixtures/pretty/custom-time-label.js +9 -0
  83. package/test/fixtures/pretty/custom-time.js +9 -0
  84. package/test/fixtures/pretty/dateformat.js +10 -0
  85. package/test/fixtures/pretty/error-props.js +9 -0
  86. package/test/fixtures/pretty/error.js +7 -0
  87. package/test/fixtures/pretty/final-no-log-before.js +8 -0
  88. package/test/fixtures/pretty/final-return.js +7 -0
  89. package/test/fixtures/pretty/final.js +9 -0
  90. package/test/fixtures/pretty/formatters.js +13 -0
  91. package/test/fixtures/pretty/level-first.js +6 -0
  92. package/test/fixtures/pretty/no-time.js +9 -0
  93. package/test/fixtures/pretty/null-prototype.js +8 -0
  94. package/test/fixtures/pretty/obj-msg-prop.js +6 -0
  95. package/test/fixtures/pretty/pretty-factory.js +6 -0
  96. package/test/fixtures/pretty/redact.js +9 -0
  97. package/test/fixtures/pretty/serializers.js +17 -0
  98. package/test/fixtures/pretty/skipped-output.js +13 -0
  99. package/test/fixtures/pretty/suppress-flush-sync-warning.js +7 -0
  100. package/test/fixtures/stdout-hack-protection.js +11 -0
  101. package/test/fixtures/syncfalse-child.js +6 -0
  102. package/test/fixtures/syncfalse-exit.js +9 -0
  103. package/test/fixtures/syncfalse-flush-exit.js +10 -0
  104. package/test/fixtures/syncfalse.js +6 -0
  105. package/test/fixtures/to-file-transport-with-transform.js +20 -0
  106. package/test/fixtures/to-file-transport.js +13 -0
  107. package/test/fixtures/to-file-transport.mjs +8 -0
  108. package/test/fixtures/transport/index.js +12 -0
  109. package/test/fixtures/transport/package.json +5 -0
  110. package/test/fixtures/transport-exit-immediately-with-async-dest.js +16 -0
  111. package/test/fixtures/transport-exit-immediately.js +11 -0
  112. package/test/fixtures/transport-exit-on-ready.js +12 -0
  113. package/test/fixtures/transport-main.js +9 -0
  114. package/test/fixtures/transport-many-lines.js +29 -0
  115. package/test/fixtures/transport-string-stdout.js +9 -0
  116. package/test/fixtures/transport-transform.js +21 -0
  117. package/test/fixtures/transport-worker.js +13 -0
  118. package/test/fixtures/transport-wrong-export-type.js +3 -0
  119. package/test/fixtures/ts/to-file-transport-with-transform.ts +18 -0
  120. package/test/fixtures/ts/to-file-transport.es2017.cjs +12 -0
  121. package/test/fixtures/ts/to-file-transport.es5.cjs +58 -0
  122. package/test/fixtures/ts/to-file-transport.es6.cjs +23 -0
  123. package/test/fixtures/ts/to-file-transport.esnext.cjs +12 -0
  124. package/test/fixtures/ts/to-file-transport.ts +11 -0
  125. package/test/fixtures/ts/transpile.cjs +40 -0
  126. package/test/fixtures/ts/transport-exit-immediately-with-async-dest.ts +15 -0
  127. package/test/fixtures/ts/transport-exit-immediately.ts +10 -0
  128. package/test/fixtures/ts/transport-exit-on-ready.ts +11 -0
  129. package/test/fixtures/ts/transport-main.ts +8 -0
  130. package/test/fixtures/ts/transport-string-stdout.ts +8 -0
  131. package/test/fixtures/ts/transport-worker.ts +14 -0
  132. package/test/formatters.test.js +355 -0
  133. package/test/helper.d.ts +4 -0
  134. package/test/helper.js +128 -0
  135. package/test/hooks.test.js +97 -0
  136. package/test/http.test.js +242 -0
  137. package/test/is-level-enabled.test.js +43 -0
  138. package/test/jest/basic.spec.js +10 -0
  139. package/test/levels.test.js +528 -0
  140. package/test/metadata.test.js +106 -0
  141. package/test/mixin-merge-strategy.test.js +55 -0
  142. package/test/mixin.test.js +162 -0
  143. package/test/multistream.test.js +589 -0
  144. package/test/pretty.test.js +392 -0
  145. package/test/redact.test.js +828 -0
  146. package/test/serializers.test.js +253 -0
  147. package/test/stdout-protection.test.js +19 -0
  148. package/test/syncfalse.test.js +118 -0
  149. package/test/timestamp.test.js +121 -0
  150. package/test/transport/big.test.js +41 -0
  151. package/test/transport/bundlers-support.test.js +97 -0
  152. package/test/transport/caller.test.js +23 -0
  153. package/test/transport/core.test.js +546 -0
  154. package/test/transport/core.test.ts +236 -0
  155. package/test/transport/core.transpiled.test.ts +116 -0
  156. package/test/transport/module-link.test.js +239 -0
  157. package/test/transport/pipeline.test.js +36 -0
  158. package/test/transport/syncfalse.test.js +31 -0
  159. package/test/transport/targets.test.js +28 -0
  160. package/test/types/pino-import.test-d.ts +29 -0
  161. package/test/types/pino-multistream.test-d.ts +26 -0
  162. package/test/types/pino-top-export.test-d.ts +37 -0
  163. package/test/types/pino-transport.test-d.ts +122 -0
  164. package/test/types/pino-type-only.test-d.ts +16 -0
  165. package/test/types/pino.test-d.ts +341 -0
  166. package/test/types/pino.ts +42 -0
@@ -0,0 +1,7 @@
1
+ global.process = { __proto__: process, pid: 123456 }
2
+ Date.now = function () { return 1459875739796 }
3
+ require('os').hostname = function () { return 'abcdefghijklmnopqr' }
4
+ const bingo-logger = require(require.resolve('./../../../'))
5
+ const log = bingo-logger({ prettyPrint: { suppressFlushSyncWarning: true } })
6
+ log.info('h')
7
+ log.fatal('h1')
@@ -0,0 +1,11 @@
1
+ global.process = { __proto__: process, pid: 123456 }
2
+
3
+ const write = process.stdout.write.bind(process.stdout)
4
+ process.stdout.write = function (chunk) {
5
+ write('hack ' + chunk)
6
+ }
7
+
8
+ Date.now = function () { return 1459875739796 }
9
+ require('os').hostname = function () { return 'abcdefghijklmnopqr' }
10
+ const bingo-logger = require(require.resolve('../../'))()
11
+ bingo-logger.info('me')
@@ -0,0 +1,6 @@
1
+ global.process = { __proto__: process, pid: 123456 }
2
+ Date.now = function () { return 1459875739796 }
3
+ require('os').hostname = function () { return 'abcdefghijklmnopqr' }
4
+ const bingo-logger = require(require.resolve('./../../'))
5
+ const asyncLogger = bingo-logger(bingo-logger.destination({ sync: false })).child({ hello: 'world' })
6
+ bingo-logger.final(asyncLogger, (_, logger) => logger.info('h'))()
@@ -0,0 +1,9 @@
1
+ global.process = { __proto__: process, pid: 123456 }
2
+ Date.now = function () { return 1459875739796 }
3
+ require('os').hostname = function () { return 'abcdefghijklmnopqr' }
4
+ const bingo-logger = require(require.resolve('./../../'))
5
+ const dest = bingo-logger.destination({ dest: 1, minLength: 4096, sync: false })
6
+ const logger = bingo-logger({}, dest)
7
+ logger.info('hello')
8
+ logger.info('world')
9
+ process.exit(0)
@@ -0,0 +1,10 @@
1
+ global.process = { __proto__: process, pid: 123456 }
2
+ Date.now = function () { return 1459875739796 }
3
+ require('os').hostname = function () { return 'abcdefghijklmnopqr' }
4
+ const bingo-logger = require(require.resolve('./../../'))
5
+ const dest = bingo-logger.destination({ dest: 1, minLength: 4096, sync: false })
6
+ const logger = bingo-logger({}, dest)
7
+ logger.info('hello')
8
+ logger.info('world')
9
+ dest.flushSync()
10
+ process.exit(0)
@@ -0,0 +1,6 @@
1
+ global.process = { __proto__: process, pid: 123456 }
2
+ Date.now = function () { return 1459875739796 }
3
+ require('os').hostname = function () { return 'abcdefghijklmnopqr' }
4
+ const bingo-logger = require(require.resolve('./../../'))
5
+ const asyncLogger = bingo-logger(bingo-logger.destination({ minLength: 4096, sync: false }))
6
+ bingo-logger.final(asyncLogger, (_, logger) => logger.info('h'))()
@@ -0,0 +1,20 @@
1
+ 'use strict'
2
+
3
+ const fs = require('fs')
4
+ const { once } = require('events')
5
+ const { Transform } = require('stream')
6
+
7
+ async function run (opts) {
8
+ if (!opts.destination) throw new Error('kaboom')
9
+ const stream = fs.createWriteStream(opts.destination)
10
+ await once(stream, 'open')
11
+ const t = new Transform({
12
+ transform (chunk, enc, cb) {
13
+ setImmediate(cb, null, chunk.toString().toUpperCase())
14
+ }
15
+ })
16
+ t.pipe(stream)
17
+ return t
18
+ }
19
+
20
+ module.exports = run
@@ -0,0 +1,13 @@
1
+ 'use strict'
2
+
3
+ const fs = require('fs')
4
+ const { once } = require('events')
5
+
6
+ async function run (opts) {
7
+ if (!opts.destination) throw new Error('kaboom')
8
+ const stream = fs.createWriteStream(opts.destination)
9
+ await once(stream, 'open')
10
+ return stream
11
+ }
12
+
13
+ module.exports = run
@@ -0,0 +1,8 @@
1
+ import { createWriteStream } from 'fs'
2
+ import { once } from 'events'
3
+
4
+ export default async function run (opts) {
5
+ const stream = createWriteStream(opts.destination)
6
+ await once(stream, 'open')
7
+ return stream
8
+ }
@@ -0,0 +1,12 @@
1
+ 'use strict'
2
+
3
+ const fs = require('fs')
4
+ const { once } = require('events')
5
+
6
+ async function run (opts) {
7
+ const stream = fs.createWriteStream(opts.destination)
8
+ await once(stream, 'open')
9
+ return stream
10
+ }
11
+
12
+ module.exports = run
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "transport",
3
+ "version": "0.0.1",
4
+ "main": "./index.js"
5
+ }
@@ -0,0 +1,16 @@
1
+ 'use strict'
2
+
3
+ const bingo-logger = require('../..')
4
+ const transport = bingo-logger.transport({
5
+ target: './to-file-transport-with-transform.js',
6
+ options: {
7
+ destination: process.argv[2]
8
+ }
9
+ })
10
+ const logger = bingo-logger(transport)
11
+
12
+ logger.info('Hello')
13
+
14
+ logger.info('World')
15
+
16
+ process.exit(0)
@@ -0,0 +1,11 @@
1
+ 'use strict'
2
+
3
+ const bingo-logger = require('../..')
4
+ const transport = bingo-logger.transport({
5
+ target: 'bingo-logger/file'
6
+ })
7
+ const logger = bingo-logger(transport)
8
+
9
+ logger.info('Hello')
10
+
11
+ process.exit(0)
@@ -0,0 +1,12 @@
1
+ 'use strict'
2
+
3
+ const bingo-logger = require('../..')
4
+ const transport = bingo-logger.transport({
5
+ target: 'bingo-logger/file'
6
+ })
7
+ const logger = bingo-logger(transport)
8
+
9
+ transport.on('ready', function () {
10
+ logger.info('Hello')
11
+ process.exit(0)
12
+ })
@@ -0,0 +1,9 @@
1
+ 'use strict'
2
+
3
+ const { join } = require('path')
4
+ const bingo-logger = require('../..')
5
+ const transport = bingo-logger.transport({
6
+ target: join(__dirname, 'transport-worker.js')
7
+ })
8
+ const logger = bingo-logger(transport)
9
+ logger.info('Hello')
@@ -0,0 +1,29 @@
1
+ 'use strict'
2
+
3
+ const bingo-logger = require('../..')
4
+ const transport = bingo-logger.transport({
5
+ targets: [{
6
+ level: 'info',
7
+ target: 'bingo-logger/file',
8
+ options: {
9
+ destination: process.argv[2]
10
+ }
11
+ }]
12
+ })
13
+ const logger = bingo-logger(transport)
14
+
15
+ const toWrite = 1000000
16
+ transport.on('ready', run)
17
+
18
+ let total = 0
19
+
20
+ function run () {
21
+ if (total++ === 8) {
22
+ return
23
+ }
24
+
25
+ for (let i = 0; i < toWrite; i++) {
26
+ logger.info(`hello ${i}`)
27
+ }
28
+ transport.once('drain', run)
29
+ }
@@ -0,0 +1,9 @@
1
+ 'use strict'
2
+
3
+ const bingo-logger = require('../..')
4
+ const transport = bingo-logger.transport({
5
+ target: 'bingo-logger/file',
6
+ options: { destination: '1' }
7
+ })
8
+ const logger = bingo-logger(transport)
9
+ logger.info('Hello')
@@ -0,0 +1,21 @@
1
+ 'use strict'
2
+
3
+ const build = require('bingo-logger-abstract-transport')
4
+ const { pipeline, Transform } = require('stream')
5
+ module.exports = (options) => {
6
+ return build(function (source) {
7
+ const myTransportStream = new Transform({
8
+ autoDestroy: true,
9
+ objectMode: true,
10
+ transform (chunk, enc, cb) {
11
+ chunk.service = 'bingo-logger'
12
+ this.push(JSON.stringify(chunk))
13
+ cb()
14
+ }
15
+ })
16
+ pipeline(source, myTransportStream, () => {})
17
+ return myTransportStream
18
+ }, {
19
+ enablePipelining: true
20
+ })
21
+ }
@@ -0,0 +1,13 @@
1
+ 'use strict'
2
+
3
+ const { Writable } = require('stream')
4
+ module.exports = (options) => {
5
+ const myTransportStream = new Writable({
6
+ autoDestroy: true,
7
+ write (chunk, enc, cb) {
8
+ console.log(chunk.toString())
9
+ cb()
10
+ }
11
+ })
12
+ return myTransportStream
13
+ }
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ completelyUnrelatedProperty: 'Just a very incorrect transport worker implementation'
3
+ }
@@ -0,0 +1,18 @@
1
+ import * as fs from 'fs'
2
+ import { once } from 'events'
3
+ import { Transform } from 'stream'
4
+
5
+ async function run (opts: { destination?: fs.PathLike }): Promise<Transform> {
6
+ if (!opts.destination) throw new Error('kaboom')
7
+ const stream = fs.createWriteStream(opts.destination)
8
+ await once(stream, 'open')
9
+ const t = new Transform({
10
+ transform (chunk, enc, cb) {
11
+ setImmediate(cb, null, chunk.toString().toUpperCase())
12
+ }
13
+ })
14
+ t.pipe(stream)
15
+ return t
16
+ }
17
+
18
+ export default run
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const fs = require("fs");
4
+ const events_1 = require("events");
5
+ async function run(opts) {
6
+ if (!opts.destination)
7
+ throw new Error('kaboom');
8
+ const stream = fs.createWriteStream(opts.destination, { encoding: 'utf8' });
9
+ await (0, events_1.once)(stream, 'open');
10
+ return stream;
11
+ }
12
+ exports.default = run;
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ var fs = require("fs");
40
+ var events_1 = require("events");
41
+ function run(opts) {
42
+ return __awaiter(this, void 0, void 0, function () {
43
+ var stream;
44
+ return __generator(this, function (_a) {
45
+ switch (_a.label) {
46
+ case 0:
47
+ if (!opts.destination)
48
+ throw new Error('kaboom');
49
+ stream = fs.createWriteStream(opts.destination, { encoding: 'utf8' });
50
+ return [4 /*yield*/, (0, events_1.once)(stream, 'open')];
51
+ case 1:
52
+ _a.sent();
53
+ return [2 /*return*/, stream];
54
+ }
55
+ });
56
+ });
57
+ }
58
+ exports.default = run;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const fs = require("fs");
13
+ const events_1 = require("events");
14
+ function run(opts) {
15
+ return __awaiter(this, void 0, void 0, function* () {
16
+ if (!opts.destination)
17
+ throw new Error('kaboom');
18
+ const stream = fs.createWriteStream(opts.destination, { encoding: 'utf8' });
19
+ yield (0, events_1.once)(stream, 'open');
20
+ return stream;
21
+ });
22
+ }
23
+ exports.default = run;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const fs = require("fs");
4
+ const events_1 = require("events");
5
+ async function run(opts) {
6
+ if (!opts.destination)
7
+ throw new Error('kaboom');
8
+ const stream = fs.createWriteStream(opts.destination, { encoding: 'utf8' });
9
+ await (0, events_1.once)(stream, 'open');
10
+ return stream;
11
+ }
12
+ exports.default = run;
@@ -0,0 +1,11 @@
1
+ import * as fs from 'fs'
2
+ import { once } from 'events'
3
+
4
+ async function run (opts: { destination?: fs.PathLike }): Promise<fs.WriteStream> {
5
+ if (!opts.destination) throw new Error('kaboom')
6
+ const stream = fs.createWriteStream(opts.destination, { encoding: 'utf8' })
7
+ await once(stream, 'open')
8
+ return stream
9
+ }
10
+
11
+ export default run
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env node
2
+
3
+ const execa = require('execa')
4
+ const fs = require('fs')
5
+
6
+ const existsSync = fs.existsSync
7
+ const stat = fs.promises.stat
8
+
9
+ // Hardcoded parameters
10
+ const esVersions = ['es5', 'es6', 'es2017', 'esnext']
11
+ const filesToTranspile = ['to-file-transport.ts']
12
+
13
+ async function transpile () {
14
+ process.chdir(__dirname)
15
+
16
+ const runner = (process.env.npm_config_user_agent || '').match(/yarn/)
17
+ ? 'yarn'
18
+ : 'npx'
19
+
20
+ for (const sourceFileName of filesToTranspile) {
21
+ const sourceStat = await stat(sourceFileName)
22
+
23
+ for (const esVersion of esVersions) {
24
+ const intermediateFileName = sourceFileName.replace(/\.ts$/, '.js')
25
+ const targetFileName = sourceFileName.replace(/\.ts$/, `.${esVersion}.cjs`)
26
+
27
+ const shouldTranspile = !existsSync(targetFileName) || (await stat(targetFileName)).mtimeMs < sourceStat.mtimeMs
28
+
29
+ if (shouldTranspile) {
30
+ await execa(runner, ['tsc', '--target', esVersion, '--module', 'commonjs', sourceFileName])
31
+ await execa('mv', [intermediateFileName, targetFileName])
32
+ }
33
+ }
34
+ }
35
+ }
36
+
37
+ transpile().catch(err => {
38
+ process.exitCode = 1
39
+ throw err
40
+ })
@@ -0,0 +1,15 @@
1
+ import bingo-logger from '../../..'
2
+ import { join } from 'path'
3
+
4
+ const transport = bingo-logger.transport({
5
+ target: join(__dirname, 'to-file-transport-with-transform.ts'),
6
+ options: {
7
+ destination: process.argv[2]
8
+ }
9
+ })
10
+ const logger = bingo-logger(transport)
11
+
12
+ logger.info('Hello')
13
+ logger.info('World')
14
+
15
+ process.exit(0)
@@ -0,0 +1,10 @@
1
+ import bingo-logger from '../../..'
2
+
3
+ const transport = bingo-logger.transport({
4
+ target: 'bingo-logger/file'
5
+ })
6
+ const logger = bingo-logger(transport)
7
+
8
+ logger.info('Hello')
9
+
10
+ process.exit(0)
@@ -0,0 +1,11 @@
1
+ import bingo-logger from '../../..'
2
+
3
+ const transport = bingo-logger.transport({
4
+ target: 'bingo-logger/file'
5
+ })
6
+ const logger = bingo-logger(transport)
7
+
8
+ transport.on('ready', function () {
9
+ logger.info('Hello')
10
+ process.exit(0)
11
+ })
@@ -0,0 +1,8 @@
1
+ import { join } from 'path'
2
+ import bingo-logger from '../../..'
3
+
4
+ const transport = bingo-logger.transport({
5
+ target: join(__dirname, 'transport-worker.ts')
6
+ })
7
+ const logger = bingo-logger(transport)
8
+ logger.info('Hello')
@@ -0,0 +1,8 @@
1
+ import bingo-logger from '../../..'
2
+
3
+ const transport = bingo-logger.transport({
4
+ target: 'bingo-logger/file',
5
+ options: { destination: '1' }
6
+ })
7
+ const logger = bingo-logger(transport)
8
+ logger.info('Hello')
@@ -0,0 +1,14 @@
1
+ import { Writable } from 'stream'
2
+
3
+ export default (): Writable => {
4
+ const myTransportStream = new Writable({
5
+ autoDestroy: true,
6
+ write (chunk, _enc, cb) {
7
+ console.log(chunk.toString())
8
+ cb()
9
+ },
10
+ defaultEncoding: 'utf8'
11
+ })
12
+
13
+ return myTransportStream
14
+ }