Gathering detailed insights and metrics for bytestreamjs-wildcards
Gathering detailed insights and metrics for bytestreamjs-wildcards
Gathering detailed insights and metrics for bytestreamjs-wildcards
Gathering detailed insights and metrics for bytestreamjs-wildcards
ByteStream.js is a set of classes manipulating bytes and bits with optimized for speed perfomance
npm install bytestreamjs-wildcards
Typescript
Module System
Min. Node Version
Node Version
NPM Version
TypeScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
NOASSERTION License
84 Commits
2 Branches
1 Contributors
Updated on Oct 03, 2024
Latest Version
2.1.0
Package Id
bytestreamjs-wildcards@2.1.0
Unpacked Size
167.27 kB
Size
18.12 kB
File Count
24
NPM Version
10.8.3
Node Version
20.9.0
Published on
Oct 03, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
ByteStream class is the major class for all others. It provides many useful function for making search for patterns and data transformation. Optimized for fast as possible data processing.
Method | Description |
---|---|
clear | Clear existing stream |
fromArrayBuffer | Initialize "Stream" object from existing "ArrayBuffer" |
fromUint8Array | Initialize "Stream" object from existing "Uint8Array" |
fromString | Initialize "Stream" object from existing string |
toString | Represent "Stream" object content as a string |
fromHexString | Initialize "Stream" object from existing hexdecimal string |
toHexString | Represent "Stream" object content as a hexdecimal string |
copy | Return copy of existing "Stream" |
slice | Return slice of existing "Stream" |
realloc | Change size of existing "Stream" |
append | Append a new "Stream" content to the current "Stream" |
insert | Insert "Stream" content to the current "Stream" at specific position |
isEqual | Check that two "Stream" objects has equal content |
isEqualView | Check that current "Stream" objects has equal content with input "Uint8Array" |
findPattern | Find any byte pattern in "Stream" |
findFirstIn | Find first position of any pattern from input array |
findAllIn | Find all positions of any pattern from input array |
findAllPatternIn | Find all positions of a pattern |
findFirstNotIn | Find first position of data, not included in patterns from input array |
findAllNotIn | Find all positions of data, not included in patterns from input array |
findFirstSequence | Find position of a sequence of any patterns from input array |
findAllSequences | Find all positions of a sequence of any patterns from input array |
findPairedPatterns | Find all paired patterns in the stream |
findPairedArrays | Find all paired patterns in the stream |
replacePattern | Replace one patter with other |
skipPatterns | Skip any pattern from input array |
skipNotPatterns | Skip any pattern not from input array |
SeqStream class is the aux class for sequential reading/writing data from/to ByteStream underline class.
Method | Description |
---|---|
resetPosition | Reset current position of the "SeqStream" |
findPattern | Find any byte pattern in "ByteStream" |
findFirstIn | Find first position of any pattern from input array |
findAllIn | Find all positions of any pattern from input array |
findFirstNotIn | Find first position of data, not included in patterns from input array |
findAllNotIn | Find all positions of data, not included in patterns from input array |
findFirstSequence | Find position of a sequence of any patterns from input array |
findAllSequences | Find position of a sequence of any patterns from input array |
findPairedPatterns | Find all paired patterns in the stream |
findPairedArrays | Find all paired patterns in the stream |
replacePattern | Replace one patter with other |
skipPatterns | Skip of any pattern from input array |
skipNotPatterns | Skip of any pattern from input array |
append | Append a new "Stream" content to the current "Stream" |
appendView | Append a "view" content to the current "Stream" |
appendChar | Append a new char to the current "Stream" |
getBlock | Get a block of data |
getUint32 | Get 4-byte unsigned integer value |
Main purpose of the BitStream is manipulating of each bit inside any ByteStream data.
Method | Description |
---|---|
clear | Clear existing stream |
fromByteStream | Initialize "BitStream" by data from existing "ByteStream" |
fromArrayBuffer | Initialize "BitStream" object from existing "ArrayBuffer" |
fromUint8Array | Initialize "BitStream" object from existing "Uint8Array" |
fromString | Initialize "BitStream" object from existing bit string |
toString | Represent "BitStream" object content as a string |
shiftRight | Shift entire "BitStream" value right to number of bits |
shiftLeft | Shift entire "BitStream" value left to number of bits |
slice | Return slice of existing "BitStream" |
copy | Return copy of existing "BitStream" |
shrink | Shrink unnecessary bytes in current stream accordingly to "bitsCount" value |
reverseBytes | Reverse bits order in each byte in the stream |
reverseValue | Reverse all bits in entire "BitStream" |
getNumberValue | Trying to represent entire "BitStream" as an unsigned integer |
findPattern | Find any bit pattern in "BitStream" |
findFirstIn | Find first position of any pattern from input array |
findAllIn | Find all positions of any pattern from input array |
findAllPatternIn | Find all positions of a pattern |
findFirstNotIn | Find first position of data, not included in patterns from input array |
findAllNotIn | Find all positions of data, not included in patterns from input array |
findFirstSequence | Find position of a sequence of any patterns from input array |
findAllSequences | Find position of a sequence of any patterns from input array |
findPairedPatterns | Find all paired patterns in the stream |
findPairedArrays | Find all paired patterns in the stream |
replacePattern | Replace one pattern with other |
skipPatterns | Skip any pattern from input array |
skipNotPatterns | Skip any pattern not from input array |
append | Append a new "BitStream" content to the current "BitStream" |
SeqBitStream class is the aux class for sequential reading/writing data from/to BitStream underline class.
Method | Description |
---|---|
getBits | Get next "length" bits from the stream |
getBitsString | Get string representation for the next "length" bits from the stream |
getBitsReversedValue | Get number value representation of the next "length" bits from the stream, preliminary reversed |
toString | Represent remaining bits in "BitStream" as a string |
The ByteStream class provides an option to use wildcard byte patterns. These are useful in searching for magic bytes in a file format.
Example of using wildcard byte patterns:
1let wildcard = "?".charCodeAt(0); 2let searchPattern = new ByteStream({ 3 // set wildcard byte value 4 wildcard: wildcard, 5 // set search pattern with wildcard bytes ("s??e ") 6 view: new Uint8Array([0x73, wildcard, wildcard, 0x65, 0x20]) 7}); 8let dataPattern = new ByteStream({ data: 'some random data 0x00 0x00 0x01 0x45' }); 9dataPattern.findPattern(searchPattern); // find search pattern in data pattern
The parseByteMap
function is intended to parse and check byte streams with determined structure.
Example of map used as a kind of template. Exactly this map is using for parsing PDF xref table:
1let map = [ 2 { 3 type: "string", 4 name: "type", 5 minlength: 1, 6 maxlength: 1, 7 func: function(array){ 8 let result = { 9 status: (-1), 10 length: 1 11 }; 12 13 switch(array[0]) 14 { 15 case 0x6E: // "n" 16 result.value = "n"; 17 break; 18 case 0x66: // "f" 19 result.value = "f"; 20 break; 21 default: 22 return result; 23 } 24 25 result.status = 1; 26 27 return result; 28 } 29 }, 30 { 31 type: "check", 32 minlength: 1, 33 maxlength: 2, 34 func: function(array){ 35 let position = (-1); 36 37 if(array[0] == 0x0A) 38 position = 1; 39 if(array[1] == 0x0A) 40 position = 2; 41 42 return { 43 status: (position > 0) ? 1 : (-1), 44 length: position 45 }; 46 } 47 } 48];
Copyright (c) 2016-2022, Peculiar Ventures All rights reserved.
Author 2016-2018 Yury Strozhevsky.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
No vulnerabilities found.
No security vulnerabilities found.