@hyperfrontend/project-scope/coreCore Module
The core module provides foundational utilities for file system operations, path manipulation, logging, caching, error handling, and pattern matching. These utilities are used throughout the library and are also available for consumers.
Capabilities
File System (fs/)
Safe, typed file system operations with comprehensive error handling.
import {
readFileContent,
readJsonFile,
writeFileContent,
writeJsonFile,
readDirectory,
readDirectoryRecursive,
exists,
isFile,
isDirectory,
ensureDir,
} from '@hyperfrontend/project-scope'
// Read files
const content = readFileContent('./package.json')
const config = readJsonFile<Config>('./config.json', { default: {} })
// Write files (creates directories automatically)
writeFileContent('./output/data.txt', 'Hello, World!')
writeJsonFile('./output/config.json', { port: 3000 })
// Directory operations
const entries = readDirectory('./src')
const allFiles = readDirectoryRecursive('./src', { maxDepth: 5 })
// Stat operations
if (exists('./config.json') && isFile('./config.json')) {
// Process file
}
Key Functions
| Function | Description |
|---|---|
readFileContent |
Read file as string with encoding support |
readFileBuffer |
Read file as Buffer |
readFileIfExists |
Read file or return null |
readJsonFile |
Parse JSON file with type inference |
readJsonFileIfExists |
Parse JSON file or return null |
writeFileContent |
Write string to file |
writeFileBuffer |
Write Buffer to file |
writeJsonFile |
Serialize and write JSON |
ensureDir |
Create directory recursively |
readDirectory |
List directory contents |
readDirectoryRecursive |
List contents recursively |
exists |
Check if path exists |
isFile |
Check if path is a file |
isDirectory |
Check if path is a directory |
isSymlink |
Check if path is a symlink |
getFileStat |
Get detailed file statistics |
Path Utilities (path/)
Cross-platform path manipulation utilities.
import {
normalizePath,
joinPath,
resolvePath,
relativePath,
isAbsolute,
getDirname,
getBasename,
getExtension,
} from '@hyperfrontend/project-scope'
const normalized = normalizePath('./src/../lib/index.ts') // 'lib/index.ts'
const joined = joinPath('src', 'utils', 'helper.ts') // 'src/utils/helper.ts'
Encoding (encoding/)
Utilities for detecting and converting file encodings.
import { detectEncoding, convertEncoding } from '@hyperfrontend/project-scope'
const encoding = detectEncoding(buffer)
const utf8Content = convertEncoding(buffer, 'utf-8')
Platform Detection (platform/)
Detect operating system and normalize platform-specific behaviors.
import { detectPlatform, isWindows, isMacOS, isLinux, normalizeLineEndings } from '@hyperfrontend/project-scope'
const platform = detectPlatform() // 'windows' | 'macos' | 'linux'
const normalizedContent = normalizeLineEndings(content, 'lf')
Logger (logger.ts)
Scoped logging with automatic secret sanitization.
import { createScopedLogger, setGlobalLogLevel } from '@hyperfrontend/project-scope'
// Create a scoped logger
const logger = createScopedLogger('my-module')
// Log messages with optional metadata
logger.info('Starting process', { path: './project' })
logger.debug('Config loaded', { apiKey: 'secret123' }) // apiKey is auto-redacted
// Set global log level
setGlobalLogLevel('debug') // 'error' | 'warn' | 'log' | 'info' | 'debug'
Cache (cache.ts)
In-memory cache with TTL and size limits.
import { createCache, clearAllCaches } from '@hyperfrontend/project-scope'
// Create cache with TTL
const cache = createCache<string, Object>({ ttl: 60000 }) // 60 second TTL
// Create cache with size limit
const lruCache = createCache<string, Object>({ maxSize: 100 })
// Combined options
const configCache = createCache<string, Config>({ ttl: 30000, maxSize: 50 })
cache.set('key', { data: 'value' })
const value = cache.get('key')
// Clear all registered caches
clearAllCaches()
Structured Errors (errors/)
Create errors with machine-readable codes and context.
import {
createStructuredError,
createConfigError,
createFsError,
createParseError,
createValidationError,
} from '@hyperfrontend/project-scope'
throw createStructuredError('Config not found', 'CONFIG_NOT_FOUND', {
path: './config.json',
searched: ['./config.json', './settings.json'],
})
// Specialized error factories
throw createFsError('File not found', 'ENOENT', { path: './missing.txt' })
throw createParseError('Invalid JSON', 'PARSE_ERROR', { line: 10, column: 5 })
Glob Pattern Matching (patterns/)
Safe glob matching without regex (ReDoS-protected).
import { matchGlobPattern } from '@hyperfrontend/project-scope'
matchGlobPattern('src/utils/helper.ts', '**/*.ts') // true
matchGlobPattern('test.spec.ts', '*.spec.ts') // true
matchGlobPattern('config.json', '*.{json,yaml}') // true
matchGlobPattern('src/index.ts', 'src/*.ts') // true
Supported Patterns
| Pattern | Description |
|---|---|
* |
Match any characters except / |
** |
Match any characters including / |
? |
Match exactly one character |
{a,b,c} |
Match any alternative |
Design Principles
- Safe by default: All operations handle errors gracefully with typed error objects
- No side effects: Functions are pure where possible
- ReDoS protection: Glob matching uses character iteration instead of regex
- Secret sanitization: Logging automatically redacts sensitive values
- Cross-platform: Path operations normalize across Windows/Unix
API Reference
ƒ Functions
Parameters
| Name | Type | Description |
|---|---|---|
§content | string | String to add BOM to |
Returns
stringExample
Adding UTF-8 BOM to content
const content = 'Hello World'
const withBom = addBom(content)
// => '\ufeffHello World'Parameters
Returns
stringExample
Converting file buffer to string with auto-detection
const fileBuffer = readFileSync('./config.json')
const content = bufferToString(fileBuffer)
// => '{"key": "value"}'Useful for testing or when a global state reset is needed. This clears all caches created via
createCache().Example
Clearing caches in tests
// In tests
afterEach(() => {
clearAllCaches()
})The cache provides a simple key-value store with:
- Optional TTL (time-to-live) for automatic expiration
- Optional maxSize for limiting cache size with FIFO eviction
- Lazy expiration (entries are checked on access)
Parameters
| Name | Type | Description |
|---|---|---|
§options? | CacheOptions | Cache configuration options |
Returns
Cache<K, V>Example
Creating caches with different options
// Basic cache
const cache = createCache<string, number>()
cache.set('answer', 42)
cache.get('answer') // 42
// Cache with TTL (expires after 60 seconds)
const ttlCache = createCache<string, object>({ ttl: 60000 })
// Cache with max size (evicts oldest when full)
const lruCache = createCache<string, object>({ maxSize: 100 })
// Combined options
const configCache = createCache<string, object>({
ttl: 30000,
maxSize: 50
})createConfigError(message: string, code: string, context?: Record<string, unknown>): StructuredError
Parameters
Returns
StructuredErrorExample
Creating a configuration error
throw createConfigError(
'Invalid port number',
'CONFIG_INVALID_PORT',
{ configFile: './app.config.json', value: -1 }
)Parameters
Example
Creating directories
// Create nested directories
createDirectory('./output/reports/2024')
// Create single directory without parents
createDirectory('./logs', { recursive: false })createFileSystemError(message: string, code: FileSystemErrorCode, context: FileSystemErrorContext): Error
Parameters
Returns
ErrorExample
Creating a file system error
throw createFileSystemError(
'Cannot read file',
'FS_READ_ERROR',
{ path: './missing.txt', operation: 'read' }
)createFsError(message: string, code: string, context?: Record<string, unknown>): StructuredError
Parameters
Returns
StructuredErrorExample
Creating a filesystem error
throw createFsError(
'Configuration file not found',
'ENOENT',
{ path: './missing.json', operation: 'read' }
)createParseError(message: string, code: string, context?: Record<string, unknown>): StructuredError
Parameters
Returns
StructuredErrorExample
Creating a parse error
throw createParseError(
'Invalid JSON syntax',
'JSON_PARSE_ERROR',
{ file: './config.json', line: 42, column: 15 }
)Parameters
Returns
ScopedLoggerExample
Creating a scoped logger
const logger = createScopedLogger('project-scope')
logger.setLogLevel('debug')
// Basic logging
logger.info('Starting analysis', { path: './project' })
// Sensitive data is automatically redacted
logger.debug('Config loaded', { apiKey: 'secret123' })
// Output: [project-scope] Config loaded {"apiKey":"[REDACTED]"}createStructuredError(message: string, code: string, context?: Record<string, unknown>): StructuredError
Parameters
Returns
StructuredErrorExample
Creating a structured error with context
import { createStructuredError } from '@hyperfrontend/project-scope'
throw createStructuredError(
'Configuration file not found',
'CONFIG_NOT_FOUND',
{ path: './config.json', searched: ['./config.json', './settings.json'] }
)createValidationError(message: string, code: string, context?: Record<string, unknown>): StructuredError
Parameters
Returns
StructuredErrorExample
Creating a validation error
throw createValidationError(
'Email format is invalid',
'INVALID_EMAIL',
{ field: 'email', value: 'not-an-email' }
)Returns
booleanExample
Detecting case sensitivity
if (detectCaseSensitivity()) {
// Linux: 'File.ts' and 'file.ts' are different files
} else {
// Windows/macOS: treat as same file
}Parameters
| Name | Type | Description |
|---|---|---|
§buffer | Buffer | Buffer to analyze |
Returns
BufferEncodingExample
Detecting encoding from buffer
const buffer = readFileSync('./data.txt')
const encoding = detectEncoding(buffer)
const content = buffer.toString(encoding)Parameters
| Name | Type | Description |
|---|---|---|
§buffer | Buffer | Buffer to analyze |
Returns
EncodingInfoExample
Detecting encoding and BOM info
const buffer = readFileSync('./document.txt')
const info = detectEncodingInfo(buffer)
if (info.type === 'text') {
console.log(`Encoding: ${info.encoding}, BOM: ${info.hasBom}`)
}Parameters
| Name | Type | Description |
|---|---|---|
§content | string | Content to analyze |
Returns
DetectedLineEndingExample
Detecting line ending style
const ending = detectLineEnding('line1\nline2\n')
// => 'lf'
const mixed = detectLineEnding('line1\r\nline2\nline3')
// => 'mixed'Returns
PlatformInfoExample
Detecting current platform
const platform = detectPlatform()
if (platform.isWindows) {
// Windows-specific handling
}Parameters
| Name | Type | Description |
|---|---|---|
§dirPath | string | Directory path to ensure exists |
Example
Ensuring directory exists
ensureDir('./output/reports')
// Directory now exists (created if missing)Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to process |
Returns
stringExample
Ensuring trailing slash
ensureTrailingSlash('src/components')
// => 'src/components/'
ensureTrailingSlash('already/has/')
// => 'already/has/'Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to check |
Returns
booleanExample
Checking if path exists
if (exists('./config.json')) {
const config = readJsonFile('./config.json')
}Parameters
Returns
stringExample
Finding directory with specific config
// Find directory with a specific config
const configDir = findUpwardWhere('./deep/nested/path', (dir) =>
existsSync(join(dir, '.eslintrc.js'))
)Parameters
Returns
stringExample
Getting basename
getBasename('src/components/Button.tsx')
// => 'Button.tsx'
getBasename('src/components/Button.tsx', '.tsx')
// => 'Button'Primarily used for testing.
Returns
numberExample
Getting the number of active caches
const count = getCacheCount()
// => 3 (number of active caches)Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to extract directory from |
Returns
stringExample
Getting directory name
getDirname('src/components/Button.tsx')
// => 'src/components'Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to extract extension from |
Returns
stringExample
Getting file extension
getExtension('src/utils/helpers.ts')
// => '.ts'
getExtension('package.json')
// => '.json'Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to extract name from |
Returns
stringExample
Getting filename without extension
getFileNameWithoutExtension('src/utils/helpers.ts')
// => 'helpers'Parameters
Returns
FileStatsExample
Getting file statistics
const stats = getFileStat('./package.json')
if (stats) {
console.log(`Size: ${stats.size} bytes`)
console.log(`Modified: ${stats.modified}`)
}Returns
LogLevelExample
Getting current log level
setGlobalLogLevel('debug')
const level = getGlobalLogLevel()
// => 'debug'Returns
"
" | "
"Example
Getting platform line ending
const eol = getLineEnding()
const lines = ['line1', 'line2', 'line3']
const content = lines.join(eol)Returns
"\" | "/"Example
Getting platform path separator
const sep = getPathSeparator()
const fullPath = ['src', 'utils', 'helpers.ts'].join(sep)Returns
PlatformInfoExample
Getting platform information
const info = getPlatformInfo()
console.log(info.os) // => 'linux'
console.log(info.pathSeparator) // => '/'
console.log(info.lineEnding) // => '\n'Parameters
| Name | Type | Description |
|---|---|---|
§buffer | Buffer | Buffer to check |
Returns
booleanExample
Checking if buffer has BOM
const buffer = readFileSync('./file.txt')
if (hasBom(buffer)) {
// Strip BOM before processing
}Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to check |
Returns
booleanExample
Checking absolute path
isAbsolute('/workspace/src/index.ts')
// => true
isAbsolute('./src/index.ts')
// => falseReturns
booleanExample
Checking case sensitivity
const caseSensitive = isCaseSensitiveFs()
// => true on Linux, false on Windows/macOSParameters
| Name | Type | Description |
|---|---|---|
§dirPath | string | Path to check |
Returns
booleanExample
Checking if path is a directory
if (isDirectory('./src')) {
// Path exists and is a directory
}Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to check |
Returns
booleanExample
Checking if path is a file
if (isFile('./package.json')) {
// Path exists and is a regular file
}Parameters
| Name | Type | Description |
|---|---|---|
§linkPath | string | Path to check |
Returns
booleanExample
Checking if path is a symlink
if (isSymlink('./node_modules/.bin/tsc')) {
// Path is a symbolic link
}Parameters
| Name | Type | Description |
|---|---|---|
§buffer | Buffer | Buffer to check |
Returns
booleanExample
Checking if content is text
const buffer = readFileSync('./unknown-file')
if (isTextFile(buffer)) {
const content = buffer.toString('utf-8')
}Returns
booleanExample
Checking for Windows
if (isWindows()) {
// Use Windows-specific paths or commands
}Parameters
| Name | Type | Description |
|---|---|---|
§...paths | string[] | Path segments to join |
Returns
stringExample
Joining path segments
const fullPath = join('src', 'components', 'Button.tsx')
// => 'src/components/Button.tsx' (or 'src\\components\\Button.tsx' on Windows)Parameters
| Name | Type | Description |
|---|---|---|
§...segments | string[] | Path segments to join |
Returns
stringExample
Joining path segments
joinPath('src', 'components', 'Button.tsx')
// => 'src/components/Button.tsx'Parameters
| Name | Type | Description |
|---|---|---|
§...paths | string[] | Path segments to join |
Returns
stringExample
Joining paths with forward slashes
const configPath = joinPosix('config', 'settings', 'app.json')
// => 'config/settings/app.json'Parameters
Returns
stringExample
Finding project root by marker files
// Find project root by looking for common marker files
const projectRoot = locateByMarkers('./src/components', [
'package.json',
'nx.json',
'tsconfig.base.json'
])
// => '/workspace/my-project'Returns
booleanExample
Checking path against multiple patterns
const ignorePatterns = ['*.log', 'node_modules/**', '*.tmp']
const shouldIgnore = matchesAnyPattern('debug.log', ignorePatterns)
// => trueReturns
booleanExample
Exact path matching
matchesExact('package.json', 'package.json')
// => true
matchesExact('src/package.json', 'package.json')
// => falseSupported patterns:
- matches any characters except /
- * matches any characters including /
- ? matches exactly one character except /
- {a,b,c} matches any of the alternatives
Parameters
Returns
booleanExample
Matching paths against glob patterns
import { matchGlobPattern } from '@hyperfrontend/project-scope'
matchGlobPattern('src/utils/helper.ts', '\*\*/*.ts') // true
matchGlobPattern('test.spec.ts', '\*.spec.ts') // true
matchGlobPattern('config.json', '\*.{json,yaml}') // true
matchGlobPattern('src/index.ts', 'src/\*.ts') // trueThe memoized function caches results based on the first argument (key). If additional arguments are needed, use the options.keyFn parameter.
Parameters
Returns
MemoizedFunction<K, V>Example
Memoizing an expensive function
// Memoize a detection function
const detectTechStackMemo = memoize(
(path: string) => expensiveDetection(path),
{ ttl: 60000 }
)
const result1 = detectTechStackMemo('/path/to/project')
const result2 = detectTechStackMemo('/path/to/project') // Returns cached
// Clear the cache
detectTechStackMemo.cache.clear()Parameters
Returns
stringExample
Normalizing line endings
// Normalize to Unix line endings
const normalized = normalizeLineEndings('line1\r\nline2\r\n', 'lf')
// => 'line1\nline2\n'
// Use platform default
const platformNormalized = normalizeLineEndings(content, 'auto')Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to normalize |
Returns
stringExample
Normalizing path separators
const path = normalizePath('src\\components\\Button.tsx')
// => 'src/components/Button.tsx'. and .. segments for cross-platform configuration.Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | The input path to convert |
Returns
stringExample
Converting to forward slashes
const path = normalizeToForwardSlashes('./src/../lib/utils')
// => 'lib/utils'Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | The input path to convert |
Returns
stringExample
Converting to native separators
const path = normalizeToNative('src/components/Button.tsx')
// => 'src\\components\\Button.tsx' on Windows
// => 'src/components/Button.tsx' on UnixParameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to calculate offset for |
Returns
stringExample
Calculating offset from root
offsetFromRoot('libs/utils/src')
// => '../../../'
offsetFromRoot('apps')
// => '../'Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to parse |
Returns
ParsedPathExample
Parsing path components
const parsed = parsePath('/workspace/src/index.ts')
// => { root: '/', dir: '/workspace/src', base: 'index.ts', ext: '.ts', name: 'index' }Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to split |
Returns
string[]Example
Splitting path into segments
pathSegments('src/components/Button.tsx')
// => ['src', 'components', 'Button.tsx']Returns
booleanExample
Comparing paths
// On case-insensitive filesystem (Windows/macOS)
pathsEqual('src/App.tsx', 'src/app.tsx')
// => true
// On case-sensitive filesystem (Linux)
pathsEqual('src/App.tsx', 'src/app.tsx')
// => falseParameters
| Name | Type | Description |
|---|---|---|
§dirPath | string | Absolute or relative path to the directory |
Returns
DirectoryEntry[]Example
Listing directory contents
import { readDirectory } from '@hyperfrontend/project-scope'
const entries = readDirectory('./src')
for (const entry of entries) {
console.log(entry.name, entry.isFile ? 'file' : 'directory')
}Parameters
Returns
DirectoryEntry[]Example
Recursive directory listing with options
import { readDirectoryRecursive } from '@hyperfrontend/project-scope'
// List all files up to 3 levels deep
const entries = readDirectoryRecursive('./src', { maxDepth: 3 })
// Include hidden files
const allEntries = readDirectoryRecursive('./project', { includeHidden: true })Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to file |
Returns
BufferExample
Reading file as buffer
const buffer = readFileBuffer('./image.png')
console.log(buffer.length) // File size in bytesParameters
Returns
stringExample
Reading file contents
import { readFileContent } from '@hyperfrontend/project-scope'
const content = readFileContent('./package.json')
console.log(content) // JSON stringParameters
Returns
stringExample
Reading file if it exists
const content = readFileIfExists('./optional-config.json')
if (content) {
// File existed, use content
}Parameters
Returns
TExample
Reading JSON file
import { readJsonFile } from '@hyperfrontend/project-scope'
// Read with type inference
interface Config { port: number }
const config = readJsonFile<Config>('./config.json')
// Read with default fallback
const settings = readJsonFile('./settings.json', { default: {} })Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to JSON file |
Returns
TExample
Reading JSON file if it exists
interface UserSettings { theme: string }
const settings = readJsonFileIfExists<UserSettings>('./user-settings.json')
const theme = settings?.theme ?? 'default'Returns
stringExample
Computing relative path
relativePath('/workspace/src/utils', '/workspace/lib/helpers')
// => '../../lib/helpers'Parameters
Example
Removing directories
// Remove directory and all contents
removeDirectory('./temp', { recursive: true })
// Safe removal (no error if missing)
removeDirectory('./cache', { recursive: true, force: true })Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path that may have trailing slashes |
Returns
stringExample
Removing trailing slashes
removeTrailingSlash('src/components/')
// => 'src/components'
removeTrailingSlash('path\\to\\dir\\')
// => 'path\\to\\dir'Example
Resetting the global log level
setGlobalLogLevel('debug')
// ... perform debugging ...
resetGlobalLogLevel()
// Global override removed, loggers use individual levelsParameters
Returns
stringExample
Resolving from workspace root
const configPath = resolveFromWorkspace('/workspace', 'config', 'app.json')
// => '/workspace/config/app.json'Parameters
| Name | Type | Description |
|---|---|---|
§...segments | string[] | Path segments to resolve |
Returns
stringExample
Resolving to absolute path
const absPath = resolvePath('src', 'components', 'Button.tsx')
// => '/workspace/project/src/components/Button.tsx'Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to resolve |
Returns
stringExample
Resolving symlinks
const realPath = resolveRealPath('./node_modules/.bin/tsc')
// => '/workspace/node_modules/typescript/bin/tsc'Parameters
| Name | Type | Description |
|---|---|---|
§obj | unknown | Object to sanitize |
Returns
unknownExample
Sanitizing sensitive data
const config = { apiKey: 'secret123', endpoint: 'https://api.example.com' }
const safe = sanitize(config)
// => { apiKey: '[REDACTED]', endpoint: 'https://api.example.com' }Parameters
| Name | Type | Description |
|---|---|---|
§level | LogLevel | The log level to set globally |
Example
Enabling debug logging globally
import { setGlobalLogLevel } from '@hyperfrontend/project-scope/core'
// Enable debug logging for all project-scope modules
setGlobalLogLevel('debug')Parameters
| Name | Type | Description |
|---|---|---|
§content | string | String that may have BOM |
Returns
stringExample
Stripping BOM from a string
const withBom = '\ufeffHello World'
const clean = stripBom(withBom)
// => 'Hello World'Parameters
Returns
stringExample
Converting a buffer to UTF-8 string
const buffer = Buffer.from('Hello', 'utf-8')
const text = toUtf8(buffer)
// => 'Hello'Parameters
Returns
stringExample
Finding directory containing README
// Find first directory containing a README
const readmeDir = traverseUpward('./src/utils', (dir) =>
existsSync(join(dir, 'README.md'))
)
// => '/project' or nullUseful for cleanup in tests or when a cache is no longer needed.
Parameters
| Name | Type | Description |
|---|---|---|
§cache | Cache<K, V> | Cache to unregister |
Returns
booleanExample
Unregistering a cache from the registry
const myCache = createCache<string, number>({ name: 'temp-cache' })
const wasRemoved = unregisterCache(myCache)
// => trueParameters
Example
Writing binary buffer to file
const imageBuffer = Buffer.from([0x89, 0x50, 0x4e, 0x47])
writeFileBuffer('./output/image.png', imageBuffer)Parameters
Example
Writing text content to file
import { writeFileContent } from '@hyperfrontend/project-scope'
// Write a simple text file
writeFileContent('./output/data.txt', 'Hello, World!')
// Write with custom encoding
writeFileContent('./output/data.txt', 'Content', { encoding: 'utf-8' })Parameters
Example
Writing JSON data to file
import { writeJsonFile } from '@hyperfrontend/project-scope'
// Write object to JSON file
writeJsonFile('./config.json', { port: 3000, debug: true })
// Write with custom indentation
writeJsonFile('./config.json', data, { indent: 4 })◈ Interfaces
Properties
Properties
Properties
Properties
◆ Types
type DetectedLineEnding = "lf" | "crlf" | "mixed" | "none"type EncodingInfo = TextEncodingInfo | BinaryEncodingInfotype FileSystemErrorCode = "FS_NOT_FOUND" | "FS_READ_ERROR" | "FS_WRITE_ERROR" | "FS_PARSE_ERROR" | "FS_NOT_A_DIRECTORY"type LineEndingStyle = "lf" | "crlf" | "auto"type LogLevel = "none" | "error" | "warn" | "log" | "info" | "debug"