@kaeawc/auto-mobile 0.0.90 → 0.0.92
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 +7 -0
- package/README.md.backup +7 -0
- package/dist/build-info.json +12 -11
- package/dist/schemas/README.md +16 -0
- package/dist/schemas/prototype-icon-names.json +302 -0
- package/dist/schemas/prototype-platform-permissions.json +75 -0
- package/dist/schemas/test-plan.schema.json +2 -2
- package/dist/src/chunk-09442h7v.js +4 -0
- package/dist/src/chunk-0dfnyfkh.js +5 -0
- package/dist/src/chunk-0e4gm1kj.js +5 -0
- package/dist/src/chunk-0eb8576f.js +4 -0
- package/dist/src/chunk-0rjm4nx7.js +5 -0
- package/dist/src/chunk-0w1spptt.js +6 -0
- package/dist/src/chunk-1zmh2eak.js +4 -0
- package/dist/src/chunk-28k63ha3.js +5 -0
- package/dist/src/chunk-2d4wmp8b.js +4 -0
- package/dist/src/chunk-2e6s75qv.js +78 -0
- package/dist/src/chunk-2v7tw1nj.js +5 -0
- package/dist/src/chunk-32jpxz2y.js +323 -0
- package/dist/src/chunk-34zxqcmq.js +5 -0
- package/dist/src/chunk-3jmvqygr.js +238 -0
- package/dist/src/chunk-3swvfhqt.js +5 -0
- package/dist/src/chunk-44bt78m9.js +5 -0
- package/dist/src/chunk-488vt2bp.js +4 -0
- package/dist/src/chunk-4fgdhcwx.js +5 -0
- package/dist/src/chunk-4jp2se4w.js +4 -0
- package/dist/src/chunk-4pfftt07.js +5 -0
- package/dist/src/chunk-4vhr9e4t.js +4 -0
- package/dist/src/chunk-4xd6zs3y.js +15 -0
- package/dist/src/chunk-51567pg8.js +4 -0
- package/dist/src/chunk-5agqsfev.js +4 -0
- package/dist/src/chunk-5d706gmr.js +4 -0
- package/dist/src/chunk-5kd4rqk7.js +5 -0
- package/dist/src/chunk-5s645vr4.js +4 -0
- package/dist/src/chunk-61t538bm.js +4 -0
- package/dist/src/chunk-6d3mmqxt.js +54 -0
- package/dist/src/chunk-6hyt398x.js +5 -0
- package/dist/src/chunk-6mnr8kpm.js +4 -0
- package/dist/src/chunk-6pg7bqck.js +4 -0
- package/dist/src/chunk-79q5xsdc.js +42 -0
- package/dist/src/chunk-7bdgand3.js +4 -0
- package/dist/src/chunk-84cp9dw5.js +4 -0
- package/dist/src/chunk-86f2h5ww.js +5 -0
- package/dist/src/chunk-8cghfzb2.js +19 -0
- package/dist/src/chunk-8en08r7q.js +5 -0
- package/dist/src/chunk-950qcq1e.js +10 -0
- package/dist/src/chunk-9rkfyt6q.js +5 -0
- package/dist/src/chunk-9tf2p9y9.js +5 -0
- package/dist/src/chunk-9y5bcy28.js +6 -0
- package/dist/src/chunk-a2sc4jm0.js +5 -0
- package/dist/src/chunk-a4k9rt7z.js +5 -0
- package/dist/src/chunk-aa5ng3d1.js +4 -0
- package/dist/src/chunk-ajsrz473.js +5 -0
- package/dist/src/chunk-b3h0a6ca.js +4 -0
- package/dist/src/chunk-b4cxdzwy.js +20 -0
- package/dist/src/chunk-b6a737qt.js +4 -0
- package/dist/src/chunk-bn64x5z5.js +5 -0
- package/dist/src/chunk-bvh649za.js +12 -0
- package/dist/src/chunk-c9nk1r78.js +5 -0
- package/dist/src/chunk-c9tyfg4j.js +26 -0
- package/dist/src/chunk-cfsdfqnm.js +4 -0
- package/dist/src/chunk-cxyf04jc.js +7 -0
- package/dist/src/chunk-d57432wq.js +4 -0
- package/dist/src/chunk-da08tx5v.js +4 -0
- package/dist/src/chunk-eka89q3k.js +4 -0
- package/dist/src/chunk-f2tc08m2.js +4 -0
- package/dist/src/chunk-f8tnk179.js +5 -0
- package/dist/src/chunk-f9s1kkhx.js +5 -0
- package/dist/src/chunk-fbp8a4rx.js +4 -0
- package/dist/src/chunk-fd2z0sze.js +4 -0
- package/dist/src/chunk-fk927f4q.js +54 -0
- package/dist/src/chunk-fxmr3a0f.js +4 -0
- package/dist/src/chunk-gaqwhd44.js +4 -0
- package/dist/src/chunk-ggtd5x5a.js +5 -0
- package/dist/src/chunk-gndcfrm7.js +4 -0
- package/dist/src/chunk-h3n4adc6.js +310 -0
- package/dist/src/chunk-h5pjbb83.js +4 -0
- package/dist/src/chunk-hgnnh302.js +4 -0
- package/dist/src/chunk-hmke8nhx.js +5 -0
- package/dist/src/chunk-j2bx12hn.js +4 -0
- package/dist/src/chunk-j70y1a2g.js +4 -0
- package/dist/src/chunk-jdqvcq0a.js +5 -0
- package/dist/src/chunk-jhnbfj19.js +55 -0
- package/dist/src/chunk-js1jpyxp.js +6 -0
- package/dist/src/chunk-kbjq0qvb.js +4 -0
- package/dist/src/chunk-kfwx57xd.js +4 -0
- package/dist/src/chunk-km0dy5vc.js +71 -0
- package/dist/src/chunk-kzwctna2.js +4 -0
- package/dist/src/chunk-m9ehyehy.js +4 -0
- package/dist/src/chunk-mct91p1f.js +4 -0
- package/dist/src/chunk-mf9spd4g.js +5 -0
- package/dist/src/chunk-mgrcansb.js +4 -0
- package/dist/src/chunk-mqc1d0eb.js +6 -0
- package/dist/src/chunk-n1zmpk0z.js +4 -0
- package/dist/src/chunk-ncyjf63g.js +4 -0
- package/dist/src/chunk-nr64d21q.js +973 -0
- package/dist/src/chunk-nwm2pq5v.js +168 -0
- package/dist/src/chunk-pm06b05d.js +9 -0
- package/dist/src/chunk-q50s00ry.js +4 -0
- package/dist/src/chunk-qv2918jt.js +4 -0
- package/dist/src/chunk-qwye1958.js +14 -0
- package/dist/src/chunk-r0f1q783.js +5 -0
- package/dist/src/chunk-r14wwk37.js +18 -0
- package/dist/src/chunk-r20pe1nv.js +5 -0
- package/dist/src/chunk-r8z9pfve.js +5 -0
- package/dist/src/chunk-rdpgkjf6.js +4 -0
- package/dist/src/chunk-rkr0dks9.js +5 -0
- package/dist/src/chunk-rn84t3sf.js +11 -0
- package/dist/src/chunk-s123kn7n.js +4 -0
- package/dist/src/chunk-s1zq65ny.js +4 -0
- package/dist/src/chunk-s73qn3fx.js +4 -0
- package/dist/src/chunk-sjn0nj4p.js +5 -0
- package/dist/src/chunk-sns0c35v.js +7 -0
- package/dist/src/chunk-stfzjr9y.js +8 -0
- package/dist/src/chunk-sz1a7p43.js +4 -0
- package/dist/src/chunk-t4dr5c8v.js +8 -0
- package/dist/src/chunk-tc8k9c1j.js +4 -0
- package/dist/src/chunk-teznhase.js +4 -0
- package/dist/src/chunk-ty9xgmz4.js +4 -0
- package/dist/src/chunk-tyazf3sk.js +145 -0
- package/dist/src/chunk-v6npjrjm.js +5 -0
- package/dist/src/chunk-v90es00d.js +4 -0
- package/dist/src/chunk-vbvtzkwz.js +5 -0
- package/dist/src/chunk-vefd8qee.js +8 -0
- package/dist/src/chunk-vs9r72ta.js +17 -0
- package/dist/src/chunk-w2mwa0jk.js +4 -0
- package/dist/src/chunk-w7zsh13a.js +9 -0
- package/dist/src/chunk-w88k0bgr.js +4 -0
- package/dist/src/chunk-wry6skrm.js +4 -0
- package/dist/src/chunk-wzdt0enk.js +4 -0
- package/dist/src/chunk-xhhv854c.js +4 -0
- package/dist/src/chunk-y58270hd.js +4 -0
- package/dist/src/chunk-yk0hmbex.js +4 -0
- package/dist/src/chunk-ympy4fdz.js +28 -0
- package/dist/src/chunk-yw436axy.js +4 -0
- package/dist/src/chunk-z04jrpjy.js +5 -0
- package/dist/src/chunk-z2xznczw.js +4 -0
- package/dist/src/chunk-z4xnrgps.js +4 -0
- package/dist/src/chunk-z7csyszv.js +4 -0
- package/dist/src/chunk-z8t0v07j.js +11 -0
- package/dist/src/chunk-z916af47.js +228 -0
- package/dist/src/chunk-zcr8he8q.js +5 -0
- package/dist/src/chunk-zd9vmkzn.js +9 -0
- package/dist/src/chunk-zg67wjkh.js +5 -0
- package/dist/src/chunk-zj939v0h.js +5 -0
- package/dist/src/chunk-zkdjwtc1.js +4 -0
- package/dist/src/chunk-zkv5kzt6.js +4 -0
- package/dist/src/daemon/processEntry.js +4 -0
- package/dist/src/index.js +4 -2797
- package/dist/src/runtime/bunRuntimeGuard.js +4 -0
- package/dist/src/utils/workers/iosBundleExtractWorker.js +2 -3
- package/node_modules/strtok3/lib/BufferSizeError.js +1 -1
- package/node_modules/strtok3/lib/TokenWriter.js +151 -0
- package/node_modules/strtok3/lib/core.js +1 -0
- package/node_modules/strtok3/package.json +2 -2
- package/node_modules/token-types/LICENSE.txt +9 -9
- package/node_modules/token-types/{lib → dist/lib}/index.js +21 -3
- package/node_modules/token-types/package.json +81 -81
- package/package.json +10 -10
- package/schemas/README.md +16 -0
- package/schemas/prototype-icon-names.json +302 -0
- package/schemas/prototype-platform-permissions.json +75 -0
- package/schemas/test-plan.schema.json +2 -2
- package/node_modules/@borewit/text-codec/README.md +0 -87
- package/node_modules/@jimp/diff/node_modules/pixelmatch/README.md +0 -110
- package/node_modules/@jimp/diff/node_modules/pixelmatch/node_modules/pngjs/README.md +0 -433
- package/node_modules/@jimp/file-ops/dist/browser/index.js +0 -8
- package/node_modules/@jimp/js-png/README.md +0 -35
- package/node_modules/@jimp/js-png/src/__image_snapshots__/index-node-test-ts-png-should-use-png-options-1-snap.png +0 -0
- package/node_modules/@jimp/js-png/src/output.png +0 -0
- package/node_modules/@jimp/js-png/vitest.config.browser.mjs +0 -3
- package/node_modules/@jimp/plugin-resize/README.md +0 -12
- package/node_modules/@jimp/plugin-resize/vitest.config.browser.mjs +0 -3
- package/node_modules/@tokenizer/inflate/README.md +0 -114
- package/node_modules/@tokenizer/token/README.md +0 -19
- package/node_modules/await-to-js/README.md +0 -82
- package/node_modules/debug/README.md +0 -481
- package/node_modules/exif-parser/README.md +0 -83
- package/node_modules/file-type/readme.md +0 -667
- package/node_modules/ieee754/README.md +0 -51
- package/node_modules/mime/README.md +0 -178
- package/node_modules/ms/readme.md +0 -59
- package/node_modules/parse-bmfont-xml/README.md +0 -74
- package/node_modules/parse-bmfont-xml/lib/browser.js +0 -85
- package/node_modules/parse-bmfont-xml/node_modules/xml2js/README.md +0 -507
- package/node_modules/pngjs/README.md +0 -287
- package/node_modules/sax/README.md +0 -228
- package/node_modules/strtok3/README.md +0 -736
- package/node_modules/tinycolor2/README.md +0 -492
- package/node_modules/tinycolor2/cjs/test.js +0 -2191
- package/node_modules/tinycolor2/cjs/test_template.js +0 -26
- package/node_modules/tinycolor2/deno_asserts@0.168.0.mjs +0 -807
- package/node_modules/tinycolor2/esm/test.js +0 -2189
- package/node_modules/tinycolor2/esm/test_template.js +0 -24
- package/node_modules/tinycolor2/tinycolor.js +0 -1191
- package/node_modules/token-types/README.md +0 -120
- package/node_modules/uint8array-extras/readme.md +0 -318
- package/node_modules/xml-parse-from-string/README.md +0 -35
- package/node_modules/xmlbuilder/README.md +0 -86
- package/node_modules/zod/README.md +0 -208
- package/node_modules/zod/v4/locales/ar.d.cts +0 -4
- package/node_modules/zod/v4/locales/ar.d.ts +0 -4
- package/node_modules/zod/v4/locales/az.d.cts +0 -4
- package/node_modules/zod/v4/locales/az.d.ts +0 -4
- package/node_modules/zod/v4/locales/be.d.cts +0 -4
- package/node_modules/zod/v4/locales/be.d.ts +0 -4
- package/node_modules/zod/v4/locales/ca.d.cts +0 -4
- package/node_modules/zod/v4/locales/ca.d.ts +0 -4
- package/node_modules/zod/v4/locales/cs.d.cts +0 -4
- package/node_modules/zod/v4/locales/cs.d.ts +0 -4
- package/node_modules/zod/v4/locales/de.d.cts +0 -4
- package/node_modules/zod/v4/locales/de.d.ts +0 -4
- package/node_modules/zod/v4/locales/en.d.cts +0 -5
- package/node_modules/zod/v4/locales/en.d.ts +0 -5
- package/node_modules/zod/v4/locales/eo.d.cts +0 -5
- package/node_modules/zod/v4/locales/eo.d.ts +0 -5
- package/node_modules/zod/v4/locales/es.d.cts +0 -4
- package/node_modules/zod/v4/locales/es.d.ts +0 -4
- package/node_modules/zod/v4/locales/fa.d.cts +0 -4
- package/node_modules/zod/v4/locales/fa.d.ts +0 -4
- package/node_modules/zod/v4/locales/fi.d.cts +0 -4
- package/node_modules/zod/v4/locales/fi.d.ts +0 -4
- package/node_modules/zod/v4/locales/fr-CA.d.cts +0 -4
- package/node_modules/zod/v4/locales/fr-CA.d.ts +0 -4
- package/node_modules/zod/v4/locales/fr.d.cts +0 -4
- package/node_modules/zod/v4/locales/fr.d.ts +0 -4
- package/node_modules/zod/v4/locales/he.d.cts +0 -4
- package/node_modules/zod/v4/locales/he.d.ts +0 -4
- package/node_modules/zod/v4/locales/hu.d.cts +0 -4
- package/node_modules/zod/v4/locales/hu.d.ts +0 -4
- package/node_modules/zod/v4/locales/id.d.cts +0 -4
- package/node_modules/zod/v4/locales/id.d.ts +0 -4
- package/node_modules/zod/v4/locales/index.d.cts +0 -39
- package/node_modules/zod/v4/locales/index.d.ts +0 -39
- package/node_modules/zod/v4/locales/it.d.cts +0 -4
- package/node_modules/zod/v4/locales/it.d.ts +0 -4
- package/node_modules/zod/v4/locales/ja.d.cts +0 -4
- package/node_modules/zod/v4/locales/ja.d.ts +0 -4
- package/node_modules/zod/v4/locales/kh.d.cts +0 -4
- package/node_modules/zod/v4/locales/kh.d.ts +0 -4
- package/node_modules/zod/v4/locales/ko.d.cts +0 -4
- package/node_modules/zod/v4/locales/ko.d.ts +0 -4
- package/node_modules/zod/v4/locales/mk.d.cts +0 -4
- package/node_modules/zod/v4/locales/mk.d.ts +0 -4
- package/node_modules/zod/v4/locales/ms.d.cts +0 -4
- package/node_modules/zod/v4/locales/ms.d.ts +0 -4
- package/node_modules/zod/v4/locales/nl.d.cts +0 -4
- package/node_modules/zod/v4/locales/nl.d.ts +0 -4
- package/node_modules/zod/v4/locales/no.d.cts +0 -4
- package/node_modules/zod/v4/locales/no.d.ts +0 -4
- package/node_modules/zod/v4/locales/ota.d.cts +0 -4
- package/node_modules/zod/v4/locales/ota.d.ts +0 -4
- package/node_modules/zod/v4/locales/pl.d.cts +0 -4
- package/node_modules/zod/v4/locales/pl.d.ts +0 -4
- package/node_modules/zod/v4/locales/ps.d.cts +0 -4
- package/node_modules/zod/v4/locales/ps.d.ts +0 -4
- package/node_modules/zod/v4/locales/pt.d.cts +0 -4
- package/node_modules/zod/v4/locales/pt.d.ts +0 -4
- package/node_modules/zod/v4/locales/ru.d.cts +0 -4
- package/node_modules/zod/v4/locales/ru.d.ts +0 -4
- package/node_modules/zod/v4/locales/sl.d.cts +0 -4
- package/node_modules/zod/v4/locales/sl.d.ts +0 -4
- package/node_modules/zod/v4/locales/sv.d.cts +0 -4
- package/node_modules/zod/v4/locales/sv.d.ts +0 -4
- package/node_modules/zod/v4/locales/ta.d.cts +0 -4
- package/node_modules/zod/v4/locales/ta.d.ts +0 -4
- package/node_modules/zod/v4/locales/th.d.cts +0 -4
- package/node_modules/zod/v4/locales/th.d.ts +0 -4
- package/node_modules/zod/v4/locales/tr.d.cts +0 -5
- package/node_modules/zod/v4/locales/tr.d.ts +0 -5
- package/node_modules/zod/v4/locales/ua.d.cts +0 -4
- package/node_modules/zod/v4/locales/ua.d.ts +0 -4
- package/node_modules/zod/v4/locales/ur.d.cts +0 -4
- package/node_modules/zod/v4/locales/ur.d.ts +0 -4
- package/node_modules/zod/v4/locales/vi.d.cts +0 -4
- package/node_modules/zod/v4/locales/vi.d.ts +0 -4
- package/node_modules/zod/v4/locales/zh-CN.d.cts +0 -4
- package/node_modules/zod/v4/locales/zh-CN.d.ts +0 -4
- package/node_modules/zod/v4/locales/zh-TW.d.cts +0 -4
- package/node_modules/zod/v4/locales/zh-TW.d.ts +0 -4
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
# await-to-js
|
|
2
|
-
|
|
3
|
-
[![NPM version][npm-image]][npm-url]
|
|
4
|
-
[![Downloads][download-badge]][npm-url]
|
|
5
|
-
|
|
6
|
-
> Async await wrapper for easy error handling
|
|
7
|
-
|
|
8
|
-
## Pre-requisites
|
|
9
|
-
You need to use Node 7.6 (or later) or an ES7 transpiler in order to use async/await functionality.
|
|
10
|
-
You can use babel or typescript for that.
|
|
11
|
-
|
|
12
|
-
## Install
|
|
13
|
-
|
|
14
|
-
```sh
|
|
15
|
-
npm i await-to-js --save
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
## Usage
|
|
19
|
-
|
|
20
|
-
```js
|
|
21
|
-
import to from 'await-to-js';
|
|
22
|
-
// If you use CommonJS (i.e NodeJS environment), it should be:
|
|
23
|
-
// const to = require('await-to-js').default;
|
|
24
|
-
|
|
25
|
-
async function asyncTaskWithCb(cb) {
|
|
26
|
-
let err, user, savedTask, notification;
|
|
27
|
-
|
|
28
|
-
[ err, user ] = await to(UserModel.findById(1));
|
|
29
|
-
if(!user) return cb('No user found');
|
|
30
|
-
|
|
31
|
-
[ err, savedTask ] = await to(TaskModel({userId: user.id, name: 'Demo Task'}));
|
|
32
|
-
if(err) return cb('Error occurred while saving task');
|
|
33
|
-
|
|
34
|
-
if(user.notificationsEnabled) {
|
|
35
|
-
[ err ] = await to(NotificationService.sendNotification(user.id, 'Task Created'));
|
|
36
|
-
if(err) return cb('Error while sending notification');
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if(savedTask.assignedUser.id !== user.id) {
|
|
40
|
-
[ err, notification ] = await to(NotificationService.sendNotification(savedTask.assignedUser.id, 'Task was created for you'));
|
|
41
|
-
if(err) return cb('Error while sending notification');
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
cb(null, savedTask);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
async function asyncFunctionWithThrow() {
|
|
48
|
-
const [err, user] = await to(UserModel.findById(1));
|
|
49
|
-
if (!user) throw new Error('User not found');
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
## TypeScript usage
|
|
55
|
-
```javascript
|
|
56
|
-
interface ServerResponse {
|
|
57
|
-
test: number;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const p = Promise.resolve({test: 123});
|
|
61
|
-
|
|
62
|
-
const [err, data] = await to<ServerResponse>(p);
|
|
63
|
-
console.log(data.test);
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
## License
|
|
67
|
-
|
|
68
|
-
MIT © [Dima Grossman](http://blog.grossman.io) && Tomer Barnea
|
|
69
|
-
|
|
70
|
-
[npm-url]: https://npmjs.org/package/await-to-js
|
|
71
|
-
[npm-image]: https://img.shields.io/npm/v/await-to-js.svg?style=flat-square
|
|
72
|
-
|
|
73
|
-
[travis-url]: https://travis-ci.org/scopsy/await-to-js
|
|
74
|
-
[travis-image]: https://img.shields.io/travis/scopsy/await-to-js.svg?style=flat-square
|
|
75
|
-
|
|
76
|
-
[coveralls-url]: https://coveralls.io/r/scopsy/await-to-js
|
|
77
|
-
[coveralls-image]: https://img.shields.io/coveralls/scopsy/await-to-js.svg?style=flat-square
|
|
78
|
-
|
|
79
|
-
[depstat-url]: https://david-dm.org/scopsy/await-to-js
|
|
80
|
-
[depstat-image]: https://david-dm.org/scopsy/await-to-js.svg?style=flat-square
|
|
81
|
-
|
|
82
|
-
[download-badge]: http://img.shields.io/npm/dm/await-to-js.svg?style=flat-square
|
|
@@ -1,481 +0,0 @@
|
|
|
1
|
-
# debug
|
|
2
|
-
[](#backers)
|
|
3
|
-
[](#sponsors)
|
|
4
|
-
|
|
5
|
-
<img width="647" src="https://user-images.githubusercontent.com/71256/29091486-fa38524c-7c37-11e7-895f-e7ec8e1039b6.png">
|
|
6
|
-
|
|
7
|
-
A tiny JavaScript debugging utility modelled after Node.js core's debugging
|
|
8
|
-
technique. Works in Node.js and web browsers.
|
|
9
|
-
|
|
10
|
-
## Installation
|
|
11
|
-
|
|
12
|
-
```bash
|
|
13
|
-
$ npm install debug
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
## Usage
|
|
17
|
-
|
|
18
|
-
`debug` exposes a function; simply pass this function the name of your module, and it will return a decorated version of `console.error` for you to pass debug statements to. This will allow you to toggle the debug output for different parts of your module as well as the module as a whole.
|
|
19
|
-
|
|
20
|
-
Example [_app.js_](./examples/node/app.js):
|
|
21
|
-
|
|
22
|
-
```js
|
|
23
|
-
var debug = require('debug')('http')
|
|
24
|
-
, http = require('http')
|
|
25
|
-
, name = 'My App';
|
|
26
|
-
|
|
27
|
-
// fake app
|
|
28
|
-
|
|
29
|
-
debug('booting %o', name);
|
|
30
|
-
|
|
31
|
-
http.createServer(function(req, res){
|
|
32
|
-
debug(req.method + ' ' + req.url);
|
|
33
|
-
res.end('hello\n');
|
|
34
|
-
}).listen(3000, function(){
|
|
35
|
-
debug('listening');
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
// fake worker of some kind
|
|
39
|
-
|
|
40
|
-
require('./worker');
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
Example [_worker.js_](./examples/node/worker.js):
|
|
44
|
-
|
|
45
|
-
```js
|
|
46
|
-
var a = require('debug')('worker:a')
|
|
47
|
-
, b = require('debug')('worker:b');
|
|
48
|
-
|
|
49
|
-
function work() {
|
|
50
|
-
a('doing lots of uninteresting work');
|
|
51
|
-
setTimeout(work, Math.random() * 1000);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
work();
|
|
55
|
-
|
|
56
|
-
function workb() {
|
|
57
|
-
b('doing some work');
|
|
58
|
-
setTimeout(workb, Math.random() * 2000);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
workb();
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
The `DEBUG` environment variable is then used to enable these based on space or
|
|
65
|
-
comma-delimited names.
|
|
66
|
-
|
|
67
|
-
Here are some examples:
|
|
68
|
-
|
|
69
|
-
<img width="647" alt="screen shot 2017-08-08 at 12 53 04 pm" src="https://user-images.githubusercontent.com/71256/29091703-a6302cdc-7c38-11e7-8304-7c0b3bc600cd.png">
|
|
70
|
-
<img width="647" alt="screen shot 2017-08-08 at 12 53 38 pm" src="https://user-images.githubusercontent.com/71256/29091700-a62a6888-7c38-11e7-800b-db911291ca2b.png">
|
|
71
|
-
<img width="647" alt="screen shot 2017-08-08 at 12 53 25 pm" src="https://user-images.githubusercontent.com/71256/29091701-a62ea114-7c38-11e7-826a-2692bedca740.png">
|
|
72
|
-
|
|
73
|
-
#### Windows command prompt notes
|
|
74
|
-
|
|
75
|
-
##### CMD
|
|
76
|
-
|
|
77
|
-
On Windows the environment variable is set using the `set` command.
|
|
78
|
-
|
|
79
|
-
```cmd
|
|
80
|
-
set DEBUG=*,-not_this
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
Example:
|
|
84
|
-
|
|
85
|
-
```cmd
|
|
86
|
-
set DEBUG=* & node app.js
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
##### PowerShell (VS Code default)
|
|
90
|
-
|
|
91
|
-
PowerShell uses different syntax to set environment variables.
|
|
92
|
-
|
|
93
|
-
```cmd
|
|
94
|
-
$env:DEBUG = "*,-not_this"
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
Example:
|
|
98
|
-
|
|
99
|
-
```cmd
|
|
100
|
-
$env:DEBUG='app';node app.js
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
Then, run the program to be debugged as usual.
|
|
104
|
-
|
|
105
|
-
npm script example:
|
|
106
|
-
```js
|
|
107
|
-
"windowsDebug": "@powershell -Command $env:DEBUG='*';node app.js",
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
## Namespace Colors
|
|
111
|
-
|
|
112
|
-
Every debug instance has a color generated for it based on its namespace name.
|
|
113
|
-
This helps when visually parsing the debug output to identify which debug instance
|
|
114
|
-
a debug line belongs to.
|
|
115
|
-
|
|
116
|
-
#### Node.js
|
|
117
|
-
|
|
118
|
-
In Node.js, colors are enabled when stderr is a TTY. You also _should_ install
|
|
119
|
-
the [`supports-color`](https://npmjs.org/supports-color) module alongside debug,
|
|
120
|
-
otherwise debug will only use a small handful of basic colors.
|
|
121
|
-
|
|
122
|
-
<img width="521" src="https://user-images.githubusercontent.com/71256/29092181-47f6a9e6-7c3a-11e7-9a14-1928d8a711cd.png">
|
|
123
|
-
|
|
124
|
-
#### Web Browser
|
|
125
|
-
|
|
126
|
-
Colors are also enabled on "Web Inspectors" that understand the `%c` formatting
|
|
127
|
-
option. These are WebKit web inspectors, Firefox ([since version
|
|
128
|
-
31](https://hacks.mozilla.org/2014/05/editable-box-model-multiple-selection-sublime-text-keys-much-more-firefox-developer-tools-episode-31/))
|
|
129
|
-
and the Firebug plugin for Firefox (any version).
|
|
130
|
-
|
|
131
|
-
<img width="524" src="https://user-images.githubusercontent.com/71256/29092033-b65f9f2e-7c39-11e7-8e32-f6f0d8e865c1.png">
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
## Millisecond diff
|
|
135
|
-
|
|
136
|
-
When actively developing an application it can be useful to see when the time spent between one `debug()` call and the next. Suppose for example you invoke `debug()` before requesting a resource, and after as well, the "+NNNms" will show you how much time was spent between calls.
|
|
137
|
-
|
|
138
|
-
<img width="647" src="https://user-images.githubusercontent.com/71256/29091486-fa38524c-7c37-11e7-895f-e7ec8e1039b6.png">
|
|
139
|
-
|
|
140
|
-
When stdout is not a TTY, `Date#toISOString()` is used, making it more useful for logging the debug information as shown below:
|
|
141
|
-
|
|
142
|
-
<img width="647" src="https://user-images.githubusercontent.com/71256/29091956-6bd78372-7c39-11e7-8c55-c948396d6edd.png">
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
## Conventions
|
|
146
|
-
|
|
147
|
-
If you're using this in one or more of your libraries, you _should_ use the name of your library so that developers may toggle debugging as desired without guessing names. If you have more than one debuggers you _should_ prefix them with your library name and use ":" to separate features. For example "bodyParser" from Connect would then be "connect:bodyParser". If you append a "*" to the end of your name, it will always be enabled regardless of the setting of the DEBUG environment variable. You can then use it for normal output as well as debug output.
|
|
148
|
-
|
|
149
|
-
## Wildcards
|
|
150
|
-
|
|
151
|
-
The `*` character may be used as a wildcard. Suppose for example your library has
|
|
152
|
-
debuggers named "connect:bodyParser", "connect:compress", "connect:session",
|
|
153
|
-
instead of listing all three with
|
|
154
|
-
`DEBUG=connect:bodyParser,connect:compress,connect:session`, you may simply do
|
|
155
|
-
`DEBUG=connect:*`, or to run everything using this module simply use `DEBUG=*`.
|
|
156
|
-
|
|
157
|
-
You can also exclude specific debuggers by prefixing them with a "-" character.
|
|
158
|
-
For example, `DEBUG=*,-connect:*` would include all debuggers except those
|
|
159
|
-
starting with "connect:".
|
|
160
|
-
|
|
161
|
-
## Environment Variables
|
|
162
|
-
|
|
163
|
-
When running through Node.js, you can set a few environment variables that will
|
|
164
|
-
change the behavior of the debug logging:
|
|
165
|
-
|
|
166
|
-
| Name | Purpose |
|
|
167
|
-
|-----------|-------------------------------------------------|
|
|
168
|
-
| `DEBUG` | Enables/disables specific debugging namespaces. |
|
|
169
|
-
| `DEBUG_HIDE_DATE` | Hide date from debug output (non-TTY). |
|
|
170
|
-
| `DEBUG_COLORS`| Whether or not to use colors in the debug output. |
|
|
171
|
-
| `DEBUG_DEPTH` | Object inspection depth. |
|
|
172
|
-
| `DEBUG_SHOW_HIDDEN` | Shows hidden properties on inspected objects. |
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
__Note:__ The environment variables beginning with `DEBUG_` end up being
|
|
176
|
-
converted into an Options object that gets used with `%o`/`%O` formatters.
|
|
177
|
-
See the Node.js documentation for
|
|
178
|
-
[`util.inspect()`](https://nodejs.org/api/util.html#util_util_inspect_object_options)
|
|
179
|
-
for the complete list.
|
|
180
|
-
|
|
181
|
-
## Formatters
|
|
182
|
-
|
|
183
|
-
Debug uses [printf-style](https://wikipedia.org/wiki/Printf_format_string) formatting.
|
|
184
|
-
Below are the officially supported formatters:
|
|
185
|
-
|
|
186
|
-
| Formatter | Representation |
|
|
187
|
-
|-----------|----------------|
|
|
188
|
-
| `%O` | Pretty-print an Object on multiple lines. |
|
|
189
|
-
| `%o` | Pretty-print an Object all on a single line. |
|
|
190
|
-
| `%s` | String. |
|
|
191
|
-
| `%d` | Number (both integer and float). |
|
|
192
|
-
| `%j` | JSON. Replaced with the string '[Circular]' if the argument contains circular references. |
|
|
193
|
-
| `%%` | Single percent sign ('%'). This does not consume an argument. |
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
### Custom formatters
|
|
197
|
-
|
|
198
|
-
You can add custom formatters by extending the `debug.formatters` object.
|
|
199
|
-
For example, if you wanted to add support for rendering a Buffer as hex with
|
|
200
|
-
`%h`, you could do something like:
|
|
201
|
-
|
|
202
|
-
```js
|
|
203
|
-
const createDebug = require('debug')
|
|
204
|
-
createDebug.formatters.h = (v) => {
|
|
205
|
-
return v.toString('hex')
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
// …elsewhere
|
|
209
|
-
const debug = createDebug('foo')
|
|
210
|
-
debug('this is hex: %h', new Buffer('hello world'))
|
|
211
|
-
// foo this is hex: 68656c6c6f20776f726c6421 +0ms
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
## Browser Support
|
|
216
|
-
|
|
217
|
-
You can build a browser-ready script using [browserify](https://github.com/substack/node-browserify),
|
|
218
|
-
or just use the [browserify-as-a-service](https://wzrd.in/) [build](https://wzrd.in/standalone/debug@latest),
|
|
219
|
-
if you don't want to build it yourself.
|
|
220
|
-
|
|
221
|
-
Debug's enable state is currently persisted by `localStorage`.
|
|
222
|
-
Consider the situation shown below where you have `worker:a` and `worker:b`,
|
|
223
|
-
and wish to debug both. You can enable this using `localStorage.debug`:
|
|
224
|
-
|
|
225
|
-
```js
|
|
226
|
-
localStorage.debug = 'worker:*'
|
|
227
|
-
```
|
|
228
|
-
|
|
229
|
-
And then refresh the page.
|
|
230
|
-
|
|
231
|
-
```js
|
|
232
|
-
a = debug('worker:a');
|
|
233
|
-
b = debug('worker:b');
|
|
234
|
-
|
|
235
|
-
setInterval(function(){
|
|
236
|
-
a('doing some work');
|
|
237
|
-
}, 1000);
|
|
238
|
-
|
|
239
|
-
setInterval(function(){
|
|
240
|
-
b('doing some work');
|
|
241
|
-
}, 1200);
|
|
242
|
-
```
|
|
243
|
-
|
|
244
|
-
In Chromium-based web browsers (e.g. Brave, Chrome, and Electron), the JavaScript console will—by default—only show messages logged by `debug` if the "Verbose" log level is _enabled_.
|
|
245
|
-
|
|
246
|
-
<img width="647" src="https://user-images.githubusercontent.com/7143133/152083257-29034707-c42c-4959-8add-3cee850e6fcf.png">
|
|
247
|
-
|
|
248
|
-
## Output streams
|
|
249
|
-
|
|
250
|
-
By default `debug` will log to stderr, however this can be configured per-namespace by overriding the `log` method:
|
|
251
|
-
|
|
252
|
-
Example [_stdout.js_](./examples/node/stdout.js):
|
|
253
|
-
|
|
254
|
-
```js
|
|
255
|
-
var debug = require('debug');
|
|
256
|
-
var error = debug('app:error');
|
|
257
|
-
|
|
258
|
-
// by default stderr is used
|
|
259
|
-
error('goes to stderr!');
|
|
260
|
-
|
|
261
|
-
var log = debug('app:log');
|
|
262
|
-
// set this namespace to log via console.log
|
|
263
|
-
log.log = console.log.bind(console); // don't forget to bind to console!
|
|
264
|
-
log('goes to stdout');
|
|
265
|
-
error('still goes to stderr!');
|
|
266
|
-
|
|
267
|
-
// set all output to go via console.info
|
|
268
|
-
// overrides all per-namespace log settings
|
|
269
|
-
debug.log = console.info.bind(console);
|
|
270
|
-
error('now goes to stdout via console.info');
|
|
271
|
-
log('still goes to stdout, but via console.info now');
|
|
272
|
-
```
|
|
273
|
-
|
|
274
|
-
## Extend
|
|
275
|
-
You can simply extend debugger
|
|
276
|
-
```js
|
|
277
|
-
const log = require('debug')('auth');
|
|
278
|
-
|
|
279
|
-
//creates new debug instance with extended namespace
|
|
280
|
-
const logSign = log.extend('sign');
|
|
281
|
-
const logLogin = log.extend('login');
|
|
282
|
-
|
|
283
|
-
log('hello'); // auth hello
|
|
284
|
-
logSign('hello'); //auth:sign hello
|
|
285
|
-
logLogin('hello'); //auth:login hello
|
|
286
|
-
```
|
|
287
|
-
|
|
288
|
-
## Set dynamically
|
|
289
|
-
|
|
290
|
-
You can also enable debug dynamically by calling the `enable()` method :
|
|
291
|
-
|
|
292
|
-
```js
|
|
293
|
-
let debug = require('debug');
|
|
294
|
-
|
|
295
|
-
console.log(1, debug.enabled('test'));
|
|
296
|
-
|
|
297
|
-
debug.enable('test');
|
|
298
|
-
console.log(2, debug.enabled('test'));
|
|
299
|
-
|
|
300
|
-
debug.disable();
|
|
301
|
-
console.log(3, debug.enabled('test'));
|
|
302
|
-
|
|
303
|
-
```
|
|
304
|
-
|
|
305
|
-
print :
|
|
306
|
-
```
|
|
307
|
-
1 false
|
|
308
|
-
2 true
|
|
309
|
-
3 false
|
|
310
|
-
```
|
|
311
|
-
|
|
312
|
-
Usage :
|
|
313
|
-
`enable(namespaces)`
|
|
314
|
-
`namespaces` can include modes separated by a colon and wildcards.
|
|
315
|
-
|
|
316
|
-
Note that calling `enable()` completely overrides previously set DEBUG variable :
|
|
317
|
-
|
|
318
|
-
```
|
|
319
|
-
$ DEBUG=foo node -e 'var dbg = require("debug"); dbg.enable("bar"); console.log(dbg.enabled("foo"))'
|
|
320
|
-
=> false
|
|
321
|
-
```
|
|
322
|
-
|
|
323
|
-
`disable()`
|
|
324
|
-
|
|
325
|
-
Will disable all namespaces. The functions returns the namespaces currently
|
|
326
|
-
enabled (and skipped). This can be useful if you want to disable debugging
|
|
327
|
-
temporarily without knowing what was enabled to begin with.
|
|
328
|
-
|
|
329
|
-
For example:
|
|
330
|
-
|
|
331
|
-
```js
|
|
332
|
-
let debug = require('debug');
|
|
333
|
-
debug.enable('foo:*,-foo:bar');
|
|
334
|
-
let namespaces = debug.disable();
|
|
335
|
-
debug.enable(namespaces);
|
|
336
|
-
```
|
|
337
|
-
|
|
338
|
-
Note: There is no guarantee that the string will be identical to the initial
|
|
339
|
-
enable string, but semantically they will be identical.
|
|
340
|
-
|
|
341
|
-
## Checking whether a debug target is enabled
|
|
342
|
-
|
|
343
|
-
After you've created a debug instance, you can determine whether or not it is
|
|
344
|
-
enabled by checking the `enabled` property:
|
|
345
|
-
|
|
346
|
-
```javascript
|
|
347
|
-
const debug = require('debug')('http');
|
|
348
|
-
|
|
349
|
-
if (debug.enabled) {
|
|
350
|
-
// do stuff...
|
|
351
|
-
}
|
|
352
|
-
```
|
|
353
|
-
|
|
354
|
-
You can also manually toggle this property to force the debug instance to be
|
|
355
|
-
enabled or disabled.
|
|
356
|
-
|
|
357
|
-
## Usage in child processes
|
|
358
|
-
|
|
359
|
-
Due to the way `debug` detects if the output is a TTY or not, colors are not shown in child processes when `stderr` is piped. A solution is to pass the `DEBUG_COLORS=1` environment variable to the child process.
|
|
360
|
-
For example:
|
|
361
|
-
|
|
362
|
-
```javascript
|
|
363
|
-
worker = fork(WORKER_WRAP_PATH, [workerPath], {
|
|
364
|
-
stdio: [
|
|
365
|
-
/* stdin: */ 0,
|
|
366
|
-
/* stdout: */ 'pipe',
|
|
367
|
-
/* stderr: */ 'pipe',
|
|
368
|
-
'ipc',
|
|
369
|
-
],
|
|
370
|
-
env: Object.assign({}, process.env, {
|
|
371
|
-
DEBUG_COLORS: 1 // without this settings, colors won't be shown
|
|
372
|
-
}),
|
|
373
|
-
});
|
|
374
|
-
|
|
375
|
-
worker.stderr.pipe(process.stderr, { end: false });
|
|
376
|
-
```
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
## Authors
|
|
380
|
-
|
|
381
|
-
- TJ Holowaychuk
|
|
382
|
-
- Nathan Rajlich
|
|
383
|
-
- Andrew Rhyne
|
|
384
|
-
- Josh Junon
|
|
385
|
-
|
|
386
|
-
## Backers
|
|
387
|
-
|
|
388
|
-
Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/debug#backer)]
|
|
389
|
-
|
|
390
|
-
<a href="https://opencollective.com/debug/backer/0/website" target="_blank"><img src="https://opencollective.com/debug/backer/0/avatar.svg"></a>
|
|
391
|
-
<a href="https://opencollective.com/debug/backer/1/website" target="_blank"><img src="https://opencollective.com/debug/backer/1/avatar.svg"></a>
|
|
392
|
-
<a href="https://opencollective.com/debug/backer/2/website" target="_blank"><img src="https://opencollective.com/debug/backer/2/avatar.svg"></a>
|
|
393
|
-
<a href="https://opencollective.com/debug/backer/3/website" target="_blank"><img src="https://opencollective.com/debug/backer/3/avatar.svg"></a>
|
|
394
|
-
<a href="https://opencollective.com/debug/backer/4/website" target="_blank"><img src="https://opencollective.com/debug/backer/4/avatar.svg"></a>
|
|
395
|
-
<a href="https://opencollective.com/debug/backer/5/website" target="_blank"><img src="https://opencollective.com/debug/backer/5/avatar.svg"></a>
|
|
396
|
-
<a href="https://opencollective.com/debug/backer/6/website" target="_blank"><img src="https://opencollective.com/debug/backer/6/avatar.svg"></a>
|
|
397
|
-
<a href="https://opencollective.com/debug/backer/7/website" target="_blank"><img src="https://opencollective.com/debug/backer/7/avatar.svg"></a>
|
|
398
|
-
<a href="https://opencollective.com/debug/backer/8/website" target="_blank"><img src="https://opencollective.com/debug/backer/8/avatar.svg"></a>
|
|
399
|
-
<a href="https://opencollective.com/debug/backer/9/website" target="_blank"><img src="https://opencollective.com/debug/backer/9/avatar.svg"></a>
|
|
400
|
-
<a href="https://opencollective.com/debug/backer/10/website" target="_blank"><img src="https://opencollective.com/debug/backer/10/avatar.svg"></a>
|
|
401
|
-
<a href="https://opencollective.com/debug/backer/11/website" target="_blank"><img src="https://opencollective.com/debug/backer/11/avatar.svg"></a>
|
|
402
|
-
<a href="https://opencollective.com/debug/backer/12/website" target="_blank"><img src="https://opencollective.com/debug/backer/12/avatar.svg"></a>
|
|
403
|
-
<a href="https://opencollective.com/debug/backer/13/website" target="_blank"><img src="https://opencollective.com/debug/backer/13/avatar.svg"></a>
|
|
404
|
-
<a href="https://opencollective.com/debug/backer/14/website" target="_blank"><img src="https://opencollective.com/debug/backer/14/avatar.svg"></a>
|
|
405
|
-
<a href="https://opencollective.com/debug/backer/15/website" target="_blank"><img src="https://opencollective.com/debug/backer/15/avatar.svg"></a>
|
|
406
|
-
<a href="https://opencollective.com/debug/backer/16/website" target="_blank"><img src="https://opencollective.com/debug/backer/16/avatar.svg"></a>
|
|
407
|
-
<a href="https://opencollective.com/debug/backer/17/website" target="_blank"><img src="https://opencollective.com/debug/backer/17/avatar.svg"></a>
|
|
408
|
-
<a href="https://opencollective.com/debug/backer/18/website" target="_blank"><img src="https://opencollective.com/debug/backer/18/avatar.svg"></a>
|
|
409
|
-
<a href="https://opencollective.com/debug/backer/19/website" target="_blank"><img src="https://opencollective.com/debug/backer/19/avatar.svg"></a>
|
|
410
|
-
<a href="https://opencollective.com/debug/backer/20/website" target="_blank"><img src="https://opencollective.com/debug/backer/20/avatar.svg"></a>
|
|
411
|
-
<a href="https://opencollective.com/debug/backer/21/website" target="_blank"><img src="https://opencollective.com/debug/backer/21/avatar.svg"></a>
|
|
412
|
-
<a href="https://opencollective.com/debug/backer/22/website" target="_blank"><img src="https://opencollective.com/debug/backer/22/avatar.svg"></a>
|
|
413
|
-
<a href="https://opencollective.com/debug/backer/23/website" target="_blank"><img src="https://opencollective.com/debug/backer/23/avatar.svg"></a>
|
|
414
|
-
<a href="https://opencollective.com/debug/backer/24/website" target="_blank"><img src="https://opencollective.com/debug/backer/24/avatar.svg"></a>
|
|
415
|
-
<a href="https://opencollective.com/debug/backer/25/website" target="_blank"><img src="https://opencollective.com/debug/backer/25/avatar.svg"></a>
|
|
416
|
-
<a href="https://opencollective.com/debug/backer/26/website" target="_blank"><img src="https://opencollective.com/debug/backer/26/avatar.svg"></a>
|
|
417
|
-
<a href="https://opencollective.com/debug/backer/27/website" target="_blank"><img src="https://opencollective.com/debug/backer/27/avatar.svg"></a>
|
|
418
|
-
<a href="https://opencollective.com/debug/backer/28/website" target="_blank"><img src="https://opencollective.com/debug/backer/28/avatar.svg"></a>
|
|
419
|
-
<a href="https://opencollective.com/debug/backer/29/website" target="_blank"><img src="https://opencollective.com/debug/backer/29/avatar.svg"></a>
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
## Sponsors
|
|
423
|
-
|
|
424
|
-
Become a sponsor and get your logo on our README on Github with a link to your site. [[Become a sponsor](https://opencollective.com/debug#sponsor)]
|
|
425
|
-
|
|
426
|
-
<a href="https://opencollective.com/debug/sponsor/0/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/0/avatar.svg"></a>
|
|
427
|
-
<a href="https://opencollective.com/debug/sponsor/1/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/1/avatar.svg"></a>
|
|
428
|
-
<a href="https://opencollective.com/debug/sponsor/2/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/2/avatar.svg"></a>
|
|
429
|
-
<a href="https://opencollective.com/debug/sponsor/3/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/3/avatar.svg"></a>
|
|
430
|
-
<a href="https://opencollective.com/debug/sponsor/4/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/4/avatar.svg"></a>
|
|
431
|
-
<a href="https://opencollective.com/debug/sponsor/5/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/5/avatar.svg"></a>
|
|
432
|
-
<a href="https://opencollective.com/debug/sponsor/6/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/6/avatar.svg"></a>
|
|
433
|
-
<a href="https://opencollective.com/debug/sponsor/7/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/7/avatar.svg"></a>
|
|
434
|
-
<a href="https://opencollective.com/debug/sponsor/8/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/8/avatar.svg"></a>
|
|
435
|
-
<a href="https://opencollective.com/debug/sponsor/9/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/9/avatar.svg"></a>
|
|
436
|
-
<a href="https://opencollective.com/debug/sponsor/10/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/10/avatar.svg"></a>
|
|
437
|
-
<a href="https://opencollective.com/debug/sponsor/11/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/11/avatar.svg"></a>
|
|
438
|
-
<a href="https://opencollective.com/debug/sponsor/12/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/12/avatar.svg"></a>
|
|
439
|
-
<a href="https://opencollective.com/debug/sponsor/13/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/13/avatar.svg"></a>
|
|
440
|
-
<a href="https://opencollective.com/debug/sponsor/14/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/14/avatar.svg"></a>
|
|
441
|
-
<a href="https://opencollective.com/debug/sponsor/15/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/15/avatar.svg"></a>
|
|
442
|
-
<a href="https://opencollective.com/debug/sponsor/16/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/16/avatar.svg"></a>
|
|
443
|
-
<a href="https://opencollective.com/debug/sponsor/17/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/17/avatar.svg"></a>
|
|
444
|
-
<a href="https://opencollective.com/debug/sponsor/18/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/18/avatar.svg"></a>
|
|
445
|
-
<a href="https://opencollective.com/debug/sponsor/19/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/19/avatar.svg"></a>
|
|
446
|
-
<a href="https://opencollective.com/debug/sponsor/20/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/20/avatar.svg"></a>
|
|
447
|
-
<a href="https://opencollective.com/debug/sponsor/21/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/21/avatar.svg"></a>
|
|
448
|
-
<a href="https://opencollective.com/debug/sponsor/22/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/22/avatar.svg"></a>
|
|
449
|
-
<a href="https://opencollective.com/debug/sponsor/23/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/23/avatar.svg"></a>
|
|
450
|
-
<a href="https://opencollective.com/debug/sponsor/24/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/24/avatar.svg"></a>
|
|
451
|
-
<a href="https://opencollective.com/debug/sponsor/25/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/25/avatar.svg"></a>
|
|
452
|
-
<a href="https://opencollective.com/debug/sponsor/26/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/26/avatar.svg"></a>
|
|
453
|
-
<a href="https://opencollective.com/debug/sponsor/27/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/27/avatar.svg"></a>
|
|
454
|
-
<a href="https://opencollective.com/debug/sponsor/28/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/28/avatar.svg"></a>
|
|
455
|
-
<a href="https://opencollective.com/debug/sponsor/29/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/29/avatar.svg"></a>
|
|
456
|
-
|
|
457
|
-
## License
|
|
458
|
-
|
|
459
|
-
(The MIT License)
|
|
460
|
-
|
|
461
|
-
Copyright (c) 2014-2017 TJ Holowaychuk <tj@vision-media.ca>
|
|
462
|
-
Copyright (c) 2018-2021 Josh Junon
|
|
463
|
-
|
|
464
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
465
|
-
a copy of this software and associated documentation files (the
|
|
466
|
-
'Software'), to deal in the Software without restriction, including
|
|
467
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
468
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
469
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
470
|
-
the following conditions:
|
|
471
|
-
|
|
472
|
-
The above copyright notice and this permission notice shall be
|
|
473
|
-
included in all copies or substantial portions of the Software.
|
|
474
|
-
|
|
475
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
476
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
477
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
478
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
479
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
480
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
481
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
exif-parser
|
|
2
|
-
========
|
|
3
|
-
exif-parser is a parser for image metadata in the exif format, the most popular metadata format for jpeg and tiff images. It is written in pure javascript and has no external dependencies. It can also get the size of jpeg images and the size of the jpeg thumbnail embedded in the exif data. It can also extract the embedded thumbnail image.
|
|
4
|
-
|
|
5
|
-
### Installing
|
|
6
|
-
|
|
7
|
-
npm install exif-parser
|
|
8
|
-
|
|
9
|
-
You can also build a browser bundle to include it with a `<script>` tag in a HTML document, like this:
|
|
10
|
-
|
|
11
|
-
git clone git@github.com:bwindels/exif-parser.git
|
|
12
|
-
cd exif-parser/
|
|
13
|
-
make build-browser-bundle
|
|
14
|
-
|
|
15
|
-
Built versions of the bundles are also available in the [exif-parser-browser-bundles repo](https://github.com/bwindels/exif-parser-browser-bundles).
|
|
16
|
-
|
|
17
|
-
This will generate a `dist/exif-parser-(version).js` and `dist/exif-parser-(version)-min.js` file. These bundles expose the parser on the `ExifParser` global variable, which you would use like this:
|
|
18
|
-
|
|
19
|
-
var parser = window.ExifParser.create(arrayBuffer);
|
|
20
|
-
|
|
21
|
-
### Creating a parser
|
|
22
|
-
To start parsing exif data, create a new parser like below. Note that the buffer you pass does not have to be the buffer for the full jpeg file. The exif section of a jpeg file has a maximum size of 65535 bytes and the section seems to always occur within the first 100 bytes of the file. So it is safe to only fetch the first 65635 bytes of a jpeg file and pass those to the parser.
|
|
23
|
-
|
|
24
|
-
The buffer you pass to create can be a node buffer or a DOM ArrayBuffer.
|
|
25
|
-
|
|
26
|
-
```
|
|
27
|
-
var parser = require('exif-parser').create(buffer);
|
|
28
|
-
var result = parser.parse();
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
### Setting the flags
|
|
32
|
-
|
|
33
|
-
Before calling parse, you can set a number of flags on the parser, telling it how to behave while parsing.
|
|
34
|
-
|
|
35
|
-
Add fields in the binary format to result. Since these fields are mostly used for internal fields like Padding, you generally are not interested in these. If enabled, values for these fields will be a Buffer object in node or an ArrayBuffer in DOM environments (browsers).
|
|
36
|
-
|
|
37
|
-
parser.enableBinaryFields([boolean]), default false;
|
|
38
|
-
|
|
39
|
-
EXIF tags are organized into different sections, and to tell you the offset to other sections, EXIF uses certain tags. These tags don't tell you anything about the image, but are more for parsers to find out about all tags. Hence, these "pointer" fields are not included in the result tags field by default. Change this flag to include them nonetheless.
|
|
40
|
-
|
|
41
|
-
parser.enablePointers([boolean]), default false;
|
|
42
|
-
|
|
43
|
-
Resolve tags to their textual name, making result.tags a dictonary object instead of an array with the tag objects with no textual tag name.
|
|
44
|
-
|
|
45
|
-
parser.enableTagNames([boolean]), default true;
|
|
46
|
-
|
|
47
|
-
Read the image size while parsing.
|
|
48
|
-
|
|
49
|
-
parser.enableImageSize([boolean]), default true;
|
|
50
|
-
|
|
51
|
-
Read the EXIF tags. Could be useful to disable if you only want to read the image size.
|
|
52
|
-
|
|
53
|
-
parser.enableReturnTags([boolean]), default true;
|
|
54
|
-
|
|
55
|
-
EXIF values can be represented in a number of formats (fractions, degrees, arrays, ...) with different precision.
|
|
56
|
-
Enabling this tries to cast values as much as possible to the appropriate javascript types like number, Date.
|
|
57
|
-
|
|
58
|
-
parser.enableSimpleValues([boolean]), default true;
|
|
59
|
-
|
|
60
|
-
### working with the result
|
|
61
|
-
|
|
62
|
-
#### Getting the tags
|
|
63
|
-
the tags that were found while parsing are stored in ```result.tags``` unless you set ```parser.enableReturnTags(false)```. If ```parser.enableTagNames``` is set to true, ```result.tags``` will be an object with the key being the tag name and the value being the tag value. If ```parser.enableTagNames``` is set to false, ```result.tags``` will be an array of objects containing section, type and value properties.
|
|
64
|
-
|
|
65
|
-
#### Getting the image size
|
|
66
|
-
If ```parser.enableImageSize``` is set to true, ```result.getImageSize()``` will give you the image size as an object with width and height properties.
|
|
67
|
-
|
|
68
|
-
#### Getting the thumbnail
|
|
69
|
-
|
|
70
|
-
You can check if there is a thumbnail present in the exif data with ```result.hasThumbnail()```. Exif supports thumbnails is jpeg and tiff format, though most are in jpeg format. You can check if there is a thumbnail present in a give format by passing the mime type: ```result.hasThumbnail("image/jpeg")```.
|
|
71
|
-
|
|
72
|
-
You can also get the image size of the thumbnail as an object with width and height properties: ```result.getThumbnailSize()```.
|
|
73
|
-
|
|
74
|
-
To get the node buffer or arraybuffer containing just the thumbnail, call ```result.getThumbnailBuffer()```
|
|
75
|
-
|
|
76
|
-
# Running the unit tests
|
|
77
|
-
|
|
78
|
-
Install `nodeunit` globally from npm if you haven't done so already.
|
|
79
|
-
You can run the tests with `nodeunit test/test-*.js`.
|
|
80
|
-
|
|
81
|
-
# Contributions
|
|
82
|
-
|
|
83
|
-
I welcome external contributions through pull requests. If you do so, please don't use regular expressions. I don't like them, and don't want to maintain a project where they are used. Also, when fixing a bug please provide a regression unit test if it makes sense.
|