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

ng1-shift

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ng1-shift - npm Package Compare versions

Comparing version 0.0.11 to 0.0.12

decorators/component/helpers.ts

45

example/package.json

@@ -28,29 +28,28 @@ {

"devDependencies": {
"@angular/common": "4.0.2",
"@angular/compiler": "4.0.2",
"@angular/compiler-cli": "4.0.2",
"@angular/core": "4.0.2",
"@angular/forms": "4.0.2",
"@angular/http": "4.0.2",
"@angular/platform-browser": "4.0.2",
"@angular/platform-browser-dynamic": "4.0.2",
"@angular/platform-server": "4.0.2",
"@angular/router": "4.0.2",
"@types/core-js": "0.9.35",
"@types/node": "7.0.5",
"angular": "1.6.4",
"@angular/common": "4.4.6",
"@angular/compiler": "4.4.6",
"@angular/compiler-cli": "4.4.6",
"@angular/core": "4.4.6",
"@angular/forms": "4.4.6",
"@angular/http": "4.4.6",
"@angular/platform-browser": "4.4.6",
"@angular/platform-browser-dynamic": "4.4.6",
"@angular/platform-server": "4.4.6",
"@angular/router": "4.4.6",
"@types/core-js": "0.9.43",
"@types/node": "9.4.0",
"angular": "1.6.8",
"angular-router-loader": "0.6.0",
"angular-ui-router": "1.0.0-alpha.5",
"core-js": "2.4.1",
"html-webpack-plugin": "2.28.0",
"core-js": "2.5.1",
"html-webpack-plugin": "2.30.1",
"raw-loader": "0.5.1",
"reflect-metadata": "0.1.10",
"rxjs": "5.1.0",
"ts-loader": "^2.0.2",
"typescript": "2.3.4",
"webpack": "2.2.1",
"webpack-dev-server": "2.3.0",
"webpack-merge": "2.6.1",
"zone.js": "0.8.5"
"reflect-metadata": "0.1.12",
"rxjs": "5.5.6",
"ts-loader": "3.4.0",
"typescript": "2.7.1",
"webpack": "3.10.0",
"webpack-dev-server": "2.11.1",
"zone.js": "0.8.18"
}
}

@@ -9,8 +9,9 @@ const {Directive, EventEmitter, Input, Output} = require("../../export-switch");

@Output() ngShiftDirectiveOutput = new EventEmitter();
private name = "NgShiftAttrDirective";
ngOnInit() {
console.log(this.constructor.name, this.ngShiftDirectiveProp);
console.log(this.name, this.ngShiftDirectiveProp);
const titleSpan = document.createElement("span");
titleSpan.textContent = this.constructor.name;
titleSpan.textContent = this.name;

@@ -27,4 +28,4 @@ document.querySelector("ng-shift-directive > div").appendChild(titleSpan);

ngOnChanges() {
console.log("onChanges", this.constructor.name);
console.log("onChanges", this.name);
}
}

@@ -9,8 +9,9 @@ const {Directive, EventEmitter, Input, Output} = require("../../export-switch");

@Output() ngShiftDirectiveOutput = new EventEmitter();
private name = "NgShiftClassDirective";
ngOnInit() {
console.log(this.constructor.name);
console.log(this.name);
const titleSpan = document.createElement("span");
titleSpan.textContent = `, ${this.constructor.name}`;
titleSpan.textContent = `, ${this.name}`;

@@ -23,4 +24,4 @@ document.querySelector("ng-shift-directive > div").appendChild(titleSpan);

ngOnChanges() {
console.log("onChanges", this.constructor.name);
console.log("onChanges", this.name);
}
}

@@ -9,8 +9,9 @@ const {Directive, EventEmitter, Input, Output} = require("../../export-switch");

@Output() ngShiftDirectiveOutput = new EventEmitter();
private name = "NgShiftElemDirective";
ngOnInit() {
console.log(this.constructor.name);
console.log(this.name);
const titleSpan = document.createElement("span");
titleSpan.textContent = `, ${this.constructor.name}`;
titleSpan.textContent = `, ${this.name}`;

@@ -23,4 +24,4 @@ document.querySelector("ng-shift-directive > div").appendChild(titleSpan);

ngOnChanges() {
console.log("onChanges", this.constructor.name);
console.log("onChanges", this.name);
}
}

@@ -1,19 +0,13 @@

import {DeclarationType} from "./models/declaration-type";
import {Metakeys} from "./models/metakeys";
import {ComponentMetadataService} from "./decorators/component/metadata.service";
import {IComponentClass} from "./decorators/component/interfaces";
export * from "./decorators/ng-module";
export * from "./decorators/component";
export * from "./decorators/directive";
export * from "./decorators/lifecycle_hooks";
interface IComponentClass extends Function {
$inject?: Array<string>;
bindings?: {[key: string]: string};
controller: Object;
template: string;
constructor: IComponentClass;
}
export function Input(alias?: string): PropertyDecorator {
return function (target: IComponentClass, property: string) {
const componentMetadata = new ComponentMetadataService(target.constructor);
if (!target.constructor.bindings) {

@@ -23,3 +17,6 @@ target.constructor.bindings = {};

target.constructor.bindings[property] = "<" + (alias ? alias : "");
const attrBinding = alias ? alias : property;
target.constructor.bindings[property] = "<" + attrBinding;
componentMetadata.addInput(property, attrBinding);
};

@@ -30,2 +27,4 @@ }

return function (target: IComponentClass, property: string) {
const componentMetadata = new ComponentMetadataService(target.constructor);
if (!target.constructor.bindings) {

@@ -39,2 +38,3 @@ target.constructor.bindings = {};

target.constructor.bindings[privateCallbackName] = `&${attrBinding}`;
componentMetadata.addOutput(property, attrBinding);

@@ -89,40 +89,2 @@ Object.defineProperty(target, privateCallbackName, {

export function Component(config?: {selector?: string, template?: string}): ClassDecorator {
return function (target: any) {
if (config) {
if (config.template) {
target.template = config.template;
}
if (config.selector) {
target.selector = config.selector;
}
}
// Lifecycle hooks aliases
if (target.prototype.ngOnInit) {
target.prototype.$onInit = target.prototype.ngOnInit;
}
if (target.prototype.ngAfterViewInit) {
target.prototype.$postLink = target.prototype.ngAfterViewInit;
}
if (target.prototype.ngOnChanges) {
target.prototype.$onChanges = target.prototype.ngOnChanges;
}
if (target.prototype.ngOnDestroy) {
target.prototype.$onDestroy = target.prototype.ngOnDestroy;
}
// Controller linking
target.controller = target;
Reflect.defineMetadata(Metakeys.type, DeclarationType.component, target);
return target;
};
}
export class EventEmitter {

@@ -129,0 +91,0 @@ private listeners: Array<Function> = [];

export const Metakeys = {
type: "ng1-shift:type"
type: "ng1-shift:type",
componentOptions: "ng1-shift:componentOptions"
};
{
"name": "ng1-shift",
"version": "0.0.11",
"version": "0.0.12",
"description": "Angular 1.5+ decorators for writing Angular2 like.",

@@ -38,15 +38,13 @@ "scripts": {

},
"dependencies": {
"typescript": "2.3.4"
},
"devDependencies": {
"@types/angular": "1.6.26",
"@types/jest": "19.2.4",
"jest": "20.0.4",
"onchange": "3.2.1",
"reflect-metadata": "0.1.10",
"ts-jest": "20.0.5",
"tslib": "1.7.1",
"tslint": "5.8.0"
"@types/angular": "^1.6.42",
"@types/jest": "^22.1.1",
"jest": "^22.1.4",
"onchange": "^3.3.0",
"reflect-metadata": "^0.1.12",
"ts-jest": "^22.0.2",
"tslib": "^1.9.0",
"tslint": "^5.9.1",
"typescript": "^2.7.1"
}
}
# ng1-shift
[![bitHound Overall Score](https://www.bithound.io/github/readdle/ng1-shift/badges/score.svg)](https://www.bithound.io/github/readdle/ng1-shift)
Library allows you to write with Angular 2 syntax on Angular 1.5+. That will make your migration to Angular 2(or 4) more easier.

@@ -131,3 +133,24 @@

In order to setup two-way binding, you should add `@Input` for that property and `@Output` with 'Change' postfix property.
```typescript
class DogComponent {
@Input() name: string;
@Output() nameChange = new EventEmitter();
}
```
Equals to:
```typescript
class DogComponent {
static bindings = {
name: "=",
nameChange: "&"
};
name: string;
nameChange: Function;
}
```
## Output

@@ -134,0 +157,0 @@ Property decorator for callback bindings. Literary puts binding property name into static object `bindings` as callback binding "&".

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