MCPcopy
hub / github.com/josdejong/mathjs / _setObjectProperty

Function _setObjectProperty

src/function/matrix/subset.js:273–289  ·  view source on GitHub ↗

* Set a property on an object * @param {Object} object * @param {Index} index * @param {*} replacement * @return {*} Returns the updated object * @private

(object, index, replacement)

Source from the content-addressed store, hash-verified

271 * @private
272 */
273function _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}

Callers

nothing calls this directly

Calls 4

isEmptyIndexFunction · 0.90
cloneFunction · 0.90
setSafePropertyFunction · 0.90
sizeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…