{"id":17087895,"url":"https://github.com/geraintluff/jsfx-preprocessor","last_synced_at":"2025-08-19T08:33:10.825Z","repository":{"id":66040934,"uuid":"80006602","full_name":"geraintluff/jsfx-preprocessor","owner":"geraintluff","description":null,"archived":false,"fork":false,"pushed_at":"2018-12-07T11:33:18.000Z","size":15,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-23T15:16:34.394Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/geraintluff.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-01-25T11:01:42.000Z","updated_at":"2023-12-16T00:49:59.000Z","dependencies_parsed_at":null,"dependency_job_id":"9b931a3a-e55c-4ae2-8a8c-2eef93707d8b","html_url":"https://github.com/geraintluff/jsfx-preprocessor","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/geraintluff/jsfx-preprocessor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geraintluff%2Fjsfx-preprocessor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geraintluff%2Fjsfx-preprocessor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geraintluff%2Fjsfx-preprocessor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geraintluff%2Fjsfx-preprocessor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/geraintluff","download_url":"https://codeload.github.com/geraintluff/jsfx-preprocessor/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geraintluff%2Fjsfx-preprocessor/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271121776,"owners_count":24702871,"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","status":"online","status_checked_at":"2025-08-19T02:00:09.176Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-10-14T13:35:20.004Z","updated_at":"2025-08-19T08:33:10.771Z","avatar_url":"https://github.com/geraintluff.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JSFX Pre-Processor\n\nThis is a pre-processor for REAPER's JSFX language, that makes it easier to manage structured data and large code-bases.\n\nIt adds two types of syntax: automatic enums and switchable functions.\n\n## Usage\n\nAs command-line tool (installed with `npm install --global jsfx-preprocessor`):\n\n```\njsfx-preprocessor input.txt output.jsfx\n```\n\nFrom Node:\n\n```javascript\nvar pp = require('jsfx-preprocessor'); // function\n\nvar code = fs.readFileSync(inputFile, {encoding: 'utf-8'});\nfs.writeFileSync(outputFile, pp(code));\n```\n\nOnline demo:\n\nThere is a [webpage](https://geraintluff.github.io/jsfx-preprocessor/) where you can try it out in the browser.\n\n## Automatic enums\n\nThis is designed to help you use structured data within the memory block/array.  A group identifier can be composed of letters, numbers, and `_`, followed by the hash symbol `#`.\n\nGiven a group, e.g. `FOO#`, each suffix (e.g. `FOO#bar`) is given a unique index, counting from zero.  The plain expression (e.g. just `FOO#` without a suffix) is replaced by the number of suffices there are defined by that group.\n\n### Example\n\nInput:\n\n```\npointer = mylist_start; // Array of MYSTRUCTs\nwhile (pointer \u003c mylist_end) (\n\tpointer[MYSTRUCT#FOO] = \"foo\";\n\tpointer[MYSTRUCT#BAR] = 5;\n\tpointer += MYSTRUCT#; // Struct length\n);\n```\n\nOutput:\n\n```\npointer = mylist_start; // Array of MYSTRUCTs\nwhile (pointer \u003c mylist_end) (\n\tpointer[0] = \"foo\";\n\tpointer[1] = 5;\n\tpointer += 2;\n);\n```\n\n### Forcing\n\nTo force an enum to have a particular value, you can include a number in brackets after it, e.g. `FOO#bar(5)`.  If there is a conflict in these, the pre-processor throws an error.\n\n### Counting\n\nIf a group is not counted (e.g. `FOO#`) at any point in the code, then a warning is produced.\n\n## Switchable functions\n\nThe JSFX language has no function pointers, but sometimes you want a different function to be called depending on a field in your struct.  In that case, you can create a \"switchable function group\", which generates a function that checks the value and then relays to other functions.\n\n### Example\n\nInput:\n\n```\npointer[MYSTRUCT#INIT_FUNC] = {init_func}some_init; // Create reference to function\nfunction some_init(x, y) (\n\t// Perform some init\n);\n\n// Group declaration - placed below all references\nfunction {init_func}(x, y);\n\n// Call a function pointer\n{init_func:pointer[MYSTRUCT#INIT_FUNC]}(1, 2);\n```\n\nOutput:\n\n```\npointer[0] = 1; // Create reference to function\nfunction some_init(x, y) (\n        // Perform some init\n);\n\n// Group declaration - placed below all references\nfunction init_func(function_id, x, y) (\n        function_id ? (\n                function_id == 1 ? some_init(x, y)\n        );\n);;\n\n// Call a function pointer\ninit_func(pointer[0], 1, 2);\n```\n\n## Sequence templates\n\nUnrolling loops produces a lot of almost-duplicated code, so we have a syntax for numeric sequences.\n\nSequences are opened with `{#var=start,end}` and closed with `{#}`.  `start` and `end` are integers.  The limits are inclusive, and can be reversed to get a backwards-counting sequence.\n\n### Example\n\nInput:\n\n```\n{#FOO=1,10}\nvarFOO += FOO;\n{#}\n```\n\nOutput:\n\n```\nvar1 += 1;\nvar2 += 2;\nvar3 += 3;\nvar4 += 4;\nvar5 += 5;\nvar6 += 6;\nvar7 += 7;\nvar8 += 8;\nvar9 += 9;\nvar10 += 10;\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeraintluff%2Fjsfx-preprocessor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeraintluff%2Fjsfx-preprocessor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeraintluff%2Fjsfx-preprocessor/lists"}