https://github.com/ericvera/sort-value
A JavaScript utility library to generate sort values (floating point)
https://github.com/ericvera/sort-value
Last synced: 10 months ago
JSON representation
A JavaScript utility library to generate sort values (floating point)
- Host: GitHub
- URL: https://github.com/ericvera/sort-value
- Owner: ericvera
- License: mit
- Created: 2017-10-02T07:23:49.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-10-02T07:46:46.000Z (over 8 years ago)
- Last Synced: 2025-07-05T11:11:34.022Z (12 months ago)
- Language: JavaScript
- Size: 28.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# sort-value
A JavaScript utility library to generate sort values (floating point).
# Usage
Install the module:
```sh
npm install sort-value --save
```
```js
sortValue(after, before);
```
Returns a value between the after and before.
```js
import sortValue from 'sort-value';
const value = sortValue(0, 1);
console.log(value);
// Output: 0.5
```
# Input => Output
* undefined, 0 => -1
* 0, undefined => 1
* 0, 1 => 0.5
* 0, 0.5 => 0.3
* 0, 0.1 => 0.05
# License
[MIT](https://github.com/ericvera/sort-value/blob/master/LICENSE)