# string-type-convertor

> transform string to typed value (number, boolean, float, null, undefined, ...)

Latest version **1.2.0** (published 2020-12-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install string-type-convertor
pnpm add string-type-convertor
yarn add string-type-convertor
bun add string-type-convertor
```

## 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.2.0 |
| Published | 2020-12-02 |
| First published | 2020-11-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | benevolarX |
| Maintainers | benevolar |
| Keywords | string, type, convertor, convert, transform, typeConvertor, string-to-number, string-to-boolean, string-to-float |

## Links

- npm: https://www.npmjs.com/package/string-type-convertor
- Repository: https://github.com/benevolarX/string-type-convertor
- Homepage: https://github.com/benevolarX/string-type-convertor#readme
- Issues: https://github.com/benevolarX/string-type-convertor/issues
- npm.io page: https://npm.io/package/string-type-convertor

## Alternatives

- [@libsql/sqlite3](https://npm.io/package/@libsql/sqlite3.md) — 39.8K weekly downloads
- [@fortemi/core](https://npm.io/package/@fortemi/core.md) — 461 weekly downloads
- [cdb-converter](https://npm.io/package/cdb-converter.md) — 341 weekly downloads
- [@uplo/adapter-prisma](https://npm.io/package/@uplo/adapter-prisma.md) — 75 weekly downloads
- [typeorm-aios](https://npm.io/package/typeorm-aios.md) — 30 weekly downloads

## Recent versions

- 1.2.0 (latest) — 2020-12-02
- 1.1.0 — 2020-11-22
- 1.0.1 — 2020-11-04
- 1.0.0 — 2020-11-03

## README

[![GitHub license](https://img.shields.io/github/license/benevolarX/string-type-convertor?style=for-the-badge)](https://github.com/benevolarX/string-type-convertor/blob/main/LICENSE)
[![npm](https://img.shields.io/npm/v/string-type-convertor?style=for-the-badge)](https://www.npmjs.com/package/string-type-convertor)
[![npm](https://img.shields.io/npm/dw/string-type-convertor?style=for-the-badge)](https://www.npmjs.com/package/string-type-convertor)
![npm bundle size](https://img.shields.io/bundlephobia/min/string-type-convertor?style=for-the-badge)
[![GitHub issues](https://img.shields.io/github/issues/benevolarX/string-type-convertor?style=for-the-badge)](https://github.com/benevolarX/string-type-convertor/issues)


# string-type-convertor
string-type-convertor is a js library for transform string to typed value (number, boolean, float, null, undefined, ...)
It is useful when creating a router to retrieve the typed parameters of the url.

## Installation

Download [nodejs](https://nodejs.org/) first.
Use [npm](https://www.npmjs.com/package/npm) to install string-type-convertor.

```bash
npm i string-type-convertor
```

## Usage

```js
const typeConvertor = require('string-type-convertor');

typeConvertor("undefined"); // return undefined
typeConvertor("null"); // return null
typeConvertor("true"); // return true
typeConvertor("false"); // return false
typeConvertor("37n"); // return 37n
typeConvertor("3.14"); // return 3.14
typeConvertor("150"); // return 150
typeConvertor("hello"); // return 'hello'

const myTest = (val) => {
    return val === 'email';
}

const myConvert = (val) => {
    return `no-reply@my-website.com`;
}

const personnal = {
    test: myTest,
    convert: myConvert
}

typeConvertor("email", [personnal]); // return 'no-reply@my-website.com'


```

## Contributing
I try to publish a small js helper.
README generate by Google Translate (sorry for bad english)

## License
[MIT](https://github.com/benevolarX/string-type-convertor/blob/main/LICENSE)

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