@hpcc-js/util 2.45.0 → 2.46.1
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/LICENSE +43 -43
- package/dist/index.js +2290 -2289
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/lib-es6/__package__.js +3 -3
- package/lib-es6/array.js +84 -84
- package/lib-es6/array.js.map +1 -1
- package/lib-es6/cache.js +60 -60
- package/lib-es6/debounce.js +85 -85
- package/lib-es6/dictionary.js +61 -61
- package/lib-es6/dispatch.js +101 -101
- package/lib-es6/esp.js +32 -32
- package/lib-es6/graph.js +348 -348
- package/lib-es6/graph.js.map +1 -1
- package/lib-es6/graph2.js +603 -603
- package/lib-es6/graph2.js.map +1 -1
- package/lib-es6/hashSum.js +49 -49
- package/lib-es6/immutable.js +54 -54
- package/lib-es6/index.js +21 -21
- package/lib-es6/logging.js +177 -177
- package/lib-es6/logging.js.map +1 -1
- package/lib-es6/math.js +90 -90
- package/lib-es6/object.js +121 -121
- package/lib-es6/object.js.map +1 -1
- package/lib-es6/observer.js +79 -79
- package/lib-es6/platform.js +17 -17
- package/lib-es6/saxParser.js +125 -125
- package/lib-es6/stack.js +41 -41
- package/lib-es6/stateful.js +170 -170
- package/lib-es6/string.js +22 -22
- package/lib-es6/url.js +32 -32
- package/lib-es6/url.js.map +1 -1
- package/package.json +6 -21
- package/src/__package__.ts +2 -2
- package/src/array.ts +98 -98
- package/src/cache.ts +65 -65
- package/src/debounce.ts +88 -88
- package/src/dictionary.ts +69 -69
- package/src/dispatch.ts +119 -119
- package/src/esp.ts +32 -32
- package/src/graph.ts +353 -353
- package/src/graph2.ts +661 -661
- package/src/hashSum.ts +55 -55
- package/src/immutable.ts +57 -57
- package/src/index.ts +21 -21
- package/src/logging.ts +211 -211
- package/src/math.ts +92 -92
- package/src/object.ts +117 -117
- package/src/observer.ts +91 -91
- package/src/platform.ts +20 -20
- package/src/saxParser.ts +135 -135
- package/src/stack.ts +41 -41
- package/src/stateful.ts +178 -178
- package/src/string.ts +21 -21
- package/src/url.ts +27 -27
- package/types/__package__.d.ts +3 -3
- package/types/array.d.ts +13 -13
- package/types/cache.d.ts +20 -20
- package/types/debounce.d.ts +12 -12
- package/types/dictionary.d.ts +20 -20
- package/types/dispatch.d.ts +26 -26
- package/types/esp.d.ts +1 -1
- package/types/graph.d.ts +73 -73
- package/types/graph2.d.ts +111 -111
- package/types/hashSum.d.ts +1 -1
- package/types/immutable.d.ts +2 -2
- package/types/index.d.ts +21 -21
- package/types/logging.d.ts +57 -57
- package/types/math.d.ts +70 -70
- package/types/object.d.ts +48 -48
- package/types/observer.d.ts +18 -18
- package/types/platform.d.ts +5 -5
- package/types/saxParser.d.ts +28 -28
- package/types/stack.d.ts +28 -28
- package/types/stateful.d.ts +33 -33
- package/types/string.d.ts +2 -2
- package/types/url.d.ts +2 -2
- package/types-3.4/__package__.d.ts +2 -2
package/lib-es6/logging.js
CHANGED
|
@@ -1,178 +1,178 @@
|
|
|
1
|
-
import { isNode } from "./platform";
|
|
2
|
-
import { Stack } from "./stack";
|
|
3
|
-
export var Level;
|
|
4
|
-
(function (Level) {
|
|
5
|
-
Level[Level["debug"] = 0] = "debug";
|
|
6
|
-
Level[Level["info"] = 1] = "info";
|
|
7
|
-
Level[Level["notice"] = 2] = "notice";
|
|
8
|
-
Level[Level["warning"] = 3] = "warning";
|
|
9
|
-
Level[Level["error"] = 4] = "error";
|
|
10
|
-
Level[Level["critical"] = 5] = "critical";
|
|
11
|
-
Level[Level["alert"] = 6] = "alert";
|
|
12
|
-
Level[Level["emergency"] = 7] = "emergency";
|
|
13
|
-
})(Level || (Level = {}));
|
|
14
|
-
var colours = {
|
|
15
|
-
debug: "cyan",
|
|
16
|
-
info: "green",
|
|
17
|
-
notice: "grey",
|
|
18
|
-
warning: "blue",
|
|
19
|
-
error: "red",
|
|
20
|
-
critical: "magenta",
|
|
21
|
-
alert: "magenta",
|
|
22
|
-
emergency: "magenta"
|
|
23
|
-
};
|
|
24
|
-
var ConsoleWriter = /** @class */ (function () {
|
|
25
|
-
function ConsoleWriter() {
|
|
26
|
-
}
|
|
27
|
-
ConsoleWriter.prototype.write = function (dateTime, level, id, msg) {
|
|
28
|
-
if (isNode) {
|
|
29
|
-
console.log("["
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
console.log("["
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
return ConsoleWriter;
|
|
36
|
-
}());
|
|
37
|
-
var Logging = /** @class */ (function () {
|
|
38
|
-
function Logging() {
|
|
39
|
-
this._levelStack = new Stack();
|
|
40
|
-
this._level = Level.info;
|
|
41
|
-
this._filter = "";
|
|
42
|
-
this._writer = new ConsoleWriter();
|
|
43
|
-
}
|
|
44
|
-
Logging.Instance = function () {
|
|
45
|
-
return this._instance || (this._instance = new this());
|
|
46
|
-
};
|
|
47
|
-
Logging.prototype.stringify = function (obj) {
|
|
48
|
-
var cache = [];
|
|
49
|
-
return JSON.stringify(obj, function (_key, value) {
|
|
50
|
-
if (typeof value === "object" && value !== null) {
|
|
51
|
-
if (cache.indexOf(value) !== -1) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
cache.push(value);
|
|
55
|
-
}
|
|
56
|
-
return value;
|
|
57
|
-
}, 2);
|
|
58
|
-
};
|
|
59
|
-
Logging.prototype.writer = function (_) {
|
|
60
|
-
if (_ === void 0)
|
|
61
|
-
return this._writer;
|
|
62
|
-
this._writer = _;
|
|
63
|
-
return this;
|
|
64
|
-
};
|
|
65
|
-
Logging.prototype.log = function (level, id, msg) {
|
|
66
|
-
if (level < this._level)
|
|
67
|
-
return;
|
|
68
|
-
if (this._filter && this._filter !== id)
|
|
69
|
-
return;
|
|
70
|
-
var dateTime = new Date().toISOString();
|
|
71
|
-
if (this._writer.rawWrite) {
|
|
72
|
-
this._writer.rawWrite(dateTime, level, id, msg);
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
if (typeof msg !== "string") {
|
|
76
|
-
msg = this.stringify(msg);
|
|
77
|
-
}
|
|
78
|
-
if (this._writer.write) {
|
|
79
|
-
this._writer.write(dateTime, level, id, msg);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
Logging.prototype.debug = function (id, msg) {
|
|
84
|
-
this.log(Level.debug, id, msg);
|
|
85
|
-
};
|
|
86
|
-
Logging.prototype.info = function (id, msg) {
|
|
87
|
-
this.log(Level.info, id, msg);
|
|
88
|
-
};
|
|
89
|
-
Logging.prototype.notice = function (id, msg) {
|
|
90
|
-
this.log(Level.notice, id, msg);
|
|
91
|
-
};
|
|
92
|
-
Logging.prototype.warning = function (id, msg) {
|
|
93
|
-
this.log(Level.warning, id, msg);
|
|
94
|
-
};
|
|
95
|
-
Logging.prototype.error = function (id, msg) {
|
|
96
|
-
this.log(Level.error, id, msg);
|
|
97
|
-
};
|
|
98
|
-
Logging.prototype.critical = function (id, msg) {
|
|
99
|
-
this.log(Level.critical, id, msg);
|
|
100
|
-
};
|
|
101
|
-
Logging.prototype.alert = function (id, msg) {
|
|
102
|
-
this.log(Level.alert, id, msg);
|
|
103
|
-
};
|
|
104
|
-
Logging.prototype.emergency = function (id, msg) {
|
|
105
|
-
this.log(Level.emergency, id, msg);
|
|
106
|
-
};
|
|
107
|
-
Logging.prototype.level = function (_) {
|
|
108
|
-
if (_ === void 0)
|
|
109
|
-
return this._level;
|
|
110
|
-
this._level = _;
|
|
111
|
-
return this;
|
|
112
|
-
};
|
|
113
|
-
Logging.prototype.pushLevel = function (_) {
|
|
114
|
-
this._levelStack.push(this._level);
|
|
115
|
-
this._level = _;
|
|
116
|
-
return this;
|
|
117
|
-
};
|
|
118
|
-
Logging.prototype.popLevel = function () {
|
|
119
|
-
this._level = this._levelStack.pop();
|
|
120
|
-
return this;
|
|
121
|
-
};
|
|
122
|
-
Logging.prototype.filter = function (_) {
|
|
123
|
-
if (_ === void 0)
|
|
124
|
-
return this._filter;
|
|
125
|
-
this._filter = _;
|
|
126
|
-
return this;
|
|
127
|
-
};
|
|
128
|
-
return Logging;
|
|
129
|
-
}());
|
|
130
|
-
export { Logging };
|
|
131
|
-
export var logger = Logging.Instance();
|
|
132
|
-
var ScopedLogging = /** @class */ (function () {
|
|
133
|
-
function ScopedLogging(scopeID) {
|
|
134
|
-
this._scopeID = scopeID;
|
|
135
|
-
}
|
|
136
|
-
ScopedLogging.prototype.debug = function (msg) {
|
|
137
|
-
logger.debug(this._scopeID, msg);
|
|
138
|
-
};
|
|
139
|
-
ScopedLogging.prototype.info = function (msg) {
|
|
140
|
-
logger.info(this._scopeID, msg);
|
|
141
|
-
};
|
|
142
|
-
ScopedLogging.prototype.notice = function (msg) {
|
|
143
|
-
logger.notice(this._scopeID, msg);
|
|
144
|
-
};
|
|
145
|
-
ScopedLogging.prototype.warning = function (msg) {
|
|
146
|
-
logger.warning(this._scopeID, msg);
|
|
147
|
-
};
|
|
148
|
-
ScopedLogging.prototype.error = function (msg) {
|
|
149
|
-
logger.error(this._scopeID, msg);
|
|
150
|
-
};
|
|
151
|
-
ScopedLogging.prototype.critical = function (msg) {
|
|
152
|
-
logger.critical(this._scopeID, msg);
|
|
153
|
-
};
|
|
154
|
-
ScopedLogging.prototype.alert = function (msg) {
|
|
155
|
-
logger.alert(this._scopeID, msg);
|
|
156
|
-
};
|
|
157
|
-
ScopedLogging.prototype.emergency = function (msg) {
|
|
158
|
-
logger.emergency(this._scopeID, msg);
|
|
159
|
-
};
|
|
160
|
-
ScopedLogging.prototype.pushLevel = function (_) {
|
|
161
|
-
logger.pushLevel(_);
|
|
162
|
-
return this;
|
|
163
|
-
};
|
|
164
|
-
ScopedLogging.prototype.popLevel = function () {
|
|
165
|
-
logger.popLevel();
|
|
166
|
-
return this;
|
|
167
|
-
};
|
|
168
|
-
return ScopedLogging;
|
|
169
|
-
}());
|
|
170
|
-
export { ScopedLogging };
|
|
171
|
-
export function scopedLogger(scopeID, filter) {
|
|
172
|
-
if (filter === void 0) { filter = false; }
|
|
173
|
-
if (filter) {
|
|
174
|
-
logger.filter(scopeID);
|
|
175
|
-
}
|
|
176
|
-
return new ScopedLogging(scopeID);
|
|
177
|
-
}
|
|
1
|
+
import { isNode } from "./platform";
|
|
2
|
+
import { Stack } from "./stack";
|
|
3
|
+
export var Level;
|
|
4
|
+
(function (Level) {
|
|
5
|
+
Level[Level["debug"] = 0] = "debug";
|
|
6
|
+
Level[Level["info"] = 1] = "info";
|
|
7
|
+
Level[Level["notice"] = 2] = "notice";
|
|
8
|
+
Level[Level["warning"] = 3] = "warning";
|
|
9
|
+
Level[Level["error"] = 4] = "error";
|
|
10
|
+
Level[Level["critical"] = 5] = "critical";
|
|
11
|
+
Level[Level["alert"] = 6] = "alert";
|
|
12
|
+
Level[Level["emergency"] = 7] = "emergency";
|
|
13
|
+
})(Level || (Level = {}));
|
|
14
|
+
var colours = {
|
|
15
|
+
debug: "cyan",
|
|
16
|
+
info: "green",
|
|
17
|
+
notice: "grey",
|
|
18
|
+
warning: "blue",
|
|
19
|
+
error: "red",
|
|
20
|
+
critical: "magenta",
|
|
21
|
+
alert: "magenta",
|
|
22
|
+
emergency: "magenta"
|
|
23
|
+
};
|
|
24
|
+
var ConsoleWriter = /** @class */ (function () {
|
|
25
|
+
function ConsoleWriter() {
|
|
26
|
+
}
|
|
27
|
+
ConsoleWriter.prototype.write = function (dateTime, level, id, msg) {
|
|
28
|
+
if (isNode) {
|
|
29
|
+
console.log("[".concat(dateTime, "] ").concat(Level[level].toUpperCase(), " ").concat(id, ": ").concat(msg));
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
console.log("[".concat(dateTime, "] %c").concat(Level[level].toUpperCase(), "%c ").concat(id, ": ").concat(msg), "color:".concat(colours[Level[level]]), "");
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
return ConsoleWriter;
|
|
36
|
+
}());
|
|
37
|
+
var Logging = /** @class */ (function () {
|
|
38
|
+
function Logging() {
|
|
39
|
+
this._levelStack = new Stack();
|
|
40
|
+
this._level = Level.info;
|
|
41
|
+
this._filter = "";
|
|
42
|
+
this._writer = new ConsoleWriter();
|
|
43
|
+
}
|
|
44
|
+
Logging.Instance = function () {
|
|
45
|
+
return this._instance || (this._instance = new this());
|
|
46
|
+
};
|
|
47
|
+
Logging.prototype.stringify = function (obj) {
|
|
48
|
+
var cache = [];
|
|
49
|
+
return JSON.stringify(obj, function (_key, value) {
|
|
50
|
+
if (typeof value === "object" && value !== null) {
|
|
51
|
+
if (cache.indexOf(value) !== -1) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
cache.push(value);
|
|
55
|
+
}
|
|
56
|
+
return value;
|
|
57
|
+
}, 2);
|
|
58
|
+
};
|
|
59
|
+
Logging.prototype.writer = function (_) {
|
|
60
|
+
if (_ === void 0)
|
|
61
|
+
return this._writer;
|
|
62
|
+
this._writer = _;
|
|
63
|
+
return this;
|
|
64
|
+
};
|
|
65
|
+
Logging.prototype.log = function (level, id, msg) {
|
|
66
|
+
if (level < this._level)
|
|
67
|
+
return;
|
|
68
|
+
if (this._filter && this._filter !== id)
|
|
69
|
+
return;
|
|
70
|
+
var dateTime = new Date().toISOString();
|
|
71
|
+
if (this._writer.rawWrite) {
|
|
72
|
+
this._writer.rawWrite(dateTime, level, id, msg);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
if (typeof msg !== "string") {
|
|
76
|
+
msg = this.stringify(msg);
|
|
77
|
+
}
|
|
78
|
+
if (this._writer.write) {
|
|
79
|
+
this._writer.write(dateTime, level, id, msg);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
Logging.prototype.debug = function (id, msg) {
|
|
84
|
+
this.log(Level.debug, id, msg);
|
|
85
|
+
};
|
|
86
|
+
Logging.prototype.info = function (id, msg) {
|
|
87
|
+
this.log(Level.info, id, msg);
|
|
88
|
+
};
|
|
89
|
+
Logging.prototype.notice = function (id, msg) {
|
|
90
|
+
this.log(Level.notice, id, msg);
|
|
91
|
+
};
|
|
92
|
+
Logging.prototype.warning = function (id, msg) {
|
|
93
|
+
this.log(Level.warning, id, msg);
|
|
94
|
+
};
|
|
95
|
+
Logging.prototype.error = function (id, msg) {
|
|
96
|
+
this.log(Level.error, id, msg);
|
|
97
|
+
};
|
|
98
|
+
Logging.prototype.critical = function (id, msg) {
|
|
99
|
+
this.log(Level.critical, id, msg);
|
|
100
|
+
};
|
|
101
|
+
Logging.prototype.alert = function (id, msg) {
|
|
102
|
+
this.log(Level.alert, id, msg);
|
|
103
|
+
};
|
|
104
|
+
Logging.prototype.emergency = function (id, msg) {
|
|
105
|
+
this.log(Level.emergency, id, msg);
|
|
106
|
+
};
|
|
107
|
+
Logging.prototype.level = function (_) {
|
|
108
|
+
if (_ === void 0)
|
|
109
|
+
return this._level;
|
|
110
|
+
this._level = _;
|
|
111
|
+
return this;
|
|
112
|
+
};
|
|
113
|
+
Logging.prototype.pushLevel = function (_) {
|
|
114
|
+
this._levelStack.push(this._level);
|
|
115
|
+
this._level = _;
|
|
116
|
+
return this;
|
|
117
|
+
};
|
|
118
|
+
Logging.prototype.popLevel = function () {
|
|
119
|
+
this._level = this._levelStack.pop();
|
|
120
|
+
return this;
|
|
121
|
+
};
|
|
122
|
+
Logging.prototype.filter = function (_) {
|
|
123
|
+
if (_ === void 0)
|
|
124
|
+
return this._filter;
|
|
125
|
+
this._filter = _;
|
|
126
|
+
return this;
|
|
127
|
+
};
|
|
128
|
+
return Logging;
|
|
129
|
+
}());
|
|
130
|
+
export { Logging };
|
|
131
|
+
export var logger = Logging.Instance();
|
|
132
|
+
var ScopedLogging = /** @class */ (function () {
|
|
133
|
+
function ScopedLogging(scopeID) {
|
|
134
|
+
this._scopeID = scopeID;
|
|
135
|
+
}
|
|
136
|
+
ScopedLogging.prototype.debug = function (msg) {
|
|
137
|
+
logger.debug(this._scopeID, msg);
|
|
138
|
+
};
|
|
139
|
+
ScopedLogging.prototype.info = function (msg) {
|
|
140
|
+
logger.info(this._scopeID, msg);
|
|
141
|
+
};
|
|
142
|
+
ScopedLogging.prototype.notice = function (msg) {
|
|
143
|
+
logger.notice(this._scopeID, msg);
|
|
144
|
+
};
|
|
145
|
+
ScopedLogging.prototype.warning = function (msg) {
|
|
146
|
+
logger.warning(this._scopeID, msg);
|
|
147
|
+
};
|
|
148
|
+
ScopedLogging.prototype.error = function (msg) {
|
|
149
|
+
logger.error(this._scopeID, msg);
|
|
150
|
+
};
|
|
151
|
+
ScopedLogging.prototype.critical = function (msg) {
|
|
152
|
+
logger.critical(this._scopeID, msg);
|
|
153
|
+
};
|
|
154
|
+
ScopedLogging.prototype.alert = function (msg) {
|
|
155
|
+
logger.alert(this._scopeID, msg);
|
|
156
|
+
};
|
|
157
|
+
ScopedLogging.prototype.emergency = function (msg) {
|
|
158
|
+
logger.emergency(this._scopeID, msg);
|
|
159
|
+
};
|
|
160
|
+
ScopedLogging.prototype.pushLevel = function (_) {
|
|
161
|
+
logger.pushLevel(_);
|
|
162
|
+
return this;
|
|
163
|
+
};
|
|
164
|
+
ScopedLogging.prototype.popLevel = function () {
|
|
165
|
+
logger.popLevel();
|
|
166
|
+
return this;
|
|
167
|
+
};
|
|
168
|
+
return ScopedLogging;
|
|
169
|
+
}());
|
|
170
|
+
export { ScopedLogging };
|
|
171
|
+
export function scopedLogger(scopeID, filter) {
|
|
172
|
+
if (filter === void 0) { filter = false; }
|
|
173
|
+
if (filter) {
|
|
174
|
+
logger.filter(scopeID);
|
|
175
|
+
}
|
|
176
|
+
return new ScopedLogging(scopeID);
|
|
177
|
+
}
|
|
178
178
|
//# sourceMappingURL=logging.js.map
|
package/lib-es6/logging.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logging.js","sourceRoot":"","sources":["../src/logging.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;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C,CAAC;IAED,iCAAS,GAAT,UAAU,GAAoB;QAC1B,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IACzC,CAAC;IAED,iCAAS,GAAT,UAAU,CAAQ;QACd,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QACpB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,gCAAQ,GAAR;QACI,MAAM,CAAC,QAAQ,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC;IAChB,CAAC;IACL,oBAAC;AAAD,CAAC,AAhDD,IAgDC;;AAED,MAAM,UAAU,YAAY,CAAC,OAAe,EAAE,MAAuB;IAAvB,uBAAA,EAAA,cAAuB;IACjE,IAAI,MAAM,EAAE;QACR,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;KAC1B;IACD,OAAO,IAAI,aAAa,CAAC,OAAO,CAAC,CAAC;AACtC,CAAC"}
|
package/lib-es6/math.js
CHANGED
|
@@ -1,91 +1,91 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* degreesToRadians - converts degrees to radians
|
|
3
|
-
* Usage: degreesToRadians(1080);
|
|
4
|
-
*
|
|
5
|
-
* @param degrees
|
|
6
|
-
* @returns Number radians
|
|
7
|
-
*/
|
|
8
|
-
export function degreesToRadians(degrees) {
|
|
9
|
-
return degrees * (Math.PI / 180);
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* radiansToDegrees - converts radians to degrees
|
|
13
|
-
* Usage: radiansToDegrees(7);
|
|
14
|
-
*
|
|
15
|
-
* @param radians
|
|
16
|
-
* @returns Number degreees
|
|
17
|
-
*/
|
|
18
|
-
export function radiansToDegrees(radians) {
|
|
19
|
-
return radians * (180 / Math.PI);
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* polarToCartesian - converts (r, theta) to {x, y}
|
|
23
|
-
* Usage: polarToCartesian(5, Math.PI);
|
|
24
|
-
*
|
|
25
|
-
* @param r radius
|
|
26
|
-
* @param theta angle in radians
|
|
27
|
-
* @returns { x: number, y: number }
|
|
28
|
-
*/
|
|
29
|
-
export function polarToCartesian(r, theta) {
|
|
30
|
-
return {
|
|
31
|
-
x: r * Math.cos(theta),
|
|
32
|
-
y: r * Math.sin(theta)
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* cartesianToPolar - converts (x, y) to {r, theta}
|
|
37
|
-
* Usage: cartesianToPolar(100, 200);
|
|
38
|
-
*
|
|
39
|
-
* @param x
|
|
40
|
-
* @param y
|
|
41
|
-
* @returns { r: number, theta: number }
|
|
42
|
-
*/
|
|
43
|
-
export function cartesianToPolar(x, y) {
|
|
44
|
-
return {
|
|
45
|
-
r: Math.sqrt(x * x + y * y),
|
|
46
|
-
theta: Math.atan2(y, x)
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* normalizeRadians - normalizes a radian value to within the provided range
|
|
51
|
-
* Usage: normalizeRadians(7);
|
|
52
|
-
*
|
|
53
|
-
* @param radians value to be normalized
|
|
54
|
-
* @param min lower limit
|
|
55
|
-
* @param max upper limit
|
|
56
|
-
* @returns Number normalized to within the provided range
|
|
57
|
-
*/
|
|
58
|
-
export function normalizeRadians(radians, min, max) {
|
|
59
|
-
if (min === void 0) { min = -Math.PI; }
|
|
60
|
-
if (max === void 0) { max = Math.PI; }
|
|
61
|
-
return normalize(radians, min, max);
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* normalizeDegrees - normalizes a degree value to within the provided range
|
|
65
|
-
* Usage: normalizeDegrees(1080);
|
|
66
|
-
*
|
|
67
|
-
* @param degrees value to be normalized
|
|
68
|
-
* @param min lower limit
|
|
69
|
-
* @param max upper limit
|
|
70
|
-
* @returns Number normalized to within the provided range
|
|
71
|
-
*/
|
|
72
|
-
export function normalizeDegrees(degrees, min, max) {
|
|
73
|
-
if (min === void 0) { min = -180; }
|
|
74
|
-
if (max === void 0) { max = 180; }
|
|
75
|
-
return normalize(degrees, min, max);
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* normalize - normalizes a value to within the provided range
|
|
79
|
-
* Usage: normalize(1000, 0, 365);
|
|
80
|
-
*
|
|
81
|
-
* @param value value to be normalized
|
|
82
|
-
* @param min lower limit
|
|
83
|
-
* @param max upper limit
|
|
84
|
-
* @returns Number normalized to within the provided range
|
|
85
|
-
*/
|
|
86
|
-
export function normalize(value, min, max) {
|
|
87
|
-
var spread = max - min;
|
|
88
|
-
var offsetValue = value - min;
|
|
89
|
-
return (offsetValue - (Math.floor(offsetValue / spread) * spread)) + min;
|
|
90
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* degreesToRadians - converts degrees to radians
|
|
3
|
+
* Usage: degreesToRadians(1080);
|
|
4
|
+
*
|
|
5
|
+
* @param degrees
|
|
6
|
+
* @returns Number radians
|
|
7
|
+
*/
|
|
8
|
+
export function degreesToRadians(degrees) {
|
|
9
|
+
return degrees * (Math.PI / 180);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* radiansToDegrees - converts radians to degrees
|
|
13
|
+
* Usage: radiansToDegrees(7);
|
|
14
|
+
*
|
|
15
|
+
* @param radians
|
|
16
|
+
* @returns Number degreees
|
|
17
|
+
*/
|
|
18
|
+
export function radiansToDegrees(radians) {
|
|
19
|
+
return radians * (180 / Math.PI);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* polarToCartesian - converts (r, theta) to {x, y}
|
|
23
|
+
* Usage: polarToCartesian(5, Math.PI);
|
|
24
|
+
*
|
|
25
|
+
* @param r radius
|
|
26
|
+
* @param theta angle in radians
|
|
27
|
+
* @returns { x: number, y: number }
|
|
28
|
+
*/
|
|
29
|
+
export function polarToCartesian(r, theta) {
|
|
30
|
+
return {
|
|
31
|
+
x: r * Math.cos(theta),
|
|
32
|
+
y: r * Math.sin(theta)
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* cartesianToPolar - converts (x, y) to {r, theta}
|
|
37
|
+
* Usage: cartesianToPolar(100, 200);
|
|
38
|
+
*
|
|
39
|
+
* @param x
|
|
40
|
+
* @param y
|
|
41
|
+
* @returns { r: number, theta: number }
|
|
42
|
+
*/
|
|
43
|
+
export function cartesianToPolar(x, y) {
|
|
44
|
+
return {
|
|
45
|
+
r: Math.sqrt(x * x + y * y),
|
|
46
|
+
theta: Math.atan2(y, x)
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* normalizeRadians - normalizes a radian value to within the provided range
|
|
51
|
+
* Usage: normalizeRadians(7);
|
|
52
|
+
*
|
|
53
|
+
* @param radians value to be normalized
|
|
54
|
+
* @param min lower limit
|
|
55
|
+
* @param max upper limit
|
|
56
|
+
* @returns Number normalized to within the provided range
|
|
57
|
+
*/
|
|
58
|
+
export function normalizeRadians(radians, min, max) {
|
|
59
|
+
if (min === void 0) { min = -Math.PI; }
|
|
60
|
+
if (max === void 0) { max = Math.PI; }
|
|
61
|
+
return normalize(radians, min, max);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* normalizeDegrees - normalizes a degree value to within the provided range
|
|
65
|
+
* Usage: normalizeDegrees(1080);
|
|
66
|
+
*
|
|
67
|
+
* @param degrees value to be normalized
|
|
68
|
+
* @param min lower limit
|
|
69
|
+
* @param max upper limit
|
|
70
|
+
* @returns Number normalized to within the provided range
|
|
71
|
+
*/
|
|
72
|
+
export function normalizeDegrees(degrees, min, max) {
|
|
73
|
+
if (min === void 0) { min = -180; }
|
|
74
|
+
if (max === void 0) { max = 180; }
|
|
75
|
+
return normalize(degrees, min, max);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* normalize - normalizes a value to within the provided range
|
|
79
|
+
* Usage: normalize(1000, 0, 365);
|
|
80
|
+
*
|
|
81
|
+
* @param value value to be normalized
|
|
82
|
+
* @param min lower limit
|
|
83
|
+
* @param max upper limit
|
|
84
|
+
* @returns Number normalized to within the provided range
|
|
85
|
+
*/
|
|
86
|
+
export function normalize(value, min, max) {
|
|
87
|
+
var spread = max - min;
|
|
88
|
+
var offsetValue = value - min;
|
|
89
|
+
return (offsetValue - (Math.floor(offsetValue / spread) * spread)) + min;
|
|
90
|
+
}
|
|
91
91
|
//# sourceMappingURL=math.js.map
|