build(deps): add eslint
This commit is contained in:
68
.eslintrc.cjs
Normal file
68
.eslintrc.cjs
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
module.exports = {
|
||||||
|
root: true,
|
||||||
|
parser: "@typescript-eslint/parser",
|
||||||
|
parserOptions: {
|
||||||
|
project: ["./tsconfig.json"],
|
||||||
|
ecmaVersion: 2016,
|
||||||
|
},
|
||||||
|
plugins: ["@typescript-eslint", "prefer-arrow"],
|
||||||
|
extends: [
|
||||||
|
"eslint:recommended",
|
||||||
|
"plugin:@typescript-eslint/recommended",
|
||||||
|
"plugin:@typescript-eslint/recommended-requiring-type-checking",
|
||||||
|
"plugin:security/recommended-legacy",
|
||||||
|
"prettier",
|
||||||
|
],
|
||||||
|
ignorePatterns: ["*.js"],
|
||||||
|
env: {
|
||||||
|
browser: true,
|
||||||
|
es2016: true,
|
||||||
|
node: true,
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
"@typescript-eslint/no-misused-promises": [
|
||||||
|
"error",
|
||||||
|
{ checksVoidReturn: false },
|
||||||
|
],
|
||||||
|
"@typescript-eslint/no-unsafe-argument": "off",
|
||||||
|
"@typescript-eslint/naming-convention": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
selector: "interface",
|
||||||
|
format: ["PascalCase"],
|
||||||
|
prefix: ["I"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
selector: "typeLike",
|
||||||
|
format: ["PascalCase"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
selector: "variableLike",
|
||||||
|
format: ["camelCase", "UPPER_CASE"],
|
||||||
|
leadingUnderscore: "allow",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"@typescript-eslint/prefer-ts-expect-error": "error",
|
||||||
|
"prefer-arrow/prefer-arrow-functions": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
disallowPrototype: true,
|
||||||
|
singleReturnOnly: false,
|
||||||
|
classPropertiesAllowed: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
eqeqeq: "error",
|
||||||
|
curly: ["error", "all"],
|
||||||
|
"no-console": ["warn", { allow: ["warn", "error"] }],
|
||||||
|
"no-eval": "error",
|
||||||
|
"brace-style": ["error", "1tbs"],
|
||||||
|
"arrow-body-style": ["error", "as-needed"],
|
||||||
|
"object-shorthand": ["error", "always"],
|
||||||
|
"no-lonely-if": "error",
|
||||||
|
"prefer-const": "error",
|
||||||
|
"prefer-arrow-callback": "error",
|
||||||
|
"no-var": "error",
|
||||||
|
"default-case-last": "warn",
|
||||||
|
"no-nested-ternary": "warn",
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
### Functions
|
### Functions
|
||||||
|
|
||||||
- [SplitIntoChunks](modules.md#splitintochunks)
|
|
||||||
- [capitalizeFirstChar](modules.md#capitalizefirstchar)
|
- [capitalizeFirstChar](modules.md#capitalizefirstchar)
|
||||||
- [classNames](modules.md#classnames)
|
- [classNames](modules.md#classnames)
|
||||||
- [conditionalJoin](modules.md#conditionaljoin)
|
- [conditionalJoin](modules.md#conditionaljoin)
|
||||||
@@ -15,40 +14,10 @@
|
|||||||
- [removeFromArrayByKeyValue](modules.md#removefromarraybykeyvalue)
|
- [removeFromArrayByKeyValue](modules.md#removefromarraybykeyvalue)
|
||||||
- [removeObjectProperty](modules.md#removeobjectproperty)
|
- [removeObjectProperty](modules.md#removeobjectproperty)
|
||||||
- [replaceFromArrayByKeyValue](modules.md#replacefromarraybykeyvalue)
|
- [replaceFromArrayByKeyValue](modules.md#replacefromarraybykeyvalue)
|
||||||
|
- [splitIntoChunks](modules.md#splitintochunks)
|
||||||
|
|
||||||
## Functions
|
## Functions
|
||||||
|
|
||||||
### SplitIntoChunks
|
|
||||||
|
|
||||||
▸ **SplitIntoChunks**\<`T`\>(`array`, `chunkSize`): `T`[][]
|
|
||||||
|
|
||||||
Splits an array into chunks
|
|
||||||
|
|
||||||
#### Type parameters
|
|
||||||
|
|
||||||
| Name |
|
|
||||||
| :------ |
|
|
||||||
| `T` |
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
| Name | Type | Description |
|
|
||||||
| :------ | :------ | :------ |
|
|
||||||
| `array` | `T`[] | array which shall be split into chunks |
|
|
||||||
| `chunkSize` | `number` | size of a single chunk |
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`T`[][]
|
|
||||||
|
|
||||||
array of chunks
|
|
||||||
|
|
||||||
#### Defined in
|
|
||||||
|
|
||||||
functions/splitIntoChuks.ts:27
|
|
||||||
|
|
||||||
___
|
|
||||||
|
|
||||||
### capitalizeFirstChar
|
### capitalizeFirstChar
|
||||||
|
|
||||||
▸ **capitalizeFirstChar**(`string`): `string`
|
▸ **capitalizeFirstChar**(`string`): `string`
|
||||||
@@ -209,35 +178,37 @@ modified array
|
|||||||
**`Remarks`**
|
**`Remarks`**
|
||||||
|
|
||||||
This method doesn't support deep comparements.
|
This method doesn't support deep comparements.
|
||||||
|
Vulnerable to generic object injection sink
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
functions/removeFromArrayByKeyValue.ts:30
|
functions/removeFromArrayByKeyValue.ts:31
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
### removeObjectProperty
|
### removeObjectProperty
|
||||||
|
|
||||||
▸ **removeObjectProperty**\<`T`\>(`object`, `key`): `T`
|
▸ **removeObjectProperty**\<`T`, `K`\>(`object`, `key`): `Omit`\<`T`, `K`\>
|
||||||
|
|
||||||
Removes an object property by provided key
|
Removes an object property by provided key
|
||||||
|
|
||||||
#### Type parameters
|
#### Type parameters
|
||||||
|
|
||||||
| Name |
|
| Name | Type |
|
||||||
| :------ |
|
| :------ | :------ |
|
||||||
| `T` |
|
| `T` | `T` |
|
||||||
|
| `K` | extends `string` \| `number` \| `symbol` |
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `object` | `T` | object which shall be manipulated |
|
| `object` | `T` | object which shall be manipulated |
|
||||||
| `key` | keyof `T` | key which should be used to remove a property from object |
|
| `key` | `K` | key which should be used to remove a property from object |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`T`
|
`Omit`\<`T`, `K`\>
|
||||||
|
|
||||||
new object
|
new object
|
||||||
|
|
||||||
@@ -276,7 +247,39 @@ modified array
|
|||||||
**`Remarks`**
|
**`Remarks`**
|
||||||
|
|
||||||
This method doesn't support deep comparements.
|
This method doesn't support deep comparements.
|
||||||
|
Vulnerable to generic object injection sink
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
functions/replaceFromArrayByKeyValue.ts:31
|
functions/replaceFromArrayByKeyValue.ts:32
|
||||||
|
|
||||||
|
___
|
||||||
|
|
||||||
|
### splitIntoChunks
|
||||||
|
|
||||||
|
▸ **splitIntoChunks**\<`T`\>(`array`, `chunkSize`): `T`[][]
|
||||||
|
|
||||||
|
Splits an array into chunks
|
||||||
|
|
||||||
|
#### Type parameters
|
||||||
|
|
||||||
|
| Name |
|
||||||
|
| :------ |
|
||||||
|
| `T` |
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
| :------ | :------ | :------ |
|
||||||
|
| `array` | `T`[] | array which shall be split into chunks |
|
||||||
|
| `chunkSize` | `number` | size of a single chunk |
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`T`[][]
|
||||||
|
|
||||||
|
array of chunks
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
functions/splitIntoChuks.ts:27
|
||||||
|
|||||||
@@ -12,7 +12,8 @@
|
|||||||
"build": "pnpm run build:package && pnpm run build:docs",
|
"build": "pnpm run build:package && pnpm run build:docs",
|
||||||
"build:package": "rm -rf dist && tsc --module ESNext --outdir dist/esm && tsc --module commonjs --outdir dist/cjs",
|
"build:package": "rm -rf dist && tsc --module ESNext --outdir dist/esm && tsc --module commonjs --outdir dist/cjs",
|
||||||
"build:docs": "typedoc --plugin typedoc-plugin-markdown src",
|
"build:docs": "typedoc --plugin typedoc-plugin-markdown src",
|
||||||
"prepublish": "pnpm run build"
|
"prepublish": "pnpm run build",
|
||||||
|
"lint": "eslint src"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -29,6 +30,12 @@
|
|||||||
"license": "GPL-3.0-or-later",
|
"license": "GPL-3.0-or-later",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^20.11.25",
|
"@types/node": "^20.11.25",
|
||||||
|
"@typescript-eslint/eslint-plugin": "^7.2.0",
|
||||||
|
"@typescript-eslint/parser": "^7.2.0",
|
||||||
|
"eslint": "^8.57.0",
|
||||||
|
"eslint-config-prettier": "^9.1.0",
|
||||||
|
"eslint-plugin-prefer-arrow": "^1.2.3",
|
||||||
|
"eslint-plugin-security": "^2.1.1",
|
||||||
"prettier": "^3.2.5",
|
"prettier": "^3.2.5",
|
||||||
"typedoc": "^0.25.12",
|
"typedoc": "^0.25.12",
|
||||||
"typedoc-plugin-markdown": "^3.17.1",
|
"typedoc-plugin-markdown": "^3.17.1",
|
||||||
|
|||||||
960
pnpm-lock.yaml
generated
960
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -1,20 +1,20 @@
|
|||||||
/*
|
/**
|
||||||
Copyright 2024 Resultium LLC
|
* Copyright 2024 Resultium LLC
|
||||||
|
*
|
||||||
This file is part of @resultium/utils.
|
* This file is part of @resultium/utils.
|
||||||
|
*
|
||||||
@resultium/utils is free software: you can redistribute it and/or modify
|
* @resultium/utils is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
any later version.
|
* any later version.
|
||||||
|
*
|
||||||
@resultium/utils is distributed in the hope that it will be useful,
|
* @resultium/utils is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
along with RCZ. If not, see <https://www.gnu.org/licenses/>.
|
* along with RCZ. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -23,6 +23,5 @@ along with RCZ. If not, see <https://www.gnu.org/licenses/>.
|
|||||||
* @param string - string to modify
|
* @param string - string to modify
|
||||||
* @returns new string
|
* @returns new string
|
||||||
*/
|
*/
|
||||||
export const capitalizeFirstChar = (string: string) => {
|
export const capitalizeFirstChar = (string: string) =>
|
||||||
return `${string[0].toUpperCase()}${string.slice(1)}`;
|
`${string[0].toUpperCase()}${string.slice(1)}`;
|
||||||
};
|
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
/*
|
/**
|
||||||
Copyright 2024 Resultium LLC
|
* Copyright 2024 Resultium LLC
|
||||||
|
*
|
||||||
This file is part of @resultium/utils.
|
* This file is part of @resultium/utils.
|
||||||
|
*
|
||||||
@resultium/utils is free software: you can redistribute it and/or modify
|
* @resultium/utils is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
any later version.
|
* any later version.
|
||||||
|
*
|
||||||
@resultium/utils is distributed in the hope that it will be useful,
|
* @resultium/utils is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
along with RCZ. If not, see <https://www.gnu.org/licenses/>.
|
* along with RCZ. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
/*
|
/**
|
||||||
Copyright 2024 Resultium LLC
|
* Copyright 2024 Resultium LLC
|
||||||
|
*
|
||||||
This file is part of @resultium/utils.
|
* This file is part of @resultium/utils.
|
||||||
|
*
|
||||||
@resultium/utils is free software: you can redistribute it and/or modify
|
* @resultium/utils is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
any later version.
|
* any later version.
|
||||||
|
*
|
||||||
@resultium/utils is distributed in the hope that it will be useful,
|
* @resultium/utils is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
along with RCZ. If not, see <https://www.gnu.org/licenses/>.
|
* along with RCZ. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
/*
|
/**
|
||||||
Copyright 2024 Resultium LLC
|
* Copyright 2024 Resultium LLC
|
||||||
|
*
|
||||||
This file is part of @resultium/utils.
|
* This file is part of @resultium/utils.
|
||||||
|
*
|
||||||
@resultium/utils is free software: you can redistribute it and/or modify
|
* @resultium/utils is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
any later version.
|
* any later version.
|
||||||
|
*
|
||||||
@resultium/utils is distributed in the hope that it will be useful,
|
* @resultium/utils is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
along with RCZ. If not, see <https://www.gnu.org/licenses/>.
|
* along with RCZ. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -26,6 +26,5 @@ along with RCZ. If not, see <https://www.gnu.org/licenses/>.
|
|||||||
* @param obj2 - second object to compare with first
|
* @param obj2 - second object to compare with first
|
||||||
* @returns true if equal
|
* @returns true if equal
|
||||||
*/
|
*/
|
||||||
export const isDeepWeakEqual = (obj1: object, obj2: object) => {
|
export const isDeepWeakEqual = (obj1: object, obj2: object) =>
|
||||||
return JSON.stringify(obj1) === JSON.stringify(obj2);
|
JSON.stringify(obj1) === JSON.stringify(obj2);
|
||||||
};
|
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
/*
|
/**
|
||||||
Copyright 2024 Resultium LLC
|
* Copyright 2024 Resultium LLC
|
||||||
|
*
|
||||||
This file is part of @resultium/utils.
|
* This file is part of @resultium/utils.
|
||||||
|
*
|
||||||
@resultium/utils is free software: you can redistribute it and/or modify
|
* @resultium/utils is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
any later version.
|
* any later version.
|
||||||
|
*
|
||||||
@resultium/utils is distributed in the hope that it will be useful,
|
* @resultium/utils is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
along with RCZ. If not, see <https://www.gnu.org/licenses/>.
|
* along with RCZ. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -28,6 +28,5 @@ along with RCZ. If not, see <https://www.gnu.org/licenses/>.
|
|||||||
* @param max - maximum acceptable value
|
* @param max - maximum acceptable value
|
||||||
* @returns number [min; max]
|
* @returns number [min; max]
|
||||||
*/
|
*/
|
||||||
export const randomInRange = (min: number, max: number) => {
|
export const randomInRange = (min: number, max: number) =>
|
||||||
return Math.floor(Math.random() * (max - min)) + min;
|
Math.floor(Math.random() * (max - min)) + min;
|
||||||
};
|
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
/*
|
/**
|
||||||
Copyright 2024 Resultium LLC
|
* Copyright 2024 Resultium LLC
|
||||||
|
*
|
||||||
This file is part of @resultium/utils.
|
* This file is part of @resultium/utils.
|
||||||
|
*
|
||||||
@resultium/utils is free software: you can redistribute it and/or modify
|
* @resultium/utils is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
any later version.
|
* any later version.
|
||||||
|
*
|
||||||
@resultium/utils is distributed in the hope that it will be useful,
|
* @resultium/utils is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
along with RCZ. If not, see <https://www.gnu.org/licenses/>.
|
* along with RCZ. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -22,6 +22,7 @@ along with RCZ. If not, see <https://www.gnu.org/licenses/>.
|
|||||||
*
|
*
|
||||||
* @remarks
|
* @remarks
|
||||||
* This method doesn't support deep comparements.
|
* This method doesn't support deep comparements.
|
||||||
|
* Vulnerable to generic object injection sink
|
||||||
*
|
*
|
||||||
* @param array - array which shall be manipulated with
|
* @param array - array which shall be manipulated with
|
||||||
* @param keyValue - key-value object which defines which object shall be removed from the array
|
* @param keyValue - key-value object which defines which object shall be removed from the array
|
||||||
@@ -33,7 +34,8 @@ export const removeFromArrayByKeyValue = <T>(
|
|||||||
) => {
|
) => {
|
||||||
const keys = Object.keys(keyValue) as Array<keyof T>;
|
const keys = Object.keys(keyValue) as Array<keyof T>;
|
||||||
|
|
||||||
return array.filter((item) => {
|
return array.filter(
|
||||||
return !keys.every((key) => item[key] === keyValue[key]);
|
// eslint-disable-next-line security/detect-object-injection -- warned at remarks
|
||||||
});
|
(item) => !keys.every((key) => item[key] === keyValue[key]),
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
/*
|
/**
|
||||||
Copyright 2024 Resultium LLC
|
* Copyright 2024 Resultium LLC
|
||||||
|
*
|
||||||
This file is part of @resultium/utils.
|
* This file is part of @resultium/utils.
|
||||||
|
*
|
||||||
@resultium/utils is free software: you can redistribute it and/or modify
|
* @resultium/utils is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
any later version.
|
* any later version.
|
||||||
|
*
|
||||||
@resultium/utils is distributed in the hope that it will be useful,
|
* @resultium/utils is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
along with RCZ. If not, see <https://www.gnu.org/licenses/>.
|
* along with RCZ. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -24,7 +24,11 @@ along with RCZ. If not, see <https://www.gnu.org/licenses/>.
|
|||||||
* @param key - key which should be used to remove a property from object
|
* @param key - key which should be used to remove a property from object
|
||||||
* @returns new object
|
* @returns new object
|
||||||
*/
|
*/
|
||||||
export const removeObjectProperty = <T>(object: T, key: keyof T) => {
|
export const removeObjectProperty = <T, K extends keyof T>(
|
||||||
|
object: T,
|
||||||
|
key: K,
|
||||||
|
): Omit<T, K> => {
|
||||||
|
// eslint-disable-next-line security/detect-object-injection -- delete operation is performed
|
||||||
delete object[key];
|
delete object[key];
|
||||||
return object;
|
return object;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
/*
|
/**
|
||||||
Copyright 2024 Resultium LLC
|
* Copyright 2024 Resultium LLC
|
||||||
|
*
|
||||||
This file is part of @resultium/utils.
|
* This file is part of @resultium/utils.
|
||||||
|
*
|
||||||
@resultium/utils is free software: you can redistribute it and/or modify
|
* @resultium/utils is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
any later version.
|
* any later version.
|
||||||
|
*
|
||||||
@resultium/utils is distributed in the hope that it will be useful,
|
* @resultium/utils is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
along with RCZ. If not, see <https://www.gnu.org/licenses/>.
|
* along with RCZ. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -22,6 +22,7 @@ along with RCZ. If not, see <https://www.gnu.org/licenses/>.
|
|||||||
*
|
*
|
||||||
* @remarks
|
* @remarks
|
||||||
* This method doesn't support deep comparements.
|
* This method doesn't support deep comparements.
|
||||||
|
* Vulnerable to generic object injection sink
|
||||||
*
|
*
|
||||||
* @param array - array which shall be manipulated with
|
* @param array - array which shall be manipulated with
|
||||||
* @param keyValue - key-value object which defines which object shall be removed from the array
|
* @param keyValue - key-value object which defines which object shall be removed from the array
|
||||||
@@ -35,11 +36,13 @@ export const replaceFromArrayByKeyValue = <T>(
|
|||||||
) => {
|
) => {
|
||||||
const keys = Object.keys(keyValue) as Array<keyof T>;
|
const keys = Object.keys(keyValue) as Array<keyof T>;
|
||||||
|
|
||||||
const itemIndex = array.findIndex((item) => {
|
const itemIndex = array.findIndex(
|
||||||
return !keys.every((key) => item[key] === keyValue[key]);
|
(item) =>
|
||||||
});
|
// eslint-disable-next-line security/detect-object-injection -- warned at remarks
|
||||||
|
!keys.every((key) => item[key] === keyValue[key]),
|
||||||
|
);
|
||||||
|
|
||||||
array[itemIndex] = { ...array[itemIndex], ...newObject };
|
array[`${itemIndex}`] = { ...array[`${itemIndex}`], ...newObject };
|
||||||
|
|
||||||
return array;
|
return array;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
/*
|
/**
|
||||||
Copyright 2024 Resultium LLC
|
* Copyright 2024 Resultium LLC
|
||||||
|
*
|
||||||
This file is part of @resultium/utils.
|
* This file is part of @resultium/utils.
|
||||||
|
*
|
||||||
@resultium/utils is free software: you can redistribute it and/or modify
|
* @resultium/utils is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
any later version.
|
* any later version.
|
||||||
|
*
|
||||||
@resultium/utils is distributed in the hope that it will be useful,
|
* @resultium/utils is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
along with RCZ. If not, see <https://www.gnu.org/licenses/>.
|
* along with RCZ. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -24,16 +24,15 @@ along with RCZ. If not, see <https://www.gnu.org/licenses/>.
|
|||||||
* @param chunkSize - size of a single chunk
|
* @param chunkSize - size of a single chunk
|
||||||
* @returns array of chunks
|
* @returns array of chunks
|
||||||
*/
|
*/
|
||||||
export const splitIntoChunks = <T>(array: T[], chunkSize: number): T[][] => {
|
export const splitIntoChunks = <T>(array: T[], chunkSize: number): T[][] =>
|
||||||
return array.reduce<T[][]>((splitArray, item, index) => {
|
array.reduce<T[][]>((splitArray, item, index) => {
|
||||||
const chunkIndex = Math.floor(index / chunkSize);
|
const chunkIndex = Math.floor(index / chunkSize);
|
||||||
|
|
||||||
if (!splitArray[chunkIndex]) {
|
if (!splitArray[`${chunkIndex}`]) {
|
||||||
splitArray[chunkIndex] = [];
|
splitArray[`${chunkIndex}`] = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
splitArray[chunkIndex]?.push(item);
|
splitArray[`${chunkIndex}`]?.push(item);
|
||||||
|
|
||||||
return splitArray;
|
return splitArray;
|
||||||
}, []);
|
}, []);
|
||||||
};
|
|
||||||
|
|||||||
34
src/index.ts
34
src/index.ts
@@ -1,20 +1,20 @@
|
|||||||
/*
|
/**
|
||||||
Copyright 2024 Resultium LLC
|
* Copyright 2024 Resultium LLC
|
||||||
|
*
|
||||||
This file is part of @resultium/utils.
|
* This file is part of @resultium/utils.
|
||||||
|
*
|
||||||
@resultium/utils is free software: you can redistribute it and/or modify
|
* @resultium/utils is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
any later version.
|
* any later version.
|
||||||
|
*
|
||||||
@resultium/utils is distributed in the hope that it will be useful,
|
* @resultium/utils is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
along with RCZ. If not, see <https://www.gnu.org/licenses/>.
|
* along with RCZ. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export * from "./functions/capitalizeFirstChar";
|
export * from "./functions/capitalizeFirstChar";
|
||||||
|
|||||||
Reference in New Issue
Block a user