facebook / facebook/jscodeshift

Path containing an array VS array of paths

Open
#320 0 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
JavaScript
Stars
10k
Forks
498
PR merge metrics
No merged PRs in 30d

Description

Is there a more idiomatic way of doing this? The `map(p => p)` part (which I've found in #46) is counterintuitive. My proposal is to call it automatically inside `Collection#map` when it gets a path containing an array.

```ts
const topLevelThingies = ast.map(path =>
path.get('program')
.get('body') // Doesn't return an array, it returns a NodePath that contains an array.
.map(p => p) // Converting to an array of paths. ¯\_(ツ)_/¯
);
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.