lscontests 1.7.0 → 1.7.1
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +6 -6
- package/dist/cli.js +2 -2
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
@@ -111,9 +111,9 @@ If you want to call lscontests in your project to get a list of contests informa
|
|
111
111
|
#### Get contests information string
|
112
112
|
|
113
113
|
```typescript
|
114
|
-
import {
|
114
|
+
import { getContestInfo } from "lscontests";
|
115
115
|
|
116
|
-
|
116
|
+
getContestInfo({ abbrList: ["cf", "lg"] }).then(console.log);
|
117
117
|
```
|
118
118
|
|
119
119
|
The result of this code is the same as `lsct -o cf lg`.
|
@@ -121,9 +121,9 @@ The result of this code is the same as `lsct -o cf lg`.
|
|
121
121
|
#### Get contests information list
|
122
122
|
|
123
123
|
```typescript
|
124
|
-
import {
|
124
|
+
import { getContestList } from "lscontests";
|
125
125
|
|
126
|
-
|
126
|
+
getContestList({ sort: false }).then(console.log);
|
127
127
|
```
|
128
128
|
|
129
129
|
The result of this code is the same as `lsct -r --no-sort`.
|
@@ -131,7 +131,7 @@ The result of this code is the same as `lsct -r --no-sort`.
|
|
131
131
|
#### Add OJ support
|
132
132
|
|
133
133
|
```typescript
|
134
|
-
import { addOJ,
|
134
|
+
import { addOJ, getContestList } from "lscontests";
|
135
135
|
|
136
136
|
addOJ("ts", {
|
137
137
|
name: "testOJ", get: async () => [{
|
@@ -144,7 +144,7 @@ addOJ("ts", {
|
|
144
144
|
}]
|
145
145
|
});
|
146
146
|
|
147
|
-
|
147
|
+
getContestList({ abbrList: ["ts"], days: 7 }).then(console.log);
|
148
148
|
```
|
149
149
|
|
150
150
|
The result of this code is as follows:
|
package/dist/cli.js
CHANGED
@@ -36,9 +36,9 @@ function main() {
|
|
36
36
|
sort: opts.sort
|
37
37
|
};
|
38
38
|
if (opts.raw)
|
39
|
-
console.log(yield (0, _1.
|
39
|
+
console.log(yield (0, _1.getContestList)(config));
|
40
40
|
else
|
41
|
-
console.log(yield (0, _1.
|
41
|
+
console.log(yield (0, _1.getContestInfo)(config, opts.language));
|
42
42
|
}
|
43
43
|
});
|
44
44
|
}
|
package/dist/cli.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,kDAA0C;AAC1C,yCAA4C;AAC5C,iCAAiC;AACjC,
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,kDAA0C;AAC1C,yCAA4C;AAC5C,iCAAiC;AACjC,wBAAqE;AAErE,mBAAO;KACF,IAAI,CAAC,MAAM,CAAC;KACZ,OAAO,CAAC,sBAAO,CAAC;KAChB,MAAM,CAAC,mBAAmB,EAAE,4CAA4C,EAAE,GAAG,CAAC;KAC9E,MAAM,CAAC,YAAY,EAAE,uBAAuB,CAAC;KAC7C,SAAS,CAAC,IAAI,kBAAM,CAAC,mBAAmB,EAAE,iCAAiC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,UAAK,CAAC,CAAC,CAAC;KACzG,SAAS,CAAC,IAAI,kBAAM,CAAC,WAAW,EAAE,wBAAwB,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;KAClF,SAAS,CAAC,IAAI,kBAAM,CAAC,uBAAuB,EAAE,qBAAqB,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,WAAQ,CAAC,CAAC;KACxG,MAAM,CAAC,WAAW,EAAE,qDAAqD,CAAC;KAC1E,KAAK,EAAE,CAAC;AAEb,MAAM,IAAI,GAAG,mBAAO,CAAC,IAAI,EAAE,CAAC;AAE5B,SAAe,IAAI;;QACf,IAAI,IAAI,CAAC,IAAI;YAAE,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,UAAK,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;aACjE;YACD,MAAM,MAAM,GAAW;gBACnB,QAAQ,EAAE,IAAI,CAAC,EAAE;gBACjB,IAAI,EAAE,IAAI,CAAC,IAAc;gBACzB,IAAI,EAAE,IAAI,CAAC,IAAI;aAClB,CAAC;YACF,IAAI,IAAI,CAAC,GAAG;gBAAE,OAAO,CAAC,GAAG,CAAC,MAAM,IAAA,iBAAc,EAAC,MAAM,CAAC,CAAC,CAAC;;gBACnD,OAAO,CAAC,GAAG,CAAC,MAAM,IAAA,iBAAc,EAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;SACjE;IACL,CAAC;CAAA;AAED,IAAI,EAAE,CAAC"}
|
package/dist/index.d.ts
CHANGED
@@ -4,7 +4,7 @@ export declare type config = {
|
|
4
4
|
days?: number;
|
5
5
|
sort?: boolean;
|
6
6
|
};
|
7
|
-
declare function
|
7
|
+
declare function getContestList(config?: config): Promise<import("./lib/contest").contest[]>;
|
8
8
|
export declare const langList: string[];
|
9
|
-
declare function
|
10
|
-
export { addOJ,
|
9
|
+
declare function getContestInfo(config?: config, language?: string): Promise<string>;
|
10
|
+
export { addOJ, getContestList, getContestInfo };
|
package/dist/index.js
CHANGED
@@ -32,7 +32,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
32
32
|
});
|
33
33
|
};
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
35
|
-
exports.
|
35
|
+
exports.getContestInfo = exports.getContestList = exports.addOJ = exports.langList = void 0;
|
36
36
|
const fs_1 = require("fs");
|
37
37
|
const oj_1 = require("./lib/oj");
|
38
38
|
Object.defineProperty(exports, "addOJ", { enumerable: true, get: function () { return oj_1.addOJ; } });
|
@@ -41,7 +41,7 @@ const defaultConfig = {
|
|
41
41
|
days: 3,
|
42
42
|
sort: true
|
43
43
|
};
|
44
|
-
function
|
44
|
+
function getContestList(config) {
|
45
45
|
return __awaiter(this, void 0, void 0, function* () {
|
46
46
|
const cfg = Object.assign(Object.assign({}, defaultConfig), config);
|
47
47
|
if (!cfg.abbrList)
|
@@ -62,19 +62,19 @@ function getList(config) {
|
|
62
62
|
return contests;
|
63
63
|
});
|
64
64
|
}
|
65
|
-
exports.
|
65
|
+
exports.getContestList = getContestList;
|
66
66
|
exports.langList = (0, fs_1.readdirSync)(`${__dirname}/locale`).map((fileName) => fileName.replace(".json", ""));
|
67
67
|
function format(s, ...args) {
|
68
68
|
for (let i = 0; i < args.length; i++)
|
69
69
|
s = s.replace(`{${i}}`, args[i]);
|
70
70
|
return s;
|
71
71
|
}
|
72
|
-
function
|
72
|
+
function getContestInfo(config, language = "zh-CN") {
|
73
73
|
return __awaiter(this, void 0, void 0, function* () {
|
74
74
|
if (!exports.langList.includes(language))
|
75
75
|
throw new Error(`Illegal language ${language}, the allowed languages are ${exports.langList}`);
|
76
76
|
const cfg = Object.assign(Object.assign({}, defaultConfig), config);
|
77
|
-
const contests = yield
|
77
|
+
const contests = yield getContestList(cfg);
|
78
78
|
const info = [];
|
79
79
|
const lang = yield Promise.resolve().then(() => __importStar(require(`./locale/${language}.json`)));
|
80
80
|
info.push(format(lang.welcome, cfg.days.toString(), contests.length.toString()));
|
@@ -89,5 +89,5 @@ function getString(config, language = "zh-CN") {
|
|
89
89
|
return info.join("\n");
|
90
90
|
});
|
91
91
|
}
|
92
|
-
exports.
|
92
|
+
exports.getContestInfo = getContestInfo;
|
93
93
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2BAAiC;AACjC,iCAAwC;AAuE/B,sFAvEA,UAAK,OAuEA;AA/Dd,MAAM,aAAa,GAAG;IAClB,QAAQ,EAAE,MA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