An open API service indexing awesome lists of open source software.

https://github.com/imcuttle/quote-it

Safe quoting a given string without adding duplicate quotes
https://github.com/imcuttle/quote-it

quote stringify

Last synced: about 1 year ago
JSON representation

Safe quoting a given string without adding duplicate quotes

Awesome Lists containing this project

README

          

# quote-it

[![build status](https://img.shields.io/travis/imcuttle/quote-it/master.svg?style=flat-square)](https://travis-ci.org/imcuttle/quote-it)
[![Test coverage](https://img.shields.io/codecov/c/github/imcuttle/quote-it.svg?style=flat-square)](https://codecov.io/github/imcuttle/quote-it?branch=master)
[![NPM version](https://img.shields.io/npm/v/quote-it.svg?style=flat-square)](https://www.npmjs.com/package/quote-it)
[![NPM Downloads](https://img.shields.io/npm/dm/quote-it.svg?style=flat-square&maxAge=43200)](https://www.npmjs.com/package/quote-it)

Safe quoting a given string without adding duplicate quotes

## API

### quote

[index.js:46-57](https://github.com/imcuttle/quote-it/blob/5c1b0291e0cc2742427b102f31b68d1ca0cf1f87/index.js#L46-L57 'Source code on GitHub')

Uses `quoteChar` to wrap string.

#### Parameters

- `string` {string}
- `quoteChar` {string}

#### Examples

```javascript
import quote from 'quote-it'
quote('abc', "'") === "'abc'"
```

Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**

### single

[index.js:68-70](https://github.com/imcuttle/quote-it/blob/5c1b0291e0cc2742427b102f31b68d1ca0cf1f87/index.js#L68-L70 'Source code on GitHub')

Uses single quote to wrap string.

#### Parameters

- `string`

#### Examples

```javascript
import { single } from 'quote-it'
single("a'bc") === "'a'bc'"
```

Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**

### double

[index.js:78-80](https://github.com/imcuttle/quote-it/blob/5c1b0291e0cc2742427b102f31b68d1ca0cf1f87/index.js#L78-L80 'Source code on GitHub')

Uses double quote to wrap string.

#### Parameters

- `string`

Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**

## License

MIT