GithubHelp home page GithubHelp logo

empathizejs / framework Goto Github PK

View Code? Open in Web Editor NEW
14.0 1.0 1.0 180 KB

Empathize is a framework for Neutralino - lightweight and portable desktop application development framework similar to Electron

Home Page: https://krypt0nn.gitbook.io/empathize/

License: GNU General Public License v3.0

TypeScript 100.00%
neutralino neutralinojs typescript framework

framework's Introduction

Empathize - A Neutralino Framework

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

framework's People

Contributors

krypt0nn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

daniel-lxs

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.