diff --git a/package.json b/package.json index 0ebaf892..191591a4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "stated-js", - "version": "0.1.49", + "version": "0.1.50", "license": "Apache-2.0", "description": "JSONata embedded in JSON", "main": "./dist/src/index.js", diff --git a/src/test/TemplateProcessor.test.js b/src/test/TemplateProcessor.test.js index 961507ee..b21603a9 100644 --- a/src/test/TemplateProcessor.test.js +++ b/src/test/TemplateProcessor.test.js @@ -5694,6 +5694,23 @@ test("test import with props", async () => { } }); +test("test async function stringifyy", async () => { + const foo = async function(){ + return 'bar'; + }; + + const o = { + a:42, + b: foo + }; + expect(JSON.parse(stringifyTemplateJSON(o))).toStrictEqual({ + a:42, + b: "{function:}" + }) +}); + + + diff --git a/src/utils/stringify.ts b/src/utils/stringify.ts index 1f2979dd..6577b8ee 100644 --- a/src/utils/stringify.ts +++ b/src/utils/stringify.ts @@ -36,7 +36,7 @@ export const circularReplacer = (key: any, value: any) => { if (tag === '[object Timeout]'|| (_idleTimeout !== undefined && _onTimeout !== undefined)) { //Node.js return "--interval/timeout--"; } - if (tag === '[object Function]') { + if (tag === '[object Function]' || tag==='[object AsyncFunction]') { return "{function:}"; } // Check if value is a module-like object