From 12093eda14d3195439ad9aa6d523cc4b48caf93c Mon Sep 17 00:00:00 2001 From: TopchetoEU <36534413+TopchetoEU@users.noreply.github.com> Date: Sat, 26 Aug 2023 00:44:28 +0300 Subject: [PATCH] fix: fully encapsulate native generator --- lib/values/function.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/values/function.ts b/lib/values/function.ts index 52bbf43..7bf7178 100644 --- a/lib/values/function.ts +++ b/lib/values/function.ts @@ -166,8 +166,16 @@ setProps(Function, { }, generator(func) { if (typeof func !== 'function') throw new TypeError('Expected func to be function.'); - return Object.assign(internals.makeGenerator(func), { - [Symbol.iterator]() { return this; } - }); + const gen = internals.makeGenerator(func); + return (...args: any[]) => { + const it = gen(args); + + return { + next: it.next, + return: it.return, + throw: it.throw, + [Symbol.iterator]() { return this; } + } + } } }) \ No newline at end of file