Skip to content

Commit 6521481

Browse files
committed
docs: update
1 parent 7f1b948 commit 6521481

7 files changed

Lines changed: 43 additions & 289 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# @moeru/std
22

3-
Standard TypeScript Library for Moeru AI.
3+
Standard for Moeru AI.
44

55
## License
66

docs/content/docs/packages/meta.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
"---results---",
1010
"results/index",
1111
"---eslint-config---",
12-
"eslint-config/index"
12+
"eslint-config/index",
13+
"---tsconfig---",
14+
"tsconfig/index"
1315
]
1416
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
title: TSConfig
3+
description: TypeScript Configuration for Moeru AI.
4+
---
5+
6+
```package-install
7+
npm i -D @moeru/tsconfig
8+
```
9+
10+
```jsonc
11+
// tsconfig.json
12+
{
13+
"files": [],
14+
"references": [
15+
{ "path": "./tsconfig.app.json" },
16+
{ "path": "./tsconfig.node.json" }
17+
]
18+
}
19+
```
20+
21+
```jsonc
22+
// tsconfig.app.json
23+
{
24+
"extends": "@moeru/tsconfig",
25+
"include": ["src"]
26+
}
27+
```
28+
29+
```jsonc
30+
// tsconfig.node.json
31+
{
32+
"extends": "@moeru/tsconfig/tsconfig.node.json",
33+
"include": ["*.config.ts", "scripts"]
34+
}
35+
```

packages/eslint-config/README.md

Lines changed: 1 addition & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1 @@
1-
# @moeru/eslint-config
2-
3-
> ESLint Configuration for Moeru AI.
4-
5-
A superset of `@antfu/eslint-config` with optional features:
6-
7-
- [Oxlint](https://oxc.rs/docs/guide/usage/linter) Support (with easy-to-use `moeru-lint` script)
8-
- [Perfectionist Natural](https://github.com/azat-io/eslint-plugin-perfectionist)
9-
- [SonarJS](https://github.com/SonarSource/SonarJS/blob/master/packages/jsts/src/rules/README.md)
10-
- [MaskNet](https://github.com/DimensionDev/eslint-plugin)
11-
- [De Morgan](https://github.com/azat-io/eslint-plugin-de-morgan)
12-
- [Prefer Arrow](https://github.com/TristonJ/eslint-plugin-prefer-arrow)
13-
- [Prefer Let](https://github.com/thefrontside/javascript/tree/v3/packages/eslint-plugin-prefer-let)
14-
15-
## Usage
16-
17-
### Starter Wizard
18-
19-
You can use antfu's Starter Wizard to get started quickly:
20-
21-
```bash
22-
pnpm dlx @antfu/eslint-config@latest
23-
```
24-
25-
Replace `antfu()` to `defineConfig()`:
26-
27-
```diff
28-
- import antfu from '@antfu/eslint-config'
29-
+ import { defineConfig } from '@moeru/eslint-config'
30-
31-
- export default antfu({
32-
+ export default defineConfig({
33-
...options,
34-
})
35-
```
36-
37-
### Manual Install
38-
39-
```bash
40-
pnpm add -D eslint @antfu/eslint-config @moeru/eslint-config
41-
```
42-
43-
```ts
44-
import { defineConfig } from '@moeru/eslint-config'
45-
46-
export default defineConfig({
47-
...options,
48-
})
49-
```
50-
51-
If you only need the default configuration, you can just re-export the default:
52-
53-
```ts
54-
export { default } from '@moeru/eslint-config'
55-
```
56-
57-
### With Oxlint
58-
59-
```bash
60-
pnpm add -D oxlint eslint-plugin-oxlint
61-
```
62-
63-
`@moeru/eslint-config` automatically detects if oxlint is installed, or you can specify it explicitly:
64-
65-
```diff
66-
import { defineConfig } from '@moeru/eslint-config'
67-
68-
export default defineConfig({
69-
...options,
70-
+ oxlint: true,
71-
})
72-
```
73-
74-
You can also use the moeru-lint script to simplify setup:
75-
76-
```diff
77-
{
78-
"scripts": {
79-
- "lint": "oxlint && eslint",
80-
+ "lint": "moeru-lint",
81-
# just use "pnpm lint --fix"!
82-
- "lint:fix": "oxlint --fix && eslint --fix"
83-
}
84-
}
85-
```
86-
87-
moeru-lint enables [ESLint Caching](https://eslint.org/docs/latest/use/command-line-interface#caching) by default to speed things up, you can disable it with `--no-cache`.
88-
89-
## License
90-
91-
[MIT](../../LICENSE.md)
1+
https://std.moeru.ai/docs/packages/eslint-config

packages/results/README.md

Lines changed: 1 addition & 160 deletions
Original file line numberDiff line numberDiff line change
@@ -1,160 +1 @@
1-
# @moeru/eslint-config
2-
3-
> Small and tree-shakeable Result/Option implementation.
4-
5-
## Usage
6-
7-
### Result
8-
9-
> compare with [Rust by Example](https://doc.rust-lang.org/rust-by-example/std/option.html)
10-
11-
```ts
12-
import type { Option } from '@moeru/results'
13-
14-
import { none, option as o, some } from '@moeru/results'
15-
16-
const checkedDivision = (dividend: number, divisor: number): Option<number> =>
17-
divisor === 0
18-
? none
19-
: some(dividend / divisor)
20-
21-
const tryDivision = (dividend: number, divisor: number) =>
22-
o.match(
23-
checkedDivision(dividend, divisor),
24-
quotient => `${dividend} / ${divisor} = ${quotient}`,
25-
() => { throw new Error(`${dividend} / ${divisor} failed!`) },
26-
)
27-
28-
const main = () => {
29-
tryDivision(4, 2) // "4 / 2 = 2"
30-
tryDivision(1, 0) // throw error
31-
32-
const optionalFloat = some(0)
33-
34-
console.log(`${optionalFloat} unwraps to ${o.unwrap(optionalFloat)}`)
35-
console.log(`${none} unwraps to ${o.unwrap(none)}`) // throw error
36-
}
37-
```
38-
39-
### Result
40-
41-
> compare with [Rust by Example](https://doc.rust-lang.org/rust-by-example/std/result.html)
42-
43-
```ts
44-
import type { Result } from '@moeru/results'
45-
46-
import { err, ok, result as r } from '@moeru/results'
47-
48-
enum MathError {
49-
DivisionByZero = 'DivisionByZero',
50-
NegativeSquareRoot = 'NegativeSquareRoot',
51-
NonPositiveLogarithm = 'NonPositiveLogarithm',
52-
}
53-
54-
type MathResult = Result<number, MathError>
55-
56-
const div = (x: number, y: number): MathResult =>
57-
y === 0
58-
? err(MathError.DivisionByZero)
59-
: ok(x / y)
60-
61-
const sqrt = (x: number): MathResult =>
62-
x < 0
63-
? err(MathError.NegativeSquareRoot)
64-
: ok(Math.sqrt(x))
65-
66-
const ln = (x: number): MathResult =>
67-
x <= 0
68-
? err(MathError.NonPositiveLogarithm)
69-
: ok(Math.log(x))
70-
71-
const op = (x: number, y: number): number =>
72-
r.match(
73-
div(x, y),
74-
radio => r.match(
75-
ln(radio),
76-
ln => r.match(
77-
sqrt(ln),
78-
sqrt => sqrt,
79-
(err) => { throw err },
80-
),
81-
(err) => { throw err },
82-
),
83-
(err) => { throw err },
84-
)
85-
86-
const main = () =>
87-
console.log(op(1, 10))
88-
```
89-
90-
### Methods
91-
92-
Most of the methods are the same as in Rust.
93-
94-
We provide different import points for Option and Result:
95-
96-
```ts
97-
import { option as o, result as r } from '@moeru/results'
98-
// import * as o from '@moeru/results/option'
99-
// import * as r from '@moeru/results/result'
100-
101-
console.log(Object.keys(o))
102-
console.log(Object.keys(r))
103-
```
104-
105-
###### extract
106-
107-
Extracted values or errors.
108-
109-
```ts
110-
import { option as o, ok, result as r, some } from '@moeru/results'
111-
112-
o.extract(some('foo') as Option<string>) // string | undefined
113-
r.extract(ok('bar') as Result<string, Error>) // string | Error
114-
```
115-
116-
###### from
117-
118-
Convert common types / function results to Option or Result.
119-
120-
```ts
121-
import { option as o, result as r } from '@moeru/results'
122-
123-
o.from('foo' as 'foo' | undefined) // Option<'foo'>
124-
125-
export const tryParseURL = (url: string) =>
126-
r.from(() => new URL(url)) // Result<string, Error>
127-
```
128-
129-
###### wrap
130-
131-
You can achieve something like the question mark operator in Rust.
132-
133-
Let's modify the Result Example above to use `wrap` / `unwrap` instead of `match`:
134-
135-
```diff
136-
const op = (x: number, y: number): number =>
137-
r.match(
138-
- div(x, y),
139-
- radio => r.match(
140-
- ln(radio),
141-
- ln => r.match(
142-
- sqrt(ln),
143-
- sqrt => sqrt,
144-
- (err) => { throw err },
145-
- ),
146-
- (err) => { throw err },
147-
- ),
148-
+ r.wrap(() => {
149-
+ let _ratio = unwrap(div(x, y))
150-
+ let _ln = unwrap(ln(_ratio))
151-
+ return sqrt(_ln)
152-
+ }),
153-
+ (value) => value,
154-
(err) => { throw err },
155-
)
156-
```
157-
158-
## License
159-
160-
[MIT](../../LICENSE.md)
1+
https://std.moeru.ai/docs/packages/results

packages/std/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://std.moeru.ai/docs/packages/std

packages/tsconfig/README.md

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1 @@
1-
# @moeru/tsconfig
2-
3-
> TypeScript Configuration for Moeru AI.
4-
5-
## Usage
6-
7-
```jsonc
8-
// tsconfig.json
9-
{
10-
"files": [],
11-
"references": [
12-
{ "path": "./tsconfig.app.json" },
13-
{ "path": "./tsconfig.node.json" }
14-
]
15-
}
16-
```
17-
18-
```jsonc
19-
// tsconfig.app.json
20-
{
21-
"extends": "@moeru/tsconfig",
22-
"include": ["src"]
23-
}
24-
```
25-
26-
```jsonc
27-
// tsconfig.node.json
28-
{
29-
"extends": "@moeru/tsconfig/tsconfig.node.json",
30-
"include": ["*.config.ts", "scripts"]
31-
}
32-
```
33-
34-
## License
35-
36-
[MIT](../../LICENSE.md)
1+
https://std.moeru.ai/docs/packages/tsconfig

0 commit comments

Comments
 (0)