diff --git a/README.md b/README.md index 7ba0a1b..2626458 100644 --- a/README.md +++ b/README.md @@ -1582,6 +1582,12 @@ terminology to reference different levels of API's: In the above example `iter` is a generator instance. +Iterators and generators are similar but not the same. Some objects like `Array`'s, +`Map`'s and `Set`'s provide a number of generic iterators that are not implemented +as generators. These objects are also extended by `ig-types/generator` to match the +`` object API defined below. + + #### `generator.Generator` diff --git a/generator.js b/generator.js index 5c69aff..610d849 100644 --- a/generator.js +++ b/generator.js @@ -66,7 +66,17 @@ module.Generator = (function*(){}).constructor -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +// base iterator prototypes... +var ITERATOR_PROTOTYPES = [ + Array, + Set, + Map, +].map(function(e){ + return (new e()).values().__proto__ }) + + + +//--------------------------------------------------------------------- // generic generator wrapper... var iter = @@ -395,6 +405,13 @@ GeneratorMixin(GeneratorPrototype) GeneratorProtoMixin(GeneratorPrototype.prototype) +// Extend base iterators... +ITERATOR_PROTOTYPES + .forEach(function(proto){ + GeneratorProtoMixin(proto) }) + + + //--------------------------------------------------------------------- // Generators... diff --git a/package.json b/package.json index ec11328..44f5489 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ig-types", - "version": "6.3.2", + "version": "6.4.0", "description": "Generic JavaScript types and type extensions...", "main": "main.js", "scripts": {