a zip code crypto-currency system good for red ONLY

index.js 791B

1234567891011121314151617181920212223242526272829303132333435
  1. var nargs = /\{([0-9a-zA-Z]+)\}/g
  2. var slice = Array.prototype.slice
  3. module.exports = template
  4. function template(string) {
  5. var args
  6. if (arguments.length === 2 && typeof arguments[1] === "object") {
  7. args = arguments[1]
  8. } else {
  9. args = slice.call(arguments, 1)
  10. }
  11. if (!args || !args.hasOwnProperty) {
  12. args = {}
  13. }
  14. return string.replace(nargs, function replaceArg(match, i, index) {
  15. var result
  16. if (string[index - 1] === "{" &&
  17. string[index + match.length] === "}") {
  18. return i
  19. } else {
  20. result = args.hasOwnProperty(i) ? args[i] : null
  21. if (result === null || result === undefined) {
  22. return ""
  23. }
  24. return result
  25. }
  26. })
  27. }