-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
universalweb
committed
Mar 2, 2023
1 parent
a7a40fc
commit ff283c9
Showing
2 changed files
with
19 additions
and
10 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |