{"id":16125693,"url":"https://github.com/dy/save-file","last_synced_at":"2025-09-12T21:33:17.127Z","repository":{"id":65422020,"uuid":"85372084","full_name":"dy/save-file","owner":"dy","description":"Save any data to file in browser or node","archived":false,"fork":false,"pushed_at":"2020-06-02T04:35:26.000Z","size":89,"stargazers_count":43,"open_issues_count":14,"forks_count":3,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-12-28T06:41:45.385Z","etag":null,"topics":["blob","filesystem","save"],"latest_commit_sha":null,"homepage":"","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/dy.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":"2017-03-18T03:08:53.000Z","updated_at":"2024-11-06T22:59:02.000Z","dependencies_parsed_at":"2023-01-22T21:25:11.234Z","dependency_job_id":null,"html_url":"https://github.com/dy/save-file","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/dy%2Fsave-file","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dy%2Fsave-file/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dy%2Fsave-file/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dy%2Fsave-file/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dy","download_url":"https://codeload.github.com/dy/save-file/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232792150,"owners_count":18577262,"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":["blob","filesystem","save"],"created_at":"2024-10-09T21:30:43.566Z","updated_at":"2025-01-06T21:54:59.885Z","avatar_url":"https://github.com/dy.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# save-file [![unstable](https://img.shields.io/badge/stability-unstable-green.svg)](http://github.com/badges/stability-badges) [![Build Status](https://img.shields.io/travis/dy/save-file.svg)](https://travis-ci.org/dy/save-file) [![Greenkeeper badge](https://badges.greenkeeper.io/dy/save-file.svg)](https://greenkeeper.io/)\n\nSave file in node/browser. In browser it prompts save file dialog, in node it creates a file.\n\n* Provides common interface for both node/browser.\n* Fixes dialog race in browser − when multiple save-files are called at the same time.\n* Handles any types of input data − _Buffer_, _ArrayBuffer_, _ArrayBufferView_, _File_, _Blob_, data-uri string, _ImageData_ etc.\n\n## Usage\n\n[![npm install save-file](https://nodei.co/npm/save-file.png?mini=true)](https://npmjs.org/package/save-file/)\n\n```js\n// const save = require('save-file')\nimport { save } from 'save-file'\n\nawait save(data, 'example.mp3')\n\nconst saveSync = require('save-file/sync')\nsaveSync(otherData, 'example2.mp3')\n```\n\n## API\n\n### `await save(data|filename, filename|data)`\n\nSave `data` source to the `filename` destination, return actual saved _ArrayBuffer_. `saveSync` performs synchronous call.\n\n`data` type can be:\n* _Buffer_, _ArrayBuffer_\n* _File_, _Blob_\n* dataURI, base64 string\n* _TypedArray_, _Array_\n* _ImageData_, _AudioBuffer_\n* _Object_\n* [ndarray](https://github.com/scijs/ndarray)\n* etc.\n\nSee [to-array-buffer](https://github.com/dy/to-array-buffer) for the full list. The data is expected to be encoded to target format, for that purpose see [image-encode](https://ghub.io/image-encode), [audio-encode](https://ghub.io/audio-encode) etc.\n\nMime type is detected from the file extension/data type automatically.\n\n\n## Credits \u0026 related\n\n* [file-saver](https://npmjs.org/package/file-saver) − create download file dialog in browser.\n* [write](https://npmjs.org/package/write) − write file in node, create directories if none.\n* [to-array-buffer](https://github.com/dy/to-array-buffer) — turn anything into ArrayBuffer.\n* [simple-mime](https://npmjs.org/package/simple-mime) — tiny mime types detector.\n\n## Copyright\n\n© Dmitry Yv 2018. MIT Licensed.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdy%2Fsave-file","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdy%2Fsave-file","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdy%2Fsave-file/lists"}