https://github.com/reasonml-old/refmt-js
refmt packaged as a JS library
https://github.com/reasonml-old/refmt-js
reasonml refmt
Last synced: about 1 year ago
JSON representation
refmt packaged as a JS library
- Host: GitHub
- URL: https://github.com/reasonml-old/refmt-js
- Owner: reasonml-old
- License: other
- Created: 2017-08-23T23:44:19.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2018-03-13T00:10:53.000Z (over 8 years ago)
- Last Synced: 2025-05-26T03:11:07.565Z (about 1 year ago)
- Topics: reasonml, refmt
- Language: JavaScript
- Size: 4.13 MB
- Stars: 6
- Watchers: 7
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Deprecated
Reason now comes with a `refmt.js`! See https://github.com/facebook/reason/tree/master#installation-for-programmatic-usage
**======================== Old README**
## Installation
```
npm i refmt
```
## Usage
```js
const refmt = require('refmt')
const myReasonMLCode = fs.readFileSync('file.re')
const formattedCode = refmt(myReasonMLCode)
```
## API
#### `refmt(source: string, sourceLang: string?, sourceType: string?, targetLang: string?): string`
The `refmt` function will output styled ReasonML or OCaml source code. The only required param is
`source`, the input source code. `sourceLang` specifies the input language, defaulted to Reason.
Specify `'RE'` for Reason, or `'ML'` for OCaml input. `sourceType` specifies the source code type,
either `'implementation'` or `'interface'`, defaults to implementation. `targetLang` specifies the
output language, `'RE'` for Reason, or `'ML'` for OCaml, defaults to Reason.
## Source Maps
The distibution also includes a sourcemap for the compiled JS. To enable Node to use the provided source
map, please use [`source-map-support`](https://github.com/evanw/node-source-map-support).