@guillaume-docquier/tools-ts 1.1.0 → 1.2.0
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/debounce.d.ts +5 -0
- package/dist/debounce.js +14 -0
- package/dist/debounce.js.map +1 -0
- package/dist/entry.tools-ts.d.ts +4 -0
- package/dist/entry.tools-ts.js +4 -0
- package/dist/entry.tools-ts.js.map +1 -1
- package/dist/logging/formatter/jsonLineFormatter.js +5 -18
- package/dist/logging/formatter/jsonLineFormatter.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a debounced function that delays invoking the callback until after wait milliseconds have elapsed
|
|
3
|
+
* since the last time the debounced function was invoked.
|
|
4
|
+
*/
|
|
5
|
+
export declare function debounce<TArgs extends unknown[]>(callback: (...args: TArgs) => void, delayMs: number): (...args: TArgs) => void;
|
package/dist/debounce.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a debounced function that delays invoking the callback until after wait milliseconds have elapsed
|
|
3
|
+
* since the last time the debounced function was invoked.
|
|
4
|
+
*/
|
|
5
|
+
export function debounce(callback, delayMs) {
|
|
6
|
+
let timeoutId = undefined;
|
|
7
|
+
return (...args) => {
|
|
8
|
+
clearTimeout(timeoutId);
|
|
9
|
+
timeoutId = setTimeout(() => {
|
|
10
|
+
callback(...args);
|
|
11
|
+
}, delayMs);
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=debounce.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debounce.js","sourceRoot":"","sources":["../src/debounce.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAA0B,QAAkC,EAAE,OAAe;IACnG,IAAI,SAAS,GAA8C,SAAS,CAAA;IAEpE,OAAO,CAAC,GAAG,IAAW,EAAE,EAAE;QACxB,YAAY,CAAC,SAAS,CAAC,CAAA;QAEvB,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE;YAC1B,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAA;QACnB,CAAC,EAAE,OAAO,CAAC,CAAA;IACb,CAAC,CAAA;AACH,CAAC"}
|
package/dist/entry.tools-ts.d.ts
CHANGED
|
@@ -12,8 +12,12 @@ export { TypeGuard } from "./TypeGuard.js";
|
|
|
12
12
|
export { setTimeoutAsync } from "./setTimeoutAsync.js";
|
|
13
13
|
export { noop, asyncNoop } from "./noop.js";
|
|
14
14
|
export { Logger } from "./logging/Logger.js";
|
|
15
|
+
export { RECOMMENDED_LOG_REDACTION } from "./logging/redaction.js";
|
|
16
|
+
export { jsonLineFormatter } from "./logging/formatter/jsonLineFormatter.js";
|
|
17
|
+
export { prettyConsoleFormatter } from "./logging/formatter/prettyConsoleFormatter.js";
|
|
15
18
|
export type { LogSink } from "./logging/sink/LogSink.js";
|
|
16
19
|
export { createConsoleLogSink } from "./logging/sink/ConsoleLogSink.js";
|
|
17
20
|
export type { LogContext } from "./logging/log-context/LogContext.js";
|
|
18
21
|
export type { LoggerContext } from "./logging/log-context/LoggerContext.js";
|
|
19
22
|
export type { LogContextProvider } from "./logging/log-context/LogContextProvider.js";
|
|
23
|
+
export { debounce } from "./debounce.js";
|
package/dist/entry.tools-ts.js
CHANGED
|
@@ -11,5 +11,9 @@ export { TypeGuard } from "./TypeGuard.js";
|
|
|
11
11
|
export { setTimeoutAsync } from "./setTimeoutAsync.js";
|
|
12
12
|
export { noop, asyncNoop } from "./noop.js";
|
|
13
13
|
export { Logger } from "./logging/Logger.js";
|
|
14
|
+
export { RECOMMENDED_LOG_REDACTION } from "./logging/redaction.js";
|
|
15
|
+
export { jsonLineFormatter } from "./logging/formatter/jsonLineFormatter.js";
|
|
16
|
+
export { prettyConsoleFormatter } from "./logging/formatter/prettyConsoleFormatter.js";
|
|
14
17
|
export { createConsoleLogSink } from "./logging/sink/ConsoleLogSink.js";
|
|
18
|
+
export { debounce } from "./debounce.js";
|
|
15
19
|
//# sourceMappingURL=entry.tools-ts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry.tools-ts.js","sourceRoot":"","sources":["../src/entry.tools-ts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAA;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAI5C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,MAAM,EAA8B,MAAM,aAAa,CAAA;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAE3C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"entry.tools-ts.js","sourceRoot":"","sources":["../src/entry.tools-ts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAA;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAI5C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,MAAM,EAA8B,MAAM,aAAa,CAAA;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAE3C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAC5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAA;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAA;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,+CAA+C,CAAA;AAEtF,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAA;AAKvE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA"}
|
|
@@ -3,25 +3,12 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const jsonLineFormatter = (logRecord) => {
|
|
5
5
|
const { scopes, ...context } = logRecord.properties;
|
|
6
|
-
return
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
// LogTape supports template literals, but we don't.
|
|
12
|
-
// See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals to learn more about template literals.
|
|
13
|
-
// We don't validate for performance reasons. We compensate with tests.
|
|
6
|
+
return JSON.stringify({
|
|
7
|
+
...context,
|
|
8
|
+
timestamp: new Date(logRecord.timestamp).toISOString(),
|
|
9
|
+
level: logRecord.level.toUpperCase(),
|
|
10
|
+
scope: scopes.length > 0 ? scopes.join(" ") : undefined,
|
|
14
11
|
message: logRecord.rawMessage,
|
|
15
|
-
context,
|
|
16
12
|
});
|
|
17
13
|
};
|
|
18
|
-
function formatConsoleMessage(data) {
|
|
19
|
-
return JSON.stringify({
|
|
20
|
-
...data.context,
|
|
21
|
-
timestamp: new Date(data.timestamp).toISOString(),
|
|
22
|
-
level: data.level.toUpperCase(),
|
|
23
|
-
scope: data.scopes.length > 0 ? data.scopes.join(" ") : undefined,
|
|
24
|
-
message: data.message,
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
14
|
//# sourceMappingURL=jsonLineFormatter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsonLineFormatter.js","sourceRoot":"","sources":["../../../src/logging/formatter/jsonLineFormatter.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAkB,CAAC,SAAS,EAAE,EAAE;IAC5D,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,GAAG,SAAS,CAAC,UAA2B,CAAA;IAEpE,OAAO,
|
|
1
|
+
{"version":3,"file":"jsonLineFormatter.js","sourceRoot":"","sources":["../../../src/logging/formatter/jsonLineFormatter.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAkB,CAAC,SAAS,EAAE,EAAE;IAC5D,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,GAAG,SAAS,CAAC,UAA2B,CAAA;IAEpE,OAAO,IAAI,CAAC,SAAS,CAAC;QACpB,GAAG,OAAO;QACV,SAAS,EAAE,IAAI,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE;QACtD,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,WAAW,EAAE;QACpC,KAAK,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS;QACvD,OAAO,EAAE,SAAS,CAAC,UAAU;KAC9B,CAAC,CAAA;AACJ,CAAC,CAAA"}
|