@valkyriestudios/utils 6.1.0 → 6.3.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,21 @@ 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.3.0] - 2023-05-01
9
+ ### Added
10
+ - date/toUTC (benchmark 1.000.000 opts in ~500ms)
11
+
12
+ ## [6.2.0] - 2023-04-29
13
+ ### Added
14
+ - date/nowUnix
15
+ - date/nowUnixMs
16
+
17
+ ### Improved
18
+ - number/round: Improve precision on edge case numbers by using epsilon differentiator
19
+ - number/round: Improve performance and add benchmark (1.000.000 round ops in ~250ms)
20
+ - Dep: Upgrade @babel/core to 7.21.5
21
+ - Dep: Upgrade @babel/preset-env to 7.21.5
22
+
8
23
  ## [6.1.0] - 2023-04-23
9
24
  ### Improved
10
25
  - Reduce eventual bundle size for package
package/README.md CHANGED
@@ -278,6 +278,15 @@ 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
+ - **toUTC(val:Date)**
282
+ Takes the passed date object and returns a new date object set for utc
283
+
284
+ - **nowUnix()**
285
+ Returns the current unix timestamp in seconds
286
+
287
+ - **nowUnixMs()**
288
+ Returns the current unix timestamp in milliseconds
289
+
281
290
  ### deep
282
291
  - **deepFreeze(val:Object)**
283
292
  Recursively freezes all properties of an object
@@ -746,4 +755,4 @@ humanizeNumber(47328748923747923479); // '47,328.75q'
746
755
  allows passing options to control the output, following options are possible:
747
756
 
748
757
  ## Contributors
749
- - Peter Vermeulen : [Valkyrie Studios](www.valkyriestudios.be)
758
+ - [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/date/toUTC.js ADDED
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ });
6
+ exports["default"] = toUTC;
7
+ var _is = _interopRequireDefault(require("./is"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
9
+ function toUTC(val) {
10
+ if (!(0, _is["default"])(val)) throw new Error('Date To UTC requires a date object');
11
+ return new Date(Date.UTC(val.getUTCFullYear(), val.getUTCMonth(), val.getUTCDate(), val.getUTCHours(), val.getUTCMinutes(), val.getUTCSeconds(), val.getUTCMilliseconds()));
12
+ }
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.3.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",