This repository has been archived by the owner on Aug 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(common): ES5 support, Catch accepts arguments passed into decora…
…ted function (#38)
- Loading branch information
Showing
11 changed files
with
60 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
src/**/*.ts | ||
!src/**/*.d.ts | ||
index.ts | ||
tsconfig.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export interface CommonMeta { | ||
parameters: { | ||
[key: string]: number[]; | ||
}; | ||
} | ||
|
||
export interface CommonClass extends Object { | ||
__meta__: CommonMeta; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import { CommonClass, CommonMeta } from './interface'; | ||
|
||
/** | ||
* Get or initiate metadata on target | ||
* @param target | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"compileOnSave": false, | ||
"compilerOptions": { | ||
"declaration": true, | ||
"emitDecoratorMetadata": true, | ||
"experimentalDecorators": true, | ||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
"noEmitOnError": true, | ||
"noImplicitAny": false, | ||
"rootDir": ".", | ||
"sourceMap": true, | ||
"target": "es5", | ||
"pretty": true, | ||
"lib": [ | ||
"es2015" | ||
] | ||
}, | ||
"files": [ | ||
"src/index.ts" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,20 @@ | ||
import { Log, Bind } from '@decorators/common'; | ||
import { Catch } from '@decorators/common'; | ||
|
||
@Log() | ||
class Animal { | ||
|
||
constructor( | ||
public name: string | ||
) {} | ||
|
||
@Bind() | ||
@Catch((volume: number, err: Error) => { | ||
console.log(volume); | ||
console.log(err); | ||
}) | ||
sound(volume: number) { | ||
console.log(this.name, ': Auuuu', volume); | ||
throw new Error(volume.toString()); | ||
} | ||
|
||
} | ||
|
||
let rabbit: Animal = new Animal('Rabbit'); | ||
|
||
function exec(fn, arg) { | ||
//some heavy logic | ||
return fn(arg); | ||
} | ||
|
||
|
||
|
||
rabbit.sound = function () { | ||
console.log(this.name); | ||
}; | ||
|
||
exec(rabbit.sound, 500); | ||
rabbit.sound(10); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.