Skip to content

Commit

Permalink
State conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
universalweb committed Mar 2, 2023
1 parent a7a40fc commit ff283c9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
File renamed without changes.
29 changes: 19 additions & 10 deletions state/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
module.exports = (type, state = {}) => {
state.type = type;
state.utility = require('Acid');
state.getUtil = (names) => {
names.forEach((item) => {
require(`../utilities/${item}/`)(state);
import { eachAsyncArray, construct } from 'Acid';
class State {
constructor(type, existingState) {
this.type = type;
this.utility = require('Acid');
}
modules = ['console', 'msgpack', 'file', 'crypto', 'certificate'];
getUtil() {
const thisClass = this;
eachAsyncArray(this.modules, async (item) => {
const imported = await import(`../utilities/${item}/`);
await imported(thisClass);
});
};
state.getUtil(['console', 'msgpack', 'file', 'crypto', 'certificate']);
return state;
};
}
}
function state(...args) {
return construct(State, args);
}
export { State };
export default state;

0 comments on commit ff283c9

Please sign in to comment.