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.2.0 to 0.3.0

64

lib/Cocktail.js

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

Cocktail,
ANNOTATION_REG_EXP = /^@/,
DEFAULT_PROCESSORS = {};
ANNOTATION_REG_EXP = /^@/;

@@ -22,4 +21,12 @@

/**
*@private
* Current processor list map
*/
_processors: {},
/**
* @protected
* Returns the processor list map
*/
getProcessors : function(){

@@ -29,18 +36,16 @@ return this._processors;

// -- >Experimental
// --- This methods are used for testing, find a better desing to avoid them
restoreDefaultProcessors: function() {
this._processors = DEFAULT_PROCESSORS;
/**
* @protected
* sets the processor object list. It is an Object used as a map
*/
setProcessors: function (processor) {
this._processors = processor;
},
clearProcessors: function() {
var processors = this.getProcessors(),
key;
for(key in processors){
if(processors.hasOwnProperty(key) && key !== 'no-op'){
delete processors[key];
}
}
/**
* @protected
* returns the list of default processors
*/
getDefaultProcessors: function () {
return Cocktail._DEFAULT_PROCESSORS;
},

@@ -58,6 +63,2 @@

// -- >End of Experimental
/**

@@ -70,5 +71,3 @@ * @private

P;
P = (processors[key] || processors['no-op']);
return new P();

@@ -167,13 +166,16 @@ },

_isClassDefition: function (subject) {
var isClassDef = false,
var isClassDef = (subject && subject['@as'] && subject['@as'].toLowerCase() === 'class'),
definitionProps = ['constructor', '@extends', '@traits', '@requires', '@annotation'],
key;
for (key in subject) {
if(definitionProps.indexOf(key) > -1){
isClassDef = true;
break;
if (!isClassDef) {
for (key in subject) {
if(definitionProps.indexOf(key) > -1){
isClassDef = true;
break;
}
}
}
return isClassDef;

@@ -218,3 +220,2 @@ },

options = subject;
return this.mix(defaultConstructor, options);

@@ -251,4 +252,5 @@

*/
DEFAULT_PROCESSORS = {
Cocktail._DEFAULT_PROCESSORS = {
'no-op' : require('./processor/NoOp'),
'@as' : undefined,
'@merge' : require('./processor/annotation/Merge'),

@@ -265,3 +267,3 @@ '@extends' : require('./processor/annotation/Extends'),

Cocktail.registerProcessors(DEFAULT_PROCESSORS);
Cocktail.registerProcessors(Cocktail._DEFAULT_PROCESSORS);

@@ -271,5 +273,5 @@ Cocktail.mix(Cocktail, {

* @public
* SEQUENCE is used to define a enumaration of priorities for annotations
* SEQUENCE is used to define a enumeration of priorities for annotations
*/
SEQUENCE: sequence
});
{
"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.2.0",
"version": "0.3.0",
"homepage": "http://cocktailjs.github.io",

@@ -6,0 +6,0 @@ "author": {

@@ -54,3 +54,20 @@ # Cocktail JS

###Even easier Single Parameter Class Definition
Version 0.3 introduces a pseudo-annotation `@as` to help Single Parameter Class Definition. Now you can define
a Class using `@as` passing a value of `class`:
MySuperClass.js
var Cocktail = require('Cocktail')
Cocktail.mix({
'@exports' : module,
'@as' : 'class',
'@properties' : {
name: 'a default name'
}
});
## Getting Started

@@ -95,4 +112,10 @@

- 0.2.0 (current master)
- 0.3.0 (current master)
- status: Alpha
- Introduced pseudo-annotation `@as` intended for single parameter class definition
- Tests for pseudo-annotation `@as`
- 0.2.0
- status: Alpha
- Added single parameter class/trait definition. If the first parameter is an object literal and it contains a

@@ -99,0 +122,0 @@ constructor definition, or the annotation '@extends', '@traits', '@requires' or '@annotation' it will be treated as

Sorry, the diff of this file is not supported yet

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