2023-03-14 13:18:55 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
|
|
*/
|
|
|
|
|
2022-02-10 15:28:26 +00:00
|
|
|
import { helper } from '@ember/component/helper';
|
|
|
|
import { get } from '@ember/object';
|
|
|
|
|
|
|
|
export default helper(([arrayLike = [], prop], hash) => {
|
|
|
|
if (!Array.isArray(arrayLike)) {
|
|
|
|
arrayLike = arrayLike.toArray();
|
|
|
|
}
|
|
|
|
return arrayLike.reduce((prev, item, i) => {
|
|
|
|
prev[get(item, prop)] = item;
|
|
|
|
return prev;
|
|
|
|
}, {});
|
|
|
|
});
|