Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bennidi/coffee-latte
Sweet mixins for coffeescript. Supports prototype and class methods as well as constructor call hierarchies.
https://github.com/bennidi/coffee-latte
coffeescript mixins prototype traits
Last synced: about 1 month ago
JSON representation
Sweet mixins for coffeescript. Supports prototype and class methods as well as constructor call hierarchies.
- Host: GitHub
- URL: https://github.com/bennidi/coffee-latte
- Owner: bennidi
- Created: 2016-12-23T20:52:09.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2016-12-26T18:26:04.000Z (almost 8 years ago)
- Last Synced: 2024-09-14T09:16:18.176Z (about 2 months ago)
- Topics: coffeescript, mixins, prototype, traits
- Language: CoffeeScript
- Size: 104 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Latte: Advanced mixins for CoffeeScript
As CoffeeScript users we have been told many times that there is no support for mixins on the language level because it is so easy to implement them on top of native language concepts. Although I believe that native support for Mixins would be a lovely addition to CS, I also understand that it ain't gonna happen.
## Features
- Mixins are classes, no restrictions made
- Both prototype and class level properties take part in mixes
- Mixin consumers are classes that extend Mixin
- Mixins can extend Mixins
- Mixins can have constructors```coffeescript
class AutoUUID
constructor: -> @_id ?= randomId()class Named extends Mixin
constructor:(@name)->
nickname: -> "nick#{@name}"
@staticName:->"static#{@name}"class NamedIdentifiable extends Mixin
@with AutoUUID, Named
constructor:-> super() # super call is required
instance = new NamedIdentifiable()
expect(instance).to.have.property '_id'
expect(instance.nickname()).to.be 'nickundefined'```