utils.js 418 B

1234567891011121314151617181920
  1. var slice = Array.prototype.slice;
  2. exports.extend = function (obj) {
  3. slice.call(arguments, 1).forEach(function (props) {
  4. var prop;
  5. for (prop in props) {
  6. obj[prop] = props[prop];
  7. }
  8. });
  9. return obj;
  10. };
  11. exports.replace = function (str, values) {
  12. var name, value;
  13. for (name in values) {
  14. value = values[name];
  15. str = str.replace(new RegExp(':' + name, 'g'), value);
  16. }
  17. return str;
  18. };