1.4.15 • Published 3 years ago

@empathize/framework v1.4.15

Weekly downloads
-
License
GPL-3.0
Repository
github
Last release
3 years ago

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

Installation

npm i @empathize/framework

or

yarn add @empathize/framework

Documentation

Projects using Empathize

Examples

Fetch computer's IP

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}`);
});

Download and unpack an archive

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');
            });
        });
    });
});

Store something in config file

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'));
});

Cache some data

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

1.4.15

3 years ago

1.4.14

3 years ago

1.4.13

3 years ago

1.4.11

3 years ago

1.4.10

3 years ago

1.4.12

3 years ago

1.4.9

3 years ago

1.4.8

3 years ago

1.4.7

3 years ago

1.4.6

3 years ago

1.4.5

3 years ago

1.4.4

3 years ago

1.4.3

3 years ago

1.4.2

3 years ago

1.4.1

3 years ago

1.4.0

3 years ago

1.3.5

3 years ago

1.3.4

3 years ago

1.3.3

3 years ago

1.3.2

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.0

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.4.1

4 years ago

0.4.0

4 years ago

0.3.0

4 years ago

0.1.0

4 years ago