img-fingerprint
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -8,6 +8,21 @@ /* tslint:disable */ | ||
/** | ||
* Get image hash | ||
* | ||
* output should be 32 bytes length | ||
* @param {Uint8Array} bytes | ||
* @returns {Uint8Array} | ||
* @param {Uint8Array} output | ||
*/ | ||
export function image_hash(bytes: Uint8Array): Uint8Array; | ||
export function image_hash(bytes: Uint8Array, output: Uint8Array): void; | ||
/** | ||
* bytes to base64 UTF-8 string array | ||
* @param {Uint8Array} bytes | ||
* @param {Uint8Array} output | ||
*/ | ||
export function base64(bytes: Uint8Array, output: Uint8Array): void; | ||
/** | ||
* get base64 output length | ||
* @param {number} bytes | ||
* @returns {number} | ||
*/ | ||
export function base64_len(bytes: number): number; | ||
@@ -19,4 +34,5 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module; | ||
readonly main: () => void; | ||
readonly image_hash: (a: number, b: number, c: number) => void; | ||
readonly __wbindgen_add_to_stack_pointer: (a: number) => number; | ||
readonly image_hash: (a: number, b: number, c: number, d: number) => void; | ||
readonly base64: (a: number, b: number, c: number, d: number) => void; | ||
readonly base64_len: (a: number) => number; | ||
readonly __wbindgen_malloc: (a: number) => number; | ||
@@ -23,0 +39,0 @@ readonly __wbindgen_free: (a: number, b: number) => void; |
@@ -46,34 +46,50 @@ | ||
} | ||
let cachegetInt32Memory0 = null; | ||
function getInt32Memory0() { | ||
if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) { | ||
cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer); | ||
/** | ||
* Get image hash | ||
* | ||
* output should be 32 bytes length | ||
* @param {Uint8Array} bytes | ||
* @param {Uint8Array} output | ||
*/ | ||
export function image_hash(bytes, output) { | ||
try { | ||
var ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ptr1 = passArray8ToWasm0(output, wasm.__wbindgen_malloc); | ||
var len1 = WASM_VECTOR_LEN; | ||
wasm.image_hash(ptr0, len0, ptr1, len1); | ||
} finally { | ||
output.set(getUint8Memory0().subarray(ptr1 / 1, ptr1 / 1 + len1)); | ||
wasm.__wbindgen_free(ptr1, len1 * 1); | ||
} | ||
return cachegetInt32Memory0; | ||
} | ||
function getArrayU8FromWasm0(ptr, len) { | ||
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len); | ||
} | ||
/** | ||
* bytes to base64 UTF-8 string array | ||
* @param {Uint8Array} bytes | ||
* @returns {Uint8Array} | ||
* @param {Uint8Array} output | ||
*/ | ||
export function image_hash(bytes) { | ||
export function base64(bytes, output) { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.image_hash(retptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var v1 = getArrayU8FromWasm0(r0, r1).slice(); | ||
wasm.__wbindgen_free(r0, r1 * 1); | ||
return v1; | ||
var ptr1 = passArray8ToWasm0(output, wasm.__wbindgen_malloc); | ||
var len1 = WASM_VECTOR_LEN; | ||
wasm.base64(ptr0, len0, ptr1, len1); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
output.set(getUint8Memory0().subarray(ptr1 / 1, ptr1 / 1 + len1)); | ||
wasm.__wbindgen_free(ptr1, len1 * 1); | ||
} | ||
} | ||
/** | ||
* get base64 output length | ||
* @param {number} bytes | ||
* @returns {number} | ||
*/ | ||
export function base64_len(bytes) { | ||
var ret = wasm.base64_len(bytes); | ||
return ret >>> 0; | ||
} | ||
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); | ||
@@ -149,2 +165,10 @@ | ||
let cachegetInt32Memory0 = null; | ||
function getInt32Memory0() { | ||
if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) { | ||
cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer); | ||
} | ||
return cachegetInt32Memory0; | ||
} | ||
async function load(module, imports) { | ||
@@ -151,0 +175,0 @@ if (typeof Response === 'function' && module instanceof Response) { |
@@ -6,3 +6,3 @@ { | ||
], | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"files": [ | ||
@@ -9,0 +9,0 @@ "img_fingerprint_bg.wasm", |
Sorry, the diff of this file is not supported yet
38534
249