]> git.ardis.lu - csvio/commitdiff
Simplify with early returns
authorArdis Lu <ardisglu@gmail.com>
Mon, 20 Jan 2025 07:40:42 +0000 (23:40 -0800)
committerArdis Lu <ardisglu@gmail.com>
Mon, 20 Jan 2025 07:40:42 +0000 (23:40 -0800)
src/core.js

index b3a4c4051339feae1c19cba5ec3faaa309f94a39..94c47d800999254e946d57e08aa0c02917c01858 100644 (file)
@@ -13,20 +13,18 @@ import { fileURLToPath } from 'node:url';
  * @throws {TypeError} If `path` is not a `string`, `Buffer`, or `URL`, or it is a `URL` that is not using the `file` schema.
  */
 export function parsePathLike(path) {
-  let parsedPath;
   if (typeof path === 'string') {
-    parsedPath = normalize(path);
+    return normalize(path);
   }
   else if (ArrayBuffer.isView(path) || path instanceof ArrayBuffer) {
-    parsedPath = normalize(new TextDecoder().decode(path));
+    return normalize(new TextDecoder().decode(path));
   }
   else if (path instanceof URL) {
-    parsedPath = fileURLToPath(path);
+    return fileURLToPath(path);
   }
   else {
     throw new TypeError(`Expected a string, Buffer, or URL, but received ${typeof path}.`);
   }
-  return parsedPath;
 }
 
 /**
This page took 0.044945 seconds and 4 git commands to generate.