Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alphabetically sort loaded resources #282

Merged
merged 11 commits into from
Jan 17, 2022
Merged

Alphabetically sort loaded resources #282

merged 11 commits into from
Jan 17, 2022

Conversation

rvanbaalen
Copy link
Contributor

Added the following function to alphabetically sort resources by object property.

function sortResourcesBy(prop, resources)
{
    return resources.sort((a, b) => {
        if ( a[prop] < b[prop] ){
            return -1;
        }
        if ( a[prop] > b[prop] ){
            return 1;
        }
        return 0;
    });
}

Example:

var arr = [{name: "Beatles"}, {name: "Robin"}, {name: "Foddy"}]
var sortedArr = sortResourcesBy("name", arr);

// sortedArr:
// [{name: "Beatles"}, {name: "Foddy"}, {name: "Robin"}]

This allows users to easily find the resources they're looking for especially when you have dozens of Hue lights set up around your home.

@Foddy Foddy merged commit 5972266 into Foddy:master Jan 17, 2022
@Foddy
Copy link
Owner

Foddy commented Jan 17, 2022

Thanks! This should be definitely a part of the next version

Foddy added a commit that referenced this pull request Jan 18, 2022
* New queue worker throttles the number of parallel requests to the bridge to avoid 503 API limit errors (can be configured in the Bridge configuration)
* Resources are now alphabetically sorted in the node´s configuration inetrface ([#282](#282)) (thx)
* "Hue Bridghtness" node was optimized to output more accurate "dark" and "dayLight" values
* Several optimizations in the documentation of some nodes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants