@loopback/metadata
Advanced tools
Comparing version 1.3.8 to 1.3.9
@@ -6,2 +6,10 @@ # Change Log | ||
## [1.3.9](https://github.com/strongloop/loopback-next/compare/@loopback/metadata@1.3.8...@loopback/metadata@1.3.9) (2019-12-09) | ||
**Note:** Version bump only for package @loopback/metadata | ||
## [1.3.8](https://github.com/strongloop/loopback-next/compare/@loopback/metadata@1.3.7...@loopback/metadata@1.3.8) (2019-11-25) | ||
@@ -8,0 +16,0 @@ |
@@ -6,7 +6,10 @@ "use strict"; | ||
// License text available at https://opensource.org/licenses/MIT | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const debugModule = require("debug"); | ||
const _ = require("lodash"); | ||
const debug_1 = __importDefault(require("debug")); | ||
const lodash_1 = __importDefault(require("lodash")); | ||
const reflect_1 = require("./reflect"); | ||
const debug = debugModule('loopback:metadata:decorator'); | ||
const debug = debug_1.default('loopback:metadata:decorator'); | ||
/** | ||
@@ -43,2 +46,3 @@ * Base factory class for decorator functions | ||
constructor(key, spec, options = {}) { | ||
var _a; | ||
this.key = key; | ||
@@ -52,3 +56,3 @@ this.spec = spec; | ||
const defaultDecoratorName = this.constructor.name.replace(/Factory$/, ''); | ||
this.decoratorName = this.options.decoratorName || defaultDecoratorName; | ||
this.decoratorName = (_a = this.options.decoratorName, (_a !== null && _a !== void 0 ? _a : defaultDecoratorName)); | ||
if (this.options.cloneInputSpec) { | ||
@@ -261,3 +265,3 @@ this.spec = DecoratorFactory.cloneDeep(spec); | ||
return val; | ||
return _.cloneDeepWith(val, v => { | ||
return lodash_1.default.cloneDeepWith(val, v => { | ||
if (typeof v !== 'object') | ||
@@ -264,0 +268,0 @@ return v; |
@@ -26,4 +26,4 @@ "use strict"; | ||
static getClassMetadata(key, target, options) { | ||
return options && options.ownMetadataOnly | ||
? reflect_1.Reflector.getOwnMetadata(key.toString(), target) | ||
var _a; | ||
return ((_a = options) === null || _a === void 0 ? void 0 : _a.ownMetadataOnly) ? reflect_1.Reflector.getOwnMetadata(key.toString(), target) | ||
: reflect_1.Reflector.getMetadata(key.toString(), target); | ||
@@ -49,4 +49,4 @@ } | ||
static getAllMethodMetadata(key, target, options) { | ||
return options && options.ownMetadataOnly | ||
? reflect_1.Reflector.getOwnMetadata(key.toString(), target) | ||
var _a; | ||
return ((_a = options) === null || _a === void 0 ? void 0 : _a.ownMetadataOnly) ? reflect_1.Reflector.getOwnMetadata(key.toString(), target) | ||
: reflect_1.Reflector.getMetadata(key.toString(), target); | ||
@@ -64,7 +64,7 @@ } | ||
static getMethodMetadata(key, target, methodName, options) { | ||
methodName = methodName || ''; | ||
const meta = options && options.ownMetadataOnly | ||
? reflect_1.Reflector.getOwnMetadata(key.toString(), target) | ||
var _a, _b; | ||
methodName = (methodName !== null && methodName !== void 0 ? methodName : ''); | ||
const meta = ((_a = options) === null || _a === void 0 ? void 0 : _a.ownMetadataOnly) ? reflect_1.Reflector.getOwnMetadata(key.toString(), target) | ||
: reflect_1.Reflector.getMetadata(key.toString(), target); | ||
return meta && meta[methodName]; | ||
return (_b = meta) === null || _b === void 0 ? void 0 : _b[methodName]; | ||
} | ||
@@ -79,4 +79,4 @@ /** | ||
static getAllPropertyMetadata(key, target, options) { | ||
return options && options.ownMetadataOnly | ||
? reflect_1.Reflector.getOwnMetadata(key.toString(), target) | ||
var _a; | ||
return ((_a = options) === null || _a === void 0 ? void 0 : _a.ownMetadataOnly) ? reflect_1.Reflector.getOwnMetadata(key.toString(), target) | ||
: reflect_1.Reflector.getMetadata(key.toString(), target); | ||
@@ -94,6 +94,6 @@ } | ||
static getPropertyMetadata(key, target, propertyName, options) { | ||
const meta = options && options.ownMetadataOnly | ||
? reflect_1.Reflector.getOwnMetadata(key.toString(), target) | ||
var _a, _b; | ||
const meta = ((_a = options) === null || _a === void 0 ? void 0 : _a.ownMetadataOnly) ? reflect_1.Reflector.getOwnMetadata(key.toString(), target) | ||
: reflect_1.Reflector.getMetadata(key.toString(), target); | ||
return meta && meta[propertyName]; | ||
return (_b = meta) === null || _b === void 0 ? void 0 : _b[propertyName]; | ||
} | ||
@@ -110,7 +110,7 @@ /** | ||
static getAllParameterMetadata(key, target, methodName, options) { | ||
methodName = methodName || ''; | ||
const meta = options && options.ownMetadataOnly | ||
? reflect_1.Reflector.getOwnMetadata(key.toString(), target) | ||
var _a, _b; | ||
methodName = (methodName !== null && methodName !== void 0 ? methodName : ''); | ||
const meta = ((_a = options) === null || _a === void 0 ? void 0 : _a.ownMetadataOnly) ? reflect_1.Reflector.getOwnMetadata(key.toString(), target) | ||
: reflect_1.Reflector.getMetadata(key.toString(), target); | ||
return meta && meta[methodName]; | ||
return (_b = meta) === null || _b === void 0 ? void 0 : _b[methodName]; | ||
} | ||
@@ -128,8 +128,8 @@ /** | ||
static getParameterMetadata(key, target, methodName, index, options) { | ||
var _a, _b, _c; | ||
methodName = methodName || ''; | ||
const meta = options && options.ownMetadataOnly | ||
? reflect_1.Reflector.getOwnMetadata(key.toString(), target) | ||
const meta = ((_a = options) === null || _a === void 0 ? void 0 : _a.ownMetadataOnly) ? reflect_1.Reflector.getOwnMetadata(key.toString(), target) | ||
: reflect_1.Reflector.getMetadata(key.toString(), target); | ||
const params = meta && meta[methodName]; | ||
return params && params[index]; | ||
const params = (_b = meta) === null || _b === void 0 ? void 0 : _b[methodName]; | ||
return (_c = params) === null || _c === void 0 ? void 0 : _c[index]; | ||
} | ||
@@ -136,0 +136,0 @@ /** |
{ | ||
"name": "@loopback/metadata", | ||
"version": "1.3.8", | ||
"version": "1.3.9", | ||
"description": "LoopBack's metadata utilities for reflection and decoration", | ||
@@ -26,8 +26,8 @@ "engines": { | ||
"devDependencies": { | ||
"@loopback/build": "^2.1.0", | ||
"@loopback/eslint-config": "^4.1.5", | ||
"@loopback/testlab": "^1.9.5", | ||
"@loopback/build": "^3.0.0", | ||
"@loopback/eslint-config": "^5.0.0", | ||
"@loopback/testlab": "^1.10.0", | ||
"@types/debug": "^4.1.5", | ||
"@types/lodash": "^4.14.149", | ||
"@types/node": "^10.17.5" | ||
"@types/node": "^10.17.6" | ||
}, | ||
@@ -55,3 +55,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "c111543a6139c5a2999930c593aabbbdf10a838e" | ||
"gitHead": "89eb61bacaed75e6eb61ae6840cea266cb888659" | ||
} |
@@ -6,4 +6,4 @@ // Copyright IBM Corp. 2017,2019. All Rights Reserved. | ||
import * as debugModule from 'debug'; | ||
import * as _ from 'lodash'; | ||
import debugModule from 'debug'; | ||
import _ from 'lodash'; | ||
import {Reflector} from './reflect'; | ||
@@ -95,3 +95,3 @@ import {DecoratorType, MetadataKey, MetadataMap} from './types'; | ||
const defaultDecoratorName = this.constructor.name.replace(/Factory$/, ''); | ||
this.decoratorName = this.options.decoratorName || defaultDecoratorName; | ||
this.decoratorName = this.options.decoratorName ?? defaultDecoratorName; | ||
if (this.options.cloneInputSpec) { | ||
@@ -98,0 +98,0 @@ this.spec = DecoratorFactory.cloneDeep(spec); |
@@ -61,3 +61,3 @@ // Copyright IBM Corp. 2017,2019. All Rights Reserved. | ||
): T | undefined { | ||
return options && options.ownMetadataOnly | ||
return options?.ownMetadataOnly | ||
? Reflector.getOwnMetadata(key.toString(), target) | ||
@@ -95,3 +95,3 @@ : Reflector.getMetadata(key.toString(), target); | ||
): MetadataMap<T> | undefined { | ||
return options && options.ownMetadataOnly | ||
return options?.ownMetadataOnly | ||
? Reflector.getOwnMetadata(key.toString(), target) | ||
@@ -116,8 +116,7 @@ : Reflector.getMetadata(key.toString(), target); | ||
): T | undefined { | ||
methodName = methodName || ''; | ||
const meta: MetadataMap<T> = | ||
options && options.ownMetadataOnly | ||
? Reflector.getOwnMetadata(key.toString(), target) | ||
: Reflector.getMetadata(key.toString(), target); | ||
return meta && meta[methodName]; | ||
methodName = methodName ?? ''; | ||
const meta: MetadataMap<T> = options?.ownMetadataOnly | ||
? Reflector.getOwnMetadata(key.toString(), target) | ||
: Reflector.getMetadata(key.toString(), target); | ||
return meta?.[methodName]; | ||
} | ||
@@ -137,3 +136,3 @@ | ||
): MetadataMap<T> | undefined { | ||
return options && options.ownMetadataOnly | ||
return options?.ownMetadataOnly | ||
? Reflector.getOwnMetadata(key.toString(), target) | ||
@@ -158,7 +157,6 @@ : Reflector.getMetadata(key.toString(), target); | ||
): T | undefined { | ||
const meta: MetadataMap<T> = | ||
options && options.ownMetadataOnly | ||
? Reflector.getOwnMetadata(key.toString(), target) | ||
: Reflector.getMetadata(key.toString(), target); | ||
return meta && meta[propertyName]; | ||
const meta: MetadataMap<T> = options?.ownMetadataOnly | ||
? Reflector.getOwnMetadata(key.toString(), target) | ||
: Reflector.getMetadata(key.toString(), target); | ||
return meta?.[propertyName]; | ||
} | ||
@@ -181,8 +179,7 @@ | ||
): T[] | undefined { | ||
methodName = methodName || ''; | ||
const meta: MetadataMap<T[]> = | ||
options && options.ownMetadataOnly | ||
? Reflector.getOwnMetadata(key.toString(), target) | ||
: Reflector.getMetadata(key.toString(), target); | ||
return meta && meta[methodName]; | ||
methodName = methodName ?? ''; | ||
const meta: MetadataMap<T[]> = options?.ownMetadataOnly | ||
? Reflector.getOwnMetadata(key.toString(), target) | ||
: Reflector.getMetadata(key.toString(), target); | ||
return meta?.[methodName]; | ||
} | ||
@@ -208,8 +205,7 @@ | ||
methodName = methodName || ''; | ||
const meta: MetadataMap<T[]> = | ||
options && options.ownMetadataOnly | ||
? Reflector.getOwnMetadata(key.toString(), target) | ||
: Reflector.getMetadata(key.toString(), target); | ||
const params = meta && meta[methodName]; | ||
return params && params[index]; | ||
const meta: MetadataMap<T[]> = options?.ownMetadataOnly | ||
? Reflector.getOwnMetadata(key.toString(), target) | ||
: Reflector.getMetadata(key.toString(), target); | ||
const params = meta?.[methodName]; | ||
return params?.[index]; | ||
} | ||
@@ -216,0 +212,0 @@ |
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
151867