Skip to content
Myr

Add expo-random support to nanoid/async

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Andrey Sitnik · committed by Andrey Sitnik · parent ea3eecb · Browse files · 8 files+70 added−22 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

8 files+70 added−22 removed

  • tests:+20 added−1 removed
  • other:+50 added−21 removed

8 files+70 added−22 removed

added:async/random/index.browser.js+4 added
added:async/random/index.d.ts+12 added
added:async/random/index.js+19 added
added:async/random/index.native.js+5 added
modified:async/index.browser.js+3 added-1 removed
modified:async/index.js+2 added-19 removed
modified:test/async.test.js+20 added-1 removed
21 unmodified lines
22}2324for (let type of ['node', 'browser']) {25 describe(`${type}`, () => {26 let { nanoid, customAlphabet } = type === 'node' ? node : browser26 let { nanoid, customAlphabet, random } = type === 'node' ? node : browser2728 describe('nanoid', () => {29 function mock (callback) {30 crypto.randomFill = callback
75 unmodified lines
106 })107 }108 })109110 describe('random', () => {111 it('generates small random buffers', async () => {112 expect(await random(10)).toHaveLength(10)113 })114115 it('generates random buffers', async () => {116 let numbers = {}117 let bytes = await random(10000)118 expect(bytes).toHaveLength(10000)119 for (let byte of bytes) {120 if (!numbers[byte]) numbers[byte] = 0121 numbers[byte] += 1122 expect(typeof byte).toEqual('number')123 expect(byte).toBeLessThanOrEqual(255)124 expect(byte).toBeGreaterThanOrEqual(0)125 }126 })127 })128129 describe('customAlphabet', () => {130 it('has options', async () => {131 let nanoidA = customAlphabet('a', 5)132 let id = await nanoidA()
33 unmodified lines
modified:package.json+5 added-1 removed
23 unmodified lines
24 "browser": {25 "./index.js": "./index.browser.js",26 "./async/index.js": "./async/index.browser.js"27 },28 "react-native": {29 "./async/random/index.js": "./async/random/index.native.js",30 "./async/index.js": "./async/index.js"31 },32 "bin": "./bin/nanoid.cjs",33 "sideEffects": false,34 "devDependencies": {35 "@logux/eslint-config": "^38.0.0",
86 unmodified lines
122 "yoda": "off"123 },124 "overrides": [125 {122 "files": "*.rn.js",126 "files": "*.native.js",127 "rules": {128 "node/no-missing-require": "off",129 "global-require": "off"130 }
71 unmodified lines