专一于 npm,移除 Bower & Component 包支持git
放弃对 IE 6-8 的支持es6
令 _.forEach
, _.forIn
, _.forOwn
, & _.times
隐式结束链式调用队列api
var wrapped = _([1, 2, 3]); // 在 3.10.1 wrapped.forEach(function(n) { console.log(n); }); // → returns the lodash wrapper without logging until `value` is called // → 在 `value` 调用以前返回 lodash 包装器(并不会打印记录) wrapped.forEach(function(n) { console.log(n); }).value(); // → logs each value from left to right and returns the array // → 从左到右记录每一个值,并返回该数组 // 在 4.0.0 wrapped.forEach(function(n) { console.log(n); }); // → logs each value from left to right and returns the array // → 从左到右记录每一个值,并返回该数组
移除模块路径的分类名数组
// in 3.10.1 var chunk = require('lodash/array/chunk'); // in 4.0.0 var chunk = require('lodash/chunk');
移除 _.pluck
,使用 _.map
迭代器简写代替缓存
var objects = [{ 'a': 1 }, { 'a': 2 }]; // in 3.10.1 _.pluck(objects, 'a'); // → [1, 2] _.map(objects, 'a'); // → [1, 2] // in 4.0.0 _.map(objects, 'a'); // → [1, 2]
大多数方法移除 thisArg
性能优化
var objects = [{ 'a': 1 }, { 'a': 2 }]; var context = { 'b': 5 }; function callback(item) { return item.a + this.b; } // in 3.10.1 _.map(objects, callback, context); // in 4.0.0 _.map(objects, _.bind(callback, context));
将 _.max
& _.min
拆分红 _.maxBy & _.minByapp
var array = [1, 2, 3], objects = [{ 'a': 1 }, { 'a': 2 }]; // in 3.10.1 _.max(array); // → 3 _.max(objects, 'a'); // → { 'a': 2 } _.min(array); // → 1 _.min(objects, 'a'); // → { 'a': 1 } // in 4.0.0 _.max(array); // → 3 _.maxBy(objects, 'a'); // → { 'a': 2 } _.min(array); // → 1 _.minBy(objects, 'a'); // → { 'a': 1 }
移除方法less
移除 _.support
移除 _.findWhere
,使用 _.find
迭代器简写代替
移除 _.where
,使用 _.filter
迭代器简写代替
移除 _.pluck
,使用 _map
迭代器简写代替
方法名变动
_.first
改名为 _.head
_.indexBy
改名为 _.keyBy
_.invoke
改名为 _.invokeMap
_.modArgs
改名为 _.overArgs
_.padLeft
& _.padRight
改名为 _padStart
& _.padEnd
_.pairs
改名为 _.toPairs
_.rest
改名为 _.tail
_.restParam
改名为 _.rest
_.sortByOrder
改名为 _.orderBy
_.trimLeft
& _.trimRight
改名为 _.trimStart
& _.trimEnd
_.trunc
改名为 _.truncate
拆分方法
从 _.indexOf
& _.lastIndexOf
拆分出 _.sortedIndexOf
& _.sortedLastIndexOf
从_.max
& _.min
拆分出 _.maxBy
& _.minBy
从 _.omit
& _.pick
拆分出 _.omitBy
& _.pickBy
从 _.sample
拆分出 _.sampleSize
从 _.sortedIndex
拆分出 _.sortedIndexBy
从_.sortedLastIndex
拆分出 _.sortedLastIndexBy
从 _.uniq
拆分出 _.sortedUniq
, _.sortedUniqBy
, & _.uniqBy
将 _.sortByAll
并入 _.sortBy
变动 _.at
的类别为 “Object”
变动 _.bindAll
的类别为 Utility
令 "By" 方法的迭代器只提供一个参数
令 _.capitalize
会转换第一个字符为大写 & 其余字符为小写
令 _.functions
返回自有方法的方法名名
令 _.words
默承认链式调用
_.clone
& _.flatten
移除 isDeep
参数
当未指定方法名时,移除_.bindAll
绑定全部方法的支持
_.before
& _.after
移除 func
-第一个参数前面
_.debounce
, _.mixin
, & _.throttle
移除布尔值 options
参数支持
_.orderBy
移除布尔值 orders
参数的支持
令 _.max
, _.min
, & _.sum
只支持数组
_.template
移除传统 options
参数签名
简化 _.escapeRegExp
,以向已中止的 ES7 提案对齐
4 kB (gzipped) core build (65 个方法; Backbone v1.2.4 compatible)_.assignIn
, _.before
, _.bind
, _.chain
, _.clone
, _.compact
, _.concat
,
_.create
, _.defaults
, _.defer
, _.delay
, _.each
, _.escape
, _.every
,_.filter
, _.find
, _.first
, _.flatten
, _.flattenDeep
, _.forEach
,_.has
, _.head
, _.identity
, _.indexOf
, _.invokeMap
, _.isArguments
,_.isArray
, _.isBoolean
, _.isDate
, _.isEmpty
, _.isEqual
, _.isFinite
,_.isFunction
, _.isNaN
, _.isNull
, _.isNumber
, _.isObject
, _.isRegExp
,_.isString
, _.isUndefined
, _.iteratee
, _.keys
, _.last
, _.map
,_.max
, _.min
, _.mixin
, _.negate
, _.noConflict
, _.noop
, _.now
,_.once
, _.pick
, _.reduce
, _.result
, _.size
, _.slice
, _.some
,_.sortBy
, _.tap
, _.thru
, _.toArray
, _.uniqueId
, _.value
, & _.values
新增 80 个方法
23 个 array 方法:
_.concat, _.differenceBy, _.differenceWith, _.flatMap, _.fromPairs, _.intersectionBy,
_.intersectionWith, _.join, _.pullAll, _.pullAllBy, _.reverse, _.sortedIndexBy, _.sortedIndexOf,
_.sortedLastIndexBy, _.sortedLastIndexOf, _.sortedUniq, _.sortedUniqBy, _.unionBy,
_.unionWith, _.uniqBy, _.uniqWith, _.xorBy, & _.xorWith
18 个 lang 方法:
_.cloneDeepWith, _.cloneWith, _.eq, _.isArrayLike, _.isArrayLikeObject, _.isEqualWith, _.isInteger,
_.isLength, _.isMatchWith, _.isNil, _.isObjectLike, _.isSafeInteger, _.isSymbol, _.toInteger,
_.toLength, _.toNumber, _.toSafeInteger, & _.toString
13 个object :
_.assignIn, _.assignInWith, _.assignWith, _.functionsIn, _.hasIn, _.invoke, _.mergeWith,
_.omitBy, _.pickBy, _.setWith, _.toPairs, _.toPairsIn, & _.unset
8 个 string 方法:
_.lowerCase, _.lowerFirst, _.replace, _.split, _.upperCase, _.upperFirst, _.toLower, & _.toUpper
8 个 utility 方法:
_.cond, _.conforms, _.nthArg, _.over, _.overEvery, _.overSome, _.rangeRight, & _.toPath
2 个 number 方法:
_.clamp & _.subtract
1 个 chain 方法:
_#next
1 个 collection 方法:
_.sampleSize
添加 3 别名
_.extend
做为 _.assignIn
的别名
_.extendWith
做为 _.assignInWith
的别名
_.first
做为 _.head
的别名
移除 17 个别名_.all
, _.any
, _.backflow
, _.callback
, _.collect
, _.compose
, _.contains
,
_.detect
, _.foldl
, _.foldr
, _.include
, _.inject
, _.methods
, _.object
,_.#run
, _.select
, & _.unique
性能优化
开启 _.at
, _.find
& _.findLast
的快速合并机制
优化匹配方法,避免若是 object
和 source
相同时进行深度爬行
优化循环引用搜索
优化 _.isEqual
,避免当数组或对象拥有不一样长度时的堆栈爬行
支持 Emoji
Added support for astral symbols, combining diacritical marks, dingbats,
regional indicator symbols, unicode modifiers, variation selectors, &
zero-width-joiners to string methods
功能性改进
添加 _.cond, _.conforms, _.flip, _.nthArg, _.over, _.overEvery, _.overSome, & _.unary
将 lodash-fp
移动到 lodash
,使用 require('lodash/fp')
做为不可变 iteratee-first data-last 方法
为 _.memoize.Cache
添加 clear
方法
为防反跳函数和节流阀函数添加 flush
方法
_.clone
, _.isEqual
, & _.toArray
支持 ES6 映射、集合 & 标记
_.isEqual
支持数组缓存
_.toArray
支持转换迭代器
_.zipObject
支持深度路径
Changed UMD to export to window
or self
when available regardless of other exports
_.flow
& _.flowRight
如今能够接受一个函数数组
确保 “Collection” 方法能将函数视为对象
确保防反跳方法 cancel
可以清除 args
& thisArg
引用
确保 _.add
, _.subtract
, & _.sum
不会跳过 NaN
值
确保 _.assign
, _.defaults
, & _.merge
强制将 object
值转换为对象
确保使用 new
操做符调用时 _.bindKey
绑定的函数时调用 object[key]
确保 _.clone
可以将生成器视为函数
确保 _.clone
可以根据源对象的 [[Prototype]]
进行克隆
确保 _.defaults
可以根据 Object.prototype
分配属性
确保 _.defaultsDeep
不能将字符串并入数组
确保 _.defaultsDeep
& _.merge
不会修改源对象
确保 _.defaultsDeep
可以循环引用
确保 _.isFunction
对生成器函数可以返回 true
确保 _.keys
在 Safari 9 的严格模式下将跳过 "length" 属性
确保 _.merge
可以直接布置类型数组
确保 _.merge
不能将字符串转换为数组
确保 _.merge
可以将纯粹对象合并到非纯粹对象中
确保 _#plant
的克隆队列充值迭代器的数据
确保 _.random
min
大于 max
时交换 min
& max
确保 _.range
preserves the sign of start
of -0
确保 _.reduce
& _.reduceRight
在数组分支中使用 getIteratee
修正 _.floor
带 precision
参数时四舍五入的问题
使 _(...)
成为一个迭代器 & 可迭代的对象
使 _.drop
, _.take
, & 从右迭代的方法强制将 n
由 undefined
转换为 0