startup.js
is a lightweight JavaScript utility library designed for startups and small projects. It includes a collection of core functions that help accelerate web development without the overhead of larger frameworks. The library is modular, easy to extend, and optimized for performance, making it ideal for rapid prototyping and early-stage development.
- Core Utilities: Type checking, deep cloning, unique ID generation, throttling, and debouncing.
- DOM Manipulation: Simple, lightweight functions for selecting elements, managing events, and applying styles.
- AJAX and Fetch: Easy-to-use HTTP
GET
andPOST
requests using the Fetch API. - Storage Utilities: Simplified local storage handling.
- Form Handling: Functions for serializing form data to an object format.
You can include startup.js
in your project by downloading the file or by using a CDN (if available).
<script src="path/to/startup.js"></script>
const startup = require('startup.js');
import startup from './path/to/startup.js';
startup.isType([1, 2, 3], 'array'); // true
startup.isType('Hello', 'string'); // true
const original = { a: 1, b: { c: 2 } };
const clone = startup.deepClone(original);
console.log(clone); // { a: 1, b: { c: 2 } }
const id = startup.generateUUID();
console.log(id); // e.g., '123e4567-e89b-12d3-a456-426614174000'
window.addEventListener('resize', startup.throttle(() => {
console.log('Throttled resize event');
}, 200));
const handleSearch = startup.debounce(() => {
console.log('Debounced search input');
}, 300);
document.querySelector('input').addEventListener('input', handleSearch);
const element = startup.$('#myElement');
console.log(element); // <div id="myElement">...</div>
const button = startup.$('#myButton');
startup.on(button, 'click', () => {
alert('Button clicked!');
});
const element = startup.$('#myElement');
startup.setStyles(element, {
color: 'blue',
fontSize: '18px'
});
startup.httpGet('https://api.example.com/data')
.then(data => console.log(data))
.catch(error => console.error(error));
startup.httpPost('https://api.example.com/data', { key: 'value' })
.then(response => console.log(response))
.catch(error => console.error(error));
startup.setLocalStorage('user', { name: 'John', age: 30 });
const user = startup.getLocalStorage('user');
console.log(user); // { name: 'John', age: 30 }
startup.removeLocalStorage('user');
const form = document.querySelector('#myForm');
const formData = startup.serializeForm(form);
console.log(formData); // { name: 'John', email: 'john@example.com' }
Feel free to contribute to this library by submitting issues or creating pull requests. Contributions are welcome to expand functionality, improve documentation, or fix bugs.
startup.js
is licensed under the MIT License. See the LICENSE file for more details.
For questions, issues, or suggestions, feel free to reach out via email at [your-email@example.com].
This library is inspired by the need for lightweight and performance-oriented solutions in early-stage startup environments, offering alternatives to bulkier frameworks.