elseware-nodejs 1.3.1 → 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/README.md CHANGED
@@ -1 +1 @@
1
- # elseware-nodejs
1
+ # elseware-nodejs
package/dist/index.cjs CHANGED
@@ -212,6 +212,42 @@ var APIFactory = class {
212
212
  });
213
213
  }
214
214
  };
215
+
216
+ // src/api/pickFields.ts
217
+ function pickFields(obj, fields, options = {}) {
218
+ const removeUndefined = options.removeUndefined ?? false;
219
+ const removeNull = options.removeNull ?? false;
220
+ const removeEmptyString = options.removeEmptyString ?? false;
221
+ const strict = options.strict ?? false;
222
+ const defaults = options.defaults ?? {};
223
+ const rename = options.rename ?? {};
224
+ const transform = options.transform ?? {};
225
+ const result = {};
226
+ if (strict) {
227
+ for (const key of Object.keys(obj)) {
228
+ if (!fields.includes(key)) {
229
+ throw new Error(`Unknown field: ${key}`);
230
+ }
231
+ }
232
+ }
233
+ for (const field of fields) {
234
+ let value = obj[field];
235
+ if (value === void 0 && field in defaults) {
236
+ value = defaults[field];
237
+ }
238
+ if (removeUndefined && value === void 0) continue;
239
+ if (removeNull && value === null) continue;
240
+ if (removeEmptyString && value === "") continue;
241
+ if (transform[field]) {
242
+ value = transform[field](value);
243
+ }
244
+ const outputKey = rename[field] ?? field;
245
+ if (Object.prototype.hasOwnProperty.call(obj, field) || field in defaults) {
246
+ result[outputKey] = value;
247
+ }
248
+ }
249
+ return result;
250
+ }
215
251
  var AzureBlobService = class {
216
252
  containerName;
217
253
  blobServiceClient;
@@ -5412,6 +5448,7 @@ exports.loadEnv = loadEnv;
5412
5448
  exports.logger = logger;
5413
5449
  exports.milliseconds = milliseconds;
5414
5450
  exports.minutes = minutes;
5451
+ exports.pickFields = pickFields;
5415
5452
  exports.seconds = seconds;
5416
5453
  exports.sleep = sleep;
5417
5454
  exports.toHours = toHours;