@bytebury/toolkit 1.3.0 → 1.4.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/esm/src/duration.d.ts +91 -0
- package/esm/src/duration.d.ts.map +1 -1
- package/esm/src/duration.js +105 -0
- package/package.json +1 -1
- package/script/src/duration.d.ts +91 -0
- package/script/src/duration.d.ts.map +1 -1
- package/script/src/duration.js +112 -0
package/esm/src/duration.d.ts
CHANGED
|
@@ -122,4 +122,95 @@ export declare class Duration {
|
|
|
122
122
|
*/
|
|
123
123
|
sleep(): Promise<void>;
|
|
124
124
|
}
|
|
125
|
+
/**
|
|
126
|
+
* Converts milliseconds to milliseconds. This is shorthand for the following:
|
|
127
|
+
*
|
|
128
|
+
* ```ts
|
|
129
|
+
* Duration.milliseconds(milliseconds as Milliseconds).toMilliseconds();
|
|
130
|
+
* ```
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```ts
|
|
134
|
+
* milliseconds(1000);
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
export declare function milliseconds(milliseconds: number): Milliseconds;
|
|
138
|
+
/**
|
|
139
|
+
* Converts seconds to milliseconds. This is shorthand for the following:
|
|
140
|
+
*
|
|
141
|
+
* ```ts
|
|
142
|
+
* Duration.seconds(seconds as Seconds).toMilliseconds();
|
|
143
|
+
* ```
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* ```ts
|
|
147
|
+
* seconds(60);
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
export declare function seconds(seconds: number): Milliseconds;
|
|
151
|
+
/**
|
|
152
|
+
* Converts minutes to milliseconds. This is shorthand for the following:
|
|
153
|
+
*
|
|
154
|
+
* ```ts
|
|
155
|
+
* Duration.minutes(minutes as Minutes).toMilliseconds();
|
|
156
|
+
* ```
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* ```ts
|
|
160
|
+
* minutes(1);
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
export declare function minutes(minutes: number): Milliseconds;
|
|
164
|
+
/**
|
|
165
|
+
* Converts hours to milliseconds. This is shorthand for the following:
|
|
166
|
+
*
|
|
167
|
+
* ```ts
|
|
168
|
+
* Duration.hours(hours as Hours).toMilliseconds();
|
|
169
|
+
* ```
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* ```ts
|
|
173
|
+
* hours(1);
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
export declare function hours(hours: number): Milliseconds;
|
|
177
|
+
/**
|
|
178
|
+
* Converts days to milliseconds. This is shorthand for the following:
|
|
179
|
+
*
|
|
180
|
+
* ```ts
|
|
181
|
+
* Duration.days(days as Days).toMilliseconds();
|
|
182
|
+
* ```
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* ```ts
|
|
186
|
+
* days(1);
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
export declare function days(days: number): Milliseconds;
|
|
190
|
+
/**
|
|
191
|
+
* Converts weeks to milliseconds. This is shorthand for the following:
|
|
192
|
+
*
|
|
193
|
+
* ```ts
|
|
194
|
+
* Duration.weeks(weeks as Weeks).toMilliseconds();
|
|
195
|
+
* ```
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* ```ts
|
|
199
|
+
* weeks(1);
|
|
200
|
+
* ```
|
|
201
|
+
*/
|
|
202
|
+
export declare function weeks(weeks: number): Milliseconds;
|
|
203
|
+
/**
|
|
204
|
+
* Converts years to milliseconds. This is shorthand for the following:
|
|
205
|
+
*
|
|
206
|
+
* ```ts
|
|
207
|
+
* Duration.years(years as Years).toMilliseconds();
|
|
208
|
+
* ```
|
|
209
|
+
*
|
|
210
|
+
* @example
|
|
211
|
+
* ```ts
|
|
212
|
+
* years(1);
|
|
213
|
+
* ```
|
|
214
|
+
*/
|
|
215
|
+
export declare function years(years: number): Milliseconds;
|
|
125
216
|
//# sourceMappingURL=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,CAAC,YAAY,EAAE,MAAM,GAAG,YAAY,CAE/D;AAGD;;;;;;;;;;;GAWG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,CAErD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,CAErD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAEjD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAE/C;AAGD;;;;;;;;;;;GAWG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAEjD;AAGD;;;;;;;;;;;GAWG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAEjD"}
|
package/esm/src/duration.js
CHANGED
|
@@ -135,3 +135,108 @@ export class Duration {
|
|
|
135
135
|
await new Promise((resolve) => setTimeout(resolve, this.toMilliseconds()));
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* Converts milliseconds to milliseconds. This is shorthand for the following:
|
|
140
|
+
*
|
|
141
|
+
* ```ts
|
|
142
|
+
* Duration.milliseconds(milliseconds as Milliseconds).toMilliseconds();
|
|
143
|
+
* ```
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* ```ts
|
|
147
|
+
* milliseconds(1000);
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
export function milliseconds(milliseconds) {
|
|
151
|
+
return Duration.milliseconds(milliseconds).toMilliseconds();
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Converts seconds to milliseconds. This is shorthand for the following:
|
|
155
|
+
*
|
|
156
|
+
* ```ts
|
|
157
|
+
* Duration.seconds(seconds as Seconds).toMilliseconds();
|
|
158
|
+
* ```
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* ```ts
|
|
162
|
+
* seconds(60);
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
165
|
+
export function seconds(seconds) {
|
|
166
|
+
return Duration.seconds(seconds).toMilliseconds();
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Converts minutes to milliseconds. This is shorthand for the following:
|
|
170
|
+
*
|
|
171
|
+
* ```ts
|
|
172
|
+
* Duration.minutes(minutes as Minutes).toMilliseconds();
|
|
173
|
+
* ```
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* ```ts
|
|
177
|
+
* minutes(1);
|
|
178
|
+
* ```
|
|
179
|
+
*/
|
|
180
|
+
export function minutes(minutes) {
|
|
181
|
+
return Duration.minutes(minutes).toMilliseconds();
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Converts hours to milliseconds. This is shorthand for the following:
|
|
185
|
+
*
|
|
186
|
+
* ```ts
|
|
187
|
+
* Duration.hours(hours as Hours).toMilliseconds();
|
|
188
|
+
* ```
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* ```ts
|
|
192
|
+
* hours(1);
|
|
193
|
+
* ```
|
|
194
|
+
*/
|
|
195
|
+
export function hours(hours) {
|
|
196
|
+
return Duration.hours(hours).toMilliseconds();
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Converts days to milliseconds. This is shorthand for the following:
|
|
200
|
+
*
|
|
201
|
+
* ```ts
|
|
202
|
+
* Duration.days(days as Days).toMilliseconds();
|
|
203
|
+
* ```
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* ```ts
|
|
207
|
+
* days(1);
|
|
208
|
+
* ```
|
|
209
|
+
*/
|
|
210
|
+
export function days(days) {
|
|
211
|
+
return Duration.days(days).toMilliseconds();
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Converts weeks to milliseconds. This is shorthand for the following:
|
|
215
|
+
*
|
|
216
|
+
* ```ts
|
|
217
|
+
* Duration.weeks(weeks as Weeks).toMilliseconds();
|
|
218
|
+
* ```
|
|
219
|
+
*
|
|
220
|
+
* @example
|
|
221
|
+
* ```ts
|
|
222
|
+
* weeks(1);
|
|
223
|
+
* ```
|
|
224
|
+
*/
|
|
225
|
+
export function weeks(weeks) {
|
|
226
|
+
return Duration.weeks(weeks).toMilliseconds();
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Converts years to milliseconds. This is shorthand for the following:
|
|
230
|
+
*
|
|
231
|
+
* ```ts
|
|
232
|
+
* Duration.years(years as Years).toMilliseconds();
|
|
233
|
+
* ```
|
|
234
|
+
*
|
|
235
|
+
* @example
|
|
236
|
+
* ```ts
|
|
237
|
+
* years(1);
|
|
238
|
+
* ```
|
|
239
|
+
*/
|
|
240
|
+
export function years(years) {
|
|
241
|
+
return Duration.years(years).toMilliseconds();
|
|
242
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bytebury/toolkit",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "TypeScript utility library to help energize your projects with useful functions for any size project. Save yourself some time and focus on shipping features.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
package/script/src/duration.d.ts
CHANGED
|
@@ -122,4 +122,95 @@ export declare class Duration {
|
|
|
122
122
|
*/
|
|
123
123
|
sleep(): Promise<void>;
|
|
124
124
|
}
|
|
125
|
+
/**
|
|
126
|
+
* Converts milliseconds to milliseconds. This is shorthand for the following:
|
|
127
|
+
*
|
|
128
|
+
* ```ts
|
|
129
|
+
* Duration.milliseconds(milliseconds as Milliseconds).toMilliseconds();
|
|
130
|
+
* ```
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```ts
|
|
134
|
+
* milliseconds(1000);
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
export declare function milliseconds(milliseconds: number): Milliseconds;
|
|
138
|
+
/**
|
|
139
|
+
* Converts seconds to milliseconds. This is shorthand for the following:
|
|
140
|
+
*
|
|
141
|
+
* ```ts
|
|
142
|
+
* Duration.seconds(seconds as Seconds).toMilliseconds();
|
|
143
|
+
* ```
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* ```ts
|
|
147
|
+
* seconds(60);
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
export declare function seconds(seconds: number): Milliseconds;
|
|
151
|
+
/**
|
|
152
|
+
* Converts minutes to milliseconds. This is shorthand for the following:
|
|
153
|
+
*
|
|
154
|
+
* ```ts
|
|
155
|
+
* Duration.minutes(minutes as Minutes).toMilliseconds();
|
|
156
|
+
* ```
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* ```ts
|
|
160
|
+
* minutes(1);
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
export declare function minutes(minutes: number): Milliseconds;
|
|
164
|
+
/**
|
|
165
|
+
* Converts hours to milliseconds. This is shorthand for the following:
|
|
166
|
+
*
|
|
167
|
+
* ```ts
|
|
168
|
+
* Duration.hours(hours as Hours).toMilliseconds();
|
|
169
|
+
* ```
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* ```ts
|
|
173
|
+
* hours(1);
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
export declare function hours(hours: number): Milliseconds;
|
|
177
|
+
/**
|
|
178
|
+
* Converts days to milliseconds. This is shorthand for the following:
|
|
179
|
+
*
|
|
180
|
+
* ```ts
|
|
181
|
+
* Duration.days(days as Days).toMilliseconds();
|
|
182
|
+
* ```
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* ```ts
|
|
186
|
+
* days(1);
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
export declare function days(days: number): Milliseconds;
|
|
190
|
+
/**
|
|
191
|
+
* Converts weeks to milliseconds. This is shorthand for the following:
|
|
192
|
+
*
|
|
193
|
+
* ```ts
|
|
194
|
+
* Duration.weeks(weeks as Weeks).toMilliseconds();
|
|
195
|
+
* ```
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* ```ts
|
|
199
|
+
* weeks(1);
|
|
200
|
+
* ```
|
|
201
|
+
*/
|
|
202
|
+
export declare function weeks(weeks: number): Milliseconds;
|
|
203
|
+
/**
|
|
204
|
+
* Converts years to milliseconds. This is shorthand for the following:
|
|
205
|
+
*
|
|
206
|
+
* ```ts
|
|
207
|
+
* Duration.years(years as Years).toMilliseconds();
|
|
208
|
+
* ```
|
|
209
|
+
*
|
|
210
|
+
* @example
|
|
211
|
+
* ```ts
|
|
212
|
+
* years(1);
|
|
213
|
+
* ```
|
|
214
|
+
*/
|
|
215
|
+
export declare function years(years: number): Milliseconds;
|
|
125
216
|
//# sourceMappingURL=duration.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"duration.d.ts","sourceRoot":"","sources":["../../src/src/duration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAEhD;;;;;;;;;;GAUG;AACH,MAAM,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;AACzD,gDAAgD;AAChD,MAAM,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAC/C,gDAAgD;AAChD,MAAM,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAC/C,8CAA8C;AAC9C,MAAM,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC3C,6CAA6C;AAC7C,MAAM,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AACzC,8CAA8C;AAC9C,MAAM,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC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AG,QAAQ;IAIjC;;OAEG;IACH,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,QAAQ;IAIpC;;OAEG;IACH,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,QAAQ;IAIpC;;OAEG;IACH,cAAc,IAAI,YAAY;IAI9B;;OAEG;IACH,SAAS,IAAI,OAAO;IAIpB;;OAEG;IACH,SAAS,IAAI,OAAO;IAIpB;;OAEG;IACH,OAAO,IAAI,KAAK;IAIhB;;OAEG;IACH,MAAM,IAAI,IAAI;IAId;;OAEG;IACH,OAAO,IAAI,KAAK;IAIhB;;OAEG;IACH,OAAO,IAAI,KAAK;IAIhB;;;;;;;;OAQG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,YAAY,CAE/D;AAGD;;;;;;;;;;;GAWG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,CAErD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,CAErD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAEjD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAE/C;AAGD;;;;;;;;;;;GAWG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAEjD;AAGD;;;;;;;;;;;GAWG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAEjD"}
|
package/script/src/duration.js
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Duration = exports.sleep = void 0;
|
|
4
|
+
exports.milliseconds = milliseconds;
|
|
5
|
+
exports.seconds = seconds;
|
|
6
|
+
exports.minutes = minutes;
|
|
7
|
+
exports.hours = hours;
|
|
8
|
+
exports.days = days;
|
|
9
|
+
exports.weeks = weeks;
|
|
10
|
+
exports.years = years;
|
|
4
11
|
/**
|
|
5
12
|
* Sleeps for the given duration of milliseconds.
|
|
6
13
|
*
|
|
@@ -140,3 +147,108 @@ class Duration {
|
|
|
140
147
|
}
|
|
141
148
|
}
|
|
142
149
|
exports.Duration = Duration;
|
|
150
|
+
/**
|
|
151
|
+
* Converts milliseconds to milliseconds. This is shorthand for the following:
|
|
152
|
+
*
|
|
153
|
+
* ```ts
|
|
154
|
+
* Duration.milliseconds(milliseconds as Milliseconds).toMilliseconds();
|
|
155
|
+
* ```
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```ts
|
|
159
|
+
* milliseconds(1000);
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
function milliseconds(milliseconds) {
|
|
163
|
+
return Duration.milliseconds(milliseconds).toMilliseconds();
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Converts seconds to milliseconds. This is shorthand for the following:
|
|
167
|
+
*
|
|
168
|
+
* ```ts
|
|
169
|
+
* Duration.seconds(seconds as Seconds).toMilliseconds();
|
|
170
|
+
* ```
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* ```ts
|
|
174
|
+
* seconds(60);
|
|
175
|
+
* ```
|
|
176
|
+
*/
|
|
177
|
+
function seconds(seconds) {
|
|
178
|
+
return Duration.seconds(seconds).toMilliseconds();
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Converts minutes to milliseconds. This is shorthand for the following:
|
|
182
|
+
*
|
|
183
|
+
* ```ts
|
|
184
|
+
* Duration.minutes(minutes as Minutes).toMilliseconds();
|
|
185
|
+
* ```
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* ```ts
|
|
189
|
+
* minutes(1);
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
function minutes(minutes) {
|
|
193
|
+
return Duration.minutes(minutes).toMilliseconds();
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Converts hours to milliseconds. This is shorthand for the following:
|
|
197
|
+
*
|
|
198
|
+
* ```ts
|
|
199
|
+
* Duration.hours(hours as Hours).toMilliseconds();
|
|
200
|
+
* ```
|
|
201
|
+
*
|
|
202
|
+
* @example
|
|
203
|
+
* ```ts
|
|
204
|
+
* hours(1);
|
|
205
|
+
* ```
|
|
206
|
+
*/
|
|
207
|
+
function hours(hours) {
|
|
208
|
+
return Duration.hours(hours).toMilliseconds();
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Converts days to milliseconds. This is shorthand for the following:
|
|
212
|
+
*
|
|
213
|
+
* ```ts
|
|
214
|
+
* Duration.days(days as Days).toMilliseconds();
|
|
215
|
+
* ```
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* ```ts
|
|
219
|
+
* days(1);
|
|
220
|
+
* ```
|
|
221
|
+
*/
|
|
222
|
+
function days(days) {
|
|
223
|
+
return Duration.days(days).toMilliseconds();
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Converts weeks to milliseconds. This is shorthand for the following:
|
|
227
|
+
*
|
|
228
|
+
* ```ts
|
|
229
|
+
* Duration.weeks(weeks as Weeks).toMilliseconds();
|
|
230
|
+
* ```
|
|
231
|
+
*
|
|
232
|
+
* @example
|
|
233
|
+
* ```ts
|
|
234
|
+
* weeks(1);
|
|
235
|
+
* ```
|
|
236
|
+
*/
|
|
237
|
+
function weeks(weeks) {
|
|
238
|
+
return Duration.weeks(weeks).toMilliseconds();
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Converts years to milliseconds. This is shorthand for the following:
|
|
242
|
+
*
|
|
243
|
+
* ```ts
|
|
244
|
+
* Duration.years(years as Years).toMilliseconds();
|
|
245
|
+
* ```
|
|
246
|
+
*
|
|
247
|
+
* @example
|
|
248
|
+
* ```ts
|
|
249
|
+
* years(1);
|
|
250
|
+
* ```
|
|
251
|
+
*/
|
|
252
|
+
function years(years) {
|
|
253
|
+
return Duration.years(years).toMilliseconds();
|
|
254
|
+
}
|