I have several utility functions. What is the best way to package these up, and then import them?
This is what I am trying to do:
import * as util f
You can also create a util.ts class which has a function to export
export const formatDateOfBirth =
(dob: string) : string => `${dob.substring(0, 4)}-${dob.substring(4, 6)}-${dob.substring(6, 8)}`;
Now you can import the method as below, shared folder structure is src > app > shared, I am calling this import inside src > app > shelf > shelf.component.ts file
import { formatDateOfBirth } from '../shared/utils/util';
public getFormattedDate(dob: string):string{
return formatDateOfBirth(dob);
}