stampit-org / stampit

OOP is better with stamps: Composable object factories.
https://stampit.js.org
MIT License
3.02k stars 102 forks source link

Add another non-spec metadata - "name" to change factory name #338

Closed koresar closed 6 years ago

koresar commented 6 years ago

Proposal details: https://github.com/stampit-org/stamp-specification/issues/121

TL;DR:

const HaveName = stampit({
  name: "Superman"
});

HaveName.name === "Superman"  // instead of the default "Stamp"
koresar commented 6 years ago

ping @FredyC

danielkcz commented 6 years ago

I don't know man, I never had this need for naming stamps really. It kinda feels weird that resulting name depends on the last named stamp composed in there. How can that be a good thing?

koresar commented 6 years ago

Well, properties, initializer, methods, etc behave the same way.

resulting [SOMETHING] depends on the last [HAS SOMETHING] stamp composed in there

Totally within the philosophy of stamps IMO.

koresar commented 6 years ago

Here is a blog post draft: https://medium.com/@koresar/fun-with-stamps-episode-23-new-name-feature-4be91c27edcb

danielkcz commented 6 years ago

Ok sure, since this far from a breaking change, then go ahead :)

Btw, I am still unsure why you are actually maintaining this package when there is the @stamp/it one which you even introduced in your blog as new way to do things. You should probably do the same change there if you want them to be the same although I don't see the point really. I thought that eventually, the stampit will just a be a redirect to @stamp/it to have a sane codebase. Your call.

koresar commented 6 years ago

Thanks mate.

I agree this package would be need to be eventually redirected to stamp/it. But it's too early.

stampit supports any JS environments (like IE, or other ES5). stamp/it supports only the node v6 and above. Excluding IE.

Someday they will be merged. Currently it's easier this way to maintain things for me.

Btw, you could have noticed the other PR linked little above your first comment: https://github.com/stampit-org/stamp/pull/49