@inglorious/utils 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +9 -0
- package/README.md +71 -0
- package/package.json +48 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright © 2025 Inglorious Coderz Srl.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# @inglorious/utils
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@inglorious/utils)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
|
|
6
|
+
A set of general-purpose utility functions designed with functional programming principles in mind. This package is part of the [Inglorious Engine](https://github.com/IngloriousCoderz/inglorious-engine) monorepo.
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
This package provides a collection of pure, composable helper functions to streamline development in any JavaScript or TypeScript project. It embraces a data-oriented and functional approach, operating on plain data structures like objects and arrays.
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install @inglorious/utils
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
Here are a few examples of how you can use the utilities in this package.
|
|
21
|
+
|
|
22
|
+
### `pipe`
|
|
23
|
+
|
|
24
|
+
Compose functions together in a readable, left-to-right sequence.
|
|
25
|
+
|
|
26
|
+
```javascript
|
|
27
|
+
import { pipe } from "@inglorious/utils/function"
|
|
28
|
+
|
|
29
|
+
const add = (a) => (b) => a + b
|
|
30
|
+
const multiply = (a) => (b) => a * b
|
|
31
|
+
|
|
32
|
+
const calculate = pipe(
|
|
33
|
+
add(5), // 10 + 5 = 15
|
|
34
|
+
multiply(2), // 15 * 2 = 30
|
|
35
|
+
add(10), // 30 + 10 = 40
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
const result = calculate(10) // 40
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Vector Math
|
|
42
|
+
|
|
43
|
+
Perform vector operations on plain objects.
|
|
44
|
+
|
|
45
|
+
```javascript
|
|
46
|
+
import { add } from "@inglorious/utils/vector"
|
|
47
|
+
|
|
48
|
+
const position = { x: 10, y: 20 }
|
|
49
|
+
const velocity = { x: 2, y: -1 }
|
|
50
|
+
|
|
51
|
+
const newPosition = add(position, velocity)
|
|
52
|
+
// => { x: 12, y: 19 }
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## API
|
|
56
|
+
|
|
57
|
+
This package is designed to be used with subpath imports, which helps with tree-shaking.
|
|
58
|
+
|
|
59
|
+
- **`@inglorious/utils/function`**: Utilities for function composition.
|
|
60
|
+
- **`@inglorious/utils/vector`**: Utilities for 2D vector math on plain objects.
|
|
61
|
+
- **`@inglorious/utils/random`**: Utilities for random number and data generation.
|
|
62
|
+
|
|
63
|
+
_(This is a sample API. Please update it to reflect the actual exported functions.)_
|
|
64
|
+
|
|
65
|
+
## Contributing
|
|
66
|
+
|
|
67
|
+
We welcome contributions! Please see the root `CONTRIBUTING.md` file for more details.
|
|
68
|
+
|
|
69
|
+
## License
|
|
70
|
+
|
|
71
|
+
This project is licensed under the MIT License.
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@inglorious/utils",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A set of general-purpose utility functions designed with functional programming principles in mind.",
|
|
5
|
+
"author": "IceOnFire <antony.mistretta@gmail.com> (https://ingloriouscoderz.it)",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/IngloriousCoderz/inglorious-engine.git"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://inglorious-engine.vercel.app/",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/IngloriousCoderz/inglorious-engine/issues"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"functional-programming",
|
|
17
|
+
"gamedev",
|
|
18
|
+
"game-engine",
|
|
19
|
+
"inglorious-engine",
|
|
20
|
+
"utils"
|
|
21
|
+
],
|
|
22
|
+
"type": "module",
|
|
23
|
+
"files": [
|
|
24
|
+
"src",
|
|
25
|
+
"README.md",
|
|
26
|
+
"LICENSE"
|
|
27
|
+
],
|
|
28
|
+
"exports": {
|
|
29
|
+
"./*": "./*"
|
|
30
|
+
},
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"prettier": "^3.6.2",
|
|
36
|
+
"vite": "^7.1.3",
|
|
37
|
+
"vitest": "^1.6.1"
|
|
38
|
+
},
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">= 22"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"format": "prettier --write '**/*.{js,jsx}'",
|
|
44
|
+
"lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0",
|
|
45
|
+
"test:watch": "vitest",
|
|
46
|
+
"test": "vitest run"
|
|
47
|
+
}
|
|
48
|
+
}
|