npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

gulp-math

v1.0.0

Published

Evaluate math expressions with gulp

Readme

gulp-math

Evaluate math expressions with gulp

gulp-math makes use of the Math.js library for Javascript and Node.js. Their documentation can be used to form the math expressions used by gulp-math.

Usage

First, install gulp-math as a development dependency:

npm install gulp-math

Then, add it to your gulpfile.js:

var math = require('gulp-math');

gulp.task('generate', function() {
    return gulp.src('pre.html')
        .pipe(math({columns: 12, column_padding: 20, max_content_width: 660}).on('error', function(err) {
            console.log(err.toString());
            this.emit('end');
        }))
        .pipe(gulp.dest(''));
});

Now, use gulpmath(); in your code:

gulpmath(10 * 2 - 5 / 3);

Options

gulp-math accepts a list of variables to be used in the calculations.

math(vars[, options])

vars

Type: Array Object

An associative array of variables to be used in the math expressions. The keys will be used as variable names.

.pipe(math({columns: 12, column_padding: 20, max_content_width: 660}))

options

Type: Array Object

An associative array of option used by the plugin. All Math.js configuration options are available. Documentation for Math.js options are taken directly from their site. Please note, gulp-math uses the eval function for evaluating expressions.

options.epsilon

Type: Number Default: 1e-14

The minimum relative difference used to test equality between two compared values. This value is used by all relational functions.

options.eval_precision

Type: Integer Default: 3 Available values: 0-15

The number of decimal places used when evaluating expressions. This option will only be used if options.number is set to number.

options.matrix

Type: String Default: matrix Available values: matrix or array

The default type of matrix output for functions. Available values are: matrix (default) or array. Where possible, the type of matrix output from functions is determined from the function input: An array as input will return an Array, a Matrix as input will return a Matrix. In case of no matrix as input, the type of output is determined by the option matrix. In case of mixed matrix inputs, a matrix will be returned always.

options.number

Type: String Default: number Available values: number or bignumber

The default type of numbers. This setting is used by functions like eval which cannot determine the correct type of output from the functions input. For most functions though, the type of output is determined from the the input: a number as input will return a number as output, a BigNumber as input returns a BigNumber as output. Available values are: number (default) or bignumber. BigNumbers have higher precision than the default numbers of JavaScript.

options.precision

Type: Integer Default: 64

The maximum number of significant digits for bigNumbers. This setting only applies to BigNumbers, not to numbers. Default value is 64.

Example

An HTML file with the following markup:

<div>
    gulpmath(abc = 5);
    <p>There are gulpmath(10 * 2 - abc); meese in the lodge.</p>
</div>

Will output the following:

<div>
    <p>There are 15 meese in the lodge.</p>
</div>

You can escape semi-colons in your expressions if you need to use them:

gulpmath(5\;20); // returns [20]

Known Issues

Unit conversions work, but the results may produce unusual results:

gulpmath(5.08 cm to inch); // on Windows, this produces 2.0000000000000004 inch