+11
-0
@@ -46,2 +46,13 @@ 'use strict'; | ||
| fixedstr.strTrunc = function (name, size) { | ||
| return { | ||
| name: name, | ||
| size: size, | ||
| toFixedString: function (field, value) { | ||
| var str = (value || '').substring(0, size); | ||
| return textToString(field, str); | ||
| } | ||
| }; | ||
| } | ||
| fixedstr.number = function (name, size) { | ||
@@ -48,0 +59,0 @@ return { |
+1
-1
| { | ||
| "name": "fixedstr", | ||
| "description": "Transforms fixed string to object and vice versa", | ||
| "version": "0.0.3", | ||
| "version": "0.0.4", | ||
| "keywords": [ | ||
@@ -6,0 +6,0 @@ "string", |
+8
-0
@@ -96,2 +96,10 @@ 'use strict'; | ||
| }); | ||
| it('should not throw truncation error if using fixedstr.strTrunc', function() { | ||
| var t = fixedstr([fixedstr.strTrunc('TEST', 5)]); | ||
| var str = t.stringify({ | ||
| TEST: '123456' | ||
| }); | ||
| expect(str).to.equal('12345'); | ||
| }); | ||
| }); |
6500
8.84%167
11.33%