The above InstanceOf stamp overrides the default instanceof behavior using ES6 will-known symbol Symbol.hasInstance. Compose it with your stamps if you need the instanceof to work as expected for you.
The composers are concatenated into a deduplicated array. As the result, the order of composition becomes the order of composer execution.
const {composers} = stampitconstLog1=composers(() =>console.log(1))constLog2=composers(() =>console.log(1))constLog3=composers(() =>console.log(1))constMultiLog=stampit(Log1, Log2, Log3)MultiLog() // Will print three times:// 1// 1// 1// because there are 3 composersMultiLog.compose.composers.length===3
Stamps remove duplicate composers.
const {composers} = stampitconstfunc= () =>console.log(1)constLog1=composers(func)constLog2=composers(func)constLog3=composers(func)constMultiLog=stampit(Log1, Log2, Log3)MultiLog() // Will print only once:// 1// because there is only one composerMultiLog.compose.composers.length===1
Composer arguments
Every composer always receive this object: { stamp, composables }. Where:
stamp is the stamp which was used to create this object. Useful to retrieve stamp's metadata (aka descriptor).
composables is the array of stamps and descriptors the above stamp was composed with.
Other ways to add composers
Exactly the same stamp can be created in few ways. Here they all are.
functionmyDebugComposer ({ stamp, composables }) {console.log(`Stamp ${stamp} was composed of ${composables}`)}constLogger=stampit({ composers: myDebugComposer})constLogger=stampit({ composers: [myDebugComposer]})constLogger=stampit.composers(myDebugComposer)constLogger=stampit.composers([myDebugComposer])constLogger=stampit().composers(myDebugComposer)constLogger=stampit().composers([myDebugComposer])