@ai-sdk/google 4.0.0-canary.80 → 4.0.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.
@@ -1255,11 +1255,25 @@ function parsePath(rawPath) {
1255
1255
  }
1256
1256
  return segments;
1257
1257
  }
1258
+ var hasOwn = Object.prototype.hasOwnProperty;
1259
+ function hasOwnProperty(obj, key) {
1260
+ return hasOwn.call(obj, key);
1261
+ }
1262
+ function defineOwnProperty(obj, key, value) {
1263
+ Object.defineProperty(obj, key, {
1264
+ value,
1265
+ enumerable: true,
1266
+ configurable: true,
1267
+ writable: true
1268
+ });
1269
+ }
1258
1270
  function getNestedValue(obj, segments) {
1259
1271
  let current = obj;
1260
1272
  for (const pathSegment of segments) {
1261
1273
  if (current == null || typeof current !== "object") return void 0;
1262
- current = current[pathSegment];
1274
+ const currentRecord = current;
1275
+ if (!hasOwnProperty(currentRecord, pathSegment)) return void 0;
1276
+ current = currentRecord[pathSegment];
1263
1277
  }
1264
1278
  return current;
1265
1279
  }
@@ -1268,12 +1282,16 @@ function setNestedValue(obj, segments, value) {
1268
1282
  for (let i = 0; i < segments.length - 1; i++) {
1269
1283
  const pathSegment = segments[i];
1270
1284
  const nextSeg = segments[i + 1];
1271
- if (current[pathSegment] == null) {
1272
- current[pathSegment] = typeof nextSeg === "number" ? [] : {};
1285
+ if (!hasOwnProperty(current, pathSegment) || current[pathSegment] == null) {
1286
+ defineOwnProperty(
1287
+ current,
1288
+ pathSegment,
1289
+ typeof nextSeg === "number" ? [] : {}
1290
+ );
1273
1291
  }
1274
1292
  current = current[pathSegment];
1275
1293
  }
1276
- current[segments[segments.length - 1]] = value;
1294
+ defineOwnProperty(current, segments[segments.length - 1], value);
1277
1295
  }
1278
1296
  function resolvePartialArgValue(arg) {
1279
1297
  var _a, _b;