minor tweaks and cleanup...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2021-05-25 18:44:09 +03:00
parent fe1f39cba6
commit 40d08efc5c
3 changed files with 4 additions and 18 deletions

View File

@ -31,22 +31,7 @@ module.STOP =
// Wrap .map(..) / .filter(..) / .reduce(..) / .. to support STOP...
//
// NOTE: these add almost no overhead to the iteration.
// NOTE: these will not return a partial result if stopped.
//
/*/ XXX should these return a partial result on STOP?
// ...use generators to do this...
var stoppable = function(iter){
return function(func){
try {
return this[iter](...arguments)
} catch(err){
if(err === STOP){
return
} else if(err instanceof STOP){
return err.value }
throw err } } }
/*/
// NOTE: internally these are implemented as for-of loops...
var stoppableList = function(iter){
return function(func){
return [...this.iter()[iter](...arguments)] } }
@ -56,7 +41,6 @@ var stoppableValue = function(iter, no_return=false){
return no_return ?
undefined
: res } }
//*/
// Equivalent to .map(..) / .filter(..) / .reduce(..) that process the
@ -504,6 +488,7 @@ object.Mixin('ArrayProtoMixin', 'soft', {
// Stoppable iteration...
//
// NOTE: internally these are generators...
smap: stoppableList('map'),
sfilter: stoppableList('filter'),
sreduce: stoppableValue('reduce'),

View File

@ -178,6 +178,7 @@ function(func){
var GeneratorMixin =
module.GeneratorMixin =
object.Mixin('GeneratorMixin', 'soft', {
STOP: object.STOP,
gat: makeGenerator('gat'),
at: function(i){

View File

@ -1,6 +1,6 @@
{
"name": "ig-types",
"version": "6.3.1",
"version": "6.3.2",
"description": "Generic JavaScript types and type extensions...",
"main": "main.js",
"scripts": {