{"action":"closed","issue":{"number":331,"created_at":"2011-10-14T18:36:55Z","pull_request":{"diff_url":null,"patch_url":null,"html_url":null},"body":"I would like to know if `_.once'd` function was run for the first time or it returns memoized results, something like:\r\n\r\n```javascript\r\n_.once = function(func) {\r\n    var memo, f;\r\n    f = function() {\r\n      if (f.ran) return memo;\r\n      f.ran = true;\r\n      return memo = func.apply(this, arguments);\r\n    };\r\n    return f;\r\n  };\r\n```\r\n\r\nand then:\r\n\r\n```javascript\r\nfunc = function () {\r\n    console.log('execution!');\r\n    return 42;\r\n}\r\n\r\nonced = _.once(func);\r\n\r\nconsole.log(!onced.ran?'virgin':'deprived virginity');\r\n// >> virgin\r\nconsole.log(onced());\r\n// >> execution!\r\n// = 42\r\nconsole.log(!onced.ran?'virgin':'deprived virginity');\r\n// >> deprived virginity\r\nconsole.log(onced());\r\n// = 42\r\nconsole.log(!onced.ran?'virgin':'deprived virginity');\r\n// >> deprived virginity\r\n```\r\n\r\n","comments":4,"title":"let know if _.once'd function was already ran","updated_at":"2011-10-17T21:33:28Z","url":"https://api.github.com/repos/documentcloud/underscore/issues/331","id":1912978,"assignee":null,"milestone":null,"closed_at":"2011-10-17T21:33:28Z","user":{"gravatar_id":"7bda913da78955ffcfe7ae3b3e5a4fc5","avatar_url":"https://secure.gravatar.com/avatar/7bda913da78955ffcfe7ae3b3e5a4fc5?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/thesebas","id":827416,"login":"thesebas"},"html_url":"https://github.com/documentcloud/underscore/issues/331","labels":[{"name":"enhancement","url":"https://api.github.com/repos/documentcloud/underscore/labels/enhancement","color":"89e0fa"},{"name":"wontfix","url":"https://api.github.com/repos/documentcloud/underscore/labels/wontfix","color":"ffffff"}],"state":"closed"},"legacy":{"number":331,"action":"closed","issue":1912978}}