当前位置:网站首页>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命令
边栏推荐
- Mysql的redo log详解
- bytebuffer internal structure
- 程序开发的一些常规套路(一)
- [MRCTF2020]Ezpop(详解)
- DEJA_VU3D - Cesium功能集 之 056-智图Arcgis地图纠偏
- How to find all fields with empty data in sql
- There are several common event handling methods in Swing?How to listen for events?
- 工业级远距离无线传输装置的功能有哪些?
- bytebuffer put flip compact clear 方法演示
- overloaded operator
猜你喜欢

UE4 opens door via interaction (keyboard key)

Qixi Festival code confession

测试薪资这么高?刚毕业就20K

【8.1】代码源 - 【第二大数字和】【石子游戏 III】【平衡二叉树】

Web3.0 Dapps - the road to the future financial world

UE4 第一人称角色模板 添加蹲伏功能

36-Jenkins-Job Migration
![[SWPU2019]Web1](/img/06/36e69a2d7d5475a6749a7d81edf50f.png)
[SWPU2019]Web1

MySql的索引学习和使用;(本人觉得足够详细)

What is the function of industrial-grade remote wireless transmission device?
随机推荐
What is the difference between SAP ERP and ORACLE ERP?
银行数据采集,数据补录与指标管理3大问题如何解决?
从企业的视角来看,数据中台到底意味着什么?
2022.8.4-----leetcode.1403
四位数显表头设计
MySql的索引学习和使用;(本人觉得足够详细)
工业级远距离无线传输装置的功能有哪些?
Bytebuffer put flip compact clear method demonstration
【8.1】代码源 - 【第二大数字和】【石子游戏 III】【平衡二叉树】
pyqt5 + socket 实现客户端A经socket服务器中转后主动向客户端B发送文件
flink读取mongodb数据源
[Geek Challenge 2019]FinalSQL
Slapped in the face: there are so many testers in a certain department of byte
905. Interval selection
The sword refers to Offer--find the repeated numbers in the array (three solutions)
将故事写成我们
【背包九讲——01背包问题】
DNS被劫持如何处理?
UE4 更改组件变量 (以修改第一人称角色模板的最大行走速度和跳跃高度为例)
Fifteen. Actual combat - MySQL database building table character set and collation