import { Arr } from '@ephox.katamari'; const words = ['hello', 'world', 'what', 'is', 'up']; const filteredWords = Arr.filter(words, (word) => { return word.length > 3; }); console.log(filteredWords); // ['hello', 'world']
import { Arr } from '@ephox.katamari'; const data = [ { name: 'John', age: 27 }, { name: 'Mary', age: 33 }, { name: 'Peter', age: 22 }, { name: 'Jane', age: 40 }, ]; const filteredData = Arr.filter(data, (item) => { return item.age > 30; }); console.log(filteredData); // [{ name: 'Mary', age: 33 }, { name: 'Jane', age: 40 }]In this example, we use the Arr.filter method to filter an array of objects based on their age property. We only keep the objects that have an age greater than 30 and print the result to the console. In conclusion, the @ephox.katamari Arr filter package is a TypeScript library that provides an easy way to filter arrays. It is commonly used when dealing with large sets of data and you need to quickly parse and filter the data. Its flexibility and simplicity make it a popular choice among developers.