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 84
84
* [ toInteger] ( toInteger.md )
85
85
* [ lastIndexOf] ( lastIndexOf.md )
86
86
* [ nth] ( nth.md )
87
+ * [ pullAll] ( pullAll.md )
87
88
88
89
## License
89
90
Original file line number Diff line number Diff line change 63
63
+ [ toInteger] ( toInteger.md )
64
64
+ [ lastIndexOf] ( lastIndexOf.md )
65
65
+ [ 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