Giter Club home page Giter Club logo

newtonmath.js's Introduction

NewtonMath.js

npm Travis build status

Basics

NewtonMath.js is an ES2016 compliant JavaScript API wrapper providing full support for the newton micro-service, which is available on GitHub.

Newton does anything from numerical calculation to symbolic math parsing.

Installation

Using npm:

npm install newtonmath.js --save

Usage

NewtonMath.js is compatible with node 6.x and both CommonJS and AMD module specifications and can run in the browser. API calls are implemented asynchronously and the result is available as the most appropriate type via a callback.

See the newton API GitHub repo for the full list of endpoints.

Node

newton = require('newtonmath.js');

newton.derive('x^2', r => console.log(r)); // -> '2 x'
newton.cos('pi', r => console.log(r)); // -> -1
newton.zeroes('x^2+2x', r => console.log(r)); // -> [-2, 0]

Browser

<!-- In <head> -->
<script src="newtonmath-min.js"></script>

<!-- In <body> or script file -->
<script>
NewtonMath.derive('x^2', r => console.log(r)); // -> '2 x'
</script>

noConflict

In the same vein as jQuery's noConflict method, you can reset the NewtonMath global to its value prior to loading the module.

newton = NewtonMath.noConflict();

Optional arguments

The following methods take optional extra arguments for convenience. As per the API, if these are not specified they must be included before a horizontal bar '|' in the expression for newton.

newton.log('2|8', r => console.log(r)); // -> 3
newton.log(8, 2, r => console.log(r)); // -> 3

newton.tangent('2|x^3', r => console.log(r)); // -> '12 x + -16'
newton.tangent('x^3', 2, r => console.log(r)); // -> '12 x + -16'

newton.area('2:4|x^3', r => console.log(r)); // -> 60
newton.area('x^3', 2, 4, r => console.log(r)); // -> 60

Building and testing

Build the minified file and source map with babili:

npm run-script build

Run tests with Jasmine:

npm test

newtonmath.js's People

Contributors

benpryke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 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.