qwik-saga
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

qwik-saga

saga process flow handling module for qwik based on redux-saga, but I would like a found a much cleaner way.

! under development, just for lock a module name

placeholder code, just for check module development works

this is some real basics array lib, will be removed!!

export type Mapper = <T>(list: T[]) => T[];
export type Picker = <T>(list: T[]) => T;
export type PickerBy = <T>(list: T[], seek: T) => T;
export type Creators = <T>(amount: number, creators: () => T) => T[];

export const rotateList:Mapper = ([first, ...rest]) => [...rest, first];
export const shuffleList:Mapper = list => [...list].sort(() => Math.random() > 0.5 ? 1 : -1);
export const randomPick:Picker = (list) => list[Math.random() * list.length | 0];
export const createList:Creators = (amount, creators) =>
  Array(amount)
    .fill(0)
    .map(() => creators())
  ;
export const nextOf:PickerBy = (list, current) => list[(list.indexOf(current) + 1) % list.length];

Installation

npm add qwik-saga
# or yarn
yarn add qwik-saga
# or pnpm
pnpm add qwik-saga

Package Sidebar

Install

npm i qwik-saga

Weekly Downloads

1

Version

0.0.1

License

MIT

Unpacked Size

7.91 kB

Total Files

12

Last publish

Collaborators

  • pengeszikra