diff --git a/.gitignore b/.gitignore index 76add87..04c01ba 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -node_modules -dist \ No newline at end of file +node_modules/ +dist/ \ No newline at end of file diff --git a/README.md b/README.md index 3155182..8123d10 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,12 @@ # long-ts -An alternative to [https://github.com/dcodeIO/long.js](long.js) with support for ESM, CJS, UMD and [https://github.com/developit/microbundle#modern](Modern Mode). It's written in TypeScript and thus houses it's own type declarations. The only notable differences between long-ts and long.js are the removal of `Long.isLong()` in favor of using `instanceof`. All aliased shorthand methods are also removed. +An alternative to [long.js](https://github.com/dcodeIO/long.js) with support for ESM, CJS, UMD and [Modern Mode](https://github.com/developit/microbundle#modern). It's written in TypeScript and thus houses it's own type declarations. + +long-ts and long.js differences: + +- Removed `Long.isLong()` in favor of using `instanceof`. +- Removed all aliased shorthand methods like `eq` and `shr` and more. +- Using named export `import { Long } from 'long-ts'` instead of `const Long = require('long.js')` ## Installation @@ -20,4 +26,25 @@ console.log(longVal.toString()); ## Documentation -... +https://hornta.github.io/long-ts/modules.html + +## Building + +`npm run build` will also build the documentation in `/docs` + +``` +npm install +npm run build +``` + +Running tests: + +``` +npm run test +``` + +Running linter: + +``` +npm run lint +``` diff --git a/docs/assets/highlight.css b/docs/assets/highlight.css index a13094d..1fac3df 100644 --- a/docs/assets/highlight.css +++ b/docs/assets/highlight.css @@ -1,22 +1,78 @@ :root { + --light-hl-0: #001080; + --dark-hl-0: #9CDCFE; + --light-hl-1: #000000; + --dark-hl-1: #D4D4D4; + --light-hl-2: #AF00DB; + --dark-hl-2: #C586C0; + --light-hl-3: #A31515; + --dark-hl-3: #CE9178; + --light-hl-4: #0000FF; + --dark-hl-4: #569CD6; + --light-hl-5: #0070C1; + --dark-hl-5: #4FC1FF; + --light-hl-6: #795E26; + --dark-hl-6: #DCDCAA; + --light-hl-7: #098658; + --dark-hl-7: #B5CEA8; --light-code-background: #FFFFFF; --dark-code-background: #1E1E1E; } @media (prefers-color-scheme: light) { :root { + --hl-0: var(--light-hl-0); + --hl-1: var(--light-hl-1); + --hl-2: var(--light-hl-2); + --hl-3: var(--light-hl-3); + --hl-4: var(--light-hl-4); + --hl-5: var(--light-hl-5); + --hl-6: var(--light-hl-6); + --hl-7: var(--light-hl-7); --code-background: var(--light-code-background); } } @media (prefers-color-scheme: dark) { :root { + --hl-0: var(--dark-hl-0); + --hl-1: var(--dark-hl-1); + --hl-2: var(--dark-hl-2); + --hl-3: var(--dark-hl-3); + --hl-4: var(--dark-hl-4); + --hl-5: var(--dark-hl-5); + --hl-6: var(--dark-hl-6); + --hl-7: var(--dark-hl-7); --code-background: var(--dark-code-background); } } body.light { + --hl-0: var(--light-hl-0); + --hl-1: var(--light-hl-1); + --hl-2: var(--light-hl-2); + --hl-3: var(--light-hl-3); + --hl-4: var(--light-hl-4); + --hl-5: var(--light-hl-5); + --hl-6: var(--light-hl-6); + --hl-7: var(--light-hl-7); --code-background: var(--light-code-background); } body.dark { + --hl-0: var(--dark-hl-0); + --hl-1: var(--dark-hl-1); + --hl-2: var(--dark-hl-2); + --hl-3: var(--dark-hl-3); + --hl-4: var(--dark-hl-4); + --hl-5: var(--dark-hl-5); + --hl-6: var(--dark-hl-6); + --hl-7: var(--dark-hl-7); --code-background: var(--dark-code-background); } +.hl-0 { color: var(--hl-0); } +.hl-1 { color: var(--hl-1); } +.hl-2 { color: var(--hl-2); } +.hl-3 { color: var(--hl-3); } +.hl-4 { color: var(--hl-4); } +.hl-5 { color: var(--hl-5); } +.hl-6 { color: var(--hl-6); } +.hl-7 { color: var(--hl-7); } pre, code { background: var(--code-background); } diff --git a/docs/classes/Long.html b/docs/classes/Long.html index d9d159c..4704d64 100644 --- a/docs/classes/Long.html +++ b/docs/classes/Long.html @@ -1,65 +1,65 @@ -
Generated using TypeDoc
Generated using TypeDoc
An alternative to long.js with support for ESM, CJS, UMD and Modern Mode. It's written in TypeScript and thus houses it's own type declarations. The only notable differences between long-ts and long.js are the removal of Long.isLong()
in favor of using instanceof
. All aliased shorthand methods are also removed.
npm install long-ts
+
+
+
+ import { Long } from "long-ts";
const longVal = new Long(0xffffffff, 0x7fffffff);
console.log(longVal.toString());
+
+
+
+ https://hornta.github.io/long-ts/modules.html
+ + +You are recommended to be using at least Node LTS during development.
+# Builds the ESM, CJS, UMD, Modern Mode and TypeScript declaration files.
npm run build
# Executes the unit tests
npm run test
# Lint files
npm run lint
# Generates the /docs folder
npm run generateDocs
+
+Generated using TypeDoc
- Preparing search index...
- The search index is not available
long-tsClass Long
Hierarchy
Index
Constructors
Properties
Methods
Constructors
constructor
Parameters
low: number
high: number
unsigned: boolean = false
Returns Long
Properties
high
low
unsigned
Static Readonly MAX_ UNSIGNED_ VALUE
Static Readonly MAX_ VALUE
Static Readonly MIN_ VALUE
Static Readonly NEG_ ONE
Static Readonly ONE
Static Readonly UONE
Static Readonly UZERO
Static Readonly ZERO
Methods
add
Returns the sum of this and the specified Long.
-Parameters
addend: string | number | Long
Returns Long
and
Parameters
addend: string | number | Long
Returns Long
and
Returns the bitwise AND of this Long and the specified.
-Parameters
other: string | number | Long
Returns Long
compare
Parameters
other: string | number | Long
Returns Long
compare
Compares this Long's value with the specified's.
-Parameters
other: string | number | Long
Returns 0 | 1 | -1
divide
Parameters
other: string | number | Long
Returns 0 | 1 | -1
divide
Returns this Long divided by the specified. The result is signed if this Long is signed or unsigned if this Long is unsigned.
-Parameters
divisor: string | number | Long
Returns Long
equals
Parameters
other: string | number | Long
Returns boolean
get High Bits
Parameters
divisor: string | number | Long
Returns Long
equals
Parameters
other: string | number | Long
Returns boolean
get High Bits
Gets the high 32 bits as a signed integer.
-Returns number
get High Bits Unsigned
Returns number
get High Bits Unsigned
Gets the high 32 bits as an unsigned integer.
-Returns number
get Low Bits
Returns number
get Low Bits
Gets the low 32 bits as a signed integer.
-Returns number
get Low Bits Unsigned
Returns number
get Low Bits Unsigned
Gets the low 32 bits as an unsigned integer.
-Returns number
get Num Bits Abs
Returns number
get Num Bits Abs
Gets the number of bits needed to represent the absolute value of this Long.
-Returns number
greater Than
Parameters
other: string | number | Long
Returns boolean
greater Than Or Equal
Parameters
other: string | number | Long
Returns boolean
is Even
Returns boolean
is Negative
Returns boolean
is Odd
Returns boolean
is Positive
Returns boolean
is Zero
Returns boolean
less Than
Parameters
other: string | number | Long
Returns boolean
less Than Or Equal
Parameters
other: string | number | Long
Returns boolean
modulo
Returns number
greater Than
Parameters
other: string | number | Long
Returns boolean
greater Than Or Equal
Parameters
other: string | number | Long
Returns boolean
is Even
Returns boolean
is Negative
Returns boolean
is Odd
Returns boolean
is Positive
Returns boolean
is Zero
Returns boolean
less Than
Parameters
other: string | number | Long
Returns boolean
less Than Or Equal
Parameters
other: string | number | Long
Returns boolean
modulo
Returns this Long modulo the specified.
-Parameters
divisor: string | number | Long
Returns Long
multiply
Parameters
divisor: string | number | Long
Returns Long
multiply
Returns the product of this and the specified Long.
-Parameters
multiplier: string | number | Long
Returns Long
negate
Parameters
multiplier: string | number | Long
Returns Long
negate
Negates this Long's value.
-Returns Long
not
Returns Long
not
Returns the bitwise NOT of this Long.
-Returns Long
not Equals
Parameters
other: string | number | Long
Returns boolean
or
Returns Long
not Equals
Parameters
other: string | number | Long
Returns boolean
or
Returns the bitwise OR of this Long and the specified.
-Parameters
other: string | number | Long
Returns Long
rotate Left
Parameters
other: string | number | Long
Returns Long
rotate Left
Returns this Long with bits rotated to the left by the given amount.
-Parameters
numBits: number | Long
Returns Long
rotate Right
Parameters
numBits: number | Long
Returns Long
rotate Right
Returns this Long with bits rotated to the right by the given amount.
-Parameters
numBits: number | Long
Returns Long
shift Left
Parameters
numBits: number | Long
Returns Long
shift Left
Returns this Long with bits shifted to the left by the given amount.
-Parameters
numBits: number | Long
Returns Long
shift Right
Parameters
numBits: number | Long
Returns Long
shift Right
Returns this Long with bits arithmetically shifted to the right by the given amount.
-Parameters
numBits: number | Long
Returns Long
shift Right Unsigned
Parameters
numBits: number | Long
Returns Long
shift Right Unsigned
Returns this Long with bits logically shifted to the right by the given amount.
-Parameters
numBits: number | Long
Returns Long
subtract
Parameters
numBits: number | Long
Returns Long
subtract
Returns the difference of this and the specified Long.
-Parameters
subtrahend: string | number | Long
Returns Long
to Bytes
Parameters
subtrahend: string | number | Long
Returns Long
to Bytes
Converts this Long to its byte representation.
-Parameters
Optional le: boolean
Returns number[]
to BytesBE
Parameters
Optional le: boolean
Returns number[]
to BytesBE
Converts this Long to its big endian byte representation.
-Returns number[]
to BytesLE
Returns number[]
to BytesLE
Converts this Long to its little endian byte representation.
-Returns number[]
to Int
Returns number[]
to Int
Converts the Long to a 32 bit integer, assuming it is a 32 bit integer.
-Returns number
to Number
Returns number
to Number
Converts the Long to a the nearest floating-point representation of this value (double, 53 bit mantissa).
-Returns number
to Signed
Returns number
to Signed
Converts this Long to signed.
-Returns Long
to String
Returns Long
to String
Converts the Long to a string written in the specified radix.
-Parameters
radix: number = 10
Returns string
to Unsigned
Parameters
radix: number = 10
Returns string
to Unsigned
Converts this Long to unsigned.
-Returns Long
xor
Returns Long
xor
Returns the bitwise XOR of this Long and the given one.
-Parameters
other: string | number | Long
Returns Long
Static from Bits
Parameters
lowBits: number
highBits: number
Optional unsigned: boolean
Returns Long
Static from Bytes
Parameters
other: string | number | Long
Returns Long
Static from Bits
Parameters
lowBits: number
highBits: number
Optional unsigned: boolean
Returns Long
Static from Bytes
Creates a Long from its byte representation.
-Parameters
bytes: number[]
Optional unsigned: boolean
Optional le: boolean
Returns Long
Static from BytesBE
Parameters
bytes: number[]
Optional unsigned: boolean
Optional le: boolean
Returns Long
Static from BytesBE
Creates a Long from its big endian byte representation.
-Parameters
bytes: number[]
Optional unsigned: boolean
Returns Long
Static from BytesLE
Parameters
bytes: number[]
Optional unsigned: boolean
Returns Long
Static from BytesLE
Creates a Long from its little endian byte representation.
-Parameters
bytes: number[]
Optional unsigned: boolean
Returns Long
Static from Int
Parameters
value: number
Optional unsigned: boolean
Returns Long
Static from Number
Parameters
value: number
Optional unsigned: boolean
Returns Long
Static from String
Parameters
str: string
Optional unsigned: number | boolean
Optional radix: number
Returns Long
Static from Value
Parameters
val: string | number | Long | { high: number; low: number; unsigned: boolean }
Optional unsigned: boolean
Returns Long
Generated using TypeDoc