es6-fuzz 3.0.5 → 3.0.6

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/docs/CHANGELOG.md CHANGED
@@ -1,6 +1,15 @@
1
+ 2022-06-02
2
+ ==========
3
+
4
+ * feature: chehck if init was called before any logic os performed
5
+ * test: add another example to the tests
6
+ * chore: remove travis config
7
+ * chore: update dependencies
8
+
1
9
  2019-01-15
2
10
  ==========
3
11
 
12
+ * (churn): changelog
4
13
  * 3.0.5
5
14
  * Updated docs gen
6
15
 
@@ -145,12 +154,3 @@
145
154
  ==========
146
155
 
147
156
  * (churn): changelog
148
- * 2.5.3
149
- * Update deps
150
-
151
- 2016-10-14
152
- ==========
153
-
154
- * (churn): changelog
155
- * 2.5.2
156
- * Sigmoid as well
package/lib/logic.js CHANGED
@@ -27,6 +27,7 @@ const ruleEngine = {
27
27
  /** Class helping with FuzzyLogic. */
28
28
 
29
29
  class Logic {
30
+ initCalled = false;
30
31
  constructor() {
31
32
  this.c = {
32
33
  Shape,
@@ -40,28 +41,39 @@ class Logic {
40
41
  };
41
42
  this.rules = [];
42
43
  }
44
+
45
+ checkInitCalled() {
46
+ if (!this.initCalled) {
47
+ throw Error('init needs to be called before performing logic');
48
+ }
49
+ }
50
+
43
51
  init(output, shape) {
52
+ this.initCalled = true;
44
53
  let type = TYPE_INIT;
45
54
  this.rules.push({ output, shape, type });
46
55
  return this;
47
56
  }
48
57
  and(output, shape) {
58
+ this.checkInitCalled();
49
59
  let type = TYPE_AND;
50
60
  this.rules.push({ output, shape, type });
51
61
  return this;
52
62
  }
53
63
  or(output, shape) {
64
+ this.checkInitCalled();
54
65
  let type = TYPE_OR;
55
66
  this.rules.push({ output, shape, type });
56
67
  return this;
57
68
  }
58
69
  not(output, shape) {
70
+ this.checkInitCalled();
59
71
  let type = TYPE_NOT;
60
72
  this.rules.push({ output, shape, type });
61
73
  return this;
62
74
  }
63
75
  defuzzify(value) {
64
-
76
+ this.checkInitCalled();
65
77
  let defuzzified = 'none';
66
78
  let fuzzified = 0;
67
79
  let lastShape;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "es6-fuzz",
3
3
  "description": "fuzzy logic with and for es6",
4
- "version": "3.0.5",
4
+ "version": "3.0.6",
5
5
  "main": "lib/logic.js",
6
6
  "repository": "git@github.com:sebs/es6-fuzz.git",
7
7
  "homepage": "https://github.com/sebs/es6-fuzz",
@@ -35,20 +35,20 @@
35
35
  "author": "Sebastian Schürmann",
36
36
  "license": "MIT",
37
37
  "devDependencies": {
38
- "browserify": "^16.2.2",
39
- "changelog": "^1.0.7",
40
- "documentation": "^9.1.1",
41
- "es6ify": "^1.6.0",
42
- "eslint": "^5.6.0",
43
- "gh-pages": "^2.0.0",
44
- "ink-docstrap": "^1.3.0",
45
- "jscs": "^3.0.7",
46
- "jsdoc": "^3.4.3",
47
- "mocha": "^5.2.0",
48
- "mocha-traceur": "^2.1.0",
38
+ "browserify": "17.0.0",
39
+ "changelog": "1.4.2",
40
+ "documentation": "13.2.5",
41
+ "es6ify": "1.6.0",
42
+ "eslint": "8.16.0",
43
+ "gh-pages": "4.0.0",
44
+ "ink-docstrap": "1.3.2",
45
+ "jscs": "3.0.7",
46
+ "jsdoc": "3.6.10",
47
+ "mocha": "10.0.0",
48
+ "mocha-traceur": "2.1.0",
49
49
  "traceur": "0.0.111"
50
50
  },
51
51
  "dependencies": {
52
- "blanket": "^1.2.3"
52
+ "blanket": "1.2.3"
53
53
  }
54
54
  }
@@ -0,0 +1,25 @@
1
+ const assert = require('assert');
2
+ const Logic = require('../lib/logic');
3
+ const Triangle = require('../lib/curve/triangle');
4
+
5
+ describe('Example Test', function() {
6
+ var fuzzyvariable_pageSize;
7
+ beforeEach(()=>{
8
+ const logic = new Logic();
9
+ fuzzyvariable_pageSize = logic
10
+ .init('Excellent', new Triangle(20, 40, 60))
11
+ .or('Medium', new Triangle(40,60,80))
12
+ .or('Bad', new Triangle(60,80,100))
13
+
14
+ })
15
+
16
+ it('40 is excellent', ()=>{
17
+ assert.equal(fuzzyvariable_pageSize.defuzzify(40).defuzzified, 'Excellent');
18
+ })
19
+ it('60 is medium', ()=>{
20
+ assert.equal(fuzzyvariable_pageSize.defuzzify(60).defuzzified, 'Medium');
21
+ })
22
+ it('80 is bad', ()=>{
23
+ assert.equal(fuzzyvariable_pageSize.defuzzify(80).defuzzified, 'Bad');
24
+ });
25
+ });
@@ -0,0 +1,16 @@
1
+ const assert = require('assert');
2
+ const Logic = require('../lib/logic');
3
+ const Triangle = require('../lib/curve/triangle');
4
+
5
+ describe('Example Test', function() {
6
+
7
+ it('init needs to be called before using logic', ()=>{
8
+
9
+ assert.throws(()=>{
10
+ const logic = new Logic();
11
+ fuzzyvariable_pageSize = logic
12
+ .or('Excellent', new Triangle(20, 40, 60))
13
+ });
14
+ });
15
+
16
+ });
package/.travis.yml DELETED
@@ -1,4 +0,0 @@
1
- language: node_js
2
- node_js:
3
- - '9'
4
- - '10'