1.0.9 • Published 2 years ago
@drango/tag-functions v1.0.9
Install
npm i @drango/tag-functions
About
Why would you want a tag?
Normally a function works like this:
const greet = (name: string) => `Hello, ${name}`;
greet("Kevin"); // Works 👍
greet`Kevin`; // Errors 👎
But using createTag
, the same function will also work as a tag with minimum effort:
import createTag from "@drango/tag-functions";
const greetFn = (name: string) => `Hello, ${name}`;
const greet = createTag(greetFn);
greet("Kevin"); // Works 👍
greet`Kevin`; // Works 👍