@automapper/classes
Advanced tools
Comparing version 2.0.1 to 2.1.0
{ | ||
"name": "@automapper/classes", | ||
"version": "2.0.1", | ||
"version": "2.1.0", | ||
"peerDependencies": { | ||
"reflect-metadata": "~0.1.13", | ||
"@automapper/core": "2.0.1", | ||
"@automapper/types": "2.0.1" | ||
"@automapper/core": "2.1.0", | ||
"@automapper/types": "2.1.0" | ||
}, | ||
@@ -9,0 +9,0 @@ "sideEffects": false, |
export * from './lib/classes'; | ||
export * from './lib/decorators'; | ||
export * from './lib/constants'; |
@@ -6,2 +6,3 @@ "use strict"; | ||
tslib_1.__exportStar(require("./lib/decorators"), exports); | ||
tslib_1.__exportStar(require("./lib/constants"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -6,2 +6,3 @@ "use strict"; | ||
require("reflect-metadata"); | ||
const constants_1 = require("./constants"); | ||
const storages_1 = require("./storages"); | ||
@@ -90,3 +91,3 @@ const utils_1 = require("./utils"); | ||
// get the metadata from Reflection then populate metadataStorage and instanceStorage | ||
const metadataList = Reflect.getMetadata('automap:properties', model); | ||
const metadataList = Reflect.getMetadata(constants_1.AUTOMAP_PROPERTIES_METADATA_KEY, model); | ||
// skip if no metadata | ||
@@ -93,0 +94,0 @@ if (!core_1.isDefined(metadataList)) |
@@ -8,2 +8,2 @@ import type { Constructible } from '../types'; | ||
*/ | ||
export declare const AutoMap: (typeFn?: (() => Constructible) | undefined, depth?: number) => PropertyDecorator; | ||
export declare const AutoMap: (typeFn?: () => Constructible, depth?: number) => PropertyDecorator; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.AutoMap = void 0; | ||
const constants_1 = require("../constants"); | ||
/** | ||
@@ -11,9 +12,8 @@ * AutoMap decorator to decorate fields in classes to store metadata of that field | ||
exports.AutoMap = (typeFn, depth = 0) => (target, propertyKey) => { | ||
// get existing metadata | ||
const existingMetadataList = Reflect.getMetadata(constants_1.AUTOMAP_PROPERTIES_METADATA_KEY, target.constructor) || | ||
[]; | ||
// If `typeFn` is provided, classes plugin does not have to guess with Reflect and just `defineMetadata` | ||
if (typeFn) { | ||
Reflect.defineMetadata('automap:properties', [ | ||
...(Reflect.getMetadata('automap:properties', target.constructor) || | ||
[]), | ||
[propertyKey, { typeFn, depth }], | ||
], target.constructor); | ||
Reflect.defineMetadata(constants_1.AUTOMAP_PROPERTIES_METADATA_KEY, [...existingMetadataList, [propertyKey, { typeFn, depth }]], target.constructor); | ||
} | ||
@@ -23,7 +23,3 @@ else { | ||
if (meta) { | ||
Reflect.defineMetadata('automap:properties', [ | ||
...(Reflect.getMetadata('automap:properties', target.constructor) || | ||
[]), | ||
[propertyKey, { typeFn: () => meta }], | ||
], target.constructor); | ||
Reflect.defineMetadata(constants_1.AUTOMAP_PROPERTIES_METADATA_KEY, [...existingMetadataList, [propertyKey, { typeFn: () => meta }]], target.constructor); | ||
} | ||
@@ -30,0 +26,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
43262
50
621