core-decorators
Advanced tools
Comparing version 0.0.3 to 0.0.4
{ | ||
"name": "core-decorators", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Library of ES7 decorators inspired by languages that come with built-ins like @override, @deprecated, etc", | ||
@@ -5,0 +5,0 @@ "main": "src/core-decorators/index.js", |
@@ -0,19 +1,5 @@ | ||
import { decorate } from './private/utils'; | ||
const DEFAULT_MSG = 'This function will be removed in future versions.'; | ||
function isDescriptor(desc) { | ||
if (!desc || !desc.hasOwnProperty) { | ||
return false; | ||
} | ||
const keys = ['value', 'get', 'set']; | ||
for (const key of keys) { | ||
if (desc.hasOwnProperty(key)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
function handleDescriptor(target, key, descriptor, [msg = DEFAULT_MSG, options = {}]) { | ||
@@ -39,10 +25,4 @@ if (typeof descriptor.value !== 'function') { | ||
export default function deprecated(...entryArgs) { | ||
if (isDescriptor(entryArgs[entryArgs.length - 1])) { | ||
return handleDescriptor(...entryArgs, []); | ||
} else { | ||
return function () { | ||
return handleDescriptor(...arguments, entryArgs); | ||
}; | ||
} | ||
export default function deprecated() { | ||
return decorate(handleDescriptor, arguments); | ||
} |
@@ -0,1 +1,3 @@ | ||
import { decorate } from './private/utils'; | ||
const GENERIC_FUNCTION_ERROR = '{child} does not properly override {parent}'; | ||
@@ -222,3 +224,3 @@ const FUNCTION_REGEXP = /^function ([_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*)?(\([^\)]*\))[\s\S]+$/; | ||
export default function override(klass, key, descriptor) { | ||
function handleDescriptor(target, key, descriptor) { | ||
descriptor.key = key; | ||
@@ -239,1 +241,5 @@ const superKlass = Object.getPrototypeOf(klass); | ||
} | ||
export default function override() { | ||
return decorate(handleDescriptor, arguments); | ||
} |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
11907
7
241
0