Skip to content

Commit

Permalink
chore: update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret committed Oct 1, 2022
1 parent 29ad3fe commit 75182af
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,23 @@ console.log(tsFormatter.formatText("file.ts", "const t = 5;"));

## Node.js

Use the following:

```ts
import { createFromBuffer } from "@dprint/formatter";
import { getBuffer } from "@dprint/json";
// You may have to use `getBuffer` on plugins that haven't updated yet.
// See the plugins README.md for details.
import { getPath } from "@dprint/json";
import * as fs from "fs";

// or provide something like fs.readFileSync("./json.wasm")
const formatter = createFromBuffer(getBuffer());
const buffer = fs.readFileSync(getPath());
const formatter = createFromBuffer(buffer);

console.log(formatter.formatText("test.json", "{test: 5}"));
```

Unfortunately Node.js doesn't have any way to cache compiles at the moment and so it will have a slower than ideal startup time.

### Plugin NPM Packages

- [@dprint/json](https://www.npmjs.com/package/@dprint/json)
Expand Down
7 changes: 3 additions & 4 deletions dprint.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"incremental": true,
"typescript": {
"indentWidth": 2
},
Expand All @@ -14,8 +13,8 @@
"**/*-lock.json"
],
"plugins": [
"https://plugins.dprint.dev/typescript-0.61.0.wasm",
"https://plugins.dprint.dev/json-0.14.0.wasm",
"https://plugins.dprint.dev/markdown-0.12.0.wasm"
"https://plugins.dprint.dev/typescript-0.74.0.wasm",
"https://plugins.dprint.dev/json-0.15.6.wasm",
"https://plugins.dprint.dev/markdown-0.14.1.wasm"
]
}

0 comments on commit 75182af

Please sign in to comment.