{"version":3,"file":"ts-lab-auto-mapper.mjs","sources":["../../../projects/auto-mapper/src/lib/classes/auto-mapper.ts","../../../projects/auto-mapper/src/lib/classes/profile.ts","../../../projects/auto-mapper/src/lib/classes/index.ts","../../../projects/auto-mapper/src/public-api.ts","../../../projects/auto-mapper/src/ts-lab-auto-mapper.ts"],"sourcesContent":["import { Profile } from \"./profile\";\r\n\r\nexport class AutoMapper {\r\n    public static map<T extends object, D extends object>(source: T, profile: Profile<T, D>): D {\r\n        const destination: D = profile.getInitialState();\r\n\r\n        for (const key in destination) {\r\n            if (destination.hasOwnProperty(key)) {\r\n                const destFn = destination[key];\r\n                if (typeof destFn === \"function\") {\r\n                    destination[key] = destFn(source);\r\n                } else {\r\n                  // @ts-ignore\r\n                  destination[key] = source[key];\r\n                }\r\n            }\r\n        }\r\n\r\n        return destination;\r\n    }\r\n\r\n    public static mapArray<T extends object, D extends object>(source: T[], profile: Profile<T, D>): D[] {\r\n        const destination: D[] = [];\r\n\r\n        for (const item of source) {\r\n            destination.push(AutoMapper.map(item, profile));\r\n        }\r\n\r\n        return destination;\r\n    }\r\n}\r\n\r\n","import { PropertyMapper } from \"../types/property-mapper\";\r\n\r\nexport class Profile<S extends object, D extends object> {\r\n  private readonly _destinationInitialState: D;\r\n\r\n  constructor(destinationInitialState: D) {\r\n    this._destinationInitialState = {...destinationInitialState};\r\n  }\r\n\r\n  public forMember<K extends keyof D>(destKey: K, destFn: PropertyMapper<S, D, K>): this {\r\n    // @ts-ignore\r\n    this._destinationInitialState[destKey] = destFn;\r\n    return this;\r\n  }\r\n\r\n  /**\r\n   * Internal method to get the initial state of the destination object\r\n   */\r\n  public getInitialState(): D {\r\n    return { ...this._destinationInitialState };\r\n  }\r\n}\r\n","// 1. Auto mapper\r\n\r\nexport * from './auto-mapper';\r\n\r\n// 2. Profiler\r\n\r\nexport * from './profile';\r\n","/*\r\n * Public API Surface of typescript-auto-mapper\r\n */\r\n\r\nexport * from './lib/classes';\r\n","/**\n * Generated bundle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