mirror of
https://github.com/checktheroads/hyperglass
synced 2024-05-11 05:55:08 +00:00
12 lines
323 B
TypeScript
12 lines
323 B
TypeScript
import { useMemo } from 'react';
|
|
import format from 'string-format';
|
|
|
|
import type { UseStrfArgs } from './types';
|
|
|
|
/**
|
|
* Format a string with variables, like Python's string.format()
|
|
*/
|
|
export function useStrf(str: string, fmt: UseStrfArgs, ...deps: unknown[]): string {
|
|
return useMemo(() => format(str, fmt), deps);
|
|
}
|