node-red-contrib-web-worldmap 5.0.4 → 5.0.6
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 +1 -0
- package/README.md +1 -0
- package/node_modules/accepts/node_modules/negotiator/HISTORY.md +108 -0
- package/node_modules/{body-parser/node_modules/bytes → accepts/node_modules/negotiator}/LICENSE +3 -2
- package/node_modules/accepts/node_modules/negotiator/README.md +203 -0
- package/node_modules/accepts/node_modules/negotiator/index.js +82 -0
- package/node_modules/accepts/node_modules/negotiator/lib/charset.js +169 -0
- package/node_modules/accepts/node_modules/negotiator/lib/encoding.js +184 -0
- package/node_modules/accepts/node_modules/negotiator/lib/language.js +179 -0
- package/node_modules/accepts/node_modules/negotiator/lib/mediaType.js +294 -0
- package/node_modules/accepts/node_modules/negotiator/package.json +42 -0
- package/node_modules/bytes/History.md +15 -0
- package/node_modules/bytes/Readme.md +45 -18
- package/node_modules/bytes/index.js +15 -4
- package/node_modules/bytes/package.json +7 -4
- package/node_modules/compression/HISTORY.md +15 -0
- package/node_modules/compression/README.md +4 -6
- package/node_modules/compression/index.js +3 -8
- package/node_modules/compression/package.json +19 -19
- package/node_modules/negotiator/HISTORY.md +5 -0
- package/node_modules/negotiator/README.md +9 -0
- package/node_modules/negotiator/index.js +4 -4
- package/node_modules/negotiator/lib/encoding.js +26 -5
- package/node_modules/negotiator/lib/mediaType.js +3 -3
- package/node_modules/negotiator/package.json +1 -1
- package/node_modules/object-inspect/CHANGELOG.md +12 -0
- package/node_modules/object-inspect/index.js +17 -3
- package/node_modules/object-inspect/package.json +6 -6
- package/node_modules/object-inspect/test/quoteStyle.js +9 -0
- package/node_modules/safe-buffer/index.js +3 -0
- package/node_modules/safe-buffer/package.json +18 -4
- package/node_modules/tslib/modules/index.d.ts +1 -0
- package/node_modules/tslib/modules/index.js +2 -0
- package/node_modules/tslib/package.json +1 -1
- package/node_modules/tslib/tslib.d.ts +7 -0
- package/node_modules/tslib/tslib.es6.js +24 -1
- package/node_modules/tslib/tslib.es6.mjs +24 -1
- package/node_modules/tslib/tslib.js +56 -1
- package/package.json +2 -2
- package/worldmap/worldmap.js +4 -1
- package/worldmap.js +2 -2
- package/node_modules/body-parser/node_modules/bytes/History.md +0 -97
- package/node_modules/body-parser/node_modules/bytes/Readme.md +0 -152
- package/node_modules/body-parser/node_modules/bytes/index.js +0 -170
- package/node_modules/body-parser/node_modules/bytes/package.json +0 -42
- package/node_modules/content-disposition/node_modules/safe-buffer/LICENSE +0 -21
- package/node_modules/content-disposition/node_modules/safe-buffer/README.md +0 -584
- package/node_modules/content-disposition/node_modules/safe-buffer/index.d.ts +0 -187
- package/node_modules/content-disposition/node_modules/safe-buffer/index.js +0 -65
- package/node_modules/content-disposition/node_modules/safe-buffer/package.json +0 -51
- package/node_modules/express/node_modules/safe-buffer/LICENSE +0 -21
- package/node_modules/express/node_modules/safe-buffer/README.md +0 -584
- package/node_modules/express/node_modules/safe-buffer/index.d.ts +0 -187
- package/node_modules/express/node_modules/safe-buffer/index.js +0 -65
- package/node_modules/express/node_modules/safe-buffer/package.json +0 -51
- package/node_modules/raw-body/node_modules/bytes/History.md +0 -97
- package/node_modules/raw-body/node_modules/bytes/LICENSE +0 -23
- package/node_modules/raw-body/node_modules/bytes/Readme.md +0 -152
- package/node_modules/raw-body/node_modules/bytes/index.js +0 -170
- package/node_modules/raw-body/node_modules/bytes/package.json +0 -42
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "safe-buffer",
|
|
3
3
|
"description": "Safer Node.js Buffer API",
|
|
4
|
-
"version": "5.1
|
|
4
|
+
"version": "5.2.1",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Feross Aboukhadijeh",
|
|
7
7
|
"email": "feross@feross.org",
|
|
8
|
-
"url": "
|
|
8
|
+
"url": "https://feross.org"
|
|
9
9
|
},
|
|
10
10
|
"bugs": {
|
|
11
11
|
"url": "https://github.com/feross/safe-buffer/issues"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
14
|
"standard": "*",
|
|
15
|
-
"tape": "^
|
|
15
|
+
"tape": "^5.0.0"
|
|
16
16
|
},
|
|
17
17
|
"homepage": "https://github.com/feross/safe-buffer",
|
|
18
18
|
"keywords": [
|
|
@@ -33,5 +33,19 @@
|
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
35
|
"test": "standard && tape test/*.js"
|
|
36
|
-
}
|
|
36
|
+
},
|
|
37
|
+
"funding": [
|
|
38
|
+
{
|
|
39
|
+
"type": "github",
|
|
40
|
+
"url": "https://github.com/sponsors/feross"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"type": "patreon",
|
|
44
|
+
"url": "https://www.patreon.com/feross"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"type": "consulting",
|
|
48
|
+
"url": "https://feross.org/support"
|
|
49
|
+
}
|
|
50
|
+
]
|
|
37
51
|
}
|
|
@@ -31,6 +31,7 @@ const {
|
|
|
31
31
|
__classPrivateFieldIn,
|
|
32
32
|
__addDisposableResource,
|
|
33
33
|
__disposeResources,
|
|
34
|
+
__rewriteRelativeImportExtension,
|
|
34
35
|
} = tslib;
|
|
35
36
|
export {
|
|
36
37
|
__extends,
|
|
@@ -64,5 +65,6 @@ export {
|
|
|
64
65
|
__classPrivateFieldIn,
|
|
65
66
|
__addDisposableResource,
|
|
66
67
|
__disposeResources,
|
|
68
|
+
__rewriteRelativeImportExtension,
|
|
67
69
|
};
|
|
68
70
|
export default tslib;
|
|
@@ -451,3 +451,10 @@ export declare function __addDisposableResource<T>(env: { stack: { value?: unkno
|
|
|
451
451
|
* @seealso {@link __addDisposableResource}
|
|
452
452
|
*/
|
|
453
453
|
export declare function __disposeResources(env: { stack: { value?: unknown, dispose?: Function, async: boolean }[]; error: unknown; hasError: boolean; }): any;
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* Transforms a relative import specifier ending in a non-declaration TypeScript file extension to its JavaScript file extension counterpart.
|
|
457
|
+
* @param path The import specifier.
|
|
458
|
+
* @param preserveJsx Causes '*.tsx' to transform to '*.jsx' instead of '*.js'. Should be true when `--jsx` is set to `preserve`.
|
|
459
|
+
*/
|
|
460
|
+
export declare function __rewriteRelativeImportExtension(path: string, preserveJsx?: boolean): string;
|
|
@@ -263,10 +263,19 @@ var __setModuleDefault = Object.create ? (function(o, v) {
|
|
|
263
263
|
o["default"] = v;
|
|
264
264
|
};
|
|
265
265
|
|
|
266
|
+
var ownKeys = function(o) {
|
|
267
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
268
|
+
var ar = [];
|
|
269
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
270
|
+
return ar;
|
|
271
|
+
};
|
|
272
|
+
return ownKeys(o);
|
|
273
|
+
};
|
|
274
|
+
|
|
266
275
|
export function __importStar(mod) {
|
|
267
276
|
if (mod && mod.__esModule) return mod;
|
|
268
277
|
var result = {};
|
|
269
|
-
if (mod != null) for (var k
|
|
278
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
270
279
|
__setModuleDefault(result, mod);
|
|
271
280
|
return result;
|
|
272
281
|
}
|
|
@@ -348,12 +357,25 @@ export function __disposeResources(env) {
|
|
|
348
357
|
return next();
|
|
349
358
|
}
|
|
350
359
|
|
|
360
|
+
export function __rewriteRelativeImportExtension(path, preserveJsx) {
|
|
361
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
362
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
363
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
return path;
|
|
367
|
+
}
|
|
368
|
+
|
|
351
369
|
export default {
|
|
352
370
|
__extends: __extends,
|
|
353
371
|
__assign: __assign,
|
|
354
372
|
__rest: __rest,
|
|
355
373
|
__decorate: __decorate,
|
|
356
374
|
__param: __param,
|
|
375
|
+
__esDecorate: __esDecorate,
|
|
376
|
+
__runInitializers: __runInitializers,
|
|
377
|
+
__propKey: __propKey,
|
|
378
|
+
__setFunctionName: __setFunctionName,
|
|
357
379
|
__metadata: __metadata,
|
|
358
380
|
__awaiter: __awaiter,
|
|
359
381
|
__generator: __generator,
|
|
@@ -376,4 +398,5 @@ export default {
|
|
|
376
398
|
__classPrivateFieldIn: __classPrivateFieldIn,
|
|
377
399
|
__addDisposableResource: __addDisposableResource,
|
|
378
400
|
__disposeResources: __disposeResources,
|
|
401
|
+
__rewriteRelativeImportExtension: __rewriteRelativeImportExtension,
|
|
379
402
|
};
|
|
@@ -263,10 +263,19 @@ var __setModuleDefault = Object.create ? (function(o, v) {
|
|
|
263
263
|
o["default"] = v;
|
|
264
264
|
};
|
|
265
265
|
|
|
266
|
+
var ownKeys = function(o) {
|
|
267
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
268
|
+
var ar = [];
|
|
269
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
270
|
+
return ar;
|
|
271
|
+
};
|
|
272
|
+
return ownKeys(o);
|
|
273
|
+
};
|
|
274
|
+
|
|
266
275
|
export function __importStar(mod) {
|
|
267
276
|
if (mod && mod.__esModule) return mod;
|
|
268
277
|
var result = {};
|
|
269
|
-
if (mod != null) for (var k
|
|
278
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
270
279
|
__setModuleDefault(result, mod);
|
|
271
280
|
return result;
|
|
272
281
|
}
|
|
@@ -347,12 +356,25 @@ export function __disposeResources(env) {
|
|
|
347
356
|
return next();
|
|
348
357
|
}
|
|
349
358
|
|
|
359
|
+
export function __rewriteRelativeImportExtension(path, preserveJsx) {
|
|
360
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
361
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
362
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
return path;
|
|
366
|
+
}
|
|
367
|
+
|
|
350
368
|
export default {
|
|
351
369
|
__extends,
|
|
352
370
|
__assign,
|
|
353
371
|
__rest,
|
|
354
372
|
__decorate,
|
|
355
373
|
__param,
|
|
374
|
+
__esDecorate,
|
|
375
|
+
__runInitializers,
|
|
376
|
+
__propKey,
|
|
377
|
+
__setFunctionName,
|
|
356
378
|
__metadata,
|
|
357
379
|
__awaiter,
|
|
358
380
|
__generator,
|
|
@@ -375,4 +397,5 @@ export default {
|
|
|
375
397
|
__classPrivateFieldIn,
|
|
376
398
|
__addDisposableResource,
|
|
377
399
|
__disposeResources,
|
|
400
|
+
__rewriteRelativeImportExtension,
|
|
378
401
|
};
|
|
@@ -44,6 +44,7 @@ var __classPrivateFieldIn;
|
|
|
44
44
|
var __createBinding;
|
|
45
45
|
var __addDisposableResource;
|
|
46
46
|
var __disposeResources;
|
|
47
|
+
var __rewriteRelativeImportExtension;
|
|
47
48
|
(function (factory) {
|
|
48
49
|
var root = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : {};
|
|
49
50
|
if (typeof define === "function" && define.amd) {
|
|
@@ -311,10 +312,19 @@ var __disposeResources;
|
|
|
311
312
|
o["default"] = v;
|
|
312
313
|
};
|
|
313
314
|
|
|
315
|
+
var ownKeys = function(o) {
|
|
316
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
317
|
+
var ar = [];
|
|
318
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
319
|
+
return ar;
|
|
320
|
+
};
|
|
321
|
+
return ownKeys(o);
|
|
322
|
+
};
|
|
323
|
+
|
|
314
324
|
__importStar = function (mod) {
|
|
315
325
|
if (mod && mod.__esModule) return mod;
|
|
316
326
|
var result = {};
|
|
317
|
-
if (mod != null) for (var k
|
|
327
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
318
328
|
__setModuleDefault(result, mod);
|
|
319
329
|
return result;
|
|
320
330
|
};
|
|
@@ -395,6 +405,15 @@ var __disposeResources;
|
|
|
395
405
|
return next();
|
|
396
406
|
};
|
|
397
407
|
|
|
408
|
+
__rewriteRelativeImportExtension = function (path, preserveJsx) {
|
|
409
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
410
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
411
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
return path;
|
|
415
|
+
};
|
|
416
|
+
|
|
398
417
|
exporter("__extends", __extends);
|
|
399
418
|
exporter("__assign", __assign);
|
|
400
419
|
exporter("__rest", __rest);
|
|
@@ -426,4 +445,40 @@ var __disposeResources;
|
|
|
426
445
|
exporter("__classPrivateFieldIn", __classPrivateFieldIn);
|
|
427
446
|
exporter("__addDisposableResource", __addDisposableResource);
|
|
428
447
|
exporter("__disposeResources", __disposeResources);
|
|
448
|
+
exporter("__rewriteRelativeImportExtension", __rewriteRelativeImportExtension);
|
|
449
|
+
});
|
|
450
|
+
|
|
451
|
+
0 && (module.exports = {
|
|
452
|
+
__extends: __extends,
|
|
453
|
+
__assign: __assign,
|
|
454
|
+
__rest: __rest,
|
|
455
|
+
__decorate: __decorate,
|
|
456
|
+
__param: __param,
|
|
457
|
+
__esDecorate: __esDecorate,
|
|
458
|
+
__runInitializers: __runInitializers,
|
|
459
|
+
__propKey: __propKey,
|
|
460
|
+
__setFunctionName: __setFunctionName,
|
|
461
|
+
__metadata: __metadata,
|
|
462
|
+
__awaiter: __awaiter,
|
|
463
|
+
__generator: __generator,
|
|
464
|
+
__exportStar: __exportStar,
|
|
465
|
+
__createBinding: __createBinding,
|
|
466
|
+
__values: __values,
|
|
467
|
+
__read: __read,
|
|
468
|
+
__spread: __spread,
|
|
469
|
+
__spreadArrays: __spreadArrays,
|
|
470
|
+
__spreadArray: __spreadArray,
|
|
471
|
+
__await: __await,
|
|
472
|
+
__asyncGenerator: __asyncGenerator,
|
|
473
|
+
__asyncDelegator: __asyncDelegator,
|
|
474
|
+
__asyncValues: __asyncValues,
|
|
475
|
+
__makeTemplateObject: __makeTemplateObject,
|
|
476
|
+
__importStar: __importStar,
|
|
477
|
+
__importDefault: __importDefault,
|
|
478
|
+
__classPrivateFieldGet: __classPrivateFieldGet,
|
|
479
|
+
__classPrivateFieldSet: __classPrivateFieldSet,
|
|
480
|
+
__classPrivateFieldIn: __classPrivateFieldIn,
|
|
481
|
+
__addDisposableResource: __addDisposableResource,
|
|
482
|
+
__disposeResources: __disposeResources,
|
|
483
|
+
__rewriteRelativeImportExtension: __rewriteRelativeImportExtension,
|
|
429
484
|
});
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-red-contrib-web-worldmap",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.6",
|
|
4
4
|
"description": "A Node-RED node to provide a web page of a world map for plotting things on.",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@turf/bezier-spline": "~7.1.0",
|
|
7
7
|
"cgi": "0.3.1",
|
|
8
|
-
"compression": "^1.7.
|
|
8
|
+
"compression": "^1.7.5",
|
|
9
9
|
"express": "^4.21.1",
|
|
10
10
|
"sockjs": "~0.3.24"
|
|
11
11
|
},
|
package/worldmap/worldmap.js
CHANGED
|
@@ -2123,12 +2123,13 @@ function setMarker(data) {
|
|
|
2123
2123
|
}
|
|
2124
2124
|
opts.size = opts.size || sz;
|
|
2125
2125
|
opts.size = opts.size * (opts.scale || 1);
|
|
2126
|
-
if (data.SIDC.length > 12) {
|
|
2126
|
+
if (data.SIDC.length > 12 && data.SIDC.substr(12,2) !== "**") {
|
|
2127
2127
|
var cc = data.SIDC.substr(12,2).toLowerCase();
|
|
2128
2128
|
opts.country = cc.toUpperCase();
|
|
2129
2129
|
opts.staffComments = emojify(":flag-"+cc+":") + " " + (opts?.staffComments || "");
|
|
2130
2130
|
data.flag = emojify(":flag-"+cc+":");
|
|
2131
2131
|
}
|
|
2132
|
+
if (data?.speed) { opts.direction = data?.bearing || data?.hdg || data?.COG }
|
|
2132
2133
|
// escape out any isocodes eg flag symbols
|
|
2133
2134
|
var optfields = ["additionalInformation","higherFormation","specialHeadquarters","staffComments","type","uniqueDesignation","speed","country"];
|
|
2134
2135
|
//const regex = /\p{Extended_Pictographic}/ug;
|
|
@@ -3317,6 +3318,7 @@ function doTAKjson(p) {
|
|
|
3317
3318
|
d.name = p.detail?.contact?.callsign || p.uid;
|
|
3318
3319
|
d.lat = Number(p.point.lat);
|
|
3319
3320
|
d.lon = Number(p.point.lon);
|
|
3321
|
+
d.layer = "TAK";
|
|
3320
3322
|
if (p.type.indexOf('a') === 0) {
|
|
3321
3323
|
d.hdg = p.detail?.track?.course;
|
|
3322
3324
|
if (p.detail?.track?.speed) {
|
|
@@ -3368,6 +3370,7 @@ function doTAKMCjson(p) {
|
|
|
3368
3370
|
var d = {};
|
|
3369
3371
|
d.lat = p.lat;
|
|
3370
3372
|
d.lon = p.lon;
|
|
3373
|
+
d.layer = "TAK";
|
|
3371
3374
|
if (p.detail?.__group?.name) {
|
|
3372
3375
|
d.team = p.detail?.__group?.name;
|
|
3373
3376
|
d.team = d.team + ' <i style="color:' + d.team + '" class="fa fa-square"></i>';
|
package/worldmap.js
CHANGED
|
@@ -71,7 +71,7 @@ module.exports = function(RED) {
|
|
|
71
71
|
res.send({key:process.env.MAPBOXGL_TOKEN});
|
|
72
72
|
}
|
|
73
73
|
else {
|
|
74
|
-
node.error("No API key set");
|
|
74
|
+
node.error("No MapBox API key set");
|
|
75
75
|
res.send({key:''})
|
|
76
76
|
}
|
|
77
77
|
});
|
|
@@ -271,7 +271,7 @@ module.exports = function(RED) {
|
|
|
271
271
|
ui = RED.require("node-red-dashboard")(RED);
|
|
272
272
|
}
|
|
273
273
|
catch(e) {
|
|
274
|
-
RED.log.info("Node-RED Dashboard not found - ui_worldmap not installed.");
|
|
274
|
+
RED.log.info("Node-RED Dashboard 1 not found - ui_worldmap node not installed.");
|
|
275
275
|
}
|
|
276
276
|
setTimeout( function() {
|
|
277
277
|
if (ui) {
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
3.1.2 / 2022-01-27
|
|
2
|
-
==================
|
|
3
|
-
|
|
4
|
-
* Fix return value for un-parsable strings
|
|
5
|
-
|
|
6
|
-
3.1.1 / 2021-11-15
|
|
7
|
-
==================
|
|
8
|
-
|
|
9
|
-
* Fix "thousandsSeparator" incorrecting formatting fractional part
|
|
10
|
-
|
|
11
|
-
3.1.0 / 2019-01-22
|
|
12
|
-
==================
|
|
13
|
-
|
|
14
|
-
* Add petabyte (`pb`) support
|
|
15
|
-
|
|
16
|
-
3.0.0 / 2017-08-31
|
|
17
|
-
==================
|
|
18
|
-
|
|
19
|
-
* Change "kB" to "KB" in format output
|
|
20
|
-
* Remove support for Node.js 0.6
|
|
21
|
-
* Remove support for ComponentJS
|
|
22
|
-
|
|
23
|
-
2.5.0 / 2017-03-24
|
|
24
|
-
==================
|
|
25
|
-
|
|
26
|
-
* Add option "unit"
|
|
27
|
-
|
|
28
|
-
2.4.0 / 2016-06-01
|
|
29
|
-
==================
|
|
30
|
-
|
|
31
|
-
* Add option "unitSeparator"
|
|
32
|
-
|
|
33
|
-
2.3.0 / 2016-02-15
|
|
34
|
-
==================
|
|
35
|
-
|
|
36
|
-
* Drop partial bytes on all parsed units
|
|
37
|
-
* Fix non-finite numbers to `.format` to return `null`
|
|
38
|
-
* Fix parsing byte string that looks like hex
|
|
39
|
-
* perf: hoist regular expressions
|
|
40
|
-
|
|
41
|
-
2.2.0 / 2015-11-13
|
|
42
|
-
==================
|
|
43
|
-
|
|
44
|
-
* add option "decimalPlaces"
|
|
45
|
-
* add option "fixedDecimals"
|
|
46
|
-
|
|
47
|
-
2.1.0 / 2015-05-21
|
|
48
|
-
==================
|
|
49
|
-
|
|
50
|
-
* add `.format` export
|
|
51
|
-
* add `.parse` export
|
|
52
|
-
|
|
53
|
-
2.0.2 / 2015-05-20
|
|
54
|
-
==================
|
|
55
|
-
|
|
56
|
-
* remove map recreation
|
|
57
|
-
* remove unnecessary object construction
|
|
58
|
-
|
|
59
|
-
2.0.1 / 2015-05-07
|
|
60
|
-
==================
|
|
61
|
-
|
|
62
|
-
* fix browserify require
|
|
63
|
-
* remove node.extend dependency
|
|
64
|
-
|
|
65
|
-
2.0.0 / 2015-04-12
|
|
66
|
-
==================
|
|
67
|
-
|
|
68
|
-
* add option "case"
|
|
69
|
-
* add option "thousandsSeparator"
|
|
70
|
-
* return "null" on invalid parse input
|
|
71
|
-
* support proper round-trip: bytes(bytes(num)) === num
|
|
72
|
-
* units no longer case sensitive when parsing
|
|
73
|
-
|
|
74
|
-
1.0.0 / 2014-05-05
|
|
75
|
-
==================
|
|
76
|
-
|
|
77
|
-
* add negative support. fixes #6
|
|
78
|
-
|
|
79
|
-
0.3.0 / 2014-03-19
|
|
80
|
-
==================
|
|
81
|
-
|
|
82
|
-
* added terabyte support
|
|
83
|
-
|
|
84
|
-
0.2.1 / 2013-04-01
|
|
85
|
-
==================
|
|
86
|
-
|
|
87
|
-
* add .component
|
|
88
|
-
|
|
89
|
-
0.2.0 / 2012-10-28
|
|
90
|
-
==================
|
|
91
|
-
|
|
92
|
-
* bytes(200).should.eql('200b')
|
|
93
|
-
|
|
94
|
-
0.1.0 / 2012-07-04
|
|
95
|
-
==================
|
|
96
|
-
|
|
97
|
-
* add bytes to string conversion [yields]
|
|
@@ -1,152 +0,0 @@
|
|
|
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
|