@teselagen/file-utils 0.3.16 → 0.3.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@teselagen/file-utils",
3
- "version": "0.3.16",
3
+ "version": "0.3.17",
4
4
  "dependencies": {
5
5
  "bluebird": "^3.7.2",
6
6
  "jszip": "^3.10.1",
7
- "lodash": "^4.17.21",
7
+ "lodash-es": "^4.17.21",
8
8
  "papaparse": "^5.4.1"
9
9
  },
10
10
  "devDependencies": {
package/src/file-utils.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /* Copyright (C) 2018 TeselaGen Biotechnology, Inc. */
2
- import { camelCase, flatMap, remove, startsWith, snakeCase } from "lodash";
2
+ import { camelCase, flatMap, remove, startsWith, snakeCase } from "lodash-es";
3
3
  import { loadAsync } from "jszip";
4
4
  import Promise from "bluebird";
5
5
  import { parse, unparse } from "papaparse";
@@ -75,7 +75,6 @@ export const extractZipFiles = async allFiles => {
75
75
  const defaultCsvParserOptions = {
76
76
  header: true,
77
77
  skipEmptyLines: "greedy",
78
- trimHeaders: true
79
78
  };
80
79
  export const setupCsvParserOptions = (parserOptions = {}) => {
81
80
  const {
@@ -123,6 +122,17 @@ export const setupCsvParserOptions = (parserOptions = {}) => {
123
122
  return transHeader;
124
123
  };
125
124
  }
125
+ // tnw: the papaparse trimHeaders option was removed so we need to trim headers manually
126
+ const transformToAlwaysRun = header => header.trim();
127
+ if (parserOptions.transformHeader) {
128
+ const existingTransformHeader = parserOptions.transformHeader;
129
+ papaParseOpts.transformHeader = header => {
130
+ const trimmedHeader = transformToAlwaysRun(header);
131
+ return existingTransformHeader(trimmedHeader);
132
+ };
133
+ } else {
134
+ papaParseOpts.transformHeader = transformToAlwaysRun;
135
+ }
126
136
 
127
137
  return papaParseOpts;
128
138
  };