update tsconfig

This commit is contained in:
Philipp Kunz 2024-04-14 17:20:59 +02:00
parent b9c828f092
commit d608aa81a8
4 changed files with 105 additions and 29 deletions

View File

@ -8,14 +8,28 @@
"description": "a package exposing async manipulation for arrays",
"npmPackagename": "@push.rocks/smartarray",
"license": "MIT",
"projectDomain": "push.rocks"
"projectDomain": "push.rocks",
"keywords": [
"async",
"arrays",
"manipulation",
"filter",
"deduplicate",
"typescript",
"nodejs",
"async programming",
"development",
"npm package",
"code quality",
"open source"
]
}
},
"npmci": {
"npmGlobalTools": [],
"npmAccessLevel": "public"
},
"tsdocs": {
"tsdoc": {
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
}
}

View File

@ -35,5 +35,19 @@
"npmextra.json",
"readme.md"
],
"type": "module"
}
"type": "module",
"keywords": [
"async",
"arrays",
"manipulation",
"filter",
"deduplicate",
"typescript",
"nodejs",
"async programming",
"development",
"npm package",
"code quality",
"open source"
]
}

1
readme.hints.md Normal file
View File

@ -0,0 +1 @@

View File

@ -1,37 +1,84 @@
# @push.rocks/smartarray
a package exposing async manipulation for arrays
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@push.rocks/smartarray)
* [gitlab.com (source)](https://gitlab.com/push.rocks/smartarray)
* [github.com (source mirror)](https://github.com/push.rocks/smartarray)
* [docs (typedoc)](https://push.rocks.gitlab.io/smartarray/)
## Install
To add `@push.rocks/smartarray` to your project, run the following command:
## Status for master
```bash
npm install @push.rocks/smartarray --save
```
Status Category | Status Badge
-- | --
GitLab Pipelines | [![pipeline status](https://gitlab.com/push.rocks/smartarray/badges/master/pipeline.svg)](https://lossless.cloud)
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/push.rocks/smartarray/badges/master/coverage.svg)](https://lossless.cloud)
npm | [![npm downloads per month](https://badgen.net/npm/dy/@push.rocks/smartarray)](https://lossless.cloud)
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/push.rocks/smartarray)](https://lossless.cloud)
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@push.rocks/smartarray)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@push.rocks/smartarray)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@push.rocks/smartarray)](https://lossless.cloud)
This will install the package and add it to your project's dependencies. Ensure you have Node.js and npm installed on your machine before running this command.
## Usage
Use TypeScript for best in class intellisense
`@push.rocks/smartarray` simplifies the manipulation of arrays with asynchronous operations in TypeScript. It provides utility functions such as filtering and deduplication of arrays with asynchronous predicates or key generation functions. Let's delve into code examples to understand how to utilize these features effectively.
## Contribution
### Importing the module
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
First, import the functions you need from the module:
For further information read the linked docs at the top of this readme.
```typescript
import { filter, deduplicate } from '@push.rocks/smartarray';
```
## Legal
> MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
### Filtering an Array Asynchronously
The `filter` function allows you to filter an array based on a predicate function that returns a Promise. This is particularly useful when your filtering condition involves asynchronous operations, such as fetching data from an API or accessing a database.
Suppose you have an array of user IDs, and you want to filter out IDs that do not correspond to active users. You might have an asynchronous function `isActiveUser(userId): Promise<boolean>` that checks user's status. Here's how you can filter out inactive user IDs:
```typescript
const userIds = [1, 2, 3, 4, 5];
const activeUserIds = await filter(userIds, async (userId) => {
return isActiveUser(userId);
});
console.log(activeUserIds); // Logs: [1, 3, 5] assuming these IDs are active
```
### Deduplicating an Array Asynchronously
The `deduplicate` function removes duplicate elements from an array based on a key generated by an asynchronous function. This is handy when you need to remove duplicates based on complex or asynchronous criteria.
Imagine you have an array of objects representing job applications, where each object contains a `userId` and `applicationId`. If you want to ensure that there's only one application per user, you could use the `deduplicate` function as shown:
```typescript
const applications = [
{ userId: 1, applicationId: 'a1' },
{ userId: 2, applicationId: 'a2' },
{ userId: 1, applicationId: 'a3' }, // Duplicate user
{ userId: 3, applicationId: 'a4' }
];
const uniqueApplications = await deduplicate(applications, async (app) => {
// The key is the userId, ensuring uniqueness by user
return app.userId;
});
console.log(uniqueApplications);
// Logs: [{ userId: 1, applicationId: 'a1' }, { userId: 2, applicationId: 'a2' }, { userId: 3, applicationId: 'a4' }]
```
In this example, the second application from the same user (`userId: 1`) was removed, leaving only unique user applications in the array.
These examples illustrate how `@push.rocks/smartarray` can be utilized for asynchronous array manipulation, offering flexibility and performance for handling complex data processing tasks in a modern JavaScript or TypeScript application.
Remember, all operations return promises, so ensure you handle them properly using `async/await` syntax or `.then().catch()` chains according to your application's structure or personal preference.
## License and Legal Information
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
### Trademarks
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
### Company Information
Task Venture Capital GmbH
Registered at District court Bremen HRB 35230 HB, Germany
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.