
Security News
MCP Community Begins Work on Official MCP Metaregistry
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
extract-dat
Advanced tools
Runs an extractor function against a value in order to pull out some other value. If the extractor function fails to pull the data out for any reason, `extract-dat` will suppress any errors and simply return the default value. Because SOMETIMES... you jus
Runs an extractor function against a value in order to pull out some other value. If the extractor function fails to pull the data out for any reason, extract-dat
will suppress any errors and simply return the default value. Because SOMETIMES... you just want a value without all the whining.
npm install --save extract-dat
import extract from "extract-dat";
extract(dataValue, extractorFn, [defaultValue=null])
// => value or defaultValue
Argument | Type | Description |
---|---|---|
dataValue | Any | Value to be passed into extractorFn as the first parameter. |
extractorFn | Function | Function to extract a value from dataValue . |
defaultValue | Any | Value to be returned if extractorFn produces an error or returns undefined . |
import extract from "extract-dat";
const user = {
phone: {type: 'home', number: '123-456-7890'},
greet: 'Hello World',
roles: ['editor', 'contributor']
};
const name = extract(user, x => x.name, 'Bob');
// => "Bob"
const greeting = extract(user, x => x.greet, 'HI!');
// => "Hello World"
const email = extract(user, x => x.email);
// => null
const isAdmin = extract(user, x => x.roles.includes('admin'), false);
// => false
const isEditor = extract(user, x => x.roles.includes('editor'), false);
// => true
const formattedPhone = extract(user, x => `${x.phone.number} (${x.phone.type})`, 'No Phone Number');
// => "123-456-7890 (home)"
extract-dat
is part of lib-dat
, a suite of tools that all...
FAQs
Runs an extractor function against a value in order to pull out some other value. If the extractor function fails to pull the data out for any reason, `extract-dat` will suppress any errors and simply return the default value. Because SOMETIMES... you jus
The npm package extract-dat receives a total of 2 weekly downloads. As such, extract-dat popularity was classified as not popular.
We found that extract-dat demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
Research
Security News
Malicious npm packages posing as developer tools target macOS Cursor IDE users, stealing credentials and modifying files to gain persistent backdoor access.