New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

array-of-objects-functions

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array-of-objects-functions

Useful functions to use with array of objects.

latest
Source
npmnpm
Version
0.2.1
Version published
Maintainers
1
Created
Source

Array of Objects

Useful functions to help working with Javascript Array of Objects


Usage

Install the package

package.json

{
  "dependencies": {
    "array-of-objects-functions": "latest"
  }
}

After that (with Yarn):

yarn install

Or with NPM:

npm install

And finally you can use it in your project:

import { getUniqueValues } from "array-of-objects-functions"

const arrayOfObjects = [
  {
    name: "John"
  },
  {
    name: "James"
  },
  {
    name: "John"
  }
]

const uniqueNames = getUniqueValues(arrayOfObjects, "name")

Functions

1) getUniqueValues(arrayOfObjects, propertyName)

This function returns an array containing only the unique values of a specific property in the objects. It accepts as parameters first the ArrayOfObjects and second - a string of the property name.

2) findFirstOneMatching(arrayOfObjects, propertyName, propertyValue)

3) findLastOneMatching(arrayOfObjects, propertyName, propertyValue)

4) findAllMatching(arrayOfObjects, propertyName, propertyValue)

5) removeFirstOneMatching(arrayOfObjects, propertyName, propertyValue)

6) removeLastOneMatching(arrayOfObjects, propertyName, propertyValue)

7) removeAllMatching(arrayOfObjects, propertyName, propertyValue)

Contribution

Everybody can contribute

Useful commands (examples with yarn)

Build your code:

yarn build

Run tests:

yarn test

Generate test coverage:

yarn test:coverage

Run ESLint:

yarn lint

Important

Please before opening a PR for this package - run tests and eslint and fix the errors in your code. Also for new functions - please add tests.

License

MIT

Keywords

array

FAQs

Package last updated on 29 Jan 2022

Did you know?

Socket

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.

Install

Related posts