How is filter implemented in Vue?

{{ 10 | fn1 | fn2 }}

for example, you can use filter in the template of vue.
I wonder, how exactly does Vue implement it? Do you have a simple explanation?


put aside the mechanism of Vue, something like this.

// 
let str = '10 | fn1 | fn2';
// 
let host = {
  fn1: a => 2 * a,
  fn2: a => 3 + a
};

filter(str, host); // 3 + (2 * 10) = 23

function filter(str, host) {
  let arr = str.split(/\s*\|\s*/g);
  return arr.slice(1).reduce((a, b) => host[b](a), arr[0]);
}

is an ordinary function call. It is written in the form of a pipeline, which takes the value or result of the face as the following input parameter, such as 10 | fn1 | fn2 | fn3 . By parsing the string and dividing it according to | , you can get ['104th,' fn1', 'fn2',' fn3'] . Then the process of calling is:

.
fn3(fn2(fn1(10)))
Is there a more general explanation for

? You can use no code.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bdca2a-30670.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bdca2a-30670.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?