
Product
Introducing Pull Request Stories to Help Security Teams Track Supply Chain Risks
Socket’s new Pull Request Stories give security teams clear visibility into dependency risks and outcomes across scanned pull requests.
@g2crowd/extract-options
Advanced tools
This package is responsible for extracting a subset of a hash, based on a namespaced key.
It is useful for reading options out of DOM data attributes, where there may be multiple keys with different concerns.
npm install @g2crowd/extract-options --save
This will create a new hash, seperating out keys based on a common prefix:
import { extractOptions } from '@g2crowd/extract-options';
const startingHash = { prefixOne: 1, prefixTwo: 2, otherKey: 3 };
extractOptions(startingHash, 'prefix'); //=> { one: 1, two: 2 }
It will treat keys with an Options
suffix as special. It will expect a hash of raw options to follow:
const startingHash = { prefixOne: 1, prefixTwo: 2, otherKey: 3, prefixOptions: { three: 3 } };
extractOptions(startingHash, 'prefix'); //=> { one: 1, two: 2, three: 3 }
Pairs nicely with jQuery.data
:
<div id="element" data-prefix-one="1" data-prefix-two="2" data-other-key="3"></div>
let data = $('#element').data();
const options = extractOptions(data, 'prefix'); //=> { one: 1, two: 2 }
FAQs
Pull namespaced options out of a hash
We found that @g2crowd/extract-options demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers 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.
Product
Socket’s new Pull Request Stories give security teams clear visibility into dependency risks and outcomes across scanned pull requests.
Research
/Security News
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.