nanoid#customAlphabet JavaScript Examples

The following examples show how to use nanoid#customAlphabet. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.js    From maji with Apache License 2.0 6 votes vote down vote up
/**
 * @description: 获取组件basedata数据,初始化使用
 * @param {type}componentName 组件名
 * @return: 配置数据或组件
 */
export function getComponentData(componentName) {
  const id = `${componentName}${customAlphabet('1234567890', 10)()}`
  // 从schema初始化对数据
  const fromSchema = schemaData({ type: componentName })
  // 兼容未补全schema的组件
  if (Object.keys(fromSchema).length > 1) {   
    return {
      baseData: fromSchema,
      id
    }
  }
  // 返回基础信息
  return {
    baseData: getComponentFile(componentName, 'data').baseData,
    id
  }
}
Example #2
Source File: generateId.js    From dnd-builder with MIT License 5 votes vote down vote up
generateId = (length = 6) => {
  const id = customAlphabet('1234567890jotfrm', length);
  return id().toString();
}
Example #3
Source File: index.js    From airboardgame with MIT License 5 votes vote down vote up
uid = customAlphabet(alpha, 10)
Example #4
Source File: index.js    From airboardgame with MIT License 5 votes vote down vote up
smallUid = customAlphabet(alpha, 5)
Example #5
Source File: updateAvatar.js    From clubhouse-api with MIT License 5 votes vote down vote up
random = customAlphabet('1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ', 16)
Example #6
Source File: serverUtil.js    From asymptoteWebApplication with GNU Lesser General Public License v3.0 5 votes vote down vote up
nanoid = customAlphabet(digits + lAlphabets + uAlphabets, 4)