当前位置:网站首页>[node] common methods of path module
[node] common methods of path module
2022-06-12 00:13:00 【FunctionKang】
path The module provides a series of methods to operate on the path ,path The return result of all methods of the module is a path string
- join
String concatenation , Generate new path
join The input parameters of the method are several strings ,join Method will use all stringsconst path = require("path"); const p = path.join("user", "file", "01.js"); // user\file\01.js\The backslashes are spliced together to create a new path - node Constant ( Commonly used for path operations )
- __dirname
The absolute path of the folder where the current file is located - __filename
Absolute path to the current file
- __dirname
- resolve
Convert parameters to absolute paths , Splice based on the absolute path of the folder where the current file is located
The above two cases will be spliced backward based on the absolute path of the folder where the current file is located , Generate new pathpath.resolve("file"); path.resolve("./file"); // example :F:\aaa\...\bbb\file
Withpath.resolve("/file"); // example :F:\file/The slash will start with the drive letter of the current file
There are many. , But it's not just arguments that start with slashes , Starting from the drive letter, the last parameter starting with a slash to all the last parameters are spliced in turnpath.resolve("a", "c", "b", "d", "e"); // F:\d\e path.resolve("/a", "/c", "b", "/d", "e"); // F:\file\...\a\c\b\d\e - parse
Parsing path , Parse the path string into a routing objectpath.parse("F:/aaa/bbb/ccc/path.js"); /* { root: 'F:/', dir: 'F:/aaa/bbb/ccc', base: 'path.js', ext: '.js', name: 'path' } */attribute describe root Drive letter of directory dir Absolute path base The full name of the file to which the path points ( Include file suffixes ) ext file type , If it's a folder , Is an empty string name File name
边栏推荐
- ironSource  New functions are released, and developers can adjust advertising strategies in real time in the same session
- Cube technology interpretation | detailed explanation of cube applet Technology
- (linear DP | monotone queue) acwing 895 Longest ascending subsequence
- Class. Getresource() and class Getresourceasstream() method
- 926. Flip String to Monotone Increasing
- Pre resolution and scope
- (simple statistics) acwing 3404 Who are your potential friends
- How many steps does it take for C language to become Fibonacci number
- 【JUC系列】Executor框架之概览
- EFCore中数据表的两种配置方式
猜你喜欢
![[day 7 of JUC learning] reentrantlock and reentrantreadwritelock](/img/44/0ba7f06287734179ee66b8f4990910.png)
[day 7 of JUC learning] reentrantlock and reentrantreadwritelock

Dry goods | what do testers need to do for a complete performance test?

Point cloud library PCL from introduction to mastery learning records Chapter 8

Mingdeyang FPGA development board xilinx-k7 core board kinex7k325 410t industrial grade

DPT-FSNET: DUAL-PATH TRANSFORMER BASED FULL-BAND AND SUB-BAND FUSION NETWORK FOR SPEECH ENHANCEMENT

(greedy + longest ascending subsequence) acwing 896 Longest ascending subsequence II

The road of global evolution of vivo global mall -- multilingual solution

【JUC系列】Executor框架之概览
![[JUC series] overview of executor framework](/img/e3/5131dcdd255c1571e64ae1f0459113.png)
[JUC series] overview of executor framework

图及图的遍历
随机推荐
SF14 | supertrend "super trend" indicator magic change and upgrade (source code)
Jenkins基本配置
(digital statistics dp+good) acwing 338 Counting problem
Microservice automation
11. conditional statement if, switch
On the knowledge points of cookie attributes and the differences between webstorage and cookies?
Design a MySQL table for message queue to store message data
How to cancel smart table style in WPS table
Custom JSP tag - > concept - > lifecycle
[flume] notes
926. Flip String to Monotone Increasing
【juc学习之路第5天】引用原子类和属性修改器
[day 6 of JUC learning] concurrent calculator and thread random factor
DPT-FSNET: DUAL-PATH TRANSFORMER BASED FULL-BAND AND SUB-BAND FUSION NETWORK FOR SPEECH ENHANCEMENT
使用 select 切换协程
How to change the font size of Apple phone WPS
(dp+ group backpack) acwing 9 Group knapsack problem
统一认证中心 Oauth2 高可用坑
[tense] 1. General present tense 2. Do not translate Chinese
愉快无负担的跨进程通信方式