Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/devongovett/dprint-node
A node API for the dprint TypeScript and JavaScript code formatter
https://github.com/devongovett/dprint-node
Last synced: 9 days ago
JSON representation
A node API for the dprint TypeScript and JavaScript code formatter
- Host: GitHub
- URL: https://github.com/devongovett/dprint-node
- Owner: devongovett
- License: mit
- Created: 2021-06-02T05:35:56.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-09-15T04:48:55.000Z (about 1 year ago)
- Last Synced: 2024-10-10T00:11:12.972Z (30 days ago)
- Language: Rust
- Size: 84 KB
- Stars: 484
- Watchers: 3
- Forks: 11
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome - devongovett/dprint-node - A node API for the dprint TypeScript and JavaScript code formatter (Rust)
- jimsghstars - devongovett/dprint-node - A node API for the dprint TypeScript and JavaScript code formatter (Rust)
README
# dprint-node
A node API for the [dprint](https://dprint.dev) TypeScript and JavaScript code formatter. It's written in Rust for blazing fast speed.
## Usage
Pass a file path and the code to format to `dprint.format`.
```js
const dprint = require('dprint-node');dprint.format(filePath, code);
```You can also optionally pass some configuration options as an object to the third parameter. All of the [options listed here](https://dprint.dev/plugins/typescript/config/) are supported.
```js
dprint.format(filePath, code, {
lineWidth: 100
});
```## Benchmark
```
$ node bench.js
#1 dprint: 12,173 opts/sec, ±17% (mean: 0.082ms, stddev: 0.051ms, 50 samples)
#2 prettier: 450 opts/sec, ±53% (mean: 2.222ms, stddev: 4.229ms, 50 samples)
```