Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cocktail

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cocktail

Shake your Objects and Classes with Cocktail!

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
126
increased by13.51%
Maintainers
1
Weekly downloads
 
Created
Source

Cocktail JS Build Status

Cocktail is a small but yet powerful library with very simple principles:

  • Reuse code
  • Keep it simple

##Reuse code Cocktail explores three mechanisms to share/reuse/mix code:

  • Extends: Classical OOP inheritance implemented in Javascript.
  • Traits: Traits are composable behavior units that can be added to a Class.
  • Talents: Same idea as Traits but applied to instances of a Class.

##Keep it simple Cocktail has only one public method Cocktail.mix() but it relies on annotations to tag some meta-data that describe the mix.

###Annotations Annotations are simple meta-data Cocktail uses to perform some tasks over the given mix. They become part of the process but usually they are not kept in the result of a mix.

var Cocktail = require('Cocktail'),
	MyClass  = function(){};
	
Cocktail.mix(MyClass, {
	'@properties': {
		name: 'default name'
	}
});	

In the example above we created a "Class" named MyClass, and we use the @properties annotation to create the property name and the corresponding setName and getName methods.

As it was mentioned before, annotations are meta-data, which means that they are not part of MyClass or its prototype.

Getting Started

  • Install the module with: npm install cocktail
  • Start playing by just adding a require('Cocktail') in your file.

Documentation

(Coming soon)

Examples

A Cocktail playground can be found in cocktail recipes repo.

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Release History

(Nothing yet)

License

Copyright (c) 2013 Maximiliano Fierro
Licensed under the MIT license.

FAQs

Package last updated on 27 Mar 2013

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc