1.0.2 • Published 8 months ago

@takuyaw-w/uselist v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

@takuyaw-w/useList

@takuyaw-w/useList is a custom hook for Vue 3. This custom hook allows you to easily manage and manipulate lists. It encapsulates the state of the list and provides convenient methods.

Installation

You can install this custom hook using the following command:

npm install @takuyaw-w/uselist

Usage

Example of importing and using the custom hook:

import { useList } from '@takuyaw-w/uselist';

// Initialize the custom hook to manage the list
const [list, actions] = useList([1,2,3]);

// List operations
actions.push(4);
actions.removeAt(1);

// Display the state of the list
console.log(list.value); // [1,3,4]

Parametor

NameTypeDescription
defaultListT[]The initial list of elements. Default is an empty array.

Return Value

NameParametersDescription
0The current list of elements.
1.setnewList: T[]Replaces the list with a new list.
1.pushelement: TAdds an element to the end of the list.
1.unshiftelement: TAdds an element to the beginning of the list.
1.removeAtindex: numberRemoves the element at the specified index.
1.insertAtindex: number, element: TInserts an element at the specified index.
1.updateAtindex: number, element: TReplaces the element at the specified index with a new element.
1.clearEmpties the list.
1.filtercondition: (element: T) => booleanKeeps only the elements that match the condition in the list.
1.sortcompareFn: (a: T, b: T) => numberSorts the list based on a custom comparison function.
1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago