https://github.com/tecfu/is-multiple-of
Floating point modulus for javascript.
https://github.com/tecfu/is-multiple-of
Last synced: over 1 year ago
JSON representation
Floating point modulus for javascript.
- Host: GitHub
- URL: https://github.com/tecfu/is-multiple-of
- Owner: tecfu
- License: mit
- Created: 2020-03-08T23:48:59.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-30T19:50:23.000Z (over 3 years ago)
- Last Synced: 2025-03-23T02:44:47.922Z (over 1 year ago)
- Language: JavaScript
- Size: 1.49 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# is-multiple-of
[](https://travis-ci.org/tecfu/is-multiple-of) [](http://badge.fury.io/js/is-multiple-of) [](https://coveralls.io/github/tecfu/is-multiple-of?branch=master)
---
Floating point modulus operator functionality for javascript.
Accurate to 16 digits and 6 decimal places.
---
## Rationale
- javascript can't divide floats accurately: i.e. 4.55 / .05 === 90.999999
```js
4.55 % .05 === 0 // false
```
whereas:
```js
multipleOf(4.55, .05) // true
```
## Installation
- Node Module
```sh
$ npm install @tecfu/is-multiple-of
```
- Browser
```js
import multipleOf from 'https://cdn.jsdelivr.net/gh/tecfu/is-multiple-of/dist/is-multiple-of.esm.js'
let multipleOf = require('is-multiple-of') // https://cdn.jsdelivr.net/gh/tecfu/is-multiple-of/dist/is-multiple-of.cjs.js
let multipleOf = IsMultipleOf; // https://cdn.jsdelivr.net/gh/tecfu/is-multiple-of/dist/is-multiple-of.umd.js
```
## Version Compatibility
| Node Version | multipleOf Version |
| -------------- | ------------------|
| 8.0 | >= 1.0 |
## Running tests
```sh
$ npm test
```
## Pull Requests
Pull requests are encouraged!
- Please remember to add a unit test when necessary
- Please format your commit messages according to the ["Conventional Commits"](https://www.conventionalcommits.org/en/v1.0.0/) specification
If you aren't familiar with Conventional Commits, here's a good [article on the topic](https://dev.to/maniflames/how-conventional-commits-improved-my-git-skills-1jfk)
TL/DR:
- feat: a feature that is visible for end users.
- fix: a bugfix that is visible for end users.
- chore: a change that doesn't impact end users (e.g. chances to CI pipeline)
- docs: a change in the README or documentation
- refactor: a change in production code focused on readability, style and/or performance.
## License
[MIT License](https://opensource.org/licenses/MIT)
Copyright 2020, Tecfu.