1.0.3 โข Published 5 months ago
@feelinglovelynow/loop-backwards v1.0.3
๐ @feelinglovelynow/loop-backwards
๐ Install
pnpm add @feelinglovelynow/loop-backwards
๐ค Unit Tests
๐ Description
Loop an array backwards! Give loopBackwards() an array and a callback. Calback provides the current item, a splice function, and the current index. Splice function removes item from the array. If the splice function is called & the current item is a DOM element the item is removed from the array & the item is removed from the DOM
๐ Example: Array of numbers
import loopBackwards from '@feelinglovelynow/loop-backwards'
loopBackwards(numbers, (number, splice, index) => {
if (number === 9 || index === 9) splice()
})
๐ Example: Array of objects
loopBackwards(items, ({ foo }, splice) => {
if (foo === 'bar') splice()
})
๐งก Example: Array of DOM elements
const domElements = document.querySelectorAll('div')
const arrayElements = Array.from(domElements)
loopBackwards(arrayElements, (element, splice) => {
if (element.getAttribute('foo') === 'bar') splice()
})
๐ All Our Packages
- @feelinglovelynow/datetime-local: NPM โ Github
- @feelinglovelynow/dgraph: NPM โ Github
- @feelinglovelynow/env-write: NPM โ Github
- @feelinglovelynow/get-form-entries: NPM โ Github
- @feelinglovelynow/get-relative-time: NPM โ Github
- @feelinglovelynow/global-style: NPM โ Github
- @feelinglovelynow/jwt: NPM โ Github
- @feelinglovelynow/loop-backwards: NPM โ Github
- @feelinglovelynow/slug: NPM โ Github
- @feelinglovelynow/svelte-catch: NPM โ Github
- @feelinglovelynow/svelte-kv: NPM โ Github
- @feelinglovelynow/svelte-loading-anchor: NPM โ Github
- @feelinglovelynow/svelte-modal: NPM โ Github
- @feelinglovelynow/svelte-turnstile: NPM โ Github
- @feelinglovelynow/toast: NPM โ Github