Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
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
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.