| Server IP : 34.87.99.72 / Your IP : 216.73.217.31 Web Server : Apache/2.4.46 (Unix) OpenSSL/1.1.1n System : Linux zlock-bitnami-lamp-prod-v2-vm 4.19.0-16-cloud-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64 User : bitnami ( 1000) PHP Version : 7.4.18 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /opt/bitnami/nami/node_modules/prime/prime/ |
Upload File : |
/*
prime
- prototypal inheritance
*/"use strict"
var has = function(self, key){
return Object.hasOwnProperty.call(self, key)
}
var each = function(object, method, context){
for (var key in object) if (method.call(context, object[key], key, object) === false) break
return object
}
/*(es5 && fixEnumBug)?*/
if (!({valueOf: 0}).propertyIsEnumerable("valueOf")){ // fix stupid IE enum 🐛
var buggy = "constructor,toString,valueOf,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString".split(","),
proto = Object.prototype
each = function(object, method, context){
var i = buggy.length, key, value
for (key in object) if (method.call(context, object[key], key, object) === false) return object
while (i--){
key = buggy[i]
value = object[key]
if (value !== proto[key] && method.call(context, value, key, object) === false) break
}
return object
}
}/*:*/
var create = Object.create/*(es5)?*/ || function(self){
var F = function(){}
F.prototype = self
return new F
}/*:*/
var mutator = function(key, value){
this.prototype[key] = value
}
var implement = function(obj){
each(obj, function(value, key){
if (key !== "constructor" && key !== "inherits" && key !== "mutator") this.mutator(key, value)
}, this)
return this
}
var prime = function(proto){
var superprime = proto.inherits, superproto
if (superprime) superproto = superprime.prototype
// if our nice proto object has no own constructor property
// then we proceed using a ghosting constructor that all it does is
// call the parent's constructor if it has a superprime, else an empty constructor
// proto.constructor becomes the effective constructor
var constructor = (has(proto, "constructor")) ? proto.constructor : (superprime) ? function(){
return superproto.constructor.apply(this, arguments)
} : function(){}
if (superprime){
// inherit from superprime
var cproto = constructor.prototype = create(superproto)
// setting constructor.parent to superprime.prototype
// because it's the shortest possible absolute reference
constructor.parent = superproto
cproto.constructor = constructor
}
// inherit (kindof inherit) mutator
constructor.mutator = proto.mutator || (superprime && superprime.mutator) || mutator
// copy implement (this should never change)
constructor.implement = implement
// finally implement proto and return constructor
return constructor.implement(proto)
}
prime.each = each
prime.has = has
prime.create = create
module.exports = prime