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 - npm Package Compare versions

Comparing version 0.4.6 to 0.5.0

6

CHANGELOG.md
##CHANGE LOG
- 0.5.0
- status: Alpha
- Added new method to register custom annotations (cocktail.use())
- Refactored `@annotation` processor.
- Small code improvements and tests.
- 0.4.6

@@ -4,0 +10,0 @@ - status: Alpha

@@ -55,2 +55,7 @@ /*

/**
* @protected
* registers a processor definition
* @param processorsConfig {Object} a key-value pair of processors
*/
registerProcessors: function(processorsConfig){

@@ -67,2 +72,15 @@ var processors = this.getProcessors(),

/**
* @public
*/
use: function(annotation){
var name = annotation.name || (annotation.prototype && annotation.prototype.name),
processor = {};
if(name && annotation.prototype){
processor[name] = annotation;
this.registerProcessors(processor);
}
},
/**
* @private

@@ -69,0 +87,0 @@ * returns a processor instance for the given key or a NoOp instance if it is not found.

12

lib/processor/annotation/Annotation.js

@@ -9,4 +9,3 @@ /*

var cocktail = require('../../cocktail'),
sequence = require('../sequence'),
var sequence = require('../sequence'),
Annotation = function(){};

@@ -29,9 +28,6 @@

process: function(subject /*, proto*/){
var name = '@'+this.getParameter(),
processor = {};
process: function(subject){
var name = '@'+this.getParameter();
processor[name] = subject;
cocktail.registerProcessors(processor);
subject.prototype.name = name;
}

@@ -38,0 +34,0 @@

@@ -71,18 +71,3 @@ /*

_mergeDeepMine : function(mine, their){
var key;
for(key in their){
if(their.hasOwnProperty(key)){
if(typeof their[key] === "object"){
if(their[key] instanceof Array){
mine[key] = [].concat(mine[key], their[key]);
}else{
mine[key] = this._mergeMine(mine[key], their[key]);
}
}else{
mine[key] = their[key];
}
}
}
return mine;
return this._mergeDeep(mine, their, this._mergeMine);
},

@@ -106,3 +91,2 @@

/**

@@ -115,2 +99,9 @@ * deepMine merge strategy: their params over mine.

_mergeDeepTheir : function(mine, their){
return this._mergeDeep(mine, their, this._mergeTheir);
},
/**
* runs the deep merge using the given strategy
*/
_mergeDeep: function(mine, their, strategy){
var key;

@@ -124,3 +115,3 @@

}else{
mine[key] = this._mergeTheir(mine[key], their[key]);
mine[key] = strategy(mine[key], their[key]);
}

@@ -133,3 +124,3 @@ }else if(mine[key] === undefined ){

return mine;
},
},

@@ -140,4 +131,4 @@ _shouldUsePrototypeWhenSubjectIsClass: function() {

process: function(subject, proto){
var their = proto,
process: function(subject, options){
var their = options,
useProto = this._shouldUsePrototypeWhenSubjectIsClass(),

@@ -144,0 +135,0 @@ mine = (useProto && subject.prototype) || subject,

{
"name": "cocktail",
"description": "CocktailJS is a small library to explore traits, talents, inheritance and annotations concepts in nodejs - Shake your objects and classes with Cocktail!",
"version": "0.4.6",
"version": "0.5.0",
"homepage": "http://cocktailjs.github.io",

@@ -35,3 +35,3 @@ "author": {

"grunt-mocha": "0.2.1",
"grunt-contrib-jshint": "~0.1.1",
"grunt-contrib-jshint": "~0.7.2",
"grunt-contrib-watch": "~0.2.0",

@@ -38,0 +38,0 @@ "grunt": "~0.4.1",

# Cocktail JS
[![Build Status](https://travis-ci.org/CocktailJS/cocktail.png?branch=master)](https://travis-ci.org/CocktailJS/cocktail)
[![NPM version](https://badge.fury.io/js/cocktail.png)](http://badge.fury.io/js/cocktail)
[![Code Climate](https://codeclimate.com/github/CocktailJS/cocktail.png)](https://codeclimate.com/github/CocktailJS/cocktail)

@@ -5,0 +7,0 @@ Cocktail is a small but yet powerful library with very simple principles:

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