Content-Length: 267281 | pFad | http://github.com/cmdruid/buff/commit/26acc232e15ea79a7024a5885e496f8427518dc0

4C update · cmdruid/buff@26acc23 · GitHub
Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
cmd committed Nov 1, 2023
1 parent a2c5d93 commit 26acc23
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
9 changes: 3 additions & 6 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { webcrypto } from 'crypto'
import { webcrypto } from 'crypto'
import { within_size } from './assert.js'
import { Endian, Bytes } from './types.js'

Expand All @@ -25,17 +25,14 @@ export function random (size = 32) : Uint8Array {

export function is_hex (input : string) : boolean {
if (
input.match(/[^a-fA-f0-9]/) === null &&
input.match(/[^a-fA-F0-9]/) === null &&
input.length % 2 === 0
) { return true }
return false
}

export function is_bytes (input : any) : input is Bytes {
if (
typeof input === 'string' &&
is_hex(input)
) {
if (typeof input === 'string' && is_hex(input)) {
return true
} else if (
typeof input === 'number' ||
Expand Down
7 changes: 2 additions & 5 deletions test/scratch.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { Buff } from '../src/index.js'

const test_hash = Buff.str('testing').digest.hex
const is_hex = Buff.is_hex('OP_1')

const rand_hash = Buff.random(32).hex

console.log('test hash:', test_hash)
console.log('rand hash:', rand_hash)
console.log(is_hex)
1 change: 1 addition & 0 deletions test/src/util.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Need to add unit tests for the utility methods

0 comments on commit 26acc23

Please sign in to comment.








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/cmdruid/buff/commit/26acc232e15ea79a7024a5885e496f8427518dc0

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy