new Field(content)
- Description:
- Represents a Field in a Segment.
- Source:
Examples
const field = new Field("ST");
const field = new Field("997");
const field = new Field("0001");
Parameters:
Name |
Type |
Description |
content |
String
|
The content of the Field. |
Methods
(static) getLength() → {Number}
- Description:
- Returns the length of the Field.
- Source:
Example
console.log(field.content);
// "ST"
const length = field.getLength();
console.log(length);
// 2
Returns:
-
Type
-
Number
(static) toJSON() → {Object}
- Description:
- Returns a JSON representation of the Field.
- Source:
Examples
const json = field.toJSON();
console.log(json);
// {
// content: "ST",
// }
const json = field.toJSON();
console.log(json);
// {
// content: "997",
// }
Returns:
-
Type
-
Object
(static) toString() → {String}
- Description:
- Returns the Field as a string.
- Source:
Example
console.log(field.toString());
// "ST"
Returns:
-
Type
-
String
(static) trim() → {Field}
- Description:
- Removes whitespace from the Field and replaces newlines, tabs, and carriage returns with an empty string.
- Source:
Example
console.log(field.content);
// " ST\n"
field.trim();
console.log(field.content);
// "ST"
Returns:
-
Type
-
Field