1.0.3 โ€ข Published 5 months ago

@feelinglovelynow/loop-backwards v1.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
5 months ago

๐Ÿ•‰ @feelinglovelynow/loop-backwards

๐Ÿ’Ž Install

pnpm add @feelinglovelynow/loop-backwards

๐Ÿค“ Unit Tests

Statements

๐Ÿ™ 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

  1. @feelinglovelynow/datetime-local: NPM โ‹… Github
  2. @feelinglovelynow/dgraph: NPM โ‹… Github
  3. @feelinglovelynow/env-write: NPM โ‹… Github
  4. @feelinglovelynow/get-form-entries: NPM โ‹… Github
  5. @feelinglovelynow/get-relative-time: NPM โ‹… Github
  6. @feelinglovelynow/global-style: NPM โ‹… Github
  7. @feelinglovelynow/jwt: NPM โ‹… Github
  8. @feelinglovelynow/loop-backwards: NPM โ‹… Github
  9. @feelinglovelynow/slug: NPM โ‹… Github
  10. @feelinglovelynow/svelte-catch: NPM โ‹… Github
  11. @feelinglovelynow/svelte-kv: NPM โ‹… Github
  12. @feelinglovelynow/svelte-loading-anchor: NPM โ‹… Github
  13. @feelinglovelynow/svelte-modal: NPM โ‹… Github
  14. @feelinglovelynow/svelte-turnstile: NPM โ‹… Github
  15. @feelinglovelynow/toast: NPM โ‹… Github
1.0.3

5 months ago

1.0.2

5 months ago

1.0.1

6 months ago

1.0.0

7 months ago