noloopfor
v2.0.8
Published
Pacote para fazer loops sem o uso de for
Downloads
60
Maintainers
Keywords
Readme
Languages
About
JavaScript library for making functional loops
Get Started
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
Reference
loop
loop(number, numberOfIterations, callback)
const number = 10
loop(number, 20, (iterations)=>{
console.log(iterations)
})
loopStep
loopStep(number, numberOfIterations, numberStep, callback)
const number = 10
loopStep(number, 100, 10, (iterations)=>{
console.log(iterations)
})
decrementLoop
decrementLoop(number, numberTarget, callback)
const number = 10
decrementLoop(number, 1, (iterations)=>{
console.log(iterations)
})
decrementStep
decrementStep(number, numberTarget, numberStep, callback)
const number = 20
decrementStep(number, 10, 1, (iterations)=>{
console.log(iterations)
})
Licence:
MIT