Creating a namespace-like organization in a google apps script library -
i looking building toolset using google apps script. problem far can tell in allows 1 level of organization. can create library called stopwatch , call methods stopwatch.start() , stopwatch.stop() pretty cool.
what had in mind though more utils.stopwatch().start() , utils.timer.start() etc. think it's possible in javascript, in order keep breaking apps script autocomplete function needs added in format. below example example of doing wrong (gives error) perhaps saves time. it's based on this article.
/** * stopwatch object. * @return {object} stopwatch methods */ function stopwatch() { var current; /** * stop stopwatch. * @param {time} time in miliseconds */ function timeinseconds_(time) { return time/1000; } return { /** * start stopwatch. */ start: function() { var time = new date().gettime(); current = timeinseconds_(time); }, /** * stop stopwatch. * @return {decimal} time passed since calling * start (in seconds) */ stop: function() { var time = new date().gettime(); var difference = timeinseconds_(time) - this.current; return difference.tofixed(3); } }; } thanks
you can submit feature requests here:
http://code.google.com/p/google-apps-script-issues/issues/list
Comments
Post a Comment