Skip to content

A tiny util library to pluck keys from deep arrays and array

License

Notifications You must be signed in to change notification settings

excitepv/pluckey

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pluckey - plucks key

A tiny util library to pluck key from deep arrays and objects

const pluckey = require('pluckey');

//sample object
let college={
	class:{
		student:[{
			'name':'Vigneshwaran P',
			'rollNo':'103',
			'results':[
				{
					'subject': 'Tamil',
					'mark':99
				},
				{
					'subject': 'Nodejs',
					'mark':80
				}
			]
		},
		{
			'name':'Bob',
			'rollNo':'102',
			'results':[
				{
					'subject': 'English',
					'mark':88
				},
				{
					'subject': 'Nodejs',
					'mark':89
				}
			]
		}
		]
	}
}

pluckey(college,'class.student.results.subject');
//output=> [ 'Tamil', 'Nodejs', 'English', 'Nodejs' ]

pluckey(college,'class.student.results'); 
/*output=> [
  { subject: 'Tamil', mark: 99 },
  { subject: 'Nodejs', mark: 80 },
  { subject: 'English', mark: 88 },
  { subject: 'Nodejs', mark: 89 }
]*/

pluckey(college,'class.student.name');
//output=>[ 'Vigneshwaran P', 'Bob' ]

Installation

Installation is done using the npm install command:

$ npm install pluckey

About

A tiny util library to pluck keys from deep arrays and array

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •