File tree Expand file tree Collapse file tree 3 files changed +51
-0
lines changed Expand file tree Collapse file tree 3 files changed +51
-0
lines changed Original file line number Diff line number Diff line change 8484*  [ toInteger] ( toInteger.md ) 
8585*  [ lastIndexOf] ( lastIndexOf.md ) 
8686*  [ nth] ( nth.md ) 
87+ *  [ pullAll] ( pullAll.md ) 
8788
8889## License  
8990
Original file line number Diff line number Diff line change 6363+  [ toInteger] ( toInteger.md ) 
6464+  [ lastIndexOf] ( lastIndexOf.md ) 
6565+  [ nth] ( nth.md ) 
66+ +  [ pullAll] ( pullAll.md ) 
Original file line number Diff line number Diff line change 1+ # lodash源码分析之pullAll  
2+ 
3+ 本文为读 lodash 源码的第六十一篇,后续文章会更新到这个仓库中,欢迎 star:[ pocket-lodash] ( https://github.com/yeyuqiudeng/pocket-lodash ) 
4+ 
5+ gitbook也会同步仓库的更新,gitbook地址:[ pocket-lodash] ( https://www.gitbook.com/book/yeyuqiudeng/pocket-lodash/details ) 
6+ 
7+ ## 依赖  
8+ 
9+ ``` javascript 
10+ import  basePullAll  from  ' ./.internal/basePullAll.js' 
11+ ``` 
12+ 
13+ [ 《lodash源码分析之basePullAll》] ( internal/basePullAll.md ) 
14+ 
15+ ## 源码分析  
16+ 
17+ ``` javascript 
18+ function  pullAll (array , values ) {
19+   return  (array !=  null  &&  array .length  &&  values !=  null  &&  values .length )
20+     ?  basePullAll (array, values)
21+     :  array
22+ }
23+ ``` 
24+ 
25+ 有了 ` basePullAll `  ,要实现 ` pullAll `  就简单了。
26+ 
27+ 其实 ` pullAll `  最终调用的是 ` basePullAll `  ,只不过在调用之前,对 ` array `  和 ` values `  做了一些基本的检测。
28+ 
29+ ``` javascript 
30+ array !=  null  &&  array .length 
31+ ``` 
32+ 
33+ 确保 ` array `  有传,并且不为空
34+ 
35+ ``` javascript 
36+ values !=  null  &&  values .length 
37+ ``` 
38+ 
39+ 确保 ` values `  有传,并且不为空
40+ 
41+ 如果条件不满足,则直接返回 ` array `  ,否则调用 ` basePullAll `  。
42+ 
43+ ## License  
44+ 
45+ [ 署名-非商业性使用-禁止演绎 4.0 国际 (CC BY-NC-ND 4.0)] ( http://creativecommons.org/licenses/by-nc-nd/4.0/ ) 
46+ 
47+ 最后,所有文章都会同步发送到微信公众号上,欢迎关注,欢迎提意见:  ![ ] ( https://raw.githubusercontent.com/yeyuqiudeng/resource/master/images/qrcode_front-end-article.jpg )  
48+ 
49+ 作者:对角另一面 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments