Registry / data / file-pluck

file-pluck

JSON →
library0.6.5jsnpmunverified

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.

npm install file-pluck
INSTALL
IMPORT
SIG · FILE-PLUCK
F
file-pluck
datajavascriptv0.6.5
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
const filePluck = require('file-pluck')
import filePluck from 'file-pluck'
file-pluck uses CommonJS, not ESM. No default export exists for ES modules.
pluckFile
const p = filePluck(); p.pluckFile('file.txt')
filePluck.pluckFile('file.txt')
pluckFile is an instance method, not a static method. You must call filePluck() first.
objectify
const p = filePluck(); p.objectify(snippets)
filePluck.objectify(snippets)
objectify is an instance method, not a static method.

Demonstrates basic usage: creating an instance with default options, plucking snippets from a file, and logging results.

const filePluck = require('file-pluck'); // Create an instance with default delimiters (opening: '/***', closing: '***/') const p = filePluck(); // Pluck snippets from a file p.pluckFile('example.txt') .then(snippets => { console.log('Snippets:', snippets); // Output: ['pluck this text', 'pluck this text too'] }) .catch(err => { console.error('Error:', err); });
Debug
Known issues
gotchafilePluck() must be called to create an instance; methods like pluckFile and objectify are not static.
fix
Use const p = filePluck(); then call p.pluckFile() or p.objectify()
affects: >=0.0.0
breakingThe API no longer returns a promise directly from require; you must instantiate.
fix
Update code to call filePluck() before using methods.
affects: >=0.5.0
deprecatedSome users expect ES module import; package only provides CommonJS.
fix
Use require() or set up bundler to handle CJS.
affects: >=0.0.0
gotchaGlob patterns are supported but not documented; may cause unexpected matching.
fix
Test glob patterns carefully; use simple file paths when possible.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: filePluck.pluckFile is not a function
Calling pluckFile as a static method instead of an instance method.
fix
const p = filePluck(); then p.pluckFile('file.txt')
ReferenceError: require is not defined
Attempting to use require in an ES module environment.
fix
Use dynamic import or configure your project for CommonJS.
Cannot find module 'file-pluck'
Package not installed or missing from node_modules.
fix
Run: npm install file-pluck
Upgrade
Version history
0.6.5latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
file-pluck — npm install file-pluck · libregistry