##// END OF EJS Templates
corrected code to support ts strict mode...
corrected code to support ts strict mode safe.ts - more tight typings - added notImplemented stub function - added fork funtion - added keys function (like Object.keys but extracts keys type) - added isKeyof typeguard - added 'primitive' union type added EventProvider for the observable

File last commit:

r115:691199f665e0 ioc ts support
r115:691199f665e0 ioc ts support
Show More
Converter.ts
30 lines | 912 B | video/mp2t | TypeScriptLexer
cin
StringBuilder, TextWriter, ConsoleWriter tests
r82 import { isPrimitive, isNull } from "../safe";
export class Converter {
static readonly default = new Converter();
cin
corrected code to support ts strict mode...
r115 convert(value: any, pattern?: string) {
cin
StringBuilder, TextWriter, ConsoleWriter tests
r82 if (pattern && pattern.toLocaleLowerCase() === "json") {
cin
corrected code to support ts strict mode...
r115 const seen: any[] = [];
cin
StringBuilder, TextWriter, ConsoleWriter tests
r82 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();
}
}
}