From 5479bb4e428222a46d1c919d974d46588ad58871 Mon Sep 17 00:00:00 2001 From: Robert Wittman Date: Sat, 2 Nov 2024 16:00:58 -0400 Subject: [PATCH] If included not provided, simply return --- index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 2699228..16eab45 100644 --- a/index.js +++ b/index.js @@ -28,12 +28,15 @@ const transformKeys = (obj, transformFunc) => { /** * Finds an included resource by type and id. - * @param {Array} included - The array of included resources. + * @param {Array|undefined} included - The array of included resources. * @param {string} type - The type of the resource to find. * @param {string} id - The id of the resource to find. * @returns {Object|undefined} The found resource or undefined. */ const findIncluded = (included, type, id) => { + if (!(Array.isArray(included))) { + return + } return included.find(item => item.type === type && item.id === id); };