• Login
    • Report A Bug
    • System Information
    • System Tests
    • System Policies
    • Code Documentation
    • Occam Source Code
    • Web Client Source Code
    • About Occam
    • Acknowledgements
    • Guides / Documentation
    • Publications

translation missing: en.flash.saving
translation missing: en.flash.error
  • Bibliography Data
  • Metadata
resource
  • git
    https://github.com/npm/wrappy.git Source Repository
    Qma7zjvXn12oWjYjpjPahk3TTBRDduUWmJ3dFv1kcCJqC1
    71d91b6dc5bdeac37e218c2cf03f9ab55b60d214
      Qma7zjvXn12oWjYjpjPahk3TTBRDduUWmJ3dFv1kcCJqC1
      71d91b6dc5bdeac37e218c2cf03f9ab55b60d214

      • Details
      • Files
      • History
        • Source

          https://github.com/npm/wrappy.git

          wrappy

          Callback wrapping utility

          USAGE

          var wrappy = require("wrappy")
          
          // var wrapper = wrappy(wrapperFunction)
          
          // make sure a cb is called only once
          // See also: http://npm.im/once for this specific use case
          var once = wrappy(function (cb) {
            var called = false
            return function () {
              if (called) return
              called = true
              return cb.apply(this, arguments)
            }
          })
          
          function printBoo () {
            console.log('boo')
          }
          // has some rando property
          printBoo.iAmBooPrinter = true
          
          var onlyPrintOnce = once(printBoo)
          
          onlyPrintOnce() // prints 'boo'
          onlyPrintOnce() // does nothing
          
          // random property is retained!
          assert.equal(onlyPrintOnce.iAmBooPrinter, true)
          

          Related

          • maintainer

            npm

          Share

          • URL

            Copy
          • Embed Link

            Copy
          • QR Code

        • JavaScript must be enabled.

          There was an error retrieving this content.

          The content could not be found.

        • JavaScript must be enabled.

          There was an error retrieving this content.

          The content could not be found.

        Confirm
        Do you wish to proceed?

        Confirm message?