boor

0.0.4 • Public • Published

boor

Warning! This is not a polite library.

(SYNC) Loop through Array items

/**
 * Loop through values only
 */
let values = ['Apple', 'Banana', 'Cagaita']
 
foreach(values, (value) => {
    console.log('=>', value)    
})
 
// Output:
//=> Apple
//=> Banana
//=> Cagaita
/**
 * Loop through key-value pairs
 */
let values = ['Apple', 'Banana', 'Cagaita']
 
foreach(values, (key, value) => {
    console.log(key, '=>', value)    
})
 
// Output:
//0 => "Apple"
//1 => "Banana"
//2 => "Cagaita"

(ASYNC) Loop through Array items

/**
 * Loop through values only
 */
let values = ['Apple', 'Banana', 'Cagaita']
 
foreach(values, (index, next) => {
    console.log('=>', value)
    next()
}).then(() => {
    console.log('=> --end--')
})
 
// Output:
//=> Apple
//=> Banana
//=> Cagaita
//=> --end--
/**
 * Loop through key-value pairs
 */
let values = ['Apple', 'Banana', 'Cagaita']
 
foreach(values, (key, value) => {
    console.log(key, '=>', value)    
})
 
// Output:
//0 => "Apple"
//1 => "Banana"
//2 => "Cagaita"

Readme

Keywords

none

Package Sidebar

Install

npm i boor

Weekly Downloads

2

Version

0.0.4

License

MIT

Unpacked Size

16.9 kB

Total Files

14

Last publish

Collaborators

  • francescobianco