protoblast
Advanced tools
Comparing version 0.6.0 to 0.6.1
@@ -0,1 +1,8 @@ | ||
## 0.6.1 (2018-10-16) | ||
* `Informer#forwardEvent()` now accepts a single event emitter to forward ALL events to | ||
* Make `Blast#setImmediate()` throw an error if the callback argument isn't a function | ||
* `Function.setMethod()` will use `Obj.getPropertyDescriptor` to check existing methods, so no getters are accidentally triggered | ||
* Fix inheriting from a namespace when it is not yet available | ||
## 0.6.0 (2018-08-27) | ||
@@ -2,0 +9,0 @@ |
@@ -24,7 +24,7 @@ module.exports = function BlastCache(Blast, Collection) { | ||
* @since 0.6.0 | ||
* @version 0.6.0 | ||
* @version 0.6.1 | ||
*/ | ||
var Cache = Collection.Function.inherits('Informer', 'Develry', function Cache(options) { | ||
this.reset(); | ||
Object.assign(this, options); | ||
this.reset(); | ||
}); | ||
@@ -31,0 +31,0 @@ |
@@ -127,3 +127,3 @@ module.exports = function BlastInheritance(Blast, Collection) { | ||
* @since 0.2.1 | ||
* @version 0.5.0 | ||
* @version 0.6.1 | ||
* | ||
@@ -137,3 +137,4 @@ * @param {String} namespace | ||
var result, | ||
name; | ||
name, | ||
data; | ||
@@ -172,2 +173,12 @@ // Try getting the namespace | ||
Obj.setPath(Blast.Classes, namespace, result); | ||
// Emit the creation of this namespace | ||
if (Blast.emit) { | ||
data = { | ||
type : 'namespace', | ||
namespace : namespace | ||
}; | ||
Blast.emit(data, namespace); | ||
} | ||
} | ||
@@ -307,3 +318,3 @@ | ||
* @since 0.1.3 | ||
* @version 0.5.1 | ||
* @version 0.6.1 | ||
* | ||
@@ -321,2 +332,3 @@ * @param {String|Function|Array} _parent Parent class to inherit from | ||
parent_constructor, | ||
whenClassAvailable, | ||
super_constructor, | ||
@@ -328,2 +340,3 @@ parentConstructor = _parent, | ||
namespace = _namespace, | ||
ns_filter, | ||
multiple, | ||
@@ -396,4 +409,17 @@ pieces, | ||
Blast.once(filter, function whenClassAvailable() { | ||
if (config.namespace) { | ||
ns_filter = { | ||
type : 'extended', | ||
descendant : config.name, | ||
namespace : config.namespace + '.' + config.name | ||
}; | ||
Blast.once(ns_filter, function whenNsClassAvailable() { | ||
Blast.removeAllListeners(filter); | ||
whenClassAvailable(); | ||
}); | ||
} | ||
whenClassAvailable = function whenClassAvailable() { | ||
var oldProto = newConstructor.prototype, | ||
@@ -431,2 +457,11 @@ arr, | ||
} | ||
}; | ||
Blast.once(filter, function classIsAvailable() { | ||
if (ns_filter) { | ||
Blast.removeAllListeners(ns_filter); | ||
} | ||
whenClassAvailable(); | ||
}); | ||
@@ -585,6 +620,6 @@ | ||
var data = { | ||
type: 'extended', | ||
ancestor: parentConstructor.name, | ||
descendant: newConstructor.name, | ||
namespace: namespace | ||
type : 'extended', | ||
ancestor : parentConstructor.name, | ||
descendant : newConstructor.name, | ||
namespace : namespace | ||
}; | ||
@@ -1001,3 +1036,3 @@ | ||
* @since 0.1.3 | ||
* @version 0.6.0 | ||
* @version 0.6.1 | ||
* | ||
@@ -1040,11 +1075,12 @@ * @param {Function} constructor Constructor to modify prototype of | ||
if (i == 0) { | ||
// Get a possible existing value | ||
existing = proto[keys[0]]; | ||
existing = Blast.Bound.Object.getPropertyDescriptor(proto, keys[0]); | ||
// If there already was something here, set it as this method's parent | ||
if (typeof existing !== 'undefined') { | ||
if (existing && typeof existing.value !== 'undefined') { | ||
if (typeof method == 'object') { | ||
Blast.defineValue(method.value, 'super', existing); | ||
Blast.defineValue(method.value, 'super', existing.value); | ||
} else { | ||
Blast.defineValue(method, 'super', existing); | ||
Blast.defineValue(method, 'super', existing.value); | ||
} | ||
@@ -1051,0 +1087,0 @@ } |
@@ -324,3 +324,3 @@ module.exports = function BlastInformer(Blast, Collection) { | ||
* @since 0.1.8 | ||
* @version 0.1.8 | ||
* @version 0.6.1 | ||
* | ||
@@ -334,2 +334,12 @@ * @param {String|Object} type | ||
Informer.setMethod(function forwardEvent(type, target, context) { | ||
if (typeof type == 'object' && arguments.length == 1) { | ||
if (!this.forward_targets) { | ||
this.forward_targets = []; | ||
} | ||
this.forward_targets.push(type); | ||
return; | ||
} | ||
return this.addListener(type, function onEvent() { | ||
@@ -1030,3 +1040,3 @@ | ||
cb = null; | ||
} else if (listeners.length < 3) { | ||
} else if (listeners.length < 3 && !this.forward_targets) { | ||
// The first 2 items are the type & filter object, | ||
@@ -1049,4 +1059,13 @@ // if only those are present, no listeners were found | ||
args = new Array(argLength - 1); | ||
for (i = 1; i < argLength; i++) args[i-1] = arguments[i]; | ||
for (i = 1; i < argLength; i++) { | ||
args[i-1] = arguments[i]; | ||
} | ||
if (this.forward_targets) { | ||
for (i = 0; i < this.forward_targets.length; i++) { | ||
this.forward_targets[i].emit.apply(this.forward_targets[i], [type].concat(args)); | ||
} | ||
} | ||
tasks = []; | ||
@@ -1053,0 +1072,0 @@ subtasks = []; |
@@ -310,3 +310,3 @@ // Copyright (c) 2012 Barnesandnoble.com, llc, Donavon West, and Domenic Denicola | ||
* @since 0.5.1 | ||
* @version 0.5.1 | ||
* @version 0.6.1 | ||
* | ||
@@ -318,6 +318,12 @@ * @param {Function} task | ||
var args = [], | ||
var args, | ||
i; | ||
if (typeof task != 'function') { | ||
throw new TypeError('"callback" argument must be a function'); | ||
} | ||
if (arguments.length > 2) { | ||
args = []; | ||
for (i = 2; i < arguments.length; i++) { | ||
@@ -324,0 +330,0 @@ args.push(arguments[i]); |
{ | ||
"name": "protoblast", | ||
"description": "Native object expansion library", | ||
"version": "0.6.0", | ||
"version": "0.6.1", | ||
"author": "Jelle De Loecker <jelle@develry.be>", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
570837
23291