{"id":13525232,"url":"https://github.com/mscdex/mmmagic","last_synced_at":"2025-05-15T02:10:31.605Z","repository":{"id":3150664,"uuid":"4180476","full_name":"mscdex/mmmagic","owner":"mscdex","description":"An async libmagic binding for node.js for detecting content types by data inspection","archived":false,"fork":false,"pushed_at":"2024-06-21T09:48:41.000Z","size":4924,"stargazers_count":624,"open_issues_count":30,"forks_count":52,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-05-08T19:07:05.660Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","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/mscdex.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2012-04-30T06:45:14.000Z","updated_at":"2025-04-14T14:47:58.000Z","dependencies_parsed_at":"2024-06-18T12:25:31.957Z","dependency_job_id":"d8f84d94-cad6-4b93-a638-3d540c594f57","html_url":"https://github.com/mscdex/mmmagic","commit_stats":{"total_commits":181,"total_committers":5,"mean_commits":36.2,"dds":0.02209944751381221,"last_synced_commit":"e3238ba2a1be7e113f604f4124b073309db9ed0e"},"previous_names":[],"tags_count":36,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mscdex%2Fmmmagic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mscdex%2Fmmmagic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mscdex%2Fmmmagic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mscdex%2Fmmmagic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mscdex","download_url":"https://codeload.github.com/mscdex/mmmagic/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254259387,"owners_count":22040821,"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-08-01T06:01:17.009Z","updated_at":"2025-05-15T02:10:26.595Z","avatar_url":"https://github.com/mscdex.png","language":"C++","funding_links":[],"categories":["C++"],"sub_categories":[],"readme":"\nDescription\n===========\n\nAn async libmagic binding for [node.js](http://nodejs.org/) for detecting content types by data inspection.\n\n[![Build Status](https://travis-ci.org/mscdex/mmmagic.svg?branch=master)](https://travis-ci.org/mscdex/mmmagic)\n[![Build status](https://ci.appveyor.com/api/projects/status/mva462lka1ap5a3t)](https://ci.appveyor.com/project/mscdex/mmmagic)\n\n\nRequirements\n============\n\n* [node.js](http://nodejs.org/) -- v4.0.0 or newer\n\n\nInstall\n=======\n\n    npm install mmmagic\n\n\nExamples\n========\n\n* Get general description of a file:\n```javascript\n  var Magic = require('mmmagic').Magic;\n\n  var magic = new Magic();\n  magic.detectFile('node_modules/mmmagic/build/Release/magic.node', function(err, result) {\n      if (err) throw err;\n      console.log(result);\n      // output on Windows with 32-bit node:\n      //    PE32 executable (DLL) (GUI) Intel 80386, for MS Windows\n  });\n```\n* Get mime type for a file:\n```javascript\n  var mmm = require('mmmagic'),\n      Magic = mmm.Magic;\n\n  var magic = new Magic(mmm.MAGIC_MIME_TYPE);\n  magic.detectFile('node_modules/mmmagic/build/Release/magic.node', function(err, result) {\n      if (err) throw err;\n      console.log(result);\n      // output on Windows with 32-bit node:\n      //    application/x-dosexec\n  });\n```\n* Get mime type and mime encoding for a file:\n```javascript\n  var mmm = require('mmmagic'),\n      Magic = mmm.Magic;\n\n  var magic = new Magic(mmm.MAGIC_MIME_TYPE | mmm.MAGIC_MIME_ENCODING);\n  // the above flags can also be shortened down to just: mmm.MAGIC_MIME\n  magic.detectFile('node_modules/mmmagic/build/Release/magic.node', function(err, result) {\n      if (err) throw err;\n      console.log(result);\n      // output on Windows with 32-bit node:\n      //    application/x-dosexec; charset=binary\n  });\n```\n* Get general description of the contents of a Buffer:\n```javascript\n  var Magic = require('mmmagic').Magic;\n\n  var magic = new Magic(),\n        buf = new Buffer('import Options\\nfrom os import unlink, symlink');\n  \n  magic.detect(buf, function(err, result) {\n      if (err) throw err;\n      console.log(result);\n      // output: Python script, ASCII text executable\n  });\n```\n\nAPI\n===\n\nMagic methods\n-------------\n\n* **(constructor)**([\u003c _mixed_ \u003emagicSource][, \u003c _Integer_ \u003eflags]) - Creates and returns a new Magic instance. `magicSource` (if specified) can either be a path string that points to a (compatible) magic file to use *or* it can be a _Buffer_ containing the contents of a (compatible) magic file. If `magicSource` is not a string and not `false`, the bundled magic file will be used. If `magicSource` is `false`, mmmagic will default to searching for a magic file to use (order of magic file searching: `MAGIC` env var -\u003e various file system paths (see `man file`)). flags is a bitmask with the following valid values (available as constants on `require('mmmagic')`):\n\n    * **MAGIC\\_NONE** - No flags set\n    * **MAGIC\\_DEBUG** - Turn on debugging\n    * **MAGIC\\_SYMLINK** - Follow symlinks **(default for non-Windows)**\n    * **MAGIC\\_DEVICES** - Look at the contents of devices\n    * **MAGIC\\_MIME_TYPE** - Return the MIME type\n    * **MAGIC\\_CONTINUE** - Return all matches (returned as an array of strings)\n    * **MAGIC\\_CHECK** - Print warnings to stderr\n    * **MAGIC\\_PRESERVE\\_ATIME** - Restore access time on exit\n    * **MAGIC\\_RAW** - Don't translate unprintable chars\n    * **MAGIC\\_MIME\\_ENCODING** - Return the MIME encoding\n    * **MAGIC\\_MIME** - (**MAGIC\\_MIME\\_TYPE** | **MAGIC\\_MIME\\_ENCODING**)\n    * **MAGIC\\_APPLE** - Return the Apple creator and type\n    * **MAGIC\\_NO\\_CHECK\\_TAR** - Don't check for tar files\n    * **MAGIC\\_NO\\_CHECK\\_SOFT** - Don't check magic entries\n    * **MAGIC\\_NO\\_CHECK\\_APPTYPE** - Don't check application type\n    * **MAGIC\\_NO\\_CHECK\\_ELF** - Don't check for elf details\n    * **MAGIC\\_NO\\_CHECK\\_TEXT** - Don't check for text files\n    * **MAGIC\\_NO\\_CHECK\\_CDF** - Don't check for cdf files\n    * **MAGIC\\_NO\\_CHECK\\_TOKENS** - Don't check tokens\n    * **MAGIC\\_NO\\_CHECK\\_ENCODING** - Don't check text encodings\n\n* **detectFile**(\u003c _String_ \u003epath, \u003c _Function_ \u003ecallback) - _(void)_ - Inspects the file pointed at by path. The callback receives two arguments: an \u003c _Error_ \u003e object in case of error (null otherwise), and a \u003c _String_ \u003e containing the result of the inspection.\n\n* **detect**(\u003c _Buffer_ \u003edata, \u003c _Function_ \u003ecallback) - _(void)_ - Inspects the contents of data. The callback receives two arguments: an \u003c _Error_ \u003e object in case of error (null otherwise), and a \u003c _String_ \u003e containing the result of the inspection.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmscdex%2Fmmmagic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmscdex%2Fmmmagic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmscdex%2Fmmmagic/lists"}