We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6093c82 commit 90a048fCopy full SHA for 90a048f
examples/log-message.js
@@ -1,4 +1,5 @@
1
const strif = require('../strif');
2
+strif.addTransformer('test', (s) => s);
3
4
const template = strif
5
.template('[{time}] {user} - {message}', {
strif.js
@@ -177,6 +177,20 @@ class StrifFormatter {
177
}
178
179
180
+ addTransformer(name, transformer) {
181
+ if (typeof name != 'string') {
182
+ throw new Error('name is required to be a string');
183
+ }
184
+
185
+ if (typeof transformer != 'function') {
186
+ throw new Error('transformer is required to be a function');
187
188
189
+ this.transformers[name] = transformer;
190
191
+ return this;
192
193
194
/**
195
* @param {string} template
196
* @param {object} options
0 commit comments