@rokii/utils
v2.0.10
Published
Toolkit for developing Rokii plugins
Downloads
6
Readme
Available Utils
Memoize
import { memoize } from '@rokii/utils';
const fetchResults = memoize(() => {
// Your long running function
})
Use memoize
function for your long-running functions, like API-requests.
Under the hood it just uses just-memoize. Check the documentation for more details.
Search
import { search } from '@rokii/utils';
// Filter your results array
const results = search(arr, 'something', (el) => el.key);
// Display filtered results
display(results);
Simple function to search in your collection:
search = (items, term, toString = (item) => item) => {}
Where
items
– your array of items;term
– search term;toString
– function to convert your collection item to string.
ShellCommand
import { shellCommand } from '@rokii/utils';
// Run your shell command
const result = await shellCommand('ls -la');
Simple function to run shell commands. It uses native child_process
module.
Related
- Rokii – main repo for Cerebro app;
License
MIT © David Jiménez