ig-types 6.16.1 → 6.16.4

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.
package/README.md CHANGED
@@ -100,6 +100,7 @@ Library of JavaScript type extensions, types and utilities.
100
100
  - [`<generator>.iter(..)`](#generatoriter-1)
101
101
  - [`<generator>.map(..)` / `<generator>.filter(..)`](#generatormap--generatorfilter)
102
102
  - [`<generator>.reduce(..)` / `<generator>.greduce(..)`](#generatorreduce--generatorgreduce)
103
+ - [`<generator>.forEach(..)`](#generatorforeach)
103
104
  - [`<generator>.slice(..)`](#generatorslice)
104
105
  - [`<generator>.at(..)` / `<generator>.gat(..)`](#generatorat--generatorgat)
105
106
  - [`<generator>.flat(..)`](#generatorflat)
@@ -2135,6 +2136,17 @@ XXX .reduce(..) can return a non-iterable -- test and document this case...
2135
2136
  ...compare with Array.prototype.reduce(..)
2136
2137
  -->
2137
2138
 
2139
+ #### `<generator>.forEach(..)`
2140
+
2141
+ ```bnf
2142
+ <generator>.forEach(<func>)
2143
+ -> <array>
2144
+ ```
2145
+
2146
+ This is different from the above in that this will unwind the `<generator>`.
2147
+
2148
+ Note that this differs from `<array>.forEach(..)` in that his will return the resulting array, essentially behaving like `.map(..)`.
2149
+
2138
2150
 
2139
2151
  #### `<generator>.slice(..)`
2140
2152
 
package/event.js CHANGED
@@ -116,7 +116,8 @@ object.Constructor('Eventful', {
116
116
  this.handlerLocation == 'method' ?
117
117
  (this.__event_handlers__ = this.__event_handlers__ || [])
118
118
  // context (default)...
119
- : (context.__event_handlers__ == null ?
119
+ //: (context.__event_handlers__ == null ?
120
+ : !context.hasOwnProperty('__event_handlers__') ?
120
121
  Object.defineProperty(context, '__event_handlers__', {
121
122
  value: {[this.name]: (handlers = [])},
122
123
  enumerable: false,
@@ -124,16 +125,19 @@ object.Constructor('Eventful', {
124
125
  writable: true,
125
126
  })
126
127
  && handlers
127
- : (context.__event_handlers__[this.name] =
128
- context.__event_handlers__[this.name] || []))
128
+ : (context.__event_handlers__[this.name] =
129
+ context.__event_handlers__[this.name] || [])
129
130
  // add handler...
130
131
  handlers.push(handler)
131
132
  return this },
132
133
  unbind: function(context, handler){
133
134
  var handlers =
134
- (this.handlerLocation == 'method' ?
135
+ this.handlerLocation == 'method' ?
135
136
  method.__event_handlers__
136
- : (context.__event_handlers__ || {})[this.name]) || []
137
+ //: (context.__event_handlers__ || {})[this.name]) || []
138
+ : context.hasOwnProperty('__event_handlers__') ?
139
+ (context.__event_handlers__ || {})[this.name] || []
140
+ : []
137
141
  handlers.splice(0, handlers.length,
138
142
  ...handlers.filter(function(h){
139
143
  return h !== handler
@@ -149,7 +153,10 @@ object.Constructor('Eventful', {
149
153
  // context (default)...
150
154
  // NOTE: these are allways called...
151
155
  handlers = handlers
152
- .concat((context.__event_handlers__ || {})[this.name] || [])
156
+ //.concat((context.__event_handlers__ || {})[this.name] || [])
157
+ .concat(context.hasOwnProperty('__event_handlers__') ?
158
+ (context.__event_handlers__ || {})[this.name] || []
159
+ : [])
153
160
 
154
161
  // NOTE: this will stop event handling if one of the handlers
155
162
  // explicitly returns false...
@@ -291,7 +298,8 @@ module.EventHandlerMixin = object.Mixin('EventHandlerMixin', {
291
298
  this[evt].bind(this, func)
292
299
  // non-event...
293
300
  } else {
294
- this.__event_handlers__ == null
301
+ //this.__event_handlers__ == null
302
+ !this.hasOwnProperty('__event_handlers__')
295
303
  && Object.defineProperty(this, '__event_handlers__', {
296
304
  value: {},
297
305
  enumerable: false,
@@ -332,7 +340,8 @@ module.EventHandlerMixin = object.Mixin('EventHandlerMixin', {
332
340
  evt in this ?
333
341
  // XXX add a better check...
334
342
  this[evt](module.TRIGGER, ...args)
335
- : this.__event_handlers__
343
+ //: this.__event_handlers__
344
+ : this.hasOwnProperty('__event_handlers__')
336
345
  && (this.__event_handlers__[evt] || [])
337
346
  .forEach(function(h){ h(evt, ...args) })
338
347
  return this },
package/generator.js CHANGED
@@ -223,6 +223,12 @@ object.Mixin('GeneratorMixin', 'soft', {
223
223
  reduce: makeGenerator('reduce'),
224
224
  reduceRight: makeGenerator('reduceRight'),
225
225
 
226
+ // XXX add .toString(..) ???
227
+ forEach: function(func){
228
+ var that = this
229
+ return function(){
230
+ return that(...arguments).forEach(func) } },
231
+
226
232
  // non-generators...
227
233
  //
228
234
  toArray: function(){
@@ -397,6 +403,12 @@ object.Mixin('GeneratorProtoMixin', 'soft', {
397
403
  greduce: function*(func, res){
398
404
  yield this.reduce(...arguments) },
399
405
 
406
+ // NOTE: this is a special case in that it will unwind the generator...
407
+ // NOTE: this is different from <array>.forEach(..) in that this will
408
+ // return the resulting array.
409
+ forEach: function(func){
410
+ return [...this].map(func) },
411
+
400
412
  pop: function(){
401
413
  return [...this].pop() },
402
414
  // XXX this needs the value to be iterable...
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ig-types",
3
- "version": "6.16.1",
3
+ "version": "6.16.4",
4
4
  "description": "Generic JavaScript types and type extensions...",
5
5
  "main": "main.js",
6
6
  "scripts": {