How to use the uuid/v5 function in uuid

To help you get started, we’ve selected a few uuid examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github AJInteractive / InterviewJS / packages / composer / src / partials / panes / interviewee / ImagePane.js View on Github external
const fileToKey = (data, storyId) => {
  const { name, type } = data;
  // console.log(name, type);

  let namespace = storyId;
  if (namespace.indexOf("_")) namespace = namespace.split("_").pop();
  if (namespace.length < 36) namespace = shortUuid().toUUID(namespace);

  const uuid = uuidv5(`${type},${name}`, namespace);
  return `${shortUuid().fromUUID(uuid)}-${name}`;
};
github AJInteractive / InterviewJS / packages / composer / src / partials / forms / MetaForm.js View on Github external
const fileToKey = (data, storyId) => {
  const { name, type } = data;
  // console.log(name, type);

  let namespace = storyId;
  if (namespace.indexOf("_")) namespace = namespace.split("_").pop();
  if (namespace.length < 36) namespace = shortUuid().toUUID(namespace);

  const uuid = uuidv5(`${type},${name}`, namespace);
  return `${shortUuid().fromUUID(uuid)}-${name}`;
};
github adishegde / media_hub / src / core / daemon / fileIndex / metaData.js View on Github external
updateDownload(path, delta = 1) {
        let id = uuid(path, UUID_NAMESPACE);

        return this.db
            .get(id)
            .then(data => {
                data.downloads += delta;
                return this.db.put(id, data);
            })
            .then(retVal => {
                // We also need to update parent's download value.
                // NOTE: If this is might cause perfomance problems.
                let parentPath = Path.dirname(path);
                this.db
                    .get(uuid(parentPath, UUID_NAMESPACE))
                    .then(() => {
                        this.update(parentPath);
                    })
github adishegde / media_hub / src / core / daemon / fileIndex / metaData.js View on Github external
async update(path) {
        try {
            let stat = await fstat(path);

            let name = Path.basename(path);
            let downloads = 0;
            let description = "";
            let tags = [];
            let type = "file";
            let id = uuid(path, UUID_NAMESPACE);
            let size = stat.size;

            try {
                // Extract old values if they exist
                ({ downloads, tags, description } = await this.db.get(id));
            } catch (err) {
                // If error occured for a reason other than key not being
                // present then rethrow error
                if (!err.notFound) throw err;
            }

            // Set downloads value to max of children if directory and also
            // Calculate size of directory
            if (stat.isDirectory()) {
                type = "dir";
                size = 0;
github AJInteractive / InterviewJS / packages / composer / src / partials / modals / PublishStoryModal.js View on Github external
const computeId = (userId, storyId) => {
  let namespace = userId;
  if (namespace.indexOf(":") > 0) namespace = namespace.split(":").pop();

  let id = storyId;
  if (id.indexOf("_")) id = id.split("_").pop();
  if (id.length < 36) id = shortUuid().toUUID(id);

  const uuid = uuidv5(id, namespace);
  return shortUuid().fromUUID(uuid);
};
github angeloashmore / gatsby-source-prismic / src / browser / helpers.js View on Github external
const createNodeId = id =>
  uuidv5(id, uuidv5('gatsby-source-prismic', seedConstant))
const createContentDigest = obj => md5(JSON.stringify(obj))
github adishegde / media_hub / src / core / daemon / fileIndex / metaData.js View on Github external
getDataFromPath(path) {
        return this.db.get(uuid(path, UUID_NAMESPACE));
    }