Skip to content

elvinaspredkelis/dirty-pluck

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dirty-pluck

NPM Version NPM Bundle Size

dirty-pluck is a tiny and straight-forward library for plucking JSON values. It's great for adapters of all sorts.

Installation

To add dirty-pluck to your project, you can use your favorite package manager.

npm install dirty-pluck
yarn add dirty-pluck

Usage

dirty-pluck is opinionated and not meant to be a query language. However, it's as simple as it gets if you want to pluck whatever values that get in the way.

import pluck from "dirty-pluck";

const data = {
  restaurant: {
    title: "The Best Restaurant",
    reviews: [{ rating: 8.5 }, { rating: 2.7 }, { rating: 9.1 }],
  },
};

pluck(data, "restaurant.title");
// => ["The Best Restaurant"]

pluck(data, "restaurant.reviews");
// => [{ rating: 8.5 }, { rating: 2.7 }, { rating: 9.1 }]

pluck(data, "restaurant.reviews.rating");
// => [8.5, 2.7, 9.1]

Licence

dirty-pluck is released under the MIT License.

Acknowledgements

This package is inspired by JSONata and JMESpath and fostered by the people at Primevise and Mintis

About

Tiny library for plucking JSON values, but dirty.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published