{"id":16371196,"url":"https://github.com/unional/tersify","last_synced_at":"2025-06-25T01:43:25.743Z","repository":{"id":26920565,"uuid":"111905620","full_name":"unional/tersify","owner":"unional","description":"Provide an alternative formatting to objects","archived":false,"fork":false,"pushed_at":"2025-03-11T10:09:49.000Z","size":4197,"stargazers_count":7,"open_issues_count":13,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-11T11:24:09.930Z","etag":null,"topics":["format","formatter","function-formatter","json","stringify"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/unional.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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},"funding":{"ko_fi":"unional"}},"created_at":"2017-11-24T10:22:21.000Z","updated_at":"2024-03-01T17:31:38.000Z","dependencies_parsed_at":"2023-12-16T02:37:24.912Z","dependency_job_id":"0ddf0bd6-9fac-4100-8b42-266f31556fd1","html_url":"https://github.com/unional/tersify","commit_stats":{"total_commits":345,"total_committers":8,"mean_commits":43.125,"dds":0.5536231884057972,"last_synced_commit":"7b2a5774407b420978a8082ac3b5f12bbe2ebeff"},"previous_names":["unional/function-formatter"],"tags_count":67,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unional%2Ftersify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unional%2Ftersify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unional%2Ftersify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unional%2Ftersify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/unional","download_url":"https://codeload.github.com/unional/tersify/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243544669,"owners_count":20308168,"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":["format","formatter","function-formatter","json","stringify"],"created_at":"2024-10-11T03:07:15.618Z","updated_at":"2025-03-15T11:32:46.774Z","avatar_url":"https://github.com/unional.png","language":"TypeScript","readme":"# tersify\n\n[![NPM version][npm-image]][npm-url]\n[![NPM downloads][downloads-image]][downloads-url]\n\n[![GitHub NodeJS][github-nodejs]][github-action-url]\n[![Codecov][codecov-image]][codecov-url]\n\n[![Semantic Release][semantic-release-image]][semantic-release-url]\n\n[![Visual Studio Code][vscode-image]][vscode-url]\n\nCreate a readable terse representation of the subject.\n\nYou can specify `maxLength` to further trim the resulting string.\n\nYou can also override the result by providing your own `tersify()` function on the subject.\n\n```ts\nimport { tersify } from 'tersify'\n\n// `() =\u003e 'foo'`\ntersify(() =\u003e { return 'foo' })\n\n// `fn(x, y) { return x + y; }`\ntersify(function (x, y) { return x + y })\n\n// `fn foo(y) { return y++; }`\ntersify(function foo(y) { return y++ })\n\n// Change result to 80 character long.\n// result will have `...` to indicate info missing.\n// e.g. `{ a: 'a', ... }`\ntersify({...}, { maxLength: 80 })\n\n// '{ a: 1 }`\ntersify({ a: 1 })\n\n// `() =\u003e Sym(abc)`\ntersify(() =\u003e { return Symbol.for(abc) })\n```\n\n## `tersible`\n\nInject a `tersify()` function to the subject.\n\n```ts\nimport { tersible } from 'tersify'\n\nconst increment = tersible(\n\ta =\u003e a + 1,\n\t() =\u003e 'a++'\n)\nincrement.tersify() // 'a++'\n\n// `{ a: 1 }`\ntersible({ a: 1 }, function () {\n\treturn `{ a: ${this.a} }`\n}).tersify()\n\nconst decrement = tersible(a =\u003e a--, 'a--')\ndecrement.tersify() // 'a--'\n\n// `a: 10`\ntersible({ a: 1 }, options =\u003e `a: ${options.maxLength}`).tersify({ maxLength: 10 })\n```\n\n## `Tersiblized`\n\nMixin `Tersible` to a class.\n\n```ts\nimport { Tersiblized } from 'tersify'\n\nclass Foo {\n\ta = 1\n}\nclass Boo extends Tersiblized(Foo, function () {\n\treturn `{ a: ${this.a} }`\n}) {}\n\nconst boo = new Boo()\nboo.a = 3\nboo.tersify() // '{ a: 3 }'\n```\n\n[codecov-image]: https://codecov.io/gh/unional/tersify/branch/master/graph/badge.svg\n[codecov-url]: https://codecov.io/gh/unional/tersify\n[downloads-image]: https://img.shields.io/npm/dm/tersify.svg?style=flat\n[downloads-url]: https://npmjs.org/package/tersify\n[github-nodejs]: https://github.com/unional/tersify/workflows/nodejs/badge.svg\n[github-action-url]: https://github.com/unional/tersify/actions\n[npm-image]: https://img.shields.io/npm/v/tersify.svg?style=flat\n[npm-url]: https://npmjs.org/package/tersify\n[semantic-release-image]: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg\n[semantic-release-url]: https://github.com/semantic-release/semantic-release\n[vscode-image]: https://img.shields.io/badge/vscode-ready-green.svg\n[vscode-url]: https://code.visualstudio.com/\n","funding_links":["https://ko-fi.com/unional"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funional%2Ftersify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funional%2Ftersify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funional%2Ftersify/lists"}