ig-types 6.20.0 → 6.20.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/event.js +22 -9
  2. package/package.json +1 -1
package/event.js CHANGED
@@ -51,6 +51,8 @@ module.TRIGGER = module.EventCommand('TRIGGER')
51
51
  // Trigger the event...
52
52
  // method(...args)
53
53
  // -> ..
54
+ // NOTE: if func(..) returns undefined this will return undefined
55
+ // when called without a context and the call context otherwise
54
56
  //
55
57
  //
56
58
  // func(handle, ...args)
@@ -99,6 +101,14 @@ object.Constructor('Eventful', {
99
101
 
100
102
  handlerLocation: 'context',
101
103
 
104
+ // Sets the default return mode for .__call__(..) if either .func(..)
105
+ // is not set or returns undefined...
106
+ //
107
+ // Can be:
108
+ // 'context'
109
+ // undefined
110
+ defaultReturn: 'context',
111
+
102
112
  name: null,
103
113
  func: null,
104
114
 
@@ -190,7 +200,11 @@ object.Constructor('Eventful', {
190
200
  // or explicitly called handle(false)...
191
201
  !did_handle
192
202
  && handle()
193
- return res },
203
+
204
+ return res
205
+ ?? (this.defaultReturn == 'context' ?
206
+ context
207
+ : res ) },
194
208
 
195
209
  __init__: function(name, func, options={}){
196
210
  options = func && typeof(func) != 'function' ?
@@ -251,16 +265,15 @@ object.Constructor('Event', Eventful, {
251
265
  .replace(/^(function[^(]*\()[^,)]*, ?/, '$1')
252
266
  : `Event function ${this.name}(){}`},
253
267
  __call__: function(context, ...args){
268
+ // add handler...
254
269
  // NOTE: when the first arg is an event command this will
255
270
  // fall through to calling the action...
256
- typeof(args[0]) == 'function' ?
257
- // add handler...
258
- this.bind(context, args[0])
259
- // call the action...
260
- : object.parentCall(Event.prototype.__call__, this, context, ...args)
261
- // XXX workaround for above line -- remove when fully tested...
262
- //: Eventful.prototype.__call__.call(this, context, ...args)
263
- return context },
271
+ if(typeof(args[0]) == 'function'){
272
+ this.bind(context, args[0])
273
+ return context
274
+ // call the action...
275
+ } else {
276
+ return object.parentCall(Event.prototype.__call__, this, context, ...args) } },
264
277
  })
265
278
 
266
279
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ig-types",
3
- "version": "6.20.0",
3
+ "version": "6.20.2",
4
4
  "description": "Generic JavaScript types and type extensions...",
5
5
  "main": "main.js",
6
6
  "scripts": {