
Security News
TypeScript is Porting Its Compiler to Go for 10x Faster Builds
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
deep-pick-omit
Advanced tools
Deep-pick and deep-omit objects with typesafe paths.
Both deepPick
and deepOmit
take an object and an array of dot-notation paths to respectively pick and omit from the object. By default, TypeScript will infer types for paths and error if a path does not exist in the object.
deepPick
import { deepPick } from 'deep-pick-omit'
const obj = {
a: {
b: 'this',
c: 'not this'
},
d: 'this'
}
deepPick(obj, ['a.b', 'e'])
// -> { a: { b: 'this' }, d: 'this' }
deepPick(obj, ['f'])
// -> TypeScript Error: `f` is not a key of `obj`
deepOmit
import { deepOmit } from 'deep-pick-omit'
const obj = {
a: {
b: 'this',
c: 'not this'
},
d: 'this'
}
deepOmit(obj, ['a.c'])
// -> { a: { b: 'this' }, d: 'this' }
deepOmit(obj, ['f'])
// -> TypeScript Error: `f` is not a key of `obj`
[!NOTE] Pathing through array values is not allowed typesafe path methods. See unsafe methods.
If paths type-safety is a problem for some edge cases, the package exposes the same methods without the type-checking on paths.
deepPickUnsafe
import { deepPickUnsafe } from 'deep-pick-omit'
const obj = {
a: {
c: 'not this'
},
d: 'this'
}
deepPickUnsafe(obj, ['d', 'f'])
// -> { d: 'this' }
deepOmitUnsafe
import { deepOmitUnsafe } from 'deep-pick-omit'
const obj = {
a: {
b: 'this',
c: 'not this'
},
d: 'this'
}
deepOmitUnsafe(obj, ['a.c', 'f'])
// -> { a: { b: 'this' }, d: 'this' }
MIT — Made with 💖.
v1.2.1
FAQs
Deep-pick and deep-omit objects with typesafe paths.
The npm package deep-pick-omit receives a total of 107,439 weekly downloads. As such, deep-pick-omit popularity was classified as popular.
We found that deep-pick-omit 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
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.