@bitblit/ratchet-common 4.0.99-alpha → 4.0.103-alpha
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.
- package/{dist/types → lib}/2d/line-2d.d.ts +1 -1
- package/{dist/types → lib}/2d/poly-line-2d.d.ts +1 -1
- package/{dist/types → lib}/2d/ratchet-2d.d.ts +4 -4
- package/{dist/es → lib}/2d/ratchet-2d.js +1 -1
- package/lib/2d/ratchet-2d.spec.js +117 -0
- package/{dist/types → lib}/build/ratchet-common-info.d.ts +1 -1
- package/{dist/types → lib}/histogram/histogram.d.ts +1 -4
- package/{dist/es → lib}/histogram/histogram.js +1 -3
- package/lib/histogram/histogram.spec.js +19 -0
- package/lib/jwt/common-jwt-token.d.ts +6 -0
- package/{dist/types → lib}/jwt/jwt-ratchet-like.d.ts +3 -6
- package/{dist/types → lib}/jwt/jwt-ratchet.d.ts +4 -13
- package/{dist/es → lib}/jwt/jwt-ratchet.js +12 -7
- package/lib/jwt/jwt-ratchet.spec.js +49 -0
- package/{dist/types → lib}/jwt/jwt-token-base.d.ts +0 -4
- package/lib/lang/array-ratchet.d.ts +14 -0
- package/{dist/es → lib}/lang/array-ratchet.js +2 -2
- package/lib/lang/array-ratchet.spec.js +68 -0
- package/{dist/types → lib}/lang/base64-ratchet.d.ts +1 -1
- package/{dist/es → lib}/lang/base64-ratchet.js +1 -1
- package/lib/lang/base64-ratchet.spec.js +28 -0
- package/{dist/es → lib}/lang/boolean-ratchet.js +1 -1
- package/lib/lang/boolean-ratchet.spec.js +81 -0
- package/{dist/types → lib}/lang/composite-last-success-provider.d.ts +1 -2
- package/{dist/es → lib}/lang/composite-last-success-provider.js +2 -0
- package/lib/lang/composite-last-success-provider.spec.js +26 -0
- package/{dist/es → lib}/lang/date-ratchet.js +5 -5
- package/lib/lang/date-ratchet.spec.js +21 -0
- package/{dist/es → lib}/lang/duration-ratchet.js +1 -1
- package/lib/lang/duration-ratchet.spec.js +39 -0
- package/lib/lang/enum-ratchet.d.ts +5 -0
- package/{dist/es → lib}/lang/enum-ratchet.js +1 -1
- package/lib/lang/enum-ratchet.spec.d.ts +5 -0
- package/lib/lang/enum-ratchet.spec.js +31 -0
- package/{dist/es → lib}/lang/error-ratchet.js +1 -1
- package/lib/lang/error-ratchet.spec.js +20 -0
- package/lib/lang/esm-ratchet.d.ts +4 -0
- package/lib/lang/esm-ratchet.js +11 -0
- package/{dist/types → lib}/lang/expiring-object.d.ts +1 -1
- package/{dist/es → lib}/lang/expiring-object.js +13 -4
- package/lib/lang/expiring-object.spec.js +51 -0
- package/{dist/es → lib}/lang/geolocation-ratchet.js +4 -4
- package/lib/lang/geolocation-ratchet.spec.d.ts +1 -0
- package/lib/lang/geolocation-ratchet.spec.js +74 -0
- package/{dist/es → lib}/lang/global-ratchet.js +3 -3
- package/lib/lang/global-ratchet.spec.d.ts +1 -0
- package/lib/lang/global-ratchet.spec.js +14 -0
- package/{dist/es → lib}/lang/key-value.js +2 -0
- package/lib/lang/last-success-provider.d.ts +3 -0
- package/lib/lang/last-success-provider.js +1 -0
- package/{dist/types → lib}/lang/map-ratchet.d.ts +1 -1
- package/{dist/es → lib}/lang/map-ratchet.js +3 -3
- package/lib/lang/map-ratchet.spec.d.ts +1 -0
- package/lib/lang/map-ratchet.spec.js +90 -0
- package/lib/lang/no.spec.d.ts +1 -0
- package/lib/lang/no.spec.js +7 -0
- package/{dist/es → lib}/lang/number-ratchet.js +3 -3
- package/lib/lang/number-ratchet.spec.d.ts +1 -0
- package/lib/lang/number-ratchet.spec.js +118 -0
- package/lib/lang/parsed-url.js +1 -0
- package/lib/lang/promise-ratchet.d.ts +18 -0
- package/{dist/es → lib}/lang/promise-ratchet.js +5 -5
- package/lib/lang/promise-ratchet.spec.d.ts +1 -0
- package/lib/lang/promise-ratchet.spec.js +74 -0
- package/{dist/es → lib}/lang/require-ratchet.js +1 -1
- package/lib/lang/require-ratchet.spec.d.ts +3 -0
- package/lib/lang/require-ratchet.spec.js +80 -0
- package/{dist/types → lib}/lang/stop-watch.d.ts +1 -1
- package/{dist/es → lib}/lang/stop-watch.js +9 -8
- package/{dist/es → lib}/lang/string-ratchet.js +2 -2
- package/lib/lang/string-ratchet.spec.d.ts +1 -0
- package/lib/lang/string-ratchet.spec.js +158 -0
- package/lib/lang/time-zone-ratchet.d.ts +19 -0
- package/{dist/es → lib}/lang/time-zone-ratchet.js +2 -1
- package/lib/lang/time-zone-ratchet.spec.d.ts +1 -0
- package/lib/lang/time-zone-ratchet.spec.js +40 -0
- package/{dist/types → lib}/lang/timeout-token.d.ts +1 -1
- package/{dist/es → lib}/lang/timeout-token.js +5 -3
- package/lib/lang/timeout-token.spec.d.ts +1 -0
- package/lib/lang/timeout-token.spec.js +9 -0
- package/{dist/types → lib}/lang/transform-ratchet.d.ts +1 -1
- package/{dist/es → lib}/lang/transform-ratchet.js +1 -1
- package/lib/lang/transform-ratchet.spec.d.ts +1 -0
- package/lib/lang/transform-ratchet.spec.js +118 -0
- package/lib/logger/classic-single-line-log-message-formatter.d.ts +6 -0
- package/{dist/types → lib}/logger/log-message-builder.d.ts +2 -2
- package/{dist/es → lib}/logger/log-message-builder.js +1 -0
- package/{dist/types → lib}/logger/log-message-formatter.d.ts +2 -2
- package/lib/logger/log-message-formatter.js +1 -0
- package/{dist/types → lib}/logger/log-message-processor.d.ts +1 -1
- package/lib/logger/log-message-processor.js +1 -0
- package/{dist/types → lib}/logger/log-message.d.ts +1 -1
- package/lib/logger/log-message.js +1 -0
- package/{dist/types → lib}/logger/log-snapshot.d.ts +1 -1
- package/lib/logger/log-snapshot.js +1 -0
- package/{dist/types → lib}/logger/logger-instance.d.ts +6 -6
- package/{dist/es → lib}/logger/logger-instance.js +15 -8
- package/{dist/types → lib}/logger/logger-meta.d.ts +1 -1
- package/lib/logger/logger-meta.js +1 -0
- package/{dist/types → lib}/logger/logger-options.d.ts +4 -4
- package/lib/logger/logger-options.js +1 -0
- package/{dist/types → lib}/logger/logger-ring-buffer.d.ts +2 -2
- package/{dist/es → lib}/logger/logger-ring-buffer.js +7 -6
- package/{dist/types → lib}/logger/logger-util.d.ts +2 -2
- package/{dist/es → lib}/logger/logger-util.js +10 -10
- package/lib/logger/logger-util.spec.d.ts +1 -0
- package/lib/logger/logger-util.spec.js +9 -0
- package/{dist/types → lib}/logger/logger.d.ts +7 -16
- package/{dist/es → lib}/logger/logger.js +14 -14
- package/lib/logger/logger.spec.d.ts +1 -0
- package/lib/logger/logger.spec.js +134 -0
- package/lib/logger/none-log-message-formatter.d.ts +6 -0
- package/lib/logger/structured-json-log-message-formatter.d.ts +6 -0
- package/{dist/types → lib}/network/browser-local-ip-provider.d.ts +1 -1
- package/{dist/es → lib}/network/browser-local-ip-provider.js +3 -3
- package/lib/network/browser-local-ip-provider.spec.d.ts +1 -0
- package/lib/network/browser-local-ip-provider.spec.js +16 -0
- package/{dist/types → lib}/network/fixed-local-ip-provider.d.ts +1 -1
- package/{dist/es → lib}/network/fixed-local-ip-provider.js +1 -0
- package/lib/network/local-ip-provider.d.ts +3 -0
- package/lib/network/local-ip-provider.js +1 -0
- package/{dist/types → lib}/network/network-ratchet.d.ts +1 -1
- package/{dist/es → lib}/network/network-ratchet.js +2 -2
- package/lib/network/network-ratchet.spec.d.ts +1 -0
- package/lib/network/network-ratchet.spec.js +13 -0
- package/{dist/types → lib}/stream/buffer-writable.d.ts +2 -2
- package/{dist/es → lib}/stream/buffer-writable.js +1 -1
- package/lib/stream/multi-stream.d.ts +7 -0
- package/lib/stream/multi-stream.js +12 -0
- package/{dist/types → lib}/stream/stream-ratchet.d.ts +2 -2
- package/{dist/es → lib}/stream/stream-ratchet.js +2 -2
- package/lib/stream/stream-ratchet.spec.d.ts +1 -0
- package/lib/stream/stream-ratchet.spec.js +13 -0
- package/{dist/types → lib}/stream/string-writable.d.ts +1 -1
- package/{dist/es → lib}/stream/string-writable.js +1 -1
- package/lib/stream/string-writable.spec.d.ts +1 -0
- package/lib/stream/string-writable.spec.js +12 -0
- package/{dist/es → lib}/third-party/google/google-recaptcha-ratchet.js +3 -3
- package/lib/third-party/google/google-recaptcha-ratchet.spec.d.ts +1 -0
- package/lib/third-party/google/google-recaptcha-ratchet.spec.js +20 -0
- package/{dist/types → lib}/third-party/twilio/twilio-ratchet.d.ts +0 -4
- package/{dist/es → lib}/third-party/twilio/twilio-ratchet.js +8 -5
- package/{dist/types → lib}/transform/built-in-transforms.d.ts +1 -1
- package/{dist/es → lib}/transform/built-in-transforms.js +2 -2
- package/lib/transform/transform-rule.js +1 -0
- package/{dist/types → lib}/tx/transaction-configuration.d.ts +2 -2
- package/lib/tx/transaction-configuration.js +1 -0
- package/{dist/types → lib}/tx/transaction-ratchet.d.ts +3 -3
- package/{dist/es → lib}/tx/transaction-ratchet.js +4 -4
- package/lib/tx/transaction-ratchet.spec.d.ts +1 -0
- package/lib/tx/transaction-ratchet.spec.js +130 -0
- package/{dist/types → lib}/tx/transaction-result.d.ts +1 -1
- package/lib/tx/transaction-result.js +1 -0
- package/lib/tx/transaction-step.js +1 -0
- package/package.json +11 -12
- package/dist/cjs/2d/line-2d.js +0 -2
- package/dist/cjs/2d/plane-2d.js +0 -2
- package/dist/cjs/2d/point-2d.js +0 -2
- package/dist/cjs/2d/poly-line-2d.js +0 -2
- package/dist/cjs/2d/ratchet-2d.js +0 -250
- package/dist/cjs/build/build-information.js +0 -2
- package/dist/cjs/build/ratchet-common-info.js +0 -18
- package/dist/cjs/histogram/histogram-entry.js +0 -2
- package/dist/cjs/histogram/histogram.js +0 -54
- package/dist/cjs/index.js +0 -74
- package/dist/cjs/jwt/common-jwt-token.js +0 -2
- package/dist/cjs/jwt/expired-jwt-handling.js +0 -9
- package/dist/cjs/jwt/jwt-ratchet-like.js +0 -2
- package/dist/cjs/jwt/jwt-ratchet.js +0 -164
- package/dist/cjs/jwt/jwt-token-base.js +0 -2
- package/dist/cjs/lang/array-ratchet.js +0 -87
- package/dist/cjs/lang/base64-ratchet.js +0 -49
- package/dist/cjs/lang/boolean-ratchet.js +0 -49
- package/dist/cjs/lang/composite-last-success-provider.js +0 -28
- package/dist/cjs/lang/date-ratchet.js +0 -33
- package/dist/cjs/lang/duration-ratchet.js +0 -46
- package/dist/cjs/lang/enum-ratchet.js +0 -34
- package/dist/cjs/lang/error-ratchet.js +0 -49
- package/dist/cjs/lang/expiring-object.js +0 -68
- package/dist/cjs/lang/geolocation-ratchet.js +0 -267
- package/dist/cjs/lang/global-ratchet.js +0 -48
- package/dist/cjs/lang/key-value.js +0 -6
- package/dist/cjs/lang/last-success-provider.js +0 -2
- package/dist/cjs/lang/map-ratchet.js +0 -168
- package/dist/cjs/lang/no.js +0 -8
- package/dist/cjs/lang/number-ratchet.js +0 -159
- package/dist/cjs/lang/parsed-url.js +0 -2
- package/dist/cjs/lang/promise-ratchet.js +0 -142
- package/dist/cjs/lang/require-ratchet.js +0 -60
- package/dist/cjs/lang/stop-watch.js +0 -117
- package/dist/cjs/lang/string-ratchet.js +0 -195
- package/dist/cjs/lang/time-zone-ratchet.js +0 -80
- package/dist/cjs/lang/timeout-token.js +0 -19
- package/dist/cjs/lang/transform-ratchet.js +0 -70
- package/dist/cjs/logger/classic-single-line-log-message-formatter.js +0 -18
- package/dist/cjs/logger/log-message-builder.js +0 -51
- package/dist/cjs/logger/log-message-format-type.js +0 -9
- package/dist/cjs/logger/log-message-formatter.js +0 -2
- package/dist/cjs/logger/log-message-processor.js +0 -2
- package/dist/cjs/logger/log-message.js +0 -2
- package/dist/cjs/logger/log-snapshot.js +0 -2
- package/dist/cjs/logger/logger-instance.js +0 -207
- package/dist/cjs/logger/logger-level-name.js +0 -12
- package/dist/cjs/logger/logger-meta.js +0 -2
- package/dist/cjs/logger/logger-options.js +0 -2
- package/dist/cjs/logger/logger-output-function.js +0 -9
- package/dist/cjs/logger/logger-ring-buffer.js +0 -76
- package/dist/cjs/logger/logger-util.js +0 -49
- package/dist/cjs/logger/logger.js +0 -139
- package/dist/cjs/logger/none-log-message-formatter.js +0 -9
- package/dist/cjs/logger/structured-json-log-message-formatter.js +0 -24
- package/dist/cjs/network/browser-local-ip-provider.js +0 -25
- package/dist/cjs/network/fixed-local-ip-provider.js +0 -12
- package/dist/cjs/network/local-ip-provider.js +0 -2
- package/dist/cjs/network/network-ratchet.js +0 -106
- package/dist/cjs/stream/buffer-writable.js +0 -20
- package/dist/cjs/stream/stream-ratchet.js +0 -72
- package/dist/cjs/stream/string-writable.js +0 -18
- package/dist/cjs/third-party/google/google-recaptcha-ratchet.js +0 -33
- package/dist/cjs/third-party/twilio/twilio-ratchet.js +0 -75
- package/dist/cjs/transform/built-in-transforms.js +0 -195
- package/dist/cjs/transform/transform-rule.js +0 -2
- package/dist/cjs/tx/transaction-configuration.js +0 -2
- package/dist/cjs/tx/transaction-final-state.js +0 -9
- package/dist/cjs/tx/transaction-ratchet.js +0 -80
- package/dist/cjs/tx/transaction-result.js +0 -2
- package/dist/cjs/tx/transaction-step.js +0 -2
- package/dist/es/index.js +0 -71
- package/dist/tsconfig.cjs.tsbuildinfo +0 -1
- package/dist/tsconfig.es.tsbuildinfo +0 -1
- package/dist/tsconfig.types.tsbuildinfo +0 -1
- package/dist/types/index.d.ts +0 -74
- package/dist/types/jwt/common-jwt-token.d.ts +0 -17
- package/dist/types/lang/array-ratchet.d.ts +0 -30
- package/dist/types/lang/enum-ratchet.d.ts +0 -12
- package/dist/types/lang/last-success-provider.d.ts +0 -4
- package/dist/types/lang/promise-ratchet.d.ts +0 -32
- package/dist/types/lang/time-zone-ratchet.d.ts +0 -50
- package/dist/types/logger/classic-single-line-log-message-formatter.d.ts +0 -6
- package/dist/types/logger/none-log-message-formatter.d.ts +0 -6
- package/dist/types/logger/structured-json-log-message-formatter.d.ts +0 -6
- package/dist/types/network/local-ip-provider.d.ts +0 -4
- /package/{dist/es → lib}/2d/line-2d.js +0 -0
- /package/{dist/types → lib}/2d/plane-2d.d.ts +0 -0
- /package/{dist/es → lib}/2d/plane-2d.js +0 -0
- /package/{dist/types → lib}/2d/point-2d.d.ts +0 -0
- /package/{dist/es → lib}/2d/point-2d.js +0 -0
- /package/{dist/es → lib}/2d/poly-line-2d.js +0 -0
- /package/{dist/es/build/build-information.js → lib/2d/ratchet-2d.spec.d.ts} +0 -0
- /package/{dist/types → lib}/build/build-information.d.ts +0 -0
- /package/{dist/es/histogram/histogram-entry.js → lib/build/build-information.js} +0 -0
- /package/{dist/es → lib}/build/ratchet-common-info.js +0 -0
- /package/{dist/types → lib}/histogram/histogram-entry.d.ts +0 -0
- /package/{dist/es/jwt/common-jwt-token.js → lib/histogram/histogram-entry.js} +0 -0
- /package/{dist/es/jwt/jwt-ratchet-like.js → lib/histogram/histogram.spec.d.ts} +0 -0
- /package/{dist/es/jwt/jwt-token-base.js → lib/index.d.ts} +0 -0
- /package/{dist/es/lang/last-success-provider.js → lib/index.js} +0 -0
- /package/{dist/es/lang/parsed-url.js → lib/jwt/common-jwt-token.js} +0 -0
- /package/{dist/types → lib}/jwt/expired-jwt-handling.d.ts +0 -0
- /package/{dist/es → lib}/jwt/expired-jwt-handling.js +0 -0
- /package/{dist/es/logger/log-message-formatter.js → lib/jwt/jwt-ratchet-like.js} +0 -0
- /package/{dist/es/logger/log-message-processor.js → lib/jwt/jwt-ratchet.spec.d.ts} +0 -0
- /package/{dist/es/logger/log-message.js → lib/jwt/jwt-token-base.js} +0 -0
- /package/{dist/es/logger/log-snapshot.js → lib/lang/array-ratchet.spec.d.ts} +0 -0
- /package/{dist/es/logger/logger-meta.js → lib/lang/base64-ratchet.spec.d.ts} +0 -0
- /package/{dist/types → lib}/lang/boolean-ratchet.d.ts +0 -0
- /package/{dist/es/logger/logger-options.js → lib/lang/boolean-ratchet.spec.d.ts} +0 -0
- /package/{dist/es/network/local-ip-provider.js → lib/lang/composite-last-success-provider.spec.d.ts} +0 -0
- /package/{dist/types → lib}/lang/date-ratchet.d.ts +0 -0
- /package/{dist/es/transform/transform-rule.js → lib/lang/date-ratchet.spec.d.ts} +0 -0
- /package/{dist/types → lib}/lang/duration-ratchet.d.ts +0 -0
- /package/{dist/es/tx/transaction-configuration.js → lib/lang/duration-ratchet.spec.d.ts} +0 -0
- /package/{dist/types → lib}/lang/error-ratchet.d.ts +0 -0
- /package/{dist/es/tx/transaction-result.js → lib/lang/error-ratchet.spec.d.ts} +0 -0
- /package/{dist/es/tx/transaction-step.js → lib/lang/expiring-object.spec.d.ts} +0 -0
- /package/{dist/types → lib}/lang/geolocation-ratchet.d.ts +0 -0
- /package/{dist/types → lib}/lang/global-ratchet.d.ts +0 -0
- /package/{dist/types → lib}/lang/key-value.d.ts +0 -0
- /package/{dist/types → lib}/lang/no.d.ts +0 -0
- /package/{dist/es → lib}/lang/no.js +0 -0
- /package/{dist/types → lib}/lang/number-ratchet.d.ts +0 -0
- /package/{dist/types → lib}/lang/parsed-url.d.ts +0 -0
- /package/{dist/types → lib}/lang/require-ratchet.d.ts +0 -0
- /package/{dist/types → lib}/lang/string-ratchet.d.ts +0 -0
- /package/{dist/es → lib}/logger/classic-single-line-log-message-formatter.js +0 -0
- /package/{dist/types → lib}/logger/log-message-format-type.d.ts +0 -0
- /package/{dist/es → lib}/logger/log-message-format-type.js +0 -0
- /package/{dist/types → lib}/logger/logger-level-name.d.ts +0 -0
- /package/{dist/es → lib}/logger/logger-level-name.js +0 -0
- /package/{dist/types → lib}/logger/logger-output-function.d.ts +0 -0
- /package/{dist/es → lib}/logger/logger-output-function.js +0 -0
- /package/{dist/es → lib}/logger/none-log-message-formatter.js +0 -0
- /package/{dist/es → lib}/logger/structured-json-log-message-formatter.js +0 -0
- /package/{dist/types → lib}/third-party/google/google-recaptcha-ratchet.d.ts +0 -0
- /package/{dist/types → lib}/transform/transform-rule.d.ts +0 -0
- /package/{dist/types → lib}/tx/transaction-final-state.d.ts +0 -0
- /package/{dist/es → lib}/tx/transaction-final-state.js +0 -0
- /package/{dist/types → lib}/tx/transaction-step.d.ts +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { LogMessage } from './log-message';
|
|
2
|
-
import { LoggerMeta } from './logger-meta';
|
|
1
|
+
import { LogMessage } from './log-message.js';
|
|
2
|
+
import { LoggerMeta } from './logger-meta.js';
|
|
3
3
|
export interface LogMessageFormatter {
|
|
4
4
|
formatMessage(msg: LogMessage, meta: LoggerMeta): string;
|
|
5
5
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { LogMessage } from './log-message';
|
|
2
|
-
import { LoggerOptions } from './logger-options';
|
|
3
|
-
import { LoggerRingBuffer } from './logger-ring-buffer';
|
|
4
|
-
import { LoggerLevelName } from './logger-level-name';
|
|
5
|
-
import { LogMessageBuilder } from './log-message-builder';
|
|
6
|
-
import { LogMessageProcessor } from './log-message-processor';
|
|
1
|
+
import { LogMessage } from './log-message.js';
|
|
2
|
+
import { LoggerOptions } from './logger-options.js';
|
|
3
|
+
import { LoggerRingBuffer } from './logger-ring-buffer.js';
|
|
4
|
+
import { LoggerLevelName } from './logger-level-name.js';
|
|
5
|
+
import { LogMessageBuilder } from './log-message-builder.js';
|
|
6
|
+
import { LogMessageProcessor } from './log-message-processor.js';
|
|
7
7
|
export declare class LoggerInstance {
|
|
8
8
|
private loggerInstanceName;
|
|
9
9
|
private _loggerMeta;
|
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
import { LoggerRingBuffer } from './logger-ring-buffer';
|
|
2
|
-
import { LoggerLevelName } from './logger-level-name';
|
|
3
|
-
import { LoggerUtil } from './logger-util';
|
|
4
|
-
import { LogMessageFormatType } from './log-message-format-type';
|
|
5
|
-
import { ClassicSingleLineLogMessageFormatter } from './classic-single-line-log-message-formatter';
|
|
6
|
-
import { NoneLogMessageFormatter } from './none-log-message-formatter';
|
|
7
|
-
import { StructuredJsonLogMessageFormatter } from './structured-json-log-message-formatter';
|
|
8
|
-
import { StringRatchet } from '../lang/string-ratchet';
|
|
1
|
+
import { LoggerRingBuffer } from './logger-ring-buffer.js';
|
|
2
|
+
import { LoggerLevelName } from './logger-level-name.js';
|
|
3
|
+
import { LoggerUtil } from './logger-util.js';
|
|
4
|
+
import { LogMessageFormatType } from './log-message-format-type.js';
|
|
5
|
+
import { ClassicSingleLineLogMessageFormatter } from './classic-single-line-log-message-formatter.js';
|
|
6
|
+
import { NoneLogMessageFormatter } from './none-log-message-formatter.js';
|
|
7
|
+
import { StructuredJsonLogMessageFormatter } from './structured-json-log-message-formatter.js';
|
|
8
|
+
import { StringRatchet } from '../lang/string-ratchet.js';
|
|
9
9
|
export class LoggerInstance {
|
|
10
|
+
loggerInstanceName;
|
|
11
|
+
_loggerMeta;
|
|
12
|
+
_ringBuffer;
|
|
13
|
+
_formatter;
|
|
14
|
+
_level;
|
|
15
|
+
_handlerFunctionMap;
|
|
16
|
+
_options;
|
|
10
17
|
constructor(loggerInstanceName = 'default', inOptions) {
|
|
11
18
|
this.loggerInstanceName = loggerInstanceName;
|
|
12
19
|
this.options = inOptions;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { LogMessageFormatType } from './log-message-format-type';
|
|
2
|
-
import { LoggerLevelName } from './logger-level-name';
|
|
3
|
-
import { LogMessageProcessor } from './log-message-processor';
|
|
4
|
-
import { LoggerOutputFunction } from './logger-output-function';
|
|
1
|
+
import { LogMessageFormatType } from './log-message-format-type.js';
|
|
2
|
+
import { LoggerLevelName } from './logger-level-name.js';
|
|
3
|
+
import { LogMessageProcessor } from './log-message-processor.js';
|
|
4
|
+
import { LoggerOutputFunction } from './logger-output-function.js';
|
|
5
5
|
export interface LoggerOptions {
|
|
6
6
|
initialLevel?: LoggerLevelName;
|
|
7
7
|
formatType?: LogMessageFormatType;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { LogMessage } from './log-message';
|
|
2
|
-
import { LogSnapshot } from './log-snapshot';
|
|
1
|
+
import { LogMessage } from './log-message.js';
|
|
2
|
+
import { LogSnapshot } from './log-snapshot.js';
|
|
3
3
|
export declare class LoggerRingBuffer {
|
|
4
4
|
private _lastLogMessage;
|
|
5
5
|
private _buffer;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { Logger } from './logger';
|
|
2
|
-
import { LoggerLevelName } from './logger-level-name';
|
|
1
|
+
import { Logger } from './logger.js';
|
|
2
|
+
import { LoggerLevelName } from './logger-level-name.js';
|
|
3
3
|
export class LoggerRingBuffer {
|
|
4
|
+
_lastLogMessage = { messageSource: 'No message yet', timestamp: new Date().getTime(), lvl: LoggerLevelName.info };
|
|
5
|
+
_buffer = [];
|
|
6
|
+
_bufferIdx = 0;
|
|
7
|
+
_lastSnapshotIdx = 0;
|
|
8
|
+
_bufferSize;
|
|
4
9
|
constructor(size) {
|
|
5
|
-
this._lastLogMessage = { messageSource: 'No message yet', timestamp: new Date().getTime(), lvl: LoggerLevelName.info };
|
|
6
|
-
this._buffer = [];
|
|
7
|
-
this._bufferIdx = 0;
|
|
8
|
-
this._lastSnapshotIdx = 0;
|
|
9
10
|
if (!size) {
|
|
10
11
|
throw new Error('Cannot create ring buffer of size 0');
|
|
11
12
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { LoggerLevelName } from './logger-level-name';
|
|
2
|
-
import { LoggerOutputFunction } from './logger-output-function';
|
|
1
|
+
import { LoggerLevelName } from './logger-level-name.js';
|
|
2
|
+
import { LoggerOutputFunction } from './logger-output-function.js';
|
|
3
3
|
export declare class LoggerUtil {
|
|
4
4
|
private static LOG_LEVELS_IN_ORDER;
|
|
5
5
|
static handlerFunctionMap(outputFn?: LoggerOutputFunction): Map<LoggerLevelName, (...any: any[]) => void>;
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
import { LoggerLevelName } from './logger-level-name';
|
|
2
|
-
import { LoggerOutputFunction } from './logger-output-function';
|
|
1
|
+
import { LoggerLevelName } from './logger-level-name.js';
|
|
2
|
+
import { LoggerOutputFunction } from './logger-output-function.js';
|
|
3
3
|
export class LoggerUtil {
|
|
4
|
+
static LOG_LEVELS_IN_ORDER = [
|
|
5
|
+
LoggerLevelName.error,
|
|
6
|
+
LoggerLevelName.warn,
|
|
7
|
+
LoggerLevelName.info,
|
|
8
|
+
LoggerLevelName.verbose,
|
|
9
|
+
LoggerLevelName.debug,
|
|
10
|
+
LoggerLevelName.silly,
|
|
11
|
+
];
|
|
4
12
|
static handlerFunctionMap(outputFn = LoggerOutputFunction.Console) {
|
|
5
13
|
const output = new Map();
|
|
6
14
|
if (outputFn === LoggerOutputFunction.StdOut) {
|
|
@@ -34,11 +42,3 @@ export class LoggerUtil {
|
|
|
34
42
|
return idxTarget > -1 && lvl > -1 && lvl >= idxTarget;
|
|
35
43
|
}
|
|
36
44
|
}
|
|
37
|
-
LoggerUtil.LOG_LEVELS_IN_ORDER = [
|
|
38
|
-
LoggerLevelName.error,
|
|
39
|
-
LoggerLevelName.warn,
|
|
40
|
-
LoggerLevelName.info,
|
|
41
|
-
LoggerLevelName.verbose,
|
|
42
|
-
LoggerLevelName.debug,
|
|
43
|
-
LoggerLevelName.silly,
|
|
44
|
-
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { LoggerUtil } from './logger-util.js';
|
|
2
|
+
import { LoggerLevelName } from './logger-level-name.js';
|
|
3
|
+
describe('#checkLevel', function () {
|
|
4
|
+
it('should check that level logging works', function () {
|
|
5
|
+
expect(LoggerUtil.levelIsEnabled(LoggerLevelName.info, LoggerLevelName.warn)).toEqual(false);
|
|
6
|
+
expect(LoggerUtil.levelIsEnabled(LoggerLevelName.warn, LoggerLevelName.info)).toEqual(true);
|
|
7
|
+
expect(LoggerUtil.levelIsEnabled(LoggerLevelName.warn, LoggerLevelName.warn)).toEqual(true);
|
|
8
|
+
});
|
|
9
|
+
});
|
|
@@ -1,19 +1,10 @@
|
|
|
1
|
-
import { LogMessage } from './log-message';
|
|
2
|
-
import { LogSnapshot } from './log-snapshot';
|
|
3
|
-
import { LoggerOptions } from './logger-options';
|
|
4
|
-
import { LoggerInstance } from './logger-instance';
|
|
5
|
-
import { LoggerLevelName } from './logger-level-name';
|
|
6
|
-
import { LoggerRingBuffer } from './logger-ring-buffer';
|
|
7
|
-
import { LogMessageBuilder } from './log-message-builder';
|
|
8
|
-
/**
|
|
9
|
-
* Class to simplify logging across both browsers and node (especially lambda)
|
|
10
|
-
*
|
|
11
|
-
* Important note : This class is here to make logging SIMPLE - mainly it is focused on simplicity,
|
|
12
|
-
* and single point of enable/disable logging. Output goes to console, since thats the only thing
|
|
13
|
-
* that is present in both the browser and node. If you need to do something more complicated (like
|
|
14
|
-
* logging to files, multiple transports, etc) you really should just use something heavier like
|
|
15
|
-
* Winston directly and skip this class entirely
|
|
16
|
-
*/
|
|
1
|
+
import { LogMessage } from './log-message.js';
|
|
2
|
+
import { LogSnapshot } from './log-snapshot.js';
|
|
3
|
+
import { LoggerOptions } from './logger-options.js';
|
|
4
|
+
import { LoggerInstance } from './logger-instance.js';
|
|
5
|
+
import { LoggerLevelName } from './logger-level-name.js';
|
|
6
|
+
import { LoggerRingBuffer } from './logger-ring-buffer.js';
|
|
7
|
+
import { LogMessageBuilder } from './log-message-builder.js';
|
|
17
8
|
export declare class Logger {
|
|
18
9
|
private static LOGGER_INSTANCES;
|
|
19
10
|
private static DEFAULT_OPTIONS;
|
|
@@ -1,8 +1,18 @@
|
|
|
1
|
-
import { LoggerInstance } from './logger-instance';
|
|
2
|
-
import { LogMessageFormatType } from './log-message-format-type';
|
|
3
|
-
import { LoggerLevelName } from './logger-level-name';
|
|
4
|
-
import { LoggerOutputFunction } from './logger-output-function';
|
|
1
|
+
import { LoggerInstance } from './logger-instance.js';
|
|
2
|
+
import { LogMessageFormatType } from './log-message-format-type.js';
|
|
3
|
+
import { LoggerLevelName } from './logger-level-name.js';
|
|
4
|
+
import { LoggerOutputFunction } from './logger-output-function.js';
|
|
5
5
|
export class Logger {
|
|
6
|
+
static LOGGER_INSTANCES = new Map();
|
|
7
|
+
static DEFAULT_OPTIONS = {
|
|
8
|
+
initialLevel: LoggerLevelName.info,
|
|
9
|
+
formatType: LogMessageFormatType.ClassicSingleLine,
|
|
10
|
+
trace: null,
|
|
11
|
+
globalVars: {},
|
|
12
|
+
outputFunction: LoggerOutputFunction.Console,
|
|
13
|
+
ringBufferSize: 0,
|
|
14
|
+
preProcessors: [],
|
|
15
|
+
};
|
|
6
16
|
static applyDefaultsToOptions(input) {
|
|
7
17
|
const rval = input || {};
|
|
8
18
|
rval.initialLevel = rval.initialLevel ?? Logger.DEFAULT_OPTIONS.initialLevel;
|
|
@@ -122,13 +132,3 @@ export class Logger {
|
|
|
122
132
|
return buf ? buf.getLastLogMessage() : null;
|
|
123
133
|
}
|
|
124
134
|
}
|
|
125
|
-
Logger.LOGGER_INSTANCES = new Map();
|
|
126
|
-
Logger.DEFAULT_OPTIONS = {
|
|
127
|
-
initialLevel: LoggerLevelName.info,
|
|
128
|
-
formatType: LogMessageFormatType.ClassicSingleLine,
|
|
129
|
-
trace: null,
|
|
130
|
-
globalVars: {},
|
|
131
|
-
outputFunction: LoggerOutputFunction.Console,
|
|
132
|
-
ringBufferSize: 0,
|
|
133
|
-
preProcessors: [],
|
|
134
|
-
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { Logger } from './logger.js';
|
|
2
|
+
import { LoggerLevelName } from './logger-level-name.js';
|
|
3
|
+
import { StringRatchet } from '../lang/string-ratchet.js';
|
|
4
|
+
import { LogMessageBuilder } from './log-message-builder.js';
|
|
5
|
+
import { LogMessageFormatType } from './log-message-format-type.js';
|
|
6
|
+
import { LoggerOutputFunction } from './logger-output-function.js';
|
|
7
|
+
describe('#setLevel', function () {
|
|
8
|
+
it('should change the level to debug then info then debug', function () {
|
|
9
|
+
Logger.dumpConfigurationIntoLog();
|
|
10
|
+
expect(Logger.getLevel()).toEqual(LoggerLevelName.info);
|
|
11
|
+
Logger.setLevel(LoggerLevelName.debug);
|
|
12
|
+
expect(Logger.getLevel()).toEqual(LoggerLevelName.debug);
|
|
13
|
+
Logger.setLevel(LoggerLevelName.info);
|
|
14
|
+
expect(Logger.getLevel()).toEqual(LoggerLevelName.info);
|
|
15
|
+
Logger.setLevel(LoggerLevelName.debug);
|
|
16
|
+
expect(Logger.getLevel()).toEqual(LoggerLevelName.debug);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
describe('#takeSnapshot', function () {
|
|
20
|
+
it('should advance the pointer correctly after a snapshot', function () {
|
|
21
|
+
Logger.changeRingBufferSize(5);
|
|
22
|
+
expect(Logger.getRingBuffer().currentIndex).toEqual(0);
|
|
23
|
+
Logger.info('m1');
|
|
24
|
+
Logger.info('m2');
|
|
25
|
+
Logger.info('m3');
|
|
26
|
+
const snap1 = Logger.takeSnapshot();
|
|
27
|
+
Logger.info('m4');
|
|
28
|
+
Logger.info('m5');
|
|
29
|
+
const snap2 = Logger.takeSnapshot();
|
|
30
|
+
Logger.info('m6');
|
|
31
|
+
Logger.info('m7');
|
|
32
|
+
Logger.info('m8');
|
|
33
|
+
const snap3 = Logger.takeSnapshot();
|
|
34
|
+
expect(snap1.messages.length).toEqual(3);
|
|
35
|
+
expect(snap2.messages.length).toEqual(2);
|
|
36
|
+
expect(snap3.messages.length).toEqual(3);
|
|
37
|
+
expect(Logger.getRingBuffer().currentIndex).toEqual(8);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
describe('#testTracePrefix', function () {
|
|
41
|
+
it('should apply a trace prefix correctly', function () {
|
|
42
|
+
Logger.updateTracePrefix('::TRACE::');
|
|
43
|
+
Logger.changeRingBufferSize(3);
|
|
44
|
+
Logger.info('m1');
|
|
45
|
+
Logger.info('m2');
|
|
46
|
+
const snap1 = Logger.takeSnapshot();
|
|
47
|
+
const snap1String = Logger.formatMessages(snap1.messages);
|
|
48
|
+
expect(snap1String.length).toBeGreaterThan(0);
|
|
49
|
+
snap1String.forEach((m) => {
|
|
50
|
+
expect(m.indexOf('::TRACE::')).toBeGreaterThan(-1);
|
|
51
|
+
});
|
|
52
|
+
Logger.updateTracePrefix(null);
|
|
53
|
+
Logger.info('m1');
|
|
54
|
+
Logger.info('m2');
|
|
55
|
+
const snap2 = Logger.takeSnapshot();
|
|
56
|
+
expect(snap2.messages.length).toBeGreaterThan(0);
|
|
57
|
+
snap2.messages.forEach((m) => {
|
|
58
|
+
expect(m.messageSource.indexOf('::TRACE::')).toEqual(-1);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
describe('#testLastMessage', function () {
|
|
63
|
+
it('should return the last message', function () {
|
|
64
|
+
Logger.info('m1');
|
|
65
|
+
Logger.info('m2');
|
|
66
|
+
const last = Logger.getLastLogMessage();
|
|
67
|
+
expect(last).toBeTruthy();
|
|
68
|
+
expect(last.lvl).toEqual(LoggerLevelName.info);
|
|
69
|
+
expect(last.messageSource.endsWith('m2')).toBeTruthy();
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
describe('#testPassThruFunctions', function () {
|
|
73
|
+
it('should pass through values', function () {
|
|
74
|
+
Logger.setLevel(LoggerLevelName.debug);
|
|
75
|
+
Logger.error('Test %s', 'tVal');
|
|
76
|
+
Logger.errorP('TestP %s', 'tVal');
|
|
77
|
+
Logger.errorP('TestP 2', 27, { some: 'Object' });
|
|
78
|
+
Logger.warn('Test %s', 'tVal');
|
|
79
|
+
Logger.warnP('TestP %s', 'tVal');
|
|
80
|
+
Logger.info('Test %s', 'tVal');
|
|
81
|
+
Logger.infoP('TestP %s', 'tVal');
|
|
82
|
+
Logger.debug('Test %s', 'tVal');
|
|
83
|
+
Logger.debugP('TestP %s', 'tVal');
|
|
84
|
+
Logger.verbose('Test %s', 'tVal');
|
|
85
|
+
Logger.verboseP('TestP %s', 'tVal');
|
|
86
|
+
Logger.silly('Test %s', 'tVal');
|
|
87
|
+
Logger.sillyP('TestP %s', 'tVal');
|
|
88
|
+
Logger.setLevel(LoggerLevelName.debug);
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
describe('#testFormatter', function () {
|
|
92
|
+
it('should format values', function () {
|
|
93
|
+
const msg = {
|
|
94
|
+
lvl: LoggerLevelName.info,
|
|
95
|
+
timestamp: Date.now(),
|
|
96
|
+
messageSource: 'Test %d %d',
|
|
97
|
+
subsVars: [1, 2],
|
|
98
|
+
params: {},
|
|
99
|
+
};
|
|
100
|
+
Logger.info('Test %d %d', 3, 4);
|
|
101
|
+
const msgS = Logger.formatMessages([msg])[0];
|
|
102
|
+
expect(msgS).toEqual('[info] Test 1 2');
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
describe('#testPreProcessor', function () {
|
|
106
|
+
it('should perform a preprocess', function () {
|
|
107
|
+
const preProc = {
|
|
108
|
+
process(msg) {
|
|
109
|
+
msg.messageSource = 'Preprocess';
|
|
110
|
+
return msg;
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
const output = Logger.getLogger(StringRatchet.createRandomHexString(4), { preProcessors: [preProc] }).info('This is a test %s', 'bob');
|
|
114
|
+
expect(output).toEqual('[info] Preprocess bob');
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
describe('#testBuilder', function () {
|
|
118
|
+
it('should use a builder', function () {
|
|
119
|
+
const output = Logger.getLogger(StringRatchet.createRandomHexString(4)).recordMessageBuilder(new LogMessageBuilder(LoggerLevelName.warn, 'This is a test %s').subVars(['bob']));
|
|
120
|
+
expect(output).toEqual('[warn] This is a test bob');
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
describe('#testStructured', function () {
|
|
124
|
+
it('should use a structured logger', function () {
|
|
125
|
+
const output = Logger.getLogger(StringRatchet.createRandomHexString(4), {
|
|
126
|
+
formatType: LogMessageFormatType.StructuredJson,
|
|
127
|
+
outputFunction: LoggerOutputFunction.StdOut,
|
|
128
|
+
}).recordMessageBuilder(new LogMessageBuilder(LoggerLevelName.warn, 'This is a test %s').subVars(['bob']).p('a', 27));
|
|
129
|
+
const parsed = JSON.parse(output);
|
|
130
|
+
expect(parsed.msg).toEqual('This is a test bob');
|
|
131
|
+
expect(parsed.logLevel).toEqual('warn');
|
|
132
|
+
expect(parsed.a).toEqual(27);
|
|
133
|
+
});
|
|
134
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { LogMessage } from './log-message.js';
|
|
2
|
+
import { LogMessageFormatter } from './log-message-formatter.js';
|
|
3
|
+
import { LoggerMeta } from './logger-meta.js';
|
|
4
|
+
export declare class NoneLogMessageFormatter implements LogMessageFormatter {
|
|
5
|
+
formatMessage(msg: LogMessage, meta: LoggerMeta): string;
|
|
6
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { LogMessage } from './log-message.js';
|
|
2
|
+
import { LogMessageFormatter } from './log-message-formatter.js';
|
|
3
|
+
import { LoggerMeta } from './logger-meta.js';
|
|
4
|
+
export declare class StructuredJsonLogMessageFormatter implements LogMessageFormatter {
|
|
5
|
+
formatMessage(msg: LogMessage, meta: LoggerMeta): string;
|
|
6
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { NetworkRatchet } from './network-ratchet';
|
|
2
|
-
import { Logger } from '../logger/logger';
|
|
1
|
+
import { NetworkRatchet } from './network-ratchet.js';
|
|
2
|
+
import { Logger } from '../logger/logger.js';
|
|
3
3
|
export class BrowserLocalIpProvider {
|
|
4
|
+
currentIp = 'UNSET';
|
|
4
5
|
constructor() {
|
|
5
|
-
this.currentIp = 'UNSET';
|
|
6
6
|
NetworkRatchet.findLocalIp(false)
|
|
7
7
|
.then((result) => {
|
|
8
8
|
Logger.info('Setting local IP to %s', result);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BrowserLocalIpProvider } from './browser-local-ip-provider.js';
|
|
2
|
+
import { NetworkRatchet } from './network-ratchet.js';
|
|
3
|
+
import { PromiseRatchet } from '../lang/promise-ratchet.js';
|
|
4
|
+
import { jest } from '@jest/globals';
|
|
5
|
+
jest.mock('./network-ratchet');
|
|
6
|
+
describe('#browserLocalIpProvider', function () {
|
|
7
|
+
it('should pull a local ip and return it', async () => {
|
|
8
|
+
const mockStaticFn = jest.fn(() => Promise.resolve('192.168.1.1'));
|
|
9
|
+
NetworkRatchet.findLocalIp = mockStaticFn;
|
|
10
|
+
const up = new BrowserLocalIpProvider();
|
|
11
|
+
while (!up.ready()) {
|
|
12
|
+
await PromiseRatchet.wait(250);
|
|
13
|
+
}
|
|
14
|
+
expect(up.currentLocalIpAddress()).toEqual('192.168.1.1');
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Logger } from '../logger/logger';
|
|
1
|
+
import { Logger } from '../logger/logger.js';
|
|
2
2
|
export class NetworkRatchet {
|
|
3
|
+
static LOCAL_IP = null;
|
|
3
4
|
static findLocalIp(useCache = true) {
|
|
4
5
|
Logger.info('Attempting to find local IP (V 2)');
|
|
5
6
|
if (NetworkRatchet.LOCAL_IP && useCache) {
|
|
@@ -99,4 +100,3 @@ export class NetworkRatchet {
|
|
|
99
100
|
}
|
|
100
101
|
}
|
|
101
102
|
}
|
|
102
|
-
NetworkRatchet.LOCAL_IP = null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { NetworkRatchet } from './network-ratchet.js';
|
|
2
|
+
describe('#parseUrl', function () {
|
|
3
|
+
it('should parse the url and return correct values', function () {
|
|
4
|
+
const result = NetworkRatchet.parseUrl('http://example.com:3000/pathname/?search=test#hash');
|
|
5
|
+
expect(result.protocol).toEqual('http:');
|
|
6
|
+
expect(result.host).toEqual('example.com:3000');
|
|
7
|
+
expect(result.hostname).toEqual('example.com');
|
|
8
|
+
expect(result.port).toEqual('3000');
|
|
9
|
+
expect(result.pathname).toEqual('/pathname/');
|
|
10
|
+
expect(result.search).toEqual('?search=test');
|
|
11
|
+
expect(result.hash).toEqual('#hash');
|
|
12
|
+
});
|
|
13
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
3
3
|
import { Writable } from 'stream';
|
|
4
4
|
export declare class BufferWritable extends Writable {
|
|
5
5
|
private _val;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Readable } from 'stream';
|
|
2
|
+
export class MultiStream extends Readable {
|
|
3
|
+
_object;
|
|
4
|
+
constructor(object, options = {}) {
|
|
5
|
+
super(object instanceof Buffer || typeof object === 'string' ? options : { objectMode: true });
|
|
6
|
+
this._object = object;
|
|
7
|
+
}
|
|
8
|
+
_read() {
|
|
9
|
+
this.push(this._object);
|
|
10
|
+
this._object = null;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
3
3
|
import { Readable } from 'stream';
|
|
4
4
|
export declare class StreamRatchet {
|
|
5
5
|
private constructor();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Readable } from 'stream';
|
|
2
|
-
import { ErrorRatchet } from '../lang/error-ratchet';
|
|
3
|
-
import { StringRatchet } from '../lang/string-ratchet';
|
|
2
|
+
import { ErrorRatchet } from '../lang/error-ratchet.js';
|
|
3
|
+
import { StringRatchet } from '../lang/string-ratchet.js';
|
|
4
4
|
export class StreamRatchet {
|
|
5
5
|
constructor() { }
|
|
6
6
|
static readableToBufferSync(stream) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { StreamRatchet } from './stream-ratchet.js';
|
|
2
|
+
describe('#StreamRatchet', function () {
|
|
3
|
+
it('should wrap a string in a readable', async () => {
|
|
4
|
+
const r = StreamRatchet.stringToReadable('test');
|
|
5
|
+
const out = r.read(200);
|
|
6
|
+
expect(out.length).toEqual(4);
|
|
7
|
+
});
|
|
8
|
+
it('should wrap an number in a readable', async () => {
|
|
9
|
+
const r = StreamRatchet.anyToStringReadable(401);
|
|
10
|
+
const out = r.read(200);
|
|
11
|
+
expect(out.length).toEqual(3);
|
|
12
|
+
});
|
|
13
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|