stampit API
  • Introduction
  • Essentials
    • What is a Stamp
    • Installation
    • Specification
      • Merging algorithm
      • Object creation internals
    • FAQ
  • API
    • Quick start
    • Basics
    • Methods
    • Properties
    • Deep properties
    • Initializers
    • Static properties
    • Static deep properties
    • Configuration
    • Deep configuration
    • Composers
    • Property descriptors
    • Static property descriptors
    • Name
  • Ecosystem
    • Ecosystem Overview
    • @stamp/collision
    • @stamp/required
    • @stamp/privatize
    • @stamp/named (DEPRECATED)
    • @stamp/instanceof
Powered by GitBook
On this page
  • @stamp/named (DEPRECATED)
  • Example
  1. Ecosystem

@stamp/named (DEPRECATED)

Previous@stamp/privatizeNext@stamp/instanceof

Last updated 6 years ago

This stamp (aka behaviour) is built into the stampit since stampit@4.2.0 and @stamp/it@1.1.

@stamp/named (DEPRECATED)

Changes the Stamp.name property using the .

Supported platforms: node>=4, iOS>=10, Edge, FF, Chrome, Safari

If used in a non-supported environment (node <v4, or IE any version) then nothing will throw. But the Stamp.name will always be "Stamp".

Example

Default behaviour (without this stamp):

const MyRegularStamp = compose(...);
console.log(MyRegularStamp.name); // 'Stamp'

New behaviour:

import Named from '@stamp/named';

const MyNamedStamp = MyRegularStamp.compose(Named).setName('MyNamedStamp');

Or if you don't want to import the stamp you can import only the method:

import {setName} from '@stamp/named';
const MyNamedStamp = MyRegularStamp.compose(setName('MyNamedStamp'));

Then stamp receives a different name instead of the default "Stamp":

console.log(MyNamedStamp.name); // 'MyNamedStamp'

Derived stamps behaviour:

// All derived stamps will also be named 'MyNamedStamp' until changed:
let Stamp2 = compose(..., MyNamedStamp, ...);
console.log(Stamp2.name); // WARNING! Still 'MyNamedStamp' !!!

// Overwriting the name
Stamp2 = Stamp2.setName('Stamp2');
console.log(Stamp2.name); // 'Stamp2' :)
new ES6 feature