JavaScript library for making functional loops
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'
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>
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
loop(number, numberOfIterations, callback)
const number = 10
loop(number, 20, (iterations)=>{
console.log(iterations)
})
loopStep(number, numberOfIterations, numberStep, callback)
const number = 10
loopStep(number, 100, 10, (iterations)=>{
console.log(iterations)
})
decrementLoop(number, numberTarget, callback)
const number = 10
decrementLoop(number, 1, (iterations)=>{
console.log(iterations)
})
decrementStep(number, numberTarget, numberStep, callback)
const number = 20
decrementStep(number, 10, 1, (iterations)=>{
console.log(iterations)
})
MIT