LogoLogo
GitHubNPMDiscord Support
5.x
5.x
  • What is Enmap?
  • Enmap Installation
    • Troubleshooting Guide
    • Migrating data from Enmap 3
  • Usage Documentation
    • Basic Data Use
    • Understanding Paths
    • Working with Objects
    • Array Methods
    • Mathematical Methods
    • Using the fetchAll option
    • Using from multiple files
    • Serializing and Deserializing
  • Full Documentation
  • Examples
    • D.js Points/Currency
    • D.js Per-Server Settings
    • D.js Mod Logs
    • Koa Authentication
  • Blog Posts
    • Enmap's History
    • Why SQLITE only?
    • Enmap and Josh
  • Supporters and Partners
Powered by GitBook
On this page
  • enmap.math(key, operation, operator, [objectPath])
  • enmap.inc(key, [objectPath])
  • enmap.dec(key. [objectPath])
Export as PDF
  1. Usage Documentation

Mathematical Methods

This page is a work in progress and may not have the polish of a usual Evie-Written document!

Some quick docs:

enmap.math(key, operation, operator, [objectPath])

// Assuming
points.set("number", 42);
points.set("numberInObject", {sub: { anInt: 5 }});
 
points.math("number", "/", 2); // 21
points.math("number", "add", 5); // 26
points.math("number", "modulo", 3); // 2
points.math("numberInObject", "+", 10, "sub.anInt");

Possible Operators (accepts all variations listed below, as strings):

  • +, add, addition: Increments the value in the enmap by the provided value.

  • -, sub, subtract: Decrements the value in the enmap by the provided value.

  • *, mult, multiply: Multiply the value in the enmap by the provided value.

  • /, div, divide: Divide the value in the enmap by the provided value.

  • %, mod, modulo: Gets the modulo of the value in the enmap by the provided value.

  • ^, exp, exponential: Raises the value in the enmap by the power of the provided value.

enmap.inc(key, [objectPath])

// Assuming
points.set("number", 42);
points.set("numberInObject", {sub: { anInt: 5 }});
 
points.inc("number"); // 43
points.inc("numberInObject", "sub.anInt"); // {sub: { anInt: 6 }}

enmap.dec(key. [objectPath])

// Assuming
points.set("number", 42);
points.set("numberInObject", {sub: { anInt: 5 }});
 
points.dec("number"); // 41
points.dec("numberInObject", "sub.anInt"); // {sub: { anInt: 4 }}

PreviousArray MethodsNextUsing the fetchAll option

Last updated 6 years ago