todolibformobileapp
v1.0.8
Published
A comprehensive ToDo library for managing categories and tasks with priority, recurring schedules, and automatic cleanup
Downloads
12
Maintainers
Readme
ToDoLib
A comprehensive JavaScript library for managing todo categories and tasks with advanced features like priority management, recurring schedules, and automatic cleanup.
Features
- Category Management: Create, update, delete, and prioritize categories
- Task Management: Add, update, delete, and prioritize tasks within categories
- Priority System: Automatic priority management for both categories and tasks
- Recurring Tasks: Support for repeatable tasks with flexible scheduling
- Automatic Cleanup: Clean up completed non-repeatable tasks and empty categories
- Data Sorting: Built-in sorting functionality for organized data
- Immutable Operations: All operations return new data without mutating the original
Installation
npm install todolibformobileappQuick Start
// ES6 Modules
import ToDoLib from "todolibformobileapp";
// or import specific functions
import { addCategory, addTask, sortToDos } from "todolibformobileapp";
// Create a new category
let data = [];
data = ToDoLib.addCategory(data, "cat_001", "Work", "#FF5733");
// Add a task to the category
data = ToDoLib.addTask(data, "cat_001", {
name: "Complete project",
notes: "Finish the final implementation",
canBeRepeated: false,
});
// Sort the data
data = ToDoLib.sortToDos(data);API Reference
Category Operations
addCategory(data, _id, name, color)
Adds a new category to the data.
data: Array of category objects_id: Unique identifier for the categoryname: Category namecolor: Category color (hex code)
deleteCategoryById(data, _id)
Deletes a category by its ID.
updateCategoryPriority(data, _id, newPriority)
Updates the priority of a category.
toggleCategoryDone(data, _id, status?)
Toggles the done status of a category and all its tasks.
Task Operations
addTask(data, _id, taskDetails)
Adds a task to a specific category.
const taskDetails = {
name: "Task name",
notes: "Task description",
canBeRepeated: true,
when: "Monday,Wednesday,Friday",
};addOrUpdateTask(data, _id, name, notes?, canBeRepeated?, when?)
Adds a new task or updates an existing one.
updateTask(data, _id, taskName, updateDetails)
Updates an existing task's properties.
deleteTask(data, _id, name)
Deletes a task from a category.
updateTaskPriority(data, _id, name, newPriority)
Updates the priority of a specific task.
toggleTaskDone(data, _id, name, status)
Toggles the done status of a task.
Utility Functions
sortToDos(data)
Sorts categories and tasks by priority.
getModifiedCategories(data)
Returns categories that have been modified.
chron(data)
Processes recurring tasks and cleans up completed tasks.
Returns an object with:
update: Modified categoriesdelete: Array of deleted category IDs
Data Structure
Category Object
{
_id: "cat_001",
name: "Work",
color: "#FF5733",
priority: 1,
done: 2,
notDone: 3,
total: 5,
isMarkedDone: false,
tasks: [...]
}Task Object
{
name: "Complete project",
notes: "Finish the implementation",
priority: 1,
done: false,
canBeRepeated: true,
when: "Monday,Wednesday,Friday"
}Recurring Tasks
The library supports flexible recurring task scheduling:
- Days of week: "Monday,Wednesday,Friday"
- Specific dates: "2025-08-22"
- Date numbers: "15" (15th of each month)
Use the chron() function to process recurring tasks automatically.
License
MIT
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Support
For issues and questions, please use the GitHub Issues page.
