1
0
mirror of https://github.com/onkelbeh/cheatsheets.git synced 2025-10-15 15:08:27 +02:00
cheatsheets/nodejs-path.md
Rico Sta. Cruz 511de900ba
Formatting updates (#2133)
- Update some sheets which have very long sections
- Remove `layout: 2017/sheet` (everything has the same layout now)
- Remove outdated sheets
2024-04-03 18:30:24 +11:00

602 B

title, category, intro
title category intro
Node.js path API Node.js Quick reference to the [Node.js path API](https://nodejs.org/api/path.html).

Functions

const fs = require('fs')

fs.realpath('/etc/passwd', function (err, path) {
  path // => "/private/etc/passwd"
})
const path = require('path')
dir = path.join('etc', 'passwd')
dir = path.resolve('/etc', 'passwd', '..', 'var')
path.dirname('/etc/passwd') //      => "/etc"
path.basename('/etc/passwd') //     => "passwd"
path.basename('/etc/rc.d', '.d') // => "rc"

References