Skip to content

Commit

Permalink
Merge pull request #225 from Phuire-Research/Consistency
Browse files Browse the repository at this point in the history
Removed Buffer v0.1.71
  • Loading branch information
REllEK-IO committed May 16, 2024
2 parents cd64ff4 + cb7bbf1 commit 3a70432
Show file tree
Hide file tree
Showing 9 changed files with 4 additions and 447 deletions.
11 changes: 0 additions & 11 deletions ActionStrategy.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,16 +182,6 @@ export const createAsyncMethodThrottle =
export const createAsyncMethodThrottleWithState =
(asyncMethodWithState: (controller: ActionController, action: Action, concepts: Concepts) =>
void, concepts$: UnifiedSubject, semaphore: number, duration: number): [Method, Subject<Action>] => {}
export const createMethodBuffer =
(method: (action: Action) => Action, duration: number): [Method, Subject<Action>] => {}
export const createMethodBufferWithState =
(methodWithState: (action: Action, concepts: Concepts) => Action, concepts$: UnifiedSubject, semaphore: number, duration: number)
: [Method, Subject<Action>] => {}
export const createAsyncMethodBuffer =
(asyncMethod: (controller: ActionController, action: Action) => void, duration: number): [Method, Subject<Action>] => {}
export const createAsyncMethodBufferWithState =
(asyncMethodWithState: (controller: ActionController, action: Action, concepts: Concepts) =>
void, concepts$: UnifiedSubject, semaphore: number, duration: number): [Method, Subject<Action>] => {}
```
* createMethod - Your standard method, be sure to handle the action.strategy via one of the strategy decision functions, in addition to passing the action if there is no attached strategy.
* createMethodWithState - This will allow your method to have the most recent state to be accessed via the asyncMethod function.
Expand All @@ -207,7 +197,6 @@ export const createAsyncMethodBufferWithState =
* createMethodThrottleWithState- Fires the first action, alongside the most recent state, then filters rest as conclude.
* createAsyncMethodThrottle - Asynchronously fires the first action, will filtering the rest for the set duration as conclude.
* createAsyncMethodThrottleWithState - Fires the first action asynchronously with the most recent state, and filters action during the duration as conclude to remove stale tickers from ownership if loaded.
* **Buffer Series** similar to debounce method series, but will issue each possible action that encounters the quality for a length of time. Note these will fail ActionStrategies whose time has expired.

## "Creator Functions"
Note here this is merely a guideline to inform the creation of your strategies.
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,9 @@ When in doubt simplify.
* [Unified Turing Machine](https://github.com/Phuire-Research/Stratimux/blob/main/The-Unified-Turing-Machine.md) - The governing concept for this entire framework.

## Change Log ![Tests](https://github.com/Phuire-Research/Stratimux/actions/workflows/node.js.yml/badge.svg)
### Consistency Update v0.1.70 5/16/2024
* Added new buffer method series that will delay the dispatch of some possible set of actions for a period of time.
* **NOTE CURRENTLY INVESTIGATING WHY BUFFER WORKS IN ISOLATION, BUT NOT IN A COMPLEX SET UP**
* Finally removed the need to add "as Subject<Concepts> | UnifiedSubject" when creating methods that access state or concepts.
### Consistency Update v0.1.71 5/16/2024
* Finally removed the need to add "as Subject<Concepts> | UnifiedSubject" when creating methods that access state or concepts.
* Added then **removed** a new Buffer Method Creator Series. See branch Stash-Buffer for details.
### v0.1.69 5/15/2024
* Added priority to axium strategies.
* Improved consistency of logic due the above change.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "stratimux",
"license": "GPL-3.0",
"version": "0.1.70",
"version": "0.1.71",
"description": "Unified Turing Machine",
"main": "dist/index.js",
"module": "dist/index.mjs",
Expand Down
6 changes: 0 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,6 @@ export {
createMethodDebounceWithConcepts,
createAsyncMethodThrottleWithConcepts,
createAsyncMethodDebounceWithConcepts,
createMethodBuffer,
createMethodBufferWithState,
createMethodBufferWithConcepts,
createAsyncMethodBuffer,
createAsyncMethodBufferWithConcepts,
createAsyncMethodBufferWithState,
method
} from './model/method';
export {
Expand Down
143 changes: 0 additions & 143 deletions src/model/method.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,143 +98,6 @@ export const createAsyncMethodWithState =
defaultMethod.toString = () => ('Async Method with State');
return [defaultMethod, defaultSubject];
};
export const createMethodBuffer =
(method: (action: Action) => Action, duration: number): [Method, Subject<Action>] => {
const defaultSubject = new Subject<Action>();
const defaultMethod: Method = defaultSubject.pipe(
bufferTime(duration),
filter(actions => actions.length > 0),
switchMap(actions => createActionControllerForEach$(actions)),
map((action: Action) => {
// Logically Determined axiumConclude
if (action.semaphore[3] !== 3) {
const methodAction = method(action);
if (methodAction.strategy) {
return [methodAction, true];
}
const conclude = axiumConclude();
return [{
...action,
...conclude,
}, false];
} else {
return [action, true];
}
}),
);
defaultMethod.toString = () => ('Debounce Method');
return [defaultMethod, defaultSubject];
};
export const createMethodBufferWithState =
<T>(methodWithState:
(action: Action, state: T) => Action, concepts$: Subject<Concepts>, semaphore: number, duration: number): [Method, Subject<Action>] => {
const defaultSubject = new Subject<Action>();
const defaultMethod: Method = defaultSubject.pipe(
bufferTime(duration),
switchMap(actions => createActionControllerForEach$(actions)),
withLatestFrom(concepts$),
map(([act, concepts] : [Action, Concepts]): [Action, T] => ([act, selectUnifiedState<T>(concepts, semaphore) as T])),
map(([act, state] : [Action, T]) => {
// Logically Determined axiumConclude
if (act.semaphore[3] !== 3) {
const methodAction = methodWithState(act, state);
if (methodAction.strategy) {
return [methodAction, true];
}
const conclude = axiumConclude();
return [{
...act,
...conclude,
}, true];
} else {
return [act, true];
}
}),
);
defaultMethod.toString = () => ('Buffer Method with State');
return [defaultMethod, defaultSubject];
};
export const createMethodBufferWithConcepts =
(
methodWithConcepts: (action: Action, concepts: Concepts, semaphore: number) => Action, concepts$: Subject<Concepts>,
semaphore: number,
duration: number
) : [Method, Subject<Action>] => {
const defaultSubject = new Subject<Action>();
const defaultMethod: Method = defaultSubject.pipe(
bufferTime(duration),
switchMap(actions => createActionControllerForEach$(actions)),
withLatestFrom(concepts$),
map(([act, concepts] : [Action, Concepts]) => {
// Logically Determined axiumConclude
if (act.semaphore[3] !== 3) {
const methodAction = methodWithConcepts(act, concepts, semaphore);
if (methodAction.strategy) {
return [methodAction, true];
}
const conclude = axiumConclude();
return [{
...act,
...conclude,
}, false];
} else {
return [act, true];
}
}),
);
defaultMethod.toString = () => ('Buffer Method with Concepts');
return [defaultMethod, defaultSubject];
};
export const createAsyncMethodBuffer =
(asyncMethod: (controller: ActionController, action: Action) => void, duration: number): [Method, Subject<Action>] => {
const defaultSubject = new Subject<Action>();
const defaultMethod: Method = defaultSubject.pipe(
bufferTime(duration),
switchMap(actions => createActionControllerForEach$(actions)),
mergeMap((act) => {
return createActionController$(act, (controller: ActionController, action: Action) => {
asyncMethod(controller, action);
});
}),
);
defaultMethod.toString = () => ('Async Buffer Method');
return [defaultMethod, defaultSubject];
};
export const createAsyncMethodBufferWithState =
<T>(asyncMethodWithState: (controller: ActionController, action: Action, state: T) =>
void, concepts$: Subject<Concepts>, semaphore: number, duration: number, ): [Method, Subject<Action>] => {
const defaultSubject = new Subject<Action>();
const defaultMethod: Method = defaultSubject.pipe(
bufferTime(duration),
switchMap(actions => createActionControllerForEach$(actions)),
withLatestFrom(concepts$),
map(([act, concepts] : [Action, Concepts]): [Action, T] => ([act, selectUnifiedState<T>(concepts, semaphore) as T])),
mergeMap(([act, state] : [Action, T]) => {
return createActionController$(act, (controller: ActionController, action: Action) => {
asyncMethodWithState(controller, action, state);
});
})
);
defaultMethod.toString = () => ('Async Buffer Method with State');
return [defaultMethod, defaultSubject];
};
export const createAsyncMethodBufferWithConcepts =
(asyncMethodWithConcepts: (controller: ActionController, action: Action, concepts: Concepts, semaphore: number) =>
void, concepts$: Subject<Concepts>, semaphore: number, duration: number, ): [Method, Subject<Action>] => {
const defaultSubject = new Subject<Action>();
const defaultMethod: Method = defaultSubject.pipe(
bufferTime(duration),
switchMap(actions => createActionControllerForEach$(actions)),
withLatestFrom(concepts$),
mergeMap(([act, concepts] : [Action, Concepts]) => {
return createActionController$(act, (controller: ActionController, action: Action) => {
asyncMethodWithConcepts(controller, action, concepts, semaphore);
});
}),
);
defaultMethod.toString = () => ('Async Buffer Method with Concepts');
return [defaultMethod, defaultSubject];
};
export const createMethodDebounce =
(method: (action: Action) => Action, duration: number): [Method, Subject<Action>] => {
const defaultSubject = new Subject<Action>();
Expand Down Expand Up @@ -555,11 +418,5 @@ export const method = ({
createAsyncThrottle: createAsyncMethodThrottle,
createAsyncThrottleWithState: createAsyncMethodThrottleWithState,
createAsyncThrottleWithConcepts: createAsyncMethodThrottleWithConcepts,
createBuffer: createMethodBuffer,
createBufferWithState: createMethodBufferWithState,
createMethodBufferWithConcepts: createMethodBufferWithConcepts,
createAsyncBuffer: createAsyncMethodBuffer,
createAsyncBufferWithState: createAsyncMethodBufferWithState,
createAsyncBufferWithConcepts: createAsyncMethodBufferWithConcepts
});
/*#>*/
Loading

0 comments on commit 3a70432

Please sign in to comment.