SOLFIND
Web Lens
Portal home

GitHub - electron/asar: Simple extensive tar-like archive format with indexing · GitHub

https://github.com/electron/asar • 342 KB fetched
Open original page


GitHub - electron/asar: Simple extensive tar-like archive format with indexing · GitHub Skip to content Navigation Menu Sign in Appearance settings * Platform * AI CODE CREATION * GitHub Copilot Write better code with AI * GitHub Copilot app Direct agents from issue to merge * MCP Registry Integrate external tools * DEVELOPER WORKFLOWS * Actions Automate any workflow * Codespaces Instant dev environments * Issues Plan and track work * Code Review Manage code changes * Code Quality Enforce quality at merge * APPLICATION SECURITY * GitHub Advanced Security Find and fix vulnerabilities * Code security Secure your code as you build * Secret protection Stop leaks before they start * EXPLORE * Why GitHub * Documentation * Blog * Changelog * Marketplace View all features * Solutions * BY COMPANY SIZE * Enterprises * Small and medium teams * Startups * Nonprofits * BY USE CASE * App Modernization * DevSecOps * DevOps * CI/CD * View all use cases * BY INDUSTRY * Healthcare * Financial services * Manufacturing * Government * View all industries View all solutions * Resources * EXPLORE BY TOPIC * AI * Software Development * DevOps * Security * View all topics * EXPLORE BY TYPE * Customer stories * Events & webinars * Ebooks & reports * Business insights * GitHub Skills * SUPPORT & SERVICES * Documentation * Customer support * Community forum * Trust center * Partners View all resources * Open Source * COMMUNITY * GitHub Sponsors Fund open source developers * PROGRAMS * Security Lab * Maintainer Community * GitHub Stars * Archive Program * REPOSITORIES * Topics * Trending * Collections * Enterprise * ENTERPRISE SOLUTIONS * Enterprise platform AI-powered developer platform * AVAILABLE ADD-ONS * GitHub Advanced Security Enterprise-grade security features * Copilot for Business Enterprise-grade AI features * Premium Support Enterprise-grade 24/7 support * Pricing Search / Sign in Sign up Appearance settings You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert Uh oh! There was an error while loading. Please reload this page . electron / asar Public * Notifications You must be signed in to change notification settings * Fork 265 * Star 2.9k * Code * Issues 6 * Pull requests 6 * Actions * Security and quality 0 * Insights Additional navigation options * Code * Issues * Pull requests * Actions * Security and quality * Insights main Branches Tags Go to file Code Open more actions menu Latest commit   History 474 Commits 474 Commits Folders and files Name Name Last commit message Last commit date .github .github     .husky .husky     .yarn/ releases .yarn/ releases     benchmark benchmark     bin bin     src src     test test     .gitattributes .gitattributes     .gitignore .gitignore     .mocharc.js .mocharc.js     .nvmrc .nvmrc     .oxfmtrc.json .oxfmtrc.json     .oxlintrc.json .oxlintrc.json     .releaserc.json .releaserc.json     .yarnrc.yml .yarnrc.yml     CHANGELOG.md CHANGELOG.md     LICENSE.md LICENSE.md     README.md README.md     package.json package.json     tsconfig.json tsconfig.json     vitest.config.ts vitest.config.ts     yarn.lock yarn.lock     View all files Repository files navigation * * README * Code of conduct * MIT license More items @electron/asar - Electron Archive ASAR is a simple extensive archive format. It concatenates all files together without compression (like tar ) while having random access support. Features * Support random access * Use JSON to store file information * Very easy to write a parser * Store the contents of duplicated files only once CLI Install This module requires Node 22.12.0 or later. npm install --engine-strict @electron/asar Usage $ asar --help Usage: asar [options] [command] Commands: pack | p < dir > < output > create asar archive list | l < archive > list files of asar archive extract-file | ef < archive > < filename > extract one file from archive extract | e < archive > < dest > extract archive Options: -h, --help output usage information -V, --version output the version number Excluding multiple resources from being packed Given: app (a) ├── x1 (b) ├── x2 (c) ├── y3 (d) │   ├── x1 (e) │   └── z1 (f) │   └── x2 (g) └── z4 (h) └── w1 Exclude: a, b asar pack app app.asar --unpack-dir " {x1,x2} " Exclude: a, b, d, f asar pack app app.asar --unpack-dir " **/{x1,x2} " Exclude: a, b, d, f, h asar pack app app.asar --unpack-dir " {**/x1,**/x2,z4/w1} " Programmatic usage For full API usage, see the API documentation . Example import { createPackage } from '@electron/asar' ; const src = 'some/path/' ; const dest = 'name.asar' ; await createPackage ( src , dest ) ; console . log ( 'done.' ) ; Please note that there is currently no error handling provided! Deduplication Files with identical contents are stored once and shared: the first copy is written into the archive and every other copy's header entry points at that same offset . Nothing changes for readers — each file still has its own entry, size, integrity hash, and executable bit — but archives with duplicated contents (a common shape for bundled node_modules ) get smaller and pack faster, since the redundant bytes are never written. Unpacked files ( unpack / unpackDir ) are always written out in full, because they live on disk outside the archive. Transform You can pass in a transform option, that is a function, which either returns nothing, or a stream.Transform . The latter will be used on files that will be in the .asar file to transform them (e.g. compress). import { createPackageWithOptions } from '@electron/asar' ; const src = 'some/path/' ; const dest = 'name.asar' ; function transform ( filename ) { return new CustomTransformStream ( ) } await createPackageWithOptions ( src , dest , { transform : transform } ) ; console . log ( 'done.' ) ; Format Asar uses Pickle to safely serialize binary value to file. The format of asar is very flat: | UInt32: header_size | String: header | Bytes: file1 | ... | Bytes: file42 | The header_size and header are serialized with Pickle class, and header_size 's Pickle object is 8 bytes. The header is a JSON string, and the header_size is the size of header 's Pickle object. Structure of header is something like this: { "files" : { "tmp" : { "files" : {} }, "usr" : { "files" : { "bin" : { "files" : { "ls" : { "offset" : " 0 " , "size" : 100 , "executable" : true , "integrity" : { "algorithm" : " SHA256 " , "hash" : " ... " , "blockSize" : 1024 , "blocks" : [ " ... " , " ... " ] } }, "cd" : { "offset" : " 100 " , "size" : 100 , "executable" : true , "integrity" : { "algorithm" : " SHA256 " , "hash" : " ... " , "blockSize" : 1024 , "blocks" : [ " ... " , " ... " ] } } } } } }, "etc" : { "files" : { "hosts" : { "offset" : " 200 " , "size" : 32 , "integrity" : { "algorithm" : " SHA256 " , "hash" : " ... " , "blockSize" : 1024 , "blocks" : [ " ... " , " ... " ] } } } } } } offset and size records the information to read the file from archive, the offset starts from 0 so you have to manually add the size of header_size and header to the offset to get the real offset of the file. Files with identical contents share a single copy in the archive, so more than one entry can point at the same offset . offset is a UINT64 number represented in string, because there is no way to precisely represent UINT64 in JavaScript Number . size is a JavaScript Number that is no larger than Number.MAX_SAFE_INTEGER , which has a value of 9007199254740991 and is about 8PB in size. We didn't store size in UINT64 because file size in Node.js is represented as Number and it is not safe to convert Number to UINT64. integrity is an object consisting of a few keys: * A hashing algorithm , currently only SHA256 is supported. * A hex encoded hash value representing the hash of the entire file. * An array of hex encoded hashes for the blocks of the file (i.e. for a blockSize of 4KB, this array contains the hash of every block if you split the file into N 4KB blocks). * A integer value blockSize representing the size in bytes of each block in the blocks hashes above. About Simple extensive tar-like archive format with indexing Topics asar chrome electron javascript pickle Resources Readme MIT license Code of conduct Code of conduct Activity Custom properties Stars 2.9k stars Watchers 64 watching Forks 265 forks Report repository Releases Packages Used by Contributors Languages Footer (c) 2026 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Community * Docs * Contact * Manage cookies * Do not share my personal information You can’t perform that action at this time.

Links found on this page

  1. Skip to content [direct]
  2. Sign in [direct]
  3. GitHub Copilot Write better code with AI [direct]
  4. GitHub Copilot app Direct agents from issue to merge [direct]
  5. MCP Registry Integrate external tools [direct]
  6. Actions Automate any workflow [direct]
  7. Codespaces Instant dev environments [direct]
  8. Issues Plan and track work [direct]
  9. Code Review Manage code changes [direct]
  10. Code Quality Enforce quality at merge [direct]
  11. GitHub Advanced Security Find and fix vulnerabilities [direct]
  12. Code security Secure your code as you build [direct]
  13. Secret protection Stop leaks before they start [direct]
  14. Why GitHub [direct]
  15. Documentation [direct]
  16. Blog [direct]
  17. Changelog [direct]
  18. Marketplace [direct]
  19. View all features [direct]
  20. Enterprises [direct]
  21. Small and medium teams [direct]
  22. Startups [direct]
  23. Nonprofits [direct]
  24. App Modernization [direct]
  25. DevSecOps [direct]
  26. DevOps [direct]
  27. CI/CD [direct]
  28. View all use cases [direct]
  29. Healthcare [direct]
  30. Financial services [direct]
  31. Manufacturing [direct]
  32. Government [direct]
  33. View all industries [direct]
  34. View all solutions [direct]
  35. AI [direct]
  36. Software Development [direct]
  37. DevOps [direct]
  38. Security [direct]
  39. View all topics [direct]
  40. Customer stories [direct]
  41. Events & webinars [direct]
  42. Ebooks & reports [direct]
  43. Business insights [direct]
  44. GitHub Skills [direct]
  45. Customer support [direct]
  46. Community forum [direct]
  47. Trust center [direct]
  48. Partners [direct]
  49. View all resources [direct]
  50. GitHub Sponsors Fund open source developers [direct]
  51. Security Lab [direct]
  52. Maintainer Community [direct]
  53. GitHub Stars [direct]
  54. Archive Program [direct]
  55. Topics [direct]
  56. Trending [direct]
  57. Collections [direct]
  58. Copilot for Business Enterprise-grade AI features [direct]
  59. Premium Support Enterprise-grade 24/7 support [direct]
  60. Pricing [direct]
  61. Sign up [direct]
  62. electron [direct]
  63. Notifications [direct]
  64. Issues 6 [direct]
  65. Pull requests 6 [direct]
  66. Actions [direct]
  67. Security and quality 0 [direct]
  68. Insights [direct]
  69. Branches [direct]
  70. Tags [direct]
  71. 474 Commits [direct]
  72. .github [direct]
  73. .husky [direct]
  74. .yarn/ releases [direct]
  75. benchmark [direct]
  76. bin [direct]
  77. src [direct]
  78. test [direct]
  79. .gitattributes [direct]
  80. .gitignore [direct]