fable 3.0.49 → 3.0.50

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.49",
3
+ "version": "3.0.50",
4
4
  "description": "An entity behavior management and API bundling library.",
5
5
  "main": "source/Fable.js",
6
6
  "scripts": {
@@ -20,7 +20,8 @@ class DataFormat extends libFableServiceProviderBase
20
20
  // Thoughts about below: /^([+-]?)(0*)(\d+)(\.(\d+))?$/;
21
21
  this._Regex_formatterAddCommasToNumber = /^([-+]?)(0?)(\d+)(.?)(\d+)$/g;
22
22
  this._Regex_formatterDollarsRemoveCommas = /,/gi;
23
- this._Regex_formatterCleanNonAlpha = /[^a-z0-9]/gi;
23
+ this._Regex_formatterCleanNonAlphaChar = /[^a-zA-Z]/gi;
24
+ this._Regex_formatterCapitalizeEachWord = /([a-zA-Z]+)/g;
24
25
 
25
26
  // TODO: Potentially pull these in from a configuration.
26
27
  // TODO: Use locale data for this if it's defaults all the way down.
@@ -29,7 +30,7 @@ class DataFormat extends libFableServiceProviderBase
29
30
  this._Value_GroupSeparator_Number = ',';
30
31
 
31
32
  this._Value_Prefix_StringHash = 'HSH';
32
- this._Value_Clean_formatterCleanNonAlpha = '_';
33
+ this._Value_Clean_formatterCleanNonAlpha = '';
33
34
 
34
35
  this._UseEngineStringStartsWith = (typeof(String.prototype.startsWith) === 'function');
35
36
  this._UseEngineStringEndsWith = (typeof(String.prototype.endsWith) === 'function');
@@ -147,6 +148,15 @@ class DataFormat extends libFableServiceProviderBase
147
148
  return `${this._Value_Prefix_StringHash}${tmpHash}`;
148
149
  }
149
150
 
151
+ capitalizeEachWord (pString)
152
+ {
153
+ return pString.replace(this._Regex_formatterCapitalizeEachWord,
154
+ (pMatch) =>
155
+ {
156
+ return pMatch.charAt(0).toUpperCase() + pMatch.substr(1);
157
+ });
158
+ }
159
+
150
160
  /**
151
161
  * Clean wrapping characters if they exist consistently around the string. If they do not, the string is returned unchanged.
152
162
  *
@@ -179,6 +189,7 @@ class DataFormat extends libFableServiceProviderBase
179
189
  }
180
190
 
181
191
  /**
192
+ * Clean a string of any non-alpha characters (including numbers)
182
193
  *
183
194
  * @param {*} pString
184
195
  * @returns
@@ -187,8 +198,10 @@ class DataFormat extends libFableServiceProviderBase
187
198
  {
188
199
  if ((typeof(pString) == 'string') && (pString != ''))
189
200
  {
190
- return pString.replace(this._Regex_formatterCleanNonAlpha, this._Value_Clean_formatterCleanNonAlpha);
201
+ return pString.replace(this._Regex_formatterCleanNonAlphaChar, this._Value_Clean_formatterCleanNonAlpha);
191
202
  }
203
+
204
+ return '';
192
205
  }
193
206
 
194
207
 
@@ -62,6 +62,37 @@ suite
62
62
  return fTestComplete();
63
63
  }
64
64
  )
65
+ test
66
+ (
67
+ 'Remove non-alpha characters from a string',
68
+ (fTestComplete)=>
69
+ {
70
+ let testFable = new libFable({LogStreams: false});
71
+ let _DataFormat = testFable.defaultServices.DataFormat;
72
+ Expect(_DataFormat.cleanNonAlphaCharacters('Dogs'))
73
+ .to.equal('Dogs');
74
+ Expect(_DataFormat.cleanNonAlphaCharacters('Dogs1'))
75
+ .to.equal('Dogs');
76
+ Expect(_DataFormat.cleanNonAlphaCharacters('Dogs-with-guns 12321'))
77
+ .to.equal('Dogswithguns');
78
+ return fTestComplete();
79
+ }
80
+ )
81
+ test
82
+ (
83
+ 'Capitalize each word in a string',
84
+ (fTestComplete)=>
85
+ {
86
+ let testFable = new libFable({LogStreams: false});
87
+ let _DataFormat = testFable.defaultServices.DataFormat;
88
+ Expect(_DataFormat.capitalizeEachWord('Dogs-with-guns 12321'))
89
+ .to.equal('Dogs-With-Guns 12321');
90
+ Expect(_DataFormat.cleanNonAlphaCharacters(_DataFormat.capitalizeEachWord('meadow-endpoints')))
91
+ .to.equal('MeadowEndpoints');
92
+ return fTestComplete();
93
+ }
94
+ )
95
+
65
96
  test
66
97
  (
67
98
  'Clean wrapping characters from a valid enclosure.',
@@ -205,15 +236,15 @@ suite
205
236
  .to.equal('Dogs');
206
237
  Expect(_DataFormat
207
238
  .cleanNonAlphaCharacters('Dogs are cool'))
208
- .to.equal('Dogs_are_cool');
239
+ .to.equal('Dogsarecool');
209
240
  Expect(_DataFormat
210
241
  .cleanNonAlphaCharacters('Dogs are cool!'))
211
- .to.equal('Dogs_are_cool_');
242
+ .to.equal('Dogsarecool');
212
243
  // Test cleaning with no character
213
- _DataFormat._Value_Clean_formatterCleanNonAlpha = '';
244
+ _DataFormat._Value_Clean_formatterCleanNonAlpha = '_';
214
245
  Expect(_DataFormat
215
246
  .cleanNonAlphaCharacters('Dogs are cool!'))
216
- .to.equal('Dogsarecool');
247
+ .to.equal('Dogs_are_cool_');
217
248
  return fTestComplete();
218
249
  }
219
250
  );