Let's say I build a library class for helper methods. I have one file containing string utils, one file containing ajax utils and so on.
The main class looks something like this:
// helperUtils.js
export class helperUtils {
constructor() {}
basicHelperFn() {
return true;
}
}
now i have a file exporting those string utils:
// helperUtils/stringUtils.js
import { helperUtils } from '../helperUtils.js';
helperUtils.prototype = {
stringUtil1 : (str) => {
return str += ' this is very helpful!';
}
}
export const stringUtils = helperUtils.prototype;
// more files...
// helperUtils/ajaxUtils.js
// helperUtils/objUtils.js
// ...
How can I now import the main class and extend it with only some of the prototype methods splitted up over several files, for example only import the string utils.
import { helperUtils } from './helperUtils';
import { stringUtils} from './helperUtils/stringUtils';
const helper = new helperUtils();
helper.basicHelperFn();
helper.stringUtil1();