ali-skills 0.0.21 → 0.0.23
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/node_modules/@ali/cli-skills/dist/cli.mjs +1410 -316
- package/node_modules/@ali/cli-skills/package.json +5 -2
- package/node_modules/@ali/o2-open-client/.editorconfig +11 -0
- package/node_modules/@ali/o2-open-client/README.md +80 -0
- package/node_modules/@ali/o2-open-client/abc.json +8 -0
- package/node_modules/@ali/o2-open-client/es/browser/ee.d.ts +23 -0
- package/node_modules/@ali/o2-open-client/es/browser/ee.js +82 -0
- package/node_modules/@ali/o2-open-client/es/browser/entry.d.ts +32 -0
- package/node_modules/@ali/o2-open-client/es/browser/entry.js +306 -0
- package/node_modules/@ali/o2-open-client/es/browser/escape.d.ts +12 -0
- package/node_modules/@ali/o2-open-client/es/browser/escape.js +178 -0
- package/node_modules/@ali/o2-open-client/es/browser/fetch.d.ts +1 -0
- package/node_modules/@ali/o2-open-client/es/browser/fetch.js +14 -0
- package/node_modules/@ali/o2-open-client/es/browser/index.d.ts +1 -0
- package/node_modules/@ali/o2-open-client/es/browser/index.js +1 -0
- package/node_modules/@ali/o2-open-client/es/common/constant.d.ts +42 -0
- package/node_modules/@ali/o2-open-client/es/common/constant.js +53 -0
- package/node_modules/@ali/o2-open-client/es/common/format.d.ts +14 -0
- package/node_modules/@ali/o2-open-client/es/common/format.js +43 -0
- package/node_modules/@ali/o2-open-client/es/common/service-meta.d.ts +33 -0
- package/node_modules/@ali/o2-open-client/es/common/service-meta.js +33 -0
- package/node_modules/@ali/o2-open-client/es/index.d.ts +1 -0
- package/node_modules/@ali/o2-open-client/es/index.js +8 -0
- package/node_modules/@ali/o2-open-client/es/node/config.d.ts +47 -0
- package/node_modules/@ali/o2-open-client/es/node/config.js +188 -0
- package/node_modules/@ali/o2-open-client/es/node/escape.d.ts +22 -0
- package/node_modules/@ali/o2-open-client/es/node/escape.js +131 -0
- package/node_modules/@ali/o2-open-client/es/node/help.d.ts +10 -0
- package/node_modules/@ali/o2-open-client/es/node/help.js +96 -0
- package/node_modules/@ali/o2-open-client/es/node/index.d.ts +48 -0
- package/node_modules/@ali/o2-open-client/es/node/index.js +247 -0
- package/node_modules/@ali/o2-open-client/es/node/token-handler.d.ts +1 -0
- package/node_modules/@ali/o2-open-client/es/node/token-handler.js +21 -0
- package/node_modules/@ali/o2-open-client/lib/browser/ee.d.ts +23 -0
- package/node_modules/@ali/o2-open-client/lib/browser/ee.js +86 -0
- package/node_modules/@ali/o2-open-client/lib/browser/entry.d.ts +32 -0
- package/node_modules/@ali/o2-open-client/lib/browser/entry.js +310 -0
- package/node_modules/@ali/o2-open-client/lib/browser/escape.d.ts +12 -0
- package/node_modules/@ali/o2-open-client/lib/browser/escape.js +185 -0
- package/node_modules/@ali/o2-open-client/lib/browser/fetch.d.ts +1 -0
- package/node_modules/@ali/o2-open-client/lib/browser/fetch.js +18 -0
- package/node_modules/@ali/o2-open-client/lib/common/constant.d.ts +42 -0
- package/node_modules/@ali/o2-open-client/lib/common/constant.js +56 -0
- package/node_modules/@ali/o2-open-client/lib/common/format.d.ts +14 -0
- package/node_modules/@ali/o2-open-client/lib/common/format.js +48 -0
- package/node_modules/@ali/o2-open-client/lib/common/service-meta.d.ts +33 -0
- package/node_modules/@ali/o2-open-client/lib/common/service-meta.js +36 -0
- package/node_modules/@ali/o2-open-client/lib/index.d.ts +1 -0
- package/node_modules/@ali/o2-open-client/lib/index.js +20 -0
- package/node_modules/@ali/o2-open-client/lib/node/config.d.ts +47 -0
- package/node_modules/@ali/o2-open-client/lib/node/config.js +192 -0
- package/node_modules/@ali/o2-open-client/lib/node/escape.d.ts +22 -0
- package/node_modules/@ali/o2-open-client/lib/node/escape.js +137 -0
- package/node_modules/@ali/o2-open-client/lib/node/help.d.ts +10 -0
- package/node_modules/@ali/o2-open-client/lib/node/help.js +100 -0
- package/node_modules/@ali/o2-open-client/lib/node/index.d.ts +48 -0
- package/node_modules/@ali/o2-open-client/lib/node/index.js +250 -0
- package/node_modules/@ali/o2-open-client/lib/node/token-handler.d.ts +1 -0
- package/node_modules/@ali/o2-open-client/lib/node/token-handler.js +25 -0
- package/node_modules/@ali/o2-open-client/package.json +46 -0
- package/node_modules/@ali/o2-open-client/playwright.config.ts +54 -0
- package/node_modules/@ali/o2-open-client/tsconfig.es.json +31 -0
- package/node_modules/@ali/o2-open-client/tsconfig.json +31 -0
- package/node_modules/@ali/o2-open-client/tsx2doc.config.js +5 -0
- package/node_modules/@ali/o2-open-client/typings/index.d.ts +36 -0
- package/node_modules/@types/node/LICENSE +21 -0
- package/node_modules/@types/node/README.md +15 -0
- package/node_modules/@types/node/assert/strict.d.ts +8 -0
- package/node_modules/@types/node/assert.d.ts +1062 -0
- package/node_modules/@types/node/async_hooks.d.ts +605 -0
- package/node_modules/@types/node/buffer.buffer.d.ts +471 -0
- package/node_modules/@types/node/buffer.d.ts +1936 -0
- package/node_modules/@types/node/child_process.d.ts +1475 -0
- package/node_modules/@types/node/cluster.d.ts +577 -0
- package/node_modules/@types/node/compatibility/disposable.d.ts +16 -0
- package/node_modules/@types/node/compatibility/index.d.ts +9 -0
- package/node_modules/@types/node/compatibility/indexable.d.ts +20 -0
- package/node_modules/@types/node/compatibility/iterators.d.ts +21 -0
- package/node_modules/@types/node/console.d.ts +452 -0
- package/node_modules/@types/node/constants.d.ts +21 -0
- package/node_modules/@types/node/crypto.d.ts +4590 -0
- package/node_modules/@types/node/dgram.d.ts +597 -0
- package/node_modules/@types/node/diagnostics_channel.d.ts +578 -0
- package/node_modules/@types/node/dns/promises.d.ts +479 -0
- package/node_modules/@types/node/dns.d.ts +871 -0
- package/node_modules/@types/node/domain.d.ts +170 -0
- package/node_modules/@types/node/events.d.ts +977 -0
- package/node_modules/@types/node/fs/promises.d.ts +1270 -0
- package/node_modules/@types/node/fs.d.ts +4375 -0
- package/node_modules/@types/node/globals.d.ts +172 -0
- package/node_modules/@types/node/globals.typedarray.d.ts +38 -0
- package/node_modules/@types/node/http.d.ts +2049 -0
- package/node_modules/@types/node/http2.d.ts +2631 -0
- package/node_modules/@types/node/https.d.ts +578 -0
- package/node_modules/@types/node/index.d.ts +93 -0
- package/node_modules/@types/node/inspector.generated.d.ts +3966 -0
- package/node_modules/@types/node/module.d.ts +539 -0
- package/node_modules/@types/node/net.d.ts +1031 -0
- package/node_modules/@types/node/os.d.ts +506 -0
- package/node_modules/@types/node/package.json +140 -0
- package/node_modules/@types/node/path.d.ts +200 -0
- package/node_modules/@types/node/perf_hooks.d.ts +961 -0
- package/node_modules/@types/node/process.d.ts +1961 -0
- package/node_modules/@types/node/punycode.d.ts +117 -0
- package/node_modules/@types/node/querystring.d.ts +152 -0
- package/node_modules/@types/node/readline/promises.d.ts +162 -0
- package/node_modules/@types/node/readline.d.ts +589 -0
- package/node_modules/@types/node/repl.d.ts +430 -0
- package/node_modules/@types/node/sea.d.ts +153 -0
- package/node_modules/@types/node/stream/consumers.d.ts +38 -0
- package/node_modules/@types/node/stream/promises.d.ts +90 -0
- package/node_modules/@types/node/stream/web.d.ts +533 -0
- package/node_modules/@types/node/stream.d.ts +1698 -0
- package/node_modules/@types/node/string_decoder.d.ts +67 -0
- package/node_modules/@types/node/test.d.ts +1787 -0
- package/node_modules/@types/node/timers/promises.d.ts +108 -0
- package/node_modules/@types/node/timers.d.ts +286 -0
- package/node_modules/@types/node/tls.d.ts +1259 -0
- package/node_modules/@types/node/trace_events.d.ts +197 -0
- package/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +468 -0
- package/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +34 -0
- package/node_modules/@types/node/ts5.6/index.d.ts +93 -0
- package/node_modules/@types/node/tty.d.ts +208 -0
- package/node_modules/@types/node/url.d.ts +964 -0
- package/node_modules/@types/node/util.d.ts +2331 -0
- package/node_modules/@types/node/v8.d.ts +809 -0
- package/node_modules/@types/node/vm.d.ts +1001 -0
- package/node_modules/@types/node/wasi.d.ts +181 -0
- package/node_modules/@types/node/web-globals/abortcontroller.d.ts +34 -0
- package/node_modules/@types/node/web-globals/domexception.d.ts +68 -0
- package/node_modules/@types/node/web-globals/events.d.ts +97 -0
- package/node_modules/@types/node/web-globals/fetch.d.ts +55 -0
- package/node_modules/@types/node/worker_threads.d.ts +715 -0
- package/node_modules/@types/node/zlib.d.ts +598 -0
- package/node_modules/ansi-styles/index.d.ts +345 -0
- package/node_modules/ansi-styles/index.js +163 -0
- package/node_modules/ansi-styles/license +9 -0
- package/node_modules/ansi-styles/package.json +56 -0
- package/node_modules/ansi-styles/readme.md +152 -0
- package/node_modules/await-event/LICENSE +22 -0
- package/node_modules/await-event/README.md +48 -0
- package/node_modules/await-event/index.js +13 -0
- package/node_modules/await-event/package.json +33 -0
- package/node_modules/await-first/LICENSE +21 -0
- package/node_modules/await-first/README.md +80 -0
- package/node_modules/await-first/lib/index.js +21 -0
- package/node_modules/await-first/package.json +49 -0
- package/node_modules/byte/LICENSE.txt +21 -0
- package/node_modules/byte/README.md +207 -0
- package/node_modules/byte/lib/byte.js +635 -0
- package/node_modules/byte/lib/number.js +82 -0
- package/node_modules/byte/package.json +61 -0
- package/node_modules/chalk/index.d.ts +415 -0
- package/node_modules/chalk/license +9 -0
- package/node_modules/chalk/package.json +68 -0
- package/node_modules/chalk/readme.md +341 -0
- package/node_modules/chalk/source/index.js +229 -0
- package/node_modules/chalk/source/templates.js +134 -0
- package/node_modules/chalk/source/util.js +39 -0
- package/node_modules/circular-json-for-egg/LICENSE.txt +19 -0
- package/node_modules/circular-json-for-egg/README.md +148 -0
- package/node_modules/circular-json-for-egg/build/circular-json.amd.js +2 -0
- package/node_modules/circular-json-for-egg/build/circular-json.js +2 -0
- package/node_modules/circular-json-for-egg/build/circular-json.max.amd.js +210 -0
- package/node_modules/circular-json-for-egg/build/circular-json.max.js +210 -0
- package/node_modules/circular-json-for-egg/build/circular-json.node.js +207 -0
- package/node_modules/circular-json-for-egg/package.json +42 -0
- package/node_modules/cluster-client/LICENSE +21 -0
- package/node_modules/cluster-client/README.md +319 -0
- package/node_modules/cluster-client/index.js +66 -0
- package/node_modules/cluster-client/lib/api_client.js +74 -0
- package/node_modules/cluster-client/lib/connection.js +180 -0
- package/node_modules/cluster-client/lib/const.js +5 -0
- package/node_modules/cluster-client/lib/default_logger.js +11 -0
- package/node_modules/cluster-client/lib/default_transcode.js +6 -0
- package/node_modules/cluster-client/lib/follower.js +331 -0
- package/node_modules/cluster-client/lib/index.js +213 -0
- package/node_modules/cluster-client/lib/leader.js +437 -0
- package/node_modules/cluster-client/lib/protocol/byte_buffer.js +8 -0
- package/node_modules/cluster-client/lib/protocol/packet.js +103 -0
- package/node_modules/cluster-client/lib/protocol/request.js +17 -0
- package/node_modules/cluster-client/lib/protocol/response.js +14 -0
- package/node_modules/cluster-client/lib/server.js +256 -0
- package/node_modules/cluster-client/lib/symbol.js +20 -0
- package/node_modules/cluster-client/lib/utils.js +103 -0
- package/node_modules/cluster-client/lib/wrapper/base.js +210 -0
- package/node_modules/cluster-client/lib/wrapper/cluster.js +57 -0
- package/node_modules/cluster-client/lib/wrapper/single.js +192 -0
- package/node_modules/cluster-client/package.json +60 -0
- package/node_modules/co/LICENSE +22 -0
- package/node_modules/co/Readme.md +212 -0
- package/node_modules/co/index.js +237 -0
- package/node_modules/co/package.json +34 -0
- package/node_modules/color-convert/LICENSE +21 -0
- package/node_modules/color-convert/README.md +68 -0
- package/node_modules/color-convert/conversions.js +839 -0
- package/node_modules/color-convert/index.js +81 -0
- package/node_modules/color-convert/package.json +48 -0
- package/node_modules/color-convert/route.js +97 -0
- package/node_modules/color-name/LICENSE +8 -0
- package/node_modules/color-name/README.md +11 -0
- package/node_modules/color-name/index.js +152 -0
- package/node_modules/color-name/package.json +28 -0
- package/node_modules/core-util-is/LICENSE +19 -0
- package/node_modules/core-util-is/README.md +3 -0
- package/node_modules/core-util-is/lib/util.js +107 -0
- package/node_modules/core-util-is/package.json +38 -0
- package/node_modules/debug/LICENSE +20 -0
- package/node_modules/debug/README.md +481 -0
- package/node_modules/debug/package.json +64 -0
- package/node_modules/debug/src/browser.js +272 -0
- package/node_modules/debug/src/common.js +292 -0
- package/node_modules/debug/src/index.js +10 -0
- package/node_modules/debug/src/node.js +263 -0
- package/node_modules/depd/History.md +103 -0
- package/node_modules/depd/LICENSE +22 -0
- package/node_modules/depd/Readme.md +280 -0
- package/node_modules/depd/index.js +538 -0
- package/node_modules/depd/lib/browser/index.js +77 -0
- package/node_modules/depd/package.json +45 -0
- package/node_modules/ee-first/LICENSE +22 -0
- package/node_modules/ee-first/README.md +80 -0
- package/node_modules/ee-first/index.js +95 -0
- package/node_modules/ee-first/package.json +29 -0
- package/node_modules/egg-errors/LICENSE +21 -0
- package/node_modules/egg-errors/README.md +259 -0
- package/node_modules/egg-errors/lib/base.d.ts +10 -0
- package/node_modules/egg-errors/lib/base.js +28 -0
- package/node_modules/egg-errors/lib/base_error.d.ts +6 -0
- package/node_modules/egg-errors/lib/base_error.js +13 -0
- package/node_modules/egg-errors/lib/base_exception.d.ts +6 -0
- package/node_modules/egg-errors/lib/base_exception.js +13 -0
- package/node_modules/egg-errors/lib/error.d.ts +6 -0
- package/node_modules/egg-errors/lib/error.js +13 -0
- package/node_modules/egg-errors/lib/error_options.d.ts +5 -0
- package/node_modules/egg-errors/lib/error_options.js +6 -0
- package/node_modules/egg-errors/lib/error_type.d.ts +6 -0
- package/node_modules/egg-errors/lib/error_type.js +10 -0
- package/node_modules/egg-errors/lib/exception.d.ts +6 -0
- package/node_modules/egg-errors/lib/exception.js +13 -0
- package/node_modules/egg-errors/lib/framework/formatter.d.ts +6 -0
- package/node_modules/egg-errors/lib/framework/formatter.js +29 -0
- package/node_modules/egg-errors/lib/framework/framework_base_error.d.ts +10 -0
- package/node_modules/egg-errors/lib/framework/framework_base_error.js +32 -0
- package/node_modules/egg-errors/lib/http/400.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/400.js +13 -0
- package/node_modules/egg-errors/lib/http/401.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/401.js +13 -0
- package/node_modules/egg-errors/lib/http/402.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/402.js +13 -0
- package/node_modules/egg-errors/lib/http/403.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/403.js +13 -0
- package/node_modules/egg-errors/lib/http/404.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/404.js +13 -0
- package/node_modules/egg-errors/lib/http/405.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/405.js +13 -0
- package/node_modules/egg-errors/lib/http/406.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/406.js +13 -0
- package/node_modules/egg-errors/lib/http/407.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/407.js +13 -0
- package/node_modules/egg-errors/lib/http/408.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/408.js +13 -0
- package/node_modules/egg-errors/lib/http/409.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/409.js +13 -0
- package/node_modules/egg-errors/lib/http/410.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/410.js +13 -0
- package/node_modules/egg-errors/lib/http/411.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/411.js +13 -0
- package/node_modules/egg-errors/lib/http/412.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/412.js +13 -0
- package/node_modules/egg-errors/lib/http/413.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/413.js +13 -0
- package/node_modules/egg-errors/lib/http/414.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/414.js +13 -0
- package/node_modules/egg-errors/lib/http/415.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/415.js +13 -0
- package/node_modules/egg-errors/lib/http/416.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/416.js +13 -0
- package/node_modules/egg-errors/lib/http/417.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/417.js +13 -0
- package/node_modules/egg-errors/lib/http/418.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/418.js +13 -0
- package/node_modules/egg-errors/lib/http/421.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/421.js +13 -0
- package/node_modules/egg-errors/lib/http/422.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/422.js +13 -0
- package/node_modules/egg-errors/lib/http/423.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/423.js +13 -0
- package/node_modules/egg-errors/lib/http/424.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/424.js +13 -0
- package/node_modules/egg-errors/lib/http/425.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/425.js +13 -0
- package/node_modules/egg-errors/lib/http/426.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/426.js +13 -0
- package/node_modules/egg-errors/lib/http/428.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/428.js +13 -0
- package/node_modules/egg-errors/lib/http/429.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/429.js +13 -0
- package/node_modules/egg-errors/lib/http/431.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/431.js +13 -0
- package/node_modules/egg-errors/lib/http/451.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/451.js +13 -0
- package/node_modules/egg-errors/lib/http/500.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/500.js +13 -0
- package/node_modules/egg-errors/lib/http/501.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/501.js +13 -0
- package/node_modules/egg-errors/lib/http/502.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/502.js +13 -0
- package/node_modules/egg-errors/lib/http/503.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/503.js +13 -0
- package/node_modules/egg-errors/lib/http/504.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/504.js +13 -0
- package/node_modules/egg-errors/lib/http/505.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/505.js +13 -0
- package/node_modules/egg-errors/lib/http/506.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/506.js +13 -0
- package/node_modules/egg-errors/lib/http/507.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/507.js +13 -0
- package/node_modules/egg-errors/lib/http/508.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/508.js +13 -0
- package/node_modules/egg-errors/lib/http/509.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/509.js +13 -0
- package/node_modules/egg-errors/lib/http/510.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/510.js +13 -0
- package/node_modules/egg-errors/lib/http/511.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/511.js +13 -0
- package/node_modules/egg-errors/lib/http/http_error.d.ts +10 -0
- package/node_modules/egg-errors/lib/http/http_error.js +13 -0
- package/node_modules/egg-errors/lib/http/http_error_options.d.ts +6 -0
- package/node_modules/egg-errors/lib/http/http_error_options.js +7 -0
- package/node_modules/egg-errors/lib/http/http_header.d.ts +3 -0
- package/node_modules/egg-errors/lib/http/http_header.js +3 -0
- package/node_modules/egg-errors/lib/index.d.ts +50 -0
- package/node_modules/egg-errors/lib/index.js +149 -0
- package/node_modules/egg-errors/package.json +49 -0
- package/node_modules/egg-logger/LICENSE +21 -0
- package/node_modules/egg-logger/README.md +128 -0
- package/node_modules/egg-logger/README.zh-CN.md +125 -0
- package/node_modules/egg-logger/index.d.ts +233 -0
- package/node_modules/egg-logger/index.js +18 -0
- package/node_modules/egg-logger/lib/egg/console_logger.js +36 -0
- package/node_modules/egg-logger/lib/egg/context_logger.js +43 -0
- package/node_modules/egg-logger/lib/egg/custom_logger.js +10 -0
- package/node_modules/egg-logger/lib/egg/error_logger.js +31 -0
- package/node_modules/egg-logger/lib/egg/logger.js +128 -0
- package/node_modules/egg-logger/lib/egg/loggers.js +163 -0
- package/node_modules/egg-logger/lib/level.js +34 -0
- package/node_modules/egg-logger/lib/logger.js +170 -0
- package/node_modules/egg-logger/lib/transports/console.js +52 -0
- package/node_modules/egg-logger/lib/transports/file.js +134 -0
- package/node_modules/egg-logger/lib/transports/file_buffer.js +113 -0
- package/node_modules/egg-logger/lib/transports/transport.js +129 -0
- package/node_modules/egg-logger/lib/utils.js +296 -0
- package/node_modules/egg-logger/package.json +54 -0
- package/node_modules/escape-html/LICENSE +24 -0
- package/node_modules/escape-html/Readme.md +43 -0
- package/node_modules/escape-html/index.js +78 -0
- package/node_modules/escape-html/package.json +24 -0
- package/node_modules/extend-shallow/LICENSE +21 -0
- package/node_modules/extend-shallow/README.md +61 -0
- package/node_modules/extend-shallow/index.js +33 -0
- package/node_modules/extend-shallow/package.json +56 -0
- package/node_modules/has-flag/index.d.ts +39 -0
- package/node_modules/has-flag/index.js +8 -0
- package/node_modules/has-flag/license +9 -0
- package/node_modules/has-flag/package.json +46 -0
- package/node_modules/has-flag/readme.md +89 -0
- package/node_modules/heartbeats/.eslintrc +151 -0
- package/node_modules/heartbeats/.npmignore +28 -0
- package/node_modules/heartbeats/.travis.yml +10 -0
- package/node_modules/heartbeats/LICENSE +21 -0
- package/node_modules/heartbeats/README.md +323 -0
- package/node_modules/heartbeats/lib/beatevent.js +35 -0
- package/node_modules/heartbeats/lib/heart.js +178 -0
- package/node_modules/heartbeats/lib/pulse.js +39 -0
- package/node_modules/heartbeats/main.js +34 -0
- package/node_modules/heartbeats/package.json +39 -0
- package/node_modules/heartbeats/test/benchmark.js +138 -0
- package/node_modules/heartbeats/test/spawn.js +16 -0
- package/node_modules/heartbeats/test/test.js +158 -0
- package/node_modules/httpx/README.md +96 -0
- package/node_modules/httpx/lib/index.d.ts +31 -0
- package/node_modules/httpx/lib/index.js +396 -0
- package/node_modules/httpx/package.json +36 -0
- package/node_modules/iconv-lite/.github/dependabot.yml +11 -0
- package/node_modules/iconv-lite/.idea/codeStyles/Project.xml +47 -0
- package/node_modules/iconv-lite/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/node_modules/iconv-lite/.idea/iconv-lite.iml +12 -0
- package/node_modules/iconv-lite/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/node_modules/iconv-lite/.idea/modules.xml +8 -0
- package/node_modules/iconv-lite/.idea/vcs.xml +6 -0
- package/node_modules/iconv-lite/Changelog.md +212 -0
- package/node_modules/iconv-lite/LICENSE +21 -0
- package/node_modules/iconv-lite/README.md +130 -0
- package/node_modules/iconv-lite/encodings/dbcs-codec.js +597 -0
- package/node_modules/iconv-lite/encodings/dbcs-data.js +188 -0
- package/node_modules/iconv-lite/encodings/index.js +23 -0
- package/node_modules/iconv-lite/encodings/internal.js +198 -0
- package/node_modules/iconv-lite/encodings/sbcs-codec.js +72 -0
- package/node_modules/iconv-lite/encodings/sbcs-data-generated.js +451 -0
- package/node_modules/iconv-lite/encodings/sbcs-data.js +179 -0
- package/node_modules/iconv-lite/encodings/tables/big5-added.json +122 -0
- package/node_modules/iconv-lite/encodings/tables/cp936.json +264 -0
- package/node_modules/iconv-lite/encodings/tables/cp949.json +273 -0
- package/node_modules/iconv-lite/encodings/tables/cp950.json +177 -0
- package/node_modules/iconv-lite/encodings/tables/eucjp.json +182 -0
- package/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json +1 -0
- package/node_modules/iconv-lite/encodings/tables/gbk-added.json +56 -0
- package/node_modules/iconv-lite/encodings/tables/shiftjis.json +125 -0
- package/node_modules/iconv-lite/encodings/utf16.js +197 -0
- package/node_modules/iconv-lite/encodings/utf32.js +319 -0
- package/node_modules/iconv-lite/encodings/utf7.js +290 -0
- package/node_modules/iconv-lite/lib/bom-handling.js +52 -0
- package/node_modules/iconv-lite/lib/index.d.ts +41 -0
- package/node_modules/iconv-lite/lib/index.js +180 -0
- package/node_modules/iconv-lite/lib/streams.js +109 -0
- package/node_modules/iconv-lite/package.json +44 -0
- package/node_modules/ip/README.md +90 -0
- package/node_modules/ip/lib/ip.js +496 -0
- package/node_modules/ip/package.json +25 -0
- package/node_modules/is-class-hotfix/.editorconfig +23 -0
- package/node_modules/is-class-hotfix/.gitattributes +2 -0
- package/node_modules/is-class-hotfix/CHANGELOG.md +7 -0
- package/node_modules/is-class-hotfix/LICENSE.md +21 -0
- package/node_modules/is-class-hotfix/README.md +35 -0
- package/node_modules/is-class-hotfix/bower.json +24 -0
- package/node_modules/is-class-hotfix/is-class.js +28 -0
- package/node_modules/is-class-hotfix/package.json +31 -0
- package/node_modules/is-class-hotfix/test/babel-class.js +27 -0
- package/node_modules/is-class-hotfix/test/is-class.js +31 -0
- package/node_modules/is-extendable/LICENSE +21 -0
- package/node_modules/is-extendable/README.md +72 -0
- package/node_modules/is-extendable/index.js +13 -0
- package/node_modules/is-extendable/package.json +51 -0
- package/node_modules/is-type-of/LICENSE +21 -0
- package/node_modules/is-type-of/README.md +105 -0
- package/node_modules/is-type-of/index.d.ts +65 -0
- package/node_modules/is-type-of/index.js +125 -0
- package/node_modules/is-type-of/package.json +45 -0
- package/node_modules/isstream/.jshintrc +59 -0
- package/node_modules/isstream/.npmignore +1 -0
- package/node_modules/isstream/.travis.yml +12 -0
- package/node_modules/isstream/LICENSE.md +11 -0
- package/node_modules/isstream/README.md +66 -0
- package/node_modules/isstream/isstream.js +27 -0
- package/node_modules/isstream/package.json +33 -0
- package/node_modules/isstream/test.js +168 -0
- package/node_modules/json-stringify-safe/.npmignore +1 -0
- package/node_modules/json-stringify-safe/CHANGELOG.md +14 -0
- package/node_modules/json-stringify-safe/LICENSE +15 -0
- package/node_modules/json-stringify-safe/Makefile +35 -0
- package/node_modules/json-stringify-safe/README.md +52 -0
- package/node_modules/json-stringify-safe/package.json +31 -0
- package/node_modules/json-stringify-safe/stringify.js +27 -0
- package/node_modules/json-stringify-safe/test/mocha.opts +2 -0
- package/node_modules/json-stringify-safe/test/stringify_test.js +246 -0
- package/node_modules/kitx/LICENSE +21 -0
- package/node_modules/kitx/README.md +35 -0
- package/node_modules/kitx/lib/index.d.ts +45 -0
- package/node_modules/kitx/lib/index.js +289 -0
- package/node_modules/kitx/package.json +41 -0
- package/node_modules/long/LICENSE +202 -0
- package/node_modules/long/README.md +246 -0
- package/node_modules/long/dist/long.js +2 -0
- package/node_modules/long/dist/long.js.map +1 -0
- package/node_modules/long/index.js +1 -0
- package/node_modules/long/package.json +34 -0
- package/node_modules/long/src/long.js +1323 -0
- package/node_modules/ms/index.js +162 -0
- package/node_modules/ms/license.md +21 -0
- package/node_modules/ms/package.json +38 -0
- package/node_modules/ms/readme.md +59 -0
- package/node_modules/p-timeout/index.d.ts +113 -0
- package/node_modules/p-timeout/index.js +71 -0
- package/node_modules/p-timeout/license +9 -0
- package/node_modules/p-timeout/package.json +44 -0
- package/node_modules/p-timeout/readme.md +117 -0
- package/node_modules/safer-buffer/LICENSE +21 -0
- package/node_modules/safer-buffer/Porting-Buffer.md +268 -0
- package/node_modules/safer-buffer/Readme.md +156 -0
- package/node_modules/safer-buffer/dangerous.js +58 -0
- package/node_modules/safer-buffer/package.json +34 -0
- package/node_modules/safer-buffer/safer.js +77 -0
- package/node_modules/safer-buffer/tests.js +406 -0
- package/node_modules/sdk-base/LICENSE +21 -0
- package/node_modules/sdk-base/README.md +165 -0
- package/node_modules/sdk-base/index.d.ts +29 -0
- package/node_modules/sdk-base/index.js +251 -0
- package/node_modules/sdk-base/package.json +54 -0
- package/node_modules/serialize-json/LICENSE +21 -0
- package/node_modules/serialize-json/README.md +74 -0
- package/node_modules/serialize-json/lib/decoder.js +190 -0
- package/node_modules/serialize-json/lib/encoder.js +200 -0
- package/node_modules/serialize-json/lib/index.js +15 -0
- package/node_modules/serialize-json/package.json +53 -0
- package/node_modules/supports-color/browser.js +5 -0
- package/node_modules/supports-color/index.js +135 -0
- package/node_modules/supports-color/license +9 -0
- package/node_modules/supports-color/package.json +53 -0
- package/node_modules/supports-color/readme.md +76 -0
- package/node_modules/tcp-base/LICENSE +21 -0
- package/node_modules/tcp-base/README.md +134 -0
- package/node_modules/tcp-base/lib/base.js +456 -0
- package/node_modules/tcp-base/package.json +44 -0
- package/node_modules/undici-types/LICENSE +21 -0
- package/node_modules/undici-types/README.md +6 -0
- package/node_modules/undici-types/agent.d.ts +31 -0
- package/node_modules/undici-types/api.d.ts +43 -0
- package/node_modules/undici-types/balanced-pool.d.ts +29 -0
- package/node_modules/undici-types/cache.d.ts +36 -0
- package/node_modules/undici-types/client.d.ts +108 -0
- package/node_modules/undici-types/connector.d.ts +34 -0
- package/node_modules/undici-types/content-type.d.ts +21 -0
- package/node_modules/undici-types/cookies.d.ts +28 -0
- package/node_modules/undici-types/diagnostics-channel.d.ts +66 -0
- package/node_modules/undici-types/dispatcher.d.ts +256 -0
- package/node_modules/undici-types/env-http-proxy-agent.d.ts +21 -0
- package/node_modules/undici-types/errors.d.ts +149 -0
- package/node_modules/undici-types/eventsource.d.ts +61 -0
- package/node_modules/undici-types/fetch.d.ts +209 -0
- package/node_modules/undici-types/file.d.ts +39 -0
- package/node_modules/undici-types/filereader.d.ts +54 -0
- package/node_modules/undici-types/formdata.d.ts +108 -0
- package/node_modules/undici-types/global-dispatcher.d.ts +9 -0
- package/node_modules/undici-types/global-origin.d.ts +7 -0
- package/node_modules/undici-types/handlers.d.ts +15 -0
- package/node_modules/undici-types/header.d.ts +4 -0
- package/node_modules/undici-types/index.d.ts +71 -0
- package/node_modules/undici-types/interceptors.d.ts +17 -0
- package/node_modules/undici-types/mock-agent.d.ts +50 -0
- package/node_modules/undici-types/mock-client.d.ts +25 -0
- package/node_modules/undici-types/mock-errors.d.ts +12 -0
- package/node_modules/undici-types/mock-interceptor.d.ts +93 -0
- package/node_modules/undici-types/mock-pool.d.ts +25 -0
- package/node_modules/undici-types/package.json +55 -0
- package/node_modules/undici-types/patch.d.ts +33 -0
- package/node_modules/undici-types/pool-stats.d.ts +19 -0
- package/node_modules/undici-types/pool.d.ts +39 -0
- package/node_modules/undici-types/proxy-agent.d.ts +28 -0
- package/node_modules/undici-types/readable.d.ts +65 -0
- package/node_modules/undici-types/retry-agent.d.ts +8 -0
- package/node_modules/undici-types/retry-handler.d.ts +116 -0
- package/node_modules/undici-types/util.d.ts +18 -0
- package/node_modules/undici-types/webidl.d.ts +228 -0
- package/node_modules/undici-types/websocket.d.ts +150 -0
- package/node_modules/unescape/LICENSE +21 -0
- package/node_modules/unescape/README.md +134 -0
- package/node_modules/unescape/index.js +103 -0
- package/node_modules/unescape/package.json +67 -0
- package/node_modules/utility/LICENSE.txt +21 -0
- package/node_modules/utility/README.md +370 -0
- package/node_modules/utility/dist/commonjs/array.d.ts +11 -0
- package/node_modules/utility/dist/commonjs/array.js +46 -0
- package/node_modules/utility/dist/commonjs/crypto.d.ts +86 -0
- package/node_modules/utility/dist/commonjs/crypto.js +159 -0
- package/node_modules/utility/dist/commonjs/date.d.ts +63 -0
- package/node_modules/utility/dist/commonjs/date.js +219 -0
- package/node_modules/utility/dist/commonjs/fs.d.ts +6 -0
- package/node_modules/utility/dist/commonjs/fs.js +20 -0
- package/node_modules/utility/dist/commonjs/function.d.ts +12 -0
- package/node_modules/utility/dist/commonjs/function.js +35 -0
- package/node_modules/utility/dist/commonjs/index.d.ts +12 -0
- package/node_modules/utility/dist/commonjs/index.js +29 -0
- package/node_modules/utility/dist/commonjs/json.d.ts +14 -0
- package/node_modules/utility/dist/commonjs/json.js +41 -0
- package/node_modules/utility/dist/commonjs/number.d.ts +24 -0
- package/node_modules/utility/dist/commonjs/number.js +66 -0
- package/node_modules/utility/dist/commonjs/object.d.ts +20 -0
- package/node_modules/utility/dist/commonjs/object.js +73 -0
- package/node_modules/utility/dist/commonjs/optimize.d.ts +21 -0
- package/node_modules/utility/dist/commonjs/optimize.js +60 -0
- package/node_modules/utility/dist/commonjs/package.json +3 -0
- package/node_modules/utility/dist/commonjs/string.d.ts +29 -0
- package/node_modules/utility/dist/commonjs/string.js +126 -0
- package/node_modules/utility/dist/commonjs/timeout.d.ts +6 -0
- package/node_modules/utility/dist/commonjs/timeout.js +34 -0
- package/node_modules/utility/dist/commonjs/web.d.ts +29 -0
- package/node_modules/utility/dist/commonjs/web.js +61 -0
- package/node_modules/utility/dist/esm/array.d.ts +11 -0
- package/node_modules/utility/dist/esm/array.js +42 -0
- package/node_modules/utility/dist/esm/crypto.d.ts +86 -0
- package/node_modules/utility/dist/esm/crypto.js +146 -0
- package/node_modules/utility/dist/esm/date.d.ts +63 -0
- package/node_modules/utility/dist/esm/date.js +204 -0
- package/node_modules/utility/dist/esm/fs.d.ts +6 -0
- package/node_modules/utility/dist/esm/fs.js +17 -0
- package/node_modules/utility/dist/esm/function.d.ts +12 -0
- package/node_modules/utility/dist/esm/function.js +28 -0
- package/node_modules/utility/dist/esm/index.d.ts +12 -0
- package/node_modules/utility/dist/esm/index.js +13 -0
- package/node_modules/utility/dist/esm/json.d.ts +14 -0
- package/node_modules/utility/dist/esm/json.js +34 -0
- package/node_modules/utility/dist/esm/number.d.ts +24 -0
- package/node_modules/utility/dist/esm/number.js +60 -0
- package/node_modules/utility/dist/esm/object.d.ts +20 -0
- package/node_modules/utility/dist/esm/object.js +67 -0
- package/node_modules/utility/dist/esm/optimize.d.ts +21 -0
- package/node_modules/utility/dist/esm/optimize.js +54 -0
- package/node_modules/utility/dist/esm/package.json +3 -0
- package/node_modules/utility/dist/esm/string.d.ts +29 -0
- package/node_modules/utility/dist/esm/string.js +118 -0
- package/node_modules/utility/dist/esm/timeout.d.ts +6 -0
- package/node_modules/utility/dist/esm/timeout.js +28 -0
- package/node_modules/utility/dist/esm/web.d.ts +29 -0
- package/node_modules/utility/dist/esm/web.js +52 -0
- package/node_modules/utility/dist/package.json +4 -0
- package/node_modules/utility/package.json +85 -0
- package/node_modules/utility/src/array.ts +44 -0
- package/node_modules/utility/src/crypto.ts +160 -0
- package/node_modules/utility/src/date.ts +232 -0
- package/node_modules/utility/src/fs.ts +17 -0
- package/node_modules/utility/src/function.ts +30 -0
- package/node_modules/utility/src/index.ts +12 -0
- package/node_modules/utility/src/json.ts +48 -0
- package/node_modules/utility/src/number.ts +63 -0
- package/node_modules/utility/src/object.ts +72 -0
- package/node_modules/utility/src/optimize.ts +62 -0
- package/node_modules/utility/src/string.ts +132 -0
- package/node_modules/utility/src/timeout.ts +37 -0
- package/node_modules/utility/src/web.ts +53 -0
- package/node_modules/ylru/LICENSE +25 -0
- package/node_modules/ylru/README.md +120 -0
- package/node_modules/ylru/dist/commonjs/index.d.ts +21 -0
- package/node_modules/ylru/dist/commonjs/index.js +112 -0
- package/node_modules/ylru/dist/commonjs/package.json +3 -0
- package/node_modules/ylru/dist/esm/index.d.ts +21 -0
- package/node_modules/ylru/dist/esm/index.js +108 -0
- package/node_modules/ylru/dist/esm/package.json +3 -0
- package/node_modules/ylru/package.json +71 -0
- package/node_modules/ylru/src/index.ts +124 -0
- package/package.json +2 -2
- package/node_modules/@ali/cli-skills/dist/_chunks/libs/abort-controller.mjs +0 -424
- package/node_modules/@ali/cli-skills/dist/_chunks/libs/archiver.mjs +0 -19586
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const debug = require('debug')('serialize-json#JSONEncoder');
|
|
4
|
+
const is = require('is-type-of');
|
|
5
|
+
const utility = require('utility');
|
|
6
|
+
|
|
7
|
+
const REG_STR_REPLACER = /[\+ \|\^\%]/g;
|
|
8
|
+
const ENCODER_REPLACER = {
|
|
9
|
+
' ': '+',
|
|
10
|
+
'+': '%2B',
|
|
11
|
+
'|': '%7C',
|
|
12
|
+
'^': '%5E',
|
|
13
|
+
'%': '%25',
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const TOKEN_TRUE = -1;
|
|
17
|
+
const TOKEN_FALSE = -2;
|
|
18
|
+
const TOKEN_NULL = -3;
|
|
19
|
+
const TOKEN_EMPTY_STRING = -4;
|
|
20
|
+
const TOKEN_UNDEFINED = -5;
|
|
21
|
+
|
|
22
|
+
class JSONEncoder {
|
|
23
|
+
constructor() {
|
|
24
|
+
this.dictionary = null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
encode(json) {
|
|
28
|
+
this.dictionary = {
|
|
29
|
+
strings: [],
|
|
30
|
+
integers: [],
|
|
31
|
+
floats: [],
|
|
32
|
+
dates: [],
|
|
33
|
+
};
|
|
34
|
+
const ast = this._buildAst(json);
|
|
35
|
+
|
|
36
|
+
let packed = this.dictionary.strings.join('|');
|
|
37
|
+
packed += `^${this.dictionary.integers.join('|')}`;
|
|
38
|
+
packed += `^${this.dictionary.floats.join('|')}`;
|
|
39
|
+
packed += `^${this.dictionary.dates.join('|')}`;
|
|
40
|
+
packed += `^${this._pack(ast)}`;
|
|
41
|
+
|
|
42
|
+
debug('pack the json => %s', packed);
|
|
43
|
+
return Buffer.from(packed);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
_pack(ast) {
|
|
47
|
+
if (is.array(ast)) {
|
|
48
|
+
let packed = ast.shift();
|
|
49
|
+
for (const item of ast) {
|
|
50
|
+
packed += `${this._pack(item)}|`;
|
|
51
|
+
}
|
|
52
|
+
return (packed[packed.length - 1] === '|' ? packed.slice(0, -1) : packed) + ']';
|
|
53
|
+
}
|
|
54
|
+
const type = ast.type;
|
|
55
|
+
const index = ast.index;
|
|
56
|
+
const dictionary = this.dictionary;
|
|
57
|
+
const strLen = dictionary.strings.length;
|
|
58
|
+
const intLen = dictionary.integers.length;
|
|
59
|
+
const floatLen = dictionary.floats.length;
|
|
60
|
+
|
|
61
|
+
switch (type) {
|
|
62
|
+
case 'string':
|
|
63
|
+
return this._base10To36(index);
|
|
64
|
+
case 'integer':
|
|
65
|
+
return this._base10To36(strLen + index);
|
|
66
|
+
case 'float':
|
|
67
|
+
return this._base10To36(strLen + intLen + index);
|
|
68
|
+
case 'date':
|
|
69
|
+
return this._base10To36(strLen + intLen + floatLen + index);
|
|
70
|
+
default:
|
|
71
|
+
return this._base10To36(index);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
_encodeString(str) {
|
|
76
|
+
return str.replace(REG_STR_REPLACER, a => ENCODER_REPLACER[a]);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
_base10To36(num) {
|
|
80
|
+
return num.toString(36).toUpperCase();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
_dateTo36(date) {
|
|
84
|
+
return this._base10To36(date.getTime());
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
_buildStringAst(str) {
|
|
88
|
+
const dictionary = this.dictionary;
|
|
89
|
+
if (str === '') {
|
|
90
|
+
return {
|
|
91
|
+
type: 'empty',
|
|
92
|
+
index: TOKEN_EMPTY_STRING,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
const data = this._encodeString(str);
|
|
96
|
+
return {
|
|
97
|
+
type: 'string',
|
|
98
|
+
index: dictionary.strings.push(data) - 1,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
_buildNumberAst(num) {
|
|
103
|
+
const dictionary = this.dictionary;
|
|
104
|
+
// integer
|
|
105
|
+
if (num % 1 === 0) {
|
|
106
|
+
const data = this._base10To36(num);
|
|
107
|
+
return {
|
|
108
|
+
type: 'integer',
|
|
109
|
+
index: dictionary.integers.push(data) - 1,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
// float
|
|
113
|
+
return {
|
|
114
|
+
type: 'float',
|
|
115
|
+
index: dictionary.floats.push(num) - 1,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
_buildObjectAst(obj) {
|
|
120
|
+
if (obj === null) {
|
|
121
|
+
return {
|
|
122
|
+
type: 'null',
|
|
123
|
+
index: TOKEN_NULL,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
if (is.date(obj)) {
|
|
127
|
+
const dictionary = this.dictionary;
|
|
128
|
+
const data = this._dateTo36(obj);
|
|
129
|
+
return {
|
|
130
|
+
type: 'date',
|
|
131
|
+
index: dictionary.dates.push(data) - 1,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
let ast;
|
|
135
|
+
if (is.array(obj)) {
|
|
136
|
+
ast = [ '@' ];
|
|
137
|
+
for (const item of obj) {
|
|
138
|
+
ast.push(this._buildAst(item));
|
|
139
|
+
}
|
|
140
|
+
return ast;
|
|
141
|
+
}
|
|
142
|
+
if (is.buffer(obj)) {
|
|
143
|
+
ast = [ '*' ];
|
|
144
|
+
for (const item of obj.values()) {
|
|
145
|
+
ast.push(this._buildAst(item));
|
|
146
|
+
}
|
|
147
|
+
return ast;
|
|
148
|
+
}
|
|
149
|
+
if (is.error(obj)) {
|
|
150
|
+
ast = [ '#' ];
|
|
151
|
+
ast.push(this._buildAst('message'));
|
|
152
|
+
ast.push(this._buildAst(obj.message));
|
|
153
|
+
ast.push(this._buildAst('stack'));
|
|
154
|
+
ast.push(this._buildAst(obj.stack));
|
|
155
|
+
} else {
|
|
156
|
+
ast = [ '$' ];
|
|
157
|
+
}
|
|
158
|
+
for (const key in obj) {
|
|
159
|
+
// support object without prototype, like: Object.create(null)
|
|
160
|
+
if (!utility.has(obj, key)) {
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
ast.push(this._buildAst(key));
|
|
164
|
+
ast.push(this._buildAst(obj[key]));
|
|
165
|
+
}
|
|
166
|
+
return ast;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
_buildAst(item) {
|
|
170
|
+
const type = typeof item;
|
|
171
|
+
debug('calling buildAst with type: %s and data: %j', type, item);
|
|
172
|
+
|
|
173
|
+
switch (type) {
|
|
174
|
+
case 'string':
|
|
175
|
+
return this._buildStringAst(item);
|
|
176
|
+
case 'number':
|
|
177
|
+
return this._buildNumberAst(item);
|
|
178
|
+
case 'boolean':
|
|
179
|
+
return {
|
|
180
|
+
type: 'boolean',
|
|
181
|
+
index: item ? TOKEN_TRUE : TOKEN_FALSE,
|
|
182
|
+
};
|
|
183
|
+
case 'undefined':
|
|
184
|
+
return {
|
|
185
|
+
type: 'undefined',
|
|
186
|
+
index: TOKEN_UNDEFINED,
|
|
187
|
+
};
|
|
188
|
+
case 'object':
|
|
189
|
+
return this._buildObjectAst(item);
|
|
190
|
+
default:
|
|
191
|
+
debug('unsupported type: %s, return null', type);
|
|
192
|
+
return {
|
|
193
|
+
type: 'null',
|
|
194
|
+
index: TOKEN_NULL,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
module.exports = JSONEncoder;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const JSONEncoder = require('./encoder');
|
|
4
|
+
const JSONDecoder = require('./decoder');
|
|
5
|
+
|
|
6
|
+
const encoder = new JSONEncoder();
|
|
7
|
+
const decoder = new JSONDecoder();
|
|
8
|
+
|
|
9
|
+
exports.encode = json => {
|
|
10
|
+
return encoder.encode(json);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
exports.decode = buf => {
|
|
14
|
+
return decoder.decode(buf);
|
|
15
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "serialize-json",
|
|
3
|
+
"version": "1.0.3",
|
|
4
|
+
"description": "A serialize algorithm for JSON",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"lib"
|
|
8
|
+
],
|
|
9
|
+
"scripts": {
|
|
10
|
+
"autod": "autod",
|
|
11
|
+
"pkgfiles": "egg-bin pkgfiles --check",
|
|
12
|
+
"lint": "eslint --ext .js lib test",
|
|
13
|
+
"test": "npm run lint && npm run test-local",
|
|
14
|
+
"test-local": "egg-bin test",
|
|
15
|
+
"cov": "egg-bin cov",
|
|
16
|
+
"ci": "npm run autod -- --check && npm run lint && npm run cov"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/node-modules/serialize-json.git"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"json",
|
|
24
|
+
"serialization"
|
|
25
|
+
],
|
|
26
|
+
"author": "gxcsoccer@126.com",
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"bugs": {
|
|
29
|
+
"url": "https://github.com/node-modules/serialize-json/issues"
|
|
30
|
+
},
|
|
31
|
+
"homepage": "https://github.com/node-modules/serialize-json#readme",
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"debug": "^3.2.6",
|
|
34
|
+
"is-type-of": "^1.2.1",
|
|
35
|
+
"utility": "^1.15.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"autod": "^3.0.1",
|
|
39
|
+
"beautify-benchmark": "^0.2.4",
|
|
40
|
+
"benchmark": "^2.1.4",
|
|
41
|
+
"egg-bin": "^1.11.1",
|
|
42
|
+
"egg-ci": "^1.10.0",
|
|
43
|
+
"eslint": "^4.19.1",
|
|
44
|
+
"eslint-config-egg": "^6.0.0",
|
|
45
|
+
"mm": "^2.4.1"
|
|
46
|
+
},
|
|
47
|
+
"engines": {
|
|
48
|
+
"node": ">= 4.0.0"
|
|
49
|
+
},
|
|
50
|
+
"ci": {
|
|
51
|
+
"version": "4, 6, 8, 10, 11"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const os = require('os');
|
|
3
|
+
const tty = require('tty');
|
|
4
|
+
const hasFlag = require('has-flag');
|
|
5
|
+
|
|
6
|
+
const {env} = process;
|
|
7
|
+
|
|
8
|
+
let forceColor;
|
|
9
|
+
if (hasFlag('no-color') ||
|
|
10
|
+
hasFlag('no-colors') ||
|
|
11
|
+
hasFlag('color=false') ||
|
|
12
|
+
hasFlag('color=never')) {
|
|
13
|
+
forceColor = 0;
|
|
14
|
+
} else if (hasFlag('color') ||
|
|
15
|
+
hasFlag('colors') ||
|
|
16
|
+
hasFlag('color=true') ||
|
|
17
|
+
hasFlag('color=always')) {
|
|
18
|
+
forceColor = 1;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if ('FORCE_COLOR' in env) {
|
|
22
|
+
if (env.FORCE_COLOR === 'true') {
|
|
23
|
+
forceColor = 1;
|
|
24
|
+
} else if (env.FORCE_COLOR === 'false') {
|
|
25
|
+
forceColor = 0;
|
|
26
|
+
} else {
|
|
27
|
+
forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function translateLevel(level) {
|
|
32
|
+
if (level === 0) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
level,
|
|
38
|
+
hasBasic: true,
|
|
39
|
+
has256: level >= 2,
|
|
40
|
+
has16m: level >= 3
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function supportsColor(haveStream, streamIsTTY) {
|
|
45
|
+
if (forceColor === 0) {
|
|
46
|
+
return 0;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (hasFlag('color=16m') ||
|
|
50
|
+
hasFlag('color=full') ||
|
|
51
|
+
hasFlag('color=truecolor')) {
|
|
52
|
+
return 3;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (hasFlag('color=256')) {
|
|
56
|
+
return 2;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (haveStream && !streamIsTTY && forceColor === undefined) {
|
|
60
|
+
return 0;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const min = forceColor || 0;
|
|
64
|
+
|
|
65
|
+
if (env.TERM === 'dumb') {
|
|
66
|
+
return min;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (process.platform === 'win32') {
|
|
70
|
+
// Windows 10 build 10586 is the first Windows release that supports 256 colors.
|
|
71
|
+
// Windows 10 build 14931 is the first release that supports 16m/TrueColor.
|
|
72
|
+
const osRelease = os.release().split('.');
|
|
73
|
+
if (
|
|
74
|
+
Number(osRelease[0]) >= 10 &&
|
|
75
|
+
Number(osRelease[2]) >= 10586
|
|
76
|
+
) {
|
|
77
|
+
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return 1;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if ('CI' in env) {
|
|
84
|
+
if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'GITHUB_ACTIONS', 'BUILDKITE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
|
|
85
|
+
return 1;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return min;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if ('TEAMCITY_VERSION' in env) {
|
|
92
|
+
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (env.COLORTERM === 'truecolor') {
|
|
96
|
+
return 3;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if ('TERM_PROGRAM' in env) {
|
|
100
|
+
const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
|
|
101
|
+
|
|
102
|
+
switch (env.TERM_PROGRAM) {
|
|
103
|
+
case 'iTerm.app':
|
|
104
|
+
return version >= 3 ? 3 : 2;
|
|
105
|
+
case 'Apple_Terminal':
|
|
106
|
+
return 2;
|
|
107
|
+
// No default
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (/-256(color)?$/i.test(env.TERM)) {
|
|
112
|
+
return 2;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
|
116
|
+
return 1;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if ('COLORTERM' in env) {
|
|
120
|
+
return 1;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return min;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function getSupportLevel(stream) {
|
|
127
|
+
const level = supportsColor(stream, stream && stream.isTTY);
|
|
128
|
+
return translateLevel(level);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
module.exports = {
|
|
132
|
+
supportsColor: getSupportLevel,
|
|
133
|
+
stdout: translateLevel(supportsColor(true, tty.isatty(1))),
|
|
134
|
+
stderr: translateLevel(supportsColor(true, tty.isatty(2)))
|
|
135
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "supports-color",
|
|
3
|
+
"version": "7.2.0",
|
|
4
|
+
"description": "Detect whether a terminal supports color",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": "chalk/supports-color",
|
|
7
|
+
"author": {
|
|
8
|
+
"name": "Sindre Sorhus",
|
|
9
|
+
"email": "sindresorhus@gmail.com",
|
|
10
|
+
"url": "sindresorhus.com"
|
|
11
|
+
},
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=8"
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"test": "xo && ava"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"index.js",
|
|
20
|
+
"browser.js"
|
|
21
|
+
],
|
|
22
|
+
"keywords": [
|
|
23
|
+
"color",
|
|
24
|
+
"colour",
|
|
25
|
+
"colors",
|
|
26
|
+
"terminal",
|
|
27
|
+
"console",
|
|
28
|
+
"cli",
|
|
29
|
+
"ansi",
|
|
30
|
+
"styles",
|
|
31
|
+
"tty",
|
|
32
|
+
"rgb",
|
|
33
|
+
"256",
|
|
34
|
+
"shell",
|
|
35
|
+
"xterm",
|
|
36
|
+
"command-line",
|
|
37
|
+
"support",
|
|
38
|
+
"supports",
|
|
39
|
+
"capability",
|
|
40
|
+
"detect",
|
|
41
|
+
"truecolor",
|
|
42
|
+
"16m"
|
|
43
|
+
],
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"has-flag": "^4.0.0"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"ava": "^1.4.1",
|
|
49
|
+
"import-fresh": "^3.0.0",
|
|
50
|
+
"xo": "^0.24.0"
|
|
51
|
+
},
|
|
52
|
+
"browser": "browser.js"
|
|
53
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# supports-color [](https://travis-ci.org/chalk/supports-color)
|
|
2
|
+
|
|
3
|
+
> Detect whether a terminal supports color
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
```
|
|
9
|
+
$ npm install supports-color
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
const supportsColor = require('supports-color');
|
|
17
|
+
|
|
18
|
+
if (supportsColor.stdout) {
|
|
19
|
+
console.log('Terminal stdout supports color');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (supportsColor.stdout.has256) {
|
|
23
|
+
console.log('Terminal stdout supports 256 colors');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (supportsColor.stderr.has16m) {
|
|
27
|
+
console.log('Terminal stderr supports 16 million colors (truecolor)');
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
## API
|
|
33
|
+
|
|
34
|
+
Returns an `Object` with a `stdout` and `stderr` property for testing either streams. Each property is an `Object`, or `false` if color is not supported.
|
|
35
|
+
|
|
36
|
+
The `stdout`/`stderr` objects specifies a level of support for color through a `.level` property and a corresponding flag:
|
|
37
|
+
|
|
38
|
+
- `.level = 1` and `.hasBasic = true`: Basic color support (16 colors)
|
|
39
|
+
- `.level = 2` and `.has256 = true`: 256 color support
|
|
40
|
+
- `.level = 3` and `.has16m = true`: Truecolor support (16 million colors)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
## Info
|
|
44
|
+
|
|
45
|
+
It obeys the `--color` and `--no-color` CLI flags.
|
|
46
|
+
|
|
47
|
+
For situations where using `--color` is not possible, use the environment variable `FORCE_COLOR=1` (level 1), `FORCE_COLOR=2` (level 2), or `FORCE_COLOR=3` (level 3) to forcefully enable color, or `FORCE_COLOR=0` to forcefully disable. The use of `FORCE_COLOR` overrides all other color support checks.
|
|
48
|
+
|
|
49
|
+
Explicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=16m` flags, respectively.
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
## Related
|
|
53
|
+
|
|
54
|
+
- [supports-color-cli](https://github.com/chalk/supports-color-cli) - CLI for this module
|
|
55
|
+
- [chalk](https://github.com/chalk/chalk) - Terminal string styling done right
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
## Maintainers
|
|
59
|
+
|
|
60
|
+
- [Sindre Sorhus](https://github.com/sindresorhus)
|
|
61
|
+
- [Josh Junon](https://github.com/qix-)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
<div align="center">
|
|
67
|
+
<b>
|
|
68
|
+
<a href="https://tidelift.com/subscription/pkg/npm-supports-color?utm_source=npm-supports-color&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
|
|
69
|
+
</b>
|
|
70
|
+
<br>
|
|
71
|
+
<sub>
|
|
72
|
+
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
|
73
|
+
</sub>
|
|
74
|
+
</div>
|
|
75
|
+
|
|
76
|
+
---
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016 node-modules and other contributors.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# tcp-base
|
|
2
|
+
|
|
3
|
+
A base class for tcp client with basic functions
|
|
4
|
+
|
|
5
|
+
[![NPM version][npm-image]][npm-url]
|
|
6
|
+
[](https://github.com/node-modules/tcp-base/actions/workflows/nodejs.yml)
|
|
7
|
+
[![Test coverage][codecov-image]][codecov-url]
|
|
8
|
+
[![npm download][download-image]][download-url]
|
|
9
|
+
|
|
10
|
+
[npm-image]: https://img.shields.io/npm/v/tcp-base.svg?style=flat-square
|
|
11
|
+
[npm-url]: https://npmjs.org/package/tcp-base
|
|
12
|
+
[codecov-image]: https://codecov.io/gh/node-modules/tcp-base/branch/master/graph/badge.svg
|
|
13
|
+
[codecov-url]: https://codecov.io/gh/node-modules/tcp-base
|
|
14
|
+
[download-image]: https://img.shields.io/npm/dm/tcp-base.svg?style=flat-square
|
|
15
|
+
[download-url]: https://npmjs.org/package/tcp-base
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install tcp-base --save
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Node.js >= 6.0.0 required
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
A quick guide to implement a tcp echo client
|
|
28
|
+
|
|
29
|
+
Client:
|
|
30
|
+
|
|
31
|
+
```js
|
|
32
|
+
const TCPBase = require('tcp-base');
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* A Simple Protocol:
|
|
36
|
+
* (4B): request id
|
|
37
|
+
* (4B): body length
|
|
38
|
+
* ------------------------------
|
|
39
|
+
* body data
|
|
40
|
+
*/
|
|
41
|
+
class Client extends TCPBase {
|
|
42
|
+
getHeader() {
|
|
43
|
+
return this.read(8);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
getBodyLength(header) {
|
|
47
|
+
return header.readInt32BE(4);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
decode(body, header) {
|
|
51
|
+
return {
|
|
52
|
+
id: header.readInt32BE(0),
|
|
53
|
+
data: body,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// heartbeat packet
|
|
58
|
+
get heartBeatPacket() {
|
|
59
|
+
return Buffer.from([ 255, 255, 255, 255, 0, 0, 0, 0 ]);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const client = new Client({
|
|
64
|
+
host: '127.0.0.1',
|
|
65
|
+
port: 8080,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const body = Buffer.from('hello');
|
|
69
|
+
const data = Buffer.alloc(8 + body.length);
|
|
70
|
+
data.writeInt32BE(1, 0);
|
|
71
|
+
data.writeInt32BE(body.length, 4);
|
|
72
|
+
body.copy(data, 8, 0);
|
|
73
|
+
|
|
74
|
+
client.send({
|
|
75
|
+
id: 1,
|
|
76
|
+
data,
|
|
77
|
+
timeout: 5000,
|
|
78
|
+
}, (err, res) => {
|
|
79
|
+
if (err) {
|
|
80
|
+
console.error(err);
|
|
81
|
+
}
|
|
82
|
+
console.log(res.toString()); // should echo 'hello'
|
|
83
|
+
});
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Server:
|
|
87
|
+
|
|
88
|
+
```js
|
|
89
|
+
'use strict';
|
|
90
|
+
|
|
91
|
+
const net = require('net');
|
|
92
|
+
|
|
93
|
+
const server = net.createServer(socket => {
|
|
94
|
+
let header;
|
|
95
|
+
let bodyLen;
|
|
96
|
+
|
|
97
|
+
function readPacket() {
|
|
98
|
+
if (bodyLen == null) {
|
|
99
|
+
header = socket.read(8);
|
|
100
|
+
if (!header) {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
bodyLen = header.readInt32BE(4);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (bodyLen === 0) {
|
|
107
|
+
socket.write(header);
|
|
108
|
+
} else {
|
|
109
|
+
const body = socket.read(bodyLen);
|
|
110
|
+
if (!body) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
socket.write(Buffer.concat([ header, body ]));
|
|
114
|
+
}
|
|
115
|
+
bodyLen = null;
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
socket.on('readable', () => {
|
|
120
|
+
try {
|
|
121
|
+
let remaining = false;
|
|
122
|
+
do {
|
|
123
|
+
remaining = readPacket();
|
|
124
|
+
}
|
|
125
|
+
while (remaining);
|
|
126
|
+
} catch (err) {
|
|
127
|
+
console.error(err);
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
server.listen(8080);
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
[MIT](LICENSE)
|