devionjs
v1.0.8
Published
Devion is a comprehensive utility library for web developers.
Downloads
9
Maintainers
Readme
DevionJS
DevionJS is a comprehensive utility library for Node.js developers. It provides a wide range of functions for string manipulation, array operations, object manipulation, date operations, AJAX requests, validation, performance optimization, utility functions, logging, multimedia conversion, and text processing.
Installation
To install DevionJS, use npm:
npm install devionjs
Usage
To use DevionJS in your project, import the required functions:
import { capitalizeString, shuffleArray, deepCloneObject } from 'devionjs';
const capitalized = capitalizeString('hello world');
const shuffledArray = shuffleArray([1, 2, 3, 4, 5]);
const clonedObject = deepCloneObject({ key: 'value' });
API
String Manipulation
- capitalizeString(str): Capitalizes the first letter of a string.
- truncateString(str, length, ending = '...'): Truncates a string to a specified length and adds an optional ending.
- slugifyString(str): Converts a string to a URL-friendly slug.
Array Operations
- shuffleArray(arr): Shuffles the elements of an array.
- uniqueArray(arr): Returns a new array with unique elements.
- flattenArray(arr): Flattens a nested array.
Object Manipulation
- deepCloneObject(obj): Creates a deep clone of an object.
- mergeObjects(target, ...sources): Merges multiple objects into a target object.
Date Operations
- formatDate(date, format = 'YYYY-MM-DD'): Formats a date according to the specified format.
- daysBetweenDates(date1, date2): Calculates the number of days between two dates.
AJAX
- fetchJson(url, options = {}): Fetches JSON data from a URL using native fetch.
Validation
- isValidEmail(email): Validates an email address.
- isValidUrl(url): Validates a URL.
Performance
- debounceFunction(func, wait): Creates a debounced function that delays invoking the provided function.
- throttleFunction(func, limit): Creates a throttled function that only invokes the provided function at most once per specified time limit.
Utility
- generateUuid(): Generates a UUID.
- memoizeFunction(fn): Creates a memoized version of a function.
Logging
- logMessage(message): Logs a message to the console.
- warnMessage(message): Logs a warning message to the console.
- debugMessage(message): Logs a debug message to the console.
Multimedia
- convertImage(imageBuffer, format): Converts an image buffer to the specified format.
- convertAudio(audioBuffer, format): Converts an audio buffer to the specified format.
- convertVideo(videoBuffer, format): Converts a video buffer to the specified format.
Text
- csvToJson(csvBuffer): Converts a CSV buffer to JSON.
- jsonToCsv(jsonData): Converts JSON data to CSV.
Contributing
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
License
This project is licensed under the MIT License.
Contact
For any questions or inquiries, please contact the project maintainer.