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.0.3 to 0.0.4

89

lib/processor/annotation/Merge.js

@@ -13,7 +13,14 @@ /*

retain : false,
value : undefined,
name : '@merge',
_value: undefined,
_value : undefined,
_strategies: {
'single' : '_mergeMine',
'mine' : '_mergeMine',
'their' : '_mergeTheir',
'deep-mine' : '_mergeDeepMine',
'deep-their' : '_mergeDeepTheir'
},
setParameter: function(value){

@@ -27,3 +34,6 @@ this._value = value;

_merge : function(mine, their){
/**
* mine merge strategy: mine params over their. If params is already defined it gets overriden.
*/
_mergeMine : function(mine, their){
var key;

@@ -40,7 +50,76 @@

/**
* deepMine merge strategy: mine params over their.
* If params is already defined and it is an object it is merged with strategy mine,
* if params is already defined and it is an array it is concatenated,
* otherwise it gets overriden with mine.
*/
_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;
},
/**
* their merge strategy: their params over mine. If params is already defined it doesn't get overriden.
*/
_mergeTheir : function(mine, their){
var key;
for(key in their){
if(their.hasOwnProperty(key) && mine[key] === undefined ){
mine[key] = their[key];
}
}
return mine;
},
/**
* deepMine merge strategy: their params over mine.
* If params is already defined and it is an object it is merged with strategy their,
* if params is already defined and it is an array it is concatenated,
* otherwise it gets overriden with mine.
*/
_mergeDeepTheir : 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._mergeTheir(mine[key], their[key]);
}
}else if(mine[key] === undefined ){
mine[key] = their[key];
}
}
}
return mine;
},
process: function(subject, proto){
var their = proto,
mine = subject.prototype || subject;
mine = subject.prototype || subject,
strategy = this._strategies[this.getParameter()];
this._merge(mine, their);
this[strategy](mine, their);
}

@@ -47,0 +126,0 @@ };

9

package.json
{
"name": "cocktail",
"description": "Annotations, Traits and Talents - Shake your objects and classes with Cocktail!",
"version": "0.0.3",
"homepage": "http://cocktailjs.github.com",
"description": "CocktailJS is an small library to explore traits, talents, inheritance and annotations concepts in nodejs - Shake your objects and classes with Cocktail!",
"version": "0.0.4",
"homepage": "http://cocktailjs.github.io",
"author": {

@@ -50,4 +50,5 @@ "name": "Maximiliano Fierro",

"mix",
"class"
"class",
"inheritance"
]
}

@@ -37,8 +37,10 @@ # Cocktail JS [![Build Status](https://travis-ci.org/CocktailJS/Cocktail.png?branch=master)](https://travis-ci.org/CocktailJS/Cocktail)

## Getting Started
- Install the module with: `npm install cocktail`
- Start playing by just adding a `require('Cocktail')` in your file.
Guides will be soon posted on CocktailJS site.
- Install the module with: `npm install cocktail` or add cocktail to your `package.json` and then `npm install`
- Start playing by just adding a `var Cocktail = require('Cocktail')` in your file.
## Documentation
_(Coming soon)_
The latest documentation is published at [CocktailJS Documentation](http://cocktailjs.github.io/docs/)

@@ -52,6 +54,25 @@ ## Examples

## Release History
_(Nothing yet)_
- 0.0.4 (current master)
- status: Alpha
- Added new merge strategies: mine (default -same as single), their, deep-mine and deep-their.
- Test for Merge strategies.
- 0.0.3
- status: Alpha.
- Annotation, traits, talents, extends, and properties features are stable and tested.
- Adde custom Annotations definitions mechanism thru @annotation.
- Added merge strategy: single.
- 0.0.2
- status: Alpha.
- Alpha version for traits, talents, extends, and properties features.
- Tests.
- 0.0.1
- status: Alpha.
- First draft version
## License
Copyright (c) 2013 Maximiliano Fierro
Licensed under the MIT license.
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