Skip to content

Commit

Permalink
Private member fix and readme examples rename
Browse files Browse the repository at this point in the history
  • Loading branch information
Haaxor1689 committed Jul 28, 2023
1 parent 3810ea6 commit 9b85606
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ TypeScript-first binary data parsing library with static type inference. Heavily
## Installation

```
npm install nil
npm install @haaxor1689/nil
```

## Basic usage

Creating a simple string schema

```ts
import { n } from 'nil';
import { n } from '@haaxor1689/nil';

// Create schema for string with length of 14 characters
const mySchema = n.string(14);
Expand Down Expand Up @@ -45,7 +45,7 @@ User.fromBuffer(buffer);
## Primitives

```ts
import { n } from 'nil';
import { n } from '@haaxor1689/nil';

// boolean
n.bool();
Expand All @@ -70,7 +70,7 @@ n.uint64();
By default, all numbers are assumed to be in little-endian byte order. You can change this by using the `.be()` option:

```ts
import { n } from 'nil';
import { n } from '@haaxor1689/nil';

// Will be read in big-endian byte order
n.int32().be();
Expand All @@ -83,7 +83,7 @@ n.int32().be();
Since we are dealing with binary data, there are no optional properties and **order of the attributes matters**. All values are read in order they were declared in.

```ts
import { n } from 'nil';
import { n } from '@haaxor1689/nil';

// Declare object schema with given shape
const User = n.object({
Expand Down Expand Up @@ -115,7 +115,7 @@ struct User {
All array-like types must have a known size. It can either be provided as a constant, or by referencing value from surrounding context.

```ts
import { n } from 'nil';
import { n } from '@haaxor1689/nil';

// Constant size
n.buffer(10); // Uint8Array
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@haaxor1689/nil",
"version": "0.0.2",
"version": "0.0.3",
"description": "TypeScript-first binary data parsing library with static type inference",
"author": "Maroš Beťko <[email protected]>",
"repository": {
Expand Down
8 changes: 4 additions & 4 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ class NilArray<T extends NilTypeAny> extends NilType<
size(value?: T['_input'][], ctx?: ParseContext) {
const { length, inBytes } = this._def;

const elementSize = this.elementSize(value, ctx);
const elementSize = this.#elementSize(value, ctx);
let byteLength = 0;
if (typeof length !== 'number') {
const resolved = resolvePath(length, ctx);
Expand All @@ -312,7 +312,7 @@ class NilArray<T extends NilTypeAny> extends NilType<
const { schema } = this._def;
const value: T['_input'][] = [];

const elementSize = this.elementSize(undefined, ctx);
const elementSize = this.#elementSize(undefined, ctx);
const size = this.size(undefined, ctx);

let offset = 0;
Expand All @@ -338,7 +338,7 @@ class NilArray<T extends NilTypeAny> extends NilType<
_encode(data: DataView, value: T['_input'][], ctx?: ParseContext) {
const { schema } = this._def;

const elementSize = this.elementSize(undefined, ctx);
const elementSize = this.#elementSize(undefined, ctx);

let offset = 0;
value.forEach((v, i) => {
Expand Down Expand Up @@ -384,7 +384,7 @@ class NilArray<T extends NilTypeAny> extends NilType<
});
}

private elementSize(value?: T['_input'][], ctx?: ParseContext) {
#elementSize(value?: T['_input'][], ctx?: ParseContext) {
const { schema } = this._def;
const newCtx: ParseContext = {
// FIXME: Types
Expand Down

0 comments on commit 9b85606

Please sign in to comment.