fable 3.0.40 → 3.0.41

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.
@@ -5,7 +5,7 @@
5
5
 
6
6
  "LibraryOutputFolder": "./dist/",
7
7
 
8
- "LibraryUniminifiedFileName": "fable.js",
8
+ "LibraryUniminifiedFileName": "fable.compatible.js",
9
9
 
10
- "LibraryMinifiedFileName": "fable.min.js"
10
+ "LibraryMinifiedFileName": "fable.compatible.min.js"
11
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fable",
3
- "version": "3.0.40",
3
+ "version": "3.0.41",
4
4
  "description": "An entity behavior management and API bundling library.",
5
5
  "main": "source/Fable.js",
6
6
  "scripts": {
@@ -68,6 +68,7 @@
68
68
  "dependencies": {
69
69
  "async.eachlimit": "^0.5.2",
70
70
  "async.waterfall": "^0.5.2",
71
+ "cachetrax": "^1.0.2",
71
72
  "data-arithmatic": "^1.0.7",
72
73
  "fable-log": "^3.0.10",
73
74
  "fable-serviceproviderbase": "^3.0.3",
package/source/Fable.js CHANGED
@@ -51,6 +51,7 @@ class Fable
51
51
  this.serviceManager.addServiceType('RestClient', require('./services/Fable-Service-RestClient.js'));
52
52
  this.serviceManager.addServiceType('CSVParser', require('./services/Fable-Service-CSVParser.js'));
53
53
  this.serviceManager.addServiceType('Manifest', require('manyfest'));
54
+ this.serviceManager.addServiceType('ObjectCache', require('cachetrax'));
54
55
  }
55
56
 
56
57
  get isFable()
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Unit tests for Fable
3
+ *
4
+ * @license MIT
5
+ *
6
+ * @author Steven Velozo <steven@velozo.com>
7
+ */
8
+
9
+ var libFable = require('../source/Fable.js');
10
+
11
+ var Chai = require("chai");
12
+ var Expect = Chai.expect;
13
+
14
+ suite
15
+ (
16
+ 'Object Cache Test',
17
+ function()
18
+ {
19
+ suite
20
+ (
21
+ 'Basic object cache',
22
+ function()
23
+ {
24
+ test
25
+ (
26
+ 'Leverage the object cache',
27
+ function(fDone)
28
+ {
29
+ let testFable = new libFable();
30
+
31
+ let testCache = testFable.serviceManager.instantiateServiceProvider('ObjectCache');
32
+
33
+ testCache.maxLength = 2;
34
+
35
+ // Cache some data
36
+ testCache.put('ABC', 'A');
37
+ testCache.put('DEF', 'D');
38
+ Expect(testCache._List.head.Datum).to.equal('ABC');
39
+ Expect(testCache._List.tail.Datum).to.equal('DEF');
40
+ Expect(testCache._List.length).to.equal(2);
41
+
42
+ testCache.put('GHI', 'G');
43
+ Expect(testCache._List.head.Datum).to.equal('DEF');
44
+ Expect(testCache._List.tail.Datum).to.equal('GHI');
45
+ Expect(testCache._List.length).to.equal(2);
46
+
47
+ testCache.put('JKL', 'J');
48
+ testCache.put('MNO', 'M');
49
+ Expect(testCache._List.head.Datum).to.equal('JKL');
50
+ Expect(testCache._List.tail.Datum).to.equal('MNO');
51
+ Expect(testCache._List.length).to.equal(2);
52
+
53
+ // Now grow the cache, allowing it to hold more items.
54
+ testCache.maxLength = 5
55
+ testCache.put('PQR', 'P');
56
+ testCache.put('STU', 'S');
57
+ Expect(testCache._List.head.Datum).to.equal('JKL');
58
+ Expect(testCache._List.tail.Datum).to.equal('STU');
59
+ Expect(testCache._List.length).to.equal(4);
60
+
61
+
62
+ testCache.put('VWX', 'V');
63
+ Expect(testCache._List.head.Datum).to.equal('JKL');
64
+ Expect(testCache._List.tail.Datum).to.equal('VWX');
65
+ Expect(testCache._List.length).to.equal(5);
66
+
67
+ testCache.put('YZ', 'Y');
68
+ Expect(testCache._List.head.Datum).to.equal('MNO');
69
+ Expect(testCache._List.tail.Datum).to.equal('YZ');
70
+ Expect(testCache._List.length).to.equal(5);
71
+
72
+ // Now shrink it again... the list will only maintain its length until a prune occurs
73
+ testCache.maxLength = 2;
74
+
75
+ testCache.put('012', '0');
76
+ Expect(testCache._List.head.Datum).to.equal('PQR');
77
+ Expect(testCache._List.tail.Datum).to.equal('012');
78
+ Expect(testCache._List.length).to.equal(5);
79
+
80
+ testCache.prune((pRemovedRecords)=>
81
+ {
82
+ Expect(testCache._List.head.Datum).to.equal('YZ');
83
+ Expect(testCache._List.tail.Datum).to.equal('012');
84
+ Expect(testCache._List.length).to.equal(2);
85
+ return fDone();
86
+ });
87
+ }
88
+ );
89
+ }
90
+ );
91
+ }
92
+ );