4
4
*/
5
5
'use strict' ;
6
6
7
+ var find = require ( 'array.prototype.find' ) ;
7
8
var variableUtil = require ( '../util/variable' ) ;
8
9
9
10
// ------------------------------------------------------------------------------
@@ -20,7 +21,7 @@ module.exports = {
20
21
} ,
21
22
create : function ( context ) {
22
23
function findSpreadVariable ( name ) {
23
- return variableUtil . variablesInScope ( context ) . find ( function ( item ) {
24
+ return find ( variableUtil . variablesInScope ( context ) , function ( item ) {
24
25
return item . name === name ;
25
26
} ) ;
26
27
}
@@ -33,7 +34,7 @@ module.exports = {
33
34
if ( ! node . properties ) {
34
35
return false ;
35
36
}
36
- return node . properties . find ( function ( prop ) {
37
+ return find ( node . properties , function ( prop ) {
37
38
if ( prop . type === 'Property' ) {
38
39
return prop . key . name === propName ;
39
40
} else if ( prop . type === 'ExperimentalSpreadProperty' ) {
@@ -53,7 +54,7 @@ module.exports = {
53
54
*/
54
55
function findJsxProp ( node , propName ) {
55
56
var attributes = node . openingElement . attributes ;
56
- return attributes . find ( function ( attribute ) {
57
+ return find ( attributes , function ( attribute ) {
57
58
if ( attribute . type === 'JSXSpreadAttribute' ) {
58
59
var variable = findSpreadVariable ( attribute . argument . name ) ;
59
60
if ( variable && variable . defs . length && variable . defs [ 0 ] . node . init ) {
@@ -94,7 +95,7 @@ module.exports = {
94
95
var props = node . arguments [ 1 ] ;
95
96
96
97
if ( props . type === 'Identifier' ) {
97
- var variable = variableUtil . variablesInScope ( context ) . find ( function ( item ) {
98
+ var variable = find ( variableUtil . variablesInScope ( context ) , function ( item ) {
98
99
return item . name === props . name ;
99
100
} ) ;
100
101
if ( variable && variable . defs [ 0 ] . node . init ) {
0 commit comments