From 7223251ca6fff82a64e98b2f55efdfd4d49bcf26 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Tue, 5 Jul 2022 23:14:09 +0300 Subject: [PATCH] made the module simpler to use... Signed-off-by: Alex A. Naanou --- package.json | 2 +- stoppable.js | 28 +++++++++++++--------------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 50e4097..bfb8aa0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ig-stoppable", - "version": "1.0.0", + "version": "2.0.0", "description": "Utility library implementing tooling to make stoppable functions...", "main": "stoppable.js", "scripts": { diff --git a/stoppable.js b/stoppable.js index 95ebe06..0a955a7 100644 --- a/stoppable.js +++ b/stoppable.js @@ -26,19 +26,6 @@ var AsyncGenerator = -//--------------------------------------------------------------------- - -var STOP = -module.STOP = -function(value){ - return { - __proto__: STOP.prototype, - doc: 'stop iteration.', - value, - } } - - - //--------------------------------------------------------------------- // Wrap a callable in a STOP handler @@ -76,8 +63,7 @@ function(value){ // // NOTE: this repeats the same code at lest twice, not sure yet how to avoid // this... -var stoppable = -module.stoppable = +module = function(func){ return Object.assign( func instanceof Generator ? @@ -140,5 +126,17 @@ function(func){ +//--------------------------------------------------------------------- + +module.STOP = +function(value){ + return { + __proto__: module.STOP.prototype, + doc: 'stop iteration.', + value, + } } + + + /********************************************************************** * vim:set ts=4 sw=4 nowrap : */ return module })