ya-struct 0.0.8 → 0.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.
@@ -111,6 +111,14 @@ const layoutStruct = ({
111
111
 
112
112
  break;
113
113
  }
114
+ case "struct": {
115
+
116
+ if (currentOffsetInBits % 64 !== 0) {
117
+ throw Error("nested struct alignment handling not implemented yet");
118
+ }
119
+
120
+ break;
121
+ }
114
122
  case "string": {
115
123
  // no special alignment needed
116
124
  break;
@@ -37,7 +37,7 @@ const createStringParser = ({ length }/*: { length: number }*/)/*: TStringParser
37
37
 
38
38
  const encoded = encoder.encode(value);
39
39
 
40
- if (encoded.length + 1 >= length) {
40
+ if (encoded.length + 1 > length) {
41
41
  throw Error("string too long to fit in target");
42
42
  }
43
43
 
package/lib/layout.ts CHANGED
@@ -111,6 +111,14 @@ const layoutStruct = ({
111
111
 
112
112
  break;
113
113
  }
114
+ case "struct": {
115
+
116
+ if (currentOffsetInBits % 64 !== 0) {
117
+ throw Error("nested struct alignment handling not implemented yet");
118
+ }
119
+
120
+ break;
121
+ }
114
122
  case "string": {
115
123
  // no special alignment needed
116
124
  break;
@@ -37,7 +37,7 @@ const createStringParser = ({ length }: { length: number }): TStringParser => {
37
37
 
38
38
  const encoded = encoder.encode(value);
39
39
 
40
- if (encoded.length + 1 >= length) {
40
+ if (encoded.length + 1 > length) {
41
41
  throw Error("string too long to fit in target");
42
42
  }
43
43
 
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.8",
2
+ "version": "0.0.9",
3
3
  "name": "ya-struct",
4
4
  "type": "module",
5
5
  "description": "Yet Another Node.js Structure API",