Empathize is a framework for Neutralino - lightweight and portable desktop application development framework similar to Electron
Empathize adds some useful functions which can help in the development of your application
npm i @empathize/framework
or
yarn add @empathize/framework
- Unofficial Cloudflare WARP
import { fetch } from '@empathize/framework';
// https://ipinfo.io/developers
fetch('https://ipinfo.io').then((response) => {
if (response.ok)
{
console.log(`OK: ${response.status}`);
response.body().then((body) => {
console.log(`Your IP: ${JSON.parse(body).ip}`);
});
}
else console.log(`Error: ${response.status}`);
});
import { Downloader, Archive } from '@empathize/framework';
Downloader.download('https://example.com/archive.zip', 'tmp.zip').then((stream) => {
stream.progressInterval = 1000;
stream.start(() => {
console.log('Downloading started');
});
stream.start((current, total) => {
console.log(`Downloading progress: ${Math.round(current / total * 100)}%`);
});
stream.finish(() => {
console.log('Downloading finished');
Archive.extract('tmp.zip', 'my_folder').then((stream) => {
stream.start(() => {
console.log('Unpacking started');
});
stream.start((current, total) => {
console.log(`Unpacking progress: ${Math.round(current / total * 100)}%`);
});
stream.finish(() => {
console.log('Unpacking finished');
});
});
});
});
import { Configs, promisify } from '@empathize/framework';
promisify(async () => {
// Save default values
await Configs.defaults({
default: {
value_1: 1,
value_2: {
value_3: 3
}
},
example: [1, 2, 3]
});
// Prints 3
console.log(await Configs.get('default.value_2.value_3'));
});
import { Cache, promisify } from '@empathize/framework';
promisify(async () => {
// Save this for 10 seconds
await Cache.set('example', 'some important data', 10);
// Cache expired: false
console.log(`Cache expired: ${(await Cache.get('example')).expired}`);
// After 10 seconds
setTimeout(async () => {
// Cache expired: true
console.log(`Cache expired: ${(await Cache.get('example')).expired}`);
}, 10000);
});
And so on
Author: Nikita Podvirnyy
Licensed under GNU GPL-3.0