Os
The handful of operating-system facts worth a named helper — platform, architecture, release, home and temp directories. Each one guards on process being present and returns undefined off Node rather than throwing, so a shared module can call them without a runtime check. They are passthroughs, so you get exactly what Node reports ('darwin', not 'macOS'); for browser-side platform sniffing use system.
Example
import { getHomeDir, getOsPlatform, getTmpDir } from '@rtorcato/js-common/os'
// Off Node these return `undefined` instead of throwing, so a module shared with
// the browser can call them without a runtime guard.
const cacheDir = `${getHomeDir() ?? getTmpDir()}/.myapp`
getOsPlatform() // 'darwin' | 'linux' | 'win32' — Node's own strings, unmapped
Import
import { getHomeDir, getOsArch, getOsPlatform } from '@rtorcato/js-common/os'
Exports
| Name | Summary |
|---|---|
getHomeDir | Returns the user's home directory (Node.js only). |
getOsArch | Returns the OS architecture (Node.js only). |
getOsPlatform | Returns the current operating system platform (Node.js only). |
getOsRelease | Returns the OS release/version (Node.js only). |
getTmpDir | Returns the system's temporary directory (Node.js only). |