1 . 每个包文件夹应该包含的内容:
package.json文件,里面记录包的相关信息
- 入口文件 index.js (require时要加载的文件)
- README.md 文档
2 . 根据实现要求,在 index.js 中定义相关方法
2 . 1 转义 HTML 的方法
function htmlEscape(htmlStr){
return htmlStr.replace(/<|>|"|&/g , (match)=> {
switch(match){
case '<':
return '<'
case '>':
return '>'
case '"':
return '"'
case '&':
return '&'
}
})
}
3 . 将不同的功能进行模块化拆分
最后 ,写 README.md 文档