Socket
Socket
Sign inDemoInstall

multimix

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

multimix - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

123

lib/experiments/demo.js

@@ -1,5 +0,4 @@

// Generated by CoffeeScript 2.3.2
(function() {
'use strict';
var CND, alert, badge, debug, example_using_multimix, help, info, rewritten_example, rpr, urge, warn, whisper,
var CND, alert, badge, debug, example_for_overwrite_false, example_using_multimix, help, info, rewritten_example, rpr, urge, warn, whisper,
indexOf = [].indexOf;

@@ -263,2 +262,13 @@

}).call(this));
},
find: function() {
var k;
return info("instance method 'find()'", (function() {
var results;
results = [];
for (k in this) {
results.push(k);
}
return results;
}).call(this));
}

@@ -300,5 +310,9 @@ };

Intertype.extend(object_with_class_properties);
Intertype.extend(object_with_class_properties, {
overwrite: true
});
Intertype.include(object_with_instance_properties);
Intertype.include(object_with_instance_properties, {
overwrite: true
});

@@ -315,3 +329,4 @@ //-------------------------------------------------------------------------------------------------------

//#########################################################################################################
intertype_1 = new Intertype;
target = {};
intertype_1 = new Intertype(target);
intertype_2 = new Intertype;

@@ -331,5 +346,98 @@ info('µ002-1', Intertype.base_types);

info('µ002-11', target.isa('new_on_it1', 1, 2, 3));
return info('µ002-12', target.isa.new_on_it1(1, 2, 3));
info('µ002-12', target.isa.new_on_it1(1, 2, 3));
info('µ002-13', intertype_1.find());
info('µ002-14', intertype_2.find());
debug(target);
return debug(intertype_2);
};
//-----------------------------------------------------------------------------------------------------------
example_for_overwrite_false = function() {
var Intertype, Multimix, error, isa, object_with_class_properties, object_with_instance_properties;
Multimix = require('../..');
//=========================================================================================================
// SAMPLE OBJECTS WITH INSTANCE METHODS, STATIC METHODS
//---------------------------------------------------------------------------------------------------------
object_with_class_properties = {
find: function(id) {
var k;
return info("class method 'find()'", (function() {
var results;
results = [];
for (k in this) {
results.push(k);
}
return results;
}).call(this));
},
create: function(attrs) {
var k;
return info("class method 'create()'", (function() {
var results;
results = [];
for (k in this) {
results.push(k);
}
return results;
}).call(this));
}
};
//---------------------------------------------------------------------------------------------------------
object_with_instance_properties = {
save: function() {
var k;
return info("instance method 'save()'", (function() {
var results;
results = [];
for (k in this) {
results.push(k);
}
return results;
}).call(this));
},
find: function() {
var k;
return info("instance method 'find()'", (function() {
var results;
results = [];
for (k in this) {
results.push(k);
}
return results;
}).call(this));
}
};
//=========================================================================================================
// CLASS DECLARATION
//---------------------------------------------------------------------------------------------------------
isa = function(type, ...xP) {
/* NOTE realistic method should throw error when `type` not in `specs` */
urge(`µ1129 object ${rpr(this.instance_name)} isa ${rpr(type)} called with ${rpr(xP)}`);
urge(`µ1129 my @specs: ${rpr(this.specs)}`);
return urge(`µ1129 spec for type ${rpr(type)}: ${rpr(this.specs[type])}`);
};
try {
Intertype = (function() {
//---------------------------------------------------------------------------------------------------------
class Intertype extends Multimix {};
Intertype.extend(object_with_class_properties, {
overwrite: false
});
Intertype.include(object_with_instance_properties, {
overwrite: false
});
return Intertype;
}).call(this);
} catch (error1) {
// intertype = new Intertype()
error = error1;
warn(error.message);
}
return null;
};
//###########################################################################################################

@@ -340,6 +448,5 @@ if (module.parent == null) {

example_using_multimix();
example_for_overwrite_false();
}
}).call(this);
//# sourceMappingURL=demo.js.map

31

lib/main.js

@@ -1,2 +0,1 @@

// Generated by CoffeeScript 2.3.2
(function() {

@@ -40,9 +39,16 @@ 'use strict';

//---------------------------------------------------------------------------------------------------------
static extend(object) {
static extend(object, settings = null) {
var key, ref, value;
settings = {...{
overwrite: true
}, ...(settings != null ? settings : null)};
for (key in object) {
value = object[key];
if (indexOf.call(module_keywords, key) < 0) {
this[key] = value;
if (!(indexOf.call(module_keywords, key) < 0)) {
continue;
}
if ((!settings.overwrite) && ((this.prototype[key] != null) || (this[key] != null))) {
throw new Error(`^multimix/include@5684 overwrite set to false but name already set: ${rpr(key)}`);
}
this[key] = value;
}

@@ -56,10 +62,17 @@ if ((ref = object.extended) != null) {

//---------------------------------------------------------------------------------------------------------
static include(object) {
static include(object, settings = null) {
var key, ref, value;
settings = {...{
overwrite: true
}, ...(settings != null ? settings : null)};
for (key in object) {
value = object[key];
if (indexOf.call(module_keywords, key) < 0) {
// Assign properties to the prototype
this.prototype[key] = value;
if (!(indexOf.call(module_keywords, key) < 0)) {
continue;
}
if ((!settings.overwrite) && ((this.prototype[key] != null) || (this[key] != null))) {
throw new Error(`^multimix/include@5683 overwrite set to false but name already set: ${rpr(key)}`);
}
// Assign properties to the prototype
this.prototype[key] = value;
}

@@ -131,3 +144,1 @@ if ((ref = object.included) != null) {

}).call(this);
//# sourceMappingURL=main.js.map
{
"name": "multimix",
"version": "2.0.0",
"version": "2.1.0",
"description": "flexible object copying",

@@ -5,0 +5,0 @@ "main": "lib/main.js",

@@ -27,5 +27,6 @@

* `<class>.extend: ( object ) ->`—extends class with the properties of `object` (class-level mixin).
* `<class>.include: ( object ) ->`—extends instances with the properties of `object` (instance-level
mixin).
* `<class>.extend: ( object, settings = null ) ->`—extends class with the properties of `object`
(class-level mixin).
* `<class>.include: ( object, settings = null ) ->`—extends instances with the properties of `object`
(instance-level mixin).
* `<class>.get_keymethod_proxy = ( bind_target, f ) ->`—produces an instance method `f` which will

@@ -49,2 +50,5 @@ translate calls from immediate attributes (as in, `f.some_text some_value`) to calls to `f` proper,

* When `extend()` or `include()` are used with `settings` as ` { overwrite: false, }`, an error will
be raised during class definition time when any name clashes are detected.
Code:

@@ -51,0 +55,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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