You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
509 B
JavaScript
16 lines
509 B
JavaScript
"use strict";
|
|
|
|
module.exports = function stringOperation({ textMode, characterIndex, input, operation }) {
|
|
let { string } = operation;
|
|
|
|
if (!textMode) {
|
|
throw new Error(`Cannot use string literal rules in binary parsing mode`);
|
|
} else if (currentIndex + string.length > input.length) {
|
|
return NotEnoughInput;
|
|
} else if (input.slice(characterIndex, characterIndex + string.length) === operation.string) {
|
|
return { value: string, consumedCharacters: string.length };
|
|
} else {
|
|
return NoMatch;
|
|
}
|
|
};
|