@splendidlabz/utils 1.12.0 → 1.13.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.
Files changed (62) hide show
  1. package/dist/cjs/dom/font-size.cjs +1 -1
  2. package/dist/cjs/dom/index.cjs +1 -1
  3. package/dist/cjs/lib/colors.cjs +39 -0
  4. package/dist/cjs/lib/date/index.cjs +1 -1
  5. package/dist/cjs/lib/date/time.cjs +1 -1
  6. package/dist/cjs/lib/http/index.cjs +100 -0
  7. package/dist/cjs/lib/http/status-text.cjs +98 -0
  8. package/dist/cjs/lib/index.cjs +584 -11
  9. package/dist/cjs/lib/numbers/index.cjs +12 -1
  10. package/dist/cjs/lib/numbers/random.cjs +35 -0
  11. package/dist/cjs/lib/numbers/split-unit.cjs +35 -0
  12. package/dist/cjs/lib/promises/index.cjs +72 -15
  13. package/dist/cjs/lib/promises/reject.cjs +72 -13
  14. package/dist/cjs/lib/strings/index.cjs +368 -6
  15. package/dist/cjs/lib/strings/pluralize.cjs +372 -14
  16. package/dist/cjs/lib/strings/query-string.cjs +0 -6
  17. package/dist/cjs/lib/style/index.cjs +35 -1
  18. package/dist/cjs/lib/style/scatter.cjs +60 -0
  19. package/dist/cjs/lib/style/to-style-string.cjs +64 -0
  20. package/dist/cjs/lib/svg/displace.cjs +94 -0
  21. package/dist/cjs/lib/svg/index.cjs +126 -0
  22. package/dist/cjs/lib/svg/noise.cjs +56 -0
  23. package/dist/esm/lib/colors.js +14 -0
  24. package/dist/esm/lib/http/index.js +1 -0
  25. package/dist/esm/lib/http/status-text.js +72 -0
  26. package/dist/esm/lib/index.js +3 -0
  27. package/dist/esm/lib/numbers/index.js +2 -10
  28. package/dist/esm/lib/numbers/random.js +10 -0
  29. package/dist/esm/lib/numbers/split-unit.js +10 -0
  30. package/dist/esm/lib/promises/reject.js +2 -2
  31. package/dist/esm/lib/strings/pluralize.js +366 -3
  32. package/dist/esm/lib/strings/query-string.js +0 -5
  33. package/dist/esm/lib/style/index.js +2 -12
  34. package/dist/esm/lib/style/scatter.js +25 -0
  35. package/dist/esm/lib/style/to-style-string.js +12 -0
  36. package/dist/esm/lib/svg/displace.js +68 -0
  37. package/dist/esm/lib/svg/index.js +2 -0
  38. package/dist/esm/lib/svg/noise.js +16 -0
  39. package/dist/types/dom/font-size.d.cts +1 -1
  40. package/dist/types/lib/colors.d.cts +12 -0
  41. package/dist/types/lib/http/index.d.cts +1 -0
  42. package/dist/types/lib/http/status-text.d.cts +73 -0
  43. package/dist/types/lib/index.d.cts +11 -5
  44. package/dist/types/lib/numbers/index.d.cts +2 -4
  45. package/dist/types/lib/numbers/random.d.cts +14 -0
  46. package/dist/types/lib/numbers/split-unit.d.cts +8 -0
  47. package/dist/types/lib/strings/index.d.cts +2 -2
  48. package/dist/types/lib/strings/pluralize.d.cts +24 -2
  49. package/dist/types/lib/strings/query-string.d.cts +1 -2
  50. package/dist/types/lib/style/index.d.cts +2 -3
  51. package/dist/types/lib/style/scatter.d.cts +48 -0
  52. package/dist/types/lib/style/to-style-string.d.cts +8 -0
  53. package/dist/types/lib/svg/displace.d.cts +54 -0
  54. package/dist/types/lib/svg/index.d.cts +2 -0
  55. package/dist/types/lib/svg/noise.d.cts +24 -0
  56. package/dist/types/node/dirname.d.cts +2 -2
  57. package/dist/types/node/file.d.cts +1 -1
  58. package/dist/types/node/hash.d.cts +1 -1
  59. package/dist/types/node/pkce.d.cts +4 -4
  60. package/dist/types/node/random-string.d.cts +1 -1
  61. package/dist/types/node/uuid.d.cts +1 -1
  62. package/package.json +3 -6
@@ -19,6 +19,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  // src/lib/numbers/index.js
20
20
  var numbers_exports = {};
21
21
  __export(numbers_exports, {
22
+ seededRandom: () => seededRandom,
22
23
  splitUnit: () => splitUnit,
23
24
  toDegrees: () => toDegrees,
24
25
  toRadians: () => toRadians
@@ -33,7 +34,16 @@ function toRadians(angle) {
33
34
  return angle * (Math.PI / 180);
34
35
  }
35
36
 
36
- // src/lib/numbers/index.js
37
+ // src/lib/numbers/random.js
38
+ function seededRandom(seed = 1) {
39
+ let state = seed >>> 0;
40
+ return () => {
41
+ state = state * 1664525 + 1013904223 >>> 0;
42
+ return state / 4294967296;
43
+ };
44
+ }
45
+
46
+ // src/lib/numbers/split-unit.js
37
47
  function splitUnit(string) {
38
48
  if (typeof string === "number") return [string, null];
39
49
  const regex = /(-?\d*\.?\d+)\s*([a-z]+)/i;
@@ -43,6 +53,7 @@ function splitUnit(string) {
43
53
  }
44
54
  // Annotate the CommonJS export names for ESM import in node:
45
55
  0 && (module.exports = {
56
+ seededRandom,
46
57
  splitUnit,
47
58
  toDegrees,
48
59
  toRadians
@@ -0,0 +1,35 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/lib/numbers/random.js
20
+ var random_exports = {};
21
+ __export(random_exports, {
22
+ seededRandom: () => seededRandom
23
+ });
24
+ module.exports = __toCommonJS(random_exports);
25
+ function seededRandom(seed = 1) {
26
+ let state = seed >>> 0;
27
+ return () => {
28
+ state = state * 1664525 + 1013904223 >>> 0;
29
+ return state / 4294967296;
30
+ };
31
+ }
32
+ // Annotate the CommonJS export names for ESM import in node:
33
+ 0 && (module.exports = {
34
+ seededRandom
35
+ });
@@ -0,0 +1,35 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/lib/numbers/split-unit.js
20
+ var split_unit_exports = {};
21
+ __export(split_unit_exports, {
22
+ splitUnit: () => splitUnit
23
+ });
24
+ module.exports = __toCommonJS(split_unit_exports);
25
+ function splitUnit(string) {
26
+ if (typeof string === "number") return [string, null];
27
+ const regex = /(-?\d*\.?\d+)\s*([a-z]+)/i;
28
+ const match = string.match(regex);
29
+ if (match) return [parseFloat(match[1]), match[2]];
30
+ return [parseFloat(string), null];
31
+ }
32
+ // Annotate the CommonJS export names for ESM import in node:
33
+ 0 && (module.exports = {
34
+ splitUnit
35
+ });
@@ -1,8 +1,6 @@
1
- var __create = Object.create;
2
1
  var __defProp = Object.defineProperty;
3
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
5
  var __export = (target, all) => {
8
6
  for (var name in all)
@@ -16,14 +14,6 @@ var __copyProps = (to, from, except, desc) => {
16
14
  }
17
15
  return to;
18
16
  };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
18
 
29
19
  // src/lib/promises/index.js
@@ -33,9 +23,6 @@ __export(promises_exports, {
33
23
  });
34
24
  module.exports = __toCommonJS(promises_exports);
35
25
 
36
- // src/lib/promises/reject.js
37
- var import_statuses = __toESM(require("statuses"), 1);
38
-
39
26
  // src/lib/objects/omit-empty.js
40
27
  function omitEmpty(obj, shallow = false) {
41
28
  if (typeof obj !== "object" || obj === null) return obj;
@@ -50,13 +37,83 @@ function omitEmpty(obj, shallow = false) {
50
37
  return result;
51
38
  }
52
39
 
40
+ // src/lib/http/status-text.js
41
+ var statusTexts = {
42
+ 100: "Continue",
43
+ 101: "Switching Protocols",
44
+ 102: "Processing",
45
+ 103: "Early Hints",
46
+ 200: "OK",
47
+ 201: "Created",
48
+ 202: "Accepted",
49
+ 203: "Non-Authoritative Information",
50
+ 204: "No Content",
51
+ 205: "Reset Content",
52
+ 206: "Partial Content",
53
+ 207: "Multi-Status",
54
+ 208: "Already Reported",
55
+ 226: "IM Used",
56
+ 300: "Multiple Choices",
57
+ 301: "Moved Permanently",
58
+ 302: "Found",
59
+ 303: "See Other",
60
+ 304: "Not Modified",
61
+ 305: "Use Proxy",
62
+ 307: "Temporary Redirect",
63
+ 308: "Permanent Redirect",
64
+ 400: "Bad Request",
65
+ 401: "Unauthorized",
66
+ 402: "Payment Required",
67
+ 403: "Forbidden",
68
+ 404: "Not Found",
69
+ 405: "Method Not Allowed",
70
+ 406: "Not Acceptable",
71
+ 407: "Proxy Authentication Required",
72
+ 408: "Request Timeout",
73
+ 409: "Conflict",
74
+ 410: "Gone",
75
+ 411: "Length Required",
76
+ 412: "Precondition Failed",
77
+ 413: "Payload Too Large",
78
+ 414: "URI Too Long",
79
+ 415: "Unsupported Media Type",
80
+ 416: "Range Not Satisfiable",
81
+ 417: "Expectation Failed",
82
+ 418: "I'm a Teapot",
83
+ 421: "Misdirected Request",
84
+ 422: "Unprocessable Entity",
85
+ 423: "Locked",
86
+ 424: "Failed Dependency",
87
+ 425: "Too Early",
88
+ 426: "Upgrade Required",
89
+ 428: "Precondition Required",
90
+ 429: "Too Many Requests",
91
+ 431: "Request Header Fields Too Large",
92
+ 451: "Unavailable For Legal Reasons",
93
+ 500: "Internal Server Error",
94
+ 501: "Not Implemented",
95
+ 502: "Bad Gateway",
96
+ 503: "Service Unavailable",
97
+ 504: "Gateway Timeout",
98
+ 505: "HTTP Version Not Supported",
99
+ 506: "Variant Also Negotiates",
100
+ 507: "Insufficient Storage",
101
+ 508: "Loop Detected",
102
+ 509: "Bandwidth Limit Exceeded",
103
+ 510: "Not Extended",
104
+ 511: "Network Authentication Required"
105
+ };
106
+ function statusText(code) {
107
+ return statusTexts[code];
108
+ }
109
+
53
110
  // src/lib/promises/reject.js
54
111
  function reject(props, { includeStack = true } = {}) {
55
- const { status, statusText, body, message } = props;
112
+ const { status, statusText: statusText2, body, message } = props;
56
113
  const e = new Error();
57
114
  const err = {
58
115
  status,
59
- statusText: statusText || status && (0, import_statuses.default)(status),
116
+ statusText: statusText2 || status && statusText(status),
60
117
  body,
61
118
  message,
62
119
  stack: includeStack && e.stack
@@ -1,8 +1,6 @@
1
- var __create = Object.create;
2
1
  var __defProp = Object.defineProperty;
3
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
5
  var __export = (target, all) => {
8
6
  for (var name in all)
@@ -16,14 +14,6 @@ var __copyProps = (to, from, except, desc) => {
16
14
  }
17
15
  return to;
18
16
  };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
18
 
29
19
  // src/lib/promises/reject.js
@@ -32,7 +22,6 @@ __export(reject_exports, {
32
22
  reject: () => reject
33
23
  });
34
24
  module.exports = __toCommonJS(reject_exports);
35
- var import_statuses = __toESM(require("statuses"), 1);
36
25
 
37
26
  // src/lib/objects/omit-empty.js
38
27
  function omitEmpty(obj, shallow = false) {
@@ -48,13 +37,83 @@ function omitEmpty(obj, shallow = false) {
48
37
  return result;
49
38
  }
50
39
 
40
+ // src/lib/http/status-text.js
41
+ var statusTexts = {
42
+ 100: "Continue",
43
+ 101: "Switching Protocols",
44
+ 102: "Processing",
45
+ 103: "Early Hints",
46
+ 200: "OK",
47
+ 201: "Created",
48
+ 202: "Accepted",
49
+ 203: "Non-Authoritative Information",
50
+ 204: "No Content",
51
+ 205: "Reset Content",
52
+ 206: "Partial Content",
53
+ 207: "Multi-Status",
54
+ 208: "Already Reported",
55
+ 226: "IM Used",
56
+ 300: "Multiple Choices",
57
+ 301: "Moved Permanently",
58
+ 302: "Found",
59
+ 303: "See Other",
60
+ 304: "Not Modified",
61
+ 305: "Use Proxy",
62
+ 307: "Temporary Redirect",
63
+ 308: "Permanent Redirect",
64
+ 400: "Bad Request",
65
+ 401: "Unauthorized",
66
+ 402: "Payment Required",
67
+ 403: "Forbidden",
68
+ 404: "Not Found",
69
+ 405: "Method Not Allowed",
70
+ 406: "Not Acceptable",
71
+ 407: "Proxy Authentication Required",
72
+ 408: "Request Timeout",
73
+ 409: "Conflict",
74
+ 410: "Gone",
75
+ 411: "Length Required",
76
+ 412: "Precondition Failed",
77
+ 413: "Payload Too Large",
78
+ 414: "URI Too Long",
79
+ 415: "Unsupported Media Type",
80
+ 416: "Range Not Satisfiable",
81
+ 417: "Expectation Failed",
82
+ 418: "I'm a Teapot",
83
+ 421: "Misdirected Request",
84
+ 422: "Unprocessable Entity",
85
+ 423: "Locked",
86
+ 424: "Failed Dependency",
87
+ 425: "Too Early",
88
+ 426: "Upgrade Required",
89
+ 428: "Precondition Required",
90
+ 429: "Too Many Requests",
91
+ 431: "Request Header Fields Too Large",
92
+ 451: "Unavailable For Legal Reasons",
93
+ 500: "Internal Server Error",
94
+ 501: "Not Implemented",
95
+ 502: "Bad Gateway",
96
+ 503: "Service Unavailable",
97
+ 504: "Gateway Timeout",
98
+ 505: "HTTP Version Not Supported",
99
+ 506: "Variant Also Negotiates",
100
+ 507: "Insufficient Storage",
101
+ 508: "Loop Detected",
102
+ 509: "Bandwidth Limit Exceeded",
103
+ 510: "Not Extended",
104
+ 511: "Network Authentication Required"
105
+ };
106
+ function statusText(code) {
107
+ return statusTexts[code];
108
+ }
109
+
51
110
  // src/lib/promises/reject.js
52
111
  function reject(props, { includeStack = true } = {}) {
53
- const { status, statusText, body, message } = props;
112
+ const { status, statusText: statusText2, body, message } = props;
54
113
  const e = new Error();
55
114
  const err = {
56
115
  status,
57
- statusText: statusText || status && (0, import_statuses.default)(status),
116
+ statusText: statusText2 || status && statusText(status),
58
117
  body,
59
118
  message,
60
119
  stack: includeStack && e.stack