aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorStephen Blott2016-03-18 06:12:55 +0000
committerStephen Blott2016-03-18 06:12:58 +0000
commit5f1acf3c66d9e128883a7a54409a08a42ab9ea05 (patch)
treeb4d0950c468ccadd2a055c5e8327eb67010a592c /lib
parent307ecffc4b5d1ebfc4e48c09e0f333296d509947 (diff)
downloadvimium-5f1acf3c66d9e128883a7a54409a08a42ab9ea05.tar.bz2
Add Utils.makeIdempotent.
The intention is to use this to clean up some of the initialisation sequences in the front end.
Diffstat (limited to 'lib')
-rw-r--r--lib/utils.coffee4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/utils.coffee b/lib/utils.coffee
index 9969811a..31f4bec6 100644
--- a/lib/utils.coffee
+++ b/lib/utils.coffee
@@ -236,6 +236,10 @@ Utils =
# Like Nodejs's nextTick.
nextTick: (func) -> @setTimeout 0, func
+ # Make an idempotent function.
+ makeIdempotent: (func) ->
+ (args...) -> ([previousFunc, func] = [func, null])[0]? args...
+
# Utility for parsing and using the custom search-engine configuration. We re-use the previous parse if the
# search-engine configuration is unchanged.
SearchEngines =