]> git.ardis.lu - csvio/commitdiff
Clarify type to allow raw `ArrayBuffer`, not just `TypedArray`
authorArdis Lu <ardisglu@gmail.com>
Sun, 8 Jun 2025 03:42:00 +0000 (20:42 -0700)
committerArdis Lu <ardisglu@gmail.com>
Sun, 8 Jun 2025 03:42:00 +0000 (20:42 -0700)
src/core.js
test/core.test.js

index 6c59a1a9b65e25c89233df0b35ff37f39b640d18..60132d624f154a083b74d8eecced2ec4f961197a 100644 (file)
@@ -8,7 +8,7 @@ import { ReadableStream, WritableStream, TransformStream } from 'node:stream/web
 /**
  * Parse and normalize a `PathLike` object into a string.
  * 
- * @param {PathLike|ArrayBufferView} path A `string`, `Buffer`, or `URL` representing a path to a local file.
+ * @param {PathLike|ArrayBufferView|ArrayBuffer} path A `string`, `Buffer`, or `URL` representing a path to a local file.
  * @returns {string} The normalized file path in string form.
  * @throws {TypeError} If `path` is not a `string`, `Buffer`, or `URL`, or it is a `URL` that is not using the `file` schema.
  */
index 366c0b1b43dfd9f72436514f694c0e92299d0182..c709a793fd07d5e39ded2b16a7c49ce64e587493 100644 (file)
@@ -31,8 +31,10 @@ suite('parsePathLike', { concurrency: true }, () => {
   const vectors = [
     { name: 'parses string relative path', input: './folder/example.txt', output: './folder/example.txt' },
     { name: 'parses string absolute path', input: '/absolute/path/to/file.txt', output: '/absolute/path/to/file.txt' },
-    { name: 'parses Buffer relative path', input: new TextEncoder().encode('./folder/example.txt'), output: './folder/example.txt' },
-    { name: 'parses Buffer absolute path', input: new TextEncoder().encode('/absolute/path/to/file.txt'), output: '/absolute/path/to/file.txt' },
+    { name: 'parses TypedArray relative path', input: new TextEncoder().encode('./folder/example.txt'), output: './folder/example.txt' },
+    { name: 'parses TypedArray absolute path', input: new TextEncoder().encode('/absolute/path/to/file.txt'), output: '/absolute/path/to/file.txt' },
+    { name: 'parses Buffer relative path', input: new TextEncoder().encode('./folder/example.txt').buffer, output: './folder/example.txt' },
+    { name: 'parses Buffer absolute path', input: new TextEncoder().encode('/absolute/path/to/file.txt').buffer, output: '/absolute/path/to/file.txt' },
     { name: 'parses URL relative path', input: pathToFileURL('./folder/example.txt'), output: resolve('./folder/example.txt') }, // Must use resolve because URLs automatically resolve to absolute path
     { name: 'parses URL absolute path', input: pathToFileURL('/absolute/path/to/file.txt'), output: resolve('/absolute/path/to/file.txt') },
     { name: 'parses URL with percent-encoding', input: pathToFileURL('./folder/example%20chars.txt'), output: resolve('./folder/example%20chars.txt') },
This page took 0.042602 seconds and 4 git commands to generate.