@cjser/is-image 4.0.0-cjser.2

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.
@@ -0,0 +1,153 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // packages/@cjser/is-image.tmp-26-1778152637309/index.js
30
+ var index_exports = {};
31
+ __export(index_exports, {
32
+ default: () => isImage
33
+ });
34
+ module.exports = __toCommonJS(index_exports);
35
+ var import_node_path = __toESM(require("node:path"), 1);
36
+ var extensions = /* @__PURE__ */ new Set([
37
+ "3dv",
38
+ "ai",
39
+ "amf",
40
+ "art",
41
+ "ase",
42
+ "awg",
43
+ "blp",
44
+ "bmp",
45
+ "bw",
46
+ "cd5",
47
+ "cdr",
48
+ "cgm",
49
+ "cit",
50
+ "cmx",
51
+ "cpt",
52
+ "cr2",
53
+ "cur",
54
+ "cut",
55
+ "dds",
56
+ "dib",
57
+ "djvu",
58
+ "dxf",
59
+ "e2d",
60
+ "ecw",
61
+ "egt",
62
+ "emf",
63
+ "eps",
64
+ "exif",
65
+ "fs",
66
+ "gbr",
67
+ "gif",
68
+ "gpl",
69
+ "grf",
70
+ "hdp",
71
+ "heic",
72
+ "heif",
73
+ "icns",
74
+ "ico",
75
+ "iff",
76
+ "int",
77
+ "inta",
78
+ "jfif",
79
+ "jng",
80
+ "jp2",
81
+ "jpeg",
82
+ "jpg",
83
+ "jps",
84
+ "jxr",
85
+ "lbm",
86
+ "liff",
87
+ "max",
88
+ "miff",
89
+ "mng",
90
+ "msp",
91
+ "nef",
92
+ "nitf",
93
+ "nrrd",
94
+ "odg",
95
+ "ota",
96
+ "pam",
97
+ "pbm",
98
+ "pc1",
99
+ "pc2",
100
+ "pc3",
101
+ "pcf",
102
+ "pct",
103
+ "pcx",
104
+ "pdd",
105
+ "pdn",
106
+ "pgf",
107
+ "pgm",
108
+ "PI1",
109
+ "PI2",
110
+ "PI3",
111
+ "pict",
112
+ "png",
113
+ "pnm",
114
+ "pns",
115
+ "ppm",
116
+ "psb",
117
+ "psd",
118
+ "psp",
119
+ "px",
120
+ "pxm",
121
+ "pxr",
122
+ "qfx",
123
+ "ras",
124
+ "raw",
125
+ "rgb",
126
+ "rgba",
127
+ "rle",
128
+ "sct",
129
+ "sgi",
130
+ "sid",
131
+ "stl",
132
+ "sun",
133
+ "svg",
134
+ "sxd",
135
+ "tga",
136
+ "tif",
137
+ "tiff",
138
+ "v2d",
139
+ "vnd",
140
+ "vrml",
141
+ "vtf",
142
+ "wdp",
143
+ "webp",
144
+ "wmf",
145
+ "x3d",
146
+ "xar",
147
+ "xbm",
148
+ "xcf",
149
+ "xpm"
150
+ ]);
151
+ function isImage(filePath) {
152
+ return extensions.has(import_node_path.default.extname(filePath).slice(1).toLowerCase());
153
+ }
package/index.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ /**
2
+ Check if a file path is an image.
3
+
4
+ @example
5
+ ```
6
+ import isImage from '@cjser/is-image';
7
+
8
+ isImage('source/unicorn.png');
9
+ //=> true
10
+
11
+ isImage('source/unicorn.txt');
12
+ //=> false
13
+ ```
14
+ */
15
+ export default function isImage(filePath: string): boolean;
package/index.js ADDED
@@ -0,0 +1,121 @@
1
+ import path from 'node:path';
2
+
3
+ const extensions = new Set([
4
+ '3dv',
5
+ 'ai',
6
+ 'amf',
7
+ 'art',
8
+ 'ase',
9
+ 'awg',
10
+ 'blp',
11
+ 'bmp',
12
+ 'bw',
13
+ 'cd5',
14
+ 'cdr',
15
+ 'cgm',
16
+ 'cit',
17
+ 'cmx',
18
+ 'cpt',
19
+ 'cr2',
20
+ 'cur',
21
+ 'cut',
22
+ 'dds',
23
+ 'dib',
24
+ 'djvu',
25
+ 'dxf',
26
+ 'e2d',
27
+ 'ecw',
28
+ 'egt',
29
+ 'emf',
30
+ 'eps',
31
+ 'exif',
32
+ 'fs',
33
+ 'gbr',
34
+ 'gif',
35
+ 'gpl',
36
+ 'grf',
37
+ 'hdp',
38
+ 'heic',
39
+ 'heif',
40
+ 'icns',
41
+ 'ico',
42
+ 'iff',
43
+ 'int',
44
+ 'inta',
45
+ 'jfif',
46
+ 'jng',
47
+ 'jp2',
48
+ 'jpeg',
49
+ 'jpg',
50
+ 'jps',
51
+ 'jxr',
52
+ 'lbm',
53
+ 'liff',
54
+ 'max',
55
+ 'miff',
56
+ 'mng',
57
+ 'msp',
58
+ 'nef',
59
+ 'nitf',
60
+ 'nrrd',
61
+ 'odg',
62
+ 'ota',
63
+ 'pam',
64
+ 'pbm',
65
+ 'pc1',
66
+ 'pc2',
67
+ 'pc3',
68
+ 'pcf',
69
+ 'pct',
70
+ 'pcx',
71
+ 'pdd',
72
+ 'pdn',
73
+ 'pgf',
74
+ 'pgm',
75
+ 'PI1',
76
+ 'PI2',
77
+ 'PI3',
78
+ 'pict',
79
+ 'png',
80
+ 'pnm',
81
+ 'pns',
82
+ 'ppm',
83
+ 'psb',
84
+ 'psd',
85
+ 'psp',
86
+ 'px',
87
+ 'pxm',
88
+ 'pxr',
89
+ 'qfx',
90
+ 'ras',
91
+ 'raw',
92
+ 'rgb',
93
+ 'rgba',
94
+ 'rle',
95
+ 'sct',
96
+ 'sgi',
97
+ 'sid',
98
+ 'stl',
99
+ 'sun',
100
+ 'svg',
101
+ 'sxd',
102
+ 'tga',
103
+ 'tif',
104
+ 'tiff',
105
+ 'v2d',
106
+ 'vnd',
107
+ 'vrml',
108
+ 'vtf',
109
+ 'wdp',
110
+ 'webp',
111
+ 'wmf',
112
+ 'x3d',
113
+ 'xar',
114
+ 'xbm',
115
+ 'xcf',
116
+ 'xpm',
117
+ ]);
118
+
119
+ export default function isImage(filePath) {
120
+ return extensions.has(path.extname(filePath).slice(1).toLowerCase());
121
+ }
package/license ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/package.json ADDED
@@ -0,0 +1,75 @@
1
+ {
2
+ "name": "@cjser/is-image",
3
+ "version": "4.0.0-cjser.2",
4
+ "description": "Check if a file path is an image",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://code.moenext.com/3rdeye/cjser.git"
9
+ },
10
+ "author": {
11
+ "name": "Sindre Sorhus",
12
+ "email": "sindresorhus@gmail.com",
13
+ "url": "sindresorhus.com"
14
+ },
15
+ "type": "module",
16
+ "exports": {
17
+ "types": "./index.d.ts",
18
+ "require": "./dist-cjser/index.cjs",
19
+ "default": "./index.js"
20
+ },
21
+ "engines": {
22
+ "node": ">=16"
23
+ },
24
+ "scripts": {
25
+ "test": "xo && ava && tsd"
26
+ },
27
+ "files": [
28
+ "index.js",
29
+ "index.d.ts",
30
+ "dist-cjser"
31
+ ],
32
+ "keywords": [
33
+ "extension",
34
+ "extensions",
35
+ "file",
36
+ "path",
37
+ "check",
38
+ "detect",
39
+ "is",
40
+ "image",
41
+ "img",
42
+ "photo",
43
+ "picture",
44
+ "jpg",
45
+ "jpeg",
46
+ "png"
47
+ ],
48
+ "devDependencies": {
49
+ "ava": "^5.3.1",
50
+ "tsd": "^0.28.1",
51
+ "xo": "^0.55.0"
52
+ },
53
+ "types": "./index.d.ts",
54
+ "main": "./dist-cjser/index.cjs",
55
+ "cjser": {
56
+ "sourceVersion": "4.0.0",
57
+ "cjserVersion": 2,
58
+ "original": {
59
+ "name": "is-image",
60
+ "version": "4.0.0",
61
+ "exports": {
62
+ "types": "./index.d.ts",
63
+ "default": "./index.js"
64
+ },
65
+ "repository": "sindresorhus/is-image",
66
+ "files": [
67
+ "index.js",
68
+ "index.d.ts"
69
+ ],
70
+ "scripts": {
71
+ "test": "xo && ava && tsd"
72
+ }
73
+ }
74
+ }
75
+ }
package/readme.md ADDED
@@ -0,0 +1,35 @@
1
+ # is-image
2
+
3
+ > Check if a file path is an image
4
+
5
+ It just checks the extension. Use [`image-type`](https://github.com/sindresorhus/image-type) if you want to check the actual file.
6
+
7
+ ## Install
8
+
9
+ ```sh
10
+ npm install is-image
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```js
16
+ import isImage from 'is-image';
17
+
18
+ isImage('source/unicorn.png');
19
+ //=> true
20
+
21
+ isImage('source/unicorn.txt');
22
+ //=> false
23
+ ```
24
+
25
+ ## Related
26
+
27
+ - [image-extensions](https://github.com/arthurvr/image-extensions) - List of image extensions
28
+ - [image-type](https://github.com/sindresorhus/image-type) - Detect the image type of a Buffer/Uint8Array
29
+ - [is-text-path](https://github.com/sindresorhus/is-text-path) - Check if a filepath is a text file
30
+ - [is-binary-path](https://github.com/sindresorhus/is-binary-path) - Check if a filepath is a binary file
31
+
32
+ ## cjser
33
+
34
+ This package is a CommonJS-compatible build generated by cjser for projects that still need `require()` support. The source version matches the original npm package version, with a cjser prerelease suffix for this generated build.
35
+ Original repository: https://github.com/sindresorhus/is-image