Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

deprecated-decorator

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deprecated-decorator - npm Package Compare versions

Comparing version 0.1.3 to 0.1.4

4

bld/debug/test.js

@@ -47,2 +47,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {

bar.abc, bar.def, bar.ghi;
var fn = _1.default('biu', function yo(x) {
return x.length;
});
console.log(fn('abc'));
//# sourceMappingURL=test.js.map

@@ -9,2 +9,7 @@ export declare type DeprecatedDecorator = ClassDecorator & PropertyDecorator;

export declare function deprecated(alternative?: string, version?: string, url?: string): DeprecatedDecorator;
export declare function deprecated<T extends Function>(fn: T): T;
export declare function deprecated<T extends Function>(options: DeprecatedOptions, fn: T): T;
export declare function deprecated<T extends Function>(alternative: string, fn: T): T;
export declare function deprecated<T extends Function>(alternative: string, version: string, fn: T): T;
export declare function deprecated<T extends Function>(alternative: string, version: string, url: string, fn: T): T;
export default deprecated;

@@ -26,2 +26,5 @@ /*

switch (type) {
case 'class':
message = 'Class';
break;
case 'property':

@@ -33,4 +36,4 @@ message = 'Property';

break;
case 'class':
message = 'Class';
case 'function':
message = 'Function';
break;

@@ -98,3 +101,3 @@ }

warner();
target.apply(this, arguments);
return target.apply(this, arguments);
};

@@ -113,6 +116,31 @@ for (var _i = 0, _a = Object.getOwnPropertyNames(target); _i < _a.length; _i++) {

}
function deprecated(options, version, url) {
function decorateFunction(target, alternative, version, url) {
var name = target.name;
var warner = (exports.options.getWarner || createWarner)('function', name, alternative, version, url);
var fn = function () {
warner();
return target.apply(this, arguments);
};
return fn;
}
function deprecated() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
}
var fn = args[args.length - 1];
if (typeof fn === 'function') {
fn = args.pop();
}
else {
fn = undefined;
}
var options = args[0];
var alternative;
var version;
var url;
if (typeof options === 'string') {
alternative = options;
version = args[1];
url = args[2];
}

@@ -122,2 +150,5 @@ else if (options) {

}
if (fn) {
return decorateFunction(fn, alternative, version, url);
}
return function (target, name, descriptor) {

@@ -131,6 +162,7 @@ if (typeof name === 'string') {

var constructor = decorateClass(target, alternative, version, url);
var className = target.name;
for (var _i = 0, _a = Object.getOwnPropertyNames(constructor); _i < _a.length; _i++) {
var propertyName = _a[_i];
var descriptor_1 = Object.getOwnPropertyDescriptor(constructor, propertyName);
descriptor_1 = decorateProperty('class', target.name, descriptor_1, alternative, version, url);
descriptor_1 = decorateProperty('class', className, descriptor_1, alternative, version, url);
if (descriptor_1.writable) {

@@ -137,0 +169,0 @@ constructor[propertyName] = target[propertyName];

4

package.json
{
"name": "deprecated-decorator",
"version": "0.1.3",
"version": "0.1.4",
"description": "A simple decorator for deprecated methods and properties.",

@@ -15,3 +15,3 @@ "main": "bld/index.js",

},
"keywords": ["deprecated", "decorator"],
"keywords": ["deprecated", "decorator", "typescript", "babel", "es7"],
"author": "vilicvane",

@@ -18,0 +18,0 @@ "license": "MIT",

@@ -8,2 +8,7 @@ [![NPM Package](https://badge.fury.io/js/deprecated-decorator.svg)](https://www.npmjs.com/package/deprecated-decorator)

Transpilers supported:
- **TypeScript** with `experimentalDecorators` option enabled.
- **Babel** with [transform-decorators-legacy](https://github.com/loganfsmyth/babel-plugin-transform-decorators-legacy) for version 6.x.
## Install

@@ -10,0 +15,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc