MCPcopy Index your code
hub / github.com/Legitcode/tests / element

Function element

src/tests.js:28–48  ·  view source on GitHub ↗
(select, callback)

Source from the content-addressed store, hash-verified

26 component,
27 elements: {},
28 element(select, callback) {
29 let element
30 if (typeof select === 'string') {
31 element = this.elements[select]
32 callback.call(this, element)
33 return this
34 }
35
36 if (Array.isArray(select)) {
37 const args = select.map(elem => this.elements[elem])
38 callback.call(this, ...args)
39 return this
40 }
41
42 if (Object.keys(this.elements).length === 1) {
43 select.call(this, this.elements[Object.keys(this.elements)[0]])
44 } else {
45 throw new Error("There are multiple elements select one")
46 }
47 return this
48 },
49 use(callback, data) {
50 callback.call(this, data)
51 return this

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected