From b1cae8da4f50ce77fcfcd8853a65b05319873be9 Mon Sep 17 00:00:00 2001 From: Ricci Dorian Date: Fri, 27 Jul 2018 10:55:14 +0200 Subject: [PATCH] added utility function to AddOrUpdate a field on object --- tarteaucitron.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tarteaucitron.js b/tarteaucitron.js index 39de7c1..6596829 100644 --- a/tarteaucitron.js +++ b/tarteaucitron.js @@ -11,6 +11,20 @@ var scripts = document.getElementsByTagName('script'), tarteaucitronProLoadServices, tarteaucitronNoAdBlocker = false; +/** + Utility function to Add or update the fields of obj1 with the ones in obj2 +*/ +function AddOrUpdate(obj1, obj2){ + for(key in obj2){ + if(obj2[key] instanceof Object){ + obj1[key] = AddOrUpdate(obj1[key], obj2[key]); + }else{ + obj1[key] = obj2[key]; + } + } + return obj1; +} + var tarteaucitron = { "version": 323, "cdn": cdn,