Bump csv-parse from 6.2.1 to 7.0.0 (#472)
c648472 · dependabot[bot] · 2026-06-29 22:17
Message
{commit_body(@commit)}
Files changed
modified
dist/index.js
+303
−84
@@ -34569,22 +34569,67 @@ class ResizeableBuffer {
| 34569 | 34569 | ;// CONCATENATED MODULE: ./node_modules/csv-parse/lib/api/init_state.js |
| 34570 | 34570 | |
| 34571 | 34571 | |
| 34572 | −// white space characters | |
| 34573 | −// https://en.wikipedia.org/wiki/Whitespace_character | |
| 34574 | −// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Character_Classes#Types | |
| 34575 | −// \f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff | |
| 34576 | −const np = 12; | |
| 34577 | −const cr = 13; // `\r`, carriage return, 0x0D in hexadécimal, 13 in decimal | |
| 34578 | −const nl = 10; // `\n`, newline, 0x0A in hexadecimal, 10 in decimal | |
| 34579 | −const space = 32; | |
| 34580 | −const tab = 9; | |
| 34581 | − | |
| 34582 | 34572 | const init_state = function (options) { |
| 34573 | + // ECMAScript WhiteSpace + LineTerminator codepoints, encoded under | |
| 34574 | + // `options.encoding`. Aligns trimming with `String.prototype.trim()`. | |
| 34575 | + // https://tc39.es/ecma262/#sec-white-space | |
| 34576 | + // https://tc39.es/ecma262/#sec-line-terminators | |
| 34577 | + // | |
| 34578 | + // Codepoints unrepresentable in the target encoding are dropped: Node's | |
| 34579 | + // Buffer substitutes them with `?` (0x3F), and including those would cause | |
| 34580 | + // literal `?` bytes in the input to be trimmed under `latin1`/`ascii`. | |
| 34581 | + const timchars = [ | |
| 34582 | + // Basic Latin | |
| 34583 | + 0x0020, // [Space](https://www.fileformat.info/info/unicode/char/0020/index.htm) | |
| 34584 | + 0x0009, // [CHARACTER TABULATION (HT)](https://www.fileformat.info/info/unicode/char/0009/index.htm) | |
| 34585 | + 0x000a, // [LINE FEED (LF)](https://www.fileformat.info/info/unicode/char/000a/index.htm) | |
| 34586 | + 0x000d, // [CARRIAGE RETURN (CR)](https://www.fileformat.info/info/unicode/char/000d/index.htm) | |
| 34587 | + 0x000c, // [FORM FEED (FF)](https://www.fileformat.info/info/unicode/char/000c/index.htm) | |
| 34588 | + 0x000b, // [LINE TABULATION (VT)](https://www.fileformat.info/info/unicode/char/000b/index.htm) | |
| 34589 | + // Latin-1 Supplement | |
| 34590 | + 0x00a0, // [NO-BREAK SPACE (NBSP)](https://www.fileformat.info/info/unicode/char/00a0/index.htm) | |
| 34591 | + // Ogham | |
| 34592 | + 0x1680, // [OGHAM SPACE MARK](https://www.fileformat.info/info/unicode/char/1680/index.htm) | |
| 34593 | + // General Punctuation | |
| 34594 | + 0x2000, // [EN QUAD](https://www.fileformat.info/info/unicode/char/2000/index.htm) | |
| 34595 | + 0x2001, // [EM QUAD](https://www.fileformat.info/info/unicode/char/2001/index.htm) | |
| 34596 | + 0x2002, // [EN SPACE](https://www.fileformat.info/info/unicode/char/2002/index.htm) | |
| 34597 | + 0x2003, // [EM SPACE](https://www.fileformat.info/info/unicode/char/2003/index.htm) | |
| 34598 | + 0x2004, // [THREE-PER-EM SPACE](https://www.fileformat.info/info/unicode/char/2004/index.htm) | |
| 34599 | + 0x2005, // [FOUR-PER-EM SPACE](https://www.fileformat.info/info/unicode/char/2005/index.htm) | |
| 34600 | + 0x2006, // [SIX-PER-EM SPACE](https://www.fileformat.info/info/unicode/char/2006/index.htm) | |
| 34601 | + 0x2007, // [FIGURE SPACE](https://www.fileformat.info/info/unicode/char/2007/index.htm) | |
| 34602 | + 0x2008, // [PUNCTUATION SPACE](https://www.fileformat.info/info/unicode/char/2008/index.htm) | |
| 34603 | + 0x2009, // [THIN SPACE](https://www.fileformat.info/info/unicode/char/2009/index.htm) | |
| 34604 | + 0x200a, // [HAIR SPACE](https://www.fileformat.info/info/unicode/char/200a/index.htm) | |
| 34605 | + 0x2028, // [LINE SEPARATOR](https://www.fileformat.info/info/unicode/char/2028/index.htm) | |
| 34606 | + 0x2029, // [PARAGRAPH SEPARATOR](https://www.fileformat.info/info/unicode/char/2029/index.htm) | |
| 34607 | + 0x202f, // [NARROW NO-BREAK SPACE (NNBSP)](https://www.fileformat.info/info/unicode/char/202f/index.htm) | |
| 34608 | + 0x205f, // [MEDIUM MATHEMATICAL SPACE (MMSP)](https://www.fileformat.info/info/unicode/char/205f/index.htm) | |
| 34609 | + 0x3000, // [IDEOGRAPHIC SPACE](https://www.fileformat.info/info/unicode/char/3000/index.htm) | |
| 34610 | + 0xfeff, // [ZERO WIDTH NO-BREAK SPACE (BOM)](https://www.fileformat.info/info/unicode/char/feff/index.htm) | |
| 34611 | + ].reduce((acc, codepoint) => { | |
| 34612 | + const encoded = Buffer.from( | |
| 34613 | + String.fromCharCode(codepoint), | |
| 34614 | + options.encoding, | |
| 34615 | + ); | |
| 34616 | + if (codepoint !== 0x3f && encoded.length === 1 && encoded[0] === 0x3f) { | |
| 34617 | + return acc; | |
| 34618 | + } | |
| 34619 | + acc.push(encoded); | |
| 34620 | + return acc; | |
| 34621 | + }, []); | |
| 34622 | + // First-byte lookup table for `__isCharTrimable`. Non-whitespace bytes | |
| 34623 | + // (the common case) bail out in O(1) without scanning every timchar. | |
| 34624 | + const timcharFirstBytes = new Uint8Array(256); | |
| 34625 | + for (const t of timchars) timcharFirstBytes[t[0]] = 1; | |
| 34583 | 34626 | return { |
| 34584 | 34627 | bomSkipped: false, |
| 34585 | 34628 | bufBytesStart: 0, |
| 34586 | 34629 | castField: options.cast_function, |
| 34587 | 34630 | commenting: false, |
| 34631 | + delimiterBufPrevious: undefined, | |
| 34632 | + delimiterDiscovered: false, | |
| 34588 | 34633 | // Current error encountered by a record |
| 34589 | 34634 | error: undefined, |
| 34590 | 34635 | enabled: options.from_line === 1, |
@@ -34603,9 +34648,15 @@ const init_state = function (options) {
| 34603 | 34648 | // Skip if the remaining buffer smaller than comment |
| 34604 | 34649 | options.comment !== null ? options.comment.length : 0, |
| 34605 | 34650 | // Skip if the remaining buffer can be delimiter |
| 34606 | − ...options.delimiter.map((delimiter) => delimiter.length), | |
| 34651 | + ...(options.delimiter | |
| 34652 | + ? options.delimiter.map((delimiter) => delimiter.length) | |
| 34653 | + : []), | |
| 34654 | + // Auto discovery of delimiter is limited to 1 character | |
| 34655 | + options.delimiter_auto ? 1 : 0, | |
| 34607 | 34656 | // Skip if the remaining buffer can be escape sequence |
| 34608 | 34657 | options.quote !== null ? options.quote.length : 0, |
| 34658 | + // Skip if the remaining buffer can be a multi-byte trim character | |
| 34659 | + ...timchars.map((t) => t.length), | |
| 34609 | 34660 | ), |
| 34610 | 34661 | previousBuf: undefined, |
| 34611 | 34662 | quoting: false, |
@@ -34624,13 +34675,8 @@ const init_state = function (options) {
| 34624 | 34675 | ], |
| 34625 | 34676 | wasQuoting: false, |
| 34626 | 34677 | wasRowDelimiter: false, |
| 34627 | − timchars: [ | |
| 34628 | − Buffer.from(Buffer.from([cr], "utf8").toString(), options.encoding), | |
| 34629 | − Buffer.from(Buffer.from([nl], "utf8").toString(), options.encoding), | |
| 34630 | − Buffer.from(Buffer.from([np], "utf8").toString(), options.encoding), | |
| 34631 | − Buffer.from(Buffer.from([space], "utf8").toString(), options.encoding), | |
| 34632 | − Buffer.from(Buffer.from([tab], "utf8").toString(), options.encoding), | |
| 34633 | − ], | |
| 34678 | + timchars: timchars, | |
| 34679 | + timcharFirstBytes: timcharFirstBytes, | |
| 34634 | 34680 | }; |
| 34635 | 34681 | }; |
| 34636 | 34682 |
@@ -34650,6 +34696,7 @@ const underscore = function (str) {
| 34650 | 34696 | |
| 34651 | 34697 | |
| 34652 | 34698 | |
| 34699 | + | |
| 34653 | 34700 | const normalize_options = function (opts) { |
| 34654 | 34701 | const options = {}; |
| 34655 | 34702 | // Merge with user options |
@@ -34838,25 +34885,95 @@ const normalize_options = function (opts) {
| 34838 | 34885 | options, |
| 34839 | 34886 | ); |
| 34840 | 34887 | } |
| 34841 | − // Normalize option `delimiter` | |
| 34842 | − const delimiter_json = JSON.stringify(options.delimiter); | |
| 34843 | − if (!Array.isArray(options.delimiter)) | |
| 34844 | − options.delimiter = [options.delimiter]; | |
| 34845 | − if (options.delimiter.length === 0) { | |
| 34888 | + // Normalize option `delimiter_auto` | |
| 34889 | + if ( | |
| 34890 | + options.delimiter_auto === undefined || | |
| 34891 | + options.delimiter_auto === null || | |
| 34892 | + options.delimiter_auto === false | |
| 34893 | + ) { | |
| 34894 | + options.delimiter_auto = false; | |
| 34895 | + } else if (options.delimiter_auto === true) { | |
| 34896 | + options.delimiter_auto = {}; | |
| 34897 | + } else if (!is_object(options.delimiter_auto)) { | |
| 34846 | 34898 | throw new CsvError( |
| 34847 | − "CSV_INVALID_OPTION_DELIMITER", | |
| 34899 | + "CSV_INVALID_OPTION_DELIMITER_AUTO", | |
| 34848 | 34900 | [ |
| 34849 | − "Invalid option delimiter:", | |
| 34850 | − "delimiter must be a non empty string or buffer or array of string|buffer,", | |
| 34851 | − `got ${delimiter_json}`, | |
| 34901 | + "Invalid option delimiter_auto:", | |
| 34902 | + "delimiter_auto must be a boolean or a configuration object,", | |
| 34903 | + `got ${JSON.stringify(options.delimiter_auto)}`, | |
| 34852 | 34904 | ], |
| 34853 | 34905 | options, |
| 34854 | 34906 | ); |
| 34855 | 34907 | } |
| 34856 | − options.delimiter = options.delimiter.map(function (delimiter) { | |
| 34857 | − if (delimiter === undefined || delimiter === null || delimiter === false) { | |
| 34858 | − return Buffer.from(",", options.encoding); | |
| 34908 | + if (options.delimiter_auto) { | |
| 34909 | + if (options.delimiter_auto.preferred === undefined) | |
| 34910 | + options.delimiter_auto.preferred = { | |
| 34911 | + [",".charCodeAt(0)]: 1.8, | |
| 34912 | + ["\t".charCodeAt(0)]: 1.8, | |
| 34913 | + [";".charCodeAt(0)]: 1.6, | |
| 34914 | + [" ".charCodeAt(0)]: 1.6, | |
| 34915 | + [":".charCodeAt(0)]: 1.5, | |
| 34916 | + [".".charCodeAt(0)]: 1.4, | |
| 34917 | + ["/".charCodeAt(0)]: 1.4, | |
| 34918 | + }; | |
| 34919 | + else if (!is_object(options.delimiter_auto.preferred)) { | |
| 34920 | + throw new CsvError( | |
| 34921 | + "CSV_INVALID_OPTION_DELIMITER_AUTO", | |
| 34922 | + [ | |
| 34923 | + "Invalid option delimiter_auto:", | |
| 34924 | + "preferred must be an object,", | |
| 34925 | + `got ${JSON.stringify(options.delimiter_auto.preferred)}`, | |
| 34926 | + ], | |
| 34927 | + options, | |
| 34928 | + ); | |
| 34929 | + } | |
| 34930 | + if (options.delimiter_auto.score === undefined) | |
| 34931 | + options.delimiter_auto.score = (info, options) => { | |
| 34932 | + return ( | |
| 34933 | + (info.total - info.std) * (options.preferred[info.char_code] || 1) | |
| 34934 | + ); | |
| 34935 | + }; | |
| 34936 | + else if (typeof options.delimiter_auto.score !== "function") { | |
| 34937 | + throw new CsvError( | |
| 34938 | + "CSV_INVALID_OPTION_DELIMITER_AUTO", | |
| 34939 | + [ | |
| 34940 | + "Invalid option delimiter_auto:", | |
| 34941 | + "score must be a function,", | |
| 34942 | + `got ${JSON.stringify(options.delimiter_auto.score)}`, | |
| 34943 | + ], | |
| 34944 | + options, | |
| 34945 | + ); | |
| 34859 | 34946 | } |
| 34947 | + if (options.delimiter_auto.size === undefined) | |
| 34948 | + options.delimiter_auto.size = 2048; | |
| 34949 | + else if (typeof options.delimiter_auto.size !== "number") { | |
| 34950 | + throw new CsvError( | |
| 34951 | + "CSV_INVALID_OPTION_DELIMITER_AUTO", | |
| 34952 | + [ | |
| 34953 | + "Invalid option delimiter_auto:", | |
| 34954 | + "size must be a number,", | |
| 34955 | + `got ${JSON.stringify(options.delimiter_auto.size)}`, | |
| 34956 | + ], | |
| 34957 | + options, | |
| 34958 | + ); | |
| 34959 | + } | |
| 34960 | + } | |
| 34961 | + // Normalize option `delimiter` | |
| 34962 | + const delimiter_json = JSON.stringify(options.delimiter); | |
| 34963 | + if (options.delimiter_auto !== false) { | |
| 34964 | + options.delimiter = []; | |
| 34965 | + } | |
| 34966 | + if (!Array.isArray(options.delimiter)) { | |
| 34967 | + if ( | |
| 34968 | + options.delimiter === undefined || | |
| 34969 | + options.delimiter === null || | |
| 34970 | + options.delimiter === false | |
| 34971 | + ) { | |
| 34972 | + options.delimiter = Buffer.from(",", options.encoding); | |
| 34973 | + } | |
| 34974 | + options.delimiter = [options.delimiter]; | |
| 34975 | + } | |
| 34976 | + options.delimiter = options.delimiter.map(function (delimiter) { | |
| 34860 | 34977 | if (typeof delimiter === "string") { |
| 34861 | 34978 | delimiter = Buffer.from(delimiter, options.encoding); |
| 34862 | 34979 | } |
@@ -35338,12 +35455,80 @@ const normalize_options = function (opts) {
| 35338 | 35455 | |
| 35339 | 35456 | |
| 35340 | 35457 | |
| 35458 | +;// CONCATENATED MODULE: ./node_modules/csv-parse/lib/utils/delimiter_discover.js | |
| 35459 | + | |
| 35460 | + | |
| 35461 | + | |
| 35462 | +// Discussed in [issue #400](https://github.com/adaltas/node-csv/issues/400) | |
| 35463 | +// See https://github.com/python/cpython/blob/ea1b1c579f600cc85d145c60862b2e6b98701b24/Lib/csv.py#L349 | |
| 35464 | +const delimiter_discover = function (records, options) { | |
| 35465 | + // Normalize the configuration | |
| 35466 | + if (!options) { | |
| 35467 | + ({ delimiter_auto: options } = normalize_options({ delimiter_auto: true })); | |
| 35468 | + } | |
| 35469 | + // Convert String to Buffer | |
| 35470 | + if (typeof records === "string") { | |
| 35471 | + records = Buffer.from(records); | |
| 35472 | + } | |
| 35473 | + // Convert Buffer to an array of records | |
| 35474 | + if (Buffer.isBuffer(records)) { | |
| 35475 | + records = ((data) => { | |
| 35476 | + const records = []; | |
| 35477 | + const parser = transform({ delimiter: [] }); | |
| 35478 | + const push = (record) => records.push(record); | |
| 35479 | + const close = () => {}; | |
| 35480 | + const error = parser.parse(data, true, push, close); | |
| 35481 | + if (error !== undefined) throw error; | |
| 35482 | + return records; | |
| 35483 | + })(records); | |
| 35484 | + } | |
| 35485 | + // Info array initialization, 127 entries, one per char code | |
| 35486 | + const info = Array(127) | |
| 35487 | + .fill() | |
| 35488 | + .map(() => ({ lines: [] })); | |
| 35489 | + // Traverse each records, count occurences per char code | |
| 35490 | + records.map(([record], line) => { | |
| 35491 | + for (let i = 0, l = record.length; i < l; i++) { | |
| 35492 | + // Count the character frequency | |
| 35493 | + const code = record.charCodeAt(i); | |
| 35494 | + if (info[code].lines[line] === undefined) info[code].lines[line] = 0; | |
| 35495 | + info[code].lines[line]++; | |
| 35496 | + } | |
| 35497 | + }); | |
| 35498 | + // Traverse each char code, compute the score | |
| 35499 | + info.map((info, i) => { | |
| 35500 | + info.char_code = i; | |
| 35501 | + info.std = std(info.lines); | |
| 35502 | + info.total = info.lines.reduce((acc, val) => acc + val, 0); | |
| 35503 | + info.preferred = !!options.preferred[i]; | |
| 35504 | + info.score = options.score(info, options); | |
| 35505 | + }); | |
| 35506 | + // Extract the dominant character | |
| 35507 | + const result = info.reduce( | |
| 35508 | + (acc, info) => (acc.score > info.score ? acc : info), | |
| 35509 | + {}, | |
| 35510 | + ); | |
| 35511 | + return String.fromCharCode(result.char_code); | |
| 35512 | +}; | |
| 35513 | + | |
| 35514 | +const std = function (array) { | |
| 35515 | + const n = array.length; | |
| 35516 | + if (n === 0) return 0; | |
| 35517 | + const mean = array.reduce((a, b) => a + b) / n; | |
| 35518 | + return Math.sqrt( | |
| 35519 | + array.map((x) => Math.pow(x - mean, 2)).reduce((a, b) => a + b) / n, | |
| 35520 | + ); | |
| 35521 | +}; | |
| 35522 | + | |
| 35523 | + | |
| 35524 | + | |
| 35341 | 35525 | ;// CONCATENATED MODULE: ./node_modules/csv-parse/lib/api/index.js |
| 35342 | 35526 | |
| 35343 | 35527 | |
| 35344 | 35528 | |
| 35345 | 35529 | |
| 35346 | 35530 | |
| 35531 | + | |
| 35347 | 35532 | const isRecordEmpty = function (record) { |
| 35348 | 35533 | return record.every( |
| 35349 | 35534 | (field) => |
@@ -35351,8 +35536,8 @@ const isRecordEmpty = function (record) {
| 35351 | 35536 | ); |
| 35352 | 35537 | }; |
| 35353 | 35538 | |
| 35354 | −const api_cr = 13; // `\r`, carriage return, 0x0D in hexadécimal, 13 in decimal | |
| 35355 | −const api_nl = 10; // `\n`, newline, 0x0A in hexadecimal, 10 in decimal | |
| 35539 | +const cr = 13; // `\r`, carriage return, 0x0D in hexadécimal, 13 in decimal | |
| 35540 | +const nl = 10; // `\n`, newline, 0x0A in hexadecimal, 10 in decimal | |
| 35356 | 35541 | |
| 35357 | 35542 | const boms = { |
| 35358 | 35543 | // Note, the following are equals: |
@@ -35411,6 +35596,7 @@ const transform = function (original_options = {}) {
| 35411 | 35596 | const { |
| 35412 | 35597 | bom, |
| 35413 | 35598 | comment_no_infix, |
| 35599 | + delimiter_auto, | |
| 35414 | 35600 | encoding, |
| 35415 | 35601 | from_line, |
| 35416 | 35602 | ltrim, |
@@ -35423,7 +35609,45 @@ const transform = function (original_options = {}) {
| 35423 | 35609 | to_line, |
| 35424 | 35610 | } = this.options; |
| 35425 | 35611 | let { comment, escape, quote, record_delimiter } = this.options; |
| 35426 | − const { bomSkipped, previousBuf, rawBuffer, escapeIsQuote } = this.state; | |
| 35612 | + const { | |
| 35613 | + bomSkipped, | |
| 35614 | + delimiterDiscovered, | |
| 35615 | + delimiterBufPrevious, | |
| 35616 | + rawBuffer, | |
| 35617 | + escapeIsQuote, | |
| 35618 | + } = this.state; | |
| 35619 | + // Automatic delimiter discovery | |
| 35620 | + if (!delimiterDiscovered && delimiter_auto) { | |
| 35621 | + let delimiterBuf; | |
| 35622 | + if (delimiterBufPrevious === undefined) { | |
| 35623 | + delimiterBuf = nextBuf; | |
| 35624 | + } else if ( | |
| 35625 | + delimiterBufPrevious !== undefined && | |
| 35626 | + nextBuf === undefined | |
| 35627 | + ) { | |
| 35628 | + delimiterBuf = delimiterBufPrevious; | |
| 35629 | + } else { | |
| 35630 | + delimiterBuf = Buffer.concat([delimiterBufPrevious, nextBuf]); | |
| 35631 | + } | |
| 35632 | + // Ensure that nextBuf is not concatenated a second time during buffer reconciliation | |
| 35633 | + nextBuf = undefined; | |
| 35634 | + // this.delimiterBufPrevious = delimiterBuf; | |
| 35635 | + if (end || delimiterBuf.length > delimiter_auto.size) { | |
| 35636 | + this.options.delimiter = [ | |
| 35637 | + Buffer.from( | |
| 35638 | + delimiter_discover(delimiterBuf, this.options.delimiter_auto), | |
| 35639 | + ), | |
| 35640 | + ]; | |
| 35641 | + this.state.previousBuf = delimiterBuf; | |
| 35642 | + this.state.delimiterBufPrevious = undefined; | |
| 35643 | + this.state.delimiterDiscovered = true; | |
| 35644 | + } else { | |
| 35645 | + this.state.delimiterBufPrevious = delimiterBuf; | |
| 35646 | + return; | |
| 35647 | + } | |
| 35648 | + } | |
| 35649 | + // Previous buffers reconciliation | |
| 35650 | + const { previousBuf } = this.state; | |
| 35427 | 35651 | let buf; |
| 35428 | 35652 | if (previousBuf === undefined) { |
| 35429 | 35653 | if (nextBuf === undefined) { |
@@ -35505,7 +35729,7 @@ const transform = function (original_options = {}) {
| 35505 | 35729 | rawBuffer.append(chr); |
| 35506 | 35730 | } |
| 35507 | 35731 | if ( |
| 35508 | − (chr === api_cr || chr === api_nl) && | |
| 35732 | + (chr === cr || chr === nl) && | |
| 35509 | 35733 | this.state.wasRowDelimiter === false |
| 35510 | 35734 | ) { |
| 35511 | 35735 | this.state.wasRowDelimiter = true; |
@@ -36078,30 +36302,6 @@ const transform = function (original_options = {}) {
| 36078 | 36302 | } |
| 36079 | 36303 | return [undefined, field]; |
| 36080 | 36304 | }, |
| 36081 | − // Helper to test if a character is a space or a line delimiter | |
| 36082 | − __isCharTrimable: function (buf, pos) { | |
| 36083 | − const isTrim = (buf, pos) => { | |
| 36084 | − const { timchars } = this.state; | |
| 36085 | − loop1: for (let i = 0; i < timchars.length; i++) { | |
| 36086 | − const timchar = timchars[i]; | |
| 36087 | − for (let j = 0; j < timchar.length; j++) { | |
| 36088 | − if (timchar[j] !== buf[pos + j]) continue loop1; | |
| 36089 | − } | |
| 36090 | − return timchar.length; | |
| 36091 | − } | |
| 36092 | − return 0; | |
| 36093 | − }; | |
| 36094 | − return isTrim(buf, pos); | |
| 36095 | − }, | |
| 36096 | − // Keep it in case we implement the `cast_int` option | |
| 36097 | − // __isInt(value){ | |
| 36098 | − // // return Number.isInteger(parseInt(value)) | |
| 36099 | − // // return !isNaN( parseInt( obj ) ); | |
| 36100 | − // return /^(\-|\+)?[1-9][0-9]*$/.test(value) | |
| 36101 | − // } | |
| 36102 | − __isFloat: function (value) { | |
| 36103 | − return value - parseFloat(value) + 1 >= 0; // Borrowed from jquery | |
| 36104 | − }, | |
| 36105 | 36305 | __compareBytes: function (sourceBuf, targetBuf, targetPos, firstByte) { |
| 36106 | 36306 | if (sourceBuf[0] !== firstByte) return 0; |
| 36107 | 36307 | const sourceLength = sourceBuf.length; |
@@ -36110,6 +36310,22 @@ const transform = function (original_options = {}) {
| 36110 | 36310 | } |
| 36111 | 36311 | return sourceLength; |
| 36112 | 36312 | }, |
| 36313 | + // Helper to test if a character is trimable | |
| 36314 | + __isCharTrimable: function (buf, pos) { | |
| 36315 | + const { timchars, timcharFirstBytes } = this.state; | |
| 36316 | + // Fast bail-out: non-whitespace bytes (the common case) are rejected | |
| 36317 | + // without scanning the full timchar list. | |
| 36318 | + const first = buf[pos]; | |
| 36319 | + if (first === undefined || timcharFirstBytes[first] === 0) return 0; | |
| 36320 | + loop1: for (let i = 0; i < timchars.length; i++) { | |
| 36321 | + const timchar = timchars[i]; | |
| 36322 | + for (let j = 0; j < timchar.length; j++) { | |
| 36323 | + if (timchar[j] !== buf[pos + j]) continue loop1; | |
| 36324 | + } | |
| 36325 | + return timchar.length; | |
| 36326 | + } | |
| 36327 | + return 0; | |
| 36328 | + }, | |
| 36113 | 36329 | __isDelimiter: function (buf, pos, chr) { |
| 36114 | 36330 | const { delimiter, ignore_last_delimiters } = this.options; |
| 36115 | 36331 | if ( |
@@ -36135,24 +36351,6 @@ const transform = function (original_options = {}) {
| 36135 | 36351 | } |
| 36136 | 36352 | return 0; |
| 36137 | 36353 | }, |
| 36138 | − __isRecordDelimiter: function (chr, buf, pos) { | |
| 36139 | − const { record_delimiter } = this.options; | |
| 36140 | − const recordDelimiterLength = record_delimiter.length; | |
| 36141 | − loop1: for (let i = 0; i < recordDelimiterLength; i++) { | |
| 36142 | − const rd = record_delimiter[i]; | |
| 36143 | − const rdLength = rd.length; | |
| 36144 | − if (rd[0] !== chr) { | |
| 36145 | − continue; | |
| 36146 | − } | |
| 36147 | − for (let j = 1; j < rdLength; j++) { | |
| 36148 | − if (rd[j] !== buf[pos + j]) { | |
| 36149 | − continue loop1; | |
| 36150 | − } | |
| 36151 | − } | |
| 36152 | − return rd.length; | |
| 36153 | − } | |
| 36154 | − return 0; | |
| 36155 | − }, | |
| 36156 | 36354 | __isEscape: function (buf, pos, chr) { |
| 36157 | 36355 | const { escape } = this.options; |
| 36158 | 36356 | if (escape === null) return false; |
@@ -36167,6 +36365,15 @@ const transform = function (original_options = {}) {
| 36167 | 36365 | } |
| 36168 | 36366 | return false; |
| 36169 | 36367 | }, |
| 36368 | + __isFloat: function (value) { | |
| 36369 | + return value - parseFloat(value) + 1 >= 0; // Borrowed from jquery | |
| 36370 | + }, | |
| 36371 | + // Keep it in case we implement the `cast_int` option | |
| 36372 | + // __isInt(value){ | |
| 36373 | + // // return Number.isInteger(parseInt(value)) | |
| 36374 | + // // return !isNaN( parseInt( obj ) ); | |
| 36375 | + // return /^(\-|\+)?[1-9][0-9]*$/.test(value) | |
| 36376 | + // } | |
| 36170 | 36377 | __isQuote: function (buf, pos) { |
| 36171 | 36378 | const { quote } = this.options; |
| 36172 | 36379 | if (quote === null) return false; |
@@ -36178,6 +36385,24 @@ const transform = function (original_options = {}) {
| 36178 | 36385 | } |
| 36179 | 36386 | return true; |
| 36180 | 36387 | }, |
| 36388 | + __isRecordDelimiter: function (chr, buf, pos) { | |
| 36389 | + const { record_delimiter } = this.options; | |
| 36390 | + const recordDelimiterLength = record_delimiter.length; | |
| 36391 | + loop1: for (let i = 0; i < recordDelimiterLength; i++) { | |
| 36392 | + const rd = record_delimiter[i]; | |
| 36393 | + const rdLength = rd.length; | |
| 36394 | + if (rd[0] !== chr) { | |
| 36395 | + continue; | |
| 36396 | + } | |
| 36397 | + for (let j = 1; j < rdLength; j++) { | |
| 36398 | + if (rd[j] !== buf[pos + j]) { | |
| 36399 | + continue loop1; | |
| 36400 | + } | |
| 36401 | + } | |
| 36402 | + return rd.length; | |
| 36403 | + } | |
| 36404 | + return 0; | |
| 36405 | + }, | |
| 36181 | 36406 | __autoDiscoverRecordDelimiter: function (buf, pos) { |
| 36182 | 36407 | const { encoding } = this.options; |
| 36183 | 36408 | // Note, we don't need to cache this information in state, |
@@ -36265,11 +36490,12 @@ const transform = function (original_options = {}) {
| 36265 | 36490 | ;// CONCATENATED MODULE: ./node_modules/csv-parse/lib/sync.js |
| 36266 | 36491 | |
| 36267 | 36492 | |
| 36493 | + | |
| 36268 | 36494 | const parse = function (data, opts = {}) { |
| 36269 | 36495 | if (typeof data === "string") { |
| 36270 | 36496 | data = Buffer.from(data); |
| 36271 | 36497 | } |
| 36272 | − const records = opts && opts.objname ? {} : []; | |
| 36498 | + const records = opts && opts.objname ? Object.create(null) : []; | |
| 36273 | 36499 | const parser = transform(opts); |
| 36274 | 36500 | const push = (record) => { |
| 36275 | 36501 | if (parser.options.objname === undefined) records.push(record); |
@@ -36280,16 +36506,9 @@ const parse = function (data, opts = {}) {
| 36280 | 36506 | const close = () => {}; |
| 36281 | 36507 | const error = parser.parse(data, true, push, close); |
| 36282 | 36508 | if (error !== undefined) throw error; |
| 36283 | − // 250606: `parser.parse` was implemented as 2 calls: | |
| 36284 | − // const err1 = parser.parse(data, false, push, close); | |
| 36285 | − // if (err1 !== undefined) throw err1; | |
| 36286 | − // const err2 = parser.parse(undefined, true, push, close); | |
| 36287 | − // if (err2 !== undefined) throw err2; | |
| 36288 | 36509 | return records; |
| 36289 | 36510 | }; |
| 36290 | 36511 | |
| 36291 | −// export default parse | |
| 36292 | − | |
| 36293 | 36512 | |
| 36294 | 36513 | |
| 36295 | 36514 | ;// CONCATENATED MODULE: ./node_modules/smol-toml/dist/error.js |
modified
package-lock.json
+4
−4
@@ -10,7 +10,7 @@
| 10 | 10 | "@actions/core": "3.0.0", |
| 11 | 11 | "@actions/exec": "3.0.0", |
| 12 | 12 | "@actions/tool-cache": "4.0.0", |
| 13 | − "csv-parse": "6.2.1", | |
| 13 | + "csv-parse": "7.0.0", | |
| 14 | 14 | "semver": "7.7.4", |
| 15 | 15 | "smol-toml": "1.6.1" |
| 16 | 16 | }, |
@@ -838,9 +838,9 @@
| 838 | 838 | } |
| 839 | 839 | }, |
| 840 | 840 | "node_modules/csv-parse": { |
| 841 | − "version": "6.2.1", | |
| 842 | − "resolved": "https://registry.npmjs.org/csv-parse/-/csv-parse-6.2.1.tgz", | |
| 843 | − "integrity": "sha512-LRLMV+UCyfMokp8Wb411duBf1gaBKJfOfBWU9eHMJ+b+cJYZsNu3AFmjJf3+yPGd59Exz1TsMjaSFyxnYB9+IQ==", | |
| 841 | + "version": "7.0.0", | |
| 842 | + "resolved": "https://registry.npmjs.org/csv-parse/-/csv-parse-7.0.0.tgz", | |
| 843 | + "integrity": "sha512-CSssqPAK5us09FhMI9juM0jnqXUJP+rtWeIfivTYBLNH/8rnxkQlZvoRemF6MAyfNov9XU8mN2wwF/pP68sxTA==", | |
| 844 | 844 | "license": "MIT" |
| 845 | 845 | }, |
| 846 | 846 | "node_modules/debug": { |
modified
package.json
+1
−1
@@ -20,7 +20,7 @@
| 20 | 20 | "@actions/core": "3.0.0", |
| 21 | 21 | "@actions/exec": "3.0.0", |
| 22 | 22 | "@actions/tool-cache": "4.0.0", |
| 23 | − "csv-parse": "6.2.1", | |
| 23 | + "csv-parse": "7.0.0", | |
| 24 | 24 | "semver": "7.7.4", |
| 25 | 25 | "smol-toml": "1.6.1" |
| 26 | 26 | }, |
Parents: 3809396