From 7586e2a1caab21d51684e97f88f6779f2188ff29 Mon Sep 17 00:00:00 2001 From: ALONGKORN CHETASUMON Date: Thu, 13 Dec 2018 00:35:33 +0700 Subject: [PATCH] Update jsonld.js I am working on node for ios app (https://code.janeasystems.com/nodejs-mobile) which run on node-chakracore instead of v8. I found that the spread operator of _setDefaults does not work on node-chakracore, so I would like to change to code by using the basic style (does not affect functional). Please help to review and approve --- lib/jsonld.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/jsonld.js b/lib/jsonld.js index ae8ad2eb..bf29442c 100644 --- a/lib/jsonld.js +++ b/lib/jsonld.js @@ -1045,10 +1045,15 @@ if(_nodejs) { jsonld.useDocumentLoader('xhr'); } -function _setDefaults(options, { - documentLoader = jsonld.documentLoader, - ...defaults -}) { +function _setDefaults(options, additionalOptions) { + const documentLoader = additionalOptions.documentLoader || jsonld.documentLoader + const defaults = {} + for (const key in additionalOptions) { + if (key !== 'documentLoader') { + defaults[key] = additionalOptions[key] + } + } + if(typeof options === 'function') { options = {}; }