{"action":"created","issue":{"url":"https://api.github.com/repos/Afforess/Factorio-Stdlib/issues/8","repository_url":"https://api.github.com/repos/Afforess/Factorio-Stdlib","labels_url":"https://api.github.com/repos/Afforess/Factorio-Stdlib/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/Afforess/Factorio-Stdlib/issues/8/comments","events_url":"https://api.github.com/repos/Afforess/Factorio-Stdlib/issues/8/events","html_url":"https://github.com/Afforess/Factorio-Stdlib/issues/8","id":152419883,"number":8,"title":"util module","user":{"login":"Choumiko","id":5612780,"avatar_url":"https://avatars.githubusercontent.com/u/5612780?v=3","gravatar_id":"","url":"https://api.github.com/users/Choumiko","html_url":"https://github.com/Choumiko","followers_url":"https://api.github.com/users/Choumiko/followers","following_url":"https://api.github.com/users/Choumiko/following{/other_user}","gists_url":"https://api.github.com/users/Choumiko/gists{/gist_id}","starred_url":"https://api.github.com/users/Choumiko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Choumiko/subscriptions","organizations_url":"https://api.github.com/users/Choumiko/orgs","repos_url":"https://api.github.com/users/Choumiko/repos","events_url":"https://api.github.com/users/Choumiko/events{/privacy}","received_events_url":"https://api.github.com/users/Choumiko/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-05-01T20:45:37Z","updated_at":"2016-05-03T03:37:30Z","closed_at":null,"body":"I just realised i have a few small functions i use across mods that are not necessarily restricted to something Factorio specific, e.g.\r\n```lua\r\nfunction trim(s)\r\n  return (s:gsub(\"^%s*(.-)%s*$\", \"%1\"))\r\nend\r\nfunction round(num, idp)\r\n  local mult = 10^(idp or 0)\r\n  return math.floor(num * mult + 0.5) / mult\r\nend\r\nfunction isEmpty(tableA)\r\n  if tableA ~= nil then\r\n    return next(tableA) == nil\r\n  end\r\n  return true\r\nend\r\n```\r\nWould a util module make sense? It could get out of hand rather quick i guess.\r\nRight now i'm thinking something like\r\n```lua\r\nutil.string.trim(s)\r\nutil.string.starts_with(s, needle)\r\nutil.string.ends_with(s, needle)\r\n\r\nutil.math.round(num, idp)\r\n\r\nutil.table.is_empty(table_)\r\n```\r\nshould work for a start. If it get's too much it can be moved to a own module."},"comment":{"url":"https://api.github.com/repos/Afforess/Factorio-Stdlib/issues/comments/216428100","html_url":"https://github.com/Afforess/Factorio-Stdlib/issues/8#issuecomment-216428100","issue_url":"https://api.github.com/repos/Afforess/Factorio-Stdlib/issues/8","id":216428100,"user":{"login":"Afforess","id":513639,"avatar_url":"https://avatars.githubusercontent.com/u/513639?v=3","gravatar_id":"","url":"https://api.github.com/users/Afforess","html_url":"https://github.com/Afforess","followers_url":"https://api.github.com/users/Afforess/followers","following_url":"https://api.github.com/users/Afforess/following{/other_user}","gists_url":"https://api.github.com/users/Afforess/gists{/gist_id}","starred_url":"https://api.github.com/users/Afforess/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Afforess/subscriptions","organizations_url":"https://api.github.com/users/Afforess/orgs","repos_url":"https://api.github.com/users/Afforess/repos","events_url":"https://api.github.com/users/Afforess/events{/privacy}","received_events_url":"https://api.github.com/users/Afforess/received_events","type":"User","site_admin":false},"created_at":"2016-05-03T03:37:30Z","updated_at":"2016-05-03T03:37:30Z","body":"I think you could even add the functions directly to the metatables of the classes they best fit with. So you could add trim, starts_with, etc to the string class by updating the metatable."}}