Skip to content

Commit

Permalink
fix: Iterator returns object { file, suffix} not { name } (#585)
Browse files Browse the repository at this point in the history
I wanted to use this exact script, however it didn't work as the iterator returns no object containing `name`.

Refer to coding in  `cds/lib/compile/to/edm.js`, specifically the function `function* _many` which `yields`:
```js
for (let file in all) yield [ callback(all[file]), { file, suffix } ]
```
  • Loading branch information
patricebender authored Jan 10, 2024
1 parent 2f7a510 commit 281dc87
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions node.js/cds-compile.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ Accepted `options` the same [as documented for `cds.compile.for.odata`](#for-oda
* Either choose exactly one, for example, `{service:'Catalog'}`
* Choose to return EDM objects for all, that means, `{service:'all'}`

In case of the latter, a generator is returned that yields `[ edm, {name} ]` for each service.
In case of the latter, a generator is returned that yields `[ edm, {file, suffix} ]` for each service.
For example, use it as follows:

```js
Expand All @@ -203,7 +203,7 @@ console.log (edm)
```js
// for all services
let all = cds.compile.to.edm (csn, {service:'all'})
for (let [edm,{name}] of all) console.log (name,edm)
for (let [edm,{file,suffix}] of all) console.log (file,suffix,edm)
```


Expand Down

0 comments on commit 281dc87

Please sign in to comment.