summaryrefslogtreecommitdiff
path: root/node_modules/textr/test/support.js
blob: a5302536c822803994f2180dd3e0899bdbc24643 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
'use strict';

/**
 * Convert text to capitalized string
 * @param {String} text
 * @return {String}
 */
exports.capitalize = function(text) {
  return text.replace(/\b(.{1})/g, function (l) {
    return l.toUpperCase();
  });
};

/**
 * Wrap text by html headline with given level
 * @param {Number} level
 * @return {Function}
 */
exports.headline = function(level) {
  return function(text) {
    return '<h' + level + '>' + text + '</h' + level + '>';
  };
};

/**
 * noop function
 */
exports.noop = function() {};