Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix generateRandomString #223

Merged
merged 2 commits into from
Feb 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 17 additions & 20 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ name: Node.js CI

on:
push:
branches: [ "master" ]
branches: ['master']
pull_request:
branches: [ "master" ]
branches: ['master']

jobs:
build:

runs-on: ubuntu-latest

strategy:
Expand All @@ -20,25 +19,23 @@ jobs:
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- run: yarn
- run: yarn run build


- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- run: yarn
- run: yarn run build

prettier:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Prettify code
uses: creyD/prettier_action@v4.2
with:
dry: True
prettier_options: --check **/*.{ts,tsx,js,md,html,json} #todo add svg
- uses: actions/checkout@v3

- name: Prettify code
uses: creyD/prettier_action@v4.3
with:
dry: True
prettier_options: --check **/*.{ts,tsx,js,md,html,json} #todo add svg
3 changes: 2 additions & 1 deletion libs/utils/src/string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ export const padLeadingZero = (nr: number) => (nr < 10 ? '0' + nr : nr);
export const generateRandomString = (length: number) => {
const alphabet = '0123456789';
const generatedString = new Array(length).fill(0).reduce((result) => {
return result + alphabet.substring(Math.random() * alphabet.length, 1);
const index = Math.random() * alphabet.length;
return result + alphabet.substring(index, index + 1);
}, '') as string;

return generatedString;
Expand Down