Skip to content

Commit

Permalink
fix: update parse-duration
Browse files Browse the repository at this point in the history
  • Loading branch information
kukhariev committed Jun 10, 2023
1 parent a43b2f5 commit 414b1fd
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"dependencies": {
"bytes": "^3.1.0",
"multiparty": "^4.2.2",
"parse-duration": "^1.0.0"
"parse-duration": "^1.1.0"
},
"devDependencies": {
"@types/bytes": "3.1.1",
Expand Down
9 changes: 5 additions & 4 deletions packages/core/src/utils/primitives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,18 @@ export function extendObject<T extends Record<any, any>>(target: T, ...sources:
/**
* Convert a human-readable duration to ms
*/
export function toMilliseconds(value: string | number | undefined): number | null {
export function toMilliseconds(value: string | number | undefined): number | undefined {
if (isNumber(value)) return value;
if (!value) return null;
if (!value) return undefined;
return duration(value);
}
/**
* Convert a human-readable duration to seconds
*/
export function toSeconds(value: string | number): number {
export function toSeconds(value: string | number): number | undefined {
if (isNumber(value)) return value;
return duration(value, 'sec');
const s = duration(value, 'sec');
return s ? ~~s : s;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/s3/src/s3-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ export class S3Storage extends BaseStorage<S3File> {
file.partSize ??= this._partSize;
const partsNum = ~~(file.size / this._partSize) + 1;
const promises = [];
const expiresIn = ~~toSeconds(this.config.expiration?.maxAge || '6hrs');
const expiresIn = toSeconds(this.config.expiration?.maxAge || '6hrs');
for (let i = 0; i < partsNum; i++) {
const partCommandInput = {
Bucket: this.bucket,
Expand Down

0 comments on commit 414b1fd

Please sign in to comment.