@valkyriestudios/utils 6.1.0 → 6.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic
6
6
  Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [6.2.0] - 2023-04-29
9
+ ### Added
10
+ - date/nowUnix
11
+ - date/nowUnixMs
12
+
13
+ ### Improved
14
+ - number/round: Improve precision on edge case numbers by using epsilon differentiator
15
+ - number/round: Improve performance and add benchmark (1.000.000 round ops in ~250ms)
16
+ - Dep: Upgrade @babel/core to 7.21.5
17
+ - Dep: Upgrade @babel/preset-env to 7.21.5
18
+
8
19
  ## [6.1.0] - 2023-04-23
9
20
  ### Improved
10
21
  - Reduce eventual bundle size for package
package/README.md CHANGED
@@ -278,6 +278,12 @@ isDate(new Date('December 17, 1995 03:24:00'); // TRUE
278
278
  isDate('December 17, 1995 03:24:00'); // FALSE
279
279
  ```
280
280
 
281
+ - **nowUnix()**
282
+ Returns the current unix timestamp in seconds
283
+
284
+ - **nowUnixMs()**
285
+ Returns the current unix timestamp in milliseconds
286
+
281
287
  ### deep
282
288
  - **deepFreeze(val:Object)**
283
289
  Recursively freezes all properties of an object
@@ -746,4 +752,4 @@ humanizeNumber(47328748923747923479); // '47,328.75q'
746
752
  allows passing options to control the output, following options are possible:
747
753
 
748
754
  ## Contributors
749
- - Peter Vermeulen : [Valkyrie Studios](www.valkyriestudios.be)
755
+ - [Peter Vermeulen](mailto:contact@valkyriestudios.be)
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ });
6
+ exports["default"] = nowUnix;
7
+ function nowUnix() {
8
+ return Math.floor(Date.now() / 1000);
9
+ }
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ });
6
+ exports["default"] = nowUnixMs;
7
+ function nowUnixMs() {
8
+ return Math.floor(Date.now());
9
+ }
package/number/round.js CHANGED
@@ -10,6 +10,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
10
10
  function round(val) {
11
11
  var precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
12
12
  if (!(0, _is["default"])(val)) throw new TypeError('Value should be numeric');
13
- if (!(0, _isIntegerAbove["default"])(precision, 0)) return Math.round(val);
14
- return Number(Math.round(val + 'e' + precision) + 'e-' + precision);
13
+ var exp = Math.pow(10, (0, _isIntegerAbove["default"])(precision, 0) ? precision : 0);
14
+ var num = val * exp * (1 + Number.EPSILON);
15
+ return Math.round(num) / exp;
15
16
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valkyriestudios/utils",
3
- "version": "6.1.0",
3
+ "version": "6.2.0",
4
4
  "description": "A collection of single-function utilities for common tasks",
5
5
  "main": "index.js",
6
6
  "author": {
@@ -32,8 +32,8 @@
32
32
  },
33
33
  "homepage": "https://github.com/ValkyrieStudios/utils#readme",
34
34
  "devDependencies": {
35
- "@babel/core": "^7.21.4",
36
- "@babel/preset-env": "^7.21.4",
35
+ "@babel/core": "^7.21.5",
36
+ "@babel/preset-env": "^7.21.5",
37
37
  "@babel/register": "^7.21.0",
38
38
  "babel-plugin-check-es2015-constants": "^6.22.0",
39
39
  "babel-plugin-transform-member-expression-literals": "^6.9.4",