{"id":15722576,"url":"https://github.com/thinknathan/defold-estring","last_synced_at":"2026-02-11T16:02:07.919Z","repository":{"id":171209344,"uuid":"647568264","full_name":"thinknathan/defold-estring","owner":"thinknathan","description":"A native extension for Defold with functions to manipulate strings.","archived":false,"fork":false,"pushed_at":"2026-02-01T18:50:21.000Z","size":238,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-02T03:11:40.299Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thinknathan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-05-31T04:04:49.000Z","updated_at":"2026-02-01T18:50:18.000Z","dependencies_parsed_at":"2024-03-04T00:25:24.953Z","dependency_job_id":"427d11c9-4157-4022-9cad-c83c7eb6bf0b","html_url":"https://github.com/thinknathan/defold-estring","commit_stats":{"total_commits":99,"total_committers":3,"mean_commits":33.0,"dds":0.303030303030303,"last_synced_commit":"0d852d32315d738669e4a2a23736d28b458eca7a"},"previous_names":["thinknathan/defold-estring"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/thinknathan/defold-estring","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinknathan%2Fdefold-estring","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinknathan%2Fdefold-estring/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinknathan%2Fdefold-estring/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinknathan%2Fdefold-estring/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thinknathan","download_url":"https://codeload.github.com/thinknathan/defold-estring/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinknathan%2Fdefold-estring/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29337001,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-11T16:00:30.228Z","status":"ssl_error","status_checked_at":"2026-02-11T16:00:25.398Z","response_time":97,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["defold","defold-extension","defold-game-engine","defold-library","defold-native-extension","gamedev"],"created_at":"2024-10-03T22:08:28.053Z","updated_at":"2026-02-11T16:02:07.900Z","avatar_url":"https://github.com/thinknathan.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"_docs/def-estring-x1.png\" alt=\"Def-eString\"\u003e\n\n# Def-eString\n\n[![Build with bob](https://github.com/thinknathan/defold-estring/actions/workflows/bob.yml/badge.svg)](https://github.com/thinknathan/defold-estring/actions/workflows/bob.yml) ![GitHub License](https://img.shields.io/github/license/thinknathan/defold-estring)\n\nThis Defold native extension implements functions for string manipulation in Lua scripts.\n\n## API\n\n- `estring.concat(...)`\n- Joins strings or numbers and returns the result.\n\n- `estring.trim(str)`\n- Removes leading and trailing whitespace from a string.\n\n- `estring.split(str, delimiter)`\n- Splits a string into parts using a specified delimiter and returns them in a table.\n\n- `estring.pad_start(str, padStr, targetLength)`\n- Pads the start of a string with a specified padding string to reach a target length.\n\n- `estring.pad_end(str, padStr, targetLength)`\n- Pads the end of a string with a specified padding string to reach a target length.\n\n- `estring.format_time(timeValue, formatType, delimiter)`\n- Formats a time value based on the provided format type, optionally using a specified delimiter.\n\n- `estring.format_number(number, precision, thousandsSeparator, decimalSeparator)`\n- Formats a number as a string with options for precision, thousands separator, and decimal separator.\n\n## Background\n\nIn Lua, strings are immutable. Every modification you make to a string value causes a new string object to be allocated.\n\nExample:\n\n```lua\nlocal first = 'the '\nlocal second = 'lazy '\nlocal third = 'dog'\nlocal sentence = first .. second .. third -- 'the lazy dog'\n-- An intermediate string 'the lazy ' is allocated when first and second are joined\n```\n\nThis library aims to avoid the creation of intermediate Lua strings by doing the work in C++ and only returning the final result to Lua.\n\n```lua\nlocal first = 'the '\nlocal second = 'lazy '\nlocal third = 'dog'\nlocal sentence = estring.concat(first, second, third) -- 'the lazy dog'\n-- No intermediate string is allocated\n```\n\n## Installation\n\n1. Edit game.project\n2. Add dependency `https://github.com/thinknathan/defold-estring/archive/main.zip` for the current version\n   - Or add a specific [release](https://github.com/thinknathan/defold-estring/releases)\n\n### TypeScript Definitions\n\nThis extension includes types for use with [TypeScript + Defold](https://ts-defold.dev/).\n\n1. Install these types\n\n```bash\nyarn add git+https://git@github.com/thinknathan/defold-estring.git#^2.0.0 -D\n# or\nnpm install git+https://git@github.com/thinknathan/defold-estring.git#^2.0.0 --save-dev\n```\n\n2. Add `defold-estring` to `types` in `tsconfig.json`\n\n```diff\n{\n\t\"compilerOptions\": {\n\t\t\"types\": [\n+\t\t\t\"defold-estring\",\n\t\t],\n\t}\n}\n```\n\n3. Add `node_modules/@types` to `typeRoots` in `tsconfig.json` if it's not already there\n\n```diff\n{\n\t\"compilerOptions\": {\n\t\t\"typeRoots\": [\n+\t\t\t\"node_modules/@types\",\n\t\t],\n\t}\n}\n```\n\n## Usage\n\n```lua\n-- concat\n-- Joins strings or numbers and returns the result.\nlocal result_concat = estring.concat(\"Hello, \", \"world\", 123, \"!\")\nprint(result_concat) -- Output: Hello, world123!\n\n-- trim\n-- Removes leading and trailing whitespace from a string.\nlocal result_trim = estring.trim(\"   This is a string with spaces   \")\nprint(result_trim) -- Output: This is a string with spaces\n\n-- split\n-- Splits a string into parts using a specified delimiter and returns them in a table.\nlocal result_split = estring.split(\"apple,orange,banana\", \",\")\nfor i, value in ipairs(result_split) do\n    print(i, value)\nend\n-- Output:\n-- 1   apple\n-- 2   orange\n-- 3   banana\n\n-- pad_start\n-- Pads the start of a string with a specified padding string to reach a target length.\nlocal result_pad_start = estring.pad_start(\"42\", \"0\", 5)\nprint(result_pad_start) -- Output: 00042\n\n-- pad_end\n-- Pads the end of a string with a specified padding string to reach a target length.\nlocal result_pad_end = estring.pad_end(\"42\", \"0\", 5)\nprint(result_pad_end) -- Output: 42000\n\n-- format_time\n-- Formats a time value based on the provided format type, optionally using a specified delimiter.\nlocal result_format_time = estring.format_time(os.time(), 2, \"-\")\nprint(result_format_time) -- Output: 12-45-30 PM\n-- Parameters:\n-- timeValue: (number or string) The time value to format. It can be either a numeric timestamp or a string representing a date and time.\n-- formatType: (constant) Specifies the desired format type:\n-- \testring.FORMAT_12H: \"h:mm AM/PM\"\n-- \testring.FORMAT_12H_LEADING_ZERO: \"hh:mm AM/PM\"\n-- \testring.FORMAT_12H_LEADING_ZERO_WITH_SECONDS: \"hh:mm:ss AM/PM\"\n-- \testring.FORMAT_HH_MM_SS: \"HH:mm:ss\"\n-- \testring.FORMAT_HH_MM: \"HH:mm\"\n-- \testring.FORMAT_MM_SS: \"mm:ss\"\n-- delimiter: (string, optional) The delimiter used in the formatted time. Default is \":\".\n\n-- format_number\n-- Formats a number as a string with options for precision, thousands separator, and decimal separator.\nlocal result_format_number = estring.format_number(1234567.89, 2, \",\", \".\")\nprint(result_format_number) -- Output: 1,234,567.89\n-- Parameters:\n-- numberValue: (number or string) The number to format.\n-- precision: (integer, optional) The number of decimal places. Default is 0.\n-- thousandsSeparator: (string, optional) The character used as a separator for thousands. Default is \",\".\n-- decimalSeparator: (string, optional) The character used as a decimal point. Default is \".\".\n```\n\n## Alternatives\n\n[DefString](https://github.com/subsoap/defstring) is a pure Lua implementation of string manipulation.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthinknathan%2Fdefold-estring","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthinknathan%2Fdefold-estring","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthinknathan%2Fdefold-estring/lists"}