ical-generator 11.0.0 → 11.1.0-develop.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
@@ -9,7 +9,7 @@
9
9
  "@eslint/js": "^10.0.1",
10
10
  "@istanbuljs/nyc-config-typescript": "^1.0.2",
11
11
  "@qiwi/semantic-release-gh-pages-plugin": "^5.4.3",
12
- "@sebbo2002/semantic-release-jsr": "^3.2.1",
12
+ "@sebbo2002/semantic-release-jsr": "^4.0.2",
13
13
  "@semantic-release/changelog": "^6.0.3",
14
14
  "@semantic-release/exec": "^7.1.0",
15
15
  "@semantic-release/git": "^10.0.1",
@@ -18,13 +18,13 @@
18
18
  "@types/express": "^5.0.6",
19
19
  "@types/luxon": "^3.7.1",
20
20
  "@types/mocha": "^10.0.10",
21
- "@types/node": "^25.9.1",
21
+ "@types/node": "^25.9.3",
22
22
  "c8": "^11.0.0",
23
23
  "dayjs": "^1.11.21",
24
- "eslint": "^10.4.0",
24
+ "eslint": "^10.4.1",
25
25
  "eslint-config-prettier": "^10.1.8",
26
- "eslint-plugin-jsonc": "^3.1.2",
27
- "eslint-plugin-perfectionist": "^5.9.0",
26
+ "eslint-plugin-jsonc": "^3.2.0",
27
+ "eslint-plugin-perfectionist": "^5.9.1",
28
28
  "esm": "^3.2.25",
29
29
  "globals": "^17.6.0",
30
30
  "husky": "^9.1.7",
@@ -35,14 +35,14 @@
35
35
  "moment": "^2.30.1",
36
36
  "moment-timezone": "^0.6.2",
37
37
  "nyc": "^18.0.0",
38
- "prettier": "^3.8.3",
38
+ "prettier": "^3.8.4",
39
39
  "rrule": "^2.8.1",
40
- "semantic-release": "^25.0.3",
40
+ "semantic-release": "^25.0.5",
41
41
  "semantic-release-license": "^1.0.2",
42
42
  "source-map-support": "^0.5.21",
43
43
  "temporal-polyfill": "^0.3.0",
44
- "tsdown": "^0.22.0",
45
- "tsx": "^4.22.3",
44
+ "tsdown": "^0.22.2",
45
+ "tsx": "^4.22.4",
46
46
  "typedoc": "^0.28.19",
47
47
  "typescript": "^6.0.3",
48
48
  "typescript-eslint": "^8.60.1"
@@ -141,5 +141,5 @@
141
141
  "test": "mocha"
142
142
  },
143
143
  "type": "module",
144
- "version": "11.0.0"
144
+ "version": "11.1.0-develop.1"
145
145
  }
package/src/tools.ts CHANGED
@@ -219,28 +219,41 @@ export function escape(str: string | unknown, inQuotes: boolean): string {
219
219
  /**
220
220
  * Trim line length of given string
221
221
  */
222
+ const MAX_OCTETS = 74;
223
+
222
224
  export function foldLines(input: string): string {
223
225
  return input
224
226
  .split('\r\n')
225
227
  .map(function (line) {
228
+ // Fast path: a short, pure-ASCII line can never need folding.
229
+ if (line.length <= MAX_OCTETS && isAscii(line)) {
230
+ return line;
231
+ }
232
+
226
233
  let result = '';
227
- let c = 0;
234
+ let octets = 0;
228
235
  for (let i = 0; i < line.length; i++) {
229
236
  let ch = line.charAt(i);
230
-
231
- // surrogate pair, see https://mathiasbynens.be/notes/javascript-encoding#surrogate-pairs
232
- if (ch >= '\ud800' && ch <= '\udbff') {
237
+ const charCode = line.charCodeAt(i);
238
+
239
+ let charsize: number;
240
+ if (charCode < 0x80) {
241
+ charsize = 1;
242
+ } else if (charCode < 0x800) {
243
+ charsize = 2;
244
+ } else if (charCode >= 0xd800 && charCode <= 0xdbff) {
245
+ // surrogate pair, see https://mathiasbynens.be/notes/javascript-encoding#surrogate-pairs
233
246
  ch += line.charAt(++i);
247
+ charsize = 4;
248
+ } else {
249
+ charsize = 3;
234
250
  }
235
251
 
236
- // TextEncoder is available in browsers and node.js >= 11.0.0
237
- const charsize = new TextEncoder().encode(ch).length;
238
- c += charsize;
239
- if (c > 74) {
252
+ octets += charsize;
253
+ if (octets > MAX_OCTETS) {
240
254
  result += '\r\n ';
241
- c = charsize;
255
+ octets = charsize;
242
256
  }
243
-
244
257
  result += ch;
245
258
  }
246
259
  return result;
@@ -474,6 +487,7 @@ export function isLuxonDate(
474
487
  !isTemporal(value)
475
488
  );
476
489
  }
490
+
477
491
  export function isMoment(value: ICalDateTimeValue): value is ICalMomentStub {
478
492
  return (
479
493
  value != null &&
@@ -497,7 +511,6 @@ export function isMomentTZ(
497
511
  ): value is ICalMomentTimezoneStub {
498
512
  return isMoment(value) && 'tz' in value && typeof value.tz === 'function';
499
513
  }
500
-
501
514
  export function isRRule(value: unknown): value is ICalRRuleStub {
502
515
  return (
503
516
  value !== null &&
@@ -734,3 +747,10 @@ export function toJSON(
734
747
 
735
748
  return value.toJSON();
736
749
  }
750
+
751
+ function isAscii(line: string): boolean {
752
+ for (let i = 0; i < line.length; i++) {
753
+ if (line.charCodeAt(i) > 0x7f) return false;
754
+ }
755
+ return true;
756
+ }