custom-ability
Advanced tools
Comparing version 2.0.0-alpha.0 to 2.0.0-alpha.1
{ | ||
"name": "custom-ability", | ||
"version": "2.0.0-alpha.0", | ||
"version": "2.0.0-alpha.1", | ||
"description": "make custom ability more easy. generate the ability which can be added to any class directly.", | ||
"homepage": "https://github.com/snowyu/custom-ability.js", | ||
"source": "./src/index.ts", | ||
"main": "./lib/index.js", | ||
@@ -30,3 +31,3 @@ "module": "./lib/esm/index.js", | ||
"lint.fix": "npm run lint -- --fix", | ||
"release": "npm run clean && npm run build && npx standard-version", | ||
"release": "npm run clean && npm run build && git add docs && git ci -m 'docs: update API docs' && npx standard-version -s", | ||
"release.alpha": "npm run release -- --prerelease alpha", | ||
@@ -39,4 +40,4 @@ "test": "mocha" | ||
"dependencies": { | ||
"inherits-ex": "^2.1.0-alpha.3", | ||
"util-ex": "^2.0.0-alpha.1" | ||
"inherits-ex": "^2.1.0-alpha.5", | ||
"util-ex": "^2.0.0-alpha.3" | ||
}, | ||
@@ -43,0 +44,0 @@ "devDependencies": { |
@@ -22,3 +22,3 @@ # custom-ability [![Build Status](https://img.shields.io/travis/snowyu/custom-ability.js/master.png)](http://travis-ci.org/snowyu/custom-ability.js) [![npm](https://img.shields.io/npm/v/custom-ability.svg)](https://npmjs.org/package/custom-ability) [![downloads](https://img.shields.io/npm/dm/custom-ability.svg)](https://npmjs.org/package/custom-ability) [![license](https://img.shields.io/npm/l/custom-ability.svg)](https://npmjs.org/package/custom-ability) | ||
1. Define an ability class that contains the methods you want to inject into other classes. | ||
2. Use the customAbility function to create a new function that can inject the ability into target classes. | ||
2. Use the `createAbilityInjector` function to create an injector function that can inject the ability into target classes. | ||
3. Call the new function with the ability class and any optional parameters to inject the ability into a target class. | ||
@@ -115,11 +115,13 @@ | ||
## additional $abilities | ||
## Additional Abilities($abilities) | ||
Another type of injection is the "additional abilities" that can be injected using the methods and classMethods parameters. These additional methods are necessary when modifying existing methods of the target class to call the old/original method to make a certain ability work. | ||
Another type of injection is the "**Additional Abilities**" that can be injected using the methods and classMethods parameters. These additional methods are necessary when modifying existing methods of the target class to call the old/original method to make a certain ability work. | ||
The injected methods are encapsulated in a closure. And the passed `this` object inside the closure is not the original instance object, but `self`, and the original method is referred to as `super`. | ||
**Note**: The methods must be non-enumerable members of the target class(prototype). | ||
In order to make certain ability to work, you need to modify some methods | ||
of the class which could call the old(original) method. this time we need | ||
the "additional abilities" now. eg, the event-able ability to [AbstractObject](https://github.com/snowyu/abstract-object). | ||
the "Additional Abilities" now. eg, the event-able ability to [AbstractObject](https://github.com/snowyu/abstract-object). | ||
We need to send a notification event when the state of the object changes(life cycle). | ||
@@ -188,2 +190,4 @@ So the event-able of [AbstractObject](https://github.com/snowyu/abstract-object) | ||
Full API see the folder: [docs](docs/modules.md) | ||
This library provides a function customAbility that can inject the abilities of a "mixin" class onto another target class or object. | ||
@@ -240,2 +244,9 @@ | ||
### V2 | ||
* Transpile to ESM Format in lib/esm folder | ||
* Export all helper functions on index.js | ||
* TypeScript supports | ||
* NodeJS >= 12 | ||
### V1.6.2 | ||
@@ -242,0 +253,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
114878
539
0
Updatedinherits-ex@^2.1.0-alpha.5
Updatedutil-ex@^2.0.0-alpha.3