Commit 35a59b38 authored by Eduardo Sanz García's avatar Eduardo Sanz García Committed by Eduardo

Correct some oddities

* import only the `generateHexString` function
* declare the `typdef` on one common JSDoc comment after the imports
* remove unnecessary helper function
parent 521127dd
import * as random from '../random';
import { generateHexString } from '../random';
describe('sidebar.util.random', () => {
describe('#generateHexString', () => {
[2, 4, 8, 16].forEach(len => {
it(`returns a ${len} digit hex string`, () => {
const re = new RegExp(`^[0-9a-fA-F]{${len}}$`);
const str = random.generateHexString(len);
const str = generateHexString(len);
assert.isTrue(re.test(str));
});
});
......
/** @typedef {import('../../types/api').Annotation} Annotation */
/** @typedef {import('../../types/annotator').AnnotationData} AnnotationData */
import { generateHexString } from '../../shared/random';
import * as metadata from '../helpers/annotation-metadata';
import {
......@@ -9,6 +6,11 @@ import {
sharedPermissions,
} from '../helpers/permissions';
/**
* @typedef {import('../../types/api').Annotation} Annotation
* @typedef {import('../../types/annotator').AnnotationData} AnnotationData
*/
/**
* A service for creating, updating and persisting annotations both in the
* local store and on the backend via the API.
......
import { generateHexString } from '../../shared/random';
/** Generate a random ID to associate RPC requests and responses. */
function generateId() {
return generateHexString(10);
}
/**
* Return a Promise that rejects with an error after `delay` ms.
*/
......@@ -33,7 +28,7 @@ export function call(
params = [],
timeout = 2000,
window_ = window,
id = generateId()
id = generateHexString(10)
) {
// Send RPC request.
const request = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment