@feelinglovelynow/loop-backwards
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

🕉 @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: NPMGithub
  2. @feelinglovelynow/dgraph: NPMGithub
  3. @feelinglovelynow/env-write: NPMGithub
  4. @feelinglovelynow/get-form-entries: NPMGithub
  5. @feelinglovelynow/get-relative-time: NPMGithub
  6. @feelinglovelynow/global-style: NPMGithub
  7. @feelinglovelynow/jwt: NPMGithub
  8. @feelinglovelynow/loop-backwards: NPMGithub
  9. @feelinglovelynow/slug: NPMGithub
  10. @feelinglovelynow/svelte-catch: NPMGithub
  11. @feelinglovelynow/svelte-kv: NPMGithub
  12. @feelinglovelynow/svelte-loading-anchor: NPMGithub
  13. @feelinglovelynow/svelte-modal: NPMGithub
  14. @feelinglovelynow/svelte-turnstile: NPMGithub
  15. @feelinglovelynow/toast: NPMGithub

Package Sidebar

Install

npm i @feelinglovelynow/loop-backwards

Weekly Downloads

0

Version

1.0.3

License

MIT

Unpacked Size

13.6 kB

Total Files

20

Last publish

Collaborators

  • feelinglovelynow