当前位置:网站首页>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 ls
command to view the current server address
星号*
代表当前服务器地址
把包发布到npm上
包使用 cd 文件夹名
Change to the package root directory
再运行npm publish
命令
边栏推荐
- 【8.2】代码源 - 【货币系统】【硬币】【新年的问题(数据加强版)】【三段式】
- iMedicalLIS监听程序(2)
- Acid (ACID) Base (BASE) Principles for Database Design
- [8.1] Code Source - [The Second Largest Number Sum] [Stone Game III] [Balanced Binary Tree]
- 银行数据采集,数据补录与指标管理3大问题如何解决?
- bytebuffer put flip compact clear 方法演示
- bytebuffer use demo
- 商业智能BI业务分析思维:现金流量风控分析(一)营运资金风险
- The first performance test practice, there are "100 million" a little nervous
- 测试薪资这么高?刚毕业就20K
猜你喜欢
Increasing leetcode - a daily topic 1403. The order of the boy sequence (greed)
多御安全浏览器 V10.8.3.1 版正式发布,优化多项内容
Defect detection (image processing part)
Mysql's redo log detailed explanation
数据库设计的酸(ACID)碱(BASE)原则
Swing有几种常用的事件处理方式?如何监听事件?
iMedicalLIS监听程序(2)
[MRCTF2020]PYWebsite
Android 面试题——如何徒手写一个非阻塞线程安全队列 ConcurrentLinkedQueue?
[TA-Frost Wolf_may-"Hundred Talents Project"] Graphics 4.3 Real-time Shadow Introduction
随机推荐
[SWPU2019]Web1
Slapped in the face: there are so many testers in a certain department of byte
How to solve complex distribution and ledger problems?
Four-digit display header design
Mysql的redo log详解
How to solve the three major problems of bank data collection, data supplementary recording and index management?
Ali's local life's single-quarter revenue is 10.6 billion, Da Wenyu's revenue is 7.2 billion, and Cainiao's revenue is 12.1 billion
MySql index learning and use; (I think it is detailed enough)
[MRCTF2020]PYWebsite
The most effective seven performance testing techniques of software testing techniques
[MRCTF2020] Ezpop (detailed)
Acid (ACID) Base (BASE) Principles for Database Design
UE4 opens door via interaction (keyboard key)
多御安全浏览器新版下载 | 功能优秀性能出众
flink reads mongodb data source
Qixi Festival code confession
UE4 通过与其它Actor互动开门
[BSidesCF 2019] Kookie
Paparazzi: Surface Editing by way of Multi-View Image Processing
Web3.0 Dapps - the road to the future financial world