Code Monkey home page Code Monkey logo

numi-extensions's Introduction

Numi

Numi is a handy calculator app for macOS. It allows to describe tasks the natural way and instantly get an accurate answer. For example, $20 in euro - 5% discount or today + 2 weeks.

You can use JavaScript extensions to add global variables, custom units or functions. Right now only limited set of API is available via JavaScript, but the plan is to open as much API as possible.

Table of Contents

Logging

Use log function to send output from your extension to log window.

log("Function called!");

Values and Variables

Each value in Numi might be represented in JavaScript as an object with a set of properties, describing decimal value, unit type etc. Here is the usual way of creating new values for Numi:

var value = { "double": 5, "unitId" : "USD" }

Use numi.setVariable function to declare global variables.

numi.setVariable("xxx", { "double": 5, "unitId" : "USD" });

You can also use plain JavaScript numbers for cases when you'll need to return value for Numi. This will be treated as a value with decimal number.

numi.setVariable("yyy", 122);

Custom Units

Use numi.addUnit to add new unit. id field required for internal use, and might be any unique literal. phrases contains string with comma-separated phrases that might be used for the unit, format field used for results formatting.

Unit conversion limited to ratio-based conversion ATM. For each unit you can specify base unit identifier baseUnitId and ratio to that unit. Conversion from one unit to another in this case happening through base unit. On first step value will be converted to the base unit. On second step base value will be converted to result unit. baseUnitId might be picked up from list of base units.

numi.addUnit({
    "id": "horse",
    "phrases": "horse, horses, hrs",
    "baseUnitId": "m",
    "format" : "hrs",
    "ratio" : 2.4,
});

Custom Functions

Use numi.addFunction to add new function. Values passed into evaluated function in form of array. To use function with multiple arguments you can use ; in Numi, like myFunction(1;5;4).

numi.addFunction({ "id": "zum", "phrases": "zum" }, function(values) {
    return { "double": values[0].double + values[1].double };
});

List of Base Units

Unit name Unit ID
Meter m
Second second
Percentage percent
Square meter m2
Cubic meter m3
Bit bit
Byte byte
Radian radian
Gram gram
US Dollars USD

Sample Extensions

Alfred integration

You can use Numi with Alfred for quick calculations. Just type numi, n or = in front of your expressions in Alfred. First you will need to install the Numi workflow, and enable Alfred integration in Numi preferences. The workflow can also be installed easily with Homebrew-alfred:

brew tap danielbayley/alfred
brew cask install alfred-numi

For the LaunchBar extension please refer to https://github.com/Rahlir/NumiLaunchbar.

gif

numi-extensions's People

Contributors

nikolaeu avatar danielbayley avatar muescha avatar goschevski avatar gomako avatar jjshammas avatar leoyuholo avatar meermanr avatar vitalii-komenda avatar retifrav avatar

Watchers

James Cloos avatar  avatar

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.