nv-facutil-ab
v1.0.5
Published
nv-facutil-ab ======================= - serveral simple function for copy-arraybuffer
Downloads
46
Readme
nv-facutil-ab
- serveral simple function for copy-arraybuffer
install
- npm install nv-facutil-ab
usage
const {
_cp,
cp,
cp_from_src_start,
cp_all_if_dst_is_enough,
cp_all_if_same_blen
} = require("nv-facutil-ab");
example
var src_ab = new ArrayBuffer(10);
var src_u8a = new Uint8Array(src_ab,3,2);
src_u8a[0] =11
src_u8a[1] =22
/*
> src_ab
ArrayBuffer {
[Uint8Contents]: <00 00 00 0b 16 00 00 00 00 00>,
byteLength: 10
}
>
*/
var dst_ab = new ArrayBuffer(5);
/*
> dst_ab
ArrayBuffer { [Uint8Contents]: <00 00 00 00 00>, byteLength: 5 }
>
*/
_cp(src_ab,3,2,dst_ab,1)
/*
> dst_ab
ArrayBuffer { [Uint8Contents]: <00 0b 16 00 00>, byteLength: 5 }
>
*/
METHODS
APIS
const _cp = (src_ab,src_offset,cp_size,dst_ab,dst_offset) => {
const cp = (src_ab,dst_ab,src_offset,cp_size,dst_offset) => {
const cp_from_src_start = (src_ab,dst_ab,cp_size,dst_offset=0) => cp(src_ab,dst_ab,0,cp_size,dst_offset);
const cp_all_if_dst_is_enough = (src_ab,dst_ab, dst_offset=0) => _cp(src_ab,0,src_ab.byteLength,dst_ab,dst_offset);
const cp_all_if_same_blen = (src_ab,dst_ab) => _cp(src_ab,0,src_ab.byteLength,dst_ab,0);
LICENSE
- ISC