当前位置:网站首页>Develop your own node package
Develop your own node package
2022-08-05 04:11:00 【quite a bit】
开发属于自己的包


转译htmlA package of character functions:
htmlEscape(自定义方法 暴露出来 然后require引入,The escape is specifically defined belowhtml方法的过程)
还原htmlfunction of special characters
htmlUnEscape(自定义方法 暴露出来 然后require引入,The escape is specifically defined belowhtml方法的过程)
注:
Need to customize one with 格式化时间,转译html特殊字符(htmlEscape) 及 还原html特殊字符(htmlUnEscape) 这3个功能的 自定义包(自定义模块)
初始化包的基本结构

初始化package.json
注:
Package names are unique的,不能重复,是package.json文件中的name属性来决定的(Not the name of the project folder, etc)
注:
So when it comes to naming packages,最好先去npmjs官网上搜索一下
注:
上方node中提到的nodeThe official website isnpmjs官网(npmjs.com),写错了
main:入口文件descriprion:描述信息license:Kaiyuan License Agreement,默认ISCkeywords:数组,The search key is in the array
在index.js中定义 格式化时间 的方法
dateFormat

或者
date.format
// Node.js program to demonstrate the
// Date.format() method
// Importing module
const date = require('date-and-time')
// Creating object of current date and time
// by using Date()
const now = new Date();
// Formating the date and time
// by using date.format() method
const value = date.format(now,'YYYY/MM/DD HH:mm:ss');
// Display the result
console.log("current date and time:" + value)
使用以下命令运行index.js文件:
node index.js
输出:
current date and time:2021/03/07 12:13:46
在index.js中定义转义html的方法

在index.js中定义还原html方法


将不同的功能进行模块化拆分


编写包的说明文档
6项内容
书写格式:
发布包
1.注册npm账号
2.登陆npm账号
注:
Login here is notnpmLogin on the website,而是终端运行npm login命令
注:
运行npm login命令时,下包服务器的地址一定要切换为npm官方地址,否则会导致发布包失败
It is recommended to use it firstnrm lscommand to view the current server address
星号*代表当前服务器地址
把包发布到npm上
包使用 cd 文件夹名 Change to the package root directory
再运行npm publish命令
边栏推荐
- token、jwt、oauth2、session解析
- Ffmpeg - sources analysis
- [8.2] Code Source - [Currency System] [Coins] [New Year's Questions (Data Enhanced Edition)] [Three Stages]
- UE4 后期处理体积 (角色受到伤害场景颜色变淡案例)
- 日志导致线程Block的这些坑,你不得不防
- pyqt5 + socket 实现客户端A经socket服务器中转后主动向客户端B发送文件
- 不看后悔,appium自动化环境完美搭建
- 2022.8.4-----leetcode.1403
- Hard power or soft power, which is more important to testers?
- 概率论的学习和整理8: 几何分布和超几何分布
猜你喜欢

bytebuffer 内部结构

How to solve complex distribution and ledger problems?

Learning and finishing of probability theory 8: Geometric and hypergeometric distributions

Spark基础【介绍、入门WordCount案例】

Industry Status?Why do Internet companies prefer to spend 20k to recruit people rather than raise their salary to retain old employees~

UE4 为子弹蓝图添加声音和粒子效果

UI自动化测试 App的WebView页面中,当搜索栏无搜索按钮时处理方法

【8.4】代码源 - 【数学】【历法】【删库】【不朴素的数列(Bonus)】

Walter talked little knowledge | "remote passthrough" that something

What is the function of industrial-grade remote wireless transmission device?
随机推荐
UE4 后期处理体积 (角色受到伤害场景颜色变淡案例)
DEJA_VU3D - Cesium功能集 之 058-高德地图纠偏
多御安全浏览器新版下载 | 功能优秀性能出众
Web3.0 Dapps - the road to the future financial world
Slapped in the face: there are so many testers in a certain department of byte
Mathematics - Properties of Summation Symbols
Spark Basics [Introduction, Getting Started with WordCount Cases]
UE4 通过互动(键盘按键)开门
工业级远距离无线传输装置的功能有哪些?
Spark基础【介绍、入门WordCount案例】
DEJA_VU3D - Cesium功能集 之 057-百度地图纠偏
Qixi Festival code confession
35岁的软件测试工程师,月薪不足2W,辞职又怕找不到工作,该何去何从?
GC Gaode coordinate and Baidu coordinate conversion
token、jwt、oauth2、session解析
Walter talked little knowledge | "remote passthrough" that something
第一次性能测试实践,有“亿”点点紧张
Defect detection (image processing part)
从企业的视角来看,数据中台到底意味着什么?
DNS被劫持如何处理?