当前位置:网站首页>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命令
边栏推荐
- Redis key basic commands
- 2022.8.4-----leetcode.1403
- bytebuffer internal structure
- 炎炎夏日教你利用小米智能家居配件+树莓派4接入Apple HomeKit
- UE4 更改组件变量 (以修改第一人称角色模板的最大行走速度和跳跃高度为例)
- [BSidesCF 2019] Kookie
- 【8.1】代码源 - 【第二大数字和】【石子游戏 III】【平衡二叉树】
- Paparazzi: Surface Editing by way of Multi-View Image Processing
- [8.1] Code Source - [The Second Largest Number Sum] [Stone Game III] [Balanced Binary Tree]
- [MRCTF2020]PYWebsite
猜你喜欢
随机推荐
新人如何入门和学习软件测试?
Fifteen. Actual combat - MySQL database building table character set and collation
iMedicalLIS监听程序(2)
Slapped in the face: there are so many testers in a certain department of byte
四位数显表头设计
No regrets, the appium automation environment is perfectly built
Bosses, I noticed that a mysql CDC connector parameters scan. The incremental. Sna
炎炎夏日教你利用小米智能家居配件+树莓派4接入Apple HomeKit
多御安全浏览器 V10.8.3.1 版正式发布,优化多项内容
[Paper Notes] MapReduce: Simplified Data Processing on Large Clusters
Getting Started with Kubernetes Networking
第一次性能测试实践,有“亿”点点紧张
UI自动化测试 App的WebView页面中,当搜索栏无搜索按钮时处理方法
阿里本地生活单季营收106亿,大文娱营收72亿,菜鸟营收121亿
不看后悔,appium自动化环境完美搭建
token、jwt、oauth2、session解析
The sword refers to Offer--find the repeated numbers in the array (three solutions)
flink reads mongodb data source
UE4 opens door via interaction (keyboard key)
[MRCTF2020] PYWebsite






![[BJDCTF2020] EasySearch](/img/60/464de3bcdda876171b9f61ad31bff1.png)

