{"id":16209210,"url":"https://github.com/gilzoide/stringstream-lua","last_synced_at":"2025-08-02T05:08:23.718Z","repository":{"id":70590676,"uuid":"327166359","full_name":"gilzoide/stringstream-lua","owner":"gilzoide","description":"An object that loads chunks of strings on demand compatible with a subset of the Lua string API suitable for parsing","archived":false,"fork":false,"pushed_at":"2023-01-08T14:42:05.000Z","size":60,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-22T10:44:15.009Z","etag":null,"topics":["lua","lua-library","stream","streaming-parser","stringstream"],"latest_commit_sha":null,"homepage":"https://gilzoide.github.io/stringstream-lua/","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gilzoide.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":["gilzoide"],"patreon":null,"open_collective":null,"ko_fi":"gilzoide","tidelift":null,"community_bridge":null,"liberapay":"gilzoide","issuehunt":null,"otechie":null,"custom":["https://www.buymeacoffee.com/gilzoide"]}},"created_at":"2021-01-06T01:31:50.000Z","updated_at":"2023-01-08T14:42:10.000Z","dependencies_parsed_at":"2023-06-09T22:00:27.254Z","dependency_job_id":null,"html_url":"https://github.com/gilzoide/stringstream-lua","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/gilzoide/stringstream-lua","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gilzoide%2Fstringstream-lua","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gilzoide%2Fstringstream-lua/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gilzoide%2Fstringstream-lua/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gilzoide%2Fstringstream-lua/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gilzoide","download_url":"https://codeload.github.com/gilzoide/stringstream-lua/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gilzoide%2Fstringstream-lua/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268338058,"owners_count":24234540,"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-02T02:00:12.353Z","response_time":74,"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":["lua","lua-library","stream","streaming-parser","stringstream"],"created_at":"2024-10-10T10:28:38.566Z","updated_at":"2025-08-02T05:08:23.684Z","avatar_url":"https://github.com/gilzoide.png","language":"Lua","funding_links":["https://github.com/sponsors/gilzoide","https://ko-fi.com/gilzoide","https://liberapay.com/gilzoide","https://www.buymeacoffee.com/gilzoide"],"categories":[],"sub_categories":[],"readme":"# stringstream\nAn object that loads chunks of strings on demand compatible with a subset\nof the [Lua string API](https://www.lua.org/manual/5.4/manual.html#6.4)\nsuitable for parsing. Compatible with Lua 5.1+\n\nUseful for passing streams (e.g.: files) to parser functionality\nthat expects strings and use method notation (`text:match(...)`).\n\nIt is available as a [LuaRocks package](https://luarocks.org/modules/gilzoide/stringstream)\nand has [online documentation](https://gilzoide.github.io/stringstream-lua/):\n\n    $ luarocks install stringstream\n\nOr just copy `stringstream.lua` into your Lua path and `require` it, the module has no dependencies.\n\n\n## Using\n```lua\nlocal stringstream = require 'stringstream'\n\n-- Streams may be created with callable objects (functions or tables/userdata\n-- with __call metamethod) like the ones `load` expects, or file-like objects\n-- that contain a `read` method, like open files.\nlocal stream = assert(stringstream.new(io.stdin))\n\n-- Alternatively, `stringstream.open(filename, ...)` may be used to open a file\n-- by name in read mode and create a stringstream from it.\n--\n-- local stream = assert(stringstream.open(\"README.md\"))\n\n-- Now just call the supported string methods =D\nwhile true do\n    local token, advance = stream:match(\"(%S+)()\")\n    if not token then break end\n    -- ... do something with token\n    print('TOKEN', token)\n    stream = stream:sub(advance)\nend\n```\n\n\n## Supported methods and metamethods\n\n- [__tostring](https://www.lua.org/manual/5.4/manual.html#2.4):\n  Returns the current loaded content string.\n  Be careful that it almost never reflects the entire content string.\n- [__len](https://www.lua.org/manual/5.4/manual.html#2.4), [len](https://www.lua.org/manual/5.4/manual.html#pdf-string.len):\n  Returns the length of the current loaded content.\n  Be careful that it almost never reflects the entire contents length.\n- [sub](https://www.lua.org/manual/5.4/manual.html#pdf-string.sub):\n  If both `i` and `j` are passed, returns the string that starts at `i` and continues until `j`.\n  If only `i` is passed, returns a new view into stream with starting index `i`. \n  Loads contents from stream if necessary.\n  Negative indices are not supported.\n- [find](https://www.lua.org/manual/5.4/manual.html#pdf-string.find):\n  Try finding pattern on loaded contents. Upon failure or repetition items that\n  match the whole string, loads new chunks and try again.\n  Maximum number of extra bytes loaded is parameterizable upon creation.\n  Negative indices are not supported.\n- [match](https://www.lua.org/manual/5.4/manual.html#pdf-string.match):\n  Try matching pattern on loaded contents. Upon failure or repetition items that\n  match the whole string, loads new chunks and try again.\n  Maximum number of extra bytes loaded is parameterizable upon creation.\n  Negative indices are not supported.\n- [gmatch](https://www.lua.org/manual/5.4/manual.html#pdf-string.gmatch):\n  Returns an iterator function that, each time it is called, returns the next\n  match from loaded contents. On iteration end or repetition items that match\n  the whole string, loads new chunks and retry.\n  Maximum number of extra bytes loaded is parameterizable upon creation.\n  Negative indices are not supported.\n\n\n## Running tests\nTests are run using [busted](https://olivinelabs.com/busted/):\n\n    $ busted\n\n\n## Documentation\nThe API is documented using [LDoc](https://github.com/stevedonovan/LDoc) and\nis available at [github pages](https://gilzoide.github.io/stringstream-lua/).\n\nTo generate:\n\n    $ ldoc .\n\n## TODO\n\n- Automated tests\n- Remove commented `print` debug lines\n- Add chunk caching configurations and document how memory is managed\n- Check if should implement gsub and `__eq` with strings\n- Check if should implement negative indices for streams that support seek operations (e.g.: files)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgilzoide%2Fstringstream-lua","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgilzoide%2Fstringstream-lua","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgilzoide%2Fstringstream-lua/lists"}