atomic-fns 1.2.0 → 2.0.0
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/README.md +397 -91
- package/dist/array/index.d.ts +9 -0
- package/dist/array/index.js +9 -0
- package/dist/array/list.d.ts +99 -0
- package/dist/array/list.js +133 -0
- package/dist/array/sets.d.ts +130 -0
- package/dist/array/sets.js +213 -0
- package/dist/async/index.d.ts +6 -0
- package/dist/async/index.js +6 -0
- package/dist/async/retry.d.ts +38 -0
- package/dist/async/retry.js +56 -0
- package/dist/async/sleep.d.ts +42 -0
- package/dist/async/sleep.js +76 -0
- package/dist/collections/bisect.d.ts +103 -0
- package/dist/collections/bisect.js +157 -0
- package/dist/collections/deque.d.ts +67 -97
- package/dist/collections/deque.js +197 -256
- package/dist/collections/entries.d.ts +89 -0
- package/dist/collections/entries.js +131 -0
- package/dist/collections/frozen-set.d.ts +42 -0
- package/dist/collections/frozen-set.js +64 -0
- package/dist/collections/group.d.ts +141 -0
- package/dist/collections/group.js +241 -0
- package/dist/collections/heap.d.ts +64 -0
- package/dist/collections/heap.js +205 -0
- package/dist/collections/index.d.ts +15 -623
- package/dist/collections/index.js +14 -844
- package/dist/collections/internal/arrayKeys.d.ts +19 -0
- package/dist/collections/internal/arrayKeys.js +83 -0
- package/dist/collections/internal/invariants.d.ts +4 -0
- package/dist/collections/internal/invariants.js +12 -0
- package/dist/collections/internal/iterable.d.ts +25 -0
- package/dist/collections/internal/iterable.js +62 -0
- package/dist/collections/iterate.d.ts +162 -0
- package/dist/collections/iterate.js +188 -0
- package/dist/collections/lru-cache.d.ts +58 -0
- package/dist/collections/lru-cache.js +164 -0
- package/dist/collections/order.d.ts +19 -0
- package/dist/collections/order.js +38 -0
- package/dist/collections/shape.d.ts +32 -0
- package/dist/collections/shape.js +86 -0
- package/dist/collections/sorted-map.d.ts +171 -0
- package/dist/collections/sorted-map.js +845 -0
- package/dist/collections/sorted-set.d.ts +103 -0
- package/dist/collections/sorted-set.js +147 -0
- package/dist/collections/splay-tree.d.ts +82 -0
- package/dist/collections/splay-tree.js +354 -0
- package/dist/collections/trie.d.ts +58 -0
- package/dist/collections/trie.js +196 -0
- package/dist/decimal/currency.d.ts +211 -0
- package/dist/decimal/currency.js +321 -0
- package/dist/decimal/decimal.d.ts +299 -0
- package/dist/decimal/decimal.js +660 -0
- package/dist/decimal/index.d.ts +11 -148
- package/dist/decimal/index.js +10 -410
- package/dist/decimal/internal/bits.d.ts +2 -0
- package/dist/decimal/internal/bits.js +7 -0
- package/dist/decimal/internal/echo.d.ts +4 -0
- package/dist/decimal/internal/echo.js +6 -0
- package/dist/decimal/internal/isqrt.d.ts +9 -0
- package/dist/decimal/internal/isqrt.js +34 -0
- package/dist/decimal/internal/locale.d.ts +7 -0
- package/dist/decimal/internal/locale.js +24 -0
- package/dist/decimal/internal/minor-units.d.ts +2 -0
- package/dist/decimal/internal/minor-units.js +33 -0
- package/dist/decimal/internal/pow10.d.ts +24 -0
- package/dist/decimal/internal/pow10.js +96 -0
- package/dist/encoding/base64.d.ts +39 -0
- package/dist/encoding/base64.js +53 -0
- package/dist/encoding/hex.d.ts +23 -0
- package/dist/encoding/hex.js +34 -0
- package/dist/encoding/index.d.ts +6 -0
- package/dist/encoding/index.js +6 -0
- package/dist/function/debounce.d.ts +68 -0
- package/dist/function/debounce.js +203 -0
- package/dist/function/index.d.ts +6 -0
- package/dist/function/index.js +6 -0
- package/dist/function/shared.d.ts +2 -0
- package/dist/function/shared.js +5 -0
- package/dist/function/wrap.d.ts +130 -0
- package/dist/function/wrap.js +113 -0
- package/dist/hash/digest.d.ts +18 -0
- package/dist/hash/digest.js +26 -0
- package/dist/hash/hash.d.ts +22 -0
- package/dist/hash/hash.js +252 -0
- package/dist/hash/hashString.d.ts +13 -0
- package/dist/hash/hashString.js +53 -0
- package/dist/hash/index.d.ts +8 -0
- package/dist/hash/index.js +8 -0
- package/dist/hash/stableStringify.d.ts +19 -0
- package/dist/hash/stableStringify.js +102 -0
- package/dist/id/index.d.ts +7 -0
- package/dist/id/index.js +7 -0
- package/dist/id/nanoid.d.ts +16 -0
- package/dist/id/nanoid.js +65 -0
- package/dist/id/uniqueId.d.ts +14 -0
- package/dist/id/uniqueId.js +20 -0
- package/dist/id/uuid.d.ts +25 -0
- package/dist/id/uuid.js +64 -0
- package/dist/index.d.ts +15 -8
- package/dist/index.js +15 -8
- package/dist/internal/bytes.d.ts +11 -0
- package/dist/internal/bytes.js +33 -0
- package/dist/internal/codec.d.ts +11 -0
- package/dist/internal/codec.js +84 -0
- package/dist/internal/compare.d.ts +10 -0
- package/dist/internal/compare.js +26 -0
- package/dist/internal/crypto.d.ts +5 -0
- package/dist/internal/crypto.js +11 -0
- package/dist/internal/keys.d.ts +12 -0
- package/dist/internal/keys.js +23 -0
- package/dist/internal/kind.d.ts +44 -0
- package/dist/internal/kind.js +139 -0
- package/dist/internal/sparse.d.ts +51 -0
- package/dist/internal/sparse.js +104 -0
- package/dist/internal/text.d.ts +7 -0
- package/dist/internal/text.js +15 -0
- package/dist/internal/timer.d.ts +10 -0
- package/dist/internal/timer.js +17 -0
- package/dist/internal/truncate.d.ts +10 -0
- package/dist/internal/truncate.js +22 -0
- package/dist/internal/walk.d.ts +47 -0
- package/dist/internal/walk.js +100 -0
- package/dist/is/index.d.ts +8 -0
- package/dist/is/index.js +8 -0
- package/dist/is/isArrayLike.d.ts +18 -0
- package/dist/is/isArrayLike.js +25 -0
- package/dist/is/isError.d.ts +13 -0
- package/dist/is/isError.js +18 -0
- package/dist/is/isNil.d.ts +12 -0
- package/dist/is/isNil.js +14 -0
- package/dist/is/isPlainObject.d.ts +15 -0
- package/dist/is/isPlainObject.js +34 -0
- package/dist/number/index.d.ts +7 -0
- package/dist/number/index.js +7 -0
- package/dist/number/round.d.ts +86 -0
- package/dist/number/round.js +130 -0
- package/dist/number/stats.d.ts +52 -0
- package/dist/number/stats.js +115 -0
- package/dist/object/cloneDeep.d.ts +28 -0
- package/dist/object/cloneDeep.js +200 -0
- package/dist/object/index.d.ts +14 -0
- package/dist/object/index.js +13 -0
- package/dist/object/isEqual.d.ts +64 -0
- package/dist/object/isEqual.js +289 -0
- package/dist/object/matches.d.ts +40 -0
- package/dist/object/matches.js +284 -0
- package/dist/object/merge.d.ts +66 -0
- package/dist/object/merge.js +272 -0
- package/dist/object/parsePath.d.ts +22 -0
- package/dist/object/parsePath.js +111 -0
- package/dist/object/path.d.ts +85 -0
- package/dist/object/path.js +208 -0
- package/dist/object/pick.d.ts +91 -0
- package/dist/object/pick.js +180 -0
- package/dist/object/reshape.d.ts +73 -0
- package/dist/object/reshape.js +144 -0
- package/dist/random/index.d.ts +96 -32
- package/dist/random/index.js +215 -53
- package/dist/string/case.d.ts +71 -0
- package/dist/string/case.js +152 -0
- package/dist/string/fold.d.ts +35 -0
- package/dist/string/fold.js +100 -0
- package/dist/string/index.d.ts +6 -187
- package/dist/string/index.js +6 -224
- package/dist/string/truncate.d.ts +25 -0
- package/dist/string/truncate.js +44 -0
- package/dist/string/words.d.ts +27 -0
- package/dist/string/words.js +241 -0
- package/package.json +99 -51
- package/dist/collections/BTree.d.ts +0 -230
- package/dist/collections/BTree.js +0 -1143
- package/dist/collections/Heap.d.ts +0 -69
- package/dist/collections/Heap.js +0 -181
- package/dist/collections/LRUCache.d.ts +0 -83
- package/dist/collections/LRUCache.js +0 -139
- package/dist/collections/SortedMap.d.ts +0 -92
- package/dist/collections/SortedMap.js +0 -131
- package/dist/collections/SortedSet.d.ts +0 -69
- package/dist/collections/SortedSet.js +0 -99
- package/dist/collections/SortedTree.d.ts +0 -103
- package/dist/collections/SortedTree.js +0 -142
- package/dist/collections/SplayTree.d.ts +0 -107
- package/dist/collections/SplayTree.js +0 -351
- package/dist/collections/Trie.d.ts +0 -42
- package/dist/collections/Trie.js +0 -104
- package/dist/collections/abc.d.ts +0 -152
- package/dist/collections/abc.js +0 -39
- package/dist/collections/frozenset.d.ts +0 -19
- package/dist/collections/frozenset.js +0 -33
- package/dist/functools/index.d.ts +0 -106
- package/dist/functools/index.js +0 -203
- package/dist/globals/index.d.ts +0 -268
- package/dist/globals/index.js +0 -447
- package/dist/i18n/currency.d.ts +0 -27
- package/dist/i18n/currency.js +0 -100
- package/dist/i18n/date/index.d.ts +0 -210
- package/dist/i18n/date/index.js +0 -552
- package/dist/i18n/date/utils.d.ts +0 -64
- package/dist/i18n/date/utils.js +0 -192
- package/dist/i18n/duration.d.ts +0 -113
- package/dist/i18n/duration.js +0 -398
- package/dist/i18n/format.d.ts +0 -34
- package/dist/i18n/format.js +0 -378
- package/dist/i18n/index.d.ts +0 -9
- package/dist/i18n/index.js +0 -8
- package/dist/itertools/index.d.ts +0 -251
- package/dist/itertools/index.js +0 -434
- package/dist/math/index.d.ts +0 -79
- package/dist/math/index.js +0 -81
- package/dist/mod.d.ts +0 -1
- package/dist/mod.js +0 -1
- package/dist/operators/index.d.ts +0 -148
- package/dist/operators/index.js +0 -325
- package/dist/types.d.ts +0 -19
- package/dist/types.js +0 -1
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
import { Duration, type DurationUnit, type TDuration } from '../duration.js';
|
|
2
|
-
import { asDate, formatDate, strftime } from '../format.js';
|
|
3
|
-
import { type DateObject, daysInMonth, daysInYear, isLeapYear, maxDate, minDate, weeksInYear } from './utils.js';
|
|
4
|
-
export { asDate, daysInMonth, daysInYear, formatDate, isLeapYear, maxDate, minDate, strftime, weeksInYear };
|
|
5
|
-
export type { DateObject };
|
|
6
|
-
export type DateLike = number | string | Date | IntlDate | DateObject;
|
|
7
|
-
/**
|
|
8
|
-
* 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.
|
|
9
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl Intl Apis}
|
|
10
|
-
*/
|
|
11
|
-
export declare class IntlDate {
|
|
12
|
-
private _date;
|
|
13
|
-
readonly locale?: string;
|
|
14
|
-
intlRelativeFormat: Intl.RelativeTimeFormat;
|
|
15
|
-
/** Parses the provided value as UTC date or returns the current UTC date. */
|
|
16
|
-
static UTC(value?: DateLike, locale?: string): IntlDate;
|
|
17
|
-
/** Returns the current local date and time. */
|
|
18
|
-
static now(): IntlDate;
|
|
19
|
-
/** Creates a new date from a Unix timestamp (seconds since the unix epoch) */
|
|
20
|
-
static unix(seconds: number): IntlDate;
|
|
21
|
-
/**
|
|
22
|
-
* Creates a new `IntlDate` in local time and specified locale (default is system locale).
|
|
23
|
-
* **Note:** The allowed values for `month` start at 1, which is different from legacy `Date`
|
|
24
|
-
* @param {DateLike} obj The date value (default is current local time)
|
|
25
|
-
* @param {Object} opts The options for this date
|
|
26
|
-
* @param {boolean?} opts.utc Converts input or current time to UTC
|
|
27
|
-
* @param {string?} opts.locale A locale string to use for this date
|
|
28
|
-
* @returns
|
|
29
|
-
*/
|
|
30
|
-
constructor(obj?: DateLike, { locale, utc }?: any);
|
|
31
|
-
/** Get the date's year. */
|
|
32
|
-
get year(): number;
|
|
33
|
-
/** Get the this date's month as a number from 1 to 12, inclusive. */
|
|
34
|
-
get month(): number;
|
|
35
|
-
/** Returns the weekday as a number between 1 and 7, inclusive, where Monday is 1 and Sunday is 7. */
|
|
36
|
-
get dayOfWeek(): number;
|
|
37
|
-
/** Get the this date's current day of the month. */
|
|
38
|
-
get day(): number;
|
|
39
|
-
/** Get the this date's current hour. */
|
|
40
|
-
get hour(): number;
|
|
41
|
-
/** Get the this date's current minute. */
|
|
42
|
-
get minute(): number;
|
|
43
|
-
/** Get the this date's current second. */
|
|
44
|
-
get second(): number;
|
|
45
|
-
/** Get the this date's current millisecond. */
|
|
46
|
-
get millisecond(): number;
|
|
47
|
-
isValid(): boolean;
|
|
48
|
-
/** Get the number of days in this date's month. */
|
|
49
|
-
daysInMonth(): number;
|
|
50
|
-
/** Get the number of days in this date's year. */
|
|
51
|
-
daysInYear(): number;
|
|
52
|
-
dayOfYear(): number;
|
|
53
|
-
/** Returns `true` if this date's year is a leap year. */
|
|
54
|
-
isLeapYear(): boolean;
|
|
55
|
-
/** Gets the number of Monday-first weeks in the current year, where week 1 is the first full week. */
|
|
56
|
-
weeksInYear(): number;
|
|
57
|
-
/** Gets the number of weeks in the current year, according to ISO weeks. */
|
|
58
|
-
isoWeeksInYear(): number;
|
|
59
|
-
/** Returns the current week of the year. */
|
|
60
|
-
week(): number;
|
|
61
|
-
/** Returns the ISO week of the year. */
|
|
62
|
-
isoWeek(): number;
|
|
63
|
-
/**
|
|
64
|
-
* Returns a localized string representation of this date.
|
|
65
|
-
* @param {Intl.DateTimeFormatOptions} opts The options to use for the format
|
|
66
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat Intl.DateTimeFormat()}
|
|
67
|
-
*/
|
|
68
|
-
toString(opts?: Intl.DateTimeFormatOptions): string;
|
|
69
|
-
/**
|
|
70
|
-
* 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}.
|
|
71
|
-
* @param {string} str The format string to use
|
|
72
|
-
* @see {@link https://momentjs.com/docs/#/displaying/format/ List of formats}
|
|
73
|
-
* @example
|
|
74
|
-
```js
|
|
75
|
-
new IntlDate().format('MM/DD/YYYY') // '10/31/2022'
|
|
76
|
-
```
|
|
77
|
-
*/
|
|
78
|
-
format(str: string): string;
|
|
79
|
-
/**
|
|
80
|
-
* Returns a new copy of the native `Date` object used by this instance.
|
|
81
|
-
* @returns {Date} A new `Date` object
|
|
82
|
-
*/
|
|
83
|
-
toDate(): Date;
|
|
84
|
-
/**
|
|
85
|
-
* Returns the number of seconds since the Unix Epoch (January 1, 1970 UTC).
|
|
86
|
-
* @see {@link IntlDate.timestamp}
|
|
87
|
-
* @see {@link IntlDate.unix}
|
|
88
|
-
* @example
|
|
89
|
-
```js
|
|
90
|
-
new IntlDate().toSeconds() // 1318874398
|
|
91
|
-
```
|
|
92
|
-
*/
|
|
93
|
-
toSeconds(): number;
|
|
94
|
-
/**
|
|
95
|
-
* Returns the number of seconds since the Unix Epoch (January 1, 1970 UTC).
|
|
96
|
-
* @see {@link IntlDate.toSeconds}
|
|
97
|
-
* @see {@link IntlDate.unix}
|
|
98
|
-
* @example
|
|
99
|
-
```js
|
|
100
|
-
new IntlDate().timestamp() // 1318874398
|
|
101
|
-
```
|
|
102
|
-
*/
|
|
103
|
-
timestamp(): number;
|
|
104
|
-
/**
|
|
105
|
-
* Returns the number of seconds since the Unix Epoch (January 1, 1970 UTC).
|
|
106
|
-
* @see {@link IntlDate.toSeconds}
|
|
107
|
-
* @see {@link IntlDate.timestamp}
|
|
108
|
-
* @example
|
|
109
|
-
```js
|
|
110
|
-
new IntlDate().unix() // 1318874398
|
|
111
|
-
```
|
|
112
|
-
*/
|
|
113
|
-
unix(): number;
|
|
114
|
-
/** Formats a string to the ISO8601 standard.
|
|
115
|
-
* @example
|
|
116
|
-
```js
|
|
117
|
-
new IntlDate().toISOString() // '2022-10-31T22:44:30.652Z'
|
|
118
|
-
```
|
|
119
|
-
*/
|
|
120
|
-
toISOString(): string;
|
|
121
|
-
/** Returns the date part formatted as ISO8601.
|
|
122
|
-
* @example
|
|
123
|
-
```js
|
|
124
|
-
new IntlDate().toISODate() // '2022-10-31'
|
|
125
|
-
```
|
|
126
|
-
*/
|
|
127
|
-
toISODate(): string;
|
|
128
|
-
/** Returns the time part formatted as ISO8601.
|
|
129
|
-
* @example
|
|
130
|
-
```js
|
|
131
|
-
new IntlDate().toISOTime() // '22:44:30.652Z'
|
|
132
|
-
```
|
|
133
|
-
*/
|
|
134
|
-
toISOTime(): string;
|
|
135
|
-
/**
|
|
136
|
-
* Returns an object containing year, month, day-of-month, hours, minutes, seconds, milliseconds.
|
|
137
|
-
* @returns {Object} An object like `{year, month, day, hour, minute, second, millisecond}`
|
|
138
|
-
*/
|
|
139
|
-
toObject(): DateObject;
|
|
140
|
-
/** Returns the number of milliseconds since the Unix Epoch (January 1, 1970 UTC) */
|
|
141
|
-
getTime(): number;
|
|
142
|
-
/** Alias of {@link IntlDate.getTime} */
|
|
143
|
-
valueOf(): number;
|
|
144
|
-
/** Returns the timezone string name */
|
|
145
|
-
zoneName(): string;
|
|
146
|
-
/** Returns the timezone GMT offset as a string */
|
|
147
|
-
zone(): string;
|
|
148
|
-
/** Returns the difference in `minutes` between this date and UTC */
|
|
149
|
-
utcOffset(): number;
|
|
150
|
-
/**
|
|
151
|
-
* Check if this date is before another date. The other value will be parsed as an `IntlDate` if not already so.
|
|
152
|
-
* @param {DateLike} other Another date or date like object
|
|
153
|
-
* @returns {boolean} Returns `true` if this date is before the given value
|
|
154
|
-
*/
|
|
155
|
-
isBefore(other: DateLike): boolean;
|
|
156
|
-
/**
|
|
157
|
-
* 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.
|
|
158
|
-
* @param {DateLike} start The smaller date
|
|
159
|
-
* @param {DateLike} stop The larger date
|
|
160
|
-
* @returns {boolean} Returns `true` if this date is greater than `start` and less than `stop`.
|
|
161
|
-
*/
|
|
162
|
-
isBetween(start: DateLike, stop: DateLike): boolean;
|
|
163
|
-
/**
|
|
164
|
-
* Check if this date is after another date. The other value will be parsed as an `IntlDate` if not already so.
|
|
165
|
-
* @param {DateLike} other Another date or date like object
|
|
166
|
-
* @returns {boolean} Returns `true` if this date is after the given value
|
|
167
|
-
*/
|
|
168
|
-
isAfter(other: DateLike): boolean;
|
|
169
|
-
/**
|
|
170
|
-
* Check if this date is the same as `other`.
|
|
171
|
-
* @param other Another date object
|
|
172
|
-
* @returns {boolean} Returns `true` if this date is the same as other
|
|
173
|
-
*/
|
|
174
|
-
isSame(other: Date | IntlDate): boolean;
|
|
175
|
-
lt(other: Date | IntlDate): boolean;
|
|
176
|
-
eq(other: Date | IntlDate): boolean;
|
|
177
|
-
compare(other: Date | IntlDate): number;
|
|
178
|
-
set(values: DateObject): IntlDate;
|
|
179
|
-
get relativeFormat(): Intl.RelativeTimeFormat;
|
|
180
|
-
relativeTime(n: number, unit?: Intl.RelativeTimeFormatUnit): string;
|
|
181
|
-
fromNow(unit?: Intl.RelativeTimeFormatUnit): string;
|
|
182
|
-
from(other: DateLike, unit?: Intl.RelativeTimeFormatUnit): string;
|
|
183
|
-
toNow(unit?: Intl.RelativeTimeFormatUnit): string;
|
|
184
|
-
to(other: DateLike, unit?: Intl.RelativeTimeFormatUnit): string;
|
|
185
|
-
diff(other: DateLike, unit?: DurationUnit, exact?: boolean): number;
|
|
186
|
-
add(duration: TDuration, exact?: boolean): IntlDate;
|
|
187
|
-
subtract(duration: TDuration, exact?: boolean): IntlDate;
|
|
188
|
-
startOf(unit: DurationUnit): any;
|
|
189
|
-
endOf(unit: DurationUnit): any;
|
|
190
|
-
clone(date?: DateLike): IntlDate;
|
|
191
|
-
static max(...args: any[]): any;
|
|
192
|
-
static min(...args: any[]): any;
|
|
193
|
-
inspect(): string;
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* Add the specified years, months, weeks, days, hours, minutes and seconds to the given date
|
|
197
|
-
* @param date
|
|
198
|
-
* @param duration
|
|
199
|
-
* @param exact Kept for callers that pass it, it no longer changes the result.
|
|
200
|
-
* @returns
|
|
201
|
-
*/
|
|
202
|
-
export declare function addDuration(date: number | string | Date, duration: number | Duration | TDuration, exact?: boolean): Date;
|
|
203
|
-
/**
|
|
204
|
-
* Subtract the specified years, months, weeks, days, hours, minutes and seconds from the given date.
|
|
205
|
-
* @param date
|
|
206
|
-
* @param duration
|
|
207
|
-
* @param exact Kept for callers that pass it, it no longer changes the result.
|
|
208
|
-
* @returns
|
|
209
|
-
*/
|
|
210
|
-
export declare function subDuration(date: number | string | Date, duration: number | Duration | TDuration, exact?: boolean): Date;
|