2.0.7 • Published 1 year ago

binarytojson v2.0.7

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

Types of format

export const formats = {
  string: 'string',
  stringNumber: 'stringNumber',
  number: 'number',
  float: 'float',
  bitFlag: 'bitFlag',
  array: 'array',
  spare: 'spare',
  flag: 'flag',
  packed: 'packed',
  packedNumber: 'packedNumber',
  date: 'date',
};

Description of each format

string: The hex data is directly converted into EBCDIC (string). If the hex data matches the pattern /\0.*$/g then an empty string ("") is populated

stringNumber: This format assumes that the hex data is a string which represents a number. It first converts the hex data to EBCDIC (string) and then uses the parseFloat function to convert the string into a float.

number: Directly converts the hex into decimal

float: Directly converts the hex into decimal and then divides by 100

bitFlag: This format is for a single byte of data. The single byte is converted into 8 bits, and then depending on the value of the bit, if its 1, the data is set to true and if its 0, the data is set to false.

array: This format is useful for array type of data. The normal layout fields work a bit differently in format array

  • numBytes: For array, numBytes field holds the size of a SINGLE ELEMENT. Suppose you have a array of size 10 and each array element is a character of size 1 byte. The value of numBytes in this case should be 1
  • numEntries: This is a special field only used in format array. This represents the number of elements in the array. Suppose you have a array of size 10 and each array element is a character of size 1 byte. The value of numEntries in this case should be 10
  • base: This is a special field only used in format array. This field holds the base location in the JSON where the array must reside.
  • arrayDetails: This is a special field only used in format array. arrayDetails holds a new Layout format which describes the layout of the array which is being mapped.

spare: Should only be used when you want to ignore the data. No location field needed in this format because the data isnt being inserted anyways

flag: If the hex data is e8 (Y) or a8 (y), then the data is set to true else false

packed: Only the last character is removed the from hex data. Reset everything is kept the same. Even the data itself stays in hex format

packedNumber: The last character is removed from the hex data. Then a decimal point in inserted at second last position. After this, the parseFloat method is ran.

date: This format is similar to packed, where in it removes the last character from the hex data. The remaining data is the parsed into the mainframe date format, ran throught Luxon's DateTime.local() function and only the date is returned using toISODate() function

binary: Not implemented yet

2.0.7

1 year ago

2.0.5

1 year ago

2.0.4

1 year ago

2.0.6

1 year ago

2.0.3

1 year ago

2.0.2

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago