ali-skills 0.0.21 → 0.0.22
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 +1214 -287
- 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,406 @@
|
|
|
1
|
+
/* eslint-disable node/no-deprecated-api */
|
|
2
|
+
|
|
3
|
+
'use strict'
|
|
4
|
+
|
|
5
|
+
var test = require('tape')
|
|
6
|
+
|
|
7
|
+
var buffer = require('buffer')
|
|
8
|
+
|
|
9
|
+
var index = require('./')
|
|
10
|
+
var safer = require('./safer')
|
|
11
|
+
var dangerous = require('./dangerous')
|
|
12
|
+
|
|
13
|
+
/* Inheritance tests */
|
|
14
|
+
|
|
15
|
+
test('Default is Safer', function (t) {
|
|
16
|
+
t.equal(index, safer)
|
|
17
|
+
t.notEqual(safer, dangerous)
|
|
18
|
+
t.notEqual(index, dangerous)
|
|
19
|
+
t.end()
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
test('Is not a function', function (t) {
|
|
23
|
+
[index, safer, dangerous].forEach(function (impl) {
|
|
24
|
+
t.equal(typeof impl, 'object')
|
|
25
|
+
t.equal(typeof impl.Buffer, 'object')
|
|
26
|
+
});
|
|
27
|
+
[buffer].forEach(function (impl) {
|
|
28
|
+
t.equal(typeof impl, 'object')
|
|
29
|
+
t.equal(typeof impl.Buffer, 'function')
|
|
30
|
+
})
|
|
31
|
+
t.end()
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
test('Constructor throws', function (t) {
|
|
35
|
+
[index, safer, dangerous].forEach(function (impl) {
|
|
36
|
+
t.throws(function () { impl.Buffer() })
|
|
37
|
+
t.throws(function () { impl.Buffer(0) })
|
|
38
|
+
t.throws(function () { impl.Buffer('a') })
|
|
39
|
+
t.throws(function () { impl.Buffer('a', 'utf-8') })
|
|
40
|
+
t.throws(function () { return new impl.Buffer() })
|
|
41
|
+
t.throws(function () { return new impl.Buffer(0) })
|
|
42
|
+
t.throws(function () { return new impl.Buffer('a') })
|
|
43
|
+
t.throws(function () { return new impl.Buffer('a', 'utf-8') })
|
|
44
|
+
})
|
|
45
|
+
t.end()
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
test('Safe methods exist', function (t) {
|
|
49
|
+
[index, safer, dangerous].forEach(function (impl) {
|
|
50
|
+
t.equal(typeof impl.Buffer.alloc, 'function', 'alloc')
|
|
51
|
+
t.equal(typeof impl.Buffer.from, 'function', 'from')
|
|
52
|
+
})
|
|
53
|
+
t.end()
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
test('Unsafe methods exist only in Dangerous', function (t) {
|
|
57
|
+
[index, safer].forEach(function (impl) {
|
|
58
|
+
t.equal(typeof impl.Buffer.allocUnsafe, 'undefined')
|
|
59
|
+
t.equal(typeof impl.Buffer.allocUnsafeSlow, 'undefined')
|
|
60
|
+
});
|
|
61
|
+
[dangerous].forEach(function (impl) {
|
|
62
|
+
t.equal(typeof impl.Buffer.allocUnsafe, 'function')
|
|
63
|
+
t.equal(typeof impl.Buffer.allocUnsafeSlow, 'function')
|
|
64
|
+
})
|
|
65
|
+
t.end()
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
test('Generic methods/properties are defined and equal', function (t) {
|
|
69
|
+
['poolSize', 'isBuffer', 'concat', 'byteLength'].forEach(function (method) {
|
|
70
|
+
[index, safer, dangerous].forEach(function (impl) {
|
|
71
|
+
t.equal(impl.Buffer[method], buffer.Buffer[method], method)
|
|
72
|
+
t.notEqual(typeof impl.Buffer[method], 'undefined', method)
|
|
73
|
+
})
|
|
74
|
+
})
|
|
75
|
+
t.end()
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
test('Built-in buffer static methods/properties are inherited', function (t) {
|
|
79
|
+
Object.keys(buffer).forEach(function (method) {
|
|
80
|
+
if (method === 'SlowBuffer' || method === 'Buffer') return;
|
|
81
|
+
[index, safer, dangerous].forEach(function (impl) {
|
|
82
|
+
t.equal(impl[method], buffer[method], method)
|
|
83
|
+
t.notEqual(typeof impl[method], 'undefined', method)
|
|
84
|
+
})
|
|
85
|
+
})
|
|
86
|
+
t.end()
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
test('Built-in Buffer static methods/properties are inherited', function (t) {
|
|
90
|
+
Object.keys(buffer.Buffer).forEach(function (method) {
|
|
91
|
+
if (method === 'allocUnsafe' || method === 'allocUnsafeSlow') return;
|
|
92
|
+
[index, safer, dangerous].forEach(function (impl) {
|
|
93
|
+
t.equal(impl.Buffer[method], buffer.Buffer[method], method)
|
|
94
|
+
t.notEqual(typeof impl.Buffer[method], 'undefined', method)
|
|
95
|
+
})
|
|
96
|
+
})
|
|
97
|
+
t.end()
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
test('.prototype property of Buffer is inherited', function (t) {
|
|
101
|
+
[index, safer, dangerous].forEach(function (impl) {
|
|
102
|
+
t.equal(impl.Buffer.prototype, buffer.Buffer.prototype, 'prototype')
|
|
103
|
+
t.notEqual(typeof impl.Buffer.prototype, 'undefined', 'prototype')
|
|
104
|
+
})
|
|
105
|
+
t.end()
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
test('All Safer methods are present in Dangerous', function (t) {
|
|
109
|
+
Object.keys(safer).forEach(function (method) {
|
|
110
|
+
if (method === 'Buffer') return;
|
|
111
|
+
[index, safer, dangerous].forEach(function (impl) {
|
|
112
|
+
t.equal(impl[method], safer[method], method)
|
|
113
|
+
if (method !== 'kStringMaxLength') {
|
|
114
|
+
t.notEqual(typeof impl[method], 'undefined', method)
|
|
115
|
+
}
|
|
116
|
+
})
|
|
117
|
+
})
|
|
118
|
+
Object.keys(safer.Buffer).forEach(function (method) {
|
|
119
|
+
[index, safer, dangerous].forEach(function (impl) {
|
|
120
|
+
t.equal(impl.Buffer[method], safer.Buffer[method], method)
|
|
121
|
+
t.notEqual(typeof impl.Buffer[method], 'undefined', method)
|
|
122
|
+
})
|
|
123
|
+
})
|
|
124
|
+
t.end()
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
test('Safe methods from Dangerous methods are present in Safer', function (t) {
|
|
128
|
+
Object.keys(dangerous).forEach(function (method) {
|
|
129
|
+
if (method === 'Buffer') return;
|
|
130
|
+
[index, safer, dangerous].forEach(function (impl) {
|
|
131
|
+
t.equal(impl[method], dangerous[method], method)
|
|
132
|
+
if (method !== 'kStringMaxLength') {
|
|
133
|
+
t.notEqual(typeof impl[method], 'undefined', method)
|
|
134
|
+
}
|
|
135
|
+
})
|
|
136
|
+
})
|
|
137
|
+
Object.keys(dangerous.Buffer).forEach(function (method) {
|
|
138
|
+
if (method === 'allocUnsafe' || method === 'allocUnsafeSlow') return;
|
|
139
|
+
[index, safer, dangerous].forEach(function (impl) {
|
|
140
|
+
t.equal(impl.Buffer[method], dangerous.Buffer[method], method)
|
|
141
|
+
t.notEqual(typeof impl.Buffer[method], 'undefined', method)
|
|
142
|
+
})
|
|
143
|
+
})
|
|
144
|
+
t.end()
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
/* Behaviour tests */
|
|
148
|
+
|
|
149
|
+
test('Methods return Buffers', function (t) {
|
|
150
|
+
[index, safer, dangerous].forEach(function (impl) {
|
|
151
|
+
t.ok(buffer.Buffer.isBuffer(impl.Buffer.alloc(0)))
|
|
152
|
+
t.ok(buffer.Buffer.isBuffer(impl.Buffer.alloc(0, 10)))
|
|
153
|
+
t.ok(buffer.Buffer.isBuffer(impl.Buffer.alloc(0, 'a')))
|
|
154
|
+
t.ok(buffer.Buffer.isBuffer(impl.Buffer.alloc(10)))
|
|
155
|
+
t.ok(buffer.Buffer.isBuffer(impl.Buffer.alloc(10, 'x')))
|
|
156
|
+
t.ok(buffer.Buffer.isBuffer(impl.Buffer.alloc(9, 'ab')))
|
|
157
|
+
t.ok(buffer.Buffer.isBuffer(impl.Buffer.from('')))
|
|
158
|
+
t.ok(buffer.Buffer.isBuffer(impl.Buffer.from('string')))
|
|
159
|
+
t.ok(buffer.Buffer.isBuffer(impl.Buffer.from('string', 'utf-8')))
|
|
160
|
+
t.ok(buffer.Buffer.isBuffer(impl.Buffer.from('b25ldHdvdGhyZWU=', 'base64')))
|
|
161
|
+
t.ok(buffer.Buffer.isBuffer(impl.Buffer.from([0, 42, 3])))
|
|
162
|
+
t.ok(buffer.Buffer.isBuffer(impl.Buffer.from(new Uint8Array([0, 42, 3]))))
|
|
163
|
+
t.ok(buffer.Buffer.isBuffer(impl.Buffer.from([])))
|
|
164
|
+
});
|
|
165
|
+
['allocUnsafe', 'allocUnsafeSlow'].forEach(function (method) {
|
|
166
|
+
t.ok(buffer.Buffer.isBuffer(dangerous.Buffer[method](0)))
|
|
167
|
+
t.ok(buffer.Buffer.isBuffer(dangerous.Buffer[method](10)))
|
|
168
|
+
})
|
|
169
|
+
t.end()
|
|
170
|
+
})
|
|
171
|
+
|
|
172
|
+
test('Constructor is buffer.Buffer', function (t) {
|
|
173
|
+
[index, safer, dangerous].forEach(function (impl) {
|
|
174
|
+
t.equal(impl.Buffer.alloc(0).constructor, buffer.Buffer)
|
|
175
|
+
t.equal(impl.Buffer.alloc(0, 10).constructor, buffer.Buffer)
|
|
176
|
+
t.equal(impl.Buffer.alloc(0, 'a').constructor, buffer.Buffer)
|
|
177
|
+
t.equal(impl.Buffer.alloc(10).constructor, buffer.Buffer)
|
|
178
|
+
t.equal(impl.Buffer.alloc(10, 'x').constructor, buffer.Buffer)
|
|
179
|
+
t.equal(impl.Buffer.alloc(9, 'ab').constructor, buffer.Buffer)
|
|
180
|
+
t.equal(impl.Buffer.from('').constructor, buffer.Buffer)
|
|
181
|
+
t.equal(impl.Buffer.from('string').constructor, buffer.Buffer)
|
|
182
|
+
t.equal(impl.Buffer.from('string', 'utf-8').constructor, buffer.Buffer)
|
|
183
|
+
t.equal(impl.Buffer.from('b25ldHdvdGhyZWU=', 'base64').constructor, buffer.Buffer)
|
|
184
|
+
t.equal(impl.Buffer.from([0, 42, 3]).constructor, buffer.Buffer)
|
|
185
|
+
t.equal(impl.Buffer.from(new Uint8Array([0, 42, 3])).constructor, buffer.Buffer)
|
|
186
|
+
t.equal(impl.Buffer.from([]).constructor, buffer.Buffer)
|
|
187
|
+
});
|
|
188
|
+
[0, 10, 100].forEach(function (arg) {
|
|
189
|
+
t.equal(dangerous.Buffer.allocUnsafe(arg).constructor, buffer.Buffer)
|
|
190
|
+
t.equal(dangerous.Buffer.allocUnsafeSlow(arg).constructor, buffer.SlowBuffer(0).constructor)
|
|
191
|
+
})
|
|
192
|
+
t.end()
|
|
193
|
+
})
|
|
194
|
+
|
|
195
|
+
test('Invalid calls throw', function (t) {
|
|
196
|
+
[index, safer, dangerous].forEach(function (impl) {
|
|
197
|
+
t.throws(function () { impl.Buffer.from(0) })
|
|
198
|
+
t.throws(function () { impl.Buffer.from(10) })
|
|
199
|
+
t.throws(function () { impl.Buffer.from(10, 'utf-8') })
|
|
200
|
+
t.throws(function () { impl.Buffer.from('string', 'invalid encoding') })
|
|
201
|
+
t.throws(function () { impl.Buffer.from(-10) })
|
|
202
|
+
t.throws(function () { impl.Buffer.from(1e90) })
|
|
203
|
+
t.throws(function () { impl.Buffer.from(Infinity) })
|
|
204
|
+
t.throws(function () { impl.Buffer.from(-Infinity) })
|
|
205
|
+
t.throws(function () { impl.Buffer.from(NaN) })
|
|
206
|
+
t.throws(function () { impl.Buffer.from(null) })
|
|
207
|
+
t.throws(function () { impl.Buffer.from(undefined) })
|
|
208
|
+
t.throws(function () { impl.Buffer.from() })
|
|
209
|
+
t.throws(function () { impl.Buffer.from({}) })
|
|
210
|
+
t.throws(function () { impl.Buffer.alloc('') })
|
|
211
|
+
t.throws(function () { impl.Buffer.alloc('string') })
|
|
212
|
+
t.throws(function () { impl.Buffer.alloc('string', 'utf-8') })
|
|
213
|
+
t.throws(function () { impl.Buffer.alloc('b25ldHdvdGhyZWU=', 'base64') })
|
|
214
|
+
t.throws(function () { impl.Buffer.alloc(-10) })
|
|
215
|
+
t.throws(function () { impl.Buffer.alloc(1e90) })
|
|
216
|
+
t.throws(function () { impl.Buffer.alloc(2 * (1 << 30)) })
|
|
217
|
+
t.throws(function () { impl.Buffer.alloc(Infinity) })
|
|
218
|
+
t.throws(function () { impl.Buffer.alloc(-Infinity) })
|
|
219
|
+
t.throws(function () { impl.Buffer.alloc(null) })
|
|
220
|
+
t.throws(function () { impl.Buffer.alloc(undefined) })
|
|
221
|
+
t.throws(function () { impl.Buffer.alloc() })
|
|
222
|
+
t.throws(function () { impl.Buffer.alloc([]) })
|
|
223
|
+
t.throws(function () { impl.Buffer.alloc([0, 42, 3]) })
|
|
224
|
+
t.throws(function () { impl.Buffer.alloc({}) })
|
|
225
|
+
});
|
|
226
|
+
['allocUnsafe', 'allocUnsafeSlow'].forEach(function (method) {
|
|
227
|
+
t.throws(function () { dangerous.Buffer[method]('') })
|
|
228
|
+
t.throws(function () { dangerous.Buffer[method]('string') })
|
|
229
|
+
t.throws(function () { dangerous.Buffer[method]('string', 'utf-8') })
|
|
230
|
+
t.throws(function () { dangerous.Buffer[method](2 * (1 << 30)) })
|
|
231
|
+
t.throws(function () { dangerous.Buffer[method](Infinity) })
|
|
232
|
+
if (dangerous.Buffer[method] === buffer.Buffer.allocUnsafe) {
|
|
233
|
+
t.skip('Skipping, older impl of allocUnsafe coerced negative sizes to 0')
|
|
234
|
+
} else {
|
|
235
|
+
t.throws(function () { dangerous.Buffer[method](-10) })
|
|
236
|
+
t.throws(function () { dangerous.Buffer[method](-1e90) })
|
|
237
|
+
t.throws(function () { dangerous.Buffer[method](-Infinity) })
|
|
238
|
+
}
|
|
239
|
+
t.throws(function () { dangerous.Buffer[method](null) })
|
|
240
|
+
t.throws(function () { dangerous.Buffer[method](undefined) })
|
|
241
|
+
t.throws(function () { dangerous.Buffer[method]() })
|
|
242
|
+
t.throws(function () { dangerous.Buffer[method]([]) })
|
|
243
|
+
t.throws(function () { dangerous.Buffer[method]([0, 42, 3]) })
|
|
244
|
+
t.throws(function () { dangerous.Buffer[method]({}) })
|
|
245
|
+
})
|
|
246
|
+
t.end()
|
|
247
|
+
})
|
|
248
|
+
|
|
249
|
+
test('Buffers have appropriate lengths', function (t) {
|
|
250
|
+
[index, safer, dangerous].forEach(function (impl) {
|
|
251
|
+
t.equal(impl.Buffer.alloc(0).length, 0)
|
|
252
|
+
t.equal(impl.Buffer.alloc(10).length, 10)
|
|
253
|
+
t.equal(impl.Buffer.from('').length, 0)
|
|
254
|
+
t.equal(impl.Buffer.from('string').length, 6)
|
|
255
|
+
t.equal(impl.Buffer.from('string', 'utf-8').length, 6)
|
|
256
|
+
t.equal(impl.Buffer.from('b25ldHdvdGhyZWU=', 'base64').length, 11)
|
|
257
|
+
t.equal(impl.Buffer.from([0, 42, 3]).length, 3)
|
|
258
|
+
t.equal(impl.Buffer.from(new Uint8Array([0, 42, 3])).length, 3)
|
|
259
|
+
t.equal(impl.Buffer.from([]).length, 0)
|
|
260
|
+
});
|
|
261
|
+
['allocUnsafe', 'allocUnsafeSlow'].forEach(function (method) {
|
|
262
|
+
t.equal(dangerous.Buffer[method](0).length, 0)
|
|
263
|
+
t.equal(dangerous.Buffer[method](10).length, 10)
|
|
264
|
+
})
|
|
265
|
+
t.end()
|
|
266
|
+
})
|
|
267
|
+
|
|
268
|
+
test('Buffers have appropriate lengths (2)', function (t) {
|
|
269
|
+
t.equal(index.Buffer.alloc, safer.Buffer.alloc)
|
|
270
|
+
t.equal(index.Buffer.alloc, dangerous.Buffer.alloc)
|
|
271
|
+
var ok = true;
|
|
272
|
+
[ safer.Buffer.alloc,
|
|
273
|
+
dangerous.Buffer.allocUnsafe,
|
|
274
|
+
dangerous.Buffer.allocUnsafeSlow
|
|
275
|
+
].forEach(function (method) {
|
|
276
|
+
for (var i = 0; i < 1e2; i++) {
|
|
277
|
+
var length = Math.round(Math.random() * 1e5)
|
|
278
|
+
var buf = method(length)
|
|
279
|
+
if (!buffer.Buffer.isBuffer(buf)) ok = false
|
|
280
|
+
if (buf.length !== length) ok = false
|
|
281
|
+
}
|
|
282
|
+
})
|
|
283
|
+
t.ok(ok)
|
|
284
|
+
t.end()
|
|
285
|
+
})
|
|
286
|
+
|
|
287
|
+
test('.alloc(size) is zero-filled and has correct length', function (t) {
|
|
288
|
+
t.equal(index.Buffer.alloc, safer.Buffer.alloc)
|
|
289
|
+
t.equal(index.Buffer.alloc, dangerous.Buffer.alloc)
|
|
290
|
+
var ok = true
|
|
291
|
+
for (var i = 0; i < 1e2; i++) {
|
|
292
|
+
var length = Math.round(Math.random() * 2e6)
|
|
293
|
+
var buf = index.Buffer.alloc(length)
|
|
294
|
+
if (!buffer.Buffer.isBuffer(buf)) ok = false
|
|
295
|
+
if (buf.length !== length) ok = false
|
|
296
|
+
var j
|
|
297
|
+
for (j = 0; j < length; j++) {
|
|
298
|
+
if (buf[j] !== 0) ok = false
|
|
299
|
+
}
|
|
300
|
+
buf.fill(1)
|
|
301
|
+
for (j = 0; j < length; j++) {
|
|
302
|
+
if (buf[j] !== 1) ok = false
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
t.ok(ok)
|
|
306
|
+
t.end()
|
|
307
|
+
})
|
|
308
|
+
|
|
309
|
+
test('.allocUnsafe / .allocUnsafeSlow are fillable and have correct lengths', function (t) {
|
|
310
|
+
['allocUnsafe', 'allocUnsafeSlow'].forEach(function (method) {
|
|
311
|
+
var ok = true
|
|
312
|
+
for (var i = 0; i < 1e2; i++) {
|
|
313
|
+
var length = Math.round(Math.random() * 2e6)
|
|
314
|
+
var buf = dangerous.Buffer[method](length)
|
|
315
|
+
if (!buffer.Buffer.isBuffer(buf)) ok = false
|
|
316
|
+
if (buf.length !== length) ok = false
|
|
317
|
+
buf.fill(0, 0, length)
|
|
318
|
+
var j
|
|
319
|
+
for (j = 0; j < length; j++) {
|
|
320
|
+
if (buf[j] !== 0) ok = false
|
|
321
|
+
}
|
|
322
|
+
buf.fill(1, 0, length)
|
|
323
|
+
for (j = 0; j < length; j++) {
|
|
324
|
+
if (buf[j] !== 1) ok = false
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
t.ok(ok, method)
|
|
328
|
+
})
|
|
329
|
+
t.end()
|
|
330
|
+
})
|
|
331
|
+
|
|
332
|
+
test('.alloc(size, fill) is `fill`-filled', function (t) {
|
|
333
|
+
t.equal(index.Buffer.alloc, safer.Buffer.alloc)
|
|
334
|
+
t.equal(index.Buffer.alloc, dangerous.Buffer.alloc)
|
|
335
|
+
var ok = true
|
|
336
|
+
for (var i = 0; i < 1e2; i++) {
|
|
337
|
+
var length = Math.round(Math.random() * 2e6)
|
|
338
|
+
var fill = Math.round(Math.random() * 255)
|
|
339
|
+
var buf = index.Buffer.alloc(length, fill)
|
|
340
|
+
if (!buffer.Buffer.isBuffer(buf)) ok = false
|
|
341
|
+
if (buf.length !== length) ok = false
|
|
342
|
+
for (var j = 0; j < length; j++) {
|
|
343
|
+
if (buf[j] !== fill) ok = false
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
t.ok(ok)
|
|
347
|
+
t.end()
|
|
348
|
+
})
|
|
349
|
+
|
|
350
|
+
test('.alloc(size, fill) is `fill`-filled', function (t) {
|
|
351
|
+
t.equal(index.Buffer.alloc, safer.Buffer.alloc)
|
|
352
|
+
t.equal(index.Buffer.alloc, dangerous.Buffer.alloc)
|
|
353
|
+
var ok = true
|
|
354
|
+
for (var i = 0; i < 1e2; i++) {
|
|
355
|
+
var length = Math.round(Math.random() * 2e6)
|
|
356
|
+
var fill = Math.round(Math.random() * 255)
|
|
357
|
+
var buf = index.Buffer.alloc(length, fill)
|
|
358
|
+
if (!buffer.Buffer.isBuffer(buf)) ok = false
|
|
359
|
+
if (buf.length !== length) ok = false
|
|
360
|
+
for (var j = 0; j < length; j++) {
|
|
361
|
+
if (buf[j] !== fill) ok = false
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
t.ok(ok)
|
|
365
|
+
t.deepEqual(index.Buffer.alloc(9, 'a'), index.Buffer.alloc(9, 97))
|
|
366
|
+
t.notDeepEqual(index.Buffer.alloc(9, 'a'), index.Buffer.alloc(9, 98))
|
|
367
|
+
|
|
368
|
+
var tmp = new buffer.Buffer(2)
|
|
369
|
+
tmp.fill('ok')
|
|
370
|
+
if (tmp[1] === tmp[0]) {
|
|
371
|
+
// Outdated Node.js
|
|
372
|
+
t.deepEqual(index.Buffer.alloc(5, 'ok'), index.Buffer.from('ooooo'))
|
|
373
|
+
} else {
|
|
374
|
+
t.deepEqual(index.Buffer.alloc(5, 'ok'), index.Buffer.from('okoko'))
|
|
375
|
+
}
|
|
376
|
+
t.notDeepEqual(index.Buffer.alloc(5, 'ok'), index.Buffer.from('kokok'))
|
|
377
|
+
|
|
378
|
+
t.end()
|
|
379
|
+
})
|
|
380
|
+
|
|
381
|
+
test('safer.Buffer.from returns results same as Buffer constructor', function (t) {
|
|
382
|
+
[index, safer, dangerous].forEach(function (impl) {
|
|
383
|
+
t.deepEqual(impl.Buffer.from(''), new buffer.Buffer(''))
|
|
384
|
+
t.deepEqual(impl.Buffer.from('string'), new buffer.Buffer('string'))
|
|
385
|
+
t.deepEqual(impl.Buffer.from('string', 'utf-8'), new buffer.Buffer('string', 'utf-8'))
|
|
386
|
+
t.deepEqual(impl.Buffer.from('b25ldHdvdGhyZWU=', 'base64'), new buffer.Buffer('b25ldHdvdGhyZWU=', 'base64'))
|
|
387
|
+
t.deepEqual(impl.Buffer.from([0, 42, 3]), new buffer.Buffer([0, 42, 3]))
|
|
388
|
+
t.deepEqual(impl.Buffer.from(new Uint8Array([0, 42, 3])), new buffer.Buffer(new Uint8Array([0, 42, 3])))
|
|
389
|
+
t.deepEqual(impl.Buffer.from([]), new buffer.Buffer([]))
|
|
390
|
+
})
|
|
391
|
+
t.end()
|
|
392
|
+
})
|
|
393
|
+
|
|
394
|
+
test('safer.Buffer.from returns consistent results', function (t) {
|
|
395
|
+
[index, safer, dangerous].forEach(function (impl) {
|
|
396
|
+
t.deepEqual(impl.Buffer.from(''), impl.Buffer.alloc(0))
|
|
397
|
+
t.deepEqual(impl.Buffer.from([]), impl.Buffer.alloc(0))
|
|
398
|
+
t.deepEqual(impl.Buffer.from(new Uint8Array([])), impl.Buffer.alloc(0))
|
|
399
|
+
t.deepEqual(impl.Buffer.from('string', 'utf-8'), impl.Buffer.from('string'))
|
|
400
|
+
t.deepEqual(impl.Buffer.from('string'), impl.Buffer.from([115, 116, 114, 105, 110, 103]))
|
|
401
|
+
t.deepEqual(impl.Buffer.from('string'), impl.Buffer.from(impl.Buffer.from('string')))
|
|
402
|
+
t.deepEqual(impl.Buffer.from('b25ldHdvdGhyZWU=', 'base64'), impl.Buffer.from('onetwothree'))
|
|
403
|
+
t.notDeepEqual(impl.Buffer.from('b25ldHdvdGhyZWU='), impl.Buffer.from('onetwothree'))
|
|
404
|
+
})
|
|
405
|
+
t.end()
|
|
406
|
+
})
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 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,165 @@
|
|
|
1
|
+
sdk-base
|
|
2
|
+
---------------
|
|
3
|
+
|
|
4
|
+
[![NPM version][npm-image]][npm-url]
|
|
5
|
+
[](https://github.com/node-modules/sdk-base/actions/workflows/nodejs.yml)
|
|
6
|
+
[![Test coverage][coveralls-image]][coveralls-url]
|
|
7
|
+
[![npm download][download-image]][download-url]
|
|
8
|
+
|
|
9
|
+
[npm-image]: https://img.shields.io/npm/v/sdk-base.svg?style=flat-square
|
|
10
|
+
[npm-url]: https://npmjs.org/package/sdk-base
|
|
11
|
+
[coveralls-image]: https://img.shields.io/coveralls/node-modules/sdk-base.svg?style=flat-square
|
|
12
|
+
[coveralls-url]: https://coveralls.io/r/node-modules/sdk-base?branch=master
|
|
13
|
+
[download-image]: https://img.shields.io/npm/dm/sdk-base.svg?style=flat-square
|
|
14
|
+
[download-url]: https://npmjs.org/package/sdk-base
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
A base class for sdk with some common & useful functions.
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
$ npm install sdk-base
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
Constructor argument:
|
|
28
|
+
- {Object} options
|
|
29
|
+
- {String} [initMethod] - the async init method name, the method should be a function return promise. If set, will execute the function in the constructor.
|
|
30
|
+
- {AsyncLocalStorage} [localStorage] - async localStorage instance.
|
|
31
|
+
|
|
32
|
+
```js
|
|
33
|
+
const Base = require('sdk-base');
|
|
34
|
+
|
|
35
|
+
class Client extends Base {
|
|
36
|
+
constructor() {
|
|
37
|
+
super({
|
|
38
|
+
initMethod: 'init',
|
|
39
|
+
localStorage: app.ctxStorage,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async init() {
|
|
44
|
+
// put your async init logic here
|
|
45
|
+
}
|
|
46
|
+
// support async function too
|
|
47
|
+
// async init() {
|
|
48
|
+
// // put your async init logic here
|
|
49
|
+
// }
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
(async function main() {
|
|
53
|
+
const client = new Client();
|
|
54
|
+
// wait client ready, if init failed, client will throw an error.
|
|
55
|
+
await client.ready();
|
|
56
|
+
|
|
57
|
+
// support async event listener
|
|
58
|
+
client.on('data', async function (data) {
|
|
59
|
+
// put your async process logic here
|
|
60
|
+
//
|
|
61
|
+
// @example
|
|
62
|
+
// ----------
|
|
63
|
+
// await submit(data);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
client.emit('data', { foo: 'bar' });
|
|
67
|
+
|
|
68
|
+
})().catch(err => { console.error(err); });
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### API
|
|
72
|
+
|
|
73
|
+
- `.ready(flagOrFunction)` flagOrFunction is optional, and the argument type can be Boolean, Error or Function.
|
|
74
|
+
|
|
75
|
+
```js
|
|
76
|
+
// init ready
|
|
77
|
+
client.ready(true);
|
|
78
|
+
// init failed
|
|
79
|
+
client.ready(new Error('init failed'));
|
|
80
|
+
|
|
81
|
+
// listen client ready
|
|
82
|
+
client.ready(err => {
|
|
83
|
+
if (err) {
|
|
84
|
+
console.log('client init failed');
|
|
85
|
+
console.error(err);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
console.log('client is ready');
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
// support promise style call
|
|
92
|
+
client.ready()
|
|
93
|
+
.then(() => { ... })
|
|
94
|
+
.catch(err => { ... });
|
|
95
|
+
|
|
96
|
+
// support async function style call
|
|
97
|
+
await client.ready();
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
- `async readyOrTimeout(milliseconds)` ready or timeout, after milliseconds not ready will throw TimeoutError
|
|
101
|
+
|
|
102
|
+
```js
|
|
103
|
+
await client.readyOrTimeout(100);
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
- `.isReady getter` detect client start ready or not.
|
|
107
|
+
- `.on(event, listener)` wrap the [EventEmitter.prototype.on(event, listener)](https://nodejs.org/api/events.html#events_emitter_on_eventname_listener), the only difference is to support adding async function listener on events, except 'error' event.
|
|
108
|
+
- `once(event, listener)` wrap the [EventEmitter.prototype.once(event, listener)](https://nodejs.org/api/events.html#events_emitter_once_eventname_listener), the only difference is to support adding async function listener on events, except 'error' event.
|
|
109
|
+
- `prependListener(event, listener)` wrap the [EventEmitter.prototype.prependListener(event, listener)](https://nodejs.org/api/events.html#events_emitter_prependlistener_eventname_listener), the only difference is to support adding async function listener on events, except 'error' event.
|
|
110
|
+
- `prependOnceListener(event, listener)` wrap the [EventEmitter.prototype.prependOnceListener(event, listener)](https://nodejs.org/api/events.html#events_emitter_prependoncelistener_eventname_listener), the only difference is to support adding generator listener on events, except 'error' event.
|
|
111
|
+
- `addListener(event, listener)` wrap the [EventEmitter.prototype.addListener(event, listener)](https://nodejs.org/api/events.html#events_emitter_addlistener_eventname_listener), the only difference is to support adding async function listener on events, except 'error' event.
|
|
112
|
+
|
|
113
|
+
```js
|
|
114
|
+
client.on('data', async function(data) {
|
|
115
|
+
// your async process logic here
|
|
116
|
+
});
|
|
117
|
+
client.once('foo', async function(bar) {
|
|
118
|
+
// ...
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
// listen error event
|
|
122
|
+
client.on('error', err => {
|
|
123
|
+
console.error(err.stack);
|
|
124
|
+
});
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
- `.await(event)`: [await an event](https://github.com/cojs/await-event), return a promise, and it will resolve(reject if event is `error`) once this event emmited.
|
|
128
|
+
|
|
129
|
+
```js
|
|
130
|
+
const data = await client.await('data');
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
- `.awaitFirst(event)`: [await the first event in a set of event pairs](https://github.com/node-modules/await-first), return a promise, and it will clean up after itself.
|
|
134
|
+
|
|
135
|
+
```js
|
|
136
|
+
(async function main() {
|
|
137
|
+
const o = await client.awaitFirst([ 'foo', 'bar' ]);
|
|
138
|
+
if (o.event === 'foo') {
|
|
139
|
+
// ...
|
|
140
|
+
}
|
|
141
|
+
if (o.event === 'bar') {
|
|
142
|
+
// ...
|
|
143
|
+
}
|
|
144
|
+
})();
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
- `._close()`: The `_close()` method is called by `close`, It can be overridden by child class, but should not be called directly. It must return promise or generator.
|
|
148
|
+
|
|
149
|
+
- `.close()`: The `close()` method is used to close the instance.
|
|
150
|
+
|
|
151
|
+
### License
|
|
152
|
+
|
|
153
|
+
[MIT](LICENSE)
|
|
154
|
+
|
|
155
|
+
<!-- GITCONTRIBUTOR_START -->
|
|
156
|
+
|
|
157
|
+
## Contributors
|
|
158
|
+
|
|
159
|
+
|[<img src="https://avatars.githubusercontent.com/u/985607?v=4" width="100px;"/><br/><sub><b>dead-horse</b></sub>](https://github.com/dead-horse)<br/>|[<img src="https://avatars.githubusercontent.com/u/156269?v=4" width="100px;"/><br/><sub><b>fengmk2</b></sub>](https://github.com/fengmk2)<br/>|[<img src="https://avatars.githubusercontent.com/u/1207064?v=4" width="100px;"/><br/><sub><b>gxcsoccer</b></sub>](https://github.com/gxcsoccer)<br/>|[<img src="https://avatars.githubusercontent.com/u/360661?v=4" width="100px;"/><br/><sub><b>popomore</b></sub>](https://github.com/popomore)<br/>|[<img src="https://avatars.githubusercontent.com/u/2039144?v=4" width="100px;"/><br/><sub><b>sang4lv</b></sub>](https://github.com/sang4lv)<br/>|[<img src="https://avatars.githubusercontent.com/u/1474688?v=4" width="100px;"/><br/><sub><b>luckydrq</b></sub>](https://github.com/luckydrq)<br/>|
|
|
160
|
+
| :---: | :---: | :---: | :---: | :---: | :---: |
|
|
161
|
+
[<img src="https://avatars.githubusercontent.com/u/12656301?v=4" width="100px;"/><br/><sub><b>brizer</b></sub>](https://github.com/brizer)<br/>|[<img src="https://avatars.githubusercontent.com/u/6897780?v=4" width="100px;"/><br/><sub><b>killagu</b></sub>](https://github.com/killagu)<br/>
|
|
162
|
+
|
|
163
|
+
This project follows the git-contributor [spec](https://github.com/xudafeng/git-contributor), auto updated at `Sat Dec 03 2022 16:27:57 GMT+0800`.
|
|
164
|
+
|
|
165
|
+
<!-- GITCONTRIBUTOR_END -->
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/* =================== USAGE ===================
|
|
2
|
+
import Base from "sdk-base";
|
|
3
|
+
class newSDK extends Base {}
|
|
4
|
+
class newSDK extends Base<FooContext> {}
|
|
5
|
+
=============================================== */
|
|
6
|
+
|
|
7
|
+
import { EventEmitter } from 'events';
|
|
8
|
+
import { AsyncLocalStorage } from 'async_hooks';
|
|
9
|
+
|
|
10
|
+
export interface BaseOptions {
|
|
11
|
+
initMethod?: string;
|
|
12
|
+
localStorage?: any;
|
|
13
|
+
[key: string]: any;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default class Base<TContext = any> extends EventEmitter {
|
|
17
|
+
constructor(option?: BaseOptions);
|
|
18
|
+
|
|
19
|
+
isReady: boolean;
|
|
20
|
+
options: BaseOptions;
|
|
21
|
+
localStorage?: AsyncLocalStorage<TContext>;
|
|
22
|
+
await(...args: any[]): Promise<any>;
|
|
23
|
+
awaitFirst(...args: any[]): Promise<any>;
|
|
24
|
+
ready(): Promise<any>;
|
|
25
|
+
ready(err: Error): void;
|
|
26
|
+
ready(ready: boolean): void;
|
|
27
|
+
ready(readyCallback: Function): void;
|
|
28
|
+
readyOrTimeout(milliseconds: number): Promise<void>;
|
|
29
|
+
}
|