Skip to content

Commit

Permalink
Merge branch 'nodecli-esm' of github.com:asciidwango/js-primer into n…
Browse files Browse the repository at this point in the history
…odecli-esm
  • Loading branch information
lacolaco committed Sep 4, 2022
2 parents 8303765 + aecdae4 commit df3adaa
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion source/use-case/nodecli/read-file/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Node.jsでファイルの読み書きを行うには、標準モジュールの[
Node.jsの標準モジュールは`node:fs`のように`node:`プリフィックスをつけてインポートできます。
プリフィックスを付けない`fs`でもインポートできますが、npmからインストールしたサードパーティ製のモジュールとの区別が明確になるため、付けておくことが推奨されます。

次のサンプルコードは、ECMAScriptモジュールの`import * as`構文を使って、`fs/promises` モジュール全体を`fs`オブジェクトとしてインポートしています。
次のコードは、ECMAScriptモジュールの`import * as`構文を使って、`fs/promises` モジュール全体を`fs`オブジェクトとしてインポートしています。

<!-- doctest:disable -->
```js
Expand Down
2 changes: 1 addition & 1 deletion source/use-case/nodecli/refactor-and-unittest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ ECMAScriptモジュールでは`export`文を使って変数や関数などの
[import, title:"greet-main.js"](src/example/greet-main.js)

これから行うアプリケーションのモジュール化とは、このようにアプリケーションの一部分を別のファイルに切り出した上で、必要なオブジェクトをエクスポートして外部から利用可能にするということです。
モジュールとして切り出されることで、アプリケーションとユニットテストの両方から利用できるようになります。
機能をモジュールとして切り出すことで、アプリケーションとユニットテストの両方から利用できるようになります。

それではCLIアプリケーションのソースコードをモジュールに分割してみましょう。
`md2html.js`という名前のJavaScriptファイルを作成し、次のようにmarkedを使ったMarkdownの変換処理を記述します。
Expand Down

0 comments on commit df3adaa

Please sign in to comment.