Last active
June 25, 2019 05:11
-
-
Save gotraveltoworld/3b203a6593002118cce95cd8f5848202 to your computer and use it in GitHub Desktop.
To memo the NodeJS's path library(include syntax and functions).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Nodejs's Path built-in library. | |
let path = require('path'); | |
// Get dir's path. | |
let dirPath = path.dirname('/xx/yy/zz.js'); | |
console.log('dirPath', dirPath); | |
// Get join's path. | |
let joinPath = path.join(__dirname, '/xx'); | |
console.log('joinPath', joinPath); | |
// Get basename's path. | |
let basenamePath = path.basename('/xx/yy/zz.js'); | |
console.log('basenamePath', basenamePath); | |
// Get extname's path. | |
let extnamePath = path.extname('/xx/yy/zz.js'); | |
console.log('extnamePath', extnamePath); | |
// Get path's object. | |
let objPath = path.parse('/xx/yy/zz.js'); | |
console.log('objPath', objPath); | |
// objPath { root: '/', dir: '/xx/yy', base: 'zz.js', ext: '.js', name: 'zz' } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment