UNPKG

1.92 kBSource Map (JSON)View Raw
1{"version":3,"file":"Random.js","sourceRoot":"","sources":["../src/Random.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,OAAO,UAAU,MAAM,cAAc,CAAC;AAEtC,SAAS,eAAe,CAAC,KAAU;IACjC,IACE,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,CAAC,KAAK,CAAC;QACZ,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;QACrB,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,IAAI,EACxB;QACA,MAAM,IAAI,SAAS,CACjB,oCAAoC,KAAK,+CAA+C,CACzF,CAAC;KACH;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,SAAiB;IACzD,eAAe,CAAC,SAAS,CAAC,CAAC;IAC3B,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAC7C,IAAI,UAAU,CAAC,mBAAmB,EAAE;QAClC,OAAO,MAAM,UAAU,CAAC,mBAAmB,CAAC,cAAc,CAAC,CAAC;KAC7D;SAAM,IAAI,UAAU,CAAC,0BAA0B,EAAE;QAChD,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,0BAA0B,CAAC,cAAc,CAAC,CAAC;QAC3E,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC;KAC5B;SAAM;QACL,MAAM,IAAI,mBAAmB,CAAC,aAAa,EAAE,qBAAqB,CAAC,CAAC;KACrE;AACH,CAAC","sourcesContent":["import { UnavailabilityError } from '@unimodules/core';\nimport { toByteArray } from 'base64-js';\n\nimport ExpoRandom from './ExpoRandom';\n\nfunction assertByteCount(value: any): void {\n if (\n typeof value !== 'number' ||\n isNaN(value) ||\n Math.floor(value) < 0 ||\n Math.floor(value) > 1024\n ) {\n throw new TypeError(\n `expo-random: getRandomBytesAsync(${value}) expected a valid number from range 0...1024`\n );\n }\n}\n\nexport async function getRandomBytesAsync(byteCount: number): Promise<Uint8Array> {\n assertByteCount(byteCount);\n const validByteCount = Math.floor(byteCount);\n if (ExpoRandom.getRandomBytesAsync) {\n return await ExpoRandom.getRandomBytesAsync(validByteCount);\n } else if (ExpoRandom.getRandomBase64StringAsync) {\n const base64 = await ExpoRandom.getRandomBase64StringAsync(validByteCount);\n return toByteArray(base64);\n } else {\n throw new UnavailabilityError('expo-random', 'getRandomBytesAsync');\n }\n}\n"]}
\No newline at end of file