feat: util/simpleSerialize 추가

This commit is contained in:
Hide_D committed 2022-05-17 00:07:18 +09:00
1 parent 815f03af5d
commit 3c078e7f4a
2 files changed
+38

No files matched your search

+17
View File
@@ -0,0 +1,17 @@
import { isInteger, isString } from "lodash";
export function simpleSerialize(...values : (string|number)[]): string{
const result = [];
for(const value of values){
if(isString(value)){
result.push(`str(${value.length},${value})`);
continue;
}
if(isInteger(value)){
result.push(`int(${value})`);
}
const float6 = value.toLocaleString("en-US", {maximumFractionDigits: 6});
result.push(`float(${float6})`);
}
return result.join('|');
}