atomic-fns 0.3.4 → 0.4.2

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.
Files changed (106) hide show
  1. package/README.md +3 -3
  2. package/{core → dist}/collections/BTree.d.ts +6 -6
  3. package/{core → dist}/collections/BTree.js +17 -17
  4. package/{core → dist}/collections/Heap.d.ts +3 -3
  5. package/{core → dist}/collections/Heap.js +0 -0
  6. package/dist/collections/LRUCache.d.ts +80 -0
  7. package/dist/collections/LRUCache.js +126 -0
  8. package/{core → dist}/collections/SortedMap.d.ts +2 -2
  9. package/{core → dist}/collections/SortedMap.js +0 -0
  10. package/{core → dist}/collections/SortedSet.d.ts +3 -3
  11. package/{core → dist}/collections/SortedSet.js +1 -1
  12. package/{core → dist}/collections/SortedTree.d.ts +3 -3
  13. package/{core → dist}/collections/SortedTree.js +1 -1
  14. package/{core → dist}/collections/SplayTree.d.ts +5 -5
  15. package/{core → dist}/collections/SplayTree.js +0 -0
  16. package/{core → dist}/collections/abc.d.ts +1 -1
  17. package/{core → dist}/collections/abc.js +0 -0
  18. package/dist/collections/deque.d.ts +117 -0
  19. package/{core → dist}/collections/deque.js +61 -53
  20. package/{core → dist}/collections/frozenset.d.ts +0 -0
  21. package/{core → dist}/collections/frozenset.js +3 -6
  22. package/{core → dist}/collections/index.d.ts +4 -4
  23. package/{core → dist}/collections/index.js +0 -0
  24. package/{core → dist}/functools/index.d.ts +28 -13
  25. package/{core → dist}/functools/index.js +34 -12
  26. package/{core → dist}/globals/index.d.ts +8 -11
  27. package/{core → dist}/globals/index.js +8 -15
  28. package/dist/i18n/date/index.d.ts +204 -0
  29. package/dist/i18n/date/index.js +530 -0
  30. package/dist/i18n/date/utils.d.ts +65 -0
  31. package/dist/i18n/date/utils.js +312 -0
  32. package/dist/i18n/duration.d.ts +112 -0
  33. package/dist/i18n/duration.js +392 -0
  34. package/dist/i18n/format.d.ts +26 -0
  35. package/dist/i18n/format.js +495 -0
  36. package/{core → dist}/i18n/index.d.ts +1 -1
  37. package/{core → dist}/i18n/index.js +1 -1
  38. package/{core → dist}/index.d.ts +0 -0
  39. package/{core → dist}/index.js +0 -0
  40. package/{core → dist}/itertools/index.d.ts +27 -27
  41. package/{core → dist}/itertools/index.js +24 -24
  42. package/{core → dist}/math/index.d.ts +3 -3
  43. package/{core → dist}/math/index.js +0 -0
  44. package/{core → dist}/operators/index.d.ts +2 -2
  45. package/{core → dist}/operators/index.js +2 -2
  46. package/{core → dist}/random/index.d.ts +1 -1
  47. package/{core → dist}/random/index.js +3 -3
  48. package/package.json +28 -42
  49. package/.editorconfig +0 -12
  50. package/.esdoc.json +0 -27
  51. package/.eslintignore +0 -1
  52. package/.eslintrc.json +0 -35
  53. package/.firebaserc +0 -5
  54. package/.prettierrc +0 -19
  55. package/core/collections/BTree.ts +0 -1340
  56. package/core/collections/Heap.ts +0 -189
  57. package/core/collections/LRUCache.d.ts +0 -152
  58. package/core/collections/LRUCache.js +0 -409
  59. package/core/collections/LRUCache.ts +0 -486
  60. package/core/collections/SortedMap.ts +0 -146
  61. package/core/collections/SortedSet.ts +0 -110
  62. package/core/collections/SortedTree.ts +0 -160
  63. package/core/collections/SplayTree.ts +0 -354
  64. package/core/collections/abc.ts +0 -176
  65. package/core/collections/deque.d.ts +0 -110
  66. package/core/collections/deque.ts +0 -329
  67. package/core/collections/frozenset.ts +0 -37
  68. package/core/collections/index.ts +0 -1024
  69. package/core/collections/test.html +0 -10
  70. package/core/collections/typedArrays.d.ts +0 -31
  71. package/core/collections/typedArrays.js +0 -143
  72. package/core/collections/typedArrays.ts +0 -163
  73. package/core/functools/index.ts +0 -258
  74. package/core/globals/index.ts +0 -481
  75. package/core/i18n/date/format.d.ts +0 -16
  76. package/core/i18n/date/format.js +0 -307
  77. package/core/i18n/date/format.ts +0 -343
  78. package/core/i18n/date/index.d.ts +0 -223
  79. package/core/i18n/date/index.js +0 -387
  80. package/core/i18n/date/index.ts +0 -471
  81. package/core/i18n/date/test.html +0 -67
  82. package/core/i18n/index.ts +0 -8
  83. package/core/index.ts +0 -8
  84. package/core/itertools/index.ts +0 -494
  85. package/core/math/index.ts +0 -152
  86. package/core/operators/index.ts +0 -310
  87. package/core/random/index.ts +0 -66
  88. package/firebase.json +0 -10
  89. package/jasmine.json +0 -14
  90. package/tests/BTree.spec.ts +0 -143
  91. package/tests/Cache.spec.ts +0 -161
  92. package/tests/Heap.spec.ts +0 -66
  93. package/tests/SortedMap.spec.ts +0 -144
  94. package/tests/SortedSet.spec.ts +0 -84
  95. package/tests/SortedTree.spec.ts +0 -164
  96. package/tests/SplayTree.spec.ts +0 -121
  97. package/tests/collections.spec.ts +0 -288
  98. package/tests/deque.spec.ts +0 -107
  99. package/tests/globals.spec.ts +0 -270
  100. package/tests/itertools.spec.ts +0 -266
  101. package/tests/math.spec.ts +0 -25
  102. package/tests/operators.spec.ts +0 -40
  103. package/tests/random.spec.ts +0 -46
  104. package/tsconfig.json +0 -126
  105. package/tsconfig.node.json +0 -18
  106. package/tsconfig.xo.json +0 -9
@@ -0,0 +1,204 @@
1
+ import { Duration, DurationUnit, TDuration } from '../duration.js';
2
+ import { asDate, formatDate, strftime } from '../format.js';
3
+ import { DateParts, daysInMonth, daysInYear, isLeapYear, maxDate, minDate, weeksInYear } from './utils.js';
4
+ export { asDate, daysInMonth, daysInYear, formatDate, isLeapYear, maxDate, minDate, strftime, weeksInYear };
5
+ declare type DateInput = number | string | Date;
6
+ declare type DateLike = DateInput | DateParts | IntlDate;
7
+ export { DateInput, DateParts, DateLike };
8
+ /**
9
+ * Creates a date tied to a given locale (default system locale) which can be formatted in that locale's language using the native {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl Intl Apis} directly or using a formatting string.
10
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl Intl Apis}
11
+ */
12
+ export declare class IntlDate {
13
+ private _date;
14
+ readonly locale?: string;
15
+ intlRelativeFormat: Intl.RelativeTimeFormat;
16
+ /** Parses the provided value as UTC date or returns the current UTC date. */
17
+ static UTC(value?: DateLike, locale?: string): IntlDate;
18
+ /** Returns the current local date and time.*/
19
+ static now(): IntlDate;
20
+ /** Creates a new date from a Unix timestamp (seconds since the unix epoch) */
21
+ static unix(seconds: number): IntlDate;
22
+ /**
23
+ * Creates a new `IntlDate` in local time and specified locale (default is system locale).
24
+ * **Note:** The allowed values for `month` start at 1, which is different from legacy `Date`
25
+ * @param {DateLike} obj The date value (default is current local time)
26
+ * @param {Object} opts The options for this date
27
+ * @param {boolean?} opts.utc Converts input or current time to UTC
28
+ * @param {string?} opts.locale A locale string to use for this date
29
+ * @returns
30
+ */
31
+ constructor(obj?: DateLike, { locale, utc }?: any);
32
+ /** Get the date's year. */
33
+ get year(): number;
34
+ /** Get the this date's month as a number from 1 to 12, inclusive. */
35
+ get month(): number;
36
+ /** Returns the weekday as a number between 1 and 7, inclusive, where Monday is 1 and Sunday is 7. */
37
+ get dayOfWeek(): number;
38
+ /** Get the this date's current day of the month. */
39
+ get day(): number;
40
+ /** Get the this date's current hour. */
41
+ get hour(): number;
42
+ /** Get the this date's current minute. */
43
+ get minute(): number;
44
+ /** Get the this date's current second. */
45
+ get second(): number;
46
+ /** Get the this date's current millisecond. */
47
+ get millisecond(): number;
48
+ isValid(): boolean;
49
+ /** Get the number of days in this date's month. */
50
+ daysInMonth(): number;
51
+ /** Get the number of days in this date's year. */
52
+ daysInYear(): 366 | 365;
53
+ dayOfYear(): number;
54
+ /** Returns `true` if this date's year is a leap year. */
55
+ isLeapYear(): boolean;
56
+ /** Gets the number of weeks according to locale in the current year. */
57
+ weeksInYear(): number;
58
+ /** Gets the number of weeks in the current year, according to ISO weeks. */
59
+ isoWeeksInYear(): number;
60
+ /** Returns the current week of the year. */
61
+ week(): any;
62
+ /** Returns the ISO week of the year. */
63
+ isoWeek(): any;
64
+ /**
65
+ * Returns a localized string representation of this date.
66
+ * @param {Intl.DateTimeFormatOptions} opts The options to use for the format
67
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat Intl.DateTimeFormat()}
68
+ */
69
+ toString(opts?: Intl.DateTimeFormatOptions): string;
70
+ /**
71
+ * Returns a localized string representation of this date, according to the given format string. Format codes use the same specification as {@link https://momentjs.com/docs/#/displaying/format/ moment}.
72
+ * @param {string} str The format string to use
73
+ * @see {@link https://momentjs.com/docs/#/displaying/format/ List of formats}
74
+ * @example
75
+ ```js
76
+ new IntlDate().format('MM/DD/YYYY') // '10/31/2022'
77
+ ```
78
+ */
79
+ format(str: string): string;
80
+ /**
81
+ * Returns a new copy of the native `Date` object used by this instance.
82
+ * @returns {Date} A new `Date` object
83
+ */
84
+ toDate(): Date;
85
+ /**
86
+ * Returns the number of seconds since the Unix Epoch (January 1, 1970 UTC).
87
+ * @see {@link IntlDate.timestamp}
88
+ * @see {@link IntlDate.unix}
89
+ * @example
90
+ ```js
91
+ new IntlDate().toSeconds() // 1318874398
92
+ ```
93
+ */
94
+ toSeconds(): number;
95
+ /**
96
+ * Returns the number of seconds since the Unix Epoch (January 1, 1970 UTC).
97
+ * @see {@link IntlDate.toSeconds}
98
+ * @see {@link IntlDate.unix}
99
+ * @example
100
+ ```js
101
+ new IntlDate().timestamp() // 1318874398
102
+ ```
103
+ */
104
+ timestamp(): number;
105
+ /**
106
+ * Returns the number of seconds since the Unix Epoch (January 1, 1970 UTC).
107
+ * @see {@link IntlDate.toSeconds}
108
+ * @see {@link IntlDate.timestamp}
109
+ * @example
110
+ ```js
111
+ new IntlDate().unix() // 1318874398
112
+ ```
113
+ */
114
+ unix(): number;
115
+ /** Formats a string to the ISO8601 standard.
116
+ * @example
117
+ ```js
118
+ new IntlDate().toISOString() // '2022-10-31T22:44:30.652Z'
119
+ ```
120
+ */
121
+ toISOString(): string;
122
+ /** Returns the date part formatted as ISO8601.
123
+ * @example
124
+ ```js
125
+ new IntlDate().toISODate() // '2022-10-31'
126
+ ```
127
+ */
128
+ toISODate(): string;
129
+ /** Returns the time part formatted as ISO8601.
130
+ * @example
131
+ ```js
132
+ new IntlDate().toISOTime() // 'T22:44:30.652Z'
133
+ ```
134
+ */
135
+ toISOTime(): string;
136
+ /**
137
+ * Returns an object containing year, month, day-of-month, hours, minutes, seconds, milliseconds.
138
+ * @returns {Object} An object like `{year, month, date, hours, minutes, seconds, ms}`
139
+ */
140
+ toObject(): DateParts;
141
+ /** Returns the number of milliseconds since the Unix Epoch (January 1, 1970 UTC) */
142
+ getTime(): number;
143
+ /** Alias of {@link IntlDate.getTime} */
144
+ valueOf(): number;
145
+ /** Returns the timezone string name */
146
+ zoneName(): string;
147
+ /** Returns the timezone GMT offset as a string */
148
+ zone(): string;
149
+ /** Returns the difference in `minutes` between this date and UTC */
150
+ utcOffset(): number;
151
+ /**
152
+ * Check if this date is before another date. The other value will be parsed as an `IntlDate` if not already so.
153
+ * @param {DateLike} other Another date or date like object
154
+ * @returns {boolean} Returns `true` if this date is before the given value
155
+ */
156
+ isBefore(other: DateLike): boolean;
157
+ /**
158
+ * Check if this date is strictly after the given `start` and before `stop` dates. The values will be parsed as an `IntlDate` if not already so.
159
+ * @param {DateLike} start The smaller date
160
+ * @param {DateLike} stop The larger date
161
+ * @returns {boolean} Returns `true` if this date is greater than `start` and less than `stop`.
162
+ */
163
+ isBetween(start: DateLike, stop: DateLike): boolean;
164
+ /**
165
+ * Check if this date is after another date. The other value will be parsed as an `IntlDate` if not already so.
166
+ * @param {DateLike} other Another date or date like object
167
+ * @returns {boolean} Returns `true` if this date is after the given value
168
+ */
169
+ isAfter(other: DateLike): boolean;
170
+ /**
171
+ * Check if this date is the same as `other`.
172
+ * @param other Another date object
173
+ * @returns {boolean} Returns `true` if this date is the same as other
174
+ */
175
+ isSame(other: Date | IntlDate): boolean;
176
+ lt(other: Date | IntlDate): boolean;
177
+ eq(other: Date | IntlDate): boolean;
178
+ compare(other: Date | IntlDate): number;
179
+ set(values: DateParts): IntlDate;
180
+ get relativeFormat(): Intl.RelativeTimeFormat;
181
+ relativeTime(n: number, unit?: Intl.RelativeTimeFormatUnit): string;
182
+ fromNow(unit?: Intl.RelativeTimeFormatUnit): string;
183
+ from(other: DateLike, unit?: Intl.RelativeTimeFormatUnit): string;
184
+ toNow(unit?: Intl.RelativeTimeFormatUnit): string;
185
+ to(other: DateLike, unit?: Intl.RelativeTimeFormatUnit): string;
186
+ diff(other: DateLike, unit?: DurationUnit, exact?: boolean): number;
187
+ add(duration: TDuration, exact?: boolean): IntlDate;
188
+ subtract(duration: TDuration, exact?: boolean): IntlDate;
189
+ startOf(unit: DurationUnit): IntlDate;
190
+ endOf(unit: DurationUnit): IntlDate;
191
+ clone(date?: DateLike): IntlDate;
192
+ static max(...args: any[]): any;
193
+ static min(...args: any[]): any;
194
+ inspect(): string;
195
+ }
196
+ export declare function addDuration(date: DateInput, duration: number | TDuration | Duration, exact?: boolean): Date;
197
+ /**
198
+ * Subtract the specified years, months, weeks, days, hours, minutes and seconds from the given date.
199
+ * @param date
200
+ * @param duration
201
+ * @param exact
202
+ * @returns
203
+ */
204
+ export declare function subDuration(date: DateInput, duration: TDuration, exact?: boolean): Date;