ai 1.0.0 → 2.0.0
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/LICENSE +10 -24
- package/dist/ai-stream.d.ts +18 -0
- package/dist/ai-stream.js +132 -0
- package/dist/ai-stream.mjs +13 -0
- package/dist/anthropic-stream.d.ts +5 -0
- package/dist/anthropic-stream.js +133 -0
- package/dist/anthropic-stream.mjs +8 -0
- package/dist/chunk-265FSSO4.mjs +91 -0
- package/dist/chunk-2L3ZO4UM.mjs +45 -0
- package/dist/chunk-EZJ7FC5E.mjs +33 -0
- package/dist/chunk-JGDC3BXD.mjs +22 -0
- package/dist/chunk-NK2CVBLI.mjs +38 -0
- package/dist/chunk-PEYAHBDF.mjs +43 -0
- package/dist/chunk-TJMME6CL.mjs +24 -0
- package/dist/huggingface-stream.d.ts +5 -0
- package/dist/huggingface-stream.js +121 -0
- package/dist/huggingface-stream.mjs +8 -0
- package/dist/index.d.ts +131 -0
- package/dist/index.js +278 -0
- package/dist/index.mjs +35 -0
- package/dist/index.test.d.ts +2 -0
- package/dist/index.test.js +12 -0
- package/dist/index.test.mjs +10 -0
- package/dist/langchain-stream.d.ts +12 -0
- package/dist/langchain-stream.js +102 -0
- package/dist/langchain-stream.mjs +8 -0
- package/dist/openai-stream.d.ts +5 -0
- package/dist/openai-stream.js +144 -0
- package/dist/openai-stream.mjs +8 -0
- package/dist/streaming-text-response.d.ts +17 -0
- package/dist/streaming-text-response.js +75 -0
- package/dist/streaming-text-response.mjs +9 -0
- package/package.json +78 -29
- package/react/dist/chunk-5PP6W52J.mjs +202 -0
- package/react/dist/chunk-6EH3SWMP.mjs +55 -0
- package/react/dist/chunk-PW6HSU2N.mjs +154 -0
- package/react/dist/index.d.ts +3 -0
- package/react/dist/index.js +424 -0
- package/react/dist/index.mjs +12 -0
- package/react/dist/types-f862f74a.d.ts +123 -0
- package/react/dist/use-chat.d.ts +42 -0
- package/react/dist/use-chat.js +276 -0
- package/react/dist/use-chat.mjs +8 -0
- package/react/dist/use-completion.d.ts +47 -0
- package/react/dist/use-completion.js +229 -0
- package/react/dist/use-completion.mjs +8 -0
- package/svelte/dist/chunk-6USBQIV6.mjs +177 -0
- package/svelte/dist/chunk-BQ64GHZ3.mjs +136 -0
- package/svelte/dist/chunk-CENOSGDG.mjs +493 -0
- package/svelte/dist/index.d.ts +4 -0
- package/svelte/dist/index.js +808 -0
- package/svelte/dist/index.mjs +11 -0
- package/svelte/dist/types-f862f74a.d.ts +123 -0
- package/svelte/dist/use-chat.d.ts +39 -0
- package/svelte/dist/use-chat.js +680 -0
- package/svelte/dist/use-chat.mjs +7 -0
- package/svelte/dist/use-completion.d.ts +38 -0
- package/svelte/dist/use-completion.js +640 -0
- package/svelte/dist/use-completion.mjs +7 -0
- package/.npmignore +0 -15
- package/.travis.yml +0 -4
- package/README.md +0 -21
- package/bin/ai.js +0 -22
- package/index.js +0 -32
- package/node_modules/request/.npmignore +0 -2
- package/node_modules/request/.travis.yml +0 -12
- package/node_modules/request/CHANGELOG.md +0 -954
- package/node_modules/request/LICENSE +0 -55
- package/node_modules/request/README.md +0 -421
- package/node_modules/request/index.js +0 -166
- package/node_modules/request/lib/cookies.js +0 -40
- package/node_modules/request/lib/copy.js +0 -8
- package/node_modules/request/lib/debug.js +0 -7
- package/node_modules/request/lib/getSafe.js +0 -34
- package/node_modules/request/lib/optional.js +0 -5
- package/node_modules/request/node_modules/aws-sign2/LICENSE +0 -55
- package/node_modules/request/node_modules/aws-sign2/README.md +0 -4
- package/node_modules/request/node_modules/aws-sign2/index.js +0 -202
- package/node_modules/request/node_modules/aws-sign2/package.json +0 -47
- package/node_modules/request/node_modules/forever-agent/LICENSE +0 -55
- package/node_modules/request/node_modules/forever-agent/README.md +0 -4
- package/node_modules/request/node_modules/forever-agent/index.js +0 -119
- package/node_modules/request/node_modules/forever-agent/package.json +0 -46
- package/node_modules/request/node_modules/form-data/License +0 -19
- package/node_modules/request/node_modules/form-data/Readme.md +0 -175
- package/node_modules/request/node_modules/form-data/lib/form_data.js +0 -351
- package/node_modules/request/node_modules/form-data/node_modules/async/.travis.yml +0 -3
- package/node_modules/request/node_modules/form-data/node_modules/async/LICENSE +0 -19
- package/node_modules/request/node_modules/form-data/node_modules/async/README.md +0 -1646
- package/node_modules/request/node_modules/form-data/node_modules/async/component.json +0 -11
- package/node_modules/request/node_modules/form-data/node_modules/async/lib/async.js +0 -1123
- package/node_modules/request/node_modules/form-data/node_modules/async/package.json +0 -60
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/License +0 -19
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/Readme.md +0 -132
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/lib/combined_stream.js +0 -186
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/.npmignore +0 -2
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/License +0 -19
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/Makefile +0 -7
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/Readme.md +0 -154
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/lib/delayed_stream.js +0 -99
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/package.json +0 -42
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/common.js +0 -6
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-http-upload.js +0 -38
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream-auto-pause.js +0 -21
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream-pause.js +0 -14
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream.js +0 -48
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-handle-source-errors.js +0 -15
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-max-data-size.js +0 -18
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-pipe-resumes.js +0 -13
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-proxy-readable.js +0 -13
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/run.js +0 -7
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/package.json +0 -61
- package/node_modules/request/node_modules/form-data/node_modules/mime/LICENSE +0 -19
- package/node_modules/request/node_modules/form-data/node_modules/mime/README.md +0 -66
- package/node_modules/request/node_modules/form-data/node_modules/mime/mime.js +0 -114
- package/node_modules/request/node_modules/form-data/node_modules/mime/package.json +0 -59
- package/node_modules/request/node_modules/form-data/node_modules/mime/test.js +0 -84
- package/node_modules/request/node_modules/form-data/node_modules/mime/types/mime.types +0 -1588
- package/node_modules/request/node_modules/form-data/node_modules/mime/types/node.types +0 -77
- package/node_modules/request/node_modules/form-data/package.json +0 -80
- package/node_modules/request/node_modules/hawk/.npmignore +0 -18
- package/node_modules/request/node_modules/hawk/.travis.yml +0 -5
- package/node_modules/request/node_modules/hawk/LICENSE +0 -24
- package/node_modules/request/node_modules/hawk/Makefile +0 -10
- package/node_modules/request/node_modules/hawk/README.md +0 -625
- package/node_modules/request/node_modules/hawk/example/usage.js +0 -78
- package/node_modules/request/node_modules/hawk/images/hawk.png +0 -0
- package/node_modules/request/node_modules/hawk/images/logo.png +0 -0
- package/node_modules/request/node_modules/hawk/index.js +0 -1
- package/node_modules/request/node_modules/hawk/lib/browser.js +0 -507
- package/node_modules/request/node_modules/hawk/lib/client.js +0 -371
- package/node_modules/request/node_modules/hawk/lib/crypto.js +0 -118
- package/node_modules/request/node_modules/hawk/lib/index.js +0 -15
- package/node_modules/request/node_modules/hawk/lib/server.js +0 -523
- package/node_modules/request/node_modules/hawk/lib/utils.js +0 -183
- package/node_modules/request/node_modules/hawk/node_modules/boom/.npmignore +0 -18
- package/node_modules/request/node_modules/hawk/node_modules/boom/.travis.yml +0 -5
- package/node_modules/request/node_modules/hawk/node_modules/boom/LICENSE +0 -24
- package/node_modules/request/node_modules/hawk/node_modules/boom/Makefile +0 -11
- package/node_modules/request/node_modules/hawk/node_modules/boom/README.md +0 -6
- package/node_modules/request/node_modules/hawk/node_modules/boom/images/boom.png +0 -0
- package/node_modules/request/node_modules/hawk/node_modules/boom/index.js +0 -1
- package/node_modules/request/node_modules/hawk/node_modules/boom/lib/index.js +0 -207
- package/node_modules/request/node_modules/hawk/node_modules/boom/package.json +0 -64
- package/node_modules/request/node_modules/hawk/node_modules/boom/test/index.js +0 -245
- package/node_modules/request/node_modules/hawk/node_modules/cryptiles/.npmignore +0 -18
- package/node_modules/request/node_modules/hawk/node_modules/cryptiles/.travis.yml +0 -5
- package/node_modules/request/node_modules/hawk/node_modules/cryptiles/LICENSE +0 -24
- package/node_modules/request/node_modules/hawk/node_modules/cryptiles/Makefile +0 -11
- package/node_modules/request/node_modules/hawk/node_modules/cryptiles/README.md +0 -6
- package/node_modules/request/node_modules/hawk/node_modules/cryptiles/index.js +0 -1
- package/node_modules/request/node_modules/hawk/node_modules/cryptiles/lib/index.js +0 -68
- package/node_modules/request/node_modules/hawk/node_modules/cryptiles/package.json +0 -65
- package/node_modules/request/node_modules/hawk/node_modules/cryptiles/test/index.js +0 -101
- package/node_modules/request/node_modules/hawk/node_modules/hoek/.npmignore +0 -18
- package/node_modules/request/node_modules/hawk/node_modules/hoek/.travis.yml +0 -5
- package/node_modules/request/node_modules/hawk/node_modules/hoek/LICENSE +0 -33
- package/node_modules/request/node_modules/hawk/node_modules/hoek/Makefile +0 -10
- package/node_modules/request/node_modules/hawk/node_modules/hoek/README.md +0 -436
- package/node_modules/request/node_modules/hawk/node_modules/hoek/images/hoek.png +0 -0
- package/node_modules/request/node_modules/hawk/node_modules/hoek/index.js +0 -1
- package/node_modules/request/node_modules/hawk/node_modules/hoek/lib/escape.js +0 -132
- package/node_modules/request/node_modules/hawk/node_modules/hoek/lib/index.js +0 -585
- package/node_modules/request/node_modules/hawk/node_modules/hoek/package.json +0 -70
- package/node_modules/request/node_modules/hawk/node_modules/hoek/test/escaper.js +0 -86
- package/node_modules/request/node_modules/hawk/node_modules/hoek/test/index.js +0 -1078
- package/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test1.js +0 -1
- package/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test2.js +0 -1
- package/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test3.js +0 -1
- package/node_modules/request/node_modules/hawk/node_modules/sntp/.npmignore +0 -18
- package/node_modules/request/node_modules/hawk/node_modules/sntp/.travis.yml +0 -5
- package/node_modules/request/node_modules/hawk/node_modules/sntp/LICENSE +0 -24
- package/node_modules/request/node_modules/hawk/node_modules/sntp/Makefile +0 -11
- package/node_modules/request/node_modules/hawk/node_modules/sntp/README.md +0 -68
- package/node_modules/request/node_modules/hawk/node_modules/sntp/examples/offset.js +0 -16
- package/node_modules/request/node_modules/hawk/node_modules/sntp/examples/time.js +0 -25
- package/node_modules/request/node_modules/hawk/node_modules/sntp/index.js +0 -1
- package/node_modules/request/node_modules/hawk/node_modules/sntp/lib/index.js +0 -409
- package/node_modules/request/node_modules/hawk/node_modules/sntp/package.json +0 -65
- package/node_modules/request/node_modules/hawk/node_modules/sntp/test/index.js +0 -359
- package/node_modules/request/node_modules/hawk/package.json +0 -70
- package/node_modules/request/node_modules/hawk/test/browser.js +0 -817
- package/node_modules/request/node_modules/hawk/test/client.js +0 -206
- package/node_modules/request/node_modules/hawk/test/crypto.js +0 -86
- package/node_modules/request/node_modules/hawk/test/index.js +0 -316
- package/node_modules/request/node_modules/hawk/test/message.js +0 -246
- package/node_modules/request/node_modules/hawk/test/readme.js +0 -98
- package/node_modules/request/node_modules/hawk/test/server.js +0 -686
- package/node_modules/request/node_modules/hawk/test/uri.js +0 -456
- package/node_modules/request/node_modules/hawk/test/utils.js +0 -120
- package/node_modules/request/node_modules/http-signature/.dir-locals.el +0 -6
- package/node_modules/request/node_modules/http-signature/.npmignore +0 -7
- package/node_modules/request/node_modules/http-signature/LICENSE +0 -18
- package/node_modules/request/node_modules/http-signature/README.md +0 -75
- package/node_modules/request/node_modules/http-signature/http_signing.md +0 -296
- package/node_modules/request/node_modules/http-signature/lib/index.js +0 -25
- package/node_modules/request/node_modules/http-signature/lib/parser.js +0 -304
- package/node_modules/request/node_modules/http-signature/lib/signer.js +0 -179
- package/node_modules/request/node_modules/http-signature/lib/util.js +0 -249
- package/node_modules/request/node_modules/http-signature/lib/verify.js +0 -42
- package/node_modules/request/node_modules/http-signature/node_modules/asn1/.npmignore +0 -2
- package/node_modules/request/node_modules/http-signature/node_modules/asn1/LICENSE +0 -19
- package/node_modules/request/node_modules/http-signature/node_modules/asn1/README.md +0 -50
- package/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/errors.js +0 -13
- package/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/index.js +0 -27
- package/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/reader.js +0 -267
- package/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/types.js +0 -36
- package/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/writer.js +0 -317
- package/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/index.js +0 -20
- package/node_modules/request/node_modules/http-signature/node_modules/asn1/package.json +0 -63
- package/node_modules/request/node_modules/http-signature/node_modules/asn1/tst/ber/reader.test.js +0 -172
- package/node_modules/request/node_modules/http-signature/node_modules/asn1/tst/ber/writer.test.js +0 -296
- package/node_modules/request/node_modules/http-signature/node_modules/assert-plus/README.md +0 -126
- package/node_modules/request/node_modules/http-signature/node_modules/assert-plus/assert.js +0 -196
- package/node_modules/request/node_modules/http-signature/node_modules/assert-plus/package.json +0 -38
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/CHANGELOG +0 -71
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/LICENSE +0 -24
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/README +0 -82
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/README.old +0 -298
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/ctf.js +0 -245
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/ctio.js +0 -1485
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/ctype.js +0 -944
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/man/man3ctype/ctio.3ctype +0 -241
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/package.json +0 -36
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tools/jsl.conf +0 -129
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tools/jsstyle +0 -839
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/float.json +0 -13
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/int.json +0 -13
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/psinfo.json +0 -104
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/struct.json +0 -19
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/tst.fail.js +0 -39
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/tst.float.js +0 -14
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/tst.int.js +0 -14
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/tst.psinfo.js +0 -17
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/tst.struct.js +0 -18
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/tst.typedef.js +0 -15
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/typedef.json +0 -14
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/float/tst.rfloat.js +0 -767
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/float/tst.wfloat.js +0 -753
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/int/tst.64.js +0 -638
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/int/tst.rint.js +0 -101
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/int/tst.wbounds.js +0 -53
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/int/tst.wint.js +0 -92
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/uint/tst.64.js +0 -451
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/uint/tst.roundtrip.js +0 -81
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/uint/tst.ruint.js +0 -95
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/uint/tst.wuint.js +0 -156
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.basicr.js +0 -50
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.basicw.js +0 -44
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.char.js +0 -42
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.endian.js +0 -45
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.oldwrite.js +0 -28
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.readSize.js +0 -128
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.structw.js +0 -28
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.writeStruct.js +0 -31
- package/node_modules/request/node_modules/http-signature/package.json +0 -54
- package/node_modules/request/node_modules/json-stringify-safe/LICENSE +0 -27
- package/node_modules/request/node_modules/json-stringify-safe/README.md +0 -49
- package/node_modules/request/node_modules/json-stringify-safe/package.json +0 -51
- package/node_modules/request/node_modules/json-stringify-safe/stringify.js +0 -39
- package/node_modules/request/node_modules/json-stringify-safe/test.js +0 -128
- package/node_modules/request/node_modules/mime-types/.npmignore +0 -14
- package/node_modules/request/node_modules/mime-types/.travis.yml +0 -12
- package/node_modules/request/node_modules/mime-types/LICENSE +0 -22
- package/node_modules/request/node_modules/mime-types/Makefile +0 -9
- package/node_modules/request/node_modules/mime-types/README.md +0 -101
- package/node_modules/request/node_modules/mime-types/SOURCES.md +0 -17
- package/node_modules/request/node_modules/mime-types/component.json +0 -16
- package/node_modules/request/node_modules/mime-types/lib/custom.json +0 -27
- package/node_modules/request/node_modules/mime-types/lib/index.js +0 -75
- package/node_modules/request/node_modules/mime-types/lib/mime.json +0 -3317
- package/node_modules/request/node_modules/mime-types/lib/node.json +0 -55
- package/node_modules/request/node_modules/mime-types/package.json +0 -69
- package/node_modules/request/node_modules/node-uuid/.npmignore +0 -2
- package/node_modules/request/node_modules/node-uuid/LICENSE.md +0 -2
- package/node_modules/request/node_modules/node-uuid/README.md +0 -207
- package/node_modules/request/node_modules/node-uuid/benchmark/README.md +0 -53
- package/node_modules/request/node_modules/node-uuid/benchmark/bench.gnu +0 -174
- package/node_modules/request/node_modules/node-uuid/benchmark/bench.sh +0 -34
- package/node_modules/request/node_modules/node-uuid/benchmark/benchmark-native.c +0 -34
- package/node_modules/request/node_modules/node-uuid/benchmark/benchmark.js +0 -84
- package/node_modules/request/node_modules/node-uuid/component.json +0 -18
- package/node_modules/request/node_modules/node-uuid/package.json +0 -54
- package/node_modules/request/node_modules/node-uuid/test/compare_v1.js +0 -63
- package/node_modules/request/node_modules/node-uuid/test/test.html +0 -17
- package/node_modules/request/node_modules/node-uuid/test/test.js +0 -228
- package/node_modules/request/node_modules/node-uuid/uuid.js +0 -245
- package/node_modules/request/node_modules/oauth-sign/LICENSE +0 -55
- package/node_modules/request/node_modules/oauth-sign/README.md +0 -4
- package/node_modules/request/node_modules/oauth-sign/index.js +0 -43
- package/node_modules/request/node_modules/oauth-sign/package.json +0 -49
- package/node_modules/request/node_modules/oauth-sign/test.js +0 -49
- package/node_modules/request/node_modules/qs/.jshintignore +0 -1
- package/node_modules/request/node_modules/qs/.jshintrc +0 -10
- package/node_modules/request/node_modules/qs/.npmignore +0 -18
- package/node_modules/request/node_modules/qs/.travis.yml +0 -4
- package/node_modules/request/node_modules/qs/LICENSE +0 -28
- package/node_modules/request/node_modules/qs/Makefile +0 -8
- package/node_modules/request/node_modules/qs/Readme.md +0 -120
- package/node_modules/request/node_modules/qs/index.js +0 -1
- package/node_modules/request/node_modules/qs/lib/index.js +0 -15
- package/node_modules/request/node_modules/qs/lib/parse.js +0 -151
- package/node_modules/request/node_modules/qs/lib/stringify.js +0 -52
- package/node_modules/request/node_modules/qs/lib/utils.js +0 -131
- package/node_modules/request/node_modules/qs/package.json +0 -61
- package/node_modules/request/node_modules/qs/test/parse.js +0 -236
- package/node_modules/request/node_modules/qs/test/stringify.js +0 -123
- package/node_modules/request/node_modules/stringstream/.npmignore +0 -15
- package/node_modules/request/node_modules/stringstream/.travis.yml +0 -4
- package/node_modules/request/node_modules/stringstream/LICENSE.txt +0 -4
- package/node_modules/request/node_modules/stringstream/README.md +0 -38
- package/node_modules/request/node_modules/stringstream/example.js +0 -27
- package/node_modules/request/node_modules/stringstream/package.json +0 -48
- package/node_modules/request/node_modules/stringstream/stringstream.js +0 -102
- package/node_modules/request/node_modules/tough-cookie/.jshintrc +0 -70
- package/node_modules/request/node_modules/tough-cookie/.npmignore +0 -3
- package/node_modules/request/node_modules/tough-cookie/.travis.yml +0 -8
- package/node_modules/request/node_modules/tough-cookie/LICENSE +0 -78
- package/node_modules/request/node_modules/tough-cookie/README.md +0 -412
- package/node_modules/request/node_modules/tough-cookie/generate-pubsuffix.js +0 -239
- package/node_modules/request/node_modules/tough-cookie/lib/cookie.js +0 -1107
- package/node_modules/request/node_modules/tough-cookie/lib/memstore.js +0 -123
- package/node_modules/request/node_modules/tough-cookie/lib/pubsuffix.js +0 -69
- package/node_modules/request/node_modules/tough-cookie/lib/store.js +0 -37
- package/node_modules/request/node_modules/tough-cookie/node_modules/punycode/LICENSE-MIT.txt +0 -20
- package/node_modules/request/node_modules/tough-cookie/node_modules/punycode/README.md +0 -176
- package/node_modules/request/node_modules/tough-cookie/node_modules/punycode/package.json +0 -87
- package/node_modules/request/node_modules/tough-cookie/node_modules/punycode/punycode.js +0 -528
- package/node_modules/request/node_modules/tough-cookie/package.json +0 -67
- package/node_modules/request/node_modules/tough-cookie/public-suffix.txt +0 -5229
- package/node_modules/request/node_modules/tough-cookie/test.js +0 -1625
- package/node_modules/request/node_modules/tunnel-agent/.jshintrc +0 -5
- package/node_modules/request/node_modules/tunnel-agent/LICENSE +0 -55
- package/node_modules/request/node_modules/tunnel-agent/README.md +0 -4
- package/node_modules/request/node_modules/tunnel-agent/index.js +0 -236
- package/node_modules/request/node_modules/tunnel-agent/package.json +0 -46
- package/node_modules/request/package.json +0 -77
- package/node_modules/request/request.js +0 -1428
- package/test/fixtures/github-response.json +0 -1367
- package/test/index.js +0 -55
@@ -1,298 +0,0 @@
|
|
1
|
-
This library provides a way to read and write binary data.
|
2
|
-
|
3
|
-
Node CType is a way to read and write binary data in structured and easy to use
|
4
|
-
formats. It's name comes from the header file, though it does not share as much
|
5
|
-
with it as it perhaps should.
|
6
|
-
|
7
|
-
There are two levels of the API. One is the raw API which everything is built on
|
8
|
-
top of, while the other provides a much nicer abstraction and is built entirely
|
9
|
-
by using the lower level API. The hope is that the low level API is both clear
|
10
|
-
and useful. The low level API gets it's names from stdint.h (a rather
|
11
|
-
appropriate source). The lower level API is presented at the end of this
|
12
|
-
document.
|
13
|
-
|
14
|
-
Standard CType API
|
15
|
-
|
16
|
-
The CType interface is presented as a parser object that controls the
|
17
|
-
endianness combined with a series of methods to change that value, parse and
|
18
|
-
write out buffers, and a way to provide typedefs. Standard Types
|
19
|
-
|
20
|
-
The CType parser supports the following basic types which return Numbers except
|
21
|
-
as indicated:
|
22
|
-
|
23
|
-
* int8_t
|
24
|
-
* int16_t
|
25
|
-
* int32_t
|
26
|
-
* int64_t (returns an array where val[0] << 32 + val[1] would be the value)
|
27
|
-
* uint8_t
|
28
|
-
* uint16_t
|
29
|
-
* uint32_t
|
30
|
-
* uint64_t (returns an array where val[0] << 32 + val[1] would be the value)
|
31
|
-
* float
|
32
|
-
* double
|
33
|
-
* char (returns a buffer with just that single character)
|
34
|
-
* char[] (returns an object with the buffer and the number of characters read which is either the total amount requested or until the first 0)
|
35
|
-
|
36
|
-
Specifying Structs
|
37
|
-
|
38
|
-
The CType parser also supports the notion of structs. A struct is an array of
|
39
|
-
JSON objects that defines an order of keys which have types and values. One
|
40
|
-
would build a struct to represent a point (x,y) as follows:
|
41
|
-
|
42
|
-
[
|
43
|
-
{ x: { type: 'int16_t' }},
|
44
|
-
{ y: { type: 'int16_t' }}
|
45
|
-
]
|
46
|
-
|
47
|
-
When this is passed into the read routine, it would read the first two bytes
|
48
|
-
(as defined by int16_t) to determine the Number to use for X, and then it would
|
49
|
-
read the next two bytes to determine the value of Y. When read this could
|
50
|
-
return something like:
|
51
|
-
|
52
|
-
{
|
53
|
-
x: 42,
|
54
|
-
y: -23
|
55
|
-
}
|
56
|
-
|
57
|
-
When someone wants to write values, we use the same format as above, but with
|
58
|
-
additional value field:
|
59
|
-
|
60
|
-
[
|
61
|
-
{ x: { type: 'int16_t', value: 42 }},
|
62
|
-
{ y: { type: 'int16_t', value: -23 }}
|
63
|
-
]
|
64
|
-
|
65
|
-
Now, the structure above may be optionally annotated with offsets. This tells
|
66
|
-
us to rather than read continuously we should read the given value at the
|
67
|
-
specified offset. If an offset is provided, it is is effectively the equivalent
|
68
|
-
of lseek(offset, SEEK_SET). Thus, subsequent values will be read from that
|
69
|
-
offset and incremented by the appropriate value. As an example:
|
70
|
-
|
71
|
-
[
|
72
|
-
{ x: { type: 'int16_t' }},
|
73
|
-
{ y: { type: 'int16_t', offset: 20 }},
|
74
|
-
{ z: { type: 'int16_t' }}
|
75
|
-
]
|
76
|
-
|
77
|
-
We would read x from the first starting offset given to us, for the sake of
|
78
|
-
example, let's assume that's 0. After reading x, the next offset to read from
|
79
|
-
would be 2; however, y specifies an offset, thus we jump directly to that
|
80
|
-
offset and read y from byte 20. We would then read z from byte 22.
|
81
|
-
|
82
|
-
The same offsets may be used when writing values.
|
83
|
-
|
84
|
-
Typedef
|
85
|
-
|
86
|
-
The basic set of types while covers the basics, is somewhat limiting. To make
|
87
|
-
this richer, there is functionality to typedef something like in C. One can use
|
88
|
-
typedef to add a new name to an existing type or to define a name to refer to a
|
89
|
-
struct. Thus the following are all examples of a typedef:
|
90
|
-
|
91
|
-
typedef('size_t', 'uint32_t');
|
92
|
-
typedef('ssize_t', 'int32_t');
|
93
|
-
typedef('point_t', [
|
94
|
-
{ x: { type: 'int16_t' }},
|
95
|
-
{ y: { type: 'int16_t' }}
|
96
|
-
]);
|
97
|
-
|
98
|
-
Once something has been typedef'd it can be used in any of the definitions
|
99
|
-
previously shown.
|
100
|
-
|
101
|
-
One cannot remove a typedef once created, this is analogous to C.
|
102
|
-
|
103
|
-
The set of defined types can be printed with lstypes. The format of this output
|
104
|
-
is subject to change, but likely will look something like:
|
105
|
-
|
106
|
-
> lstypes();
|
107
|
-
{
|
108
|
-
size_t: 'uint32_t',
|
109
|
-
ssize_t: 'int32_t',
|
110
|
-
point_t: [
|
111
|
-
{ x: { type: 'int16_t' }},
|
112
|
-
{ y: { type: 'int16_t' }}
|
113
|
-
]
|
114
|
-
}
|
115
|
-
|
116
|
-
Specifying arrays
|
117
|
-
|
118
|
-
Arrays can be specified by appending []s to a type. Arrays must have the size
|
119
|
-
specified. The size must be specified and it can be done in one of two ways:
|
120
|
-
|
121
|
-
* An explicit non-zero integer size
|
122
|
-
* A name of a previously declared variable in the struct whose value is a
|
123
|
-
number.
|
124
|
-
|
125
|
-
Note, that when using the name of a variable, it should be the string name for
|
126
|
-
the key. This is only valid inside structs and the value must be declared
|
127
|
-
before the value with the array. The following are examples:
|
128
|
-
|
129
|
-
[
|
130
|
-
{ ip_addr4: { type: 'uint8_t[4]' }},
|
131
|
-
{ len: { type: 'uint32_t' }},
|
132
|
-
{ data: { type: 'uint8_t[len]' }}
|
133
|
-
]
|
134
|
-
|
135
|
-
Arrays are permitted in typedefs; however, they must have a declared integer
|
136
|
-
size. The following are examples of valid and invalid arrays:
|
137
|
-
|
138
|
-
typedef('path', 'char[1024]'); /* Good */
|
139
|
-
typedef('path', 'char[len]'); /* Bad! */
|
140
|
-
|
141
|
-
64 bit values:
|
142
|
-
|
143
|
-
Unfortunately Javascript represents values with a double, so you lose precision
|
144
|
-
and the ability to represent Integers roughly beyond 2^53. To alleviate this, I
|
145
|
-
propose the following for returning 64 bit integers when read:
|
146
|
-
|
147
|
-
value[2]: Each entry is a 32 bit number which can be reconstructed to the
|
148
|
-
original by the following formula:
|
149
|
-
|
150
|
-
value[0] << 32 + value[1] (Note this will not work in Javascript)
|
151
|
-
|
152
|
-
CTF JSON data:
|
153
|
-
|
154
|
-
node-ctype can also handle JSON data that mathces the format described in the
|
155
|
-
documentation of the tool ctf2json. Given the JSON data which specifies type
|
156
|
-
information, it will transform that into a parser that understands all of the
|
157
|
-
types defined inside of it. This is useful for more complicated structures that
|
158
|
-
have a lot of typedefs.
|
159
|
-
|
160
|
-
Interface overview
|
161
|
-
|
162
|
-
The following is the header-file like interface to the parser object:
|
163
|
-
|
164
|
-
/*
|
165
|
-
* Create a new instance of the parser. Each parser has its own store of
|
166
|
-
* typedefs and endianness. Conf is an object with the following values:
|
167
|
-
*
|
168
|
-
* endian Either 'big' or 'little' do determine the endianness we
|
169
|
-
* want to read from or write to.
|
170
|
-
*
|
171
|
-
*/
|
172
|
-
function CTypeParser(conf);
|
173
|
-
|
174
|
-
/*
|
175
|
-
* Parses the CTF JSON data and creates a parser that understands all of those
|
176
|
-
* types.
|
177
|
-
*
|
178
|
-
* data Parsed JSON data that maches that CTF JSON
|
179
|
-
* specification.
|
180
|
-
*
|
181
|
-
* conf The configuration object to create a new CTypeParser
|
182
|
-
* from.
|
183
|
-
*/
|
184
|
-
CTypeParser parseCTF(data, conf);
|
185
|
-
|
186
|
-
/*
|
187
|
-
* This is what we were born to do. We read the data from a buffer and return it
|
188
|
-
* in an object whose keys match the values from the object.
|
189
|
-
*
|
190
|
-
* def The array definition of the data to read in
|
191
|
-
*
|
192
|
-
* buffer The buffer to read data from
|
193
|
-
*
|
194
|
-
* offset The offset to start writing to
|
195
|
-
*
|
196
|
-
* Returns an object where each key corresponds to an entry in def and the value
|
197
|
-
* is the read value.
|
198
|
-
*/
|
199
|
-
Object CTypeParser.readData(<Type Definition>, buffer, offset);
|
200
|
-
|
201
|
-
/*
|
202
|
-
* This is the second half of what we were born to do, write out the data
|
203
|
-
* itself.
|
204
|
-
*
|
205
|
-
* def The array definition of the data to write out with
|
206
|
-
* values
|
207
|
-
*
|
208
|
-
* buffer The buffer to write to
|
209
|
-
*
|
210
|
-
* offset The offset in the buffer to write to
|
211
|
-
*/
|
212
|
-
void CTypeParser.writeData(<Type Definition>, buffer, offset);
|
213
|
-
|
214
|
-
/*
|
215
|
-
* A user has requested to add a type, let us honor their request. Yet, if their
|
216
|
-
* request doth spurn us, send them unto the Hells which Dante describes.
|
217
|
-
*
|
218
|
-
* name The string for the type definition we're adding
|
219
|
-
*
|
220
|
-
* value Either a string that is a type/array name or an object
|
221
|
-
* that describes a struct.
|
222
|
-
*/
|
223
|
-
void CTypeParser.prototype.typedef(name, value);
|
224
|
-
|
225
|
-
Object CTypeParser.prototype.lstypes();
|
226
|
-
|
227
|
-
/*
|
228
|
-
* Get the endian value for the current parser
|
229
|
-
*/
|
230
|
-
String CTypeParser.prototype.getEndian();
|
231
|
-
|
232
|
-
/*
|
233
|
-
* Sets the current endian value for the Parser. If the value is not valid,
|
234
|
-
* throws an Error.
|
235
|
-
*
|
236
|
-
* endian Either 'big' or 'little' do determine the endianness we
|
237
|
-
* want to read from or write to.
|
238
|
-
*
|
239
|
-
*/
|
240
|
-
void CTypeParser.protoype.setEndian(String);
|
241
|
-
|
242
|
-
/*
|
243
|
-
* Attempts to convert an array of two integers returned from rsint64 / ruint64
|
244
|
-
* into an absolute 64 bit number. If however the value would exceed 2^52 this
|
245
|
-
* will instead throw an error. The mantissa in a double is a 52 bit number and
|
246
|
-
* rather than potentially give you a value that is an approximation this will
|
247
|
-
* error. If you would rather an approximation, please see toApprox64.
|
248
|
-
*
|
249
|
-
* val An array of two 32-bit integers
|
250
|
-
*/
|
251
|
-
Number function toAbs64(val)
|
252
|
-
|
253
|
-
/*
|
254
|
-
* Will return the 64 bit value as returned in an array from rsint64 / ruint64
|
255
|
-
* to a value as close as it can. Note that Javascript stores all numbers as a
|
256
|
-
* double and the mantissa only has 52 bits. Thus this version may approximate
|
257
|
-
* the value.
|
258
|
-
*
|
259
|
-
* val An array of two 32-bit integers
|
260
|
-
*/
|
261
|
-
Number function toApprox64(val)
|
262
|
-
|
263
|
-
Low Level API
|
264
|
-
|
265
|
-
The following function are provided at the low level:
|
266
|
-
|
267
|
-
Read unsigned integers from a buffer:
|
268
|
-
Number ruint8(buffer, endian, offset);
|
269
|
-
Number ruint16(buffer, endian, offset);
|
270
|
-
Number ruint32(buffer, endian, offset);
|
271
|
-
Number[] ruint64(buffer, endian, offset);
|
272
|
-
|
273
|
-
Read signed integers from a buffer:
|
274
|
-
Number rsint8(buffer, endian, offset);
|
275
|
-
Number rsint16(buffer, endian, offset);
|
276
|
-
Number rsint32(buffer, endian, offset);
|
277
|
-
Number[] rsint64(buffer, endian, offset);
|
278
|
-
|
279
|
-
Read floating point numbers from a buffer:
|
280
|
-
Number rfloat(buffer, endian, offset); /* IEEE-754 Single precision */
|
281
|
-
Number rdouble(buffer, endian, offset); /* IEEE-754 Double precision */
|
282
|
-
|
283
|
-
Write unsigned integers to a buffer:
|
284
|
-
void wuint8(Number, endian, buffer, offset);
|
285
|
-
void wuint16(Number, endian, buffer, offset);
|
286
|
-
void wuint32(Number, endian, buffer, offset);
|
287
|
-
void wuint64(Number[], endian, buffer, offset);
|
288
|
-
|
289
|
-
Write signed integers from a buffer:
|
290
|
-
void wsint8(Number, endian, buffer, offset);
|
291
|
-
void wsint16(Number, endian, buffer, offset);
|
292
|
-
void wsint32(Number, endian, buffer, offset);
|
293
|
-
void wsint64(Number[], endian, buffer offset);
|
294
|
-
|
295
|
-
Write floating point numbers from a buffer:
|
296
|
-
void wfloat(Number, buffer, endian, offset); /* IEEE-754 Single precision */
|
297
|
-
void wdouble(Number, buffer, endian, offset); /* IEEE-754 Double precision */
|
298
|
-
|
@@ -1,245 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* ctf.js
|
3
|
-
*
|
4
|
-
* Understand and parse all of the different JSON formats of CTF data and
|
5
|
-
* translate that into a series of node-ctype friendly pieces. The reason for
|
6
|
-
* the abstraction is to handle different changes in the file format.
|
7
|
-
*
|
8
|
-
* We have to be careful here that we don't end up using a name that is already
|
9
|
-
* a built in type.
|
10
|
-
*/
|
11
|
-
var mod_assert = require('assert');
|
12
|
-
var ASSERT = mod_assert.ok;
|
13
|
-
|
14
|
-
var ctf_versions = [ '1.0' ];
|
15
|
-
var ctf_entries = [ 'integer', 'float', 'typedef', 'struct' ];
|
16
|
-
var ctf_deftypes = [ 'int8_t', 'uint8_t', 'int16_t', 'uint16_t', 'int32_t',
|
17
|
-
'uint32_t', 'float', 'double' ];
|
18
|
-
|
19
|
-
function ctfParseInteger(entry, ctype)
|
20
|
-
{
|
21
|
-
var name, sign, len, type;
|
22
|
-
|
23
|
-
name = entry['name'];
|
24
|
-
if (!('signed' in entry['integer']))
|
25
|
-
throw (new Error('Malformed CTF JSON: integer missing ' +
|
26
|
-
'signed value'));
|
27
|
-
|
28
|
-
|
29
|
-
if (!('length' in entry['integer']))
|
30
|
-
throw (new Error('Malformed CTF JSON: integer missing ' +
|
31
|
-
'length value'));
|
32
|
-
|
33
|
-
sign = entry['integer']['signed'];
|
34
|
-
len = entry['integer']['length'];
|
35
|
-
type = null;
|
36
|
-
|
37
|
-
if (sign && len == 1)
|
38
|
-
type = 'int8_t';
|
39
|
-
else if (len == 1)
|
40
|
-
type = 'uint8_t';
|
41
|
-
else if (sign && len == 2)
|
42
|
-
type = 'int16_t';
|
43
|
-
else if (len == 2)
|
44
|
-
type = 'uint16_t';
|
45
|
-
else if (sign && len == 4)
|
46
|
-
type = 'int32_t';
|
47
|
-
else if (len == 4)
|
48
|
-
type = 'uint32_t';
|
49
|
-
else if (sign && len == 8)
|
50
|
-
type = 'int64_t';
|
51
|
-
else if (len == 8)
|
52
|
-
type = 'uint64_t';
|
53
|
-
|
54
|
-
if (type === null)
|
55
|
-
throw (new Error('Malformed CTF JSON: integer has ' +
|
56
|
-
'unsupported length and sign - ' + len + '/' + sign));
|
57
|
-
|
58
|
-
/*
|
59
|
-
* This means that this is the same as one of our built in types. If
|
60
|
-
* that's the case defining it would be an error. So instead of trying
|
61
|
-
* to typedef it, we'll return here.
|
62
|
-
*/
|
63
|
-
if (name == type)
|
64
|
-
return;
|
65
|
-
|
66
|
-
if (name == 'char') {
|
67
|
-
ASSERT(type == 'int8_t');
|
68
|
-
return;
|
69
|
-
}
|
70
|
-
|
71
|
-
ctype.typedef(name, type);
|
72
|
-
}
|
73
|
-
|
74
|
-
function ctfParseFloat(entry, ctype)
|
75
|
-
{
|
76
|
-
var name, len;
|
77
|
-
|
78
|
-
name = entry['name'];
|
79
|
-
if (!('length' in entry['float']))
|
80
|
-
throw (new Error('Malformed CTF JSON: float missing ' +
|
81
|
-
'length value'));
|
82
|
-
|
83
|
-
len = entry['float']['length'];
|
84
|
-
if (len != 4 && len != 8)
|
85
|
-
throw (new Error('Malformed CTF JSON: float has invalid ' +
|
86
|
-
'length value'));
|
87
|
-
|
88
|
-
if (len == 4) {
|
89
|
-
if (name == 'float')
|
90
|
-
return;
|
91
|
-
ctype.typedef(name, 'float');
|
92
|
-
} else if (len == 8) {
|
93
|
-
if (name == 'double')
|
94
|
-
return;
|
95
|
-
ctype.typedef(name, 'double');
|
96
|
-
}
|
97
|
-
}
|
98
|
-
|
99
|
-
function ctfParseTypedef(entry, ctype)
|
100
|
-
{
|
101
|
-
var name, type, ii;
|
102
|
-
|
103
|
-
name = entry['name'];
|
104
|
-
if (typeof (entry['typedef']) != 'string')
|
105
|
-
throw (new Error('Malformed CTF JSON: typedef value in not ' +
|
106
|
-
'a string'));
|
107
|
-
|
108
|
-
type = entry['typedef'];
|
109
|
-
|
110
|
-
/*
|
111
|
-
* We need to ensure that we're not looking at type that's one of our
|
112
|
-
* built in types. Traditionally in C a uint32_t would be a typedef to
|
113
|
-
* some kind of integer. However, those size types are built ins.
|
114
|
-
*/
|
115
|
-
for (ii = 0; ii < ctf_deftypes.length; ii++) {
|
116
|
-
if (name == ctf_deftypes[ii])
|
117
|
-
return;
|
118
|
-
}
|
119
|
-
|
120
|
-
ctype.typedef(name, type);
|
121
|
-
}
|
122
|
-
|
123
|
-
function ctfParseStruct(entry, ctype)
|
124
|
-
{
|
125
|
-
var name, type, ii, val, index, member, push;
|
126
|
-
|
127
|
-
member = [];
|
128
|
-
if (!Array.isArray(entry['struct']))
|
129
|
-
throw (new Error('Malformed CTF JSON: struct value is not ' +
|
130
|
-
'an array'));
|
131
|
-
|
132
|
-
for (ii = 0; ii < entry['struct'].length; ii++) {
|
133
|
-
val = entry['struct'][ii];
|
134
|
-
if (!('name' in val))
|
135
|
-
throw (new Error('Malformed CTF JSON: struct member ' +
|
136
|
-
'missing name'));
|
137
|
-
|
138
|
-
if (!('type' in val))
|
139
|
-
throw (new Error('Malformed CTF JSON: struct member ' +
|
140
|
-
'missing type'));
|
141
|
-
|
142
|
-
if (typeof (val['name']) != 'string')
|
143
|
-
throw (new Error('Malformed CTF JSON: struct member ' +
|
144
|
-
'name isn\'t a string'));
|
145
|
-
|
146
|
-
if (typeof (val['type']) != 'string')
|
147
|
-
throw (new Error('Malformed CTF JSON: struct member ' +
|
148
|
-
'type isn\'t a string'));
|
149
|
-
|
150
|
-
/*
|
151
|
-
* CTF version 2 specifies array names as <type> [<num>] where
|
152
|
-
* as node-ctype does this as <type>[<num>].
|
153
|
-
*/
|
154
|
-
name = val['name'];
|
155
|
-
type = val['type'];
|
156
|
-
index = type.indexOf(' [');
|
157
|
-
if (index != -1) {
|
158
|
-
type = type.substring(0, index) +
|
159
|
-
type.substring(index + 1, type.length);
|
160
|
-
}
|
161
|
-
push = {};
|
162
|
-
push[name] = { 'type': type };
|
163
|
-
member.push(push);
|
164
|
-
}
|
165
|
-
|
166
|
-
name = entry['name'];
|
167
|
-
ctype.typedef(name, member);
|
168
|
-
}
|
169
|
-
|
170
|
-
function ctfParseEntry(entry, ctype)
|
171
|
-
{
|
172
|
-
var ii, found;
|
173
|
-
|
174
|
-
if (!('name' in entry))
|
175
|
-
throw (new Error('Malformed CTF JSON: entry missing "name" ' +
|
176
|
-
'section'));
|
177
|
-
|
178
|
-
for (ii = 0; ii < ctf_entries.length; ii++) {
|
179
|
-
if (ctf_entries[ii] in entry)
|
180
|
-
found++;
|
181
|
-
}
|
182
|
-
|
183
|
-
if (found === 0)
|
184
|
-
throw (new Error('Malformed CTF JSON: found no entries'));
|
185
|
-
|
186
|
-
if (found >= 2)
|
187
|
-
throw (new Error('Malformed CTF JSON: found more than one ' +
|
188
|
-
'entry'));
|
189
|
-
|
190
|
-
if ('integer' in entry) {
|
191
|
-
ctfParseInteger(entry, ctype);
|
192
|
-
return;
|
193
|
-
}
|
194
|
-
|
195
|
-
if ('float' in entry) {
|
196
|
-
ctfParseFloat(entry, ctype);
|
197
|
-
return;
|
198
|
-
}
|
199
|
-
|
200
|
-
if ('typedef' in entry) {
|
201
|
-
ctfParseTypedef(entry, ctype);
|
202
|
-
return;
|
203
|
-
}
|
204
|
-
|
205
|
-
if ('struct' in entry) {
|
206
|
-
ctfParseStruct(entry, ctype);
|
207
|
-
return;
|
208
|
-
}
|
209
|
-
|
210
|
-
ASSERT(false, 'shouldn\'t reach here');
|
211
|
-
}
|
212
|
-
|
213
|
-
function ctfParseJson(json, ctype)
|
214
|
-
{
|
215
|
-
var version, ii;
|
216
|
-
|
217
|
-
ASSERT(json);
|
218
|
-
ASSERT(ctype);
|
219
|
-
if (!('metadata' in json))
|
220
|
-
throw (new Error('Invalid CTF JSON: missing metadata section'));
|
221
|
-
|
222
|
-
if (!('ctf2json_version' in json['metadata']))
|
223
|
-
throw (new Error('Invalid CTF JSON: missing ctf2json_version'));
|
224
|
-
|
225
|
-
version = json['metadata']['ctf2json_version'];
|
226
|
-
for (ii = 0; ii < ctf_versions.length; ii++) {
|
227
|
-
if (ctf_versions[ii] == version)
|
228
|
-
break;
|
229
|
-
}
|
230
|
-
|
231
|
-
if (ii == ctf_versions.length)
|
232
|
-
throw (new Error('Unsuported ctf2json_version: ' + version));
|
233
|
-
|
234
|
-
if (!('data' in json))
|
235
|
-
throw (new Error('Invalid CTF JSON: missing data section'));
|
236
|
-
|
237
|
-
if (!Array.isArray(json['data']))
|
238
|
-
throw (new Error('Malformed CTF JSON: data section is not ' +
|
239
|
-
'an array'));
|
240
|
-
|
241
|
-
for (ii = 0; ii < json['data'].length; ii++)
|
242
|
-
ctfParseEntry(json['data'][ii], ctype);
|
243
|
-
}
|
244
|
-
|
245
|
-
exports.ctfParseJson = ctfParseJson;
|