1 Star 0 Fork 0

UnPourTous/lodash

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
takeRightWhile.js 888 Bytes
一键复制 编辑 原始数据 按行查看 历史
John-David Dalton 提交于 2017-03-01 05:39 +08:00 . Use consistent nullish check for array.
import baseWhile from './.internal/baseWhile.js'
/**
* Creates a slice of `array` with elements taken from the end. Elements are
* taken until `predicate` returns falsey. The predicate is invoked with
* three arguments: (value, index, array).
*
* @since 3.0.0
* @category Array
* @param {Array} array The array to query.
* @param {Function} predicate The function invoked per iteration.
* @returns {Array} Returns the slice of `array`.
* @example
*
* const users = [
* { 'user': 'barney', 'active': false },
* { 'user': 'fred', 'active': true },
* { 'user': 'pebbles', 'active': true }
* ]
*
* takeRightWhile(users, ({ active }) => active)
* // => objects for ['fred', 'pebbles']
*/
function takeRightWhile(array, predicate) {
return (array != null && array.length)
? baseWhile(array, predicate, false, true)
: []
}
export default takeRightWhile
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/UnPourTous/lodash.git
git@gitee.com:UnPourTous/lodash.git
UnPourTous
lodash
lodash
master

搜索帮助