koajs / koajs/compose

[feat] compose should handle deeply nested arrays

Open
#184 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
JavaScript
Stars
1k
Forks
144
PR merge metrics
No merged PRs in 30d

Description

## Describe the feature

https://github.com/koajs/compose/blob/9a2a426b32c614835b812ecb8de5af06c6c87f6f/index.js#L31

`.flat()` takes `depth` parameter, which defaults to 1 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat. Developers should expect it to be `Infinity` as currently this function would (probably, I haven't checked) break with an argument like `compose([ [fn1, fn2] ])`

this was not supported before the introduction of `.flat()` so is not a bug

Contributor guide

Open the contributing guide

Research direction

Start at index.js line 31 and inspect how compose flattens middleware arrays. Verify that deeply nested input such as compose([[fn1, fn2]]) is accepted, and confirm completion by covering the behavior in the repository's existing tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.