{"id":13582,"library":"my-node-fp","title":"Node.js Functional Programming Utilities","description":"my-node-fp is a utility library for Node.js, currently at version 0.10.3, offering a collection of simple functional programming utilities primarily focused on file system (fs) and path manipulation. It ships with TypeScript types, enhancing developer experience. The library provides both asynchronous and synchronous versions for many file system operations, such as checking file existence or directory status. Key differentiators include specialized path utilities like `replaceSepToPosix` and `win32DriveLetterUpdown`, which abstract away OS-specific path concerns. Given its pre-1.0 versioning, users should anticipate potential API changes in future releases, though it appears to be actively maintained based on its recent version number.","status":"active","version":"0.10.3","language":"javascript","source_language":"en","source_url":"https://github.com/imjuni/my-node-fp","tags":["javascript","typescript"],"install":[{"cmd":"npm install my-node-fp","lang":"bash","label":"npm"},{"cmd":"yarn add my-node-fp","lang":"bash","label":"yarn"},{"cmd":"pnpm add my-node-fp","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Imports the asynchronous file existence check. Note that Node.js's native `fs.exists` is deprecated, and this library's `exists` mirrors that behavior.","wrong":"const { exists } = require('my-node-fp').fs;","symbol":"exists","correct":"import { exists } from 'my-node-fp/fs';"},{"note":"Imports the synchronous directory check. Ensure you import from the '/fs' subpath, not directly from the root package, as functions are organized by category.","wrong":"import { isDirectorySync } from 'my-node-fp';","symbol":"isDirectorySync","correct":"import { isDirectorySync } from 'my-node-fp/fs';"},{"note":"Imports the utility for extracting basenames from a path, allowing suffixes to be specified. Functions are grouped into subpaths like '/path' for better organization and tree-shaking.","wrong":"import { basenames } from 'my-node-fp/utils';","symbol":"basenames","correct":"import { basenames } from 'my-node-fp/path';"}],"quickstart":{"code":"import { exists, isDirectory, isEmptyDir } from 'my-node-fp/fs';\nimport { basenames, replaceSepToPosix } from 'my-node-fp/path';\nimport * as fs from 'node:fs/promises';\nimport * as path from 'node:path';\n\nasync function runExample() {\n  const tempDir = path.join(process.cwd(), 'temp_my_node_fp_test');\n  const tempFile = path.join(tempDir, 'test_file.txt');\n\n  // Ensure temp directory exists and is empty for consistent testing\n  if (await exists(tempDir)) {\n    await fs.rm(tempDir, { recursive: true, force: true });\n  }\n  await fs.mkdir(tempDir, { recursive: true });\n  await fs.writeFile(tempFile, 'Hello, my-node-fp!');\n\n  console.log(`Checking if '${tempDir}' exists: ${await exists(tempDir)}`);\n  console.log(`Checking if '${tempFile}' is a directory: ${await isDirectory(tempFile)}`);\n  console.log(`Checking if '${tempDir}' is empty: ${await isEmptyDir(tempDir)}`); // Should be false now\n\n  const filePath = '/usr/local/bin/node_modules/my-package/index.js';\n  const windowsPath = 'C:\\\\Users\\\\User\\\\Documents\\\\file.txt';\n  console.log(`Basenames of '${filePath}' (excluding '.js'): ${basenames(filePath, '.js')}`);\n  console.log(`Posix path for '${windowsPath}': ${replaceSepToPosix(windowsPath)}`);\n\n  // Cleanup after example\n  await fs.rm(tempDir, { recursive: true, force: true });\n  console.log('Cleanup complete.');\n}\n\nrunExample().catch(console.error);","lang":"typescript","description":"Demonstrates basic asynchronous file system checks and path manipulation utilities, including creating and cleaning up temporary files and directories, and transforming path separators."},"warnings":[{"fix":"For robust existence checks, consider using `fs.access` (or `fs.promises.access`) with `fs.constants.F_OK` or `fs.stat` (or `fs.promises.stat`) within a `try...catch` block directly, especially in new code or security-sensitive contexts.","message":"The `exists` and `existsSync` functions directly mirror the deprecated `fs.exists` and `fs.existsSync` in Node.js. While they function, Node.js documentation recommends using `fs.stat` or `fs.access` for existence checks, as `fs.exists` can lead to race conditions (e.g., checking for existence then performing an operation, where the file might be deleted between checks).","severity":"deprecated","affected_versions":">=0.1.0"},{"fix":"Pin to exact versions (e.g., `\"my-node-fp\": \"0.10.3\"`) or use a lockfile (`package-lock.json`, `yarn.lock`) to prevent unexpected breaking changes during dependency updates. Always review release notes carefully when upgrading to newer pre-1.0 versions.","message":"As a pre-1.0 package (current version 0.10.3), the API surface of `my-node-fp` is not yet stable. Future minor versions may introduce breaking changes without strict adherence to semantic versioning for major increments, as the library is still in active development.","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"Prefer the asynchronous versions of functions (e.g., `isDirectory` over `isDirectorySync`) for all I/O operations in performance-sensitive applications, especially in Node.js server contexts. Only use synchronous variants for startup scripts, CLI tools, or non-critical blocking operations where performance is not a primary concern.","message":"Some functions, particularly in the `fs` category, offer both asynchronous (e.g., `isDirectory`) and synchronous (e.g., `isDirectorySync`) variants. Using synchronous file system calls can block the Node.js event loop, severely impacting application performance and responsiveness in server environments or I/O-intensive tasks.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"search_vec":"'-1.0':86 '0.10.3':18 'abstract':76 'activ':102 'anticip':90 'api':92 'appear':99 'asynchron':48 'away':77 'base':104 'chang':93 'check':59 'collect':21 'concern':82 'current':15 'develop':42 'differenti':66 'directori':63 'enhanc':41 'exist':61 'experi':43 'file':30,54,60 'focus':28 'fp':8 'fs':32 'function':2,24 'futur':95 'given':83 'includ':67 'javascript':110 'key':65 'librari':12,45 'like':71 'maintain':103 'mani':53 'manipul':35 'my-node-fp':5 'node':7 'node.js':1,14 'number':109 'offer':19 'oper':56 'os':79 'os-specif':78 'path':34,69,81 'potenti':91 'pre':85 'primarili':27 'program':3,25 'provid':46 'recent':107 'releas':96 'replaceseptoposix':72 'ship':37 'simpl':23 'special':68 'specif':80 'status':64 'synchron':50 'system':31,55 'though':97 'type':40 'typescript':39,111 'user':88 'util':4,11,26,70 'version':17,51,87,108 'win32driveletterupdown':74","created_at":"2026-04-20T01:55:15.271192+00:00","updated_at":"2026-04-20T01:55:15.271192+00:00","problems":[{"fix":"Ensure you are using named imports from the correct subpath for the specific utility category, e.g., `import { exists } from 'my-node-fp/fs';` for file system utilities or `import { basenames } from 'my-node-fp/path';` for path utilities.","cause":"Attempting to import a module's function from the wrong subpath or using an incorrect destructuring pattern (e.g., importing from 'my-node-fp' instead of 'my-node-fp/fs'). This error is common in bundlers like Webpack.","error":"TypeError: (0, _my_node_fp_fs__WEBPACK_IMPORTED_MODULE_0__.exists) is not a function"},{"fix":"Verify that your Node.js process has the necessary read/write/execute permissions for the target file or directory. If encountering this after an existence check, be aware of the race conditions inherent to `fs.exists` (and `my-node-fp`'s mirror thereof); prefer using `fs.promises.access` or handling errors from operations like `fs.promises.stat` or `fs.promises.mkdir` directly.","cause":"Insufficient operating system permissions for the Node.js process to perform the requested file system operation (e.g., reading a file, creating a directory), or a race condition when checking for file existence and then attempting an operation.","error":"Error: EPERM: operation not permitted, stat 'C:\\path\\to\\file'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/imjuni/my-node-fp","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/my-node-fp","openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-18","install_tag":null}}