Skip to content

Commit

Permalink
docs: move usage to example
Browse files Browse the repository at this point in the history
  • Loading branch information
mumu-lhl committed Aug 17, 2024
1 parent c4731e7 commit 3502cf6
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 104 deletions.
53 changes: 1 addition & 52 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,55 +23,4 @@ dart pub add dict_reader

## Usage

### Read Data Directly

```dart
import 'package:dict_reader/dict_reader.dart';
void main() async {
final dictReader = DictReader("MDX FILE PATH");
await dictReader.init();
await for (final (keyText, data) in dictReader.read(true)) {
print("$keyText, $data");
}
}
```

### Read Data Offset, Read Data Later

```dart
import 'package:dict_reader/dict_reader.dart';
void main() async {
final dictReader = DictReader("MDX FILE PATH");
await dictReader.init();
final map = <String, (int, int, int, int)>{};
await for (final (keyText, offset) in dictReader.read()) {
map[keyText] = offset;
}
final offset = map["go"];
print(await dictReader.readOne(offset!.$1, offset.$2, offset.$3, offset.$4));
}
```

### Read Data After Stored Data Offset

```dart
import 'package:dict_reader/dict_reader.dart';
// ...
void main() async {
// ...
final dictReader = DictReader("MDX FILE PATH");
// Pass false to reduce initialization time
await dictReader.init(false);
final offset = map["go"];
print(await dictReader.readOne(offset!.$1, offset.$2, offset.$3, offset.$4));
}
```
See [Example](./example/README.md).
53 changes: 1 addition & 52 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,55 +23,4 @@ dart pub add dict_reader

## 使用

### 直接读取数据

```dart
import 'package:dict_reader/dict_reader.dart';
void main() async {
final dictReader = DictReader("MDX FILE PATH");
await dictReader.init();
await for (final (keyText, data) in dictReader.read(true)) {
print("$keyText, $data");
}
}
```

### 读取数据 offset,之后读取数据

```dart
import 'package:dict_reader/dict_reader.dart';
void main() async {
final dictReader = DictReader("MDX FILE PATH");
await dictReader.init();
final map = <String, (int, int, int, int)>{};
await for (final (keyText, offset) in dictReader.read()) {
map[keyText] = offset;
}
final offset = map["go"];
print(await dictReader.readOne(offset!.$1, offset.$2, offset.$3, offset.$4));
}
```

### 当已保存数据 offset,读取数据

```dart
import 'package:dict_reader/dict_reader.dart';
// ...
void main() async {
// ...
final dictReader = DictReader("MDX FILE PATH");
// Pass false to reduce initialization time
await dictReader.init(false);
final offset = map["go"];
print(await dictReader.readOne(offset!.$1, offset.$2, offset.$3, offset.$4));
}
```
[示例](./example/README_CN.md)
56 changes: 56 additions & 0 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Example

English | [中文](./README_CN.md)

## Read Data Directly

```dart
import 'package:dict_reader/dict_reader.dart';
void main() async {
final dictReader = DictReader("MDX FILE PATH");
await dictReader.init();
await for (final (keyText, data) in dictReader.read(true)) {
print("$keyText, $data");
}
}
```

## Read Data Offset, Read Data Later

```dart
import 'package:dict_reader/dict_reader.dart';
void main() async {
final dictReader = DictReader("MDX FILE PATH");
await dictReader.init();
final map = <String, (int, int, int, int)>{};
await for (final (keyText, offset) in dictReader.read()) {
map[keyText] = offset;
}
final offset = map["go"];
print(await dictReader.readOne(offset!.$1, offset.$2, offset.$3, offset.$4));
}
```

## Read Data After Stored Data Offset

```dart
import 'package:dict_reader/dict_reader.dart';
// ...
void main() async {
// ...
final dictReader = DictReader("MDX FILE PATH");
// Pass false to reduce initialization time
await dictReader.init(false);
final offset = map["go"];
print(await dictReader.readOne(offset!.$1, offset.$2, offset.$3, offset.$4));
}
```
56 changes: 56 additions & 0 deletions example/README_CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# 示例

[English](./README.md) | 中文

## 直接读取数据

```dart
import 'package:dict_reader/dict_reader.dart';
void main() async {
final dictReader = DictReader("MDX FILE PATH");
await dictReader.init();
await for (final (keyText, data) in dictReader.read(true)) {
print("$keyText, $data");
}
}
```

## 读取数据 offset,之后读取数据

```dart
import 'package:dict_reader/dict_reader.dart';
void main() async {
final dictReader = DictReader("MDX FILE PATH");
await dictReader.init();
final map = <String, (int, int, int, int)>{};
await for (final (keyText, offset) in dictReader.read()) {
map[keyText] = offset;
}
final offset = map["go"];
print(await dictReader.readOne(offset!.$1, offset.$2, offset.$3, offset.$4));
}
```

## 当已保存数据 offset,读取数据

```dart
import 'package:dict_reader/dict_reader.dart';
// ...
void main() async {
// ...
final dictReader = DictReader("MDX FILE PATH");
// Pass false to reduce initialization time
await dictReader.init(false);
final offset = map["go"];
print(await dictReader.readOne(offset!.$1, offset.$2, offset.$3, offset.$4));
}
```

0 comments on commit 3502cf6

Please sign in to comment.