So I just read through the new Composition API RFC (link). Here they compare multiple methods to reuse code across components. Therein the import from module method is not included. I guess that's because they are talking about VueJS strictly and for comparison purposes.
In the example they state a search algorithm. This I used in one of my projects. First I made a module which exports the function as an object:
##search_module.js
let fnc = {
perform_simple_search: function (str, arr) {
let result = [];
arr.forEach(value => {
if (value.toString().toLocaleUpperCase().includes(str.toLocaleUpperCase()) || value.toString().toLocaleLowerCase().includes(str.toLocaleLowerCase())) {
if (result.indexOf(value) === -1) {
result.push(value)
}
}
});
}
}
module.exports = {
perform_simple_search: fnc.perform_simple_search
};
And where I needed the function in a component I just imported it like so:
import {perform_simple_search} from "../search_module";
And here is now my Question:
Why use a composition Function if I can just import a function from a module?