@@ -2,7 +2,7 @@ import { describe, expect, it } from 'vitest'
22
33import type { ParseResult } from '../src/types'
44import { parseURL } from '../src/url'
5- import { toUrl } from '../src/utils'
5+ import { toURL } from '../src/utils'
66import { PARSE_TESTS } from './cases'
77
88function * parseMock ( text : string ) : Generator < ParseResult , void , unknown > {
@@ -25,7 +25,7 @@ function* parseMock(text: string): Generator<ParseResult, void, unknown> {
2525describe ( 'parseURL, while mocking parse, ' , ( ) => {
2626 it . each ( [ 1 , 2 , 3 , 10 , 17 , 18 , 19 , 20 , 21 , 1_000 , undefined ] ) ( 'accepts chunk size of %s' , async ( chunkSize ) => {
2727 const text = 'hello, csvremote!!!' // length: 19
28- const { url, fileSize, revoke } = toUrl ( text )
28+ const { url, fileSize, revoke } = toURL ( text )
2929 let result = ''
3030 let bytes = 0
3131 // passing 'to: fileSize - 1' for Node.js bug: https://github.com/nodejs/node/issues/60382
@@ -41,7 +41,7 @@ describe('parseURL, while mocking parse, ', () => {
4141
4242 it . each ( [ 0 , - 1 , 1.5 , NaN , Infinity ] ) ( 'throws if chunkSize is invalid: %s' , async ( chunkSize ) => {
4343 const text = 'hello, csvremote!!!'
44- const { url, fileSize, revoke } = toUrl ( text )
44+ const { url, fileSize, revoke } = toURL ( text )
4545 const iterator = parseURL ( url , { chunkSize, lastByte : fileSize - 1 } )
4646 await expect ( iterator . next ( ) ) . rejects . toThrow ( )
4747 revoke ( )
@@ -57,7 +57,7 @@ describe('parseURL, while mocking parse, ', () => {
5757 [ 5 , 5 , ',' ] ,
5858 ] ) ( 'accepts valid firstByte: %s and lastByte: %s' , async ( firstByte , lastByte , expected ) => {
5959 const text = 'hello, csvremote!!!'
60- const { url, revoke } = toUrl ( text )
60+ const { url, revoke } = toURL ( text )
6161 let result = ''
6262 // implicit assertation in the loop: no exceptions thrown
6363 for await ( const { row } of parseURL ( url , { firstByte, lastByte, parse : parseMock } ) ) {
@@ -82,15 +82,15 @@ describe('parseURL, while mocking parse, ', () => {
8282 // [5, 0], // now allowed
8383 ] ) ( 'throws for invalid from: %s or lastByte: %s' , async ( firstByte , lastByte ) => {
8484 const text = 'hello, csvremote!!!'
85- const { url, revoke } = toUrl ( text )
85+ const { url, revoke } = toURL ( text )
8686 const iterator = parseURL ( url , { chunkSize : 10 , firstByte, lastByte } )
8787 await expect ( iterator . next ( ) ) . rejects . toThrow ( )
8888 revoke ( )
8989 } )
9090
9191 it ( 'uses the requestInit option, allowing to pass an abort signal' , async ( ) => {
9292 const text = 'hello, csvremote!!!'
93- const { url, revoke } = toUrl ( text )
93+ const { url, revoke } = toURL ( text )
9494 const controller = new AbortController ( )
9595 const iterator = parseURL ( url , { requestInit : { signal : controller . signal } } )
9696 controller . abort ( )
@@ -100,7 +100,7 @@ describe('parseURL, while mocking parse, ', () => {
100100
101101 it ( 'throws if parse yields more bytes than provided' , async ( ) => {
102102 const text = 'hello, csvremote!!!'
103- const { url, revoke } = toUrl ( text )
103+ const { url, revoke } = toURL ( text )
104104 function * parseMock ( text : string ) {
105105 // yield more bytes than provided
106106 yield {
@@ -129,7 +129,7 @@ describe('Papaparse high-level tests', () => {
129129 PARSE_TESTS . forEach ( ( test ) => {
130130 it ( test . description , async ( ) => {
131131 const config : Parameters < typeof parseURL > [ 1 ] = test . config || { }
132- const { url, fileSize, revoke } = toUrl ( test . text )
132+ const { url, fileSize, revoke } = toURL ( test . text )
133133 const result = [ ]
134134 for await ( const r of parseURL ( url , { ...config , lastByte : fileSize - 1 } ) ) {
135135 result . push ( r )
@@ -170,7 +170,7 @@ describe('parseURL', () => {
170170 } )
171171 it . for ( [ 1 , 2 , 3 , 5 , 9 , 14 ] ) ( 'with known delimiter and newline, accepts chunk size of %s bytes.' , async ( chunkSize ) => {
172172 const text = 'a,b,c\n1,2,3\n4,5,6\n7,8,9\na,b,c\n1,2,3\n4,5,6\n7,8,9\na,b,c\n1,2,3\n4,5,6\n7,8,9\n'
173- const { url, fileSize, revoke } = toUrl ( text )
173+ const { url, fileSize, revoke } = toURL ( text )
174174 const result = [ ]
175175 let bytes = 0
176176 for await ( const { row, meta : { byteOffset, byteCount } } of parseURL ( url , { chunkSize, lastByte : fileSize - 1 } ) ) {
@@ -184,7 +184,7 @@ describe('parseURL', () => {
184184 } )
185185 it . each ( [ undefined , true , false ] ) ( 'should respect the stripBOM option (%s), and count the bytes correctly' , async ( stripBOM ) => {
186186 const text = '\ufeffhello, csvremote!!!'
187- const { url, fileSize, revoke } = toUrl ( text )
187+ const { url, fileSize, revoke } = toURL ( text )
188188 const result = [ ]
189189 for await ( const r of parseURL ( url , { stripBOM, lastByte : fileSize - 1 } ) ) {
190190 result . push ( r )
@@ -213,7 +213,7 @@ describe('parseURL', () => {
213213 ] ) ( 'should support cutting 👉🏿 emoji: firstByte=$firstByte, lastByte=$lastByte' , async ( { firstByte, lastByte, expected : { row, charCount, invalidByteCount } } ) => {
214214 // 👉🏿 uses 8 bytes in UTF-8.
215215 const text = '👉🏿,1'
216- const { url, fileSize, revoke } = toUrl ( text )
216+ const { url, fileSize, revoke } = toURL ( text )
217217 lastByte ??= fileSize - 1
218218 const result = [ ]
219219 for await ( const r of parseURL ( url , { firstByte, lastByte, delimiter : ',' , newline : '\n' } ) ) {
@@ -245,7 +245,7 @@ describe('parseURL', () => {
245245
246246 it ( 'should search invalid bytes over multiple chunks if needed' , async ( ) => {
247247 const text = '👉,1'
248- const { url, fileSize, revoke } = toUrl ( text )
248+ const { url, fileSize, revoke } = toURL ( text )
249249 const result = [ ]
250250 // There are 3 invalid bytes at start, when starting at byte 1. Using chunkSize=1 to force multiple iterations.
251251 for await ( const r of parseURL ( url , { chunkSize : 1 , firstByte : 1 , lastByte : fileSize - 1 , delimiter : ',' , newline : '\n' } ) ) {
@@ -273,7 +273,7 @@ describe('parseURL', () => {
273273
274274 it ( 'should report invalid data in multiple rows' , async ( ) => {
275275 const text = '👉a,b\n1,2'
276- const { url, fileSize, revoke } = toUrl ( text )
276+ const { url, fileSize, revoke } = toURL ( text )
277277 const result = [ ]
278278 for await ( const r of parseURL ( url , { firstByte : 3 , lastByte : fileSize - 1 , delimiter : ',' , newline : '\n' } ) ) {
279279 result . push ( r )
0 commit comments