-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core-bwlimit-flow): enable limit speed
- Loading branch information
Showing
4 changed files
with
118 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { AjaxFlowInteralNode, CombErr } from '../core'; | ||
import { IRcloneServer } from '../extra'; | ||
import { PostFlow } from './post-flow'; | ||
|
||
export interface CoreBwlimitFlowParamsNode { | ||
rate?: string; | ||
} | ||
|
||
export interface CoreBwlimitFlowInNode extends IRcloneServer, CoreBwlimitFlowParamsNode {} | ||
|
||
export interface CoreBwlimitFlowOutNode { | ||
bandwidth: { | ||
bytesPerSecond: number; | ||
rate: string; | ||
}; | ||
} | ||
|
||
export abstract class CoreBwlimitFlow extends PostFlow< | ||
CoreBwlimitFlowInNode, | ||
CoreBwlimitFlowOutNode, | ||
CoreBwlimitFlowParamsNode | ||
> { | ||
// public prerequest$: Observable<CombErr<IRcloneServer>>; | ||
protected cmd = 'core/bwlimit'; | ||
protected cacheSupport = false; | ||
protected params = (pre: CombErr<CoreBwlimitFlowInNode>): CoreBwlimitFlowParamsNode => { | ||
if (pre[1].length !== 0) return {}; | ||
if (pre[0].rate) return { rate: pre[0].rate }; | ||
return {}; | ||
}; | ||
protected reconstructAjaxResult(x: AjaxFlowInteralNode): CombErr<CoreBwlimitFlowOutNode> { | ||
if (x[1].length !== 0) return [{}, x[1]] as any; | ||
const rsp = x[0].ajaxRsp.response; | ||
return [{ bandwidth: rsp }, []]; | ||
} | ||
} |
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