@@ -586,14 +586,14 @@ convertToFunctionExpression = function convertToFunctionExpression(obj) {
586
586
} ) ;
587
587
callbackFunc . body . body = body ;
588
588
// Returns an array of all return statements
589
- returnStatements = _ . where ( body , { 'type' : 'ReturnStatement' } ) ;
590
- exportsExpressions = _ . where ( body , {
589
+ returnStatements = _ . filter ( body , { 'type' : 'ReturnStatement' } ) ;
590
+ exportsExpressions = _ . filter ( body , {
591
591
'left' : {
592
592
'type' : 'Identifier' ,
593
593
'name' : 'exports'
594
594
}
595
595
} ) ;
596
- moduleExportsExpressions = _ . where ( body , {
596
+ moduleExportsExpressions = _ . filter ( body , {
597
597
'left' : {
598
598
'type' : 'MemberExpression' ,
599
599
'object' : {
@@ -647,18 +647,18 @@ convertToFunctionExpression = function convertToFunctionExpression(obj) {
647
647
} ( ) , hasReturnStatement = function ( ) {
648
648
var returns = [ ] ;
649
649
if ( callbackFunc && callbackFunc . body && _ . isArray ( callbackFunc . body . body ) ) {
650
- returns = _ . where ( callbackFunc . body . body , { 'type' : 'ReturnStatement' } ) ;
650
+ returns = _ . filter ( callbackFunc . body . body , { 'type' : 'ReturnStatement' } ) ;
651
651
if ( returns . length ) {
652
652
return true ;
653
653
}
654
654
}
655
655
return false ;
656
656
} ( ) , originalCallbackFuncParams , hasExportsParam = function ( ) {
657
657
var cbParams = callbackFunc . params || [ ] ;
658
- return _ . where ( cbParams , { 'name' : 'exports' } ) . length ;
658
+ return _ . filter ( cbParams , { 'name' : 'exports' } ) . length ;
659
659
} ( ) , hasModuleParam = function ( ) {
660
660
var cbParams = callbackFunc . params || [ ] ;
661
- return _ . where ( cbParams , { 'name' : 'module' } ) . length ;
661
+ return _ . filter ( cbParams , { 'name' : 'module' } ) . length ;
662
662
} ( ) , normalizeDependencyNames = { } , dependencyNames = function ( ) {
663
663
var deps = [ ] , currentName ;
664
664
_ . each ( dependencies , function ( currentDependency ) {
@@ -709,7 +709,7 @@ convertToFunctionExpression = function convertToFunctionExpression(obj) {
709
709
if ( node . id && node . id . name && node . init && node . init [ 'arguments' ] && node . init [ 'arguments' ] [ 0 ] && node . init [ 'arguments' ] [ 0 ] . value ) {
710
710
variableName = node . id . name ;
711
711
expressionName = normalizeModuleName . call ( amdclean , utils . normalizeDependencyName ( moduleId , node . init [ 'arguments' ] [ 0 ] . value , moduleId ) ) ;
712
- if ( ! _ . contains ( ignoreModules , expressionName ) && variableName === expressionName ) {
712
+ if ( ! _ . includes ( ignoreModules , expressionName ) && variableName === expressionName ) {
713
713
matchingNames . push ( {
714
714
'originalName' : expressionName ,
715
715
'newName' : findNewParamName ( expressionName ) ,
@@ -792,7 +792,7 @@ convertToFunctionExpression = function convertToFunctionExpression(obj) {
792
792
'count' : 1
793
793
} ] ;
794
794
} else {
795
- mappedParameter = _ . where ( amdclean . callbackParameterMap [ dependencyNames [ iterator ] . name ] , { 'name' : currentName } ) ;
795
+ mappedParameter = _ . filter ( amdclean . callbackParameterMap [ dependencyNames [ iterator ] . name ] , { 'name' : currentName } ) ;
796
796
if ( mappedParameter . length ) {
797
797
mappedParameter = mappedParameter [ 0 ] ;
798
798
mappedParameter . count += 1 ;
@@ -852,11 +852,11 @@ convertToFunctionExpression = function convertToFunctionExpression(obj) {
852
852
if ( utils . isRequireExpression ( node ) ) {
853
853
if ( node [ 'arguments' ] && node [ 'arguments' ] [ 0 ] && node [ 'arguments' ] [ 0 ] . value ) {
854
854
normalizedModuleName = normalizeModuleName . call ( amdclean , utils . normalizeDependencyName ( moduleId , node [ 'arguments' ] [ 0 ] . value , moduleId ) ) ;
855
- if ( _ . contains ( ignoreModules , normalizedModuleName ) ) {
855
+ if ( _ . includes ( ignoreModules , normalizedModuleName ) ) {
856
856
return node ;
857
857
}
858
- if ( _ . where ( matchingRequireExpressionNames , { 'originalName' : normalizedModuleName } ) . length ) {
859
- newName = _ . where ( matchingRequireExpressionNames , { 'originalName' : normalizedModuleName } ) [ 0 ] . newName ;
858
+ if ( _ . filter ( matchingRequireExpressionNames , { 'originalName' : normalizedModuleName } ) . length ) {
859
+ newName = _ . filter ( matchingRequireExpressionNames , { 'originalName' : normalizedModuleName } ) [ 0 ] . newName ;
860
860
}
861
861
return {
862
862
'type' : 'Identifier' ,
@@ -898,13 +898,13 @@ convertToObjectDeclaration = function (obj, type) {
898
898
modReturnValue = obj . moduleReturnValue ;
899
899
callee = modReturnValue . callee ;
900
900
params = callee . params ;
901
- if ( params && params . length && _ . isArray ( params ) && _ . where ( params , { 'name' : 'global' } ) ) {
901
+ if ( params && params . length && _ . isArray ( params ) && _ . filter ( params , { 'name' : 'global' } ) ) {
902
902
if ( _ . isObject ( callee . body ) && _ . isArray ( callee . body . body ) ) {
903
- returnStatement = _ . where ( callee . body . body , { 'type' : 'ReturnStatement' } ) [ 0 ] ;
903
+ returnStatement = _ . filter ( callee . body . body , { 'type' : 'ReturnStatement' } ) [ 0 ] ;
904
904
if ( _ . isObject ( returnStatement ) && _ . isObject ( returnStatement . argument ) && returnStatement . argument . type === 'FunctionExpression' ) {
905
905
internalFunctionExpression = returnStatement . argument ;
906
906
if ( _ . isObject ( internalFunctionExpression . body ) && _ . isArray ( internalFunctionExpression . body . body ) ) {
907
- nestedReturnStatement = _ . where ( internalFunctionExpression . body . body , { 'type' : 'ReturnStatement' } ) [ 0 ] ;
907
+ nestedReturnStatement = _ . filter ( internalFunctionExpression . body . body , { 'type' : 'ReturnStatement' } ) [ 0 ] ;
908
908
if ( _ . isObject ( nestedReturnStatement . argument ) && _ . isObject ( nestedReturnStatement . argument . right ) && _ . isObject ( nestedReturnStatement . argument . right . property ) ) {
909
909
if ( nestedReturnStatement . argument . right . property . name ) {
910
910
modReturnValue = {
@@ -1032,7 +1032,7 @@ convertDefinesAndRequires = function convertDefinesAndRequires(node, parent) {
1032
1032
} else {
1033
1033
deps = [ ] ;
1034
1034
}
1035
- hasExportsParam = _ . where ( deps , { 'value' : 'exports' } ) . length ;
1035
+ hasExportsParam = _ . filter ( deps , { 'value' : 'exports' } ) . length ;
1036
1036
if ( _ . isArray ( deps ) && deps . length ) {
1037
1037
_ . each ( deps , function ( currentDependency ) {
1038
1038
if ( dependencyBlacklist [ currentDependency . value ] && ! shouldOptimize ) {
@@ -1072,7 +1072,7 @@ convertDefinesAndRequires = function convertDefinesAndRequires(node, parent) {
1072
1072
amdclean . options . ignoreModules . push ( moduleName ) ;
1073
1073
return node ;
1074
1074
}
1075
- if ( _ . contains ( options . removeModules , moduleName ) ) {
1075
+ if ( _ . includes ( options . removeModules , moduleName ) ) {
1076
1076
// Remove the current module from the source
1077
1077
return { 'type' : 'EmptyStatement' } ;
1078
1078
}
@@ -1089,7 +1089,7 @@ convertDefinesAndRequires = function convertDefinesAndRequires(node, parent) {
1089
1089
} else if ( params . moduleReturnValue && params . moduleReturnValue . type === 'Identifier' ) {
1090
1090
type = 'functionExpression' ;
1091
1091
}
1092
- if ( _ . contains ( options . ignoreModules , moduleName ) ) {
1092
+ if ( _ . includes ( options . ignoreModules , moduleName ) ) {
1093
1093
return node ;
1094
1094
} else if ( utils . isFunctionExpression ( moduleReturnValue ) || type === 'functionExpression' ) {
1095
1095
return convertToFunctionExpression . call ( amdclean , params ) ;
@@ -1116,16 +1116,16 @@ convertDefinesAndRequires = function convertDefinesAndRequires(node, parent) {
1116
1116
}
1117
1117
} else {
1118
1118
// If the node is a function expression that has an exports parameter and does not return anything, return exports
1119
- if ( node . type === 'FunctionExpression' && _ . isArray ( node . params ) && _ . where ( node . params , {
1119
+ if ( node . type === 'FunctionExpression' && _ . isArray ( node . params ) && _ . filter ( node . params , {
1120
1120
'type' : 'Identifier' ,
1121
1121
'name' : 'exports'
1122
- } ) . length && _ . isObject ( node . body ) && _ . isArray ( node . body . body ) && ! _ . where ( node . body . body , { 'type' : 'ReturnStatement' } ) . length ) {
1122
+ } ) . length && _ . isObject ( node . body ) && _ . isArray ( node . body . body ) && ! _ . filter ( node . body . body , { 'type' : 'ReturnStatement' } ) . length ) {
1123
1123
parentHasFunctionExpressionArgument = function ( ) {
1124
1124
if ( ! parent || ! parent . arguments ) {
1125
1125
return false ;
1126
1126
}
1127
1127
if ( parent && parent . arguments && parent . arguments . length ) {
1128
- return _ . where ( parent . arguments , { 'type' : 'FunctionExpression' } ) . length ;
1128
+ return _ . filter ( parent . arguments , { 'type' : 'FunctionExpression' } ) . length ;
1129
1129
}
1130
1130
return false ;
1131
1131
} ( ) ;
@@ -1432,7 +1432,7 @@ clean = function clean() {
1432
1432
} , { } ) ) , hoistedCallbackParameters ) ;
1433
1433
// Creates variable declarations for each AMD module/callback parameter that needs to be hoisted
1434
1434
_ . each ( hoistedVariables , function ( moduleValue , moduleName ) {
1435
- if ( ! _ . contains ( options . ignoreModules , moduleName ) ) {
1435
+ if ( ! _ . includes ( options . ignoreModules , moduleName ) ) {
1436
1436
var _initValue = amdclean . exportsModules [ moduleName ] !== true ? null : {
1437
1437
type : 'ObjectExpression' ,
1438
1438
properties : [ ]
0 commit comments