@valueerror/ltjs-core 0.1.0 → 0.1.1

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@valueerror/ltjs-core",
3
3
  "description": "LanguageTool port to JavaScript: core, server and CLI (languages in @valueerror/ltjs-lang-* packages)",
4
- "version": "0.1.0",
4
+ "version": "0.1.1",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "type": "module",
7
7
  "engines": {
@@ -64,17 +64,17 @@
64
64
  "express": "^5.3.0"
65
65
  },
66
66
  "peerDependencies": {
67
- "@valueerror/ltjs-lang-de": "^0.1.0",
68
- "@valueerror/ltjs-lang-en": "^0.1.0",
69
- "@valueerror/ltjs-lang-es": "^0.1.0",
70
- "@valueerror/ltjs-lang-fr": "^0.1.0",
71
- "@valueerror/ltjs-lang-it": "^0.1.0",
72
- "@valueerror/ltjs-lang-pl": "^0.1.0",
73
- "@valueerror/ltjs-lang-ru": "^0.1.0",
74
- "@valueerror/ltjs-lang-sk": "^0.1.0",
75
- "@valueerror/ltjs-lang-sl": "^0.1.0",
76
- "@valueerror/ltjs-lang-de-at": "^0.1.0",
77
- "@valueerror/ltjs-lang-de-ch": "^0.1.0"
67
+ "@valueerror/ltjs-lang-de": "^0.1.1",
68
+ "@valueerror/ltjs-lang-en": "^0.1.1",
69
+ "@valueerror/ltjs-lang-es": "^0.1.1",
70
+ "@valueerror/ltjs-lang-fr": "^0.1.1",
71
+ "@valueerror/ltjs-lang-it": "^0.1.1",
72
+ "@valueerror/ltjs-lang-pl": "^0.1.1",
73
+ "@valueerror/ltjs-lang-ru": "^0.1.1",
74
+ "@valueerror/ltjs-lang-sk": "^0.1.1",
75
+ "@valueerror/ltjs-lang-sl": "^0.1.1",
76
+ "@valueerror/ltjs-lang-de-at": "^0.1.1",
77
+ "@valueerror/ltjs-lang-de-ch": "^0.1.1"
78
78
  },
79
79
  "peerDependenciesMeta": {
80
80
  "@valueerror/ltjs-lang-de": {
@@ -15,7 +15,7 @@ import { isMixedCase, uppercaseFirstChar } from '../../text/StringTools.js';
15
15
  import { Pattern } from '../../../lib/java/regex/index.js';
16
16
  import { Locale } from '../../../lib/java/Locale.js';
17
17
  import { binarySearch, listGet } from '../../../lib/java/arrays.js';
18
- import { commonPrefix } from '../../../lib/java/Strings.js';
18
+ import { commonPrefix } from '../../../lib/guava/Strings.js';
19
19
  import { AbstractMethodError, RuntimeException, IOException, IllegalStateException } from '../../../lib/java/errors.js';
20
20
  import { CASE_INSENSITIVE_ORDER, javaCompare, javaSplit, javaTrim, toLowerCase } from '../../../lib/java/strings.js';
21
21
 
@@ -0,0 +1,18 @@
1
+ // Guava com.google.common.base.Strings (used methods only)
2
+
3
+ // Java: Strings#validSurrogatePairAt(CharSequence,int) (private)
4
+ function validSurrogatePairAt(s, index) {
5
+ if (index < 0 || index > s.length - 2) return false;
6
+ const hi = s.charCodeAt(index);
7
+ const lo = s.charCodeAt(index + 1);
8
+ return hi >= 0xd800 && hi <= 0xdbff && lo >= 0xdc00 && lo <= 0xdfff;
9
+ }
10
+
11
+ // Java: Strings#commonPrefix(CharSequence,CharSequence)
12
+ export function commonPrefix(a, b) {
13
+ const maxPrefixLength = Math.min(a.length, b.length);
14
+ let p = 0;
15
+ while (p < maxPrefixLength && a.charCodeAt(p) === b.charCodeAt(p)) p++;
16
+ if (validSurrogatePairAt(a, p - 1) || validSurrogatePairAt(b, p - 1)) p--;
17
+ return a.substring(0, p);
18
+ }