@paydirt/fmt
Version:
String formating using commonly used standards
17 lines (16 loc) • 422 B
JavaScript
import stringReplacer from './string';
var typeMap = new Map([
['string', 's'],
['boolean', 't'],
['number', 'f'],
]);
export default function (_, mods, value) {
var flag = typeMap.get(typeof value);
if (flag !== undefined) {
return stringReplacer(flag, mods, value);
}
if (mods.negative) {
return JSON.stringify(Object.values(value));
}
return JSON.stringify(value);
}