ig-types 6.16.3 → 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.
Files changed (3) hide show
  1. package/README.md +12 -0
  2. package/generator.js +12 -0
  3. package/package.json +1 -1
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/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.3",
3
+ "version": "6.16.4",
4
4
  "description": "Generic JavaScript types and type extensions...",
5
5
  "main": "main.js",
6
6
  "scripts": {