MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / func

Function func

tests/xs/issues/__540.js:6–40  ·  view source on GitHub ↗
(descriptors)

Source from the content-addressed store, hash-verified

4---*/
5
6function func(descriptors) {
7 const obj = {}
8
9 for (const [key, descriptor] of Object.entries(descriptors)) {
10 const type =
11 typeof descriptor.type == 'string'
12 ? descriptor.type.toLowerCase()
13 : typeof descriptor.type.name == 'string'
14 ? descriptor.type.name.toLowerCase()
15 : ''
16 if ((type == 'digital')) {
17 if (typeof descriptor.mode == 'string') {
18 // It should be possible to declare using const, but the let to be declared next will be treated as const.
19 const mode = descriptor.mode.toLowerCase()
20 if (mode == 'output') descriptor.mode = 1
21 }
22 if (descriptor.mode == 1) {
23 let value = descriptor.default || false
24 //value = !value // ERROR!! set value: const!
25
26 Object.defineProperty(obj, key, {
27 get() {
28 return value
29 },
30 set(val) {
31 value = val // ERROR!! set value: const!
32 },
33 enumerable: true,
34 })
35 }
36 }
37 }
38
39 return obj
40}
41
42const obj = func({
43 prop: {

Callers 4

harness.jsFile · 0.85
__540.jsFile · 0.85
promise_setupFunction · 0.85
testharness.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected