Commit 0ac3581 1 parent 2ef8afe commit 0ac3581 Copy full SHA for 0ac3581
File tree 3 files changed +12
-16
lines changed
3 files changed +12
-16
lines changed Original file line number Diff line number Diff line change @@ -4,12 +4,7 @@ import type {
4
4
DataType ,
5
5
TypedArrayConstructor ,
6
6
} from "../metadata.js" ;
7
- import {
8
- byteswap_inplace ,
9
- get_array_order ,
10
- get_ctr ,
11
- get_strides ,
12
- } from "../util.js" ;
7
+ import { byteswap_inplace , get_ctr , get_strides } from "../util.js" ;
13
8
14
9
const LITTLE_ENDIAN_OS = system_is_little_endian ( ) ;
15
10
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import type {
5
5
ArrayMetadata ,
6
6
Attributes ,
7
7
Chunk ,
8
+ CodecMetadata ,
8
9
DataType ,
9
10
GroupMetadata ,
10
11
Scalar ,
@@ -19,7 +20,6 @@ import {
19
20
import {
20
21
create_chunk_key_encoder ,
21
22
ensure_correct_scalar ,
22
- get_array_order ,
23
23
get_ctr ,
24
24
get_strides ,
25
25
} from "./util.js" ;
@@ -28,7 +28,7 @@ export class Location<Store> {
28
28
constructor (
29
29
public readonly store : Store ,
30
30
public readonly path : AbsolutePath = "/" ,
31
- ) { }
31
+ ) { }
32
32
33
33
resolve ( path : string ) : Location < Store > {
34
34
// reuse URL resolution logic built into the browser
@@ -63,6 +63,14 @@ export class Group<Store extends Readable> extends Location<Store> {
63
63
}
64
64
}
65
65
66
+ function get_array_order (
67
+ codecs : CodecMetadata [ ] ,
68
+ ) : "C" | "F" | globalThis . Array < number > {
69
+ const maybe_transpose_codec = codecs . find ( ( c ) => c . name === "transpose" ) ;
70
+ // @ts -expect-error - TODO: Should validate?
71
+ return maybe_transpose_codec ?. configuration ?. order ?? "C" ;
72
+ }
73
+
66
74
const CONTEXT_MARKER = Symbol ( "zarrita.context" ) ;
67
75
68
76
export function get_context < T > ( obj : { [ CONTEXT_MARKER ] : T } ) : T {
Original file line number Diff line number Diff line change @@ -121,21 +121,14 @@ export function create_chunk_key_encoder({
121
121
throw new Error ( `Unknown chunk key encoding: ${ name } ` ) ;
122
122
}
123
123
124
- export function get_array_order ( codecs : CodecMetadata [ ] ) : "C" | "F" {
125
- const maybe_transpose_codec = codecs . find ( ( c ) => c . name === "transpose" ) ;
126
- return maybe_transpose_codec ?. configuration ?. order === "F" ? "F" : "C" ;
127
- }
128
-
129
- const endian_regex = / ^ ( [ < | > ] ) ( .* ) $ / ;
130
-
131
124
function coerce_dtype (
132
125
dtype : string ,
133
126
) : { data_type : DataType } | { data_type : DataType ; endian : "little" | "big" } {
134
127
if ( dtype === "|O" ) {
135
128
return { data_type : "v2:object" } ;
136
129
}
137
130
138
- let match = dtype . match ( endian_regex ) ;
131
+ let match = dtype . match ( / ^ ( [ < | > ] ) ( . * ) $ / ) ;
139
132
assert ( match , `Invalid dtype: ${ dtype } ` ) ;
140
133
141
134
let [ , endian , rest ] = match ;
You can’t perform that action at this time.
0 commit comments