当前位置:网站首页>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's redo log detailed explanation
- [Paper Notes] MapReduce: Simplified Data Processing on Large Clusters
- Mysql的redo log详解
- flink读取mongodb数据源
- bytebuffer internal structure
- DEJA_VU3D - Cesium功能集 之 058-高德地图纠偏
- Increasing leetcode - a daily topic 1403. The order of the boy sequence (greed)
- This year's Qixi Festival, "love vegetables" are more loving than gifts
- 数组常用方法总结
猜你喜欢

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

Use CH341A to program external Flash (W25Q16JV)

UE4 第一人称角色模板 添加生命值和调试伤害

Static method to get configuration file data

35岁的软件测试工程师,月薪不足2W,辞职又怕找不到工作,该何去何从?

public static
List asList(T... a) What is the prototype? 
bytebuffer 使用demo

UE4 opens doors with overlapping events
![[8.1] Code Source - [The Second Largest Number Sum] [Stone Game III] [Balanced Binary Tree]](/img/f3/0d92e22a424206241f4e1640f1bf6b.png)
[8.1] Code Source - [The Second Largest Number Sum] [Stone Game III] [Balanced Binary Tree]

UE4 为子弹蓝图添加声音和粒子效果
随机推荐
XMjs cross-domain problem solving
从企业的视角来看,数据中台到底意味着什么?
Four-digit display header design
iMedicalLIS监听程序(2)
UE4 在游戏运行时更改变量 (通过鼠标滑轮来更改第一人称角色的最大行走速度)
[MRCTF2020] PYWebsite
What is the difference between SAP ERP and ORACLE ERP?
阿里本地生活单季营收106亿,大文娱营收72亿,菜鸟营收121亿
[MRCTF2020]PYWebsite
DNS被劫持如何处理?
The sword refers to Offer--find the repeated numbers in the array (three solutions)
数据库设计的酸(ACID)碱(BASE)原则
如何解决复杂的分销分账问题?
【8.4】代码源 - 【数学】【历法】【删库】【不朴素的数列(Bonus)】
1007 Climb Stairs (greedy | C thinking)
There are several common event handling methods in Swing?How to listen for events?
【Mysql进阶优化篇02】索引失效的10种情况及原理
[MRCTF2020]Ezpop(详解)
Walter talked little knowledge | "remote passthrough" that something
[8.2] Code Source - [Currency System] [Coins] [New Year's Questions (Data Enhanced Edition)] [Three Stages]