Lodash 4.0.0 更新文档

Lodash 4.0 版本更新包括移除 Bower 和 Component 支持,不再兼容 IE6-8,引入新的方法如 .maxBy 和 .minBy,废弃 .pluck 和 .where 等旧方法,并进行了一系列的功能改进与性能优化。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

兼容性警告

  • 专注于 npm,移除 Bower & Component 包支持
  • 放弃对 IE 6-8 的支持
    – Use es5-shim, & optionally es6-shim, to enable support
    – 可以使用 es5-shim, & optionally es6-shim, 以继续开启支持
  • .forEach, .forIn, .forOwn, & .times 隐式结束链式调用队列
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 & .minBy
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 }
  • 移除方法
    1. 移除 _.support
    2. 移除 .findWhere,使用 .find 迭代器简写代替
    3. 移除 .where,使用 .filter 迭代器简写代替
    4. 移除 _.pluck,使用 _map 迭代器简写代替
  • 方法名变更
    1. .first 更名为 .head
    2. .indexBy 更名为 .keyBy
    3. .invoke 更名为 .invokeMap
    4. .modArgs 更名为 .overArgs
    5. .padLeft & .padRight 更名为 padStart & .padEnd
    6. .pairs 更名为 .toPairs
    7. .rest 更名为 .tail
    8. .restParam 更名为 .rest
    9. .sortByOrder 更名为 .orderBy
    10. .trimLeft & .trimRight 更名为 .trimStart & .trimEnd
    11. .trunc 更名为 .truncate
  • 拆分方法
    1. .indexOf & .lastIndexOf 拆分出 .sortedIndexOf & .sortedLastIndexOf
    2. .max & .min 拆分出 .maxBy & .minBy
    3. .omit & .pick 拆分出 .omitBy & .pickBy
    4. .sample 拆分出 .sampleSize
    5. .sortedIndex 拆分出 .sortedIndexBy
    6. .sortedLastIndex 拆分出 .sortedLastIndexBy
    7. .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
- 4 个 math 方法:

.maxBy, .mean, .minBy, & .sumBy
- 2 个 function 方法:

.flip & .unary
- 2 个 number 方法:

.clamp & .subtract
- 1 个 chain 方法:

_#next
- 1 个 collection 方法:

_.sampleSize
- 添加 3 别名
1. .extend 作为 .assignIn 的别名
2. .extendWith 作为 .assignInWith 的别名
3. .first 作为 .head 的别名
- 移除 17 个别名

.all, .any, .backflow, .callback, .collect, .compose, _.contains,
.detect, .foldl, .foldr, .include, .inject, .methods, _.object,
.#run, .select, & _.unique

  • 性能优化
    1. 开启 .at, .find & _.findLast 的快速合并机制
    2. 优化匹配方法,避免如果 object 和 source 相同时进行深度爬行
    3. 优化循环引用搜索
    4. 优化 _.isEqual,避免当数组或对象拥有不同长度时的堆栈爬行
  • 支持 Emoji
    1. Added support for astral symbols, combining diacritical marks, dingbats,
      regional indicator symbols, unicode modifiers, variation selectors, &
      zero-width-joiners to string methods
  • 功能性改进
    1. 添加 .cond, .conforms, .flip, .nthArg, .over, .overEvery, .overSome, & .unary
    2. 将 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
{ "name": "vue-antd-jeecg", "version": "3.4.3", "private": true, "scripts": { "pre": "cnpm install || yarn --registry https://registry.npm.taobao.org || npm install --registry https://registry.npm.taobao.org ", "serve": "vue-cli-service serve", "build:test": "vue-cli-service build --mode test", "build": "vue-cli-service build", "lint": "vue-cli-service lint" }, "dependencies": { "@jeecg/antd-online-mini": "3.4.3-beta2", "ant-design-vue": "^1.7.2", "@antv/data-set": "^0.11.4", "viser-vue": "^2.4.8", "axios": "^0.18.0", "dayjs": "^1.8.0", "enquire.js": "^2.1.6", "js-cookie": "^2.2.0", "lodash.get": "^4.4.2", "lodash.pick": "^4.4.0", "md5": "^2.2.1", "nprogress": "^0.2.0", "vue": "^2.6.10", "vue-cropper": "^0.5.4", "vue-i18n": "^8.7.0", "vue-loader": "^15.7.0", "vue-ls": "^3.2.0", "vue-router": "^3.0.1", "vuex": "^3.1.0", "vue-print-nb-jeecg": "^1.0.12", "clipboard": "^2.0.4", "vue-photo-preview": "^1.1.3", "vue-splitpane": "^1.0.4", "vuedraggable": "^2.20.0", "codemirror": "^5.46.0", "@tinymce/tinymce-vue": "2.1.0", "tinymce": "5.4.1", "@toast-ui/editor": "^2.1.2", "vue-area-linkage": "^5.1.0", "china-area-data": "^5.0.1", "dom-align": "1.12.0", "xe-utils": "2.4.8", "vxe-table": "2.9.13", "vxe-table-plugin-antd": "1.8.10", "cron-parser": "^2.10.0", "qiankun": "^2.5.1", "xss": "^1.0.13" }, "devDependencies": { "@babel/polyfill": "^7.2.5", "@vue/cli-plugin-babel": "^3.3.0", "@vue/cli-plugin-eslint": "^3.3.0", "@vue/cli-service": "^3.3.0", "@vue/eslint-config-standard": "^4.0.0", "babel-eslint": "7.2.3", "eslint": "^5.16.0", "eslint-plugin-vue": "^5.1.0", "less": "^3.9.0", "less-loader": "^4.1.0", "vue-template-compiler": "^2.6.10", "html-webpack-plugin": "^4.2.0", "compression-webpack-plugin": "^3.1.0" }, "eslintConfig": { "root"
最新发布
03-31
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

卡搜偶

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值