Comparing version 1.0.1 to 1.0.2
41
index.js
var exports = {}; | ||
exports.abstract = function (type) { | ||
var old = type; | ||
type = (function () { | ||
var old = this.old; | ||
return function () { | ||
if (this.constructor == old) | ||
throw Error(type.name + " instance can not be created!"); | ||
old.apply(this, arguments); | ||
} | ||
}).call({ old: old }); | ||
type.prototype = old.prototype; | ||
Object.defineProperty(type, "name", { value: old.name }); | ||
return type; | ||
var fn = 'function ' + type.name + '() { if (this.constructor == type) throw Error(type.name + " instance can not be created!"); type.apply(this, arguments); }'; | ||
var ju = new Function("type", "return " + fn + ";")(type); | ||
ju.prototype = type.prototype; | ||
Object.defineProperty(ju, "name", { value: type.name }); | ||
return ju; | ||
} | ||
exports.inherit = function (type, base) { | ||
var old = type; | ||
type = (function () { | ||
var old = this.old, base = this.base; | ||
return function () { | ||
base.apply(this, arguments); | ||
old.apply(this, arguments); | ||
} | ||
}).call({ old: old, base: base }); | ||
type.prototype = old.prototype; | ||
type.prototype.__proto__ = base.prototype; | ||
Object.defineProperty(type, "name", { value: old.name }); | ||
return type; | ||
var fn = 'function ' + type.name + '() { base.apply(this, arguments); type.apply(this, arguments); }'; | ||
var ju = new Function("type", "base", "return " + fn + ";")(type, base); | ||
ju.prototype = type.prototype; | ||
ju.prototype.__proto__ = base.prototype; | ||
Object.defineProperty(ju, "name", { value: type.name }); | ||
return ju; | ||
} | ||
module.exports = exports; |
{ | ||
"name": "jujsoop", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "For inheritance in javascript.", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "mocha" | ||
}, | ||
@@ -19,7 +19,10 @@ "author": "josephuz", | ||
}, | ||
"keywords":[ | ||
"keywords": [ | ||
"OOP", | ||
"Javascript OOP", | ||
"Inheritance" | ||
] | ||
], | ||
"devDependencies": { | ||
"mocha": "^5.2.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
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
1
3480
1
16