@punks/backend-core 0.0.34 → 0.0.36

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/dist/cjs/index.js CHANGED
@@ -145,9 +145,18 @@ const addTime = (date, offset) => {
145
145
  case "seconds":
146
146
  newDate.setSeconds(date.getSeconds() + value);
147
147
  break;
148
+ case "milliseconds":
149
+ newDate.setMilliseconds(date.getMilliseconds() + value);
150
+ break;
148
151
  }
149
152
  return newDate;
150
153
  };
154
+ const subtractTime = (date, offset) => {
155
+ return addTime(date, {
156
+ value: -offset.value,
157
+ unit: offset.unit,
158
+ });
159
+ };
151
160
 
152
161
  const DEFAULT_DELIMITER = ";";
153
162
  const splitRows = (data) => {
@@ -272,6 +281,21 @@ const buildObject = (...props) => {
272
281
  }
273
282
  return out;
274
283
  };
284
+ const mergeDeep = (a, b) => {
285
+ const c = { ...(a ?? {}) };
286
+ for (const key in b ?? {}) {
287
+ if (b.hasOwnProperty(key)) {
288
+ const value = b[key];
289
+ if (typeof value === "object" && !Array.isArray(value)) {
290
+ c[key] = mergeDeep(c[key] ?? {}, value);
291
+ }
292
+ else {
293
+ c[key] = value;
294
+ }
295
+ }
296
+ }
297
+ return c;
298
+ };
275
299
 
276
300
  const pluralize = (word) => {
277
301
  return word.endsWith("s") ? `${word}es` : `${word}s`;
@@ -28519,6 +28543,7 @@ exports.joinPath = joinPath;
28519
28543
  exports.jsonDistinct = jsonDistinct;
28520
28544
  exports.last = last;
28521
28545
  exports.mapOrThrow = mapOrThrow;
28546
+ exports.mergeDeep = mergeDeep;
28522
28547
  exports.newUuid = newUuid;
28523
28548
  exports.notNull = notNull;
28524
28549
  exports.notUndefined = notUndefined;
@@ -28531,6 +28556,7 @@ exports.sleep = sleep;
28531
28556
  exports.sort = sort;
28532
28557
  exports.splitPath = splitPath;
28533
28558
  exports.subArrays = subArrays;
28559
+ exports.subtractTime = subtractTime;
28534
28560
  exports.toCamelCase = toCamelCase;
28535
28561
  exports.toDict = toDict;
28536
28562
  exports.toItemsDict = toItemsDict;