Basics
Creating Stamps
Stampit gives you several ways to create your stamps (aka factory functions).
NOTE!
Any time you compose - you create a NEW stamp. Every function below always returns a NEW stamp.
Pass plain descriptor
You can pass standard stamp descriptor to stampit.
const descriptor = {
methods: ...,
properties: ...,
deepProperties: ...,
propertyDescriptors: ...,
initializers: ...,
staticProperties: ...,
staticDeepProperties: ...,
staticPropertyDescriptors: ...,
composers: ...,
configuration: ...,
deepConfiguration: ...,
name: ...
}
const MyStamp = stampit(descriptor) // passing the descriptorOr you can pass stampit-flavoured descriptor (shorter version of the standard descriptor).
Shortcut functions
Stampit has 18 shortcut functions attached to it. For example:
You can create stamps from them too.
The full list of the shortcut functions matches the list of keys you can pass as stamp descriptor (see above).
Creating same stamp in few ways
All the examples below create exactly the same stamp.
Classic way
Classic way using shorter API
Shortcut way
Composition way
Chaining
You can chain all the shortcut functions (see the full list above).
Below is just an example of what you can do. It is a utility stamp. If you compose it to any of your stamps then it will count the number of object instances created from your stamp. Feel free to remove unwanted parts.
Same InstanceCounter stamp but using the classic stampit way.
Last updated