Skip to content

Commit ea41894

Browse files
committed
feat(filematch): export API
1 parent 7a55cac commit ea41894

3 files changed

Lines changed: 45 additions & 0 deletions

File tree

packages/@d-zero/filematch/README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,41 @@ https://example.com/test1.js https://example.com/test2.js
5555
npx @d-zero/filematch -f list.txt
5656
```
5757

58+
## API
59+
60+
このパッケージはAPIとしても使用できます。
61+
62+
### 基本的な使い方
63+
64+
```typescript
65+
import { compare } from '@d-zero/filematch';
66+
67+
// 2つのファイルパスまたはURLを比較
68+
const result = await compare('./test1.pdf', './test2.pdf');
69+
console.log(result); // true または false
70+
```
71+
72+
### 進捗の監視
73+
74+
```typescript
75+
import { compare } from '@d-zero/filematch';
76+
77+
const result = await compare('./test1.pdf', './test2.pdf', (progress) => {
78+
// progress は 0.0 から 1.0 の間の値
79+
console.log(`進捗: ${(progress * 100).toFixed(2)}%`);
80+
});
81+
```
82+
83+
### 型定義
84+
85+
```typescript
86+
import type { OnProgress } from '@d-zero/filematch';
87+
88+
const onProgress: OnProgress = (progress) => {
89+
console.log(`進捗: ${progress}`);
90+
};
91+
```
92+
5893
## 動作環境
5994

6095
- Node.js 20.11以降

packages/@d-zero/filematch/package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@
88
"access": "public"
99
},
1010
"type": "module",
11+
"main": "./dist/index.js",
12+
"types": "./dist/index.d.ts",
13+
"exports": {
14+
".": {
15+
"import": "./dist/index.js",
16+
"types": "./dist/index.d.ts"
17+
}
18+
},
1119
"bin": "./dist/cli.js",
1220
"files": [
1321
"dist"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { compare } from './compare.js';
2+
export type { OnProgress } from './types.js';

0 commit comments

Comments
 (0)