@naturalcycles/js-lib 15.93.3 → 15.93.4

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.
@@ -12,6 +12,19 @@ import type { IANATimezone } from '../types.js';
12
12
  * Don't pass unbounded dynamic values (e.g arbitrary user input) as locales or options.
13
13
  */
14
14
  declare class MemoizedIntl {
15
+ /**
16
+ * Escape hatch: for when you want to use native Intl, but linter screams at you - then you can use
17
+ * Intl2.Intl.*
18
+ *
19
+ * Prefer the memoized methods of Intl2 for creating formatters; use this for static functions
20
+ * (e.g `getCanonicalLocales`), `instanceof` checks, and cheap objects like Locale.
21
+ *
22
+ * Intl.Locale is not wrapped consciously: it was benchmarked and does NOT benefit from memoization.
23
+ * It's cheap to create (~1.3µs raw vs ~0.2µs cache hit, so ~1µs saved), while its tag often comes
24
+ * from runtime data (e.g request language), which would grow the never-evicted cache unboundedly.
25
+ * Use `new Intl2.Intl.Locale(tag)` instead.
26
+ */
27
+ readonly Intl: typeof Intl;
15
28
  /**
16
29
  * Returns the IANA timezone e.g `Europe/Stockholm`.
17
30
  * https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
package/dist/intl/intl.js CHANGED
@@ -14,6 +14,19 @@ import { _Memo } from '../decorators/memo.decorator.js';
14
14
  * Don't pass unbounded dynamic values (e.g arbitrary user input) as locales or options.
15
15
  */
16
16
  class MemoizedIntl {
17
+ /**
18
+ * Escape hatch: for when you want to use native Intl, but linter screams at you - then you can use
19
+ * Intl2.Intl.*
20
+ *
21
+ * Prefer the memoized methods of Intl2 for creating formatters; use this for static functions
22
+ * (e.g `getCanonicalLocales`), `instanceof` checks, and cheap objects like Locale.
23
+ *
24
+ * Intl.Locale is not wrapped consciously: it was benchmarked and does NOT benefit from memoization.
25
+ * It's cheap to create (~1.3µs raw vs ~0.2µs cache hit, so ~1µs saved), while its tag often comes
26
+ * from runtime data (e.g request language), which would grow the never-evicted cache unboundedly.
27
+ * Use `new Intl2.Intl.Locale(tag)` instead.
28
+ */
29
+ Intl = Intl;
17
30
  /**
18
31
  * Returns the IANA timezone e.g `Europe/Stockholm`.
19
32
  * https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@naturalcycles/js-lib",
3
3
  "type": "module",
4
- "version": "15.93.3",
4
+ "version": "15.93.4",
5
5
  "dependencies": {
6
6
  "tslib": "^2"
7
7
  },
package/src/intl/intl.ts CHANGED
@@ -16,6 +16,20 @@ import type { AnyObject, IANATimezone } from '../types.js'
16
16
  * Don't pass unbounded dynamic values (e.g arbitrary user input) as locales or options.
17
17
  */
18
18
  class MemoizedIntl {
19
+ /**
20
+ * Escape hatch: for when you want to use native Intl, but linter screams at you - then you can use
21
+ * Intl2.Intl.*
22
+ *
23
+ * Prefer the memoized methods of Intl2 for creating formatters; use this for static functions
24
+ * (e.g `getCanonicalLocales`), `instanceof` checks, and cheap objects like Locale.
25
+ *
26
+ * Intl.Locale is not wrapped consciously: it was benchmarked and does NOT benefit from memoization.
27
+ * It's cheap to create (~1.3µs raw vs ~0.2µs cache hit, so ~1µs saved), while its tag often comes
28
+ * from runtime data (e.g request language), which would grow the never-evicted cache unboundedly.
29
+ * Use `new Intl2.Intl.Locale(tag)` instead.
30
+ */
31
+ readonly Intl = Intl
32
+
19
33
  /**
20
34
  * Returns the IANA timezone e.g `Europe/Stockholm`.
21
35
  * https://en.wikipedia.org/wiki/List_of_tz_database_time_zones