1 line
5.4 KiB
JavaScript
1 line
5.4 KiB
JavaScript
(window.webpackJsonp=window.webpackJsonp||[]).push([[191],{386:function(t,e,n){"use strict";n.r(e);var a=n(37),v=Object(a.a)({},function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[n("h1",{attrs:{id:"functions"}},[n("a",{staticClass:"header-anchor",attrs:{href:"#functions","aria-hidden":"true"}},[t._v("#")]),t._v(" Functions")]),t._v(" "),n("p",[n("a",{attrs:{id:"bntou8a"}})]),t._v(" "),n("h2",{attrs:{id:"bntou8a"}},[n("a",{staticClass:"header-anchor",attrs:{href:"#bntou8a","aria-hidden":"true"}},[t._v("#")]),t._v(" bnToU8a")]),t._v(" "),n("p",[t._v("▸ "),n("strong",[t._v("bnToU8a")]),t._v("(value: "),n("em",[n("code",[t._v("BN")]),t._v(" | "),n("code",[t._v("number")]),t._v(" | "),n("code",[t._v("null")])]),t._v(", options?: "),n("em",[n("code",[t._v("Options")])]),t._v("): "),n("code",[t._v("Uint8Array")])]),t._v(" "),n("p",[t._v("▸ "),n("strong",[t._v("bnToU8a")]),t._v("(value: "),n("em",[n("code",[t._v("BN")]),t._v(" | "),n("code",[t._v("number")]),t._v(" | "),n("code",[t._v("null")])]),t._v(", bitLength?: "),n("em",[n("code",[t._v("undefined")]),t._v(" | "),n("code",[t._v("number")])]),t._v(", isLe?: "),n("em",[n("code",[t._v("undefined")]),t._v(" | "),n("code",[t._v("false")]),t._v(" | "),n("code",[t._v("true")])]),t._v("): "),n("code",[t._v("Uint8Array")])]),t._v(" "),n("p",[n("em",[t._v("Defined in "),n("a",{attrs:{href:"https://github.com/polkadot-js/common/blob/db4b221/packages/util/src/bn/toU8a.ts#L29",target:"_blank",rel:"noopener noreferrer"}},[t._v("bn/toU8a.ts:29"),n("OutboundLink")],1)])]),t._v(" "),n("p",[n("em",[n("strong",[t._v("name")])]),t._v(": bnToU8a")]),t._v(" "),n("p",[n("em",[n("strong",[t._v("summary")])]),t._v(": Creates a Uint8Array object from a BN.")]),t._v(" "),n("p",[n("em",[n("strong",[t._v("description")])]),t._v(": "),n("code",[t._v("null")]),t._v("/"),n("code",[t._v("undefined")]),t._v("/"),n("code",[t._v("NaN")]),t._v(" inputs returns an empty "),n("code",[t._v("Uint8Array")]),t._v(" result. "),n("code",[t._v("BN")]),t._v(" input values return the actual bytes value converted to a "),n("code",[t._v("Uint8Array")]),t._v(". Optionally convert using little-endian format if "),n("code",[t._v("isLE")]),t._v(" is set.")]),t._v(" "),n("p",[n("em",[n("strong",[t._v("example")])]),t._v(":")]),t._v(" "),n("div",{staticClass:"language-javascript line-numbers-mode"},[n("pre",{pre:!0,attrs:{class:"language-javascript"}},[n("code",[n("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("import")]),t._v(" "),n("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v(" bnToU8a "),n("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v(" "),n("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("from")]),t._v(" "),n("span",{pre:!0,attrs:{class:"token string"}},[t._v("'@polkadot/util'")]),n("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n\n"),n("span",{pre:!0,attrs:{class:"token function"}},[t._v("bnToU8a")]),n("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),n("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("new")]),t._v(" "),n("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("BN")]),n("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),n("span",{pre:!0,attrs:{class:"token number"}},[t._v("0x1234")]),n("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),n("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),n("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v(" "),n("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// => [0x12, 0x34]")]),t._v("\n")])]),t._v(" "),n("div",{staticClass:"line-numbers-wrapper"},[n("span",{staticClass:"line-number"},[t._v("1")]),n("br"),n("span",{staticClass:"line-number"},[t._v("2")]),n("br"),n("span",{staticClass:"line-number"},[t._v("3")]),n("br")])]),n("p",[n("strong",[t._v("Parameters:")])]),t._v(" "),n("table",[n("thead",[n("tr",[n("th",[t._v("Name")]),t._v(" "),n("th",[t._v("Type")])])]),t._v(" "),n("tbody",[n("tr",[n("td",[t._v("value")]),t._v(" "),n("td",[n("code",[t._v("BN")]),t._v(" | "),n("code",[t._v("number")]),t._v(" | "),n("code",[t._v("null")])])]),t._v(" "),n("tr",[n("td",[n("code",[t._v("Optional")]),t._v(" options")]),t._v(" "),n("td",[n("code",[t._v("Options")])])])])]),t._v(" "),n("p",[n("strong",[t._v("Returns:")]),t._v(" "),n("code",[t._v("Uint8Array")])]),t._v(" "),n("p",[n("em",[t._v("Defined in "),n("a",{attrs:{href:"https://github.com/polkadot-js/common/blob/db4b221/packages/util/src/bn/toU8a.ts#L30",target:"_blank",rel:"noopener noreferrer"}},[t._v("bn/toU8a.ts:30"),n("OutboundLink")],1)])]),t._v(" "),n("p",[n("strong",[t._v("Parameters:")])]),t._v(" "),n("table",[n("thead",[n("tr",[n("th",[t._v("Name")]),t._v(" "),n("th",[t._v("Type")])])]),t._v(" "),n("tbody",[n("tr",[n("td",[t._v("value")]),t._v(" "),n("td",[n("code",[t._v("BN")]),t._v(" | "),n("code",[t._v("number")]),t._v(" | "),n("code",[t._v("null")])])]),t._v(" "),n("tr",[n("td",[n("code",[t._v("Optional")]),t._v(" bitLength")]),t._v(" "),n("td",[n("code",[t._v("undefined")]),t._v(" | "),n("code",[t._v("number")])])]),t._v(" "),n("tr",[n("td",[n("code",[t._v("Optional")]),t._v(" isLe")]),t._v(" "),n("td",[n("code",[t._v("undefined")]),t._v(" | "),n("code",[t._v("false")]),t._v(" | "),n("code",[t._v("true")])])])])]),t._v(" "),n("p",[n("strong",[t._v("Returns:")]),t._v(" "),n("code",[t._v("Uint8Array")])]),t._v(" "),n("hr")])},[],!1,null,null,null);e.default=v.exports}}]); |