const phoneNumber = function (result, chars, phraseIndex, data) {
if (result.state === id.MATCH) {
if (Array.isArray(data) === false) {
throw new Error("parser's user data must be an array");
}
data.length = 0;
}
};
const areaCode = function (result, chars, phraseIndex, data) {
if (result.state === id.MATCH) {
data['area-code'] = apgLib.utils.charsToString(chars, phraseIndex, result.phraseLength);
}
};
const subscriber = function (result, chars, phraseIndex, data) {
if (result.state === id.MATCH) {
data.subscriber = apgLib.utils.charsToString(chars, phraseIndex, result.phraseLength);
}
};
parser.callbacks['phone-number'] = phoneNumber;
parser.callbacks['area-code'] = areaCode;
parser.callbacks.u_office = UDToffice;
parser.callbacks.subscriber = subscriber;
const inputString = '(555)234-5678';
const inputCharacterCodes = apgLib.utils.stringToChars(inputString);
const startRule = 'phone-number';
const phoneParts = [];