# @f/stringify-attrs

> Turn an attributes object into a string

Latest version **1.0.5** (published 2016-10-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install @f/stringify-attrs
pnpm add @f/stringify-attrs
yarn add @f/stringify-attrs
bun add @f/stringify-attrs
```

## 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.5 |
| Published | 2016-10-17 |
| First published | 2016-01-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | f |

## Links

- npm: https://www.npmjs.com/package/@f/stringify-attrs
- Repository: https://github.com/micro-js/stringify-attrs
- Homepage: https://github.com/micro-js/stringify-attrs#readme
- Issues: https://github.com/micro-js/stringify-attrs/issues
- npm.io page: https://npm.io/package/@f/stringify-attrs

## Dependencies (2)

- [@f/is-valid-attr](https://npm.io/package/@f/is-valid-attr.md) ^1.0.0
- [@f/to-inline-style](https://npm.io/package/@f/to-inline-style.md) ^0.1.3

## Recent versions

- 1.0.5 (latest) — 2016-10-17
- 1.0.4 — 2016-04-29
- 1.0.3 — 2016-04-21
- 1.0.2 — 2016-01-08
- 1.0.1 — 2016-01-08
- 1.0.0 — 2016-01-08

## README

# stringify-attrs

[![Build status][travis-image]][travis-url]
[![Git tag][git-image]][git-url]
[![NPM version][npm-image]][npm-url]
[![Code style][standard-image]][standard-url]

Turn an attributes object into a string

## Installation

    $ npm install @f/stringify-attrs

## Usage

```js
var stringifyAttrs = require('@f/stringify-attrs')

stringifyAttrs({href: 'http://www.google.com', class: 'link'}) === ' href="http://www.google.com" class="link"'
```

## API

### stringifyAttrs(attrs, skip)

- `attrs` - An object of key/value pairs representing attributes
- `skip` - Optional. Map of attribute names to skip. E.g. `{innerHTML: true}`. This is useful if there are certain attribute names that don't make sense when rendered as strings.

**Returns:** A string containing the attributes in `key=value` style. Returns empty string if falsy value passed.

## Prepended space

The returned string starts with a prepended space (e.g. `' class="link"'`). This makes the code short, simpler, and faster, and also comports better with the most common use-case, which is rendering a DOM element as a string (if you don't have the prepended space, you have to again awkwardly check whether attrs is empty).

## License

MIT

[travis-image]: https://img.shields.io/travis/micro-js/stringify-attrs.svg?style=flat-square
[travis-url]: https://travis-ci.org/micro-js/stringify-attrs
[git-image]: https://img.shields.io/github/tag/micro-js/stringify-attrs.svg
[git-url]: https://github.com/micro-js/stringify-attrs
[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat
[standard-url]: https://github.com/feross/standard
[npm-image]: https://img.shields.io/npm/v/@f/stringify-attrs.svg?style=flat-square
[npm-url]: https://npmjs.org/package/@f/stringify-attrs

---
_Source: https://npm.io/package/@f/stringify-attrs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
