index.js
 1  'use strict';
 2  
 3  const matchOperatorsRegex = /[|\\{}()[\]^$+*?.-]/g;
 4  
 5  module.exports = string => {
 6  	if (typeof string !== 'string') {
 7  		throw new TypeError('Expected a string');
 8  	}
 9  
10  	return string.replace(matchOperatorsRegex, '\\$&');
11  };