Cocoon
A small utility module for wrapping property getters within functions.
It is useful as a TDD helper for creating mockable/spyable methods on top of another library's methods that are returned via a getter.
Note: This is not a cure-all. Objects could be frozen, etc.
Example
var lib = {} {} lib
With something like sinon
, you can't (at the moment) mock setters.
With cocoon
, you can:
var cocoon = var c = cocoon sinon // works c
Yay.
However.. if:
var self = {} {} self Object moduleexports = self
..Nope. Not going to happen.