Skip to content

Commit c8e207c

Browse files
committed
chore(sprintf): expose named export, deprecate default
This commit adds a named export for `sprintf`. The default export is still supported but deprecated. Related-to: GH-4860.
1 parent d427c39 commit c8e207c

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

sprintf/index.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,7 @@ const LOWERCASE_S_CODE = 115; /* s */
5858
* @returns
5959
* Formatted string.
6060
*/
61-
export default function sprintf(
62-
template: string,
63-
...values: unknown[]
64-
): string {
61+
export function sprintf(template: string, ...values: unknown[]): string {
6562
if (typeof template !== "string") {
6663
throw new TypeError("First argument must be a string");
6764
}
@@ -190,3 +187,11 @@ export default function sprintf(
190187

191188
return output;
192189
}
190+
191+
/**
192+
* Format a string.
193+
*
194+
* @deprecated
195+
* Use `sprintf` instead.
196+
*/
197+
export default sprintf;

sprintf/test/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import test from "node:test";
44
test("@arcjet/sprintf", async function (t) {
55
await t.test("should expose the public api", async function () {
66
assert.deepEqual(Object.keys(await import("../index.js")).sort(), [
7-
// TODO(@wooorm-arcjet): named exports.
87
"default",
8+
"sprintf",
99
]);
1010
});
1111
});

0 commit comments

Comments
 (0)