UNPKG

asn1-ts

Version:

ASN.1 encoding and decoding, including BER, CER, and DER.

10 lines (9 loc) 265 B
export default function setBit(to, bitIndex, value) { const byteIndex = to.length - (Math.floor(bitIndex / 7) + 1); if (value) { to[byteIndex] |= (0x01 << (bitIndex % 7)); } else { to[byteIndex] &= ~(0x01 << (bitIndex % 7)); } }