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

custom-ability

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

custom-ability - npm Package Compare versions

Comparing version 2.0.0-alpha.0 to 2.0.0-alpha.1

9

package.json
{
"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 @@

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