noloopfor

Pacote para fazer loops sem o uso de for

Usage no npm install needed!

<script type="module">
  import noloopfor from 'https://cdn.skypack.dev/noloopfor';
</script>

README

No loop for

No loop for

GitHub top language Codacy Badge GitHub license


Languages

About

JavaScript library for making functional loops

Get Started

  • On the Node JS

    To install on the node, just execute the command below on the terminal
npm install noloopfor

To import the the desired function use destructuring assignment, for example, the bellow code is importing the function loop.

const { loop } = require('noloopfor')

If using React JS, or some other JS library that allows you to use the ESM syntax, you can use it with destructuring assignment, as in the example below

import { loop } from 'noloopfor'
  • On the browser

    If you're out of Node JS you don't need to install anything, just import the desired function using ESM syntax, for example, the below code is importing the function loop, and then is implementing the same.
<script type="module">
import { loop } from 'https://cdn.jsdelivr.net/gh/david-fernando/noForLoop/dist/noforloop.js'

const number = 10

loop(number, 20, (iterations)=>{
 console.log(iterations)
})

</script>
  • With TypeScript

    To use it with TypeScript, just install the TypeScript declarations with one of the commands below
npm install @types/noloopfor

// or

yarn add @types/noloopfor

Reference

loop

  • Syntax

loop(number, numberOfIterations, callback)
  • Example

const number = 10
loop(number, 20, (iterations)=>{
 console.log(iterations)
})

loopStep

  • Syntax

loopStep(number, numberOfIterations, numberStep, callback)
  • Example

const number = 10
loopStep(number, 100, 10, (iterations)=>{
 console.log(iterations)
})

decrementLoop

  • Syntax

decrementLoop(number, numberTarget, callback)
  • Example

const number = 10
decrementLoop(number, 1, (iterations)=>{
 console.log(iterations)
})

decrementStep

  • Syntax

decrementStep(number, numberTarget, numberStep, callback)
  • Example

const number = 20
decrementStep(number, 10, 1, (iterations)=>{
 console.log(iterations)
})

Licence:

MIT