fable 3.0.6 → 3.0.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fable",
3
- "version": "3.0.6",
3
+ "version": "3.0.7",
4
4
  "description": "An entity behavior management and API bundling library.",
5
5
  "main": "source/Fable.js",
6
6
  "scripts": {
@@ -57,6 +57,7 @@
57
57
  "vinyl-source-stream": "^2.0.0"
58
58
  },
59
59
  "dependencies": {
60
+ "async": "^3.2.4",
60
61
  "fable-log": "^3.0.1",
61
62
  "fable-settings": "^3.0.0",
62
63
  "fable-uuid": "^3.0.1"
@@ -1,5 +1,14 @@
1
1
  class FableUtility
2
2
  {
3
+ // Underscore and lodash have a behavior, _.template, which compiles a
4
+ // string-based template with code snippets into simple executable pieces,
5
+ // with the added twist of returning a precompiled function ready to go.
6
+ //
7
+ // NOTE: This does not implement underscore escape expressions
8
+ // NOTE: This does not implement underscore magic browser variable assignment
9
+ //
10
+ // This is an implementation of that.
11
+ // TODO: Make this use precedent, add configuration, add debugging.
3
12
  constructor(pFable, pTemplateText)
4
13
  {
5
14
  this.fable = pFable;
@@ -56,15 +65,6 @@ class FableUtility
56
65
  return fRenderTemplateBound;
57
66
  }
58
67
 
59
- // Underscore and lodash have a behavior, _.template, which compiles a
60
- // string-based template with code snippets into simple executable pieces,
61
- // with the added twist of returning a precompiled function ready to go.
62
- //
63
- // NOTE: This does not implement underscore escape expressions
64
- // NOTE: This does not implement underscore magic browser variable assignment
65
- //
66
- // This is an implementation of that.
67
- // TODO: Make this use precedent, add configuration, add debugging.
68
68
  buildTemplateFunction(pTemplateText, pData)
69
69
  {
70
70
  // For now this is being kept in a weird form ... this is to mimic the old
@@ -1,10 +1,16 @@
1
1
  const libFableUtilityTemplate = require('./Fable-Utility-Template.js');
2
+ const libAsyncWaterfall = require('async/waterfall');
3
+ const libAsyncEachLimit = require('async/eachLimit');
2
4
 
3
5
  class FableUtility
4
6
  {
5
7
  constructor(pFable)
6
8
  {
7
9
  this.fable = pFable;
10
+
11
+ // These two functions are used extensively throughout
12
+ this.waterfall = libAsyncWaterfall;
13
+ this.eachLimit = libAsyncEachLimit;
8
14
  }
9
15
 
10
16
  // Underscore and lodash have a behavior, _.extend, which merges objects.
@@ -111,7 +111,7 @@ suite
111
111
  );
112
112
  test
113
113
  (
114
- 'chunk should work like underscore',
114
+ 'chunk should work _exactly_ like underscore',
115
115
  function()
116
116
  {
117
117
  testFable = new libFable();
@@ -137,8 +137,65 @@ suite
137
137
 
138
138
  Expect(testFable.Utility.chunk([10, 20, 30, 40, 50, 60, 70], 2)).to.deep.equal([[10, 20], [30, 40], [50, 60], [70]]); // chunk into parts of less then current array length elements');
139
139
  Expect(testFable.Utility.chunk([10, 20, 30, 40, 50, 60, 70], 3)).to.deep.equal([[10, 20, 30], [40, 50, 60], [70]]); // chunk into parts of less then current array length elements');
140
- });
141
- }
140
+ }
141
+ );
142
+ test
143
+ (
144
+ 'waterfall should be passed in from async',
145
+ function(fDone)
146
+ {
147
+ testFable = new libFable();
148
+
149
+ let tmpState = {};
150
+
151
+ testFable.Utility.waterfall([
152
+ (fStageComplete)=>
153
+ {
154
+ tmpState.Name = 'The Pixies';
155
+ fStageComplete();
156
+ },
157
+ (fStageComplete)=>
158
+ {
159
+ tmpState.Type = 'Band';
160
+ fStageComplete();
161
+ }],
162
+ (pError)=>
163
+ {
164
+ Expect(tmpState.Name).to.equal('The Pixies');
165
+ Expect(tmpState.Type).to.equal('Band');
166
+ fDone();
167
+ })
168
+ }
169
+ );
170
+ test
171
+ (
172
+ 'eachLimit should be passed in from async',
173
+ function(fDone)
174
+ {
175
+ testFable = new libFable();
176
+
177
+ let tmpState = {};
178
+
179
+ let tmpData = ['a','b','c','d','e'];
180
+
181
+ testFable.Utility.eachLimit(tmpData, 2,
182
+ (pItem, fCallback)=>
183
+ {
184
+ tmpState[pItem] = pItem;
185
+ fCallback();
186
+ },
187
+ (pError)=>
188
+ {
189
+ Expect(tmpState).to.have.a.property('a');
190
+ Expect(tmpState).to.have.a.property('b');
191
+ Expect(tmpState).to.have.a.property('c');
192
+ Expect(tmpState).to.have.a.property('d');
193
+ Expect(tmpState).to.have.a.property('e');
194
+ Expect(tmpState.c).to.equal('c');
195
+ fDone();
196
+ })
197
+ }
198
+ ); }
142
199
  );
143
200
  }
144
201
  );