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 🙏

© 2024 – Pkg Stats / Ryan Hefner

easy-calculation

v1.0.2

Published

NodeJS Calculation Package

Downloads

9

Readme

A Simple NodeJS Calculation Package, Can be used in Projects such as Discord Bots.


Features:

  1. User-Friendly Mode
  2. No Vulnerabilities
  3. Easy to Use
  4. Fast

How To Use?

Example Usage:

console.log(require('easy-calculation').calculate('2+2')); // 4
console.log(require('easy-calculation').calculate('pi')); // 3.141592653589793
console.log(require('easy-calculation').calculate('qwerty')); // NaN
console.log(require('easy-calculation').calculate('(2+2)>(4+4)')); // false
console.log(require('easy-calculation').calculate('(2+2)<(4+4)')); // true
console.log(require('easy-calculation').calculate('Infinity')); // Infinity
console.log(require('easy-calculation').calculate('')); // null
console.log(require('easy-calculation').calculate('random')); // 0.7804080476762894
console.log(require('easy-calculation').calculate('round(pi)')); // 3
console.log(require('easy-calculation').calculate('trunc(pi)')); // 3
console.log(require('easy-calculation').calculate('sqrt(pi)')); // 1.7724538509055159
console.log(require('easy-calculation').calculate('floor(random * floor(50))')); // 39
console.log(require('easy-calculation').calculate('cbrt(pi)')); // 1.4645918875615231

User-Friendly Mode:

console.log(require('easy-calculation').calculate('2+2', true)); // 4
console.log(require('easy-calculation').calculate('pi', true)); // 3.141592653589793
console.log(require('easy-calculation').calculate('qwerty', true)); // Invalid Calculation
console.log(require('easy-calculation').calculate('(2+2)>(4+4)', true)); // False
console.log(require('easy-calculation').calculate('(2+2)<(4+4)', true)); // True
console.log(require('easy-calculation').calculate('Infinity', true)); // Too Big to Display
console.log(require('easy-calculation').calculate('', true)); // No Calculation Provided
console.log(require('easy-calculation').calculate('random', true)); // 0.7804080476762894
console.log(require('easy-calculation').calculate('round(pi)', true)); // 3
console.log(require('easy-calculation').calculate('trunc(pi)', true)); // 3
console.log(require('easy-calculation').calculate('sqrt(pi)', true)); // 1.7724538509055159
console.log(require('easy-calculation').calculate('floor(random * floor(50))', true)); // 39
console.log(require('easy-calculation').calculate('cbrt(pi)'), true); // 1.4645918875615231

User-Friendly Mode is a Boolean argument after the Calculation argument.


Example Usage in Discord.js:

const Discord = require('discord.js');
const calculator = require('easy-calculation');
module.exports = {
    name: 'calc',
    execute(message, args) {
        return message.channel.send(new Discord.MessageEmbed()
            .setAuthor(message.author.tag, message.author.displayAvatarURL({ dynamic: true }))
            .setTitle('Calculator')
            .setDescription(calculator.calculate(args.join(" "), true))
            .setColor(24325));
    }
}

Example Usage in Eris:

const calculator = require('easy-calculation');
module.exports = {
    name: 'calc',
    execute(message, args) {
        return message.channel.createMessage({embed: {
            author: {
                name: message.author.username + '#' + message.author.discriminator,
                icon_url: message.author.avatarURL
            },
            title: 'Calculator',
            description: calculator.calculate(args.join(" "), true),
            color: 24325
        }});
    }
}

Need More Support? Join our Discord Server!