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

Method prepareEnv

tools/nodered2mcu.js:1846–1869  ·  view source on GitHub ↗
(env)

Source from the content-addressed store, hash-verified

1844 delete config.tooltip;
1845 }
1846 prepareEnv(env) {
1847 const parts = [];
1848
1849 env.forEach(env => {
1850 const value = this.resolveValue(env.type, env.value);
1851 const name = regexIdentifierNameES6.test(env.name) ? `${env.name}` : `["${env.name}"]`;
1852 switch (env.type) {
1853 case "str":
1854 case "num":
1855 case "bool":
1856 case "bin":
1857 parts.push(`\t\t${name}: ${value},`);
1858 break;
1859 case "json": {
1860 let t = JSON.parse(value);
1861 t = JSON.stringify(t, null, "\t");
1862 t = t.split("\n").map((line, i) => (i ? "\t\t" : "") + line).join("\n"); // indent multi-line JSON
1863 parts.push(`\t\t${name}: ${t},`);
1864 } break;
1865 }
1866 });
1867
1868 return parts;
1869 }
1870 applyEnv(config, name, node, flows) {
1871 const value = config[name];
1872

Callers 2

transformFlowsMethod · 0.80
prepareNodeMethod · 0.80

Calls 5

resolveValueMethod · 0.80
testMethod · 0.80
mapMethod · 0.80
parseMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected