Socket
Socket
Sign inDemoInstall

@cocreate/uuid

Package Overview
Dependencies
Maintainers
1
Versions
201
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cocreate/uuid - npm Package Compare versions

Comparing version 1.4.11 to 1.4.12

8

CHANGELOG.md

@@ -0,1 +1,9 @@

## [1.4.12](https://github.com/CoCreate-app/CoCreate-uuid/compare/v1.4.11...v1.4.12) (2023-06-04)
### Bug Fixes
* formating ([4d131af](https://github.com/CoCreate-app/CoCreate-uuid/commit/4d131af6ec386d8a1ae0e6be2fbfa2fbb7e583e5))
* **semantic-release:** worklow error solved by running node version 14 ([ab280e9](https://github.com/CoCreate-app/CoCreate-uuid/commit/ab280e94b2c052012941ae5c82ac9f9ce76fac00))
## [1.4.11](https://github.com/CoCreate-app/CoCreate-uuid/compare/v1.4.10...v1.4.11) (2023-05-21)

@@ -2,0 +10,0 @@

0

CoCreate.config.js

@@ -0,0 +0,0 @@ module.exports = {

@@ -0,0 +0,0 @@ # Contributing to CoCreate-uuid

4

package.json
{
"name": "@cocreate/uuid",
"version": "1.4.11",
"version": "1.4.12",
"description": "A simple uuid component in vanilla javascript. Easily configured using HTML5 attributes and/or JavaScript API.",

@@ -62,4 +62,4 @@ "keywords": [

"dependencies": {
"@cocreate/docs": "^1.7.12"
"@cocreate/docs": "^1.7.13"
}
}

@@ -0,0 +0,0 @@ # CoCreate-uuid

@@ -0,0 +0,0 @@ module.exports = {

@@ -8,4 +8,4 @@ // export function randomId() {

if (typeof define === 'function' && define.amd) {
define([], function() {
return factory(window)
define([], function () {
return factory(window)
});

@@ -16,68 +16,68 @@ } else if (typeof module === 'object' && module.exports) {

root.returnExports = factory(window);
}
}
}(typeof self !== 'undefined' ? self : this, function (wnd) {
const CoCreateUUID = {
attribute: 'uuid',
init: function(container) {
if (!wnd.document) return;
const __container = container || wnd.document
if (!__container.querySelectorAll) {
return;
}
let elements = __container.querySelectorAll(`[${this.attribute}]`);
const self = this;
elements.forEach(el => {
const len = parseInt(el.getAttribute(self.attribute)) || 36;
const uuid = self.generate(len)
if (el.tagName === "INPUT" || el.tagName === "TEXTAREA") {
el.value = uuid;
} else {
el.innerHTML = uuid;
}
})
},
generate: function(length = 36) {
let d = new Date().getTime();
let d2 = (wnd.performance && wnd.performance.now && (wnd.performance.now()*1000)) || 0;
let pattern = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
if (length <= pattern.length) {
pattern = pattern.substring(0, length);
} else {
let add_len = length - pattern.length;
let sub_pattern = "-xxxyyxxx";
let group_n = Math.floor(add_len / sub_pattern.length);
for (let i = 0; i < group_n; i++) {
pattern += sub_pattern;
}
group_n = add_len - group_n * sub_pattern.length;
pattern += sub_pattern.substring(0, group_n);
}
let uuid = pattern.replace(/[xy]/g, function(c) {
var r = Math.random() * 16;
if (d > 0){
var r = (d + r)%16 | 0;
d = Math.floor(d/16);
} else {
var r = (d2 + r)%16 | 0;
d2 = Math.floor(d2/16);
}
return (c=='x' ? r : (r&0x7|0x8)).toString(16);
});
return uuid;
},
}
CoCreateUUID.init();
return CoCreateUUID;
const CoCreateUUID = {
attribute: 'uuid',
init: function (container) {
if (!wnd.document) return;
const __container = container || wnd.document
if (!__container.querySelectorAll) {
return;
}
let elements = __container.querySelectorAll(`[${this.attribute}]`);
const self = this;
elements.forEach(el => {
const len = parseInt(el.getAttribute(self.attribute)) || 36;
const uuid = self.generate(len)
if (el.tagName === "INPUT" || el.tagName === "TEXTAREA") {
el.value = uuid;
} else {
el.innerHTML = uuid;
}
})
},
generate: function (length = 36) {
let d = new Date().getTime();
let d2 = (wnd.performance && wnd.performance.now && (wnd.performance.now() * 1000)) || 0;
let pattern = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
if (length <= pattern.length) {
pattern = pattern.substring(0, length);
} else {
let add_len = length - pattern.length;
let sub_pattern = "-xxxyyxxx";
let group_n = Math.floor(add_len / sub_pattern.length);
for (let i = 0; i < group_n; i++) {
pattern += sub_pattern;
}
group_n = add_len - group_n * sub_pattern.length;
pattern += sub_pattern.substring(0, group_n);
}
let uuid = pattern.replace(/[xy]/g, function (c) {
var r = Math.random() * 16;
if (d > 0) {
var r = (d + r) % 16 | 0;
d = Math.floor(d / 16);
} else {
var r = (d2 + r) % 16 | 0;
d2 = Math.floor(d2 / 16);
}
return (c == 'x' ? r : (r & 0x7 | 0x8)).toString(16);
});
return uuid;
},
}
CoCreateUUID.init();
return CoCreateUUID;
}));

@@ -0,0 +0,0 @@ const path = require("path")

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc