Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

### Fixed
## [Unreleased]

### Changed
- Remove redundant `'assert'` dependency from the code. (#672)

## [Unreleased]
### Fixed
- Fixed library support for IE11. The `unorm` package is added to the dependencies (#675)

## [0.6.0] - 2021-04-27

Expand Down
9 changes: 5 additions & 4 deletions docs/guide/dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ features.

| Name | License | Author |
| :--- | :--- | :--- |
| [bessel](https://github.com/SheetJS/bessel) | Apache v2.0 | SheetJS |
| [Chevrotain](https://github.com/SAP/chevrotain) | Apache v2.0 | SAP SE or an SAP affiliate company |
| [GPU.js](https://github.com/gpujs/gpu.js/) ([optional](enabling-gpu-acceleration.md)) | The MIT License | gpu.js Team |
| [core-js](https://github.com/zloirock/core-js) | The MIT License | Denis Pushkarev |
| [tiny-emitter](https://github.com/scottcorgan/tiny-emitter) | The MIT License | Scott Corgan |
| [regenerator-runtime](https://github.com/facebook/regenerator/tree/master/packages/regenerator-runtime) | The MIT License | Facebook, Inc. |
| [GPU.js](https://github.com/gpujs/gpu.js/) ([optional](enabling-gpu-acceleration.md)) | The MIT License | gpu.js Team |
| [jStat](https://github.com/jstat/jstat) | The MIT License | jStat |
| [bessel](https://github.com/SheetJS/bessel) | Apache v2.0 | SheetJS |
| [regenerator-runtime](https://github.com/facebook/regenerator/tree/master/packages/regenerator-runtime) | The MIT License | Facebook, Inc. |
| [tiny-emitter](https://github.com/scottcorgan/tiny-emitter) | The MIT License | Scott Corgan |
| [unorm](https://github.com/walling/unorm) | The MIT or GPL-2.0 License | Matsuza, Bjarke Walling |

<br>

Expand Down
29 changes: 28 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
"@types/jest": "^25.1.3",
"@types/jsdom": "^16.2.1",
"@types/node": "^10.17.19",
"@types/unorm": "^1.3.28",
"@types/webpack-env": "^1.15.2",
"@typescript-eslint/eslint-plugin": "^2.20.0",
"@typescript-eslint/parser": "^2.20.0",
Expand Down Expand Up @@ -144,7 +145,8 @@
"chevrotain": "^6.5.0",
"core-js": "^3.6.4",
"regenerator-runtime": "^0.13.3",
"tiny-emitter": "^2.1.0"
"tiny-emitter": "^2.1.0",
"unorm": "^1.6.0"
},
"optionalDependencies": {
"gpu.js": "2.3.0"
Expand Down
11 changes: 9 additions & 2 deletions src/interpreter/ArithmeticHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Copyright (c) 2021 Handsoncode. All rights reserved.
*/

import unorm from 'unorm'
import {CellError, CellValueTypeOrd, ErrorType, getCellValueType} from '../Cell'
import {Config} from '../Config'
import {DateTimeHelper} from '../DateTimeHelper'
Expand Down Expand Up @@ -115,7 +116,7 @@ export class ArithmeticHelper {
str = str.toLowerCase()
}
if(!this.config.accentSensitive) {
str = str.normalize('NFD').replace(/[\u0300-\u036f]/g, '')
str = normalizeString(str, 'nfd').replace(/[\u0300-\u036f]/g, '')
}
return str
}
Expand Down Expand Up @@ -758,6 +759,12 @@ function inferExtendedNumberTypeMultiplicative(leftArg: ExtendedNumber, rightArg
}

export function forceNormalizeString(str: string): string {
return str.toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, '')
return normalizeString(str.toLowerCase(), 'nfd').replace(/[\u0300-\u036f]/g, '')
}

type NormalizationForm = 'nfc' | 'nfd' | 'nfkc' | 'nfkd'

export function normalizeString(str: string, form: NormalizationForm): string {
return typeof str.normalize === 'function'
? str.normalize(form.toUpperCase()) : unorm[form](str)
}
13 changes: 12 additions & 1 deletion test/column-index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,21 @@ describe('ColumnIndex#add', () => {
index.add('A', adr('A2'))
index.add('ą', adr('A3'))

// Some strings don't have a canonical form, so for them, the index is created as usual.
index.add('l', adr('A4'))
index.add('ł', adr('A5'))
index.add('t', adr('A6'))
index.add('ŧ', adr('A7'))

const columnMap = index.getColumnMap(0, 0)

// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
// eslint-disable @typescript-eslint/no-non-null-assertion
expect(columnMap.get('a')!.index.length).toBe(3)
expect(columnMap.get('l')!.index.length).toBe(1)
expect(columnMap.get('ł')!.index.length).toBe(1)
expect(columnMap.get('t')!.index.length).toBe(1)
expect(columnMap.get('ŧ')!.index.length).toBe(1)
// eslint-enable @typescript-eslint/no-non-null-assertion
})
})

Expand Down
Loading