{"id":27048647,"url":"https://github.com/meezwhite/opstring","last_synced_at":"2025-04-05T07:15:29.410Z","repository":{"id":180806546,"uuid":"660809107","full_name":"meezwhite/OpString","owner":"meezwhite","description":"OpString is a JavaScript module for mapping and executing operations defined by character sequences.","archived":false,"fork":false,"pushed_at":"2023-08-31T14:10:06.000Z","size":185,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-05T07:15:25.698Z","etag":null,"topics":["character-sequence","dsl","javascript","javascript-library","javascript-module","mapping","operations","opstring","string","strings"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/meezwhite.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-06-30T22:52:54.000Z","updated_at":"2023-07-18T09:34:06.000Z","dependencies_parsed_at":"2023-07-13T00:01:18.791Z","dependency_job_id":"8bb5d82f-d212-40fe-8422-d4ea738702a7","html_url":"https://github.com/meezwhite/OpString","commit_stats":{"total_commits":170,"total_committers":1,"mean_commits":170.0,"dds":0.0,"last_synced_commit":"cea05816ce85eecaffda3ce737aa1dd7b2bd7876"},"previous_names":["meezwhite/opstring"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meezwhite%2FOpString","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meezwhite%2FOpString/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meezwhite%2FOpString/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meezwhite%2FOpString/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/meezwhite","download_url":"https://codeload.github.com/meezwhite/OpString/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247299851,"owners_count":20916193,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["character-sequence","dsl","javascript","javascript-library","javascript-module","mapping","operations","opstring","string","strings"],"created_at":"2025-04-05T07:15:28.693Z","updated_at":"2025-04-05T07:15:29.405Z","avatar_url":"https://github.com/meezwhite.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpString\n\nOpString is a JavaScript module for mapping and executing operations represented by character sequences.\n\n## Table of Contents\n\n- [Introduction](#introduction)\n- [Getting Started](#getting-started)\n- [Usage](#usage)\n- [Error Handling](#error-handling)\n- [API](#api)\n- [Contributing](#contributing)\n- [License](#license)\n\n\u003ca name=\"introduction\"\u003e\u003c/a\u003e\n## Introduction\n\nOpString simplifies the process of mapping characters to operations and values, and provides functionality to compose character sequences and execute the respective mapped operations.\n\nOpString is particularly useful in scenarios where data saving is crucial. By representing operations using compact character sequences, OpString enables you to pack more functionality into less data, optimizing storage efficiency.\n\nFor example, let's say you have the operations `circle(30, 30, 20)` and `rect(30, 20, 55, 55)` that you would like to store as a string for later use. Your string could look something like this `circle(30,30,20);rect(30,20,55,55)` and would be 34 characters long. With OpString you could represent the same operations with the character sequence `AaabBabcc`, which would shorten it to 9 characters.\n\n\u003ca name=\"getting-started\"\u003e\u003c/a\u003e\n## Getting Started\n\n### Using a bundler\n\nInstall OpString using `npm`:\n\n```bash\nnpm install opstring\n```\n\nImport OpString into your project using the `import` statement.\n\n```js\nimport OpString from 'opstring';\n```\n\n### Without a bundler\n\nDownload the latest version from [Releases](https://github.com/meezwhite/OpString/releases).\n\nImport OpString into your project using the `import` statement, referencing `opstring.js`.\n\n```js\n// app.js\n\nimport OpString from 'opstring.js';\n```\n\nMake sure that the `\u003cscript\u003e` tag, which embeds the JavaScript file containing the import of OpString, has the attribute `type=\"module\"`.\n\n```html\n\u003cscript src=\"app.js\" type=\"module\"\u003e\u003c/script\u003e\n```\n\n\u003ca name=\"usage\"\u003e\u003c/a\u003e\n## Usage\n\nWhen using OpString, there are mainly three steps involved:\n1. Register operations and values\n2. Compose character sequence\n3. Execute character sequence\n\nOpString provides flexibility in managing these steps. Below, you will find two approaches for using OpString, which **can be combined as needed**.\n\n### Approach 1: Define Everything When Creating the OpString Instance\n\nWith this approach, you register operations and values, and specify the character sequence when creating the OpString instance.\n\n```js\n// Create a new instance and configure it with initial settings\nconst opString = new OpString({\n    sequence: 'AaabBabcc',\n    operations: {\n        'A': (x, y, d) =\u003e { console.log(x, y, d); },\n        'B': (x, y, w, h) =\u003e { console.log(x, y, w, h); },\n    },\n    values: {\n        'a': 30,\n        'b': 20,\n        'c': 55,\n    },\n    labels: {\n        'circle': 'A',\n        'rect': 'B',\n    },\n    maxSequenceLength: 10,\n    ignoreWarnings: false, // (default: false)\n    strictMode: true, // (default: false)\n});\n\n// Execute the sequence 'AaabBabcc'\nopString.execute();\n\n// Execute a custom sequence\nopString.execute('Babcc');\n```\n\n*Note: The properties `ignoreWarnings` and `strictMode` can only be configured when creating an OpString instance. (see [Error Handling](#error-handling))*\n\n### Approach 2: Register Operations and Values as Needed\n\nWith this approach, you start with an empty OpString instance and register operations and values as needed. Then, you compose the character sequence by appending, inserting, prepending and removing operations and their corresponding values.\n\n```js\n// Create an empty OpString instance\nconst opString = new OpString();\n\n// Set the maximum sequence length\nopString.setMaxSequenceLength(10);\n\n// Register operations\nopString.registerOperation('A', (x, y, d) =\u003e { console.log(x, y, d); });\nopString.registerOperation('B', (x, y, w, h) =\u003e { console.log(x, y, w, h); });\n// Alternatives: `registerOperations` and `setOperations`\n\n// Register values\nopString.registerValue('a', 30);\nopString.registerValue('b', 20);\nopString.registerValue('c', 55);\n// Alternatives: `registerValues` and `setValues`\n\n// Register labels\nopString.registerLabel('circle', 'A');\nopString.registerLabel('twenty', 'b');\n// Alternatives: `registerLabels` and `setLabels`\n\n// Get symbols for values\nconst char = opString.getCharForValue(55); // Returns: 'c'\nconst charCode = opString.getCharCodeForValue(55); // Returns: 99\n\n// Get symbols for labels\nconst labelChar = opString.getCharForLabel('circle'); // Returns: 'A'\nconst labelCharCode = opString.getCharCodeForLabel('circle'); // Returns: 65\n\n// Compose the character sequence\nopString.append('A', ['a', 'a', 'b']);\nopString.append('B', ['a', 'b', 'c', 'c']);\n// Alternative: `setSequence`\n\n// Insert an operation at a specific position\nconst operationId = opString.insert(1, 'X', ['x', 'y', 'z']);\n\nconsole.debug(opString.getSequence());\n// Expected output: 'AaabXxyzBabcc'\n\n// Remove an operation by its id\nopString.remove(operationId);\n\nconsole.debug(opString.getSequence());\n// Expected output: 'AaabBabcc'\n\n// Execute the composed sequence\nopString.execute();\n\n// Execute a custom sequence\nopString.execute('Babcc');\n```\n\n\u003ca name=\"error-handling\"\u003e\u003c/a\u003e\n## Error Handling\n\nOpString aims to handle errors gracefully, providing warnings without interrupting its functionality.\n\n### `ignoreWarnings`\n\nTo ignore warnings, you can set `ignoreWarnings` to `true` when creating an OpString instance. When `ignoreWarnings` is `true` and errors occur, warnings will not be logged to the console.\n\n```js\n// Create an OpString instance and ignore warnings\nconst opString = new OpString({\n    ignoreWarnings: true, // (default: false)\n});\n```\n\n### `strictMode`\n\nTo enable `strictMode`, you can set `strictMode` to `true` when creating an OpString instance.\n\nIn `strictMode` OpString will log errors instead of warnings to the console. Furthermore, OpString will not be as graceful anymore and certain functionalities like `setSequence` or `execute` will not work when errors occur, such as exceeding the `maxSequenceLength` limit.\n\n```js\n// Create an OpString instance with `strictMode` enabled\nconst opString = new OpString({\n    strictMode: true, // (default: false)\n});\n```\n\n*Note: In `strictMode` the `ignoreWarnings` property is irrelevant as warnings are never logged.*\n\n\u003ca name=\"api\"\u003e\u003c/a\u003e\n## API\n\n*Note: OpString is still in the initial development phase and the API can still change. Always review the release notes.*\n\nOpString exposes the following properties and methods:\n\n### Properties\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003eversion\u003c/code\u003e\u003c/summary\u003e\n\u003cbr\u003eA string representing the version of OpString.\n\n#### Examples\n\n```js\n// Access the version of OpString\nconsole.log(opString.version);\n\n// Output: '0.5.1'\n```\n\n\u003c/br\u003e\n\u003c/details\u003e\n\n### Methods\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003econstructor(config?)\u003c/code\u003e\u003c/summary\u003e\n\u003cbr\u003eCreates an instance of OpString.\n\n### Examples\n\n```js\n// Create an empty OpString instance\nconst opString = new OpString();\n\n// Create an OpString instance and enable `strictMode`\nconst opString = new OpString({\n    strictMode: true, // (default: false)\n});\n\n// Create a new instance and configure it with initial settings\nconst opString = new OpString({\n    sequence: 'AaabBabcc',\n    operations: {\n        'A': (x, y, d) =\u003e { console.log(x, y, d); },\n        'B': (x, y, w, h) =\u003e { console.log(x, y, w, h); },\n    },\n    values: {\n        'a': 30,\n        'b': 20,\n        'c': 55,\n    },\n    labels: {\n        'circle': 'A',\n        'rect': 'B',\n    },\n    maxSequenceLength: 10,\n    ignoreWarnings: false, // (default: false)\n    strictMode: true, // (default: false)\n});\n```\n\n### Parameters\n\n| Parameter | Type | Description |\n| --- | --- | --- |\n| `config?` | `Object` | (Optional) Config object to configure OpString features. |\n| `config.sequence?` | `string` | (Optional) The character sequence to be executed when `execute` is called without providing a sequence parameter. (default: `''`) |\n| `config.operations?` | `Object` | (Optional) Object containing the operation mappings to be registered. (default: `{}`) |\n| `config.values?` | `string` | (Optional) Object containing the value mappings to be registered. (default: `{}`) |\n| `config.labels?` | `string` | (Optional) Object containing the label mappings to be registered. (default: `{}`) |\n| `config.maxSequenceLength?` | `string` | (Optional) Specifies a maximum allowed sequence length. If defined, it must be a positive safe integer. (default: `undefined`) |\n| `config.ignoreWarnings?` | `string` | (Optional) Specifies whether warnings should be ignored. (default: `false`) |\n| `config.strictMode?` | `string` | (Optional) Specifies the behavior of the OpString with regard to errors. If set to `true`, errors will be logged; otherwise, warnings will be logged. Furthermore, if set to `true` the `maxSequenceLength` must strictly be adhered to, otherwise, the respective character sequence will not be set/executed. (default: `false`) |\n\n\u003c/br\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003egetNextId()\u003c/code\u003e\u003c/summary\u003e\n\u003cbr\u003eReturns the id to be assigned to the next appended operation.\n\n#### Examples\n\n```js\n// Get the next operation id\nconst nextId = opString.getNextId();\n\n// Example output: 3\n```\n\n#### Returns\n\n`number` - The next operation id\n\n\u003c/br\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003eappend(operation, values?)\u003c/code\u003e\u003c/summary\u003e\n\u003cbr\u003eAppends an operation to the sequence and returns the id of the appended operation.\n\n#### Examples\n\n```js\n// Append an operation to the sequence and return its id\nconst operationId = opString.append('V');\n\n// Specify the values to be passed to the operation. This will append 'Aaab' to the sequence.\nopString.append('A', ['a', 'a', 'b']);\n\n/**\n * Alternatively, you can use character codes instead of characters (e.g. 'A'.charCodeAt(0) =\u003e 65).\n * This will also append 'Aaab' to the sequence.\n */\nopString.append(65, [97, 97, 98]);\n```\n\n#### Parameters\n\n| Parameter | Type | Description |\n| --- | --- | --- |\n| `operation` | `string\\|number` | The character code of the operation to be appended. |\n| `values?` | `Array\u003cstring\\|number\u003e` | (Optional) An array with the character codes of the values corresponding to the operation to be appended. |\n\n#### Returns\n\n`number|boolean` - The id of the appended operation or `false` if the operation wasn't appended.\n\n\u003c/br\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003einsert(index, operation, values?)\u003c/code\u003e\u003c/summary\u003e\n\u003cbr\u003eInserts an operation to the sequence at the specified index and returns the id of the inserted operation.\n\n#### Examples\n\n```js\n/**\n * Insert an operation at index 2 of the operations to be executed and returns \n * its id. The operation will be the third one to be executed.\n */\nconst operationId = opString.insert(2, 'V');\n\n/**\n * Specify the values to be passed to the operation.\n * \n * The following example inserts the operation 'Aaab' at index 2 of the\n * operations to be executed, making it the third operation to be executed.\n */\nopString.insert(2, 'A', ['a', 'a', 'b']);\n\n/**\n * Alternatively, you can use character codes instead of characters (e.g. 'A'.charCodeAt(0) =\u003e 65).\n * This will also insert 'Aaab' at index 2 of the sequence.\n */\nopString.insert(2, 65, [97, 97, 98]);\n```\n\n#### Parameters\n\n| Parameter | Type | Description |\n| --- | --- | --- |\n| `index` | `number` | The index at which the operation should be added. |\n| `operation` | `string\\|number` | The character code of the operation to be appended. |\n| `values?` | `Array\u003cstring\\|number\u003e` | (Optional) An array with the character codes of the values corresponding to the operation to be appended. |\n\n#### Returns\n\n`number|boolean` - The id of the inserted operation or `false` if the operation wasn't inserted.\n\n\u003c/br\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003eprepend(operation, values?)\u003c/code\u003e\u003c/summary\u003e\n\u003cbr\u003ePrepends an operation to the sequence and returns its id.\n\n#### Examples\n\n```js\n// Prepend an operation to the sequence and return its id\nconst operationId = opString.prepend('V');\n\n// Specify the values to be passed to the operation. This will prepend 'Aaab' to the sequence.\nopString.prepend('A', ['a', 'a', 'b']);\n\n/**\n * Alternatively, you can use character codes instead of characters (e.g. 'A'.charCodeAt(0) =\u003e 65).\n * This will also prepend 'Aaab' to the sequence.\n */\nopString.prepend(65, [97, 97, 98]);\n```\n\n#### Parameters\n\n| Parameter | Type | Description |\n| --- | --- | --- |\n| `operation` | `string\\|number` | The character or character code of the operation to be prepended. |\n| `values?` | `Array\u003cstring\\|number\u003e` | (Optional) An array with the characters or character codes of the values corresponding to the operation to be prepended. |\n\n#### Returns\n\n`number|boolean` - The id of the prepended operation or `false` if the operation wasn't prepended.\n\n\u003c/br\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003eremove(id)\u003c/code\u003e\u003c/summary\u003e\n\u003cbr\u003eRemoves the operation with the specified id from the sequence.\n\n#### Examples\n\n```js\n// Remove operation with id 3 from the sequence\nconst removed = opString.remove(3);\n```\n\n#### Parameters\n\n| Parameter | Type | Description |\n| --- | --- | --- |\n| `id` | `number` | The id of the operation that should be removed. |\n\n#### Returns\n\n`boolean` - If the respective operation was removed `true`, otherwise `false`.\n\n\u003c/br\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003eindex(id)\u003c/code\u003e\u003c/summary\u003e\n\u003cbr\u003eReturns the index of the operation with the provided id in the sequence.\n\n#### Examples\n\n```js\n// Get the index of operation with id 3 in the sequence\nconst operationIndex = opString.index(3);\n```\n\n#### Parameters\n\n| Parameter | Type | Description |\n| --- | --- | --- |\n| `id` | `number` | The id of the operation in the sequence for which the index should be returned. |\n\n#### Returns\n\n`number|undefined` - Index of the operation in the sequence, or `undefined` if not found.\n\n\u003c/br\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003esetSequence(sequence)\u003c/code\u003e\u003c/summary\u003e\n\u003cbr\u003eSets the character sequence.\n\n#### Examples\n\n```js\n// Set the character sequence\nopString.setSequence('AaabBabcc');\n\n/**\n * Handling an unknown value character\n *\n * Suppose the sequence is 'Ba?c'. The '?' represents an unknown value character.\n * In this case, the unknown character will be registered with a value of `null`.\n * By registering it this way, the associated operation can still be executed.\n */\nopString.setSequence('Ba?c');\n```\n\n#### Parameters\n\n| Parameter | Type | Description |\n| --- | --- | --- |\n| `sequence` | `string` | The character sequence that should be set. |\n\n\u003c/br\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003egetSequence()\u003c/code\u003e\u003c/summary\u003e\n\u003cbr\u003eReturns the character sequence.\n\n#### Examples\n\n```js\n// Get the character sequence\nconst sequence = opString.getSequence();\n\n// Example output: 'AaabBabcc'\n```\n\n#### Returns\n\n`string` - The character sequence.\n\n\u003c/br\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003egetSequenceData()\u003c/code\u003e\u003c/summary\u003e\n\u003cbr\u003eReturns the sequence data array.\n\n#### Examples\n\n```js\n// Get the sequence data array\nconst sequenceData = opString.getSequenceData();\n\n// Example output for sequence 'AaabBabcc':\n// [\n//   { id: 1, operation: 65, values: [ 97, 97, 98 ] },\n//   { id: 2, operation: 66, values: [ 97, 98, 99, 99 ] }\n// ]\n```\n\n#### Returns\n\n`Array\u003cObject\u003e` - The sequence data array\n\n\u003c/br\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003eregisterOperation(symbol, callback)\u003c/code\u003e\u003c/summary\u003e\n\u003cbr\u003eRegisters an operation mapping.\n\n#### Examples\n\n```js\n// Register an operation mapping\nopString.registerOperation('X', () =\u003e console.log('Operation X'));\n\n// Register an operation mapping using character code\nopString.registerOperation(88, () =\u003e console.log('Operation X'));\n```\n\n#### Parameters\n\n| Parameter | Type | Description |\n| --- | --- | --- |\n| `symbol` | `string|number` | The character or character code to be mapped to a function. |\n| `callback` | `function` | The function to which the symbol should be mapped. |\n\n\u003c/br\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003eregisterOperations(operations)\u003c/code\u003e\u003c/summary\u003e\n\u003cbr\u003eRegisters additional operation mappings provided by the `operations` object.\n\n#### Examples\n\n```js\n// Register additional operation mappings\nopString.registerOperations({\n    'D': () =\u003e { /*...*/ },\n    'E': () =\u003e { /*...*/ },\n    'F': () =\u003e { /*...*/ },\n});\n\n// Register additional operation mappings using chracter codes\nopString.registerOperations({\n    68: () =\u003e { /*...*/ },\n    69: () =\u003e { /*...*/ },\n    70: () =\u003e { /*...*/ },\n});\n```\n\n#### Parameters\n\n| Parameter | Type | Description |\n| --- | --- | --- |\n| `operations` | `Object` | Object containing additional operation mappings to be registered. |\n\n\u003c/br\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003esetOperations(operations)\u003c/code\u003e\u003c/summary\u003e\n\u003cbr\u003eRegisters the operation mappings provided by the `operations` object. Previously registered operation mappings will be deleted.\n\n#### Examples\n\n```js\n// Set new operation mappings\nopString.setOperations({\n    'A': () =\u003e { /*...*/ },\n    'B': () =\u003e { /*...*/ },\n    'C': () =\u003e { /*...*/ },\n});\n```\n\n#### Parameters\n\n| Parameter | Type | Description |\n| --- | --- | --- |\n| `operations` | `Object` | Object containing new operation mappings to be registered. |\n\n\u003c/br\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003egetOperations()\u003c/code\u003e\u003c/summary\u003e\n\u003cbr\u003eReturns the registered operations.\n\n#### Examples\n\n```js\n// Get the registered operations\nconst operations = opString.getOperations();\n\n// Example output:\n// { '65': [Function: A], '66': [Function: B] }\n```\n\n#### Returns\n\n`Object` - The registered operations\n\n\u003c/br\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003eregisterValue(symbol, value)\u003c/code\u003e\u003c/summary\u003e\n\u003cbr\u003eRegisters a value mapping.\n\n#### Examples\n\n```js\n// Register a value mapping\nopString.registerValue('x', 10);\n\n// Register a value mapping using character code\nopString.registerValue(120, 10);\n```\n\n#### Parameters\n\n| Parameter | Type | Description |\n| --- | --- | --- |\n| `symbol` | `string|number` | The character or character code to be mapped to a value. |\n| `value` | `*` | The value to which the symbol should be mapped. |\n\n\u003c/br\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003eregisterValues(values)\u003c/code\u003e\u003c/summary\u003e\n\u003cbr\u003eRegisters additional value mappings provided by the `values` object.\n\n#### Examples\n\n```js\n// Register additional value mappings\nopString.registerValues({\n    'x': 10,\n    'y': 11,\n    'z': 12,\n});\n\n// Alternatively, you can register additional value mappings using character codes\nopString.registerValues({\n    120: 10,\n    121: 11,\n    122: 12,\n});\n```\n\n#### Parameters\n\n| Parameter | Type | Description |\n| --- | --- | --- |\n| `values` | `Object` | Object containing additional value mappings to be registered. |\n\n\u003c/br\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003esetValues(values)\u003c/code\u003e\u003c/summary\u003e\n\u003cbr\u003eRegisters the value mappings provided by the `values` object. Previously registered value mappings will be deleted.\n\n#### Examples\n\n```js\n// Set new value mappings\nopString.setValues({\n    'a': 1,\n    'b': 2,\n    'c': 3,\n});\n\n// Alternatively, you can set new value mappings using character codes\nopString.setValues({\n    97: 1,\n    98: 2,\n    99: 3,\n});\n```\n\n#### Parameters\n\n| Parameter | Type | Description |\n| --- | --- | --- |\n| `values` | `Object` | Object containing new value mappings to be registered. |\n\n\u003c/br\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003egetValues()\u003c/code\u003e\u003c/summary\u003e\n\u003cbr\u003eReturns the registered values.\n\n#### Examples\n\n```js\n// Get the registered values\nconst values = opString.getValues();\n\n// Example output:\n// { '97': 30, '98': 20, '99': 55 }\n```\n\n#### Returns\n\n`Object` - The registered values.\n\n\u003c/br\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003egetCharForValue(value)\u003c/code\u003e\u003c/summary\u003e\n\u003cbr\u003eReturns the corresponding character for the provided value, if the value is registered.\n\n#### Examples\n\n```js\n// Get the corresponding character for the provided value\nconst char = opString.getCharCodeForValue(55);\n\n// Example output: 'c'\n```\n\n#### Parameters\n\n| Parameter | Type | Description |\n| --- | --- | --- |\n| `value` | `*` | The value for which a coresponding character should be returned. |\n\n#### Returns\n\n`string|undefined` - If the value is registered, the corresponding character is returned; otherwise `undefined`.\n\n\u003c/br\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003egetCharCodeForValue(value)\u003c/code\u003e\u003c/summary\u003e\n\u003cbr\u003eReturns the corresponding character code for the provided value, if the value is registered.\n\n#### Examples\n\n```js\n// Get the corresponding charCode for the provided value\nconst charCode = opString.getCharCodeForValue(55);\n\n// Example output: 99\n```\n\n#### Parameters\n\n| Parameter | Type | Description |\n| --- | --- | --- |\n| `value` | `*` | The value for which a coresponding character code should be returned. |\n\n#### Returns\n\n`number|undefined` - If the value is registered, the corresponding character code is returned; otherwise `undefined`.\n\n\u003c/br\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003eregisterLabel(label, symbol)\u003c/code\u003e\u003c/summary\u003e\n\u003cbr\u003eRegisters a label mapping to represent the provided symbol.\n\n#### Examples\n\n```js\n// Register a label mapping\nopString.registerLabel('circle', 'A');\n\n// Register a label mapping using character code\nopString.registerLabel('circle', 65);\n```\n\n#### Parameters\n\n| Parameter | Type | Description |\n| --- | --- | --- |\n| `label` | `string` | The label to represent the provided symbol. |\n| `symbol` | `string\\|number` | The character or character code to be mapped to the label. |\n\n\u003c/br\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003eregisterLabels(labels)\u003c/code\u003e\u003c/summary\u003e\n\u003cbr\u003eRegisters additional label mappings provided by the `labels` object.\n\n#### Examples\n\n```js\n// Register additional label mappings\nopString.registerLabels({\n    'circle': 'A',\n    'rect': 'B',\n    'ten': 'x',\n});\n\n// Alternatively, you can register additional label mappings using character codes\nopString.registerLabels({\n    'circle': 65,\n    'rect': 66,\n    'ten': 120,\n});\n```\n\n#### Parameters\n\n| Parameter | Type | Description |\n| --- | --- | --- |\n| `labels` | `Object` | Object containing additional label mappings to be registered. |\n\n\u003c/br\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003esetLabels(labels)\u003c/code\u003e\u003c/summary\u003e\n\u003cbr\u003eRegisters the label mappings provided by the `labels` object. Previously registered label mappings will be deleted.\n\n#### Examples\n\n```js\n// Set new label mappings\nopString.setLabels({\n    'circle': 'A',\n    'rect': 'B',\n    'ten': 'x',\n});\n\n// Alternatively, you can set new label mappings using character codes\nopString.setLabels({\n    'circle': 65,\n    'rect': 66,\n    'ten': 120,\n});\n```\n\n#### Parameters\n\n| Parameter | Type | Description |\n| --- | --- | --- |\n| `labels` | `Object` | Object containing new label mappings to be registered. |\n\n\u003c/br\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003egetLabels()\u003c/code\u003e\u003c/summary\u003e\n\u003cbr\u003eReturns the registered labels.\n\n#### Examples\n\n```js\n// Get the registered labels\nconst labels = opString.getLabels();\n\n// Example output:\n// { 'circle': 65, 'rect': 66, 'ten': 120 }\n```\n\n#### Returns\n\n`Object` - The registered labels.\n\n\u003c/br\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003egetCharForLabel(label)\u003c/code\u003e\u003c/summary\u003e\n\u003cbr\u003eReturns the corresponding character for the provided label, if the label is registered.\n\n#### Examples\n\n```js\n// Get the corresponding character for the provided label\nconst char = opString.getCharCodeForLabel('circle');\n\n// Example output: 'A'\n```\n\n#### Parameters\n\n| Parameter | Type | Description |\n| --- | --- | --- |\n| `label` | `string` | The label for which a coresponding character should be returned. |\n\n#### Returns\n\n`string|undefined` - If the label is registered, the corresponding character is returned; otherwise `undefined`.\n\n\u003c/br\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003egetCharCodeForLabel(label)\u003c/code\u003e\u003c/summary\u003e\n\u003cbr\u003eReturns the corresponding character code for the provided label, if the label is registered.\n\n#### Examples\n\n```js\n// Get the corresponding charCode for the provided label\nconst charCode = opString.getCharCodeForLabel('circle');\n\n// Example output: 65\n```\n\n#### Parameters\n\n| Parameter | Type | Description |\n| --- | --- | --- |\n| `label` | `string` | The label for which a coresponding character code should be returned. |\n\n#### Returns\n\n`number|undefined` - If the label is registered, the corresponding character code is returned; otherwise `undefined`.\n\n\u003c/br\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003esetMaxSequenceLength(maxSequenceLength)\u003c/code\u003e\u003c/summary\u003e\n\u003cbr\u003eSets the maximum allowed sequence limit.\n\n#### Examples\n\n```js\n// Set the maximum sequence length to 100\nopString.setMaxSequenceLength(100);\n```\n\n#### Parameters\n\n| Parameter | Type | Description |\n| --- | --- | --- |\n| `maxSequenceLength` | `number` | The maximum allowed sequence length. |\n\n\u003c/br\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003egetMaxSequenceLength()\u003c/code\u003e\u003c/summary\u003e\n\u003cbr\u003eReturns the configured `maxSequenceLength` value. If the `maxSequenceLength` has not been configured, `undefined` is returned.\n\n#### Examples\n\n```js\n// Get the max sequence length\nconst maxSequenceLength = opString.getMaxSequenceLength();\n\n// Example output, if configured: 100\n\n// Output, if not configured: undefined\n```\n\n#### Returns\n\n`number|undefined` - The configured `maxSequenceLength` value, or `undefined` if not configured.\n\n\u003c/br\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003eexecute(sequence?)\u003c/code\u003e\u003c/summary\u003e\n\u003cbr\u003eAttempts to execute the character sequence of the current instance or a provided character sequence specified by the `sequence` parameter.\n\n#### Examples\n\n```js\n// Execute the character sequence of the current instance\nopString.execute();\n\n// Execute a provided character sequence\nopString.execute('XxxyYxyzz');\n```\n\n#### Parameters\n\n| Parameter | Type | Description |\n| --- | --- | --- |\n| `sequence` | `string` | (Optional) The character sequence to be executed instead of the character sequence of the current instance. |\n\n\u003c/br\u003e\n\u003c/details\u003e\n\n\u003ca name=\"contributing\"\u003e\u003c/a\u003e\n## Contributing\n\nAre you considering contributing to OpString? Check out our [contributing guidelines](./CONTRIBUTING.md).\n\n\u003ca name=\"license\"\u003e\u003c/a\u003e\n## License\n\nOpString is [MIT licensed](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeezwhite%2Fopstring","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmeezwhite%2Fopstring","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeezwhite%2Fopstring/lists"}