https://github.com/viktor-maksimov/array-of-objects-functions
Useful functions to use with array of objects.
https://github.com/viktor-maksimov/array-of-objects-functions
array array-of-objects es6 find javascript objects remove typescript unique unique-values values
Last synced: 4 months ago
JSON representation
Useful functions to use with array of objects.
- Host: GitHub
- URL: https://github.com/viktor-maksimov/array-of-objects-functions
- Owner: viktor-maksimov
- License: mit
- Created: 2019-08-04T17:15:48.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-01-29T21:14:28.000Z (over 3 years ago)
- Last Synced: 2025-05-26T18:15:58.658Z (5 months ago)
- Topics: array, array-of-objects, es6, find, javascript, objects, remove, typescript, unique, unique-values, values
- Language: TypeScript
- Homepage:
- Size: 19.5 KB
- Stars: 9
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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