You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`stampit` is a JavaScript module which implements the [**stamp** specification](https://www.gitbook.com/book/stampit-org/docs/edit#). **Stamps** are composable factory functions.
3
+
## What is stampit
4
+
5
+
`stampit` is a JavaScript module which implements the [**stamp** specification](essentials/specification/). **Stamps** are composable factory functions.
4
6
5
7
**Think of **_**stamps**_** as classic classes but without any limits, boundaries, or rules.**
6
8
7
9
The stamps brag large amount of features and things you can do with your objects and/or stamps.
8
10
9
-
Head straight to the [Quick Start](/start.md) page for code examples.
11
+
Head straight to the [Quick Start](api/quick-start.md) page for code examples.
10
12
11
-

13
+

12
14
13
-
# Differences from classes
15
+
##Differences from classes
14
16
15
17
* Inheritance
16
18
* Classes
17
19
* Classes do child+parent+parent+parent... inheritance chains. See picture above.
18
20
* When you extend a class you link class prototypes.
19
21
* Stamps
20
22
* Stamp are single object + single prototype. See picture above.
21
-
* When you "extend" you separately merge [methods](/methods.md), separately merge [properties](/properties.md), separately merge [static properties](/static-properties.md), separately merge [initializers](/initializers.md)\(aka constructors\), etc etc etc.
22
-
* That's why it is not just inheritance, but special type of object composition. The stamp composition algorithm is [standardized](/specification/merging-algorithm.md).
23
-
* You can influence composition result with your code at runtime using the [composers](/composers.md) feature.
23
+
* When you "extend" you separately merge [methods](https://github.com/stampit-org/docs/tree/cb1b11dcef3e3b0b3aa5212adcf9047a2f882b06/methods.md), separately merge [properties](https://github.com/stampit-org/docs/tree/cb1b11dcef3e3b0b3aa5212adcf9047a2f882b06/properties.md), separately merge [static properties](https://github.com/stampit-org/docs/tree/cb1b11dcef3e3b0b3aa5212adcf9047a2f882b06/static-properties.md), separately merge [initializers](https://github.com/stampit-org/docs/tree/cb1b11dcef3e3b0b3aa5212adcf9047a2f882b06/initializers.md)\(aka constructors\), etc etc etc.
24
+
* That's why it is not just inheritance, but special type of object composition. The stamp composition algorithm is [standardized](essentials/specification/merging-algorithm.md).
25
+
* You can influence composition result with your code at runtime using the [composers](https://github.com/stampit-org/docs/tree/cb1b11dcef3e3b0b3aa5212adcf9047a2f882b06/composers.md) feature.
24
26
* Object creation
25
27
* Classes
26
28
* In most programming languages you execute only one constructor per class.
@@ -30,19 +32,19 @@ Head straight to the [Quick Start](/start.md) page for code examples.
30
32
* Stamp executes every initializer \(aka constructor\) it has.
31
33
* All initializers receive exactly the same set of arguments, no need to manually pass data.
32
34
* The initializer execution sequence is the same as the stamp composition sequence.
33
-
* To create an object you [call stamp](/start.md) as a function: `const object = MyStamp()`.
35
+
* To create an object you [call stamp](https://github.com/stampit-org/docs/tree/cb1b11dcef3e3b0b3aa5212adcf9047a2f882b06/start.md) as a function: `const object = MyStamp()`.
34
36
35
-
# History
37
+
##History
36
38
37
-
The original idea of Stamps belongs to [Eric Elliott](https://ericelliottjs.com/). See his [first commit](https://github.com/stampit-org/stampit/commit/ac330e8537e349a9640bbe4a34c63150db445a20) from 11 Feb 2013 in the stampit repository. Since then the idea evolved to the [specification](/specification.md) and a whole [ecosystem](/ecosystem.md) of mini modules.
39
+
The original idea of Stamps belongs to [Eric Elliott](https://ericelliottjs.com/). See his [first commit](https://github.com/stampit-org/stampit/commit/ac330e8537e349a9640bbe4a34c63150db445a20) from 11 Feb 2013 in the stampit repository. Since then the idea evolved to the [specification](https://github.com/stampit-org/docs/tree/cb1b11dcef3e3b0b3aa5212adcf9047a2f882b06/specification.md) and a whole [ecosystem](https://github.com/stampit-org/docs/tree/cb1b11dcef3e3b0b3aa5212adcf9047a2f882b06/ecosystem.md) of mini modules.
38
40
39
-
# Using Stamps
41
+
##Using Stamps
40
42
41
-
Head straight to the [Quick start](/start.md) for code examples.
43
+
Head straight to the [Quick start](https://github.com/stampit-org/docs/tree/cb1b11dcef3e3b0b3aa5212adcf9047a2f882b06/start.md) for code examples.
42
44
43
-
# Ecosystem
45
+
##Ecosystem
44
46
45
47
Stampit have a lot of helper modules. You can always find the list of official NPM packages here: [https://www.npmjs.com/~stamp](https://www.npmjs.com/~stamp)
46
48
47
-
See more information on the [Ecosystem](/ecosystem.md) page.
49
+
See more information on the [Ecosystem](https://github.com/stampit-org/docs/tree/cb1b11dcef3e3b0b3aa5212adcf9047a2f882b06/ecosystem.md) page.
@@ -33,13 +33,13 @@ The above `InstanceOf` stamp overrides the default `instanceof` behavior using E
33
33
34
34
> NOTE
35
35
>
36
-
> You can find the stamp above as the [`@stamp/instanceof`](/stampinstanceof.md) NPM module.
36
+
> You can find the stamp above as the [`@stamp/instanceof`](https://github.com/stampit-org/docs/tree/cb1b11dcef3e3b0b3aa5212adcf9047a2f882b06/stampinstanceof.md) NPM module.
37
37
38
38
## Descriptor merging algorithm
39
39
40
40
The composers are concatenated into a deduplicated array. As the result, the order of composition becomes **the order of composer execution**.
You can access the configuration in stamp [initializers](/initializers.md)\(aka constructors\).
29
+
You can access the configuration in stamp [initializers](https://github.com/stampit-org/docs/tree/cb1b11dcef3e3b0b3aa5212adcf9047a2f882b06/initializers.md)\(aka constructors\).
Copy file name to clipboardExpand all lines: api/deep-configuration.md
+10-12
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
-
# Deep Configuration
1
+
# Deep configuration
2
2
3
-
Deep Configuration is a storage of an arbitrary data in the `.deepConfiguration` metadata of stamp's descriptor. But unlike regular \(shallow\) configuration these are deeply merged together by stamp [deep merging algorithm](/specification/merging-algorithm.md).
3
+
Deep Configuration is a storage of an arbitrary data in the `.deepConfiguration` metadata of stamp's descriptor. But unlike regular \(shallow\) configuration these are deeply merged together by stamp [deep merging algorithm](../essentials/specification/merging-algorithm.md).
You can set deep configuration in [static methods](/static-properties.md):
29
+
You can set deep configuration in [static methods](https://github.com/stampit-org/docs/tree/cb1b11dcef3e3b0b3aa5212adcf9047a2f882b06/static-properties.md):
30
30
31
-
```js
31
+
```javascript
32
32
Kue =Kue.statics({
33
33
configureKue(options) {
34
34
returnthis.deepConf({Kue: options}) // create new stamp by composing parent stamp with some configuration
You can access the configuration in stamp [initializers](/initializers.md) \(aka constructors\).
48
+
You can access the configuration in stamp [initializers](https://github.com/stampit-org/docs/tree/cb1b11dcef3e3b0b3aa5212adcf9047a2f882b06/initializers.md) \(aka constructors\).
The deepConfiguration is **deeply merged** using stamp [deep merging algorithm](/specification/merging-algorithm.md). See below - the `Kue` value is always a new object.
68
+
The deepConfiguration is **deeply merged** using stamp [deep merging algorithm](../essentials/specification/merging-algorithm.md). See below - the `Kue` value is always a new object.
69
69
70
-
```js
70
+
```javascript
71
71
Kue.compose.deepConfiguration.Kue!==MyKue.compose.deepConfiguration.Kue// NEVER EQUAL! NO MATTER WHAT!
72
72
```
73
73
74
74
## Other ways to add deep configuration
75
75
76
76
Exactly the same stamp can be created in few ways. Here they all are.
0 commit comments