A powerful and precise tool for traversing and investigating nested objects in JavaScript.
- 🎯 Find values by key in deeply nested objects
- 📍 Get exact paths to found values
- 🔄 Case-sensitive and case-insensitive search
- 🚀 High performance with optional caching
- 🎮 Simple and intuitive API
- 📊 Built-in performance monitoring
- 💪 Written in TypeScript with full type support
npm install probejs-core
# or
yarn add probejs-core
import { Probe } from 'probejs-core';
const data = {
users: {
john: {
id: 1,
email: 'john@example.com',
profile: {
email: 'john.doe@example.com'
}
}
}
};
// Create a new probe
const probe = new Probe(data);
// Find first email
const result = probe.find('email');
console.log(result);
// { value: 'john@example.com', path: 'users.john.email', key: 'email' }
// Find all emails
const allEmails = probe.find('email', 'all');
// [
// { value: 'john@example.com', path: 'users.john.email', key: 'email' },
// { value: 'john.doe@example.com', path: 'users.john.profile.email', key: 'email' }
// ]
const probe = new Probe(data, {
caseSensitive: true, // default: true
maxDepth: Infinity, // default: Infinity
pathDelimiter: '.', // default: '.'
caching: true // default: true
});
Find value(s) by key
probe.find('email'); // Find first occurrence
probe.find('email', 'last'); // Find last occurrence
probe.find('email', 'all'); // Find all occurrences
Find value at exact path
probe.findByPath('users.john.email');
Find values matching a condition
probe.findWhere(value => typeof value === 'number' && value > 10);
// Get performance statistics
const stats = probe.getStatistics();
console.log(stats);
// {
// searches: number,
// cacheHits: number,
// cacheMisses: number,
// averageSearchTime: number
// }
// Clear the cache
probe.clearCache();
Check out the examples directory for more use cases.
Full documentation is available in the docs directory.
Contributions are welcome! Please read our Contributing Guide for details.
MIT © [Damanpreet Singh]