- // Extend opts
- if (opts) {
- for (property in opts) {
- if (opts.hasOwnProperty(property)) {
- this[property] = opts[property];
- }
- }
- }
+const Utilities = require('../utilities');
+
+/**
+ * Token formatter. Given a format string it will attempt to output
+ * a message.
+ *
+ * @memberof Formatters
+ * @implements IFormatter
+ * @class Token
+ */
+module.exports = class TokenFormatter {
+ constructor(config) {
+
+ /**
+ * The string to use as a template string. By default, any property
+ * inside double curly braces `{{likeThis}}` will be extracted from
+ * the object and replaced. If the object does not contain the
+ * property, it will leave it.
+ *
+ * @name formatString
+ * @instance
+ * @memberof Formatters.Token
+ * @type String
+ * @default '{{message}}'
+ */
+ this.formatString = '{{message}}';
+
+ /**
+ * The regex rule to use to match the tokens.
+ *
+ * @name replaceRule
+ * @instance
+ * @memberof Formatters.Token
+ * @type RegExp
+ * @default /{{(.{1,255}?)}}/g
+ */
+ this.replaceRule = /{{(.{1,255}?)}}/g;