feat: util/simpleSerialize 추가

This commit is contained in:
2022-05-17 00:07:18 +09:00
parent 56fd26935d
commit 2cb697f3dc
2 changed files with 38 additions and 0 deletions
+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('|');
}