File tree Expand file tree Collapse file tree 2 files changed +17
-5
lines changed
Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -257,6 +257,17 @@ export default class Astx extends ExtendableProxy implements Iterable<Astx> {
257257 return result
258258 }
259259
260+ flatMap < T > (
261+ iteratee : ( astx : Astx , index : number , parent : Astx ) => T | T [ ]
262+ ) : T [ ] {
263+ const result : any [ ] = [ ]
264+ let index = 0
265+ for ( const astx of this ) {
266+ result . push ( iteratee ( astx , index ++ , this ) )
267+ }
268+ return result . flat ( )
269+ }
270+
260271 at ( index : number ) : Astx {
261272 return new Astx (
262273 this . context ,
Original file line number Diff line number Diff line change @@ -6,11 +6,12 @@ import { mapValues, map } from 'lodash'
66import { fromPairs } from 'lodash'
77`
88
9- export function astx ( { astx, statement } : TransformOptions ) : void {
10- astx . find `import { $$imports } from 'lodash'` . replace ( ( { $$imports } ) =>
11- $$imports . map (
12- ( imp ) => statement `import ${ imp . code } from 'lodash/${ imp . code } '`
13- )
9+ export function astx ( { astx } : TransformOptions ) : void {
10+ astx . find `import { $$imports } from 'lodash'` . replace (
11+ ( { $$imports } , parse ) =>
12+ $$imports . flatMap (
13+ ( imp ) => parse `import ${ imp . code } from 'lodash/${ imp . code } '`
14+ )
1415 )
1516}
1617
You can’t perform that action at this time.
0 commit comments