es6-fuzz 3.0.2 → 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/.gitattributes ADDED
@@ -0,0 +1 @@
1
+ * text=auto
@@ -1,4 +1,6 @@
1
- # fuzzylogic for javascript
1
+ # es6-fuzz
2
+
3
+ > Fuzzy Logic in Javascript
2
4
 
3
5
  [![npm](https://img.shields.io/npm/dt/es6-fuzz.svg)](https://www.npmjs.com/package/es6-fuzz)
4
6
  [![license](https://img.shields.io/github/license/sebs/es6-fuzz.svg)](https://github.com/sebs/es6-fuzz/blob/master/LICENSE.md)
@@ -8,6 +10,7 @@
8
10
 
9
11
  Supported fuzzyfiers
10
12
 
13
+
11
14
  * Constant
12
15
  * Grade
13
16
  * Reverse Grade
@@ -15,6 +18,7 @@ Supported fuzzyfiers
15
18
  * Trapezoid
16
19
  * Triangle
17
20
 
21
+
18
22
  * [api docs](https://github.com/sebs/es6-fuzz)
19
23
  * [changelog](./docs/changelog.md)
20
24
 
package/docs/CHANGELOG.md CHANGED
@@ -1,3 +1,36 @@
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
+
9
+ 2019-01-15
10
+ ==========
11
+
12
+ * (churn): changelog
13
+ * 3.0.5
14
+ * Updated docs gen
15
+
16
+ 2018-09-24
17
+ ==========
18
+
19
+ * Badges
20
+ * Add text=auto
21
+ * docs
22
+ * Move badges to top
23
+ * Docs: Move icons behind the heading
24
+ * CI: Only node 9 and 10
25
+ * Add node6 to 10 to target
26
+ * Add Homepage
27
+ * fix list
28
+ * (churn): changelog
29
+ * 3.0.4
30
+ * remove package-lock before release
31
+ * Update deps
32
+ * Remove package-lock.json
33
+
1
34
  2018-08-11
2
35
  ==========
3
36
 
@@ -121,44 +154,3 @@
121
154
  ==========
122
155
 
123
156
  * (churn): changelog
124
- * 2.5.3
125
- * Update deps
126
-
127
- 2016-10-14
128
- ==========
129
-
130
- * (churn): changelog
131
- * 2.5.2
132
- * Sigmoid as well
133
- * 2.5.1
134
- * Glossary
135
-
136
- 2016-10-05
137
- ==========
138
-
139
- * (churn): changelog
140
- * 2.5.0
141
- * (chrun): deps
142
-
143
- 2016-10-03
144
- ==========
145
-
146
- * (churn): changelog
147
- * 2.4.4
148
- * (docs): badges
149
-
150
- 2016-09-30
151
- ==========
152
-
153
- * (churn): test node 4-6
154
- * (churn): changelog
155
- * 2.4.3
156
- * (feature): autochangelog
157
-
158
- 2016-09-27
159
- ==========
160
-
161
- * 2.4.2
162
- * (chore): docs
163
- * chore(package): update mocha to version 3.1.0
164
- https://greenkeeper.io/
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,9 +1,10 @@
1
1
  {
2
2
  "name": "es6-fuzz",
3
3
  "description": "fuzzy logic with and for es6",
4
- "version": "3.0.2",
4
+ "version": "3.0.6",
5
5
  "main": "lib/logic.js",
6
6
  "repository": "git@github.com:sebs/es6-fuzz.git",
7
+ "homepage": "https://github.com/sebs/es6-fuzz",
7
8
  "scripts": {
8
9
  "env": "env",
9
10
  "changelog": "rm ./docs/CHANGELOG.md && changelog https://github.com/sebs/es6-fuzz all > ./docs/CHANGELOG.md && git add . && git commit . -m '(churn): changelog'",
@@ -12,6 +13,7 @@
12
13
  "addpush": "git add . && git commit . -m 'docs'",
13
14
  "pages": "node ./scripts/publish-gh.js",
14
15
  "docs": "jsdoc -c ./jsdoc.json -t ./node_modules/ink-docstrap/template -R ./Readme.md -u ./docs",
16
+ "preversion": "rm -f package-lock.json",
15
17
  "postversion": "git push && git push --tags && npm run changelog && npm run docs && npm run pages"
16
18
  },
17
19
  "keywords": [
@@ -33,20 +35,20 @@
33
35
  "author": "Sebastian Schürmann",
34
36
  "license": "MIT",
35
37
  "devDependencies": {
36
- "browserify": "^14.0.0",
37
- "changelog": "^1.0.7",
38
- "documentation": "^4.0.0-beta10",
39
- "es6ify": "^1.6.0",
40
- "eslint": "^3.7.1",
41
- "gh-pages": "^0.12.0",
42
- "ink-docstrap": "^1.3.0",
43
- "jscs": "^3.0.7",
44
- "jsdoc": "^3.4.3",
45
- "mocha": "^3.2.0",
46
- "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",
47
49
  "traceur": "0.0.111"
48
50
  },
49
51
  "dependencies": {
50
- "blanket": "^1.2.3"
52
+ "blanket": "1.2.3"
51
53
  }
52
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,12 +0,0 @@
1
- language: node_js
2
- node_js:
3
- - '6'
4
- - '7'
5
- deploy:
6
- provider: npm
7
- email: sebs@2xs.org
8
- api_key:
9
- secure: T35SMb9f2nbwvl1yviqoofkaAon01DmgSoV4Stf0ZNb1FVdpEAv7yAhWJ4NJAueg9cY+WF+M1n3i/3dy3+v5xAC3Vd1gNfuRAWjCTf7eEbhmRPoSBXeOBSFR3I3MTMN6L2iiRTv9TIqhLMBRydJ4dVeYlvFDybTlM3lfEXzfQ60bbZ3xppv9rjDj7qg0SAi3ro1Xf7aCZ9fnlsZDj5nA5KtHdFrdvp+YV/H62z6g+L/wWpFgipfIL6ZXDgBuMF3rA4XzlyiKW4FcNC9nfRGdMpJeoiqsmubOL40E64RrZnXbU8FkEQkX+taRoyWipTvENvPxDWBlRABxp6h/2qElRtKLaaGbJzzZqu8FoSauLX93rusaTAlwjtEIjZuxlZkKiGAiB/Otl9R6AS1QUBxlZckGum4z/VHGhZyCBhtIqlC2X3+1d//ooGjoDt/r+/cfL/hiChGsyV14ftOf/KEvtX25vTUOYgcoBezLNJG0TI/KEyxeEQGxDhM2BBmMydwGs2k54fZ2BS5w2r7Ue04JTcFcChXfQ590rHFMRx/HSD8Axk/zhir4lgGU/Umr9erbeTr1UaUvjYR8TgPgIeEnMQQOvqXMd7wvrajrfjMlKGxhqAPumtMVcB4S+QznVBqZkuRbszflwU+J1OT4GAgvsV2xhd77Nz19VrQWo+JE0mk=
10
- on:
11
- tags: true
12
- repo: sebs/es6-fuzz