
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
filter-anything
Advanced tools
A simple integration of "fillables" and "guard" filtering on the props of an object
npm i filter-anything
Filter out object props based on "fillables" and "guard". A simple & small integration.
I created this package because I needed to filter object props on fillables or guard and have support for sub-properties.
You can filter out any prop in an object based on fillables or guard.
You can use it by doing filter(object, fillables, guard)
and it will return the object
with just the props as per the fillables and/or guard!
In the example below we want to get rid of the properties called "discard1" and "discard2".
import filter from 'filter-anything'
const doc = {keep1: '📌', keep2: '🧷', keep3: '📎', discard1: '✂️', discard2: '🖍'}
// via fillables
const fillables = ['keep1', 'keep2', 'keep3']
filter(doc, fillables)
// returns {keep1: 1, keep2: 1, keep3: 1}
// OR via guard
const guard = ['discard1', 'discard2']
filter(doc, [], guard)
// returns {keep1: 1, keep2: 1, keep3: 1}
In the example below we want to get rid of the nested property called "discard".
const doc = {items: {keep: '📌', discard: '✂️'}}
// via fillables:
const fillables = ['items.keep']
filter(doc, fillables)
// returns {items: {keep: '📌'}}
// OR via guard:
const guard = ['items.discard']
filter(doc, [], guard)
// returns {items: {keep: '📌'}}
Yes! You can also work with wildcards by using *
in the path.
const doc = {
'123': {keep: '📌', discard: '✂️'},
'456': {keep: '📌', discard: '✂️'}
}
// use wildcard *
const guard = ['*.discard']
filter(doc, [], guard)
// returns {
// '123': {keep: '📌'},
// '456': {keep: '📌'}
// }
Feel free to open issues for any requests, questions or bugs!
FAQs
A simple (TypeScript) integration of "pick" and "omit" to filter props of an object
The npm package filter-anything receives a total of 10,667 weekly downloads. As such, filter-anything popularity was classified as popular.
We found that filter-anything demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.