@loaders.gl/netcdf 3.1.3 → 4.0.0-alpha.5

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 (50) hide show
  1. package/dist/index.js +3 -7
  2. package/dist/index.js.map +1 -0
  3. package/dist/iobuffer/iobuffer.js +370 -425
  4. package/dist/iobuffer/iobuffer.js.map +1 -0
  5. package/dist/netcdf-loader.js +36 -46
  6. package/dist/netcdf-loader.js.map +1 -0
  7. package/dist/{es5/netcdfjs → netcdfjs}/LICENSE +0 -0
  8. package/dist/netcdfjs/netcdf-reader.js +126 -155
  9. package/dist/netcdfjs/netcdf-reader.js.map +1 -0
  10. package/dist/netcdfjs/netcdf-types.js +2 -2
  11. package/dist/{es5/netcdfjs → netcdfjs}/netcdf-types.js.map +0 -0
  12. package/dist/netcdfjs/read-data.js +26 -47
  13. package/dist/netcdfjs/read-data.js.map +1 -0
  14. package/dist/netcdfjs/read-header.js +173 -206
  15. package/dist/netcdfjs/read-header.js.map +1 -0
  16. package/dist/netcdfjs/read-type.js +117 -130
  17. package/dist/netcdfjs/read-type.js.map +1 -0
  18. package/package.json +5 -5
  19. package/dist/es5/index.js +0 -22
  20. package/dist/es5/index.js.map +0 -1
  21. package/dist/es5/iobuffer/iobuffer.js +0 -432
  22. package/dist/es5/iobuffer/iobuffer.js.map +0 -1
  23. package/dist/es5/netcdf-loader.js +0 -105
  24. package/dist/es5/netcdf-loader.js.map +0 -1
  25. package/dist/es5/netcdfjs/netcdf-reader.js +0 -207
  26. package/dist/es5/netcdfjs/netcdf-reader.js.map +0 -1
  27. package/dist/es5/netcdfjs/netcdf-types.js +0 -2
  28. package/dist/es5/netcdfjs/read-data.js +0 -38
  29. package/dist/es5/netcdfjs/read-data.js.map +0 -1
  30. package/dist/es5/netcdfjs/read-header.js +0 -207
  31. package/dist/es5/netcdfjs/read-header.js.map +0 -1
  32. package/dist/es5/netcdfjs/read-type.js +0 -142
  33. package/dist/es5/netcdfjs/read-type.js.map +0 -1
  34. package/dist/esm/index.js +0 -3
  35. package/dist/esm/index.js.map +0 -1
  36. package/dist/esm/iobuffer/iobuffer.js +0 -372
  37. package/dist/esm/iobuffer/iobuffer.js.map +0 -1
  38. package/dist/esm/netcdf-loader.js +0 -42
  39. package/dist/esm/netcdf-loader.js.map +0 -1
  40. package/dist/esm/netcdfjs/LICENSE +0 -24
  41. package/dist/esm/netcdfjs/netcdf-reader.js +0 -136
  42. package/dist/esm/netcdfjs/netcdf-reader.js.map +0 -1
  43. package/dist/esm/netcdfjs/netcdf-types.js +0 -2
  44. package/dist/esm/netcdfjs/netcdf-types.js.map +0 -1
  45. package/dist/esm/netcdfjs/read-data.js +0 -28
  46. package/dist/esm/netcdfjs/read-data.js.map +0 -1
  47. package/dist/esm/netcdfjs/read-header.js +0 -197
  48. package/dist/esm/netcdfjs/read-header.js.map +0 -1
  49. package/dist/esm/netcdfjs/read-type.js +0 -127
  50. package/dist/esm/netcdfjs/read-type.js.map +0 -1
@@ -1,140 +1,127 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.str2num = exports.num2bytes = exports.num2str = exports.readType = exports.TYPES = void 0;
4
- exports.TYPES = {
5
- BYTE: 1,
6
- CHAR: 2,
7
- SHORT: 3,
8
- INT: 4,
9
- FLOAT: 5,
10
- DOUBLE: 6
1
+ export const TYPES = {
2
+ BYTE: 1,
3
+ CHAR: 2,
4
+ SHORT: 3,
5
+ INT: 4,
6
+ FLOAT: 5,
7
+ DOUBLE: 6
11
8
  };
12
- /**
13
- * Given a type and a size reads the next element
14
- * @param buffer - Buffer for the file data
15
- * @param type - Type of the data to read
16
- * @param size - Size of the element to read
17
- * @return
18
- */
19
- function readType(buffer, type, size) {
20
- switch (type) {
21
- case exports.TYPES.BYTE:
22
- return buffer.readBytes(size);
23
- case exports.TYPES.CHAR:
24
- return trimNull(buffer.readChars(size));
25
- case exports.TYPES.SHORT:
26
- return readNumber(size, buffer.readInt16.bind(buffer));
27
- case exports.TYPES.INT:
28
- return readNumber(size, buffer.readInt32.bind(buffer));
29
- case exports.TYPES.FLOAT:
30
- return readNumber(size, buffer.readFloat32.bind(buffer));
31
- case exports.TYPES.DOUBLE:
32
- return readNumber(size, buffer.readFloat64.bind(buffer));
33
- /* istanbul ignore next */
34
- default:
35
- throw new Error(`NetCDF: non valid type ${type}`);
36
- }
9
+ export function readType(buffer, type, size) {
10
+ switch (type) {
11
+ case TYPES.BYTE:
12
+ return buffer.readBytes(size);
13
+
14
+ case TYPES.CHAR:
15
+ return trimNull(buffer.readChars(size));
16
+
17
+ case TYPES.SHORT:
18
+ return readNumber(size, buffer.readInt16.bind(buffer));
19
+
20
+ case TYPES.INT:
21
+ return readNumber(size, buffer.readInt32.bind(buffer));
22
+
23
+ case TYPES.FLOAT:
24
+ return readNumber(size, buffer.readFloat32.bind(buffer));
25
+
26
+ case TYPES.DOUBLE:
27
+ return readNumber(size, buffer.readFloat64.bind(buffer));
28
+
29
+ default:
30
+ throw new Error("NetCDF: non valid type ".concat(type));
31
+ }
37
32
  }
38
- exports.readType = readType;
39
- /**
40
- * Parse a number into their respective type
41
- * @param type - integer that represents the type
42
- * @return parsed value of the type
43
- */
44
- function num2str(type) {
45
- switch (Number(type)) {
46
- case exports.TYPES.BYTE:
47
- return 'byte';
48
- case exports.TYPES.CHAR:
49
- return 'char';
50
- case exports.TYPES.SHORT:
51
- return 'short';
52
- case exports.TYPES.INT:
53
- return 'int';
54
- case exports.TYPES.FLOAT:
55
- return 'float';
56
- case exports.TYPES.DOUBLE:
57
- return 'double';
58
- /* istanbul ignore next */
59
- default:
60
- return 'undefined';
61
- }
33
+ export function num2str(type) {
34
+ switch (Number(type)) {
35
+ case TYPES.BYTE:
36
+ return 'byte';
37
+
38
+ case TYPES.CHAR:
39
+ return 'char';
40
+
41
+ case TYPES.SHORT:
42
+ return 'short';
43
+
44
+ case TYPES.INT:
45
+ return 'int';
46
+
47
+ case TYPES.FLOAT:
48
+ return 'float';
49
+
50
+ case TYPES.DOUBLE:
51
+ return 'double';
52
+
53
+ default:
54
+ return 'undefined';
55
+ }
62
56
  }
63
- exports.num2str = num2str;
64
- /**
65
- * Parse a number type identifier to his size in bytes
66
- * @param type - integer that represents the type
67
- * @return size of the type
68
- */
69
- function num2bytes(type) {
70
- switch (Number(type)) {
71
- case exports.TYPES.BYTE:
72
- return 1;
73
- case exports.TYPES.CHAR:
74
- return 1;
75
- case exports.TYPES.SHORT:
76
- return 2;
77
- case exports.TYPES.INT:
78
- return 4;
79
- case exports.TYPES.FLOAT:
80
- return 4;
81
- case exports.TYPES.DOUBLE:
82
- return 8;
83
- /* istanbul ignore next */
84
- default:
85
- return -1;
86
- }
57
+ export function num2bytes(type) {
58
+ switch (Number(type)) {
59
+ case TYPES.BYTE:
60
+ return 1;
61
+
62
+ case TYPES.CHAR:
63
+ return 1;
64
+
65
+ case TYPES.SHORT:
66
+ return 2;
67
+
68
+ case TYPES.INT:
69
+ return 4;
70
+
71
+ case TYPES.FLOAT:
72
+ return 4;
73
+
74
+ case TYPES.DOUBLE:
75
+ return 8;
76
+
77
+ default:
78
+ return -1;
79
+ }
87
80
  }
88
- exports.num2bytes = num2bytes;
89
- /**
90
- * Reverse search of num2str
91
- * @param type string that represents the type
92
- * @return parsed value of the type
93
- */
94
- function str2num(type) {
95
- switch (String(type)) {
96
- case 'byte':
97
- return exports.TYPES.BYTE;
98
- case 'char':
99
- return exports.TYPES.CHAR;
100
- case 'short':
101
- return exports.TYPES.SHORT;
102
- case 'int':
103
- return exports.TYPES.INT;
104
- case 'float':
105
- return exports.TYPES.FLOAT;
106
- case 'double':
107
- return exports.TYPES.DOUBLE;
108
- /* istanbul ignore next */
109
- default:
110
- return -1;
111
- }
81
+ export function str2num(type) {
82
+ switch (String(type)) {
83
+ case 'byte':
84
+ return TYPES.BYTE;
85
+
86
+ case 'char':
87
+ return TYPES.CHAR;
88
+
89
+ case 'short':
90
+ return TYPES.SHORT;
91
+
92
+ case 'int':
93
+ return TYPES.INT;
94
+
95
+ case 'float':
96
+ return TYPES.FLOAT;
97
+
98
+ case 'double':
99
+ return TYPES.DOUBLE;
100
+
101
+ default:
102
+ return -1;
103
+ }
112
104
  }
113
- exports.str2num = str2num;
114
- /**
115
- * Auxiliary function to read numeric data
116
- * @param size - Size of the element to read
117
- * @param bufferReader - Function to read next value
118
- * @return
119
- */
105
+
120
106
  function readNumber(size, bufferReader) {
121
- if (size !== 1) {
122
- const numbers = new Array(size);
123
- for (let i = 0; i < size; i++) {
124
- numbers[i] = bufferReader();
125
- }
126
- return numbers;
107
+ if (size !== 1) {
108
+ const numbers = new Array(size);
109
+
110
+ for (let i = 0; i < size; i++) {
111
+ numbers[i] = bufferReader();
127
112
  }
128
- return bufferReader();
113
+
114
+ return numbers;
115
+ }
116
+
117
+ return bufferReader();
129
118
  }
130
- /**
131
- * Removes null terminate value
132
- * @param value - String to trim
133
- * @return - Trimmed string
134
- */
119
+
135
120
  function trimNull(value) {
136
- if (value.charCodeAt(value.length - 1) === 0) {
137
- return value.substring(0, value.length - 1);
138
- }
139
- return value;
121
+ if (value.charCodeAt(value.length - 1) === 0) {
122
+ return value.substring(0, value.length - 1);
123
+ }
124
+
125
+ return value;
140
126
  }
127
+ //# sourceMappingURL=read-type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/netcdfjs/read-type.ts"],"names":["TYPES","BYTE","CHAR","SHORT","INT","FLOAT","DOUBLE","readType","buffer","type","size","readBytes","trimNull","readChars","readNumber","readInt16","bind","readInt32","readFloat32","readFloat64","Error","num2str","Number","num2bytes","str2num","String","bufferReader","numbers","Array","i","value","charCodeAt","length","substring"],"mappings":"AAEA,OAAO,MAAMA,KAAK,GAAG;AACnBC,EAAAA,IAAI,EAAE,CADa;AAEnBC,EAAAA,IAAI,EAAE,CAFa;AAGnBC,EAAAA,KAAK,EAAE,CAHY;AAInBC,EAAAA,GAAG,EAAE,CAJc;AAKnBC,EAAAA,KAAK,EAAE,CALY;AAMnBC,E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AAY,EAAzB;AACD;;AACD,WAAOC,OAAP;AACD;;AACD,SAAOD,YAAY,EAAnB;AACD;;AAOD,SAASd,QAAT,CAAkBkB,KAAlB,EAAyC;AACvC,MAAIA,KAAK,CAACC,UAAN,CAAiBD,KAAK,CAACE,MAAN,GAAe,CAAhC,MAAuC,CAA3C,EAA8C;AAC5C,WAAOF,KAAK,CAACG,SAAN,CAAgB,CAAhB,EAAmBH,KAAK,CAACE,MAAN,GAAe,CAAlC,CAAP;AACD;;AACD,SAAOF,KAAP;AACD","sourcesContent":["import {IOBuffer} from '../iobuffer/iobuffer';\n\nexport const TYPES = {\n BYTE: 1,\n CHAR: 2,\n SHORT: 3,\n INT: 4,\n FLOAT: 5,\n DOUBLE: 6\n};\n\n/**\n * Given a type and a size reads the next element\n * @param buffer - Buffer for the file data\n * @param type - Type of the data to read\n * @param size - Size of the element to read\n * @return\n */\nexport function readType(\n buffer: IOBuffer,\n type: number,\n size: number\n): string | number | number[] | Uint8Array {\n switch (type) {\n case TYPES.BYTE:\n return buffer.readBytes(size);\n case TYPES.CHAR:\n return trimNull(buffer.readChars(size));\n case TYPES.SHORT:\n return readNumber(size, buffer.readInt16.bind(buffer));\n case TYPES.INT:\n return readNumber(size, buffer.readInt32.bind(buffer));\n case TYPES.FLOAT:\n return readNumber(size, buffer.readFloat32.bind(buffer));\n case TYPES.DOUBLE:\n return readNumber(size, buffer.readFloat64.bind(buffer));\n /* istanbul ignore next */\n default:\n throw new Error(`NetCDF: non valid type ${type}`);\n }\n}\n\n/**\n * Parse a number into their respective type\n * @param type - integer that represents the type\n * @return parsed value of the type\n */\nexport function num2str(type: number): string {\n switch (Number(type)) {\n case TYPES.BYTE:\n return 'byte';\n case TYPES.CHAR:\n return 'char';\n case TYPES.SHORT:\n return 'short';\n case TYPES.INT:\n return 'int';\n case TYPES.FLOAT:\n return 'float';\n case TYPES.DOUBLE:\n return 'double';\n /* istanbul ignore next */\n default:\n return 'undefined';\n }\n}\n\n/**\n * Parse a number type identifier to his size in bytes\n * @param type - integer that represents the type\n * @return size of the type\n */\nexport function num2bytes(type: number): number {\n switch (Number(type)) {\n case TYPES.BYTE:\n return 1;\n case TYPES.CHAR:\n return 1;\n case TYPES.SHORT:\n return 2;\n case TYPES.INT:\n return 4;\n case TYPES.FLOAT:\n return 4;\n case TYPES.DOUBLE:\n return 8;\n /* istanbul ignore next */\n default:\n return -1;\n }\n}\n\n/**\n * Reverse search of num2str\n * @param type string that represents the type\n * @return parsed value of the type\n */\nexport function str2num(type: string): number {\n switch (String(type)) {\n case 'byte':\n return TYPES.BYTE;\n case 'char':\n return TYPES.CHAR;\n case 'short':\n return TYPES.SHORT;\n case 'int':\n return TYPES.INT;\n case 'float':\n return TYPES.FLOAT;\n case 'double':\n return TYPES.DOUBLE;\n /* istanbul ignore next */\n default:\n return -1;\n }\n}\n\n/**\n * Auxiliary function to read numeric data\n * @param size - Size of the element to read\n * @param bufferReader - Function to read next value\n * @return\n */\nfunction readNumber(size: number, bufferReader: () => number): number | number[] {\n if (size !== 1) {\n const numbers = new Array(size);\n for (let i = 0; i < size; i++) {\n numbers[i] = bufferReader();\n }\n return numbers;\n }\n return bufferReader();\n}\n\n/**\n * Removes null terminate value\n * @param value - String to trim\n * @return - Trimmed string\n */\nfunction trimNull(value: string): string {\n if (value.charCodeAt(value.length - 1) === 0) {\n return value.substring(0, value.length - 1);\n }\n return value;\n}\n"],"file":"read-type.js"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@loaders.gl/netcdf",
3
3
  "description": "Loader for NetCDF",
4
- "version": "3.1.3",
4
+ "version": "4.0.0-alpha.5",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -17,8 +17,8 @@
17
17
  "NetCDF"
18
18
  ],
19
19
  "types": "dist/index.d.ts",
20
- "main": "dist/es5/index.js",
21
- "module": "dist/esm/index.js",
20
+ "main": "dist/index.js",
21
+ "module": "dist/index.js",
22
22
  "sideEffects": false,
23
23
  "files": [
24
24
  "src",
@@ -30,7 +30,7 @@
30
30
  "build-bundle": "esbuild src/bundle.ts --bundle --outfile=dist/dist.min.js"
31
31
  },
32
32
  "dependencies": {
33
- "@loaders.gl/loader-utils": "3.1.3"
33
+ "@loaders.gl/loader-utils": "4.0.0-alpha.5"
34
34
  },
35
- "gitHead": "4a690c369779346d73c9a27395d1c08d77d279a4"
35
+ "gitHead": "7a71a54bdf1ddf985cc3af3db90b82e7fa97d025"
36
36
  }
package/dist/es5/index.js DELETED
@@ -1,22 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "NetCDFReader", {
7
- enumerable: true,
8
- get: function get() {
9
- return _netcdfReader.NetCDFReader;
10
- }
11
- });
12
- Object.defineProperty(exports, "NetCDFLoader", {
13
- enumerable: true,
14
- get: function get() {
15
- return _netcdfLoader.NetCDFLoader;
16
- }
17
- });
18
-
19
- var _netcdfReader = require("./netcdfjs/netcdf-reader");
20
-
21
- var _netcdfLoader = require("./netcdf-loader");
22
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;AAEA","sourcesContent":["export {NetCDFReader} from './netcdfjs/netcdf-reader';\n\nexport {NetCDFLoader} from './netcdf-loader';\n"],"file":"index.js"}