es6-fuzz 5.0.1 → 6.0.3

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.
Files changed (87) hide show
  1. package/.claude/settings.local.json +26 -0
  2. package/Readme.md +2 -5
  3. package/SECURITY.md +151 -0
  4. package/lib/curve/constant.d.ts +17 -0
  5. package/lib/curve/constant.d.ts.map +1 -0
  6. package/lib/curve/constant.js +21 -17
  7. package/lib/curve/constant.js.map +1 -0
  8. package/lib/curve/fuzzy-function.d.ts +15 -0
  9. package/lib/curve/fuzzy-function.d.ts.map +1 -0
  10. package/lib/curve/fuzzy-function.js +24 -19
  11. package/lib/curve/fuzzy-function.js.map +1 -0
  12. package/lib/curve/grade.d.ts +15 -0
  13. package/lib/curve/grade.d.ts.map +1 -0
  14. package/lib/curve/grade.js +30 -26
  15. package/lib/curve/grade.js.map +1 -0
  16. package/lib/curve/reverse-grade.d.ts +11 -0
  17. package/lib/curve/reverse-grade.d.ts.map +1 -0
  18. package/lib/curve/reverse-grade.js +30 -25
  19. package/lib/curve/reverse-grade.js.map +1 -0
  20. package/lib/curve/shape.d.ts +22 -0
  21. package/lib/curve/shape.d.ts.map +1 -0
  22. package/lib/curve/shape.js +32 -25
  23. package/lib/curve/shape.js.map +1 -0
  24. package/lib/curve/sigmoid.d.ts +24 -0
  25. package/lib/curve/sigmoid.d.ts.map +1 -0
  26. package/lib/curve/sigmoid.js +30 -23
  27. package/lib/curve/sigmoid.js.map +1 -0
  28. package/lib/curve/trapezoid.d.ts +15 -0
  29. package/lib/curve/trapezoid.d.ts.map +1 -0
  30. package/lib/curve/trapezoid.js +56 -47
  31. package/lib/curve/trapezoid.js.map +1 -0
  32. package/lib/curve/triangle.d.ts +15 -0
  33. package/lib/curve/triangle.d.ts.map +1 -0
  34. package/lib/curve/triangle.js +55 -47
  35. package/lib/curve/triangle.js.map +1 -0
  36. package/lib/logic.d.ts +49 -0
  37. package/lib/logic.d.ts.map +1 -0
  38. package/lib/logic.js +126 -130
  39. package/lib/logic.js.map +1 -0
  40. package/package.json +12 -6
  41. package/typedoc.json +20 -0
  42. package/docs/CHANGELOG.md +0 -162
  43. package/docs/glossary.md +0 -13
  44. package/docs/manual.md +0 -0
  45. package/jsdoc.json +0 -28
  46. package/scripts/publish-gh.js +0 -6
  47. package/test/curve/constant.test.js +0 -15
  48. package/test/curve/fuzzy-function.test.js +0 -17
  49. package/test/curve/grade.test.js +0 -27
  50. package/test/curve/reverse-grade.test.js +0 -27
  51. package/test/curve/shape.test.js +0 -30
  52. package/test/curve/sigmoid/sigmoid-basic.test.js +0 -27
  53. package/test/curve/sigmoid/sigmoid-center-behavior.test.js +0 -66
  54. package/test/curve/sigmoid/sigmoid-slope.test.js +0 -15
  55. package/test/curve/trapezoid/trapezoid-basic.test.js +0 -54
  56. package/test/curve/trapezoid/trapezoid-bounds.test.js +0 -30
  57. package/test/curve/triangle.test.js +0 -21
  58. package/test/edge-cases/constant-edge-values.test.js +0 -56
  59. package/test/edge-cases/fuzzy-function-edge-cases.test.js +0 -71
  60. package/test/edge-cases/grade-edge-cases.test.js +0 -42
  61. package/test/edge-cases/reverse-grade-edge-cases.test.js +0 -42
  62. package/test/edge-cases/shapes-large-values.test.js +0 -78
  63. package/test/edge-cases/shapes-negative-values.test.js +0 -75
  64. package/test/edge-cases/sigmoid-edge-cases.test.js +0 -70
  65. package/test/edge-cases/trapezoid-special-cases.test.js +0 -94
  66. package/test/edge-cases/triangle-degenerate-cases.test.js +0 -62
  67. package/test/error-handling/empty-rules-handling.test.js +0 -25
  68. package/test/error-handling/es6-class-instantiation.test.js +0 -52
  69. package/test/error-handling/fuzzy-function-validation.test.js +0 -66
  70. package/test/error-handling/invalid-chaining-sequences.test.js +0 -40
  71. package/test/error-handling/logic-validation.test.js +0 -78
  72. package/test/error-handling/property-immutability.test.js +0 -29
  73. package/test/error-handling/shape-constructor-validation.test.js +0 -70
  74. package/test/example.test.js +0 -26
  75. package/test/init-called.test.js +0 -17
  76. package/test/integration/and-or-not-combinations.test.js +0 -42
  77. package/test/integration/complex-logic-chains.test.js +0 -85
  78. package/test/integration/edge-case-combinations.test.js +0 -55
  79. package/test/integration/mixing-shape-types.test.js +0 -44
  80. package/test/integration/performance-many-rules.test.js +0 -42
  81. package/test/integration/real-world-scenarios.test.js +0 -50
  82. package/test/integration/state-management.test.js +0 -47
  83. package/test/js-bool.test.js +0 -87
  84. package/test/logic/attack-rage-calculation.test.js +0 -22
  85. package/test/logic/behaves-like-number.test.js +0 -22
  86. package/test/logic/interface.test.js +0 -20
  87. package/test/logic/not-operation.test.js +0 -17
@@ -0,0 +1,26 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "WebFetch(domain:github.com)",
5
+ "Bash(npm test:*)",
6
+ "Bash(for:*)",
7
+ "Bash(do echo \"=== $file ===\")",
8
+ "Bash(awk:*)",
9
+ "Bash(done)",
10
+ "Bash(do [ \"$file%.test.js\" = \"$file\" ])",
11
+ "Bash(mv:*)",
12
+ "Bash(mkdir:*)",
13
+ "Bash(cp:*)",
14
+ "Bash(rm:*)",
15
+ "Bash(npx tsc:*)",
16
+ "Bash(node:*)",
17
+ "Bash(npm run build:*)",
18
+ "Bash(npx typedoc:*)",
19
+ "Bash(grep:*)",
20
+ "Bash(chmod:*)",
21
+ "Bash(/Users/sebastian.schuermann/private/es6-fuzz/fix-imports.sh:*)",
22
+ "Bash(npm run docs:*)"
23
+ ],
24
+ "deny": []
25
+ }
26
+ }
package/Readme.md CHANGED
@@ -7,8 +7,7 @@
7
7
  [![GitHub tag](https://img.shields.io/github/tag/sebs/es6-fuzz.svg)](https://github.com/sebs/es6-fuzz)
8
8
  [![GitHub issues](https://img.shields.io/github/issues/sebs/es6-fuzz.svg)](https://github.com/sebs/es6-fuzz/issues)
9
9
 
10
- Supported fuzzyfiers
11
-
10
+ ## Supported fuzzyfiers
12
11
 
13
12
  * Constant
14
13
  * Grade
@@ -17,7 +16,6 @@ Supported fuzzyfiers
17
16
  * Trapezoid
18
17
  * Triangle
19
18
 
20
-
21
19
  * [api docs](http://sebs.github.io/es6-fuzz)
22
20
  * [changelog](https://github.com/sebs/es6-fuzz/blob/master/docs/CHANGELOG.md)
23
21
 
@@ -128,9 +126,8 @@ npm test
128
126
 
129
127
  ## Supported Node.js Versions
130
128
 
131
- Versions: 6 and 7
129
+ Versions: 20+
132
130
 
133
131
  ## Related
134
132
 
135
133
  * https://www.npmjs.com/package/gaussian
136
- *
package/SECURITY.md ADDED
@@ -0,0 +1,151 @@
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ Use this section to tell people about which versions of your project are
6
+ currently being supported with security updates.
7
+
8
+ | Version | Supported |
9
+ | ------- | ------------------ |
10
+ | 5.1.x | :white_check_mark: |
11
+ | 5.0.x | :x: |
12
+ | 4.0.x | :X:|
13
+ | < 4.0 | :x: |
14
+
15
+ ## Reporting a Vulnerability
16
+
17
+ **DO NOT create a public GitHub issue for security vulnerabilities.** All security bugs should be reported privately to ensure the safety of our users.
18
+
19
+ ### GitHub Private Vulnerability Reporting (Recommended)
20
+
21
+ If you're using GitHub, you can report vulnerabilities directly through our private reporting system:
22
+
23
+ 1. Go to the [Security tab](https://github.com/sebs/es6-fuzz/security) of this repository
24
+ 2. Click "Report a vulnerability"
25
+ 3. Fill out the form with your findings
26
+
27
+ This method integrates with GitHub's security advisory system and allows for coordinated disclosure.
28
+
29
+ ### Email Reporting
30
+
31
+ For more complex reports or if you prefer email communication:
32
+
33
+ **Email:** security+sebs@2xs.org
34
+
35
+ ### What to Include in Your Report
36
+
37
+ Please include the following information in your report:
38
+
39
+ - **Vulnerability Type**: What kind of security issue (e.g., code injection, XSS, prototype pollution)
40
+ - **Affected Component**: Which part of es6-fuzz is affected (e.g., specific fuzzifier, logic operations)
41
+ - **Impact Assessment**: Potential impact on applications using es6-fuzz
42
+ - **Reproduction Steps**: Clear, step-by-step instructions to reproduce the issue
43
+ - **Proof of Concept**: Working example demonstrating the vulnerability
44
+ - **Affected Versions**: Which versions of es6-fuzz are vulnerable
45
+ - **Suggested Fix**: Any ideas for mitigation or fixes (optional but appreciated)
46
+
47
+ ## Our Disclosure Process
48
+
49
+ 1. **Acknowledgement**: We will acknowledge receipt of your report within **48 hours**
50
+ 2. **Initial Assessment**: Our team will investigate and provide an initial assessment within **5 business days**
51
+ 3. **Regular Updates**: We will provide updates on our progress every **7 days** until resolution
52
+ 4. **Fix Development**: We aim to develop and test fixes within **60 days** for critical vulnerabilities, **90 days** for others
53
+ 5. **Coordinated Disclosure**: We will work with you to coordinate public disclosure timing
54
+ 6. **Security Advisory**: For confirmed vulnerabilities, we will publish a GitHub Security Advisory
55
+ 7. **Recognition**: We will publicly credit you in the security advisory and release notes, unless you prefer to remain anonymous
56
+
57
+ ## Scope
58
+
59
+ This security policy applies to the core es6-fuzz library and its official distribution channels.
60
+
61
+ ### In Scope
62
+
63
+ - **Core Library**: All code in the main es6-fuzz repository
64
+ - **NPM Package**: The official `es6-fuzz` package on npmjs.com
65
+ - **Supported Versions**: Currently supported versions listed above
66
+ - **Dependencies**: Security issues in our direct dependencies that affect es6-fuzz
67
+
68
+ ### Vulnerability Types We're Interested In
69
+
70
+ - **Code Injection**: Ability to execute arbitrary code through fuzzy logic inputs
71
+ - **Prototype Pollution**: Manipulation of JavaScript object prototypes
72
+ - **Denial of Service**: Inputs that cause excessive resource consumption
73
+ - **Logic Bypass**: Ways to circumvent intended fuzzy logic behavior
74
+ - **Supply Chain**: Compromised dependencies or build process issues
75
+
76
+ ### Out of Scope
77
+
78
+ The following are considered out of scope for this security policy:
79
+
80
+ - **Theoretical Vulnerabilities**: Issues without practical exploitation scenarios
81
+ - **Social Engineering**: Attacks targeting project maintainers or users
82
+ - **Physical Access**: Attacks requiring physical access to systems
83
+ - **Brute Force**: Attacks requiring excessive computational resources
84
+ - **Third-Party Applications**: Vulnerabilities in applications that use es6-fuzz (unless caused by es6-fuzz itself)
85
+ - **Development Dependencies**: Issues in devDependencies that don't affect the published package
86
+ - **Documentation**: Typos or errors in documentation that don't create security risks
87
+
88
+ ## Safe Harbor
89
+
90
+ We consider security research and vulnerability disclosure activities conducted under this policy to be authorized and welcome. We will not pursue civil or criminal action, or send a cease and desist, against researchers who:
91
+
92
+ - Act in good faith and adhere to this policy
93
+ - Make a reasonable effort to avoid privacy violations and service disruption
94
+ - Do not access or modify data belonging to others
95
+ - Report vulnerabilities promptly and work with us on coordinated disclosure
96
+
97
+ We consider your activities to be a benefit to our community and will work with you to understand and resolve issues quickly.
98
+
99
+ ## Recognition & Rewards
100
+
101
+ While we do not currently offer a monetary bug bounty program, we deeply value the work of security researchers. We are happy to provide:
102
+
103
+ - **Public Recognition**: Credit in our security advisories and release notes
104
+ - **GitHub Security Advisory**: Co-author credit on published security advisories
105
+ - **Community Recognition**: Mention in our project documentation and website
106
+ - **Direct Communication**: Access to our development team for technical discussions
107
+
108
+ ## Special Considerations for es6-fuzz
109
+
110
+ ### Experimental Nature
111
+
112
+ Please note that es6-fuzz is explicitly marked as an experimental library. While we take security seriously, users should be aware that:
113
+
114
+ - The API may change between versions
115
+ - Thorough security review may be limited due to the experimental status
116
+ - Production use should include additional security considerations
117
+
118
+ ### JavaScript-Specific Concerns
119
+
120
+ As a JavaScript library, es6-fuzz may be particularly susceptible to:
121
+
122
+ - **Input Validation Issues**: Malformed inputs to fuzzy logic functions
123
+ - **Prototype Pollution**: Manipulation of JavaScript object prototypes
124
+ - **Type Confusion**: Unexpected behavior with different JavaScript types
125
+ - **Performance Issues**: Inputs that cause excessive computation
126
+
127
+ ### Integration Security
128
+
129
+ When reporting vulnerabilities, please consider:
130
+
131
+ - **Client-Side Usage**: How the vulnerability affects browser-based applications
132
+ - **Server-Side Usage**: Impact on Node.js applications using es6-fuzz
133
+ - **Data Flow**: How untrusted data might reach vulnerable code paths
134
+
135
+ ## GitHub Security Advisory Integration
136
+
137
+ This project uses GitHub's Security Advisory system for coordinated vulnerability disclosure. When you report a vulnerability:
138
+
139
+ 1. **Draft Advisory**: We'll create a draft security advisory for collaboration
140
+ 2. **Private Discussion**: We can discuss the vulnerability privately within the advisory
141
+ 3. **CVE Assignment**: GitHub can assign CVE numbers for significant vulnerabilities
142
+ 4. **Coordinated Publication**: We'll coordinate the public disclosure timing with you
143
+ 5. **Dependabot Alerts**: Published advisories will trigger alerts for downstream users
144
+
145
+ ## Questions?
146
+
147
+ If you have questions about this policy or need clarification on any aspect of our security reporting process, please contact us at security+sebs@2xs.org.
148
+
149
+ ## Updates to This Policy
150
+
151
+ This security policy may be updated from time to time. We will announce significant changes through our usual communication channels (GitHub releases, npm package updates).
@@ -0,0 +1,17 @@
1
+ /** Class representing a Constant. */
2
+ export declare class Constant {
3
+ private readonly cValue;
4
+ /**
5
+ * Create a Constant Value.
6
+ * @param {number} constantValue - The value.
7
+ * @example
8
+ * new Constant(10)
9
+ */
10
+ constructor(constantValue: number);
11
+ /**
12
+ * Fuzzify
13
+ * @return {number} constant output
14
+ */
15
+ fuzzify(): number;
16
+ }
17
+ //# sourceMappingURL=constant.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constant.d.ts","sourceRoot":"","sources":["../../src/curve/constant.ts"],"names":[],"mappings":"AACA,qCAAqC;AACrC,qBAAa,QAAQ;IACnB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAEhC;;;;;OAKG;gBACS,aAAa,EAAE,MAAM;IAGjC;;;OAGG;IACH,OAAO,IAAI,MAAM;CAGlB"}
@@ -1,21 +1,25 @@
1
1
  'use strict';
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Constant = void 0;
2
4
  /** Class representing a Constant. */
3
5
  class Constant {
4
- /**
5
- * Create a Constant Value.
6
- * @param {number} constantValue - The value.
7
- * @example
8
- * new Constant(10)
9
- */
10
- constructor(constantValue) {
11
- this.cValue = constantValue;
12
- }
13
- /**
14
- * Fuzzify
15
- * @return {number} constant output
16
- */
17
- fuzzify() {
18
- return this.cValue;
19
- }
6
+ cValue;
7
+ /**
8
+ * Create a Constant Value.
9
+ * @param {number} constantValue - The value.
10
+ * @example
11
+ * new Constant(10)
12
+ */
13
+ constructor(constantValue) {
14
+ this.cValue = constantValue;
15
+ }
16
+ /**
17
+ * Fuzzify
18
+ * @return {number} constant output
19
+ */
20
+ fuzzify() {
21
+ return this.cValue;
22
+ }
20
23
  }
21
- module.exports = Constant;
24
+ exports.Constant = Constant;
25
+ //# sourceMappingURL=constant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constant.js","sourceRoot":"","sources":["../../src/curve/constant.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AACb,qCAAqC;AACrC,MAAa,QAAQ;IACF,MAAM,CAAS;IAEhC;;;;;OAKG;IACH,YAAY,aAAqB;QAC/B,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC;IAC9B,CAAC;IACD;;;OAGG;IACH,OAAO;QACL,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF;AAnBD,4BAmBC"}
@@ -0,0 +1,15 @@
1
+ /** Class representing a FuzzyFunction. */
2
+ export declare class FuzzyFunction {
3
+ private readonly cb;
4
+ /**
5
+ * Create a FuzzyFunction.
6
+ * @param {function} cb - callback function.
7
+ */
8
+ constructor(cb: (val: number) => number);
9
+ /**
10
+ * Fuzzify
11
+ * @param {number} val - value to fuzzify
12
+ */
13
+ fuzzify(val: number): number;
14
+ }
15
+ //# sourceMappingURL=fuzzy-function.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fuzzy-function.d.ts","sourceRoot":"","sources":["../../src/curve/fuzzy-function.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,EAAE,CAA0B;IAE7C;;;OAGG;gBACS,EAAE,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM;IAGvC;;;OAGG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;CAO7B"}
@@ -1,22 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FuzzyFunction = void 0;
1
4
  /** Class representing a FuzzyFunction. */
2
- class FuzzyFunction {
3
- /**
4
- * Create a FuzzyFunction.
5
- * @param {functions} - callback.
6
- */
7
- constructor(cb) {
8
- this.cb = cb;
9
- }
10
- /**
11
- * Fuzzify
12
- * @param {number} - val
13
- */
14
- fuzzify(val) {
15
- var res = this.cb(val);
16
- if (res >= 0 && res <= 1) {
17
- return res;
5
+ class FuzzyFunction {
6
+ cb;
7
+ /**
8
+ * Create a FuzzyFunction.
9
+ * @param {function} cb - callback function.
10
+ */
11
+ constructor(cb) {
12
+ this.cb = cb;
13
+ }
14
+ /**
15
+ * Fuzzify
16
+ * @param {number} val - value to fuzzify
17
+ */
18
+ fuzzify(val) {
19
+ const res = this.cb(val);
20
+ if (res >= 0 && res <= 1) {
21
+ return res;
22
+ }
23
+ throw Error('fuzzified result must be smaller than 1 but greater than 0 but is' + res);
18
24
  }
19
- throw Error('fuzzified result must be smaller than 1 but greater than 0 but is' + res);
20
- }
21
25
  }
22
- module.exports = FuzzyFunction;
26
+ exports.FuzzyFunction = FuzzyFunction;
27
+ //# sourceMappingURL=fuzzy-function.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fuzzy-function.js","sourceRoot":"","sources":["../../src/curve/fuzzy-function.ts"],"names":[],"mappings":";;;AAAA,0CAA0C;AAC1C,MAAa,aAAa;IACP,EAAE,CAA0B;IAE7C;;;OAGG;IACH,YAAY,EAA2B;QACrC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,CAAC;IACD;;;OAGG;IACH,OAAO,CAAC,GAAW;QACjB,MAAM,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;QACzB,IAAI,GAAG,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC;YACzB,OAAO,GAAG,CAAC;QACb,CAAC;QACD,MAAM,KAAK,CAAC,mEAAmE,GAAG,GAAG,CAAC,CAAC;IACzF,CAAC;CACF;AArBD,sCAqBC"}
@@ -0,0 +1,15 @@
1
+ import { Shape } from './shape';
2
+ /**
3
+ * Class representing a Grade.
4
+ * @example
5
+ * new Grade(0, 10)
6
+ */
7
+ export declare class Grade extends Shape {
8
+ /**
9
+ * Fuzzify
10
+ * @param {number} val - Point on X axis
11
+ * @return {number} fuzzy output 0..1
12
+ */
13
+ fuzzify(val: number): number;
14
+ }
15
+ //# sourceMappingURL=grade.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grade.d.ts","sourceRoot":"","sources":["../../src/curve/grade.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC;;;;GAIG;AACH,qBAAa,KAAM,SAAQ,KAAK;IAC9B;;;;OAIG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;CAmB7B"}
@@ -1,34 +1,38 @@
1
1
  'use strict';
2
- const Shape = require('./shape');
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Grade = void 0;
4
+ const shape_1 = require("./shape");
3
5
  /**
4
6
  * Class representing a Grade.
5
7
  * @example
6
8
  * new Grade(0, 10)
7
9
  */
8
- class Grade extends Shape {
9
- /**
10
- * Fuzzify
11
- * @param {number} - Point on X axis
12
- * @return {number} fuzzy output 0..1
13
- */
14
- fuzzify(val) {
15
- let result = 0;
16
- const x = val;
17
-
18
- // Handle case where x0 = x1 (vertical grade/step function)
19
- if (this.x1 === this.x0) {
20
- if (x < this.x0) return 0;
21
- return 1; // x >= x0
10
+ class Grade extends shape_1.Shape {
11
+ /**
12
+ * Fuzzify
13
+ * @param {number} val - Point on X axis
14
+ * @return {number} fuzzy output 0..1
15
+ */
16
+ fuzzify(val) {
17
+ let result = 0;
18
+ const x = val;
19
+ // Handle case where x0 = x1 (vertical grade/step function)
20
+ if (this.x1 === this.x0) {
21
+ if (x < this.x0)
22
+ return 0;
23
+ return 1; // x >= x0
24
+ }
25
+ if (x <= this.x0) {
26
+ result = 0;
27
+ }
28
+ else if (x >= this.x1) {
29
+ result = 1;
30
+ }
31
+ else {
32
+ result = (x / (this.x1 - this.x0)) - (this.x0 / (this.x1 - this.x0));
33
+ }
34
+ return result;
22
35
  }
23
-
24
- if (x <= this.x0) {
25
- result = 0;
26
- } else if (x >= this.x1) {
27
- result = 1;
28
- } else {
29
- result = (x / (this.x1 - this.x0)) - (this.x0 / (this.x1 - this.x0));
30
- }
31
- return result;
32
- }
33
36
  }
34
- module.exports = Grade;
37
+ exports.Grade = Grade;
38
+ //# sourceMappingURL=grade.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grade.js","sourceRoot":"","sources":["../../src/curve/grade.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AACb,mCAAgC;AAChC;;;;GAIG;AACH,MAAa,KAAM,SAAQ,aAAK;IAC9B;;;;OAIG;IACH,OAAO,CAAC,GAAW;QACjB,IAAI,MAAM,GAAG,CAAC,CAAC;QACf,MAAM,CAAC,GAAG,GAAG,CAAC;QAEd,2DAA2D;QAC3D,IAAI,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,EAAE,CAAC;YACxB,IAAI,CAAC,GAAG,IAAI,CAAC,EAAE;gBAAE,OAAO,CAAC,CAAC;YAC1B,OAAO,CAAC,CAAC,CAAC,UAAU;QACtB,CAAC;QAED,IAAI,CAAC,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,GAAG,CAAC,CAAC;QACb,CAAC;aAAM,IAAI,CAAC,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;YACxB,MAAM,GAAG,CAAC,CAAC;QACb,CAAC;aAAM,CAAC;YACN,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;QACvE,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAzBD,sBAyBC"}
@@ -0,0 +1,11 @@
1
+ import { Shape } from './shape';
2
+ /** Class representing a ReverseGrade. */
3
+ export declare class ReverseGrade extends Shape {
4
+ /**
5
+ * Fuzzify
6
+ * @param {number} val - Point on X axis
7
+ * @return {number} fuzzy output 0..1
8
+ */
9
+ fuzzify(val: number): number;
10
+ }
11
+ //# sourceMappingURL=reverse-grade.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reverse-grade.d.ts","sourceRoot":"","sources":["../../src/curve/reverse-grade.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,yCAAyC;AACzC,qBAAa,YAAa,SAAQ,KAAK;IACrC;;;;OAIG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;CAkB7B"}
@@ -1,29 +1,34 @@
1
1
  'use strict';
2
- const Shape = require('./shape');
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ReverseGrade = void 0;
4
+ const shape_1 = require("./shape");
3
5
  /** Class representing a ReverseGrade. */
4
- class ReverseGrade extends Shape {
5
- /**
6
- * Fuzzify
7
- * @param {number} - Point on X axis
8
- * @return {number} fuzzy output 0..1
9
- */
10
- fuzzify(val) {
11
- let result = 0;
12
- const x = val;
13
-
14
- if (x <= this.x0) {
15
- result = 1;
16
- } else if (x >= this.x1) {
17
- result = 0;
18
- } else {
19
- // Handle case where x0 = x1 (vertical reverse grade)
20
- if (this.x1 === this.x0) {
21
- result = 0;
22
- } else {
23
- result = (-x / (this.x1 - this.x0)) + (this.x1 / (this.x1 - this.x0));
24
- }
6
+ class ReverseGrade extends shape_1.Shape {
7
+ /**
8
+ * Fuzzify
9
+ * @param {number} val - Point on X axis
10
+ * @return {number} fuzzy output 0..1
11
+ */
12
+ fuzzify(val) {
13
+ let result = 0;
14
+ const x = val;
15
+ if (x <= this.x0) {
16
+ result = 1;
17
+ }
18
+ else if (x >= this.x1) {
19
+ result = 0;
20
+ }
21
+ else {
22
+ // Handle case where x0 = x1 (vertical reverse grade)
23
+ if (this.x1 === this.x0) {
24
+ result = 0;
25
+ }
26
+ else {
27
+ result = (-x / (this.x1 - this.x0)) + (this.x1 / (this.x1 - this.x0));
28
+ }
29
+ }
30
+ return result;
25
31
  }
26
- return result;
27
- }
28
32
  }
29
- module.exports = ReverseGrade;
33
+ exports.ReverseGrade = ReverseGrade;
34
+ //# sourceMappingURL=reverse-grade.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reverse-grade.js","sourceRoot":"","sources":["../../src/curve/reverse-grade.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AACb,mCAAgC;AAChC,yCAAyC;AACzC,MAAa,YAAa,SAAQ,aAAK;IACrC;;;;OAIG;IACH,OAAO,CAAC,GAAW;QACjB,IAAI,MAAM,GAAG,CAAC,CAAC;QACf,MAAM,CAAC,GAAG,GAAG,CAAC;QAEd,IAAI,CAAC,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,GAAG,CAAC,CAAC;QACb,CAAC;aAAM,IAAI,CAAC,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;YACxB,MAAM,GAAG,CAAC,CAAC;QACb,CAAC;aAAM,CAAC;YACN,qDAAqD;YACrD,IAAI,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,EAAE,CAAC;gBACxB,MAAM,GAAG,CAAC,CAAC;YACb,CAAC;iBAAM,CAAC;gBACN,MAAM,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;YACxE,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAxBD,oCAwBC"}
@@ -0,0 +1,22 @@
1
+ /** Base class representing a Shape. */
2
+ export declare abstract class Shape {
3
+ readonly x0: number;
4
+ readonly x1: number;
5
+ readonly x2: number;
6
+ readonly x3: number;
7
+ /**
8
+ * Create a Shape.
9
+ * @param {number} x0 - x0
10
+ * @param {number} x1 - x1
11
+ * @param {number} x2 - x2
12
+ * @param {number} x3 - x3
13
+ */
14
+ constructor(x0: number, x1: number, x2: number, x3: number);
15
+ /**
16
+ * Fuzzify
17
+ * @param {number} val - Point on X axis
18
+ * @return {number} fuzzy output 0..1
19
+ */
20
+ abstract fuzzify(val: number): number;
21
+ }
22
+ //# sourceMappingURL=shape.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shape.d.ts","sourceRoot":"","sources":["../../src/curve/shape.ts"],"names":[],"mappings":"AACA,uCAAuC;AACvC,8BAAsB,KAAK;IACzB,QAAQ,CAAC,EAAE,EAAG,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,EAAG,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,EAAG,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,EAAG,MAAM,CAAC;IAErB;;;;;;OAMG;gBACS,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;IAmB1D;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;CACtC"}
@@ -1,30 +1,37 @@
1
1
  'use strict';
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Shape = void 0;
2
4
  /** Base class representing a Shape. */
3
5
  class Shape {
4
- /**
5
- * Create a Shape.
6
- * @param {number} - x0
7
- * @param {number} - x1
8
- * @param {number} - x2
9
- * @param {number} - x3
10
- */
11
- constructor(x0, x1, x2, x3) {
12
- Object.defineProperty(this, 'x0', {
13
- value: x0,
14
- writable: false
15
- });
16
- Object.defineProperty(this, 'x1', {
17
- value: x1,
18
- writable: false
19
- });
20
- Object.defineProperty(this, 'x2', {
21
- value: x2,
22
- writable: false
23
- });
24
- Object.defineProperty(this, 'x3', {
25
- value: x3,
26
- writable: false
27
- });
6
+ x0;
7
+ x1;
8
+ x2;
9
+ x3;
10
+ /**
11
+ * Create a Shape.
12
+ * @param {number} x0 - x0
13
+ * @param {number} x1 - x1
14
+ * @param {number} x2 - x2
15
+ * @param {number} x3 - x3
16
+ */
17
+ constructor(x0, x1, x2, x3) {
18
+ Object.defineProperty(this, 'x0', {
19
+ value: x0,
20
+ writable: false
21
+ });
22
+ Object.defineProperty(this, 'x1', {
23
+ value: x1,
24
+ writable: false
25
+ });
26
+ Object.defineProperty(this, 'x2', {
27
+ value: x2,
28
+ writable: false
29
+ });
30
+ Object.defineProperty(this, 'x3', {
31
+ value: x3,
32
+ writable: false
33
+ });
28
34
  }
29
35
  }
30
- module.exports = Shape;
36
+ exports.Shape = Shape;
37
+ //# sourceMappingURL=shape.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shape.js","sourceRoot":"","sources":["../../src/curve/shape.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AACb,uCAAuC;AACvC,MAAsB,KAAK;IAChB,EAAE,CAAU;IACZ,EAAE,CAAU;IACZ,EAAE,CAAU;IACZ,EAAE,CAAU;IAErB;;;;;;OAMG;IACH,YAAY,EAAU,EAAE,EAAU,EAAE,EAAU,EAAE,EAAU;QACxD,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE;YAChC,KAAK,EAAE,EAAE;YACT,QAAQ,EAAE,KAAK;SAChB,CAAC,CAAC;QACH,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE;YAChC,KAAK,EAAE,EAAE;YACT,QAAQ,EAAE,KAAK;SAChB,CAAC,CAAC;QACH,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE;YAChC,KAAK,EAAE,EAAE;YACT,QAAQ,EAAE,KAAK;SAChB,CAAC,CAAC;QACH,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE;YAChC,KAAK,EAAE,EAAE;YACT,QAAQ,EAAE,KAAK;SAChB,CAAC,CAAC;IACL,CAAC;CAQF;AAtCD,sBAsCC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Class representing a Sigmoid.
3
+ * @example
4
+ * // long slope
5
+ * sigmoid = new Sigmoid(0, 100000);
6
+ * sigmoid2.fuzzify(10);
7
+ */
8
+ export declare class Sigmoid {
9
+ private readonly center;
10
+ private readonly slope;
11
+ /**
12
+ * Create a Sigmoid Function.
13
+ * @param {number} center - The center point of the sigmoid curve (where it outputs 0.5)
14
+ * @param {number} slope - The slope of the sigmoid curve (higher = steeper transition)
15
+ */
16
+ constructor(center?: number, slope?: number);
17
+ /**
18
+ * Fuzzify
19
+ * @param {number} x - Point on X axis
20
+ * @return {number} fuzzy output 0..1
21
+ */
22
+ fuzzify(x: number): number;
23
+ }
24
+ //# sourceMappingURL=sigmoid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sigmoid.d.ts","sourceRoot":"","sources":["../../src/curve/sigmoid.ts"],"names":[],"mappings":"AACA;;;;;;GAMG;AACH,qBAAa,OAAO;IAClB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAE/B;;;;OAIG;gBACS,MAAM,GAAE,MAAU,EAAE,KAAK,GAAE,MAAU;IAIjD;;;;OAIG;IACH,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM;CAS3B"}