Ale.js

Filter

filter function

The Ale function has a built-in Ale.filter function that filters sensitive information every time a DOM update is made.

In Ale, the filter is a queue. Each time you call the Ale.filter function, the filter function is automatically inserted into the queue. You can add filters this way:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/* The filter function takes a parameter and you can pass in a function. But this function must have a parameter, and then return the filtered result with return */
Ale.filter(function(msg){

/* Filter all numbers 1 */
msg = msg.replace(/1/g, "")
return msg;
})


/* Or you can pass in an array */
Ale.filter([function(msg){

/* Filter all numbers 1 */
msg = msg.replace(/1/g, "")
return msg;
}, function(msg){

/* Filter all numbers 2 */
msg = msg.replace(/2/g, "")
return msg;
}])

Online instance

In the above example, we added a global filter that filters out all the numbers. Now you can type app.data.str = "new message123" in the console to see what the filter does.


Found some errors? Edit on Github!