Code Monkey home page Code Monkey logo

rakam's Introduction

RAKAM βž• βž— πŸ“

NPM Package npm downloads circleci Build Status Codecov Coverage CodeFactor Maintenance License FOSSA Status

Rakam or (Ψ±Ω‚Ω…) in Arabic, which means "number". This is a math(s) library, one of the reasons to give this package a try is that, the performance is the main goal. As some great projects such as plotto and desmos make intense calculations in tons of iterations to generate the graph. The need of such an open-source project cares about these situations arises, don't forget to contribute by raising an issue at github or optimizing some algorithms πŸš€.

Features

  • Some helpful special maths functions in core.
  • Compile math expression from a string into js function, ready for evaluation, considering the performance as the main goal.
  • Parse math expression.
  • The same for latex.
  • Convert between latex and math expression.
  • Geometric shapes and properties and intersections: lines and circles are available now.
  • Use it harmony with other packages such as fraction.js and interval-arithmetics.

You can get and import any of Rakam's APIs directly, saving load time and bundle size.

Table Of Content

Use It

Browser.

<script src="https://cdn.jsdelivr.net/npm/rakam/main/index.js"></script>
<script src="https://cdn.jsdelivr.net/npm/rakam/main/index.min.js"></script>

Nodejs, or import then bundle.

❯ npm i rakam

core

πŸ›  engine

math2js

Rakam uses @scicave/math-parser library to parse math expression, then handle the AST, or say the parser tree, to generate the equivalent js code, in a very customizable way. After all of these steps, we easily use Function constructor, new Function(...).

See documentations for more about math2js.

math2latex

To convert ASCII-math expressions into latex representation. Let me rephrase it, 12sinx*2/3 => 12\sin{x} \cdot \frac{2}{3}.

See documentations for more about math2latex.

latex2js

Rakam uses @scicave/math-latex-parser library to parse latex expression. expression, then handle the AST, to generate the equivalent js code, in a very customizable way. After all of these steps, we easily use Function constructor, new Function(...).

See documentations for more about latex2js.

latex2math

To convert latex expressions into ASCII-math expressions. Let me rephrase it, 12\sin x\cdot\frac 23 => 12sin(x) * 2 / 3.

See documentations for more about latex2math.

πŸ“ geometry

angles

You can:

  • Convert angles from unit to another one (e.g. from deg to red, or rad to grad, etc...).
  • Calculate the angle between two vectors, { x: number, y: number }. You can also calculate the angle between two lines.
  • In both cases, between vectors or lines, you can get the minimal or maximal angle or get the angle by which the first vector (or line) rotates to reach the other vector (or line).
  • Calculate the angle in degree (as float number), and get it as {deg: number, min: number, sec: number}, degree, minutes and seconds respectively.
  • Or get it as 12Β° 26' 53.48"

Documentations: angles.

lines

You can:

  • Get a line equation parameters: "a", "b" and "c" in ax + by + c = 0.
  • Get the intersection points between lines and any other geometric shape such as circles.
  • Project a point onto a line.
  • Get the distance between a point and a line.

Documentations: lines.

circles

You can:

  • Get a line equation parameters: "h", "k" and "r" in (x-h)^2 + (y-k)^2 = r^2.
  • Get the intersection points between circles and any other geometric shape such as lines.
  • Project a point onto a circle.
  • Get the distance between a point and a line.

Documentations: circles.

βž— fraction

In order to adhere to the universal law "DON'T reinvent the wheel", fraction.js is a great and fast library to do computations on fractions. You can also use it with harmony with Rakam, see math2js and latex2js, and the options chain: true, chainHead: (num)=>{ new Fraction(num) }, chainMap.

πŸ“œ License

Copyright (Β©) 2020 sciCaveβ„’ [email protected]

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

FOSSA Status

rakam's People

Contributors

dependabot[bot] avatar fossabot avatar muhammadsawalhy avatar snyk-bot avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

rakam's Issues

Build Issue

I have installed your NPM package and tried running npm install in the node-modules/rakam directory. I have also cloned your repository and tried an install. Both fail. I have also tried npm run build in both places and it fails.

In node-modules/rakam:

npm install
npm WARN deprecated [email protected]: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.

> [email protected] prepare /home/syblackwell/git/downrunner/node_modules/rakam
> npm run lint && npm run test


> [email protected] lint /home/syblackwell/git/downrunner/node_modules/rakam
> eslint src/ --fix


Oops! Something went wrong! :(

ESLint: 7.9.0

No files matching the pattern "src/" were found.
Please check for typing mistakes in the pattern.

npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] lint: `eslint src/ --fix`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the [email protected] lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/syblackwell/.npm/_logs/2020-09-25T17_55_48_943Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] prepare: `npm run lint && npm run test`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the [email protected] prepare script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/syblackwell/.npm/_logs/2020-09-25T17_55_49_086Z-debug.log

In /rakam:

npm install

> [email protected] prepare /home/syblackwell/git/rakam
> npm run lint && npm run test


> [email protected] lint /home/syblackwell/git/rakam
> eslint src/ --fix


> [email protected] test /home/syblackwell/git/rakam
> jest

 FAIL  test/geometry/angles.test.js
  ● Test suite failed to run

    Configuration error:
    
    Could not locate module rakam mapped as:
    /home/syblackwell/git/rakam/main/index.js.
    
    Please check your configuration for these entries:
    {
      "moduleNameMapper": {
        "/rakam/": "/home/syblackwell/git/rakam/main/index.js"
      },
      "resolver": undefined
    }

    > 1 | const { angles, vector } = require('rakam');
        |                            ^
      2 | 
      3 | // the acceptable differencve between the expected
      4 | // value and the return angle from "angles" methods

      at createNoMappedModuleFoundError (node_modules/jest-resolve/build/index.js:552:17)
      at Object.<anonymous> (test/geometry/angles.test.js:1:28)

 FAIL  test/fraction/fraction.test.js
  ● Test suite failed to run

    Configuration error:
    
    Could not locate module rakam mapped as:
    /home/syblackwell/git/rakam/main/index.js.
    
    Please check your configuration for these entries:
    {
      "moduleNameMapper": {
        "/rakam/": "/home/syblackwell/git/rakam/main/index.js"
      },
      "resolver": undefined
    }

    > 1 | const {quotRem, frac, randomInt, random } = require('rakam');
        |                                             ^
      2 | 
      3 | let tests = [
      4 |   {

      at createNoMappedModuleFoundError (node_modules/jest-resolve/build/index.js:552:17)
      at Object.<anonymous> (test/fraction/fraction.test.js:1:45)

 FAIL  test/engine/math2js.test.js
  ● Test suite failed to run

    Configuration error:
    
    Could not locate module rakam mapped as:
    /home/syblackwell/git/rakam/main/index.js.
    
    Please check your configuration for these entries:
    {
      "moduleNameMapper": {
        "/rakam/": "/home/syblackwell/git/rakam/main/index.js"
      },
      "resolver": undefined
    }

      2 | 
      3 | // we are using rollup-jest transformer
    > 4 | const {math2js} = require('rakam');
        |                   ^
      5 | const defaultHandlers = math2js.defaultHandlers;
      6 | const generateJs = math2js.generateJs;
      7 | 

      at createNoMappedModuleFoundError (node_modules/jest-resolve/build/index.js:552:17)
      at Object.<anonymous> (test/engine/math2js.test.js:4:19)

Test Suites: 3 failed, 3 total
Tests:       0 total
Snapshots:   0 total
Time:        2.443 s
Ran all test suites.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] test: `jest`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/syblackwell/.npm/_logs/2020-09-25T17_43_31_829Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] prepare: `npm run lint && npm run test`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] prepare script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/syblackwell/.npm/_logs/2020-09-25T17_43_31_953Z-debug.log

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.