mixto
A mixin superclass. Its subclasses have `.extend` and `.includeInto` methods to mix behavior into other objects and classes.
Last updated 12 years ago by kevinsawicki .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install mixto 
SYNC missed versions from official npm registry.

Mixto: A simple mixin superclass Build Status

To create a mixin, subclass mixto:

Mixin = require 'mixto'

class MyMixin extends Mixin
  @classMethod: -> console.log("foo")
  instanceMethod: -> console.log("bar")

Then mix into classes with .includeInto:

class MyClass
  MyMixin.includeInto(this)
  
MyClass.classMethod()
(new MyClass).instanceMethod()

Or extend individual objects with .extend:

myObject = {a: 1, b: 2}
MyMixin.extend(myObject)
myObject.instanceMethod()

Or build standalone instances of your 'mixin':

standalone = new MyMixin
standalone.instanceMethod()

Current Tags

  • 1.0.0                                ...           latest (12 years ago)

5 Versions

  • 1.0.0                                ...           12 years ago
  • 0.4.0                                ...           12 years ago
  • 0.3.0                                ...           12 years ago
  • 0.2.0                                ...           12 years ago
  • 0.1.0                                ...           13 years ago
Maintainers (2)
Downloads
Today 0
This Week 0
This Month 4
Last Day 0
Last Week 4
Last Month 1
Dependencies (0)
None
Dev Dependencies (8)
Dependents (2)

Copyright 2013 - present © cnpmjs.org | Home |