-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add typescript-related packages * "@babel/preset-typescript" and "typescript" to build src * "ts-node" to run unit test * Add types for function parameters * Add class `Article`, `Board` * prevent sending 0 length message * Move .babelrc to babel.config.js
- Loading branch information
1 parent
103ada6
commit 79a85ce
Showing
29 changed files
with
419 additions
and
143 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,18 @@ | ||
"use strict"; | ||
|
||
module.exports = function(api) { | ||
api.cache(true); | ||
const config = { | ||
presets: [ | ||
"@babel/env", | ||
"@babel/preset-typescript" | ||
], | ||
plugins: [ | ||
"@babel/plugin-proposal-export-default-from", | ||
["@babel/plugin-proposal-class-properties", { loose: false }], | ||
"@babel/plugin-proposal-object-rest-spread", | ||
["@babel/plugin-transform-runtime", { regenerator: true }], | ||
] | ||
} | ||
return config; | ||
} |
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,3 @@ | ||
export default interface Config { | ||
[key: string]: any; | ||
}; |
This file was deleted.
Oops, something went wrong.
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,4 @@ | ||
export { default as default } from './sites/ptt'; | ||
export { default as ptt } from './sites/ptt'; | ||
export { default as Config } from './config'; | ||
export { default as Socket } from './socket'; |
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,47 @@ | ||
import {substrWidth} from '../../utils/char'; | ||
|
||
export class Article { | ||
boardname: string; | ||
sn: number; | ||
push: string; | ||
date: string; | ||
timestamp: string; | ||
author: string; | ||
status: string; | ||
title: string; | ||
fixed: boolean; | ||
private _content: string[] = []; | ||
|
||
constructor() { | ||
} | ||
|
||
static fromLine(line: string): Article { | ||
let article = new Article(); | ||
article.sn =+substrWidth('dbcs', line, 1, 7).trim(); | ||
article.push = substrWidth('dbcs', line, 9, 2).trim(); | ||
article.date = substrWidth('dbcs', line, 11, 5).trim(); | ||
article.author = substrWidth('dbcs', line, 17, 12).trim(); | ||
article.status = substrWidth('dbcs', line, 30, 2).trim(); | ||
article.title = substrWidth('dbcs', line, 32 ).trim(); | ||
article.fixed = substrWidth('dbcs', line, 1, 7).trim().includes('★'); | ||
return article; | ||
} | ||
|
||
get content(): ReadonlyArray<string> { | ||
return this._content; | ||
} | ||
set content(data: ReadonlyArray<string>) { | ||
this._content = data.slice(); | ||
} | ||
/** | ||
* @deprecated | ||
*/ | ||
get lines(): ReadonlyArray<string> { | ||
return this.content; | ||
} | ||
set lines(data: ReadonlyArray<string>) { | ||
this.content = data; | ||
} | ||
}; | ||
|
||
export default Article; |
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,45 @@ | ||
import {substrWidth} from '../../utils/char'; | ||
|
||
export class Board { | ||
boardname: string; | ||
bn: number; | ||
read: boolean; | ||
category: string; | ||
title: string; | ||
users: string; | ||
admin: string; | ||
folder: boolean = false; | ||
divider: boolean = false; | ||
|
||
constructor() { | ||
} | ||
|
||
static fromLine(line: string): Board { | ||
let board = new Board(); | ||
board.bn =+substrWidth('dbcs', line, 3, 4).trim(); | ||
board.read = substrWidth('dbcs', line, 8, 2).trim() === ''; | ||
board.boardname = substrWidth('dbcs', line, 10, 12).trim(); | ||
board.category = substrWidth('dbcs', line, 23, 4).trim(); | ||
switch (board.boardname) { | ||
case 'MyFavFolder': | ||
board.title = substrWidth('dbcs', line, 30); | ||
board.users = ''; | ||
board.admin = ''; | ||
board.folder = true; | ||
break; | ||
case '------------': | ||
board.title = substrWidth('dbcs', line, 30); | ||
board.users = ''; | ||
board.admin = ''; | ||
board.divider = true; | ||
break; | ||
default: | ||
board.title = substrWidth('dbcs', line, 30, 31); | ||
board.users = substrWidth('dbcs', line, 62, 5).trim(); | ||
board.admin = substrWidth('dbcs', line, 67 ).trim(); | ||
break; | ||
} | ||
return board; | ||
} | ||
|
||
}; |
Oops, something went wrong.