1.0.2 • Published 5 years ago
string-tag v1.0.2
string-tag
A tiny tool to create string tags.
Example
import stringTag from "string-tag";
class MyString extends String {}
const ms = stringTag(MyString);
var str = ms`this is a custom string of ${MyString.name}`;
console.assert(str instanceof MyString);
console.assert(str.valueOf() === "this is a custom string of MyString");
API
export type StringTag<T> = (strings: string[], ...data: any[]) => T;
export function stringTag<T = string>(ctor?: new (...args: any[]) => T): StringTag<T>;
export default stringTag;