File tree Expand file tree Collapse file tree 4 files changed +39
-4
lines changed Expand file tree Collapse file tree 4 files changed +39
-4
lines changed Original file line number Diff line number Diff line change 15
15
/*--------------------------------------------------------------------------*/
16
16
17
17
/**
18
- * Post-process a given minified JavaScript `source`, preparing it for
18
+ * Post-process a given minified Lo-Dash `source`, preparing it for
19
19
* deployment.
20
20
*
21
21
* @param {String } source The source to process.
Original file line number Diff line number Diff line change 198
198
/**
199
199
* Pre-process a given Lo-Dash source, preparing it for minification.
200
200
*
201
- * @param {String } source The Lo-Dash source to process.
201
+ * @param {String } source The source to process.
202
202
* @returns {String } Returns the processed source.
203
203
*/
204
204
function preprocess ( source ) {
218
218
// remove brackets from `_.escape()` in `_.template`
219
219
source = source . replace ( / _ _ e * = * _ \[ ' e s c a p e ' ] / , '__e=_.escape' ) ;
220
220
221
+ // remove brackets from `collection.indexOf` in `_.contains`
222
+ source = source . replace ( "collection['indexOf'](target)" , 'collection.indexOf(target)' ) ;
223
+
221
224
// remove brackets from `result[length].value` in `_.sortBy`
222
225
source = source . replace ( "result[length]['value']" , 'result[length].value' ) ;
223
226
Original file line number Diff line number Diff line change 514
514
data . firstArg = firstArg ;
515
515
data . hasDontEnumBug = hasDontEnumBug ;
516
516
data . isKeysFast = isKeysFast ;
517
- data . noCharByIndex = noCharByIndex ;
518
517
data . shadowed = shadowed ;
519
518
data . useHas = data . useHas !== false ;
520
519
520
+ if ( ! ( 'noCharByIndex' in data ) ) {
521
+ data . noCharByIndex = noCharByIndex ;
522
+ }
521
523
if ( ! data . exit ) {
522
524
data . exit = 'if (!' + firstArg + ') return result' ;
523
525
}
711
713
*
712
714
* _.contains([1, 2, 3], 3);
713
715
* // => true
716
+ *
717
+ * _.contains({ 'name': 'moe', 'age': 40 }, 'moe');
718
+ * // => true
719
+ *
720
+ * _.contains('curly', 'ur');
721
+ * // => true
714
722
*/
715
723
var contains = createIterator ( {
716
724
'args' : 'collection, target' ,
717
725
'init' : 'false' ,
718
- 'inLoop' : 'if (iteratee[index] === target) return true'
726
+ 'noCharByIndex' : false ,
727
+ 'beforeLoop' : {
728
+ 'array' : 'if (toString.call(iteratee) == stringClass) return collection.indexOf(target) > -1'
729
+ } ,
730
+ 'inLoop' : 'if (iteratee[index] === target) return true' ,
719
731
} ) ;
720
732
721
733
/**
2636
2648
*
2637
2649
* _.isEmpty({});
2638
2650
* // => true
2651
+ *
2652
+ * _.isEmpty('');
2653
+ * // => true
2639
2654
*/
2640
2655
var isEmpty = createIterator ( {
2641
2656
'args' : 'value' ,
Original file line number Diff line number Diff line change 132
132
133
133
/*--------------------------------------------------------------------------*/
134
134
135
+ QUnit . module ( 'lodash.contains' ) ;
136
+
137
+ ( function ( ) {
138
+ _ . each ( [
139
+ { 'kind' : 'literal' , 'value' : 'abc' } ,
140
+ { 'kind' : 'object' , 'value' : Object ( 'abc' ) }
141
+ ] ,
142
+ function ( data ) {
143
+ test ( 'should work with a string ' + data . kind + ' for `collection`' , function ( ) {
144
+ equal ( _ . contains ( data . value , 'bc' ) , true ) ;
145
+ equal ( _ . contains ( data . value , 'd' ) , false ) ;
146
+ } ) ;
147
+ } ) ;
148
+ } ( ) ) ;
149
+
150
+ /*--------------------------------------------------------------------------*/
151
+
135
152
QUnit . module ( 'lodash.debounce' ) ;
136
153
137
154
( function ( ) {
You can’t perform that action at this time.
0 commit comments