@ohos-ports/stdlib-process-read-stdin 0.0.0-stage → 0.2.3-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +177 -0
- package/NOTICE +1 -0
- package/README.md +242 -2
- package/SECURITY.md +5 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +7 -0
- package/docs/types/index.d.ts +108 -0
- package/lib/browser.js +66 -0
- package/lib/index.js +47 -0
- package/lib/main.js +159 -0
- package/node_modules/@stdlib/assert-has-node-buffer-support/LICENSE +177 -0
- package/node_modules/@stdlib/assert-has-node-buffer-support/NOTICE +1 -0
- package/node_modules/@stdlib/assert-has-node-buffer-support/README.md +187 -0
- package/node_modules/@stdlib/assert-has-node-buffer-support/SECURITY.md +5 -0
- package/node_modules/@stdlib/assert-has-node-buffer-support/dist/index.d.ts +3 -0
- package/node_modules/@stdlib/assert-has-node-buffer-support/dist/index.js +7 -0
- package/node_modules/@stdlib/assert-has-node-buffer-support/dist/index.js.map +7 -0
- package/node_modules/@stdlib/assert-has-node-buffer-support/docs/types/index.d.ts +35 -0
- package/node_modules/@stdlib/assert-has-node-buffer-support/lib/buffer.js +28 -0
- package/node_modules/@stdlib/assert-has-node-buffer-support/lib/index.js +40 -0
- package/node_modules/@stdlib/assert-has-node-buffer-support/lib/main.js +68 -0
- package/node_modules/@stdlib/assert-has-node-buffer-support/package.json +76 -0
- package/node_modules/@stdlib/assert-has-own-property/LICENSE +177 -0
- package/node_modules/@stdlib/assert-has-own-property/NOTICE +1 -0
- package/node_modules/@stdlib/assert-has-own-property/README.md +263 -0
- package/node_modules/@stdlib/assert-has-own-property/SECURITY.md +5 -0
- package/node_modules/@stdlib/assert-has-own-property/dist/index.d.ts +3 -0
- package/node_modules/@stdlib/assert-has-own-property/dist/index.js +5 -0
- package/node_modules/@stdlib/assert-has-own-property/dist/index.js.map +7 -0
- package/node_modules/@stdlib/assert-has-own-property/docs/types/index.d.ts +49 -0
- package/node_modules/@stdlib/assert-has-own-property/lib/index.js +47 -0
- package/node_modules/@stdlib/assert-has-own-property/lib/main.js +64 -0
- package/node_modules/@stdlib/assert-has-own-property/package.json +74 -0
- package/node_modules/@stdlib/assert-has-symbol-support/LICENSE +177 -0
- package/node_modules/@stdlib/assert-has-symbol-support/NOTICE +1 -0
- package/node_modules/@stdlib/assert-has-symbol-support/README.md +193 -0
- package/node_modules/@stdlib/assert-has-symbol-support/SECURITY.md +5 -0
- package/node_modules/@stdlib/assert-has-symbol-support/dist/index.d.ts +3 -0
- package/node_modules/@stdlib/assert-has-symbol-support/dist/index.js +5 -0
- package/node_modules/@stdlib/assert-has-symbol-support/dist/index.js.map +7 -0
- package/node_modules/@stdlib/assert-has-symbol-support/docs/types/index.d.ts +35 -0
- package/node_modules/@stdlib/assert-has-symbol-support/lib/index.js +40 -0
- package/node_modules/@stdlib/assert-has-symbol-support/lib/main.js +42 -0
- package/node_modules/@stdlib/assert-has-symbol-support/package.json +73 -0
- package/node_modules/@stdlib/assert-has-tostringtag-support/LICENSE +177 -0
- package/node_modules/@stdlib/assert-has-tostringtag-support/NOTICE +1 -0
- package/node_modules/@stdlib/assert-has-tostringtag-support/README.md +187 -0
- package/node_modules/@stdlib/assert-has-tostringtag-support/SECURITY.md +5 -0
- package/node_modules/@stdlib/assert-has-tostringtag-support/dist/index.d.ts +3 -0
- package/node_modules/@stdlib/assert-has-tostringtag-support/dist/index.js +5 -0
- package/node_modules/@stdlib/assert-has-tostringtag-support/dist/index.js.map +7 -0
- package/node_modules/@stdlib/assert-has-tostringtag-support/docs/types/index.d.ts +35 -0
- package/node_modules/@stdlib/assert-has-tostringtag-support/lib/index.js +40 -0
- package/node_modules/@stdlib/assert-has-tostringtag-support/lib/main.js +49 -0
- package/node_modules/@stdlib/assert-has-tostringtag-support/package.json +79 -0
- package/node_modules/@stdlib/assert-is-array/LICENSE +177 -0
- package/node_modules/@stdlib/assert-is-array/NOTICE +1 -0
- package/node_modules/@stdlib/assert-is-array/README.md +183 -0
- package/node_modules/@stdlib/assert-is-array/SECURITY.md +5 -0
- package/node_modules/@stdlib/assert-is-array/dist/index.d.ts +3 -0
- package/node_modules/@stdlib/assert-is-array/dist/index.js +5 -0
- package/node_modules/@stdlib/assert-is-array/dist/index.js.map +7 -0
- package/node_modules/@stdlib/assert-is-array/docs/types/index.d.ts +40 -0
- package/node_modules/@stdlib/assert-is-array/lib/index.js +43 -0
- package/node_modules/@stdlib/assert-is-array/lib/main.js +63 -0
- package/node_modules/@stdlib/assert-is-array/package.json +72 -0
- package/node_modules/@stdlib/assert-is-boolean/LICENSE +177 -0
- package/node_modules/@stdlib/assert-is-boolean/NOTICE +1 -0
- package/node_modules/@stdlib/assert-is-boolean/README.md +228 -0
- package/node_modules/@stdlib/assert-is-boolean/SECURITY.md +5 -0
- package/node_modules/@stdlib/assert-is-boolean/dist/index.d.ts +3 -0
- package/node_modules/@stdlib/assert-is-boolean/dist/index.js +13 -0
- package/node_modules/@stdlib/assert-is-boolean/dist/index.js.map +7 -0
- package/node_modules/@stdlib/assert-is-boolean/docs/types/index.d.ts +125 -0
- package/node_modules/@stdlib/assert-is-boolean/lib/index.js +73 -0
- package/node_modules/@stdlib/assert-is-boolean/lib/main.js +62 -0
- package/node_modules/@stdlib/assert-is-boolean/lib/object.js +68 -0
- package/node_modules/@stdlib/assert-is-boolean/lib/primitive.js +48 -0
- package/node_modules/@stdlib/assert-is-boolean/lib/tostring.js +27 -0
- package/node_modules/@stdlib/assert-is-boolean/lib/try2serialize.js +47 -0
- package/node_modules/@stdlib/assert-is-boolean/package.json +80 -0
- package/node_modules/@stdlib/assert-is-buffer/LICENSE +177 -0
- package/node_modules/@stdlib/assert-is-buffer/NOTICE +1 -0
- package/node_modules/@stdlib/assert-is-buffer/README.md +223 -0
- package/node_modules/@stdlib/assert-is-buffer/SECURITY.md +5 -0
- package/node_modules/@stdlib/assert-is-buffer/dist/index.d.ts +3 -0
- package/node_modules/@stdlib/assert-is-buffer/dist/index.js +5 -0
- package/node_modules/@stdlib/assert-is-buffer/dist/index.js.map +7 -0
- package/node_modules/@stdlib/assert-is-buffer/docs/types/index.d.ts +50 -0
- package/node_modules/@stdlib/assert-is-buffer/lib/index.js +43 -0
- package/node_modules/@stdlib/assert-is-buffer/lib/main.js +70 -0
- package/node_modules/@stdlib/assert-is-buffer/package.json +73 -0
- package/node_modules/@stdlib/assert-is-function/LICENSE +177 -0
- package/node_modules/@stdlib/assert-is-function/NOTICE +1 -0
- package/node_modules/@stdlib/assert-is-function/README.md +192 -0
- package/node_modules/@stdlib/assert-is-function/SECURITY.md +5 -0
- package/node_modules/@stdlib/assert-is-function/dist/index.d.ts +3 -0
- package/node_modules/@stdlib/assert-is-function/dist/index.js +5 -0
- package/node_modules/@stdlib/assert-is-function/dist/index.js.map +7 -0
- package/node_modules/@stdlib/assert-is-function/docs/types/index.d.ts +40 -0
- package/node_modules/@stdlib/assert-is-function/lib/index.js +44 -0
- package/node_modules/@stdlib/assert-is-function/lib/main.js +50 -0
- package/node_modules/@stdlib/assert-is-function/package.json +74 -0
- package/node_modules/@stdlib/assert-is-object-like/LICENSE +177 -0
- package/node_modules/@stdlib/assert-is-object-like/NOTICE +1 -0
- package/node_modules/@stdlib/assert-is-object-like/README.md +264 -0
- package/node_modules/@stdlib/assert-is-object-like/SECURITY.md +5 -0
- package/node_modules/@stdlib/assert-is-object-like/dist/index.d.ts +3 -0
- package/node_modules/@stdlib/assert-is-object-like/dist/index.js +5 -0
- package/node_modules/@stdlib/assert-is-object-like/dist/index.js.map +7 -0
- package/node_modules/@stdlib/assert-is-object-like/docs/types/index.d.ts +48 -0
- package/node_modules/@stdlib/assert-is-object-like/lib/index.js +67 -0
- package/node_modules/@stdlib/assert-is-object-like/lib/main.js +49 -0
- package/node_modules/@stdlib/assert-is-object-like/package.json +79 -0
- package/node_modules/@stdlib/assert-is-string/LICENSE +177 -0
- package/node_modules/@stdlib/assert-is-string/NOTICE +1 -0
- package/node_modules/@stdlib/assert-is-string/README.md +224 -0
- package/node_modules/@stdlib/assert-is-string/SECURITY.md +5 -0
- package/node_modules/@stdlib/assert-is-string/dist/index.d.ts +3 -0
- package/node_modules/@stdlib/assert-is-string/dist/index.js +13 -0
- package/node_modules/@stdlib/assert-is-string/dist/index.js.map +7 -0
- package/node_modules/@stdlib/assert-is-string/docs/types/index.d.ts +101 -0
- package/node_modules/@stdlib/assert-is-string/lib/index.js +73 -0
- package/node_modules/@stdlib/assert-is-string/lib/main.js +50 -0
- package/node_modules/@stdlib/assert-is-string/lib/object.js +65 -0
- package/node_modules/@stdlib/assert-is-string/lib/primitive.js +42 -0
- package/node_modules/@stdlib/assert-is-string/lib/try2valueof.js +47 -0
- package/node_modules/@stdlib/assert-is-string/lib/valueof.js +27 -0
- package/node_modules/@stdlib/assert-is-string/package.json +80 -0
- package/node_modules/@stdlib/assert-tools-array-function/LICENSE +177 -0
- package/node_modules/@stdlib/assert-tools-array-function/NOTICE +1 -0
- package/node_modules/@stdlib/assert-tools-array-function/README.md +216 -0
- package/node_modules/@stdlib/assert-tools-array-function/SECURITY.md +5 -0
- package/node_modules/@stdlib/assert-tools-array-function/dist/index.d.ts +3 -0
- package/node_modules/@stdlib/assert-tools-array-function/dist/index.js +5 -0
- package/node_modules/@stdlib/assert-tools-array-function/dist/index.js.map +7 -0
- package/node_modules/@stdlib/assert-tools-array-function/docs/types/index.d.ts +61 -0
- package/node_modules/@stdlib/assert-tools-array-function/lib/index.js +49 -0
- package/node_modules/@stdlib/assert-tools-array-function/lib/main.js +85 -0
- package/node_modules/@stdlib/assert-tools-array-function/package.json +73 -0
- package/node_modules/@stdlib/boolean-ctor/LICENSE +177 -0
- package/node_modules/@stdlib/boolean-ctor/NOTICE +1 -0
- package/node_modules/@stdlib/boolean-ctor/README.md +264 -0
- package/node_modules/@stdlib/boolean-ctor/SECURITY.md +5 -0
- package/node_modules/@stdlib/boolean-ctor/dist/index.d.ts +3 -0
- package/node_modules/@stdlib/boolean-ctor/dist/index.js +5 -0
- package/node_modules/@stdlib/boolean-ctor/dist/index.js.map +7 -0
- package/node_modules/@stdlib/boolean-ctor/docs/types/index.d.ts +52 -0
- package/node_modules/@stdlib/boolean-ctor/lib/index.js +52 -0
- package/node_modules/@stdlib/boolean-ctor/lib/main.js +51 -0
- package/node_modules/@stdlib/boolean-ctor/package.json +61 -0
- package/node_modules/@stdlib/buffer-ctor/LICENSE +177 -0
- package/node_modules/@stdlib/buffer-ctor/NOTICE +1 -0
- package/node_modules/@stdlib/buffer-ctor/README.md +273 -0
- package/node_modules/@stdlib/buffer-ctor/SECURITY.md +5 -0
- package/node_modules/@stdlib/buffer-ctor/dist/index.d.ts +3 -0
- package/node_modules/@stdlib/buffer-ctor/dist/index.js +19 -0
- package/node_modules/@stdlib/buffer-ctor/dist/index.js.map +7 -0
- package/node_modules/@stdlib/buffer-ctor/docs/types/index.d.ts +37 -0
- package/node_modules/@stdlib/buffer-ctor/lib/index.js +52 -0
- package/node_modules/@stdlib/buffer-ctor/lib/main.js +28 -0
- package/node_modules/@stdlib/buffer-ctor/lib/polyfill.js +37 -0
- package/node_modules/@stdlib/buffer-ctor/package.json +66 -0
- package/node_modules/@stdlib/buffer-from-string/LICENSE +177 -0
- package/node_modules/@stdlib/buffer-from-string/NOTICE +1 -0
- package/node_modules/@stdlib/buffer-from-string/README.md +249 -0
- package/node_modules/@stdlib/buffer-from-string/SECURITY.md +5 -0
- package/node_modules/@stdlib/buffer-from-string/dist/index.d.ts +3 -0
- package/node_modules/@stdlib/buffer-from-string/dist/index.js +19 -0
- package/node_modules/@stdlib/buffer-from-string/dist/index.js.map +7 -0
- package/node_modules/@stdlib/buffer-from-string/docs/types/index.d.ts +42 -0
- package/node_modules/@stdlib/buffer-from-string/lib/has_from.js +34 -0
- package/node_modules/@stdlib/buffer-from-string/lib/index.js +52 -0
- package/node_modules/@stdlib/buffer-from-string/lib/main.js +60 -0
- package/node_modules/@stdlib/buffer-from-string/lib/polyfill.js +60 -0
- package/node_modules/@stdlib/buffer-from-string/package.json +74 -0
- package/node_modules/@stdlib/error-tools-fmtprodmsg/LICENSE +177 -0
- package/node_modules/@stdlib/error-tools-fmtprodmsg/NOTICE +1 -0
- package/node_modules/@stdlib/error-tools-fmtprodmsg/README.md +182 -0
- package/node_modules/@stdlib/error-tools-fmtprodmsg/SECURITY.md +5 -0
- package/node_modules/@stdlib/error-tools-fmtprodmsg/dist/index.d.ts +3 -0
- package/node_modules/@stdlib/error-tools-fmtprodmsg/dist/index.js +5 -0
- package/node_modules/@stdlib/error-tools-fmtprodmsg/dist/index.js.map +7 -0
- package/node_modules/@stdlib/error-tools-fmtprodmsg/docs/types/index.d.ts +39 -0
- package/node_modules/@stdlib/error-tools-fmtprodmsg/lib/index.js +40 -0
- package/node_modules/@stdlib/error-tools-fmtprodmsg/lib/main.js +48 -0
- package/node_modules/@stdlib/error-tools-fmtprodmsg/package.json +71 -0
- package/node_modules/@stdlib/regexp-function-name/LICENSE +177 -0
- package/node_modules/@stdlib/regexp-function-name/NOTICE +1 -0
- package/node_modules/@stdlib/regexp-function-name/README.md +215 -0
- package/node_modules/@stdlib/regexp-function-name/SECURITY.md +5 -0
- package/node_modules/@stdlib/regexp-function-name/dist/index.d.ts +3 -0
- package/node_modules/@stdlib/regexp-function-name/dist/index.js +8 -0
- package/node_modules/@stdlib/regexp-function-name/dist/index.js.map +7 -0
- package/node_modules/@stdlib/regexp-function-name/docs/types/index.d.ts +74 -0
- package/node_modules/@stdlib/regexp-function-name/lib/index.js +61 -0
- package/node_modules/@stdlib/regexp-function-name/lib/main.js +54 -0
- package/node_modules/@stdlib/regexp-function-name/lib/regexp.js +60 -0
- package/node_modules/@stdlib/regexp-function-name/package.json +68 -0
- package/node_modules/@stdlib/streams-node-stdin/LICENSE +177 -0
- package/node_modules/@stdlib/streams-node-stdin/NOTICE +1 -0
- package/node_modules/@stdlib/streams-node-stdin/README.md +227 -0
- package/node_modules/@stdlib/streams-node-stdin/SECURITY.md +5 -0
- package/node_modules/@stdlib/streams-node-stdin/dist/index.d.ts +3 -0
- package/node_modules/@stdlib/streams-node-stdin/dist/index.js +5 -0
- package/node_modules/@stdlib/streams-node-stdin/dist/index.js.map +7 -0
- package/node_modules/@stdlib/streams-node-stdin/docs/types/index.d.ts +31 -0
- package/node_modules/@stdlib/streams-node-stdin/lib/index.js +41 -0
- package/node_modules/@stdlib/streams-node-stdin/lib/main.js +28 -0
- package/node_modules/@stdlib/streams-node-stdin/package.json +65 -0
- package/node_modules/@stdlib/string-base-format-interpolate/LICENSE +177 -0
- package/node_modules/@stdlib/string-base-format-interpolate/NOTICE +1 -0
- package/node_modules/@stdlib/string-base-format-interpolate/README.md +219 -0
- package/node_modules/@stdlib/string-base-format-interpolate/SECURITY.md +5 -0
- package/node_modules/@stdlib/string-base-format-interpolate/dist/index.d.ts +3 -0
- package/node_modules/@stdlib/string-base-format-interpolate/dist/index.js +17 -0
- package/node_modules/@stdlib/string-base-format-interpolate/dist/index.js.map +7 -0
- package/node_modules/@stdlib/string-base-format-interpolate/docs/types/index.d.ts +71 -0
- package/node_modules/@stdlib/string-base-format-interpolate/lib/format_double.js +103 -0
- package/node_modules/@stdlib/string-base-format-interpolate/lib/format_integer.js +115 -0
- package/node_modules/@stdlib/string-base-format-interpolate/lib/index.js +41 -0
- package/node_modules/@stdlib/string-base-format-interpolate/lib/is_number.js +46 -0
- package/node_modules/@stdlib/string-base-format-interpolate/lib/is_string.js +42 -0
- package/node_modules/@stdlib/string-base-format-interpolate/lib/main.js +243 -0
- package/node_modules/@stdlib/string-base-format-interpolate/lib/space_pad.js +65 -0
- package/node_modules/@stdlib/string-base-format-interpolate/lib/zero_pad.js +84 -0
- package/node_modules/@stdlib/string-base-format-interpolate/package.json +72 -0
- package/node_modules/@stdlib/string-base-format-tokenize/LICENSE +177 -0
- package/node_modules/@stdlib/string-base-format-tokenize/NOTICE +1 -0
- package/node_modules/@stdlib/string-base-format-tokenize/README.md +203 -0
- package/node_modules/@stdlib/string-base-format-tokenize/SECURITY.md +5 -0
- package/node_modules/@stdlib/string-base-format-tokenize/dist/index.d.ts +3 -0
- package/node_modules/@stdlib/string-base-format-tokenize/dist/index.js +5 -0
- package/node_modules/@stdlib/string-base-format-tokenize/dist/index.js.map +7 -0
- package/node_modules/@stdlib/string-base-format-tokenize/docs/types/index.d.ts +68 -0
- package/node_modules/@stdlib/string-base-format-tokenize/lib/index.js +41 -0
- package/node_modules/@stdlib/string-base-format-tokenize/lib/main.js +95 -0
- package/node_modules/@stdlib/string-base-format-tokenize/package.json +70 -0
- package/node_modules/@stdlib/string-format/LICENSE +177 -0
- package/node_modules/@stdlib/string-format/NOTICE +1 -0
- package/node_modules/@stdlib/string-format/README.md +341 -0
- package/node_modules/@stdlib/string-format/SECURITY.md +5 -0
- package/node_modules/@stdlib/string-format/dist/index.d.ts +3 -0
- package/node_modules/@stdlib/string-format/dist/index.js +7 -0
- package/node_modules/@stdlib/string-format/dist/index.js.map +7 -0
- package/node_modules/@stdlib/string-format/docs/types/index.d.ts +42 -0
- package/node_modules/@stdlib/string-format/lib/index.js +43 -0
- package/node_modules/@stdlib/string-format/lib/is_string.js +42 -0
- package/node_modules/@stdlib/string-format/lib/main.js +64 -0
- package/node_modules/@stdlib/string-format/package.json +73 -0
- package/node_modules/@stdlib/symbol-ctor/LICENSE +177 -0
- package/node_modules/@stdlib/symbol-ctor/NOTICE +1 -0
- package/node_modules/@stdlib/symbol-ctor/README.md +234 -0
- package/node_modules/@stdlib/symbol-ctor/SECURITY.md +5 -0
- package/node_modules/@stdlib/symbol-ctor/dist/index.d.ts +3 -0
- package/node_modules/@stdlib/symbol-ctor/dist/index.js +5 -0
- package/node_modules/@stdlib/symbol-ctor/dist/index.js.map +7 -0
- package/node_modules/@stdlib/symbol-ctor/docs/types/index.d.ts +34 -0
- package/node_modules/@stdlib/symbol-ctor/lib/index.js +40 -0
- package/node_modules/@stdlib/symbol-ctor/lib/main.js +28 -0
- package/node_modules/@stdlib/symbol-ctor/package.json +63 -0
- package/node_modules/@stdlib/types/LICENSE +177 -0
- package/node_modules/@stdlib/types/NOTICE +1 -0
- package/node_modules/@stdlib/types/README.md +212 -0
- package/node_modules/@stdlib/types/SECURITY.md +5 -0
- package/node_modules/@stdlib/types/index.d.ts +3923 -0
- package/node_modules/@stdlib/types/lib/browser.js +28 -0
- package/node_modules/@stdlib/types/lib/index.js +39 -0
- package/node_modules/@stdlib/types/lib/main.js +40 -0
- package/node_modules/@stdlib/types/package.json +68 -0
- package/node_modules/@stdlib/types/test.ts +734 -0
- package/node_modules/@stdlib/utils-constructor-name/LICENSE +177 -0
- package/node_modules/@stdlib/utils-constructor-name/NOTICE +1 -0
- package/node_modules/@stdlib/utils-constructor-name/README.md +400 -0
- package/node_modules/@stdlib/utils-constructor-name/SECURITY.md +5 -0
- package/node_modules/@stdlib/utils-constructor-name/dist/index.d.ts +3 -0
- package/node_modules/@stdlib/utils-constructor-name/dist/index.js +5 -0
- package/node_modules/@stdlib/utils-constructor-name/dist/index.js.map +7 -0
- package/node_modules/@stdlib/utils-constructor-name/docs/types/index.d.ts +52 -0
- package/node_modules/@stdlib/utils-constructor-name/lib/index.js +46 -0
- package/node_modules/@stdlib/utils-constructor-name/lib/main.js +80 -0
- package/node_modules/@stdlib/utils-constructor-name/package.json +77 -0
- package/node_modules/@stdlib/utils-define-nonenumerable-read-only-property/LICENSE +177 -0
- package/node_modules/@stdlib/utils-define-nonenumerable-read-only-property/NOTICE +1 -0
- package/node_modules/@stdlib/utils-define-nonenumerable-read-only-property/README.md +216 -0
- package/node_modules/@stdlib/utils-define-nonenumerable-read-only-property/SECURITY.md +5 -0
- package/node_modules/@stdlib/utils-define-nonenumerable-read-only-property/dist/index.d.ts +3 -0
- package/node_modules/@stdlib/utils-define-nonenumerable-read-only-property/dist/index.js +31 -0
- package/node_modules/@stdlib/utils-define-nonenumerable-read-only-property/dist/index.js.map +7 -0
- package/node_modules/@stdlib/utils-define-nonenumerable-read-only-property/dist/main.js +58 -0
- package/node_modules/@stdlib/utils-define-nonenumerable-read-only-property/docs/types/index.d.ts +52 -0
- package/node_modules/@stdlib/utils-define-nonenumerable-read-only-property/lib/index.js +47 -0
- package/node_modules/@stdlib/utils-define-nonenumerable-read-only-property/lib/main.js +58 -0
- package/node_modules/@stdlib/utils-define-nonenumerable-read-only-property/package.json +93 -0
- package/node_modules/@stdlib/utils-define-property/LICENSE +177 -0
- package/node_modules/@stdlib/utils-define-property/NOTICE +1 -0
- package/node_modules/@stdlib/utils-define-property/README.md +228 -0
- package/node_modules/@stdlib/utils-define-property/SECURITY.md +5 -0
- package/node_modules/@stdlib/utils-define-property/dist/index.d.ts +3 -0
- package/node_modules/@stdlib/utils-define-property/dist/index.js +36 -0
- package/node_modules/@stdlib/utils-define-property/dist/index.js.map +7 -0
- package/node_modules/@stdlib/utils-define-property/docs/types/index.d.ts +52 -0
- package/node_modules/@stdlib/utils-define-property/lib/builtin.js +61 -0
- package/node_modules/@stdlib/utils-define-property/lib/define_property.js +28 -0
- package/node_modules/@stdlib/utils-define-property/lib/has_define_property_support.js +51 -0
- package/node_modules/@stdlib/utils-define-property/lib/index.js +58 -0
- package/node_modules/@stdlib/utils-define-property/lib/polyfill.js +122 -0
- package/node_modules/@stdlib/utils-define-property/package.json +75 -0
- package/node_modules/@stdlib/utils-global/LICENSE +177 -0
- package/node_modules/@stdlib/utils-global/NOTICE +1 -0
- package/node_modules/@stdlib/utils-global/README.md +208 -0
- package/node_modules/@stdlib/utils-global/SECURITY.md +5 -0
- package/node_modules/@stdlib/utils-global/dist/index.d.ts +3 -0
- package/node_modules/@stdlib/utils-global/dist/index.js +36 -0
- package/node_modules/@stdlib/utils-global/dist/index.js.map +7 -0
- package/node_modules/@stdlib/utils-global/docs/types/index.d.ts +40 -0
- package/node_modules/@stdlib/utils-global/lib/browser.js +79 -0
- package/node_modules/@stdlib/utils-global/lib/codegen.js +36 -0
- package/node_modules/@stdlib/utils-global/lib/global.js +28 -0
- package/node_modules/@stdlib/utils-global/lib/global_this.js +28 -0
- package/node_modules/@stdlib/utils-global/lib/index.js +40 -0
- package/node_modules/@stdlib/utils-global/lib/main.js +83 -0
- package/node_modules/@stdlib/utils-global/lib/self.js +28 -0
- package/node_modules/@stdlib/utils-global/lib/window.js +28 -0
- package/node_modules/@stdlib/utils-global/package.json +74 -0
- package/node_modules/@stdlib/utils-native-class/LICENSE +177 -0
- package/node_modules/@stdlib/utils-native-class/NOTICE +1 -0
- package/node_modules/@stdlib/utils-native-class/README.md +349 -0
- package/node_modules/@stdlib/utils-native-class/SECURITY.md +5 -0
- package/node_modules/@stdlib/utils-native-class/dist/index.d.ts +3 -0
- package/node_modules/@stdlib/utils-native-class/dist/index.js +11 -0
- package/node_modules/@stdlib/utils-native-class/dist/index.js.map +7 -0
- package/node_modules/@stdlib/utils-native-class/docs/types/index.d.ts +51 -0
- package/node_modules/@stdlib/utils-native-class/lib/index.js +61 -0
- package/node_modules/@stdlib/utils-native-class/lib/main.js +56 -0
- package/node_modules/@stdlib/utils-native-class/lib/polyfill.js +81 -0
- package/node_modules/@stdlib/utils-native-class/lib/tostring.js +28 -0
- package/node_modules/@stdlib/utils-native-class/lib/tostringtag.js +33 -0
- package/node_modules/@stdlib/utils-native-class/package.json +84 -0
- package/node_modules/@stdlib/utils-next-tick/LICENSE +177 -0
- package/node_modules/@stdlib/utils-next-tick/NOTICE +1 -0
- package/node_modules/@stdlib/utils-next-tick/README.md +183 -0
- package/node_modules/@stdlib/utils-next-tick/SECURITY.md +5 -0
- package/node_modules/@stdlib/utils-next-tick/dist/index.d.ts +3 -0
- package/node_modules/@stdlib/utils-next-tick/dist/index.js +5 -0
- package/node_modules/@stdlib/utils-next-tick/dist/index.js.map +7 -0
- package/node_modules/@stdlib/utils-next-tick/docs/types/index.d.ts +43 -0
- package/node_modules/@stdlib/utils-next-tick/lib/index.js +43 -0
- package/node_modules/@stdlib/utils-next-tick/lib/main.js +72 -0
- package/node_modules/@stdlib/utils-next-tick/package.json +77 -0
- package/node_modules/@stdlib/utils-type-of/LICENSE +177 -0
- package/node_modules/@stdlib/utils-type-of/NOTICE +1 -0
- package/node_modules/@stdlib/utils-type-of/README.md +366 -0
- package/node_modules/@stdlib/utils-type-of/SECURITY.md +5 -0
- package/node_modules/@stdlib/utils-type-of/dist/index.d.ts +3 -0
- package/node_modules/@stdlib/utils-type-of/dist/index.js +15 -0
- package/node_modules/@stdlib/utils-type-of/dist/index.js.map +7 -0
- package/node_modules/@stdlib/utils-type-of/docs/types/index.d.ts +50 -0
- package/node_modules/@stdlib/utils-type-of/lib/check.js +55 -0
- package/node_modules/@stdlib/utils-type-of/lib/fixtures/nodelist.js +34 -0
- package/node_modules/@stdlib/utils-type-of/lib/fixtures/re.js +26 -0
- package/node_modules/@stdlib/utils-type-of/lib/fixtures/typedarray.js +26 -0
- package/node_modules/@stdlib/utils-type-of/lib/index.js +50 -0
- package/node_modules/@stdlib/utils-type-of/lib/main.js +76 -0
- package/node_modules/@stdlib/utils-type-of/lib/polyfill.js +41 -0
- package/node_modules/@stdlib/utils-type-of/package.json +72 -0
- package/package.json +108 -3
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
|
|
3
|
+
@license Apache-2.0
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2022 The Stdlib Authors.
|
|
6
|
+
|
|
7
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License.
|
|
9
|
+
You may obtain a copy of the License at
|
|
10
|
+
|
|
11
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
See the License for the specific language governing permissions and
|
|
17
|
+
limitations under the License.
|
|
18
|
+
|
|
19
|
+
-->
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
<details>
|
|
23
|
+
<summary>
|
|
24
|
+
About stdlib...
|
|
25
|
+
</summary>
|
|
26
|
+
<p>We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.</p>
|
|
27
|
+
<p>The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.</p>
|
|
28
|
+
<p>When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.</p>
|
|
29
|
+
<p>To join us in bringing numerical computing to the web, get started by checking us out on <a href="https://github.com/stdlib-js/stdlib">GitHub</a>, and please consider <a href="https://opencollective.com/stdlib">financially supporting stdlib</a>. We greatly appreciate your continued support!</p>
|
|
30
|
+
</details>
|
|
31
|
+
|
|
32
|
+
# formatInterpolate
|
|
33
|
+
|
|
34
|
+
[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] -->
|
|
35
|
+
|
|
36
|
+
> Generate string from a token array by interpolating values.
|
|
37
|
+
|
|
38
|
+
<section class="intro">
|
|
39
|
+
|
|
40
|
+
</section>
|
|
41
|
+
|
|
42
|
+
<!-- /.intro -->
|
|
43
|
+
|
|
44
|
+
<section class="installation">
|
|
45
|
+
|
|
46
|
+
## Installation
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
npm install @stdlib/string-base-format-interpolate
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
</section>
|
|
53
|
+
|
|
54
|
+
<section class="usage">
|
|
55
|
+
|
|
56
|
+
## Usage
|
|
57
|
+
|
|
58
|
+
```javascript
|
|
59
|
+
var formatInterpolate = require( '@stdlib/string-base-format-interpolate' );
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
#### formatInterpolate( tokens, ...args )
|
|
63
|
+
|
|
64
|
+
Generates string from a token array by interpolating values.
|
|
65
|
+
|
|
66
|
+
```javascript
|
|
67
|
+
var formatTokenize = require( '@stdlib/string-base-format-tokenize' );
|
|
68
|
+
|
|
69
|
+
var str = 'Hello, %s! My name is %s.';
|
|
70
|
+
var tokens = formatTokenize( str );
|
|
71
|
+
var out = formatInterpolate( tokens, 'World', 'Bob' );
|
|
72
|
+
// returns 'Hello, World! My name is Bob.'
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
The array of `tokens` should contain string parts and format identifier objects.
|
|
76
|
+
|
|
77
|
+
```javascript
|
|
78
|
+
var tokens = [ 'beep ', { 'specifier': 's' } ];
|
|
79
|
+
var out = formatInterpolate( tokens, 'boop' );
|
|
80
|
+
// returns 'beep boop'
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Format identifier objects can have the following properties:
|
|
84
|
+
|
|
85
|
+
| property | description |
|
|
86
|
+
| --------- | --------------------------------------------------------------------------------------------------- |
|
|
87
|
+
| specifier | format specifier (one of 's', 'c', 'd', 'i', 'u', 'b', 'o', 'x', 'X', 'e', 'E', 'f', 'F', 'g', 'G') |
|
|
88
|
+
| flags | format flags (string with any of '0', ' ', '+', '-', '#') |
|
|
89
|
+
| width | minimum field width (integer or `'*'`) |
|
|
90
|
+
| precision | precision (integer or `'*'`) |
|
|
91
|
+
| mapping | positional mapping from format specifier to argument index |
|
|
92
|
+
|
|
93
|
+
</section>
|
|
94
|
+
|
|
95
|
+
<!-- /.usage -->
|
|
96
|
+
|
|
97
|
+
<section class="examples">
|
|
98
|
+
|
|
99
|
+
## Examples
|
|
100
|
+
|
|
101
|
+
<!-- eslint no-undef: "error" -->
|
|
102
|
+
|
|
103
|
+
```javascript
|
|
104
|
+
var formatTokenize = require( '@stdlib/string-base-format-tokenize' );
|
|
105
|
+
var PI = require( '@stdlib/constants-float64-pi' );
|
|
106
|
+
var formatInterpolate = require( '@stdlib/string-base-format-interpolate' );
|
|
107
|
+
|
|
108
|
+
var tokens = formatTokenize( 'Hello %s!' );
|
|
109
|
+
var out = formatInterpolate( tokens, 'World' );
|
|
110
|
+
// returns 'Hello World!'
|
|
111
|
+
|
|
112
|
+
tokens = formatTokenize( 'Pi: ~%.2f' );
|
|
113
|
+
out = formatInterpolate( tokens, PI );
|
|
114
|
+
// returns 'Pi: ~3.14'
|
|
115
|
+
|
|
116
|
+
tokens = formatTokenize( 'Index: %d, Value: %s' );
|
|
117
|
+
out = formatInterpolate( tokens, 0, 'foo' );
|
|
118
|
+
// returns 'Index: 0, Value: foo'
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
</section>
|
|
122
|
+
|
|
123
|
+
<!-- /.examples -->
|
|
124
|
+
|
|
125
|
+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
|
|
126
|
+
|
|
127
|
+
<section class="related">
|
|
128
|
+
|
|
129
|
+
* * *
|
|
130
|
+
|
|
131
|
+
## See Also
|
|
132
|
+
|
|
133
|
+
- <span class="package-name">[`@stdlib/string-base/format-tokenize`][@stdlib/string/base/format-tokenize]</span><span class="delimiter">: </span><span class="description">tokenize a string into an array of string parts and format identifier objects.</span>
|
|
134
|
+
|
|
135
|
+
</section>
|
|
136
|
+
|
|
137
|
+
<!-- /.related -->
|
|
138
|
+
|
|
139
|
+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
<section class="main-repo" >
|
|
143
|
+
|
|
144
|
+
* * *
|
|
145
|
+
|
|
146
|
+
## Notice
|
|
147
|
+
|
|
148
|
+
This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
|
|
149
|
+
|
|
150
|
+
For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib].
|
|
151
|
+
|
|
152
|
+
#### Community
|
|
153
|
+
|
|
154
|
+
[![Chat][chat-image]][chat-url]
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## License
|
|
159
|
+
|
|
160
|
+
See [LICENSE][stdlib-license].
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
## Copyright
|
|
164
|
+
|
|
165
|
+
Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors].
|
|
166
|
+
|
|
167
|
+
</section>
|
|
168
|
+
|
|
169
|
+
<!-- /.stdlib -->
|
|
170
|
+
|
|
171
|
+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
|
172
|
+
|
|
173
|
+
<section class="links">
|
|
174
|
+
|
|
175
|
+
[npm-image]: http://img.shields.io/npm/v/@stdlib/string-base-format-interpolate.svg
|
|
176
|
+
[npm-url]: https://npmjs.org/package/@stdlib/string-base-format-interpolate
|
|
177
|
+
|
|
178
|
+
[test-image]: https://github.com/stdlib-js/string-base-format-interpolate/actions/workflows/test.yml/badge.svg?branch=v0.2.4
|
|
179
|
+
[test-url]: https://github.com/stdlib-js/string-base-format-interpolate/actions/workflows/test.yml?query=branch:v0.2.4
|
|
180
|
+
|
|
181
|
+
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/string-base-format-interpolate/main.svg
|
|
182
|
+
[coverage-url]: https://codecov.io/github/stdlib-js/string-base-format-interpolate?branch=main
|
|
183
|
+
|
|
184
|
+
<!--
|
|
185
|
+
|
|
186
|
+
[dependencies-image]: https://img.shields.io/david/stdlib-js/string-base-format-interpolate.svg
|
|
187
|
+
[dependencies-url]: https://david-dm.org/stdlib-js/string-base-format-interpolate/main
|
|
188
|
+
|
|
189
|
+
-->
|
|
190
|
+
|
|
191
|
+
[chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
|
|
192
|
+
[chat-url]: https://stdlib.zulipchat.com
|
|
193
|
+
|
|
194
|
+
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
195
|
+
|
|
196
|
+
[stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
|
|
197
|
+
|
|
198
|
+
[umd]: https://github.com/umdjs/umd
|
|
199
|
+
[es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
|
|
200
|
+
|
|
201
|
+
[deno-url]: https://github.com/stdlib-js/string-base-format-interpolate/tree/deno
|
|
202
|
+
[deno-readme]: https://github.com/stdlib-js/string-base-format-interpolate/blob/deno/README.md
|
|
203
|
+
[umd-url]: https://github.com/stdlib-js/string-base-format-interpolate/tree/umd
|
|
204
|
+
[umd-readme]: https://github.com/stdlib-js/string-base-format-interpolate/blob/umd/README.md
|
|
205
|
+
[esm-url]: https://github.com/stdlib-js/string-base-format-interpolate/tree/esm
|
|
206
|
+
[esm-readme]: https://github.com/stdlib-js/string-base-format-interpolate/blob/esm/README.md
|
|
207
|
+
[branches-url]: https://github.com/stdlib-js/string-base-format-interpolate/blob/main/branches.md
|
|
208
|
+
|
|
209
|
+
[stdlib-license]: https://raw.githubusercontent.com/stdlib-js/string-base-format-interpolate/main/LICENSE
|
|
210
|
+
|
|
211
|
+
<!-- <related-links> -->
|
|
212
|
+
|
|
213
|
+
[@stdlib/string/base/format-tokenize]: https://www.npmjs.com/package/@stdlib/string-base-format-tokenize
|
|
214
|
+
|
|
215
|
+
<!-- </related-links> -->
|
|
216
|
+
|
|
217
|
+
</section>
|
|
218
|
+
|
|
219
|
+
<!-- /.links -->
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";var n=function(e,i){return function(){return i||e((i={exports:{}}).exports,i),i.exports}};var d=n(function(pr,h){
|
|
2
|
+
function C(e){return typeof e=="number"}h.exports=C
|
|
3
|
+
});var v=n(function(fr,E){
|
|
4
|
+
function D(e){return e[0]==="-"}function w(e){var i="",a;for(a=0;a<e;a++)i+="0";return i}function G(e,i,a){var r=!1,t=i-e.length;return t<0||(D(e)&&(r=!0,e=e.substr(1)),e=a?e+w(t):w(t)+e,r&&(e="-"+e)),e}E.exports=G
|
|
5
|
+
});var R=n(function(ur,x){
|
|
6
|
+
var V=d(),b=v(),Z=String.prototype.toLowerCase,m=String.prototype.toUpperCase;function X(e){var i,a,r;switch(e.specifier){case"b":i=2;break;case"o":i=8;break;case"x":case"X":i=16;break;default:i=10;break}if(a=e.arg,r=parseInt(a,10),!isFinite(r)){if(!V(a))throw new Error("invalid integer. Value: "+a);r=0}return r<0&&(e.specifier==="u"||i!==10)&&(r=4294967295+r+1),r<0?(a=(-r).toString(i),e.precision&&(a=b(a,e.precision,e.padRight)),a="-"+a):(a=r.toString(i),!r&&!e.precision?a="":e.precision&&(a=b(a,e.precision,e.padRight)),e.sign&&(a=e.sign+a)),i===16&&(e.alternate&&(a="0x"+a),a=e.specifier===m.call(e.specifier)?m.call(a):Z.call(a)),i===8&&e.alternate&&a.charAt(0)!=="0"&&(a="0"+a),a}x.exports=X
|
|
7
|
+
});var _=n(function(lr,I){
|
|
8
|
+
function A(e){return typeof e=="string"}I.exports=A
|
|
9
|
+
});var P=n(function(gr,y){
|
|
10
|
+
var N=Math.abs,z=String.prototype.toLowerCase,S=String.prototype.toUpperCase,c=String.prototype.replace,W=/e\+(\d)$/,L=/e-(\d)$/,B=/^(\d+)$/,M=/^(\d+)e/,U=/\.0$/,j=/\.0*e/,Y=/(\..*[^0])0*e/;function H(e,i){var a,r;switch(i.specifier){case"e":case"E":r=e.toExponential(i.precision);break;case"f":case"F":r=e.toFixed(i.precision);break;case"g":case"G":N(e)<1e-4?(a=i.precision,a>0&&(a-=1),r=e.toExponential(a)):r=e.toPrecision(i.precision),i.alternate||(r=c.call(r,Y,"$1e"),r=c.call(r,j,"e"),r=c.call(r,U,""));break;default:throw new Error("invalid double notation. Value: "+i.specifier)}return r=c.call(r,W,"e+0$1"),r=c.call(r,L,"e-0$1"),i.alternate&&(r=c.call(r,B,"$1."),r=c.call(r,M,"$1.e")),e>=0&&i.sign&&(r=i.sign+r),r=i.specifier===S.call(i.specifier)?S.call(r):z.call(r),r}y.exports=H
|
|
11
|
+
});var q=n(function(dr,T){
|
|
12
|
+
function O(e){var i="",a;for(a=0;a<e;a++)i+=" ";return i}function J(e,i,a){var r=i-e.length;return r<0||(e=a?e+O(r):O(r)+e),e}T.exports=J
|
|
13
|
+
});var $=n(function(vr,F){
|
|
14
|
+
var K=R(),Q=_(),k=d(),rr=P(),er=q(),ir=v(),ar=String.fromCharCode,sr=Array.isArray;function g(e){return e!==e}function tr(e){var i={};return i.specifier=e.specifier,i.precision=e.precision===void 0?1:e.precision,i.width=e.width,i.flags=e.flags||"",i.mapping=e.mapping,i}function nr(e){var i,a,r,t,o,p,s,u,f,l;if(!sr(e))throw new TypeError("invalid argument. First argument must be an array. Value: `"+e+"`.");for(p="",s=1,f=0;f<e.length;f++)if(r=e[f],Q(r))p+=r;else{if(i=r.precision!==void 0,r=tr(r),!r.specifier)throw new TypeError("invalid argument. Token is missing `specifier` property. Index: `"+f+"`. Value: `"+r+"`.");for(r.mapping&&(s=r.mapping),a=r.flags,l=0;l<a.length;l++)switch(t=a.charAt(l),t){case" ":r.sign=" ";break;case"+":r.sign="+";break;case"-":r.padRight=!0,r.padZeros=!1;break;case"0":r.padZeros=a.indexOf("-")<0;break;case"#":r.alternate=!0;break;default:throw new Error("invalid flag: "+t)}if(r.width==="*"){if(r.width=parseInt(arguments[s],10),s+=1,g(r.width))throw new TypeError("the argument for * width at position "+s+" is not a number. Value: `"+r.width+"`.");r.width<0&&(r.padRight=!0,r.width=-r.width)}if(i&&r.precision==="*"){if(r.precision=parseInt(arguments[s],10),s+=1,g(r.precision))throw new TypeError("the argument for * precision at position "+s+" is not a number. Value: `"+r.precision+"`.");r.precision<0&&(r.precision=1,i=!1)}switch(r.arg=arguments[s],r.specifier){case"b":case"o":case"x":case"X":case"d":case"i":case"u":i&&(r.padZeros=!1),r.arg=K(r);break;case"s":r.maxWidth=i?r.precision:-1,r.arg=String(r.arg);break;case"c":if(!g(r.arg)){if(o=parseInt(r.arg,10),o<0||o>127)throw new Error("invalid character code. Value: "+r.arg);r.arg=g(o)?String(r.arg):ar(o)}break;case"e":case"E":case"f":case"F":case"g":case"G":if(i||(r.precision=6),u=parseFloat(r.arg),!isFinite(u)){if(!k(r.arg))throw new Error("invalid floating-point number. Value: "+p);u=r.arg,r.padZeros=!1}r.arg=rr(u,r);break;default:throw new Error("invalid specifier: "+r.specifier)}r.maxWidth>=0&&r.arg.length>r.maxWidth&&(r.arg=r.arg.substring(0,r.maxWidth)),r.padZeros?r.arg=ir(r.arg,r.width||r.precision,r.padRight):r.width&&(r.arg=er(r.arg,r.width,r.padRight)),p+=r.arg||"",s+=1}return p}F.exports=nr
|
|
15
|
+
});var cr=$();module.exports=cr;
|
|
16
|
+
/** @license Apache-2.0 */
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../lib/is_number.js", "../lib/zero_pad.js", "../lib/format_integer.js", "../lib/is_string.js", "../lib/format_double.js", "../lib/space_pad.js", "../lib/main.js", "../lib/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Tests if a value is a number primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a number primitive\n*\n* @example\n* var bool = isNumber( 3.14 );\n* // returns true\n*\n* @example\n* var bool = isNumber( NaN );\n* // returns true\n*\n* @example\n* var bool = isNumber( new Number( 3.14 ) );\n* // returns false\n*/\nfunction isNumber( value ) {\n\treturn ( typeof value === 'number' ); // NOTE: we inline the `isNumber.isPrimitive` function from `@stdlib/assert/is-number` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nmodule.exports = isNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// FUNCTIONS //\n\n/**\n* Tests if a string starts with a minus sign (`-`).\n*\n* @private\n* @param {string} str - input string\n* @returns {boolean} boolean indicating if a string starts with a minus sign (`-`)\n*/\nfunction startsWithMinus( str ) {\n\treturn str[ 0 ] === '-';\n}\n\n/**\n* Returns a string of `n` zeros.\n*\n* @private\n* @param {number} n - number of zeros\n* @returns {string} string of zeros\n*/\nfunction zeros( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += '0';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with zeros to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction zeroPad( str, width, right ) {\n\tvar negative = false;\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tif ( startsWithMinus( str ) ) {\n\t\tnegative = true;\n\t\tstr = str.substr( 1 );\n\t}\n\tstr = ( right ) ?\n\t\tstr + zeros( pad ) :\n\t\tzeros( pad ) + str;\n\tif ( negative ) {\n\t\tstr = '-' + str;\n\t}\n\treturn str;\n}\n\n\n// EXPORTS //\n\nmodule.exports = zeroPad;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isNumber = require( './is_number.js' );\nvar zeroPad = require( './zero_pad.js' );\n\n// NOTE: for the following, we explicitly avoid using stdlib packages in this particular package in order to avoid circular dependencies.\nvar lowercase = String.prototype.toLowerCase;\nvar uppercase = String.prototype.toUpperCase;\n\n\n// MAIN //\n\n/**\n* Formats a token object argument as an integer.\n*\n* @private\n* @param {Object} token - token object\n* @throws {Error} must provide a valid integer\n* @returns {string} formatted token argument\n*/\nfunction formatInteger( token ) {\n\tvar base;\n\tvar out;\n\tvar i;\n\n\tswitch ( token.specifier ) {\n\tcase 'b':\n\t\t// Case: %b (binary)\n\t\tbase = 2;\n\t\tbreak;\n\tcase 'o':\n\t\t// Case: %o (octal)\n\t\tbase = 8;\n\t\tbreak;\n\tcase 'x':\n\tcase 'X':\n\t\t// Case: %x, %X (hexadecimal)\n\t\tbase = 16;\n\t\tbreak;\n\tcase 'd':\n\tcase 'i':\n\tcase 'u':\n\tdefault:\n\t\t// Case: %d, %i, %u (decimal)\n\t\tbase = 10;\n\t\tbreak;\n\t}\n\tout = token.arg;\n\ti = parseInt( out, 10 );\n\tif ( !isFinite( i ) ) { // NOTE: We use the global `isFinite` function here instead of `@stdlib/math/base/assert/is-finite` in order to avoid circular dependencies.\n\t\tif ( !isNumber( out ) ) {\n\t\t\tthrow new Error( 'invalid integer. Value: ' + out );\n\t\t}\n\t\ti = 0;\n\t}\n\tif ( i < 0 && ( token.specifier === 'u' || base !== 10 ) ) {\n\t\ti = 0xffffffff + i + 1;\n\t}\n\tif ( i < 0 ) {\n\t\tout = ( -i ).toString( base );\n\t\tif ( token.precision ) {\n\t\t\tout = zeroPad( out, token.precision, token.padRight );\n\t\t}\n\t\tout = '-' + out;\n\t} else {\n\t\tout = i.toString( base );\n\t\tif ( !i && !token.precision ) {\n\t\t\tout = '';\n\t\t} else if ( token.precision ) {\n\t\t\tout = zeroPad( out, token.precision, token.padRight );\n\t\t}\n\t\tif ( token.sign ) {\n\t\t\tout = token.sign + out;\n\t\t}\n\t}\n\tif ( base === 16 ) {\n\t\tif ( token.alternate ) {\n\t\t\tout = '0x' + out;\n\t\t}\n\t\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\t\tuppercase.call( out ) :\n\t\t\tlowercase.call( out );\n\t}\n\tif ( base === 8 ) {\n\t\tif ( token.alternate && out.charAt( 0 ) !== '0' ) {\n\t\t\tout = '0' + out;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = formatInteger;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nmodule.exports = isString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\n// NOTE: for the following, we explicitly avoid using stdlib packages in this particular package in order to avoid circular dependencies.\nvar abs = Math.abs; // eslint-disable-line stdlib/no-builtin-math\nvar lowercase = String.prototype.toLowerCase;\nvar uppercase = String.prototype.toUpperCase;\nvar replace = String.prototype.replace;\n\n\n// VARIABLES //\n\nvar RE_EXP_POS_DIGITS = /e\\+(\\d)$/;\nvar RE_EXP_NEG_DIGITS = /e-(\\d)$/;\nvar RE_ONLY_DIGITS = /^(\\d+)$/;\nvar RE_DIGITS_BEFORE_EXP = /^(\\d+)e/;\nvar RE_TRAILING_PERIOD_ZERO = /\\.0$/;\nvar RE_PERIOD_ZERO_EXP = /\\.0*e/;\nvar RE_ZERO_BEFORE_EXP = /(\\..*[^0])0*e/;\n\n\n// MAIN //\n\n/**\n* Formats a token object argument as a floating-point number.\n*\n* @private\n* @param {number} f - parsed number\n* @param {Object} token - token object\n* @throws {Error} must provide a valid floating-point number\n* @returns {string} formatted token argument\n*/\nfunction formatDouble( f, token ) {\n\tvar digits;\n\tvar out;\n\n\tswitch ( token.specifier ) {\n\tcase 'e':\n\tcase 'E':\n\t\tout = f.toExponential( token.precision );\n\t\tbreak;\n\tcase 'f':\n\tcase 'F':\n\t\tout = f.toFixed( token.precision );\n\t\tbreak;\n\tcase 'g':\n\tcase 'G':\n\t\tif ( abs( f ) < 0.0001 ) {\n\t\t\tdigits = token.precision;\n\t\t\tif ( digits > 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e' );\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = formatDouble;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nmodule.exports = spacePad;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar formatInteger = require( './format_integer.js' );\nvar isString = require( './is_string.js' );\nvar isNumber = require( './is_number.js' );\nvar formatDouble = require( './format_double.js' );\nvar spacePad = require( './space_pad.js' );\nvar zeroPad = require( './zero_pad.js' );\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating whether a value is `NaN`.\n*\n* @private\n* @param {*} value - input value\n* @returns {boolean} boolean indicating whether a value is `NaN`\n*\n* @example\n* var bool = isnan( NaN );\n* // returns true\n*\n* @example\n* var bool = isnan( 4 );\n* // returns false\n*/\nfunction isnan( value ) { // explicitly define a function here instead of `@stdlib/math/base/assert/is-nan` in order to avoid circular dependencies\n\treturn ( value !== value );\n}\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar f;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\ttoken.arg = String( token.arg );\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ? String( token.arg ) : fromCharCode( num ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\tf = parseFloat( token.arg );\n\t\t\t\tif ( !isFinite( f ) ) { // NOTE: We use the global `isFinite` function here instead of `@stdlib/math/base/assert/is-finite` in order to avoid circular dependencies.\n\t\t\t\t\tif ( !isNumber( token.arg ) ) {\n\t\t\t\t\t\tthrow new Error( 'invalid floating-point number. Value: ' + out );\n\t\t\t\t\t}\n\t\t\t\t\t// Case: NaN, Infinity, or -Infinity\n\t\t\t\t\tf = token.arg;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( f, token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = formatInterpolate;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Generate string from a token array by interpolating values.\n*\n* @module @stdlib/string-base-format-interpolate\n*\n* @example\n* var formatInterpolate = require( '@stdlib/string-base-format-interpolate' );\n*\n* var tokens = ['Hello ', { 'specifier': 's' }, '!' ];\n* var out = formatInterpolate( tokens, 'World' );\n* // returns 'Hello World!'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
|
|
5
|
+
"mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsCA,SAASC,EAAUC,EAAQ,CAC1B,OAAS,OAAOA,GAAU,QAC3B,CAKAF,EAAO,QAAUC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AAO,yCAA2CC,CAAI,EAGjEQ,EAAIT,EAAM,IACVA,EAAM,SAAW,EAClB,CACAA,EAAM,IAAMR,GAAciB,EAAGT,CAAM,EACnC,MACD,QACC,MAAM,IAAI,MAAO,sBAAwBA,EAAM,SAAU,CAC1D,CAEKA,EAAM,UAAY,GAAKA,EAAM,IAAI,OAASA,EAAM,WACpDA,EAAM,IAAMA,EAAM,IAAI,UAAW,EAAGA,EAAM,QAAS,GAE/CA,EAAM,SACVA,EAAM,IAAMN,GAASM,EAAM,IAAKA,EAAM,OAASA,EAAM,UAAWA,EAAM,QAAS,EACpEA,EAAM,QACjBA,EAAM,IAAMP,GAAUO,EAAM,IAAKA,EAAM,MAAOA,EAAM,QAAS,GAE9DC,GAAOD,EAAM,KAAO,GACpBQ,GAAO,CACR,CAED,OAAOP,CACR,CAKAb,EAAO,QAAUc,KC/MjB,IAAIU,GAAO,IAKX,OAAO,QAAUA",
|
|
6
|
+
"names": ["require_is_number", "__commonJSMin", "exports", "module", "isNumber", "value", "require_zero_pad", "__commonJSMin", "exports", "module", "startsWithMinus", "str", "zeros", "n", "out", "i", "zeroPad", "width", "right", "negative", "pad", "require_format_integer", "__commonJSMin", "exports", "module", "isNumber", "zeroPad", "lowercase", "uppercase", "formatInteger", "token", "base", "out", "i", "require_is_string", "__commonJSMin", "exports", "module", "isString", "value", "require_format_double", "__commonJSMin", "exports", "module", "abs", "lowercase", "uppercase", "replace", "RE_EXP_POS_DIGITS", "RE_EXP_NEG_DIGITS", "RE_ONLY_DIGITS", "RE_DIGITS_BEFORE_EXP", "RE_TRAILING_PERIOD_ZERO", "RE_PERIOD_ZERO_EXP", "RE_ZERO_BEFORE_EXP", "formatDouble", "f", "token", "digits", "out", "require_space_pad", "__commonJSMin", "exports", "module", "spaces", "n", "out", "i", "spacePad", "str", "width", "right", "pad", "require_main", "__commonJSMin", "exports", "module", "formatInteger", "isString", "isNumber", "formatDouble", "spacePad", "zeroPad", "fromCharCode", "isArray", "isnan", "value", "initialize", "token", "out", "formatInterpolate", "tokens", "hasPeriod", "flags", "flag", "num", "pos", "f", "i", "j", "main"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2022 The Stdlib Authors.
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
// TypeScript Version: 4.1
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Format identifier object.
|
|
23
|
+
*/
|
|
24
|
+
interface FormatIdentifier {
|
|
25
|
+
/**
|
|
26
|
+
* Format specifier (one of 's', 'c', 'd', 'i', 'u', 'b', 'o', 'x', 'X', 'e', 'E', 'f', 'F', 'g', 'G').
|
|
27
|
+
*/
|
|
28
|
+
specifier: string;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Flags.
|
|
32
|
+
*/
|
|
33
|
+
flags?: string;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Minimum field width (integer or `'*'`).
|
|
37
|
+
*/
|
|
38
|
+
width?: string;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Precision (integer or `'*'`).
|
|
42
|
+
*/
|
|
43
|
+
precision?: string;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Positional mapping from format specifier to argument index.
|
|
47
|
+
*/
|
|
48
|
+
mapping?: number;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
type StringOrToken = string | FormatIdentifier;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Generates string from a token array by interpolating values.
|
|
55
|
+
*
|
|
56
|
+
* @param tokens - string parts and format identifier objects
|
|
57
|
+
* @param args - variable values
|
|
58
|
+
* @throws invalid flags
|
|
59
|
+
* @returns formatted string
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* var tokens = [ 'beep ', { 'specifier': 's' } ];
|
|
63
|
+
* var out = formatInterpolate( tokens, 'boop' );
|
|
64
|
+
* // returns 'beep boop'
|
|
65
|
+
*/
|
|
66
|
+
declare function formatInterpolate( tokens: Array<StringOrToken>, ...args: Array<any> ): string;
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
// EXPORTS //
|
|
70
|
+
|
|
71
|
+
export = formatInterpolate;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2022 The Stdlib Authors.
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
'use strict';
|
|
20
|
+
|
|
21
|
+
// MODULES //
|
|
22
|
+
|
|
23
|
+
// NOTE: for the following, we explicitly avoid using stdlib packages in this particular package in order to avoid circular dependencies.
|
|
24
|
+
var abs = Math.abs; // eslint-disable-line stdlib/no-builtin-math
|
|
25
|
+
var lowercase = String.prototype.toLowerCase;
|
|
26
|
+
var uppercase = String.prototype.toUpperCase;
|
|
27
|
+
var replace = String.prototype.replace;
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
// VARIABLES //
|
|
31
|
+
|
|
32
|
+
var RE_EXP_POS_DIGITS = /e\+(\d)$/;
|
|
33
|
+
var RE_EXP_NEG_DIGITS = /e-(\d)$/;
|
|
34
|
+
var RE_ONLY_DIGITS = /^(\d+)$/;
|
|
35
|
+
var RE_DIGITS_BEFORE_EXP = /^(\d+)e/;
|
|
36
|
+
var RE_TRAILING_PERIOD_ZERO = /\.0$/;
|
|
37
|
+
var RE_PERIOD_ZERO_EXP = /\.0*e/;
|
|
38
|
+
var RE_ZERO_BEFORE_EXP = /(\..*[^0])0*e/;
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
// MAIN //
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Formats a token object argument as a floating-point number.
|
|
45
|
+
*
|
|
46
|
+
* @private
|
|
47
|
+
* @param {number} f - parsed number
|
|
48
|
+
* @param {Object} token - token object
|
|
49
|
+
* @throws {Error} must provide a valid floating-point number
|
|
50
|
+
* @returns {string} formatted token argument
|
|
51
|
+
*/
|
|
52
|
+
function formatDouble( f, token ) {
|
|
53
|
+
var digits;
|
|
54
|
+
var out;
|
|
55
|
+
|
|
56
|
+
switch ( token.specifier ) {
|
|
57
|
+
case 'e':
|
|
58
|
+
case 'E':
|
|
59
|
+
out = f.toExponential( token.precision );
|
|
60
|
+
break;
|
|
61
|
+
case 'f':
|
|
62
|
+
case 'F':
|
|
63
|
+
out = f.toFixed( token.precision );
|
|
64
|
+
break;
|
|
65
|
+
case 'g':
|
|
66
|
+
case 'G':
|
|
67
|
+
if ( abs( f ) < 0.0001 ) {
|
|
68
|
+
digits = token.precision;
|
|
69
|
+
if ( digits > 0 ) {
|
|
70
|
+
digits -= 1;
|
|
71
|
+
}
|
|
72
|
+
out = f.toExponential( digits );
|
|
73
|
+
} else {
|
|
74
|
+
out = f.toPrecision( token.precision );
|
|
75
|
+
}
|
|
76
|
+
if ( !token.alternate ) {
|
|
77
|
+
out = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );
|
|
78
|
+
out = replace.call( out, RE_PERIOD_ZERO_EXP, 'e' );
|
|
79
|
+
out = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );
|
|
80
|
+
}
|
|
81
|
+
break;
|
|
82
|
+
default:
|
|
83
|
+
throw new Error( 'invalid double notation. Value: ' + token.specifier );
|
|
84
|
+
}
|
|
85
|
+
out = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );
|
|
86
|
+
out = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );
|
|
87
|
+
if ( token.alternate ) {
|
|
88
|
+
out = replace.call( out, RE_ONLY_DIGITS, '$1.' );
|
|
89
|
+
out = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );
|
|
90
|
+
}
|
|
91
|
+
if ( f >= 0 && token.sign ) {
|
|
92
|
+
out = token.sign + out;
|
|
93
|
+
}
|
|
94
|
+
out = ( token.specifier === uppercase.call( token.specifier ) ) ?
|
|
95
|
+
uppercase.call( out ) :
|
|
96
|
+
lowercase.call( out );
|
|
97
|
+
return out;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
// EXPORTS //
|
|
102
|
+
|
|
103
|
+
module.exports = formatDouble;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2022 The Stdlib Authors.
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
'use strict';
|
|
20
|
+
|
|
21
|
+
// MODULES //
|
|
22
|
+
|
|
23
|
+
var isNumber = require( './is_number.js' );
|
|
24
|
+
var zeroPad = require( './zero_pad.js' );
|
|
25
|
+
|
|
26
|
+
// NOTE: for the following, we explicitly avoid using stdlib packages in this particular package in order to avoid circular dependencies.
|
|
27
|
+
var lowercase = String.prototype.toLowerCase;
|
|
28
|
+
var uppercase = String.prototype.toUpperCase;
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
// MAIN //
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Formats a token object argument as an integer.
|
|
35
|
+
*
|
|
36
|
+
* @private
|
|
37
|
+
* @param {Object} token - token object
|
|
38
|
+
* @throws {Error} must provide a valid integer
|
|
39
|
+
* @returns {string} formatted token argument
|
|
40
|
+
*/
|
|
41
|
+
function formatInteger( token ) {
|
|
42
|
+
var base;
|
|
43
|
+
var out;
|
|
44
|
+
var i;
|
|
45
|
+
|
|
46
|
+
switch ( token.specifier ) {
|
|
47
|
+
case 'b':
|
|
48
|
+
// Case: %b (binary)
|
|
49
|
+
base = 2;
|
|
50
|
+
break;
|
|
51
|
+
case 'o':
|
|
52
|
+
// Case: %o (octal)
|
|
53
|
+
base = 8;
|
|
54
|
+
break;
|
|
55
|
+
case 'x':
|
|
56
|
+
case 'X':
|
|
57
|
+
// Case: %x, %X (hexadecimal)
|
|
58
|
+
base = 16;
|
|
59
|
+
break;
|
|
60
|
+
case 'd':
|
|
61
|
+
case 'i':
|
|
62
|
+
case 'u':
|
|
63
|
+
default:
|
|
64
|
+
// Case: %d, %i, %u (decimal)
|
|
65
|
+
base = 10;
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
out = token.arg;
|
|
69
|
+
i = parseInt( out, 10 );
|
|
70
|
+
if ( !isFinite( i ) ) { // NOTE: We use the global `isFinite` function here instead of `@stdlib/math/base/assert/is-finite` in order to avoid circular dependencies.
|
|
71
|
+
if ( !isNumber( out ) ) {
|
|
72
|
+
throw new Error( 'invalid integer. Value: ' + out );
|
|
73
|
+
}
|
|
74
|
+
i = 0;
|
|
75
|
+
}
|
|
76
|
+
if ( i < 0 && ( token.specifier === 'u' || base !== 10 ) ) {
|
|
77
|
+
i = 0xffffffff + i + 1;
|
|
78
|
+
}
|
|
79
|
+
if ( i < 0 ) {
|
|
80
|
+
out = ( -i ).toString( base );
|
|
81
|
+
if ( token.precision ) {
|
|
82
|
+
out = zeroPad( out, token.precision, token.padRight );
|
|
83
|
+
}
|
|
84
|
+
out = '-' + out;
|
|
85
|
+
} else {
|
|
86
|
+
out = i.toString( base );
|
|
87
|
+
if ( !i && !token.precision ) {
|
|
88
|
+
out = '';
|
|
89
|
+
} else if ( token.precision ) {
|
|
90
|
+
out = zeroPad( out, token.precision, token.padRight );
|
|
91
|
+
}
|
|
92
|
+
if ( token.sign ) {
|
|
93
|
+
out = token.sign + out;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if ( base === 16 ) {
|
|
97
|
+
if ( token.alternate ) {
|
|
98
|
+
out = '0x' + out;
|
|
99
|
+
}
|
|
100
|
+
out = ( token.specifier === uppercase.call( token.specifier ) ) ?
|
|
101
|
+
uppercase.call( out ) :
|
|
102
|
+
lowercase.call( out );
|
|
103
|
+
}
|
|
104
|
+
if ( base === 8 ) {
|
|
105
|
+
if ( token.alternate && out.charAt( 0 ) !== '0' ) {
|
|
106
|
+
out = '0' + out;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return out;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
// EXPORTS //
|
|
114
|
+
|
|
115
|
+
module.exports = formatInteger;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2022 The Stdlib Authors.
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
'use strict';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Generate string from a token array by interpolating values.
|
|
23
|
+
*
|
|
24
|
+
* @module @stdlib/string-base-format-interpolate
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* var formatInterpolate = require( '@stdlib/string-base-format-interpolate' );
|
|
28
|
+
*
|
|
29
|
+
* var tokens = ['Hello ', { 'specifier': 's' }, '!' ];
|
|
30
|
+
* var out = formatInterpolate( tokens, 'World' );
|
|
31
|
+
* // returns 'Hello World!'
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
// MODULES //
|
|
35
|
+
|
|
36
|
+
var main = require( './main.js' );
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
// EXPORTS //
|
|
40
|
+
|
|
41
|
+
module.exports = main;
|