Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
spec
script
src
*.coffee
.npmignore
.DS_Store
npm-debug.log
Expand Down
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ notifications:
email: false

node_js:
- 0.10
- 8
- 10
- 12
- 14

branches:
only:
Expand Down
2 changes: 1 addition & 1 deletion Gruntfile.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = (grunt) ->

shell:
test:
command: 'node --harmony_collections node_modules/jasmine-focused/bin/jasmine-focused --coffee --captureExceptions spec'
command: 'jasmine-focused --coffee --captureExceptions spec'
options:
stdout: true
stderr: true
Expand Down
49 changes: 47 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,50 @@
# Mixto: A simple mixin superclass [![Build Status](https://travis-ci.org/atom/mixto.png?branch=master)](https://travis-ci.org/atom/mixto)

# JavaScript Classes (ES6)

To create a mixin, subclass mixto:

```js
const Mixin = require('mixto/lib/es6')

class MyMixin extends Mixin {
static classMethod() { console.log("foo"); }
instanceMethod() { console.log("bar"); }
}
```

Then mix into classes with `.includeInto`:

```js
class MyClass {
static initClass() {
MyMixin.includeInto(this); // adds all the mixin's class properties or prototype properties to the target class if they aren't already defined
}
}
MyClass.initClass();

MyClass.classMethod();
(new MyClass).instanceMethod();
```

Or extend individual objects with `.extend`:

```js
const myObject = {a: 1, b: 2};
MyMixin.extend(myObject); // adds all the mixin's prototype properties to the target object if they aren't already defined
myObject.instanceMethod();
```

Or build standalone instances of your 'mixin':

```js
const standalone = new MyMixin;
standalone.instanceMethod();
```


# CoffeeScript 1 Classes (ES5)

To create a mixin, subclass mixto:

```coffee
Expand All @@ -15,7 +60,7 @@ Then mix into classes with `.includeInto`:
```coffee
class MyClass
MyMixin.includeInto(this)

MyClass.classMethod()
(new MyClass).instanceMethod()
```
Expand All @@ -30,7 +75,7 @@ myObject.instanceMethod()

Or build standalone instances of your 'mixin':

```
```coffee-script
standalone = new MyMixin
standalone.instanceMethod()
```
Loading