Melt the butter in a small heavy saucepan or skillet over low heat. Add the onions, cover, and cook slowly until tender and lightly colored, about 20 minutes.
Add the garlic, salt, and pepper to the onions, and cook, uncovered, for another 5 minutes. Remove from the heat.
Rinse the beans and drain them well. Combine the beans, onion mixture, and basil