stampit API
Search…
Static property descriptors
Static property descriptors are standard JavaScript property descriptors. They are applied last thing when a stamp is being composed.
1
let MyStamp = stampit() // empty stamp creates empty objects
2
3
MyStamp.name === 'Stamp' // every stamp default name is "Stamp"
4
5
MyStamp = MyStamp.staticPropertyDescriptors({
6
name: { value: 'MyStamp' } // this meta data will be applied just after composition, i.e. immediately
7
})
8
9
MyStamp.name === 'MyStamp'
Copied!
The code above adds some more metadata to the MyStamp stamp. It overwrites function name. (Property descriptors is the only way to change a function name.)
NOTE
The stampit and @stamp/it modules have the "name" feature built in.
1
const MyStamp = stampit({ name: 'MyStamp' })
2
MyStamp.name === 'MyStamp'
Copied!

Other ways to add static property descriptors

Exactly the same stamp can be created in few ways. Here they all are.
1
const myStampName = {
2
name: { value: 'MyStamp }
3
}
4
5
const NamedStamp = stampit({
6
staticPropertyDescriptors: myStampName
7
})
8
9
const NamedStamp = stampit.staticPropertyDescriptors(myStampName)
10
11
const NamedStamp = stampit().staticPropertyDescriptors(myStampName)
Copied!
Last modified 3yr ago