UNPKG

719 BPlain TextView Raw
1// Copyright IBM Corp. and LoopBack contributors 2018,2020. All Rights Reserved.
2// Node module: @loopback/context
3// This file is licensed under the MIT License.
4// License text available at https://opensource.org/licenses/MIT
5
6import hyperid from 'hyperid';
7
8/**
9 * Generate a (globally) unique identifier in a very fast way.
10 * Please note the ids ARE NOT formatted as UUID and have variable length.
11 * The format of generated values may change in the future.
12 *
13 * @internal
14 */
15export const generateUniqueId = hyperid({
16 fixedLength: false,
17 urlSafe: true,
18});
19
20/**
21 * A regular expression for testing values generated by generateUniqueId.
22 * @internal
23 */
24export const UNIQUE_ID_PATTERN = /[A-Za-z0-9-_]+-\d+/;