@wise-old-man/utils 3.3.9 → 3.3.10

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.
@@ -1,8 +1,5 @@
1
1
  'use strict';
2
2
 
3
- var dayjs = require('dayjs');
4
- var customParseFormatPlugin = require('dayjs/plugin/customParseFormat.js');
5
-
6
3
  var config = {
7
4
  defaultUserAgent: `WiseOldMan JS Client v${process.env.npm_package_version}`,
8
5
  baseAPIUrl: 'https://api.wiseoldman.net/v2'
@@ -47,7 +44,6 @@ function __awaiter(thisArg, _arguments, P, generator) {
47
44
  });
48
45
  }
49
46
 
50
- dayjs.extend(customParseFormatPlugin);
51
47
  function traverseTransform(input, transformation) {
52
48
  if (Array.isArray(input)) {
53
49
  return input.map(item => traverseTransform(item, transformation));
@@ -60,9 +56,8 @@ function traverseTransform(input, transformation) {
60
56
  function isValidISODate(input) {
61
57
  if (!input || typeof input !== 'string')
62
58
  return false;
63
- // DayJS has a bug with strict parsing with timezones https://github.com/iamkun/dayjs/issues/929
64
- // So I'll just strip the "Z" timezone
65
- return input.endsWith('Z') && dayjs(input.slice(0, -1), 'YYYY-MM-DDTHH:mm:ss.SSS', true).isValid();
59
+ // Validate this input string is a ISO 8601 date
60
+ return /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(input);
66
61
  }
67
62
  function transformDates(input) {
68
63
  return traverseTransform(input, val => (isValidISODate(val) ? new Date(val) : val));
package/dist/es/index.js CHANGED
@@ -1,6 +1,3 @@
1
- import dayjs from 'dayjs';
2
- import customParseFormatPlugin from 'dayjs/plugin/customParseFormat.js';
3
-
4
1
  var config = {
5
2
  defaultUserAgent: `WiseOldMan JS Client v${process.env.npm_package_version}`,
6
3
  baseAPIUrl: 'https://api.wiseoldman.net/v2'
@@ -45,7 +42,6 @@ function __awaiter(thisArg, _arguments, P, generator) {
45
42
  });
46
43
  }
47
44
 
48
- dayjs.extend(customParseFormatPlugin);
49
45
  function traverseTransform(input, transformation) {
50
46
  if (Array.isArray(input)) {
51
47
  return input.map(item => traverseTransform(item, transformation));
@@ -58,9 +54,8 @@ function traverseTransform(input, transformation) {
58
54
  function isValidISODate(input) {
59
55
  if (!input || typeof input !== 'string')
60
56
  return false;
61
- // DayJS has a bug with strict parsing with timezones https://github.com/iamkun/dayjs/issues/929
62
- // So I'll just strip the "Z" timezone
63
- return input.endsWith('Z') && dayjs(input.slice(0, -1), 'YYYY-MM-DDTHH:mm:ss.SSS', true).isValid();
57
+ // Validate this input string is a ISO 8601 date
58
+ return /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(input);
64
59
  }
65
60
  function transformDates(input) {
66
61
  return traverseTransform(input, val => (isValidISODate(val) ? new Date(val) : val));
package/dist/es/index.mjs CHANGED
@@ -1,6 +1,3 @@
1
- import dayjs from 'dayjs';
2
- import customParseFormatPlugin from 'dayjs/plugin/customParseFormat.js';
3
-
4
1
  var config = {
5
2
  defaultUserAgent: `WiseOldMan JS Client v${process.env.npm_package_version}`,
6
3
  baseAPIUrl: 'https://api.wiseoldman.net/v2'
@@ -45,7 +42,6 @@ function __awaiter(thisArg, _arguments, P, generator) {
45
42
  });
46
43
  }
47
44
 
48
- dayjs.extend(customParseFormatPlugin);
49
45
  function traverseTransform(input, transformation) {
50
46
  if (Array.isArray(input)) {
51
47
  return input.map(item => traverseTransform(item, transformation));
@@ -58,9 +54,8 @@ function traverseTransform(input, transformation) {
58
54
  function isValidISODate(input) {
59
55
  if (!input || typeof input !== 'string')
60
56
  return false;
61
- // DayJS has a bug with strict parsing with timezones https://github.com/iamkun/dayjs/issues/929
62
- // So I'll just strip the "Z" timezone
63
- return input.endsWith('Z') && dayjs(input.slice(0, -1), 'YYYY-MM-DDTHH:mm:ss.SSS', true).isValid();
57
+ // Validate this input string is a ISO 8601 date
58
+ return /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(input);
64
59
  }
65
60
  function transformDates(input) {
66
61
  return traverseTransform(input, val => (isValidISODate(val) ? new Date(val) : val));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wise-old-man/utils",
3
- "version": "3.3.9",
3
+ "version": "3.3.10",
4
4
  "description": "A JavaScript/TypeScript client that interfaces and consumes the Wise Old Man API, an API that tracks and measures players' progress in Old School Runescape.",
5
5
  "keywords": [
6
6
  "wiseoldman",
@@ -51,7 +51,5 @@
51
51
  "tslib": "^2.4.0",
52
52
  "typescript": "^5.3.3"
53
53
  },
54
- "dependencies": {
55
- "dayjs": "^1.11.5"
56
- }
54
+ "dependencies": {}
57
55
  }