@thi.ng/binary
Advanced tools
Comparing version 1.3.2 to 2.0.0
@@ -6,2 +6,21 @@ # Change Log | ||
# [2.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/binary@1.3.2...@thi.ng/binary@2.0.0) (2020-03-06) | ||
### Features | ||
* **binary:** make binary logic ops unmasked, rename masked versions ([c07cf04](https://github.com/thi-ng/umbrella/commit/c07cf040f831b7393d889f6e97dbae001769d0c2)) | ||
### BREAKING CHANGES | ||
* **binary:** make binary logic ops unmasked, rename masked versions | ||
- existing names used for unmasked versions (returning signed ints) | ||
- masked versions of bitOr/bitAnd/bitXor etc. now suffixed with `M`, e.g. `bitAndM()` | ||
## [1.3.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/binary@1.3.1...@thi.ng/binary@1.3.2) (2020-02-26) | ||
@@ -8,0 +27,0 @@ |
@@ -1,2 +0,2 @@ | ||
export type * from "./api"; | ||
export * from "./api"; | ||
export * from "./align"; | ||
@@ -3,0 +3,0 @@ export * from "./bytes"; |
@@ -113,16 +113,33 @@ 'use strict'; | ||
const bitNot = (n, x) => maskL(n, ~x); | ||
const bitAnd = (n, a, b) => maskL(n, a & b); | ||
const bitNand = (n, a, b) => maskL(n, ~(a & b)); | ||
const bitOr = (n, a, b) => maskL(n, a | b); | ||
const bitNor = (n, a, b) => maskL(n, ~(a & b)); | ||
const bitXor = (n, a, b) => maskL(n, a ^ b); | ||
const bitXnor = (n, a, b) => maskL(n, ~(a ^ b)); | ||
const bitImply = (n, a, b) => maskL(n, ~a | b); | ||
const bitAoi21 = (n, a, b, c) => maskL(n, ~(a | (b & c))); | ||
const bitOai21 = (n, a, b, c) => maskL(n, ~(a & (b | c))); | ||
const bitAoi22 = (n, a, b, c, d) => maskL(n, ~((a & b) | (c & d))); | ||
const bitOai22 = (n, a, b, c, d) => maskL(n, ~((a | b) & (c | d))); | ||
const bitMux = (n, a, b, s) => maskL(n, (a & ~s) | (b & s)); | ||
const bitDemux = (n, a, b, s) => [maskL(n, a & ~s), maskL(n, b & s)]; | ||
const bitNot = (x) => ~x; | ||
const bitAnd = (a, b) => a & b; | ||
const bitNand = (a, b) => ~(a & b); | ||
const bitOr = (a, b) => a | b; | ||
const bitNor = (a, b) => ~(a | b); | ||
const bitXor = (a, b) => a ^ b; | ||
const bitXnor = (a, b) => ~(a ^ b); | ||
const bitImply = (a, b) => ~a | b; | ||
const bitAoi21 = (a, b, c) => ~(a | (b & c)); | ||
const bitOai21 = (a, b, c) => ~(a & (b | c)); | ||
const bitAoi22 = (a, b, c, d) => ~((a & b) | (c & d)); | ||
const bitOai22 = (a, b, c, d) => ~((a | b) & (c | d)); | ||
const bitMux = (a, b, s) => ((a & ~s) | (b & s)) >>> 0; | ||
const bitDemux = (a, b, s) => [ | ||
(a & ~s) >>> 0, | ||
(b & s) >>> 0 | ||
]; | ||
const bitNotM = (n, x) => maskL(n, ~x); | ||
const bitAndM = (n, a, b) => maskL(n, a & b); | ||
const bitNandM = (n, a, b) => maskL(n, ~(a & b)); | ||
const bitOrM = (n, a, b) => maskL(n, a | b); | ||
const bitNorM = (n, a, b) => maskL(n, ~(a | b)); | ||
const bitXorM = (n, a, b) => maskL(n, a ^ b); | ||
const bitXnorM = (n, a, b) => maskL(n, ~(a ^ b)); | ||
const bitImplyM = (n, a, b) => maskL(n, ~a | b); | ||
const bitAoi21M = (n, a, b, c) => maskL(n, ~(a | (b & c))); | ||
const bitOai21M = (n, a, b, c) => maskL(n, ~(a & (b | c))); | ||
const bitAoi22M = (n, a, b, c, d) => maskL(n, ~((a & b) | (c & d))); | ||
const bitOai22M = (n, a, b, c, d) => maskL(n, ~((a | b) & (c | d))); | ||
const bitMuxM = (n, a, b, s) => maskL(n, (a & ~s) | (b & s)); | ||
const bitDemuxM = (n, a, b, s) => [maskL(n, a & ~s), maskL(n, b & s)]; | ||
@@ -200,16 +217,28 @@ const isPow2 = (x) => !!x && !(x & (x - 1)); | ||
exports.bitAnd = bitAnd; | ||
exports.bitAndM = bitAndM; | ||
exports.bitAoi21 = bitAoi21; | ||
exports.bitAoi21M = bitAoi21M; | ||
exports.bitAoi22 = bitAoi22; | ||
exports.bitAoi22M = bitAoi22M; | ||
exports.bitClear = bitClear; | ||
exports.bitClearWindow = bitClearWindow; | ||
exports.bitDemux = bitDemux; | ||
exports.bitDemuxM = bitDemuxM; | ||
exports.bitFlip = bitFlip; | ||
exports.bitImply = bitImply; | ||
exports.bitImplyM = bitImplyM; | ||
exports.bitMux = bitMux; | ||
exports.bitMuxM = bitMuxM; | ||
exports.bitNand = bitNand; | ||
exports.bitNandM = bitNandM; | ||
exports.bitNor = bitNor; | ||
exports.bitNorM = bitNorM; | ||
exports.bitNot = bitNot; | ||
exports.bitNotM = bitNotM; | ||
exports.bitOai21 = bitOai21; | ||
exports.bitOai21M = bitOai21M; | ||
exports.bitOai22 = bitOai22; | ||
exports.bitOai22M = bitOai22M; | ||
exports.bitOr = bitOr; | ||
exports.bitOrM = bitOrM; | ||
exports.bitSet = bitSet; | ||
@@ -219,3 +248,5 @@ exports.bitSetWindow = bitSetWindow; | ||
exports.bitXnor = bitXnor; | ||
exports.bitXnorM = bitXnorM; | ||
exports.bitXor = bitXor; | ||
exports.bitXorM = bitXorM; | ||
exports.bytes16 = bytes16; | ||
@@ -222,0 +253,0 @@ exports.bytes24 = bytes24; |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(((t=t||self).thi=t.thi||{},t.thi.ng=t.thi.ng||{},t.thi.ng.binary={}))}(this,(function(t){"use strict";const e=new Float64Array(1),i=new Float32Array(e.buffer),n=new Int32Array(e.buffer),o=new Uint32Array(e.buffer),a=(e[0]=2,1073741824===o[1]),s=t=>(i[0]=t,n[0]),r=t=>(i[0]=t,o[0]),l=t=>(e[0]=t,a?[o[1],o[0]]:[o[0],o[1]]),f=t=>t<-1?-1:t>1?1:t,u=(t,e=!1)=>{const i=255&t,n=t>>8&255,o=t>>16&255,a=t>>24&255;return e?[i,n,o,a]:[a,o,n,i]},b=(t,e,i=!1)=>i?u(e,i).concat(u(t,i)):u(t,i).concat(u(e,i)),c=new Array(33).fill(0).map((t,e)=>Math.pow(2,e)-1),p=t=>16843009*((t=(858993459&(t-=t>>>1&1431655765))+(t>>>2&858993459))+(t>>>4)&252645135)>>>24,y=(t,e)=>(~c[t]&c[e])>>>0,d=(t,e)=>(e&c[t])>>>0,h=(t,e)=>t>>>(3-e<<3)&255,w=(t,e)=>t>>>(7-e<<2)&15,m=(t,e,i)=>~i&t|i&e,A=t=>(t>>>24|t>>8&65280|(65280&t)<<8|t<<24)>>>0,g=A;t.IS_LE=a,t.MASKS=c,t.align=(t,e)=>t+--e&~e,t.bitAnd=(t,e,i)=>d(t,e&i),t.bitAoi21=(t,e,i,n)=>d(t,~(e|i&n)),t.bitAoi22=(t,e,i,n,o)=>d(t,~(e&i|n&o)),t.bitClear=(t,e)=>(t&~(1<<e))>>>0,t.bitClearWindow=(t,e,i)=>t&~y(e,i),t.bitDemux=(t,e,i,n)=>[d(t,e&~n),d(t,i&n)],t.bitFlip=(t,e)=>(t^1<<e)>>>0,t.bitImply=(t,e,i)=>d(t,~e|i),t.bitMux=(t,e,i,n)=>d(t,e&~n|i&n),t.bitNand=(t,e,i)=>d(t,~(e&i)),t.bitNor=(t,e,i)=>d(t,~(e&i)),t.bitNot=(t,e)=>d(t,~e),t.bitOai21=(t,e,i,n)=>d(t,~(e&(i|n))),t.bitOai22=(t,e,i,n,o)=>d(t,~((e|i)&(n|o))),t.bitOr=(t,e,i)=>d(t,e|i),t.bitSet=(t,e)=>(t|1<<e)>>>0,t.bitSetWindow=(t,e,i,n)=>{const o=y(i,n);return t&~o|e<<(1<<i)&o},t.bitSize=t=>t>1?Math.ceil(Math.log2(t)):0,t.bitXnor=(t,e,i)=>d(t,~(e^i)),t.bitXor=(t,e,i)=>d(t,e^i),t.bytes16=(t,e=!1)=>{const i=255&t,n=t>>8&255;return e?[i,n]:[n,i]},t.bytes24=(t,e=!1)=>{const i=255&t,n=t>>8&255,o=t>>16&255;return e?[i,n,o]:[o,n,i]},t.bytes32=u,t.bytes64=b,t.bytesF32=(t,e=!1)=>u(r(t),e),t.bytesF64=(t,e=!1)=>b(...l(t),e),t.ceilPow2=t=>(t+=0===t,--t,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,(t|=t>>>16)+1),t.clz32=t=>0!==t?31-(Math.log(t>>>0)/Math.LN2|0):32,t.ctz32=t=>{let e=32;return(t&=-t)&&e--,65535&t&&(e-=16),16711935&t&&(e-=8),252645135&t&&(e-=4),858993459&t&&(e-=2),1431655765&t&&(e-=1),e},t.decodeGray32=t=>(t^=t>>>16,t^=t>>>8,t^=t>>>4,t^=t>>>2,(t^=t>>>1)>>>0),t.defMask=y,t.encodeGray32=t=>(t^t>>>1)>>>0,t.f32u16=t=>32767*f(t)&65535,t.f32u24=t=>8388607*f(t)&16777215,t.f32u32=t=>2147483647*f(t)>>>0,t.f32u8=t=>127*f(t)&255,t.flip16=t=>m(t<<16,t>>>16,65535),t.flip8=A,t.flipBytes=g,t.floatToIntBits=s,t.floatToIntBits64=t=>(e[0]=t,a?[n[1],n[0]]:[n[0],n[1]]),t.floatToSortableInt=t=>{-0===t&&(t=0);const e=s(t);return t<0?~e|1<<31:e},t.floatToUintBits=r,t.floatToUintBits64=l,t.floorPow2=t=>(t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,(t|=t>>>16)-(t>>>1)),t.hammingDist=(t,e)=>p(t^e),t.intBitsToFloat=t=>(n[0]=t,i[0]),t.intBitsToFloat64=(t,i)=>(a?(n[1]=t,n[0]=i):(n[0]=t,n[1]=i),e[0]),t.isAligned=(t,e)=>!(t&e-1),t.isPow2=t=>!(!t||t&t-1),t.lane16=(t,e)=>t>>>(1-e<<4)&65535,t.lane2=(t,e)=>t>>>(15-e<<1)&3,t.lane4=w,t.lane8=h,t.maskH=(t,e)=>(e&~c[t])>>>0,t.maskL=d,t.mux=m,t.popCount=p,t.rotateLeft=(t,e)=>(t<<e|t>>>32-e)>>>0,t.rotateRight=(t,e)=>(t>>>e|t<<32-e)>>>0,t.same4=t=>(t>>4&15)==(15&t),t.same8=t=>(t>>8&255)==(255&t),t.setLane16=(t,e,i)=>i?m(t,e,65535):m(t,e<<16,4294901760),t.setLane2=(t,e,i)=>{const n=15-i<<1;return(~(3<<n)&t|(3&e)<<n)>>>0},t.setLane4=(t,e,i)=>{const n=7-i<<2;return(~(15<<n)&t|(15&e)<<n)>>>0},t.setLane8=(t,e,i)=>{const n=3-i<<3;return(~(255<<n)&t|(255&e)<<n)>>>0},t.splat16_32=t=>((t&=65535)<<16|t)>>>0,t.splat4_24=t=>1118481*(15&t),t.splat4_32=t=>286331153*(15&t)>>>0,t.splat8_24=t=>65793*(255&t),t.splat8_32=t=>16843009*(255&t)>>>0,t.swizzle4=(t,e,i,n,o,a,s,r,l)=>(w(t,e)<<28|w(t,i)<<24|w(t,n)<<20|w(t,o)<<16|w(t,a)<<12|w(t,s)<<8|w(t,r)<<4|w(t,l))>>>0,t.swizzle8=(t,e,i,n,o)=>(h(t,e)<<24|h(t,i)<<16|h(t,n)<<8|h(t,o))>>>0,t.u16f32=t=>((t&=65535)|4294901760*(t>>15))/32767,t.u24f32=t=>((t&=16777215)|4278190080*(t>>23))/8388607,t.u32f32=t=>(0|t)/2147483647,t.u8f32=t=>((t&=255)|4294967040*(t>>7))/127,t.uintBitsToFloat=t=>(o[0]=t,i[0]),t.uintBitsToFloat64=(t,i)=>(a?(o[1]=t,o[0]=i):(o[0]=t,o[1]=i),e[0]),Object.defineProperty(t,"__esModule",{value:!0})})); | ||
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i(((t=t||self).thi=t.thi||{},t.thi.ng=t.thi.ng||{},t.thi.ng.binary={}))}(this,(function(t){"use strict";const i=new Float64Array(1),e=new Float32Array(i.buffer),n=new Int32Array(i.buffer),o=new Uint32Array(i.buffer),a=(i[0]=2,1073741824===o[1]),r=t=>(e[0]=t,n[0]),s=t=>(e[0]=t,o[0]),b=t=>(i[0]=t,a?[o[1],o[0]]:[o[0],o[1]]),l=t=>t<-1?-1:t>1?1:t,f=(t,i=!1)=>{const e=255&t,n=t>>8&255,o=t>>16&255,a=t>>24&255;return i?[e,n,o,a]:[a,o,n,e]},u=(t,i,e=!1)=>e?f(i,e).concat(f(t,e)):f(t,e).concat(f(i,e)),c=new Array(33).fill(0).map((t,i)=>Math.pow(2,i)-1),M=t=>16843009*((t=(858993459&(t-=t>>>1&1431655765))+(t>>>2&858993459))+(t>>>4)&252645135)>>>24,p=(t,i)=>(~c[t]&c[i])>>>0,y=(t,i)=>(i&c[t])>>>0,d=(t,i)=>t>>>(3-i<<3)&255,m=(t,i)=>t>>>(7-i<<2)&15,h=(t,i,e)=>~e&t|e&i,w=t=>(t>>>24|t>>8&65280|(65280&t)<<8|t<<24)>>>0,A=w;t.IS_LE=a,t.MASKS=c,t.align=(t,i)=>t+--i&~i,t.bitAnd=(t,i)=>t&i,t.bitAndM=(t,i,e)=>y(t,i&e),t.bitAoi21=(t,i,e)=>~(t|i&e),t.bitAoi21M=(t,i,e,n)=>y(t,~(i|e&n)),t.bitAoi22=(t,i,e,n)=>~(t&i|e&n),t.bitAoi22M=(t,i,e,n,o)=>y(t,~(i&e|n&o)),t.bitClear=(t,i)=>(t&~(1<<i))>>>0,t.bitClearWindow=(t,i,e)=>t&~p(i,e),t.bitDemux=(t,i,e)=>[(t&~e)>>>0,(i&e)>>>0],t.bitDemuxM=(t,i,e,n)=>[y(t,i&~n),y(t,e&n)],t.bitFlip=(t,i)=>(t^1<<i)>>>0,t.bitImply=(t,i)=>~t|i,t.bitImplyM=(t,i,e)=>y(t,~i|e),t.bitMux=(t,i,e)=>(t&~e|i&e)>>>0,t.bitMuxM=(t,i,e,n)=>y(t,i&~n|e&n),t.bitNand=(t,i)=>~(t&i),t.bitNandM=(t,i,e)=>y(t,~(i&e)),t.bitNor=(t,i)=>~(t|i),t.bitNorM=(t,i,e)=>y(t,~(i|e)),t.bitNot=t=>~t,t.bitNotM=(t,i)=>y(t,~i),t.bitOai21=(t,i,e)=>~(t&(i|e)),t.bitOai21M=(t,i,e,n)=>y(t,~(i&(e|n))),t.bitOai22=(t,i,e,n)=>~((t|i)&(e|n)),t.bitOai22M=(t,i,e,n,o)=>y(t,~((i|e)&(n|o))),t.bitOr=(t,i)=>t|i,t.bitOrM=(t,i,e)=>y(t,i|e),t.bitSet=(t,i)=>(t|1<<i)>>>0,t.bitSetWindow=(t,i,e,n)=>{const o=p(e,n);return t&~o|i<<(1<<e)&o},t.bitSize=t=>t>1?Math.ceil(Math.log2(t)):0,t.bitXnor=(t,i)=>~(t^i),t.bitXnorM=(t,i,e)=>y(t,~(i^e)),t.bitXor=(t,i)=>t^i,t.bitXorM=(t,i,e)=>y(t,i^e),t.bytes16=(t,i=!1)=>{const e=255&t,n=t>>8&255;return i?[e,n]:[n,e]},t.bytes24=(t,i=!1)=>{const e=255&t,n=t>>8&255,o=t>>16&255;return i?[e,n,o]:[o,n,e]},t.bytes32=f,t.bytes64=u,t.bytesF32=(t,i=!1)=>f(s(t),i),t.bytesF64=(t,i=!1)=>u(...b(t),i),t.ceilPow2=t=>(t+=0===t,--t,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,(t|=t>>>16)+1),t.clz32=t=>0!==t?31-(Math.log(t>>>0)/Math.LN2|0):32,t.ctz32=t=>{let i=32;return(t&=-t)&&i--,65535&t&&(i-=16),16711935&t&&(i-=8),252645135&t&&(i-=4),858993459&t&&(i-=2),1431655765&t&&(i-=1),i},t.decodeGray32=t=>(t^=t>>>16,t^=t>>>8,t^=t>>>4,t^=t>>>2,(t^=t>>>1)>>>0),t.defMask=p,t.encodeGray32=t=>(t^t>>>1)>>>0,t.f32u16=t=>32767*l(t)&65535,t.f32u24=t=>8388607*l(t)&16777215,t.f32u32=t=>2147483647*l(t)>>>0,t.f32u8=t=>127*l(t)&255,t.flip16=t=>h(t<<16,t>>>16,65535),t.flip8=w,t.flipBytes=A,t.floatToIntBits=r,t.floatToIntBits64=t=>(i[0]=t,a?[n[1],n[0]]:[n[0],n[1]]),t.floatToSortableInt=t=>{-0===t&&(t=0);const i=r(t);return t<0?~i|1<<31:i},t.floatToUintBits=s,t.floatToUintBits64=b,t.floorPow2=t=>(t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,(t|=t>>>16)-(t>>>1)),t.hammingDist=(t,i)=>M(t^i),t.intBitsToFloat=t=>(n[0]=t,e[0]),t.intBitsToFloat64=(t,e)=>(a?(n[1]=t,n[0]=e):(n[0]=t,n[1]=e),i[0]),t.isAligned=(t,i)=>!(t&i-1),t.isPow2=t=>!(!t||t&t-1),t.lane16=(t,i)=>t>>>(1-i<<4)&65535,t.lane2=(t,i)=>t>>>(15-i<<1)&3,t.lane4=m,t.lane8=d,t.maskH=(t,i)=>(i&~c[t])>>>0,t.maskL=y,t.mux=h,t.popCount=M,t.rotateLeft=(t,i)=>(t<<i|t>>>32-i)>>>0,t.rotateRight=(t,i)=>(t>>>i|t<<32-i)>>>0,t.same4=t=>(t>>4&15)==(15&t),t.same8=t=>(t>>8&255)==(255&t),t.setLane16=(t,i,e)=>e?h(t,i,65535):h(t,i<<16,4294901760),t.setLane2=(t,i,e)=>{const n=15-e<<1;return(~(3<<n)&t|(3&i)<<n)>>>0},t.setLane4=(t,i,e)=>{const n=7-e<<2;return(~(15<<n)&t|(15&i)<<n)>>>0},t.setLane8=(t,i,e)=>{const n=3-e<<3;return(~(255<<n)&t|(255&i)<<n)>>>0},t.splat16_32=t=>((t&=65535)<<16|t)>>>0,t.splat4_24=t=>1118481*(15&t),t.splat4_32=t=>286331153*(15&t)>>>0,t.splat8_24=t=>65793*(255&t),t.splat8_32=t=>16843009*(255&t)>>>0,t.swizzle4=(t,i,e,n,o,a,r,s,b)=>(m(t,i)<<28|m(t,e)<<24|m(t,n)<<20|m(t,o)<<16|m(t,a)<<12|m(t,r)<<8|m(t,s)<<4|m(t,b))>>>0,t.swizzle8=(t,i,e,n,o)=>(d(t,i)<<24|d(t,e)<<16|d(t,n)<<8|d(t,o))>>>0,t.u16f32=t=>((t&=65535)|4294901760*(t>>15))/32767,t.u24f32=t=>((t&=16777215)|4278190080*(t>>23))/8388607,t.u32f32=t=>(0|t)/2147483647,t.u8f32=t=>((t&=255)|4294967040*(t>>7))/127,t.uintBitsToFloat=t=>(o[0]=t,e[0]),t.uintBitsToFloat64=(t,e)=>(a?(o[1]=t,o[0]=e):(o[0]=t,o[1]=e),i[0]),Object.defineProperty(t,"__esModule",{value:!0})})); |
@@ -1,15 +0,29 @@ | ||
export declare const bitNot: (n: number, x: number) => number; | ||
export declare const bitAnd: (n: number, a: number, b: number) => number; | ||
export declare const bitNand: (n: number, a: number, b: number) => number; | ||
export declare const bitOr: (n: number, a: number, b: number) => number; | ||
export declare const bitNor: (n: number, a: number, b: number) => number; | ||
export declare const bitXor: (n: number, a: number, b: number) => number; | ||
export declare const bitXnor: (n: number, a: number, b: number) => number; | ||
export declare const bitImply: (n: number, a: number, b: number) => number; | ||
export declare const bitAoi21: (n: number, a: number, b: number, c: number) => number; | ||
export declare const bitOai21: (n: number, a: number, b: number, c: number) => number; | ||
export declare const bitAoi22: (n: number, a: number, b: number, c: number, d: number) => number; | ||
export declare const bitOai22: (n: number, a: number, b: number, c: number, d: number) => number; | ||
export declare const bitMux: (n: number, a: number, b: number, s: number) => number; | ||
export declare const bitDemux: (n: number, a: number, b: number, s: number) => [number, number]; | ||
export declare const bitNot: (x: number) => number; | ||
export declare const bitAnd: (a: number, b: number) => number; | ||
export declare const bitNand: (a: number, b: number) => number; | ||
export declare const bitOr: (a: number, b: number) => number; | ||
export declare const bitNor: (a: number, b: number) => number; | ||
export declare const bitXor: (a: number, b: number) => number; | ||
export declare const bitXnor: (a: number, b: number) => number; | ||
export declare const bitImply: (a: number, b: number) => number; | ||
export declare const bitAoi21: (a: number, b: number, c: number) => number; | ||
export declare const bitOai21: (a: number, b: number, c: number) => number; | ||
export declare const bitAoi22: (a: number, b: number, c: number, d: number) => number; | ||
export declare const bitOai22: (a: number, b: number, c: number, d: number) => number; | ||
export declare const bitMux: (a: number, b: number, s: number) => number; | ||
export declare const bitDemux: (a: number, b: number, s: number) => [number, number]; | ||
export declare const bitNotM: (n: number, x: number) => number; | ||
export declare const bitAndM: (n: number, a: number, b: number) => number; | ||
export declare const bitNandM: (n: number, a: number, b: number) => number; | ||
export declare const bitOrM: (n: number, a: number, b: number) => number; | ||
export declare const bitNorM: (n: number, a: number, b: number) => number; | ||
export declare const bitXorM: (n: number, a: number, b: number) => number; | ||
export declare const bitXnorM: (n: number, a: number, b: number) => number; | ||
export declare const bitImplyM: (n: number, a: number, b: number) => number; | ||
export declare const bitAoi21M: (n: number, a: number, b: number, c: number) => number; | ||
export declare const bitOai21M: (n: number, a: number, b: number, c: number) => number; | ||
export declare const bitAoi22M: (n: number, a: number, b: number, c: number, d: number) => number; | ||
export declare const bitOai22M: (n: number, a: number, b: number, c: number, d: number) => number; | ||
export declare const bitMuxM: (n: number, a: number, b: number, s: number) => number; | ||
export declare const bitDemuxM: (n: number, a: number, b: number, s: number) => [number, number]; | ||
//# sourceMappingURL=logic.d.ts.map |
45
logic.js
import { maskL } from "./mask"; | ||
export const bitNot = (n, x) => maskL(n, ~x); | ||
export const bitAnd = (n, a, b) => maskL(n, a & b); | ||
export const bitNand = (n, a, b) => maskL(n, ~(a & b)); | ||
export const bitOr = (n, a, b) => maskL(n, a | b); | ||
export const bitNor = (n, a, b) => maskL(n, ~(a & b)); | ||
export const bitXor = (n, a, b) => maskL(n, a ^ b); | ||
export const bitXnor = (n, a, b) => maskL(n, ~(a ^ b)); | ||
export const bitImply = (n, a, b) => maskL(n, ~a | b); | ||
export const bitAoi21 = (n, a, b, c) => maskL(n, ~(a | (b & c))); | ||
export const bitOai21 = (n, a, b, c) => maskL(n, ~(a & (b | c))); | ||
export const bitAoi22 = (n, a, b, c, d) => maskL(n, ~((a & b) | (c & d))); | ||
export const bitOai22 = (n, a, b, c, d) => maskL(n, ~((a | b) & (c | d))); | ||
export const bitMux = (n, a, b, s) => maskL(n, (a & ~s) | (b & s)); | ||
export const bitDemux = (n, a, b, s) => [maskL(n, a & ~s), maskL(n, b & s)]; | ||
export const bitNot = (x) => ~x; | ||
export const bitAnd = (a, b) => a & b; | ||
export const bitNand = (a, b) => ~(a & b); | ||
export const bitOr = (a, b) => a | b; | ||
export const bitNor = (a, b) => ~(a | b); | ||
export const bitXor = (a, b) => a ^ b; | ||
export const bitXnor = (a, b) => ~(a ^ b); | ||
export const bitImply = (a, b) => ~a | b; | ||
export const bitAoi21 = (a, b, c) => ~(a | (b & c)); | ||
export const bitOai21 = (a, b, c) => ~(a & (b | c)); | ||
export const bitAoi22 = (a, b, c, d) => ~((a & b) | (c & d)); | ||
export const bitOai22 = (a, b, c, d) => ~((a | b) & (c | d)); | ||
export const bitMux = (a, b, s) => ((a & ~s) | (b & s)) >>> 0; | ||
export const bitDemux = (a, b, s) => [ | ||
(a & ~s) >>> 0, | ||
(b & s) >>> 0 | ||
]; | ||
export const bitNotM = (n, x) => maskL(n, ~x); | ||
export const bitAndM = (n, a, b) => maskL(n, a & b); | ||
export const bitNandM = (n, a, b) => maskL(n, ~(a & b)); | ||
export const bitOrM = (n, a, b) => maskL(n, a | b); | ||
export const bitNorM = (n, a, b) => maskL(n, ~(a | b)); | ||
export const bitXorM = (n, a, b) => maskL(n, a ^ b); | ||
export const bitXnorM = (n, a, b) => maskL(n, ~(a ^ b)); | ||
export const bitImplyM = (n, a, b) => maskL(n, ~a | b); | ||
export const bitAoi21M = (n, a, b, c) => maskL(n, ~(a | (b & c))); | ||
export const bitOai21M = (n, a, b, c) => maskL(n, ~(a & (b | c))); | ||
export const bitAoi22M = (n, a, b, c, d) => maskL(n, ~((a & b) | (c & d))); | ||
export const bitOai22M = (n, a, b, c, d) => maskL(n, ~((a | b) & (c | d))); | ||
export const bitMuxM = (n, a, b, s) => maskL(n, (a & ~s) | (b & s)); | ||
export const bitDemuxM = (n, a, b, s) => [maskL(n, a & ~s), maskL(n, b & s)]; |
{ | ||
"name": "@thi.ng/binary", | ||
"version": "1.3.2", | ||
"description": "50+ assorted binary / bitwise operations, conversions, utilities", | ||
"version": "2.0.0", | ||
"description": "95+ assorted binary / bitwise operations, conversions, utilities", | ||
"module": "./index.js", | ||
@@ -38,3 +38,3 @@ "main": "./lib/index.js", | ||
"typedoc": "^0.16.10", | ||
"typescript": "^3.8.2" | ||
"typescript": "^3.8.3" | ||
}, | ||
@@ -58,3 +58,3 @@ "keywords": [ | ||
"sideEffects": false, | ||
"gitHead": "d426e5ee02515cbc6a769458a08c0677fe003ec9" | ||
"gitHead": "18014ee1e4978dac7eb2e5d51d0a6ff7d82e9ffc" | ||
} |
<!-- This file is generated - DO NOT EDIT! --> | ||
#  | ||
#  | ||
@@ -23,3 +23,3 @@ [](https://www.npmjs.com/package/@thi.ng/binary) | ||
50+ assorted binary / bitwise operations, conversions, utilities. | ||
95+ assorted binary / bitwise operations, conversions, utilities. | ||
@@ -36,3 +36,3 @@ ### Status | ||
Package sizes (gzipped): ESM: 1.7KB / CJS: 2.0KB / UMD: 1.8KB | ||
Package sizes (gzipped): ESM: 1.9KB / CJS: 2.2KB / UMD: 1.8KB | ||
@@ -55,2 +55,4 @@ ## Dependencies | ||
hdom update performance benchmark w/ config options | ||
[Live demo](https://demo.thi.ng/umbrella/hdom-benchmark2/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/hdom-benchmark2) | ||
@@ -57,0 +59,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
94420
1317
70