MCPcopy
hub / github.com/chavyleung/scripts / lodash_set

Method lodash_set

Env.js:238–251  ·  view source on GitHub ↗
(obj, path, value)

Source from the content-addressed store, hash-verified

236 }
237
238 lodash_set(obj, path, value) {
239 if (Object(obj) !== obj) return obj
240 if (!Array.isArray(path)) path = path.toString().match(/[^.[\]]+/g) || []
241 path
242 .slice(0, -1)
243 .reduce(
244 (a, c, i) =>
245 Object(a[c]) === a[c]
246 ? a[c]
247 : (a[c] = Math.abs(path[i + 1]) >> 0 === +path[i + 1] ? [] : {}),
248 obj
249 )[path[path.length - 1]] = value
250 return obj
251 }
252
253 getdata(key) {
254 let val = this.getval(key)

Callers 1

setdataMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected