当前位置:网站首页>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命令
边栏推荐
- UE4 更改组件变量 (以修改第一人称角色模板的最大行走速度和跳跃高度为例)
- Haproxy搭建Web群集
- Index Mysql in order to optimize paper 02 】 【 10 kinds of circumstances and the principle of failure
- Paparazzi: Surface Editing by way of Multi-View Image Processing
- [极客大挑战 2019]FinalSQL
- [BJDCTF2020] EasySearch
- Getting Started with Kubernetes Networking
- Android 面试题——如何徒手写一个非阻塞线程安全队列 ConcurrentLinkedQueue?
- Mysql的redo log详解
- The most effective seven performance testing techniques of software testing techniques
猜你喜欢

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

Developing Hololens encountered The type or namespace name 'HandMeshVertex' could not be found..
![[SWPU2019]Web1](/img/06/36e69a2d7d5475a6749a7d81edf50f.png)
[SWPU2019]Web1

token、jwt、oauth2、session解析

There are several common event handling methods in Swing?How to listen for events?

creo怎么测量点到面的距离

Solana NFT开发指南
![[极客大挑战 2019]FinalSQL](/img/e4/0c8225ef7c5e7e5bdbaac2ef6fc867.png)
[极客大挑战 2019]FinalSQL

10 years of testing experience, worthless in the face of the biological age of 35

JeeSite新建报表
随机推荐
第一次性能测试实践,有“亿”点点紧张
【8.2】代码源 - 【货币系统】【硬币】【新年的问题(数据加强版)】【三段式】
【Mysql进阶优化篇02】索引失效的10种情况及原理
1007 Climb Stairs (贪心 | C思维)
2022.8.4-----leetcode.1403
Hard power or soft power, which is more important to testers?
Industry Status?Why do Internet companies prefer to spend 20k to recruit people rather than raise their salary to retain old employees~
Initial solution of the structure
36-Jenkins-Job Migration
重载运算符
[CISCN2019 华东南赛区]Web11
Fifteen. Actual combat - MySQL database building table character set and collation
Spark Basics [Introduction, Getting Started with WordCount Cases]
What is the function of industrial-grade remote wireless transmission device?
UE4 第一人称角色模板 添加蹲伏功能
概率论的学习和整理8: 几何分布和超几何分布
将故事写成我们
SkiaSharp 之 WPF 自绘 粒子花园(案例版)
Getting Started with Kubernetes Networking
Mysql的undo log详解