1、omit.js的源码分析
1.1 omit.js用于删除对象中某个或某几个属性,返回值为删除属性后的对象
(且不会改变数据简单的源对象)
function omit(obj, fields) {
const shallowCopy = Object.assign({}, obj);
for (let i = 0; i < fields.length; i += 1) {
const key = fields[i];
delete shallowCopy[key];
}
return shallowCopy;
}
1.2 测试数据

2、单元测试
2.1 单元测试代码

2.2 单元测试不通过的报错和纠正

3、package.json解析
{
"name": "omit.js",
"version": "2.0.2",
"description": "Utility function to create a shallow copy of an object which had dropped some fields.",
"main": "lib/index.js",
"module": "es/index.js",
"types": "index.d.ts",
"files": [
"lib",
"es",
"dist",
"index.d.ts"
],
"scripts": {
"start": "father doc dev --storybook",
"build": "father doc build --storybook",
"compile": "father build",
"gh-pages": "father doc deploy",
"prepublishOnly": "npm run compile && np --yolo --no-publish",
"lint": "eslint .",
"test": "father test",
"coverage": "father test --coverage"
},
"repository": {
"type": "git",
"url": "git+https://github.com/benjycui/omit.js.git"
},
"keywords": [
"object",
"omit"
],
"author": "Benjy Cui<benjytrys@gmail.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/benjycui/omit.js/issues"
},
"homepage": "https://github.com/benjycui/omit.js#readme",
"devDependencies": {
"@umijs/fabric": "^2.2.2",
"assert": "^1.4.1",
"eslint": "^7.4.0",
"father": "^2.29.5",
"np": "^6.3.1",
"rc-tools": "^6.3.3"
}
}
4、总结
4.1 第一次接触并去浅了解单元测试,知道了assert断言测试
4.2 重温vscode代码调试功能,并进行了代码的调试
4.3 搜索了解npm发布包的流程和package.json文件方法内容的解析
4.4 了解[umijs/father](https:
5、感悟
我的学习一直间间断断的,看到优秀的小伙伴每天都在进步的时候,便想开始。
开始了,便想做好(查询文章中延伸出来的-我不知道或者不了解的知识点)。
做好了,这次学习就完成了。完成了,便会感觉充实。充实了,便会更快乐一下。每天都要开心一点噢(*^▽^*)