{"id":18470710,"url":"https://github.com/orcunsaltik/njfs","last_synced_at":"2026-04-30T13:31:53.570Z","repository":{"id":65424598,"uuid":"275250053","full_name":"orcunsaltik/njfs","owner":"orcunsaltik","description":"Modern Node.js filesystem utilities - Zero dependencies, async-first API with recursive operations, cross-device move support, and full TypeScript JSDoc annotations.","archived":false,"fork":false,"pushed_at":"2025-12-11T21:40:51.000Z","size":61,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-12-13T02:18:56.448Z","etag":null,"topics":["asynchronous","copy","directory","file","filesystem","folder","folders","javascript","js","list","move","node","node-js","nodejs","root","unix"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/njfs","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/orcunsaltik.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-06-26T21:22:08.000Z","updated_at":"2025-12-11T21:40:55.000Z","dependencies_parsed_at":"2023-01-23T01:55:14.551Z","dependency_job_id":null,"html_url":"https://github.com/orcunsaltik/njfs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/orcunsaltik/njfs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orcunsaltik%2Fnjfs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orcunsaltik%2Fnjfs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orcunsaltik%2Fnjfs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orcunsaltik%2Fnjfs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/orcunsaltik","download_url":"https://codeload.github.com/orcunsaltik/njfs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orcunsaltik%2Fnjfs/sbom","scorecard":{"id":711861,"data":{"date":"2025-08-11","repo":{"name":"github.com/orcunsaltik/njfs","commit":"9bd2d6dc3c9720d76a3aa10c8ccdecb0a2d0592a"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-22T08:23:14.996Z","repository_id":65424598,"created_at":"2025-08-22T08:23:14.996Z","updated_at":"2025-08-22T08:23:14.996Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32466333,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"ssl_error","status_checked_at":"2026-04-30T13:12:06.837Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asynchronous","copy","directory","file","filesystem","folder","folders","javascript","js","list","move","node","node-js","nodejs","root","unix"],"created_at":"2024-11-06T10:14:43.338Z","updated_at":"2026-04-30T13:31:53.562Z","avatar_url":"https://github.com/orcunsaltik.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# njfs\n\n[![CI](https://github.com/orcunsaltik/njfs/actions/workflows/ci.yml/badge.svg)](https://github.com/orcunsaltik/njfs/actions/workflows/ci.yml)\n[![npm version](https://img.shields.io/npm/v/njfs.svg)](https://www.npmjs.com/package/njfs)\n[![npm downloads](https://img.shields.io/npm/dt/njfs.svg)](https://www.npmjs.com/package/njfs)\n[![license](https://img.shields.io/npm/l/njfs.svg)](https://github.com/orcunsaltik/njfs/blob/master/LICENSE)\n\n\u003e Modern Node.js filesystem utilities - Zero dependencies, async-first API with recursive operations, cross-device move support, and full TypeScript JSDoc annotations.\n\nProduction-ready filesystem utilities with zero dependencies. Supports both files and directories, recursive operations, and cross-platform compatibility.\n\n## Features\n\n- ✅ Zero dependencies\n- ✅ Simple, intuitive API\n- ✅ Async-first with optional sync methods\n- ✅ Recursive directory operations\n- ✅ Cross-device move support\n- ✅ Modern Node.js support (18+)\n- ✅ Full TypeScript JSDoc annotations\n- ✅ Production-tested\n\n## Installation\n\n```bash\nnpm install njfs\n```\n\n## Quick Start\n\n```javascript\nconst { copy, list, mkdirp, readFile, writeFile } = require('njfs');\n\n// Copy entire directory\nawait copy('./src', './dist');\n\n// List files recursively\nconst files = await list('./src', { recursive: true, extensions: ['js', 'ts'] });\n\n// Create nested directories\nawait mkdirp('./build/assets/images');\n\n// Read and write files\nconst content = await readFile('./config.json');\nawait writeFile('./output/data.json', JSON.stringify(data));\n```\n\n## API Reference\n\n### File \u0026 Directory Checking\n\n#### `exists(path)` • Async\n\nCheck if a path exists (file or directory).\n\n```javascript\nconst { exists } = require('njfs');\n\nif (await exists('./config.json')) {\n  console.log('Config exists!');\n}\n```\n\n**Returns:** `Promise\u003cboolean\u003e`\n\n---\n\n#### `isFile(path)` • Async\n\nCheck if a path is a file.\n\n```javascript\nconst { isFile } = require('njfs');\n\nif (await isFile('./package.json')) {\n  console.log('Is a file!');\n}\n```\n\n**Returns:** `Promise\u003cboolean\u003e`\n\n---\n\n#### `isDir(path)` • Async\n\nCheck if a path is a directory.\n\n```javascript\nconst { isDir } = require('njfs');\n\nif (await isDir('./src')) {\n  console.log('Is a directory!');\n}\n```\n\n**Returns:** `Promise\u003cboolean\u003e`\n\n---\n\n#### `isFileSync(path)` • Sync\n\nSynchronous version of `isFile`. Use sparingly (blocks event loop).\n\n```javascript\nconst { isFileSync } = require('njfs');\n\nif (isFileSync('./package.json')) {\n  console.log('Is a file!');\n}\n```\n\n**Returns:** `boolean`\n\n---\n\n#### `isDirSync(path)` • Sync\n\nSynchronous version of `isDir`. Use sparingly (blocks event loop).\n\n```javascript\nconst { isDirSync } = require('njfs');\n\nif (isDirSync('./src')) {\n  console.log('Is a directory!');\n}\n```\n\n**Returns:** `boolean`\n\n---\n\n### Directory Operations\n\n#### `list(path, options)` • Async\n\nList files and directories with powerful filtering options.\n\n```javascript\nconst { list } = require('njfs');\n\n// List all entries\nconst all = await list('./src');\n\n// Filter by extension\nconst jsFiles = await list('./src', { extensions: 'js' });\nconst codeFiles = await list('./src', { extensions: ['js', 'ts', 'jsx'] });\n\n// Recursive listing\nconst allFiles = await list('./src', { recursive: true });\n\n// Get full paths\nconst paths = await list('./src', {\n  recursive: true,\n  fullPath: true,\n  extensions: ['js', 'json'],\n});\n```\n\n**Options:**\n\n- `extensions` (string | string[]): Filter by file extensions\n- `recursive` (boolean): Walk subdirectories (default: `false`)\n- `fullPath` (boolean): Return absolute paths instead of names (default: `false`)\n\n**Returns:** `Promise\u003cstring[]\u003e`\n\n---\n\n#### `mkdirp(path)` • Async\n\nCreate directory recursively (like `mkdir -p`).\n\n```javascript\nconst { mkdirp } = require('njfs');\n\n// Creates all parent directories\nawait mkdirp('./dist/assets/images');\n```\n\n**Returns:** `Promise\u003cvoid\u003e`\n\n---\n\n#### `root()` • Sync\n\nGet the current working directory.\n\n```javascript\nconst { root } = require('njfs');\n\nconst projectRoot = root();\nconsole.log(projectRoot); // '/home/user/my-project'\n```\n\n**Returns:** `string`\n\n---\n\n### File Operations\n\n#### `copy(source, destination)` • Async\n\nCopy files **or directories** recursively.\n\n```javascript\nconst { copy } = require('njfs');\n\n// Copy file\nawait copy('./src/app.js', './dist/app.js');\n\n// Copy file to directory (keeps name)\nawait copy('./src/app.js', './dist/');\n\n// Copy entire directory recursively\nawait copy('./src', './dist');\n\n// Copy directory to new location\nawait copy('./templates', './build/templates');\n```\n\n**Returns:** `Promise\u003cstring\u003e` - Destination path\n\n---\n\n#### `move(source, destination)` • Async\n\nMove files **or directories** with cross-device support.\n\n```javascript\nconst { move } = require('njfs');\n\n// Move file\nawait move('./temp/file.js', './archive/file.js');\n\n// Move to directory (keeps name)\nawait move('./temp/file.js', './archive/');\n\n// Move entire directory\nawait move('./old-folder', './new-folder');\n\n// Cross-device move (automatically falls back to copy+delete)\nawait move('/mnt/drive1/data', '/mnt/drive2/data');\n```\n\n**Returns:** `Promise\u003cstring\u003e` - Destination path\n\n**Note:** Automatically handles cross-device moves by copying then deleting.\n\n---\n\n#### `remove(path)` • Async\n\nRemove file or directory recursively.\n\n```javascript\nconst { remove } = require('njfs');\n\n// Remove file\nawait remove('./temp.txt');\n\n// Remove directory and all contents\nawait remove('./build');\n```\n\n**Returns:** `Promise\u003cvoid\u003e`\n\n---\n\n#### `readFile(path, encoding)` • Async\n\nRead file contents.\n\n```javascript\nconst { readFile } = require('njfs');\n\n// Read as UTF-8 (default)\nconst text = await readFile('./config.json');\n\n// Read as buffer\nconst buffer = await readFile('./image.png', null);\n\n// Read with specific encoding\nconst latin = await readFile('./legacy.txt', 'latin1');\n```\n\n**Parameters:**\n\n- `path` (string): File path\n- `encoding` (string | null): Encoding (default: `'utf8'`, use `null` for buffer)\n\n**Returns:** `Promise\u003cstring | Buffer\u003e`\n\n---\n\n#### `writeFile(path, content)` • Async\n\nWrite content to file. Creates parent directories automatically.\n\n```javascript\nconst { writeFile } = require('njfs');\n\n// Write string\nawait writeFile('./output/data.txt', 'Hello World');\n\n// Write JSON\nawait writeFile('./config.json', JSON.stringify(config, null, 2));\n\n// Nested path (creates directories)\nawait writeFile('./build/assets/data.json', content);\n```\n\n**Returns:** `Promise\u003cvoid\u003e`\n\n---\n\n### Path Utilities\n\n#### `unix(path)` • Sync\n\nConvert path to Unix-style separators.\n\n```javascript\nconst { unix } = require('njfs');\n\nconst normalized = unix('C:\\\\Users\\\\name\\\\project');\n// Returns: 'C:/Users/name/project'\n```\n\n**Returns:** `string`\n\n---\n\n## Usage Examples\n\n### Build Script\n\n```javascript\nconst { copy, list, mkdirp, remove } = require('njfs');\n\nasync function build() {\n  // Clean\n  await remove('./dist');\n\n  // Create output structure\n  await mkdirp('./dist/js');\n  await mkdirp('./dist/css');\n\n  // Copy all JavaScript files\n  const jsFiles = await list('./src', {\n    recursive: true,\n    extensions: ['js', 'jsx'],\n    fullPath: true,\n  });\n\n  for (const file of jsFiles) {\n    const destPath = file.replace('/src/', '/dist/js/');\n    await copy(file, destPath);\n  }\n\n  console.log('Build complete!');\n}\n\nbuild();\n```\n\n---\n\n### Directory Sync\n\n```javascript\nconst { copy, list, exists, remove } = require('njfs');\n\nasync function syncDirectories(source, target) {\n  // Get all files from source\n  const sourceFiles = await list(source, {\n    recursive: true,\n    fullPath: true,\n  });\n\n  // Remove target if exists\n  if (await exists(target)) {\n    await remove(target);\n  }\n\n  // Copy entire directory\n  await copy(source, target);\n\n  console.log(`Synced ${sourceFiles.length} files`);\n}\n\nsyncDirectories('./source', './backup');\n```\n\n---\n\n### File Organization\n\n```javascript\nconst { list, move, mkdirp, unix } = require('njfs');\nconst path = require('path');\n\nasync function organizeByExtension(sourceDir) {\n  const files = await list(sourceDir, { fullPath: true });\n\n  for (const file of files) {\n    const ext = path.extname(file).slice(1) || 'no-extension';\n    const destDir = `${sourceDir}/organized/${ext}`;\n\n    await mkdirp(destDir);\n    await move(file, destDir);\n\n    console.log(`Moved: ${unix(file)} → ${ext}/`);\n  }\n}\n\norganizeByExtension('./downloads');\n```\n\n---\n\n### Recursive File Search\n\n```javascript\nconst { list, readFile } = require('njfs');\n\nasync function searchInFiles(dir, searchText) {\n  const files = await list(dir, {\n    recursive: true,\n    extensions: ['js', 'ts', 'json'],\n    fullPath: true,\n  });\n\n  const matches = [];\n\n  for (const file of files) {\n    const content = await readFile(file);\n    if (content.includes(searchText)) {\n      matches.push(file);\n    }\n  }\n\n  return matches;\n}\n\nconst results = await searchInFiles('./src', 'TODO');\nconsole.log(`Found ${results.length} files with TODOs`);\n```\n\n---\n\n### Backup System\n\n```javascript\nconst { copy, mkdirp, unix } = require('njfs');\nconst path = require('path');\n\nasync function createBackup(source, backupRoot) {\n  const timestamp = new Date().toISOString().replace(/:/g, '-');\n  const backupPath = path.join(backupRoot, timestamp);\n\n  await mkdirp(backupPath);\n  await copy(source, backupPath);\n\n  console.log(`Backup created: ${unix(backupPath)}`);\n  return backupPath;\n}\n\ncreateBackup('./important-data', './backups');\n```\n\n---\n\n### Gulp Integration\n\n```javascript\nconst { list, copy, root } = require('njfs');\nconst { series, watch } = require('gulp');\n\nasync function copyAssets() {\n  const srcDir = `${root()}/assets`;\n  const distDir = `${root()}/dist/assets`;\n\n  await copy(srcDir, distDir);\n  console.log('✓ Assets copied');\n}\n\nasync function processScripts() {\n  const files = await list('./src', {\n    recursive: true,\n    extensions: ['js', 'ts'],\n  });\n\n  console.log(`Processing ${files.length} script files...`);\n  // ... your build logic\n}\n\nexports.build = series(copyAssets, processScripts);\nexports.watch = () =\u003e {\n  watch('./assets/**/*', copyAssets);\n  watch('./src/**/*.{js,ts}', processScripts);\n};\n```\n\n---\n\n## Requirements\n\n- Node.js \u003e= 18.0.0\n\n## Changelog\n\n### v2.0.2 (2025)\n\n- 🚀 Updated config files to latest standards\n- 🚀 Improved development workflow\n- 🚀 Better code quality tools\n- 🚀 Updated SEO-friendly package description\n\n### v2.0.1 (2024)\n\n- Dependency updates\n\n### v2.0.0 (2024)\n\n- 🚀 **BREAKING:** Requires Node.js 18+\n- 🚀 **BREAKING:** `isDir` and `isFile` are now async (use `isDirSync`/`isFileSync` for sync)\n- ✨ **NEW:** `copy` now supports directories recursively\n- ✨ **NEW:** `move` now supports directories with cross-device fallback\n- ✨ **NEW:** `list` supports `recursive` and `fullPath` options\n- ✨ **NEW:** `exists(path)` - Check if path exists\n- ✨ **NEW:** `remove(path)` - Recursive delete\n- ✨ **NEW:** `mkdirp(path)` - Recursive directory creation\n- ✨ **NEW:** `readFile(path, encoding)` - Read file contents\n- ✨ **NEW:** `writeFile(path, content)` - Write file with auto-mkdir\n- 🐛 Fixed `root()` to use `process.cwd()` instead of `__dirname`\n- 🐛 Fixed path normalization bugs on Windows\n- 🐛 Fixed stream handling in `copy` to properly await completion\n- 📚 Added comprehensive JSDoc documentation\n- 🔧 Better error handling and messages\n- ⚡ Performance improvements\n\n### v1.2.5 (2021)\n\n- Previous stable release\n\n## Migration from v1.x\n\n```javascript\n// v1.x - Sync checks\nif (isDir('./src')) {\n}\n\n// v2.x - Async checks (recommended)\nif (await isDir('./src')) {\n}\n\n// v2.x - Sync fallback (use sparingly)\nif (isDirSync('./src')) {\n}\n```\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## Troubleshooting\n\nWhen you encounter a problem, please [open an issue](https://github.com/orcunsaltik/njfs/issues).\n\n## Credits\n\nSpecial thanks to Grok AI for architecture review and suggestions.\n\n## Author\n\n**Orçun Saltık**\n\n- GitHub: [@orcunsaltik](https://github.com/orcunsaltik)\n- Email: saltikorcun@gmail.com\n\n## License\n\n[MIT](LICENSE) © Orçun Saltık\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forcunsaltik%2Fnjfs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Forcunsaltik%2Fnjfs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forcunsaltik%2Fnjfs/lists"}