diff --git a/docs/docs.html b/docs/docs.html
index 8d253a13..c4fec01a 100644
--- a/docs/docs.html
+++ b/docs/docs.html
@@ -508,7 +508,7 @@
Config Options
transformHeader
- A function to apply on each header. Requires header to be true . The function receives the header as its first argument.
+ A function to apply on each header. Requires header to be true . The function receives the header as its first argument and the index as second.
Only available starting with version 5.0.
|
diff --git a/tests/test-cases.js b/tests/test-cases.js
index bc0b3339..8d15b291 100644
--- a/tests/test-cases.js
+++ b/tests/test-cases.js
@@ -767,6 +767,15 @@ var PARSE_TESTS = [
errors: []
}
},
+ {
+ description: "transformHeader accepts and optional index attribute",
+ input: 'A,B,C\r\na,b,c',
+ config: { header: true, transformHeader: function(header, i) { return i % 2 ? header.toLowerCase() : header; } },
+ expected: {
+ data: [{"A": "a", "b": "b", "C": "c"}],
+ errors: []
+ }
+ },
{
description: "Line ends with quoted field, first field of next line is empty using headers",
input: 'a,b,"c"\r\nd,e,"f"\r\n,"h","i"\r\n,"k","l"',