Sort out Gun.text.random()
This commit is contained in:
parent
c055c2fc03
commit
958c25cfba
1 changed files with 12 additions and 2 deletions
|
|
@ -6,11 +6,21 @@
|
||||||
// @ts-check
|
// @ts-check
|
||||||
/// <reference path="Smith.ts" />
|
/// <reference path="Smith.ts" />
|
||||||
/// <reference path="GunT.ts" />
|
/// <reference path="GunT.ts" />
|
||||||
|
const RealGun = require('gun')
|
||||||
const uuid = require('uuid/v1')
|
const uuid = require('uuid/v1')
|
||||||
const { fork } = require('child_process')
|
const { fork } = require('child_process')
|
||||||
|
|
||||||
const logger = require('../../config/log')
|
const logger = require('../../config/log')
|
||||||
|
|
||||||
|
const gunUUID = () => {
|
||||||
|
const RG = /** @type {any} */ (RealGun)
|
||||||
|
if (typeof RG.text === 'object' && typeof RG.text.random === 'function') {
|
||||||
|
return RG.text.random()
|
||||||
|
}
|
||||||
|
// This probably won't happen
|
||||||
|
throw new ReferenceError()
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maps a path to `on()` listeners
|
* Maps a path to `on()` listeners
|
||||||
* @type {Record<string, Set<GunT.Listener>|undefined>}
|
* @type {Record<string, Set<GunT.Listener>|undefined>}
|
||||||
|
|
@ -349,8 +359,8 @@ function createReplica(path, afterMap = false) {
|
||||||
if (afterMap) {
|
if (afterMap) {
|
||||||
throw new Error('Cannot call set() after map() on a GunSmith node')
|
throw new Error('Cannot call set() after map() on a GunSmith node')
|
||||||
}
|
}
|
||||||
// @ts-expect-error
|
|
||||||
const id = Gun.text.random()
|
const id = gunUUID()
|
||||||
this.put(
|
this.put(
|
||||||
{
|
{
|
||||||
[id]: data
|
[id]: data
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue