New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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 1.4.2 to 1.4.3

12

lib/custom-ability.js
(function() {
'use strict';
var defineProperty, extend, extendFilter, getNonEnumNames, injectMethod, injectMethods, injectMethodsFromNonEnum, isArray, isBoolean, isFunction, isInjectedOnParent,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };

@@ -84,3 +84,3 @@ isArray = require('util-ex/lib/is/type/array');

extendFilter(aClass, AbilityClass, function(k) {
return !(__indexOf.call(vExcludes, k) >= 0);
return !(indexOf.call(vExcludes, k) >= 0);
});

@@ -93,3 +93,3 @@ if (vAddtionalAbilityInjected) {

extend(aClassPrototype, AbilityClass.prototype, function(k) {
return !(__indexOf.call(vExcludes, k) >= 0);
return !(indexOf.call(vExcludes, k) >= 0);
});

@@ -179,8 +179,8 @@ }

if (result) {
result = __indexOf.call(aIncludes, k) >= 0;
result = indexOf.call(aIncludes, k) >= 0;
if (!result && aExcludes.length) {
result = !(__indexOf.call(aExcludes, k) >= 0);
result = !(indexOf.call(aExcludes, k) >= 0);
}
} else if (aExcludes.length) {
result = !(__indexOf.call(aExcludes, k) >= 0);
result = !(indexOf.call(aExcludes, k) >= 0);
} else {

@@ -187,0 +187,0 @@ result = true;

@@ -6,3 +6,3 @@ (function() {

addAbility = require(packageName + '/ability');
} catch (_error) {}
} catch (undefined) {}
if (!addAbility) {

@@ -9,0 +9,0 @@ throw TypeError('the package no ability supports.');

{
"name": "custom-ability",
"version": "1.4.2",
"version": "1.4.3",
"description": "make custom ability more easy. generate the ability which can be added to any class directly.",

@@ -19,7 +19,7 @@ "homepage": "https://github.com/snowyu/custom-ability.js",

"dependencies": {
"inherits-ex": "~1.1.3",
"util-ex": "^0.3.10"
"inherits-ex": "~1.2.0",
"util-ex": "^0.3.15"
},
"devDependencies": {
"chai": "~2.0.0",
"chai": "~4.1.0",
"connect-livereload": "*",

@@ -32,10 +32,10 @@ "grunt": "*",

"grunt-contrib-watch": "*",
"grunt-mocha-test": "~0.12.7",
"grunt-mocha-test": "~0.13.2",
"grunt-newer": "*",
"grunt-release": "*",
"grunt-saucelabs": "*",
"mocha": "~2.1.0",
"pre-commit": "~1.0.4",
"sinon": "~1.12.2",
"sinon-chai": "~2.7.0",
"mocha": "~3.4.2",
"pre-commit": "~1.2.2",
"sinon": "~2.4.1",
"sinon-chai": "~2.12.0",
"source-map-support": "*"

@@ -42,0 +42,0 @@ },

@@ -13,5 +13,5 @@ ### 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)

suppose we wanna add the RefCount ability to any class directly.
Suppose we wanna add the RefCount ability to any class directly.
the RefCount ability will add the following members to your class.
the `RefCount` ability will add the following members to your class.
and you should implement the `destroy` method which will be called

@@ -21,3 +21,3 @@ by `release`/`free`.

* properties:
* RefCount *(integer)*: the reference count.
* `RefCount` *(integer)*: the reference count.
* methods:

@@ -34,2 +34,3 @@ * `release()`/`free()`: Decrements reference count for this instance.

```coffee
# ability.coffee
customAbility = require 'custom-ability'

@@ -53,3 +54,5 @@

# We set the `addRef` method as the core methods.
# The Core methods are the ability MUST have.
# they're used to check the same ability whether the ability already added.
module.exports = customAbility RefCountable, 'addRef'

@@ -59,3 +62,3 @@

do not forget to add the `"ability"` keyword to your package.json which means
Do not forget to add the `"ability"` keyword to your package.json which means
the ability power with it.

@@ -71,3 +74,3 @@

do not forget to add the `"ability.js"` file on your package root folder too.
Do not forget to add the `"ability.js"` file on your package root folder too.

@@ -98,4 +101,4 @@ now user use this ability like this:

In order to make certain ability to work, you need to modify some methods
of the class. this time we need the "additional abilities" now. eg, the
event-able ability to [AbstractObject](https://github.com/snowyu/abstract-object).
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).
We need to send a notification event when the state of the object changes.

@@ -119,3 +122,3 @@ So the event-able of [AbstractObject](https://github.com/snowyu/abstract-object)

extend aOptions.methods,
# override methods:
# override methods: (btw: classMethods to override the class methods)
setObjectState: (value, emitted = true)->

@@ -131,5 +134,6 @@ self= @self

the original `eventable('events-ex/eventable')` is no useful for AbstractObject.
**TODO: need to more explain:**
The original `eventable('events-ex/eventable')` is no useful for AbstractObject.
but we wanna the original `eventable('events-ex/eventable')` knows the changes
But we wanna the original `eventable('events-ex/eventable')` knows the changes
and use it automatically.

@@ -170,3 +174,3 @@

* abilityClass *(function)*: the class will become to ability able.
* coreMethod *(string|array)*: optional must have coreMethod(s).
* coreMethod *(string|arrayOf string)*: optional must have coreMethod(s).
* isGetClassFunction *(boolean)*: the `AbilityClass` is a `function(aClass, aOptions)`

@@ -179,3 +183,3 @@ to return the real `Ability Class` if true. defaults to false.

the custom ability function has two arguments: `function(class[, options])`
This custom ability injection function has two arguments: `function(class[, options])`

@@ -192,3 +196,3 @@ * `class`: the class to be injected the ability.

* `this.self` is the original `this` object.
* `classMethods` *(object)*: hooked class methods to the class, it's the same as the `methods`.
* `classMethods` *(object)*: hooked class methods to the class, it's the same usage as the `methods`.
* `replacedMethods` *(array)*: the method name in the array will be replaced the original

@@ -195,0 +199,0 @@ method directly.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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