##// END OF EJS Templates
added properties to the build project...
added properties to the build project flavour=(browser|node) controls the target runtime settings symbols=(none|local|pack) controls how the source maps are generated and sources are packed

File last commit:

r82:025f02eff3b2 v1.3.0 default
r99:7071c0e728fe ts-plugin
Show More
Converter.ts
30 lines | 904 B | video/mp2t | TypeScriptLexer
import { isPrimitive, isNull } from "../safe";
export class Converter {
static readonly default = new Converter();
convert(value: any, pattern: string) {
if (pattern && pattern.toLocaleLowerCase() === "json") {
const seen = [];
return JSON.stringify(value, (k, v) => {
if (!isPrimitive(v)) {
const id = seen.indexOf(v);
if (id >= 0)
return "@ref-" + id;
else {
seen.push(v);
return v;
}
} else {
return v;
}
}, 2);
} else if (isNull(value)) {
return "";
} else if (value instanceof Date) {
return value.toISOString();
} else {
return value.toString();
}
}
}