smartfile/ts/smartfile.classes.smartfile.ts

29 lines
680 B
TypeScript
Raw Normal View History

import * as plugins from './smartfile.plugins'
export interface ISmartfileConstructorOptions {
path?: string
contentsString?: string
contentBuffer?: Buffer
}
2016-09-20 15:56:49 +00:00
export class Smartfile {
path: string
contents: Buffer
constructor(optionsArg: ISmartfileConstructorOptions) {
if (optionsArg.contentBuffer) {
this.contents = optionsArg.contentBuffer
} else if(optionsArg.contentsString) {
this.contents = new Buffer(optionsArg.contentsString)
2016-09-20 15:56:49 +00:00
}
this.path = optionsArg.path
}
/**
* set contents from string
* @param contentString
*/
setContentFromString(contentString: string) {
this.contents = new Buffer(contentString)
}
2016-09-20 15:56:49 +00:00
}