# kdu-sfc-descriptor-to-string

> Convert SFCDescriptor to source

Latest version **1.0.0** (published 2022-12-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install kdu-sfc-descriptor-to-string
pnpm add kdu-sfc-descriptor-to-string
yarn add kdu-sfc-descriptor-to-string
bun add kdu-sfc-descriptor-to-string
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2022-12-15 |
| First published | 2022-12-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 4.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | NKDuy |
| Maintainers | nkduy |
| Keywords | kdu, sfc, parse, stringify |

## Links

- npm: https://www.npmjs.com/package/kdu-sfc-descriptor-to-string
- Repository: https://github.com/khanhduy1407/kdu-sfc-descriptor-to-string
- Issues: https://github.com/khanhduy1407/kdu-sfc-descriptor-to-string/issues
- npm.io page: https://npm.io/package/kdu-sfc-descriptor-to-string

## Dependencies (1)

- [indent-string](https://npm.io/package/indent-string.md) ^3.2.0

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2022-12-15

## README

# kdu-sfc-descriptor-to-string

Convert SFCDescriptor to source

## Install

`npm install kdu-sfc-descriptor-to-string`

## Usage

```js
// parse an sfc
const compiler = require('kdu-template-compiler');
const sfcDescriptor = compiler.parseComponent(sfcSource);

// convert sfc descriptor back to source
const toString = require('kdu-sfc-descriptor-to-string');
const result = toString(sfcDescriptor);

result == sfcSource // => true, but see caveats below
```

## API

```js
const toString = require('kdu-sfc-descriptor-to-string');
```

### `toString(SFCDescriptor, options)`

#### options

Optional object, defaults to `{}`

##### options.indents

Optional object that can have a property for each sfc block name (e.g. `template`). Values are the number of spaces to indent that block's content.

Defaults to

```js
{
  template: 2,
  script: 0,
  style: 0
}
```

## Caveats

This module isn't a true inverse of `compiler.parseComponent()` because it doesn't always produce the exact same sfc compared to what was parsed. It assumes the parsed sfc

- ends with a single newline
- has a single space before each attribute on `<script>`, `<template>`, `<style>`
- has attributes in abc order on `<script>`, `<template>`, `<style>`
- other stuff

## License

MIT

---
_Source: https://npm.io/package/kdu-sfc-descriptor-to-string · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
