@niicojs/excel 0.2.3 → 0.2.5
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/LICENSE +20 -20
- package/dist/index.cjs +26 -7
- package/dist/index.d.cts +1 -0
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26 -7
- package/package.json +1 -1
- package/src/pivot-cache.ts +30 -7
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 niico
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 niico
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
SOFTWARE.
|
package/dist/index.cjs
CHANGED
|
@@ -2102,6 +2102,8 @@ const builder = new fastXmlParser.XMLBuilder(builderOptions);
|
|
|
2102
2102
|
this._records = [];
|
|
2103
2103
|
this._recordCount = 0;
|
|
2104
2104
|
this._refreshOnLoad = true; // Default to true
|
|
2105
|
+
// Optimized lookup: Map<fieldIndex, Map<stringValue, sharedItemsIndex>>
|
|
2106
|
+
this._sharedItemsIndexMap = new Map();
|
|
2105
2107
|
this._cacheId = cacheId;
|
|
2106
2108
|
this._sourceSheet = sourceSheet;
|
|
2107
2109
|
this._sourceRange = sourceRange;
|
|
@@ -2162,6 +2164,8 @@ const builder = new fastXmlParser.XMLBuilder(builderOptions);
|
|
|
2162
2164
|
minValue: undefined,
|
|
2163
2165
|
maxValue: undefined
|
|
2164
2166
|
}));
|
|
2167
|
+
// Use Sets for O(1) unique value collection during analysis
|
|
2168
|
+
const sharedItemsSets = this._fields.map(()=>new Set());
|
|
2165
2169
|
// Analyze data to determine field types and collect unique values
|
|
2166
2170
|
for (const row of data){
|
|
2167
2171
|
for(let colIdx = 0; colIdx < row.length && colIdx < this._fields.length; colIdx++){
|
|
@@ -2172,9 +2176,8 @@ const builder = new fastXmlParser.XMLBuilder(builderOptions);
|
|
|
2172
2176
|
}
|
|
2173
2177
|
if (typeof value === 'string') {
|
|
2174
2178
|
field.isNumeric = false;
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
}
|
|
2179
|
+
// O(1) Set.add instead of O(n) Array.includes + push
|
|
2180
|
+
sharedItemsSets[colIdx].add(value);
|
|
2178
2181
|
} else if (typeof value === 'number') {
|
|
2179
2182
|
if (field.minValue === undefined || value < field.minValue) {
|
|
2180
2183
|
field.minValue = value;
|
|
@@ -2190,6 +2193,22 @@ const builder = new fastXmlParser.XMLBuilder(builderOptions);
|
|
|
2190
2193
|
}
|
|
2191
2194
|
}
|
|
2192
2195
|
}
|
|
2196
|
+
// Convert Sets to arrays and build reverse index Maps for O(1) lookup during XML generation
|
|
2197
|
+
this._sharedItemsIndexMap.clear();
|
|
2198
|
+
for(let colIdx = 0; colIdx < this._fields.length; colIdx++){
|
|
2199
|
+
const field = this._fields[colIdx];
|
|
2200
|
+
const set = sharedItemsSets[colIdx];
|
|
2201
|
+
// Convert Set to array (maintains insertion order in ES6+)
|
|
2202
|
+
field.sharedItems = Array.from(set);
|
|
2203
|
+
// Build reverse lookup Map: value -> index
|
|
2204
|
+
if (field.sharedItems.length > 0) {
|
|
2205
|
+
const indexMap = new Map();
|
|
2206
|
+
for(let i = 0; i < field.sharedItems.length; i++){
|
|
2207
|
+
indexMap.set(field.sharedItems[i], i);
|
|
2208
|
+
}
|
|
2209
|
+
this._sharedItemsIndexMap.set(colIdx, indexMap);
|
|
2210
|
+
}
|
|
2211
|
+
}
|
|
2193
2212
|
// Store records
|
|
2194
2213
|
this._records = data;
|
|
2195
2214
|
}
|
|
@@ -2284,15 +2303,15 @@ const builder = new fastXmlParser.XMLBuilder(builderOptions);
|
|
|
2284
2303
|
for (const row of this._records){
|
|
2285
2304
|
const fieldNodes = [];
|
|
2286
2305
|
for(let colIdx = 0; colIdx < this._fields.length; colIdx++){
|
|
2287
|
-
const field = this._fields[colIdx];
|
|
2288
2306
|
const value = colIdx < row.length ? row[colIdx] : null;
|
|
2289
2307
|
if (value === null || value === undefined) {
|
|
2290
2308
|
// Missing value
|
|
2291
2309
|
fieldNodes.push(createElement('m', {}, []));
|
|
2292
2310
|
} else if (typeof value === 'string') {
|
|
2293
|
-
// String value - use index into sharedItems
|
|
2294
|
-
const
|
|
2295
|
-
|
|
2311
|
+
// String value - use index into sharedItems via O(1) Map lookup
|
|
2312
|
+
const indexMap = this._sharedItemsIndexMap.get(colIdx);
|
|
2313
|
+
const idx = indexMap?.get(value);
|
|
2314
|
+
if (idx !== undefined) {
|
|
2296
2315
|
fieldNodes.push(createElement('x', {
|
|
2297
2316
|
v: String(idx)
|
|
2298
2317
|
}, []));
|
package/dist/index.d.cts
CHANGED