all files / commonform-docx/ escape.js

100% Statements 4/4
100% Branches 0/0
100% Functions 2/2
100% Lines 4/4
1 2 3 4 5 6 7 8 9 10 11 12 13 43×             43× 215×      
module.exports = function escape (string) {
  var special = {
    '&': /&/g,
    ''': /'/g,
    '>': />/g,
    '&lt;': /</g,
    '&quot;': /"/g
  }
  return Object.keys(special).reduce(function (string, escaped) {
    return string.replace(special[escaped], escaped)
  }, string)
}