{"id":19338797,"url":"https://github.com/fizzygalacticus/savethis","last_synced_at":"2026-05-17T02:12:11.846Z","repository":{"id":35091288,"uuid":"205478955","full_name":"FizzyGalacticus/savethis","owner":"FizzyGalacticus","description":null,"archived":false,"fork":false,"pushed_at":"2022-02-12T13:08:37.000Z","size":134,"stargazers_count":0,"open_issues_count":6,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-03T09:55:29.349Z","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/FizzyGalacticus.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}},"created_at":"2019-08-31T01:26:04.000Z","updated_at":"2019-08-31T01:26:29.000Z","dependencies_parsed_at":"2022-08-08T05:00:45.476Z","dependency_job_id":null,"html_url":"https://github.com/FizzyGalacticus/savethis","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FizzyGalacticus%2Fsavethis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FizzyGalacticus%2Fsavethis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FizzyGalacticus%2Fsavethis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FizzyGalacticus%2Fsavethis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FizzyGalacticus","download_url":"https://codeload.github.com/FizzyGalacticus/savethis/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240441992,"owners_count":19801806,"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":[],"created_at":"2024-11-10T03:18:43.754Z","updated_at":"2026-05-17T02:12:11.774Z","avatar_url":"https://github.com/FizzyGalacticus.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# savethis\n\nA util to help save the return value of a function with minimal effort. Very helpful when debugging, especially with lots of async operations in between.\n\n## Installation\n\nUsing `npm`:\n```sh\nnpm i --save-dev @fizzygalacticus/savethis\n```\n\nUsing `yarn`:\n```sh\nyarn add --dev @fizzygalacticus/savethis\n```\n\n## Usage\n\n`savethis` is a decorator that can be used on both asynchronous and synchronous functions:\n\n**synchronous:**\n```js\n// Saves \"hello, world!\" to test.txt\nconst res = savethis(() =\u003e 'hello, world!', 'test.txt', {/* ...options */})(/* ...params */);\nconsole.log(res); // \"hello, world!\"\n```\n\n**asynchronous:**\n```js\n// Saves \"hello, world!\" to test.txt\nconst res = await savethis(() =\u003e Promise.resolve('hello, world!'), 'test.txt', {/* ...options */})(/* ...params */);\nconsole.log(res); // \"hello, world!\"\n```\n\n### Options\n* `save` - a function to save the data, with the signature `(path, data) =\u003e any`. For original functions that are synchronous (don't return a `Promise`), this is `fs.writeFileSync`. Otherwise the default is a `promisify`'d `fs.writeFile`.\n* `format` - a function to specify the formatting prior to write. Default is `data =\u003e JSON.stringify(data, null, 4)`.\n\n**notes:**\n* If your formatting function returns a `Promise`, everything will still function as it should, although if your original function does not return a `Promise`, you will need to take care to catch any errors or rejections from the formatter.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffizzygalacticus%2Fsavethis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffizzygalacticus%2Fsavethis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffizzygalacticus%2Fsavethis/lists"}