Git Product home page Git Product logo

unique-objects's Introduction

unique-objects CI

Get unique objects from array of objects based on single/multiple keys.

Install

$ npm i unique-objects

Usage

This can be helpful in cases where you need unique records based on a single key or multiple keys.

const uniqueObjects = require('unique-objects');
const users = [
	{ id: 1, username: 'bret' },
	{ id: 2, username: 'samantha' },
	{ id: 2, username: 'samantha' },
	{ id: 2, username: 'samantha2' },
	{ id: 3, username: 'elvis' },
	{ id: 3, username: 'elvis2' },
	{ id: 3, username: 'elvis2' }
];

// Get unique objects in the users array based on just id
uniqueObjects(users, ['id']);

//=> Returns just 3 unique objects out of 7
// [
// 	{ "id": 1, "username": "bret"},
// 	{ "id": 2, "username": "samantha2"},
// 	{ "id": 3, "username": "elvis2"},
// ]

// Get unique objects in the users array based on both id & username
uniqueObjects(users, ['id', 'username']);

//=> Returns just 5 unique objects out of 7
// [
// 	{ "id": 1, "username": "bret"},
// 	{ "id": 2, "username": "samantha"},
// 	{ "id": 2, "username": "samantha2"},
// 	{ "id": 3, "username": "elvis"},
// 	{ "id": 3, "username": "elvis2"},
// ]

API

uniqueObjects(arrayInput, keys)

arrayInput

Type: Array
Default: []

Must be a JavaScript Array. This is main array of object that we are going to process.

keys

Type: Array
Default: []

Must be a JavaScript Array. This is the array of key(s) in the object that is used to find object is unique or not.

License

MIT © Palash Mondal

unique-objects's People

Contributors

dependabot[bot] avatar github-actions[bot] avatar greenkeeper[bot] avatar mergify[bot] avatar palashmon avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

unique-objects's Issues

Add CI/CD pipeline configuration

Add CI/CD pipeline configuration

CI/CD (Continuous Integration/Continuous Deployment) pipelines are a set of automated processes that build, test, and deploy code changes. Adding a CI/CD pipeline to a GitHub project can have several advantages, including:

  • Faster and more reliable releases: With a CI/CD pipeline, code changes are automatically built, tested, and deployed. This can help identify issues earlier in the development process and reduce the risk of introducing bugs into the production environment.
  • More efficient use of resources: By automating the build, test, and deployment processes, developers can spend more time on writing code and less time on manual tasks.
  • Consistent and standardized deployments: A CI/CD pipeline can help ensure that code changes are deployed consistently and according to defined standards.
  • Improved collaboration: By using a CI/CD pipeline, developers can work more closely together and share their work more easily, leading to better collaboration and faster development.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.