Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
14 lines
295 B
JavaScript
14 lines
295 B
JavaScript
const arrayToReversed = (isOptionalObject, array) => {
|
|
if (isOptionalObject && (array === undefined || array === null)) {
|
|
return;
|
|
}
|
|
|
|
if (array.toReversed || !Array.isArray(array)) {
|
|
return array.toReversed();
|
|
}
|
|
|
|
return [...array].reverse();
|
|
};
|
|
|
|
export default arrayToReversed;
|