1.1.0 • Published 1 year ago

sibs v1.1.0

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

Sibs 👧🏻👦🏽

A small utility function used to loop through an array and easily access the previous and next sibling of the current item

Installation

pnpm add sibs

npm install sibs

yarn add sibs

Usage

import sibs from 'sibs';

const array = [{}, {}, {}];

for (const [previous, current, next] of sibs(array)) {
        
}

Index

import sibs from 'sibs';

const array = [{}, {}, {}];

for (const [previous, current, next, index] of sibs(array)) {
        
}

Typed

import sibs from 'sibs';

interface Item {
    id: string;
}

const array: Item[] = [...];

for (const item of sibs(array)) {
    const [
        previous,   // Item | undefined
        current,    // Item
        next,       // Item | undefined
        index,      // number
    ] = item;
}
1.1.0

1 year ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago