A collection of fun and useful JavaScript functions. This is an open-source project, and contributions are welcome!
- Simple Web Interface: A clean and intuitive web interface to use the functions.
- Dark Mode: A comfortable dark mode for those late-night coding sessions.
- Syntax Highlighting: The output is beautifully formatted with syntax highlighting.
- Easy to Contribute: A simple process for adding new functions.
To get a local copy up and running, follow these simple steps.
You'll need a modern web browser like Chrome, Firefox, or Safari.
- Clone the repo
git clone https://github.com/devgl96/fun_js_functions.git
- Navigate to the project directory
cd fun_js_functions - Open
index.htmlin your browser.
This project provides a simple web interface to use the functions.
- Open the
index.htmlfile in your web browser. - Select a function from the dropdown menu.
- Paste your JSON input into the text area on the left.
- Click the "Convert" button.
- The result will be displayed in the box on the right.
This function converts an array of JSON objects into a SQL query with UNION clauses. It's useful for generating test data or for bulk inserts where UNION is applicable.
Input (JSON):
[
{ "name": "John Doe", "age": 30 },
{ "name": "Jane Smith", "age": 25, "city": "New York" }
]Output (SQL):
SELECT 'John Doe' AS name, 30 AS age, NULL AS city
UNION
SELECT 'Jane Smith', 25, 'New York';This function converts a JSON object into a series of SQL SET statements. This is useful for setting variables in a SQL script from a configuration object.
Input (JSON):
{
"id": 1,
"user": "testuser",
"filter": "active"
}Output (SQL):
SET @id = 1;
SET @user = 'testuser';
SET @filter = 'active';We'd love for you to contribute to our project! Here's how you can help:
- Fork the repository: Start by forking the main repository.
- Clone your fork: Clone your forked repository to your local machine.
- Create a new branch: Create a new branch for your feature or bug fix.
- Add your function:
- Create a new
.jsfile for your new function (e.g.,myNewFunction.js). The file should contain only your function. - In
main.js, add the name of your function to theavailableFunctionsarray. - In
index.html, add a<script>tag for your new function file before themain.jsscript tag.
- Create a new
- Test your function: Open
index.htmland test your new function to make sure it works as expected. - Submit a pull request: Once you're happy with your changes, submit a pull request to the main repository.
We appreciate your help in making this a great collection of functions!
Distributed under the MIT License. See LICENSE for more information.