@xyo-network/hash
Advanced tools
Comparing version 2.110.19 to 2.111.0
@@ -5,5 +5,5 @@ import { PayloadHasher } from './PayloadHasher.ts'; | ||
static createNodeWorker: (func?: () => unknown) => import("@xylabs/threads/master").WorkerImplementation | undefined; | ||
static subtleHashWorkerUrl: URL | undefined; | ||
static wasmHashWorkerUrl: URL | undefined; | ||
static subtleHashWorkerUrl: import("url").URL | undefined; | ||
static wasmHashWorkerUrl: import("url").URL | undefined; | ||
} | ||
//# sourceMappingURL=BrowserPayloadHasher.d.ts.map |
@@ -5,5 +5,5 @@ import { PayloadHasher } from './PayloadHasher.ts'; | ||
static createNodeWorker: (func?: () => unknown) => import("@xylabs/threads/master").WorkerImplementation | undefined; | ||
static subtleHashWorkerUrl: URL | undefined; | ||
static wasmHashWorkerUrl: URL | undefined; | ||
static subtleHashWorkerUrl: import("url").URL | undefined; | ||
static wasmHashWorkerUrl: import("url").URL | undefined; | ||
} | ||
//# sourceMappingURL=BrowserPayloadHasher.d.ts.map |
@@ -5,5 +5,5 @@ import { PayloadHasher } from './PayloadHasher.ts'; | ||
static createNodeWorker: (func?: () => unknown) => import("@xylabs/threads/master").WorkerImplementation | undefined; | ||
static subtleHashWorkerUrl: URL | undefined; | ||
static wasmHashWorkerUrl: URL | undefined; | ||
static subtleHashWorkerUrl: import("url").URL | undefined; | ||
static wasmHashWorkerUrl: import("url").URL | undefined; | ||
} | ||
//# sourceMappingURL=BrowserPayloadHasher.d.ts.map |
@@ -13,10 +13,10 @@ { | ||
"dependencies": { | ||
"@xylabs/assert": "^3.6.6", | ||
"@xylabs/hex": "^3.6.6", | ||
"@xylabs/lodash": "^3.6.6", | ||
"@xylabs/object": "^3.6.6", | ||
"@xylabs/platform": "^3.6.6", | ||
"@xylabs/threads": "^3.6.6", | ||
"@xylabs/typeof": "^3.6.6", | ||
"@xyo-network/wasm": "^2.110.19", | ||
"@xylabs/assert": "^3.6.8", | ||
"@xylabs/hex": "^3.6.8", | ||
"@xylabs/lodash": "^3.6.8", | ||
"@xylabs/object": "^3.6.8", | ||
"@xylabs/platform": "^3.6.8", | ||
"@xylabs/threads": "^3.6.8", | ||
"@xylabs/typeof": "^3.6.8", | ||
"@xyo-network/wasm": "^2.111.0", | ||
"hash-wasm": "^4.11.0" | ||
@@ -26,5 +26,5 @@ }, | ||
"devDependencies": { | ||
"@xylabs/delay": "^3.6.6", | ||
"@xylabs/ts-scripts-yarn3": "^3.14.1", | ||
"@xylabs/tsconfig": "^3.14.1", | ||
"@xylabs/delay": "^3.6.8", | ||
"@xylabs/ts-scripts-yarn3": "^3.15.5", | ||
"@xylabs/tsconfig": "^3.15.5", | ||
"esbuild": "^0.23.0", | ||
@@ -59,3 +59,3 @@ "typescript": "^5.5.4" | ||
"main": "dist/node/index.cjs", | ||
"module": "dist/node/index.js", | ||
"module": "dist/node/index.mjs", | ||
"types": "dist/node/index.d.mts", | ||
@@ -78,4 +78,4 @@ "homepage": "https://xyo.network", | ||
"sideEffects": false, | ||
"version": "2.110.19", | ||
"version": "2.111.0", | ||
"type": "module" | ||
} |
@@ -20,2 +20,3 @@ import { createBrowserWorker } from './createBrowserWorker.ts' | ||
})() | ||
static override wasmHashWorkerUrl = (() => { | ||
@@ -22,0 +23,0 @@ try { |
@@ -1,2 +0,2 @@ | ||
declare module globalThis { | ||
declare namespace globalThis { | ||
var xyo: { | ||
@@ -3,0 +3,0 @@ hashing?: PayloadHasher |
@@ -63,4 +63,4 @@ import { assertEx } from '@xylabs/assert' | ||
try { | ||
return (this._subtleHashPool = | ||
this._subtleHashPool ?? (this.subtleHashWorkerUrl ? this.createWorkerPool(this.subtleHashWorkerUrl, subtleHashFunc) : null)) | ||
return (this._subtleHashPool | ||
= this._subtleHashPool ?? (this.subtleHashWorkerUrl ? this.createWorkerPool(this.subtleHashWorkerUrl, subtleHashFunc) : null)) | ||
} catch { | ||
@@ -78,4 +78,4 @@ console.warn('Creating subtle hash worker failed') | ||
try { | ||
return (this._wasmHashPool = | ||
this._wasmHashPool ?? (this.wasmHashWorkerUrl ? this.createWorkerPool(this.wasmHashWorkerUrl, wasmHashFunc) : null)) | ||
return (this._wasmHashPool | ||
= this._wasmHashPool ?? (this.wasmHashWorkerUrl ? this.createWorkerPool(this.wasmHashWorkerUrl, wasmHashFunc) : null)) | ||
} catch { | ||
@@ -95,3 +95,3 @@ console.warn('Creating wasm hash worker failed') | ||
const hashes = Array.isArray(hash) ? hash : [hash] | ||
return (await this.hashPairs(objs)).filter(([_, objHash]) => !hashes.includes(objHash))?.map((pair) => pair[0]) | ||
return (await this.hashPairs(objs)).filter(([_, objHash]) => !hashes.includes(objHash))?.map(pair => pair[0]) | ||
} | ||
@@ -101,3 +101,3 @@ | ||
const hashes = Array.isArray(hash) ? hash : [hash] | ||
return (await this.hashPairs(objs)).filter(([_, objHash]) => hashes.includes(objHash))?.map((pair) => pair[0]) | ||
return (await this.hashPairs(objs)).filter(([_, objHash]) => hashes.includes(objHash))?.map(pair => pair[0]) | ||
} | ||
@@ -149,3 +149,3 @@ | ||
static async hashPairs<T extends EmptyObject>(objs: T[]): Promise<[T, Hash][]> { | ||
return await Promise.all(objs.map<Promise<[T, Hash]>>(async (obj) => [obj, await PayloadHasher.hash(obj)])) | ||
return await Promise.all(objs.map<Promise<[T, Hash]>>(async obj => [obj, await PayloadHasher.hash(obj)])) | ||
} | ||
@@ -159,3 +159,3 @@ | ||
static async hashes<T extends EmptyObject>(objs?: T[]): Promise<Hash[] | undefined> { | ||
return objs ? await Promise.all(objs.map((obj) => this.hash(obj))) : undefined | ||
return objs ? await Promise.all(objs.map(obj => this.hash(obj))) : undefined | ||
} | ||
@@ -184,3 +184,3 @@ | ||
const pool = this.subtleHashPool | ||
return pool === null ? await subtle.digest('SHA-256', data) : await pool.queue(async (thread) => await thread.hash(data)) | ||
return pool === null ? await subtle.digest('SHA-256', data) : await pool.queue(async thread => await thread.hash(data)) | ||
} | ||
@@ -190,3 +190,3 @@ | ||
const pool = this.wasmHashPool | ||
return pool === null ? asHash(await sha256(data), true) : pool.queue(async (thread) => await thread.hash(data)) | ||
return pool === null ? asHash(await sha256(data), true) : pool.queue(async thread => await thread.hash(data)) | ||
} | ||
@@ -193,0 +193,0 @@ |
@@ -8,3 +8,3 @@ import { AnyObject, EmptyObject } from '@xylabs/object' | ||
if (Array.isArray(obj)) { | ||
return obj.map((value) => (typeof value === 'object' ? removeEmptyFields(value) : value)) as T | ||
return obj.map(value => (typeof value === 'object' ? removeEmptyFields(value) : value)) as T | ||
} | ||
@@ -11,0 +11,0 @@ |
@@ -11,7 +11,7 @@ import { assertEx } from '@xylabs/assert' | ||
//pick the child objects | ||
// pick the child objects | ||
const onlyObjects = pickBy<T>(obj, isObject) | ||
//pick the child non-objects | ||
const nonObjects = pickBy<T>(obj, (value) => !isObject(value)) | ||
// pick the child non-objects | ||
const nonObjects = pickBy<T>(obj, value => !isObject(value)) | ||
@@ -18,0 +18,0 @@ const pickedObjects = omitBy(onlyObjects, predicate) |
import { AnyObject, EmptyObject, isObject } from '@xylabs/object' | ||
//if an object, sub-sort | ||
// if an object, sub-sort | ||
const subSort = (value: unknown) => { | ||
@@ -5,0 +5,0 @@ return isObject(value) ? sortFields(value) : value |
@@ -1,2 +0,3 @@ | ||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
/* eslint-disable import/no-internal-modules */ | ||
/* eslint-disable @typescript-eslint/no-require-imports */ | ||
export const subtleHashFunc = () => { | ||
@@ -3,0 +4,0 @@ const { subtle } = require('@xylabs/platform') |
@@ -1,2 +0,3 @@ | ||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
/* eslint-disable import/no-internal-modules */ | ||
/* eslint-disable @typescript-eslint/no-require-imports */ | ||
export const wasmHashFunc = () => { | ||
@@ -3,0 +4,0 @@ const { sha256 } = require('hash-wasm') |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
628605
9141
Updated@xylabs/assert@^3.6.8
Updated@xylabs/hex@^3.6.8
Updated@xylabs/lodash@^3.6.8
Updated@xylabs/object@^3.6.8
Updated@xylabs/platform@^3.6.8
Updated@xylabs/threads@^3.6.8
Updated@xylabs/typeof@^3.6.8
Updated@xyo-network/wasm@^2.111.0