custom-ability
Advanced tools
+3
-3
| { | ||
| "name": "custom-ability", | ||
| "version": "2.0.0-alpha.7", | ||
| "version": "2.0.0", | ||
| "description": "make custom ability more easy. generate the ability which can be added to any class directly.", | ||
@@ -39,4 +39,4 @@ "homepage": "https://github.com/snowyu/custom-ability.js", | ||
| "dependencies": { | ||
| "inherits-ex": "^2.1.0-alpha.12", | ||
| "util-ex": "^2.0.0-alpha.10" | ||
| "inherits-ex": "^2.1.0", | ||
| "util-ex": "^2.0.0" | ||
| }, | ||
@@ -43,0 +43,0 @@ "devDependencies": { |
@@ -388,5 +388,10 @@ import chai, { expect } from 'chai'; | ||
| it('should inject class methods', function() { | ||
| var My, newExec, oldExec; | ||
| My = function() {}; | ||
| My.exec = oldExec = sinon.spy(function() {}); | ||
| let newExec; | ||
| const oldExec = sinon.spy(function() {}) | ||
| class My { | ||
| static exec: any = oldExec; | ||
| } | ||
| testable(My, { | ||
@@ -405,2 +410,28 @@ classMethods: { | ||
| }); | ||
| it('should inject class method in parent', function() { | ||
| let newExec; | ||
| const oldExec = sinon.spy(function() {}) | ||
| class MyRoot { | ||
| static exec: any = oldExec; | ||
| } | ||
| class My extends MyRoot { } | ||
| testable(My, { | ||
| classMethods: { | ||
| exec: newExec = sinon.spy(function() { | ||
| this['super'].apply(this.self, arguments); | ||
| }) | ||
| } | ||
| }); | ||
| My.exec(1, 2, 3); | ||
| newExec.should.be.calledOnce; | ||
| newExec.should.be.calledWith(1, 2, 3); | ||
| oldExec.should.be.calledOnce; | ||
| oldExec.should.be.calledWith(1, 2, 3); | ||
| }); | ||
| //assert.equal oldExec, true, 'should execute the original func' | ||
@@ -407,0 +438,0 @@ //assert.equal newExec, true, 'should execute the new func' |
@@ -365,2 +365,21 @@ import chai from 'chai'; | ||
| }); | ||
| it('should inject class methods in parent', function() { | ||
| var My, MyRoot, newExec, oldExec; | ||
| MyRoot = function() {}; | ||
| My = function() {}; | ||
| inherits(My, MyRoot); | ||
| MyRoot.exec = oldExec = sinon.spy(function() {}); | ||
| testable(My, { | ||
| classMethods: { | ||
| exec: newExec = sinon.spy(function() { | ||
| this['super'].apply(this.self, arguments); | ||
| }) | ||
| } | ||
| }); | ||
| My.exec(1, 2, 3); | ||
| newExec.should.be.calledOnce; | ||
| newExec.should.be.calledWith(1, 2, 3); | ||
| oldExec.should.be.calledOnce; | ||
| oldExec.should.be.calledWith(1, 2, 3); | ||
| }); | ||
| it('should not inject methods twice', function() { | ||
@@ -367,0 +386,0 @@ var My, Root, my, newExec, oldExec; |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
157659
0.73%3361
1.23%0
-100%Updated
Updated