@file-type/xml 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -17,15 +17,16 @@ The following example shows how add the XML detector to [file-type](https://gith
17
17
  import {NodeFileTypeParser} from 'file-type';
18
18
  import {detectXml} from '@file-type/xml';
19
19
 
20
- const parser = new NodeFileTypeParser({customDetectors: [detectXml]});
20
+ const parser = new FileTypeParser({customDetectors: [detectXml]});
21
21
  const fileType = await parser.fromFile('example.kml');
22
22
  console.log(fileType);
23
23
  ```
24
24
 
25
- You can also use the XML detector outside file-type:
25
+ You can also use the XML detector outside [file-type](https://github.com/sindresorhus/file-type):
26
26
  ```js
27
27
  import {XmlTextDetector} from '@file-type/xml';
28
28
 
29
+ const xmlTextDetector = new XmlTextDetector();
29
30
  xmlTextDetector.write('<svg xmlns="http://www.w3.org/2000/svg"><path fill="#00CD9F"/></svg>');
30
31
  const fileType = xmlTextDetector.fileType;
31
32
  console.log(JSON.stringify(fileType)); // Outputs: {"ext":"svg","mime":"image/svg+xml"}
package/lib/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { type FileTypeResult, type Detector } from 'file-type';
1
+ import type { FileTypeResult, Detector } from 'file-type';
2
2
  interface IXmlTextDetectorOptions {
3
3
  fullScan?: boolean;
4
4
  }
package/lib/index.js CHANGED
@@ -14,19 +14,19 @@ function isXml(array) {
14
14
  if (startsWith(array, [60, 63, 120, 109, 108, 32])) {
15
15
  return { xml: true, encoding: 'utf-8', offset: 0 };
16
16
  }
17
- else if (startsWith(array, [0xEF, 0xBB, 0xBF, 60, 63, 120, 109, 108, 32])) { // UTF-8 BOM
17
+ if (startsWith(array, [0xEF, 0xBB, 0xBF, 60, 63, 120, 109, 108, 32])) { // UTF-8 BOM
18
18
  return { xml: true, encoding: 'utf-8', offset: 3 };
19
19
  }
20
- else if (startsWith(array, [0xFE, 0xFF, 0, 60, 0, 63, 0, 120, 0, 109, 0, 108, 0, 32])) {
20
+ if (startsWith(array, [0xFE, 0xFF, 0, 60, 0, 63, 0, 120, 0, 109, 0, 108, 0, 32])) {
21
21
  return { xml: true, encoding: 'utf-16be', offset: 2 };
22
22
  }
23
- else if (startsWith(array, [0xFF, 0xFE, 60, 0, 63, 0, 120, 0, 109, 0, 108, 0, 32, 0])) {
23
+ if (startsWith(array, [0xFF, 0xFE, 60, 0, 63, 0, 120, 0, 109, 0, 108, 0, 32, 0])) {
24
24
  return { xml: true, encoding: 'utf-16le', offset: 2 };
25
25
  }
26
- else if (startsWith(array, [0, 60, 0, 63, 0, 120, 0, 109, 0, 108, 0, 32])) {
26
+ if (startsWith(array, [0, 60, 0, 63, 0, 120, 0, 109, 0, 108, 0, 32])) {
27
27
  return { xml: true, encoding: 'utf-16be', offset: 0 };
28
28
  }
29
- else if (startsWith(array, [60, 0, 63, 0, 120, 0, 109, 0, 108, 0, 32, 0])) {
29
+ if (startsWith(array, [60, 0, 63, 0, 120, 0, 109, 0, 108, 0, 32, 0])) {
30
30
  return { xml: true, encoding: 'utf-16le', offset: 0 };
31
31
  }
32
32
  return { xml: false };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@file-type/xml",
3
- "version": "0.4.0",
4
- "description": "XML detection plugin",
3
+ "version": "0.4.1",
4
+ "description": "XML detection plugin for file-type",
5
5
  "type": "module",
6
6
  "types": "./lib/index.d.ts",
7
7
  "exports": "./lib/index.js",
@@ -9,6 +9,7 @@
9
9
  "clean": "del-cli 'lib/**/*.js' 'lib/**/*.js.map' 'lib/**/*.d.ts' 'src/**/*.d.ts'",
10
10
  "compile-src": "tsc -p lib",
11
11
  "compile": "yarn run compile-src",
12
+ "lint-ts": "biome check",
12
13
  "build": "yarn run clean && yarn compile",
13
14
  "test": "mocha"
14
15
  },
@@ -29,14 +30,15 @@
29
30
  ],
30
31
  "dependencies": {
31
32
  "sax": "^1.4.1",
32
- "strtok3": "^10.0.1"
33
+ "strtok3": "^10.2.1"
33
34
  },
34
35
  "devDependencies": {
36
+ "@biomejs/biome": "^1.9.4",
35
37
  "@types/sax": "^1.2.7",
36
38
  "chai": "^5.1.2",
37
39
  "del-cli": "^6.0.0",
38
- "file-type": "^20.0.0",
39
- "mocha": "^11.0.1",
40
+ "file-type": "^20.1.0",
41
+ "mocha": "^11.1.0",
40
42
  "typescript": "^5.7.3"
41
43
  },
42
44
  "files": [
@@ -53,5 +55,5 @@
53
55
  "url": "git+https://github.com/Borewit/file-type-xml.git"
54
56
  },
55
57
  "license": "MIT",
56
- "packageManager": "yarn@4.5.3"
58
+ "packageManager": "yarn@4.6.0"
57
59
  }