consul/ui/packages/consul-ui/app/helpers/uniq-by.js

19 lines
382 B
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import { helper } from '@ember/component/helper';
import { isEmpty } from '@ember/utils';
import { A as emberArray } from '@ember/array';
export function uniqBy([byPath, array]) {
if (isEmpty(byPath)) {
return [];
}
return emberArray(array).uniqBy(byPath);
}
export default helper(uniqBy);