-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
20 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
import { helper } from '@ember/component/helper'; | ||
import { isEmpty } from '@ember/utils'; | ||
import { A as emberArray } from '@ember/array'; | ||
import asArray from '../utils/as-array'; | ||
import { helper } from "@ember/component/helper"; | ||
import { isEmpty } from "@ember/utils"; | ||
import { get } from "@ember/object"; | ||
import asArray from "../utils/as-array"; | ||
|
||
export function findBy([byPath, value, array]) { | ||
if (isEmpty(byPath)) { | ||
return []; | ||
} | ||
|
||
return emberArray(asArray(array)).findBy(byPath, value); | ||
return asArray(array).find((item) => get(item, byPath) === value); | ||
} | ||
|
||
export default helper(findBy); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,15 @@ | ||
import { A as emberArray } from '@ember/array'; | ||
import isEqual from '../utils/is-equal'; | ||
import isEqual from "../utils/is-equal"; | ||
|
||
export default function getIndex(array, currentValue, useDeepEqual) { | ||
let needle = currentValue; | ||
|
||
if (useDeepEqual) { | ||
needle = emberArray(array).find((object) => { | ||
needle = array.find((object) => { | ||
return isEqual(object, currentValue, useDeepEqual); | ||
}); | ||
} | ||
|
||
let index = emberArray(array).indexOf(needle); | ||
let index = (array || []).indexOf(needle); | ||
|
||
return index >= 0 ? index : null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters