node-red-contrib-web-worldmap 2.24.0 → 2.25.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 (43) hide show
  1. package/CHANGELOG.md +5 -1
  2. package/README.md +7 -2
  3. package/node_modules/{bytes → body-parser/node_modules/bytes}/History.md +0 -0
  4. package/node_modules/{bytes → body-parser/node_modules/bytes}/LICENSE +0 -0
  5. package/node_modules/{bytes → body-parser/node_modules/bytes}/Readme.md +0 -0
  6. package/node_modules/{bytes → body-parser/node_modules/bytes}/index.js +0 -0
  7. package/node_modules/{bytes → body-parser/node_modules/bytes}/package.json +2 -3
  8. package/node_modules/body-parser/package.json +2 -2
  9. package/node_modules/content-disposition/node_modules/safe-buffer/package.json +2 -2
  10. package/node_modules/content-disposition/package.json +2 -2
  11. package/node_modules/cookie/package.json +2 -2
  12. package/node_modules/express/node_modules/safe-buffer/package.json +2 -2
  13. package/node_modules/express/package.json +8 -9
  14. package/node_modules/faye-websocket/package.json +2 -2
  15. package/node_modules/forwarded/package.json +2 -2
  16. package/node_modules/http-errors/package.json +4 -4
  17. package/node_modules/inherits/package.json +2 -2
  18. package/node_modules/ipaddr.js/package.json +2 -2
  19. package/node_modules/proxy-addr/package.json +2 -2
  20. package/node_modules/qs/package.json +3 -3
  21. package/node_modules/raw-body/node_modules/bytes/History.md +92 -0
  22. package/node_modules/raw-body/node_modules/bytes/LICENSE +23 -0
  23. package/node_modules/raw-body/node_modules/bytes/Readme.md +152 -0
  24. package/node_modules/raw-body/node_modules/bytes/index.js +166 -0
  25. package/node_modules/raw-body/node_modules/bytes/package.json +84 -0
  26. package/node_modules/raw-body/package.json +2 -2
  27. package/node_modules/send/node_modules/ms/package.json +2 -2
  28. package/node_modules/send/package.json +3 -3
  29. package/node_modules/serve-static/package.json +2 -2
  30. package/node_modules/setprototypeof/package.json +3 -3
  31. package/node_modules/sockjs/package.json +8 -9
  32. package/node_modules/toidentifier/package.json +2 -2
  33. package/node_modules/uuid/package.json +2 -2
  34. package/node_modules/websocket-driver/node_modules/http-parser-js/CHANGELOG.md +14 -0
  35. package/node_modules/{http-parser-js → websocket-driver/node_modules/http-parser-js}/LICENSE.md +0 -0
  36. package/node_modules/websocket-driver/node_modules/http-parser-js/README.md +31 -0
  37. package/node_modules/{http-parser-js → websocket-driver/node_modules/http-parser-js}/http-parser.js +5 -8
  38. package/node_modules/{http-parser-js → websocket-driver/node_modules/http-parser-js}/package.json +20 -18
  39. package/package.json +1 -1
  40. package/worldmap/css/worldmap.css +7 -5
  41. package/worldmap/worldmap.js +21 -13
  42. package/node_modules/http-parser-js/README.md +0 -39
  43. package/node_modules/http-parser-js/http-parser.d.ts +0 -175
package/CHANGELOG.md CHANGED
@@ -1,12 +1,16 @@
1
1
  ### Change Log for Node-RED Worldmap
2
2
 
3
+ - v2.25.0 - Add bounds command to set overall map bounds.
4
+ - v2.24.3 - Fix geojson incorrect fill.
5
+ - v2.24.2 - Changes to drawing colours to be more visible.
6
+ - v2.24.1 - Fix ellipse accuracy.
3
7
  - v2.24.0 - Add greatcircle option, fix non default httpRoot. Issue #193
4
8
  - v2.23.5 - Fix addtoheatmap. Issue #192
5
9
  - v2.23.4 - Fix opacity of area borders
6
10
  - v2.23.3 - Fix initial load of maps
7
11
  - v2.23.2 - Add convex-hull example
8
12
  - v2.23.1 - Fix saving of custom map layer
9
- - v2.23.0 - Give logo and id so it can be overridden by toplogo command. PR #188.
13
+ - v2.23.0 - Give logo an id so it can be overridden by toplogo command. PR #188.
10
14
 
11
15
  - v2.22.3 - Don't show empty popup for geojson object. Issue #186. Add wobble to null island.
12
16
  - v2.22.2 - Be more tolerant of speed string types
package/README.md CHANGED
@@ -11,13 +11,17 @@ map web page for plotting "things" on.
11
11
 
12
12
  ### Updates
13
13
 
14
+ - v2.25.0 - Add bounds command to set overall map bounds.
15
+ - v2.24.3 - Fix geojson incorrect fill.
16
+ - v2.24.2 - Changes to drawing colours to be more visible.
17
+ - v2.24.1 - Fix ellipse accuracy
14
18
  - v2.24.0 - Add greatcircle option, fix non default httpRoot. Issue #193
15
19
  - v2.23.5 - Fix addtoheatmap. Issue #192
16
20
  - v2.23.4 - Fix opacity of area borders
17
21
  - v2.23.3 - Fix initial load of maps
18
22
  - v2.23.2 - Add convex-hull example
19
23
  - v2.23.1 - Fix saving of custom map layer
20
- - v2.23.0 - Give logo and id so it can be overridden by toplogo command. PR #188.
24
+ - v2.23.0 - Give logo an id so it can be overridden by toplogo command. PR #188.
21
25
  - v2.22.3 - Don't show empty popup for geojson object. Issue #186. Add wobble to null island.
22
26
  - v2.22.2 - Be more tolerant of speed string types
23
27
  - v2.22.0 - Separate out layer events in worldmap in
@@ -134,7 +138,7 @@ If the payload also includes a property `fit:true` the map will zoom to fit the
134
138
  Finally if a **greatcircle** property is set containing an array of two coordinates then an arc
135
139
  following the great circle between the two co-ordinates is plotted.
136
140
 
137
- msg.payload = {name:"GC1", greatcircle:[ [51.464,0], [25.76,-80.18] ] }
141
+ msg.payload = {name:"GC1", color:"#ff00ff", greatcircle:[ [51.464,0], [25.76,-80.18] ] }
138
142
 
139
143
  There are extra optional properties you can specify - see Options below.
140
144
 
@@ -385,6 +389,7 @@ Optional properties include
385
389
  - **lat** - move map to specified latitude.
386
390
  - **lon** - move map to specified longitude.
387
391
  - **zoom** - move map to specified zoom level (1 - world, 13 to 20 max zoom depending on map).
392
+ - **bounds** - if set to an array `[ [ lat(S), lon(W) ], [lat(N), lon(E)] ]` - sets the overall map bounds.
388
393
  - **layer** - set map to specified base layer name - `{"command":{"layer":"Esri"}}`
389
394
  - **search** - search markers on map for name containing `string`. If not found in existing markers, will then try geocoding looking using Nominatim. An empty string `""` clears the search results. - `{"command":{"search":"Winchester"}}`
390
395
  - **showlayer** - show the named overlay(s) - `{"command":{"showlayer":"foo"}}` or `{"command":{"showlayer":["foo","bar"]}}`
@@ -3,7 +3,7 @@
3
3
  "_id": "bytes@3.1.1",
4
4
  "_inBundle": false,
5
5
  "_integrity": "sha512-dWe4nWO/ruEOY7HkUJ5gFt1DCFV9zPRoJr8pV0/ASQermOZjtq8jMjOprC0Kd10GLN+l7xaUPvxzJFWtxGu8Fg==",
6
- "_location": "/bytes",
6
+ "_location": "/node-red-contrib-web-worldmap/body-parser/bytes",
7
7
  "_phantomChildren": {},
8
8
  "_requested": {
9
9
  "type": "version",
@@ -16,8 +16,7 @@
16
16
  "fetchSpec": "3.1.1"
17
17
  },
18
18
  "_requiredBy": [
19
- "/body-parser",
20
- "/raw-body"
19
+ "/node-red-contrib-web-worldmap/body-parser"
21
20
  ],
22
21
  "_resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.1.tgz",
23
22
  "_shasum": "3f018291cb4cbad9accb6e6970bca9c8889e879a",
@@ -3,7 +3,7 @@
3
3
  "_id": "body-parser@1.19.1",
4
4
  "_inBundle": false,
5
5
  "_integrity": "sha512-8ljfQi5eBk8EJfECMrgqNGWPEY5jWP+1IzkzkGdFFEwFQZZyaZ21UqdaHktgiMlH0xLHqIFtE/u2OYE5dOtViA==",
6
- "_location": "/body-parser",
6
+ "_location": "/node-red-contrib-web-worldmap/body-parser",
7
7
  "_phantomChildren": {},
8
8
  "_requested": {
9
9
  "type": "version",
@@ -16,7 +16,7 @@
16
16
  "fetchSpec": "1.19.1"
17
17
  },
18
18
  "_requiredBy": [
19
- "/express"
19
+ "/node-red-contrib-web-worldmap/express"
20
20
  ],
21
21
  "_resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.1.tgz",
22
22
  "_shasum": "1499abbaa9274af3ecc9f6f10396c995943e31d4",
@@ -3,7 +3,7 @@
3
3
  "_id": "safe-buffer@5.2.1",
4
4
  "_inBundle": false,
5
5
  "_integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
6
- "_location": "/content-disposition/safe-buffer",
6
+ "_location": "/node-red-contrib-web-worldmap/content-disposition/safe-buffer",
7
7
  "_phantomChildren": {},
8
8
  "_requested": {
9
9
  "type": "version",
@@ -16,7 +16,7 @@
16
16
  "fetchSpec": "5.2.1"
17
17
  },
18
18
  "_requiredBy": [
19
- "/content-disposition"
19
+ "/node-red-contrib-web-worldmap/content-disposition"
20
20
  ],
21
21
  "_resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
22
22
  "_shasum": "1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6",
@@ -3,7 +3,7 @@
3
3
  "_id": "content-disposition@0.5.4",
4
4
  "_inBundle": false,
5
5
  "_integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==",
6
- "_location": "/content-disposition",
6
+ "_location": "/node-red-contrib-web-worldmap/content-disposition",
7
7
  "_phantomChildren": {},
8
8
  "_requested": {
9
9
  "type": "version",
@@ -16,7 +16,7 @@
16
16
  "fetchSpec": "0.5.4"
17
17
  },
18
18
  "_requiredBy": [
19
- "/express"
19
+ "/node-red-contrib-web-worldmap/express"
20
20
  ],
21
21
  "_resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz",
22
22
  "_shasum": "8b82b4efac82512a02bb0b1dcec9d2c5e8eb5bfe",
@@ -3,7 +3,7 @@
3
3
  "_id": "cookie@0.4.1",
4
4
  "_inBundle": false,
5
5
  "_integrity": "sha512-ZwrFkGJxUR3EIoXtO+yVE69Eb7KlixbaeAWfBQB9vVsNn/o+Yw69gBWSSDK825hQNdN+wF8zELf3dFNl/kxkUA==",
6
- "_location": "/cookie",
6
+ "_location": "/node-red-contrib-web-worldmap/cookie",
7
7
  "_phantomChildren": {},
8
8
  "_requested": {
9
9
  "type": "version",
@@ -16,7 +16,7 @@
16
16
  "fetchSpec": "0.4.1"
17
17
  },
18
18
  "_requiredBy": [
19
- "/express"
19
+ "/node-red-contrib-web-worldmap/express"
20
20
  ],
21
21
  "_resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.1.tgz",
22
22
  "_shasum": "afd713fe26ebd21ba95ceb61f9a8116e50a537d1",
@@ -3,7 +3,7 @@
3
3
  "_id": "safe-buffer@5.2.1",
4
4
  "_inBundle": false,
5
5
  "_integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
6
- "_location": "/express/safe-buffer",
6
+ "_location": "/node-red-contrib-web-worldmap/express/safe-buffer",
7
7
  "_phantomChildren": {},
8
8
  "_requested": {
9
9
  "type": "version",
@@ -16,7 +16,7 @@
16
16
  "fetchSpec": "5.2.1"
17
17
  },
18
18
  "_requiredBy": [
19
- "/express"
19
+ "/node-red-contrib-web-worldmap/express"
20
20
  ],
21
21
  "_resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
22
22
  "_shasum": "1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6",
@@ -1,27 +1,26 @@
1
1
  {
2
- "_from": "express@4.17.2",
2
+ "_from": "express@^4.17.2",
3
3
  "_id": "express@4.17.2",
4
4
  "_inBundle": false,
5
5
  "_integrity": "sha512-oxlxJxcQlYwqPWKVJJtvQiwHgosH/LrLSPA+H4UxpyvSS6jC5aH+5MoHFM+KABgTOt0APue4w66Ha8jCUo9QGg==",
6
- "_location": "/express",
6
+ "_location": "/node-red-contrib-web-worldmap/express",
7
7
  "_phantomChildren": {},
8
8
  "_requested": {
9
- "type": "version",
9
+ "type": "range",
10
10
  "registry": true,
11
- "raw": "express@4.17.2",
11
+ "raw": "express@^4.17.2",
12
12
  "name": "express",
13
13
  "escapedName": "express",
14
- "rawSpec": "4.17.2",
14
+ "rawSpec": "^4.17.2",
15
15
  "saveSpec": null,
16
- "fetchSpec": "4.17.2"
16
+ "fetchSpec": "^4.17.2"
17
17
  },
18
18
  "_requiredBy": [
19
- "#USER",
20
- "/"
19
+ "/node-red-contrib-web-worldmap"
21
20
  ],
22
21
  "_resolved": "https://registry.npmjs.org/express/-/express-4.17.2.tgz",
23
22
  "_shasum": "c18369f265297319beed4e5558753cc8c1364cb3",
24
- "_spec": "express@4.17.2",
23
+ "_spec": "express@^4.17.2",
25
24
  "_where": "/Users/conway/Projects/worldmap",
26
25
  "author": {
27
26
  "name": "TJ Holowaychuk",
@@ -3,7 +3,7 @@
3
3
  "_id": "faye-websocket@0.11.4",
4
4
  "_inBundle": false,
5
5
  "_integrity": "sha512-CzbClwlXAuiRQAlUyfqPgvPoNKTckTPGfwZV4ZdAhVcP2lh9KUxJg2b5GkE7XbjKQ3YJnQ9z6D9ntLAlB+tP8g==",
6
- "_location": "/faye-websocket",
6
+ "_location": "/node-red-contrib-web-worldmap/faye-websocket",
7
7
  "_phantomChildren": {},
8
8
  "_requested": {
9
9
  "type": "range",
@@ -16,7 +16,7 @@
16
16
  "fetchSpec": "^0.11.3"
17
17
  },
18
18
  "_requiredBy": [
19
- "/sockjs"
19
+ "/node-red-contrib-web-worldmap/sockjs"
20
20
  ],
21
21
  "_resolved": "https://registry.npmjs.org/faye-websocket/-/faye-websocket-0.11.4.tgz",
22
22
  "_shasum": "7f0d9275cfdd86a1c963dc8b65fcc451edcbb1da",
@@ -3,7 +3,7 @@
3
3
  "_id": "forwarded@0.2.0",
4
4
  "_inBundle": false,
5
5
  "_integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==",
6
- "_location": "/forwarded",
6
+ "_location": "/node-red-contrib-web-worldmap/forwarded",
7
7
  "_phantomChildren": {},
8
8
  "_requested": {
9
9
  "type": "version",
@@ -16,7 +16,7 @@
16
16
  "fetchSpec": "0.2.0"
17
17
  },
18
18
  "_requiredBy": [
19
- "/proxy-addr"
19
+ "/node-red-contrib-web-worldmap/proxy-addr"
20
20
  ],
21
21
  "_resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
22
22
  "_shasum": "2269936428aad4c15c7ebe9779a84bf0b2a81811",
@@ -3,7 +3,7 @@
3
3
  "_id": "http-errors@1.8.1",
4
4
  "_inBundle": false,
5
5
  "_integrity": "sha512-Kpk9Sm7NmI+RHhnj6OIWDI1d6fIoFAtFt9RLaTMRlg/8w49juAStsrBgp0Dp4OdxdVbRIeKhtCUvoi/RuAhO4g==",
6
- "_location": "/http-errors",
6
+ "_location": "/node-red-contrib-web-worldmap/http-errors",
7
7
  "_phantomChildren": {},
8
8
  "_requested": {
9
9
  "type": "version",
@@ -16,9 +16,9 @@
16
16
  "fetchSpec": "1.8.1"
17
17
  },
18
18
  "_requiredBy": [
19
- "/body-parser",
20
- "/raw-body",
21
- "/send"
19
+ "/node-red-contrib-web-worldmap/body-parser",
20
+ "/node-red-contrib-web-worldmap/raw-body",
21
+ "/node-red-contrib-web-worldmap/send"
22
22
  ],
23
23
  "_resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.8.1.tgz",
24
24
  "_shasum": "7c3f28577cbc8a207388455dbd62295ed07bd68c",
@@ -3,7 +3,7 @@
3
3
  "_id": "inherits@2.0.4",
4
4
  "_inBundle": false,
5
5
  "_integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
6
- "_location": "/inherits",
6
+ "_location": "/node-red-contrib-web-worldmap/inherits",
7
7
  "_phantomChildren": {},
8
8
  "_requested": {
9
9
  "type": "version",
@@ -16,7 +16,7 @@
16
16
  "fetchSpec": "2.0.4"
17
17
  },
18
18
  "_requiredBy": [
19
- "/http-errors"
19
+ "/node-red-contrib-web-worldmap/http-errors"
20
20
  ],
21
21
  "_resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
22
22
  "_shasum": "0fa2c64f932917c3433a0ded55363aae37416b7c",
@@ -3,7 +3,7 @@
3
3
  "_id": "ipaddr.js@1.9.1",
4
4
  "_inBundle": false,
5
5
  "_integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==",
6
- "_location": "/ipaddr.js",
6
+ "_location": "/node-red-contrib-web-worldmap/ipaddr.js",
7
7
  "_phantomChildren": {},
8
8
  "_requested": {
9
9
  "type": "version",
@@ -16,7 +16,7 @@
16
16
  "fetchSpec": "1.9.1"
17
17
  },
18
18
  "_requiredBy": [
19
- "/proxy-addr"
19
+ "/node-red-contrib-web-worldmap/proxy-addr"
20
20
  ],
21
21
  "_resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
22
22
  "_shasum": "bff38543eeb8984825079ff3a2a8e6cbd46781b3",
@@ -3,7 +3,7 @@
3
3
  "_id": "proxy-addr@2.0.7",
4
4
  "_inBundle": false,
5
5
  "_integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==",
6
- "_location": "/proxy-addr",
6
+ "_location": "/node-red-contrib-web-worldmap/proxy-addr",
7
7
  "_phantomChildren": {},
8
8
  "_requested": {
9
9
  "type": "range",
@@ -16,7 +16,7 @@
16
16
  "fetchSpec": "~2.0.7"
17
17
  },
18
18
  "_requiredBy": [
19
- "/express"
19
+ "/node-red-contrib-web-worldmap/express"
20
20
  ],
21
21
  "_resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
22
22
  "_shasum": "f19fe69ceab311eeb94b42e70e8c2070f9ba1025",
@@ -3,7 +3,7 @@
3
3
  "_id": "qs@6.9.6",
4
4
  "_inBundle": false,
5
5
  "_integrity": "sha512-TIRk4aqYLNoJUbd+g2lEdz5kLWIuTMRagAXxl78Q0RiVjAOugHmeKNGdd3cwo/ktpf9aL9epCfFqWDEKysUlLQ==",
6
- "_location": "/qs",
6
+ "_location": "/node-red-contrib-web-worldmap/qs",
7
7
  "_phantomChildren": {},
8
8
  "_requested": {
9
9
  "type": "version",
@@ -16,8 +16,8 @@
16
16
  "fetchSpec": "6.9.6"
17
17
  },
18
18
  "_requiredBy": [
19
- "/body-parser",
20
- "/express"
19
+ "/node-red-contrib-web-worldmap/body-parser",
20
+ "/node-red-contrib-web-worldmap/express"
21
21
  ],
22
22
  "_resolved": "https://registry.npmjs.org/qs/-/qs-6.9.6.tgz",
23
23
  "_shasum": "26ed3c8243a431b2924aca84cc90471f35d5a0ee",
@@ -0,0 +1,92 @@
1
+ 3.1.1 / 2021-11-15
2
+ ==================
3
+
4
+ * Fix "thousandsSeparator" incorrecting formatting fractional part
5
+
6
+ 3.1.0 / 2019-01-22
7
+ ==================
8
+
9
+ * Add petabyte (`pb`) support
10
+
11
+ 3.0.0 / 2017-08-31
12
+ ==================
13
+
14
+ * Change "kB" to "KB" in format output
15
+ * Remove support for Node.js 0.6
16
+ * Remove support for ComponentJS
17
+
18
+ 2.5.0 / 2017-03-24
19
+ ==================
20
+
21
+ * Add option "unit"
22
+
23
+ 2.4.0 / 2016-06-01
24
+ ==================
25
+
26
+ * Add option "unitSeparator"
27
+
28
+ 2.3.0 / 2016-02-15
29
+ ==================
30
+
31
+ * Drop partial bytes on all parsed units
32
+ * Fix non-finite numbers to `.format` to return `null`
33
+ * Fix parsing byte string that looks like hex
34
+ * perf: hoist regular expressions
35
+
36
+ 2.2.0 / 2015-11-13
37
+ ==================
38
+
39
+ * add option "decimalPlaces"
40
+ * add option "fixedDecimals"
41
+
42
+ 2.1.0 / 2015-05-21
43
+ ==================
44
+
45
+ * add `.format` export
46
+ * add `.parse` export
47
+
48
+ 2.0.2 / 2015-05-20
49
+ ==================
50
+
51
+ * remove map recreation
52
+ * remove unnecessary object construction
53
+
54
+ 2.0.1 / 2015-05-07
55
+ ==================
56
+
57
+ * fix browserify require
58
+ * remove node.extend dependency
59
+
60
+ 2.0.0 / 2015-04-12
61
+ ==================
62
+
63
+ * add option "case"
64
+ * add option "thousandsSeparator"
65
+ * return "null" on invalid parse input
66
+ * support proper round-trip: bytes(bytes(num)) === num
67
+ * units no longer case sensitive when parsing
68
+
69
+ 1.0.0 / 2014-05-05
70
+ ==================
71
+
72
+ * add negative support. fixes #6
73
+
74
+ 0.3.0 / 2014-03-19
75
+ ==================
76
+
77
+ * added terabyte support
78
+
79
+ 0.2.1 / 2013-04-01
80
+ ==================
81
+
82
+ * add .component
83
+
84
+ 0.2.0 / 2012-10-28
85
+ ==================
86
+
87
+ * bytes(200).should.eql('200b')
88
+
89
+ 0.1.0 / 2012-07-04
90
+ ==================
91
+
92
+ * add bytes to string conversion [yields]
@@ -0,0 +1,23 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2012-2014 TJ Holowaychuk <tj@vision-media.ca>
4
+ Copyright (c) 2015 Jed Watson <jed.watson@me.com>
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining
7
+ a copy of this software and associated documentation files (the
8
+ 'Software'), to deal in the Software without restriction, including
9
+ without limitation the rights to use, copy, modify, merge, publish,
10
+ distribute, sublicense, and/or sell copies of the Software, and to
11
+ permit persons to whom the Software is furnished to do so, subject to
12
+ the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be
15
+ included in all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
18
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,152 @@
1
+ # Bytes utility
2
+
3
+ [![NPM Version][npm-image]][npm-url]
4
+ [![NPM Downloads][downloads-image]][downloads-url]
5
+ [![Build Status][ci-image]][ci-url]
6
+ [![Test Coverage][coveralls-image]][coveralls-url]
7
+
8
+ Utility to parse a string bytes (ex: `1TB`) to bytes (`1099511627776`) and vice-versa.
9
+
10
+ ## Installation
11
+
12
+ This is a [Node.js](https://nodejs.org/en/) module available through the
13
+ [npm registry](https://www.npmjs.com/). Installation is done using the
14
+ [`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
15
+
16
+ ```bash
17
+ $ npm install bytes
18
+ ```
19
+
20
+ ## Usage
21
+
22
+ ```js
23
+ var bytes = require('bytes');
24
+ ```
25
+
26
+ #### bytes(number|string value, [options]): number|string|null
27
+
28
+ Default export function. Delegates to either `bytes.format` or `bytes.parse` based on the type of `value`.
29
+
30
+ **Arguments**
31
+
32
+ | Name | Type | Description |
33
+ |---------|----------|--------------------|
34
+ | value | `number`|`string` | Number value to format or string value to parse |
35
+ | options | `Object` | Conversion options for `format` |
36
+
37
+ **Returns**
38
+
39
+ | Name | Type | Description |
40
+ |---------|------------------|-------------------------------------------------|
41
+ | results | `string`|`number`|`null` | Return null upon error. Numeric value in bytes, or string value otherwise. |
42
+
43
+ **Example**
44
+
45
+ ```js
46
+ bytes(1024);
47
+ // output: '1KB'
48
+
49
+ bytes('1KB');
50
+ // output: 1024
51
+ ```
52
+
53
+ #### bytes.format(number value, [options]): string|null
54
+
55
+ Format the given value in bytes into a string. If the value is negative, it is kept as such. If it is a float, it is
56
+ rounded.
57
+
58
+ **Arguments**
59
+
60
+ | Name | Type | Description |
61
+ |---------|----------|--------------------|
62
+ | value | `number` | Value in bytes |
63
+ | options | `Object` | Conversion options |
64
+
65
+ **Options**
66
+
67
+ | Property | Type | Description |
68
+ |-------------------|--------|-----------------------------------------------------------------------------------------|
69
+ | decimalPlaces | `number`|`null` | Maximum number of decimal places to include in output. Default value to `2`. |
70
+ | fixedDecimals | `boolean`|`null` | Whether to always display the maximum number of decimal places. Default value to `false` |
71
+ | thousandsSeparator | `string`|`null` | Example of values: `' '`, `','` and `'.'`... Default value to `''`. |
72
+ | unit | `string`|`null` | The unit in which the result will be returned (B/KB/MB/GB/TB). Default value to `''` (which means auto detect). |
73
+ | unitSeparator | `string`|`null` | Separator to use between number and unit. Default value to `''`. |
74
+
75
+ **Returns**
76
+
77
+ | Name | Type | Description |
78
+ |---------|------------------|-------------------------------------------------|
79
+ | results | `string`|`null` | Return null upon error. String value otherwise. |
80
+
81
+ **Example**
82
+
83
+ ```js
84
+ bytes.format(1024);
85
+ // output: '1KB'
86
+
87
+ bytes.format(1000);
88
+ // output: '1000B'
89
+
90
+ bytes.format(1000, {thousandsSeparator: ' '});
91
+ // output: '1 000B'
92
+
93
+ bytes.format(1024 * 1.7, {decimalPlaces: 0});
94
+ // output: '2KB'
95
+
96
+ bytes.format(1024, {unitSeparator: ' '});
97
+ // output: '1 KB'
98
+ ```
99
+
100
+ #### bytes.parse(string|number value): number|null
101
+
102
+ Parse the string value into an integer in bytes. If no unit is given, or `value`
103
+ is a number, it is assumed the value is in bytes.
104
+
105
+ Supported units and abbreviations are as follows and are case-insensitive:
106
+
107
+ * `b` for bytes
108
+ * `kb` for kilobytes
109
+ * `mb` for megabytes
110
+ * `gb` for gigabytes
111
+ * `tb` for terabytes
112
+ * `pb` for petabytes
113
+
114
+ The units are in powers of two, not ten. This means 1kb = 1024b according to this parser.
115
+
116
+ **Arguments**
117
+
118
+ | Name | Type | Description |
119
+ |---------------|--------|--------------------|
120
+ | value | `string`|`number` | String to parse, or number in bytes. |
121
+
122
+ **Returns**
123
+
124
+ | Name | Type | Description |
125
+ |---------|-------------|-------------------------|
126
+ | results | `number`|`null` | Return null upon error. Value in bytes otherwise. |
127
+
128
+ **Example**
129
+
130
+ ```js
131
+ bytes.parse('1KB');
132
+ // output: 1024
133
+
134
+ bytes.parse('1024');
135
+ // output: 1024
136
+
137
+ bytes.parse(1024);
138
+ // output: 1024
139
+ ```
140
+
141
+ ## License
142
+
143
+ [MIT](LICENSE)
144
+
145
+ [ci-image]: https://badgen.net/github/checks/visionmedia/bytes.js/master?label=ci
146
+ [ci-url]: https://github.com/visionmedia/bytes.js/actions?query=workflow%3Aci
147
+ [coveralls-image]: https://badgen.net/coveralls/c/github/visionmedia/bytes.js/master
148
+ [coveralls-url]: https://coveralls.io/r/visionmedia/bytes.js?branch=master
149
+ [downloads-image]: https://badgen.net/npm/dm/bytes
150
+ [downloads-url]: https://npmjs.org/package/bytes
151
+ [npm-image]: https://badgen.net/npm/v/bytes
152
+ [npm-url]: https://npmjs.org/package/bytes