MCPcopy
hub / github.com/webpack/webpack / destructureObject

Method destructureObject

lib/RuntimeTemplate.js:473–482  ·  view source on GitHub ↗

* Destructure object. * @param {string[]} items items * @param {string} value value * @returns {string} destructure object code

(items, value)

Source from the content-addressed store, hash-verified

471 * @returns {string} destructure object code
472 */
473 destructureObject(items, value) {
474 const decl = this.renderLet();
475 return this.supportsDestructuring()
476 ? `${decl} {${items.join(", ")}} = ${value};`
477 : Template.asString(
478 items.map(
479 (item) => `${decl} ${item} = ${value}${propertyAccess([item])};`
480 )
481 );
482 }
483
484 /**
485 * Returns iIFE code.

Callers 2

generateMethod · 0.80
generateMethod · 0.80

Calls 4

renderLetMethod · 0.95
supportsDestructuringMethod · 0.95
propertyAccessFunction · 0.85
asStringMethod · 0.45

Tested by

no test coverage detected