mirror of
https://github.com/Qortal/qortal-ui.git
synced 2025-11-03 06:07:51 +00:00
Remove use strict make api full esm compatible
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
export const randomBase58Generator = (digits) => {
|
||||
digits = digits || 0
|
||||
let base58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'.split('')
|
||||
let result = ''
|
||||
let char
|
||||
while (result.length < digits) {
|
||||
char = base58[Math.random() * 57 >> 0]
|
||||
if (result.indexOf(char) === -1) result += char
|
||||
}
|
||||
return result
|
||||
digits = digits || 0
|
||||
let base58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'.split('')
|
||||
let result = ''
|
||||
let char
|
||||
while (result.length < digits) {
|
||||
char = base58[Math.random() * 57 >> 0]
|
||||
if (result.indexOf(char) === -1) result += char
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -1,31 +1,31 @@
|
||||
import {store} from '../../api.js'
|
||||
import { store } from '../../api'
|
||||
|
||||
let subscriptions = []
|
||||
|
||||
// Have to wait with init because something import stateAwait before the store gets initialized
|
||||
let initialized = false
|
||||
const init = () => {
|
||||
initialized = true
|
||||
store.subscribe(() => {
|
||||
const state = store.getState()
|
||||
initialized = true
|
||||
store.subscribe(() => {
|
||||
const state = store.getState()
|
||||
|
||||
subscriptions = subscriptions.filter(fn => fn(state))
|
||||
})
|
||||
subscriptions = subscriptions.filter(fn => fn(state))
|
||||
})
|
||||
}
|
||||
|
||||
export const stateAwait = fn => {
|
||||
return new Promise((resolve, reject) => {
|
||||
// Check immediately...then if not true store it
|
||||
if (!initialized) {
|
||||
init()
|
||||
}
|
||||
if (fn(store.getState())) resolve()
|
||||
subscriptions.push(state => {
|
||||
if (fn(state)) {
|
||||
resolve()
|
||||
return true
|
||||
}
|
||||
return false
|
||||
})
|
||||
})
|
||||
return new Promise((resolve, reject) => {
|
||||
// Check immediately...then if not true store it
|
||||
if (!initialized) {
|
||||
init()
|
||||
}
|
||||
if (fn(store.getState())) resolve()
|
||||
subscriptions.push(state => {
|
||||
if (fn(state)) {
|
||||
resolve()
|
||||
return true
|
||||
}
|
||||
return false
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user