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 1.3.0 to 1.3.1

148

lib/custom-ability.js

@@ -36,57 +36,78 @@ (function() {

vName = AbilityClass.name;
vhasCoreMethod = aClass.prototype[(isArray(aCoreMethod) ? aCoreMethod[0] : aCoreMethod)];
if (vName && aClass.prototype.$abilities) {
$abilities = aClass.prototype.$abilities;
}
vHasAddtionalAbility = vName && $abilities && $abilities[vName];
if (aClass == null) {
aClass = AbilityClass;
} else if (!(vhasCoreMethod || ($abilities && $abilities['$' + vName]))) {
if (vName) {
if (!$abilities) {
defineProperty(aClass.prototype, '$abilities', $abilities = {});
}
$abilities['$' + vName] = abilityFn;
if (aClass != null) {
vhasCoreMethod = aClass.prototype[(isArray(aCoreMethod) ? aCoreMethod[0] : aCoreMethod)];
if (vName && aClass.prototype.$abilities) {
$abilities = aClass.prototype.$abilities;
}
if ((aOptions == null) || !(aOptions.include || aOptions.exclude)) {
extend(aClass, AbilityClass);
extend(aClass.prototype, AbilityClass.prototype);
} else {
vIncludes = aOptions.include;
if (vIncludes) {
if (!isArray(vIncludes)) {
vIncludes = [vIncludes];
vHasAddtionalAbility = vName && $abilities && $abilities[vName];
if (!(vhasCoreMethod || ($abilities && $abilities['$' + vName]))) {
if (vName) {
if (!$abilities) {
defineProperty(aClass.prototype, '$abilities', $abilities = {});
}
$abilities['$' + vName] = abilityFn;
}
if ((aOptions == null) || !(aOptions.include || aOptions.exclude)) {
extend(aClass, AbilityClass);
extend(aClass.prototype, AbilityClass.prototype);
} else {
vIncludes = [];
}
if (aCoreMethod) {
if (isArray(aCoreMethod)) {
vIncludes = vIncludes.concat(aCoreMethod);
vIncludes = aOptions.include;
if (vIncludes) {
if (!isArray(vIncludes)) {
vIncludes = [vIncludes];
}
} else {
vIncludes.push(aCoreMethod);
vIncludes = [];
}
}
vExcludes = aOptions.exclude;
if (vExcludes) {
if (!isArray(vExcludes)) {
vExcludes = [vExcludes];
if (aCoreMethod) {
if (isArray(aCoreMethod)) {
vIncludes = vIncludes.concat(aCoreMethod);
} else {
vIncludes.push(aCoreMethod);
}
}
} else {
vExcludes = [];
}
vFilter = function(k) {
return filter(k, vIncludes, vExcludes);
};
filterMethods = function(methods) {
var k;
if (methods instanceof Object) {
for (k in methods) {
if (!vFilter(k)) {
delete methods[k];
vExcludes = aOptions.exclude;
if (vExcludes) {
if (!isArray(vExcludes)) {
vExcludes = [vExcludes];
}
} else {
vExcludes = [];
}
vFilter = function(k) {
return filter(k, vIncludes, vExcludes);
};
filterMethods = function(methods) {
var k;
if (methods instanceof Object) {
for (k in methods) {
if (!vFilter(k)) {
delete methods[k];
}
}
}
};
if (vHasAddtionalAbility) {
vAbilities = getAdditionalAbility(aClass, vName);
i = vAbilities.length;
while (--i >= 0) {
vOptions = vAbilities[i]();
if (vOptions != null) {
filterMethods(vOptions.methods);
filterMethods(vOptions.classMethods);
if (vOptions.methods instanceof Object) {
injectMethods(aClass.prototype, vOptions.methods, vOptions);
}
if (vOptions.classMethods instanceof Object) {
injectMethods(aClass, vOptions.classMethods, vOptions);
}
}
}
}
};
if (vHasAddtionalAbility) {
extendFilter(aClass, AbilityClass, vFilter);
extendFilter(aClass.prototype, AbilityClass.prototype, vFilter);
filterMethods(aOptions.methods);
filterMethods(aOptions.classMethods);
}
if (vHasAddtionalAbility && !vAbilities) {
vAbilities = getAdditionalAbility(aClass, vName);

@@ -97,4 +118,2 @@ i = vAbilities.length;

if (vOptions != null) {
filterMethods(vOptions.methods);
filterMethods(vOptions.classMethods);
if (vOptions.methods instanceof Object) {

@@ -109,30 +128,13 @@ injectMethods(aClass.prototype, vOptions.methods, vOptions);

}
extendFilter(aClass, AbilityClass, vFilter);
extendFilter(aClass.prototype, AbilityClass.prototype, vFilter);
filterMethods(aOptions.methods);
filterMethods(aOptions.classMethods);
}
if (vHasAddtionalAbility && !vAbilities) {
vAbilities = getAdditionalAbility(aClass, vName);
i = vAbilities.length;
while (--i >= 0) {
vOptions = vAbilities[i]();
if (vOptions != null) {
if (vOptions.methods instanceof Object) {
injectMethods(aClass.prototype, vOptions.methods, vOptions);
}
if (vOptions.classMethods instanceof Object) {
injectMethods(aClass, vOptions.classMethods, vOptions);
}
if (aOptions != null) {
if (aOptions.methods instanceof Object) {
injectMethods(aClass.prototype, aOptions.methods, aOptions);
}
if (aOptions.classMethods instanceof Object) {
injectMethods(aClass, aOptions.classMethods, aOptions);
}
}
}
if (aOptions != null) {
if (aOptions.methods instanceof Object) {
injectMethods(aClass.prototype, aOptions.methods, aOptions);
}
if (aOptions.classMethods instanceof Object) {
injectMethods(aClass, aOptions.classMethods, aOptions);
}
}
} else {
aClass = AbilityClass;
}

@@ -139,0 +141,0 @@ return aClass;

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

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

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