js对象提取器,扩展自 json-mask 在此感谢!
npm install pick-mask
a,b,c
comma-separated list will select multiple fieldsa.b.c
path will select a field from its parenta(b,c)
sub-selection will select many fields from a parenta.*.c
the star*
wildcard will select all items in a field
a@aa,b
rename fieldsa|2-5
array interception/\\w+/
regular match
var pick = require('pick-mask')
pick({p: {a: 1, b: 2, aa: 11, bb: 22},z: 1}, 'p./^\\w$/,z') // {p: {a: 1, b : 2}, z: 1}
more examples test
MIT