Exploring angular 2 has led me to create a TypeScript definition for a truncate method that I plan to implement in one of my services.
truncate.ts
interface String {
truncate(max: number, decorator: string): string;
}
String.prototype.truncate = function(max, decorator){
decorator = decorator || '...';
return (this.length > max ? this.substring(0,max)+decorator : this);
};
Seeking guidance on how to import this into another TypeScript module or make it globally accessible.