{"_id":"@file-type/xml@1.2.0","bugs":{"url":"https://github.com/Borewit/file-type-xml/issues"},"dist":{"shasum":"279c7839b6771695d5b86fe19977bcf0ef3f84ab","tarball":"http://registry-npm.ywwl.com/@file-type/xml/download/@file-type/xml-1.2.0.tgz","fileCount":7,"integrity":"sha512-cXNWElVkCTOS0mZan1y42hZgG4iD/enZFmnV2cPmjPlgPfEsNGSTlt+1DTi+GqhW2Wj0lzGvwWTn0XiL9HvHKA==","signatures":[{"sig":"MEUCIQDDCJ2oKEbtN3ntdnUJcb7mUqq112yjGJ00+X4V7Hz2kQIgE1rZAlrdfStQ62XElKcMVHnGNbyqh4dCFU4iFJCkgQc=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIEQYbhU/6ciCNLIM5moAKd5Vwo9ozY27XZINecOHg/DcAiEAiHV9fNdIPjsomRM5TtA6b1IqdcfrAwFHj3OnZLLv0v4="}],"unpackedSize":21162,"size":6879,"noattachment":false,"key":"/@file-type/xml/-/@file-type/xml-1.2.0.tgz"},"name":"@file-type/xml","type":"module","types":"./lib/index.d.ts","author":{"url":"https://github.com/Borewit","name":"Borewit"},"exports":"./lib/index.js","gitHead":"eae53f2f5edc372dc30996dbc2006bd0d8f77cc0","license":"MIT","scripts":{"test":"mocha","build":"yarn run clean && yarn compile","clean":"del-cli 'lib/**/*.js' 'lib/**/*.js.map' 'lib/**/*.d.ts' 'src/**/*.d.ts'","compile":"yarn run  compile-src","lint:ts":"biome check","compile-src":"tsc -p lib","update-biome":"yarn add -D --exact @biomejs/biome && npx @biomejs/biome migrate --write","prepublishOnly":"yarn run build"},"version":"1.2.0","_npmUser":{"name":"borewit","email":"borewit@xs4all.nl"},"homepage":"https://github.com/Borewit/file-type-xml#readme","keywords":["file-type","detect","detection","detector","XML","signature","namespace","SVG","XHTML","RSS","KML","GML","MusicXML","plist","property list","xliff","xlf","docbook","TEI","x3d","atom","TTML","SMIL","OPML","MathML","GPX"],"repository":{"url":"git+https://github.com/Borewit/file-type-xml.git","type":"git"},"_npmVersion":"10.9.2","description":"XML detection plugin for file-type","directories":{},"maintainers":[{"name":"borewit","email":"borewit@xs4all.nl"}],"_nodeVersion":"22.14.0","dependencies":{"sax":"^1.6.1","strtok3":"^10.3.5"},"_hasShrinkwrap":false,"packageManager":"yarn@4.18.1","devDependencies":{"chai":"^6.3.0","mocha":"^12.0.3","del-cli":"^7.0.0","file-type":"^22.1.1","@types/sax":"^1.2.7","typescript":"^7.0.2","@biomejs/biome":"2.4.14"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/xml_1.2.0_1791220495748_0.6634372642771251"},"readme":"[![NPM version](https://img.shields.io/npm/v/@file-type/xml.svg)](https://npmjs.org/package/@file-type/xml)\n[![Node.js CI](https://github.com/Borewit/file-type-xml/actions/workflows/nodejs-ci.yml/badge.svg)](https://github.com/Borewit/file-type-xml/actions/workflows/nodejs-ci.yml)\n[![npm downloads](http://img.shields.io/npm/dm/@file-type/xml.svg)](https://npmcharts.com/compare/@file-type/xml?start=365)\n\n# @file-type/xml\n\nDetector plugin for [file-type](https://github.com/sindresorhus/file-type) for XML files.\n\n## Installation\n\n```bash\nnpm install @file-type/xml\n```\n\n## Usage\n\nThe following example shows how to add the XML detector to [file-type](https://github.com/sindresorhus/file-type).\n```js\nimport {FileTypeParser} from 'file-type';\nimport {detectXml} from '@file-type/xml';\n\nconst parser = new FileTypeParser({customDetectors: [detectXml]});\nconst fileType = await parser.fromFile('example.kml');\nconsole.log(fileType);\n```\n\nWith `file-type` 22, Node.js 22 or newer is required. For stream detection, pass a\nweb `ReadableStream` to `parser.fromStream()`. Convert a Node.js `Readable` with\n`Readable.toWeb()`:\n\n```js\nimport {createReadStream} from 'node:fs';\nimport {Readable} from 'node:stream';\n\nconst fileType = await parser.fromStream(Readable.toWeb(createReadStream('example.kml')));\n```\n\nThe detector inspects at most 16 KiB, including any byte order mark. To change this\nlimit, create a detector with a `sampleSize` in bytes:\n\n```js\nimport {FileTypeParser} from 'file-type';\nimport {createXmlDetector} from '@file-type/xml';\n\nconst parser = new FileTypeParser({\n    customDetectors: [createXmlDetector({sampleSize: 64 * 1024})]\n});\n```\n\nThe limit applies to both prolog detection and XML parsing. If no XML signature is\nfound within the sample, the detector returns `undefined` without consuming input.\nIf XML is recognized but its specific format cannot be determined within the sample,\nit returns `application/xml`. `sampleSize` must be a positive safe integer.\nThe `file-type` stream sampling option is separate; when using `fileTypeStream`, set\nits `sampleSize` as well if you want a larger sample.\n\nYou can also use the XML detector outside [file-type](https://github.com/sindresorhus/file-type):\n```js\nimport {XmlTextDetector} from '@file-type/xml';\n\nconst xmlTextDetector = new XmlTextDetector();\nxmlTextDetector.write('<svg xmlns=\"http://www.w3.org/2000/svg\"><path fill=\"#00CD9F\"/></svg>');\nconst fileType = xmlTextDetector.fileType;\nconsole.log(JSON.stringify(fileType)); // Outputs: {\"ext\":\"svg\",\"mime\":\"image/svg+xml\"}\n```\n\n## Support file formats\n\n- [XML](https://en.wikipedia.org/wiki/XML) (default for XML, unless a more specific format was detected)\n- [Apple Property list, `.plist`](https://en.wikipedia.org/wiki/Property_list)\n- [Atom](<https://en.wikipedia.org/wiki/Atom_(web_standard)>)\n- [DocBook](https://en.wikipedia.org/wiki/DocBook)\n- [GML (Geography Markup Language)](https://en.wikipedia.org/wiki/Geography_Markup_Language)\n- [GPX (GPS Exchange Format)](https://en.wikipedia.org/wiki/GPS_Exchange_Format)\n- [KML (Keyhole Markup Language)](https://en.wikipedia.org/wiki/Keyhole_Markup_Language)\n- [MathML (Mathematical Markup Language)](https://en.wikipedia.org/wiki/MathML)\n- [MusicXML, Uncompressed](https://en.wikipedia.org/wiki/MusicXML)\n- [OPML (Outline Processor Markup Language)](https://en.wikipedia.org/wiki/OPML)\n- [RSS (RDF Site Summary or Really Simple Syndication)](https://en.wikipedia.org/wiki/RSS)\n- [SMIL: (Synchronized Multimedia Integration Language)](https://en.wikipedia.org/wiki/Synchronized_Multimedia_Integration_Language)\n- [SVG: (Scalable Vector Graphics)](https://en.wikipedia.org/wiki/SVG)\n- [TEI, Text Encoding Initiative](https://en.wikipedia.org/wiki/Text_Encoding_Initiative)\n- [TTML: (Timed Text Markup Language)](https://en.wikipedia.org/wiki/Timed_Text_Markup_Language)\n- [X3D (Extensible 3D)](https://en.wikipedia.org/wiki/X3D)\n- [XHTML](https://en.wikipedia.org/wiki/XHTML)\n- [XLIFF (XML Localization Interchange File Format)](https://en.wikipedia.org/wiki/XLIFF)\n\n## Licence\n\nThis project is licensed under the [MIT License](LICENSE.txt). Feel free to use, modify, and distribute as needed.\n","publish_time":1791220495823,"_cnpm_publish_time":1791220495823,"dist-tags":{"latest":"1.2.0"}}