This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*! | |
* DBC Language Grammar, for PEG.js | |
* --------------------------------------------------------------------------- | |
* Copyright (c) 2021-2023+ Nicholas Berlette. All rights reserved. | |
* --------------------------------------------------------------------------- | |
* More info: [DBC Language Documentation](https://canbus-org.github.io/dbc) | |
*/ | |
// #region Internal Parser Functions | |
{ | |
const TYPES_TO_PROPERTY_NAMES = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*! | |
* DBC Language Grammar, for PEG.js | |
* --------------------------------------------------------------------------- | |
* Copyright (c) 2021-2023+ Nicholas Berlette. All rights reserved. | |
* --------------------------------------------------------------------------- | |
* More info: [DBC Language Documentation](https://canbus-org.github.io/dbc) | |
*/ | |
// #region Internal Parser Functions | |
{ | |
const TYPES_TO_PROPERTY_NAMES = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Type-Level Arithmetic Operations in TypeScript | |
// | |
// Implemented by Nicholas Berlette (@nberlette) | |
// Inspired by the work of many others :) | |
// | |
export type ADD<A extends number, B extends number> = | |
| Internal.ADD<A, B> extends infer R extends number | |
? [R] extends [never] ? number : R : number; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
assert, | |
type SerializedValue, | |
TypedArray, | |
TypedArrayTypes, | |
} from "./helpers.ts"; | |
import { StructuredReader, StructuredSyncReader } from "./reader.ts"; | |
const binaryInputTypes = [ArrayBuffer, Uint8Array] as const; | |
const streamInputTypes = [ReadableStream, ...binaryInputTypes] as const; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* MurmurHash3 128-bit implementation in TypeScript. Supports a custom seed for | |
* its first parameter. For another variant that assumes a default seed of 0, | |
* see {@link murmur128} instead. | |
* | |
* @param seed The seed to use for this hash. | |
* @param keys The keys to hash. | |
* @returns 128-bit hash as a `bigint`. | |
* | |
* Based on bryc's JavaScript hash functions: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare interface LongStatic { | |
readonly prototype: Long; | |
new (low: number, high: number): Long; | |
fromInt(value: number): Long; | |
fromBigInt(value: bigint): Long; | |
fromString(value: string, radix?: number): Long; | |
fromNumber(value: number): Long; | |
fromBits(lowBits: number, highBits: number): Long; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# A modification of the standard Deno installation script (https://deno.land/install.sh) | |
# updated to support downloading a Linux arm64 binary from LukeChannings/deno-arm64 | |
set -e | |
if ! command -v unzip >/dev/null; then | |
echo "Error: unzip is required to install Deno (see: https://github.com/denoland/deno_install#unzip-is-required)." 1>&2 | |
exit 1 | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// "deasync" by Nicholas Berlette - https://github.com/nberlette | |
// Inspired by deasync for node.js. Obviously, this is not a | |
// piece of software you should ever consider using in production. | |
// (....or even in development for that matter) | |
export type Conditional = () => boolean; | |
import { SpinWait } from "./utils.ts"; | |
// Having `null` as the superclass effectively disables both the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Adapted from https://stackoverflow.com/a/53808212/10873797 | |
export type Equal<T, U> = (<G>() => G extends T ? 1 : 2) extends | |
(<G>() => G extends U ? 1 : 2) ? true | |
: false; | |
export type AssertEqual< | |
Expected extends $, | |
Got extends $$, | |
$ = [Equal<Got, Expected>] extends [true] ? Expected | |
: ([Expected] extends [Got] ? never : Got), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { isFunction, isMissing } from "./guards.ts"; | |
/** | |
* Represents a value that can compare itself relationally with another value. | |
*/ | |
export interface Comparable { | |
/** | |
* Compares this value with another value, returning a value indicating one of the following conditions: | |
* | |
* - A negative value indicates this value is lesser. |