@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,120 +0,0 @@
|
|
|
1
|
-
[](https://github.com/Borewit/token-types/actions/workflows/nodejs-ci.yml?query=branch%3Amaster)
|
|
2
|
-
[](https://npmjs.org/package/token-types)
|
|
3
|
-
[](https://npmcharts.com/compare/token-types,strtok3?start=1200&interval=30)
|
|
4
|
-
[](https://coveralls.io/github/Borewit/token-types?branch=master)
|
|
5
|
-
[](https://www.codacy.com/app/Borewit/token-types?utm_source=github.com&utm_medium=referral&utm_content=Borewit/token-types&utm_campaign=Badge_Grade)
|
|
6
|
-
[](https://deepscan.io/dashboard#view=project&tid=5165&pid=6940&bid=61852)
|
|
7
|
-
[](https://snyk.io/test/github/Borewit/token-types?targetFile=package.json)
|
|
8
|
-
|
|
9
|
-
# token-types
|
|
10
|
-
|
|
11
|
-
A primitive token library used to read and write from a `Uint8Array`.
|
|
12
|
-
Although it is possible to use this module directly, it is primarily designed to be used with [strtok3 tokenizer](https://github.com/Borewit/strtok3).
|
|
13
|
-
|
|
14
|
-
## Compatibility
|
|
15
|
-
|
|
16
|
-
Module: version 5 migrated from [CommonJS](https://en.wikipedia.org/wiki/CommonJS) to [pure ECMAScript Module (ESM)](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c).
|
|
17
|
-
JavaScript is compliant with [ECMAScript 2019 (ES10)](https://en.wikipedia.org/wiki/ECMAScript#10th_Edition_%E2%80%93_ECMAScript_2019).
|
|
18
|
-
|
|
19
|
-
## Installation
|
|
20
|
-
|
|
21
|
-
```sh
|
|
22
|
-
npm install --save token-types
|
|
23
|
-
```
|
|
24
|
-
Usually in combination with [strtok3](https://github.com/Borewit/strtok3):
|
|
25
|
-
```sh
|
|
26
|
-
npm install --save strtok3
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
Using TypeScript you should also install [@tokenizer/token](https://github.com/Borewit/tokenizer-token) as a development
|
|
30
|
-
dependency:
|
|
31
|
-
|
|
32
|
-
```shell
|
|
33
|
-
npm install --save-dev @tokenizer/token
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
## Example
|
|
38
|
-
|
|
39
|
-
```js
|
|
40
|
-
import * as strtok3 from 'strtok3';
|
|
41
|
-
import * as token from 'token-types';
|
|
42
|
-
|
|
43
|
-
(async () => {
|
|
44
|
-
|
|
45
|
-
const tokenizer = await strtok3.fromFile("somefile.bin");
|
|
46
|
-
try {
|
|
47
|
-
const myNumber = await tokenizer.readToken(token.Float32_BE);
|
|
48
|
-
console.log(`My number: ${myNumber}`);
|
|
49
|
-
} finally {
|
|
50
|
-
tokenizer.close(); // Close the file
|
|
51
|
-
}
|
|
52
|
-
})();
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
## Tokens
|
|
56
|
-
|
|
57
|
-
### Numeric tokens
|
|
58
|
-
|
|
59
|
-
`token-types` supports a wide variety of numeric tokens out of the box:
|
|
60
|
-
|
|
61
|
-
| Token | Number | Bits | Endianness |
|
|
62
|
-
|---------------|------------------|------|----------------|
|
|
63
|
-
| `UINT8` | Unsigned integer | 8 | n/a |
|
|
64
|
-
| `UINT16_BE` | Unsigned integer | 16 | big endian |
|
|
65
|
-
| `UINT16_LE` | Unsigned integer | 16 | little endian |
|
|
66
|
-
| `UINT24_BE` | Unsigned integer | 24 | big endian |
|
|
67
|
-
| `UINT24_LE` | Unsigned integer | 24 | little endian |
|
|
68
|
-
| `UINT32_BE` | Unsigned integer | 32 | big endian |
|
|
69
|
-
| `UINT32_LE` | Unsigned integer | 32 | little endian |
|
|
70
|
-
| `UINT64_BE` | Unsigned integer | 64 | big endian |
|
|
71
|
-
| `UINT64_LE`* | Unsigned integer | 64 | little endian |
|
|
72
|
-
| `INT8` | Signed integer | 8 | n/a |
|
|
73
|
-
| `INT16_BE` | Signed integer | 16 | big endian |
|
|
74
|
-
| `INT16_LE` | Signed integer | 16 | little endian |
|
|
75
|
-
| `INT24_BE` | Signed integer | 24 | big endian |
|
|
76
|
-
| `INT24_LE` | Signed integer | 24 | little endian |
|
|
77
|
-
| `INT32_BE` | Signed integer | 32 | big endian |
|
|
78
|
-
| `INT32_LE` | Signed integer | 32 | little endian |
|
|
79
|
-
| `INT64_BE` | Signed integer | 64 | big endian |
|
|
80
|
-
| `INT64_LE`* | Signed integer | 64 | little endian |
|
|
81
|
-
| `Float16_BE` | IEEE 754 float | 16 | big endian |
|
|
82
|
-
| `Float16_LE` | IEEE 754 float | 16 | little endian |
|
|
83
|
-
| `Float32_BE` | IEEE 754 float | 32 | big endian |
|
|
84
|
-
| `Float32_LE` | IEEE 754 float | 32 | little endian |
|
|
85
|
-
| `Float64_BE` | IEEE 754 float | 64 | big endian |
|
|
86
|
-
| `Float64_LE` | IEEE 754 float | 64 | little endian |
|
|
87
|
-
| `Float80_BE`* | IEEE 754 float | 80 | big endian |
|
|
88
|
-
| `Float80_LE`* | IEEE 754 float | 80 | little endian |
|
|
89
|
-
|
|
90
|
-
(*) The tokens exceed the JavaScript IEEE 754 64-bit Floating Point precision, decoding and encoding is best effort based.
|
|
91
|
-
|
|
92
|
-
### String tokens
|
|
93
|
-
|
|
94
|
-
StringType decoding is using [@borewit/text-codec](https://github.com/Borewit/text-codec).
|
|
95
|
-
|
|
96
|
-
### Custom tokens
|
|
97
|
-
|
|
98
|
-
Custom tokens can be added, suitable for reading binary files or network messages:
|
|
99
|
-
```js
|
|
100
|
-
ExtendedHeader = {
|
|
101
|
-
len: 10,
|
|
102
|
-
|
|
103
|
-
get: (buf, off) => {
|
|
104
|
-
return {
|
|
105
|
-
// Extended header size
|
|
106
|
-
size: Token.UINT32_BE.get(buf, off),
|
|
107
|
-
// Extended Flags
|
|
108
|
-
extendedFlags: Token.UINT16_BE.get(buf, off + 4),
|
|
109
|
-
// Size of padding
|
|
110
|
-
sizeOfPadding: Token.UINT32_BE.get(buf, off + 6),
|
|
111
|
-
// CRC data present
|
|
112
|
-
crcDataPresent: common.strtokBITSET.get(buf, off + 4, 31)
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
## Licence
|
|
119
|
-
|
|
120
|
-
This project is licensed under the [MIT License](LICENSE.txt). Feel free to use, modify, and distribute as needed.
|
|
@@ -1,318 +0,0 @@
|
|
|
1
|
-
# uint8array-extras
|
|
2
|
-
|
|
3
|
-
> Useful utilities for working with [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) (and [`Buffer`](https://nodejs.org/api/buffer.html))
|
|
4
|
-
|
|
5
|
-
It's time to [transition from `Buffer` to `Uint8Array`](https://sindresorhus.com/blog/goodbye-nodejs-buffer), and this package helps fill in the gaps.
|
|
6
|
-
|
|
7
|
-
Note that `Buffer` is a `Uint8Array` subclass, so you can use this package with `Buffer` too.
|
|
8
|
-
|
|
9
|
-
This package is tree-shakeable and browser-compatible.
|
|
10
|
-
|
|
11
|
-
This package also includes methods to convert a string to Base64 and back.
|
|
12
|
-
|
|
13
|
-
Note: In the browser, do not use [`globalThis.atob()`](https://developer.mozilla.org/en-US/docs/Web/API/atob) / [`globalThis.btoa()`](https://developer.mozilla.org/en-US/docs/Web/API/btoa) because they [do not support Unicode](https://developer.mozilla.org/en-US/docs/Glossary/Base64#the_unicode_problem). This package does.
|
|
14
|
-
|
|
15
|
-
## Install
|
|
16
|
-
|
|
17
|
-
```sh
|
|
18
|
-
npm install uint8array-extras
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
## Usage
|
|
22
|
-
|
|
23
|
-
```js
|
|
24
|
-
import {concatUint8Arrays} from 'uint8array-extras';
|
|
25
|
-
|
|
26
|
-
const a = new Uint8Array([1, 2, 3]);
|
|
27
|
-
const b = new Uint8Array([4, 5, 6]);
|
|
28
|
-
|
|
29
|
-
console.log(concatUint8Arrays([a, b]));
|
|
30
|
-
//=> Uint8Array [1, 2, 3, 4, 5, 6]
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
## API
|
|
34
|
-
|
|
35
|
-
### `isUint8Array(value: unknown): boolean`
|
|
36
|
-
|
|
37
|
-
Check if the given value is an instance of `Uint8Array`.
|
|
38
|
-
|
|
39
|
-
Replacement for [`Buffer.isBuffer()`](https://nodejs.org/api/buffer.html#static-method-bufferisbufferobj).
|
|
40
|
-
|
|
41
|
-
```js
|
|
42
|
-
import {isUint8Array} from 'uint8array-extras';
|
|
43
|
-
|
|
44
|
-
console.log(isUint8Array(new Uint8Array()));
|
|
45
|
-
//=> true
|
|
46
|
-
|
|
47
|
-
console.log(isUint8Array(Buffer.from('x')));
|
|
48
|
-
//=> true
|
|
49
|
-
|
|
50
|
-
console.log(isUint8Array(new ArrayBuffer(10)));
|
|
51
|
-
//=> false
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
### `assertUint8Array(value: unknown)`
|
|
55
|
-
|
|
56
|
-
Throw a `TypeError` if the given value is not an instance of `Uint8Array`.
|
|
57
|
-
|
|
58
|
-
```js
|
|
59
|
-
import {assertUint8Array} from 'uint8array-extras';
|
|
60
|
-
|
|
61
|
-
try {
|
|
62
|
-
assertUint8Array(new ArrayBuffer(10)); // Throws a TypeError
|
|
63
|
-
} catch (error) {
|
|
64
|
-
console.error(error.message);
|
|
65
|
-
}
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
### `assertUint8ArrayOrArrayBuffer(value: unknown)`
|
|
69
|
-
|
|
70
|
-
Throw a `TypeError` if the given value is not an instance of `Uint8Array` or `ArrayBuffer`.
|
|
71
|
-
|
|
72
|
-
Useful as a guard for functions that accept either a `Uint8Array` or `ArrayBuffer`.
|
|
73
|
-
|
|
74
|
-
```js
|
|
75
|
-
import {assertUint8ArrayOrArrayBuffer} from 'uint8array-extras';
|
|
76
|
-
|
|
77
|
-
assertUint8ArrayOrArrayBuffer(new Uint8Array());
|
|
78
|
-
assertUint8ArrayOrArrayBuffer(new ArrayBuffer(8));
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
### `toUint8Array(value: TypedArray | ArrayBuffer | DataView): Uint8Array`
|
|
82
|
-
|
|
83
|
-
Convert a value to a `Uint8Array` without copying its data.
|
|
84
|
-
|
|
85
|
-
This can be useful for converting a `Buffer` to a pure `Uint8Array`. `Buffer` is already a `Uint8Array` subclass, but [`Buffer` alters some behavior](https://sindresorhus.com/blog/goodbye-nodejs-buffer), so it can be useful to cast it to a pure `Uint8Array` before returning it.
|
|
86
|
-
|
|
87
|
-
Tip: If you want a copy, just call `.slice()` on the return value.
|
|
88
|
-
|
|
89
|
-
### `concatUint8Arrays(arrays: Array<Uint8Array | ArrayBuffer>, totalLength?: number): Uint8Array`
|
|
90
|
-
|
|
91
|
-
Concatenate the given arrays into a new array.
|
|
92
|
-
|
|
93
|
-
If `arrays` is empty, it will return a zero-sized `Uint8Array`.
|
|
94
|
-
|
|
95
|
-
If `totalLength` is not specified, it is calculated from summing the lengths of the given arrays.
|
|
96
|
-
|
|
97
|
-
Replacement for [`Buffer.concat()`](https://nodejs.org/api/buffer.html#static-method-bufferconcatlist-totallength).
|
|
98
|
-
|
|
99
|
-
```js
|
|
100
|
-
import {concatUint8Arrays} from 'uint8array-extras';
|
|
101
|
-
|
|
102
|
-
const a = new Uint8Array([1, 2, 3]);
|
|
103
|
-
const b = new Uint8Array([4, 5, 6]);
|
|
104
|
-
|
|
105
|
-
console.log(concatUint8Arrays([a, b]));
|
|
106
|
-
//=> Uint8Array [1, 2, 3, 4, 5, 6]
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
### `areUint8ArraysEqual(a: Uint8Array | ArrayBuffer, b: Uint8Array | ArrayBuffer): boolean`
|
|
110
|
-
|
|
111
|
-
Check if two arrays are identical by verifying that they contain the same bytes in the same sequence.
|
|
112
|
-
|
|
113
|
-
Replacement for [`Buffer#equals()`](https://nodejs.org/api/buffer.html#bufequalsotherbuffer).
|
|
114
|
-
|
|
115
|
-
```js
|
|
116
|
-
import {areUint8ArraysEqual} from 'uint8array-extras';
|
|
117
|
-
|
|
118
|
-
const a = new Uint8Array([1, 2, 3]);
|
|
119
|
-
const b = new Uint8Array([1, 2, 3]);
|
|
120
|
-
const c = new Uint8Array([4, 5, 6]);
|
|
121
|
-
|
|
122
|
-
console.log(areUint8ArraysEqual(a, b));
|
|
123
|
-
//=> true
|
|
124
|
-
|
|
125
|
-
console.log(areUint8ArraysEqual(a, c));
|
|
126
|
-
//=> false
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
### `compareUint8Arrays(a: Uint8Array | ArrayBuffer, b: Uint8Array | ArrayBuffer): 0 | 1 | -1`
|
|
130
|
-
|
|
131
|
-
Compare two arrays and indicate their relative order or equality. Useful for sorting.
|
|
132
|
-
|
|
133
|
-
Replacement for [`Buffer.compare()`](https://nodejs.org/api/buffer.html#static-method-buffercomparebuf1-buf2).
|
|
134
|
-
|
|
135
|
-
```js
|
|
136
|
-
import {compareUint8Arrays} from 'uint8array-extras';
|
|
137
|
-
|
|
138
|
-
const array1 = new Uint8Array([1, 2, 3]);
|
|
139
|
-
const array2 = new Uint8Array([4, 5, 6]);
|
|
140
|
-
const array3 = new Uint8Array([7, 8, 9]);
|
|
141
|
-
|
|
142
|
-
[array3, array1, array2].sort(compareUint8Arrays);
|
|
143
|
-
//=> [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
### `uint8ArrayToString(array: Uint8Array | ArrayBuffer, encoding?: string = 'utf8'): string`
|
|
147
|
-
|
|
148
|
-
Convert a `Uint8Array` to a string.
|
|
149
|
-
|
|
150
|
-
- Parameter: `encoding` - The [encoding](https://developer.mozilla.org/en-US/docs/Web/API/Encoding_API/Encodings) to convert from.
|
|
151
|
-
|
|
152
|
-
Replacement for [`Buffer#toString()`](https://nodejs.org/api/buffer.html#buftostringencoding-start-end). For the `encoding` parameter, `latin1` should be used instead of `binary` and `utf-16le` instead of `utf16le`.
|
|
153
|
-
|
|
154
|
-
```js
|
|
155
|
-
import {uint8ArrayToString} from 'uint8array-extras';
|
|
156
|
-
|
|
157
|
-
const byteArray = new Uint8Array([72, 101, 108, 108, 111]);
|
|
158
|
-
console.log(uint8ArrayToString(byteArray));
|
|
159
|
-
//=> 'Hello'
|
|
160
|
-
|
|
161
|
-
const zh = new Uint8Array([167, 65, 166, 110]);
|
|
162
|
-
console.log(uint8ArrayToString(zh, 'big5'));
|
|
163
|
-
//=> '你好'
|
|
164
|
-
|
|
165
|
-
const ja = new Uint8Array([130, 177, 130, 241, 130, 201, 130, 191, 130, 205]);
|
|
166
|
-
console.log(uint8ArrayToString(ja, 'shift-jis'));
|
|
167
|
-
//=> 'こんにちは'
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
### `stringToUint8Array(string: string): Uint8Array`
|
|
171
|
-
|
|
172
|
-
Convert a string to a `Uint8Array` (using UTF-8 encoding).
|
|
173
|
-
|
|
174
|
-
Replacement for [`Buffer.from('Hello')`](https://nodejs.org/api/buffer.html#static-method-bufferfromstring-encoding).
|
|
175
|
-
|
|
176
|
-
```js
|
|
177
|
-
import {stringToUint8Array} from 'uint8array-extras';
|
|
178
|
-
|
|
179
|
-
console.log(stringToUint8Array('Hello'));
|
|
180
|
-
//=> Uint8Array [72, 101, 108, 108, 111]
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
### `uint8ArrayToBase64(array: Uint8Array | ArrayBuffer, options?: {urlSafe: boolean}): string`
|
|
184
|
-
|
|
185
|
-
Convert a `Uint8Array` to a Base64-encoded string.
|
|
186
|
-
|
|
187
|
-
Specify `{urlSafe: true}` to get a [Base64URL](https://base64.guru/standards/base64url)-encoded string.
|
|
188
|
-
|
|
189
|
-
Replacement for [`Buffer#toString('base64')`](https://nodejs.org/api/buffer.html#buftostringencoding-start-end).
|
|
190
|
-
|
|
191
|
-
```js
|
|
192
|
-
import {uint8ArrayToBase64} from 'uint8array-extras';
|
|
193
|
-
|
|
194
|
-
const byteArray = new Uint8Array([72, 101, 108, 108, 111]);
|
|
195
|
-
|
|
196
|
-
console.log(uint8ArrayToBase64(byteArray));
|
|
197
|
-
//=> 'SGVsbG8='
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
### `base64ToUint8Array(string: string): Uint8Array`
|
|
201
|
-
|
|
202
|
-
Convert a Base64-encoded or [Base64URL](https://base64.guru/standards/base64url)-encoded string to a `Uint8Array`.
|
|
203
|
-
|
|
204
|
-
Accepts Base64URL with or without padding.
|
|
205
|
-
|
|
206
|
-
Replacement for [`Buffer.from('SGVsbG8=', 'base64')`](https://nodejs.org/api/buffer.html#static-method-bufferfromstring-encoding).
|
|
207
|
-
|
|
208
|
-
```js
|
|
209
|
-
import {base64ToUint8Array} from 'uint8array-extras';
|
|
210
|
-
|
|
211
|
-
console.log(base64ToUint8Array('SGVsbG8='));
|
|
212
|
-
//=> Uint8Array [72, 101, 108, 108, 111]
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
### `stringToBase64(string: string, options?: {urlSafe: boolean}): string`
|
|
216
|
-
|
|
217
|
-
Encode a string to a Base64-encoded string.
|
|
218
|
-
|
|
219
|
-
Specify `{urlSafe: true}` to get a [Base64URL](https://base64.guru/standards/base64url)-encoded string.
|
|
220
|
-
|
|
221
|
-
Replacement for `Buffer.from('Hello').toString('base64')` and [`btoa()`](https://developer.mozilla.org/en-US/docs/Web/API/btoa).
|
|
222
|
-
|
|
223
|
-
```js
|
|
224
|
-
import {stringToBase64} from 'uint8array-extras';
|
|
225
|
-
|
|
226
|
-
console.log(stringToBase64('Hello'));
|
|
227
|
-
//=> 'SGVsbG8='
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
### `base64ToString(base64String: string): string`
|
|
231
|
-
|
|
232
|
-
Decode a Base64-encoded or [Base64URL](https://base64.guru/standards/base64url)-encoded string to a string.
|
|
233
|
-
|
|
234
|
-
Accepts Base64URL with or without padding.
|
|
235
|
-
|
|
236
|
-
Replacement for `Buffer.from('SGVsbG8=', 'base64').toString()` and [`atob()`](https://developer.mozilla.org/en-US/docs/Web/API/atob).
|
|
237
|
-
|
|
238
|
-
```js
|
|
239
|
-
import {base64ToString} from 'uint8array-extras';
|
|
240
|
-
|
|
241
|
-
console.log(base64ToString('SGVsbG8='));
|
|
242
|
-
//=> 'Hello'
|
|
243
|
-
```
|
|
244
|
-
|
|
245
|
-
### `uint8ArrayToHex(array: Uint8Array | ArrayBuffer): string`
|
|
246
|
-
|
|
247
|
-
Convert a `Uint8Array` to a Hex string.
|
|
248
|
-
|
|
249
|
-
Replacement for [`Buffer#toString('hex')`](https://nodejs.org/api/buffer.html#buftostringencoding-start-end).
|
|
250
|
-
|
|
251
|
-
```js
|
|
252
|
-
import {uint8ArrayToHex} from 'uint8array-extras';
|
|
253
|
-
|
|
254
|
-
const byteArray = new Uint8Array([72, 101, 108, 108, 111]);
|
|
255
|
-
|
|
256
|
-
console.log(uint8ArrayToHex(byteArray));
|
|
257
|
-
//=> '48656c6c6f'
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
### `hexToUint8Array(hexString: string): Uint8Array`
|
|
261
|
-
|
|
262
|
-
Convert a Hex string to a `Uint8Array`.
|
|
263
|
-
|
|
264
|
-
Replacement for [`Buffer.from('48656c6c6f', 'hex')`](https://nodejs.org/api/buffer.html#static-method-bufferfromstring-encoding).
|
|
265
|
-
|
|
266
|
-
```js
|
|
267
|
-
import {hexToUint8Array} from 'uint8array-extras';
|
|
268
|
-
|
|
269
|
-
console.log(hexToUint8Array('48656c6c6f'));
|
|
270
|
-
//=> Uint8Array [72, 101, 108, 108, 111]
|
|
271
|
-
```
|
|
272
|
-
|
|
273
|
-
### `getUintBE(view: DataView): number`
|
|
274
|
-
|
|
275
|
-
Read `DataView#byteLength` number of bytes from the given view, up to 48-bit.
|
|
276
|
-
|
|
277
|
-
Replacement for [`Buffer#readUIntBE`](https://nodejs.org/api/buffer.html#bufreaduintbeoffset-bytelength)
|
|
278
|
-
|
|
279
|
-
```js
|
|
280
|
-
import {getUintBE} from 'uint8array-extras';
|
|
281
|
-
|
|
282
|
-
const byteArray = new Uint8Array([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);
|
|
283
|
-
|
|
284
|
-
console.log(getUintBE(new DataView(byteArray.buffer)));
|
|
285
|
-
//=> 20015998341291
|
|
286
|
-
```
|
|
287
|
-
|
|
288
|
-
### `indexOf(array: Uint8Array | ArrayBuffer, value: Uint8Array | ArrayBuffer): number`
|
|
289
|
-
|
|
290
|
-
Find the index of the first occurrence of the given sequence of bytes (`value`) within the given `Uint8Array` (`array`).
|
|
291
|
-
|
|
292
|
-
Replacement for [`Buffer#indexOf`](https://nodejs.org/api/buffer.html#bufindexofvalue-byteoffset-encoding). `Uint8Array#indexOf` only takes a number which is different from Buffer's `indexOf` implementation.
|
|
293
|
-
|
|
294
|
-
```js
|
|
295
|
-
import {indexOf} from 'uint8array-extras';
|
|
296
|
-
|
|
297
|
-
const byteArray = new Uint8Array([0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef]);
|
|
298
|
-
|
|
299
|
-
console.log(indexOf(byteArray, new Uint8Array([0x78, 0x90])));
|
|
300
|
-
//=> 3
|
|
301
|
-
```
|
|
302
|
-
|
|
303
|
-
### `includes(array: Uint8Array | ArrayBuffer, value: Uint8Array | ArrayBuffer): boolean`
|
|
304
|
-
|
|
305
|
-
Checks if the given sequence of bytes (`value`) is within the given `Uint8Array` (`array`).
|
|
306
|
-
|
|
307
|
-
Returns true if the value is included, otherwise false.
|
|
308
|
-
|
|
309
|
-
Replacement for [`Buffer#includes`](https://nodejs.org/api/buffer.html#bufincludesvalue-byteoffset-encoding). `Uint8Array#includes` only takes a number which is different from Buffer's `includes` implementation.
|
|
310
|
-
|
|
311
|
-
```js
|
|
312
|
-
import {includes} from 'uint8array-extras';
|
|
313
|
-
|
|
314
|
-
const byteArray = new Uint8Array([0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef]);
|
|
315
|
-
|
|
316
|
-
console.log(includes(byteArray, new Uint8Array([0x78, 0x90])));
|
|
317
|
-
//=> true
|
|
318
|
-
```
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
# xml-parse-from-string
|
|
2
|
-
|
|
3
|
-
[](http://github.com/badges/stability-badges)
|
|
4
|
-
|
|
5
|
-
A light browser wrapper around `DOMParser.parseFromString` for XML, with fallback for IE8 and other browsers.
|
|
6
|
-
|
|
7
|
-
- attempts to use DOMParser with `"application/xml"`
|
|
8
|
-
- falls back to `ActiveXObject('Microsoft.XMLDOM')`
|
|
9
|
-
- then falls back to `createElement` / `innerHTML`
|
|
10
|
-
|
|
11
|
-
```js
|
|
12
|
-
var parseXML = require('xml-parse-from-string')
|
|
13
|
-
|
|
14
|
-
var str = '<root><foobar id="blah"></foobar></root>'
|
|
15
|
-
var doc = parseXML(str)
|
|
16
|
-
var tag = doc.getElementsByTagName('foobar')[0]
|
|
17
|
-
|
|
18
|
-
console.log(tag.getAttribute('id')) // -> "blah"
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
Be wary of subtle differences between implementations, such as case-sensitivity in `attribute.nodeName`.
|
|
22
|
-
|
|
23
|
-
PRs for Node version welcome.
|
|
24
|
-
|
|
25
|
-
## Usage
|
|
26
|
-
|
|
27
|
-
[](https://www.npmjs.com/package/xml-parse-from-string)
|
|
28
|
-
|
|
29
|
-
#### `root = parse(str)`
|
|
30
|
-
|
|
31
|
-
Parses the string as XML and returns the `root` element as a DOM element, so you can do operations similar to `document.getElementById`, `document.getElementsByTagName`, and so forth.
|
|
32
|
-
|
|
33
|
-
## License
|
|
34
|
-
|
|
35
|
-
MIT, see [LICENSE.md](http://github.com/Jam3/xml-parse-from-string/blob/master/LICENSE.md) for details.
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
# xmlbuilder-js
|
|
2
|
-
|
|
3
|
-
An XML builder for [node.js](https://nodejs.org/) similar to
|
|
4
|
-
[java-xmlbuilder](https://github.com/jmurty/java-xmlbuilder).
|
|
5
|
-
|
|
6
|
-
[](http://opensource.org/licenses/MIT)
|
|
7
|
-
[](https://npmjs.com/package/xmlbuilder)
|
|
8
|
-
[](https://npmjs.com/package/xmlbuilder)
|
|
9
|
-
|
|
10
|
-
[](http://travis-ci.org/oozcitak/xmlbuilder-js)
|
|
11
|
-
[](https://ci.appveyor.com/project/oozcitak/xmlbuilder-js)
|
|
12
|
-
[](https://david-dm.org/oozcitak/xmlbuilder-js)
|
|
13
|
-
[](https://coveralls.io/github/oozcitak/xmlbuilder-js)
|
|
14
|
-
|
|
15
|
-
### Installation:
|
|
16
|
-
|
|
17
|
-
``` sh
|
|
18
|
-
npm install xmlbuilder
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
### Usage:
|
|
22
|
-
|
|
23
|
-
``` js
|
|
24
|
-
var builder = require('xmlbuilder');
|
|
25
|
-
var xml = builder.create('root')
|
|
26
|
-
.ele('xmlbuilder')
|
|
27
|
-
.ele('repo', {'type': 'git'}, 'git://github.com/oozcitak/xmlbuilder-js.git')
|
|
28
|
-
.end({ pretty: true});
|
|
29
|
-
|
|
30
|
-
console.log(xml);
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
will result in:
|
|
34
|
-
|
|
35
|
-
``` xml
|
|
36
|
-
<?xml version="1.0"?>
|
|
37
|
-
<root>
|
|
38
|
-
<xmlbuilder>
|
|
39
|
-
<repo type="git">git://github.com/oozcitak/xmlbuilder-js.git</repo>
|
|
40
|
-
</xmlbuilder>
|
|
41
|
-
</root>
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
It is also possible to convert objects into nodes:
|
|
45
|
-
|
|
46
|
-
``` js
|
|
47
|
-
builder.create({
|
|
48
|
-
root: {
|
|
49
|
-
xmlbuilder: {
|
|
50
|
-
repo: {
|
|
51
|
-
'@type': 'git', // attributes start with @
|
|
52
|
-
'#text': 'git://github.com/oozcitak/xmlbuilder-js.git' // text node
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
If you need to do some processing:
|
|
60
|
-
|
|
61
|
-
``` js
|
|
62
|
-
var root = builder.create('squares');
|
|
63
|
-
root.com('f(x) = x^2');
|
|
64
|
-
for(var i = 1; i <= 5; i++)
|
|
65
|
-
{
|
|
66
|
-
var item = root.ele('data');
|
|
67
|
-
item.att('x', i);
|
|
68
|
-
item.att('y', i * i);
|
|
69
|
-
}
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
This will result in:
|
|
73
|
-
|
|
74
|
-
``` xml
|
|
75
|
-
<?xml version="1.0"?>
|
|
76
|
-
<squares>
|
|
77
|
-
<!-- f(x) = x^2 -->
|
|
78
|
-
<data x="1" y="1"/>
|
|
79
|
-
<data x="2" y="4"/>
|
|
80
|
-
<data x="3" y="9"/>
|
|
81
|
-
<data x="4" y="16"/>
|
|
82
|
-
<data x="5" y="25"/>
|
|
83
|
-
</squares>
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
See the [wiki](https://github.com/oozcitak/xmlbuilder-js/wiki) for details and [examples](https://github.com/oozcitak/xmlbuilder-js/wiki/Examples) for more complex examples.
|