@nnilky/structo 1.0.8 → 1.0.9

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 (73) hide show
  1. package/dist/datatypes/containers/array.d.ts +1 -1
  2. package/dist/datatypes/containers/array.test.js +2 -2
  3. package/dist/datatypes/containers/exhuastiveArray.d.ts +1 -1
  4. package/dist/datatypes/containers/exhuastiveArray.js +1 -1
  5. package/dist/datatypes/containers/exhuastiveArray.test.js +2 -2
  6. package/dist/datatypes/containers/fastObject.d.ts +1 -1
  7. package/dist/datatypes/containers/fastObject.test.js +2 -2
  8. package/dist/datatypes/containers/list.d.ts +1 -1
  9. package/dist/datatypes/containers/list.test.js +2 -2
  10. package/dist/datatypes/containers/object.d.ts +1 -1
  11. package/dist/datatypes/containers/object.test.js +2 -2
  12. package/dist/datatypes/containers/taggedUnion.d.ts +1 -1
  13. package/dist/datatypes/containers/taggedUnion.test.js +2 -2
  14. package/dist/datatypes/index.d.ts +13 -13
  15. package/dist/datatypes/index.js +13 -13
  16. package/dist/datatypes/numbers/bigints.d.ts +1 -1
  17. package/dist/datatypes/numbers/bigints.test.js +2 -2
  18. package/dist/datatypes/numbers/floats.d.ts +1 -1
  19. package/dist/datatypes/numbers/floats.test.js +2 -2
  20. package/dist/datatypes/numbers/sints.d.ts +1 -1
  21. package/dist/datatypes/numbers/sints.test.js +2 -2
  22. package/dist/datatypes/numbers/uints.d.ts +1 -1
  23. package/dist/datatypes/numbers/uints.test.js +2 -2
  24. package/dist/datatypes/values/bytes.d.ts +1 -1
  25. package/dist/datatypes/values/bytes.test.js +2 -2
  26. package/dist/datatypes/values/sizedbytes.d.ts +1 -1
  27. package/dist/datatypes/values/sizedbytes.test.js +2 -2
  28. package/dist/datatypes/values/string.d.ts +1 -1
  29. package/dist/datatypes/values/string.test.js +2 -2
  30. package/dist/index.d.ts +6 -6
  31. package/dist/index.js +5 -5
  32. package/dist/read.d.ts +1 -1
  33. package/dist/transforms/encode.d.ts +1 -1
  34. package/dist/transforms/enum.d.ts +1 -1
  35. package/dist/transforms/enum.js +1 -1
  36. package/dist/transforms/enum.test.js +2 -2
  37. package/dist/transforms/index.d.ts +11 -11
  38. package/dist/transforms/index.js +11 -11
  39. package/dist/transforms/literal.d.ts +1 -1
  40. package/dist/transforms/literal.js +1 -1
  41. package/dist/transforms/literal.test.js +2 -2
  42. package/dist/transforms/modify.d.ts +1 -1
  43. package/dist/transforms/modify.test.js +2 -2
  44. package/dist/transforms/offset.d.ts +1 -1
  45. package/dist/transforms/offset.test.js +2 -2
  46. package/dist/transforms/pipe.d.ts +1 -1
  47. package/dist/transforms/toAscii.d.ts +1 -1
  48. package/dist/transforms/toAscii.js +1 -1
  49. package/dist/transforms/toAscii.test.js +2 -2
  50. package/dist/transforms/toBase64.d.ts +1 -1
  51. package/dist/transforms/toBase64.js +1 -1
  52. package/dist/transforms/toBase64.test.js +2 -2
  53. package/dist/transforms/toBytes.d.ts +1 -1
  54. package/dist/transforms/toBytes.js +1 -1
  55. package/dist/transforms/toBytes.test.js +2 -2
  56. package/dist/transforms/toHex.d.ts +1 -1
  57. package/dist/transforms/toHex.js +1 -1
  58. package/dist/transforms/toHex.test.js +2 -2
  59. package/dist/transforms/toTypedArray.d.ts +1 -1
  60. package/dist/transforms/toTypedArray.js +1 -1
  61. package/dist/transforms/toTypedArray.test.js +2 -2
  62. package/dist/utilities/index.d.ts +3 -3
  63. package/dist/utilities/index.js +3 -3
  64. package/dist/utilities/lazy.d.ts +1 -1
  65. package/dist/utilities/lazy.test.js +2 -2
  66. package/dist/utilities/reference.d.ts +1 -1
  67. package/dist/utilities/reference.test.js +2 -2
  68. package/dist/utilities/remember.d.ts +1 -1
  69. package/dist/utilities/remember.test.js +2 -2
  70. package/dist/utils.test.d.ts +1 -1
  71. package/dist/utils.test.js +1 -1
  72. package/dist/write.d.ts +1 -1
  73. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import type { Serializer } from "../../types";
1
+ import type { Serializer } from "../../types.js";
2
2
  /**
3
3
  * `st.array` is a fixed length array, akin to a C array.
4
4
  *
@@ -1,6 +1,6 @@
1
1
  import { describe, it } from "bun:test";
2
- import { encodeTest, encodeFailTest } from "../../utils.test";
3
- import * as st from "../../index";
2
+ import { encodeTest, encodeFailTest } from "../../utils.test.js";
3
+ import * as st from "../../index.js";
4
4
  describe("st.array", () => {
5
5
  it("encode correctly", () => {
6
6
  encodeTest(st.array(4, st.u16()), [1, 2, 3, 4]);
@@ -1,4 +1,4 @@
1
- import * as st from "../../index";
1
+ import * as st from "../../index.js";
2
2
  /**
3
3
  * exhuastiveArray is read until the end of the data
4
4
  *
@@ -1,4 +1,4 @@
1
- import * as st from "../../index";
1
+ import * as st from "../../index.js";
2
2
  /**
3
3
  * exhuastiveArray is read until the end of the data
4
4
  *
@@ -1,6 +1,6 @@
1
1
  import { describe, it } from "bun:test";
2
- import { encodeTest, encodeSnapshotTest, encodeFailTest } from "../../utils.test";
3
- import * as st from "../../index";
2
+ import { encodeTest, encodeSnapshotTest, encodeFailTest } from "../../utils.test.js";
3
+ import * as st from "../../index.js";
4
4
  describe("st.exhuastiveArray", () => {
5
5
  it("encode correctly", () => {
6
6
  const spec = st.exhuastiveArray(st.u32());
@@ -1,4 +1,4 @@
1
- import type { InferInput, Serializer } from "../../types";
1
+ import type { InferInput, Serializer } from "../../types.js";
2
2
  type InferObject<T> = T extends Record<string, Serializer<any>> ? {
3
3
  [Key in keyof T]: InferInput<T[Key]>;
4
4
  } : never;
@@ -1,7 +1,7 @@
1
1
  //@ts-ignore TODO
2
2
  import { describe, it, expect } from "bun:test";
3
- import { bytes, encodeTest, encodeSnapshotTest } from "../../utils.test";
4
- import * as st from "../../index";
3
+ import { bytes, encodeTest, encodeSnapshotTest } from "../../utils.test.js";
4
+ import * as st from "../../index.js";
5
5
  describe("st.fastObject", () => {
6
6
  const spec = st.fastObject({
7
7
  a: st.u8(),
@@ -1,4 +1,4 @@
1
- import type { Serializer } from "../../types";
1
+ import type { Serializer } from "../../types.js";
2
2
  /**
3
3
  * `st.list` is a dynamically sized array
4
4
  *
@@ -1,6 +1,6 @@
1
1
  import { describe, it } from "bun:test";
2
- import { encodeTest, encodeSnapshotTest, encodeFailTest } from "../../utils.test";
3
- import * as st from "../../index";
2
+ import { encodeTest, encodeSnapshotTest, encodeFailTest } from "../../utils.test.js";
3
+ import * as st from "../../index.js";
4
4
  describe("st.list", () => {
5
5
  it("encode correctly", () => {
6
6
  const spec = st.list(st.u8(), st.u32());
@@ -1,4 +1,4 @@
1
- import type { InferInput, InferOutput, Serializer } from "../../types";
1
+ import type { InferInput, InferOutput, Serializer } from "../../types.js";
2
2
  type InferObjectInfer<T> = T extends Record<string, Serializer<any>> ? {
3
3
  [Key in keyof T]: InferInput<T[Key]>;
4
4
  } : never;
@@ -1,7 +1,7 @@
1
1
  //@ts-ignore TODO
2
2
  import { describe, it, expect, expectTypeOf } from "bun:test";
3
- import { bytes, encodeTest, encodeSnapshotTest } from "../../utils.test";
4
- import * as st from "../../index";
3
+ import { bytes, encodeTest, encodeSnapshotTest } from "../../utils.test.js";
4
+ import * as st from "../../index.js";
5
5
  describe("st.object", () => {
6
6
  it("encodes correctly", () => {
7
7
  encodeTest(st.object({ a: st.u8(), b: st.u8() }), //
@@ -1,4 +1,4 @@
1
- import type { InferInput, InferOutput, Serializer } from "../../types";
1
+ import type { InferInput, InferOutput, Serializer } from "../../types.js";
2
2
  /**
3
3
  * `st.taggedUnion` is a union type with a kind
4
4
  *
@@ -1,6 +1,6 @@
1
1
  import { describe, expectTypeOf, it } from "bun:test";
2
- import { encodeTest, expectEncodeSize, encodeSnapshotTest, encodeFailTest } from "../../utils.test";
3
- import * as st from "../../index";
2
+ import { encodeTest, expectEncodeSize, encodeSnapshotTest, encodeFailTest, } from "../../utils.test.js";
3
+ import * as st from "../../index.js";
4
4
  describe("st.taggedUnion", () => {
5
5
  it("encode correctly", () => {
6
6
  const spec = st.taggedUnion(st.u8(), {
@@ -1,13 +1,13 @@
1
- export { u64Bigint, s64Bigint } from "./numbers/bigints";
2
- export { f16, f32, f64 } from "./numbers/floats";
3
- export { s8, s16, s32, s64 } from "./numbers/sints";
4
- export { u8, u16, u32, u64 } from "./numbers/uints";
5
- export { array } from "./containers/array";
6
- export { fastObject } from "./containers/fastObject";
7
- export { object } from "./containers/object";
8
- export { list } from "./containers/list";
9
- export { taggedUnion } from "./containers/taggedUnion";
10
- export { exhuastiveArray } from "./containers/exhuastiveArray";
11
- export { bytes } from "./values/bytes";
12
- export { sizedBytes } from "./values/sizedbytes";
13
- export { string } from "./values/string";
1
+ export { u64Bigint, s64Bigint } from "./numbers/bigints.js";
2
+ export { f16, f32, f64 } from "./numbers/floats.js";
3
+ export { s8, s16, s32, s64 } from "./numbers/sints.js";
4
+ export { u8, u16, u32, u64 } from "./numbers/uints.js";
5
+ export { array } from "./containers/array.js";
6
+ export { fastObject } from "./containers/fastObject.js";
7
+ export { object } from "./containers/object.js";
8
+ export { list } from "./containers/list.js";
9
+ export { taggedUnion } from "./containers/taggedUnion.js";
10
+ export { exhuastiveArray } from "./containers/exhuastiveArray.js";
11
+ export { bytes } from "./values/bytes.js";
12
+ export { sizedBytes } from "./values/sizedbytes.js";
13
+ export { string } from "./values/string.js";
@@ -1,13 +1,13 @@
1
- export { u64Bigint, s64Bigint } from "./numbers/bigints";
2
- export { f16, f32, f64 } from "./numbers/floats";
3
- export { s8, s16, s32, s64 } from "./numbers/sints";
4
- export { u8, u16, u32, u64 } from "./numbers/uints";
5
- export { array } from "./containers/array";
6
- export { fastObject } from "./containers/fastObject";
7
- export { object } from "./containers/object";
8
- export { list } from "./containers/list";
9
- export { taggedUnion } from "./containers/taggedUnion";
10
- export { exhuastiveArray } from "./containers/exhuastiveArray";
11
- export { bytes } from "./values/bytes";
12
- export { sizedBytes } from "./values/sizedbytes";
13
- export { string } from "./values/string";
1
+ export { u64Bigint, s64Bigint } from "./numbers/bigints.js";
2
+ export { f16, f32, f64 } from "./numbers/floats.js";
3
+ export { s8, s16, s32, s64 } from "./numbers/sints.js";
4
+ export { u8, u16, u32, u64 } from "./numbers/uints.js";
5
+ export { array } from "./containers/array.js";
6
+ export { fastObject } from "./containers/fastObject.js";
7
+ export { object } from "./containers/object.js";
8
+ export { list } from "./containers/list.js";
9
+ export { taggedUnion } from "./containers/taggedUnion.js";
10
+ export { exhuastiveArray } from "./containers/exhuastiveArray.js";
11
+ export { bytes } from "./values/bytes.js";
12
+ export { sizedBytes } from "./values/sizedbytes.js";
13
+ export { string } from "./values/string.js";
@@ -1,4 +1,4 @@
1
- import type { Serializer } from "../../types";
1
+ import type { Serializer } from "../../types.js";
2
2
  /**
3
3
  * 64bit unsigned interger
4
4
  *
@@ -1,6 +1,6 @@
1
1
  import { describe, it, expect } from "bun:test";
2
- import { encodeTest, encodeSnapshotTest, randbigint, encodeFailTest } from "../../utils.test";
3
- import * as st from "../../index";
2
+ import { encodeTest, encodeSnapshotTest, randbigint, encodeFailTest } from "../../utils.test.js";
3
+ import * as st from "../../index.js";
4
4
  function test_bigint(options) {
5
5
  const { name, range: [start, end], serializer, size, } = options;
6
6
  describe(name, () => {
@@ -1,4 +1,4 @@
1
- import type { Serializer } from "../../types";
1
+ import type { Serializer } from "../../types.js";
2
2
  /** 16bit float */
3
3
  export declare function f16(endian?: "little" | "big"): Serializer<number>;
4
4
  /** 32bit float */
@@ -1,7 +1,7 @@
1
1
  //@ts-ignore TODO
2
2
  import { describe, it, expect } from "bun:test";
3
- import { encodeTest, expectEncodeSize } from "../../utils.test";
4
- import * as st from "../../index";
3
+ import { encodeTest, expectEncodeSize } from "../../utils.test.js";
4
+ import * as st from "../../index.js";
5
5
  function test_float(options) {
6
6
  const { name, serializer, size } = options;
7
7
  const expectEncodeApproximately = (value) => {
@@ -1,4 +1,4 @@
1
- import type { Serializer } from "../../types";
1
+ import type { Serializer } from "../../types.js";
2
2
  /** 8bit signed integer */
3
3
  export declare function s8(): Serializer<number>;
4
4
  /** 16bit signed integer */
@@ -1,7 +1,7 @@
1
1
  //@ts-ignore TODO
2
2
  import { describe, it, expect } from "bun:test";
3
- import { encodeTest, encodeSnapshotTest, expectError, randint, encodeFailTest, } from "../../utils.test";
4
- import * as st from "../../index";
3
+ import { encodeTest, encodeSnapshotTest, expectError, randint, encodeFailTest, } from "../../utils.test.js";
4
+ import * as st from "../../index.js";
5
5
  function test_sint(options) {
6
6
  const { name, range: [start, end], serializer, size, disableRangeCheck, } = options;
7
7
  describe(name, () => {
@@ -1,4 +1,4 @@
1
- import type { Serializer } from "../../types";
1
+ import type { Serializer } from "../../types.js";
2
2
  /** 8bit unsigned integer */
3
3
  export declare function u8(): Serializer<number>;
4
4
  /** 16bit unsigned integer */
@@ -1,7 +1,7 @@
1
1
  //@ts-ignore TODO
2
2
  import { describe, it, expect } from "bun:test";
3
- import { encodeTest, encodeSnapshotTest, expectError, randint, encodeFailTest, } from "../../utils.test";
4
- import * as st from "../../index";
3
+ import { encodeTest, encodeSnapshotTest, expectError, randint, encodeFailTest, } from "../../utils.test.js";
4
+ import * as st from "../../index.js";
5
5
  function test_uint(options) {
6
6
  const { name, range: [start, end], serializer, size, disableMaxCheck, } = options;
7
7
  describe(name, () => {
@@ -1,4 +1,4 @@
1
- import type { Serializer } from "../../types";
1
+ import type { Serializer } from "../../types.js";
2
2
  /**
3
3
  * Fixed length bytes
4
4
  *
@@ -1,6 +1,6 @@
1
1
  import { describe, it } from "bun:test";
2
- import { bytes, encodeFailTest, encodeTest } from "../../utils.test";
3
- import * as st from "../../index";
2
+ import { bytes, encodeFailTest, encodeTest } from "../../utils.test.js";
3
+ import * as st from "../../index.js";
4
4
  describe("st.bytes", () => {
5
5
  const buffer = st.bytes(2);
6
6
  it("encode correctly", () => {
@@ -1,2 +1,2 @@
1
- import type { Serializer } from "../../types";
1
+ import type { Serializer } from "../../types.js";
2
2
  export declare function sizedBytes(length: Serializer<number>): Serializer<ArrayBuffer>;
@@ -1,6 +1,6 @@
1
1
  import { describe, it } from "bun:test";
2
- import { bytes, encodeFailTest, encodeTest } from "../../utils.test";
3
- import * as st from "../../index";
2
+ import { bytes, encodeFailTest, encodeTest } from "../../utils.test.js";
3
+ import * as st from "../../index.js";
4
4
  describe("st.sizedBytes", () => {
5
5
  it("encode correctly", () => {
6
6
  const buffer = st.sizedBytes(st.u8());
@@ -1,4 +1,4 @@
1
- import type { Serializer } from "../../types";
1
+ import type { Serializer } from "../../types.js";
2
2
  /**
3
3
  * `st.json` stores string data by writing/reading the length and then reading that many bytes
4
4
  *
@@ -1,6 +1,6 @@
1
1
  import { describe, it } from "bun:test";
2
- import { encodeFailTest, encodeTest } from "../../utils.test";
3
- import * as st from "../../index";
2
+ import { encodeFailTest, encodeTest } from "../../utils.test.js";
3
+ import * as st from "../../index.js";
4
4
  describe("st.string", () => {
5
5
  it("encode correctly", () => {
6
6
  encodeTest(st.string(st.u8()), "foo");
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export type { InferOutput as Infer, InferInput, InferOutput, ReaderContext, WriterContext, Serializer, } from "./types";
2
- export { read, createReaderContext } from "./read";
3
- export { write, createdWriterContext } from "./write";
4
- export * from "./datatypes/index";
5
- export * from "./transforms/index";
6
- export * from "./utilities/index";
1
+ export type { InferOutput as Infer, InferInput, InferOutput, ReaderContext, WriterContext, Serializer, } from "./types.js";
2
+ export { read, createReaderContext } from "./read.js";
3
+ export { write, createdWriterContext } from "./write.js";
4
+ export * from "./datatypes/index.js";
5
+ export * from "./transforms/index.js";
6
+ export * from "./utilities/index.js";
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- export { read, createReaderContext } from "./read";
2
- export { write, createdWriterContext } from "./write";
3
- export * from "./datatypes/index";
4
- export * from "./transforms/index";
5
- export * from "./utilities/index";
1
+ export { read, createReaderContext } from "./read.js";
2
+ export { write, createdWriterContext } from "./write.js";
3
+ export * from "./datatypes/index.js";
4
+ export * from "./transforms/index.js";
5
+ export * from "./utilities/index.js";
package/dist/read.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import type { Serializer, ReaderContext } from "./types";
1
+ import type { Serializer, ReaderContext } from "./types.js";
2
2
  export declare function read<TIn, TOut>(serializer: Serializer<TIn, TOut>, buffer: ArrayBuffer): TOut;
3
3
  export declare function createReaderContext(buffer: ArrayBuffer): ReaderContext;
@@ -1,4 +1,4 @@
1
- import type { Transform } from "./pipe";
1
+ import type { Transform } from "./pipe.js";
2
2
  export declare function encode<TIn, TOut>(options: {
3
3
  encode: (value: TOut) => TIn;
4
4
  decode: (value: TIn) => TOut;
@@ -1,2 +1,2 @@
1
- export declare function enum_<const T>(values: T[]): import("./pipe").Transform<T, any>;
1
+ export declare function enum_<const T>(values: T[]): import("./pipe.js").Transform<T, any>;
2
2
  export { enum_ as enum };
@@ -1,4 +1,4 @@
1
- import { encode } from "./encode";
1
+ import { encode } from "./encode.js";
2
2
  export function enum_(values) {
3
3
  return encode({
4
4
  encode: (v) => {
@@ -1,6 +1,6 @@
1
1
  import { describe, it } from "node:test";
2
- import * as st from "../index";
3
- import { encodeTest, encodeFailTest } from "../utils.test";
2
+ import * as st from "../index.js";
3
+ import { encodeTest, encodeFailTest } from "../utils.test.js";
4
4
  describe("st.enum", () => {
5
5
  it("encode correctly", () => {
6
6
  encodeTest(st.pipe(st.u8(), st.enum([0, 1, 2])), //
@@ -1,11 +1,11 @@
1
- export { type Transform as Pipeline, pipe } from "./pipe";
2
- export { encode } from "./encode";
3
- export { modify } from "./modify";
4
- export { literal } from "./literal";
5
- export { enum } from "./enum";
6
- export { offset } from "./offset";
7
- export { toAscii } from "./toAscii";
8
- export { toBytes } from "./toBytes";
9
- export { toHex } from "./toHex";
10
- export { toBase64 } from "./toBase64";
11
- export { toTypedArray } from "./toTypedArray";
1
+ export { type Transform as Pipeline, pipe } from "./pipe.js";
2
+ export { encode } from "./encode.js";
3
+ export { modify } from "./modify.js";
4
+ export { literal } from "./literal.js";
5
+ export { enum } from "./enum.js";
6
+ export { offset } from "./offset.js";
7
+ export { toAscii } from "./toAscii.js";
8
+ export { toBytes } from "./toBytes.js";
9
+ export { toHex } from "./toHex.js";
10
+ export { toBase64 } from "./toBase64.js";
11
+ export { toTypedArray } from "./toTypedArray.js";
@@ -1,11 +1,11 @@
1
- export { pipe } from "./pipe";
2
- export { encode } from "./encode";
3
- export { modify } from "./modify";
4
- export { literal } from "./literal";
5
- export { enum } from "./enum";
6
- export { offset } from "./offset";
7
- export { toAscii } from "./toAscii";
8
- export { toBytes } from "./toBytes";
9
- export { toHex } from "./toHex";
10
- export { toBase64 } from "./toBase64";
11
- export { toTypedArray } from "./toTypedArray";
1
+ export { pipe } from "./pipe.js";
2
+ export { encode } from "./encode.js";
3
+ export { modify } from "./modify.js";
4
+ export { literal } from "./literal.js";
5
+ export { enum } from "./enum.js";
6
+ export { offset } from "./offset.js";
7
+ export { toAscii } from "./toAscii.js";
8
+ export { toBytes } from "./toBytes.js";
9
+ export { toHex } from "./toHex.js";
10
+ export { toBase64 } from "./toBase64.js";
11
+ export { toTypedArray } from "./toTypedArray.js";
@@ -1 +1 @@
1
- export declare function literal<const T>(value: T): import("./pipe").Transform<T, any>;
1
+ export declare function literal<const T>(value: T): import("./pipe.js").Transform<T, any>;
@@ -1,4 +1,4 @@
1
- import { encode } from "./encode";
1
+ import { encode } from "./encode.js";
2
2
  export function literal(value) {
3
3
  return encode({
4
4
  encode: (v) => {
@@ -1,6 +1,6 @@
1
1
  import { describe, it } from "node:test";
2
- import * as st from "../index";
3
- import { encodeTest, encodeFailTest } from "../utils.test";
2
+ import * as st from "../index.js";
3
+ import { encodeTest, encodeFailTest } from "../utils.test.js";
4
4
  describe("st.literal", () => {
5
5
  it("encode correctly", () => {
6
6
  encodeTest(st.pipe(st.u8(), st.literal(0)), //
@@ -1,4 +1,4 @@
1
- import type { Transform } from "./pipe";
1
+ import type { Transform } from "./pipe.js";
2
2
  /**
3
3
  * A readonly modification function, useful for sizes or offsets.
4
4
  *
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, it } from "bun:test";
2
- import { encodeFailTest } from "../utils.test";
3
- import * as st from "../index";
2
+ import { encodeFailTest } from "../utils.test.js";
3
+ import * as st from "../index.js";
4
4
  describe("st.modify", () => {
5
5
  it("encodes correctly", () => {
6
6
  const data = st.write(st.u32(), 10);
@@ -1,2 +1,2 @@
1
- import type { Serializer } from "../types";
1
+ import type { Serializer } from "../types.js";
2
2
  export declare function offset<TIn, TOut>(behaviour: "relative" | "absolute", offset: Serializer<number> | number): (type: Serializer<TIn, TOut>) => Serializer<TIn, TOut>;
@@ -1,6 +1,6 @@
1
1
  import { describe, it } from "bun:test";
2
- import { encodeTest } from "../utils.test";
3
- import * as st from "../index";
2
+ import { encodeTest } from "../utils.test.js";
3
+ import * as st from "../index.js";
4
4
  describe("st.offset(relative)", () => {
5
5
  it("encodes correctly with fixed offset", () => {
6
6
  const spec = st.object({
@@ -1,4 +1,4 @@
1
- import type { Serializer } from "../types";
1
+ import type { Serializer } from "../types.js";
2
2
  export type Transform<T = any, TNext = T> = (type: Serializer<TNext>) => Serializer<T>;
3
3
  export declare function pipe<TStart, T1>(type: Serializer<TStart>, p1: Transform<T1, TStart>): Serializer<T1>;
4
4
  export declare function pipe<TStart, T1, T2>(type: Serializer<TStart>, p1: Transform<T1, TStart>, p2: Transform<T2, T1>): Serializer<T2>;
@@ -1 +1 @@
1
- export declare function toAscii(): import("./pipe").Transform<string, ArrayBuffer>;
1
+ export declare function toAscii(): import("./pipe.js").Transform<string, ArrayBuffer>;
@@ -1,4 +1,4 @@
1
- import { encode } from "./encode";
1
+ import { encode } from "./encode.js";
2
2
  export function toAscii() {
3
3
  return encode({
4
4
  encode: (v) => new Uint8Array(Array.from(v).map((char) => validateAscii(char.charCodeAt(0)))).buffer,
@@ -1,6 +1,6 @@
1
1
  import { describe, it } from "bun:test";
2
- import { encodeTest, encodeSnapshotTest, encodeFailTest } from "../utils.test";
3
- import * as st from "../index";
2
+ import { encodeTest, encodeSnapshotTest, encodeFailTest } from "../utils.test.js";
3
+ import * as st from "../index.js";
4
4
  describe("st.toAscii", () => {
5
5
  it("encode correctly", () => {
6
6
  encodeTest(st.pipe(st.bytes(5), st.toAscii()), //
@@ -1 +1 @@
1
- export declare function toBase64(): import("./pipe").Transform<string, ArrayBuffer>;
1
+ export declare function toBase64(): import("./pipe.js").Transform<string, ArrayBuffer>;
@@ -1,4 +1,4 @@
1
- import { encode } from "./encode";
1
+ import { encode } from "./encode.js";
2
2
  export function toBase64() {
3
3
  return encode({
4
4
  encode: (v) => Uint8Array.fromBase64(v).buffer,
@@ -1,6 +1,6 @@
1
1
  import { describe, it } from "bun:test";
2
- import { encodeTest, encodeSnapshotTest, encodeFailTest } from "../utils.test";
3
- import * as st from "../index";
2
+ import { encodeTest, encodeSnapshotTest, encodeFailTest } from "../utils.test.js";
3
+ import * as st from "../index.js";
4
4
  describe("st.toBase64", () => {
5
5
  it("encode correctly", () => {
6
6
  encodeTest(st.pipe(st.bytes(1), st.toBase64()), //
@@ -10,4 +10,4 @@
10
10
  *
11
11
  * `ArrayBuffer([0, 255, c])` => `[0, 255, ArrayBuffer([0, 255, 0])]`
12
12
  */
13
- export declare function toBytes(): import("./pipe").Transform<number[], ArrayBuffer>;
13
+ export declare function toBytes(): import("./pipe.js").Transform<number[], ArrayBuffer>;
@@ -1,4 +1,4 @@
1
- import { encode } from "./encode";
1
+ import { encode } from "./encode.js";
2
2
  /**
3
3
  * Converts an ArrayBuffer to the byte digits
4
4
  *
@@ -1,6 +1,6 @@
1
1
  import { describe, it } from "bun:test";
2
- import { encodeTest, encodeSnapshotTest, encodeFailTest } from "../utils.test";
3
- import * as st from "../index";
2
+ import { encodeTest, encodeSnapshotTest, encodeFailTest } from "../utils.test.js";
3
+ import * as st from "../index.js";
4
4
  describe("st.toBytes", () => {
5
5
  it("encode correctly", () => {
6
6
  encodeTest(st.pipe(st.bytes(3), st.toBytes()), //
@@ -10,4 +10,4 @@
10
10
  *
11
11
  * `ArrayBuffer([0, 255, 0])` => `00FF00`
12
12
  */
13
- export declare function toHex(): import("./pipe").Transform<string, ArrayBuffer>;
13
+ export declare function toHex(): import("./pipe.js").Transform<string, ArrayBuffer>;
@@ -1,4 +1,4 @@
1
- import { encode } from "./encode";
1
+ import { encode } from "./encode.js";
2
2
  /**
3
3
  * Converts an ArrayBuffer to uppercase hex
4
4
  *
@@ -1,6 +1,6 @@
1
1
  import { describe, it } from "bun:test";
2
- import { encodeTest, encodeSnapshotTest, encodeFailTest } from "../utils.test";
3
- import * as st from "../index";
2
+ import { encodeTest, encodeSnapshotTest, encodeFailTest } from "../utils.test.js";
3
+ import * as st from "../index.js";
4
4
  describe("st.toHex", () => {
5
5
  it("encode correctly", () => {
6
6
  encodeTest(st.pipe(st.bytes(3), st.toHex()), //
@@ -12,5 +12,5 @@ type TypedArrayConstructor<T extends TypedArray> = new (array: ArrayBuffer) => T
12
12
  * )
13
13
  * ```
14
14
  */
15
- export declare function toTypedArray<T extends TypedArray>(arrayType: TypedArrayConstructor<T>): import("./pipe").Transform<T, ArrayBuffer>;
15
+ export declare function toTypedArray<T extends TypedArray>(arrayType: TypedArrayConstructor<T>): import("./pipe.js").Transform<T, ArrayBuffer>;
16
16
  export {};
@@ -1,4 +1,4 @@
1
- import { encode } from "./encode";
1
+ import { encode } from "./encode.js";
2
2
  /**
3
3
  * Converts an `ArrayBuffer` to a `TypedArray`
4
4
  *
@@ -1,6 +1,6 @@
1
1
  import { describe, it } from "bun:test";
2
- import { encodeTest, encodeSnapshotTest, expectError } from "../utils.test";
3
- import * as st from "../index";
2
+ import { encodeTest, encodeSnapshotTest, expectError } from "../utils.test.js";
3
+ import * as st from "../index.js";
4
4
  describe("st.toArrayBuffer", () => {
5
5
  it("encode correctly", () => {
6
6
  encodeTest(st.pipe(st.bytes(6), //
@@ -1,3 +1,3 @@
1
- export { lazy } from "./lazy";
2
- export { createReference } from "./reference";
3
- export { createRememberedValue } from "./remember";
1
+ export { lazy } from "./lazy.js";
2
+ export { createReference } from "./reference.js";
3
+ export { createRememberedValue } from "./remember.js";
@@ -1,3 +1,3 @@
1
- export { lazy } from "./lazy";
2
- export { createReference } from "./reference";
3
- export { createRememberedValue } from "./remember";
1
+ export { lazy } from "./lazy.js";
2
+ export { createReference } from "./reference.js";
3
+ export { createRememberedValue } from "./remember.js";
@@ -1,2 +1,2 @@
1
- import type { Serializer } from "../types";
1
+ import type { Serializer } from "../types.js";
2
2
  export declare function lazy<TIn, TOut = TIn>(type: () => Serializer<TIn, TOut>): Serializer<TIn, TOut>;
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, it } from "bun:test";
2
- import { encodeTest } from "../utils.test";
3
- import * as st from "../index";
2
+ import { encodeTest } from "../utils.test.js";
3
+ import * as st from "../index.js";
4
4
  describe("st.lazy", () => {
5
5
  it("encodes correctly", () => {
6
6
  const spec = st.lazy(() => st.object({
@@ -1,4 +1,4 @@
1
- import type { Serializer } from "../types";
1
+ import type { Serializer } from "../types.js";
2
2
  /**
3
3
  * createReference lets you defer writing a value until later, useful for lengths and sizes
4
4
  *
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, it } from "bun:test";
2
- import { encodeTest, encodeSnapshotTest, expectError } from "../utils.test";
3
- import * as st from "../index";
2
+ import { encodeTest, encodeSnapshotTest, expectError } from "../utils.test.js";
3
+ import * as st from "../index.js";
4
4
  describe("st.createReference", () => {
5
5
  it("encodes correctly", () => {
6
6
  const length = st.createReference();
@@ -1,4 +1,4 @@
1
- import type { Serializer } from "../types";
1
+ import type { Serializer } from "../types.js";
2
2
  /**
3
3
  * createRememberedValue lets you save and recall a value when serializing
4
4
  *
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, it } from "bun:test";
2
- import { encodeTest, encodeSnapshotTest } from "../utils.test";
3
- import * as st from "../index";
2
+ import { encodeTest, encodeSnapshotTest } from "../utils.test.js";
3
+ import * as st from "../index.js";
4
4
  describe("st.remember", () => {
5
5
  it("encodes correctly", () => {
6
6
  const v = st.createRememberedValue();
@@ -1,4 +1,4 @@
1
- import * as st from "./index";
1
+ import * as st from "./index.js";
2
2
  export declare const randint: (start: number, end: number) => number;
3
3
  export declare const randbigint: (start: bigint, end: bigint) => bigint;
4
4
  export declare const encodeTest: <TIn, TOut>(serializer: st.Serializer<TIn, TOut>, value: TIn, expected?: TOut) => void;
@@ -1,6 +1,6 @@
1
1
  //@ts-ignore TODO
2
2
  import { describe, it, expect } from "bun:test";
3
- import * as st from "./index";
3
+ import * as st from "./index.js";
4
4
  export const randint = (start, end) => {
5
5
  const range = end - start;
6
6
  return Math.floor(start + range * Math.random());
package/dist/write.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import type { WriterContext, Serializer } from "./types";
1
+ import type { WriterContext, Serializer } from "./types.js";
2
2
  export declare function write<TIn, TOut>(serializer: Serializer<TIn, TOut>, value: TIn): ArrayBuffer;
3
3
  export declare function createdWriterContext(type: Serializer<any>): WriterContext;
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "node"
10
10
  ],
11
11
  "license": "ISC",
12
- "version": "1.0.8",
12
+ "version": "1.0.9",
13
13
  "author": "Ben Brady",
14
14
  "private": false,
15
15
  "publishConfig": {