1.0.8 • Published 2 years ago

eachless v1.0.8

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

Eachless

  • tiny package helps you avoid the nested loops (for-each hell)
# install
npm i -s eachless
// usage
var {Eachless} = require("eachless")
data = {
    "products":[{
        ...
        "orders":[{
            ...
            "tags":[{
                "label": "laptop",
                "id": "tag-1"
            }]
        }]
    },{
        ...
        "orders":[{
            ...
            "tags":[{
                "label": "smartphone",
                "id": "tag-2"
            },{
                "label": "keyboard",
                "id": "tag-3"
            }]
        }]
    }]
}

to iterate through all the tag labels, use

  • example code:
const labelsIterator = Eachless(data,['products','orders','tags','label'])
for(const label of labelsIterator){
    console.log(label)
}
  • result:
- laptop
- smartphone
- keyboard
1.0.8

2 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago