Tap into classes and methods. Aspect Oriented Programming for nodejs.
dropbox = require 'dropbox'tapinto = require 'tapinto'dropboxClient:super:consolelog 'Intercepted a file read'consolelog 'Intercepted the results of a file read'#readdir: (path, options, callback) -># (error, files, dirstat, filestats) ->##stat: (path, options, callback) -># (error, stat, filestats) ->module.exports =Client: Client
Occasionally the functionality of a library is not enough, there are a few more things you want it to do. You could jump in and fork the project, but often your additions are not in line with the project direction. A mechanism to wrap and tap into the implementation of a library is useful.
Aspect Oriented Programming for nodejs.
tapinto.Class(dropbox.Client). Methods with the same name on your class will be called first. Return a method to tap into a callback.
tappedobject = tapinto.Object(targetobject, yourobject).
tappedmethod = tapinto.Function(targetmethod, yourmethod)