Quick start
Quick start
Install the JavaScript module from the NPM registry.
npm i @stamp/it
# or
npm i stampitCreate an empty stamp.
const stampit = require('@stamp/it')
let Stamp = stampit() // creates new stampCompose it with another stamp.
const HasLog = require('./HasLog')
Stamp = Stamp.compose(HasLog) // creates a new stamp composed from the twoAdd default properties to it.
Stamp = Stamp.props({ // creates a new derived stamp
S3: require('aws-sdk').S3
})Add an initializer (aka constructor).
Add a method.
Add a configuration.
Add a static method.
Make the .s3instance , .log, and .S3 properties private.
Give it a proper name.
Create objects from your stamp.
Shorter API
Here is the same FileStore stamp but written in a more concise way.
The reusable HasLog stamp can be implemented in the following way.
Using the stamp
Use your stamp ad-hoc.
Or preconfigure it.
If you want to silence the shameful fact that you are collecting cat gifs then here is how you disable log. Just overwrite the log property with a silent one.
Alternatively, you can have a generic silent logger stamp. Compose with it to override the HasLog.
The new keyword also works with any stamp.
Another way to create an object is to use .create() static method.
Mocking I/O in unit tests
Replacing actual S3 with a fake one.
Basic API
Head to the Basics page to view more API documentation. However, by now you already know all you need.
Last updated