@loaders.gl/schema 3.1.0-alpha.4 → 3.1.0-beta.3

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 (183) hide show
  1. package/dist/bundle.d.ts +2 -0
  2. package/dist/bundle.d.ts.map +1 -0
  3. package/dist/bundle.js +1289 -0
  4. package/dist/category/common.d.ts +20 -0
  5. package/dist/category/common.d.ts.map +1 -0
  6. package/dist/category/common.js +10 -0
  7. package/dist/category/gis.d.ts +50 -0
  8. package/dist/category/gis.d.ts.map +1 -0
  9. package/dist/category/gis.js +2 -0
  10. package/dist/category/mesh/convert-mesh.d.ts +15 -0
  11. package/dist/category/mesh/convert-mesh.d.ts.map +1 -0
  12. package/dist/category/mesh/convert-mesh.js +39 -0
  13. package/dist/category/mesh/deduce-mesh-schema.d.ts +24 -0
  14. package/dist/category/mesh/deduce-mesh-schema.d.ts.map +1 -0
  15. package/dist/category/mesh/deduce-mesh-schema.js +62 -0
  16. package/dist/category/mesh/mesh-to-arrow-table.d.ts +1 -0
  17. package/dist/category/mesh/mesh-to-arrow-table.d.ts.map +1 -0
  18. package/dist/category/mesh/mesh-to-arrow-table.js +44 -0
  19. package/dist/category/mesh/mesh-types.d.ts +50 -0
  20. package/dist/category/mesh/mesh-types.d.ts.map +1 -0
  21. package/dist/category/mesh/mesh-types.js +2 -0
  22. package/dist/category/mesh/mesh-utils.d.ts +23 -0
  23. package/dist/category/mesh/mesh-utils.d.ts.map +1 -0
  24. package/dist/category/mesh/mesh-utils.js +51 -0
  25. package/dist/category/table/deduce-table-schema.d.ts +9 -0
  26. package/dist/category/table/deduce-table-schema.d.ts.map +1 -0
  27. package/dist/category/table/deduce-table-schema.js +106 -0
  28. package/dist/category/table/table-types.d.ts +78 -0
  29. package/dist/category/table/table-types.d.ts.map +1 -0
  30. package/dist/category/table/table-types.js +2 -0
  31. package/dist/es5/bundle.js +1 -1
  32. package/dist/es5/bundle.js.map +1 -1
  33. package/dist/es5/category/mesh/convert-mesh.js +2 -18
  34. package/dist/es5/category/mesh/convert-mesh.js.map +1 -1
  35. package/dist/es5/category/mesh/deduce-mesh-schema.js +9 -9
  36. package/dist/es5/category/mesh/deduce-mesh-schema.js.map +1 -1
  37. package/dist/es5/category/mesh/mesh-to-arrow-table.js +0 -38
  38. package/dist/es5/category/mesh/mesh-to-arrow-table.js.map +1 -1
  39. package/dist/es5/category/mesh/mesh-utils.js +16 -16
  40. package/dist/es5/category/mesh/mesh-utils.js.map +1 -1
  41. package/dist/es5/category/table/deduce-table-schema.js +9 -9
  42. package/dist/es5/category/table/deduce-table-schema.js.map +1 -1
  43. package/dist/es5/index.js +53 -53
  44. package/dist/es5/index.js.map +1 -1
  45. package/dist/es5/lib/arrow/arrow-like-type-utils.js +1 -1
  46. package/dist/es5/lib/arrow/arrow-like-type-utils.js.map +1 -1
  47. package/dist/es5/lib/arrow/arrow-type-utils.js +0 -70
  48. package/dist/es5/lib/arrow/arrow-type-utils.js.map +1 -1
  49. package/dist/es5/lib/arrow/get-type-info.js +4 -4
  50. package/dist/es5/lib/arrow/get-type-info.js.map +1 -1
  51. package/dist/es5/lib/batches/base-table-batch-aggregator.js +42 -53
  52. package/dist/es5/lib/batches/base-table-batch-aggregator.js.map +1 -1
  53. package/dist/es5/lib/batches/columnar-table-batch-aggregator.js +71 -90
  54. package/dist/es5/lib/batches/columnar-table-batch-aggregator.js.map +1 -1
  55. package/dist/es5/lib/batches/row-table-batch-aggregator.js +59 -70
  56. package/dist/es5/lib/batches/row-table-batch-aggregator.js.map +1 -1
  57. package/dist/es5/lib/batches/table-batch-builder.js +113 -133
  58. package/dist/es5/lib/batches/table-batch-builder.js.map +1 -1
  59. package/dist/es5/lib/schema/impl/enum.js +1 -1
  60. package/dist/es5/lib/schema/impl/field.js +19 -32
  61. package/dist/es5/lib/schema/impl/field.js.map +1 -1
  62. package/dist/es5/lib/schema/impl/schema.js +54 -119
  63. package/dist/es5/lib/schema/impl/schema.js.map +1 -1
  64. package/dist/es5/lib/schema/impl/type.js +395 -728
  65. package/dist/es5/lib/schema/impl/type.js.map +1 -1
  66. package/dist/es5/lib/schema/{index.js → schema.js} +38 -38
  67. package/dist/es5/lib/schema/schema.js.map +1 -0
  68. package/dist/es5/lib/schema-utils/deduce-column-type.js.map +1 -1
  69. package/dist/es5/lib/utils/async-queue.js +81 -164
  70. package/dist/es5/lib/utils/async-queue.js.map +1 -1
  71. package/dist/es5/lib/utils/row-utils.js +4 -4
  72. package/dist/es5/lib/utils/row-utils.js.map +1 -1
  73. package/dist/esm/category/mesh/convert-mesh.js +1 -8
  74. package/dist/esm/category/mesh/convert-mesh.js.map +1 -1
  75. package/dist/esm/category/mesh/deduce-mesh-schema.js +1 -1
  76. package/dist/esm/category/mesh/deduce-mesh-schema.js.map +1 -1
  77. package/dist/esm/category/mesh/mesh-to-arrow-table.js +0 -29
  78. package/dist/esm/category/mesh/mesh-to-arrow-table.js.map +1 -1
  79. package/dist/esm/category/table/deduce-table-schema.js.map +1 -1
  80. package/dist/esm/index.js +1 -1
  81. package/dist/esm/index.js.map +1 -1
  82. package/dist/esm/lib/arrow/arrow-like-type-utils.js +1 -1
  83. package/dist/esm/lib/arrow/arrow-like-type-utils.js.map +1 -1
  84. package/dist/esm/lib/arrow/arrow-type-utils.js +0 -60
  85. package/dist/esm/lib/arrow/arrow-type-utils.js.map +1 -1
  86. package/dist/esm/lib/arrow/get-type-info.js +1 -1
  87. package/dist/esm/lib/arrow/get-type-info.js.map +1 -1
  88. package/dist/esm/lib/batches/base-table-batch-aggregator.js.map +1 -1
  89. package/dist/esm/lib/batches/columnar-table-batch-aggregator.js.map +1 -1
  90. package/dist/esm/lib/batches/row-table-batch-aggregator.js.map +1 -1
  91. package/dist/esm/lib/batches/table-batch-builder.js.map +1 -1
  92. package/dist/esm/lib/schema/impl/field.js +1 -1
  93. package/dist/esm/lib/schema/impl/field.js.map +1 -1
  94. package/dist/esm/lib/schema/impl/schema.js.map +1 -1
  95. package/dist/esm/lib/schema/impl/type.js +8 -8
  96. package/dist/esm/lib/schema/impl/type.js.map +1 -1
  97. package/dist/esm/lib/schema/{index.js → schema.js} +1 -1
  98. package/dist/esm/lib/schema/schema.js.map +1 -0
  99. package/dist/esm/lib/schema-utils/deduce-column-type.js.map +1 -1
  100. package/dist/esm/lib/utils/async-queue.js.map +1 -1
  101. package/dist/index.d.ts +23 -0
  102. package/dist/index.d.ts.map +1 -0
  103. package/dist/index.js +75 -0
  104. package/dist/lib/arrow/arrow-like-type-utils.d.ts +4 -0
  105. package/dist/lib/arrow/arrow-like-type-utils.d.ts.map +1 -0
  106. package/dist/lib/arrow/arrow-like-type-utils.js +27 -0
  107. package/dist/lib/arrow/arrow-type-utils.d.ts +1 -0
  108. package/dist/lib/arrow/arrow-type-utils.d.ts.map +1 -0
  109. package/dist/lib/arrow/arrow-type-utils.js +70 -0
  110. package/dist/lib/arrow/get-type-info.d.ts +14 -0
  111. package/dist/lib/arrow/get-type-info.d.ts.map +1 -0
  112. package/dist/lib/arrow/get-type-info.js +28 -0
  113. package/dist/lib/batches/base-table-batch-aggregator.d.ts +19 -0
  114. package/dist/lib/batches/base-table-batch-aggregator.d.ts.map +1 -0
  115. package/dist/lib/batches/base-table-batch-aggregator.js +58 -0
  116. package/dist/lib/batches/columnar-table-batch-aggregator.d.ts +23 -0
  117. package/dist/lib/batches/columnar-table-batch-aggregator.d.ts.map +1 -0
  118. package/dist/lib/batches/columnar-table-batch-aggregator.js +90 -0
  119. package/dist/lib/batches/row-table-batch-aggregator.d.ts +22 -0
  120. package/dist/lib/batches/row-table-batch-aggregator.d.ts.map +1 -0
  121. package/dist/lib/batches/row-table-batch-aggregator.js +79 -0
  122. package/dist/lib/batches/table-batch-aggregator.d.ts +25 -0
  123. package/dist/lib/batches/table-batch-aggregator.d.ts.map +1 -0
  124. package/dist/lib/batches/table-batch-aggregator.js +2 -0
  125. package/dist/lib/batches/table-batch-builder.d.ts +53 -0
  126. package/dist/lib/batches/table-batch-builder.d.ts.map +1 -0
  127. package/dist/lib/batches/table-batch-builder.js +153 -0
  128. package/dist/lib/schema/impl/enum.d.ts +92 -0
  129. package/dist/lib/schema/impl/enum.d.ts.map +1 -0
  130. package/dist/lib/schema/impl/enum.js +97 -0
  131. package/dist/lib/schema/impl/field.d.ts +19 -0
  132. package/dist/lib/schema/impl/field.d.ts.map +1 -0
  133. package/dist/lib/schema/impl/field.js +32 -0
  134. package/dist/lib/schema/impl/schema.d.ts +16 -0
  135. package/dist/lib/schema/impl/schema.d.ts.map +1 -0
  136. package/dist/lib/schema/impl/schema.js +83 -0
  137. package/dist/lib/schema/impl/type.d.ts +176 -0
  138. package/dist/lib/schema/impl/type.d.ts.map +1 -0
  139. package/dist/lib/schema/impl/type.js +462 -0
  140. package/dist/lib/schema/schema.d.ts +5 -0
  141. package/dist/lib/schema/schema.d.ts.map +1 -0
  142. package/dist/lib/schema/schema.js +90 -0
  143. package/dist/lib/schema-utils/deduce-column-type.d.ts +3 -0
  144. package/dist/lib/schema-utils/deduce-column-type.d.ts.map +1 -0
  145. package/dist/lib/schema-utils/deduce-column-type.js +92 -0
  146. package/dist/lib/utils/assert.d.ts +2 -0
  147. package/dist/lib/utils/assert.d.ts.map +1 -0
  148. package/dist/lib/utils/assert.js +12 -0
  149. package/dist/lib/utils/async-queue.d.ts +18 -0
  150. package/dist/lib/utils/async-queue.d.ts.map +1 -0
  151. package/dist/lib/utils/async-queue.js +92 -0
  152. package/dist/lib/utils/row-utils.d.ts +9 -0
  153. package/dist/lib/utils/row-utils.d.ts.map +1 -0
  154. package/dist/lib/utils/row-utils.js +33 -0
  155. package/dist/types.d.ts +8 -0
  156. package/dist/types.d.ts.map +1 -0
  157. package/dist/types.js +2 -0
  158. package/package.json +5 -7
  159. package/src/category/common.ts +2 -1
  160. package/src/category/mesh/convert-mesh.ts +6 -6
  161. package/src/category/mesh/deduce-mesh-schema.ts +1 -1
  162. package/src/category/mesh/mesh-to-arrow-table.ts +4 -2
  163. package/src/category/mesh/mesh-types.ts +1 -1
  164. package/src/category/table/deduce-table-schema.ts +1 -1
  165. package/src/category/table/table-types.ts +5 -2
  166. package/src/index.ts +1 -1
  167. package/src/lib/arrow/arrow-like-type-utils.ts +11 -1
  168. package/src/lib/arrow/arrow-type-utils.ts +2 -0
  169. package/src/lib/arrow/get-type-info.ts +1 -1
  170. package/src/lib/batches/base-table-batch-aggregator.ts +1 -1
  171. package/src/lib/batches/columnar-table-batch-aggregator.ts +1 -1
  172. package/src/lib/batches/row-table-batch-aggregator.ts +1 -1
  173. package/src/lib/batches/table-batch-aggregator.ts +1 -1
  174. package/src/lib/batches/table-batch-builder.ts +2 -2
  175. package/src/lib/schema/impl/schema.ts +2 -2
  176. package/src/lib/schema/impl/type.ts +2 -2
  177. package/src/lib/schema/{index.ts → schema.ts} +0 -0
  178. package/src/lib/schema-utils/deduce-column-type.ts +6 -2
  179. package/src/lib/utils/async-queue.ts +7 -4
  180. package/dist/dist.min.js +0 -2
  181. package/dist/dist.min.js.map +0 -1
  182. package/dist/es5/lib/schema/index.js.map +0 -1
  183. package/dist/esm/lib/schema/index.js.map +0 -1
@@ -0,0 +1,18 @@
1
+ export default class AsyncQueue<T> {
2
+ private _values;
3
+ private _settlers;
4
+ private _closed;
5
+ constructor();
6
+ close(): void;
7
+ [Symbol.asyncIterator](): AsyncIterator<T>;
8
+ enqueue(value: T | Error): void;
9
+ /**
10
+ * @returns a Promise for an IteratorResult
11
+ */
12
+ next(): Promise<any>;
13
+ }
14
+ /**
15
+ * @returns a Promise for an Array with the elements in `asyncIterable`
16
+ */
17
+ export declare function takeAsync(asyncIterable: AsyncIterable<any>, count?: number): Promise<any[]>;
18
+ //# sourceMappingURL=async-queue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async-queue.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/async-queue.ts"],"names":[],"mappings":"AAcA,MAAM,CAAC,OAAO,OAAO,UAAU,CAAC,CAAC;IAC/B,OAAO,CAAC,OAAO,CAAwB;IACvC,OAAO,CAAC,SAAS,CAA8E;IAC/F,OAAO,CAAC,OAAO,CAAU;;IAazB,KAAK,IAAI,IAAI;IAOb,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,aAAa,CAAC,CAAC,CAAC;IAI1C,OAAO,CAAC,KAAK,EAAE,CAAC,GAAG,KAAK,GAAG,IAAI;IAoB/B;;OAEG;IACH,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC;CAoBrB;AAED;;GAEG;AACH,wBAAsB,SAAS,CAC7B,aAAa,EAAE,aAAa,CAAC,GAAG,CAAC,EACjC,KAAK,SAAW,GACf,OAAO,CAAC,GAAG,EAAE,CAAC,CAWhB"}
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ // From https://github.com/rauschma/async-iter-demo/tree/master/src under MIT license
3
+ // http://2ality.com/2016/10/asynchronous-iteration.html
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.takeAsync = void 0;
6
+ class ArrayQueue extends Array {
7
+ enqueue(value) {
8
+ // Add at the end
9
+ return this.push(value);
10
+ }
11
+ dequeue() {
12
+ // Remove first element
13
+ return this.shift();
14
+ }
15
+ }
16
+ class AsyncQueue {
17
+ constructor() {
18
+ // enqueues > dequeues
19
+ this._values = new ArrayQueue();
20
+ // dequeues > enqueues
21
+ this._settlers = new ArrayQueue();
22
+ this._closed = false;
23
+ }
24
+ close() {
25
+ while (this._settlers.length > 0) {
26
+ this._settlers.dequeue().resolve({ done: true });
27
+ }
28
+ this._closed = true;
29
+ }
30
+ [Symbol.asyncIterator]() {
31
+ return this;
32
+ }
33
+ enqueue(value) {
34
+ if (this._closed) {
35
+ throw new Error('Closed');
36
+ }
37
+ if (this._settlers.length > 0) {
38
+ if (this._values.length > 0) {
39
+ throw new Error('Illegal internal state');
40
+ }
41
+ const settler = this._settlers.dequeue();
42
+ if (value instanceof Error) {
43
+ settler.reject(value);
44
+ }
45
+ else {
46
+ settler.resolve({ value });
47
+ }
48
+ }
49
+ else {
50
+ this._values.enqueue(value);
51
+ }
52
+ }
53
+ /**
54
+ * @returns a Promise for an IteratorResult
55
+ */
56
+ next() {
57
+ if (this._values.length > 0) {
58
+ const value = this._values.dequeue();
59
+ if (value instanceof Error) {
60
+ return Promise.reject(value);
61
+ }
62
+ return Promise.resolve({ value });
63
+ }
64
+ if (this._closed) {
65
+ if (this._settlers.length > 0) {
66
+ throw new Error('Illegal internal state');
67
+ }
68
+ return Promise.resolve({ done: true });
69
+ }
70
+ // Wait for new values to be enqueued
71
+ return new Promise((resolve, reject) => {
72
+ this._settlers.enqueue({ resolve, reject });
73
+ });
74
+ }
75
+ }
76
+ exports.default = AsyncQueue;
77
+ /**
78
+ * @returns a Promise for an Array with the elements in `asyncIterable`
79
+ */
80
+ async function takeAsync(asyncIterable, count = Infinity) {
81
+ const result = [];
82
+ const iterator = asyncIterable[Symbol.asyncIterator]();
83
+ while (result.length < count) {
84
+ const { value, done } = await iterator.next();
85
+ if (done) {
86
+ break;
87
+ }
88
+ result.push(value);
89
+ }
90
+ return result;
91
+ }
92
+ exports.takeAsync = takeAsync;
@@ -0,0 +1,9 @@
1
+ /** Convert an object row to an array row */
2
+ export declare function convertToObjectRow(arrayRow: any[], headers: string[]): {
3
+ [columnName: string]: any;
4
+ };
5
+ /** Convert an object row to an array row */
6
+ export declare function convertToArrayRow(objectRow: {
7
+ [columnName: string]: any;
8
+ }, headers: string[]): any[];
9
+ //# sourceMappingURL=row-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"row-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/row-utils.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,GAAG,EAAE,EACf,OAAO,EAAE,MAAM,EAAE,GAChB;IAAC,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,CAAA;CAAC,CAY7B;AAED,4CAA4C;AAC5C,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE;IAAC,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,CAAA;CAAC,EACtC,OAAO,EAAE,MAAM,EAAE,GAChB,GAAG,EAAE,CAYP"}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.convertToArrayRow = exports.convertToObjectRow = void 0;
4
+ /** Convert an object row to an array row */
5
+ function convertToObjectRow(arrayRow, headers) {
6
+ if (!arrayRow) {
7
+ throw new Error('null row');
8
+ }
9
+ if (!headers) {
10
+ throw new Error('no headers');
11
+ }
12
+ const objectRow = {};
13
+ for (let i = 0; i < headers.length; i++) {
14
+ objectRow[headers[i]] = arrayRow[i];
15
+ }
16
+ return objectRow;
17
+ }
18
+ exports.convertToObjectRow = convertToObjectRow;
19
+ /** Convert an object row to an array row */
20
+ function convertToArrayRow(objectRow, headers) {
21
+ if (!objectRow) {
22
+ throw new Error('null row');
23
+ }
24
+ if (!headers) {
25
+ throw new Error('no headers');
26
+ }
27
+ const arrayRow = new Array(headers.length);
28
+ for (let i = 0; i < headers.length; i++) {
29
+ arrayRow[i] = objectRow[headers[i]];
30
+ }
31
+ return arrayRow;
32
+ }
33
+ exports.convertToArrayRow = convertToArrayRow;
@@ -0,0 +1,8 @@
1
+ /** Any typed array */
2
+ export declare type TypedArray = Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array;
3
+ export declare type BigTypedArray = TypedArray | BigInt64Array | BigUint64Array;
4
+ /** Any numeric array: typed array or `number[]` */
5
+ export declare type NumberArray = number[] | TypedArray;
6
+ /** Any array: typed array or js array (`any[]`) */
7
+ export declare type AnyArray = any[] | TypedArray;
8
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,sBAAsB;AACtB,oBAAY,UAAU,GAClB,SAAS,GACT,UAAU,GACV,UAAU,GACV,WAAW,GACX,UAAU,GACV,WAAW,GACX,iBAAiB,GACjB,YAAY,GACZ,YAAY,CAAC;AAEjB,oBAAY,aAAa,GAAG,UAAU,GAAG,aAAa,GAAG,cAAc,CAAC;AAExE,mDAAmD;AACnD,oBAAY,WAAW,GAAG,MAAM,EAAE,GAAG,UAAU,CAAC;AAEhD,mDAAmD;AACnD,oBAAY,QAAQ,GAAG,GAAG,EAAE,GAAG,UAAU,CAAC"}
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/schema",
3
- "version": "3.1.0-alpha.4",
3
+ "version": "3.1.0-beta.3",
4
4
  "description": "Table format APIs for JSON, CSV, etc...",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -18,7 +18,7 @@
18
18
  "point cloud",
19
19
  "PLY"
20
20
  ],
21
- "types": "src/index.ts",
21
+ "types": "dist/index.d.ts",
22
22
  "main": "dist/es5/index.js",
23
23
  "module": "dist/esm/index.js",
24
24
  "sideEffects": false,
@@ -29,12 +29,10 @@
29
29
  ],
30
30
  "scripts": {
31
31
  "pre-build": "npm run build-bundle",
32
- "build-bundle": "webpack --display=minimal --config ../../scripts/webpack/bundle.js"
32
+ "build-bundle": "esbuild src/bundle.ts --bundle --outfile=dist/bundle.js"
33
33
  },
34
34
  "dependencies": {
35
- "@types/geojson": "^7946.0.7",
36
- "apache-arrow": "^4.0.0",
37
- "d3-dsv": "^1.2.0"
35
+ "@types/geojson": "^7946.0.7"
38
36
  },
39
- "gitHead": "e309784af37ef9f3640c7733c7851124c72e1fa3"
37
+ "gitHead": "3537c382b3ea4e092b24b6f94c3edee72076039c"
40
38
  }
@@ -1,4 +1,5 @@
1
- import type {RecordBatch} from 'apache-arrow';
1
+ // import type {RecordBatch} from 'apache-arrow';
2
+ type RecordBatch = any;
2
3
 
3
4
  export type Field = any;
4
5
 
@@ -1,6 +1,6 @@
1
1
  import type {Mesh} from './mesh-types';
2
2
  import type {ColumnarTable, ArrowTable} from '../table/table-types';
3
- import {convertMeshToArrowTable} from './mesh-to-arrow-table';
3
+ // import {convertMeshToArrowTable} from './mesh-to-arrow-table';
4
4
 
5
5
  type TargetShape = 'mesh' | 'columnar-table' | 'arrow-table';
6
6
 
@@ -17,11 +17,11 @@ export function convertMesh(
17
17
  return mesh;
18
18
  case 'columnar-table':
19
19
  return convertMeshToColumnarTable(mesh);
20
- case 'arrow-table':
21
- return {
22
- shape: 'arrow-table',
23
- data: convertMeshToArrowTable(mesh)
24
- };
20
+ // case 'arrow-table':
21
+ // return {
22
+ // shape: 'arrow-table',
23
+ // data: convertMeshToArrowTable(mesh)
24
+ // };
25
25
  default:
26
26
  throw new Error(`Unsupported shape ${options?.shape}`);
27
27
  }
@@ -1,5 +1,5 @@
1
1
  import {MeshAttribute, MeshAttributes} from './mesh-types';
2
- import {Schema, Field, FixedSizeList} from '../../lib/schema';
2
+ import {Schema, Field, FixedSizeList} from '../../lib/schema/schema';
3
3
  import {getArrowTypeFromTypedArray} from '../../lib/arrow/arrow-like-type-utils';
4
4
 
5
5
  /**
@@ -1,3 +1,4 @@
1
+ /*
1
2
  import {
2
3
  Table,
3
4
  Schema,
@@ -6,7 +7,7 @@ import {
6
7
  Field,
7
8
  Data,
8
9
  FixedSizeListVector
9
- } from 'apache-arrow/Arrow.dom';
10
+ } from 'apache-arrow';
10
11
  import {AbstractVector} from 'apache-arrow/vector';
11
12
  import {getArrowType, getArrowVector} from '../../lib/arrow/arrow-type-utils';
12
13
  import type {Mesh} from './mesh-types';
@@ -18,7 +19,7 @@ import {makeMeshAttributeMetadata} from './deduce-mesh-schema';
18
19
  * @param metadata
19
20
  * @param batchSize
20
21
  * @returns
21
- */
22
+ *
22
23
  export function convertMeshToArrowTable(mesh: Mesh, batchSize?: number): Table {
23
24
  const vectors: AbstractVector[] = [];
24
25
  const fields: Field[] = [];
@@ -39,3 +40,4 @@ export function convertMeshToArrowTable(mesh: Mesh, batchSize?: number): Table {
39
40
  const table = new Table(schema, recordBatch);
40
41
  return table;
41
42
  }
43
+ */
@@ -1,4 +1,4 @@
1
- import type {Schema} from '../../lib/schema';
1
+ import type {Schema} from '../../lib/schema/schema';
2
2
  import type {TypedArray} from '../../types';
3
3
  import type {ColumnarTable, ArrowTable} from '../table/table-types';
4
4
 
@@ -14,7 +14,7 @@ import {
14
14
  // Utf8,
15
15
  // TimestampMillisecond,
16
16
  // Null
17
- } from '../../lib/schema';
17
+ } from '../../lib/schema/schema';
18
18
 
19
19
  // const TYPED_ARRAY_TO_TYPE = {
20
20
  // Int8Array: new Int8(),
@@ -1,7 +1,10 @@
1
- import type {Schema} from '../../lib/schema';
2
- import type {Table as ApacheArrowTable, RecordBatch} from 'apache-arrow/Arrow.dom';
1
+ import type {Schema} from '../../lib/schema/schema';
3
2
  import type {AnyArray} from '../../types';
4
3
  import type {Batch} from '../common';
4
+ // TODO Arrow dependency causes issues
5
+ // import type {Table as ApacheArrowTable, RecordBatch} from 'apache-arrow/Arrow.dom';
6
+ type ApacheArrowTable = any;
7
+ type RecordBatch = any;
5
8
 
6
9
  /** A general table */
7
10
  export interface Table {
package/src/index.ts CHANGED
@@ -112,7 +112,7 @@ export {
112
112
  IntervalYearMonth,
113
113
  FixedSizeList,
114
114
  Struct
115
- } from './lib/schema';
115
+ } from './lib/schema/schema';
116
116
 
117
117
  // EXPERIMENTAL APIs
118
118
 
@@ -1,5 +1,15 @@
1
1
  import type {TypedArray} from '../../types';
2
- import {DataType, Float32, Float64, Int16, Int32, Int8, Uint16, Uint32, Uint8} from '../schema';
2
+ import {
3
+ DataType,
4
+ Float32,
5
+ Float64,
6
+ Int16,
7
+ Int32,
8
+ Int8,
9
+ Uint16,
10
+ Uint32,
11
+ Uint8
12
+ } from '../schema/schema';
3
13
 
4
14
  export function getArrowTypeFromTypedArray(array: TypedArray): DataType {
5
15
  switch (array.constructor) {
@@ -1,3 +1,4 @@
1
+ /*
1
2
  import type {TypedArray} from '../../types';
2
3
  import {
3
4
  DataType,
@@ -65,3 +66,4 @@ export function getArrowVector(array: TypedArray): AbstractVector {
65
66
  throw new Error('array type not supported');
66
67
  }
67
68
  }
69
+ */
@@ -1,4 +1,4 @@
1
- import {Type} from '../schema';
1
+ import {Type} from '../schema/schema';
2
2
  import {AnyArray} from '../../types';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import type {Schema} from '../schema';
1
+ import type {Schema} from '../schema/schema';
2
2
  import type {TableBatch} from '../../category/table/table-types';
3
3
  import {TableBatchAggregator, TableBatchOptions} from './table-batch-aggregator';
4
4
 
@@ -1,4 +1,4 @@
1
- import type {Schema} from '../schema';
1
+ import type {Schema} from '../schema/schema';
2
2
  import type {ColumnarTableBatch, ArrowTableBatch} from '../../category/table/table-types';
3
3
  import {TableBatchAggregator} from './table-batch-aggregator';
4
4
 
@@ -1,4 +1,4 @@
1
- import type {Schema} from '../schema';
1
+ import type {Schema} from '../schema/schema';
2
2
  import type {TableBatch} from '../../category/table/table-types';
3
3
  // import type {ArrayRowTableBatch, ObjectRowTableBatch} from '../../category/table';
4
4
  import {convertToArrayRow, convertToObjectRow} from '../utils/row-utils';
@@ -1,4 +1,4 @@
1
- import type {Schema} from '../schema';
1
+ import type {Schema} from '../schema/schema';
2
2
  import type {TableBatch} from '../../category/table/table-types';
3
3
 
4
4
  export interface TableBatchOptions {
@@ -1,4 +1,4 @@
1
- import type {Schema} from '../schema';
1
+ import type {Schema} from '../schema/schema';
2
2
  import type {TableBatch} from '../../category/table/table-types';
3
3
  import type {TableBatchAggregator, TableBatchConstructor} from './table-batch-aggregator';
4
4
  import BaseTableBatchAggregator from './base-table-batch-aggregator';
@@ -114,7 +114,7 @@ export default class TableBatchBuilder {
114
114
 
115
115
  // INTERNAL
116
116
 
117
- _estimateRowMB(row) {
117
+ _estimateRowMB(row: any[] | object): number {
118
118
  return Array.isArray(row) ? row.length * 8 : Object.keys(row).length * 8;
119
119
  }
120
120
 
@@ -82,8 +82,8 @@ export default class Schema {
82
82
  }
83
83
 
84
84
  // Warn if any duplicated field names
85
- function checkNames(fields) {
86
- const usedNames = {};
85
+ function checkNames(fields: Field[]): void {
86
+ const usedNames: Record<string, boolean> = {};
87
87
  for (const field of fields) {
88
88
  if (usedNames[field.name]) {
89
89
  // eslint-disable-next-line
@@ -333,10 +333,10 @@ const TimeUnit = {
333
333
  };
334
334
 
335
335
  export class Time extends DataType {
336
- readonly unit: number;
336
+ readonly unit: any;
337
337
  readonly bitWidth: number;
338
338
 
339
- constructor(unit, bitWidth) {
339
+ constructor(unit: any, bitWidth: number) {
340
340
  super();
341
341
  this.unit = unit;
342
342
  this.bitWidth = bitWidth;
File without changes
@@ -33,7 +33,9 @@
33
33
  // TYPED_ARRAY_TO_TYPE.BigUint64Array = new Uint64();
34
34
  // }
35
35
 
36
- export function deduceTypeFromColumn(value) {
36
+ export function deduceTypeFromColumn(
37
+ value: unknown
38
+ ): StringConstructor | DateConstructor | Float32ArrayConstructor | null {
37
39
  if (value instanceof Date) {
38
40
  return Date;
39
41
  } else if (value instanceof Number) {
@@ -44,7 +46,9 @@ export function deduceTypeFromColumn(value) {
44
46
  return null;
45
47
  }
46
48
 
47
- export function deduceTypeFromValue(value) {
49
+ export function deduceTypeFromValue(
50
+ value: unknown
51
+ ): StringConstructor | DateConstructor | Float32ArrayConstructor | null {
48
52
  if (value instanceof Date) {
49
53
  return Date;
50
54
  } else if (value instanceof Number) {
@@ -2,7 +2,7 @@
2
2
  // http://2ality.com/2016/10/asynchronous-iteration.html
3
3
 
4
4
  class ArrayQueue<T> extends Array<T> {
5
- enqueue(value) {
5
+ enqueue(value: T) {
6
6
  // Add at the end
7
7
  return this.push(value);
8
8
  }
@@ -13,15 +13,18 @@ class ArrayQueue<T> extends Array<T> {
13
13
  }
14
14
 
15
15
  export default class AsyncQueue<T> {
16
- private _values: ArrayQueue<T>;
17
- private _settlers: ArrayQueue<{resolve; reject}>;
16
+ private _values: ArrayQueue<T | Error>;
17
+ private _settlers: ArrayQueue<{resolve: (value: any) => void; reject: (reason?: any) => void}>;
18
18
  private _closed: boolean;
19
19
 
20
20
  constructor() {
21
21
  // enqueues > dequeues
22
22
  this._values = new ArrayQueue<T>();
23
23
  // dequeues > enqueues
24
- this._settlers = new ArrayQueue<{resolve; reject}>();
24
+ this._settlers = new ArrayQueue<{
25
+ resolve: (value: any) => void;
26
+ reject: (reason?: any) => void;
27
+ }>();
25
28
  this._closed = false;
26
29
  }
27
30