@dprint/formatter
Wasm formatter for dprint plugins.
Last updated 2 years ago by dsherret .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @dprint/formatter 
SYNC missed versions from official npm registry.

dprint - JS Formatter

CI npm version JSR

JS formatter for dprint Wasm plugins.

Setup

Deno:

deno add @dprint/formatter

Node.js:

npm i @dprint/formatter

Use

import { createStreaming, GlobalConfiguration } from "@dprint/formatter";

const globalConfig: GlobalConfiguration = {
  indentWidth: 2,
  lineWidth: 80,
};
const tsFormatter = await createStreaming(
  // check https://plugins.dprint.dev/ for latest plugin versions
  fetch("https://plugins.dprint.dev/typescript-0.57.0.wasm"),
);

tsFormatter.setConfig(globalConfig, {
  semiColons: "asi",
});

// outputs: "const t = 5\n"
console.log(tsFormatter.formatText("file.ts", "const   t    = 5;"));

Using with plugins on npm (ex. @dprint/json):

import { createFromBuffer } from "@dprint/formatter";
// 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 "node:fs";

const buffer = fs.readFileSync(getPath());
const formatter = createFromBuffer(buffer);

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

Plugin NPM Packages

Note: In the future I will ensure plugins are published to JSR as well.

Current Tags

  • 0.4.1                                ...           latest (2 years ago)

9 Versions

  • 0.4.1                                ...           2 years ago
  • 0.4.0                                ...           2 years ago
  • 0.3.0                                ...           2 years ago
  • 0.2.1                                ...           2 years ago
  • 0.2.0                                ...           4 years ago
  • 0.1.5                                ...           4 years ago
  • 0.1.4                                ...           5 years ago
  • 0.1.3                                ...           5 years ago
  • 0.1.2                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (4)

Copyright 2013 - present © cnpmjs.org | Home |