mirror of
https://github.com/netbymatt/nexrad-level-3-plot.git
synced 2026-11-28 10:48:04 -08:00
change to mjs
This commit is contained in:
1 parent
fa9065b8ac
commit
98a172fb63
23 files changed
+453
-136
No files matched your search
+6
-12
@@ -1,38 +1,32 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
env: {
|
||||
commonjs: true,
|
||||
node: true,
|
||||
},
|
||||
extends: 'airbnb-base',
|
||||
globals: {
|
||||
Atomics: 'readonly',
|
||||
SharedArrayBuffer: 'readonly',
|
||||
},
|
||||
parserOptions: {
|
||||
ecmaVersion: 2020,
|
||||
ecmaVersion: 2023,
|
||||
},
|
||||
rules: {
|
||||
indent: [
|
||||
'error',
|
||||
'tab',
|
||||
],
|
||||
'no-tabs': 0,
|
||||
'max-len': 0,
|
||||
'no-use-before-define': [
|
||||
'error',
|
||||
{
|
||||
variables: false,
|
||||
},
|
||||
],
|
||||
'no-param-reassign': [
|
||||
'import/extensions': [
|
||||
'error',
|
||||
{
|
||||
props: false,
|
||||
mjs: 'always',
|
||||
js: 'never',
|
||||
},
|
||||
],
|
||||
'no-tabs': 0,
|
||||
'max-len': 0,
|
||||
'no-bitwise': 0,
|
||||
'linebreak-style': 0,
|
||||
},
|
||||
ignorePatterns: [
|
||||
'*.min.js',
|
||||
|
||||
Vendored
+4
-6
@@ -6,25 +6,23 @@
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Test All",
|
||||
"program": "${workspaceFolder}/demos/test-all.js",
|
||||
"program": "${workspaceFolder}/demos/test-all.mjs",
|
||||
"cwd": "${workspaceFolder}/demos",
|
||||
"request": "launch",
|
||||
"skipFiles": [
|
||||
"<node_internals>/**"
|
||||
],
|
||||
"type": "pwa-node"
|
||||
"type": "node"
|
||||
},
|
||||
|
||||
{
|
||||
"type": "pwa-node",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Test Single",
|
||||
"skipFiles": [
|
||||
"<node_internals>/**"
|
||||
],
|
||||
"program": "${workspaceFolder}/demos/test.js",
|
||||
"program": "${workspaceFolder}/demos/test.mjs",
|
||||
"cwd": "${workspaceFolder}/demos",
|
||||
},
|
||||
|
||||
]
|
||||
}
|
||||
@@ -14,17 +14,15 @@ npm -i nexrad-level-3-plot
|
||||
|
||||
## Call
|
||||
```javascript
|
||||
const fs = require('fs');
|
||||
const { plot, writeToPngFile } = require('nexrad-level-3-plot');
|
||||
import fs from 'fs/promises';
|
||||
import { plot, writeToPngFile } from 'nexrad-level-3-plot';
|
||||
|
||||
// read a file
|
||||
const file = fs.readFileSync('<path to data>');
|
||||
const file = await fs.readFile('<path to data>');
|
||||
// parse and plot
|
||||
const level3Plot = plot(file);
|
||||
// use bundled utility to write to disk
|
||||
(async () => {
|
||||
await writePngToFile('<path to output>.png');
|
||||
})();
|
||||
await writePngToFile('<path to output>.png');
|
||||
```
|
||||
# Data
|
||||
Level three data is available from NOAA free of charge. [nexrad-level-3-data](https://github.com/netbymatt/nexrad-level-3-data/#background-information) has additional details about these data sources.
|
||||
@@ -45,7 +43,7 @@ This package is currently incomplete. It will plot raster data created by the pa
|
||||
177|HCC|Hybrid Hydrometeor Classification
|
||||
|
||||
# Demos
|
||||
Test code and data is provided in the `./demo` folder. `test.js` can be used to test any one of the products by commenting/uncommenting the appropriate line in the file. All images will be output as PNG to `./output`. A `test-all.js` is also provided to plot all of the products provided in the `./data/` folder. This test will product images in multiple sizes to show scaling built-in scaling functionality.
|
||||
Test code and data is provided in the `./demo` folder. `test.js` can be used to test any one of the products by commenting/uncommenting the appropriate line in the file. All images will be output as PNG to `./output`. A `test-all.js` is also provided to plot all of the products provided in the `./data/` folder. This test will product images in multiple sizes to show scaling built-in scaling functionality. Some non-supported products (N0S) are included in the test data to show how these are detected and throw errors.
|
||||
|
||||
# API
|
||||
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
/* eslint-disable no-console */
|
||||
const fs = require('fs');
|
||||
const { plotAndData, writePngToFile } = require('../src');
|
||||
|
||||
// sizes to produce
|
||||
const sizes = [100, 400, 900, 1350, 1800];
|
||||
|
||||
// get a list of all data files
|
||||
const files = fs.readdirSync('./data/');
|
||||
|
||||
// plot each file
|
||||
(async () => {
|
||||
await Promise.allSettled(files.map(async (file) => {
|
||||
console.log(file);
|
||||
try {
|
||||
const rawFile = fs.readFileSync(`./data/${file}`);
|
||||
// plot for each size
|
||||
return sizes.map(async (size) => {
|
||||
console.log(`${file} ${size}`);
|
||||
try {
|
||||
const level3Plot = plotAndData(rawFile, { size, palletize: { generate: 2 } });
|
||||
console.log(level3Plot);
|
||||
// test for returned image
|
||||
if (!level3Plot) return false;
|
||||
|
||||
// write to disk
|
||||
const writeResult = [];
|
||||
if (level3Plot.image) writeResult.push(await writePngToFile(`./output/${file}-${size}.png`, level3Plot.image));
|
||||
if (level3Plot.palletized) writeResult.push(await writePngToFile(`./output/${file}-${size}-pal.png`, level3Plot.palletized));
|
||||
return writeResult;
|
||||
} catch (e) {
|
||||
console.error(e.message);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(e.message);
|
||||
return false;
|
||||
}
|
||||
}).flat());
|
||||
})();
|
||||
@@ -0,0 +1,40 @@
|
||||
/* eslint-disable no-console */
|
||||
import fs from 'fs/promises';
|
||||
import { plotAndData, writePngToFile } from '../src/index.mjs';
|
||||
|
||||
// sizes to produce
|
||||
const sizes = [100, 400, 900, 1350, 1800];
|
||||
|
||||
// get a list of all data files
|
||||
const files = await fs.readdir('./data/');
|
||||
|
||||
// plot each file
|
||||
|
||||
await Promise.allSettled(files.map(async (file) => {
|
||||
console.log(file);
|
||||
try {
|
||||
const rawFile = await fs.readFile(`./data/${file}`);
|
||||
// plot for each size
|
||||
return sizes.map(async (size) => {
|
||||
console.log(`${file} ${size}`);
|
||||
try {
|
||||
const level3Plot = plotAndData(rawFile, { size, palletize: { generate: 2 } });
|
||||
console.log(level3Plot);
|
||||
// test for returned image
|
||||
if (!level3Plot) return false;
|
||||
|
||||
// write to disk
|
||||
const writeResult = [];
|
||||
if (level3Plot.image) writeResult.push(await writePngToFile(`./output/${file}-${size}.png`, level3Plot.image));
|
||||
if (level3Plot.palletized) writeResult.push(await writePngToFile(`./output/${file}-${size}-pal.png`, level3Plot.palletized));
|
||||
return writeResult;
|
||||
} catch (e) {
|
||||
console.error(e.message);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(e.message);
|
||||
return false;
|
||||
}
|
||||
}).flat());
|
||||
@@ -1,6 +1,6 @@
|
||||
/* eslint-disable no-console */
|
||||
const fs = require('fs');
|
||||
const { plotAndData, writePngToFile } = require('../src');
|
||||
import fs from 'fs/promises';
|
||||
import { plotAndData, writePngToFile } from '../src/index.mjs';
|
||||
|
||||
// read file
|
||||
|
||||
@@ -26,11 +26,9 @@ const fileName = 'LOT_DTA_2023_07_03_05_24_06';
|
||||
// const fileName = 'LOT_HHC_2021_01_31_11_06_30';
|
||||
|
||||
// pass to plotting engine as a string or buffer
|
||||
const file = fs.readFileSync(`./data/${fileName}`);
|
||||
const file = await fs.readFile(`./data/${fileName}`);
|
||||
const level3Plot = plotAndData(file, { palletize: { generate: 2 }, background: 'black' });
|
||||
|
||||
console.log(level3Plot);
|
||||
(async () => {
|
||||
await writePngToFile(`./output/${fileName}.png`, level3Plot.image);
|
||||
await writePngToFile(`./output/${fileName}-pal.png`, level3Plot.palletized);
|
||||
})();
|
||||
await writePngToFile(`./output/${fileName}.png`, level3Plot.image);
|
||||
await writePngToFile(`./output/${fileName}-pal.png`, level3Plot.palletized);
|
||||
@@ -16,6 +16,7 @@
|
||||
"palletized",
|
||||
"palletize",
|
||||
"palletized",
|
||||
"NEXRAD",
|
||||
],
|
||||
"editor.formatOnSave": true
|
||||
}
|
||||
|
||||
Generated
+348
-22
@@ -1,15 +1,16 @@
|
||||
{
|
||||
"name": "nexrad-level-3-plot",
|
||||
"version": "0.13.3",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "nexrad-level-3-plot",
|
||||
"version": "0.13.3",
|
||||
"version": "1.0.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"canvas": "^2.6.1",
|
||||
"glob": "^10.4.1",
|
||||
"nexrad-level-3-data": "^0.6.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -114,6 +115,73 @@
|
||||
"dev": true,
|
||||
"license": "BSD-3-Clause"
|
||||
},
|
||||
"node_modules/@isaacs/cliui": {
|
||||
"version": "8.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz",
|
||||
"integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"string-width": "^5.1.2",
|
||||
"string-width-cjs": "npm:string-width@^4.2.0",
|
||||
"strip-ansi": "^7.0.1",
|
||||
"strip-ansi-cjs": "npm:strip-ansi@^6.0.1",
|
||||
"wrap-ansi": "^8.1.0",
|
||||
"wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@isaacs/cliui/node_modules/ansi-regex": {
|
||||
"version": "6.0.1",
|
||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz",
|
||||
"integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/chalk/ansi-regex?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/@isaacs/cliui/node_modules/emoji-regex": {
|
||||
"version": "9.2.2",
|
||||
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz",
|
||||
"integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@isaacs/cliui/node_modules/string-width": {
|
||||
"version": "5.1.2",
|
||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz",
|
||||
"integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"eastasianwidth": "^0.2.0",
|
||||
"emoji-regex": "^9.2.2",
|
||||
"strip-ansi": "^7.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/@isaacs/cliui/node_modules/strip-ansi": {
|
||||
"version": "7.1.0",
|
||||
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz",
|
||||
"integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ansi-regex": "^6.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/chalk/strip-ansi?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/@mapbox/node-pre-gyp": {
|
||||
"version": "1.0.11",
|
||||
"resolved": "https://registry.npmjs.org/@mapbox/node-pre-gyp/-/node-pre-gyp-1.0.11.tgz",
|
||||
@@ -172,6 +240,16 @@
|
||||
"node": ">= 8"
|
||||
}
|
||||
},
|
||||
"node_modules/@pkgjs/parseargs": {
|
||||
"version": "0.11.0",
|
||||
"resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz",
|
||||
"integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==",
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/json5": {
|
||||
"version": "0.0.29",
|
||||
"resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz",
|
||||
@@ -257,7 +335,6 @@
|
||||
"version": "4.3.0",
|
||||
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
|
||||
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"color-convert": "^2.0.1"
|
||||
@@ -523,7 +600,6 @@
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
|
||||
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"color-name": "~1.1.4"
|
||||
@@ -536,7 +612,6 @@
|
||||
"version": "1.1.4",
|
||||
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
|
||||
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/color-support": {
|
||||
@@ -580,7 +655,6 @@
|
||||
"version": "7.0.3",
|
||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
|
||||
"integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"path-key": "^3.1.0",
|
||||
@@ -745,6 +819,12 @@
|
||||
"node": ">=6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/eastasianwidth": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz",
|
||||
"integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/emoji-regex": {
|
||||
"version": "8.0.0",
|
||||
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
|
||||
@@ -1292,6 +1372,34 @@
|
||||
"is-callable": "^1.1.3"
|
||||
}
|
||||
},
|
||||
"node_modules/foreground-child": {
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.1.1.tgz",
|
||||
"integrity": "sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg==",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"cross-spawn": "^7.0.0",
|
||||
"signal-exit": "^4.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/isaacs"
|
||||
}
|
||||
},
|
||||
"node_modules/foreground-child/node_modules/signal-exit": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz",
|
||||
"integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==",
|
||||
"license": "ISC",
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/isaacs"
|
||||
}
|
||||
},
|
||||
"node_modules/fs-minipass": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz",
|
||||
@@ -1421,21 +1529,22 @@
|
||||
}
|
||||
},
|
||||
"node_modules/glob": {
|
||||
"version": "7.2.3",
|
||||
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz",
|
||||
"integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==",
|
||||
"deprecated": "Glob versions prior to v9 are no longer supported",
|
||||
"version": "10.4.1",
|
||||
"resolved": "https://registry.npmjs.org/glob/-/glob-10.4.1.tgz",
|
||||
"integrity": "sha512-2jelhlq3E4ho74ZyVLN03oKdAZVUa6UDZzFLVH1H7dnoax+y9qyaq8zBkfDIggjniU19z0wU18y16jMB2eyVIw==",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"fs.realpath": "^1.0.0",
|
||||
"inflight": "^1.0.4",
|
||||
"inherits": "2",
|
||||
"minimatch": "^3.1.1",
|
||||
"once": "^1.3.0",
|
||||
"path-is-absolute": "^1.0.0"
|
||||
"foreground-child": "^3.1.0",
|
||||
"jackspeak": "^3.1.2",
|
||||
"minimatch": "^9.0.4",
|
||||
"minipass": "^7.1.2",
|
||||
"path-scurry": "^1.11.1"
|
||||
},
|
||||
"bin": {
|
||||
"glob": "dist/esm/bin.mjs"
|
||||
},
|
||||
"engines": {
|
||||
"node": "*"
|
||||
"node": ">=16 || 14 >=14.18"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/isaacs"
|
||||
@@ -1454,6 +1563,39 @@
|
||||
"node": ">=10.13.0"
|
||||
}
|
||||
},
|
||||
"node_modules/glob/node_modules/brace-expansion": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
|
||||
"integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"balanced-match": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/glob/node_modules/minimatch": {
|
||||
"version": "9.0.4",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.4.tgz",
|
||||
"integrity": "sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw==",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"brace-expansion": "^2.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16 || 14 >=14.17"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/isaacs"
|
||||
}
|
||||
},
|
||||
"node_modules/glob/node_modules/minipass": {
|
||||
"version": "7.1.2",
|
||||
"resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz",
|
||||
"integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==",
|
||||
"license": "ISC",
|
||||
"engines": {
|
||||
"node": ">=16 || 14 >=14.17"
|
||||
}
|
||||
},
|
||||
"node_modules/globals": {
|
||||
"version": "13.24.0",
|
||||
"resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz",
|
||||
@@ -1964,9 +2106,26 @@
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
|
||||
"integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==",
|
||||
"dev": true,
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/jackspeak": {
|
||||
"version": "3.2.5",
|
||||
"resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.2.5.tgz",
|
||||
"integrity": "sha512-a1hopwtr4NawFIrSmFgufzrN1Qy2BAfMJ0yScJBs/olJhTcctCy3YIDx4hTY2DOTJD1pUMTly80kmlYZxjZr5w==",
|
||||
"license": "BlueOak-1.0.0",
|
||||
"dependencies": {
|
||||
"@isaacs/cliui": "^8.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/isaacs"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@pkgjs/parseargs": "^0.11.0"
|
||||
}
|
||||
},
|
||||
"node_modules/js-yaml": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
|
||||
@@ -2061,6 +2220,15 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/lru-cache": {
|
||||
"version": "10.2.2",
|
||||
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.2.2.tgz",
|
||||
"integrity": "sha512-9hp3Vp2/hFQUiIwKo8XCeFVnrg8Pk3TYNPIR7tJADKi5YfcF7vEaK7avFHTlSy3kOKYaJQaalfEo6YuXdceBOQ==",
|
||||
"license": "ISC",
|
||||
"engines": {
|
||||
"node": "14 || >=16.14"
|
||||
}
|
||||
},
|
||||
"node_modules/make-dir": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz",
|
||||
@@ -2454,7 +2622,6 @@
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",
|
||||
"integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
@@ -2467,6 +2634,22 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/path-scurry": {
|
||||
"version": "1.11.1",
|
||||
"resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz",
|
||||
"integrity": "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==",
|
||||
"license": "BlueOak-1.0.0",
|
||||
"dependencies": {
|
||||
"lru-cache": "^10.2.0",
|
||||
"minipass": "^5.0.0 || ^6.0.2 || ^7.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16 || 14 >=14.18"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/isaacs"
|
||||
}
|
||||
},
|
||||
"node_modules/possible-typed-array-names": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/possible-typed-array-names/-/possible-typed-array-names-1.0.0.tgz",
|
||||
@@ -2606,6 +2789,27 @@
|
||||
"url": "https://github.com/sponsors/isaacs"
|
||||
}
|
||||
},
|
||||
"node_modules/rimraf/node_modules/glob": {
|
||||
"version": "7.2.3",
|
||||
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz",
|
||||
"integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==",
|
||||
"deprecated": "Glob versions prior to v9 are no longer supported",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"fs.realpath": "^1.0.0",
|
||||
"inflight": "^1.0.4",
|
||||
"inherits": "2",
|
||||
"minimatch": "^3.1.1",
|
||||
"once": "^1.3.0",
|
||||
"path-is-absolute": "^1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "*"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/isaacs"
|
||||
}
|
||||
},
|
||||
"node_modules/run-parallel": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz",
|
||||
@@ -2756,7 +2960,6 @@
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",
|
||||
"integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"shebang-regex": "^3.0.0"
|
||||
@@ -2769,7 +2972,6 @@
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz",
|
||||
"integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
@@ -2854,6 +3056,21 @@
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/string-width-cjs": {
|
||||
"name": "string-width",
|
||||
"version": "4.2.3",
|
||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
|
||||
"integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"emoji-regex": "^8.0.0",
|
||||
"is-fullwidth-code-point": "^3.0.0",
|
||||
"strip-ansi": "^6.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/string.prototype.trim": {
|
||||
"version": "1.2.9",
|
||||
"resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.2.9.tgz",
|
||||
@@ -2918,6 +3135,19 @@
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/strip-ansi-cjs": {
|
||||
"name": "strip-ansi",
|
||||
"version": "6.0.1",
|
||||
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
|
||||
"integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ansi-regex": "^5.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/strip-bom": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz",
|
||||
@@ -3165,7 +3395,6 @@
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
|
||||
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"isexe": "^2.0.0"
|
||||
@@ -3233,6 +3462,103 @@
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/wrap-ansi": {
|
||||
"version": "8.1.0",
|
||||
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz",
|
||||
"integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ansi-styles": "^6.1.0",
|
||||
"string-width": "^5.0.1",
|
||||
"strip-ansi": "^7.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/chalk/wrap-ansi?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/wrap-ansi-cjs": {
|
||||
"name": "wrap-ansi",
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz",
|
||||
"integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ansi-styles": "^4.0.0",
|
||||
"string-width": "^4.1.0",
|
||||
"strip-ansi": "^6.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/chalk/wrap-ansi?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/wrap-ansi/node_modules/ansi-regex": {
|
||||
"version": "6.0.1",
|
||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz",
|
||||
"integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/chalk/ansi-regex?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/wrap-ansi/node_modules/ansi-styles": {
|
||||
"version": "6.2.1",
|
||||
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz",
|
||||
"integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/wrap-ansi/node_modules/emoji-regex": {
|
||||
"version": "9.2.2",
|
||||
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz",
|
||||
"integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/wrap-ansi/node_modules/string-width": {
|
||||
"version": "5.1.2",
|
||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz",
|
||||
"integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"eastasianwidth": "^0.2.0",
|
||||
"emoji-regex": "^9.2.2",
|
||||
"strip-ansi": "^7.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/wrap-ansi/node_modules/strip-ansi": {
|
||||
"version": "7.1.0",
|
||||
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz",
|
||||
"integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ansi-regex": "^6.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/chalk/strip-ansi?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/wrappy": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||
|
||||
+8
-3
@@ -2,9 +2,10 @@
|
||||
"name": "nexrad-level-3-plot",
|
||||
"version": "0.13.3",
|
||||
"description": "Plotting of NEXRAD level 3 data files",
|
||||
"main": "src/index.js",
|
||||
"main": "src/index.mjs",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"lint": "eslint"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -31,6 +32,10 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"canvas": "^2.6.1",
|
||||
"glob": "^10.4.1",
|
||||
"nexrad-level-3-data": "^0.6.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
const { createCanvas } = require('canvas');
|
||||
const Palette = require('./palette');
|
||||
import { createCanvas } from 'canvas';
|
||||
import generate from './palette.mjs';
|
||||
|
||||
const DEFAULT_OPTIONS = {
|
||||
// must be a square image
|
||||
@@ -35,7 +35,7 @@ const draw = (data, product, _options) => {
|
||||
ctx.rotate(-Math.PI / 2);
|
||||
|
||||
// generate a palette
|
||||
const palette = Palette.generate(product.palette);
|
||||
const palette = generate(product.palette);
|
||||
// calculate scaling paramater with respect to pallet's designed criteria
|
||||
let paletteScale = (data?.productDescription?.plot?.maxDataValue ?? 255) / (product.palette.baseScale ?? data?.productDescription?.plot?.maxDataValue ?? 1);
|
||||
// if the product uses maximum accumulation use a different calculation
|
||||
@@ -82,7 +82,8 @@ const draw = (data, product, _options) => {
|
||||
return canvas;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
export default draw;
|
||||
export {
|
||||
draw,
|
||||
DEFAULT_OPTIONS,
|
||||
};
|
||||
@@ -41,6 +41,4 @@ const generate = (palette, _options) => {
|
||||
return expanded;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
generate,
|
||||
};
|
||||
export default generate;
|
||||
@@ -1,8 +1,8 @@
|
||||
const NexradLevel3Data = require('nexrad-level-3-data');
|
||||
const { products, productAbbreviations } = require('./products');
|
||||
const { draw } = require('./draw');
|
||||
const palletize = require('./palletize');
|
||||
const { writePngToFile } = require('./utils/file');
|
||||
import NexradLevel3Data from 'nexrad-level-3-data';
|
||||
import { products, productAbbreviations } from './products/index.mjs';
|
||||
import { draw } from './draw/index.mjs';
|
||||
import palletize from './palletize/index.mjs';
|
||||
import { writePngToFile } from './utils/file.mjs';
|
||||
|
||||
const plotAndData = (file, _options) => {
|
||||
const options = combineOptions(_options);
|
||||
@@ -69,7 +69,7 @@ const nullLogger = {
|
||||
error: () => {},
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
export {
|
||||
plot,
|
||||
writePngToFile,
|
||||
plotAndData,
|
||||
@@ -32,4 +32,4 @@ const closest = (match, palette, key) => {
|
||||
|
||||
const geometricDistance = (a, b) => a.reduce((acc, val, idx) => acc + (val - b[idx]) ** 2, 0);
|
||||
|
||||
module.exports = closest;
|
||||
export default closest;
|
||||
@@ -1,6 +1,6 @@
|
||||
// generate a palette with the number of steps provided
|
||||
const { createCanvas } = require('canvas');
|
||||
const crypto = require('crypto');
|
||||
import { createCanvas } from 'canvas';
|
||||
import crypto from 'crypto';
|
||||
|
||||
const generatePalette = (_sourcePalette, steps, background, product) => {
|
||||
// get palette from either color array only or object with color array
|
||||
@@ -63,4 +63,4 @@ const calcIntermediate = (a, b, num, den) => {
|
||||
return ((diff * num) / den + b);
|
||||
};
|
||||
|
||||
module.exports = generatePalette;
|
||||
export default generatePalette;
|
||||
@@ -1,8 +1,8 @@
|
||||
// palletize an image
|
||||
const { createCanvas } = require('canvas');
|
||||
const generatePalette = require('./generatepalette');
|
||||
const closest = require('./closest');
|
||||
const { DEFAULT_OPTIONS: DRAW_DEFAULT_OPTIONS } = require('../draw');
|
||||
import { createCanvas } from 'canvas';
|
||||
import generatePalette from './generatepalette.mjs';
|
||||
import closest from './closest.mjs';
|
||||
import { DEFAULT_OPTIONS as DRAW_DEFAULT_OPTIONS } from '../draw/index.mjs';
|
||||
|
||||
// default options
|
||||
const DEFAULT_OPTIONS = {
|
||||
@@ -61,4 +61,4 @@ const combineOptions = (_options, product) => {
|
||||
return options;
|
||||
};
|
||||
|
||||
module.exports = palletize;
|
||||
export default palletize;
|
||||
@@ -23,7 +23,7 @@ const palette = {
|
||||
thresholds: [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 140, 150, 160],
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
export {
|
||||
code,
|
||||
abbreviation,
|
||||
description,
|
||||
@@ -3,7 +3,7 @@ const abbreviation = 'DAA';
|
||||
const description = 'Digital One Hour Accumulation';
|
||||
|
||||
// same colors as 172
|
||||
const { colors } = require('../172').palette;
|
||||
const { colors } = (await import('../172/index.mjs')).palette;
|
||||
|
||||
const palette = {
|
||||
colors,
|
||||
@@ -12,7 +12,7 @@ const palette = {
|
||||
baseScale: 6.0,
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
export {
|
||||
code,
|
||||
abbreviation,
|
||||
description,
|
||||
@@ -29,7 +29,7 @@ const palette = {
|
||||
baseScale: 2.56,
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
export {
|
||||
code,
|
||||
abbreviation,
|
||||
description,
|
||||
@@ -23,7 +23,7 @@ const palette = {
|
||||
thresholds: [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 140, 150, 160],
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
export {
|
||||
code,
|
||||
abbreviation,
|
||||
description,
|
||||
@@ -22,7 +22,7 @@ const palette = [
|
||||
0, 0, 256,
|
||||
];
|
||||
|
||||
module.exports = {
|
||||
export {
|
||||
code,
|
||||
abbreviation,
|
||||
description,
|
||||
@@ -4,9 +4,9 @@ const description = 'Storm total precipitation';
|
||||
|
||||
// 4-bit palette
|
||||
// same as 78 N1P
|
||||
const { palette } = require('../78');
|
||||
const { palette } = await import('../78/index.mjs');
|
||||
|
||||
module.exports = {
|
||||
export {
|
||||
code,
|
||||
abbreviation,
|
||||
description,
|
||||
@@ -1,10 +1,8 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
import { glob } from 'glob';
|
||||
|
||||
// load all products in folder automatically
|
||||
const folders = fs.readdirSync(__dirname).filter((folder) => fs.lstatSync(path.join(__dirname, folder)).isDirectory());
|
||||
// eslint-disable-next-line import/no-dynamic-require, global-require
|
||||
const productsRaw = folders.map((folder) => require(path.join(__dirname, folder)));
|
||||
const allDescriptors = await glob('/descriptors/**/*.mjs', { root: import.meta.dirname, windowsPathsNoEscape: true });
|
||||
const productsRaw = await Promise.all(allDescriptors.map((descriptor) => import(`file:///${descriptor}`)));
|
||||
|
||||
// make up a list of products by integer type
|
||||
const products = {};
|
||||
@@ -16,7 +14,7 @@ productsRaw.forEach((product) => {
|
||||
// list of available product code abbreviations for type-checking
|
||||
const productAbbreviations = productsRaw.map((product) => product.abbreviation).flat();
|
||||
|
||||
module.exports = {
|
||||
export {
|
||||
products,
|
||||
productAbbreviations,
|
||||
};
|
||||
@@ -1,4 +1,4 @@
|
||||
const fs = require('fs');
|
||||
import fs from 'fs';
|
||||
// write a canvas to a Png file
|
||||
const writePngToFile = (fileName, canvas) => new Promise((resolve, reject) => {
|
||||
const writeStream = fs.createWriteStream(fileName);
|
||||
@@ -10,6 +10,7 @@ const writePngToFile = (fileName, canvas) => new Promise((resolve, reject) => {
|
||||
writeStream.on('error', (e) => reject(e));
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
export {
|
||||
// eslint-disable-next-line import/prefer-default-export
|
||||
writePngToFile,
|
||||
};
|
||||
Reference in new issue
Block a user