Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
bloody-class
Advanced tools
[![Build Status](https://travis-ci.org/bloodyowl/class.svg)](https://travis-ci.org/bloodyowl/class)
$ npm install bloody-class
var klass = require("bloody-class")
Classes are objects that contain inherits for instances. You can extend and create instances of an existing class. Classes are based on prototypal inheritance, that way, you can easily update all subclasses and instances from one of their parent class.
klass.extend([object])
-> newClass
Creates a new class that inherits from klass
. Optionaly takes an object
arguments that extends the newClass
as owned properties.
object
object.mixins
: arraylist of classes the given class should compose with.
klass.create([args …])
-> newInstance
Creates a new instance that inherits from klass
. Its arguments are passed to
klass.constructor
which is called if klass
owns a constructor
method.
instance.destroy([args …])
Removes all the internal references to instance
, as in parent.instances
for
instance. Its arguments are passed to klass.destructor
which is called if
klass
owns a destructor
method.
instance.accessor(name) > function
Returns a function that calls instance[name]
with instance
as thisValue
and passes its arguments to the method.
var klass = require("bloody-class")
var $ = require("jquery")
var view = klass.extend({
constructor : function(){
this.element = $(this.element || document.createElement("div"))
if(typeof this.name != "string") {
throw new TypeError("name must be a string")
}
if(typeof this.initialise == "function") {
this.initialise.apply(this, arguments)
}
this.initEvent()
},
$ : function(selector){
return this.element.find(selector)
},
destructor : function(){
this.element.off("." + this.name)
if(typeof this.release == "function") {
this.release.apply(this, arguments)
}
},
initEvent : function(){
if(!this.events) return
var index = -1
var length = this.events.length
var thisValue = this
while(++index < length) {
;(function(object){
this.element.on(
object.type + ("." + this.name),
object.selector,
function() {
return thisValue[object.listener]
.apply(thisValue, arguments)
}
)
}).call(this, this.events[index])
}
}
})
var myView = view.create({
name : "elementView",
element : "#element",
mixins : [events],
events : [
{
type : "click",
selector : ".js-anchor"
listener : "navigateTo"
}
],
navigateTo : function(eventObject){
window.scrollTo(0, $(eventObject.currentTarget).offset().top)
}
})
FAQs
[![Build Status](https://travis-ci.org/bloodyowl/class.svg)](https://travis-ci.org/bloodyowl/class)
We found that bloody-class demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.