-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #100 from e-flux-platform/formatting
Apply prettier and enforce formatting via CI
- Loading branch information
Showing
33 changed files
with
455 additions
and
349 deletions.
There are no files selected for viewing
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
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
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Check pull request | ||
|
||
on: | ||
pull_request: | ||
types: [opened, reopened, synchronize] | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
timeout-minutes: 5 | ||
|
||
- name: Install node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: package.json | ||
|
||
- name: Install dependencies | ||
run: yarn install | ||
|
||
- name: Run lint | ||
run: yarn lint |
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 +1,7 @@ | ||
src/components/RichTextEditor/utils/draft/__fixtures__/example.md | ||
**/*.md | ||
**/*.html | ||
src/schemas | ||
.webpack-cache | ||
dist | ||
**/.yarn | ||
src/semantic/ |
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
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
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,75 +1,83 @@ | ||
// Class representing clock, used to enable 'time travel' in the simulation | ||
class Clock { | ||
protected nowDate: Date | ||
protected clockInterval | ||
constructor(protected speed = 1) { | ||
this.nowDate = new Date(); | ||
this.clockInterval = setInterval(() => { | ||
this.nowDate.setTime(this.nowDate.getTime() + (1000 * this.speed)) | ||
}, 1000) | ||
} | ||
protected nowDate: Date; | ||
protected clockInterval; | ||
constructor(protected speed = 1) { | ||
this.nowDate = new Date(); | ||
this.clockInterval = setInterval(() => { | ||
this.nowDate.setTime(this.nowDate.getTime() + 1000 * this.speed); | ||
}, 1000); | ||
} | ||
|
||
public setSpeed(speed: number) { | ||
this.speed = speed; | ||
} | ||
public setSpeed(speed: number) { | ||
this.speed = speed; | ||
} | ||
|
||
public getSpeed() { | ||
return this.speed; | ||
} | ||
public getSpeed() { | ||
return this.speed; | ||
} | ||
|
||
public secondsSince(since: Date) { | ||
return Math.round((this.nowDate.getTime() - since.getTime()) / 1000); | ||
} | ||
public secondsSince(since: Date) { | ||
return Math.round((this.nowDate.getTime() - since.getTime()) / 1000); | ||
} | ||
|
||
public reset() { | ||
this.nowDate = new Date(); | ||
} | ||
public reset() { | ||
this.nowDate = new Date(); | ||
} | ||
|
||
public now() { | ||
return new Date(this.nowDate); | ||
} | ||
public now() { | ||
return new Date(this.nowDate); | ||
} | ||
|
||
public setInterval(callback: Function, interval: number, name: string = ""): Interval { | ||
return new Interval(this, callback, interval, name); | ||
} | ||
public setInterval( | ||
callback: Function, | ||
interval: number, | ||
name: string = '' | ||
): Interval { | ||
return new Interval(this, callback, interval, name); | ||
} | ||
|
||
public adjustBySpeed(input: number): number { | ||
return Math.floor(input / this.speed); | ||
} | ||
public adjustBySpeed(input: number): number { | ||
return Math.floor(input / this.speed); | ||
} | ||
} | ||
|
||
class Interval { | ||
protected timeoutHandle: NodeJS.Timeout | undefined; | ||
protected continue: boolean = false; | ||
constructor( | ||
protected readonly clock: Clock, | ||
protected readonly callback: Function, | ||
protected readonly interval: number, | ||
protected readonly name: string | ||
) { | ||
this.start(); | ||
} | ||
|
||
protected timeoutHandle: NodeJS.Timeout | undefined; | ||
protected continue: boolean = false; | ||
constructor(protected readonly clock: Clock, protected readonly callback: Function, protected readonly interval: number, protected readonly name: string) { | ||
this.start(); | ||
} | ||
public start() { | ||
this.continue = true; | ||
this.tick(); | ||
} | ||
|
||
public start() { | ||
this.continue = true; | ||
this.tick(); | ||
} | ||
public stop() { | ||
this.continue = false; | ||
clearTimeout(this.timeoutHandle); | ||
} | ||
|
||
public stop() { | ||
this.continue = false; | ||
clearTimeout(this.timeoutHandle); | ||
} | ||
|
||
protected tick() { | ||
if (this.continue) { | ||
this.timeoutHandle = setTimeout(() => { | ||
if (!this.continue) { | ||
return; | ||
} | ||
this.callback(); | ||
this.tick(); | ||
}, this.interval / this.clock.getSpeed()) | ||
protected tick() { | ||
if (this.continue) { | ||
this.timeoutHandle = setTimeout(() => { | ||
if (!this.continue) { | ||
return; | ||
} | ||
this.callback(); | ||
this.tick(); | ||
}, this.interval / this.clock.getSpeed()); | ||
} | ||
} | ||
} | ||
|
||
const clock = new Clock(); | ||
|
||
export default clock; | ||
export {Interval}; | ||
export { Interval }; |
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
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
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
21 changes: 11 additions & 10 deletions
21
src/lib/ChargeStation/eventHandlers/ocpp-16/handle-change-configuration.ts
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,18 +1,19 @@ | ||
import { ChargeStationEventHandler } from 'lib/ChargeStation/eventHandlers'; | ||
import { ChangeConfigurationRequest } from 'schemas/ocpp/1.6/ChangeConfiguration'; | ||
|
||
const handleChangeConfigurationHandler: ChargeStationEventHandler<ChangeConfigurationRequest> = | ||
({ chargepoint, callMessageId, callMessageBody }) => { | ||
const { key } = callMessageBody; | ||
const handleChangeConfigurationHandler: ChargeStationEventHandler< | ||
ChangeConfigurationRequest | ||
> = ({ chargepoint, callMessageId, callMessageBody }) => { | ||
const { key } = callMessageBody; | ||
|
||
chargepoint.configuration.setVariable(key, callMessageBody); | ||
chargepoint.configuration.setVariable(key, callMessageBody); | ||
|
||
const response = { | ||
status: 'Accepted', | ||
}; | ||
|
||
chargepoint.writeCallResult(callMessageId, response); | ||
chargepoint.save(); | ||
const response = { | ||
status: 'Accepted', | ||
}; | ||
|
||
chargepoint.writeCallResult(callMessageId, response); | ||
chargepoint.save(); | ||
}; | ||
|
||
export default handleChangeConfigurationHandler; |
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
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
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
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
Oops, something went wrong.