OneLib.js

The modern JavaScript utility library that makes everyday coding effortless

Real-World Use Cases

E-commerce Shopping Cart

Calculate totals, validate inputs, and manage cart state with ease

Cart is empty
// Add item to cart const price = 19.99; cartItems.push(price); OneLib.save('cart', cartItems); // Calculate total const total = OneLib.sum(cartItems); OneLib.text('#total', `$${OneLib.round(total, 2)}`);

Social Media Feed

Format timestamps, truncate posts, and handle user interactions

No posts yet
// Create post with timestamp const post = { content: OneLib.truncate(userInput, 280), timestamp: OneLib.now(), likes: 0 }; // Display relative time OneLib.text('.time', OneLib.since(post.timestamp));

Form Validation

Validate user inputs, sanitize data, and provide instant feedback

Enter data to validate
// Validate email const email = OneLib.trim(OneLib.lower(userInput)); const isValid = email.includes('@') && !OneLib.isempty(email); // Format name const name = OneLib.capitalize(OneLib.trim(nameInput));

Data Dashboard

Process analytics data, calculate statistics, and update charts

No data loaded
// Process analytics data const data = [45, 67, 23, 89, 12, 56, 78]; const stats = { average: OneLib.avg(data), total: OneLib.sum(data), max: OneLib.max(data), min: OneLib.min(data) };

Content Management

Create SEO-friendly URLs, manage content, and handle media

Enter a title to start
// Create SEO-friendly URL const title = "How to Build Amazing Web Apps"; const slug = OneLib.slug(title); // "how-to-build-amazing-web-apps" const url = `/articles/${slug}`; // Generate unique ID const articleId = OneLib.uuid();

User Interface Animations

Create smooth transitions, handle user interactions, and manage UI state

Click buttons to animate
// Smooth animations OneLib.fadein('#modal', 500); OneLib.move('#element', 100, 50); OneLib.scale('#image', 1.2); // Toggle UI states OneLib.cls('#menu', 'active'); OneLib.toggle('#sidebar');
63
Utility Functions
0
Dependencies
12KB
Minified Size
100%
TypeScript Support

Interactive Playground

Try OneLib Functions

Results will appear here...

Installation & Import

JavaScript / Node.js

Click to copy
npm install @gamedevayaan/onelib // ES6 Import import OneLib from '@gamedevayaan/onelib'; // CommonJS const OneLib = require('@gamedevayaan/onelib'); // Browser CDN <script src="https://cdn.example.com/onelib/v1/onelib.min.js"></script> // Usage OneLib.select('#myElement'); OneLib.sum([1, 2, 3, 4, 5]);

TypeScript

Click to copy
npm install @gamedevayaan/onelib npm install @types/@gamedevayaan/onelib // Import with full type support import OneLib from '@gamedevayaan/onelib'; // Usage with IntelliSense const result: number = OneLib.sum([1, 2, 3]); const element: Element | null = OneLib.select('.btn'); const isValid: boolean = OneLib.isnum(42);

React

Click to copy
npm install @gamedevayaan/onelib // Import in component import React, { useState, useEffect } from 'react'; import OneLib from '@gamedevayaan/onelib'; function MyComponent() { const [data, setData] = useState([]); useEffect(() => { const saved = OneLib.load('userData'); if (saved) setData(saved); }, []); const handleSave = () => { OneLib.save('userData', data); }; return <div>{OneLib.sum(data)}</div>; }

Vue.js

Click to copy
npm install @gamedevayaan/onelib // Import in component <template> <div> <p>Total: {{ total }}</p> <button @click="calculate">Calculate</button> </div> </template> <script> import OneLib from '@gamedevayaan/onelib'; export default { data() { return { numbers: [1, 2, 3, 4, 5], total: 0 } }, methods: { calculate() { this.total = OneLib.sum(this.numbers); } } } </script>

Angular

Click to copy
npm install @gamedevayaan/onelib // Import in service import { Injectable } from '@angular/core'; import OneLib from '@gamedevayaan/onelib'; @Injectable({ providedIn: 'root' }) export class DataService { processData(items: number[]): any { return { sum: OneLib.sum(items), avg: OneLib.avg(items), max: OneLib.max(items), min: OneLib.min(items) }; } saveUserData(data: any): void { OneLib.save('user', data); } }

Svelte

Click to copy
npm install @gamedevayaan/onelib // Import in component <script> import OneLib from '@gamedevayaan/onelib'; let inputText = ''; let result = ''; function processText() { result = OneLib.slug(inputText); } </script> <input bind:value={inputText} placeholder="Enter text" /> <button on:click={processText}>Create Slug</button> <p>Slug: {result}</p>

Next.js

Click to copy
npm install @gamedevayaan/onelib // pages/api/data.js (API Route) import OneLib from '@gamedevayaan/onelib'; export default function handler(req, res) { const data = req.body.numbers; const stats = { sum: OneLib.sum(data), avg: OneLib.avg(data), id: OneLib.uuid() }; res.status(200).json(stats); } // pages/index.js (Component) import OneLib from '@gamedevayaan/onelib'; export default function Home({ data }) { return <div>{OneLib.format(new Date())}</div>; }

Deno

Click to copy
// Import from URL import OneLib from 'https://deno.land/x/onelib/mod.ts'; // Or from npm import OneLib from 'npm:@gamedevayaan/onelib'; // Usage const data = [1, 2, 3, 4, 5]; console.log('Sum:', OneLib.sum(data)); console.log('Average:', OneLib.avg(data)); // File operations const text = await Deno.readTextFile('./data.txt'); const words = OneLib.words(text); console.log('Word count:', words.length);