1.0.2 ā€¢ Published 6 years ago

js2string v1.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

Simple code inside index.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

// 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}

{
    console.log('Simple Example of source usage');
},
    console.log('Simple Example of source usage');

\ ${exit[1]}

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

/

exampleSoHard.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]}

    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...

šŸ˜ˆ . . . šŸ”® . . .

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago