# js2string

> Convert JS functions, variables and etc... to String

Latest version **1.0.2** (published 2018-02-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install js2string
pnpm add js2string
yarn add js2string
bun add js2string
```

## 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.2 |
| Published | 2018-02-17 |
| First published | 2018-02-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 2.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Valeriy Zimnev |
| Maintainers | zmnv |

## Links

- npm: https://www.npmjs.com/package/js2string
- Repository: https://github.com/zmnv/js2string
- Homepage: https://github.com/zmnv/js2string#readme
- Issues: https://github.com/zmnv/js2string/issues
- npm.io page: https://npm.io/package/js2string

## Recent versions

- 1.0.2 (latest) — 2018-02-17
- 1.0.1 — 2018-02-17
- 1.0.0 — 2018-02-17

## README

>





Simple code inside **index.js**:

```js
export default function js2string(InputFunction) {
    // {([^}]*)}
    const regex = /{([^]*)}/g;
    const exit = regex.exec(InputFunction.toString());
    return exit[1];
}
```

#### RegExp Patterns
 `/{([^]*)}/g` – All In One Group  
 `/{([^}]*)}/g` – Multiply groups devided by `(){}` inside of main `(){}`

 `/g` – is for `global` search.

# Examples

## example.js
```js
// Example code to convert

const body = () => {
    console.log('Simple Example of source usage');
};



// Convert `const body` to string

function js2string(INPUT) {
    const regex = /{([^]*)}/g;
    const exit = regex.exec(INPUT.toString());

    console.log(`${exit}`);
}
js2string(body);

```

#### Returns

`${exit}`
```text
{
    console.log('Simple Example of source usage');
},
    console.log('Simple Example of source usage');
```   
   
\
`${exit[1]}`
```text

    console.log('dataCollector() run SUCCESS');

```

/
## exampleSoHard.js
```js
// Example code to convert

const soHardExample = () => {
    console.log('dataCollector() run SUCCESS');
    const getInside = () => {
        // so sweet.
    }
    const getMeOtherFunction = () => {
        // so sweet too...
        const sheDrivesMeCrazy = () => {
            // mmm okay
        }
        () => {
            // ahcucaraacha
        }
    }
};



// Convert `const body` to string

function js2string(INPUT) {
    const regex = /{([^]*)}/g;
    const exit = regex.exec(INPUT.toString());

    console.log(`${exit}`);
}
js2string(soHardExample);

```

#### Returns

`${exit[1]}`
```text

    console.log('dataCollector() run SUCCESS');
    const getInside = () => {
        // so sweet.
    }
    const getMeOtherFunction = () => {
        // so sweet too...
        const sheDrivesMeCrazy = () => {
            // mmm okay
        }
        () => {
            // ahcucaraacha
        }
    }

```

# Conclusion

You can modify that library to optimize some processes... any way it's just a simple code.
It's all about mysterious...

😈 . . . 🔮 . . .

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