@doeixd/machine 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/cjs/development/core.js +4 -2
- package/dist/cjs/development/core.js.map +2 -2
- package/dist/cjs/development/index.js +17 -7
- package/dist/cjs/development/index.js.map +2 -2
- package/dist/cjs/development/minimal.js +13 -5
- package/dist/cjs/development/minimal.js.map +2 -2
- package/dist/cjs/development/react.js +4 -2
- package/dist/cjs/development/react.js.map +2 -2
- package/dist/cjs/production/core.js +1 -1
- package/dist/cjs/production/index.js +2 -2
- package/dist/cjs/production/minimal.js +1 -1
- package/dist/cjs/production/react.js +1 -1
- package/dist/esm/development/core.js +4 -2
- package/dist/esm/development/core.js.map +2 -2
- package/dist/esm/development/index.js +17 -7
- package/dist/esm/development/index.js.map +2 -2
- package/dist/esm/development/minimal.js +13 -5
- package/dist/esm/development/minimal.js.map +2 -2
- package/dist/esm/development/react.js +4 -2
- package/dist/esm/development/react.js.map +2 -2
- package/dist/esm/production/core.js +1 -1
- package/dist/esm/production/index.js +2 -2
- package/dist/esm/production/minimal.js +1 -1
- package/dist/esm/production/react.js +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/minimal.d.ts +5 -28
- package/dist/types/minimal.d.ts.map +1 -1
- package/dist/types/types.d.ts +2 -2
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +4 -2
- package/src/minimal.ts +20 -38
- package/src/types.ts +1 -1
package/README.md
CHANGED
|
@@ -59,7 +59,9 @@ type Machine<C extends object> = {
|
|
|
59
59
|
**Flexibility**: Unlike rigid FSM implementations, you can choose your level of immutability. Want to mutate? You can. Want pure functions? You can. Want compile-time state validation? Type-State Programming gives you that.
|
|
60
60
|
|
|
61
61
|
**Read more about our core principles:** [ 📖 Core Principles Guide ](./docs/principles.md)
|
|
62
|
-
**
|
|
62
|
+
**Learn about our recent refinements and workflows:** [ 🚀 Evolution & Workflows ](./docs/evolution.md)
|
|
63
|
+
**Prefer simplicity and little abstraction?** [ 🧘 The Minimalist's Manifesto (YAGNI) ](./docs/yagni.md)
|
|
64
|
+
**Explore our utility helpers (tag, isState, tag.factory, States):** [ 🏷️ Tagged Helpers & Utilities ](./docs/tagged-helpers.md)
|
|
63
65
|
|
|
64
66
|
## Choosing the Right Pattern
|
|
65
67
|
|
|
@@ -1715,12 +1715,14 @@ function state(context, transitions) {
|
|
|
1715
1715
|
// src/index.ts
|
|
1716
1716
|
function createMachine(context, fnsOrFactory) {
|
|
1717
1717
|
if (typeof fnsOrFactory === "function") {
|
|
1718
|
+
let self;
|
|
1718
1719
|
let transitions2;
|
|
1719
1720
|
const transition = (newContext) => {
|
|
1720
|
-
return createMachine(newContext, transitions2);
|
|
1721
|
+
return newContext === context ? self : createMachine(newContext, transitions2);
|
|
1721
1722
|
};
|
|
1722
1723
|
transitions2 = fnsOrFactory(transition);
|
|
1723
|
-
|
|
1724
|
+
self = attachTransitions(Object.assign({ context }, transitions2), transitions2);
|
|
1725
|
+
return self;
|
|
1724
1726
|
}
|
|
1725
1727
|
const stored = getStoredTransitions(fnsOrFactory);
|
|
1726
1728
|
const transitions = stored != null ? stored : "context" in fnsOrFactory ? snapshotOwnTransitions(fnsOrFactory) : fnsOrFactory;
|