From 41c4614bd962abf528fdd9acb0647f61f4d7c898 Mon Sep 17 00:00:00 2001 From: Stefan Wimmer Date: Sat, 24 Sep 2016 15:35:00 +0200 Subject: [PATCH] Add isGenerator function --- package.json | 2 +- tmjs-core.js | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index af261a4..26f873c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tmjs-core", - "version": "1.0.0-alpha.2", + "version": "1.0.0-beta.1", "description": "TM.js Core is used in all TM.js modules", "main": "build/tmjs-core.js", "scripts": { diff --git a/tmjs-core.js b/tmjs-core.js index 8d29001..b39089c 100644 --- a/tmjs-core.js +++ b/tmjs-core.js @@ -25,10 +25,15 @@ g.tmjs = g.tmjs || {}; g.tmjs.__defineGetter__("core", () => "${version}"); -g.tmjs.module = (name, version, getter) => - g.tmjs.__defineGetter__(name, () => - { - let module = getter(g.tmjs); - module.__defineGetter__("version", () => version); - return module; - }); +Object.assign(g.tmjs, { + module: (name, version, getter) => + g.tmjs.__defineGetter__(name, () => + { + let module = getter(g.tmjs); + module.__defineGetter__("version", () => version); + return module; + }), + + isGenerator: generator => + generator instanceof (function *() {}).constructor +});