| Total Complexity | 4 |
| Complexity/F | 2 |
| Lines of Code | 33 |
| Function Count | 2 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | import _ from 'underscore'; |
||
|
|
|||
| 2 | |||
| 3 | import { |
||
| 4 | CellFormatter |
||
| 5 | } from './cell.js'; |
||
| 6 | /** |
||
| 7 | Formatter to convert any value to string. |
||
| 8 | |||
| 9 | @class Backgrid.StringFormatter |
||
| 10 | @extends Backgrid.CellFormatter |
||
| 11 | @constructor |
||
| 12 | */ |
||
| 13 | var StringFormatter = function () {}; |
||
| 14 | StringFormatter.prototype = new CellFormatter(); |
||
| 15 | _.extend(StringFormatter.prototype, { |
||
| 16 | /** |
||
| 17 | Converts any value to a string using Ecmascript's implicit type |
||
| 18 | conversion. If the given value is `null` or `undefined`, an empty string is |
||
| 19 | returned instead. |
||
| 20 | |||
| 21 | @member Backgrid.StringFormatter |
||
| 22 | @param {*} rawValue |
||
| 23 | @param {Backbone.Model} model Used for more complicated formatting |
||
| 24 | @return {string} |
||
| 25 | */ |
||
| 26 | fromRaw: function (rawValue, model) { |
||
| 27 | if (_.isUndefined(rawValue) || _.isNull(rawValue)) return ''; |
||
| 28 | return rawValue + ''; |
||
| 29 | } |
||
| 30 | }); |
||
| 31 | export { |
||
| 32 | StringFormatter |
||
| 33 | }; |
||
| 34 |