A small library that lets you inject some code between a third party library and the execution context. With <strong>Middleman.js</strong> you can easily:
A small library that lets you inject some code between a third party library and the execution context. With Middleman.js you can easily:
Let's say you add a third party library to your application that has a method called
var ThirdPartyLibrary =// do something cool with firstParam, then:if isAwesomeconsole.log'All up in your app, doing awesome things.';;;
You decide that you want to force the second parameter
isAwesome to be
true every time
doSomethingCool is called because your application is totally awesome. You could just write a
wrapper method like this:
var AwesomeApplication =return ThirdPartyLibrarydoSomethingCoolfirstParam true;;AwesomeApplicationdoSomethingCool'blah blah blah';/*** console: All up in your app, doing awesome things.*/
However, now you have to remember to call your method instead of the original method.
ThirdPartyLibrary is very popular (e.g. jQuery)? Your colleague Tony has been using
ThirdPartyLibrary for years. He doesn't remember to use your wrapper function when writing new
code for your application.
Middlman.js gets between Tony and
ThirdPartyLibrary, so your application stays awesome. 😑
var MM = ;MMmaplib : ThirdPartyLibrarymethod : 'doSomethingCool'// make the second parameter trueargs1 = true;return args;;ThirdPartyLibrarydoSomethingCool"I'm Tony, and the second param is undefined.";/*** console: All up in your app, doing awesome things.*/
Piece of cake.