{"id":25580,"library":"file-pluck","title":"File Pluck","description":"A Node.js library for extracting text snippets from files or strings using customizable delimiters. Version 0.6.5 is the latest stable release. The library returns snippets as strings or can break them into key/value pairs with optional JSON output. It uses a Promise-based API and supports glob patterns for file matching. Unlike simple grep or regex solutions, file-pluck provides built-in objectification and JSON serialization, making it suitable for documentation generation and structured data extraction from annotated code or markup.","status":"active","version":"0.6.5","language":"javascript","source_language":"en","source_url":"https://github.com/iamnathanj/file-pluck","tags":["javascript","read","file","pluck","write","json","documentation"],"install":[{"cmd":"npm install file-pluck","lang":"bash","label":"npm"},{"cmd":"yarn add file-pluck","lang":"bash","label":"yarn"},{"cmd":"pnpm add file-pluck","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"file-pluck uses CommonJS, not ESM. No default export exists for ES modules.","wrong":"import filePluck from 'file-pluck'","symbol":"default","correct":"const filePluck = require('file-pluck')"},{"note":"pluckFile is an instance method, not a static method. You must call filePluck() first.","wrong":"filePluck.pluckFile('file.txt')","symbol":"pluckFile","correct":"const p = filePluck(); p.pluckFile('file.txt')"},{"note":"objectify is an instance method, not a static method.","wrong":"filePluck.objectify(snippets)","symbol":"objectify","correct":"const p = filePluck(); p.objectify(snippets)"}],"quickstart":{"code":"const filePluck = require('file-pluck');\n\n// Create an instance with default delimiters (opening: '/***', closing: '***/')\nconst p = filePluck();\n\n// Pluck snippets from a file\np.pluckFile('example.txt')\n  .then(snippets => {\n    console.log('Snippets:', snippets);\n    // Output: ['pluck this text', 'pluck this text too']\n  })\n  .catch(err => {\n    console.error('Error:', err);\n  });","lang":"javascript","description":"Demonstrates basic usage: creating an instance with default options, plucking snippets from a file, and logging results."},"warnings":[{"fix":"Use const p = filePluck(); then call p.pluckFile() or p.objectify()","message":"filePluck() must be called to create an instance; methods like pluckFile and objectify are not static.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Update code to call filePluck() before using methods.","message":"The API no longer returns a promise directly from require; you must instantiate.","severity":"breaking","affected_versions":">=0.5.0"},{"fix":"Use require() or set up bundler to handle CJS.","message":"Some users expect ES module import; package only provides CommonJS.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Test glob patterns carefully; use simple file paths when possible.","message":"Glob patterns are supported but not documented; may cause unexpected matching.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"const p = filePluck(); then p.pluckFile('file.txt')","cause":"Calling pluckFile as a static method instead of an instance method.","error":"TypeError: filePluck.pluckFile is not a function"},{"fix":"Use dynamic import or configure your project for CommonJS.","cause":"Attempting to use require in an ES module environment.","error":"ReferenceError: require is not defined"},{"fix":"Run: npm install file-pluck","cause":"Package not installed or missing from node_modules.","error":"Cannot find module 'file-pluck'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}