From bcbe561bbfded4342c00c559daf5d09c3030bdc8 Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 11 Sep 2019 10:54:21 +0200 Subject: [PATCH] implement Util.both --- www/common/common-util.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/www/common/common-util.js b/www/common/common-util.js index ba70b0ceb..fe62d42ba 100644 --- a/www/common/common-util.js +++ b/www/common/common-util.js @@ -1,6 +1,14 @@ (function (window) { var Util = {}; + Util.both = function (pre, post) { + if (typeof(post) !== 'function') { post = function (x) { return x; }; } + return function () { + pre.apply(null, arguments); + return post.apply(null, arguments); + }; + }; + Util.tryParse = function (s) { try { return JSON.parse(s); } catch (e) { return;} };