base128-ascii 3.1.0 → 3.2.0

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.
Files changed (3) hide show
  1. package/main.d.ts +5 -0
  2. package/main.js +8 -3
  3. package/package.json +1 -1
package/main.d.ts CHANGED
@@ -16,6 +16,11 @@ export declare class Base128Bytes {
16
16
  */
17
17
  toJSTemplateLiterals(): string;
18
18
 
19
+ /**
20
+ * Returns a base128 Uint8Array.
21
+ */
22
+ uint8Array(): Uint8Array<ArrayBufferLike>;
23
+
19
24
  /**
20
25
  * The ArrayBuffer instance referenced by the array.
21
26
  */
package/main.js CHANGED
@@ -3,7 +3,7 @@
3
3
  export const Base128Bytes = (() => {
4
4
  class Base128Bytes {
5
5
  constructor() {
6
- return Reflect.construct(Uint8Array, arguments, Base128Bytes)
6
+ return Reflect.construct(Uint8Array, arguments, new.target)
7
7
  }
8
8
  toString() {
9
9
  return new TextDecoder().decode(this)
@@ -20,9 +20,14 @@ export const Base128Bytes = (() => {
20
20
  )
21
21
  )}\``
22
22
  }
23
+ uint8Array() {
24
+ return new Uint8Array(this.buffer)
25
+ }
26
+ }
27
+ const p = Object.getPrototypeOf(Uint8Array.prototype)
28
+ for (const key of ["buffer", "byteLength", "byteOffset", "length"]) {
29
+ Object.defineProperty(Base128Bytes.prototype, key, Object.getOwnPropertyDescriptor(p, key))
23
30
  }
24
- const { buffer, byteLength, byteOffset, length } = Object.getOwnPropertyDescriptors(Object.getPrototypeOf(Uint8Array.prototype))
25
- Object.defineProperties(Base128Bytes.prototype, { buffer, byteLength, byteOffset, length })
26
31
  return Base128Bytes
27
32
  })()
28
33
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "base128-ascii",
3
- "version": "3.1.0",
3
+ "version": "3.2.0",
4
4
  "author": "bddjr",
5
5
  "license": "Unlicense",
6
6
  "type": "module",