Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: make the endianess util constant #7

Merged
merged 1 commit into from
Feb 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions .github/workflows/depsbot.yml

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021-2022 the denosaurs team
Copyright (c) 2021-2023 the denosaurs team

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# byte_type

[![Tags](https://img.shields.io/github/release/denosaurs/byte_type)](https://github.com/denosaurs/byte_type/releases)
[![CI Status](https://img.shields.io/github/workflow/status/denosaurs/byte_type/check)](https://github.com/denosaurs/byte_type/actions)
[![Dependencies](https://img.shields.io/github/workflow/status/denosaurs/byte_type/depsbot?label=dependencies)](https://github.com/denosaurs/depsbot)
[![Checks](https://img.shields.io/github/actions/workflow/status/denosaurs/byte_type/checks.yml?branch=main)](https://github.com/denosaurs/byte_type/actions)
[![License](https://img.shields.io/github/license/denosaurs/byte_type)](https://github.com/denosaurs/byte_type/blob/master/LICENSE)

`byte_type` is a small helper module for working with different raw types
represented as a bunch of bytes.
`byte_type` is a small helper module for efficiently working with different raw
types represented as a bunch of bytes. Now with performance being close to
native js performance and ergonomic interfaces!

## Usage

Expand All @@ -33,4 +33,4 @@ Pull request, issues and feedback are very welcome. Code style is formatted with

### Licence

Copyright 2021, the denosaurs team. All rights reserved. MIT license.
Copyright 2021-2023, the denosaurs team. All rights reserved. MIT license.
2 changes: 2 additions & 0 deletions types/mod.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
export * from "./array/mod.ts";
export * from "./bitflags/mod.ts";
export * from "./misc/mod.ts";
export * from "./primitive/mod.ts";
export * from "./string/mod.ts";
export * from "./struct/mod.ts";
export * from "./tuple/mod.ts";
export * from "./types.ts";
2 changes: 1 addition & 1 deletion types/primitive/f32.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export class F32 implements AlignedType<number> {
byteAlign = 4;
endian;

constructor(endian: boolean = endianess()) {
constructor(endian: boolean = endianess) {
this.endian = endian;
}

Expand Down
2 changes: 1 addition & 1 deletion types/primitive/f64.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export class F64 implements AlignedType<number> {
byteAlign = 8;
endian;

constructor(endian: boolean = endianess()) {
constructor(endian: boolean = endianess) {
this.endian = endian;
}

Expand Down
2 changes: 1 addition & 1 deletion types/primitive/i16.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export class I16 implements AlignedType<number> {
byteAlign = 2;
endian;

constructor(endian: boolean = endianess()) {
constructor(endian: boolean = endianess) {
this.endian = endian;
}

Expand Down
2 changes: 1 addition & 1 deletion types/primitive/i32.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export class I32 implements AlignedType<number> {
byteAlign = 4;
endian;

constructor(endian: boolean = endianess()) {
constructor(endian: boolean = endianess) {
this.endian = endian;
}

Expand Down
2 changes: 1 addition & 1 deletion types/primitive/i64.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export class I64 implements AlignedType<bigint> {
byteAlign = 8;
endian;

constructor(endian: boolean = endianess()) {
constructor(endian: boolean = endianess) {
this.endian = endian;
}

Expand Down
2 changes: 1 addition & 1 deletion types/primitive/u16.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export class U16 implements AlignedType<number> {
byteAlign = 2;
endian;

constructor(endian: boolean = endianess()) {
constructor(endian: boolean = endianess) {
this.endian = endian;
}

Expand Down
2 changes: 1 addition & 1 deletion types/primitive/u32.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export class U32 implements AlignedType<number> {
byteAlign = 4;
endian;

constructor(endian: boolean = endianess()) {
constructor(endian: boolean = endianess) {
this.endian = endian;
}

Expand Down
2 changes: 1 addition & 1 deletion types/primitive/u64.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export class U64 implements AlignedType<bigint> {
byteAlign = 8;
endian;

constructor(endian: boolean = endianess()) {
constructor(endian: boolean = endianess) {
this.endian = endian;
}

Expand Down
9 changes: 0 additions & 9 deletions util.ts

This file was deleted.

7 changes: 7 additions & 0 deletions utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const buffer = new ArrayBuffer(2);
new DataView(buffer).setInt16(0, 256, true);

/**
* The endianess of your machine, true if little endian and false if big endian.
*/
export const endianess = new Int16Array(buffer)[0] === 256;