git @ Cat's Eye Technologies Lexeduct / 1f8ed61
Do these with 'chars= ' insert-chars or chars=aeiou insert-chars. --HG-- rename : src/transformers/insert-vowels.js => src/transformers/insert-chars.js Chris Pressey 6 years ago
4 changed file(s) with 20 addition(s) and 31 deletion(s). Raw diff Collapse all Expand all
2323 $ echo 'Hello!' | lexeduct.js upper
2424 HELLO
2525
26 Parameters can be given with the syntax `name=value` before the name of the
27 transformer they are to be applied to. So, for example,
28
29 $ echo 'Hello' | lexeduct.js chars=e remove-chars
30 Hllo
31
2632 You can of course use shell pipelines to compose transformers:
2733
28 $ echo 'Hello!' | lexeduct.js upper | lexeduct.js double-space
34 $ echo 'Hello!' | lexeduct.js upper | lexeduct.js 'chars= ' insert-chars
2935 H E L L O !
3036
3137 *Or* you can name multiple transformers on `lexeduct.js`'s command line to
3238 compose them:
3339
34 $ echo 'Hello!' | lexeduct.js upper double-space
40 $ echo 'Hello!' | lexeduct.js upper 'chars= ' insert-chars
3541 H E L L O !
36
37 Parameters can be given with the syntax `name=value` *before* the name of the
38 transformer they are to be applied to. So, for example,
39
40 $ echo 'Hello' | lexeduct.js chars=e remove-chars
41 Hllo
4242
4343 Transformers
4444 ------------
+0
-11
src/transformers/double-space.js less more
0 module.exports = {
1 makeTransformer: function(cfg) {
2 return function(str, state) {
3 var s = "";
4 for (var i = 0; i < str.length; i++) {
5 s += str.charAt(i) + " ";
6 }
7 return s;
8 };
9 }
10 };
0 module.exports = {
1 makeTransformer: function(cfg) {
2 return function(str, state) {
3 var s = "";
4 for (var i = 0; i < str.length; i++) {
5 var c = cfg.chars.charAt(Math.floor(Math.random() * cfg.chars.length));
6 s += str.charAt(i) + c;
7 }
8 return s;
9 };
10 }
11 };
+0
-12
src/transformers/insert-vowels.js less more
0 module.exports = {
1 makeTransformer: function(cfg) {
2 return function(str, state) {
3 var s = "";
4 var vowels = "aeiou";
5 for (var i = 0; i < str.length; i++) {
6 s += str.charAt(i) + vowels.charAt(Math.floor(Math.random() * vowels.length));
7 }
8 return s;
9 };
10 }
11 };