This repository has been archived on 2024-09-11. You can view files and clone it, but cannot push or open issues or pull requests.
svrjs-blog-newsletter/cronjob/node_modules/@smithy/util-config-provider/dist-es/numberSelector.js
2024-05-26 22:54:55 +02:00

9 lines
317 B
JavaScript

export const numberSelector = (obj, key, type) => {
if (!(key in obj))
return undefined;
const numberValue = parseInt(obj[key], 10);
if (Number.isNaN(numberValue)) {
throw new TypeError(`Cannot load ${type} '${key}'. Expected number, got '${obj[key]}'.`);
}
return numberValue;
};