DOM Utilities 13
select(selector)
Select the first element matching CSS selector
OneLib.select('#myDiv')
const el = OneLib.select('.button');
Use case: Quick DOM element selection for manipulation
html(selector, content)
Get or set innerHTML of element
OneLib.html('#content', '<h1>Hello</h1>')
OneLib.html('#title', '<strong>New Title</strong>');
Use case: Dynamic content updates, template rendering
css(selector, styles)
Apply CSS styles to element
OneLib.css('#box', {color: 'red'})
OneLib.css('.card', {transform: 'scale(1.1)'});
Use case: Dynamic styling, animations
on(selector, event, callback)
Add event listener to element
OneLib.on('#btn', 'click', handler)
OneLib.on('.tab', 'click', switchTab);
Use case: Interactive UI, form handling
Math Helpers 10
sum(array)
Calculate sum of numbers
OneLib.sum([1, 2, 3])
const total = OneLib.sum(cartPrices);
Use case: Shopping carts, totals calculation
avg(array)
Calculate average of numbers
OneLib.avg([1, 2, 3, 4, 5])
const avgScore = OneLib.avg(testScores);
Use case: Statistics, performance metrics
rand(min, max)
Generate random number between min and max
OneLib.rand(1, 100)
const price = OneLib.rand(10, 99.99);
Use case: Random values, simulations, games
clamp(value, min, max)
Clamp value between min and max bounds
OneLib.clamp(150, 0, 100)
const volume = OneLib.clamp(userInput, 0, 100);
Use case: Input validation, slider controls
Text Helpers 8
slug(text)
Convert text to URL-friendly slug
OneLib.slug('Hello World!')
const url = `/posts/${OneLib.slug(title)}`;
Use case: URL generation, SEO-friendly links
words(text)
Split text into array of words
OneLib.words('hello world')
const wordCount = OneLib.words(article).length;
Use case: Word counting, text analysis
truncate(text, length)
Truncate text with ellipsis
OneLib.truncate('Long text', 5)
const preview = OneLib.truncate(description, 100);
Use case: Text previews, card descriptions
capitalize(text)
Capitalize first letter
OneLib.capitalize('hello')
const name = OneLib.capitalize(firstName);
Use case: Name formatting, sentence case
Array Helpers 8
unique(array)
Remove duplicate values from array
OneLib.unique([1, 2, 2, 3])
const uniqueTags = OneLib.unique(allTags);
Use case: Filtering duplicates, tag systems
chunk(array, size)
Split array into chunks of specified size
OneLib.chunk([1,2,3,4,5], 2)
const pages = OneLib.chunk(items, 10);
Use case: Pagination, batch processing
shuffle(array)
Randomly shuffle array elements
OneLib.shuffle([1, 2, 3, 4])
const randomOrder = OneLib.shuffle(playlist);
Use case: Randomizing lists, shuffle features
sortnum(array)
Sort array of numbers ascending
OneLib.sortnum([3, 1, 4, 1, 5])
const sorted = OneLib.sortnum(scores);
Use case: Leaderboards, numerical data sorting
Storage & Utilities 12
save(key, value)
Save data to localStorage with JSON serialization
OneLib.save('user', {name: 'John'})
OneLib.save('settings', {theme: 'dark'});
Use case: User preferences, app state persistence
load(key)
Load data from localStorage with JSON parsing
OneLib.load('user')
const settings = OneLib.load('userSettings');
Use case: Restoring app state, loading user data
copy(text)
Copy text to clipboard
OneLib.copy('Hello World')
await OneLib.copy(shareUrl);
Use case: Share buttons, code snippets copying
uuid()
Generate UUID v4 string
OneLib.uuid()
const sessionId = OneLib.uuid();
Use case: Session IDs, database keys
Total: 63 Functions
All functions are lightweight, performant, and ready to use in your projects!
← Back to Interactive Demo