* Set a property on an object * @param {Object} object * @param {Index} index * @param {*} replacement * @return {*} Returns the updated object * @private
(object, index, replacement)
| 271 | * @private |
| 272 | */ |
| 273 | function _setObjectProperty (object, index, replacement) { |
| 274 | if (isEmptyIndex(index)) { return object } |
| 275 | if (index.size().length !== 1) { |
| 276 | throw new DimensionError(index.size(), 1) |
| 277 | } |
| 278 | |
| 279 | const key = index.dimension(0) |
| 280 | if (typeof key !== 'string') { |
| 281 | throw new TypeError('String expected as index to retrieve an object property') |
| 282 | } |
| 283 | |
| 284 | // clone the object, and apply the property to the clone |
| 285 | const updated = clone(object) |
| 286 | setSafeProperty(updated, key, replacement) |
| 287 | |
| 288 | return updated |
| 289 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…