implement Util.both

This commit is contained in:
ansuz 2019-09-11 10:54:21 +02:00
parent 89d6a7ad76
commit bcbe561bbf

View file

@ -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;}
};