@hastehaul/common 2.0.30 → 2.0.32

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,10 @@
1
+ type Setting = {
2
+ key: string;
3
+ value: any;
4
+ };
1
5
  export declare function hasElapsed(expirationDate: Date): boolean;
2
6
  export declare function colorize(text: string, colorCode: number): string;
3
7
  export declare function formatDatetimeToHumanReadable(datetime: Date, format?: string): string;
4
8
  export declare function generateIdentifier(messageContent: string): string;
9
+ export declare function getValueFromSettings(settings: Setting[], key: string, envVar: string, defaultValue: any): any;
10
+ export {};
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.generateIdentifier = exports.formatDatetimeToHumanReadable = exports.colorize = exports.hasElapsed = void 0;
6
+ exports.getValueFromSettings = exports.generateIdentifier = exports.formatDatetimeToHumanReadable = exports.colorize = exports.hasElapsed = void 0;
7
7
  const moment_1 = __importDefault(require("moment"));
8
8
  function hasElapsed(expirationDate) {
9
9
  const currentDate = (0, moment_1.default)();
@@ -25,3 +25,12 @@ function generateIdentifier(messageContent) {
25
25
  return Buffer.from(messageContent).toString('base64');
26
26
  }
27
27
  exports.generateIdentifier = generateIdentifier;
28
+ function getValueFromSettings(settings, key, envVar, defaultValue) {
29
+ if (settings.length > 0) {
30
+ const setting = settings.find(item => item.key === key);
31
+ if (setting)
32
+ return setting.value;
33
+ }
34
+ return process.env[envVar] || defaultValue;
35
+ }
36
+ exports.getValueFromSettings = getValueFromSettings;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hastehaul/common",
3
- "version": "2.0.30",
3
+ "version": "2.0.32",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",