aang 1.1.0-alpha.1

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 ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 Aadit M Shah
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,23 @@
1
+ <p align="center">
2
+ <img src="aang.svg" align="center" alt="Aang Logo" />
3
+ <h1 align="center">Aang (安昂)</h1>
4
+ <p align="center">A powerful functional programming library for TypeScript.</p>
5
+ </p>
6
+ <br/>
7
+ <p align="center">
8
+ <a href="https://github.com/aaditmshah/aang/actions/workflows/continuous-deployment.yml">
9
+ <img src="https://img.shields.io/github/actions/workflow/status/aaditmshah/aang/continuous-deployment.yml?branch=alpha&logo=github" alt="GitHub Workflow Status" />
10
+ </a>
11
+ <a href="https://github.com/aaditmshah/aang/blob/alpha/LICENSE">
12
+ <img src="https://img.shields.io/github/license/aaditmshah/aang" alt="GitHub license" />
13
+ </a>
14
+ <a href="https://www.npmjs.com/package/aang">
15
+ <img src="https://img.shields.io/npm/v/aang?logo=npm" alt="npm" />
16
+ </a>
17
+ <a href="https://github.com/semantic-release/semantic-release">
18
+ <img src="https://img.shields.io/badge/semantic--release-gitmoji-E10079?logo=semantic-release" alt="semantic-release: gitmoji" />
19
+ </a>
20
+ <a href="https://twitter.com/intent/tweet?text=Wow:&url=https%3A%2F%2Fgithub.com%2Faaditmshah%2Faang">
21
+ <img src="https://img.shields.io/twitter/url?url=https%3A%2F%2Fgithub.com%2Faaditmshah%2Faang" alt="Twitter" />
22
+ </a>
23
+ </p>
package/lib/add.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare const add: (x: number, y: number) => number;
package/lib/add.js ADDED
@@ -0,0 +1 @@
1
+ export const add = (x, y) => x + y;
@@ -0,0 +1,9 @@
1
+ export interface ErrorOptions {
2
+ cause?: unknown;
3
+ }
4
+ export declare abstract class CustomError extends Error {
5
+ constructor(name: string, message?: string, options?: ErrorOptions);
6
+ }
7
+ export declare class UnsafeExtractError extends CustomError {
8
+ constructor(message: string);
9
+ }
package/lib/errors.js ADDED
@@ -0,0 +1,19 @@
1
+ export class CustomError extends Error {
2
+ constructor(name, message, options) {
3
+ super(message, options);
4
+ Object.defineProperty(this, "name", {
5
+ value: name,
6
+ enumerable: false,
7
+ configurable: true,
8
+ });
9
+ Object.setPrototypeOf(this, new.target.prototype);
10
+ if ("captureStackTrace" in Error) {
11
+ Error.captureStackTrace(this, new.target);
12
+ }
13
+ }
14
+ }
15
+ export class UnsafeExtractError extends CustomError {
16
+ constructor(message) {
17
+ super("UnsafeExtractError", message);
18
+ }
19
+ }
package/lib/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./add.js";
2
+ export * from "./errors.js";
package/lib/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./add.js";
2
+ export * from "./errors.js";
@@ -0,0 +1,20 @@
1
+ export type Option<A> = Some<A> | None;
2
+ declare abstract class OptionMethods {
3
+ abstract readonly isSome: boolean;
4
+ abstract readonly isNone: boolean;
5
+ map<A, B>(this: Option<A>, morphism: (value: A) => B): Option<B>;
6
+ unsafeExtract<A>(this: Option<A>, error: Error | string): A;
7
+ }
8
+ declare class Some<out A> extends OptionMethods {
9
+ readonly value: A;
10
+ readonly isSome = true;
11
+ readonly isNone = false;
12
+ constructor(value: A);
13
+ }
14
+ declare class None extends OptionMethods {
15
+ readonly isSome = false;
16
+ readonly isNone = true;
17
+ }
18
+ export declare const some: <A>(value: A) => Some<A>;
19
+ export declare const none: None;
20
+ export type { Some, None };
package/lib/option.js ADDED
@@ -0,0 +1,26 @@
1
+ import { UnsafeExtractError } from "./errors.js";
2
+ class OptionMethods {
3
+ map(morphism) {
4
+ return this.isSome ? new Some(morphism(this.value)) : none;
5
+ }
6
+ unsafeExtract(error) {
7
+ if (this.isSome)
8
+ return this.value;
9
+ throw error instanceof Error ? error : new UnsafeExtractError(error);
10
+ }
11
+ }
12
+ class Some extends OptionMethods {
13
+ value;
14
+ isSome = true;
15
+ isNone = false;
16
+ constructor(value) {
17
+ super();
18
+ this.value = value;
19
+ }
20
+ }
21
+ class None extends OptionMethods {
22
+ isSome = false;
23
+ isNone = true;
24
+ }
25
+ export const some = (value) => new Some(value);
26
+ export const none = new None();
package/package.json ADDED
@@ -0,0 +1,90 @@
1
+ {
2
+ "name": "aang",
3
+ "version": "1.1.0-alpha.1",
4
+ "description": "A powerful functional programming library for TypeScript.",
5
+ "keywords": [
6
+ "aang",
7
+ "functional",
8
+ "library",
9
+ "typescript"
10
+ ],
11
+ "homepage": "https://github.com/aaditmshah/aang",
12
+ "bugs": "https://github.com/aaditmshah/aang/issues",
13
+ "license": "MIT",
14
+ "author": "Aadit M Shah <aaditmshah@aadit.codes> (https://aadit.codes/)",
15
+ "funding": [
16
+ {
17
+ "type": "individual",
18
+ "url": "https://aadit.codes/sponsor"
19
+ },
20
+ {
21
+ "type": "github",
22
+ "url": "https://github.com/sponsors/aaditmshah"
23
+ },
24
+ {
25
+ "type": "opencollective",
26
+ "url": "https://opencollective.com/aaditmshah"
27
+ },
28
+ {
29
+ "type": "patreon",
30
+ "url": "https://www.patreon.com/aaditmshah"
31
+ },
32
+ {
33
+ "type": "buymeacoffee",
34
+ "url": "https://www.buymeacoffee.com/aaditmshah"
35
+ }
36
+ ],
37
+ "files": [
38
+ "lib"
39
+ ],
40
+ "type": "module",
41
+ "exports": "./lib/index.js",
42
+ "types": "./lib/index.d.ts",
43
+ "repository": "github:aaditmshah/aang",
44
+ "scripts": {
45
+ "clean": "git clean -fdx",
46
+ "prettier:write": "prettier --write .",
47
+ "prettier:check": "prettier --check .",
48
+ "lint": "eslint .",
49
+ "typecheck": "tsc --noEmit",
50
+ "test": "rimraf coverage && jest",
51
+ "build": "rimraf lib && tsc -p tsconfig.build.json",
52
+ "check": "concurrently --kill-others-on-fail 'pnpm prettier:check' 'pnpm lint' 'pnpm typecheck' 'pnpm test' 'pnpm build'",
53
+ "prepare": "is-ci || husky install"
54
+ },
55
+ "devDependencies": {
56
+ "@jest/globals": "^29.7.0",
57
+ "@semantic-release/changelog": "^6.0.3",
58
+ "@semantic-release/exec": "^6.0.3",
59
+ "@semantic-release/git": "^10.0.1",
60
+ "@types/node": "^20.11.6",
61
+ "@typescript-eslint/eslint-plugin": "^6.19.1",
62
+ "@typescript-eslint/parser": "^6.19.1",
63
+ "concurrently": "^8.2.2",
64
+ "eslint": "^8.56.0",
65
+ "eslint-config-prettier": "^9.1.0",
66
+ "eslint-import-resolver-typescript": "^3.6.1",
67
+ "eslint-plugin-eslint-comments": "^3.2.0",
68
+ "eslint-plugin-import": "^2.29.1",
69
+ "eslint-plugin-jest": "^27.6.3",
70
+ "eslint-plugin-promise": "^6.1.1",
71
+ "eslint-plugin-unicorn": "^50.0.1",
72
+ "fast-check": "^3.15.0",
73
+ "gitmoji-cli": "^9.0.0",
74
+ "husky": "^8.0.3",
75
+ "is-ci": "^3.0.1",
76
+ "jest": "^29.7.0",
77
+ "prettier": "^3.2.4",
78
+ "rimraf": "^5.0.5",
79
+ "semantic-release": "^22.0.12",
80
+ "semantic-release-gitmoji": "^1.6.5",
81
+ "ts-jest": "^29.1.2",
82
+ "typescript": "^5.3.3"
83
+ },
84
+ "engines": {
85
+ "node": ">=16.9"
86
+ },
87
+ "publishConfig": {
88
+ "access": "public"
89
+ }
90
+ }