Socket
Socket
Sign inDemoInstall

vue-property-decorator

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-property-decorator - npm Package Compare versions

Comparing version 4.0.0 to 5.0.0

22

lib/vue-property-decorator.d.ts

@@ -1,4 +0,3 @@

import Vue from 'vue';
import { PropOptions } from 'vue';
import VueClassComponent from 'vue-class-component';
import { PropOptions, WatchOptions } from 'vue';
import Component from 'vue-class-component';
import 'reflect-metadata';

@@ -15,2 +14,8 @@ export declare type Constructor = {

/**
* decorator of a provide
* @param key key
* @return PropertyDecorator | void
*/
export declare function Provide(key?: string | symbol): PropertyDecorator;
/**
* decorator of model

@@ -20,3 +25,3 @@ * @param event event name

*/
export declare function Model(event: string): PropertyDecorator;
export declare function Model(event?: string): PropertyDecorator;
/**

@@ -27,4 +32,3 @@ * decorator of a prop

*/
export declare function Prop(target: Vue, key: string): void;
export declare function Prop(target?: (PropOptions | Constructor[])): PropertyDecorator;
export declare function Prop(options?: (PropOptions | Constructor[])): PropertyDecorator;
/**

@@ -36,5 +40,3 @@ * decorator of a watch function

*/
export declare function Watch(path: string, options?: Vue.WatchOptions): MethodDecorator;
export declare const prop: typeof Prop;
export declare const watch: typeof Watch;
export declare const Component: typeof VueClassComponent;
export declare function Watch(path: string, options?: WatchOptions): MethodDecorator;
export { Component };

@@ -1,6 +0,7 @@

/** vue-property-decorator verson 4.0.0 MIT LICENSE copyright 2017 kaorun343 */
/** vue-property-decorator verson 5.0.0 MIT LICENSE copyright 2017 kaorun343 */
'use strict';
import Vue from 'vue';
import VueClassComponent, { createDecorator } from 'vue-class-component';
import 'reflect-metadata';
Object.defineProperty(exports, "__esModule", { value: true });
var vue_class_component_1 = require("vue-class-component");
exports.Component = vue_class_component_1.default;
require("reflect-metadata");
/**

@@ -11,4 +12,4 @@ * decorator of an inject

*/
export function Inject(key) {
return createDecorator(function (componentOptions, k) {
function Inject(key) {
return vue_class_component_1.createDecorator(function (componentOptions, k) {
if (typeof componentOptions.inject === 'undefined') {

@@ -22,3 +23,26 @@ componentOptions.inject = {};

}
exports.Inject = Inject;
/**
* decorator of a provide
* @param key key
* @return PropertyDecorator | void
*/
function Provide(key) {
return vue_class_component_1.createDecorator(function (componentOptions, k) {
var provide = componentOptions.provide;
if (typeof provide !== 'function' || !provide.managed) {
var original_1 = componentOptions.provide;
provide = componentOptions.provide = function () {
var rv = Object.create((typeof original_1 === 'function' ? original_1.call(this) : original_1) || null);
for (var i in provide.managed)
rv[provide.managed[i]] = this[i];
return rv;
};
provide.managed = {};
}
provide.managed[k] = key || k;
});
}
exports.Provide = Provide;
/**
* decorator of model

@@ -28,28 +52,20 @@ * @param event event name

*/
export function Model(event) {
return createDecorator(function (componentOptions, prop) {
componentOptions.model = { prop: prop, event: event };
function Model(event) {
return vue_class_component_1.createDecorator(function (componentOptions, prop) {
componentOptions.model = { prop: prop, event: event || prop };
});
}
exports.Model = Model;
/**
* @brief Makes a decorator for prop.
*
* @param options The options
* @param target The target
* @param key The key
*
* @return PropertyDecorator
* decorator of a prop
* @param options the options for the prop
* @return PropertyDecorator | void
*/
function makePropDecorator(options) {
function Prop(options) {
if (options === void 0) { options = {}; }
return function (target, key) {
if (!Array.isArray(options) && typeof options.type === 'undefined') {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
options.type = Reflect.getMetadata('design:type', target, key);
}
else {
options.type = null;
}
options.type = Reflect.getMetadata('design:type', target, key);
}
createDecorator(function (componentOptions, k) {
vue_class_component_1.createDecorator(function (componentOptions, k) {
(componentOptions.props || (componentOptions.props = {}))[k] = options;

@@ -59,11 +75,3 @@ })(target, key);

}
export function Prop(options, key) {
if (options === void 0) { options = {}; }
if (options instanceof Vue) {
return makePropDecorator()(options, key);
}
else {
return makePropDecorator(options);
}
}
exports.Prop = Prop;
/**

@@ -75,6 +83,6 @@ * decorator of a watch function

*/
export function Watch(path, options) {
function Watch(path, options) {
if (options === void 0) { options = {}; }
var _a = options.deep, deep = _a === void 0 ? false : _a, _b = options.immediate, immediate = _b === void 0 ? false : _b;
return createDecorator(function (componentOptions, handler) {
return vue_class_component_1.createDecorator(function (componentOptions, handler) {
if (typeof componentOptions.watch !== 'object') {

@@ -86,4 +94,2 @@ componentOptions.watch = Object.create(null);

}
export var prop = Prop;
export var watch = Watch;
export var Component = VueClassComponent;
exports.Watch = Watch;
{
"name": "vue-property-decorator",
"version": "4.0.0",
"version": "5.0.0",
"description": "property decorators for Vue Component",
"main": "lib/vue-property-decorator.common.js",
"main": "src/vue-property-decorator.js",
"keywords": [

@@ -17,4 +17,4 @@ "vue",

"scripts": {
"build": "tsc -p src/tsconfig.json && rollup -c",
"test": "npm run build && tsc -p test/tsconfig.json && mocha --compilers js:babel-register"
"build": "tsc -p src/tsconfig.json",
"test": "tsc -p test/tsconfig.json && ava test/decorator.spec.js"
},

@@ -25,12 +25,4 @@ "files": [

"devDependencies": {
"@types/mocha": "^2.2.38",
"@types/node": "^7.0.5",
"@types/power-assert": "^1.4.29",
"babel": "^6.23.0",
"babel-core": "^6.23.1",
"babel-preset-es2015": "^6.22.0",
"espower-typescript": "^7.0.0",
"mocha": "^3.2.0",
"power-assert": "^1.4.2",
"rollup": "^0.41.4",
"ava": "^0.19.1",
"typescript": "^2.2.1",

@@ -37,0 +29,0 @@ "vue": "^2.2.1"

@@ -21,9 +21,9 @@ # Vue Property Decorator

* `@Model`
* `@Prop` (and `@prop`)
* `@Watch` (and `@watch`)
* `@Prop`
* `@Watch`
* `@Component` (`export Component from 'vue-class-component'`)
```typescript
import Vue = require('vue')
import { Component, Model, Prop, Watch } from 'vue-property-decorator'
import Vue from 'vue'
import { Component, Inject, Model, Prop, Watch } from 'vue-property-decorator'

@@ -39,6 +39,5 @@ const s = Symbol('baz')

@Model('change')
checked: boolean
@Model('change') checked: boolean
@Prop
@Prop()
propA: number

@@ -45,0 +44,0 @@

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