1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.getbit = getbit;
|
7 | var MAX_OFFSET = Math.pow(2, 32) - 1;
|
8 |
|
9 | function getbit(key, offset) {
|
10 | if (offset > MAX_OFFSET) throw new Error('ERR bit offset is not an integer or out of range');
|
11 | if (!this.data.has(key)) return 0;
|
12 | var current = this.data.get(key);
|
13 | if (offset > current.length * 8) return 0;
|
14 |
|
15 | var byteOffset = parseInt(offset / 8, 10);
|
16 | var shift = 7 - offset % 8;
|
17 |
|
18 | return current.charCodeAt(byteOffset) >> shift & 1;
|
19 | } |
\ | No newline at end of file |